one 2.17.1 → 2.17.3

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.
Files changed (38) hide show
  1. package/android/src/maps/java/dev/onejs/onenative/OneNativeUiMapView.kt +23 -0
  2. package/dist/cjs/router/useViteRoutes.cjs +6 -2
  3. package/dist/cjs/router/useViteRoutes.native.cjs +6 -2
  4. package/dist/cjs/router/useViteRoutes.native.js +6 -2
  5. package/dist/cjs/router/useViteRoutes.native.js.map +1 -1
  6. package/dist/esm/router/useViteRoutes.mjs +6 -2
  7. package/dist/esm/router/useViteRoutes.mjs.map +1 -1
  8. package/dist/esm/router/useViteRoutes.native.js +6 -2
  9. package/dist/esm/router/useViteRoutes.native.js.map +1 -1
  10. package/ios/OneNativeStyle.swift +8 -0
  11. package/metro-entry.js +1 -1
  12. package/package.json +16 -16
  13. package/src/layouts/Drawer.tsx +19 -3
  14. package/src/layouts/Stack.tsx +3 -2
  15. package/src/layouts/Tabs.tsx +22 -3
  16. package/src/layouts/stack-utils/StackScreen.tsx +9 -5
  17. package/src/layouts/withLayoutContext.tsx +27 -1
  18. package/src/router/useScreens.tsx +3 -1
  19. package/src/router/useViteRoutes.test.ts +9 -0
  20. package/src/router/useViteRoutes.tsx +8 -2
  21. package/src/types.ts +1 -1
  22. package/types/layouts/Drawer.d.ts +10 -2
  23. package/types/layouts/Drawer.d.ts.map +1 -1
  24. package/types/layouts/Drawer.web.d.ts +1 -1
  25. package/types/layouts/Stack.d.ts +4 -3
  26. package/types/layouts/Stack.d.ts.map +1 -1
  27. package/types/layouts/Tabs.d.ts +11 -2
  28. package/types/layouts/Tabs.d.ts.map +1 -1
  29. package/types/layouts/Tabs.linux.d.ts +4 -4
  30. package/types/layouts/stack-utils/StackScreen.d.ts +3 -1
  31. package/types/layouts/stack-utils/StackScreen.d.ts.map +1 -1
  32. package/types/layouts/withLayoutContext.d.ts +13 -1
  33. package/types/layouts/withLayoutContext.d.ts.map +1 -1
  34. package/types/router/useScreens.d.ts +4 -1
  35. package/types/router/useScreens.d.ts.map +1 -1
  36. package/types/router/useViteRoutes.d.ts.map +1 -1
  37. package/types/types.d.ts +1 -1
  38. package/types/types.d.ts.map +1 -1
@@ -305,9 +305,32 @@ class OneNativeUiMapView(context: Context) : FrameLayout(context) {
305
305
  }
306
306
  }
307
307
 
308
+ // fabric measures a view in the batch that creates it, before its screen
309
+ // joins the window, and a ComposeView throws when measured off-window.
310
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
311
+ setMeasuredDimension(
312
+ MeasureSpec.getSize(widthMeasureSpec),
313
+ MeasureSpec.getSize(heightMeasureSpec),
314
+ )
315
+ }
316
+
317
+ override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
318
+ layoutComposeContent()
319
+ }
320
+
308
321
  override fun onAttachedToWindow() {
309
322
  super.onAttachedToWindow()
310
323
  ensureLifecycleOwner()
324
+ post { layoutComposeContent() }
325
+ }
326
+
327
+ private fun layoutComposeContent() {
328
+ if (!composeView.isAttachedToWindow || width <= 0 || height <= 0) return
329
+ composeView.measure(
330
+ MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
331
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
332
+ )
333
+ composeView.layout(0, 0, width, height)
311
334
  }
312
335
 
313
336
  // maps-compose reads the lifecycle owner off the view tree, which react
@@ -179,9 +179,13 @@ function globbedRoutesToRouteContext(paths, routerRoot, options) {
179
179
  if (!promises[id]) {
180
180
  let importPromise;
181
181
  if (process.env.NODE_ENV === "development" && hmrVersion > 0 && routePaths[id]) {
182
- importPromise = import_constants.isNative ? routesSync[id]().then(() => (0, import_hmrImport.hmrImport)(routePaths[id])) : (0, import_hmrImport.hmrImport)(routePaths[id]);
182
+ importPromise = import_constants.isNative ? Promise.resolve(routesSync[id]()).then(() => (0, import_hmrImport.hmrImport)(routePaths[id])) : (0, import_hmrImport.hmrImport)(routePaths[id]);
183
183
  } else {
184
- importPromise = routesSync[id]();
184
+ const loaded = routesSync[id]();
185
+ if (!(loaded instanceof Promise)) {
186
+ return loaded;
187
+ }
188
+ importPromise = loaded;
185
189
  }
186
190
  promises[id] = importPromise.then((val) => {
187
191
  loadedRoutes[id] = val;
@@ -225,11 +225,15 @@ function globbedRoutesToRouteContext(paths, routerRoot, options) {
225
225
  if (!promises[id]) {
226
226
  var importPromise;
227
227
  if (process.env.NODE_ENV === "development" && hmrVersion > 0 && routePaths[id]) {
228
- importPromise = import_constants.isNative ? routesSync[id]().then(function() {
228
+ importPromise = import_constants.isNative ? Promise.resolve(routesSync[id]()).then(function() {
229
229
  return (0, import_hmrImport.hmrImport)(routePaths[id]);
230
230
  }) : (0, import_hmrImport.hmrImport)(routePaths[id]);
231
231
  } else {
232
- importPromise = routesSync[id]();
232
+ var loaded = routesSync[id]();
233
+ if (!(loaded instanceof Promise)) {
234
+ return loaded;
235
+ }
236
+ importPromise = loaded;
233
237
  }
234
238
  promises[id] = importPromise.then(function(val) {
235
239
  loadedRoutes[id] = val;
@@ -225,11 +225,15 @@ function globbedRoutesToRouteContext(paths, routerRoot, options) {
225
225
  if (!promises[id]) {
226
226
  var importPromise;
227
227
  if (process.env.NODE_ENV === "development" && hmrVersion > 0 && routePaths[id]) {
228
- importPromise = import_constants.isNative ? routesSync[id]().then(function() {
228
+ importPromise = import_constants.isNative ? Promise.resolve(routesSync[id]()).then(function() {
229
229
  return (0, import_hmrImport.hmrImport)(routePaths[id]);
230
230
  }) : (0, import_hmrImport.hmrImport)(routePaths[id]);
231
231
  } else {
232
- importPromise = routesSync[id]();
232
+ var loaded = routesSync[id]();
233
+ if (!(loaded instanceof Promise)) {
234
+ return loaded;
235
+ }
236
+ importPromise = loaded;
233
237
  }
234
238
  promises[id] = importPromise.then(function(val) {
235
239
  loadedRoutes[id] = val;
@@ -1 +1 @@
1
- {"version":3,"file":"useViteRoutes.native.js","names":[],"sources":["cjs/router/useViteRoutes.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 useViteRoutes_exports = {};\n__export(useViteRoutes_exports, {\n getPreloadedModule: () => getPreloadedModule,\n getPreloadedModuleKeys: () => getPreloadedModuleKeys,\n globbedRoutesToRouteContext: () => globbedRoutesToRouteContext,\n loadRoutes: () => loadRoutes,\n preloadRouteModules: () => preloadRouteModules,\n registerPreloadedRoute: () => registerPreloadedRoute,\n useViteRoutes: () => useViteRoutes\n});\nmodule.exports = __toCommonJS(useViteRoutes_exports);\nvar import_constants = require(\"../constants\");\nvar import_dynamicImport = require(\"../utils/dynamicImport\");\nvar import_diagnoseRouteLoadFailure = require(\"./diagnoseRouteLoadFailure\");\nvar import_hmrImport = require(\"./hmrImport\");\nvar lastVersion = 0;\nvar context;\nfunction useViteRoutes(routes, routerRoot, options, version) {\n if (version && version > lastVersion) {\n context = null;\n lastVersion = version;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.keys(preloadedModules)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n delete preloadedModules[key];\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n if (!context) {\n loadRoutes(routes, routerRoot, options);\n }\n return context;\n}\nvar preloadedModules = {};\nfunction registerPreloadedRoute(key, module2) {\n preloadedModules[key] = module2;\n}\nfunction getPreloadedModule(key) {\n return preloadedModules[key];\n}\nfunction getPreloadedModuleKeys() {\n return Object.keys(preloadedModules);\n}\nfunction matchDynamicRoute(routePattern, actualPath) {\n var routeSegments = routePattern.split(\"/\");\n var pathSegments = actualPath.split(\"/\");\n var hasCatchAll = routeSegments.some(function(s) {\n return s.startsWith(\"[...\");\n });\n if (hasCatchAll) {\n var catchAllIdx = routeSegments.findIndex(function(s) {\n return s.startsWith(\"[...\");\n });\n for (var i = 0; i < catchAllIdx; i++) {\n if (!routeSegments[i]) continue;\n if (routeSegments[i].startsWith(\"[\")) continue;\n if (routeSegments[i] !== pathSegments[i]) return false;\n }\n return pathSegments.length >= catchAllIdx;\n }\n if (routeSegments.length !== pathSegments.length) return false;\n for (var i1 = 0; i1 < routeSegments.length; i1++) {\n var routeSeg = routeSegments[i1];\n var pathSeg = pathSegments[i1];\n if (routeSeg.startsWith(\"[\") && routeSeg.endsWith(\"]\")) {\n continue;\n }\n if (routeSeg !== pathSeg) return false;\n }\n return true;\n}\nasync function preloadRouteModules(href) {\n var globbed = globalThis[\"__importMetaGlobbed\"];\n if (!globbed) return;\n var normalizedHref = href === \"/\" ? \"\" : href.replace(/^\\//, \"\").replace(/\\/$/, \"\");\n var promises = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n var _loop = function() {\n var key = _step.value;\n var routePath = key.replace(/^\\/[^/]+\\//, \"\");\n routePath = routePath.replace(/\\([^)]+\\)\\//g, \"\");\n routePath = routePath.replace(/\\/_layout\\.tsx$/, \"\").replace(/\\/index(\\+[a-z]+)?\\.tsx$/, \"\").replace(/(\\+[a-z]+)?\\.tsx$/, \"\");\n routePath = routePath.replace(/^\\//, \"\");\n var isStaticMatch = routePath === normalizedHref || // exact match\n routePath.startsWith(normalizedHref + \"/\") || // child route\n normalizedHref.startsWith(routePath + \"/\") || // parent layout\n routePath === \"\" || // root layout\n normalizedHref !== \"\" && routePath === normalizedHref.split(\"/\")[0];\n var isDynamicMatch = routePath.includes(\"[\") && matchDynamicRoute(routePath, normalizedHref);\n if ((isStaticMatch || isDynamicMatch) && typeof globbed[key] === \"function\") {\n promises.push(globbed[key]().then(function(mod) {\n preloadedModules[key] = mod;\n }));\n }\n };\n for (var _iterator = Object.keys(globbed)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n await Promise.all(promises);\n}\nfunction loadRoutes(paths, routerRoot, options) {\n if (context) return context;\n globalThis[\"__importMetaGlobbed\"] = paths;\n context = globbedRoutesToRouteContext(paths, routerRoot, options);\n return context;\n}\nfunction globbedRoutesToRouteContext(paths, routerRoot, options) {\n var routesSync = {};\n var routePaths = {};\n var promises = {};\n var loadedRoutes = {};\n var clears = {};\n Object.keys(paths).forEach(function(path) {\n var _options_routeModes;\n if (!paths[path]) {\n console.error(`Error: Missing route at path ${path}`);\n return;\n }\n var loadRouteFunction = paths[path];\n var pathWithoutRelative = path.replace(`/${routerRoot}/`, \"./\");\n var originalPath = pathWithoutRelative.slice(1).replace(/\\.[jt]sx?$/, \"\");\n if ((options === null || options === void 0 ? void 0 : (_options_routeModes = options.routeModes) === null || _options_routeModes === void 0 ? void 0 : _options_routeModes[originalPath]) === \"spa\") {\n console.info(`Spa mode: ${originalPath}`);\n loadedRoutes[pathWithoutRelative] = function() {\n return null;\n };\n } else {\n routesSync[pathWithoutRelative] = loadRouteFunction;\n routePaths[pathWithoutRelative] = path;\n }\n });\n var moduleKeys = Object.keys(routesSync);\n var hmrVersion = 0;\n if (typeof window !== \"undefined\") {\n ;\n window.__oneRouteCache = {\n clear: function clear() {\n hmrVersion++;\n Object.keys(loadedRoutes).forEach(function(key) {\n delete loadedRoutes[key];\n });\n Object.keys(promises).forEach(function(key) {\n delete promises[key];\n });\n Object.keys(preloadedModules).forEach(function(key) {\n delete preloadedModules[key];\n });\n },\n clearFile: function clearFile(file) {\n var normalizedFile = file.replace(/\\\\/g, \"/\").replace(/^\\//, \"\");\n var routeId = moduleKeys.find(function(key) {\n return routePaths[key].replace(/\\\\/g, \"/\").replace(/^\\//, \"\") === normalizedFile;\n });\n if (!routeId) return false;\n hmrVersion++;\n delete loadedRoutes[routeId];\n delete promises[routeId];\n delete preloadedModules[routePaths[routeId]];\n return true;\n },\n getVersion: function getVersion() {\n return hmrVersion;\n }\n };\n }\n function resolve(id) {\n clearTimeout(clears[id]);\n if (loadedRoutes[id]) {\n return loadedRoutes[id];\n }\n var preloadKey = id.replace(\"./\", `/${routerRoot}/`);\n var preloaded = getPreloadedModule(preloadKey);\n if (preloaded) {\n loadedRoutes[id] = preloaded;\n return preloaded;\n }\n if (typeof routesSync[id] !== \"function\") {\n return routesSync[id];\n }\n if (!promises[id]) {\n var importPromise;\n if (process.env.NODE_ENV === \"development\" && hmrVersion > 0 && routePaths[id]) {\n importPromise = import_constants.isNative ? routesSync[id]().then(function() {\n return (0, import_hmrImport.hmrImport)(routePaths[id]);\n }) : (0, import_hmrImport.hmrImport)(routePaths[id]);\n } else {\n importPromise = routesSync[id]();\n }\n promises[id] = importPromise.then(function(val) {\n loadedRoutes[id] = val;\n delete promises[id];\n if (process.env.NODE_ENV === \"development\") {\n clears[id] = setTimeout(function() {\n delete loadedRoutes[id];\n }, 500);\n }\n return val;\n }).catch(function(err) {\n console.error(`Error loading route`, id, err, new Error().stack);\n var reloading = (0, import_dynamicImport.isChunkLoadError)(err) && (0, import_dynamicImport.handleSkewError)();\n if (process.env.NODE_ENV === \"development\") {\n var _globalThis___oneReportRouteLoadError, _globalThis;\n ;\n (_globalThis___oneReportRouteLoadError = (_globalThis = globalThis).__oneReportRouteLoadError) === null || _globalThis___oneReportRouteLoadError === void 0 ? void 0 : _globalThis___oneReportRouteLoadError.call(_globalThis, {\n id,\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : void 0\n });\n if (import_constants.hasWebHistory && routePaths[id] && !reloading) {\n (0, import_diagnoseRouteLoadFailure.diagnoseRouteLoadFailure)(id, routePaths[id]).then(function(message) {\n if (message) console.error(message);\n }).catch(function() {\n });\n }\n }\n loadedRoutes[id] = {\n default: function _default() {\n return null;\n }\n };\n delete promises[id];\n });\n if (process.env.NODE_ENV === \"development\") {\n promises[id].stack = new Error().stack;\n }\n }\n throw promises[id];\n }\n resolve.keys = function() {\n return moduleKeys;\n };\n resolve.id = \"\";\n resolve.resolve = function(id) {\n return id;\n };\n return resolve;\n}\n//# sourceMappingURL=useViteRoutes.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,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GA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C,cAAc,WAAU,CAAE,+BAA+B,QAAQ,0CAA0C,KAAK,IAAI,KAAK,IAAI,sCAAsC,KAAK,aAAa;MAC7N;MACA,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;MACxD,OAAO,eAAe,QAAQ,IAAI,QAAQ,KAAK;KACjD,CAAC;KACD,IAAI,iBAAiB,iBAAiB,WAAW,OAAO,CAAC,WAAW;MAClE,CAAC,GAAG,gCAAgC,yBAAwB,CAAE,IAAI,WAAW,GAAG,CAAC,CAAC,KAAK,SAAS,SAAS;OACvG,IAAI,SAAS,QAAQ,MAAM,OAAO;MACpC,CAAC,CAAC,CAAC,MAAM,WAAW,CACpB,CAAC;KACH;IACF;IACA,aAAa,MAAM,EACjB,SAAS,SAAS,WAAW;KAC3B,OAAO;IACT,EACF;IACA,OAAO,SAAS;GAClB,CAAC;GACD,IAAI,QAAQ,IAAI,aAAa,eAAe;IAC1C,SAAS,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;GACnC;EACF;EACA,MAAM,SAAS;CACjB;CACA,QAAQ,OAAO,WAAW;EACxB,OAAO;CACT;CACA,QAAQ,KAAK;CACb,QAAQ,UAAU,SAAS,IAAI;EAC7B,OAAO;CACT;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"useViteRoutes.native.js","names":[],"sources":["cjs/router/useViteRoutes.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 useViteRoutes_exports = {};\n__export(useViteRoutes_exports, {\n getPreloadedModule: () => getPreloadedModule,\n getPreloadedModuleKeys: () => getPreloadedModuleKeys,\n globbedRoutesToRouteContext: () => globbedRoutesToRouteContext,\n loadRoutes: () => loadRoutes,\n preloadRouteModules: () => preloadRouteModules,\n registerPreloadedRoute: () => registerPreloadedRoute,\n useViteRoutes: () => useViteRoutes\n});\nmodule.exports = __toCommonJS(useViteRoutes_exports);\nvar import_constants = require(\"../constants\");\nvar import_dynamicImport = require(\"../utils/dynamicImport\");\nvar import_diagnoseRouteLoadFailure = require(\"./diagnoseRouteLoadFailure\");\nvar import_hmrImport = require(\"./hmrImport\");\nvar lastVersion = 0;\nvar context;\nfunction useViteRoutes(routes, routerRoot, options, version) {\n if (version && version > lastVersion) {\n context = null;\n lastVersion = version;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.keys(preloadedModules)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n delete preloadedModules[key];\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n if (!context) {\n loadRoutes(routes, routerRoot, options);\n }\n return context;\n}\nvar preloadedModules = {};\nfunction registerPreloadedRoute(key, module2) {\n preloadedModules[key] = module2;\n}\nfunction getPreloadedModule(key) {\n return preloadedModules[key];\n}\nfunction getPreloadedModuleKeys() {\n return Object.keys(preloadedModules);\n}\nfunction matchDynamicRoute(routePattern, actualPath) {\n var routeSegments = routePattern.split(\"/\");\n var pathSegments = actualPath.split(\"/\");\n var hasCatchAll = routeSegments.some(function(s) {\n return s.startsWith(\"[...\");\n });\n if (hasCatchAll) {\n var catchAllIdx = routeSegments.findIndex(function(s) {\n return s.startsWith(\"[...\");\n });\n for (var i = 0; i < catchAllIdx; i++) {\n if (!routeSegments[i]) continue;\n if (routeSegments[i].startsWith(\"[\")) continue;\n if (routeSegments[i] !== pathSegments[i]) return false;\n }\n return pathSegments.length >= catchAllIdx;\n }\n if (routeSegments.length !== pathSegments.length) return false;\n for (var i1 = 0; i1 < routeSegments.length; i1++) {\n var routeSeg = routeSegments[i1];\n var pathSeg = pathSegments[i1];\n if (routeSeg.startsWith(\"[\") && routeSeg.endsWith(\"]\")) {\n continue;\n }\n if (routeSeg !== pathSeg) return false;\n }\n return true;\n}\nasync function preloadRouteModules(href) {\n var globbed = globalThis[\"__importMetaGlobbed\"];\n if (!globbed) return;\n var normalizedHref = href === \"/\" ? \"\" : href.replace(/^\\//, \"\").replace(/\\/$/, \"\");\n var promises = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n var _loop = function() {\n var key = _step.value;\n var routePath = key.replace(/^\\/[^/]+\\//, \"\");\n routePath = routePath.replace(/\\([^)]+\\)\\//g, \"\");\n routePath = routePath.replace(/\\/_layout\\.tsx$/, \"\").replace(/\\/index(\\+[a-z]+)?\\.tsx$/, \"\").replace(/(\\+[a-z]+)?\\.tsx$/, \"\");\n routePath = routePath.replace(/^\\//, \"\");\n var isStaticMatch = routePath === normalizedHref || // exact match\n routePath.startsWith(normalizedHref + \"/\") || // child route\n normalizedHref.startsWith(routePath + \"/\") || // parent layout\n routePath === \"\" || // root layout\n normalizedHref !== \"\" && routePath === normalizedHref.split(\"/\")[0];\n var isDynamicMatch = routePath.includes(\"[\") && matchDynamicRoute(routePath, normalizedHref);\n if ((isStaticMatch || isDynamicMatch) && typeof globbed[key] === \"function\") {\n promises.push(globbed[key]().then(function(mod) {\n preloadedModules[key] = mod;\n }));\n }\n };\n for (var _iterator = Object.keys(globbed)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n await Promise.all(promises);\n}\nfunction loadRoutes(paths, routerRoot, options) {\n if (context) return context;\n globalThis[\"__importMetaGlobbed\"] = paths;\n context = globbedRoutesToRouteContext(paths, routerRoot, options);\n return context;\n}\nfunction globbedRoutesToRouteContext(paths, routerRoot, options) {\n var routesSync = {};\n var routePaths = {};\n var promises = {};\n var loadedRoutes = {};\n var clears = {};\n Object.keys(paths).forEach(function(path) {\n var _options_routeModes;\n if (!paths[path]) {\n console.error(`Error: Missing route at path ${path}`);\n return;\n }\n var loadRouteFunction = paths[path];\n var pathWithoutRelative = path.replace(`/${routerRoot}/`, \"./\");\n var originalPath = pathWithoutRelative.slice(1).replace(/\\.[jt]sx?$/, \"\");\n if ((options === null || options === void 0 ? void 0 : (_options_routeModes = options.routeModes) === null || _options_routeModes === void 0 ? void 0 : _options_routeModes[originalPath]) === \"spa\") {\n console.info(`Spa mode: ${originalPath}`);\n loadedRoutes[pathWithoutRelative] = function() {\n return null;\n };\n } else {\n routesSync[pathWithoutRelative] = loadRouteFunction;\n routePaths[pathWithoutRelative] = path;\n }\n });\n var moduleKeys = Object.keys(routesSync);\n var hmrVersion = 0;\n if (typeof window !== \"undefined\") {\n ;\n window.__oneRouteCache = {\n clear: function clear() {\n hmrVersion++;\n Object.keys(loadedRoutes).forEach(function(key) {\n delete loadedRoutes[key];\n });\n Object.keys(promises).forEach(function(key) {\n delete promises[key];\n });\n Object.keys(preloadedModules).forEach(function(key) {\n delete preloadedModules[key];\n });\n },\n clearFile: function clearFile(file) {\n var normalizedFile = file.replace(/\\\\/g, \"/\").replace(/^\\//, \"\");\n var routeId = moduleKeys.find(function(key) {\n return routePaths[key].replace(/\\\\/g, \"/\").replace(/^\\//, \"\") === normalizedFile;\n });\n if (!routeId) return false;\n hmrVersion++;\n delete loadedRoutes[routeId];\n delete promises[routeId];\n delete preloadedModules[routePaths[routeId]];\n return true;\n },\n getVersion: function getVersion() {\n return hmrVersion;\n }\n };\n }\n function resolve(id) {\n clearTimeout(clears[id]);\n if (loadedRoutes[id]) {\n return loadedRoutes[id];\n }\n var preloadKey = id.replace(\"./\", `/${routerRoot}/`);\n var preloaded = getPreloadedModule(preloadKey);\n if (preloaded) {\n loadedRoutes[id] = preloaded;\n return preloaded;\n }\n if (typeof routesSync[id] !== \"function\") {\n return routesSync[id];\n }\n if (!promises[id]) {\n var importPromise;\n if (process.env.NODE_ENV === \"development\" && hmrVersion > 0 && routePaths[id]) {\n importPromise = import_constants.isNative ? Promise.resolve(routesSync[id]()).then(function() {\n return (0, import_hmrImport.hmrImport)(routePaths[id]);\n }) : (0, import_hmrImport.hmrImport)(routePaths[id]);\n } else {\n var loaded = routesSync[id]();\n if (!(loaded instanceof Promise)) {\n return loaded;\n }\n importPromise = loaded;\n }\n promises[id] = importPromise.then(function(val) {\n loadedRoutes[id] = val;\n delete promises[id];\n if (process.env.NODE_ENV === \"development\") {\n clears[id] = setTimeout(function() {\n delete loadedRoutes[id];\n }, 500);\n }\n return val;\n }).catch(function(err) {\n console.error(`Error loading route`, id, err, new Error().stack);\n var reloading = (0, import_dynamicImport.isChunkLoadError)(err) && (0, import_dynamicImport.handleSkewError)();\n if (process.env.NODE_ENV === \"development\") {\n var _globalThis___oneReportRouteLoadError, _globalThis;\n ;\n (_globalThis___oneReportRouteLoadError = (_globalThis = globalThis).__oneReportRouteLoadError) === null || _globalThis___oneReportRouteLoadError === void 0 ? void 0 : _globalThis___oneReportRouteLoadError.call(_globalThis, {\n id,\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : void 0\n });\n if (import_constants.hasWebHistory && routePaths[id] && !reloading) {\n (0, import_diagnoseRouteLoadFailure.diagnoseRouteLoadFailure)(id, routePaths[id]).then(function(message) {\n if (message) console.error(message);\n }).catch(function() {\n });\n }\n }\n loadedRoutes[id] = {\n default: function _default() {\n return null;\n }\n };\n delete promises[id];\n });\n if (process.env.NODE_ENV === \"development\") {\n promises[id].stack = new Error().stack;\n }\n }\n throw promises[id];\n }\n resolve.keys = function() {\n return moduleKeys;\n };\n resolve.id = \"\";\n resolve.resolve = function(id) {\n return id;\n };\n return resolve;\n}\n//# sourceMappingURL=useViteRoutes.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,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,wBAAwB,CAAC;AAC7B,SAAS,uBAAuB;CAC9B,0BAA0B;CAC1B,8BAA8B;CAC9B,mCAAmC;CACnC,kBAAkB;CAClB,2BAA2B;CAC3B,8BAA8B;CAC9B,qBAAqB;AACvB,CAAC;AACD,OAAO,UAAU,aAAa,qBAAqB;AACnD,IAAI,mBAAmB,QAAQ,wBAAc;AAC7C,IAAI,uBAAuB,QAAQ,kCAAwB;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WAAW,OAAO,CAAC,WAAW;MAClE,CAAC,GAAG,gCAAgC,yBAAwB,CAAE,IAAI,WAAW,GAAG,CAAC,CAAC,KAAK,SAAS,SAAS;OACvG,IAAI,SAAS,QAAQ,MAAM,OAAO;MACpC,CAAC,CAAC,CAAC,MAAM,WAAW,CACpB,CAAC;KACH;IACF;IACA,aAAa,MAAM,EACjB,SAAS,SAAS,WAAW;KAC3B,OAAO;IACT,EACF;IACA,OAAO,SAAS;GAClB,CAAC;GACD,IAAI,QAAQ,IAAI,aAAa,eAAe;IAC1C,SAAS,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;GACnC;EACF;EACA,MAAM,SAAS;CACjB;CACA,QAAQ,OAAO,WAAW;EACxB,OAAO;CACT;CACA,QAAQ,KAAK;CACb,QAAQ,UAAU,SAAS,IAAI;EAC7B,OAAO;CACT;CACA,OAAO;AACT"}
@@ -149,9 +149,13 @@ function globbedRoutesToRouteContext(paths, routerRoot, options) {
149
149
  if (!promises[id]) {
150
150
  let importPromise;
151
151
  if (process.env.NODE_ENV === "development" && hmrVersion > 0 && routePaths[id]) {
152
- importPromise = isNative ? routesSync[id]().then(() => hmrImport(routePaths[id])) : hmrImport(routePaths[id]);
152
+ importPromise = isNative ? Promise.resolve(routesSync[id]()).then(() => hmrImport(routePaths[id])) : hmrImport(routePaths[id]);
153
153
  } else {
154
- importPromise = routesSync[id]();
154
+ const loaded = routesSync[id]();
155
+ if (!(loaded instanceof Promise)) {
156
+ return loaded;
157
+ }
158
+ importPromise = loaded;
155
159
  }
156
160
  promises[id] = importPromise.then((val) => {
157
161
  loadedRoutes[id] = val;
@@ -1 +1 @@
1
- {"version":3,"file":"useViteRoutes.js","names":[],"sources":["esm/router/useViteRoutes.js"],"sourcesContent":["import { hasWebHistory, isNative } from \"../constants\";\nimport { handleSkewError, isChunkLoadError } from \"../utils/dynamicImport\";\nimport { diagnoseRouteLoadFailure } from \"./diagnoseRouteLoadFailure\";\nimport { hmrImport } from \"./hmrImport\";\nlet lastVersion = 0;\nlet context;\nfunction useViteRoutes(routes, routerRoot, options, version) {\n if (version && version > lastVersion) {\n context = null;\n lastVersion = version;\n for (const key of Object.keys(preloadedModules)) {\n delete preloadedModules[key];\n }\n }\n if (!context) {\n loadRoutes(routes, routerRoot, options);\n }\n return context;\n}\nconst preloadedModules = {};\nfunction registerPreloadedRoute(key, module) {\n preloadedModules[key] = module;\n}\nfunction getPreloadedModule(key) {\n return preloadedModules[key];\n}\nfunction getPreloadedModuleKeys() {\n return Object.keys(preloadedModules);\n}\nfunction matchDynamicRoute(routePattern, actualPath) {\n const routeSegments = routePattern.split(\"/\");\n const pathSegments = actualPath.split(\"/\");\n const hasCatchAll = routeSegments.some((s) => s.startsWith(\"[...\"));\n if (hasCatchAll) {\n const catchAllIdx = routeSegments.findIndex((s) => s.startsWith(\"[...\"));\n for (let i = 0; i < catchAllIdx; i++) {\n if (!routeSegments[i]) continue;\n if (routeSegments[i].startsWith(\"[\")) continue;\n if (routeSegments[i] !== pathSegments[i]) return false;\n }\n return pathSegments.length >= catchAllIdx;\n }\n if (routeSegments.length !== pathSegments.length) return false;\n for (let i = 0; i < routeSegments.length; i++) {\n const routeSeg = routeSegments[i];\n const pathSeg = pathSegments[i];\n if (routeSeg.startsWith(\"[\") && routeSeg.endsWith(\"]\")) {\n continue;\n }\n if (routeSeg !== pathSeg) return false;\n }\n return true;\n}\nasync function preloadRouteModules(href) {\n const globbed = globalThis[\"__importMetaGlobbed\"];\n if (!globbed) return;\n const normalizedHref = href === \"/\" ? \"\" : href.replace(/^\\//, \"\").replace(/\\/$/, \"\");\n const promises = [];\n for (const key of Object.keys(globbed)) {\n let routePath = key.replace(/^\\/[^/]+\\//, \"\");\n routePath = routePath.replace(/\\([^)]+\\)\\//g, \"\");\n routePath = routePath.replace(/\\/_layout\\.tsx$/, \"\").replace(/\\/index(\\+[a-z]+)?\\.tsx$/, \"\").replace(/(\\+[a-z]+)?\\.tsx$/, \"\");\n routePath = routePath.replace(/^\\//, \"\");\n const isStaticMatch = routePath === normalizedHref || // exact match\n routePath.startsWith(normalizedHref + \"/\") || // child route\n normalizedHref.startsWith(routePath + \"/\") || // parent layout\n routePath === \"\" || // root layout\n normalizedHref !== \"\" && routePath === normalizedHref.split(\"/\")[0];\n const isDynamicMatch = routePath.includes(\"[\") && matchDynamicRoute(routePath, normalizedHref);\n if ((isStaticMatch || isDynamicMatch) && typeof globbed[key] === \"function\") {\n promises.push(\n globbed[key]().then((mod) => {\n preloadedModules[key] = mod;\n })\n );\n }\n }\n await Promise.all(promises);\n}\nfunction loadRoutes(paths, routerRoot, options) {\n if (context) return context;\n globalThis[\"__importMetaGlobbed\"] = paths;\n context = globbedRoutesToRouteContext(paths, routerRoot, options);\n return context;\n}\nfunction globbedRoutesToRouteContext(paths, routerRoot, options) {\n const routesSync = {};\n const routePaths = {};\n const promises = {};\n const loadedRoutes = {};\n const clears = {};\n Object.keys(paths).forEach((path) => {\n if (!paths[path]) {\n console.error(`Error: Missing route at path ${path}`);\n return;\n }\n const loadRouteFunction = paths[path];\n const pathWithoutRelative = path.replace(`/${routerRoot}/`, \"./\");\n const originalPath = pathWithoutRelative.slice(1).replace(/\\.[jt]sx?$/, \"\");\n if (options?.routeModes?.[originalPath] === \"spa\") {\n console.info(`Spa mode: ${originalPath}`);\n loadedRoutes[pathWithoutRelative] = () => {\n return null;\n };\n } else {\n routesSync[pathWithoutRelative] = loadRouteFunction;\n routePaths[pathWithoutRelative] = path;\n }\n });\n const moduleKeys = Object.keys(routesSync);\n let hmrVersion = 0;\n if (typeof window !== \"undefined\") {\n ;\n window.__oneRouteCache = {\n clear: () => {\n hmrVersion++;\n Object.keys(loadedRoutes).forEach((key) => {\n delete loadedRoutes[key];\n });\n Object.keys(promises).forEach((key) => {\n delete promises[key];\n });\n Object.keys(preloadedModules).forEach((key) => {\n delete preloadedModules[key];\n });\n },\n clearFile: (file) => {\n const normalizedFile = file.replace(/\\\\/g, \"/\").replace(/^\\//, \"\");\n const routeId = moduleKeys.find(\n (key) => routePaths[key].replace(/\\\\/g, \"/\").replace(/^\\//, \"\") === normalizedFile\n );\n if (!routeId) return false;\n hmrVersion++;\n delete loadedRoutes[routeId];\n delete promises[routeId];\n delete preloadedModules[routePaths[routeId]];\n return true;\n },\n getVersion: () => hmrVersion\n };\n }\n function resolve(id) {\n clearTimeout(clears[id]);\n if (loadedRoutes[id]) {\n return loadedRoutes[id];\n }\n const preloadKey = id.replace(\"./\", `/${routerRoot}/`);\n const preloaded = getPreloadedModule(preloadKey);\n if (preloaded) {\n loadedRoutes[id] = preloaded;\n return preloaded;\n }\n if (typeof routesSync[id] !== \"function\") {\n return routesSync[id];\n }\n if (!promises[id]) {\n let importPromise;\n if (process.env.NODE_ENV === \"development\" && hmrVersion > 0 && routePaths[id]) {\n importPromise = isNative ? routesSync[id]().then(() => hmrImport(routePaths[id])) : hmrImport(routePaths[id]);\n } else {\n importPromise = routesSync[id]();\n }\n promises[id] = importPromise.then((val) => {\n loadedRoutes[id] = val;\n delete promises[id];\n if (process.env.NODE_ENV === \"development\") {\n clears[id] = setTimeout(() => {\n delete loadedRoutes[id];\n }, 500);\n }\n return val;\n }).catch((err) => {\n console.error(`Error loading route`, id, err, new Error().stack);\n const reloading = isChunkLoadError(err) && handleSkewError();\n if (process.env.NODE_ENV === \"development\") {\n ;\n globalThis.__oneReportRouteLoadError?.({\n id,\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : void 0\n });\n if (hasWebHistory && routePaths[id] && !reloading) {\n diagnoseRouteLoadFailure(id, routePaths[id]).then((message) => {\n if (message) console.error(message);\n }).catch(() => {\n });\n }\n }\n loadedRoutes[id] = {\n default: () => null\n };\n delete promises[id];\n });\n if (process.env.NODE_ENV === \"development\") {\n promises[id].stack = new Error().stack;\n }\n }\n throw promises[id];\n }\n resolve.keys = () => moduleKeys;\n resolve.id = \"\";\n resolve.resolve = (id) => id;\n return resolve;\n}\nexport {\n getPreloadedModule,\n getPreloadedModuleKeys,\n globbedRoutesToRouteContext,\n loadRoutes,\n preloadRouteModules,\n registerPreloadedRoute,\n useViteRoutes\n};\n//# sourceMappingURL=useViteRoutes.js.map\n"],"mappings":";;;;;;AAIA,IAAI,cAAc;AAClB,IAAI;AACJ,SAAS,cAAc,QAAQ,YAAY,SAAS,SAAS;CAC3D,IAAI,WAAW,UAAU,aAAa;EACpC,UAAU;EACV,cAAc;EACd,KAAK,MAAM,OAAO,OAAO,KAAK,gBAAgB,GAAG;GAC/C,OAAO,iBAAiB;EAC1B;CACF;CACA,IAAI,CAAC,SAAS;EACZ,WAAW,QAAQ,YAAY,OAAO;CACxC;CACA,OAAO;AACT;AACA,MAAM,mBAAmB,CAAC;AAC1B,SAAS,uBAAuB,KAAK,QAAQ;CAC3C,iBAAiB,OAAO;AAC1B;AACA,SAAS,mBAAmB,KAAK;CAC/B,OAAO,iBAAiB;AAC1B;AACA,SAAS,yBAAyB;CAChC,OAAO,OAAO,KAAK,gBAAgB;AACrC;AACA,SAAS,kBAAkB,cAAc,YAAY;CACnD,MAAM,gBAAgB,aAAa,MAAM,GAAG;CAC5C,MAAM,eAAe,WAAW,MAAM,GAAG;CACzC,MAAM,cAAc,cAAc,MAAM,MAAM,EAAE,WAAW,MAAM,CAAC;CAClE,IAAI,aAAa;EACf,MAAM,cAAc,cAAc,WAAW,MAAM,EAAE,WAAW,MAAM,CAAC;EACvE,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,KAAK;GACpC,IAAI,CAAC,cAAc,IAAI;GACvB,IAAI,cAAc,EAAE,CAAC,WAAW,GAAG,GAAG;GACtC,IAAI,cAAc,OAAO,aAAa,IAAI,OAAO;EACnD;EACA,OAAO,aAAa,UAAU;CAChC;CACA,IAAI,cAAc,WAAW,aAAa,QAAQ,OAAO;CACzD,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;EAC7C,MAAM,WAAW,cAAc;EAC/B,MAAM,UAAU,aAAa;EAC7B,IAAI,SAAS,WAAW,G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CAAC,YAAY,CACf,CAAC;KACH;IACF;IACA,aAAa,MAAM,EACjB,eAAe,KACjB;IACA,OAAO,SAAS;GAClB,CAAC;GACD,IAAI,QAAQ,IAAI,aAAa,eAAe;IAC1C,SAAS,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;GACnC;EACF;EACA,MAAM,SAAS;CACjB;CACA,QAAQ,aAAa;CACrB,QAAQ,KAAK;CACb,QAAQ,WAAW,OAAO;CAC1B,OAAO;AACT"}
1
+ {"version":3,"file":"useViteRoutes.js","names":[],"sources":["esm/router/useViteRoutes.js"],"sourcesContent":["import { hasWebHistory, isNative } from \"../constants\";\nimport { handleSkewError, isChunkLoadError } from \"../utils/dynamicImport\";\nimport { diagnoseRouteLoadFailure } from \"./diagnoseRouteLoadFailure\";\nimport { hmrImport } from \"./hmrImport\";\nlet lastVersion = 0;\nlet context;\nfunction useViteRoutes(routes, routerRoot, options, version) {\n if (version && version > lastVersion) {\n context = null;\n lastVersion = version;\n for (const key of Object.keys(preloadedModules)) {\n delete preloadedModules[key];\n }\n }\n if (!context) {\n loadRoutes(routes, routerRoot, options);\n }\n return context;\n}\nconst preloadedModules = {};\nfunction registerPreloadedRoute(key, module) {\n preloadedModules[key] = module;\n}\nfunction getPreloadedModule(key) {\n return preloadedModules[key];\n}\nfunction getPreloadedModuleKeys() {\n return Object.keys(preloadedModules);\n}\nfunction matchDynamicRoute(routePattern, actualPath) {\n const routeSegments = routePattern.split(\"/\");\n const pathSegments = actualPath.split(\"/\");\n const hasCatchAll = routeSegments.some((s) => s.startsWith(\"[...\"));\n if (hasCatchAll) {\n const catchAllIdx = routeSegments.findIndex((s) => s.startsWith(\"[...\"));\n for (let i = 0; i < catchAllIdx; i++) {\n if (!routeSegments[i]) continue;\n if (routeSegments[i].startsWith(\"[\")) continue;\n if (routeSegments[i] !== pathSegments[i]) return false;\n }\n return pathSegments.length >= catchAllIdx;\n }\n if (routeSegments.length !== pathSegments.length) return false;\n for (let i = 0; i < routeSegments.length; i++) {\n const routeSeg = routeSegments[i];\n const pathSeg = pathSegments[i];\n if (routeSeg.startsWith(\"[\") && routeSeg.endsWith(\"]\")) {\n continue;\n }\n if (routeSeg !== pathSeg) return false;\n }\n return true;\n}\nasync function preloadRouteModules(href) {\n const globbed = globalThis[\"__importMetaGlobbed\"];\n if (!globbed) return;\n const normalizedHref = href === \"/\" ? \"\" : href.replace(/^\\//, \"\").replace(/\\/$/, \"\");\n const promises = [];\n for (const key of Object.keys(globbed)) {\n let routePath = key.replace(/^\\/[^/]+\\//, \"\");\n routePath = routePath.replace(/\\([^)]+\\)\\//g, \"\");\n routePath = routePath.replace(/\\/_layout\\.tsx$/, \"\").replace(/\\/index(\\+[a-z]+)?\\.tsx$/, \"\").replace(/(\\+[a-z]+)?\\.tsx$/, \"\");\n routePath = routePath.replace(/^\\//, \"\");\n const isStaticMatch = routePath === normalizedHref || // exact match\n routePath.startsWith(normalizedHref + \"/\") || // child route\n normalizedHref.startsWith(routePath + \"/\") || // parent layout\n routePath === \"\" || // root layout\n normalizedHref !== \"\" && routePath === normalizedHref.split(\"/\")[0];\n const isDynamicMatch = routePath.includes(\"[\") && matchDynamicRoute(routePath, normalizedHref);\n if ((isStaticMatch || isDynamicMatch) && typeof globbed[key] === \"function\") {\n promises.push(\n globbed[key]().then((mod) => {\n preloadedModules[key] = mod;\n })\n );\n }\n }\n await Promise.all(promises);\n}\nfunction loadRoutes(paths, routerRoot, options) {\n if (context) return context;\n globalThis[\"__importMetaGlobbed\"] = paths;\n context = globbedRoutesToRouteContext(paths, routerRoot, options);\n return context;\n}\nfunction globbedRoutesToRouteContext(paths, routerRoot, options) {\n const routesSync = {};\n const routePaths = {};\n const promises = {};\n const loadedRoutes = {};\n const clears = {};\n Object.keys(paths).forEach((path) => {\n if (!paths[path]) {\n console.error(`Error: Missing route at path ${path}`);\n return;\n }\n const loadRouteFunction = paths[path];\n const pathWithoutRelative = path.replace(`/${routerRoot}/`, \"./\");\n const originalPath = pathWithoutRelative.slice(1).replace(/\\.[jt]sx?$/, \"\");\n if (options?.routeModes?.[originalPath] === \"spa\") {\n console.info(`Spa mode: ${originalPath}`);\n loadedRoutes[pathWithoutRelative] = () => {\n return null;\n };\n } else {\n routesSync[pathWithoutRelative] = loadRouteFunction;\n routePaths[pathWithoutRelative] = path;\n }\n });\n const moduleKeys = Object.keys(routesSync);\n let hmrVersion = 0;\n if (typeof window !== \"undefined\") {\n ;\n window.__oneRouteCache = {\n clear: () => {\n hmrVersion++;\n Object.keys(loadedRoutes).forEach((key) => {\n delete loadedRoutes[key];\n });\n Object.keys(promises).forEach((key) => {\n delete promises[key];\n });\n Object.keys(preloadedModules).forEach((key) => {\n delete preloadedModules[key];\n });\n },\n clearFile: (file) => {\n const normalizedFile = file.replace(/\\\\/g, \"/\").replace(/^\\//, \"\");\n const routeId = moduleKeys.find(\n (key) => routePaths[key].replace(/\\\\/g, \"/\").replace(/^\\//, \"\") === normalizedFile\n );\n if (!routeId) return false;\n hmrVersion++;\n delete loadedRoutes[routeId];\n delete promises[routeId];\n delete preloadedModules[routePaths[routeId]];\n return true;\n },\n getVersion: () => hmrVersion\n };\n }\n function resolve(id) {\n clearTimeout(clears[id]);\n if (loadedRoutes[id]) {\n return loadedRoutes[id];\n }\n const preloadKey = id.replace(\"./\", `/${routerRoot}/`);\n const preloaded = getPreloadedModule(preloadKey);\n if (preloaded) {\n loadedRoutes[id] = preloaded;\n return preloaded;\n }\n if (typeof routesSync[id] !== \"function\") {\n return routesSync[id];\n }\n if (!promises[id]) {\n let importPromise;\n if (process.env.NODE_ENV === \"development\" && hmrVersion > 0 && routePaths[id]) {\n importPromise = isNative ? Promise.resolve(routesSync[id]()).then(() => hmrImport(routePaths[id])) : hmrImport(routePaths[id]);\n } else {\n const loaded = routesSync[id]();\n if (!(loaded instanceof Promise)) {\n return loaded;\n }\n importPromise = loaded;\n }\n promises[id] = importPromise.then((val) => {\n loadedRoutes[id] = val;\n delete promises[id];\n if (process.env.NODE_ENV === \"development\") {\n clears[id] = setTimeout(() => {\n delete loadedRoutes[id];\n }, 500);\n }\n return val;\n }).catch((err) => {\n console.error(`Error loading route`, id, err, new Error().stack);\n const reloading = isChunkLoadError(err) && handleSkewError();\n if (process.env.NODE_ENV === \"development\") {\n ;\n globalThis.__oneReportRouteLoadError?.({\n id,\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : void 0\n });\n if (hasWebHistory && routePaths[id] && !reloading) {\n diagnoseRouteLoadFailure(id, routePaths[id]).then((message) => {\n if (message) console.error(message);\n }).catch(() => {\n });\n }\n }\n loadedRoutes[id] = {\n default: () => null\n };\n delete promises[id];\n });\n if (process.env.NODE_ENV === \"development\") {\n promises[id].stack = new Error().stack;\n }\n }\n throw promises[id];\n }\n resolve.keys = () => moduleKeys;\n resolve.id = \"\";\n resolve.resolve = (id) => id;\n return resolve;\n}\nexport {\n getPreloadedModule,\n getPreloadedModuleKeys,\n globbedRoutesToRouteContext,\n loadRoutes,\n preloadRouteModules,\n registerPreloadedRoute,\n useViteRoutes\n};\n//# sourceMappingURL=useViteRoutes.js.map\n"],"mappings":";;;;;;AAIA,IAAI,cAAc;AAClB,IAAI;AACJ,SAAS,cAAc,QAAQ,YAAY,SAAS,SAAS;CAC3D,IAAI,WAAW,UAAU,aAAa;EACpC,UAAU;EACV,cAAc;EACd,KAAK,MAAM,OAAO,OAAO,KAAK,gBAAgB,GAAG;GAC/C,OAAO,iBAAiB;EAC1B;CACF;CACA,IAAI,CAAC,SAAS;EACZ,WAAW,QAAQ,YAAY,OAAO;CACxC;CACA,OAAO;AACT;AACA,MAAM,mBAAmB,CAAC;AAC1B,SAAS,uBAAuB,KAAK,QAAQ;CAC3C,iBAAiB,OAAO;AAC1B;AACA,SAAS,mBAAmB,KAAK;CAC/B,OAAO,iBAAiB;AAC1B;AACA,SAAS,yBAAyB;CAChC,OAAO,OAAO,KAAK,gBAAgB;AACrC;AACA,SAAS,kBAAkB,cAAc,YAAY;CACnD,MAAM,gBAAgB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cAAc,MAAM,QAAQ;IACzC,aAAa,MAAM;IACnB,OAAO,SAAS;IAChB,IAAI,QAAQ,IAAI,aAAa,eAAe;KAC1C,OAAO,MAAM,iBAAiB;MAC5B,OAAO,aAAa;KACtB,GAAG,GAAG;IACR;IACA,OAAO;GACT,CAAC,CAAC,CAAC,OAAO,QAAQ;IAChB,QAAQ,MAAM,uBAAuB,IAAI,KAAK,IAAI,MAAM,CAAC,CAAC,KAAK;IAC/D,MAAM,YAAY,iBAAiB,GAAG,KAAK,gBAAgB;IAC3D,IAAI,QAAQ,IAAI,aAAa,eAAe;KAC1C;KACA,WAAW,4BAA4B;MACrC;MACA,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;MACxD,OAAO,eAAe,QAAQ,IAAI,QAAQ,KAAK;KACjD,CAAC;KACD,IAAI,iBAAiB,WAAW,OAAO,CAAC,WAAW;MACjD,yBAAyB,IAAI,WAAW,GAAG,CAAC,CAAC,MAAM,YAAY;OAC7D,IAAI,SAAS,QAAQ,MAAM,OAAO;MACpC,CAAC,CAAC,CAAC,YAAY,CACf,CAAC;KACH;IACF;IACA,aAAa,MAAM,EACjB,eAAe,KACjB;IACA,OAAO,SAAS;GAClB,CAAC;GACD,IAAI,QAAQ,IAAI,aAAa,eAAe;IAC1C,SAAS,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;GACnC;EACF;EACA,MAAM,SAAS;CACjB;CACA,QAAQ,aAAa;CACrB,QAAQ,KAAK;CACb,QAAQ,WAAW,OAAO;CAC1B,OAAO;AACT"}
@@ -193,11 +193,15 @@ function globbedRoutesToRouteContext(paths, routerRoot, options) {
193
193
  if (!promises[id]) {
194
194
  var importPromise;
195
195
  if (process.env.NODE_ENV === "development" && hmrVersion > 0 && routePaths[id]) {
196
- importPromise = isNative ? routesSync[id]().then(function() {
196
+ importPromise = isNative ? Promise.resolve(routesSync[id]()).then(function() {
197
197
  return hmrImport(routePaths[id]);
198
198
  }) : hmrImport(routePaths[id]);
199
199
  } else {
200
- importPromise = routesSync[id]();
200
+ var loaded = routesSync[id]();
201
+ if (!(loaded instanceof Promise)) {
202
+ return loaded;
203
+ }
204
+ importPromise = loaded;
201
205
  }
202
206
  promises[id] = importPromise.then(function(val) {
203
207
  loadedRoutes[id] = val;
@@ -1 +1 @@
1
- {"version":3,"file":"useViteRoutes.native.js","names":[],"sources":["esm/router/useViteRoutes.native.js"],"sourcesContent":["import { hasWebHistory, isNative } from \"../constants\";\nimport { handleSkewError, isChunkLoadError } from \"../utils/dynamicImport\";\nimport { diagnoseRouteLoadFailure } from \"./diagnoseRouteLoadFailure\";\nimport { hmrImport } from \"./hmrImport\";\nvar lastVersion = 0;\nvar context;\nfunction useViteRoutes(routes, routerRoot, options, version) {\n if (version && version > lastVersion) {\n context = null;\n lastVersion = version;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.keys(preloadedModules)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n delete preloadedModules[key];\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n if (!context) {\n loadRoutes(routes, routerRoot, options);\n }\n return context;\n}\nvar preloadedModules = {};\nfunction registerPreloadedRoute(key, module) {\n preloadedModules[key] = module;\n}\nfunction getPreloadedModule(key) {\n return preloadedModules[key];\n}\nfunction getPreloadedModuleKeys() {\n return Object.keys(preloadedModules);\n}\nfunction matchDynamicRoute(routePattern, actualPath) {\n var routeSegments = routePattern.split(\"/\");\n var pathSegments = actualPath.split(\"/\");\n var hasCatchAll = routeSegments.some(function(s) {\n return s.startsWith(\"[...\");\n });\n if (hasCatchAll) {\n var catchAllIdx = routeSegments.findIndex(function(s) {\n return s.startsWith(\"[...\");\n });\n for (var i = 0; i < catchAllIdx; i++) {\n if (!routeSegments[i]) continue;\n if (routeSegments[i].startsWith(\"[\")) continue;\n if (routeSegments[i] !== pathSegments[i]) return false;\n }\n return pathSegments.length >= catchAllIdx;\n }\n if (routeSegments.length !== pathSegments.length) return false;\n for (var i1 = 0; i1 < routeSegments.length; i1++) {\n var routeSeg = routeSegments[i1];\n var pathSeg = pathSegments[i1];\n if (routeSeg.startsWith(\"[\") && routeSeg.endsWith(\"]\")) {\n continue;\n }\n if (routeSeg !== pathSeg) return false;\n }\n return true;\n}\nasync function preloadRouteModules(href) {\n var globbed = globalThis[\"__importMetaGlobbed\"];\n if (!globbed) return;\n var normalizedHref = href === \"/\" ? \"\" : href.replace(/^\\//, \"\").replace(/\\/$/, \"\");\n var promises = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n var _loop = function() {\n var key = _step.value;\n var routePath = key.replace(/^\\/[^/]+\\//, \"\");\n routePath = routePath.replace(/\\([^)]+\\)\\//g, \"\");\n routePath = routePath.replace(/\\/_layout\\.tsx$/, \"\").replace(/\\/index(\\+[a-z]+)?\\.tsx$/, \"\").replace(/(\\+[a-z]+)?\\.tsx$/, \"\");\n routePath = routePath.replace(/^\\//, \"\");\n var isStaticMatch = routePath === normalizedHref || // exact match\n routePath.startsWith(normalizedHref + \"/\") || // child route\n normalizedHref.startsWith(routePath + \"/\") || // parent layout\n routePath === \"\" || // root layout\n normalizedHref !== \"\" && routePath === normalizedHref.split(\"/\")[0];\n var isDynamicMatch = routePath.includes(\"[\") && matchDynamicRoute(routePath, normalizedHref);\n if ((isStaticMatch || isDynamicMatch) && typeof globbed[key] === \"function\") {\n promises.push(globbed[key]().then(function(mod) {\n preloadedModules[key] = mod;\n }));\n }\n };\n for (var _iterator = Object.keys(globbed)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n await Promise.all(promises);\n}\nfunction loadRoutes(paths, routerRoot, options) {\n if (context) return context;\n globalThis[\"__importMetaGlobbed\"] = paths;\n context = globbedRoutesToRouteContext(paths, routerRoot, options);\n return context;\n}\nfunction globbedRoutesToRouteContext(paths, routerRoot, options) {\n var routesSync = {};\n var routePaths = {};\n var promises = {};\n var loadedRoutes = {};\n var clears = {};\n Object.keys(paths).forEach(function(path) {\n var _options_routeModes;\n if (!paths[path]) {\n console.error(`Error: Missing route at path ${path}`);\n return;\n }\n var loadRouteFunction = paths[path];\n var pathWithoutRelative = path.replace(`/${routerRoot}/`, \"./\");\n var originalPath = pathWithoutRelative.slice(1).replace(/\\.[jt]sx?$/, \"\");\n if ((options === null || options === void 0 ? void 0 : (_options_routeModes = options.routeModes) === null || _options_routeModes === void 0 ? void 0 : _options_routeModes[originalPath]) === \"spa\") {\n console.info(`Spa mode: ${originalPath}`);\n loadedRoutes[pathWithoutRelative] = function() {\n return null;\n };\n } else {\n routesSync[pathWithoutRelative] = loadRouteFunction;\n routePaths[pathWithoutRelative] = path;\n }\n });\n var moduleKeys = Object.keys(routesSync);\n var hmrVersion = 0;\n if (typeof window !== \"undefined\") {\n ;\n window.__oneRouteCache = {\n clear: function clear() {\n hmrVersion++;\n Object.keys(loadedRoutes).forEach(function(key) {\n delete loadedRoutes[key];\n });\n Object.keys(promises).forEach(function(key) {\n delete promises[key];\n });\n Object.keys(preloadedModules).forEach(function(key) {\n delete preloadedModules[key];\n });\n },\n clearFile: function clearFile(file) {\n var normalizedFile = file.replace(/\\\\/g, \"/\").replace(/^\\//, \"\");\n var routeId = moduleKeys.find(function(key) {\n return routePaths[key].replace(/\\\\/g, \"/\").replace(/^\\//, \"\") === normalizedFile;\n });\n if (!routeId) return false;\n hmrVersion++;\n delete loadedRoutes[routeId];\n delete promises[routeId];\n delete preloadedModules[routePaths[routeId]];\n return true;\n },\n getVersion: function getVersion() {\n return hmrVersion;\n }\n };\n }\n function resolve(id) {\n clearTimeout(clears[id]);\n if (loadedRoutes[id]) {\n return loadedRoutes[id];\n }\n var preloadKey = id.replace(\"./\", `/${routerRoot}/`);\n var preloaded = getPreloadedModule(preloadKey);\n if (preloaded) {\n loadedRoutes[id] = preloaded;\n return preloaded;\n }\n if (typeof routesSync[id] !== \"function\") {\n return routesSync[id];\n }\n if (!promises[id]) {\n var importPromise;\n if (process.env.NODE_ENV === \"development\" && hmrVersion > 0 && routePaths[id]) {\n importPromise = isNative ? routesSync[id]().then(function() {\n return hmrImport(routePaths[id]);\n }) : hmrImport(routePaths[id]);\n } else {\n importPromise = routesSync[id]();\n }\n promises[id] = importPromise.then(function(val) {\n loadedRoutes[id] = val;\n delete promises[id];\n if (process.env.NODE_ENV === \"development\") {\n clears[id] = setTimeout(function() {\n delete loadedRoutes[id];\n }, 500);\n }\n return val;\n }).catch(function(err) {\n console.error(`Error loading route`, id, err, new Error().stack);\n var reloading = isChunkLoadError(err) && handleSkewError();\n if (process.env.NODE_ENV === \"development\") {\n var _globalThis___oneReportRouteLoadError, _globalThis;\n ;\n (_globalThis___oneReportRouteLoadError = (_globalThis = globalThis).__oneReportRouteLoadError) === null || _globalThis___oneReportRouteLoadError === void 0 ? void 0 : _globalThis___oneReportRouteLoadError.call(_globalThis, {\n id,\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : void 0\n });\n if (hasWebHistory && routePaths[id] && !reloading) {\n diagnoseRouteLoadFailure(id, routePaths[id]).then(function(message) {\n if (message) console.error(message);\n }).catch(function() {\n });\n }\n }\n loadedRoutes[id] = {\n default: function _default() {\n return null;\n }\n };\n delete promises[id];\n });\n if (process.env.NODE_ENV === \"development\") {\n promises[id].stack = new Error().stack;\n }\n }\n throw promises[id];\n }\n resolve.keys = function() {\n return moduleKeys;\n };\n resolve.id = \"\";\n resolve.resolve = function(id) {\n return id;\n };\n return resolve;\n}\nexport {\n getPreloadedModule,\n getPreloadedModuleKeys,\n globbedRoutesToRouteContext,\n loadRoutes,\n preloadRouteModules,\n registerPreloadedRoute,\n useViteRoutes\n};\n//# sourceMappingURL=useViteRoutes.js.map\n"],"mappings":";;;;;;AAIA,IAAI,cAAc;AAClB,IAAI;AACJ,SAAS,cAAc,QAAQ,YAAY,SAAS,SAAS;CAC3D,IAAI,WAAW,UAAU,aAAa;EACpC,UAAU;EACV,cAAc;EACd,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;EACvF,IAAI;GACF,KAAK,IAAI,YAAY,OAAO,KAAK,gBAAgB,CAAC,CAAC,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;IAC9K,IAAI,MAAM,MAAM;IAChB,OAAO,iBAAiB;GAC1B;EACF,SAAS,KAAK;GACZ,oBAAoB;GACpB,iBAAiB;EACnB,UAAU;GACR,IAAI;IACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;KAC1D,UAAU,OAAO;IACnB;GACF,UAAU;IACR,IAAI,mBAAmB;KACrB,MAAM;IACR;GACF;EACF;CACF;CACA,IAAI,CAAC,SAAS;EACZ,WAAW,QAAQ,YAAY,OAAO;CACxC;CACA,OAAO;AACT;AACA,IAAI,mBAAmB,CAAC;AACxB,SAAS,uBAAuB,KAAK,QAAQ;CAC3C,iBAAiB,OAAO;AAC1B;AACA,SAAS,mBAAmB,KAAK;CAC/B,OAAO,iBAAiB;AAC1B;AACA,SAAS,yBAAyB;CAChC,OAAO,OAAO,KAAK,gBAAgB;AACrC;AACA,SAAS,kBAAkB,cAAc,YAAY;CACnD,IAAI,gBAAgB,aAAa,MAAM,GAAG;CAC1C,IAAI,eAAe,WAAW,MAAM,GAAG;CACvC,IAAI,cAAc,cAAc,KAAK,SAAS,GAAG;EAC/C,OAAO,EAAE,WAAW,MAAM;C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AAS;OAClE,IAAI,SAAS,QAAQ,MAAM,OAAO;MACpC,CAAC,CAAC,CAAC,MAAM,WAAW,CACpB,CAAC;KACH;IACF;IACA,aAAa,MAAM,EACjB,SAAS,SAAS,WAAW;KAC3B,OAAO;IACT,EACF;IACA,OAAO,SAAS;GAClB,CAAC;GACD,IAAI,QAAQ,IAAI,aAAa,eAAe;IAC1C,SAAS,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;GACnC;EACF;EACA,MAAM,SAAS;CACjB;CACA,QAAQ,OAAO,WAAW;EACxB,OAAO;CACT;CACA,QAAQ,KAAK;CACb,QAAQ,UAAU,SAAS,IAAI;EAC7B,OAAO;CACT;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"useViteRoutes.native.js","names":[],"sources":["esm/router/useViteRoutes.native.js"],"sourcesContent":["import { hasWebHistory, isNative } from \"../constants\";\nimport { handleSkewError, isChunkLoadError } from \"../utils/dynamicImport\";\nimport { diagnoseRouteLoadFailure } from \"./diagnoseRouteLoadFailure\";\nimport { hmrImport } from \"./hmrImport\";\nvar lastVersion = 0;\nvar context;\nfunction useViteRoutes(routes, routerRoot, options, version) {\n if (version && version > lastVersion) {\n context = null;\n lastVersion = version;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.keys(preloadedModules)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n delete preloadedModules[key];\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n if (!context) {\n loadRoutes(routes, routerRoot, options);\n }\n return context;\n}\nvar preloadedModules = {};\nfunction registerPreloadedRoute(key, module) {\n preloadedModules[key] = module;\n}\nfunction getPreloadedModule(key) {\n return preloadedModules[key];\n}\nfunction getPreloadedModuleKeys() {\n return Object.keys(preloadedModules);\n}\nfunction matchDynamicRoute(routePattern, actualPath) {\n var routeSegments = routePattern.split(\"/\");\n var pathSegments = actualPath.split(\"/\");\n var hasCatchAll = routeSegments.some(function(s) {\n return s.startsWith(\"[...\");\n });\n if (hasCatchAll) {\n var catchAllIdx = routeSegments.findIndex(function(s) {\n return s.startsWith(\"[...\");\n });\n for (var i = 0; i < catchAllIdx; i++) {\n if (!routeSegments[i]) continue;\n if (routeSegments[i].startsWith(\"[\")) continue;\n if (routeSegments[i] !== pathSegments[i]) return false;\n }\n return pathSegments.length >= catchAllIdx;\n }\n if (routeSegments.length !== pathSegments.length) return false;\n for (var i1 = 0; i1 < routeSegments.length; i1++) {\n var routeSeg = routeSegments[i1];\n var pathSeg = pathSegments[i1];\n if (routeSeg.startsWith(\"[\") && routeSeg.endsWith(\"]\")) {\n continue;\n }\n if (routeSeg !== pathSeg) return false;\n }\n return true;\n}\nasync function preloadRouteModules(href) {\n var globbed = globalThis[\"__importMetaGlobbed\"];\n if (!globbed) return;\n var normalizedHref = href === \"/\" ? \"\" : href.replace(/^\\//, \"\").replace(/\\/$/, \"\");\n var promises = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n var _loop = function() {\n var key = _step.value;\n var routePath = key.replace(/^\\/[^/]+\\//, \"\");\n routePath = routePath.replace(/\\([^)]+\\)\\//g, \"\");\n routePath = routePath.replace(/\\/_layout\\.tsx$/, \"\").replace(/\\/index(\\+[a-z]+)?\\.tsx$/, \"\").replace(/(\\+[a-z]+)?\\.tsx$/, \"\");\n routePath = routePath.replace(/^\\//, \"\");\n var isStaticMatch = routePath === normalizedHref || // exact match\n routePath.startsWith(normalizedHref + \"/\") || // child route\n normalizedHref.startsWith(routePath + \"/\") || // parent layout\n routePath === \"\" || // root layout\n normalizedHref !== \"\" && routePath === normalizedHref.split(\"/\")[0];\n var isDynamicMatch = routePath.includes(\"[\") && matchDynamicRoute(routePath, normalizedHref);\n if ((isStaticMatch || isDynamicMatch) && typeof globbed[key] === \"function\") {\n promises.push(globbed[key]().then(function(mod) {\n preloadedModules[key] = mod;\n }));\n }\n };\n for (var _iterator = Object.keys(globbed)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n await Promise.all(promises);\n}\nfunction loadRoutes(paths, routerRoot, options) {\n if (context) return context;\n globalThis[\"__importMetaGlobbed\"] = paths;\n context = globbedRoutesToRouteContext(paths, routerRoot, options);\n return context;\n}\nfunction globbedRoutesToRouteContext(paths, routerRoot, options) {\n var routesSync = {};\n var routePaths = {};\n var promises = {};\n var loadedRoutes = {};\n var clears = {};\n Object.keys(paths).forEach(function(path) {\n var _options_routeModes;\n if (!paths[path]) {\n console.error(`Error: Missing route at path ${path}`);\n return;\n }\n var loadRouteFunction = paths[path];\n var pathWithoutRelative = path.replace(`/${routerRoot}/`, \"./\");\n var originalPath = pathWithoutRelative.slice(1).replace(/\\.[jt]sx?$/, \"\");\n if ((options === null || options === void 0 ? void 0 : (_options_routeModes = options.routeModes) === null || _options_routeModes === void 0 ? void 0 : _options_routeModes[originalPath]) === \"spa\") {\n console.info(`Spa mode: ${originalPath}`);\n loadedRoutes[pathWithoutRelative] = function() {\n return null;\n };\n } else {\n routesSync[pathWithoutRelative] = loadRouteFunction;\n routePaths[pathWithoutRelative] = path;\n }\n });\n var moduleKeys = Object.keys(routesSync);\n var hmrVersion = 0;\n if (typeof window !== \"undefined\") {\n ;\n window.__oneRouteCache = {\n clear: function clear() {\n hmrVersion++;\n Object.keys(loadedRoutes).forEach(function(key) {\n delete loadedRoutes[key];\n });\n Object.keys(promises).forEach(function(key) {\n delete promises[key];\n });\n Object.keys(preloadedModules).forEach(function(key) {\n delete preloadedModules[key];\n });\n },\n clearFile: function clearFile(file) {\n var normalizedFile = file.replace(/\\\\/g, \"/\").replace(/^\\//, \"\");\n var routeId = moduleKeys.find(function(key) {\n return routePaths[key].replace(/\\\\/g, \"/\").replace(/^\\//, \"\") === normalizedFile;\n });\n if (!routeId) return false;\n hmrVersion++;\n delete loadedRoutes[routeId];\n delete promises[routeId];\n delete preloadedModules[routePaths[routeId]];\n return true;\n },\n getVersion: function getVersion() {\n return hmrVersion;\n }\n };\n }\n function resolve(id) {\n clearTimeout(clears[id]);\n if (loadedRoutes[id]) {\n return loadedRoutes[id];\n }\n var preloadKey = id.replace(\"./\", `/${routerRoot}/`);\n var preloaded = getPreloadedModule(preloadKey);\n if (preloaded) {\n loadedRoutes[id] = preloaded;\n return preloaded;\n }\n if (typeof routesSync[id] !== \"function\") {\n return routesSync[id];\n }\n if (!promises[id]) {\n var importPromise;\n if (process.env.NODE_ENV === \"development\" && hmrVersion > 0 && routePaths[id]) {\n importPromise = isNative ? Promise.resolve(routesSync[id]()).then(function() {\n return hmrImport(routePaths[id]);\n }) : hmrImport(routePaths[id]);\n } else {\n var loaded = routesSync[id]();\n if (!(loaded instanceof Promise)) {\n return loaded;\n }\n importPromise = loaded;\n }\n promises[id] = importPromise.then(function(val) {\n loadedRoutes[id] = val;\n delete promises[id];\n if (process.env.NODE_ENV === \"development\") {\n clears[id] = setTimeout(function() {\n delete loadedRoutes[id];\n }, 500);\n }\n return val;\n }).catch(function(err) {\n console.error(`Error loading route`, id, err, new Error().stack);\n var reloading = isChunkLoadError(err) && handleSkewError();\n if (process.env.NODE_ENV === \"development\") {\n var _globalThis___oneReportRouteLoadError, _globalThis;\n ;\n (_globalThis___oneReportRouteLoadError = (_globalThis = globalThis).__oneReportRouteLoadError) === null || _globalThis___oneReportRouteLoadError === void 0 ? void 0 : _globalThis___oneReportRouteLoadError.call(_globalThis, {\n id,\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : void 0\n });\n if (hasWebHistory && routePaths[id] && !reloading) {\n diagnoseRouteLoadFailure(id, routePaths[id]).then(function(message) {\n if (message) console.error(message);\n }).catch(function() {\n });\n }\n }\n loadedRoutes[id] = {\n default: function _default() {\n return null;\n }\n };\n delete promises[id];\n });\n if (process.env.NODE_ENV === \"development\") {\n promises[id].stack = new Error().stack;\n }\n }\n throw promises[id];\n }\n resolve.keys = function() {\n return moduleKeys;\n };\n resolve.id = \"\";\n resolve.resolve = function(id) {\n return id;\n };\n return resolve;\n}\nexport {\n getPreloadedModule,\n getPreloadedModuleKeys,\n globbedRoutesToRouteContext,\n loadRoutes,\n preloadRouteModules,\n registerPreloadedRoute,\n useViteRoutes\n};\n//# sourceMappingURL=useViteRoutes.js.map\n"],"mappings":";;;;;;AAIA,IAAI,cAAc;AAClB,IAAI;AACJ,SAAS,cAAc,QAAQ,YAAY,SAAS,SAAS;CAC3D,IAAI,WAAW,UAAU,aAAa;EACpC,UAAU;EACV,cAAc;EACd,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;EACvF,IAAI;GACF,KAAK,IAAI,YAAY,OAAO,KAAK,gBAAgB,CAAC,CAAC,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;IAC9K,IAAI,MAAM,MAAM;IAChB,OAAO,iBAAiB;GAC1B;EACF,SAAS,KAAK;GACZ,oBAAoB;GACpB,iBAAiB;EACnB,UAAU;GACR,IAAI;IACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;KAC1D,UAAU,OAAO;IACnB;GACF,UAAU;IACR,IAAI,mBAAmB;KACrB,MAAM;IACR;GACF;EACF;CACF;CACA,IAAI,CAAC,SAAS;EACZ,WAAW,QAAQ,YAAY,OAAO;CACxC;CACA,OAAO;AACT;AACA,IAAI,mBAAmB,CAAC;AACxB,SAAS,uBAAuB,KAAK,QAAQ;CAC3C,iB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,KAAK,gBAAgB;IACzD,IAAI,QAAQ,IAAI,aAAa,eAAe;KAC1C,IAAI,uCAAuC;KAC3C;KACA,CAAC,yCAAyC,cAAc,WAAU,CAAE,+BAA+B,QAAQ,0CAA0C,KAAK,IAAI,KAAK,IAAI,sCAAsC,KAAK,aAAa;MAC7N;MACA,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;MACxD,OAAO,eAAe,QAAQ,IAAI,QAAQ,KAAK;KACjD,CAAC;KACD,IAAI,iBAAiB,WAAW,OAAO,CAAC,WAAW;MACjD,yBAAyB,IAAI,WAAW,GAAG,CAAC,CAAC,KAAK,SAAS,SAAS;OAClE,IAAI,SAAS,QAAQ,MAAM,OAAO;MACpC,CAAC,CAAC,CAAC,MAAM,WAAW,CACpB,CAAC;KACH;IACF;IACA,aAAa,MAAM,EACjB,SAAS,SAAS,WAAW;KAC3B,OAAO;IACT,EACF;IACA,OAAO,SAAS;GAClB,CAAC;GACD,IAAI,QAAQ,IAAI,aAAa,eAAe;IAC1C,SAAS,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;GACnC;EACF;EACA,MAAM,SAAS;CACjB;CACA,QAAQ,OAAO,WAAW;EACxB,OAAO;CACT;CACA,QAAQ,KAAK;CACb,QAAQ,UAAU,SAAS,IAAI;EAC7B,OAAO;CACT;CACA,OAAO;AACT"}
@@ -95,6 +95,8 @@ import WorkoutKit
95
95
  Self(kind: .onAppIntentExecution) { AnyView($0.onAppIntentExecution(intent, perform: action)) }
96
96
  }
97
97
 
98
+
99
+ #if ONE_IOS_27_SDK
98
100
  @available(iOS 27, *)
99
101
  public static func reorderContainer<Item: Identifiable>(
100
102
  for item: Item.Type, isEnabled: Bool = true,
@@ -102,6 +104,8 @@ import WorkoutKit
102
104
  ) -> Self where Item.ID: Sendable {
103
105
  Self(kind: .reorderContainer) { AnyView($0.reorderContainer(for: item, isEnabled: isEnabled, move: move)) }
104
106
  }
107
+ #endif
108
+
105
109
 
106
110
  @available(iOS 17, *)
107
111
  public static func mapFeatureSelectionContent<Content: MapContent>(
@@ -118,10 +122,14 @@ import WorkoutKit
118
122
  Self(kind: .transactionTask) { AnyView($0.transactionTask(configuration, action: action)) }
119
123
  }
120
124
 
125
+ #if ONE_IOS_27_SDK
126
+
121
127
  @available(iOS 18.4, *)
122
128
  public static func appEntityUIElements(_ action: @escaping @MainActor (AppIntents.AppEntityUIElementsContext) -> [AppIntents.AppEntityUIElement]) -> Self {
123
129
  Self(kind: .appEntityUIElements) { AnyView($0.appEntityUIElements(action)) }
124
130
  }
131
+ #endif
132
+
125
133
  #if ONE_GROUP_WALLET
126
134
 
127
135
  @available(iOS 15.5, *)
package/metro-entry.js CHANGED
@@ -19,7 +19,7 @@ const linking = process.env.ONE_ROUTER_LINKING_CONFIG
19
19
 
20
20
  const routes = ctx.keys().reduce((acc, key) => {
21
21
  const path = key.replace(/^\.\//, `/${ONE_ROUTER_ROOT_FOLDER_NAME}/`)
22
- acc[path] = async () => ctx(key)
22
+ acc[path] = () => ctx(key)
23
23
  return acc
24
24
  }, {})
25
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one",
3
- "version": "2.17.1",
3
+ "version": "2.17.3",
4
4
  "description": "One is a React framework for web, iOS, and Android apps.",
5
5
  "license": "BSD-3-Clause",
6
6
  "sideEffects": [
@@ -282,15 +282,15 @@
282
282
  "@react-navigation/routers": "8.0.0-alpha.21",
283
283
  "@rozenite/middleware": "^2.5.0",
284
284
  "@ungap/structured-clone": "^1.2.0",
285
- "@vxrn/color-scheme": "2.17.1",
286
- "@vxrn/compiler": "2.17.1",
287
- "@vxrn/resolve": "2.17.1",
288
- "@vxrn/tslib-lite": "2.17.1",
289
- "@vxrn/use-isomorphic-layout-effect": "2.17.1",
290
- "@vxrn/utils": "2.17.1",
285
+ "@vxrn/color-scheme": "2.17.3",
286
+ "@vxrn/compiler": "2.17.3",
287
+ "@vxrn/resolve": "2.17.3",
288
+ "@vxrn/tslib-lite": "2.17.3",
289
+ "@vxrn/use-isomorphic-layout-effect": "2.17.3",
290
+ "@vxrn/utils": "2.17.3",
291
291
  "citty": "^0.1.6",
292
292
  "core-js": "^3.38.1",
293
- "create-vxrn": "2.17.1",
293
+ "create-vxrn": "2.17.3",
294
294
  "escape-string-regexp": "^5.0.0",
295
295
  "fast-deep-equal": "^3.1.3",
296
296
  "fast-glob": "^3.3.3",
@@ -311,7 +311,7 @@
311
311
  "tsconfig-paths": "^4",
312
312
  "use-latest-callback": "^0.3.5",
313
313
  "vite": "^8.2.2",
314
- "vxrn": "2.17.1",
314
+ "vxrn": "2.17.3",
315
315
  "web-streams-polyfill": "^4.3.0",
316
316
  "ws": "^8.21.0",
317
317
  "xxhashjs": "^0.2.2"
@@ -341,7 +341,7 @@
341
341
  "@babel/types": "^7.28.5",
342
342
  "babel-dead-code-elimination": "1.0.10",
343
343
  "babel-plugin-module-resolver": "^5.0.2",
344
- "@vxrn/vite-plugin-metro": "2.17.1",
344
+ "@vxrn/vite-plugin-metro": "2.17.3",
345
345
  "react-native-css-interop": "^0.2.6"
346
346
  },
347
347
  "peerDependenciesMeta": {
@@ -407,19 +407,19 @@
407
407
  }
408
408
  },
409
409
  "devDependencies": {
410
- "@tamagui/sheet": "3.3.1",
410
+ "@tamagui/sheet": "3.3.2",
411
411
  "@callstack/liquid-glass": "^0.8.1",
412
412
  "@react-native/babel-plugin-codegen": "0.88.0",
413
413
  "@react-native/codegen": "^0.88.0",
414
414
  "@react-navigation/core": "8.0.0-alpha.41",
415
415
  "@react-navigation/drawer": "8.0.0-alpha.58",
416
416
  "@react-navigation/native": "8.0.0-alpha.51",
417
- "@tamagui/build": "3.3.1",
417
+ "@tamagui/build": "3.3.2",
418
418
  "@types/node": "^24.10.0",
419
419
  "@types/react-dom": "^19.3.0",
420
420
  "@types/react-test-renderer": "^19.1.0",
421
421
  "@types/xxhashjs": "^0.2.4",
422
- "@vxrn/emitter": "2.17.1",
422
+ "@vxrn/emitter": "2.17.3",
423
423
  "depcheck": "^1.4.7",
424
424
  "esbuild": "^0.28.1",
425
425
  "immer": "^10.1.1",
@@ -438,7 +438,7 @@
438
438
  "typescript": "7.0.2",
439
439
  "vitest": "^4.1.0",
440
440
  "yoga-layout": "^3.2.1",
441
- "@tamagui/web": "3.3.1",
441
+ "@tamagui/web": "3.3.2",
442
442
  "@babel/core": "^7.28.5",
443
443
  "@babel/generator": "7.29.7",
444
444
  "@babel/parser": "^7.28.5",
@@ -447,7 +447,7 @@
447
447
  "@babel/types": "^7.28.5",
448
448
  "babel-dead-code-elimination": "1.0.10",
449
449
  "babel-plugin-module-resolver": "^5.0.2",
450
- "@vxrn/vite-plugin-metro": "2.17.1",
450
+ "@vxrn/vite-plugin-metro": "2.17.3",
451
451
  "react-native-css-interop": "^0.2.6"
452
452
  },
453
453
  "publishConfig": {
@@ -616,7 +616,7 @@
616
616
  }
617
617
  }
618
618
  },
619
- "releaseSourceCommit": "a47c12ac1ff7a8252ec425b33431915a4c4fea9a",
619
+ "releaseSourceCommit": "343c80556d459192c3b4e09d89d534061820b9f5",
620
620
  "repository": {
621
621
  "type": "git",
622
622
  "url": "git+https://github.com/onejs/one.git",
@@ -2,16 +2,26 @@ import {
2
2
  createDrawerNavigator,
3
3
  type DrawerNavigationEventMap,
4
4
  type DrawerNavigationOptions,
5
+ type DrawerNavigatorProps,
5
6
  } from '@react-navigation/drawer'
6
7
  import type { DrawerNavigationState, ParamListBase } from '@react-navigation/native'
7
8
  import React, { type ComponentProps } from 'react'
8
9
 
9
- import { withLayoutContext } from './withLayoutContext'
10
+ import {
11
+ type LayoutNavigator,
12
+ type LayoutScreen,
13
+ withLayoutContext,
14
+ } from './withLayoutContext'
10
15
 
11
16
  const DrawerNavigator = createDrawerNavigator().Navigator
12
17
 
18
+ export type DrawerScreenOptions = DrawerNavigationOptions & {
19
+ /** Web only: keep the screen's subtree mounted after it is left. */
20
+ keepMounted?: boolean
21
+ }
22
+
13
23
  const RNDrawer = withLayoutContext<
14
- DrawerNavigationOptions,
24
+ DrawerScreenOptions,
15
25
  typeof DrawerNavigator,
16
26
  DrawerNavigationState<ParamListBase>,
17
27
  DrawerNavigationEventMap
@@ -21,7 +31,13 @@ const DrawerWithRender = React.forwardRef<unknown, ComponentProps<typeof RNDrawe
21
31
  (props, ref) => <RNDrawer {...(props as any)} ref={ref} />
22
32
  )
23
33
 
24
- type DrawerType = ReturnType<typeof withLayoutContext>
34
+ type DrawerType = LayoutNavigator<DrawerNavigatorProps, DrawerScreenOptions> & {
35
+ Screen: LayoutScreen<
36
+ DrawerScreenOptions,
37
+ DrawerNavigationState<ParamListBase>,
38
+ DrawerNavigationEventMap
39
+ >
40
+ }
25
41
 
26
42
  // Preserve withLayoutContext's static Screen so user code like
27
43
  // `<Drawer.Screen ... />` keeps working through the render wrapper.
@@ -2,6 +2,7 @@ import type { ParamListBase, StackNavigationState } from '@react-navigation/nati
2
2
  import type {
3
3
  NativeStackNavigationEventMap,
4
4
  NativeStackNavigationOptions,
5
+ NativeStackNavigatorProps,
5
6
  } from '@react-navigation/native-stack'
6
7
  import React, { Children, type ComponentProps, useMemo } from 'react'
7
8
  import { isChildOfType } from '../utils/children'
@@ -28,7 +29,7 @@ import {
28
29
  type StackScreenProps,
29
30
  type StackToolbarProps,
30
31
  } from './stack-utils'
31
- import { withLayoutContext } from './withLayoutContext'
32
+ import { type LayoutNavigator, withLayoutContext } from './withLayoutContext'
32
33
 
33
34
  const NativeStackNavigator = createStackNavigator().Navigator
34
35
 
@@ -163,7 +164,7 @@ type StackToolbarCompound = typeof StackToolbarComponent & {
163
164
  Badge: typeof StackToolbarBadge
164
165
  }
165
166
 
166
- type StackType = ReturnType<typeof withLayoutContext> & {
167
+ type StackType = LayoutNavigator<NativeStackNavigatorProps, StackScreenOptions> & {
167
168
  Screen: typeof StackScreen
168
169
  Header: typeof StackHeader
169
170
  Toolbar: StackToolbarCompound
@@ -1,24 +1,43 @@
1
1
  import {
2
2
  type BottomTabNavigationEventMap,
3
3
  type BottomTabNavigationOptions,
4
+ type BottomTabNavigatorProps,
4
5
  createBottomTabNavigator,
5
6
  } from '@react-navigation/bottom-tabs'
6
7
  import type { ParamListBase, TabNavigationState } from '@react-navigation/native'
7
8
 
8
9
  import { Protected } from '../views/Protected'
9
10
  import { processNativeTabsScreens } from './nativeTabsOptions'
10
- import { withLayoutContext } from './withLayoutContext'
11
+ import {
12
+ type LayoutNavigator,
13
+ type LayoutScreen,
14
+ withLayoutContext,
15
+ } from './withLayoutContext'
11
16
 
12
17
  const BottomTabNavigator = createBottomTabNavigator().Navigator
13
18
 
19
+ export type TabsScreenOptions = BottomTabNavigationOptions & {
20
+ /** Web only: the tab's link target. Native layouts reject it. */
21
+ href?: string | null
22
+ /** Web only: keep the tab's subtree mounted after it is left. */
23
+ keepMounted?: boolean
24
+ }
25
+
14
26
  const RNTabs = withLayoutContext<
15
- BottomTabNavigationOptions,
27
+ TabsScreenOptions,
16
28
  typeof BottomTabNavigator,
17
29
  TabNavigationState<ParamListBase>,
18
30
  BottomTabNavigationEventMap
19
31
  >(BottomTabNavigator, processNativeTabsScreens)
20
32
 
21
- type TabsType = ReturnType<typeof withLayoutContext> & { Protected: typeof Protected }
33
+ type TabsType = LayoutNavigator<BottomTabNavigatorProps, TabsScreenOptions> & {
34
+ Screen: LayoutScreen<
35
+ TabsScreenOptions,
36
+ TabNavigationState<ParamListBase>,
37
+ BottomTabNavigationEventMap
38
+ >
39
+ Protected: typeof Protected
40
+ }
22
41
 
23
42
  export const Tabs: TabsType = Object.assign(RNTabs, {
24
43
  Protected,
@@ -40,12 +40,16 @@ export type StackScreenOptions = Omit<NativeStackNavigationOptions, 'presentatio
40
40
 
41
41
  // every route prop the navigator reads off a screen element (listeners,
42
42
  // initialParams, getId, redirect) passes through Stack.Screen unchanged.
43
+ // options merge with Stack.Header children, so only the object form applies
43
44
  export type StackScreenProps = PropsWithChildren<
44
- ScreenProps<
45
- StackScreenOptions,
46
- StackNavigationState<ParamListBase>,
47
- NativeStackNavigationEventMap
48
- >
45
+ Omit<
46
+ ScreenProps<
47
+ StackScreenOptions,
48
+ StackNavigationState<ParamListBase>,
49
+ NativeStackNavigationEventMap
50
+ >,
51
+ 'options'
52
+ > & { options?: StackScreenOptions }
49
53
  >
50
54
 
51
55
  /**
@@ -156,6 +156,32 @@ export function useResolvedGuardedRedirects(
156
156
  }, [guardedRedirects, node])
157
157
  }
158
158
 
159
+ // named so declarations do not inline each navigator's inferred props. the
160
+ // navigator's own screenOptions are swapped for One's, which add web-only keys
161
+ type ScreenOptionsArgs<TProps> =
162
+ Extract<TProps extends { screenOptions?: infer O } ? O : never, (...args: any[]) => any> extends (
163
+ args: infer A
164
+ ) => any
165
+ ? A
166
+ : never
167
+
168
+ export type LayoutNavigator<
169
+ TProps extends { children: React.ReactNode },
170
+ TOptions extends object,
171
+ > = React.ForwardRefExoticComponent<
172
+ Omit<TProps, 'children' | 'screenOptions'> & {
173
+ children?: React.ReactNode
174
+ id?: string
175
+ screenOptions?: TOptions | ((args: ScreenOptionsArgs<TProps>) => TOptions)
176
+ } & React.RefAttributes<unknown>
177
+ >
178
+
179
+ export type LayoutScreen<
180
+ TOptions extends object,
181
+ State extends NavigationState,
182
+ EventMap extends EventMapBase,
183
+ > = React.ComponentType<ScreenProps<TOptions, State, EventMap>>
184
+
159
185
  /** Return a navigator that automatically injects matched routes and renders nothing when there are no children. Return type with children prop optional */
160
186
  export function withLayoutContext<
161
187
  TOptions extends object,
@@ -228,7 +254,7 @@ export function withLayoutContext<
228
254
  }
229
255
  ),
230
256
  {
231
- Screen: Screen as React.ComponentType<ScreenProps<TOptions, State, EventMap>>,
257
+ Screen: Screen as LayoutScreen<TOptions, State, EventMap>,
232
258
  }
233
259
  )
234
260
  }
@@ -237,7 +237,9 @@ export type ScreenProps<
237
237
  */
238
238
  redirect?: boolean
239
239
  initialParams?: Record<string, any>
240
- options?: TOptions
240
+ options?:
241
+ | TOptions
242
+ | ((prop: { route: RouteProp<ParamListBase, string>; navigation: any }) => TOptions)
241
243
 
242
244
  listeners?:
243
245
  | ScreenListeners<State, EventMap>
@@ -178,3 +178,12 @@ describe('native routes after HMR', () => {
178
178
  expect(loadWidget).toHaveBeenCalledOnce()
179
179
  })
180
180
  })
181
+
182
+ describe('routes a bundler already holds', () => {
183
+ it('returns a synchronously loaded route without throwing a promise', () => {
184
+ const route = { default: () => 'home' }
185
+ const context = globbedRoutesToRouteContext({ '/app/index.tsx': () => route }, 'app')
186
+
187
+ expect(context('./index.tsx')).toBe(route)
188
+ })
189
+ })
@@ -264,10 +264,16 @@ export function globbedRoutesToRouteContext(
264
264
  // native module exports register when the original loader initializes
265
265
  // them. an unvisited route can reach this path after another route's edit.
266
266
  importPromise = isNative
267
- ? routesSync[id]().then(() => hmrImport(routePaths[id]))
267
+ ? Promise.resolve(routesSync[id]()).then(() => hmrImport(routePaths[id]))
268
268
  : hmrImport(routePaths[id])
269
269
  } else {
270
- importPromise = routesSync[id]()
270
+ // a bundler that already holds the module (metro's require.context)
271
+ // returns it directly, so the first render does not suspend
272
+ const loaded = routesSync[id]()
273
+ if (!(loaded instanceof Promise)) {
274
+ return loaded
275
+ }
276
+ importPromise = loaded
271
277
  }
272
278
 
273
279
  promises[id] = importPromise
package/src/types.ts CHANGED
@@ -3,7 +3,7 @@ import type { One } from './vite/types'
3
3
  /** The list of input keys will become optional, everything else will remain the same. */
4
4
  export type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
5
5
 
6
- export type GlobbedRouteImports = Record<string, () => Promise<unknown>>
6
+ export type GlobbedRouteImports = Record<string, () => unknown>
7
7
 
8
8
  export type Endpoint = (req: Request) => Response | string | object | null
9
9
 
@@ -1,5 +1,13 @@
1
- import { withLayoutContext } from './withLayoutContext';
2
- type DrawerType = ReturnType<typeof withLayoutContext>;
1
+ import { type DrawerNavigationEventMap, type DrawerNavigationOptions, type DrawerNavigatorProps } from '@react-navigation/drawer';
2
+ import type { DrawerNavigationState, ParamListBase } from '@react-navigation/native';
3
+ import { type LayoutNavigator, type LayoutScreen } from './withLayoutContext';
4
+ export type DrawerScreenOptions = DrawerNavigationOptions & {
5
+ /** Web only: keep the screen's subtree mounted after it is left. */
6
+ keepMounted?: boolean;
7
+ };
8
+ type DrawerType = LayoutNavigator<DrawerNavigatorProps, DrawerScreenOptions> & {
9
+ Screen: LayoutScreen<DrawerScreenOptions, DrawerNavigationState<ParamListBase>, DrawerNavigationEventMap>;
10
+ };
3
11
  export declare const Drawer: DrawerType;
4
12
  export default Drawer;
5
13
  //# sourceMappingURL=Drawer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/layouts/Drawer.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAevD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAItD,eAAO,MAAM,MAAM,EAAE,UAEL,CAAA;eAED,MAAM"}
1
+ {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/layouts/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAGpF,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,YAAY,EAElB,MAAM,qBAAqB,CAAA;AAI5B,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG;IAC1D,oEAAoE;IACpE,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAaD,KAAK,UAAU,GAAG,eAAe,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,GAAG;IAC7E,MAAM,EAAE,YAAY,CAClB,mBAAmB,EACnB,qBAAqB,CAAC,aAAa,CAAC,EACpC,wBAAwB,CACzB,CAAA;CACF,CAAA;AAID,eAAO,MAAM,MAAM,EAAE,UAEL,CAAA;eAED,MAAM"}
@@ -189,7 +189,7 @@ export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit
189
189
  }>, Action>>) | undefined;
190
190
  routeNamesChangeBehavior?: ('firstMatch' | 'lastUnhandled') | undefined;
191
191
  }, "children">, "ref"> & import("react").RefAttributes<unknown>, "ref"> & import("react").RefAttributes<unknown>> & {
192
- Screen: import("react").ComponentType<import("../router/useScreens").ScreenProps<DrawerNavigationOptions, DrawerNavigationState<ParamListBase>, DrawerNavigationEventMap>>;
192
+ Screen: import("./withLayoutContext").LayoutScreen<DrawerNavigationOptions, DrawerNavigationState<ParamListBase>, DrawerNavigationEventMap>;
193
193
  };
194
194
  export default Drawer;
195
195
  //# sourceMappingURL=Drawer.web.d.ts.map
@@ -1,6 +1,7 @@
1
+ import type { NativeStackNavigatorProps } from '@react-navigation/native-stack';
1
2
  import { Protected } from '../views/Protected';
2
- import { StackHeader, StackHeaderSearchBar, StackScreen, StackToolbarBadge, StackToolbarButton, StackToolbarComponent, StackToolbarIcon, StackToolbarLabel, StackToolbarMenu, StackToolbarMenuAction, StackToolbarSearchBarSlot, StackToolbarSpacer } from './stack-utils';
3
- import { withLayoutContext } from './withLayoutContext';
3
+ import { StackHeader, StackHeaderSearchBar, StackScreen, StackToolbarBadge, StackToolbarButton, StackToolbarComponent, StackToolbarIcon, StackToolbarLabel, StackToolbarMenu, StackToolbarMenuAction, StackToolbarSearchBarSlot, StackToolbarSpacer, type StackScreenOptions } from './stack-utils';
4
+ import { type LayoutNavigator } from './withLayoutContext';
4
5
  type StackToolbarCompound = typeof StackToolbarComponent & {
5
6
  Button: typeof StackToolbarButton;
6
7
  Menu: typeof StackToolbarMenu;
@@ -11,7 +12,7 @@ type StackToolbarCompound = typeof StackToolbarComponent & {
11
12
  Icon: typeof StackToolbarIcon;
12
13
  Badge: typeof StackToolbarBadge;
13
14
  };
14
- type StackType = ReturnType<typeof withLayoutContext> & {
15
+ type StackType = LayoutNavigator<NativeStackNavigatorProps, StackScreenOptions> & {
15
16
  Screen: typeof StackScreen;
16
17
  Header: typeof StackHeader;
17
18
  Toolbar: StackToolbarCompound;
@@ -1 +1 @@
1
- {"version":3,"file":"Stack.d.ts","sourceRoot":"","sources":["../../src/layouts/Stack.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,OAAO,EAEL,WAAW,EAEX,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAKnB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AA4HvD,KAAK,oBAAoB,GAAG,OAAO,qBAAqB,GAAG;IACzD,MAAM,EAAE,OAAO,kBAAkB,CAAA;IACjC,IAAI,EAAE,OAAO,gBAAgB,CAAA;IAC7B,UAAU,EAAE,OAAO,sBAAsB,CAAA;IACzC,MAAM,EAAE,OAAO,kBAAkB,CAAA;IACjC,aAAa,EAAE,OAAO,yBAAyB,CAAA;IAC/C,KAAK,EAAE,OAAO,iBAAiB,CAAA;IAC/B,IAAI,EAAE,OAAO,gBAAgB,CAAA;IAC7B,KAAK,EAAE,OAAO,iBAAiB,CAAA;CAChC,CAAA;AAED,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,GAAG;IACtD,MAAM,EAAE,OAAO,WAAW,CAAA;IAC1B,MAAM,EAAE,OAAO,WAAW,CAAA;IAC1B,OAAO,EAAE,oBAAoB,CAAA;IAC7B,SAAS,EAAE,OAAO,SAAS,CAAA;IAC3B,SAAS,EAAE,OAAO,oBAAoB,CAAA;CACvC,CAAA;AAaD,eAAO,MAAM,KAAK,EAAE,SAML,CAAA;eAEA,KAAK"}
1
+ {"version":3,"file":"Stack.d.ts","sourceRoot":"","sources":["../../src/layouts/Stack.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,yBAAyB,EAC1B,MAAM,gCAAgC,CAAA;AAGvC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,OAAO,EAEL,WAAW,EAEX,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAElB,KAAK,kBAAkB,EAGxB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,qBAAqB,CAAA;AA4H7E,KAAK,oBAAoB,GAAG,OAAO,qBAAqB,GAAG;IACzD,MAAM,EAAE,OAAO,kBAAkB,CAAA;IACjC,IAAI,EAAE,OAAO,gBAAgB,CAAA;IAC7B,UAAU,EAAE,OAAO,sBAAsB,CAAA;IACzC,MAAM,EAAE,OAAO,kBAAkB,CAAA;IACjC,aAAa,EAAE,OAAO,yBAAyB,CAAA;IAC/C,KAAK,EAAE,OAAO,iBAAiB,CAAA;IAC/B,IAAI,EAAE,OAAO,gBAAgB,CAAA;IAC7B,KAAK,EAAE,OAAO,iBAAiB,CAAA;CAChC,CAAA;AAED,KAAK,SAAS,GAAG,eAAe,CAAC,yBAAyB,EAAE,kBAAkB,CAAC,GAAG;IAChF,MAAM,EAAE,OAAO,WAAW,CAAA;IAC1B,MAAM,EAAE,OAAO,WAAW,CAAA;IAC1B,OAAO,EAAE,oBAAoB,CAAA;IAC7B,SAAS,EAAE,OAAO,SAAS,CAAA;IAC3B,SAAS,EAAE,OAAO,oBAAoB,CAAA;CACvC,CAAA;AAaD,eAAO,MAAM,KAAK,EAAE,SAML,CAAA;eAEA,KAAK"}
@@ -1,6 +1,15 @@
1
+ import { type BottomTabNavigationEventMap, type BottomTabNavigationOptions, type BottomTabNavigatorProps } from '@react-navigation/bottom-tabs';
2
+ import type { ParamListBase, TabNavigationState } from '@react-navigation/native';
1
3
  import { Protected } from '../views/Protected';
2
- import { withLayoutContext } from './withLayoutContext';
3
- type TabsType = ReturnType<typeof withLayoutContext> & {
4
+ import { type LayoutNavigator, type LayoutScreen } from './withLayoutContext';
5
+ export type TabsScreenOptions = BottomTabNavigationOptions & {
6
+ /** Web only: the tab's link target. Native layouts reject it. */
7
+ href?: string | null;
8
+ /** Web only: keep the tab's subtree mounted after it is left. */
9
+ keepMounted?: boolean;
10
+ };
11
+ type TabsType = LayoutNavigator<BottomTabNavigatorProps, TabsScreenOptions> & {
12
+ Screen: LayoutScreen<TabsScreenOptions, TabNavigationState<ParamListBase>, BottomTabNavigationEventMap>;
4
13
  Protected: typeof Protected;
5
14
  };
6
15
  export declare const Tabs: TabsType;
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../src/layouts/Tabs.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAWvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,GAAG;IAAE,SAAS,EAAE,OAAO,SAAS,CAAA;CAAE,CAAA;AAEtF,eAAO,MAAM,IAAI,EAAE,QAGL,CAAA;eAEC,IAAI"}
1
+ {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../src/layouts/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAE7B,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAEjF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,YAAY,EAElB,MAAM,qBAAqB,CAAA;AAI5B,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,GAAG;IAC3D,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,iEAAiE;IACjE,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AASD,KAAK,QAAQ,GAAG,eAAe,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,GAAG;IAC5E,MAAM,EAAE,YAAY,CAClB,iBAAiB,EACjB,kBAAkB,CAAC,aAAa,CAAC,EACjC,2BAA2B,CAC5B,CAAA;IACD,SAAS,EAAE,OAAO,SAAS,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,QAGL,CAAA;eAEC,IAAI"}
@@ -187,7 +187,7 @@ export declare const Tabs: import("react").ForwardRefExoticComponent<Omit<import
187
187
  }>, Action>>) | undefined;
188
188
  routeNamesChangeBehavior?: ('firstMatch' | 'lastUnhandled') | undefined;
189
189
  }, "children">, "ref"> & import("react").RefAttributes<unknown>> & {
190
- Screen: import("react").ComponentType<import("../router/useScreens").ScreenProps<object, Readonly<{
190
+ Screen: import("./withLayoutContext").LayoutScreen<object, Readonly<{
191
191
  key: string;
192
192
  index: number;
193
193
  routeNames: string[];
@@ -195,10 +195,10 @@ export declare const Tabs: import("react").ForwardRefExoticComponent<Omit<import
195
195
  routes: import("@react-navigation/routers").NavigationRoute<import("@react-navigation/routers").ParamListBase, string>[];
196
196
  type: string;
197
197
  stale: false;
198
- }>, import("@react-navigation/core").EventMapBase>>;
198
+ }>, import("@react-navigation/core").EventMapBase>;
199
199
  } & {
200
200
  Protected: import("react").FunctionComponent<import("..").ProtectedProps>;
201
- Screen: import("react").ComponentType<import("../router/useScreens").ScreenProps<object, Readonly<{
201
+ Screen: import("./withLayoutContext").LayoutScreen<object, Readonly<{
202
202
  key: string;
203
203
  index: number;
204
204
  routeNames: string[];
@@ -206,7 +206,7 @@ export declare const Tabs: import("react").ForwardRefExoticComponent<Omit<import
206
206
  routes: import("@react-navigation/routers").NavigationRoute<import("@react-navigation/routers").ParamListBase, string>[];
207
207
  type: string;
208
208
  stale: false;
209
- }>, import("@react-navigation/core").EventMapBase>>;
209
+ }>, import("@react-navigation/core").EventMapBase>;
210
210
  };
211
211
  export default Tabs;
212
212
  //# sourceMappingURL=Tabs.linux.d.ts.map
@@ -17,7 +17,9 @@ export type StackScreenOptions = Omit<NativeStackNavigationOptions, 'presentatio
17
17
  */
18
18
  keepMounted?: boolean;
19
19
  };
20
- export type StackScreenProps = PropsWithChildren<ScreenProps<StackScreenOptions, StackNavigationState<ParamListBase>, NativeStackNavigationEventMap>>;
20
+ export type StackScreenProps = PropsWithChildren<Omit<ScreenProps<StackScreenOptions, StackNavigationState<ParamListBase>, NativeStackNavigationEventMap>, 'options'> & {
21
+ options?: StackScreenOptions;
22
+ }>;
21
23
  /**
22
24
  * Stack screen component with support for compositional header configuration.
23
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"StackScreen.d.ts","sourceRoot":"","sources":["../../../src/layouts/stack-utils/StackScreen.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACnF,OAAO,KAAK,EACV,6BAA6B,EAC7B,4BAA4B,EAC7B,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAqC,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAajF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAG1D,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,4BAA4B,EAAE,cAAc,CAAC,GAAG;IACpF,YAAY,CAAC,EAAE,4BAA4B,CAAC,cAAc,CAAC,GAAG,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;IAErF;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAID,MAAM,MAAM,gBAAgB,GAAG,iBAAi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a,CAAC,EACnC,6BAA6B,CAC9B,EACD,SAAS,CACV,GAAG;IAAE,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAAE,CACrC,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,gBAAgB,+BAS3E;AAgBD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,CAAA;AAC1F,wBAAgB,yBAAyB,CACvC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,kBAAkB,EAClD,OAAO,EAAE,CAAC,GAAG,CAAC,CAAA;AAyBhB,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,gBAAgB,GACtB,kBAAkB,CAgCpB"}
@@ -18,11 +18,23 @@ export declare function useFilterScreenChildren(children: React.ReactNode, { isC
18
18
  export declare function useResolvedGuardedRedirects(guardedRedirects: Map<string, OneRouter.Href | undefined>): Map<string, OneRouter.Href<{
19
19
  __branded__: any;
20
20
  }> | undefined>;
21
+ type ScreenOptionsArgs<TProps> = Extract<TProps extends {
22
+ screenOptions?: infer O;
23
+ } ? O : never, (...args: any[]) => any> extends (args: infer A) => any ? A : never;
24
+ export type LayoutNavigator<TProps extends {
25
+ children: React.ReactNode;
26
+ }, TOptions extends object> = React.ForwardRefExoticComponent<Omit<TProps, 'children' | 'screenOptions'> & {
27
+ children?: React.ReactNode;
28
+ id?: string;
29
+ screenOptions?: TOptions | ((args: ScreenOptionsArgs<TProps>) => TOptions);
30
+ } & React.RefAttributes<unknown>>;
31
+ export type LayoutScreen<TOptions extends object, State extends NavigationState, EventMap extends EventMapBase> = React.ComponentType<ScreenProps<TOptions, State, EventMap>>;
21
32
  /** Return a navigator that automatically injects matched routes and renders nothing when there are no children. Return type with children prop optional */
22
33
  export declare function withLayoutContext<TOptions extends object, T extends React.ComponentType<any>, State extends NavigationState, EventMap extends EventMapBase>(Nav: T, processor?: (options: ScreenProps<TOptions, State, EventMap>[]) => ScreenProps<TOptions, State, EventMap>[], options?: {
23
34
  props?: any;
24
35
  undeclaredRoutes?: boolean;
25
36
  }): React.ForwardRefExoticComponent<React.PropsWithoutRef<PickPartial<React.ComponentProps<T>, "children">> & React.RefAttributes<unknown>> & {
26
- Screen: React.ComponentType<ScreenProps<TOptions, State, EventMap>>;
37
+ Screen: LayoutScreen<TOptions, State, EventMap>;
27
38
  };
39
+ export {};
28
40
  //# sourceMappingURL=withLayoutContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withLayoutContext.d.ts","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAUrD,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,sBAAsB,CAAA;AAEzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAO3C,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,EACE,iBAAiB,EACjB,UAAU,GACX,GAAE;IACD,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAA;CACf;;;;;;;EAiGP;AAED,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC;;gBA0B1D;AAED,2JAA2J;AAC3J,wBAAgB,iBAAiB,CAC/B,QAAQ,SAAS,MAAM,EACvB,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAClC,KAAK,SAAS,eAAe,EAC7B,QAAQ,SAAS,YAAY,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AC3B;YAwDqB,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC;EAG9D"}
@@ -35,7 +35,10 @@ export type ScreenProps<TOptions extends Record<string, any> = Record<string, an
35
35
  */
36
36
  redirect?: boolean;
37
37
  initialParams?: Record<string, any>;
38
- options?: TOptions;
38
+ options?: TOptions | ((prop: {
39
+ route: RouteProp<ParamListBase, string>;
40
+ navigation: any;
41
+ }) => TOptions);
39
42
  listeners?: ScreenListeners<State, EventMap> | ((prop: {
40
43
  route: RouteProp<ParamListBase, string>;
41
44
  navigation: any;
@@ -1 +1 @@
1
- {"version":3,"file":"useScreens.d.ts","sourceRoot":"","sources":["../../src/router/useScreens.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,SAAS,EACT,eAAe,EAChB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAA0D,MAAM,OAAO,CAAA;AAiB9E,OAAO,EAIL,KAAK,SAAS,EAIf,MAAM,SAAS,CAAA;AA+ChB,eAAO,MAAQ,MAAM;;;;;;;;;;;;;;;;2BAAE,KAAK;;;;;;;;iBAAwC,CAAA;AAkJpE,MAAM,MAAM,WAAW,CACrB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1D,KAAK,SAAS,eAAe,GAAG,eAAe,EAC/C,QAAQ,SAAS,YAAY,GAAG,YAAY,IAC1C;IACF,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,OAAO,CAAC,EAAE,QAAQ,CAAA;IAElB,SAAS,CAAC,EACN,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,GAChC,CAAC,CAAC,IAAI,EAAE;QACN,KAAK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":"useViteRoutes.d.ts","sourceRoot":"","sources":["../../src/router/useViteRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAYxC,wBAAgB,aAAa,CAC3B,MAAM,EAAE,mBAAmB,EAC3B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,GAAG,CAAC,YAAY,EAC1B,OAAO,CAAC,EAAE,MAAM,OAmBjB;AAKD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,CAErE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAEnD;AAED,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AAgDD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDrE;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,mBAAmB,EAC1B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,GAAG,CAAC,YAAY,OAM3B;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,mBAAmB,EAC1B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,GAAG,CAAC,YAAY,GACzB,GAAG,CAAC,YAAY,CAuLlB"}
package/types/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { One } from './vite/types';
2
2
  /** The list of input keys will become optional, everything else will remain the same. */
3
3
  export type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
4
- export type GlobbedRouteImports = Record<string, () => Promise<unknown>>;
4
+ export type GlobbedRouteImports = Record<string, () => unknown>;
5
5
  export type Endpoint = (req: Request) => Response | string | object | null;
6
6
  export type RenderApp = (props: RenderAppProps) => Promise<string>;
7
7
  export type LoaderProps<Params extends object = Record<string, string | string[]>, SearchParams extends object | undefined = undefined> = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAEvC,yFAAyF;AACzF,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAEhF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;AAExE,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAE1E,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAElE,MAAM,MAAM,WAAW,CACrB,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EACzD,YAAY,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,IACjD;IACF,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,GAAG,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,GAChC;IACE;;;;;OAKG;IACH,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,GACD,EAAE,CAAC,CAAA;AAEP,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,GAAG,CAAC,eAAe,GAAG,WAAW,CAAA;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