UNPKG

one

Version:

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

161 lines (160 loc) 3.86 kB
import { jsx as _jsx } from "react/jsx-runtime"; 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 * as React from "react"; var noop = function () {}; var SSR_LINKING_CTX = { options: void 0 }; var SSR_BUILDER_CTX = { onDispatchAction: noop, onOptionsChange: noop, // must execute callback immediately — useNavigationBuilder calls this during render scheduleUpdate: function (cb) { return cb(); }, flushUpdates: noop, stackRef: { current: void 0 } }; var SSR_SINGLE_NAV_CTX = { register: noop, unregister: noop }; var SSR_NAV_REF = { dispatch: noop, navigate: noop, reset: noop, goBack: noop, isFocused: function () { return false; }, canGoBack: function () { return false; }, getParent: function () { return void 0; }, getState: function () { return void 0; }, getRootState: function () { return void 0; }, getCurrentRoute: function () { return void 0; }, getCurrentOptions: function () { return void 0; }, isReady: function () { return false; }, addListener: function () { return 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 }; var getPartialState = function (state) { if (!state) return void 0; var { key, routeNames, ...partial } = state; return { ...partial, stale: true, routes: state.routes.map(function (route) { return route.state ? { ...route, state: getPartialState(route.state) } : route; }) }; }; var stateCtxCache = /* @__PURE__ */new WeakMap(); function getStateContext(initialState) { if (!initialState) { return { state: void 0, getKey: function () { return void 0; }, setKey: noop, getState: function () { return void 0; }, setState: noop, getIsInitial: function () { return true; } }; } var cached = stateCtxCache.get(initialState); if (cached) return cached; var partial = getPartialState(initialState); var ctx = { state: partial, getKey: function () { return void 0; }, setKey: noop, getState: function () { return partial; }, setState: noop, getIsInitial: function () { return true; } }; stateCtxCache.set(initialState, ctx); return ctx; } function SSRNavigationContainer(param) { var { initialState, theme, linking, children } = param; var 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.native.js.map