UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

149 lines 4.51 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var SSRNavigationContainer_exports = {}; __export(SSRNavigationContainer_exports, { SSRNavigationContainer: () => SSRNavigationContainer }); module.exports = __toCommonJS(SSRNavigationContainer_exports); var import_NavigationBuilderContext = require("@react-navigation/core/lib/module/NavigationBuilderContext"); var import_NavigationStateContext = require("@react-navigation/core/lib/module/NavigationStateContext"); var import_EnsureSingleNavigator = require("@react-navigation/core/lib/module/EnsureSingleNavigator"); var import_core = require("@react-navigation/core"); var import_native = require("@react-navigation/native"); var import_jsx_runtime = require("react/jsx-runtime"); const noop = () => {}; const SSR_LINKING_CTX = { options: void 0 }; const SSR_BUILDER_CTX = { onDispatchAction: noop, onOptionsChange: noop, // must execute callback immediately — useNavigationBuilder calls this during render scheduleUpdate: cb => cb(), flushUpdates: noop, stackRef: { current: void 0 } }; const SSR_SINGLE_NAV_CTX = { register: noop, unregister: noop }; const SSR_NAV_REF = { dispatch: noop, navigate: noop, reset: noop, goBack: noop, isFocused: () => false, canGoBack: () => false, getParent: () => void 0, getState: () => void 0, getRootState: () => void 0, getCurrentRoute: () => void 0, getCurrentOptions: () => void 0, isReady: () => false, addListener: () => noop, removeListener: noop, resetRoot: noop, setOptions: noop, // CommonActions methods setParams: noop, popTo: noop, pop: noop, popToTop: noop, push: noop, replace: noop, jumpTo: noop, preload: noop }; const getPartialState = state => { if (!state) return void 0; const { key, routeNames, ...partial } = state; return { ...partial, stale: true, routes: state.routes.map(route => route.state ? { ...route, state: getPartialState(route.state) } : route) }; }; const stateCtxCache = /* @__PURE__ */new WeakMap(); function getStateContext(initialState) { if (!initialState) { return { state: void 0, getKey: () => void 0, setKey: noop, getState: () => void 0, setState: noop, getIsInitial: () => true }; } const cached = stateCtxCache.get(initialState); if (cached) return cached; const partial = getPartialState(initialState); const ctx = { state: partial, getKey: () => void 0, setKey: noop, getState: () => partial, setState: noop, getIsInitial: () => true }; stateCtxCache.set(initialState, ctx); return ctx; } function SSRNavigationContainer({ initialState, theme, linking, children }) { const linkingCtx = linking ? { options: linking } : SSR_LINKING_CTX; return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_native.LinkingContext.Provider, { value: linkingCtx, children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.NavigationContainerRefContext.Provider, { value: SSR_NAV_REF, children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_NavigationBuilderContext.NavigationBuilderContext.Provider, { value: SSR_BUILDER_CTX, children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_NavigationStateContext.NavigationStateContext.Provider, { value: getStateContext(initialState), children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_EnsureSingleNavigator.SingleNavigatorContext.Provider, { value: SSR_SINGLE_NAV_CTX, children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.ThemeProvider, { value: theme, children }) }) }) }) }) }); }