expo-router 3.1.2 → 3.2.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.
- package/build/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +57 -15
- package/build/ExpoRoot.js.map +1 -1
- package/build/LocationProvider.d.ts +3 -2
- package/build/LocationProvider.d.ts.map +1 -1
- package/build/LocationProvider.js +17 -5
- package/build/LocationProvider.js.map +1 -1
- package/build/Route.d.ts +1 -0
- package/build/Route.d.ts.map +1 -1
- package/build/Route.js +1 -1
- package/build/Route.js.map +1 -1
- package/build/fork/NavigationContainer.native.js +5 -3
- package/build/fork/NavigationContainer.native.js.map +1 -1
- package/build/fork/extractPathFromURL.d.ts.map +1 -1
- package/build/fork/extractPathFromURL.js +17 -16
- package/build/fork/extractPathFromURL.js.map +1 -1
- package/build/fork/getPathFromState.d.ts +1 -1
- package/build/fork/getPathFromState.d.ts.map +1 -1
- package/build/fork/getPathFromState.js +10 -35
- package/build/fork/getPathFromState.js.map +1 -1
- package/build/fork/getStateFromPath.d.ts +2 -2
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +59 -48
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getDevServer/index.d.ts +0 -3
- package/build/getDevServer/index.d.ts.map +1 -1
- package/build/getDevServer/index.js +1 -28
- package/build/getDevServer/index.js.map +1 -1
- package/build/getReactNavigationConfig.d.ts.map +1 -1
- package/build/getReactNavigationConfig.js +3 -0
- package/build/getReactNavigationConfig.js.map +1 -1
- package/build/getRoutes.d.ts +1 -2
- package/build/getRoutes.d.ts.map +1 -1
- package/build/getRoutes.js +51 -49
- package/build/getRoutes.js.map +1 -1
- package/build/getServerManifest.d.ts +4 -0
- package/build/getServerManifest.d.ts.map +1 -1
- package/build/getServerManifest.js +6 -5
- package/build/getServerManifest.js.map +1 -1
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +28 -2
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +0 -4
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +75 -95
- package/build/global-state/routing.js.map +1 -1
- package/build/head/ExpoHead.ios.js +4 -4
- package/build/head/ExpoHead.ios.js.map +1 -1
- package/build/head/ExpoHead.js +1 -1
- package/build/head/ExpoHead.js.map +1 -1
- package/build/head/url.d.ts.map +1 -1
- package/build/head/url.js +5 -6
- package/build/head/url.js.map +1 -1
- package/build/layouts/Tabs.js +2 -2
- package/build/layouts/Tabs.js.map +1 -1
- package/build/layouts/withLayoutContext.js +1 -1
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +54 -1
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +54 -12
- package/build/link/Link.js.map +1 -1
- package/build/link/useLinkToPathProps.js +2 -2
- package/build/link/useLinkToPathProps.js.map +1 -1
- package/build/matchers.js +1 -1
- package/build/matchers.js.map +1 -1
- package/build/onboard/Tutorial.js +41 -34
- package/build/onboard/Tutorial.js.map +1 -1
- package/build/qualified-entry.js +3 -2
- package/build/qualified-entry.js.map +1 -1
- package/build/renderRootComponent.d.ts.map +1 -1
- package/build/renderRootComponent.js +28 -4
- package/build/renderRootComponent.js.map +1 -1
- package/build/routes-manifest.d.ts +1 -0
- package/build/routes-manifest.d.ts.map +1 -1
- package/build/routes-manifest.js.map +1 -1
- package/build/sortRoutes.d.ts.map +1 -1
- package/build/sortRoutes.js +21 -2
- package/build/sortRoutes.js.map +1 -1
- package/build/static/html.js +11 -9
- package/build/static/html.js.map +1 -1
- package/build/static/renderStaticContent.d.ts +39 -2
- package/build/static/renderStaticContent.d.ts.map +1 -1
- package/build/static/renderStaticContent.js +28 -6
- package/build/static/renderStaticContent.js.map +1 -1
- package/build/testing-library/index.js +2 -2
- package/build/testing-library/index.js.map +1 -1
- package/build/testing-library/mocks.d.ts +1 -3
- package/build/testing-library/mocks.d.ts.map +1 -1
- package/build/testing-library/mocks.js +7 -5
- package/build/testing-library/mocks.js.map +1 -1
- package/build/testing-library/require-context-ponyfill.js +3 -3
- package/build/testing-library/require-context-ponyfill.js.map +1 -1
- package/build/useScreens.js +19 -16
- package/build/useScreens.js.map +1 -1
- package/build/views/EmptyRoute.js +5 -2
- package/build/views/EmptyRoute.js.map +1 -1
- package/build/views/ErrorBoundary.js +43 -28
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.js +16 -10
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Sitemap.js +49 -35
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/Splash.d.ts +1 -27
- package/build/views/Splash.d.ts.map +1 -1
- package/build/views/Splash.js +2 -112
- package/build/views/Splash.js.map +1 -1
- package/build/views/SuspenseFallback.js +3 -2
- package/build/views/SuspenseFallback.js.map +1 -1
- package/build/views/Toast.js +23 -18
- package/build/views/Toast.js.map +1 -1
- package/build/views/Try.js +1 -1
- package/build/views/Try.js.map +1 -1
- package/build/views/Unmatched.js +29 -17
- package/build/views/Unmatched.js.map +1 -1
- package/ios/ExpoHead.podspec +1 -1
- package/package.json +7 -18
- package/build/fork/react-native-web-container.d.ts +0 -8
- package/build/fork/react-native-web-container.d.ts.map +0 -1
- package/build/fork/react-native-web-container.js +0 -8
- package/build/fork/react-native-web-container.js.map +0 -1
- package/build/link/stateOperations.d.ts +0 -81
- package/build/link/stateOperations.d.ts.map +0 -1
- package/build/link/stateOperations.js +0 -105
- package/build/link/stateOperations.js.map +0 -1
- package/types/global.d.ts +0 -38
- package/types/metro-require.d.ts +0 -52
- package/types/react-native-web.d.ts +0 -295
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/getDevServer/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/getDevServer/index.ts"],"names":[],"mappings":";;;AAAO,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,OAAO;QACL,GAAG,EAAE,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG;KAClE,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB","sourcesContent":["export const getDevServer = () => {\n return {\n url: typeof location === 'undefined' ? '' : location.origin + '/',\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getReactNavigationConfig.d.ts","sourceRoot":"","sources":["../src/getReactNavigationConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,MAAM,MAAM,MAAM,GACd,MAAM,GACN;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;
|
|
1
|
+
{"version":3,"file":"getReactNavigationConfig.d.ts","sourceRoot":"","sources":["../src/getReactNavigationConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,MAAM,MAAM,MAAM,GACd,MAAM,GACN;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAyEN,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,SAAS,EAAE,EAClB,QAAQ,EAAE,OAAO,GAChB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIxB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,OAAO,GAChB;IACD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,CAKA"}
|
|
@@ -9,6 +9,9 @@ function convertDynamicRouteToReactNavigation(segment) {
|
|
|
9
9
|
if (segment === 'index') {
|
|
10
10
|
return '';
|
|
11
11
|
}
|
|
12
|
+
if (segment === '+not-found') {
|
|
13
|
+
return '*not-found';
|
|
14
|
+
}
|
|
12
15
|
const rest = (0, matchers_1.matchDeepDynamicRouteName)(segment);
|
|
13
16
|
if (rest != null) {
|
|
14
17
|
return '*' + rest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getReactNavigationConfig.js","sourceRoot":"","sources":["../src/getReactNavigationConfig.ts"],"names":[],"mappings":";;;AACA,yCAAyE;AAWzE,sBAAsB;AACtB,mBAAmB;AACnB,SAAS,oCAAoC,CAAC,OAAe;IAC3D,wEAAwE;IACxE,IAAI,OAAO,KAAK,OAAO,EAAE;QACvB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,IAAI,GAAG,IAAA,oCAAyB,EAAC,OAAO,CAAC,CAAC;IAChD,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,OAAO,GAAG,GAAG,IAAI,CAAC;KACnB;IACD,MAAM,WAAW,GAAG,IAAA,2BAAgB,EAAC,OAAO,CAAC,CAAC;IAE9C,IAAI,WAAW,IAAI,IAAI,EAAE;QACvB,OAAO,IAAI,WAAW,EAAE,CAAC;KAC1B;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,OAAO;IACL,gEAAgE;IAChE,yDAAyD;IACzD,qEAAqE;IACrE,QAAQ;SACL,KAAK,CAAC,GAAG,CAAC;QACX,qDAAqD;SACpD,GAAG,CAAC,oCAAoC,CAAC;QAC1C,sDAAsD;SACrD,MAAM,CAAC,OAAO,CAAC;QAChB,4BAA4B;SAC3B,IAAI,CAAC,GAAG,CAAC,CACb,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAe,EAAE,QAAiB;IAClE,MAAM,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;QACzB,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO;gBACL,IAAI;gBACJ,OAAO,EAAE,EAAE;gBACX,MAAM,EAAE,IAAI;aACb,CAAC;SACH;QACD,OAAO,IAAI,CAAC;KACb;IACD,MAAM,OAAO,GAAG,+BAA+B,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEzE,MAAM,MAAM,GAAW;QACrB,IAAI;QACJ,OAAO;QACP,mEAAmE;QACnE,kEAAkE;QAClE,6EAA6E;QAC7E,2CAA2C;QAC3C,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;KACxC,CAAC;IAEF,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;KACtB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,+BAA+B,CAC7C,KAAkB,EAClB,QAAiB;IAEjB,OAAO,MAAM,CAAC,WAAW,CACvB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,wBAAwB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAU,CAAC,CACrF,CAAC;AACJ,CAAC;AAPD,0EAOC;AAED,SAAgB,wBAAwB,CACtC,MAAiB,EACjB,QAAiB;IAKjB,OAAO;QACL,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,OAAO,EAAE,+BAA+B,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC;KACpE,CAAC;AACJ,CAAC;AAXD,4DAWC","sourcesContent":["import type { RouteNode } from './Route';\nimport { matchDeepDynamicRouteName, matchDynamicName } from './matchers';\n\nexport type Screen =\n | string\n | {\n path: string;\n screens: Record<string, Screen>;\n _route?: RouteNode;\n initialRouteName?: string;\n };\n\n// `[page]` -> `:page`\n// `page` -> `page`\nfunction convertDynamicRouteToReactNavigation(segment: string): string {\n // NOTE(EvanBacon): To support shared routes we preserve group segments.\n if (segment === 'index') {\n return '';\n }\n\n const rest = matchDeepDynamicRouteName(segment);\n if (rest != null) {\n return '*' + rest;\n }\n const dynamicName = matchDynamicName(segment);\n\n if (dynamicName != null) {\n return `:${dynamicName}`;\n }\n\n return segment;\n}\n\nfunction parseRouteSegments(segments: string): string {\n return (\n // NOTE(EvanBacon): When there are nested routes without layouts\n // the node.route will be something like `app/home/index`\n // this needs to be split to ensure each segment is parsed correctly.\n segments\n .split('/')\n // Convert each segment to a React Navigation format.\n .map(convertDynamicRouteToReactNavigation)\n // Remove any empty paths from groups or index routes.\n .filter(Boolean)\n // Join to return as a path.\n .join('/')\n );\n}\n\nfunction convertRouteNodeToScreen(node: RouteNode, metaOnly: boolean): Screen {\n const path = parseRouteSegments(node.route);\n if (!node.children.length) {\n if (!metaOnly) {\n return {\n path,\n screens: {},\n _route: node,\n };\n }\n return path;\n }\n const screens = getReactNavigationScreensConfig(node.children, metaOnly);\n\n const screen: Screen = {\n path,\n screens,\n // NOTE(EvanBacon): This is bad because it forces all Layout Routes\n // to be loaded into memory. We should move towards a system where\n // the initial route name is either loaded asynchronously in the Layout Route\n // or defined via a file system convention.\n initialRouteName: node.initialRouteName,\n };\n\n if (!metaOnly) {\n screen._route = node;\n }\n\n return screen;\n}\n\nexport function getReactNavigationScreensConfig(\n nodes: RouteNode[],\n metaOnly: boolean\n): Record<string, Screen> {\n return Object.fromEntries(\n nodes.map((node) => [node.route, convertRouteNodeToScreen(node, metaOnly)] as const)\n );\n}\n\nexport function getReactNavigationConfig(\n routes: RouteNode,\n metaOnly: boolean\n): {\n initialRouteName?: string;\n screens: Record<string, Screen>;\n} {\n return {\n initialRouteName: routes.initialRouteName,\n screens: getReactNavigationScreensConfig(routes.children, metaOnly),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getReactNavigationConfig.js","sourceRoot":"","sources":["../src/getReactNavigationConfig.ts"],"names":[],"mappings":";;;AACA,yCAAyE;AAWzE,sBAAsB;AACtB,mBAAmB;AACnB,SAAS,oCAAoC,CAAC,OAAe;IAC3D,wEAAwE;IACxE,IAAI,OAAO,KAAK,OAAO,EAAE;QACvB,OAAO,EAAE,CAAC;KACX;IACD,IAAI,OAAO,KAAK,YAAY,EAAE;QAC5B,OAAO,YAAY,CAAC;KACrB;IAED,MAAM,IAAI,GAAG,IAAA,oCAAyB,EAAC,OAAO,CAAC,CAAC;IAChD,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,OAAO,GAAG,GAAG,IAAI,CAAC;KACnB;IACD,MAAM,WAAW,GAAG,IAAA,2BAAgB,EAAC,OAAO,CAAC,CAAC;IAE9C,IAAI,WAAW,IAAI,IAAI,EAAE;QACvB,OAAO,IAAI,WAAW,EAAE,CAAC;KAC1B;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,OAAO;IACL,gEAAgE;IAChE,yDAAyD;IACzD,qEAAqE;IACrE,QAAQ;SACL,KAAK,CAAC,GAAG,CAAC;QACX,qDAAqD;SACpD,GAAG,CAAC,oCAAoC,CAAC;QAC1C,sDAAsD;SACrD,MAAM,CAAC,OAAO,CAAC;QAChB,4BAA4B;SAC3B,IAAI,CAAC,GAAG,CAAC,CACb,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAe,EAAE,QAAiB;IAClE,MAAM,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;QACzB,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO;gBACL,IAAI;gBACJ,OAAO,EAAE,EAAE;gBACX,MAAM,EAAE,IAAI;aACb,CAAC;SACH;QACD,OAAO,IAAI,CAAC;KACb;IACD,MAAM,OAAO,GAAG,+BAA+B,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEzE,MAAM,MAAM,GAAW;QACrB,IAAI;QACJ,OAAO;QACP,mEAAmE;QACnE,kEAAkE;QAClE,6EAA6E;QAC7E,2CAA2C;QAC3C,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;KACxC,CAAC;IAEF,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;KACtB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,+BAA+B,CAC7C,KAAkB,EAClB,QAAiB;IAEjB,OAAO,MAAM,CAAC,WAAW,CACvB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,wBAAwB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAU,CAAC,CACrF,CAAC;AACJ,CAAC;AAPD,0EAOC;AAED,SAAgB,wBAAwB,CACtC,MAAiB,EACjB,QAAiB;IAKjB,OAAO;QACL,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,OAAO,EAAE,+BAA+B,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC;KACpE,CAAC;AACJ,CAAC;AAXD,4DAWC","sourcesContent":["import type { RouteNode } from './Route';\nimport { matchDeepDynamicRouteName, matchDynamicName } from './matchers';\n\nexport type Screen =\n | string\n | {\n path: string;\n screens: Record<string, Screen>;\n _route?: RouteNode;\n initialRouteName?: string;\n };\n\n// `[page]` -> `:page`\n// `page` -> `page`\nfunction convertDynamicRouteToReactNavigation(segment: string): string {\n // NOTE(EvanBacon): To support shared routes we preserve group segments.\n if (segment === 'index') {\n return '';\n }\n if (segment === '+not-found') {\n return '*not-found';\n }\n\n const rest = matchDeepDynamicRouteName(segment);\n if (rest != null) {\n return '*' + rest;\n }\n const dynamicName = matchDynamicName(segment);\n\n if (dynamicName != null) {\n return `:${dynamicName}`;\n }\n\n return segment;\n}\n\nfunction parseRouteSegments(segments: string): string {\n return (\n // NOTE(EvanBacon): When there are nested routes without layouts\n // the node.route will be something like `app/home/index`\n // this needs to be split to ensure each segment is parsed correctly.\n segments\n .split('/')\n // Convert each segment to a React Navigation format.\n .map(convertDynamicRouteToReactNavigation)\n // Remove any empty paths from groups or index routes.\n .filter(Boolean)\n // Join to return as a path.\n .join('/')\n );\n}\n\nfunction convertRouteNodeToScreen(node: RouteNode, metaOnly: boolean): Screen {\n const path = parseRouteSegments(node.route);\n if (!node.children.length) {\n if (!metaOnly) {\n return {\n path,\n screens: {},\n _route: node,\n };\n }\n return path;\n }\n const screens = getReactNavigationScreensConfig(node.children, metaOnly);\n\n const screen: Screen = {\n path,\n screens,\n // NOTE(EvanBacon): This is bad because it forces all Layout Routes\n // to be loaded into memory. We should move towards a system where\n // the initial route name is either loaded asynchronously in the Layout Route\n // or defined via a file system convention.\n initialRouteName: node.initialRouteName,\n };\n\n if (!metaOnly) {\n screen._route = node;\n }\n\n return screen;\n}\n\nexport function getReactNavigationScreensConfig(\n nodes: RouteNode[],\n metaOnly: boolean\n): Record<string, Screen> {\n return Object.fromEntries(\n nodes.map((node) => [node.route, convertRouteNodeToScreen(node, metaOnly)] as const)\n );\n}\n\nexport function getReactNavigationConfig(\n routes: RouteNode,\n metaOnly: boolean\n): {\n initialRouteName?: string;\n screens: Record<string, Screen>;\n} {\n return {\n initialRouteName: routes.initialRouteName,\n screens: getReactNavigationScreensConfig(routes.children, metaOnly),\n };\n}\n"]}
|
package/build/getRoutes.d.ts
CHANGED
|
@@ -30,11 +30,10 @@ export declare function getRoutes(contextModule: RequireContext, options?: Optio
|
|
|
30
30
|
export declare function getRoutesAsync(contextModule: RequireContext, options?: Options): Promise<RouteNode | null>;
|
|
31
31
|
/** Get routes without unmatched or sitemap. */
|
|
32
32
|
export declare function getExactRoutes(contextModule: RequireContext, options?: Options): RouteNode | null;
|
|
33
|
-
export declare function getExactRoutesAsync(contextModule: RequireContext, options?: Options): Promise<RouteNode | null>;
|
|
34
33
|
/**
|
|
35
34
|
* Exposed for testing.
|
|
36
35
|
* @returns a top-level deep dynamic route if it exists, otherwise null.
|
|
37
36
|
*/
|
|
38
|
-
export declare function
|
|
37
|
+
export declare function getUserDefinedTopLevelNotFoundRoute(routes: RouteNode): RouteNode | null;
|
|
39
38
|
export {};
|
|
40
39
|
//# sourceMappingURL=getRoutes.d.ts.map
|
package/build/getRoutes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRoutes.d.ts","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"getRoutes.d.ts","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAU5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,GAAG,WAAW,CAAC,GAAG;IACnE,yBAAyB;IACzB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ,CA+C5D;AAqBD,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAejF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAMlE;AAoND;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,QAoBxD;AAED,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,aAAa,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAc5F;AAED,wBAAsB,cAAc,CAClC,aAAa,EAAE,cAAc,EAC7B,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAY3B;AAUD,+CAA+C;AAC/C,wBAAgB,cAAc,CAAC,aAAa,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAIjG;AAsDD;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAkBvF"}
|
package/build/getRoutes.js
CHANGED
|
@@ -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.
|
|
6
|
+
exports.getUserDefinedTopLevelNotFoundRoute = exports.getExactRoutes = exports.getRoutesAsync = 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. */
|
|
@@ -66,9 +66,19 @@ function getTreeNodesAsRouteNodes(nodes) {
|
|
|
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
|
-
|
|
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,16 +126,6 @@ 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
129
|
function folderNodeToRouteNode({ name, children }) {
|
|
130
130
|
// Empty folder, skip it.
|
|
131
131
|
if (!children.length) {
|
|
@@ -145,19 +145,8 @@ function fileNodeToRouteNode(tree) {
|
|
|
145
145
|
if (!node)
|
|
146
146
|
throw new Error('node must be defined');
|
|
147
147
|
const dynamic = generateDynamic(name);
|
|
148
|
-
const
|
|
149
|
-
|
|
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,
|
|
@@ -165,8 +154,12 @@ function fileNodeToRouteNode(tree) {
|
|
|
165
154
|
children: getTreeNodesAsRouteNodes(children),
|
|
166
155
|
dynamic,
|
|
167
156
|
};
|
|
168
|
-
if (
|
|
169
|
-
return clones.map((clone) => applyDefaultInitialRouteName(
|
|
157
|
+
if (clones.size) {
|
|
158
|
+
return [...clones].map((clone) => applyDefaultInitialRouteName({
|
|
159
|
+
...output,
|
|
160
|
+
contextKey: node.contextKey.replace(output.route, clone),
|
|
161
|
+
route: clone,
|
|
162
|
+
}));
|
|
170
163
|
}
|
|
171
164
|
return [
|
|
172
165
|
applyDefaultInitialRouteName({
|
|
@@ -178,6 +171,26 @@ function fileNodeToRouteNode(tree) {
|
|
|
178
171
|
}),
|
|
179
172
|
];
|
|
180
173
|
}
|
|
174
|
+
function extrapolateGroupRoutes(route, contextKey, routes = new Set()) {
|
|
175
|
+
const match = (0, matchers_1.matchGroupName)(route);
|
|
176
|
+
if (!match) {
|
|
177
|
+
routes.add(route);
|
|
178
|
+
return routes;
|
|
179
|
+
}
|
|
180
|
+
const groups = match?.split(',');
|
|
181
|
+
const groupsSet = new Set(groups);
|
|
182
|
+
if (groupsSet.size !== groups.length) {
|
|
183
|
+
throw new Error(`Array syntax cannot contain duplicate group name "${groups}" in "${contextKey}".`);
|
|
184
|
+
}
|
|
185
|
+
if (groups.length === 1) {
|
|
186
|
+
routes.add(route);
|
|
187
|
+
return routes;
|
|
188
|
+
}
|
|
189
|
+
for (const group of groups) {
|
|
190
|
+
extrapolateGroupRoutes(route.replace(match, group.trim()), contextKey, routes);
|
|
191
|
+
}
|
|
192
|
+
return routes;
|
|
193
|
+
}
|
|
181
194
|
function treeNodeToRouteNode(tree) {
|
|
182
195
|
if (tree.node) {
|
|
183
196
|
return fileNodeToRouteNode(tree);
|
|
@@ -237,10 +250,6 @@ function hasCustomRootLayoutNode(routes) {
|
|
|
237
250
|
}
|
|
238
251
|
return false;
|
|
239
252
|
}
|
|
240
|
-
function treeNodesToRootRoute(treeNode) {
|
|
241
|
-
const routes = treeNodeToRouteNode(treeNode);
|
|
242
|
-
return withOptionalRootLayout(routes);
|
|
243
|
-
}
|
|
244
253
|
function processKeys(files, options) {
|
|
245
254
|
const { ignore } = options;
|
|
246
255
|
return files.filter((file) => {
|
|
@@ -282,7 +291,7 @@ function getRoutes(contextModule, options) {
|
|
|
282
291
|
}
|
|
283
292
|
exports.getRoutes = getRoutes;
|
|
284
293
|
async function getRoutesAsync(contextModule, options) {
|
|
285
|
-
const route =
|
|
294
|
+
const route = getExactRoutes(contextModule, options);
|
|
286
295
|
if (!route) {
|
|
287
296
|
return null;
|
|
288
297
|
}
|
|
@@ -302,8 +311,8 @@ function getIgnoreList(options) {
|
|
|
302
311
|
/** Get routes without unmatched or sitemap. */
|
|
303
312
|
function getExactRoutes(contextModule, options) {
|
|
304
313
|
const treeNodes = contextModuleToTree(contextModule, options);
|
|
305
|
-
const
|
|
306
|
-
return
|
|
314
|
+
const routes = treeNodeToRouteNode(treeNodes);
|
|
315
|
+
return withOptionalRootLayout(routes) || null;
|
|
307
316
|
}
|
|
308
317
|
exports.getExactRoutes = getExactRoutes;
|
|
309
318
|
function contextModuleToTree(contextModule, options) {
|
|
@@ -315,12 +324,6 @@ function contextModuleToTree(contextModule, options) {
|
|
|
315
324
|
const files = contextModuleToFileNodes(contextModule, options, allowed);
|
|
316
325
|
return getRecursiveTree(files);
|
|
317
326
|
}
|
|
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
327
|
function appendSitemapRoute(routes) {
|
|
325
328
|
if (!routes.children.length ||
|
|
326
329
|
// Allow overriding the sitemap route
|
|
@@ -343,15 +346,15 @@ function appendSitemapRoute(routes) {
|
|
|
343
346
|
}
|
|
344
347
|
function appendUnmatchedRoute(routes) {
|
|
345
348
|
// Auto add not found route if it doesn't exist
|
|
346
|
-
const userDefinedDynamicRoute =
|
|
349
|
+
const userDefinedDynamicRoute = getUserDefinedTopLevelNotFoundRoute(routes);
|
|
347
350
|
if (!userDefinedDynamicRoute) {
|
|
348
351
|
routes.children.push({
|
|
349
352
|
loadRoute() {
|
|
350
353
|
return { default: require('./views/Unmatched').Unmatched };
|
|
351
354
|
},
|
|
352
|
-
route: '
|
|
353
|
-
contextKey: '
|
|
354
|
-
dynamic: [{ name: '
|
|
355
|
+
route: '+not-found',
|
|
356
|
+
contextKey: './+not-found.tsx',
|
|
357
|
+
dynamic: [{ name: '+not-found', deep: true, notFound: true }],
|
|
355
358
|
children: [],
|
|
356
359
|
generated: true,
|
|
357
360
|
internal: true,
|
|
@@ -363,19 +366,18 @@ function appendUnmatchedRoute(routes) {
|
|
|
363
366
|
* Exposed for testing.
|
|
364
367
|
* @returns a top-level deep dynamic route if it exists, otherwise null.
|
|
365
368
|
*/
|
|
366
|
-
function
|
|
369
|
+
function getUserDefinedTopLevelNotFoundRoute(routes) {
|
|
367
370
|
// Auto add not found route if it doesn't exist
|
|
368
371
|
for (const route of routes.children ?? []) {
|
|
369
372
|
if (route.generated)
|
|
370
373
|
continue;
|
|
371
|
-
const
|
|
372
|
-
const isDeepDynamic = (0, matchers_1.matchDeepDynamicRouteName)(opaqueRoute);
|
|
374
|
+
const isDeepDynamic = (0, matchers_1.stripGroupSegmentsFromPath)(route.route) === '+not-found' && route.route.match(/\+not-found$/);
|
|
373
375
|
if (isDeepDynamic) {
|
|
374
376
|
return route;
|
|
375
377
|
}
|
|
376
378
|
// Recurse through group routes
|
|
377
379
|
if ((0, matchers_1.matchGroupName)(route.route)) {
|
|
378
|
-
const child =
|
|
380
|
+
const child = getUserDefinedTopLevelNotFoundRoute(route);
|
|
379
381
|
if (child) {
|
|
380
382
|
return child;
|
|
381
383
|
}
|
|
@@ -383,7 +385,7 @@ function getUserDefinedDeepDynamicRoute(routes) {
|
|
|
383
385
|
}
|
|
384
386
|
return null;
|
|
385
387
|
}
|
|
386
|
-
exports.
|
|
388
|
+
exports.getUserDefinedTopLevelNotFoundRoute = getUserDefinedTopLevelNotFoundRoute;
|
|
387
389
|
function withOptionalRootLayout(routes) {
|
|
388
390
|
if (!routes?.length) {
|
|
389
391
|
return null;
|
package/build/getRoutes.js.map
CHANGED
|
@@ -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,C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A,yBAAc,EAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAC/B,MAAM,KAAK,GAAG,8BAA8B,CAAC,KAAK,CAAC,CAAC;YACpD,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,wEAkBC;AAED,SAAS,sBAAsB,CAAC,MAA0B;IACxD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE;QACnB,OAAO,IAAI,CAAC;KACb;IAED,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAE;QACnC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;KAClB;IAED,OAAO;QACL,SAAS,EAAE,GAAG,EAAE,CAAC,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;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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AI,CAAC;KACb;IAED,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAE;QACnC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;KAClB;IAED,OAAO;QACL,SAAS,EAAE,GAAG,EAAE,CAAC,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} 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 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): 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 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 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),\n dynamic,\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 contextKey: node.contextKey,\n children: getTreeNodesAsRouteNodes(children),\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): 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 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 = getExactRoutes(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 routes = treeNodeToRouteNode(treeNodes);\n return withOptionalRootLayout(routes) || 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\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 = getUserDefinedTopLevelNotFoundRoute(routes);\n if (!userDefinedDynamicRoute) {\n routes.children.push({\n loadRoute() {\n return { default: require('./views/Unmatched').Unmatched };\n },\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): 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(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"]}
|
|
@@ -22,6 +22,7 @@ export interface RouteRegex {
|
|
|
22
22
|
export declare function getServerManifest(route: RouteNode): {
|
|
23
23
|
apiRoutes: {
|
|
24
24
|
generated: boolean | undefined;
|
|
25
|
+
file: string;
|
|
25
26
|
page: string;
|
|
26
27
|
namedRegex: string;
|
|
27
28
|
routeKeys: {
|
|
@@ -30,6 +31,7 @@ export declare function getServerManifest(route: RouteNode): {
|
|
|
30
31
|
}[];
|
|
31
32
|
htmlRoutes: {
|
|
32
33
|
generated: boolean | undefined;
|
|
34
|
+
file: string;
|
|
33
35
|
page: string;
|
|
34
36
|
namedRegex: string;
|
|
35
37
|
routeKeys: {
|
|
@@ -38,6 +40,7 @@ export declare function getServerManifest(route: RouteNode): {
|
|
|
38
40
|
}[];
|
|
39
41
|
notFoundRoutes: {
|
|
40
42
|
generated: boolean | undefined;
|
|
43
|
+
file: string;
|
|
41
44
|
page: string;
|
|
42
45
|
namedRegex: string;
|
|
43
46
|
routeKeys: {
|
|
@@ -46,6 +49,7 @@ export declare function getServerManifest(route: RouteNode): {
|
|
|
46
49
|
}[];
|
|
47
50
|
};
|
|
48
51
|
export declare function getNamedRouteRegex(normalizedRoute: string, page: string): {
|
|
52
|
+
file: string;
|
|
49
53
|
page: string;
|
|
50
54
|
namedRegex: string;
|
|
51
55
|
routeKeys: {
|
|
@@ -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;
|
|
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;AAWD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BjD;AASD,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;;;;;EAQvE"}
|
|
@@ -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
|
-
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":";;;AAUA,yCAA2C;AAC3C,6CAA0C;AAa1C,SAAS,UAAU,CAAC,KAAgB;IAClC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,eAAe,CAAC,KAAgB;IACvC,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,EAAE;QACzB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC;AAClE,CAAC;AAED,yFAAyF;AACzF,SAAgB,iBAAiB,CAAC,KAAgB;IAChD,SAAS,YAAY,CAAC,KAAgB;QACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE;YACzB,OAAO,KAAK,C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IAAI,CAAC,GAAG,CAAC,EAAE;QACzB,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;KAC7C;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,IAAI,GAAG,KAAK,CAAC;IAEjB,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACzB,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC1B;IAED,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACxB,MAAM,GAAG,IAAI,CAAC;QACd,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACtB;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright © 2023 Vercel, Inc.\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 * Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts\n */\nimport type { RouteNode } from './Route';\nimport { getContextKey } from './matchers';\nimport { sortRoutes } from './sortRoutes';\n\nexport interface Group {\n pos: number;\n repeat: boolean;\n optional: boolean;\n}\n\nexport interface RouteRegex {\n groups: { [groupName: string]: Group };\n re: RegExp;\n}\n\nfunction isApiRoute(route: RouteNode) {\n return !route.children.length && !!route.contextKey.match(/\\+api\\.[jt]sx?$/);\n}\n\nfunction isNotFoundRoute(route: RouteNode) {\n if (route.route === '404') {\n return true;\n }\n return route.dynamic?.length && route.dynamic[0].name === '404';\n}\n\n// Given a nested route tree, return a flattened array of all routes that can be matched.\nexport function getServerManifest(route: RouteNode) {\n function getFlatNodes(route: RouteNode): [string, RouteNode][] {\n if (route.children.length) {\n return route.children.map((child) => getFlatNodes(child)).flat();\n }\n\n const key = getContextKey(route.contextKey).replace(/\\/index$/, '') ?? '/';\n return [[key, route]];\n }\n\n const flat = getFlatNodes(route)\n .sort(([, a], [, b]) => sortRoutes(b, a))\n .reverse();\n\n const apiRoutes = flat.filter(([, route]) => isApiRoute(route));\n const otherRoutes = flat.filter(([, route]) => !isApiRoute(route));\n const standardRoutes = otherRoutes.filter(([, route]) => !isNotFoundRoute(route));\n const notFoundRoutes = otherRoutes.filter(([, route]) => isNotFoundRoute(route));\n\n return {\n apiRoutes: getMatchableManifestForPaths(\n apiRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n htmlRoutes: getMatchableManifestForPaths(\n standardRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n notFoundRoutes: getMatchableManifestForPaths(\n notFoundRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n };\n}\n\nfunction getMatchableManifestForPaths(paths: [string, RouteNode][]) {\n return paths.map((normalizedRoutePath) => ({\n ...getNamedRouteRegex(normalizedRoutePath[0], normalizedRoutePath[1].contextKey),\n generated: normalizedRoutePath[1].generated,\n }));\n}\n\nexport function getNamedRouteRegex(normalizedRoute: string, page: string) {\n const result = getNamedParametrizedRoute(normalizedRoute);\n return {\n page: page.replace(/\\.[jt]sx?$/, ''),\n namedRegex: `^${result.namedParameterizedRoute}(?:/)?$`,\n routeKeys: result.routeKeys,\n };\n}\n\n/**\n * Builds a function to generate a minimal routeKey using only a-z and minimal\n * number of characters.\n */\nfunction buildGetSafeRouteKey() {\n let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler\n let currentLength = 1;\n\n return () => {\n let result = '';\n let incrementNext = true;\n\n // Iterate from right to left to build the key\n for (let i = 0; i < currentLength; i++) {\n if (incrementNext) {\n currentCharCode++;\n if (currentCharCode > 122) {\n currentCharCode = 97; // Reset to 'a'\n incrementNext = true; // Continue to increment the next character\n } else {\n incrementNext = false;\n }\n }\n result = String.fromCharCode(currentCharCode) + result;\n }\n\n // If all characters are 'z', increase the length of the key\n if (incrementNext) {\n currentLength++;\n currentCharCode = 96; // This will make the next key start with 'a'\n }\n\n return result;\n };\n}\n\nfunction removeTrailingSlash(route: string) {\n return route.replace(/\\/$/, '') || '/';\n}\n\nfunction getNamedParametrizedRoute(route: string) {\n const segments = removeTrailingSlash(route).slice(1).split('/');\n const getSafeRouteKey = buildGetSafeRouteKey();\n const routeKeys: { [named: string]: string } = {};\n return {\n namedParameterizedRoute: segments\n .map((segment) => {\n if (/^\\[.*\\]$/.test(segment)) {\n const { name, optional, repeat } = parseParameter(segment.slice(1, -1));\n // replace any non-word characters since they can break\n // the named regex\n let cleanedKey = name.replace(/\\W/g, '');\n let invalidKey = false;\n\n // check if the key is still invalid and fallback to using a known\n // safe key\n if (cleanedKey.length === 0 || cleanedKey.length > 30) {\n invalidKey = true;\n }\n if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {\n invalidKey = true;\n }\n\n // Prevent duplicates after sanitizing the key\n if (cleanedKey in routeKeys) {\n invalidKey = true;\n }\n\n if (invalidKey) {\n cleanedKey = getSafeRouteKey();\n }\n\n routeKeys[cleanedKey] = name;\n return repeat\n ? optional\n ? `(?:/(?<${cleanedKey}>.+?))?`\n : `/(?<${cleanedKey}>.+?)`\n : `/(?<${cleanedKey}>[^/]+?)`;\n } else if (/^\\(.*\\)$/.test(segment)) {\n // Make section optional\n return `(?:/${escapeStringRegexp(segment)})?`;\n } else {\n return `/${escapeStringRegexp(segment)}`;\n }\n })\n .join(''),\n routeKeys,\n };\n}\n\n// regexp is based on https://github.com/sindresorhus/escape-string-regexp\nconst reHasRegExp = /[|\\\\{}()[\\]^$+*?.-]/;\nconst reReplaceRegExp = /[|\\\\{}()[\\]^$+*?.-]/g;\n\nfunction escapeStringRegexp(str: string) {\n // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23\n if (reHasRegExp.test(str)) {\n return str.replace(reReplaceRegExp, '\\\\$&');\n }\n return str;\n}\n\nfunction parseParameter(param: string) {\n let repeat = false;\n let optional = false;\n let name = param;\n\n if (/^\\[.*\\]$/.test(name)) {\n optional = true;\n name = name.slice(1, -1);\n }\n\n if (/^\\.\\.\\./.test(name)) {\n repeat = true;\n name = name.slice(3);\n }\n\n return { name, repeat, optional };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":";;;AAUA,yCAA2C;AAC3C,6CAA0C;AAa1C,SAAS,UAAU,CAAC,KAAgB;IAClC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,eAAe,CAAC,KAAgB;IACvC,OAAO,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC3E,CAAC;AAED,yFAAyF;AACzF,SAAgB,iBAAiB,CAAC,KAAgB;IAChD,SAAS,YAAY,CAAC,KAAgB;QACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE;YACzB,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAClE;QAED,MAAM,GAAG,GAAG,IAAA,wBAAa,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;QAC3E,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,CA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CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,IAAI,GAAG,KAAK,CAAC;IAEjB,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACzB,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC1B;IAED,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACxB,MAAM,GAAG,IAAI,CAAC;QACd,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACtB;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright © 2023 Vercel, Inc.\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 * Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts\n */\nimport type { RouteNode } from './Route';\nimport { getContextKey } from './matchers';\nimport { sortRoutes } from './sortRoutes';\n\nexport interface Group {\n pos: number;\n repeat: boolean;\n optional: boolean;\n}\n\nexport interface RouteRegex {\n groups: { [groupName: string]: Group };\n re: RegExp;\n}\n\nfunction isApiRoute(route: RouteNode) {\n return !route.children.length && !!route.contextKey.match(/\\+api\\.[jt]sx?$/);\n}\n\nfunction isNotFoundRoute(route: RouteNode) {\n return route.dynamic && route.dynamic[route.dynamic.length - 1].notFound;\n}\n\n// Given a nested route tree, return a flattened array of all routes that can be matched.\nexport function getServerManifest(route: RouteNode) {\n function getFlatNodes(route: RouteNode): [string, RouteNode][] {\n if (route.children.length) {\n return route.children.map((child) => getFlatNodes(child)).flat();\n }\n\n const key = getContextKey(route.contextKey).replace(/\\/index$/, '') ?? '/';\n return [[key, route]];\n }\n\n const flat = getFlatNodes(route)\n .sort(([, a], [, b]) => sortRoutes(b, a))\n .reverse();\n\n const apiRoutes = flat.filter(([, route]) => isApiRoute(route));\n const otherRoutes = flat.filter(([, route]) => !isApiRoute(route));\n const standardRoutes = otherRoutes.filter(([, route]) => !isNotFoundRoute(route));\n const notFoundRoutes = otherRoutes.filter(([, route]) => isNotFoundRoute(route));\n\n return {\n apiRoutes: getMatchableManifestForPaths(\n apiRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n htmlRoutes: getMatchableManifestForPaths(\n standardRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n notFoundRoutes: getMatchableManifestForPaths(\n notFoundRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n };\n}\n\nfunction getMatchableManifestForPaths(paths: [string, RouteNode][]) {\n return paths.map((normalizedRoutePath) => ({\n ...getNamedRouteRegex(normalizedRoutePath[0], normalizedRoutePath[1].contextKey),\n generated: normalizedRoutePath[1].generated,\n }));\n}\n\nexport function getNamedRouteRegex(normalizedRoute: string, page: string) {\n const result = getNamedParametrizedRoute(normalizedRoute);\n return {\n file: page,\n page: page.replace(/\\.[jt]sx?$/, ''),\n namedRegex: `^${result.namedParameterizedRoute}(?:/)?$`,\n routeKeys: result.routeKeys,\n };\n}\n\n/**\n * Builds a function to generate a minimal routeKey using only a-z and minimal\n * number of characters.\n */\nfunction buildGetSafeRouteKey() {\n let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler\n let currentLength = 1;\n\n return () => {\n let result = '';\n let incrementNext = true;\n\n // Iterate from right to left to build the key\n for (let i = 0; i < currentLength; i++) {\n if (incrementNext) {\n currentCharCode++;\n if (currentCharCode > 122) {\n currentCharCode = 97; // Reset to 'a'\n incrementNext = true; // Continue to increment the next character\n } else {\n incrementNext = false;\n }\n }\n result = String.fromCharCode(currentCharCode) + result;\n }\n\n // If all characters are 'z', increase the length of the key\n if (incrementNext) {\n currentLength++;\n currentCharCode = 96; // This will make the next key start with 'a'\n }\n\n return result;\n };\n}\n\nfunction removeTrailingSlash(route: string) {\n return route.replace(/\\/$/, '') || '/';\n}\n\nfunction getNamedParametrizedRoute(route: string) {\n const segments = removeTrailingSlash(route).slice(1).split('/');\n const getSafeRouteKey = buildGetSafeRouteKey();\n const routeKeys: { [named: string]: string } = {};\n return {\n namedParameterizedRoute: segments\n .map((segment, index) => {\n if (segment === '+not-found' && index === segments.length - 1) {\n segment = '[...not-found]';\n }\n if (/^\\[.*\\]$/.test(segment)) {\n const { name, optional, repeat } = parseParameter(segment.slice(1, -1));\n // replace any non-word characters since they can break\n // the named regex\n let cleanedKey = name.replace(/\\W/g, '');\n let invalidKey = false;\n\n // check if the key is still invalid and fallback to using a known\n // safe key\n if (cleanedKey.length === 0 || cleanedKey.length > 30) {\n invalidKey = true;\n }\n if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {\n invalidKey = true;\n }\n\n // Prevent duplicates after sanitizing the key\n if (cleanedKey in routeKeys) {\n invalidKey = true;\n }\n\n if (invalidKey) {\n cleanedKey = getSafeRouteKey();\n }\n\n routeKeys[cleanedKey] = name;\n return repeat\n ? optional\n ? `(?:/(?<${cleanedKey}>.+?))?`\n : `/(?<${cleanedKey}>.+?)`\n : `/(?<${cleanedKey}>[^/]+?)`;\n } else if (/^\\(.*\\)$/.test(segment)) {\n // Make section optional\n return `(?:/${escapeStringRegexp(segment)})?`;\n } else {\n return `/${escapeStringRegexp(segment)}`;\n }\n })\n .join(''),\n routeKeys,\n };\n}\n\n// regexp is based on https://github.com/sindresorhus/escape-string-regexp\nconst reHasRegExp = /[|\\\\{}()[\\]^$+*?.-]/;\nconst reReplaceRegExp = /[|\\\\{}()[\\]^$+*?.-]/g;\n\nfunction escapeStringRegexp(str: string) {\n // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23\n if (reHasRegExp.test(str)) {\n return str.replace(reReplaceRegExp, '\\\\$&');\n }\n return str;\n}\n\nfunction parseParameter(param: string) {\n let repeat = false;\n let optional = false;\n let name = param;\n\n if (/^\\[.*\\]$/.test(name)) {\n optional = true;\n name = name.slice(1, -1);\n }\n\n if (/^\\.\\.\\./.test(name)) {\n repeat = true;\n name = name.slice(3);\n }\n\n return { name, repeat, optional };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-store.d.ts","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAGlC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"router-store.d.ts","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAGlC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAiC,aAAa,EAAY,MAAM,OAAO,CAAC;AAI/E,OAAO,EAAE,SAAS,EAAyB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAoB,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C;;;;GAIG;AACH,qBAAa,WAAW;IACtB,SAAS,EAAG,SAAS,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAG,aAAa,CAAC;IAC9B,OAAO,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,wBAAwB,CAAkB;IAElD,YAAY,EAAE,WAAW,GAAG,SAAS,CAAC;IACtC,SAAS,EAAE,WAAW,GAAG,SAAS,CAAC;IACnC,SAAS,EAAE,WAAW,GAAG,SAAS,CAAC;IACnC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAElC,aAAa,EAAG,iCAAiC,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IACjF,yBAAyB,EAAG,MAAM,IAAI,CAAC;IAEvC,oBAAoB,YAAiB,IAAI,EAAI;IAC7C,gBAAgB,YAAiB,IAAI,EAAI;IAEzC,MAAM,MAAqB;IAC3B,eAAe,MAA8B;IAC7C,MAAM,MAAqB;IAC3B,SAAS,MAAwB;IACjC,IAAI,MAAmB;IACvB,OAAO,MAAsB;IAC7B,SAAS,MAAwB;IAEjC,UAAU,CACR,OAAO,EAAE,cAAc,EACvB,aAAa,EAAE,iCAAiC,CAAC,eAAe,CAAC,aAAa,CAAC,EAC/E,eAAe,CAAC,EAAE,GAAG;IAiGvB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,cAAQ;IAWjD,YAAY,CAAC,KAAK,EAAE,WAAW;IAgB/B,kBAAkB;IAIlB,uEAAuE;IACvE,oBAAoB,eAAgB,MAAM,IAAI,mBAG5C;IACF,gBAAgB,eAAgB,MAAM,IAAI,mBAGxC;IACF,QAAQ,aAEN;IACF,iBAAiB,oBAEf;IACF,iBAAiB,kBAEf;CACH;AAED,eAAO,MAAM,KAAK,aAAoB,CAAC;AAEvC,wBAAgB,aAAa,gBAE5B;AAYD,wBAAgB,iBAAiB,gBAOhC;AAED,wBAAgB,iBAAiB,cAOhC;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,GAAG,SAAS,eAQhG"}
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.useInitializeExpoRouter = exports.useStoreRouteInfo = exports.useStoreRootState = exports.useExpoRouter = exports.store = exports.RouterStore = void 0;
|
|
4
27
|
const native_1 = require("@react-navigation/native");
|
|
28
|
+
const SplashScreen = __importStar(require("expo-splash-screen"));
|
|
5
29
|
const react_1 = require("react");
|
|
6
30
|
const routing_1 = require("./routing");
|
|
7
31
|
const sort_routes_1 = require("./sort-routes");
|
|
@@ -10,7 +34,6 @@ const getPathFromState_1 = require("../fork/getPathFromState");
|
|
|
10
34
|
const getLinkingConfig_1 = require("../getLinkingConfig");
|
|
11
35
|
const getRoutes_1 = require("../getRoutes");
|
|
12
36
|
const useScreens_1 = require("../useScreens");
|
|
13
|
-
const Splash_1 = require("../views/Splash");
|
|
14
37
|
/**
|
|
15
38
|
* This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.
|
|
16
39
|
*
|
|
@@ -70,6 +93,7 @@ class RouterStore {
|
|
|
70
93
|
this.routeInfo = {
|
|
71
94
|
unstable_globalHref: '',
|
|
72
95
|
pathname: '',
|
|
96
|
+
isIndex: false,
|
|
73
97
|
params: {},
|
|
74
98
|
segments: [],
|
|
75
99
|
};
|
|
@@ -90,7 +114,9 @@ class RouterStore {
|
|
|
90
114
|
if (!this.hasAttemptedToHideSplash) {
|
|
91
115
|
this.hasAttemptedToHideSplash = true;
|
|
92
116
|
// NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.
|
|
93
|
-
requestAnimationFrame(() =>
|
|
117
|
+
requestAnimationFrame(() =>
|
|
118
|
+
// @ts-expect-error: This function is native-only and for internal-use only.
|
|
119
|
+
SplashScreen._internal_maybeHideAsync?.());
|
|
94
120
|
}
|
|
95
121
|
let shouldUpdateSubscribers = this.nextState === state;
|
|
96
122
|
this.nextState = undefined;
|