one 2.7.6 → 2.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Root.cjs +1 -1
- package/dist/cjs/Root.native.cjs +3 -3
- package/dist/cjs/Root.native.js +3 -3
- package/dist/cjs/Root.native.js.map +1 -1
- package/dist/esm/Root.mjs +1 -1
- package/dist/esm/Root.mjs.map +1 -1
- package/dist/esm/Root.native.js +3 -3
- package/dist/esm/Root.native.js.map +1 -1
- package/package.json +15 -15
- package/src/Root.serverContext.test.tsx +52 -0
- package/src/Root.tsx +5 -3
- package/types/Root.d.ts.map +1 -1
package/dist/cjs/Root.cjs
CHANGED
|
@@ -52,8 +52,8 @@ function getCachedSSRLocation(path) {
|
|
|
52
52
|
return url;
|
|
53
53
|
}
|
|
54
54
|
const ServerAsyncLocalIDContext = (0, import_react.createContext)(null);
|
|
55
|
-
globalThis["__vxrnGetContextFromReactContext"] = () => (0, import_react.useContext)(ServerAsyncLocalIDContext);
|
|
56
55
|
function Root(props) {
|
|
56
|
+
globalThis["__vxrnGetContextFromReactContext"] = () => (0, import_react.useContext)(ServerAsyncLocalIDContext);
|
|
57
57
|
if (import_constants.isNative) {
|
|
58
58
|
(0, import_screensFeatureFlags.initScreensFeatureFlags)();
|
|
59
59
|
}
|
package/dist/cjs/Root.native.cjs
CHANGED
|
@@ -54,11 +54,11 @@ function getCachedSSRLocation(path) {
|
|
|
54
54
|
return url;
|
|
55
55
|
}
|
|
56
56
|
var ServerAsyncLocalIDContext = /* @__PURE__ */ (0, import_react.createContext)(null);
|
|
57
|
-
globalThis["__vxrnGetContextFromReactContext"] = function() {
|
|
58
|
-
return (0, import_react.useContext)(ServerAsyncLocalIDContext);
|
|
59
|
-
};
|
|
60
57
|
function Root(props) {
|
|
61
58
|
var _globalThis___vxrnrequestAsyncLocalStore;
|
|
59
|
+
globalThis["__vxrnGetContextFromReactContext"] = function() {
|
|
60
|
+
return (0, import_react.useContext)(ServerAsyncLocalIDContext);
|
|
61
|
+
};
|
|
62
62
|
if (import_constants.isNative) {
|
|
63
63
|
(0, import_screensFeatureFlags.initScreensFeatureFlags)();
|
|
64
64
|
}
|
package/dist/cjs/Root.native.js
CHANGED
|
@@ -54,11 +54,11 @@ function getCachedSSRLocation(path) {
|
|
|
54
54
|
return url;
|
|
55
55
|
}
|
|
56
56
|
var ServerAsyncLocalIDContext = /* @__PURE__ */ (0, import_react.createContext)(null);
|
|
57
|
-
globalThis["__vxrnGetContextFromReactContext"] = function() {
|
|
58
|
-
return (0, import_react.useContext)(ServerAsyncLocalIDContext);
|
|
59
|
-
};
|
|
60
57
|
function Root(props) {
|
|
61
58
|
var _globalThis___vxrnrequestAsyncLocalStore;
|
|
59
|
+
globalThis["__vxrnGetContextFromReactContext"] = function() {
|
|
60
|
+
return (0, import_react.useContext)(ServerAsyncLocalIDContext);
|
|
61
|
+
};
|
|
62
62
|
if (import_constants.isNative) {
|
|
63
63
|
(0, import_screensFeatureFlags.initScreensFeatureFlags)();
|
|
64
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.native.js","names":[],"sources":["cjs/Root.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar Root_exports = {};\n__export(Root_exports, {\n Root: () => Root\n});\nmodule.exports = __toCommonJS(Root_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_theme = require(\"./fork/theme\");\nvar import_color_scheme = require(\"@vxrn/color-scheme\");\nvar import_react = require(\"react\");\nvar import_constants = require(\"./constants\");\nvar import_screensFeatureFlags = require(\"./screensFeatureFlags\");\nvar import_SpaShellContext = require(\"./router/SpaShellContext\");\nvar import_NavigationContainer = require(\"./fork/NavigationContainer\");\nvar import_getURL = require(\"./getURL\");\nvar import_FlagsContext = require(\"./router/FlagsContext\");\nvar import_linkingConfig = require(\"./router/linkingConfig\");\nvar import_router = require(\"./router/router\");\nvar import_serverLocationContext = require(\"./router/serverLocationContext\");\nvar import_useInitializeOneRouter = require(\"./router/useInitializeOneRouter\");\nvar import_useViteRoutes = require(\"./router/useViteRoutes\");\nvar import_evictOldest = require(\"./utils/evictOldest\");\nvar import_useServerHeadInsertion = require(\"./useServerHeadInsertion\");\nvar import_PreloadLinks = require(\"./views/PreloadLinks\");\nvar import_safe_area_context = require(\"./safe-area-context\");\nvar import_RootErrorBoundary = require(\"./views/RootErrorBoundary\");\nvar import_ScrollBehavior = require(\"./views/ScrollBehavior\");\nvar ssrLocationCache = /* @__PURE__ */ new Map();\nfunction getCachedSSRLocation(path) {\n var url = ssrLocationCache.get(path);\n if (url) return url;\n url = new URL(path, (0, import_getURL.getURL)());\n (0, import_evictOldest.evictOldest)(ssrLocationCache, 5e3, 1e3);\n ssrLocationCache.set(path, url);\n return url;\n}\nvar ServerAsyncLocalIDContext = /* @__PURE__ */ (0, import_react.createContext)(null);\nglobalThis[\"__vxrnGetContextFromReactContext\"] = function() {\n return (0, import_react.useContext)(ServerAsyncLocalIDContext);\n};\nfunction Root(props) {\n var _globalThis___vxrnrequestAsyncLocalStore;\n if (import_constants.isNative) {\n (0, import_screensFeatureFlags.initScreensFeatureFlags)();\n }\n var { path, routes, routeOptions, isClient, navigationContainerProps, onRenderId, linking } = props;\n var context = (0, import_useViteRoutes.useViteRoutes)(routes, props.routerRoot, routeOptions, globalThis[\"__vxrnVersion\"]);\n var location = import_constants.isNative ? void 0 : typeof window !== \"undefined\" && window.location ? new URL(path || window.location.href || \"/\", window.location.href) : getCachedSSRLocation(path || \"/\");\n var store = (0, import_useInitializeOneRouter.useInitializeOneRouter)(context, location, linking);\n var userScheme = (0, import_color_scheme.useUserScheme)();\n var Component = store.rootComponent;\n if (!Component) {\n throw new Error(`No root component found`);\n }\n var id = (0, import_react.useId)();\n onRenderId === null || onRenderId === void 0 ? void 0 : onRenderId(id);\n var value = process.env.VERCEL ? globalThis[\"__oneGlobalContextId\"] : ((_globalThis___vxrnrequestAsyncLocalStore = globalThis[\"__vxrnrequestAsyncLocalStore\"]) === null || _globalThis___vxrnrequestAsyncLocalStore === void 0 ? void 0 : _globalThis___vxrnrequestAsyncLocalStore.getStore()) || null;\n var deferredPreloads = props.deferredPreloads;\n var contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ServerAsyncLocalIDContext.Provider, {\n value,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_useServerHeadInsertion.ServerRenderID.Provider, {\n value: id,\n children: [\n typeof window === \"undefined\" && (deferredPreloads === null || deferredPreloads === void 0 ? void 0 : deferredPreloads.map(function(src) {\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(\"link\", {\n rel: \"modulepreload\",\n fetchPriority: \"low\",\n href: src\n }, src);\n })),\n /* one owns the safe area provider on every platform: apps read it\n through One.UI.SafeArea and never mount their own */\n /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_safe_area_context.SafeAreaProvider, {\n initialMetrics: import_safe_area_context.initialWindowMetrics,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_NavigationContainer.NavigationContainer, {\n ref: store.navigationRef,\n initialState: store.initialState,\n linking: (0, import_linkingConfig.getResolvedLinking)(),\n onUnhandledAction,\n onStateChange: import_router.handleNavigationContainerStateChange,\n theme: userScheme.value === \"dark\" ? import_theme.DarkTheme : import_theme.DefaultTheme,\n documentTitle: {\n enabled: false\n },\n ...navigationContainerProps,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_serverLocationContext.ServerLocationContext.Provider, {\n value: location,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {\n children: [\n /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ScrollBehavior.ScrollBehavior, {}),\n /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_RootErrorBoundary.RootErrorBoundary, {\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {})\n })\n ]\n })\n })\n })\n }),\n typeof window !== \"undefined\" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PreloadLinks.PreloadLinks, {}, \"preload-links\")\n ]\n })\n });\n if (props.flags) {\n contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FlagsContext.FlagsContext.Provider, {\n value: props.flags,\n children: contents\n });\n }\n if (!process.env.ONE_DISABLE_STRICT_MODE) {\n contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.StrictMode, {\n children: contents\n });\n }\n if (isClient) {\n var _globalThis_SERVER_CONTEXT_KEY;\n var serverMode = (_globalThis_SERVER_CONTEXT_KEY = globalThis[import_constants.SERVER_CONTEXT_KEY]) === null || _globalThis_SERVER_CONTEXT_KEY === void 0 ? void 0 : _globalThis_SERVER_CONTEXT_KEY.mode;\n if (serverMode === \"spa\") {\n var [show, setShow] = (0, import_react.useState)(false);\n (0, import_react.useLayoutEffect)(function() {\n setShow(true);\n }, []);\n return show ? contents : null;\n }\n if (serverMode === \"spa-shell\") {\n var [isSpaShell, setIsSpaShell] = (0, import_react.useState)(true);\n (0, import_react.useLayoutEffect)(function() {\n setIsSpaShell(false);\n }, []);\n (0, import_react.useLayoutEffect)(function() {\n if (!isSpaShell) {\n var initialPath = window.location.pathname + window.location.search;\n requestAnimationFrame(function() {\n var _store_navigationRef;\n if (window.location.pathname + window.location.search !== initialPath) return;\n var nav = (_store_navigationRef = store.navigationRef) === null || _store_navigationRef === void 0 ? void 0 : _store_navigationRef.current;\n if (!nav) return;\n var linking2 = (0, import_linkingConfig.getResolvedLinking)();\n if (linking2 === null || linking2 === void 0 ? void 0 : linking2.getStateFromPath) {\n var freshState = linking2.getStateFromPath(initialPath, linking2.config);\n if (freshState) {\n nav.resetRoot(freshState);\n }\n }\n });\n }\n }, [\n isSpaShell\n ]);\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SpaShellContext.SpaShellContext.Provider, {\n value: isSpaShell,\n children: contents\n });\n }\n return contents;\n }\n if (props.mode === \"spa-shell\") {\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SpaShellContext.SpaShellContext.Provider, {\n value: true,\n children: contents\n });\n }\n return contents;\n}\nvar onUnhandledAction;\nif (process.env.NODE_ENV !== \"production\") {\n onUnhandledAction = function onUnhandledAction2(action) {\n var payload = action.payload;\n var message = `The action '${action.type}'${payload ? ` with payload ${JSON.stringify(action.payload)}` : \"\"} was not handled by any navigator.`;\n switch (action.type) {\n case \"NAVIGATE\":\n case \"PUSH\":\n case \"REPLACE\":\n case \"JUMP_TO\":\n if (payload === null || payload === void 0 ? void 0 : payload.name) {\n message += `\n\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\n\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n break;\n case \"GO_BACK\":\n case \"POP\":\n case \"POP_TO_TOP\":\n message += `\n\nIs there any screen to go back to?`;\n break;\n case \"OPEN_DRAWER\":\n case \"CLOSE_DRAWER\":\n case \"TOGGLE_DRAWER\":\n message += `\n\nIs your screen inside a Drawer navigator?`;\n break;\n }\n message += `\n\nThis is a development-only warning and won't be shown in production.`;\n if (process.env.NODE_ENV === \"test\") {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = function onUnhandledAction2() {\n };\n}\n//# sourceMappingURL=Root.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;A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AW;;;IAGX;EACJ;EACA,WAAW;;;EAGX,IAAI,QAAQ,IAAI,aAAa,QAAQ;GACnC,MAAM,IAAI,MAAM,OAAO;EACzB;EACA,QAAQ,MAAM,OAAO;CACvB;AACF,OAAO;CACL,oBAAoB,SAAS,qBAAqB,CAClD;AACF"}
|
|
1
|
+
{"version":3,"file":"Root.native.js","names":[],"sources":["cjs/Root.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar Root_exports = {};\n__export(Root_exports, {\n Root: () => Root\n});\nmodule.exports = __toCommonJS(Root_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_theme = require(\"./fork/theme\");\nvar import_color_scheme = require(\"@vxrn/color-scheme\");\nvar import_react = require(\"react\");\nvar import_constants = require(\"./constants\");\nvar import_screensFeatureFlags = require(\"./screensFeatureFlags\");\nvar import_SpaShellContext = require(\"./router/SpaShellContext\");\nvar import_NavigationContainer = require(\"./fork/NavigationContainer\");\nvar import_getURL = require(\"./getURL\");\nvar import_FlagsContext = require(\"./router/FlagsContext\");\nvar import_linkingConfig = require(\"./router/linkingConfig\");\nvar import_router = require(\"./router/router\");\nvar import_serverLocationContext = require(\"./router/serverLocationContext\");\nvar import_useInitializeOneRouter = require(\"./router/useInitializeOneRouter\");\nvar import_useViteRoutes = require(\"./router/useViteRoutes\");\nvar import_evictOldest = require(\"./utils/evictOldest\");\nvar import_useServerHeadInsertion = require(\"./useServerHeadInsertion\");\nvar import_PreloadLinks = require(\"./views/PreloadLinks\");\nvar import_safe_area_context = require(\"./safe-area-context\");\nvar import_RootErrorBoundary = require(\"./views/RootErrorBoundary\");\nvar import_ScrollBehavior = require(\"./views/ScrollBehavior\");\nvar ssrLocationCache = /* @__PURE__ */ new Map();\nfunction getCachedSSRLocation(path) {\n var url = ssrLocationCache.get(path);\n if (url) return url;\n url = new URL(path, (0, import_getURL.getURL)());\n (0, import_evictOldest.evictOldest)(ssrLocationCache, 5e3, 1e3);\n ssrLocationCache.set(path, url);\n return url;\n}\nvar ServerAsyncLocalIDContext = /* @__PURE__ */ (0, import_react.createContext)(null);\nfunction Root(props) {\n var _globalThis___vxrnrequestAsyncLocalStore;\n globalThis[\"__vxrnGetContextFromReactContext\"] = function() {\n return (0, import_react.useContext)(ServerAsyncLocalIDContext);\n };\n if (import_constants.isNative) {\n (0, import_screensFeatureFlags.initScreensFeatureFlags)();\n }\n var { path, routes, routeOptions, isClient, navigationContainerProps, onRenderId, linking } = props;\n var context = (0, import_useViteRoutes.useViteRoutes)(routes, props.routerRoot, routeOptions, globalThis[\"__vxrnVersion\"]);\n var location = import_constants.isNative ? void 0 : typeof window !== \"undefined\" && window.location ? new URL(path || window.location.href || \"/\", window.location.href) : getCachedSSRLocation(path || \"/\");\n var store = (0, import_useInitializeOneRouter.useInitializeOneRouter)(context, location, linking);\n var userScheme = (0, import_color_scheme.useUserScheme)();\n var Component = store.rootComponent;\n if (!Component) {\n throw new Error(`No root component found`);\n }\n var id = (0, import_react.useId)();\n onRenderId === null || onRenderId === void 0 ? void 0 : onRenderId(id);\n var value = process.env.VERCEL ? globalThis[\"__oneGlobalContextId\"] : ((_globalThis___vxrnrequestAsyncLocalStore = globalThis[\"__vxrnrequestAsyncLocalStore\"]) === null || _globalThis___vxrnrequestAsyncLocalStore === void 0 ? void 0 : _globalThis___vxrnrequestAsyncLocalStore.getStore()) || null;\n var deferredPreloads = props.deferredPreloads;\n var contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ServerAsyncLocalIDContext.Provider, {\n value,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_useServerHeadInsertion.ServerRenderID.Provider, {\n value: id,\n children: [\n typeof window === \"undefined\" && (deferredPreloads === null || deferredPreloads === void 0 ? void 0 : deferredPreloads.map(function(src) {\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(\"link\", {\n rel: \"modulepreload\",\n fetchPriority: \"low\",\n href: src\n }, src);\n })),\n /* one owns the safe area provider on every platform: apps read it\n through One.UI.SafeArea and never mount their own */\n /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_safe_area_context.SafeAreaProvider, {\n initialMetrics: import_safe_area_context.initialWindowMetrics,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_NavigationContainer.NavigationContainer, {\n ref: store.navigationRef,\n initialState: store.initialState,\n linking: (0, import_linkingConfig.getResolvedLinking)(),\n onUnhandledAction,\n onStateChange: import_router.handleNavigationContainerStateChange,\n theme: userScheme.value === \"dark\" ? import_theme.DarkTheme : import_theme.DefaultTheme,\n documentTitle: {\n enabled: false\n },\n ...navigationContainerProps,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_serverLocationContext.ServerLocationContext.Provider, {\n value: location,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {\n children: [\n /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ScrollBehavior.ScrollBehavior, {}),\n /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_RootErrorBoundary.RootErrorBoundary, {\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {})\n })\n ]\n })\n })\n })\n }),\n typeof window !== \"undefined\" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PreloadLinks.PreloadLinks, {}, \"preload-links\")\n ]\n })\n });\n if (props.flags) {\n contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FlagsContext.FlagsContext.Provider, {\n value: props.flags,\n children: contents\n });\n }\n if (!process.env.ONE_DISABLE_STRICT_MODE) {\n contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.StrictMode, {\n children: contents\n });\n }\n if (isClient) {\n var _globalThis_SERVER_CONTEXT_KEY;\n var serverMode = (_globalThis_SERVER_CONTEXT_KEY = globalThis[import_constants.SERVER_CONTEXT_KEY]) === null || _globalThis_SERVER_CONTEXT_KEY === void 0 ? void 0 : _globalThis_SERVER_CONTEXT_KEY.mode;\n if (serverMode === \"spa\") {\n var [show, setShow] = (0, import_react.useState)(false);\n (0, import_react.useLayoutEffect)(function() {\n setShow(true);\n }, []);\n return show ? contents : null;\n }\n if (serverMode === \"spa-shell\") {\n var [isSpaShell, setIsSpaShell] = (0, import_react.useState)(true);\n (0, import_react.useLayoutEffect)(function() {\n setIsSpaShell(false);\n }, []);\n (0, import_react.useLayoutEffect)(function() {\n if (!isSpaShell) {\n var initialPath = window.location.pathname + window.location.search;\n requestAnimationFrame(function() {\n var _store_navigationRef;\n if (window.location.pathname + window.location.search !== initialPath) return;\n var nav = (_store_navigationRef = store.navigationRef) === null || _store_navigationRef === void 0 ? void 0 : _store_navigationRef.current;\n if (!nav) return;\n var linking2 = (0, import_linkingConfig.getResolvedLinking)();\n if (linking2 === null || linking2 === void 0 ? void 0 : linking2.getStateFromPath) {\n var freshState = linking2.getStateFromPath(initialPath, linking2.config);\n if (freshState) {\n nav.resetRoot(freshState);\n }\n }\n });\n }\n }, [\n isSpaShell\n ]);\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SpaShellContext.SpaShellContext.Provider, {\n value: isSpaShell,\n children: contents\n });\n }\n return contents;\n }\n if (props.mode === \"spa-shell\") {\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SpaShellContext.SpaShellContext.Provider, {\n value: true,\n children: contents\n });\n }\n return contents;\n}\nvar onUnhandledAction;\nif (process.env.NODE_ENV !== \"production\") {\n onUnhandledAction = function onUnhandledAction2(action) {\n var payload = action.payload;\n var message = `The action '${action.type}'${payload ? ` with payload ${JSON.stringify(action.payload)}` : \"\"} was not handled by any navigator.`;\n switch (action.type) {\n case \"NAVIGATE\":\n case \"PUSH\":\n case \"REPLACE\":\n case \"JUMP_TO\":\n if (payload === null || payload === void 0 ? void 0 : payload.name) {\n message += `\n\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\n\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n break;\n case \"GO_BACK\":\n case \"POP\":\n case \"POP_TO_TOP\":\n message += `\n\nIs there any screen to go back to?`;\n break;\n case \"OPEN_DRAWER\":\n case \"CLOSE_DRAWER\":\n case \"TOGGLE_DRAWER\":\n message += `\n\nIs your screen inside a Drawer navigator?`;\n break;\n }\n message += `\n\nThis is a development-only warning and won't be shown in production.`;\n if (process.env.NODE_ENV === \"test\") {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = function onUnhandledAction2() {\n };\n}\n//# sourceMappingURL=Root.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAA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IAAG,CAAE,uBAAuB,gBAAgB,UAAU;IAClG,OAAO;IACP,UAAU;GACZ,CAAC;EACH;EACA,OAAO;CACT;CACA,IAAI,MAAM,SAAS,aAAa;EAC9B,OAAuB,iBAAC,GAAG,mBAAmB,IAAG,CAAE,uBAAuB,gBAAgB,UAAU;GAClG,OAAO;GACP,UAAU;EACZ,CAAC;CACH;CACA,OAAO;AACT;AACA,IAAI;AACJ,IAAI,QAAQ,IAAI,aAAa,cAAc;CACzC,oBAAoB,SAAS,mBAAmB,QAAQ;EACtD,IAAI,UAAU,OAAO;EACrB,IAAI,UAAU,eAAe,OAAO,KAAK,GAAG,UAAU,iBAAiB,KAAK,UAAU,OAAO,OAAO,MAAM,GAAG;EAC7G,QAAQ,OAAO,MAAf;GACE,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;IACH,IAAI,YAAY,QAAQ,YAAY,KAAK,IAAI,KAAK,IAAI,QAAQ,MAAM;KAClE,WAAW;;6BAEQ,QAAQ,KAAK;IAClC,OAAO;KACL,WAAW;;;IAGb;IACA;GACF,KAAK;GACL,KAAK;GACL,KAAK;IACH,WAAW;;;IAGX;GACF,KAAK;GACL,KAAK;GACL,KAAK;IACH,WAAW;;;IAGX;EACJ;EACA,WAAW;;;EAGX,IAAI,QAAQ,IAAI,aAAa,QAAQ;GACnC,MAAM,IAAI,MAAM,OAAO;EACzB;EACA,QAAQ,MAAM,OAAO;CACvB;AACF,OAAO;CACL,oBAAoB,SAAS,qBAAqB,CAClD;AACF"}
|
package/dist/esm/Root.mjs
CHANGED
|
@@ -30,8 +30,8 @@ function getCachedSSRLocation(path) {
|
|
|
30
30
|
return url;
|
|
31
31
|
}
|
|
32
32
|
const ServerAsyncLocalIDContext = createContext(null);
|
|
33
|
-
globalThis["__vxrnGetContextFromReactContext"] = () => useContext(ServerAsyncLocalIDContext);
|
|
34
33
|
function Root(props) {
|
|
34
|
+
globalThis["__vxrnGetContextFromReactContext"] = () => useContext(ServerAsyncLocalIDContext);
|
|
35
35
|
if (isNative) {
|
|
36
36
|
initScreensFeatureFlags();
|
|
37
37
|
}
|
package/dist/esm/Root.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.js","names":["UpstreamNavigationContainer"],"sources":["esm/Root.js"],"sourcesContent":["import { DarkTheme, DefaultTheme } from \"./fork/theme\";\nimport { useUserScheme } from \"@vxrn/color-scheme\";\nimport {\n createContext,\n StrictMode,\n useContext,\n useId,\n useLayoutEffect,\n useState\n} from \"react\";\nimport { SERVER_CONTEXT_KEY, isNative } from \"./constants\";\nimport { initScreensFeatureFlags } from \"./screensFeatureFlags\";\nimport { SpaShellContext } from \"./router/SpaShellContext\";\nimport { NavigationContainer as UpstreamNavigationContainer } from \"./fork/NavigationContainer\";\nimport { getURL } from \"./getURL\";\nimport { FlagsContext } from \"./router/FlagsContext\";\nimport { getResolvedLinking } from \"./router/linkingConfig\";\nimport { handleNavigationContainerStateChange } from \"./router/router\";\nimport { ServerLocationContext } from \"./router/serverLocationContext\";\nimport { useInitializeOneRouter } from \"./router/useInitializeOneRouter\";\nimport { useViteRoutes } from \"./router/useViteRoutes\";\nimport { evictOldest } from \"./utils/evictOldest\";\nimport { ServerRenderID } from \"./useServerHeadInsertion\";\nimport { PreloadLinks } from \"./views/PreloadLinks\";\nimport { SafeAreaProvider, initialWindowMetrics } from \"./safe-area-context\";\nimport { RootErrorBoundary } from \"./views/RootErrorBoundary\";\nimport { ScrollBehavior } from \"./views/ScrollBehavior\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nconst ssrLocationCache = /* @__PURE__ */ new Map();\nfunction getCachedSSRLocation(path) {\n let url = ssrLocationCache.get(path);\n if (url) return url;\n url = new URL(path, getURL());\n evictOldest(ssrLocationCache, 5e3, 1e3);\n ssrLocationCache.set(path, url);\n return url;\n}\nconst ServerAsyncLocalIDContext = createContext(null);\nglobalThis[\"__vxrnGetContextFromReactContext\"] = () => useContext(ServerAsyncLocalIDContext);\nfunction Root(props) {\n if (isNative) {\n initScreensFeatureFlags();\n }\n const {\n path,\n routes,\n routeOptions,\n isClient,\n navigationContainerProps,\n onRenderId,\n linking\n } = props;\n const context = useViteRoutes(\n routes,\n props.routerRoot,\n routeOptions,\n globalThis[\"__vxrnVersion\"]\n );\n const location = isNative ? void 0 : typeof window !== \"undefined\" && window.location ? new URL(path || window.location.href || \"/\", window.location.href) : getCachedSSRLocation(path || \"/\");\n const store = useInitializeOneRouter(context, location, linking);\n const userScheme = useUserScheme();\n const Component = store.rootComponent;\n if (!Component) {\n throw new Error(`No root component found`);\n }\n const id = useId();\n onRenderId?.(id);\n const value = process.env.VERCEL ? globalThis[\"__oneGlobalContextId\"] : globalThis[\"__vxrnrequestAsyncLocalStore\"]?.getStore() || null;\n const deferredPreloads = props.deferredPreloads;\n let contents = /* @__PURE__ */ jsx(ServerAsyncLocalIDContext.Provider, { value, children: /* @__PURE__ */ jsxs(ServerRenderID.Provider, { value: id, children: [\n typeof window === \"undefined\" && deferredPreloads?.map((src) => /* @__PURE__ */ jsx(\"link\", { rel: \"modulepreload\", fetchPriority: \"low\", href: src }, src)),\n /* @__PURE__ */ jsx(SafeAreaProvider, { initialMetrics: initialWindowMetrics, children: /* @__PURE__ */ jsx(\n UpstreamNavigationContainer,\n {\n ref: store.navigationRef,\n initialState: store.initialState,\n linking: getResolvedLinking(),\n onUnhandledAction,\n onStateChange: handleNavigationContainerStateChange,\n theme: userScheme.value === \"dark\" ? DarkTheme : DefaultTheme,\n documentTitle: {\n enabled: false\n },\n ...navigationContainerProps,\n children: /* @__PURE__ */ jsx(ServerLocationContext.Provider, { value: location, children: /* @__PURE__ */ jsxs(Fragment, { children: [\n /* @__PURE__ */ jsx(ScrollBehavior, {}),\n /* @__PURE__ */ jsx(RootErrorBoundary, { children: /* @__PURE__ */ jsx(Component, {}) })\n ] }) })\n }\n ) }),\n typeof window !== \"undefined\" && /* @__PURE__ */ jsx(PreloadLinks, {}, \"preload-links\")\n ] }) });\n if (props.flags) {\n contents = /* @__PURE__ */ jsx(FlagsContext.Provider, { value: props.flags, children: contents });\n }\n if (!process.env.ONE_DISABLE_STRICT_MODE) {\n contents = /* @__PURE__ */ jsx(StrictMode, { children: contents });\n }\n if (isClient) {\n const serverMode = globalThis[SERVER_CONTEXT_KEY]?.mode;\n if (serverMode === \"spa\") {\n const [show, setShow] = useState(false);\n useLayoutEffect(() => {\n setShow(true);\n }, []);\n return show ? contents : null;\n }\n if (serverMode === \"spa-shell\") {\n const [isSpaShell, setIsSpaShell] = useState(true);\n useLayoutEffect(() => {\n setIsSpaShell(false);\n }, []);\n useLayoutEffect(() => {\n if (!isSpaShell) {\n const initialPath = window.location.pathname + window.location.search;\n requestAnimationFrame(() => {\n if (window.location.pathname + window.location.search !== initialPath) return;\n const nav = store.navigationRef?.current;\n if (!nav) return;\n const linking2 = getResolvedLinking();\n if (linking2?.getStateFromPath) {\n const freshState = linking2.getStateFromPath(initialPath, linking2.config);\n if (freshState) {\n nav.resetRoot(freshState);\n }\n }\n });\n }\n }, [isSpaShell]);\n return /* @__PURE__ */ jsx(SpaShellContext.Provider, { value: isSpaShell, children: contents });\n }\n return contents;\n }\n if (props.mode === \"spa-shell\") {\n return /* @__PURE__ */ jsx(SpaShellContext.Provider, { value: true, children: contents });\n }\n return contents;\n}\nlet onUnhandledAction;\nif (process.env.NODE_ENV !== \"production\") {\n onUnhandledAction = (action) => {\n const payload = action.payload;\n let message = `The action '${action.type}'${payload ? ` with payload ${JSON.stringify(action.payload)}` : \"\"} was not handled by any navigator.`;\n switch (action.type) {\n case \"NAVIGATE\":\n case \"PUSH\":\n case \"REPLACE\":\n case \"JUMP_TO\":\n if (payload?.name) {\n message += `\n\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\n\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n break;\n case \"GO_BACK\":\n case \"POP\":\n case \"POP_TO_TOP\":\n message += `\n\nIs there any screen to go back to?`;\n break;\n case \"OPEN_DRAWER\":\n case \"CLOSE_DRAWER\":\n case \"TOGGLE_DRAWER\":\n message += `\n\nIs your screen inside a Drawer navigator?`;\n break;\n }\n message += `\n\nThis is a development-only warning and won't be shown in production.`;\n if (process.env.NODE_ENV === \"test\") {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = () => {\n };\n}\nexport {\n Root\n};\n//# sourceMappingURL=Root.js.map\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,mCAAmC,IAAI,IAAI;AACjD,SAAS,qBAAqB,MAAM;CAClC,IAAI,MAAM,iBAAiB,IAAI,IAAI;CACnC,IAAI,KAAK,OAAO;CAChB,MAAM,IAAI,IAAI,MAAM,OAAO,CAAC;CAC5B,YAAY,kBAAkB,KAAK,GAAG;CACtC,iBAAiB,IAAI,MAAM,GAAG;CAC9B,OAAO;AACT;AACA,MAAM,4BAA4B,cAAc,IAAI;AACpD,WAAW,4CAA4C,WAAW,yBAAyB;AAC3F,SAAS,KAAK,OAAO;CACnB,IAAI,UAAU;EACZ,wBAAwB;CAC1B;CACA,MAAM,EACJ,MACA,QACA,cACA,UACA,0BACA,YACA,YACE;CACJ,MAAM,UAAU,cACd,QACA,MAAM,YACN,cACA,WAAW,gBACb;CACA,MAAM,WAAW,WAAW,KAAK,IAAI,OAAO,WAAW,eAAe,OAAO,WAAW,IAAI,IAAI,QAAQ,OAAO,SAAS,QAAQ,KAAK,OAAO,SAAS,IAAI,IAAI,qBAAqB,QAAQ,GAAG;CAC7L,MAAM,QAAQ,uBAAuB,SAAS,UAAU,OAAO;CAC/D,MAAM,aAAa,cAAc;CACjC,MAAM,YAAY,MAAM;CACxB,IAAI,CAAC,WAAW;EACd,MAAM,IAAI,MAAM,yBAAyB;CAC3C;CACA,MAAM,KAAK,MAAM;CACjB,aAAa,EAAE;CACf,MAAM,QAAQ,QAAQ,IAAI,SAAS,WAAW,0BAA0B,WAAW,+BAA+B,EAAE,SAAS,KAAK;CAClI,MAAM,mBAAmB,MAAM;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EACzB;EACA,QAAQ,MAAM,OAAO;CACvB;AACF,OAAO;CACL,0BAA0B,CAC1B;AACF"}
|
|
1
|
+
{"version":3,"file":"Root.js","names":["UpstreamNavigationContainer"],"sources":["esm/Root.js"],"sourcesContent":["import { DarkTheme, DefaultTheme } from \"./fork/theme\";\nimport { useUserScheme } from \"@vxrn/color-scheme\";\nimport {\n createContext,\n StrictMode,\n useContext,\n useId,\n useLayoutEffect,\n useState\n} from \"react\";\nimport { SERVER_CONTEXT_KEY, isNative } from \"./constants\";\nimport { initScreensFeatureFlags } from \"./screensFeatureFlags\";\nimport { SpaShellContext } from \"./router/SpaShellContext\";\nimport { NavigationContainer as UpstreamNavigationContainer } from \"./fork/NavigationContainer\";\nimport { getURL } from \"./getURL\";\nimport { FlagsContext } from \"./router/FlagsContext\";\nimport { getResolvedLinking } from \"./router/linkingConfig\";\nimport { handleNavigationContainerStateChange } from \"./router/router\";\nimport { ServerLocationContext } from \"./router/serverLocationContext\";\nimport { useInitializeOneRouter } from \"./router/useInitializeOneRouter\";\nimport { useViteRoutes } from \"./router/useViteRoutes\";\nimport { evictOldest } from \"./utils/evictOldest\";\nimport { ServerRenderID } from \"./useServerHeadInsertion\";\nimport { PreloadLinks } from \"./views/PreloadLinks\";\nimport { SafeAreaProvider, initialWindowMetrics } from \"./safe-area-context\";\nimport { RootErrorBoundary } from \"./views/RootErrorBoundary\";\nimport { ScrollBehavior } from \"./views/ScrollBehavior\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nconst ssrLocationCache = /* @__PURE__ */ new Map();\nfunction getCachedSSRLocation(path) {\n let url = ssrLocationCache.get(path);\n if (url) return url;\n url = new URL(path, getURL());\n evictOldest(ssrLocationCache, 5e3, 1e3);\n ssrLocationCache.set(path, url);\n return url;\n}\nconst ServerAsyncLocalIDContext = createContext(null);\nfunction Root(props) {\n globalThis[\"__vxrnGetContextFromReactContext\"] = () => useContext(ServerAsyncLocalIDContext);\n if (isNative) {\n initScreensFeatureFlags();\n }\n const {\n path,\n routes,\n routeOptions,\n isClient,\n navigationContainerProps,\n onRenderId,\n linking\n } = props;\n const context = useViteRoutes(\n routes,\n props.routerRoot,\n routeOptions,\n globalThis[\"__vxrnVersion\"]\n );\n const location = isNative ? void 0 : typeof window !== \"undefined\" && window.location ? new URL(path || window.location.href || \"/\", window.location.href) : getCachedSSRLocation(path || \"/\");\n const store = useInitializeOneRouter(context, location, linking);\n const userScheme = useUserScheme();\n const Component = store.rootComponent;\n if (!Component) {\n throw new Error(`No root component found`);\n }\n const id = useId();\n onRenderId?.(id);\n const value = process.env.VERCEL ? globalThis[\"__oneGlobalContextId\"] : globalThis[\"__vxrnrequestAsyncLocalStore\"]?.getStore() || null;\n const deferredPreloads = props.deferredPreloads;\n let contents = /* @__PURE__ */ jsx(ServerAsyncLocalIDContext.Provider, { value, children: /* @__PURE__ */ jsxs(ServerRenderID.Provider, { value: id, children: [\n typeof window === \"undefined\" && deferredPreloads?.map((src) => /* @__PURE__ */ jsx(\"link\", { rel: \"modulepreload\", fetchPriority: \"low\", href: src }, src)),\n /* @__PURE__ */ jsx(SafeAreaProvider, { initialMetrics: initialWindowMetrics, children: /* @__PURE__ */ jsx(\n UpstreamNavigationContainer,\n {\n ref: store.navigationRef,\n initialState: store.initialState,\n linking: getResolvedLinking(),\n onUnhandledAction,\n onStateChange: handleNavigationContainerStateChange,\n theme: userScheme.value === \"dark\" ? DarkTheme : DefaultTheme,\n documentTitle: {\n enabled: false\n },\n ...navigationContainerProps,\n children: /* @__PURE__ */ jsx(ServerLocationContext.Provider, { value: location, children: /* @__PURE__ */ jsxs(Fragment, { children: [\n /* @__PURE__ */ jsx(ScrollBehavior, {}),\n /* @__PURE__ */ jsx(RootErrorBoundary, { children: /* @__PURE__ */ jsx(Component, {}) })\n ] }) })\n }\n ) }),\n typeof window !== \"undefined\" && /* @__PURE__ */ jsx(PreloadLinks, {}, \"preload-links\")\n ] }) });\n if (props.flags) {\n contents = /* @__PURE__ */ jsx(FlagsContext.Provider, { value: props.flags, children: contents });\n }\n if (!process.env.ONE_DISABLE_STRICT_MODE) {\n contents = /* @__PURE__ */ jsx(StrictMode, { children: contents });\n }\n if (isClient) {\n const serverMode = globalThis[SERVER_CONTEXT_KEY]?.mode;\n if (serverMode === \"spa\") {\n const [show, setShow] = useState(false);\n useLayoutEffect(() => {\n setShow(true);\n }, []);\n return show ? contents : null;\n }\n if (serverMode === \"spa-shell\") {\n const [isSpaShell, setIsSpaShell] = useState(true);\n useLayoutEffect(() => {\n setIsSpaShell(false);\n }, []);\n useLayoutEffect(() => {\n if (!isSpaShell) {\n const initialPath = window.location.pathname + window.location.search;\n requestAnimationFrame(() => {\n if (window.location.pathname + window.location.search !== initialPath) return;\n const nav = store.navigationRef?.current;\n if (!nav) return;\n const linking2 = getResolvedLinking();\n if (linking2?.getStateFromPath) {\n const freshState = linking2.getStateFromPath(initialPath, linking2.config);\n if (freshState) {\n nav.resetRoot(freshState);\n }\n }\n });\n }\n }, [isSpaShell]);\n return /* @__PURE__ */ jsx(SpaShellContext.Provider, { value: isSpaShell, children: contents });\n }\n return contents;\n }\n if (props.mode === \"spa-shell\") {\n return /* @__PURE__ */ jsx(SpaShellContext.Provider, { value: true, children: contents });\n }\n return contents;\n}\nlet onUnhandledAction;\nif (process.env.NODE_ENV !== \"production\") {\n onUnhandledAction = (action) => {\n const payload = action.payload;\n let message = `The action '${action.type}'${payload ? ` with payload ${JSON.stringify(action.payload)}` : \"\"} was not handled by any navigator.`;\n switch (action.type) {\n case \"NAVIGATE\":\n case \"PUSH\":\n case \"REPLACE\":\n case \"JUMP_TO\":\n if (payload?.name) {\n message += `\n\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\n\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n break;\n case \"GO_BACK\":\n case \"POP\":\n case \"POP_TO_TOP\":\n message += `\n\nIs there any screen to go back to?`;\n break;\n case \"OPEN_DRAWER\":\n case \"CLOSE_DRAWER\":\n case \"TOGGLE_DRAWER\":\n message += `\n\nIs your screen inside a Drawer navigator?`;\n break;\n }\n message += `\n\nThis is a development-only warning and won't be shown in production.`;\n if (process.env.NODE_ENV === \"test\") {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = () => {\n };\n}\nexport {\n Root\n};\n//# sourceMappingURL=Root.js.map\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,mCAAmC,IAAI,IAAI;AACjD,SAAS,qBAAqB,MAAM;CAClC,IAAI,MAAM,iBAAiB,IAAI,IAAI;CACnC,IAAI,KAAK,OAAO;CAChB,MAAM,IAAI,IAAI,MAAM,OAAO,CAAC;CAC5B,YAAY,kBAAkB,KAAK,GAAG;CACtC,iBAAiB,IAAI,MAAM,GAAG;CAC9B,OAAO;AACT;AACA,MAAM,4BAA4B,cAAc,IAAI;AACpD,SAAS,KAAK,OAAO;CACnB,WAAW,4CAA4C,WAAW,yBAAyB;CAC3F,IAAI,UAAU;EACZ,wBAAwB;CAC1B;CACA,MAAM,EACJ,MACA,QACA,cACA,UACA,0BACA,YACA,YACE;CACJ,MAAM,UAAU,cACd,QACA,MAAM,YACN,cACA,WAAW,gBACb;CACA,MAAM,WAAW,WAAW,KAAK,IAAI,OAAO,WAAW,eAAe,OAAO,WAAW,IAAI,IAAI,QAAQ,OAAO,SAAS,QAAQ,KAAK,OAAO,SAAS,IAAI,IAAI,qBAAqB,QAAQ,GAAG;CAC7L,MAAM,QAAQ,uBAAuB,SAAS,UAAU,OAAO;CAC/D,MAAM,aAAa,cAAc;CACjC,MAAM,YAAY,MAAM;CACxB,IAAI,CAAC,WAAW;EACd,MAAM,IAAI,MAAM,yBAAyB;CAC3C;CACA,MAAM,KAAK,MAAM;CACjB,aAAa,EAAE;CACf,MAAM,QAAQ,QAAQ,IAAI,SAAS,WAAW,0BAA0B,WAAW,+BAA+B,EAAE,SAAS,KAAK;CAClI,MAAM,mBAAmB,MAAM;CAC/B,IAAI,WAA2B,oBAAI,0BAA0B,U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ACF,OAAO;CACL,0BAA0B,CAC1B;AACF"}
|
package/dist/esm/Root.native.js
CHANGED
|
@@ -30,11 +30,11 @@ function getCachedSSRLocation(path) {
|
|
|
30
30
|
return url;
|
|
31
31
|
}
|
|
32
32
|
var ServerAsyncLocalIDContext = /* @__PURE__ */ createContext(null);
|
|
33
|
-
globalThis["__vxrnGetContextFromReactContext"] = function() {
|
|
34
|
-
return useContext(ServerAsyncLocalIDContext);
|
|
35
|
-
};
|
|
36
33
|
function Root(props) {
|
|
37
34
|
var _globalThis___vxrnrequestAsyncLocalStore;
|
|
35
|
+
globalThis["__vxrnGetContextFromReactContext"] = function() {
|
|
36
|
+
return useContext(ServerAsyncLocalIDContext);
|
|
37
|
+
};
|
|
38
38
|
if (isNative) {
|
|
39
39
|
initScreensFeatureFlags();
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.native.js","names":["UpstreamNavigationContainer","_Fragment"],"sources":["esm/Root.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { DarkTheme, DefaultTheme } from \"./fork/theme\";\nimport { useUserScheme } from \"@vxrn/color-scheme\";\nimport { createContext, StrictMode, useContext, useId, useLayoutEffect, useState } from \"react\";\nimport { SERVER_CONTEXT_KEY, isNative } from \"./constants\";\nimport { initScreensFeatureFlags } from \"./screensFeatureFlags\";\nimport { SpaShellContext } from \"./router/SpaShellContext\";\nimport { NavigationContainer as UpstreamNavigationContainer } from \"./fork/NavigationContainer\";\nimport { getURL } from \"./getURL\";\nimport { FlagsContext } from \"./router/FlagsContext\";\nimport { getResolvedLinking } from \"./router/linkingConfig\";\nimport { handleNavigationContainerStateChange } from \"./router/router\";\nimport { ServerLocationContext } from \"./router/serverLocationContext\";\nimport { useInitializeOneRouter } from \"./router/useInitializeOneRouter\";\nimport { useViteRoutes } from \"./router/useViteRoutes\";\nimport { evictOldest } from \"./utils/evictOldest\";\nimport { ServerRenderID } from \"./useServerHeadInsertion\";\nimport { PreloadLinks } from \"./views/PreloadLinks\";\nimport { SafeAreaProvider, initialWindowMetrics } from \"./safe-area-context\";\nimport { RootErrorBoundary } from \"./views/RootErrorBoundary\";\nimport { ScrollBehavior } from \"./views/ScrollBehavior\";\nvar ssrLocationCache = /* @__PURE__ */ new Map();\nfunction getCachedSSRLocation(path) {\n var url = ssrLocationCache.get(path);\n if (url) return url;\n url = new URL(path, getURL());\n evictOldest(ssrLocationCache, 5e3, 1e3);\n ssrLocationCache.set(path, url);\n return url;\n}\nvar ServerAsyncLocalIDContext = /* @__PURE__ */ createContext(null);\nglobalThis[\"__vxrnGetContextFromReactContext\"] = function() {\n return useContext(ServerAsyncLocalIDContext);\n};\nfunction Root(props) {\n var _globalThis___vxrnrequestAsyncLocalStore;\n if (isNative) {\n initScreensFeatureFlags();\n }\n var { path, routes, routeOptions, isClient, navigationContainerProps, onRenderId, linking } = props;\n var context = useViteRoutes(routes, props.routerRoot, routeOptions, globalThis[\"__vxrnVersion\"]);\n var location = isNative ? void 0 : typeof window !== \"undefined\" && window.location ? new URL(path || window.location.href || \"/\", window.location.href) : getCachedSSRLocation(path || \"/\");\n var store = useInitializeOneRouter(context, location, linking);\n var userScheme = useUserScheme();\n var Component = store.rootComponent;\n if (!Component) {\n throw new Error(`No root component found`);\n }\n var id = useId();\n onRenderId === null || onRenderId === void 0 ? void 0 : onRenderId(id);\n var value = process.env.VERCEL ? globalThis[\"__oneGlobalContextId\"] : ((_globalThis___vxrnrequestAsyncLocalStore = globalThis[\"__vxrnrequestAsyncLocalStore\"]) === null || _globalThis___vxrnrequestAsyncLocalStore === void 0 ? void 0 : _globalThis___vxrnrequestAsyncLocalStore.getStore()) || null;\n var deferredPreloads = props.deferredPreloads;\n var contents = /* @__PURE__ */ _jsx(ServerAsyncLocalIDContext.Provider, {\n value,\n children: /* @__PURE__ */ _jsxs(ServerRenderID.Provider, {\n value: id,\n children: [\n typeof window === \"undefined\" && (deferredPreloads === null || deferredPreloads === void 0 ? void 0 : deferredPreloads.map(function(src) {\n return /* @__PURE__ */ _jsx(\"link\", {\n rel: \"modulepreload\",\n fetchPriority: \"low\",\n href: src\n }, src);\n })),\n /* one owns the safe area provider on every platform: apps read it\n through One.UI.SafeArea and never mount their own */\n /* @__PURE__ */ _jsx(SafeAreaProvider, {\n initialMetrics: initialWindowMetrics,\n children: /* @__PURE__ */ _jsx(UpstreamNavigationContainer, {\n ref: store.navigationRef,\n initialState: store.initialState,\n linking: getResolvedLinking(),\n onUnhandledAction,\n onStateChange: handleNavigationContainerStateChange,\n theme: userScheme.value === \"dark\" ? DarkTheme : DefaultTheme,\n documentTitle: {\n enabled: false\n },\n ...navigationContainerProps,\n children: /* @__PURE__ */ _jsx(ServerLocationContext.Provider, {\n value: location,\n children: /* @__PURE__ */ _jsxs(_Fragment, {\n children: [\n /* @__PURE__ */ _jsx(ScrollBehavior, {}),\n /* @__PURE__ */ _jsx(RootErrorBoundary, {\n children: /* @__PURE__ */ _jsx(Component, {})\n })\n ]\n })\n })\n })\n }),\n typeof window !== \"undefined\" && /* @__PURE__ */ _jsx(PreloadLinks, {}, \"preload-links\")\n ]\n })\n });\n if (props.flags) {\n contents = /* @__PURE__ */ _jsx(FlagsContext.Provider, {\n value: props.flags,\n children: contents\n });\n }\n if (!process.env.ONE_DISABLE_STRICT_MODE) {\n contents = /* @__PURE__ */ _jsx(StrictMode, {\n children: contents\n });\n }\n if (isClient) {\n var _globalThis_SERVER_CONTEXT_KEY;\n var serverMode = (_globalThis_SERVER_CONTEXT_KEY = globalThis[SERVER_CONTEXT_KEY]) === null || _globalThis_SERVER_CONTEXT_KEY === void 0 ? void 0 : _globalThis_SERVER_CONTEXT_KEY.mode;\n if (serverMode === \"spa\") {\n var [show, setShow] = useState(false);\n useLayoutEffect(function() {\n setShow(true);\n }, []);\n return show ? contents : null;\n }\n if (serverMode === \"spa-shell\") {\n var [isSpaShell, setIsSpaShell] = useState(true);\n useLayoutEffect(function() {\n setIsSpaShell(false);\n }, []);\n useLayoutEffect(function() {\n if (!isSpaShell) {\n var initialPath = window.location.pathname + window.location.search;\n requestAnimationFrame(function() {\n var _store_navigationRef;\n if (window.location.pathname + window.location.search !== initialPath) return;\n var nav = (_store_navigationRef = store.navigationRef) === null || _store_navigationRef === void 0 ? void 0 : _store_navigationRef.current;\n if (!nav) return;\n var linking2 = getResolvedLinking();\n if (linking2 === null || linking2 === void 0 ? void 0 : linking2.getStateFromPath) {\n var freshState = linking2.getStateFromPath(initialPath, linking2.config);\n if (freshState) {\n nav.resetRoot(freshState);\n }\n }\n });\n }\n }, [\n isSpaShell\n ]);\n return /* @__PURE__ */ _jsx(SpaShellContext.Provider, {\n value: isSpaShell,\n children: contents\n });\n }\n return contents;\n }\n if (props.mode === \"spa-shell\") {\n return /* @__PURE__ */ _jsx(SpaShellContext.Provider, {\n value: true,\n children: contents\n });\n }\n return contents;\n}\nvar onUnhandledAction;\nif (process.env.NODE_ENV !== \"production\") {\n onUnhandledAction = function onUnhandledAction2(action) {\n var payload = action.payload;\n var message = `The action '${action.type}'${payload ? ` with payload ${JSON.stringify(action.payload)}` : \"\"} was not handled by any navigator.`;\n switch (action.type) {\n case \"NAVIGATE\":\n case \"PUSH\":\n case \"REPLACE\":\n case \"JUMP_TO\":\n if (payload === null || payload === void 0 ? void 0 : payload.name) {\n message += `\n\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\n\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n break;\n case \"GO_BACK\":\n case \"POP\":\n case \"POP_TO_TOP\":\n message += `\n\nIs there any screen to go back to?`;\n break;\n case \"OPEN_DRAWER\":\n case \"CLOSE_DRAWER\":\n case \"TOGGLE_DRAWER\":\n message += `\n\nIs your screen inside a Drawer navigator?`;\n break;\n }\n message += `\n\nThis is a development-only warning and won't be shown in production.`;\n if (process.env.NODE_ENV === \"test\") {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = function onUnhandledAction2() {\n };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MAAM;KAClE,WAAW;;6BAEQ,QAAQ,KAAK;IAClC,OAAO;KACL,WAAW;;;IAGb;IACA;GACF,KAAK;GACL,KAAK;GACL,KAAK;IACH,WAAW;;;IAGX;GACF,KAAK;GACL,KAAK;GACL,KAAK;IACH,WAAW;;;IAGX;EACJ;EACA,WAAW;;;EAGX,IAAI,QAAQ,IAAI,aAAa,QAAQ;GACnC,MAAM,IAAI,MAAM,OAAO;EACzB;EACA,QAAQ,MAAM,OAAO;CACvB;AACF,OAAO;CACL,oBAAoB,SAAS,qBAAqB,CAClD;AACF"}
|
|
1
|
+
{"version":3,"file":"Root.native.js","names":["UpstreamNavigationContainer","_Fragment"],"sources":["esm/Root.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { DarkTheme, DefaultTheme } from \"./fork/theme\";\nimport { useUserScheme } from \"@vxrn/color-scheme\";\nimport { createContext, StrictMode, useContext, useId, useLayoutEffect, useState } from \"react\";\nimport { SERVER_CONTEXT_KEY, isNative } from \"./constants\";\nimport { initScreensFeatureFlags } from \"./screensFeatureFlags\";\nimport { SpaShellContext } from \"./router/SpaShellContext\";\nimport { NavigationContainer as UpstreamNavigationContainer } from \"./fork/NavigationContainer\";\nimport { getURL } from \"./getURL\";\nimport { FlagsContext } from \"./router/FlagsContext\";\nimport { getResolvedLinking } from \"./router/linkingConfig\";\nimport { handleNavigationContainerStateChange } from \"./router/router\";\nimport { ServerLocationContext } from \"./router/serverLocationContext\";\nimport { useInitializeOneRouter } from \"./router/useInitializeOneRouter\";\nimport { useViteRoutes } from \"./router/useViteRoutes\";\nimport { evictOldest } from \"./utils/evictOldest\";\nimport { ServerRenderID } from \"./useServerHeadInsertion\";\nimport { PreloadLinks } from \"./views/PreloadLinks\";\nimport { SafeAreaProvider, initialWindowMetrics } from \"./safe-area-context\";\nimport { RootErrorBoundary } from \"./views/RootErrorBoundary\";\nimport { ScrollBehavior } from \"./views/ScrollBehavior\";\nvar ssrLocationCache = /* @__PURE__ */ new Map();\nfunction getCachedSSRLocation(path) {\n var url = ssrLocationCache.get(path);\n if (url) return url;\n url = new URL(path, getURL());\n evictOldest(ssrLocationCache, 5e3, 1e3);\n ssrLocationCache.set(path, url);\n return url;\n}\nvar ServerAsyncLocalIDContext = /* @__PURE__ */ createContext(null);\nfunction Root(props) {\n var _globalThis___vxrnrequestAsyncLocalStore;\n globalThis[\"__vxrnGetContextFromReactContext\"] = function() {\n return useContext(ServerAsyncLocalIDContext);\n };\n if (isNative) {\n initScreensFeatureFlags();\n }\n var { path, routes, routeOptions, isClient, navigationContainerProps, onRenderId, linking } = props;\n var context = useViteRoutes(routes, props.routerRoot, routeOptions, globalThis[\"__vxrnVersion\"]);\n var location = isNative ? void 0 : typeof window !== \"undefined\" && window.location ? new URL(path || window.location.href || \"/\", window.location.href) : getCachedSSRLocation(path || \"/\");\n var store = useInitializeOneRouter(context, location, linking);\n var userScheme = useUserScheme();\n var Component = store.rootComponent;\n if (!Component) {\n throw new Error(`No root component found`);\n }\n var id = useId();\n onRenderId === null || onRenderId === void 0 ? void 0 : onRenderId(id);\n var value = process.env.VERCEL ? globalThis[\"__oneGlobalContextId\"] : ((_globalThis___vxrnrequestAsyncLocalStore = globalThis[\"__vxrnrequestAsyncLocalStore\"]) === null || _globalThis___vxrnrequestAsyncLocalStore === void 0 ? void 0 : _globalThis___vxrnrequestAsyncLocalStore.getStore()) || null;\n var deferredPreloads = props.deferredPreloads;\n var contents = /* @__PURE__ */ _jsx(ServerAsyncLocalIDContext.Provider, {\n value,\n children: /* @__PURE__ */ _jsxs(ServerRenderID.Provider, {\n value: id,\n children: [\n typeof window === \"undefined\" && (deferredPreloads === null || deferredPreloads === void 0 ? void 0 : deferredPreloads.map(function(src) {\n return /* @__PURE__ */ _jsx(\"link\", {\n rel: \"modulepreload\",\n fetchPriority: \"low\",\n href: src\n }, src);\n })),\n /* one owns the safe area provider on every platform: apps read it\n through One.UI.SafeArea and never mount their own */\n /* @__PURE__ */ _jsx(SafeAreaProvider, {\n initialMetrics: initialWindowMetrics,\n children: /* @__PURE__ */ _jsx(UpstreamNavigationContainer, {\n ref: store.navigationRef,\n initialState: store.initialState,\n linking: getResolvedLinking(),\n onUnhandledAction,\n onStateChange: handleNavigationContainerStateChange,\n theme: userScheme.value === \"dark\" ? DarkTheme : DefaultTheme,\n documentTitle: {\n enabled: false\n },\n ...navigationContainerProps,\n children: /* @__PURE__ */ _jsx(ServerLocationContext.Provider, {\n value: location,\n children: /* @__PURE__ */ _jsxs(_Fragment, {\n children: [\n /* @__PURE__ */ _jsx(ScrollBehavior, {}),\n /* @__PURE__ */ _jsx(RootErrorBoundary, {\n children: /* @__PURE__ */ _jsx(Component, {})\n })\n ]\n })\n })\n })\n }),\n typeof window !== \"undefined\" && /* @__PURE__ */ _jsx(PreloadLinks, {}, \"preload-links\")\n ]\n })\n });\n if (props.flags) {\n contents = /* @__PURE__ */ _jsx(FlagsContext.Provider, {\n value: props.flags,\n children: contents\n });\n }\n if (!process.env.ONE_DISABLE_STRICT_MODE) {\n contents = /* @__PURE__ */ _jsx(StrictMode, {\n children: contents\n });\n }\n if (isClient) {\n var _globalThis_SERVER_CONTEXT_KEY;\n var serverMode = (_globalThis_SERVER_CONTEXT_KEY = globalThis[SERVER_CONTEXT_KEY]) === null || _globalThis_SERVER_CONTEXT_KEY === void 0 ? void 0 : _globalThis_SERVER_CONTEXT_KEY.mode;\n if (serverMode === \"spa\") {\n var [show, setShow] = useState(false);\n useLayoutEffect(function() {\n setShow(true);\n }, []);\n return show ? contents : null;\n }\n if (serverMode === \"spa-shell\") {\n var [isSpaShell, setIsSpaShell] = useState(true);\n useLayoutEffect(function() {\n setIsSpaShell(false);\n }, []);\n useLayoutEffect(function() {\n if (!isSpaShell) {\n var initialPath = window.location.pathname + window.location.search;\n requestAnimationFrame(function() {\n var _store_navigationRef;\n if (window.location.pathname + window.location.search !== initialPath) return;\n var nav = (_store_navigationRef = store.navigationRef) === null || _store_navigationRef === void 0 ? void 0 : _store_navigationRef.current;\n if (!nav) return;\n var linking2 = getResolvedLinking();\n if (linking2 === null || linking2 === void 0 ? void 0 : linking2.getStateFromPath) {\n var freshState = linking2.getStateFromPath(initialPath, linking2.config);\n if (freshState) {\n nav.resetRoot(freshState);\n }\n }\n });\n }\n }, [\n isSpaShell\n ]);\n return /* @__PURE__ */ _jsx(SpaShellContext.Provider, {\n value: isSpaShell,\n children: contents\n });\n }\n return contents;\n }\n if (props.mode === \"spa-shell\") {\n return /* @__PURE__ */ _jsx(SpaShellContext.Provider, {\n value: true,\n children: contents\n });\n }\n return contents;\n}\nvar onUnhandledAction;\nif (process.env.NODE_ENV !== \"production\") {\n onUnhandledAction = function onUnhandledAction2(action) {\n var payload = action.payload;\n var message = `The action '${action.type}'${payload ? ` with payload ${JSON.stringify(action.payload)}` : \"\"} was not handled by any navigator.`;\n switch (action.type) {\n case \"NAVIGATE\":\n case \"PUSH\":\n case \"REPLACE\":\n case \"JUMP_TO\":\n if (payload === null || payload === void 0 ? void 0 : payload.name) {\n message += `\n\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\n\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n break;\n case \"GO_BACK\":\n case \"POP\":\n case \"POP_TO_TOP\":\n message += `\n\nIs there any screen to go back to?`;\n break;\n case \"OPEN_DRAWER\":\n case \"CLOSE_DRAWER\":\n case \"TOGGLE_DRAWER\":\n message += `\n\nIs your screen inside a Drawer navigator?`;\n break;\n }\n message += `\n\nThis is a development-only warning and won't be shown in production.`;\n if (process.env.NODE_ENV === \"test\") {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = function onUnhandledAction2() {\n };\n}\nexport {\n Root\n};\n//# sourceMappingURL=Root.js.map\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAI,mCAAmC,IAAI,IAAI;AAC/C,SAAS,qBAAqB,MAAM;CAClC,IAAI,MAAM,iBAAiB,IAAI,IAAI;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;EACJ;EACA,WAAW;;;EAGX,IAAI,QAAQ,IAAI,aAAa,QAAQ;GACnC,MAAM,IAAI,MAAM,OAAO;EACzB;EACA,QAAQ,MAAM,OAAO;CACvB;AACF,OAAO;CACL,oBAAoB,SAAS,qBAAqB,CAClD;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "one",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.7",
|
|
4
4
|
"description": "One is a React framework for web, iOS, and Android apps.",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"sideEffects": [
|
|
@@ -236,18 +236,18 @@
|
|
|
236
236
|
"@react-navigation/native-stack": "8.0.0-alpha.59",
|
|
237
237
|
"@react-navigation/routers": "8.0.0-alpha.21",
|
|
238
238
|
"@ungap/structured-clone": "^1.2.0",
|
|
239
|
-
"@vxrn/color-scheme": "2.7.
|
|
240
|
-
"@vxrn/compiler": "2.7.
|
|
241
|
-
"@vxrn/resolve": "2.7.
|
|
242
|
-
"@vxrn/tslib-lite": "2.7.
|
|
243
|
-
"@vxrn/use-isomorphic-layout-effect": "2.7.
|
|
244
|
-
"@vxrn/utils": "2.7.
|
|
245
|
-
"@vxrn/vite-plugin-metro": "2.7.
|
|
239
|
+
"@vxrn/color-scheme": "2.7.7",
|
|
240
|
+
"@vxrn/compiler": "2.7.7",
|
|
241
|
+
"@vxrn/resolve": "2.7.7",
|
|
242
|
+
"@vxrn/tslib-lite": "2.7.7",
|
|
243
|
+
"@vxrn/use-isomorphic-layout-effect": "2.7.7",
|
|
244
|
+
"@vxrn/utils": "2.7.7",
|
|
245
|
+
"@vxrn/vite-plugin-metro": "2.7.7",
|
|
246
246
|
"babel-dead-code-elimination": "1.0.10",
|
|
247
247
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
248
248
|
"citty": "^0.1.6",
|
|
249
249
|
"core-js": "^3.38.1",
|
|
250
|
-
"create-vxrn": "2.7.
|
|
250
|
+
"create-vxrn": "2.7.7",
|
|
251
251
|
"escape-string-regexp": "^5.0.0",
|
|
252
252
|
"fast-deep-equal": "^3.1.3",
|
|
253
253
|
"fast-glob": "^3.3.3",
|
|
@@ -269,7 +269,7 @@
|
|
|
269
269
|
"tsconfig-paths": "^4",
|
|
270
270
|
"use-latest-callback": "^0.2.3",
|
|
271
271
|
"vite": "^8.2.2",
|
|
272
|
-
"vxrn": "2.7.
|
|
272
|
+
"vxrn": "2.7.7",
|
|
273
273
|
"web-streams-polyfill": "^4.3.0",
|
|
274
274
|
"ws": "^8.21.0",
|
|
275
275
|
"xxhashjs": "^0.2.2"
|
|
@@ -325,19 +325,19 @@
|
|
|
325
325
|
}
|
|
326
326
|
},
|
|
327
327
|
"devDependencies": {
|
|
328
|
-
"@tamagui/sheet": "3.0.
|
|
328
|
+
"@tamagui/sheet": "3.0.17",
|
|
329
329
|
"@callstack/liquid-glass": "^0.8.1",
|
|
330
330
|
"@react-native/babel-plugin-codegen": "0.87.1",
|
|
331
331
|
"@react-native/codegen": "^0.87.1",
|
|
332
332
|
"@react-navigation/core": "8.0.0-alpha.41",
|
|
333
333
|
"@react-navigation/drawer": "8.0.0-alpha.58",
|
|
334
334
|
"@react-navigation/native": "8.0.0-alpha.51",
|
|
335
|
-
"@tamagui/build": "3.0.
|
|
335
|
+
"@tamagui/build": "3.0.17",
|
|
336
336
|
"@types/node": "^24.10.0",
|
|
337
337
|
"@types/react-dom": "^19.2.2",
|
|
338
338
|
"@types/react-test-renderer": "^19.1.0",
|
|
339
339
|
"@types/xxhashjs": "^0.2.4",
|
|
340
|
-
"@vxrn/emitter": "2.7.
|
|
340
|
+
"@vxrn/emitter": "2.7.7",
|
|
341
341
|
"depcheck": "^1.4.7",
|
|
342
342
|
"esbuild": "^0.25.12",
|
|
343
343
|
"immer": "^10.1.1",
|
|
@@ -356,7 +356,7 @@
|
|
|
356
356
|
"typescript": "7.0.2",
|
|
357
357
|
"vitest": "^4.1.0",
|
|
358
358
|
"yoga-layout": "^3.2.1",
|
|
359
|
-
"@tamagui/web": "3.0.
|
|
359
|
+
"@tamagui/web": "3.0.17"
|
|
360
360
|
},
|
|
361
361
|
"publishConfig": {
|
|
362
362
|
"access": "public"
|
|
@@ -513,7 +513,7 @@
|
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
},
|
|
516
|
-
"releaseSourceCommit": "
|
|
516
|
+
"releaseSourceCommit": "2335a80d570e794536b7bb62b023bb73ec1e4d59",
|
|
517
517
|
"repository": {
|
|
518
518
|
"type": "git",
|
|
519
519
|
"url": "git+https://github.com/onejs/one.git",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import TestRenderer, { act } from 'react-test-renderer'
|
|
3
|
+
import { expect, it } from 'vitest'
|
|
4
|
+
import { Root } from './Root'
|
|
5
|
+
import { Slot } from './views/Navigator'
|
|
6
|
+
|
|
7
|
+
;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
|
|
8
|
+
|
|
9
|
+
it('uses the rendering root context after another environment evaluates One', async () => {
|
|
10
|
+
const previousReader = globalThis['__vxrnGetContextFromReactContext']
|
|
11
|
+
const previousStore = globalThis['__vxrnrequestAsyncLocalStore']
|
|
12
|
+
const previousVersion = globalThis['__vxrnVersion']
|
|
13
|
+
const id = { _id: 1 }
|
|
14
|
+
const observed: unknown[] = []
|
|
15
|
+
globalThis['__vxrnrequestAsyncLocalStore'] = { getStore: () => id }
|
|
16
|
+
globalThis['__vxrnGetContextFromReactContext'] = () => {
|
|
17
|
+
throw new Error('context reader from another React runtime')
|
|
18
|
+
}
|
|
19
|
+
function Page() {
|
|
20
|
+
observed.push(globalThis['__vxrnGetContextFromReactContext']())
|
|
21
|
+
return 'ready'
|
|
22
|
+
}
|
|
23
|
+
function Layout() {
|
|
24
|
+
return <Slot />
|
|
25
|
+
}
|
|
26
|
+
globalThis['__vxrnVersion'] = ((globalThis['__vxrnVersion'] as number) ?? 0) + 1
|
|
27
|
+
let renderer: TestRenderer.ReactTestRenderer | undefined
|
|
28
|
+
try {
|
|
29
|
+
await act(async () => {
|
|
30
|
+
renderer = TestRenderer.create(
|
|
31
|
+
<Root
|
|
32
|
+
path="/"
|
|
33
|
+
routerRoot="app"
|
|
34
|
+
isClient={false}
|
|
35
|
+
routes={
|
|
36
|
+
{
|
|
37
|
+
'/app/_layout.tsx': { default: Layout },
|
|
38
|
+
'/app/index.tsx': { default: Page },
|
|
39
|
+
} as any
|
|
40
|
+
}
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
expect(observed.length).toBeGreaterThan(0)
|
|
45
|
+
expect(observed.every((value) => value === id)).toBe(true)
|
|
46
|
+
} finally {
|
|
47
|
+
if (renderer) await act(async () => renderer!.unmount())
|
|
48
|
+
globalThis['__vxrnGetContextFromReactContext'] = previousReader
|
|
49
|
+
globalThis['__vxrnrequestAsyncLocalStore'] = previousStore
|
|
50
|
+
globalThis['__vxrnVersion'] = previousVersion
|
|
51
|
+
}
|
|
52
|
+
})
|
package/src/Root.tsx
CHANGED
|
@@ -78,10 +78,12 @@ type InnerProps = {
|
|
|
78
78
|
// we bridge it to react because reacts weird rendering loses it
|
|
79
79
|
const ServerAsyncLocalIDContext = createContext<One.ServerContext | null>(null)
|
|
80
80
|
|
|
81
|
-
globalThis['__vxrnGetContextFromReactContext'] = () =>
|
|
82
|
-
useContext(ServerAsyncLocalIDContext)
|
|
83
|
-
|
|
84
81
|
export function Root(props: RootProps) {
|
|
82
|
+
// other vite environments can evaluate one with a different react instance.
|
|
83
|
+
// install the reader from the root that is actually rendering.
|
|
84
|
+
globalThis['__vxrnGetContextFromReactContext'] = () =>
|
|
85
|
+
useContext(ServerAsyncLocalIDContext)
|
|
86
|
+
|
|
85
87
|
// enable synchronous screen updates on native for proper layout behavior
|
|
86
88
|
if (isNative) {
|
|
87
89
|
initScreensFeatureFlags()
|
package/types/Root.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
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