UNPKG

one

Version:

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

125 lines (124 loc) 3.33 kB
import { NavigationBuilderContext } from "@react-navigation/core/lib/module/NavigationBuilderContext"; import { NavigationStateContext } from "@react-navigation/core/lib/module/NavigationStateContext"; import { SingleNavigatorContext } from "@react-navigation/core/lib/module/EnsureSingleNavigator"; import { NavigationContainerRefContext, ThemeProvider } from "@react-navigation/core"; import { LinkingContext } from "@react-navigation/native"; import { jsx } from "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__ */jsx(LinkingContext.Provider, { value: linkingCtx, children: /* @__PURE__ */jsx(NavigationContainerRefContext.Provider, { value: SSR_NAV_REF, children: /* @__PURE__ */jsx(NavigationBuilderContext.Provider, { value: SSR_BUILDER_CTX, children: /* @__PURE__ */jsx(NavigationStateContext.Provider, { value: getStateContext(initialState), children: /* @__PURE__ */jsx(SingleNavigatorContext.Provider, { value: SSR_SINGLE_NAV_CTX, children: /* @__PURE__ */jsx(ThemeProvider, { value: theme, children }) }) }) }) }) }); } export { SSRNavigationContainer }; //# sourceMappingURL=SSRNavigationContainer.mjs.map