expo-router 5.0.6 → 5.1.0

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 (68) hide show
  1. package/assets/arrow_down.png +0 -0
  2. package/build/ExpoRoot.d.ts.map +1 -1
  3. package/build/ExpoRoot.js +3 -0
  4. package/build/ExpoRoot.js.map +1 -1
  5. package/build/exports.d.ts +1 -0
  6. package/build/exports.d.ts.map +1 -1
  7. package/build/exports.js +3 -1
  8. package/build/exports.js.map +1 -1
  9. package/build/fork/getPathFromState-forks.js +1 -4
  10. package/build/fork/getPathFromState-forks.js.map +1 -1
  11. package/build/fork/getStateFromPath-forks.d.ts +2 -0
  12. package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
  13. package/build/fork/getStateFromPath-forks.js +14 -1
  14. package/build/fork/getStateFromPath-forks.js.map +1 -1
  15. package/build/fork/useLinking.d.ts.map +1 -1
  16. package/build/fork/useLinking.js +28 -6
  17. package/build/fork/useLinking.js.map +1 -1
  18. package/build/getReactNavigationConfig.d.ts.map +1 -1
  19. package/build/getReactNavigationConfig.js +8 -7
  20. package/build/getReactNavigationConfig.js.map +1 -1
  21. package/build/getRoutesCore.d.ts.map +1 -1
  22. package/build/getRoutesCore.js +6 -10
  23. package/build/getRoutesCore.js.map +1 -1
  24. package/build/getRoutesRedirects.d.ts.map +1 -1
  25. package/build/getRoutesRedirects.js +22 -16
  26. package/build/getRoutesRedirects.js.map +1 -1
  27. package/build/global-state/router-store.d.ts.map +1 -1
  28. package/build/global-state/router-store.js +6 -1
  29. package/build/global-state/router-store.js.map +1 -1
  30. package/build/global-state/routing.d.ts +14 -0
  31. package/build/global-state/routing.d.ts.map +1 -1
  32. package/build/global-state/routing.js +41 -6
  33. package/build/global-state/routing.js.map +1 -1
  34. package/build/hooks.d.ts.map +1 -1
  35. package/build/hooks.js +5 -0
  36. package/build/hooks.js.map +1 -1
  37. package/build/imperative-api.d.ts +1 -0
  38. package/build/imperative-api.d.ts.map +1 -1
  39. package/build/imperative-api.js +9 -0
  40. package/build/imperative-api.js.map +1 -1
  41. package/build/layouts/TabsClient.d.ts +3 -1
  42. package/build/layouts/TabsClient.d.ts.map +1 -1
  43. package/build/layouts/TabsClient.js +2 -0
  44. package/build/layouts/TabsClient.js.map +1 -1
  45. package/build/matchers.d.ts +6 -3
  46. package/build/matchers.d.ts.map +1 -1
  47. package/build/matchers.js +15 -11
  48. package/build/matchers.js.map +1 -1
  49. package/build/rsc/middleware.d.ts.map +1 -1
  50. package/build/rsc/middleware.js +15 -27
  51. package/build/rsc/middleware.js.map +1 -1
  52. package/build/typed-routes/generate.js +5 -2
  53. package/build/typed-routes/generate.js.map +1 -1
  54. package/build/useFocusEffect.d.ts +2 -2
  55. package/build/useFocusEffect.js +2 -2
  56. package/build/useFocusEffect.js.map +1 -1
  57. package/build/views/Navigator.d.ts.map +1 -1
  58. package/build/views/Navigator.js +5 -2
  59. package/build/views/Navigator.js.map +1 -1
  60. package/build/views/Sitemap.d.ts.map +1 -1
  61. package/build/views/Sitemap.js +56 -72
  62. package/build/views/Sitemap.js.map +1 -1
  63. package/build/views/useSitemap.d.ts +12 -0
  64. package/build/views/useSitemap.d.ts.map +1 -0
  65. package/build/views/useSitemap.js +50 -0
  66. package/build/views/useSitemap.js.map +1 -0
  67. package/package.json +2 -2
  68. package/_async-server-import.js +0 -21
package/build/matchers.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.matchDynamicName = matchDynamicName;
4
- exports.matchDeepDynamicRouteName = matchDeepDynamicRouteName;
5
4
  exports.testNotFound = testNotFound;
6
5
  exports.matchGroupName = matchGroupName;
7
6
  exports.matchLastGroupName = matchLastGroupName;
@@ -14,15 +13,20 @@ exports.removeFileSystemDots = removeFileSystemDots;
14
13
  exports.stripGroupSegmentsFromPath = stripGroupSegmentsFromPath;
15
14
  exports.stripInvisibleSegmentsFromPath = stripInvisibleSegmentsFromPath;
16
15
  exports.isTypedRoute = isTypedRoute;
16
+ /** Match `[page]` -> `page` or `[...group]` -> `...group` */
17
+ const dynamicNameRe = /^\[([^[\]]+?)\]$/;
17
18
  /** Match `[page]` -> `page` */
18
19
  function matchDynamicName(name) {
19
- // Don't match `...` or `[` or `]` inside the brackets
20
- // eslint-disable-next-line no-useless-escape
21
- return name.match(/^\[([^[\](?:\.\.\.)]+?)\]$/)?.[1];
22
- }
23
- /** Match `[...page]` -> `page` */
24
- function matchDeepDynamicRouteName(name) {
25
- return name.match(/^\[\.\.\.([^/]+?)\]$/)?.[1];
20
+ const paramName = name.match(dynamicNameRe)?.[1];
21
+ if (paramName == null) {
22
+ return undefined;
23
+ }
24
+ else if (paramName.startsWith('...')) {
25
+ return { name: paramName.slice(3), deep: true };
26
+ }
27
+ else {
28
+ return { name: paramName, deep: false };
29
+ }
26
30
  }
27
31
  /** Test `/` -> `page` */
28
32
  function testNotFound(name) {
@@ -30,15 +34,15 @@ function testNotFound(name) {
30
34
  }
31
35
  /** Match `(page)` -> `page` */
32
36
  function matchGroupName(name) {
33
- return name.match(/^(?:[^\\(\\)])*?\(([^\\/]+)\).*?$/)?.[1];
37
+ return name.match(/^(?:[^\\()])*?\(([^\\/]+)\)/)?.[1];
34
38
  }
35
39
  /** Match `(app)/(page)` -> `page` */
36
40
  function matchLastGroupName(name) {
37
- return name.match(/.*(?:\/|^)\(([^\\/\s]+)\)[^\s]*$/)?.[1];
41
+ return name.match(/.*(?:\/|^)\(([^\\/]+)\)[^\s]*$/)?.[1];
38
42
  }
39
43
  /** Match the first array group name `(a,b,c)/(d,c)` -> `'a,b,c'` */
40
44
  function matchArrayGroupName(name) {
41
- return name.match(/(?:[^\\(\\)])*?\(([^\\/]+,[^\\/]+)\).*?$/)?.[1];
45
+ return name.match(/(?:[^\\()])*?\(([^\\/]+,[^\\/]+)\)/)?.[1];
42
46
  }
43
47
  function getNameFromFilePath(name) {
44
48
  return removeSupportedExtensions(removeFileSystemDots(name));
@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CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,KAAK,IAAI,CAAC;AAC5F,CAAC","sourcesContent":["/** Match `[page]` -> `page` */\nexport function matchDynamicName(name: string): string | undefined {\n // Don't match `...` or `[` or `]` inside the brackets\n // eslint-disable-next-line no-useless-escape\n return name.match(/^\\[([^[\\](?:\\.\\.\\.)]+?)\\]$/)?.[1];\n}\n\n/** Match `[...page]` -> `page` */\nexport function matchDeepDynamicRouteName(name: string): string | undefined {\n return name.match(/^\\[\\.\\.\\.([^/]+?)\\]$/)?.[1];\n}\n\n/** Test `/` -> `page` */\nexport function testNotFound(name: string): boolean {\n return /\\+not-found$/.test(name);\n}\n\n/** Match `(page)` -> `page` */\nexport function matchGroupName(name: string): string | undefined {\n return name.match(/^(?:[^\\\\(\\\\)])*?\\(([^\\\\/]+)\\).*?$/)?.[1];\n}\n\n/** Match `(app)/(page)` -> `page` */\nexport function matchLastGroupName(name: string): string | undefined {\n return name.match(/.*(?:\\/|^)\\(([^\\\\/\\s]+)\\)[^\\s]*$/)?.[1];\n}\n\n/** Match the first array group name `(a,b,c)/(d,c)` -> `'a,b,c'` */\nexport function matchArrayGroupName(name: string) {\n return name.match(/(?:[^\\\\(\\\\)])*?\\(([^\\\\/]+,[^\\\\/]+)\\).*?$/)?.[1];\n}\n\nexport function getNameFromFilePath(name: string): string {\n return removeSupportedExtensions(removeFileSystemDots(name));\n}\n\nexport function getContextKey(name: string): string {\n // The root path is `` (empty string) so always prepend `/` to ensure\n // there is some value.\n const normal = '/' + getNameFromFilePath(name);\n if (!normal.endsWith('_layout')) {\n return normal;\n }\n return normal.replace(/\\/?_layout$/, '');\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx`, and the +api suffix */\nexport function removeSupportedExtensions(name: string): string {\n return name.replace(/(\\+api)?\\.[jt]sx?$/g, '');\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx` */\nexport function removeFileSystemExtensions(name: string): string {\n return name.replace(/\\.[jt]sx?$/g, '');\n}\n\n// Remove any amount of `./` and `../` from the start of the string\nexport function removeFileSystemDots(filePath: string): string {\n return filePath.replace(/^(?:\\.\\.?\\/)+/g, '');\n}\n\nexport function stripGroupSegmentsFromPath(path: string): string {\n return path\n .split('/')\n .reduce((acc, v) => {\n if (matchGroupName(v) == null) {\n acc.push(v);\n }\n return acc;\n }, [] as string[])\n .join('/');\n}\n\nexport function stripInvisibleSegmentsFromPath(path: string): string {\n return stripGroupSegmentsFromPath(path).replace(/\\/?index$/, '');\n}\n\n/**\n * Match:\n * - _layout files, +html, +not-found, string+api, etc\n * - Routes can still use `+`, but it cannot be in the last segment.\n */\nexport function isTypedRoute(name: string) {\n return !name.startsWith('+') && name.match(/(_layout|[^/]*?\\+[^/]*?)\\.[tj]sx?$/) === null;\n}\n"]}
1
+ {"version":3,"file":"matchers.js","sourceRoot":"","sources":["../src/matchers.tsx"],"names":[],"mappings":";;AASA,4CASC;AAGD,oCAEC;AAGD,wCAEC;AAGD,gDAEC;AAGD,kDAEC;AAED,kDAEC;AAED,sCAQC;AAGD,8DAEC;AAGD,gEAEC;AAGD,oDAEC;AAED,gEAUC;AAED,wEAEC;AAOD,oCAEC;AA5FD,6DAA6D;AAC7D,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAOzC,+BAA+B;AAC/B,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;SAAM,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAClD,CAAC;SAAM,CAAC;QACN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AO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,mEAAmE;AACnE,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,OAAO,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,SAAgB,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACjB,IAAI,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAc,CAAC;SACjB,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAAgB,8BAA8B,CAAC,IAAY;IACzD,OAAO,0BAA0B,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,KAAK,IAAI,CAAC;AAC5F,CAAC","sourcesContent":["/** Match `[page]` -> `page` or `[...group]` -> `...group` */\nconst dynamicNameRe = /^\\[([^[\\]]+?)\\]$/;\n\ninterface DynamicNameMatch {\n name: string;\n deep: boolean;\n}\n\n/** Match `[page]` -> `page` */\nexport function matchDynamicName(name: string): DynamicNameMatch | undefined {\n const paramName = name.match(dynamicNameRe)?.[1];\n if (paramName == null) {\n return undefined;\n } else if (paramName.startsWith('...')) {\n return { name: paramName.slice(3), deep: true };\n } else {\n return { name: paramName, deep: false };\n }\n}\n\n/** Test `/` -> `page` */\nexport function testNotFound(name: string): boolean {\n return /\\+not-found$/.test(name);\n}\n\n/** Match `(page)` -> `page` */\nexport function matchGroupName(name: string): string | undefined {\n return name.match(/^(?:[^\\\\()])*?\\(([^\\\\/]+)\\)/)?.[1];\n}\n\n/** Match `(app)/(page)` -> `page` */\nexport function matchLastGroupName(name: string): string | undefined {\n return name.match(/.*(?:\\/|^)\\(([^\\\\/]+)\\)[^\\s]*$/)?.[1];\n}\n\n/** Match the first array group name `(a,b,c)/(d,c)` -> `'a,b,c'` */\nexport function matchArrayGroupName(name: string) {\n return name.match(/(?:[^\\\\()])*?\\(([^\\\\/]+,[^\\\\/]+)\\)/)?.[1];\n}\n\nexport function getNameFromFilePath(name: string): string {\n return removeSupportedExtensions(removeFileSystemDots(name));\n}\n\nexport function getContextKey(name: string): string {\n // The root path is `` (empty string) so always prepend `/` to ensure\n // there is some value.\n const normal = '/' + getNameFromFilePath(name);\n if (!normal.endsWith('_layout')) {\n return normal;\n }\n return normal.replace(/\\/?_layout$/, '');\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx`, and the +api suffix */\nexport function removeSupportedExtensions(name: string): string {\n return name.replace(/(\\+api)?\\.[jt]sx?$/g, '');\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx` */\nexport function removeFileSystemExtensions(name: string): string {\n return name.replace(/\\.[jt]sx?$/g, '');\n}\n\n// Remove any amount of `./` and `../` from the start of the string\nexport function removeFileSystemDots(filePath: string): string {\n return filePath.replace(/^(?:\\.\\.?\\/)+/g, '');\n}\n\nexport function stripGroupSegmentsFromPath(path: string): string {\n return path\n .split('/')\n .reduce((acc, v) => {\n if (matchGroupName(v) == null) {\n acc.push(v);\n }\n return acc;\n }, [] as string[])\n .join('/');\n}\n\nexport function stripInvisibleSegmentsFromPath(path: string): string {\n return stripGroupSegmentsFromPath(path).replace(/\\/?index$/, '');\n}\n\n/**\n * Match:\n * - _layout files, +html, +not-found, string+api, etc\n * - Routes can still use `+`, but it cannot be in the last segment.\n */\nexport function isTypedRoute(name: string) {\n return !name.startsWith('+') && name.match(/(_layout|[^/]*?\\+[^/]*?)\\.[tj]sx?$/) === null;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AA0EvE,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,MAAM,OAAO,CAAC,cAAc,6BAA6B,CAAC,CAAC,CAAC;CACrE,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,SAAS,EAClB,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,aAAa,GAC3F,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAuE9B;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAa9B"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAkEvE,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,MAAM,OAAO,CAAC,cAAc,6BAA6B,CAAC,CAAC,CAAC;CACrE,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,SAAS,EAClB,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,aAAa,GAC3F,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAiE9B;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAY9B"}
@@ -6,12 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.renderRscWithImportsAsync = renderRscWithImportsAsync;
7
7
  exports.renderRscAsync = renderRscAsync;
8
8
  const expo_constants_1 = __importDefault(require("expo-constants"));
9
- const _async_server_import_1 = require("expo-router/_async-server-import");
10
9
  const node_path_1 = __importDefault(require("node:path"));
11
10
  const rsc_renderer_1 = require("./rsc-renderer");
12
11
  const debug = require('debug')('expo:server:rsc-renderer');
13
12
  // Tracking the implementation in expo/cli's MetroBundlerDevServer
14
13
  const rscRenderContext = new Map();
14
+ function serverRequire(...targetOutputModulePath) {
15
+ // NOTE(@kitten): This `__dirname` will be located in the output file system, e.g. `dist/server/*`
16
+ const filePath = node_path_1.default.join(__dirname, ...targetOutputModulePath);
17
+ return $$require_external(filePath);
18
+ }
15
19
  function getRscRenderContext(platform) {
16
20
  // NOTE(EvanBacon): We memoize this now that there's a persistent server storage cache for Server Actions.
17
21
  if (rscRenderContext.has(platform)) {
@@ -21,23 +25,13 @@ function getRscRenderContext(platform) {
21
25
  rscRenderContext.set(platform, context);
22
26
  return context;
23
27
  }
24
- function interopDefault(mod) {
25
- if ('default' in mod && typeof mod.default === 'object' && mod.default) {
26
- const def = mod.default;
27
- if ('default' in def && typeof def.default === 'object' && def.default) {
28
- return def.default;
29
- }
30
- return mod.default;
31
- }
32
- return mod;
33
- }
34
- async function getServerActionManifest(distFolder, platform) {
28
+ function getServerActionManifest(_distFolder, platform) {
35
29
  const filePath = `../../rsc/${platform}/action-manifest.js`;
36
- return interopDefault(await (0, _async_server_import_1.asyncServerImport)(filePath));
30
+ return serverRequire(filePath);
37
31
  }
38
- async function getSSRManifest(_distFolder, platform) {
32
+ function getSSRManifest(_distFolder, platform) {
39
33
  const filePath = `../../rsc/${platform}/ssr-manifest.js`;
40
- return interopDefault(await (0, _async_server_import_1.asyncServerImport)(filePath));
34
+ return serverRequire(filePath);
41
35
  }
42
36
  async function renderRscWithImportsAsync(distFolder, imports, { body, platform, searchParams, config, method, input, contentType, headers }) {
43
37
  globalThis.__expo_platform_header = platform;
@@ -51,8 +45,8 @@ async function renderRscWithImportsAsync(distFolder, imports, { body, platform,
51
45
  redirects: expo_constants_1.default.expoConfig?.extra?.router?.redirects,
52
46
  rewrites: expo_constants_1.default.expoConfig?.extra?.router?.rewrites,
53
47
  });
54
- const ssrManifest = await getSSRManifest(distFolder, platform);
55
- const actionManifest = await getServerActionManifest(distFolder, platform);
48
+ const ssrManifest = getSSRManifest(distFolder, platform);
49
+ const actionManifest = getServerActionManifest(distFolder, platform);
56
50
  return (0, rsc_renderer_1.renderRsc)({
57
51
  body: body ?? undefined,
58
52
  context,
@@ -85,13 +79,8 @@ async function renderRscWithImportsAsync(distFolder, imports, { body, platform,
85
79
  },
86
80
  async loadServerModuleRsc(file) {
87
81
  debug('loadServerModuleRsc', file);
88
- const filePath = node_path_1.default.join('../../../', file);
89
- const m = await (0, _async_server_import_1.asyncServerImport)(filePath);
90
- // TODO: This is a hack to workaround a cloudflare/metro issue where there's an extra `default` wrapper.
91
- if (typeof caches !== 'undefined') {
92
- return m.default;
93
- }
94
- return m;
82
+ // NOTE(@kitten): [WORKAROUND] Assumes __dirname is at `dist/server/_expo/functions/_flight`
83
+ return serverRequire('../../../', file);
95
84
  },
96
85
  entries: entries,
97
86
  });
@@ -100,9 +89,8 @@ async function renderRscAsync(distFolder, args) {
100
89
  const platform = args.platform;
101
90
  return renderRscWithImportsAsync(distFolder, {
102
91
  router: () => {
103
- // Assumes this file is saved to: `dist/server/_expo/functions/_flight/[...rsc].js`
104
- const filePath = `../../rsc/${platform}/router.js`;
105
- return (0, _async_server_import_1.asyncServerImport)(filePath);
92
+ // NOTE(@kitten): [WORKAROUND] Assumes __dirname is at `dist/server/_expo/functions/_flight`
93
+ return serverRequire(`../../rsc/${platform}/router.js`);
106
94
  },
107
95
  }, args);
108
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":";;;;;AAsFA,8DA2EC;AAED,wCAgBC;AA1KD,oEAAuC;AACvC,2EAAqE;AACrE,0DAA6B;AAE7B,iDAA2C;AAE3C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,0BAA0B,CAAC,CAAC;AAE3D,kEAAkE;AAClE,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAe,CAAC;AAEhD,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,0GAA0G;IAC1G,IAAI,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnC,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;IACzC,CAAC;IAED,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,cAAc,CAAC,GAAQ;IAC9B,IAAI,SAAS,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACvE,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC;QACxB,IAAI,SAAS,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACvE,OAAO,GAAG,CAAC,OAAO,CAAC;QACrB,CAAC;QACD,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,KAAK,UAAU,uBAAuB,CACpC,UAAkB,EAClB,QAAgB;IAahB,MAAM,QAAQ,GAAG,aAAa,QAAQ,qBAAqB,CAAC;IAC5D,OA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,CAAC,CAAC;YAE5C,wGAAwG;YACxG,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;gBAClC,OAAO,CAAC,CAAC,OAAO,CAAC;YACnB,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,EAAE,OAAQ;KAClB,CACF,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,UAAkB,EAClB,IAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,OAAO,yBAAyB,CAC9B,UAAU,EACV;QACE,MAAM,EAAE,GAAG,EAAE;YACX,mFAAmF;YACnF,MAAM,QAAQ,GAAG,aAAa,QAAQ,YAAY,CAAC;YACnD,OAAO,IAAA,wCAAiB,EAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;KACF,EACD,IAAI,CACL,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n// This module is bundled with Metro in web/react-server mode and redirects to platform specific renderers.\nimport type { RenderRscArgs } from '@expo/server/build/middleware/rsc';\nimport Constants from 'expo-constants';\nimport { asyncServerImport } from 'expo-router/_async-server-import';\nimport path from 'node:path';\n\nimport { renderRsc } from './rsc-renderer';\n\nconst debug = require('debug')('expo:server:rsc-renderer');\n\n// Tracking the implementation in expo/cli's MetroBundlerDevServer\nconst rscRenderContext = new Map<string, any>();\n\nfunction getRscRenderContext(platform: string) {\n // NOTE(EvanBacon): We memoize this now that there's a persistent server storage cache for Server Actions.\n if (rscRenderContext.has(platform)) {\n return rscRenderContext.get(platform)!;\n }\n\n const context = {};\n\n rscRenderContext.set(platform, context);\n return context;\n}\n\nfunction interopDefault(mod: any) {\n if ('default' in mod && typeof mod.default === 'object' && mod.default) {\n const def = mod.default;\n if ('default' in def && typeof def.default === 'object' && def.default) {\n return def.default;\n }\n return mod.default;\n }\n return mod;\n}\n\nasync function getServerActionManifest(\n distFolder: string,\n platform: string\n): Promise<\n Record<\n // Input ID\n string,\n [\n // Metro ID\n string,\n // Chunk location.\n string,\n ]\n >\n> {\n const filePath = `../../rsc/${platform}/action-manifest.js`;\n return interopDefault(await asyncServerImport(filePath));\n}\n\nasync function getSSRManifest(\n _distFolder: string,\n platform: string\n): Promise<\n Record<\n // Input ID\n string,\n [\n // Metro ID\n string,\n // Chunk location.\n string,\n ]\n >\n> {\n const filePath = `../../rsc/${platform}/ssr-manifest.js`;\n return interopDefault(await asyncServerImport(filePath));\n}\n\n// The import map allows us to use external modules from different bundling contexts.\ntype ImportMap = {\n router: () => Promise<typeof import('./router/expo-definedRouter')>;\n};\n\nexport async function renderRscWithImportsAsync(\n distFolder: string,\n imports: ImportMap,\n { body, platform, searchParams, config, method, input, contentType, headers }: RenderRscArgs\n): Promise<ReadableStream<any>> {\n globalThis.__expo_platform_header = platform;\n if (method === 'POST' && !body) {\n throw new Error('Server request must be provided when method is POST (server actions)');\n }\n\n const context = getRscRenderContext(platform);\n context['__expo_requestHeaders'] = headers;\n\n const router = await imports.router();\n const entries = router.default({\n redirects: Constants.expoConfig?.extra?.router?.redirects,\n rewrites: Constants.expoConfig?.extra?.router?.rewrites,\n });\n\n const ssrManifest = await getSSRManifest(distFolder, platform);\n const actionManifest = await getServerActionManifest(distFolder, platform);\n return renderRsc(\n {\n body: body ?? undefined,\n context,\n config,\n input,\n contentType,\n decodedBody: searchParams.get('x-expo-params'),\n },\n {\n isExporting: true,\n\n resolveClientEntry(file: string, isServer: boolean) {\n debug('resolveClientEntry', file, { isServer });\n\n if (isServer) {\n if (!(file in actionManifest)) {\n throw new Error(\n `Could not find file in server action manifest: ${file}. ${JSON.stringify(actionManifest)}`\n );\n }\n\n const [id, chunk] = actionManifest[file];\n return {\n id,\n chunks: chunk ? [chunk] : [],\n };\n }\n\n if (!(file in ssrManifest)) {\n throw new Error(`Could not find file in SSR manifest: ${file}`);\n }\n\n const [id, chunk] = ssrManifest[file];\n return {\n id,\n chunks: chunk ? [chunk] : [],\n };\n },\n async loadServerModuleRsc(file) {\n debug('loadServerModuleRsc', file);\n const filePath = path.join('../../../', file);\n const m = await asyncServerImport(filePath);\n\n // TODO: This is a hack to workaround a cloudflare/metro issue where there's an extra `default` wrapper.\n if (typeof caches !== 'undefined') {\n return m.default;\n }\n return m;\n },\n\n entries: entries!,\n }\n );\n}\n\nexport async function renderRscAsync(\n distFolder: string,\n args: RenderRscArgs\n): Promise<ReadableStream<any>> {\n const platform = args.platform;\n return renderRscWithImportsAsync(\n distFolder,\n {\n router: () => {\n // Assumes this file is saved to: `dist/server/_expo/functions/_flight/[...rsc].js`\n const filePath = `../../rsc/${platform}/router.js`;\n return asyncServerImport(filePath);\n },\n },\n args\n );\n}\n"]}
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":";;;;;AA8EA,8DAqEC;AAED,wCAeC;AA3JD,oEAAuC;AACvC,0DAA6B;AAE7B,iDAA2C;AAI3C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,0BAA0B,CAAC,CAAC;AAE3D,kEAAkE;AAClE,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAe,CAAC;AAEhD,SAAS,aAAa,CAAU,GAAG,sBAAgC;IACjE,kGAAkG;IAClG,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,sBAAsB,CAAC,CAAC;IACjE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,0GAA0G;IAC1G,IAAI,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnC,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;IACzC,CAAC;IAED,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAA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AAC,CAAC;QAC1C,CAAC;QAED,OAAO,EAAE,OAAQ;KAClB,CACF,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,UAAkB,EAClB,IAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,OAAO,yBAAyB,CAC9B,UAAU,EACV;QACE,MAAM,EAAE,GAAG,EAAE;YACX,4FAA4F;YAC5F,OAAO,aAAa,CAAC,aAAa,QAAQ,YAAY,CAAC,CAAC;QAC1D,CAAC;KACF,EACD,IAAI,CACL,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n// This module is bundled with Metro in web/react-server mode and redirects to platform specific renderers.\nimport type { RenderRscArgs } from '@expo/server/build/middleware/rsc';\nimport Constants from 'expo-constants';\nimport path from 'node:path';\n\nimport { renderRsc } from './rsc-renderer';\n\ndeclare const $$require_external: typeof require;\n\nconst debug = require('debug')('expo:server:rsc-renderer');\n\n// Tracking the implementation in expo/cli's MetroBundlerDevServer\nconst rscRenderContext = new Map<string, any>();\n\nfunction serverRequire<T = any>(...targetOutputModulePath: string[]): T {\n // NOTE(@kitten): This `__dirname` will be located in the output file system, e.g. `dist/server/*`\n const filePath = path.join(__dirname, ...targetOutputModulePath);\n return $$require_external(filePath);\n}\n\nfunction getRscRenderContext(platform: string) {\n // NOTE(EvanBacon): We memoize this now that there's a persistent server storage cache for Server Actions.\n if (rscRenderContext.has(platform)) {\n return rscRenderContext.get(platform)!;\n }\n\n const context = {};\n\n rscRenderContext.set(platform, context);\n return context;\n}\n\nfunction getServerActionManifest(\n _distFolder: string,\n platform: string\n): Record<\n // Input ID\n string,\n [\n // Metro ID\n string,\n // Chunk location.\n string,\n ]\n> {\n const filePath = `../../rsc/${platform}/action-manifest.js`;\n return serverRequire(filePath);\n}\n\nfunction getSSRManifest(\n _distFolder: string,\n platform: string\n): Record<\n // Input ID\n string,\n [\n // Metro ID\n string,\n // Chunk location.\n string,\n ]\n> {\n const filePath = `../../rsc/${platform}/ssr-manifest.js`;\n return serverRequire(filePath);\n}\n\n// The import map allows us to use external modules from different bundling contexts.\ntype ImportMap = {\n router: () => Promise<typeof import('./router/expo-definedRouter')>;\n};\n\nexport async function renderRscWithImportsAsync(\n distFolder: string,\n imports: ImportMap,\n { body, platform, searchParams, config, method, input, contentType, headers }: RenderRscArgs\n): Promise<ReadableStream<any>> {\n globalThis.__expo_platform_header = platform;\n if (method === 'POST' && !body) {\n throw new Error('Server request must be provided when method is POST (server actions)');\n }\n\n const context = getRscRenderContext(platform);\n context['__expo_requestHeaders'] = headers;\n\n const router = await imports.router();\n const entries = router.default({\n redirects: Constants.expoConfig?.extra?.router?.redirects,\n rewrites: Constants.expoConfig?.extra?.router?.rewrites,\n });\n\n const ssrManifest = getSSRManifest(distFolder, platform);\n const actionManifest = getServerActionManifest(distFolder, platform);\n return renderRsc(\n {\n body: body ?? undefined,\n context,\n config,\n input,\n contentType,\n decodedBody: searchParams.get('x-expo-params'),\n },\n {\n isExporting: true,\n\n resolveClientEntry(file: string, isServer: boolean) {\n debug('resolveClientEntry', file, { isServer });\n\n if (isServer) {\n if (!(file in actionManifest)) {\n throw new Error(\n `Could not find file in server action manifest: ${file}. ${JSON.stringify(actionManifest)}`\n );\n }\n\n const [id, chunk] = actionManifest[file];\n return {\n id,\n chunks: chunk ? [chunk] : [],\n };\n }\n\n if (!(file in ssrManifest)) {\n throw new Error(`Could not find file in SSR manifest: ${file}`);\n }\n\n const [id, chunk] = ssrManifest[file];\n return {\n id,\n chunks: chunk ? [chunk] : [],\n };\n },\n async loadServerModuleRsc(file) {\n debug('loadServerModuleRsc', file);\n // NOTE(@kitten): [WORKAROUND] Assumes __dirname is at `dist/server/_expo/functions/_flight`\n return serverRequire('../../../', file);\n },\n\n entries: entries!,\n }\n );\n}\n\nexport async function renderRscAsync(\n distFolder: string,\n args: RenderRscArgs\n): Promise<ReadableStream<any>> {\n const platform = args.platform;\n return renderRscWithImportsAsync(\n distFolder,\n {\n router: () => {\n // NOTE(@kitten): [WORKAROUND] Assumes __dirname is at `dist/server/_expo/functions/_flight`\n return serverRequire(`../../rsc/${platform}/router.js`);\n },\n },\n args\n );\n}\n"]}
@@ -49,14 +49,14 @@ function getTypedRoutesDeclarationFile(ctx, { partialTypedGroups = false, testIg
49
49
  .map((param) => {
50
50
  const key = param.startsWith('...') ? param.slice(3) : param;
51
51
  const value = param.startsWith('...') ? '(string | number)[]' : 'string | number';
52
- return `${key}: ${value};`;
52
+ return `${contextKeyToProperty(key)}: ${value};`;
53
53
  })
54
54
  .join('');
55
55
  const outputParams = paramsNames
56
56
  .map((param) => {
57
57
  const key = param.startsWith('...') ? param.slice(3) : param;
58
58
  const value = param.startsWith('...') ? 'string[]' : 'string';
59
- return `${key}: ${value};`;
59
+ return `${contextKeyToProperty(key)}: ${value};`;
60
60
  })
61
61
  .join('');
62
62
  dynamicRouteStrings.push(contextKeyToType(dynamicRouteTemplate
@@ -145,6 +145,9 @@ function groupRouteNodes(routeNode, groupedContextKeys = {
145
145
  }
146
146
  return groupedContextKeys;
147
147
  }
148
+ function contextKeyToProperty(contextKey) {
149
+ return !/^(?!\d)[\w$]+$/.test(contextKey) ? JSON.stringify(contextKey) : contextKey;
150
+ }
148
151
  function contextKeyToType(contextKey, partialTypedGroups) {
149
152
  if (contextKey.match(GROUP) === null) {
150
153
  return `\`${contextKey}\``;
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":";;AAmBA,sEA+GC;AAjID,4CAAyC;AACzC,0CAAwD;AAGxD,oCAAoC;AACpC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,6BAA6B;AAC7B,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,2DAA2D;AAC3D,MAAM,KAAK,GAAG,kBAAkB,CAAC;AAEjC,MAAM,SAAS,GAA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AC5C,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO,KAAK,cAAc,UAAU,iBAAiB,IAAI,CAAC;AAC5D,CAAC","sourcesContent":["import { RouteNode } from '../Route';\nimport { getRoutes } from '../getRoutes';\nimport { removeSupportedExtensions } from '../matchers';\nimport { RequireContext } from '../types';\n\n// /[...param1]/ - Match [...param1]\nconst CATCH_ALL = /\\[\\.\\.\\..+?\\]/g;\n// /[param1] - Match [param1]\nconst SLUG = /\\[.+?\\]/g;\n// /(group)/path/(group2)/route - Match [(group), (group2)]\nconst GROUP = /(?:^|\\/)\\(.*?\\)/g;\n\nconst urlParams = \"${`?${string}` | `#${string}` | ''}\";\n\nexport type GetTypedRoutesDeclarationFileOptions = {\n partialTypedGroups?: boolean;\n testIgnoreComments?: boolean;\n};\n\nexport function getTypedRoutesDeclarationFile(\n ctx: RequireContext,\n {\n partialTypedGroups = false,\n testIgnoreComments = false,\n }: GetTypedRoutesDeclarationFileOptions = {}\n) {\n let routeNode: RouteNode | null = null;\n\n try {\n routeNode = getRoutes(ctx, {\n ignore: [/_layout\\.[tj]sx?$/], // Skip layout files\n platformRoutes: false, // We don't need to generate platform specific routes\n notFound: false, // We don't need +not-found routes either\n ignoreEntryPoints: true,\n ignoreRequireErrors: true,\n importMode: 'async', // Don't load the file\n });\n } catch {\n // Ignore errors from `getRoutes`. This is also called inside the app, which has\n // a nicer UX for showing error messages\n }\n\n const groupedNodes = groupRouteNodes(routeNode);\n const staticRoutesStrings: string[] = ['Router.RelativePathString', 'Router.ExternalPathString'];\n const staticRouteInputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownInputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownInputParams }',\n ];\n const staticRouteOutputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownOutputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams }',\n ];\n\n for (const type of groupedNodes.static) {\n staticRoutesStrings.push(contextKeyToType(type + urlParams, partialTypedGroups));\n staticRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownInputParams; }`\n );\n staticRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownOutputParams; }`\n );\n }\n\n const dynamicRouteStrings: string[] = [];\n const dynamicRouteInputObjects: string[] = [];\n const dynamicRouteOutputObjects: string[] = [];\n\n for (const [dynamicRouteTemplate, paramsNames] of groupedNodes.dynamic) {\n const inputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? '(string | number)[]' : 'string | number';\n return `${key}: ${value};`;\n })\n .join('');\n\n const outputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? 'string[]' : 'string';\n return `${key}: ${value};`;\n })\n .join('');\n\n dynamicRouteStrings.push(\n contextKeyToType(\n dynamicRouteTemplate\n .replaceAll(CATCH_ALL, '${string}')\n .replaceAll(SLUG, '${Router.SingleRoutePart<T>}'),\n partialTypedGroups\n )\n );\n\n dynamicRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownInputParams & { ${inputParams} } }`\n );\n dynamicRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownOutputParams & { ${outputParams} } }`\n );\n }\n\n const href = [\n ...staticRoutesStrings,\n ...staticRouteInputObjects,\n ...dynamicRouteStrings,\n ...dynamicRouteInputObjects,\n ].join(' | ');\n\n const hrefInputParams = [...staticRouteInputObjects, ...dynamicRouteInputObjects].join(' | ');\n const hrefOutputParams = [...staticRouteOutputObjects, ...dynamicRouteOutputObjects].join(' | ');\n\n const tsExpectError = testIgnoreComments\n ? '// @ts-ignore-error -- During tests we need to ignore the \"duplicate\" declaration error, as multiple fixture declare types \\n '\n : '';\n\n return `/* eslint-disable */\nimport * as Router from 'expo-router';\n\nexport * from 'expo-router';\n\ndeclare module 'expo-router' {\n export namespace ExpoRouter {\n export interface __routes<T extends string | object = string> {\n ${tsExpectError}hrefInputParams: ${hrefInputParams};\n ${tsExpectError}hrefOutputParams: ${hrefOutputParams};\n ${tsExpectError}href: ${href};\n }\n }\n}\n`;\n}\n\nfunction groupRouteNodes(\n routeNode: RouteNode | null,\n groupedContextKeys = {\n static: new Set<string>(),\n dynamic: new Map<string, string[]>(),\n }\n) {\n if (!routeNode) {\n return groupedContextKeys;\n }\n\n // Skip non-route files\n if (routeNode.type !== 'route') {\n // Except the root layout\n if (routeNode.route === '') {\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n return groupedContextKeys;\n }\n\n return groupedContextKeys;\n }\n\n let routeKey: string;\n\n if (routeNode.generated) {\n // Some routes like the root _layout, _sitemap, +not-found are generated.\n // We cannot use the contextKey, as their context key does not specify a route\n routeKey = routeNode.route;\n } else {\n routeKey = removeSupportedExtensions(routeNode.contextKey)\n .replace(/\\/index$/, '') // Remove any trailing /index\n .replace(/^\\./, ''); // Remove any leading .\n }\n\n routeKey ||= '/'; // A routeKey may be empty for contextKey '' or './index.js'\n\n if (!routeKey.startsWith('/')) {\n // Not all generated files will have the `/` prefix\n routeKey = `/${routeKey}`;\n }\n\n routeKey = routeKey.replace(/\\\\/g, '/');\n\n if (routeNode.dynamic) {\n groupedContextKeys.dynamic.set(\n routeKey,\n routeKey\n .split('/')\n .filter((segment) => {\n return segment.startsWith('[') && segment.endsWith(']');\n })\n .map((segment) => {\n return segment.slice(1, -1);\n })\n );\n } else {\n groupedContextKeys.static.add(routeKey);\n }\n\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n\n return groupedContextKeys;\n}\n\nfunction contextKeyToType(contextKey: string, partialTypedGroups: boolean) {\n if (contextKey.match(GROUP) === null) {\n return `\\`${contextKey}\\``;\n }\n\n // If the route has groups, turn them into template strings\n const typeWithGroups = contextKey.replaceAll(GROUP, (match) => {\n const groups = match.slice(2, -1); // Remove the leading ( and the trailing )\n // When `partialRoutes` is enabled, we always change a group to a template\n if (groups.length > 1 || partialTypedGroups) {\n // Ensure each group has the trailing slash\n const groupsAsType = groups.split(',').map((group) => `'/(${group})'`);\n // `partialRoutes` allow you to skip a group\n if (partialTypedGroups) {\n groupsAsType.push(\"''\");\n }\n // Combine together into a union\n return `\\${${groupsAsType.join(' | ')}}`;\n } else {\n return match;\n }\n });\n\n let typeWithoutGroups = contextKey.replaceAll(GROUP, '') || '/';\n\n /**\n * When getting the static routes, they include a urlParams string at the end.\n * If we have a route like `/(group)/(group2)`, this would normally be collapsed to `/`.\n * But because of the urlParams, it becomes `${urlParams}` and we need to add a `/` to the start.\n */\n if (typeWithoutGroups.startsWith(urlParams)) {\n typeWithoutGroups = `/${typeWithoutGroups}`;\n }\n\n return `\\`${typeWithGroups}\\` | \\`${typeWithoutGroups}\\``;\n}\n"]}
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":";;AAmBA,sEA+GC;AAjID,4CAAyC;AACzC,0CAAwD;AAGxD,oCAAoC;AACpC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,6BAA6B;AAC7B,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,2DAA2D;AAC3D,MAAM,KAAK,GAAG,kBAAkB,CAAC;AAEjC,MAAM,SAAS,GAAG,qCAAqC,CAAC;AAOxD,SAAgB,6BAA6B,CAC3C,GAAmB,EACnB,EACE,kBAAkB,GAAG,KAAK,EAC1B,kBAAkB,GAAG,KAAK,MACc,EAAE;IAE5C,IAAI,SAAS,GAAqB,IAAI,CAAC;IAEvC,IAAI,CAAC;QACH,SAAS,GAAG,IAAA,qBAAS,EAAC,GAAG,EAAE;YACzB,MAAM,EAAE,CAAC,mBAAmB,CAAC,EAAE,oBAAoB;YACnD,cAAc,EAAE,KAA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Ac,UAAU,iBAAiB,IAAI,CAAC;AAC5D,CAAC","sourcesContent":["import { RouteNode } from '../Route';\nimport { getRoutes } from '../getRoutes';\nimport { removeSupportedExtensions } from '../matchers';\nimport { RequireContext } from '../types';\n\n// /[...param1]/ - Match [...param1]\nconst CATCH_ALL = /\\[\\.\\.\\..+?\\]/g;\n// /[param1] - Match [param1]\nconst SLUG = /\\[.+?\\]/g;\n// /(group)/path/(group2)/route - Match [(group), (group2)]\nconst GROUP = /(?:^|\\/)\\(.*?\\)/g;\n\nconst urlParams = \"${`?${string}` | `#${string}` | ''}\";\n\nexport type GetTypedRoutesDeclarationFileOptions = {\n partialTypedGroups?: boolean;\n testIgnoreComments?: boolean;\n};\n\nexport function getTypedRoutesDeclarationFile(\n ctx: RequireContext,\n {\n partialTypedGroups = false,\n testIgnoreComments = false,\n }: GetTypedRoutesDeclarationFileOptions = {}\n) {\n let routeNode: RouteNode | null = null;\n\n try {\n routeNode = getRoutes(ctx, {\n ignore: [/_layout\\.[tj]sx?$/], // Skip layout files\n platformRoutes: false, // We don't need to generate platform specific routes\n notFound: false, // We don't need +not-found routes either\n ignoreEntryPoints: true,\n ignoreRequireErrors: true,\n importMode: 'async', // Don't load the file\n });\n } catch {\n // Ignore errors from `getRoutes`. This is also called inside the app, which has\n // a nicer UX for showing error messages\n }\n\n const groupedNodes = groupRouteNodes(routeNode);\n const staticRoutesStrings: string[] = ['Router.RelativePathString', 'Router.ExternalPathString'];\n const staticRouteInputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownInputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownInputParams }',\n ];\n const staticRouteOutputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownOutputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams }',\n ];\n\n for (const type of groupedNodes.static) {\n staticRoutesStrings.push(contextKeyToType(type + urlParams, partialTypedGroups));\n staticRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownInputParams; }`\n );\n staticRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownOutputParams; }`\n );\n }\n\n const dynamicRouteStrings: string[] = [];\n const dynamicRouteInputObjects: string[] = [];\n const dynamicRouteOutputObjects: string[] = [];\n\n for (const [dynamicRouteTemplate, paramsNames] of groupedNodes.dynamic) {\n const inputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? '(string | number)[]' : 'string | number';\n return `${contextKeyToProperty(key)}: ${value};`;\n })\n .join('');\n\n const outputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? 'string[]' : 'string';\n return `${contextKeyToProperty(key)}: ${value};`;\n })\n .join('');\n\n dynamicRouteStrings.push(\n contextKeyToType(\n dynamicRouteTemplate\n .replaceAll(CATCH_ALL, '${string}')\n .replaceAll(SLUG, '${Router.SingleRoutePart<T>}'),\n partialTypedGroups\n )\n );\n\n dynamicRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownInputParams & { ${inputParams} } }`\n );\n dynamicRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownOutputParams & { ${outputParams} } }`\n );\n }\n\n const href = [\n ...staticRoutesStrings,\n ...staticRouteInputObjects,\n ...dynamicRouteStrings,\n ...dynamicRouteInputObjects,\n ].join(' | ');\n\n const hrefInputParams = [...staticRouteInputObjects, ...dynamicRouteInputObjects].join(' | ');\n const hrefOutputParams = [...staticRouteOutputObjects, ...dynamicRouteOutputObjects].join(' | ');\n\n const tsExpectError = testIgnoreComments\n ? '// @ts-ignore-error -- During tests we need to ignore the \"duplicate\" declaration error, as multiple fixture declare types \\n '\n : '';\n\n return `/* eslint-disable */\nimport * as Router from 'expo-router';\n\nexport * from 'expo-router';\n\ndeclare module 'expo-router' {\n export namespace ExpoRouter {\n export interface __routes<T extends string | object = string> {\n ${tsExpectError}hrefInputParams: ${hrefInputParams};\n ${tsExpectError}hrefOutputParams: ${hrefOutputParams};\n ${tsExpectError}href: ${href};\n }\n }\n}\n`;\n}\n\nfunction groupRouteNodes(\n routeNode: RouteNode | null,\n groupedContextKeys = {\n static: new Set<string>(),\n dynamic: new Map<string, string[]>(),\n }\n) {\n if (!routeNode) {\n return groupedContextKeys;\n }\n\n // Skip non-route files\n if (routeNode.type !== 'route') {\n // Except the root layout\n if (routeNode.route === '') {\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n return groupedContextKeys;\n }\n\n return groupedContextKeys;\n }\n\n let routeKey: string;\n\n if (routeNode.generated) {\n // Some routes like the root _layout, _sitemap, +not-found are generated.\n // We cannot use the contextKey, as their context key does not specify a route\n routeKey = routeNode.route;\n } else {\n routeKey = removeSupportedExtensions(routeNode.contextKey)\n .replace(/\\/index$/, '') // Remove any trailing /index\n .replace(/^\\./, ''); // Remove any leading .\n }\n\n routeKey ||= '/'; // A routeKey may be empty for contextKey '' or './index.js'\n\n if (!routeKey.startsWith('/')) {\n // Not all generated files will have the `/` prefix\n routeKey = `/${routeKey}`;\n }\n\n routeKey = routeKey.replace(/\\\\/g, '/');\n\n if (routeNode.dynamic) {\n groupedContextKeys.dynamic.set(\n routeKey,\n routeKey\n .split('/')\n .filter((segment) => {\n return segment.startsWith('[') && segment.endsWith(']');\n })\n .map((segment) => {\n return segment.slice(1, -1);\n })\n );\n } else {\n groupedContextKeys.static.add(routeKey);\n }\n\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n\n return groupedContextKeys;\n}\n\nfunction contextKeyToProperty(contextKey: string) {\n return !/^(?!\\d)[\\w$]+$/.test(contextKey) ? JSON.stringify(contextKey) : contextKey;\n}\n\nfunction contextKeyToType(contextKey: string, partialTypedGroups: boolean) {\n if (contextKey.match(GROUP) === null) {\n return `\\`${contextKey}\\``;\n }\n\n // If the route has groups, turn them into template strings\n const typeWithGroups = contextKey.replaceAll(GROUP, (match) => {\n const groups = match.slice(2, -1); // Remove the leading ( and the trailing )\n // When `partialRoutes` is enabled, we always change a group to a template\n if (groups.length > 1 || partialTypedGroups) {\n // Ensure each group has the trailing slash\n const groupsAsType = groups.split(',').map((group) => `'/(${group})'`);\n // `partialRoutes` allow you to skip a group\n if (partialTypedGroups) {\n groupsAsType.push(\"''\");\n }\n // Combine together into a union\n return `\\${${groupsAsType.join(' | ')}}`;\n } else {\n return match;\n }\n });\n\n let typeWithoutGroups = contextKey.replaceAll(GROUP, '') || '/';\n\n /**\n * When getting the static routes, they include a urlParams string at the end.\n * If we have a route like `/(group)/(group2)`, this would normally be collapsed to `/`.\n * But because of the urlParams, it becomes `${urlParams}` and we need to add a `/` to the start.\n */\n if (typeWithoutGroups.startsWith(urlParams)) {\n typeWithoutGroups = `/${typeWithoutGroups}`;\n }\n\n return `\\`${typeWithGroups}\\` | \\`${typeWithoutGroups}\\``;\n}\n"]}
@@ -20,13 +20,13 @@ export type EffectCallback = () => undefined | void | (() => void);
20
20
  * // Callback should be wrapped in `React.useCallback` to avoid running the effect too often.
21
21
  * useCallback(() => {
22
22
  * // Invoked whenever the route is focused.
23
- * console.log('Hello, I'm focused!');
23
+ * console.log("Hello, I'm focused!");
24
24
  *
25
25
  * // Return function is invoked whenever the route gets out of focus.
26
26
  * return () => {
27
27
  * console.log('This route is now unfocused.');
28
28
  * };
29
- * }, []);
29
+ * }, []),
30
30
  * );
31
31
  *
32
32
  * return </>;
@@ -57,13 +57,13 @@ const useLoadedNavigation_1 = require("./link/useLoadedNavigation");
57
57
  * // Callback should be wrapped in `React.useCallback` to avoid running the effect too often.
58
58
  * useCallback(() => {
59
59
  * // Invoked whenever the route is focused.
60
- * console.log('Hello, I'm focused!');
60
+ * console.log("Hello, I'm focused!");
61
61
  *
62
62
  * // Return function is invoked whenever the route gets out of focus.
63
63
  * return () => {
64
64
  * console.log('This route is now unfocused.');
65
65
  * };
66
- * }, []);
66
+ * }, []),
67
67
  * );
68
68
  *
69
69
  * return </>;
@@ -1 +1 @@
1
- {"version":3,"file":"useFocusEffect.js","sourceRoot":"","sources":["../src/useFocusEffect.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Cb,wCAsGC;AAnJD,gFAAgF;AAChF,sEAAsE;AACtE,6CAA+B;AAE/B,oEAAmE;AAOnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,cAAc,CAAC,MAAsB,EAAE,yBAAiC;IACtF,MAAM,UAAU,GAAG,IAAA,2CAAqB,GAAE,CAAC;IAE3C,IAAI,yBAAyB,KAAK,SAAS,EAAE,CAAC;QAC5C,MAAM,OAAO,GACX,sFAAsF;YACtF,8EAA8E;YAC9E,mBAAmB;YACnB,+BAA+B;YAC/B,yBAAyB;YACzB,sBAAsB;YACtB,QAAQ;YACR,oEAAoE,CAAC;QAEvE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI,OAAwC,CAAC;QAE7C,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;YAEzB,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3D,OAAO,OAAO,CAAC;YACjB,CAAC;YAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;gBAC1C,IAAI,OAAO,GACT,6FAA6F,CAAC;gBAEhG,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;oBACrB,O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C;QAEH,OAAO,GAAG,EAAE;YACV,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["'use client';\n// A fork of `useFocusEffect` that waits for the navigation state to load before\n// running the effect. This is especially useful for native redirects.\nimport * as React from 'react';\n\nimport { useOptionalNavigation } from './link/useLoadedNavigation';\n\n/**\n * Memoized callback containing the effect, should optionally return a cleanup function.\n */\nexport type EffectCallback = () => undefined | void | (() => void);\n\n/**\n * Hook to run an effect whenever a route is **focused**. Similar to\n * [`React.useEffect`](https://react.dev/reference/react/useEffect).\n *\n * This can be used to perform side-effects such as fetching data or subscribing to events.\n * The passed callback should be wrapped in [`React.useCallback`](https://react.dev/reference/react/useCallback)\n * to avoid running the effect too often.\n *\n * @example\n * ```tsx\n * import { useFocusEffect } from 'expo-router';\n * import { useCallback } from 'react';\n *\n * export default function Route() {\n * useFocusEffect(\n * // Callback should be wrapped in `React.useCallback` to avoid running the effect too often.\n * useCallback(() => {\n * // Invoked whenever the route is focused.\n * console.log('Hello, I'm focused!');\n *\n * // Return function is invoked whenever the route gets out of focus.\n * return () => {\n * console.log('This route is now unfocused.');\n * };\n * }, []);\n * );\n *\n * return </>;\n * }\n *```\n *\n * @param effect Memoized callback containing the effect, should optionally return a cleanup function.\n * @param do_not_pass_a_second_prop\n */\nexport function useFocusEffect(effect: EffectCallback, do_not_pass_a_second_prop?: never) {\n const navigation = useOptionalNavigation();\n\n if (do_not_pass_a_second_prop !== undefined) {\n const message =\n \"You passed a second argument to 'useFocusEffect', but it only accepts one argument. \" +\n \"If you want to pass a dependency array, you can use 'React.useCallback':\\n\\n\" +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' // Your code here\\n' +\n ' }, [depA, depB])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n\n console.error(message);\n }\n\n React.useEffect(() => {\n if (!navigation) {\n return;\n }\n\n let isFocused = false;\n let cleanup: undefined | void | (() => void);\n\n const callback = () => {\n const destroy = effect();\n\n if (destroy === undefined || typeof destroy === 'function') {\n return destroy;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n let message =\n 'An effect function must not return anything besides a function, which is used for clean-up.';\n\n if (destroy === null) {\n message +=\n \" You returned 'null'. If your effect does not require clean-up, return 'undefined' (or nothing).\";\n } else if (typeof (destroy as any).then === 'function') {\n message +=\n \"\\n\\nIt looks like you wrote 'useFocusEffect(async () => ...)' or returned a Promise. \" +\n 'Instead, write the async function inside your effect ' +\n 'and call it immediately:\\n\\n' +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' async function fetchData() {\\n' +\n ' // You can await here\\n' +\n ' const response = await MyAPI.getData(someId);\\n' +\n ' // ...\\n' +\n ' }\\n\\n' +\n ' fetchData();\\n' +\n ' }, [someId])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n } else {\n message += ` You returned '${JSON.stringify(destroy)}'.`;\n }\n\n console.error(message);\n }\n };\n\n // We need to run the effect on initial render/dep changes if the screen is focused\n if (navigation.isFocused()) {\n cleanup = callback();\n isFocused = true;\n }\n\n const unsubscribeFocus = navigation.addListener('focus', () => {\n // If callback was already called for focus, avoid calling it again\n // The focus event may also fire on initial render, so we guard against running the effect twice\n if (isFocused) {\n return;\n }\n\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = callback();\n isFocused = true;\n });\n\n const unsubscribeBlur = navigation.addListener('blur', () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = undefined;\n isFocused = false;\n });\n\n return () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n unsubscribeFocus();\n unsubscribeBlur();\n };\n }, [effect, navigation]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AAC;YAED,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["'use client';\n// A fork of `useFocusEffect` that waits for the navigation state to load before\n// running the effect. This is especially useful for native redirects.\nimport * as React from 'react';\n\nimport { useOptionalNavigation } from './link/useLoadedNavigation';\n\n/**\n * Memoized callback containing the effect, should optionally return a cleanup function.\n */\nexport type EffectCallback = () => undefined | void | (() => void);\n\n/**\n * Hook to run an effect whenever a route is **focused**. Similar to\n * [`React.useEffect`](https://react.dev/reference/react/useEffect).\n *\n * This can be used to perform side-effects such as fetching data or subscribing to events.\n * The passed callback should be wrapped in [`React.useCallback`](https://react.dev/reference/react/useCallback)\n * to avoid running the effect too often.\n *\n * @example\n * ```tsx\n * import { useFocusEffect } from 'expo-router';\n * import { useCallback } from 'react';\n *\n * export default function Route() {\n * useFocusEffect(\n * // Callback should be wrapped in `React.useCallback` to avoid running the effect too often.\n * useCallback(() => {\n * // Invoked whenever the route is focused.\n * console.log(\"Hello, I'm focused!\");\n *\n * // Return function is invoked whenever the route gets out of focus.\n * return () => {\n * console.log('This route is now unfocused.');\n * };\n * }, []),\n * );\n *\n * return </>;\n * }\n *```\n *\n * @param effect Memoized callback containing the effect, should optionally return a cleanup function.\n * @param do_not_pass_a_second_prop\n */\nexport function useFocusEffect(effect: EffectCallback, do_not_pass_a_second_prop?: never) {\n const navigation = useOptionalNavigation();\n\n if (do_not_pass_a_second_prop !== undefined) {\n const message =\n \"You passed a second argument to 'useFocusEffect', but it only accepts one argument. \" +\n \"If you want to pass a dependency array, you can use 'React.useCallback':\\n\\n\" +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' // Your code here\\n' +\n ' }, [depA, depB])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n\n console.error(message);\n }\n\n React.useEffect(() => {\n if (!navigation) {\n return;\n }\n\n let isFocused = false;\n let cleanup: undefined | void | (() => void);\n\n const callback = () => {\n const destroy = effect();\n\n if (destroy === undefined || typeof destroy === 'function') {\n return destroy;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n let message =\n 'An effect function must not return anything besides a function, which is used for clean-up.';\n\n if (destroy === null) {\n message +=\n \" You returned 'null'. If your effect does not require clean-up, return 'undefined' (or nothing).\";\n } else if (typeof (destroy as any).then === 'function') {\n message +=\n \"\\n\\nIt looks like you wrote 'useFocusEffect(async () => ...)' or returned a Promise. \" +\n 'Instead, write the async function inside your effect ' +\n 'and call it immediately:\\n\\n' +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' async function fetchData() {\\n' +\n ' // You can await here\\n' +\n ' const response = await MyAPI.getData(someId);\\n' +\n ' // ...\\n' +\n ' }\\n\\n' +\n ' fetchData();\\n' +\n ' }, [someId])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n } else {\n message += ` You returned '${JSON.stringify(destroy)}'.`;\n }\n\n console.error(message);\n }\n };\n\n // We need to run the effect on initial render/dep changes if the screen is focused\n if (navigation.isFocused()) {\n cleanup = callback();\n isFocused = true;\n }\n\n const unsubscribeFocus = navigation.addListener('focus', () => {\n // If callback was already called for focus, avoid calling it again\n // The focus event may also fire on initial render, so we guard against running the effect twice\n if (isFocused) {\n return;\n }\n\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = callback();\n isFocused = true;\n });\n\n const unsubscribeBlur = navigation.addListener('blur', () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = undefined;\n isFocused = false;\n });\n\n return () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n unsubscribeFocus();\n unsubscribeBlur();\n };\n }, [effect, navigation]);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Navigator.d.ts","sourceRoot":"","sources":["../../src/views/Navigator.tsx"],"names":[],"m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S,CAAC,CAAC,SAAS,0BAA0B,GAAG,OAAO,WAAW,EAAE,EACnF,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,MAAM,EACN,aAAa,GACd,EAAE,cAAc,CAAC,CAAC,CAAC,4BA0CnB;yBAhDe,SAAS;;;;;AAkDzB;;GAEG;AACH,wBAAgB,mBAAmB,0BAMlC;AAqBD;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,qBAchE;AAED;;GAEG;AACH,iBAAS,aAAa,sBAMrB;AAKD;;GAEG;AACH,wBAAgB,gBAAgB,sBAM/B"}
@@ -42,6 +42,8 @@ exports.Slot = Slot;
42
42
  exports.DefaultNavigator = DefaultNavigator;
43
43
  const native_1 = require("@react-navigation/native");
44
44
  const React = __importStar(require("react"));
45
+ const react_1 = require("react");
46
+ const react_native_is_edge_to_edge_1 = require("react-native-is-edge-to-edge");
45
47
  const react_native_safe_area_context_1 = require("react-native-safe-area-context");
46
48
  const Screen_1 = require("./Screen");
47
49
  const Route_1 = require("../Route");
@@ -142,13 +144,14 @@ function NavigatorSlot() {
142
144
  const { state, descriptors } = context;
143
145
  return descriptors[state.routes[state.index].key]?.render() ?? null;
144
146
  }
147
+ const SlotNavigatorWrapper = process.env.EXPO_OS === 'android' && (0, react_native_is_edge_to_edge_1.isEdgeToEdge)() ? react_1.Fragment : react_native_safe_area_context_1.SafeAreaView;
145
148
  /**
146
149
  * The default navigator for the app when no root _layout is provided.
147
150
  */
148
151
  function DefaultNavigator() {
149
- return (<react_native_safe_area_context_1.SafeAreaView style={{ flex: 1 }}>
152
+ return (<SlotNavigatorWrapper style={{ flex: 1 }}>
150
153
  <SlotNavigator />
151
- </react_native_safe_area_context_1.SafeAreaView>);
154
+ </SlotNavigatorWrapper>);
152
155
  }
153
156
  Navigator.Slot = NavigatorSlot;
154
157
  Navigator.useContext = useNavigatorContext;
@@ -1 +1 @@
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ACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,IAAI,CAAC,KAA4C;IAC/D,MAAM,UAAU,GAAG,IAAA,qBAAa,GAAE,CAAC;IACnC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,wBAAgB,CAAC,CAAC;IAE5C,IAAI,OAAO,EAAE,UAAU,KAAK,UAAU,EAAE,CAAC;QACvC,mDAAmD;QACnD,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,aAAa,CAAC,AAAD,EAAG,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAS,aAAa;IACpB,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IAEtC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEvC,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,CACL,CAAC,6CAAY,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAC/B;MAAA,CAAC,aAAa,CAAC,AAAD,EAChB;IAAA,EAAE,6CAAY,CAAC,CAChB,CAAC;AACJ,CAAC;AAED,SAAS,CAAC,IAAI,GAAG,aAAa,CAAC;AAC/B,SAAS,CAAC,UAAU,GAAG,mBAAmB,CAAC;AAE3C,wCAAwC;AACxC,SAAS,CAAC,MAAM,GAAG,eAAM,CAAC","sourcesContent":["// Copyright © 2024 650 Industries.\n'use client';\n\nimport { RouterFactory, useNavigationBuilder } from '@react-navigation/native';\nimport * as React from 'react';\nimport { SafeAreaView } from 'react-native-safe-area-context';\n\nimport { Screen } from './Screen';\nimport { useContextKey } from '../Route';\nimport { StackRouter } from '../layouts/StackClient';\nimport { useFilterScreenChildren } from '../layouts/withLayoutContext';\nimport { useSortedScreens } from '../useScreens';\n\nexport type NavigatorContextValue = ReturnType<typeof useNavigationBuilder> & {\n contextKey: string;\n router: RouterFactory<any, any, any>;\n};\n\nexport const NavigatorContext = React.createContext<NavigatorContextValue | null>(null);\n\nif (process.env.NODE_ENV !== 'production') {\n NavigatorContext.displayName = 'NavigatorContext';\n}\n\ntype UseNavigationBuilderRouter = Parameters<typeof useNavigationBuilder>[0];\ntype UseNavigationBuilderOptions = Parameters<typeof useNavigationBuilder>[1];\n\nexport type NavigatorProps<T extends UseNavigationBuilderRouter> = {\n initialRouteName?: UseNavigationBuilderOptions['initialRouteName'];\n screenOptions?: UseNavigationBuilderOptions['screenOptions'];\n children?: UseNavigationBuilderOptions['children'];\n router?: T;\n routerOptions?: Omit<Parameters<T>[0], 'initialRouteName'>;\n};\n\n/**\n * An unstyled custom navigator. Good for basic web layouts.\n *\n * @hidden\n */\nexport function Navigator<T extends UseNavigationBuilderRouter = typeof StackRouter>({\n initialRouteName,\n screenOptions,\n children,\n router,\n routerOptions,\n}: NavigatorProps<T>) {\n const contextKey = useContextKey();\n\n // A custom navigator can have a mix of Screen and other components (like a Slot inside a View)\n const {\n screens,\n children: nonScreenChildren,\n protectedScreens,\n } = useFilterScreenChildren(children, {\n isCustomNavigator: true,\n contextKey,\n });\n\n const sortedScreens = useSortedScreens(screens ?? [], protectedScreens);\n\n router ||= StackRouter as unknown as T;\n\n const navigation = useNavigationBuilder(router, {\n // Used for getting the parent with navigation.getParent('/normalized/path')\n ...routerOptions,\n id: contextKey,\n children: sortedScreens || [<Screen key=\"default\" />],\n screenOptions,\n initialRouteName,\n });\n\n // useNavigationBuilder requires at least one screen to be defined otherwise it will throw.\n if (!sortedScreens.length) {\n console.warn(`Navigator at \"${contextKey}\" has no children.`);\n return null;\n }\n\n return (\n <NavigatorContext.Provider\n value={{\n ...navigation,\n contextKey,\n router,\n }}>\n {nonScreenChildren}\n </NavigatorContext.Provider>\n );\n}\n\n/**\n * @hidden\n */\nexport function useNavigatorContext() {\n const context = React.use(NavigatorContext);\n if (!context) {\n throw new Error('useNavigatorContext must be used within a <Navigator />');\n }\n return context;\n}\n\nfunction SlotNavigator(props: NavigatorProps<any>) {\n const contextKey = useContextKey();\n\n // Allows adding Screen components as children to configure routes.\n const { screens, protectedScreens } = useFilterScreenChildren([], {\n contextKey,\n });\n\n const { state, descriptors, NavigationContent } = useNavigationBuilder(StackRouter, {\n ...props,\n id: contextKey,\n children: useSortedScreens(screens ?? [], protectedScreens),\n });\n\n return (\n <NavigationContent>{descriptors[state.routes[state.index].key].render()}</NavigationContent>\n );\n}\n\n/**\n * Renders the currently selected content.\n *\n * There are actually two different implementations of `<Slot/>`:\n * - Used inside a `_layout` as the `Navigator`\n * - Used inside a `Navigator` as the content\n *\n * Since a custom `Navigator` will set the `NavigatorContext.contextKey` to\n * the current `_layout`, you can use this to determine if you are inside\n * a custom navigator or not.\n */\nexport function Slot(props: Omit<NavigatorProps<any>, 'children'>) {\n const contextKey = useContextKey();\n const context = React.use(NavigatorContext);\n\n if (context?.contextKey !== contextKey) {\n // The _layout has changed since the last navigator\n return <SlotNavigator {...props} />;\n }\n\n /*\n * The user has defined a custom navigator\n * <Navigator><Slot /></Navigator>\n */\n return <NavigatorSlot />;\n}\n\n/**\n * Render the current navigator content.\n */\nfunction NavigatorSlot() {\n const context = useNavigatorContext();\n\n const { state, descriptors } = context;\n\n return descriptors[state.routes[state.index].key]?.render() ?? null;\n}\n\n/**\n * The default navigator for the app when no root _layout is provided.\n */\nexport function DefaultNavigator() {\n return (\n <SafeAreaView style={{ flex: 1 }}>\n <SlotNavigator />\n </SafeAreaView>\n );\n}\n\nNavigator.Slot = NavigatorSlot;\nNavigator.useContext = useNavigatorContext;\n\n/** Used to configure route settings. */\nNavigator.Screen = Screen;\n"]}
1
+ {"version":3,"file":"Navigator.js","sourceRoot":"","sources":["../../src/views/Navigator.tsx"],"names":[],"mappings":";AAAA,mCAAmC;A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KAA4C;IAC/D,MAAM,UAAU,GAAG,IAAA,qBAAa,GAAE,CAAC;IACnC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,wBAAgB,CAAC,CAAC;IAE5C,IAAI,OAAO,EAAE,UAAU,KAAK,UAAU,EAAE,CAAC;QACvC,mDAAmD;QACnD,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,aAAa,CAAC,AAAD,EAAG,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAS,aAAa;IACpB,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IAEtC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEvC,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC;AACtE,CAAC;AAED,MAAM,oBAAoB,GACxB,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,IAAA,2CAAY,GAAE,CAAC,CAAC,CAAC,gBAAQ,CAAC,CAAC,CAAC,6CAAY,CAAC;AAEhF;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,CACL,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CACvC;MAAA,CAAC,aAAa,CAAC,AAAD,EAChB;IAAA,EAAE,oBAAoB,CAAC,CACxB,CAAC;AACJ,CAAC;AAED,SAAS,CAAC,IAAI,GAAG,aAAa,CAAC;AAC/B,SAAS,CAAC,UAAU,GAAG,mBAAmB,CAAC;AAE3C,wCAAwC;AACxC,SAAS,CAAC,MAAM,GAAG,eAAM,CAAC","sourcesContent":["// Copyright © 2024 650 Industries.\n'use client';\n\nimport { RouterFactory, useNavigationBuilder } from '@react-navigation/native';\nimport * as React from 'react';\nimport { Fragment } from 'react';\nimport { isEdgeToEdge } from 'react-native-is-edge-to-edge';\nimport { SafeAreaView } from 'react-native-safe-area-context';\n\nimport { Screen } from './Screen';\nimport { useContextKey } from '../Route';\nimport { StackRouter } from '../layouts/StackClient';\nimport { useFilterScreenChildren } from '../layouts/withLayoutContext';\nimport { useSortedScreens } from '../useScreens';\n\nexport type NavigatorContextValue = ReturnType<typeof useNavigationBuilder> & {\n contextKey: string;\n router: RouterFactory<any, any, any>;\n};\n\nexport const NavigatorContext = React.createContext<NavigatorContextValue | null>(null);\n\nif (process.env.NODE_ENV !== 'production') {\n NavigatorContext.displayName = 'NavigatorContext';\n}\n\ntype UseNavigationBuilderRouter = Parameters<typeof useNavigationBuilder>[0];\ntype UseNavigationBuilderOptions = Parameters<typeof useNavigationBuilder>[1];\n\nexport type NavigatorProps<T extends UseNavigationBuilderRouter> = {\n initialRouteName?: UseNavigationBuilderOptions['initialRouteName'];\n screenOptions?: UseNavigationBuilderOptions['screenOptions'];\n children?: UseNavigationBuilderOptions['children'];\n router?: T;\n routerOptions?: Omit<Parameters<T>[0], 'initialRouteName'>;\n};\n\n/**\n * An unstyled custom navigator. Good for basic web layouts.\n *\n * @hidden\n */\nexport function Navigator<T extends UseNavigationBuilderRouter = typeof StackRouter>({\n initialRouteName,\n screenOptions,\n children,\n router,\n routerOptions,\n}: NavigatorProps<T>) {\n const contextKey = useContextKey();\n\n // A custom navigator can have a mix of Screen and other components (like a Slot inside a View)\n const {\n screens,\n children: nonScreenChildren,\n protectedScreens,\n } = useFilterScreenChildren(children, {\n isCustomNavigator: true,\n contextKey,\n });\n\n const sortedScreens = useSortedScreens(screens ?? [], protectedScreens);\n\n router ||= StackRouter as unknown as T;\n\n const navigation = useNavigationBuilder(router, {\n // Used for getting the parent with navigation.getParent('/normalized/path')\n ...routerOptions,\n id: contextKey,\n children: sortedScreens || [<Screen key=\"default\" />],\n screenOptions,\n initialRouteName,\n });\n\n // useNavigationBuilder requires at least one screen to be defined otherwise it will throw.\n if (!sortedScreens.length) {\n console.warn(`Navigator at \"${contextKey}\" has no children.`);\n return null;\n }\n\n return (\n <NavigatorContext.Provider\n value={{\n ...navigation,\n contextKey,\n router,\n }}>\n {nonScreenChildren}\n </NavigatorContext.Provider>\n );\n}\n\n/**\n * @hidden\n */\nexport function useNavigatorContext() {\n const context = React.use(NavigatorContext);\n if (!context) {\n throw new Error('useNavigatorContext must be used within a <Navigator />');\n }\n return context;\n}\n\nfunction SlotNavigator(props: NavigatorProps<any>) {\n const contextKey = useContextKey();\n\n // Allows adding Screen components as children to configure routes.\n const { screens, protectedScreens } = useFilterScreenChildren([], {\n contextKey,\n });\n\n const { state, descriptors, NavigationContent } = useNavigationBuilder(StackRouter, {\n ...props,\n id: contextKey,\n children: useSortedScreens(screens ?? [], protectedScreens),\n });\n\n return (\n <NavigationContent>{descriptors[state.routes[state.index].key].render()}</NavigationContent>\n );\n}\n\n/**\n * Renders the currently selected content.\n *\n * There are actually two different implementations of `<Slot/>`:\n * - Used inside a `_layout` as the `Navigator`\n * - Used inside a `Navigator` as the content\n *\n * Since a custom `Navigator` will set the `NavigatorContext.contextKey` to\n * the current `_layout`, you can use this to determine if you are inside\n * a custom navigator or not.\n */\nexport function Slot(props: Omit<NavigatorProps<any>, 'children'>) {\n const contextKey = useContextKey();\n const context = React.use(NavigatorContext);\n\n if (context?.contextKey !== contextKey) {\n // The _layout has changed since the last navigator\n return <SlotNavigator {...props} />;\n }\n\n /*\n * The user has defined a custom navigator\n * <Navigator><Slot /></Navigator>\n */\n return <NavigatorSlot />;\n}\n\n/**\n * Render the current navigator content.\n */\nfunction NavigatorSlot() {\n const context = useNavigatorContext();\n\n const { state, descriptors } = context;\n\n return descriptors[state.routes[state.index].key]?.render() ?? null;\n}\n\nconst SlotNavigatorWrapper =\n process.env.EXPO_OS === 'android' && isEdgeToEdge() ? Fragment : SafeAreaView;\n\n/**\n * The default navigator for the app when no root _layout is provided.\n */\nexport function DefaultNavigator() {\n return (\n <SlotNavigatorWrapper style={{ flex: 1 }}>\n <SlotNavigator />\n </SlotNavigatorWrapper>\n );\n}\n\nNavigator.Slot = NavigatorSlot;\nNavigator.useContext = useNavigatorContext;\n\n/** Used to configure route settings. */\nNavigator.Screen = Screen;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Sitemap.d.ts","sourceRoot":"","sources":["../../src/views/Sitemap.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,wBAAgB,aAAa,IAAI,4BAA4B,CAiC5D;AAED,wBAAgB,OAAO,sBAStB"}
1
+ {"version":3,"file":"Sitemap.d.ts","sourceRoot":"","sources":["../../src/views/Sitemap.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,MAAM,OAAO,CAAC;AAoB1B,wBAAgB,aAAa,IAAI,4BAA4B,CAiC5D;AAED,wBAAgB,OAAO,sBAkBtB"}