expo-router 3.1.2 → 3.3.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 (168) hide show
  1. package/_ctx.android.js +1 -1
  2. package/_ctx.ios.js +1 -1
  3. package/_ctx.web.js +1 -1
  4. package/babel.js +1 -209
  5. package/build/ExpoRoot.d.ts.map +1 -1
  6. package/build/ExpoRoot.js +57 -15
  7. package/build/ExpoRoot.js.map +1 -1
  8. package/build/LocationProvider.d.ts +3 -2
  9. package/build/LocationProvider.d.ts.map +1 -1
  10. package/build/LocationProvider.js +31 -7
  11. package/build/LocationProvider.js.map +1 -1
  12. package/build/Route.d.ts +3 -0
  13. package/build/Route.d.ts.map +1 -1
  14. package/build/Route.js +1 -1
  15. package/build/Route.js.map +1 -1
  16. package/build/fork/NavigationContainer.native.js +5 -3
  17. package/build/fork/NavigationContainer.native.js.map +1 -1
  18. package/build/fork/extractPathFromURL.d.ts.map +1 -1
  19. package/build/fork/extractPathFromURL.js +17 -16
  20. package/build/fork/extractPathFromURL.js.map +1 -1
  21. package/build/fork/getPathFromState.d.ts +1 -1
  22. package/build/fork/getPathFromState.d.ts.map +1 -1
  23. package/build/fork/getPathFromState.js +17 -38
  24. package/build/fork/getPathFromState.js.map +1 -1
  25. package/build/fork/getStateFromPath.d.ts +2 -2
  26. package/build/fork/getStateFromPath.d.ts.map +1 -1
  27. package/build/fork/getStateFromPath.js +71 -52
  28. package/build/fork/getStateFromPath.js.map +1 -1
  29. package/build/getDevServer/index.d.ts +0 -3
  30. package/build/getDevServer/index.d.ts.map +1 -1
  31. package/build/getDevServer/index.js +1 -28
  32. package/build/getDevServer/index.js.map +1 -1
  33. package/build/getReactNavigationConfig.d.ts.map +1 -1
  34. package/build/getReactNavigationConfig.js +3 -0
  35. package/build/getReactNavigationConfig.js.map +1 -1
  36. package/build/getRoutes.d.ts +8 -5
  37. package/build/getRoutes.d.ts.map +1 -1
  38. package/build/getRoutes.js +150 -67
  39. package/build/getRoutes.js.map +1 -1
  40. package/build/getServerManifest.d.ts +14 -33
  41. package/build/getServerManifest.d.ts.map +1 -1
  42. package/build/getServerManifest.js +6 -5
  43. package/build/getServerManifest.js.map +1 -1
  44. package/build/global-state/router-store.d.ts.map +1 -1
  45. package/build/global-state/router-store.js +29 -3
  46. package/build/global-state/router-store.js.map +1 -1
  47. package/build/global-state/routing.d.ts +0 -4
  48. package/build/global-state/routing.d.ts.map +1 -1
  49. package/build/global-state/routing.js +76 -96
  50. package/build/global-state/routing.js.map +1 -1
  51. package/build/head/ExpoHead.ios.js +4 -4
  52. package/build/head/ExpoHead.ios.js.map +1 -1
  53. package/build/head/ExpoHead.js +1 -1
  54. package/build/head/ExpoHead.js.map +1 -1
  55. package/build/head/url.d.ts.map +1 -1
  56. package/build/head/url.js +5 -6
  57. package/build/head/url.js.map +1 -1
  58. package/build/hooks.d.ts.map +1 -1
  59. package/build/hooks.js +24 -5
  60. package/build/hooks.js.map +1 -1
  61. package/build/import-mode/index.d.ts +1 -1
  62. package/build/import-mode/index.d.ts.map +1 -1
  63. package/build/import-mode/index.js +1 -1
  64. package/build/import-mode/index.js.map +1 -1
  65. package/build/layouts/Tabs.js +2 -2
  66. package/build/layouts/Tabs.js.map +1 -1
  67. package/build/layouts/withLayoutContext.js +1 -1
  68. package/build/layouts/withLayoutContext.js.map +1 -1
  69. package/build/link/Link.d.ts +54 -1
  70. package/build/link/Link.d.ts.map +1 -1
  71. package/build/link/Link.js +54 -12
  72. package/build/link/Link.js.map +1 -1
  73. package/build/link/useLinkToPathProps.js +2 -2
  74. package/build/link/useLinkToPathProps.js.map +1 -1
  75. package/build/loadStaticParamsAsync.d.ts +1 -0
  76. package/build/loadStaticParamsAsync.d.ts.map +1 -1
  77. package/build/loadStaticParamsAsync.js +107 -72
  78. package/build/loadStaticParamsAsync.js.map +1 -1
  79. package/build/matchers.js +1 -1
  80. package/build/matchers.js.map +1 -1
  81. package/build/onboard/Tutorial.js +41 -34
  82. package/build/onboard/Tutorial.js.map +1 -1
  83. package/build/qualified-entry.d.ts.map +1 -1
  84. package/build/qualified-entry.js +10 -7
  85. package/build/qualified-entry.js.map +1 -1
  86. package/build/renderRootComponent.d.ts.map +1 -1
  87. package/build/renderRootComponent.js +28 -4
  88. package/build/renderRootComponent.js.map +1 -1
  89. package/build/routes-manifest.d.ts +1 -0
  90. package/build/routes-manifest.d.ts.map +1 -1
  91. package/build/routes-manifest.js +1 -0
  92. package/build/routes-manifest.js.map +1 -1
  93. package/build/sortRoutes.d.ts.map +1 -1
  94. package/build/sortRoutes.js +21 -2
  95. package/build/sortRoutes.js.map +1 -1
  96. package/build/static/html.d.ts.map +1 -1
  97. package/build/static/html.js +12 -10
  98. package/build/static/html.js.map +1 -1
  99. package/build/static/renderStaticContent.d.ts +13 -3
  100. package/build/static/renderStaticContent.d.ts.map +1 -1
  101. package/build/static/renderStaticContent.js +35 -11
  102. package/build/static/renderStaticContent.js.map +1 -1
  103. package/build/testing-library/index.js +3 -5
  104. package/build/testing-library/index.js.map +1 -1
  105. package/build/testing-library/mocks.d.ts +1 -3
  106. package/build/testing-library/mocks.d.ts.map +1 -1
  107. package/build/testing-library/mocks.js +17 -10
  108. package/build/testing-library/mocks.js.map +1 -1
  109. package/build/testing-library/require-context-ponyfill.js +3 -3
  110. package/build/testing-library/require-context-ponyfill.js.map +1 -1
  111. package/build/useScreens.d.ts.map +1 -1
  112. package/build/useScreens.js +19 -23
  113. package/build/useScreens.js.map +1 -1
  114. package/build/utils/url.d.ts +2 -0
  115. package/build/utils/url.d.ts.map +1 -1
  116. package/build/utils/url.js +13 -1
  117. package/build/utils/url.js.map +1 -1
  118. package/build/views/EmptyRoute.js +5 -2
  119. package/build/views/EmptyRoute.js.map +1 -1
  120. package/build/views/ErrorBoundary.js +50 -31
  121. package/build/views/ErrorBoundary.js.map +1 -1
  122. package/build/views/Navigator.js +16 -10
  123. package/build/views/Navigator.js.map +1 -1
  124. package/build/views/Sitemap.js +54 -36
  125. package/build/views/Sitemap.js.map +1 -1
  126. package/build/views/Splash.d.ts +1 -27
  127. package/build/views/Splash.d.ts.map +1 -1
  128. package/build/views/Splash.js +2 -112
  129. package/build/views/Splash.js.map +1 -1
  130. package/build/views/SuspenseFallback.d.ts +1 -1
  131. package/build/views/SuspenseFallback.d.ts.map +1 -1
  132. package/build/views/SuspenseFallback.js +7 -2
  133. package/build/views/SuspenseFallback.js.map +1 -1
  134. package/build/views/Toast.js +23 -18
  135. package/build/views/Toast.js.map +1 -1
  136. package/build/views/Try.js +1 -1
  137. package/build/views/Try.js.map +1 -1
  138. package/build/views/Unmatched.js +29 -17
  139. package/build/views/Unmatched.js.map +1 -1
  140. package/html.d.ts +1 -0
  141. package/ios/ExpoHead.podspec +1 -1
  142. package/ios/ExpoHeadModule.swift +0 -2
  143. package/package.json +11 -19
  144. package/plugin/build/index.d.ts +2 -2
  145. package/plugin/options.json +3 -3
  146. package/build/fork/react-native-web-container.d.ts +0 -8
  147. package/build/fork/react-native-web-container.d.ts.map +0 -1
  148. package/build/fork/react-native-web-container.js +0 -8
  149. package/build/fork/react-native-web-container.js.map +0 -1
  150. package/build/import-mode/index.android.d.ts +0 -3
  151. package/build/import-mode/index.android.d.ts.map +0 -1
  152. package/build/import-mode/index.android.js +0 -4
  153. package/build/import-mode/index.android.js.map +0 -1
  154. package/build/import-mode/index.ios.d.ts +0 -3
  155. package/build/import-mode/index.ios.d.ts.map +0 -1
  156. package/build/import-mode/index.ios.js +0 -4
  157. package/build/import-mode/index.ios.js.map +0 -1
  158. package/build/import-mode/index.web.d.ts +0 -3
  159. package/build/import-mode/index.web.d.ts.map +0 -1
  160. package/build/import-mode/index.web.js +0 -4
  161. package/build/import-mode/index.web.js.map +0 -1
  162. package/build/link/stateOperations.d.ts +0 -81
  163. package/build/link/stateOperations.d.ts.map +0 -1
  164. package/build/link/stateOperations.js +0 -105
  165. package/build/link/stateOperations.js.map +0 -1
  166. package/types/global.d.ts +0 -38
  167. package/types/metro-require.d.ts +0 -52
  168. package/types/react-native-web.d.ts +0 -295
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getUserDefinedDeepDynamicRoute = exports.getExactRoutesAsync = exports.getExactRoutes = exports.getRoutesAsync = exports.getRoutes = exports.assertDuplicateRoutes = exports.generateDynamic = exports.generateDynamicFromSegment = exports.getRecursiveTree = void 0;
6
+ exports.getUserDefinedTopLevelNotFoundRoute = exports.getExactRoutes = exports.getRoutes = exports.assertDuplicateRoutes = exports.generateDynamic = exports.generateDynamicFromSegment = exports.getRecursiveTree = void 0;
7
7
  const import_mode_1 = __importDefault(require("./import-mode"));
8
8
  const matchers_1 = require("./matchers");
9
9
  /** Convert a flat map of file nodes into a nested tree of files. */
@@ -59,16 +59,26 @@ function assertDeprecatedFormat(tree) {
59
59
  assertDeprecatedFormat(child);
60
60
  }
61
61
  }
62
- function getTreeNodesAsRouteNodes(nodes) {
62
+ function getTreeNodesAsRouteNodes(nodes, options) {
63
63
  return nodes
64
- .map((node) => treeNodeToRouteNode(node))
64
+ .map((node) => treeNodeToRouteNode(node, options))
65
65
  .flat()
66
66
  .filter(Boolean);
67
67
  }
68
68
  function generateDynamicFromSegment(name) {
69
+ if (name === '+not-found') {
70
+ return {
71
+ name: '+not-found',
72
+ deep: true,
73
+ notFound: true,
74
+ };
75
+ }
69
76
  const deepDynamicName = (0, matchers_1.matchDeepDynamicRouteName)(name);
70
77
  const dynamicName = deepDynamicName ?? (0, matchers_1.matchDynamicName)(name);
71
- return dynamicName ? { name: dynamicName, deep: !!deepDynamicName } : null;
78
+ if (!dynamicName) {
79
+ return null;
80
+ }
81
+ return { name: dynamicName, deep: !!deepDynamicName };
72
82
  }
73
83
  exports.generateDynamicFromSegment = generateDynamicFromSegment;
74
84
  function generateDynamic(name) {
@@ -116,17 +126,7 @@ function applyDefaultInitialRouteName(node) {
116
126
  initialRouteName,
117
127
  };
118
128
  }
119
- function cloneGroupRoute(node, { name: nextName }) {
120
- const groupName = `(${nextName})`;
121
- const parts = node.contextKey.split('/');
122
- parts[parts.length - 2] = groupName;
123
- return {
124
- ...node,
125
- route: groupName,
126
- contextKey: parts.join('/'),
127
- };
128
- }
129
- function folderNodeToRouteNode({ name, children }) {
129
+ function folderNodeToRouteNode({ name, children }, options) {
130
130
  // Empty folder, skip it.
131
131
  if (!children.length) {
132
132
  return null;
@@ -138,51 +138,68 @@ function folderNodeToRouteNode({ name, children }) {
138
138
  ...child,
139
139
  name: [name, child.name].filter(Boolean).join('/'),
140
140
  };
141
- }));
141
+ }), options);
142
142
  }
143
- function fileNodeToRouteNode(tree) {
143
+ function fileNodeToRouteNode(tree, options) {
144
144
  const { name, node, children } = tree;
145
145
  if (!node)
146
146
  throw new Error('node must be defined');
147
147
  const dynamic = generateDynamic(name);
148
- const groupName = (0, matchers_1.matchGroupName)(name);
149
- const multiGroup = groupName?.includes(',');
150
- const clones = multiGroup ? groupName.split(',').map((v) => ({ name: v.trim() })) : null;
151
- // Assert duplicates:
152
- if (clones) {
153
- const names = new Set();
154
- for (const clone of clones) {
155
- if (names.has(clone.name)) {
156
- throw new Error(`Array syntax cannot contain duplicate group name "${clone.name}" in "${node.contextKey}".`);
157
- }
158
- names.add(clone.name);
159
- }
160
- }
148
+ const clones = extrapolateGroupRoutes(name, node.contextKey);
149
+ clones.delete(name);
161
150
  const output = {
162
151
  loadRoute: node.loadRoute,
163
152
  route: name,
164
153
  contextKey: node.contextKey,
165
- children: getTreeNodesAsRouteNodes(children),
154
+ children: getTreeNodesAsRouteNodes(children, options),
166
155
  dynamic,
156
+ filePath: node.filePath,
157
+ entryPoints: options.ignoreEntryPoints || isApiRoutePath(node.contextKey) ? undefined : [node.filePath],
167
158
  };
168
- if (Array.isArray(clones)) {
169
- return clones.map((clone) => applyDefaultInitialRouteName(cloneGroupRoute({ ...output }, clone)));
159
+ if (clones.size) {
160
+ return [...clones].map((clone) => applyDefaultInitialRouteName({
161
+ ...output,
162
+ contextKey: node.contextKey.replace(output.route, clone),
163
+ route: clone,
164
+ }));
170
165
  }
171
166
  return [
172
167
  applyDefaultInitialRouteName({
173
168
  loadRoute: node.loadRoute,
174
169
  route: name,
170
+ entryPoints: options.ignoreEntryPoints || isApiRoutePath(node.contextKey) ? undefined : [node.filePath],
171
+ filePath: node.filePath,
175
172
  contextKey: node.contextKey,
176
- children: getTreeNodesAsRouteNodes(children),
173
+ children: getTreeNodesAsRouteNodes(children, options),
177
174
  dynamic,
178
175
  }),
179
176
  ];
180
177
  }
181
- function treeNodeToRouteNode(tree) {
178
+ function extrapolateGroupRoutes(route, contextKey, routes = new Set()) {
179
+ const match = (0, matchers_1.matchGroupName)(route);
180
+ if (!match) {
181
+ routes.add(route);
182
+ return routes;
183
+ }
184
+ const groups = match?.split(',');
185
+ const groupsSet = new Set(groups);
186
+ if (groupsSet.size !== groups.length) {
187
+ throw new Error(`Array syntax cannot contain duplicate group name "${groups}" in "${contextKey}".`);
188
+ }
189
+ if (groups.length === 1) {
190
+ routes.add(route);
191
+ return routes;
192
+ }
193
+ for (const group of groups) {
194
+ extrapolateGroupRoutes(route.replace(match, group.trim()), contextKey, routes);
195
+ }
196
+ return routes;
197
+ }
198
+ function treeNodeToRouteNode(tree, options) {
182
199
  if (tree.node) {
183
- return fileNodeToRouteNode(tree);
200
+ return fileNodeToRouteNode(tree, options);
184
201
  }
185
- return folderNodeToRouteNode(tree);
202
+ return folderNodeToRouteNode(tree, options);
186
203
  }
187
204
  function contextModuleToFileNodes(contextModule, options = {}, files = contextModule.keys()) {
188
205
  const nodes = files.map((key) => {
@@ -214,6 +231,7 @@ function contextModuleToFileNodes(contextModule, options = {}, files = contextMo
214
231
  }
215
232
  },
216
233
  normalizedName: (0, matchers_1.getNameFromFilePath)(key),
234
+ filePath: key,
217
235
  contextKey: key,
218
236
  };
219
237
  return node;
@@ -237,8 +255,8 @@ function hasCustomRootLayoutNode(routes) {
237
255
  }
238
256
  return false;
239
257
  }
240
- function treeNodesToRootRoute(treeNode) {
241
- const routes = treeNodeToRouteNode(treeNode);
258
+ function treeNodesToRootRoute(treeNode, options) {
259
+ const routes = treeNodeToRouteNode(treeNode, options);
242
260
  return withOptionalRootLayout(routes);
243
261
  }
244
262
  function processKeys(files, options) {
@@ -270,7 +288,7 @@ function assertDuplicateRoutes(filenames) {
270
288
  exports.assertDuplicateRoutes = assertDuplicateRoutes;
271
289
  /** Given a Metro context module, return an array of nested routes. */
272
290
  function getRoutes(contextModule, options) {
273
- const route = getExactRoutes(contextModule, options);
291
+ const route = getExactRoutesInternal(contextModule, options);
274
292
  // If there is no route, return an empty route.
275
293
  if (!route) {
276
294
  return null;
@@ -278,20 +296,83 @@ function getRoutes(contextModule, options) {
278
296
  appendSitemapRoute(route);
279
297
  // Auto add not found route if it doesn't exist
280
298
  appendUnmatchedRoute(route);
281
- return route;
299
+ if (options?.ignoreEntryPoints) {
300
+ return removeFilePath(route);
301
+ }
302
+ return removeFilePath(crawlAndAppendEntryFilesForInitialRoutes(crawlAndAppendEntryFiles(route)));
282
303
  }
283
304
  exports.getRoutes = getRoutes;
284
- async function getRoutesAsync(contextModule, options) {
285
- const route = await getExactRoutesAsync(contextModule, options);
286
- if (!route) {
305
+ function removeFilePath(route) {
306
+ if (!route)
307
+ return route;
308
+ const { filePath, ...rest } = route;
309
+ return {
310
+ ...rest,
311
+ children: route.children.map((child) => removeFilePath(child)).filter(Boolean),
312
+ };
313
+ }
314
+ function unique(array) {
315
+ return [...new Set(array)];
316
+ }
317
+ function isLayoutRoute(route) {
318
+ return route.contextKey.match(/\/_layout\.([jt]sx?)$/);
319
+ }
320
+ function isViewRoute(route) {
321
+ return !!route && !isApiRoute(route);
322
+ }
323
+ function isApiRoute(route) {
324
+ return isApiRoutePath(route.contextKey);
325
+ }
326
+ function isApiRoutePath(route) {
327
+ return !!route.match(/\+api\.[jt]sx?$/);
328
+ }
329
+ function crawlAndAppendEntryFiles(route, entryPoints = []) {
330
+ if (!isViewRoute(route)) {
287
331
  return null;
288
332
  }
289
- appendSitemapRoute(route);
290
- // Auto add not found route if it doesn't exist
291
- appendUnmatchedRoute(route);
333
+ const nextEntryPoints = unique([...entryPoints, ...(route.entryPoints ?? []), route.filePath]);
334
+ route.children.forEach((child) => {
335
+ crawlAndAppendEntryFiles(child, nextEntryPoints);
336
+ });
337
+ // Skip adding entry points for layout routes since we only need them
338
+ // for rendering child nodes.
339
+ if (isLayoutRoute(route)) {
340
+ delete route.entryPoints;
341
+ }
342
+ else {
343
+ route.entryPoints = nextEntryPoints;
344
+ }
345
+ return route;
346
+ }
347
+ function crawlAndAppendEntryFilesForInitialRoutes(route, initialRoutes = []) {
348
+ if (!isViewRoute(route)) {
349
+ return null;
350
+ }
351
+ // Skip adding entry points for layout routes since we only need them
352
+ // for rendering child nodes.
353
+ if (isLayoutRoute(route)) {
354
+ if (route.initialRouteName) {
355
+ const initialRoute = route.children.find((child) => child.route === route.initialRouteName);
356
+ if (!initialRoute) {
357
+ throw new Error(`Invalid initialRouteName "${route.initialRouteName}" defined in ${route.filePath}. Options are: ${route.children.map((route) => route.route).join(', ')}`);
358
+ }
359
+ // Update all children to include the entry points from the initial route...
360
+ route.children.forEach((child) => {
361
+ crawlAndAppendEntryFilesForInitialRoutes(child, [...initialRoutes, initialRoute]);
362
+ });
363
+ }
364
+ }
365
+ else {
366
+ const isInitial = initialRoutes.some((initialRoute) => initialRoute.contextKey === route.contextKey);
367
+ if (!isInitial) {
368
+ route.entryPoints = unique([
369
+ ...initialRoutes.map((route) => route.entryPoints ?? []).flat(),
370
+ ...(route.entryPoints ?? []),
371
+ ]);
372
+ }
373
+ }
292
374
  return route;
293
375
  }
294
- exports.getRoutesAsync = getRoutesAsync;
295
376
  function getIgnoreList(options) {
296
377
  const ignore = [/^\.\/\+html\.[tj]sx?$/, ...(options?.ignore ?? [])];
297
378
  if (options?.preserveApiRoutes !== true) {
@@ -299,11 +380,17 @@ function getIgnoreList(options) {
299
380
  }
300
381
  return ignore;
301
382
  }
383
+ function getExactRoutesInternal(contextModule, options = {}) {
384
+ const treeNodes = contextModuleToTree(contextModule, options);
385
+ return treeNodesToRootRoute(treeNodes, options);
386
+ }
302
387
  /** Get routes without unmatched or sitemap. */
303
388
  function getExactRoutes(contextModule, options) {
304
- const treeNodes = contextModuleToTree(contextModule, options);
305
- const route = treeNodesToRootRoute(treeNodes);
306
- return route || null;
389
+ const route = getExactRoutesInternal(contextModule, options);
390
+ if (!options?.ignoreEntryPoints) {
391
+ return removeFilePath(crawlAndAppendEntryFilesForInitialRoutes(crawlAndAppendEntryFiles(route)));
392
+ }
393
+ return removeFilePath(route);
307
394
  }
308
395
  exports.getExactRoutes = getExactRoutes;
309
396
  function contextModuleToTree(contextModule, options) {
@@ -315,12 +402,6 @@ function contextModuleToTree(contextModule, options) {
315
402
  const files = contextModuleToFileNodes(contextModule, options, allowed);
316
403
  return getRecursiveTree(files);
317
404
  }
318
- async function getExactRoutesAsync(contextModule, options) {
319
- const treeNodes = contextModuleToTree(contextModule, options);
320
- const route = treeNodesToRootRoute(treeNodes);
321
- return route || null;
322
- }
323
- exports.getExactRoutesAsync = getExactRoutesAsync;
324
405
  function appendSitemapRoute(routes) {
325
406
  if (!routes.children.length ||
326
407
  // Allow overriding the sitemap route
@@ -332,6 +413,7 @@ function appendSitemapRoute(routes) {
332
413
  const { Sitemap, getNavOptions } = require('./views/Sitemap');
333
414
  return { default: Sitemap, getNavOptions };
334
415
  },
416
+ filePath: 'expo-router/build/views/Sitemap.js',
335
417
  route: '_sitemap',
336
418
  contextKey: './_sitemap.tsx',
337
419
  generated: true,
@@ -343,15 +425,16 @@ function appendSitemapRoute(routes) {
343
425
  }
344
426
  function appendUnmatchedRoute(routes) {
345
427
  // Auto add not found route if it doesn't exist
346
- const userDefinedDynamicRoute = getUserDefinedDeepDynamicRoute(routes);
428
+ const userDefinedDynamicRoute = getUserDefinedTopLevelNotFoundRoute(routes);
347
429
  if (!userDefinedDynamicRoute) {
348
430
  routes.children.push({
349
431
  loadRoute() {
350
432
  return { default: require('./views/Unmatched').Unmatched };
351
433
  },
352
- route: '[...404]',
353
- contextKey: './[...404].tsx',
354
- dynamic: [{ name: '404', deep: true }],
434
+ filePath: 'expo-router/build/views/Unmatched.js',
435
+ route: '+not-found',
436
+ contextKey: './+not-found.tsx',
437
+ dynamic: [{ name: '+not-found', deep: true, notFound: true }],
355
438
  children: [],
356
439
  generated: true,
357
440
  internal: true,
@@ -363,19 +446,18 @@ function appendUnmatchedRoute(routes) {
363
446
  * Exposed for testing.
364
447
  * @returns a top-level deep dynamic route if it exists, otherwise null.
365
448
  */
366
- function getUserDefinedDeepDynamicRoute(routes) {
449
+ function getUserDefinedTopLevelNotFoundRoute(routes) {
367
450
  // Auto add not found route if it doesn't exist
368
- for (const route of routes.children ?? []) {
451
+ for (const route of routes?.children ?? []) {
369
452
  if (route.generated)
370
453
  continue;
371
- const opaqueRoute = (0, matchers_1.stripInvisibleSegmentsFromPath)(route.route);
372
- const isDeepDynamic = (0, matchers_1.matchDeepDynamicRouteName)(opaqueRoute);
454
+ const isDeepDynamic = (0, matchers_1.stripGroupSegmentsFromPath)(route.route) === '+not-found' && route.route.match(/\+not-found$/);
373
455
  if (isDeepDynamic) {
374
456
  return route;
375
457
  }
376
458
  // Recurse through group routes
377
459
  if ((0, matchers_1.matchGroupName)(route.route)) {
378
- const child = getUserDefinedDeepDynamicRoute(route);
460
+ const child = getUserDefinedTopLevelNotFoundRoute(route);
379
461
  if (child) {
380
462
  return child;
381
463
  }
@@ -383,7 +465,7 @@ function getUserDefinedDeepDynamicRoute(routes) {
383
465
  }
384
466
  return null;
385
467
  }
386
- exports.getUserDefinedDeepDynamicRoute = getUserDefinedDeepDynamicRoute;
468
+ exports.getUserDefinedTopLevelNotFoundRoute = getUserDefinedTopLevelNotFoundRoute;
387
469
  function withOptionalRootLayout(routes) {
388
470
  if (!routes?.length) {
389
471
  return null;
@@ -396,6 +478,7 @@ function withOptionalRootLayout(routes) {
396
478
  default: require('./views/Navigator')
397
479
  .DefaultNavigator,
398
480
  }),
481
+ filePath: 'expo-router/build/views/Navigator.js',
399
482
  // Generate a fake file name for the directory
400
483
  contextKey: './_layout.tsx',
401
484
  route: '',
@@ -1 +1 @@
1
- {"version":3,"file":"getRoutes.js","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":";;;;;;AACA,gEAAoD;AACpD,yCAQoB;AAsBpB,oEAAoE;AACpE,SAAgB,gBAAgB,CAAC,KAAiB;IAChD,MAAM,IAAI,GAAG;QACX,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,IAAI;KACX,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,wCAAwC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,WAAW,GAAa,IAAI,CAAC;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAEtB,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,KAAK,SAAS,EAAE;gBAChD,IAAI,WAAW,CAAC,IAAI,EAAE;oBACpB,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;oBAChD,MAAM,IAAI,KAAK,CACb,iCAAiC,IAAI,CAAC,UAAU,wCAAwC,WAAW,+BAA+B,WAAW,gBAAgB,CAC9J,CAAC;iBACH;gBACD,SAAS;aACV;YAED,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC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AAC,CAAC;YAChB,OAAO,EAAG,OAAO,CAAC,mBAAmB,CAAwC;iBAC1E,gBAAgB;SACpB,CAAC;QACF,8CAA8C;QAC9C,UAAU,EAAE,eAAe;QAC3B,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,MAAM;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import type { DynamicConvention, RouteNode } from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport {\n getNameFromFilePath,\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchGroupName,\n removeSupportedExtensions,\n stripGroupSegmentsFromPath,\n stripInvisibleSegmentsFromPath,\n} from './matchers';\nimport type { RequireContext } from './types';\n\nexport type FileNode = Pick<RouteNode, 'contextKey' | 'loadRoute'> & {\n /** Like `(tab)/index` */\n normalizedName: string;\n};\n\ntype TreeNode = {\n name: string;\n children: TreeNode[];\n parents: string[];\n /** null when there is no file in a folder. */\n node: FileNode | null;\n};\n\ntype Options = {\n ignore?: RegExp[];\n preserveApiRoutes?: boolean;\n ignoreRequireErrors?: boolean;\n};\n\n/** Convert a flat map of file nodes into a nested tree of files. */\nexport function getRecursiveTree(files: FileNode[]): TreeNode {\n const tree = {\n name: '',\n children: [],\n parents: [],\n node: null,\n };\n\n for (const file of files) {\n // ['(tab)', 'settings', '[...another]']\n const parts = file.normalizedName.split('/');\n let currentNode: TreeNode = tree;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n\n if (i === parts.length - 1 && part === '_layout') {\n if (currentNode.node) {\n const overwritten = currentNode.node.contextKey;\n throw new Error(\n `Higher priority Layout Route \"${file.contextKey}\" overriding redundant Layout Route \"${overwritten}\". Remove the Layout Route \"${overwritten}\" to fix this.`\n );\n }\n continue;\n }\n\n const existing = currentNode.children.find((item) => item.name === part);\n if (existing) {\n currentNode = existing;\n } else {\n const newNode: TreeNode = {\n name: part,\n children: [],\n parents: [...currentNode.parents, currentNode.name],\n node: null,\n };\n currentNode.children.push(newNode);\n currentNode = newNode;\n }\n }\n currentNode.node = file;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assertDeprecatedFormat(tree);\n }\n\n return tree;\n}\n\nfunction assertDeprecatedFormat(tree: TreeNode) {\n for (const child of tree.children) {\n if (child.node && child.children.length && !child.node.normalizedName.endsWith('_layout')) {\n const ext = child.node.contextKey.split('.').pop();\n throw new Error(\n `Using deprecated Layout Route format: Move \\`./app/${child.node.normalizedName}.${ext}\\` to \\`./app/${child.node.normalizedName}/_layout.${ext}\\``\n );\n }\n assertDeprecatedFormat(child);\n }\n}\n\nfunction getTreeNodesAsRouteNodes(nodes: TreeNode[]): RouteNode[] {\n return nodes\n .map((node) => treeNodeToRouteNode(node))\n .flat()\n .filter(Boolean) as RouteNode[];\n}\n\nexport function generateDynamicFromSegment(name: string): DynamicConvention | null {\n const deepDynamicName = matchDeepDynamicRouteName(name);\n const dynamicName = deepDynamicName ?? matchDynamicName(name);\n\n return dynamicName ? { name: dynamicName, deep: !!deepDynamicName } : null;\n}\n\nexport function generateDynamic(name: string): RouteNode['dynamic'] {\n const description = name\n .split('/')\n .map((segment) => generateDynamicFromSegment(segment))\n .filter(Boolean) as DynamicConvention[];\n return description.length === 0 ? null : description;\n}\n\nfunction collapseRouteSegments(route: string) {\n return stripGroupSegmentsFromPath(route.replace(/\\/index$/, ''));\n}\n\n/**\n * Given a route node and a name representing the group name,\n * find the nearest child matching the name.\n *\n * Doesn't support slashes in the name.\n * Routes like `explore/(something)/index` will be matched against `explore`.\n *\n */\nfunction getDefaultInitialRoute(node: RouteNode, name: string) {\n return node.children.find((node) => collapseRouteSegments(node.route) === name);\n}\n\nfunction applyDefaultInitialRouteName(node: RouteNode): RouteNode {\n const groupName = matchGroupName(node.route);\n if (!node.children?.length) {\n return node;\n }\n\n // Guess at the initial route based on the group name.\n // TODO(EvanBacon): Perhaps we should attempt to warn when the group doesn't match any child routes.\n let initialRouteName = groupName ? getDefaultInitialRoute(node, groupName)?.route : undefined;\n const loaded = node.loadRoute();\n\n if (loaded?.unstable_settings) {\n // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.\n initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;\n\n if (groupName) {\n // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.\n const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;\n\n initialRouteName = groupSpecificInitialRouteName ?? initialRouteName;\n }\n }\n\n return {\n ...node,\n initialRouteName,\n };\n}\n\nfunction cloneGroupRoute(node: RouteNode, { name: nextName }: { name: string }): RouteNode {\n const groupName = `(${nextName})`;\n const parts = node.contextKey.split('/');\n parts[parts.length - 2] = groupName;\n\n return {\n ...node,\n route: groupName,\n contextKey: parts.join('/'),\n };\n}\n\nfunction folderNodeToRouteNode({ name, children }: TreeNode): RouteNode[] | null {\n // Empty folder, skip it.\n if (!children.length) {\n return null;\n }\n\n // When there's a directory, but no layout route file (with valid export), the child routes won't be grouped.\n // This pushes all children into the nearest layout route.\n return getTreeNodesAsRouteNodes(\n children.map((child) => {\n return {\n ...child,\n name: [name, child.name].filter(Boolean).join('/'),\n };\n })\n );\n}\n\nfunction fileNodeToRouteNode(tree: TreeNode): RouteNode[] | null {\n const { name, node, children } = tree;\n\n if (!node) throw new Error('node must be defined');\n\n const dynamic = generateDynamic(name);\n\n const groupName = matchGroupName(name);\n const multiGroup = groupName?.includes(',');\n\n const clones = multiGroup ? groupName!.split(',').map((v) => ({ name: v.trim() })) : null;\n\n // Assert duplicates:\n if (clones) {\n const names = new Set<string>();\n for (const clone of clones) {\n if (names.has(clone.name)) {\n throw new Error(\n `Array syntax cannot contain duplicate group name \"${clone.name}\" in \"${node.contextKey}\".`\n );\n }\n names.add(clone.name);\n }\n }\n\n const output = {\n loadRoute: node.loadRoute,\n route: name,\n contextKey: node.contextKey,\n children: getTreeNodesAsRouteNodes(children),\n dynamic,\n };\n\n if (Array.isArray(clones)) {\n return clones.map((clone) =>\n applyDefaultInitialRouteName(cloneGroupRoute({ ...output }, clone))\n );\n }\n\n return [\n applyDefaultInitialRouteName({\n loadRoute: node.loadRoute,\n route: name,\n contextKey: node.contextKey,\n children: getTreeNodesAsRouteNodes(children),\n dynamic,\n }),\n ];\n}\n\nfunction treeNodeToRouteNode(tree: TreeNode): RouteNode[] | null {\n if (tree.node) {\n return fileNodeToRouteNode(tree);\n }\n\n return folderNodeToRouteNode(tree);\n}\n\nfunction contextModuleToFileNodes(\n contextModule: RequireContext,\n options: Options = {},\n files: string[] = contextModule.keys()\n): FileNode[] {\n const nodes = files.map((key) => {\n // In development, check if the file exports a default component\n // this helps keep things snappy when creating files. In production we load all screens lazily.\n try {\n if (process.env.NODE_ENV === 'development') {\n // If the user has set the `EXPO_ROUTER_IMPORT_MODE` to `sync` then we should\n // filter the missing routes.\n if (EXPO_ROUTER_IMPORT_MODE === 'sync') {\n const isApi = key.match(/\\+api\\.[jt]sx?$/);\n if (!isApi && !contextModule(key)?.default) {\n return null;\n }\n }\n }\n const node: FileNode = {\n loadRoute() {\n if (options.ignoreRequireErrors) {\n try {\n return contextModule(key);\n } catch {\n return {};\n }\n } else {\n return contextModule(key);\n }\n },\n normalizedName: getNameFromFilePath(key),\n contextKey: key,\n };\n\n return node;\n } catch (error) {\n // Probably this won't stop metro from freaking out but it's worth a try.\n console.warn('Error loading route \"' + key + '\"', error);\n }\n return null;\n });\n\n return nodes.filter(Boolean) as FileNode[];\n}\n\nfunction hasCustomRootLayoutNode(routes: RouteNode[]) {\n if (routes.length !== 1) {\n return false;\n }\n // This could either be the root _layout or an app with a single file.\n const route = routes[0];\n\n if (route.route === '' && route.contextKey.match(/^\\.\\/_layout\\.([jt]sx?)$/)) {\n return true;\n }\n return false;\n}\n\nfunction treeNodesToRootRoute(treeNode: TreeNode): RouteNode | null {\n const routes = treeNodeToRouteNode(treeNode);\n return withOptionalRootLayout(routes);\n}\n\nfunction processKeys(files: string[], options: Options): string[] {\n const { ignore } = options;\n\n return files.filter((file) => {\n return !ignore?.some((pattern) => pattern.test(file));\n });\n}\n\n/**\n * Asserts if the require.context has files that share the same name but have different extensions. Exposed for testing.\n * @private\n */\nexport function assertDuplicateRoutes(filenames: string[]) {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n const duplicates = filenames\n .map((filename) => removeSupportedExtensions(filename))\n .reduce(\n (acc, filename) => {\n acc[filename] = acc[filename] ? acc[filename] + 1 : 1;\n return acc;\n },\n {} as Record<string, number>\n );\n\n Object.entries(duplicates).forEach(([filename, count]) => {\n if (count > 1) {\n throw new Error(`Multiple files match the route name \"${filename}\".`);\n }\n });\n}\n\n/** Given a Metro context module, return an array of nested routes. */\nexport function getRoutes(contextModule: RequireContext, options?: Options): RouteNode | null {\n const route = getExactRoutes(contextModule, options);\n\n // If there is no route, return an empty route.\n if (!route) {\n return null;\n }\n\n appendSitemapRoute(route);\n\n // Auto add not found route if it doesn't exist\n appendUnmatchedRoute(route);\n\n return route;\n}\n\nexport async function getRoutesAsync(\n contextModule: RequireContext,\n options?: Options\n): Promise<RouteNode | null> {\n const route = await getExactRoutesAsync(contextModule, options);\n if (!route) {\n return null;\n }\n\n appendSitemapRoute(route);\n\n // Auto add not found route if it doesn't exist\n appendUnmatchedRoute(route);\n\n return route;\n}\n\nfunction getIgnoreList(options?: Options) {\n const ignore: RegExp[] = [/^\\.\\/\\+html\\.[tj]sx?$/, ...(options?.ignore ?? [])];\n if (options?.preserveApiRoutes !== true) {\n ignore.push(/\\+api\\.[tj]sx?$/);\n }\n return ignore;\n}\n\n/** Get routes without unmatched or sitemap. */\nexport function getExactRoutes(contextModule: RequireContext, options?: Options): RouteNode | null {\n const treeNodes = contextModuleToTree(contextModule, options);\n const route = treeNodesToRootRoute(treeNodes);\n return route || null;\n}\n\nfunction contextModuleToTree(contextModule: RequireContext, options?: Options) {\n const allowed = processKeys(contextModule.keys(), {\n ...options,\n ignore: getIgnoreList(options),\n });\n assertDuplicateRoutes(allowed);\n const files = contextModuleToFileNodes(contextModule, options, allowed);\n return getRecursiveTree(files);\n}\n\nexport async function getExactRoutesAsync(\n contextModule: RequireContext,\n options?: Options\n): Promise<RouteNode | null> {\n const treeNodes = contextModuleToTree(contextModule, options);\n const route = treeNodesToRootRoute(treeNodes);\n return route || null;\n}\n\nfunction appendSitemapRoute(routes: RouteNode) {\n if (\n !routes.children.length ||\n // Allow overriding the sitemap route\n routes.children.some((route) => route.route === '_sitemap')\n ) {\n return routes;\n }\n routes.children.push({\n loadRoute() {\n const { Sitemap, getNavOptions } = require('./views/Sitemap');\n return { default: Sitemap, getNavOptions };\n },\n route: '_sitemap',\n contextKey: './_sitemap.tsx',\n generated: true,\n internal: true,\n dynamic: null,\n children: [],\n });\n return routes;\n}\n\nfunction appendUnmatchedRoute(routes: RouteNode) {\n // Auto add not found route if it doesn't exist\n const userDefinedDynamicRoute = getUserDefinedDeepDynamicRoute(routes);\n if (!userDefinedDynamicRoute) {\n routes.children.push({\n loadRoute() {\n return { default: require('./views/Unmatched').Unmatched };\n },\n route: '[...404]',\n contextKey: './[...404].tsx',\n dynamic: [{ name: '404', deep: true }],\n children: [],\n generated: true,\n internal: true,\n });\n }\n return routes;\n}\n\n/**\n * Exposed for testing.\n * @returns a top-level deep dynamic route if it exists, otherwise null.\n */\nexport function getUserDefinedDeepDynamicRoute(routes: RouteNode): RouteNode | null {\n // Auto add not found route if it doesn't exist\n for (const route of routes.children ?? []) {\n if (route.generated) continue;\n const opaqueRoute = stripInvisibleSegmentsFromPath(route.route);\n const isDeepDynamic = matchDeepDynamicRouteName(opaqueRoute);\n if (isDeepDynamic) {\n return route;\n }\n // Recurse through group routes\n if (matchGroupName(route.route)) {\n const child = getUserDefinedDeepDynamicRoute(route);\n if (child) {\n return child;\n }\n }\n }\n return null;\n}\n\nfunction withOptionalRootLayout(routes: RouteNode[] | null): RouteNode | null {\n if (!routes?.length) {\n return null;\n }\n\n if (hasCustomRootLayoutNode(routes)) {\n return routes[0];\n }\n\n return {\n loadRoute: () => ({\n default: (require('./views/Navigator') as typeof import('./views/Navigator'))\n .DefaultNavigator,\n }),\n // Generate a fake file name for the directory\n contextKey: './_layout.tsx',\n route: '',\n generated: true,\n dynamic: null,\n children: routes,\n };\n}\n"]}
1
+ {"version":3,"file":"getRoutes.js","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":";;;;;;AACA,gEAAoD;AACpD,yCAOoB;AA4BpB,oEAAoE;AACpE,SAAgB,gBAAgB,CAAC,KAAiB;IAChD,MAAM,IAAI,GAAG;QACX,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,IAAI;KACX,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,wCAAwC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,WAAW,GAAa,IAAI,CAAC;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAEtB,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,KAAK,SAAS,EAAE;gBAChD,IAAI,WAAW,CAAC,IAAI,EAAE;oBACpB,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;oBAChD,MAAM,IAAI,KAAK,CACb,iCAAiC,IAAI,CAAC,UAAU,wCAAwC,WAAW,+BAA+B,WAAW,gBAAgB,CAC9J,CAAC;iBACH;gBACD,SAAS;aACV;YAED,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YACzE,IAAI,QAAQ,EAA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_ROUTER_IMPORT_MODE from './import-mode';\nimport {\n getNameFromFilePath,\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchGroupName,\n removeSupportedExtensions,\n stripGroupSegmentsFromPath,\n} from './matchers';\nimport type { RequireContext } from './types';\n\nexport type FileNode = Pick<IntermediateRouteNode, 'contextKey' | 'loadRoute' | 'filePath'> & {\n /** Like `(tab)/index` */\n normalizedName: string;\n};\n\ntype IntermediateRouteNode = Omit<RouteNode, 'children'> & {\n filePath: string;\n children: IntermediateRouteNode[];\n};\n\ntype TreeNode = {\n name: string;\n children: TreeNode[];\n parents: string[];\n /** null when there is no file in a folder. */\n node: FileNode | null;\n};\n\ntype Options = {\n ignore?: RegExp[];\n preserveApiRoutes?: boolean;\n ignoreRequireErrors?: boolean;\n ignoreEntryPoints?: boolean;\n};\n\n/** Convert a flat map of file nodes into a nested tree of files. */\nexport function getRecursiveTree(files: FileNode[]): TreeNode {\n const tree = {\n name: '',\n children: [],\n parents: [],\n node: null,\n };\n\n for (const file of files) {\n // ['(tab)', 'settings', '[...another]']\n const parts = file.normalizedName.split('/');\n let currentNode: TreeNode = tree;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n\n if (i === parts.length - 1 && part === '_layout') {\n if (currentNode.node) {\n const overwritten = currentNode.node.contextKey;\n throw new Error(\n `Higher priority Layout Route \"${file.contextKey}\" overriding redundant Layout Route \"${overwritten}\". Remove the Layout Route \"${overwritten}\" to fix this.`\n );\n }\n continue;\n }\n\n const existing = currentNode.children.find((item) => item.name === part);\n if (existing) {\n currentNode = existing;\n } else {\n const newNode: TreeNode = {\n name: part,\n children: [],\n parents: [...currentNode.parents, currentNode.name],\n node: null,\n };\n currentNode.children.push(newNode);\n currentNode = newNode;\n }\n }\n currentNode.node = file;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assertDeprecatedFormat(tree);\n }\n\n return tree;\n}\n\nfunction assertDeprecatedFormat(tree: TreeNode) {\n for (const child of tree.children) {\n if (child.node && child.children.length && !child.node.normalizedName.endsWith('_layout')) {\n const ext = child.node.contextKey.split('.').pop();\n throw new Error(\n `Using deprecated Layout Route format: Move \\`./app/${child.node.normalizedName}.${ext}\\` to \\`./app/${child.node.normalizedName}/_layout.${ext}\\``\n );\n }\n assertDeprecatedFormat(child);\n }\n}\n\nfunction getTreeNodesAsRouteNodes(nodes: TreeNode[], options: Options): IntermediateRouteNode[] {\n return nodes\n .map((node) => treeNodeToRouteNode(node, options))\n .flat()\n .filter(Boolean) as IntermediateRouteNode[];\n}\n\nexport function generateDynamicFromSegment(name: string): DynamicConvention | null {\n if (name === '+not-found') {\n return {\n name: '+not-found',\n deep: true,\n notFound: true,\n };\n }\n\n const deepDynamicName = matchDeepDynamicRouteName(name);\n const dynamicName = deepDynamicName ?? matchDynamicName(name);\n if (!dynamicName) {\n return null;\n }\n return { name: dynamicName, deep: !!deepDynamicName };\n}\n\nexport function generateDynamic(name: string): IntermediateRouteNode['dynamic'] {\n const description = name\n .split('/')\n .map((segment) => generateDynamicFromSegment(segment))\n .filter(Boolean) as DynamicConvention[];\n return description.length === 0 ? null : description;\n}\n\nfunction collapseRouteSegments(route: string) {\n return stripGroupSegmentsFromPath(route.replace(/\\/index$/, ''));\n}\n\n/**\n * Given a route node and a name representing the group name,\n * find the nearest child matching the name.\n *\n * Doesn't support slashes in the name.\n * Routes like `explore/(something)/index` will be matched against `explore`.\n *\n */\nfunction getDefaultInitialRoute(node: IntermediateRouteNode, name: string) {\n return node.children.find((node) => collapseRouteSegments(node.route) === name);\n}\n\nfunction applyDefaultInitialRouteName(node: IntermediateRouteNode): IntermediateRouteNode {\n const groupName = matchGroupName(node.route);\n if (!node.children?.length) {\n return node;\n }\n\n // Guess at the initial route based on the group name.\n // TODO(EvanBacon): Perhaps we should attempt to warn when the group doesn't match any child routes.\n let initialRouteName = groupName ? getDefaultInitialRoute(node, groupName)?.route : undefined;\n const loaded = node.loadRoute();\n\n if (loaded?.unstable_settings) {\n // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.\n initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;\n\n if (groupName) {\n // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.\n const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;\n\n initialRouteName = groupSpecificInitialRouteName ?? initialRouteName;\n }\n }\n\n return {\n ...node,\n initialRouteName,\n };\n}\n\nfunction folderNodeToRouteNode(\n { name, children }: TreeNode,\n options: Options\n): IntermediateRouteNode[] | null {\n // Empty folder, skip it.\n if (!children.length) {\n return null;\n }\n\n // When there's a directory, but no layout route file (with valid export), the child routes won't be grouped.\n // This pushes all children into the nearest layout route.\n return getTreeNodesAsRouteNodes(\n children.map((child) => {\n return {\n ...child,\n name: [name, child.name].filter(Boolean).join('/'),\n };\n }),\n options\n );\n}\n\nfunction fileNodeToRouteNode(tree: TreeNode, options: Options): IntermediateRouteNode[] | null {\n const { name, node, children } = tree;\n\n if (!node) throw new Error('node must be defined');\n\n const dynamic = generateDynamic(name);\n\n const clones = extrapolateGroupRoutes(name, node.contextKey);\n clones.delete(name);\n\n const output = {\n loadRoute: node.loadRoute,\n route: name,\n contextKey: node.contextKey,\n children: getTreeNodesAsRouteNodes(children, options),\n dynamic,\n filePath: node.filePath,\n entryPoints:\n options.ignoreEntryPoints || isApiRoutePath(node.contextKey) ? undefined : [node.filePath],\n };\n\n if (clones.size) {\n return [...clones].map((clone) =>\n applyDefaultInitialRouteName({\n ...output,\n contextKey: node.contextKey.replace(output.route, clone),\n route: clone,\n })\n );\n }\n\n return [\n applyDefaultInitialRouteName({\n loadRoute: node.loadRoute,\n route: name,\n entryPoints:\n options.ignoreEntryPoints || isApiRoutePath(node.contextKey) ? undefined : [node.filePath],\n filePath: node.filePath,\n contextKey: node.contextKey,\n children: getTreeNodesAsRouteNodes(children, options),\n dynamic,\n }),\n ];\n}\n\nfunction extrapolateGroupRoutes(\n route: string,\n contextKey: string,\n routes: Set<string> = new Set()\n): Set<string> {\n const match = matchGroupName(route);\n\n if (!match) {\n routes.add(route);\n return routes;\n }\n\n const groups = match?.split(',');\n const groupsSet = new Set(groups);\n\n if (groupsSet.size !== groups.length) {\n throw new Error(\n `Array syntax cannot contain duplicate group name \"${groups}\" in \"${contextKey}\".`\n );\n }\n\n if (groups.length === 1) {\n routes.add(route);\n return routes;\n }\n\n for (const group of groups) {\n extrapolateGroupRoutes(route.replace(match, group.trim()), contextKey, routes);\n }\n\n return routes;\n}\n\nfunction treeNodeToRouteNode(tree: TreeNode, options: Options): IntermediateRouteNode[] | null {\n if (tree.node) {\n return fileNodeToRouteNode(tree, options);\n }\n\n return folderNodeToRouteNode(tree, options);\n}\n\nfunction contextModuleToFileNodes(\n contextModule: RequireContext,\n options: Options = {},\n files: string[] = contextModule.keys()\n): FileNode[] {\n const nodes = files.map((key) => {\n // In development, check if the file exports a default component\n // this helps keep things snappy when creating files. In production we load all screens lazily.\n try {\n if (process.env.NODE_ENV === 'development') {\n // If the user has set the `EXPO_ROUTER_IMPORT_MODE` to `sync` then we should\n // filter the missing routes.\n if (EXPO_ROUTER_IMPORT_MODE === 'sync') {\n const isApi = key.match(/\\+api\\.[jt]sx?$/);\n if (!isApi && !contextModule(key)?.default) {\n return null;\n }\n }\n }\n const node: FileNode = {\n loadRoute() {\n if (options.ignoreRequireErrors) {\n try {\n return contextModule(key);\n } catch {\n return {};\n }\n } else {\n return contextModule(key);\n }\n },\n normalizedName: getNameFromFilePath(key),\n filePath: key,\n contextKey: key,\n };\n\n return node;\n } catch (error) {\n // Probably this won't stop metro from freaking out but it's worth a try.\n console.warn('Error loading route \"' + key + '\"', error);\n }\n return null;\n });\n\n return nodes.filter(Boolean) as FileNode[];\n}\n\nfunction hasCustomRootLayoutNode(routes: IntermediateRouteNode[]) {\n if (routes.length !== 1) {\n return false;\n }\n // This could either be the root _layout or an app with a single file.\n const route = routes[0];\n\n if (route.route === '' && route.contextKey.match(/^\\.\\/_layout\\.([jt]sx?)$/)) {\n return true;\n }\n return false;\n}\n\nfunction treeNodesToRootRoute(treeNode: TreeNode, options: Options): IntermediateRouteNode | null {\n const routes = treeNodeToRouteNode(treeNode, options);\n return withOptionalRootLayout(routes);\n}\n\nfunction processKeys(files: string[], options: Options): string[] {\n const { ignore } = options;\n\n return files.filter((file) => {\n return !ignore?.some((pattern) => pattern.test(file));\n });\n}\n\n/**\n * Asserts if the require.context has files that share the same name but have different extensions. Exposed for testing.\n * @private\n */\nexport function assertDuplicateRoutes(filenames: string[]) {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n const duplicates = filenames\n .map((filename) => removeSupportedExtensions(filename))\n .reduce(\n (acc, filename) => {\n acc[filename] = acc[filename] ? acc[filename] + 1 : 1;\n return acc;\n },\n {} as Record<string, number>\n );\n\n Object.entries(duplicates).forEach(([filename, count]) => {\n if (count > 1) {\n throw new Error(`Multiple files match the route name \"${filename}\".`);\n }\n });\n}\n\n/** Given a Metro context module, return an array of nested routes. */\nexport function getRoutes(contextModule: RequireContext, options?: Options): RouteNode | null {\n const route = getExactRoutesInternal(contextModule, options);\n\n // If there is no route, return an empty route.\n if (!route) {\n return null;\n }\n\n appendSitemapRoute(route);\n\n // Auto add not found route if it doesn't exist\n appendUnmatchedRoute(route);\n\n if (options?.ignoreEntryPoints) {\n return removeFilePath(route);\n }\n return removeFilePath(crawlAndAppendEntryFilesForInitialRoutes(crawlAndAppendEntryFiles(route)));\n}\n\nfunction removeFilePath(route: IntermediateRouteNode | null): RouteNode | null {\n if (!route) return route;\n const { filePath, ...rest } = route;\n\n return {\n ...rest,\n children: route.children.map((child) => removeFilePath(child)).filter(Boolean) as RouteNode[],\n };\n}\n\nfunction unique<T>(array: T[]): T[] {\n return [...new Set(array)];\n}\n\nfunction isLayoutRoute(route: IntermediateRouteNode) {\n return route.contextKey.match(/\\/_layout\\.([jt]sx?)$/);\n}\n\nfunction isViewRoute(route?: IntermediateRouteNode | null): route is IntermediateRouteNode {\n return !!route && !isApiRoute(route);\n}\nfunction isApiRoute(route: IntermediateRouteNode) {\n return isApiRoutePath(route.contextKey);\n}\nfunction isApiRoutePath(route: string): boolean {\n return !!route.match(/\\+api\\.[jt]sx?$/);\n}\n\nfunction crawlAndAppendEntryFiles(\n route: IntermediateRouteNode | null,\n entryPoints: string[] = []\n): IntermediateRouteNode | null {\n if (!isViewRoute(route)) {\n return null;\n }\n const nextEntryPoints = unique([...entryPoints, ...(route.entryPoints ?? []), route.filePath]);\n\n route.children.forEach((child) => {\n crawlAndAppendEntryFiles(child, nextEntryPoints);\n });\n\n // Skip adding entry points for layout routes since we only need them\n // for rendering child nodes.\n if (isLayoutRoute(route)) {\n delete route.entryPoints;\n } else {\n route.entryPoints = nextEntryPoints;\n }\n\n return route;\n}\n\nfunction crawlAndAppendEntryFilesForInitialRoutes(\n route: IntermediateRouteNode | null,\n initialRoutes: IntermediateRouteNode[] = []\n): IntermediateRouteNode | null {\n if (!isViewRoute(route)) {\n return null;\n }\n\n // Skip adding entry points for layout routes since we only need them\n // for rendering child nodes.\n if (isLayoutRoute(route)) {\n if (route.initialRouteName) {\n const initialRoute = route.children.find((child) => child.route === route.initialRouteName);\n if (!initialRoute) {\n throw new Error(\n `Invalid initialRouteName \"${route.initialRouteName}\" defined in ${\n route.filePath\n }. Options are: ${route.children.map((route) => route.route).join(', ')}`\n );\n }\n // Update all children to include the entry points from the initial route...\n\n route.children.forEach((child) => {\n crawlAndAppendEntryFilesForInitialRoutes(child, [...initialRoutes, initialRoute]);\n });\n }\n } else {\n const isInitial = initialRoutes.some(\n (initialRoute) => initialRoute.contextKey === route.contextKey\n );\n if (!isInitial) {\n route.entryPoints = unique([\n ...initialRoutes.map((route) => route.entryPoints ?? []).flat(),\n ...(route.entryPoints ?? []),\n ]);\n }\n }\n\n return route;\n}\n\nfunction getIgnoreList(options?: Options) {\n const ignore: RegExp[] = [/^\\.\\/\\+html\\.[tj]sx?$/, ...(options?.ignore ?? [])];\n if (options?.preserveApiRoutes !== true) {\n ignore.push(/\\+api\\.[tj]sx?$/);\n }\n return ignore;\n}\n\nfunction getExactRoutesInternal(\n contextModule: RequireContext,\n options: Options = {}\n): IntermediateRouteNode | null {\n const treeNodes = contextModuleToTree(contextModule, options);\n return treeNodesToRootRoute(treeNodes, options);\n}\n\n/** Get routes without unmatched or sitemap. */\nexport function getExactRoutes(contextModule: RequireContext, options?: Options): RouteNode | null {\n const route = getExactRoutesInternal(contextModule, options);\n if (!options?.ignoreEntryPoints) {\n return removeFilePath(\n crawlAndAppendEntryFilesForInitialRoutes(crawlAndAppendEntryFiles(route))\n );\n }\n\n return removeFilePath(route);\n}\n\nfunction contextModuleToTree(contextModule: RequireContext, options?: Options) {\n const allowed = processKeys(contextModule.keys(), {\n ...options,\n ignore: getIgnoreList(options),\n });\n assertDuplicateRoutes(allowed);\n const files = contextModuleToFileNodes(contextModule, options, allowed);\n return getRecursiveTree(files);\n}\n\nfunction appendSitemapRoute(routes: IntermediateRouteNode) {\n if (\n !routes.children.length ||\n // Allow overriding the sitemap route\n routes.children.some((route) => route.route === '_sitemap')\n ) {\n return routes;\n }\n routes.children.push({\n loadRoute() {\n const { Sitemap, getNavOptions } = require('./views/Sitemap');\n return { default: Sitemap, getNavOptions };\n },\n filePath: 'expo-router/build/views/Sitemap.js',\n route: '_sitemap',\n contextKey: './_sitemap.tsx',\n generated: true,\n internal: true,\n dynamic: null,\n children: [],\n });\n return routes;\n}\n\nfunction appendUnmatchedRoute(routes: IntermediateRouteNode) {\n // Auto add not found route if it doesn't exist\n const userDefinedDynamicRoute = getUserDefinedTopLevelNotFoundRoute(routes);\n if (!userDefinedDynamicRoute) {\n routes.children.push({\n loadRoute() {\n return { default: require('./views/Unmatched').Unmatched };\n },\n filePath: 'expo-router/build/views/Unmatched.js',\n route: '+not-found',\n contextKey: './+not-found.tsx',\n dynamic: [{ name: '+not-found', deep: true, notFound: true }],\n children: [],\n generated: true,\n internal: true,\n });\n }\n return routes;\n}\n\n/**\n * Exposed for testing.\n * @returns a top-level deep dynamic route if it exists, otherwise null.\n */\nexport function getUserDefinedTopLevelNotFoundRoute(routes: RouteNode | null): RouteNode | null {\n // Auto add not found route if it doesn't exist\n for (const route of routes?.children ?? []) {\n if (route.generated) continue;\n const isDeepDynamic =\n stripGroupSegmentsFromPath(route.route) === '+not-found' && route.route.match(/\\+not-found$/);\n if (isDeepDynamic) {\n return route;\n }\n // Recurse through group routes\n if (matchGroupName(route.route)) {\n const child = getUserDefinedTopLevelNotFoundRoute(route);\n if (child) {\n return child;\n }\n }\n }\n return null;\n}\n\nfunction withOptionalRootLayout(\n routes: IntermediateRouteNode[] | null\n): IntermediateRouteNode | null {\n if (!routes?.length) {\n return null;\n }\n\n if (hasCustomRootLayoutNode(routes)) {\n return routes[0];\n }\n\n return {\n loadRoute: () => ({\n default: (require('./views/Navigator') as typeof import('./views/Navigator'))\n .DefaultNavigator,\n }),\n filePath: 'expo-router/build/views/Navigator.js',\n // Generate a fake file name for the directory\n contextKey: './_layout.tsx',\n route: '',\n generated: true,\n dynamic: null,\n children: routes,\n };\n}\n"]}
@@ -8,6 +8,18 @@
8
8
  * Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts
9
9
  */
10
10
  import type { RouteNode } from './Route';
11
+ export type ExpoRouterServerManifestV1Route<TRegex = string> = {
12
+ file: string;
13
+ page: string;
14
+ routeKeys: Record<string, string>;
15
+ namedRegex: TRegex;
16
+ generated?: boolean;
17
+ };
18
+ export type ExpoRouterServerManifestV1<TRegex = string> = {
19
+ apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];
20
+ htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];
21
+ notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];
22
+ };
11
23
  export interface Group {
12
24
  pos: number;
13
25
  repeat: boolean;
@@ -19,37 +31,6 @@ export interface RouteRegex {
19
31
  };
20
32
  re: RegExp;
21
33
  }
22
- export declare function getServerManifest(route: RouteNode): {
23
- apiRoutes: {
24
- generated: boolean | undefined;
25
- page: string;
26
- namedRegex: string;
27
- routeKeys: {
28
- [named: string]: string;
29
- };
30
- }[];
31
- htmlRoutes: {
32
- generated: boolean | undefined;
33
- page: string;
34
- namedRegex: string;
35
- routeKeys: {
36
- [named: string]: string;
37
- };
38
- }[];
39
- notFoundRoutes: {
40
- generated: boolean | undefined;
41
- page: string;
42
- namedRegex: string;
43
- routeKeys: {
44
- [named: string]: string;
45
- };
46
- }[];
47
- };
48
- export declare function getNamedRouteRegex(normalizedRoute: string, page: string): {
49
- page: string;
50
- namedRegex: string;
51
- routeKeys: {
52
- [named: string]: string;
53
- };
54
- };
34
+ export declare function getServerManifest(route: RouteNode): ExpoRouterServerManifestV1;
35
+ export declare function getNamedRouteRegex(normalizedRoute: string, page: string): ExpoRouterServerManifestV1Route;
55
36
  //# sourceMappingURL=getServerManifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIzC,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC;CACZ;AAcD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;EA8BjD;AASD,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;;;;EAOvE"}
1
+ {"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,MAAM,MAAM,+BAA+B,CAAC,MAAM,GAAG,MAAM,IAAI;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,MAAM,GAAG,MAAM,IAAI;IACxD,SAAS,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;IACrD,UAAU,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;IACtD,cAAc,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;CAC3D,CAAC;AAEF,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC;CACZ;AAWD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,0BAA0B,CA8B9E;AAWD,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,GACX,+BAA+B,CAQjC"}
@@ -7,10 +7,7 @@ function isApiRoute(route) {
7
7
  return !route.children.length && !!route.contextKey.match(/\+api\.[jt]sx?$/);
8
8
  }
9
9
  function isNotFoundRoute(route) {
10
- if (route.route === '404') {
11
- return true;
12
- }
13
- return route.dynamic?.length && route.dynamic[0].name === '404';
10
+ return route.dynamic && route.dynamic[route.dynamic.length - 1].notFound;
14
11
  }
15
12
  // Given a nested route tree, return a flattened array of all routes that can be matched.
16
13
  function getServerManifest(route) {
@@ -44,6 +41,7 @@ function getMatchableManifestForPaths(paths) {
44
41
  function getNamedRouteRegex(normalizedRoute, page) {
45
42
  const result = getNamedParametrizedRoute(normalizedRoute);
46
43
  return {
44
+ file: page,
47
45
  page: page.replace(/\.[jt]sx?$/, ''),
48
46
  namedRegex: `^${result.namedParameterizedRoute}(?:/)?$`,
49
47
  routeKeys: result.routeKeys,
@@ -91,7 +89,10 @@ function getNamedParametrizedRoute(route) {
91
89
  const routeKeys = {};
92
90
  return {
93
91
  namedParameterizedRoute: segments
94
- .map((segment) => {
92
+ .map((segment, index) => {
93
+ if (segment === '+not-found' && index === segments.length - 1) {
94
+ segment = '[...not-found]';
95
+ }
95
96
  if (/^\[.*\]$/.test(segment)) {
96
97
  const { name, optional, repeat } = parseParameter(segment.slice(1, -1));
97
98
  // replace any non-word characters since they can break