expo-router 3.2.0 → 3.3.1
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/_ctx.android.js +1 -1
- package/_ctx.ios.js +1 -1
- package/_ctx.web.js +1 -1
- package/babel.js +1 -209
- package/build/LocationProvider.d.ts.map +1 -1
- package/build/LocationProvider.js +14 -2
- package/build/LocationProvider.js.map +1 -1
- package/build/Route.d.ts +2 -0
- package/build/Route.d.ts.map +1 -1
- package/build/Route.js.map +1 -1
- package/build/fork/getPathFromState.d.ts.map +1 -1
- package/build/fork/getPathFromState.js +7 -3
- package/build/fork/getPathFromState.js.map +1 -1
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +12 -4
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getRoutes.d.ts +8 -4
- package/build/getRoutes.d.ts.map +1 -1
- package/build/getRoutes.js +105 -24
- package/build/getRoutes.js.map +1 -1
- package/build/getServerManifest.d.ts +14 -37
- package/build/getServerManifest.d.ts.map +1 -1
- package/build/getServerManifest.js.map +1 -1
- package/build/global-state/router-store.js +1 -1
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.js +3 -3
- package/build/global-state/routing.js.map +1 -1
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +24 -5
- package/build/hooks.js.map +1 -1
- package/build/import-mode/index.d.ts +1 -1
- package/build/import-mode/index.d.ts.map +1 -1
- package/build/import-mode/index.js +1 -1
- package/build/import-mode/index.js.map +1 -1
- package/build/loadStaticParamsAsync.d.ts +1 -0
- package/build/loadStaticParamsAsync.d.ts.map +1 -1
- package/build/loadStaticParamsAsync.js +107 -72
- package/build/loadStaticParamsAsync.js.map +1 -1
- package/build/qualified-entry.d.ts.map +1 -1
- package/build/qualified-entry.js +7 -5
- package/build/qualified-entry.js.map +1 -1
- package/build/routes-manifest.d.ts.map +1 -1
- package/build/routes-manifest.js +1 -0
- package/build/routes-manifest.js.map +1 -1
- package/build/static/html.d.ts.map +1 -1
- package/build/static/html.js +2 -2
- package/build/static/html.js.map +1 -1
- package/build/static/renderStaticContent.d.ts +3 -30
- package/build/static/renderStaticContent.d.ts.map +1 -1
- package/build/static/renderStaticContent.js +11 -9
- package/build/static/renderStaticContent.js.map +1 -1
- package/build/testing-library/index.js +1 -3
- package/build/testing-library/index.js.map +1 -1
- package/build/testing-library/mocks.d.ts.map +1 -1
- package/build/testing-library/mocks.js +10 -5
- package/build/testing-library/mocks.js.map +1 -1
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +13 -20
- package/build/useScreens.js.map +1 -1
- package/build/utils/url.d.ts +2 -0
- package/build/utils/url.d.ts.map +1 -1
- package/build/utils/url.js +13 -1
- package/build/utils/url.js.map +1 -1
- package/build/views/ErrorBoundary.js +7 -3
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Sitemap.js +5 -1
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/SuspenseFallback.d.ts +1 -1
- package/build/views/SuspenseFallback.d.ts.map +1 -1
- package/build/views/SuspenseFallback.js +7 -3
- package/build/views/SuspenseFallback.js.map +1 -1
- package/html.d.ts +1 -0
- package/ios/ExpoHeadModule.swift +0 -2
- package/package.json +10 -8
- package/plugin/build/index.d.ts +2 -2
- package/plugin/options.json +3 -3
- package/build/import-mode/index.android.d.ts +0 -3
- package/build/import-mode/index.android.d.ts.map +0 -1
- package/build/import-mode/index.android.js +0 -4
- package/build/import-mode/index.android.js.map +0 -1
- package/build/import-mode/index.ios.d.ts +0 -3
- package/build/import-mode/index.ios.d.ts.map +0 -1
- package/build/import-mode/index.ios.js +0 -4
- package/build/import-mode/index.ios.js.map +0 -1
- package/build/import-mode/index.web.d.ts +0 -3
- package/build/import-mode/index.web.d.ts.map +0 -1
- package/build/import-mode/index.web.js +0 -4
- package/build/import-mode/index.web.js.map +0 -1
package/build/getRoutes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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CAAC,QAAQ,IAAI,EAAE,EAAE;QACzC,IAAI,KAAK,CAAC,SAAS;YAAE,SAAS;QAC9B,MAAM,aAAa,GACjB,IAAA,qCAA0B,EAAC,KAAK,CAAC,KAAK,CAAC,KAAK,YAAY,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAChG,IAAI,aAAa,EAAE;YACjB,OAAO,KAAK,CAAC;SACd;QACD,+BAA+B;QAC/B,IAAI,IAAA,yBAAc,EAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAC/B,MAAM,KAAK,GAAG,mCAAmC,CAAC,KAAK,CAAC,CAAC;YACzD,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,kFAkBC;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} 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"]}
|
|
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,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ACD,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,kFAkBC;AAED,SAAS,sBAAsB,CAC7B,MAAsC;IAEtC,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,QAAQ,EAAE,sCAAsC;QAChD,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<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,41 +31,6 @@ export interface RouteRegex {
|
|
|
19
31
|
};
|
|
20
32
|
re: RegExp;
|
|
21
33
|
}
|
|
22
|
-
export declare function getServerManifest(route: RouteNode):
|
|
23
|
-
|
|
24
|
-
generated: boolean | undefined;
|
|
25
|
-
file: string;
|
|
26
|
-
page: string;
|
|
27
|
-
namedRegex: string;
|
|
28
|
-
routeKeys: {
|
|
29
|
-
[named: string]: string;
|
|
30
|
-
};
|
|
31
|
-
}[];
|
|
32
|
-
htmlRoutes: {
|
|
33
|
-
generated: boolean | undefined;
|
|
34
|
-
file: string;
|
|
35
|
-
page: string;
|
|
36
|
-
namedRegex: string;
|
|
37
|
-
routeKeys: {
|
|
38
|
-
[named: string]: string;
|
|
39
|
-
};
|
|
40
|
-
}[];
|
|
41
|
-
notFoundRoutes: {
|
|
42
|
-
generated: boolean | undefined;
|
|
43
|
-
file: string;
|
|
44
|
-
page: string;
|
|
45
|
-
namedRegex: string;
|
|
46
|
-
routeKeys: {
|
|
47
|
-
[named: string]: string;
|
|
48
|
-
};
|
|
49
|
-
}[];
|
|
50
|
-
};
|
|
51
|
-
export declare function getNamedRouteRegex(normalizedRoute: string, page: string): {
|
|
52
|
-
file: string;
|
|
53
|
-
page: string;
|
|
54
|
-
namedRegex: string;
|
|
55
|
-
routeKeys: {
|
|
56
|
-
[named: string]: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
34
|
+
export declare function getServerManifest(route: RouteNode): ExpoRouterServerManifestV1;
|
|
35
|
+
export declare function getNamedRouteRegex(normalizedRoute: string, page: string): ExpoRouterServerManifestV1Route;
|
|
59
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;
|
|
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,CAA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I,WAAW,CAAC,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 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
|
+
{"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":";;;AAUA,yCAA2C;AAC3C,6CAA0C;AA4B1C,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,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e,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\n// TODO: Share these types across cli, server, router, etc.\nexport type ExpoRouterServerManifestV1Route<TRegex = string> = {\n file: string;\n page: string;\n routeKeys: Record<string, string>;\n namedRegex: TRegex;\n generated?: boolean;\n};\n\nexport type ExpoRouterServerManifestV1<TRegex = string> = {\n apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n};\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): ExpoRouterServerManifestV1 {\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(\n paths: [string, RouteNode][]\n): ExpoRouterServerManifestV1Route[] {\n return paths.map((normalizedRoutePath) => ({\n ...getNamedRouteRegex(normalizedRoutePath[0], normalizedRoutePath[1].contextKey),\n generated: normalizedRoutePath[1].generated,\n }));\n}\n\nexport function getNamedRouteRegex(\n normalizedRoute: string,\n page: string\n): ExpoRouterServerManifestV1Route {\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): 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"]}
|
|
@@ -69,7 +69,7 @@ class RouterStore {
|
|
|
69
69
|
this.navigationRefSubscription?.();
|
|
70
70
|
this.rootStateSubscribers.clear();
|
|
71
71
|
this.storeSubscribers.clear();
|
|
72
|
-
this.routeNode = (0, getRoutes_1.getRoutes)(context);
|
|
72
|
+
this.routeNode = (0, getRoutes_1.getRoutes)(context, { ignoreEntryPoints: true });
|
|
73
73
|
this.rootComponent = this.routeNode ? (0, useScreens_1.getQualifiedRouteComponent)(this.routeNode) : react_1.Fragment;
|
|
74
74
|
// Only error in production, in development we will show the onboarding screen
|
|
75
75
|
if (!this.routeNode && process.env.NODE_ENV === 'production') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAIkC;AAClC,iEA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AAC;AARD,0DAQC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\n\nimport { canGoBack, goBack, linkTo, push, replace, setParams } from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { deepEqual, getPathDataFromState } from '../fork/getPathFromState';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\n\n/**\n * 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.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking: ExpoLinkingOptions | undefined;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState: ResultState | undefined;\n rootState: ResultState | undefined;\n nextState: ResultState | undefined;\n routeInfo?: UrlObject | undefined;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n replace = replace.bind(this);\n setParams = setParams.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n initialLocation?: URL\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.routeInfo = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context);\n\n this.rootComponent = this.routeNode ? getQualifiedRouteComponent(this.routeNode) : Fragment;\n\n // Only error in production, in development we will show the onboarding screen\n if (!this.routeNode && process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n this.navigationRef = navigationRef;\n\n if (this.routeNode) {\n this.linking = getLinkingConfig(this.routeNode!);\n\n if (initialLocation) {\n this.linking.getInitialURL = () => initialLocation.toString();\n this.initialState = this.linking.getStateFromPath?.(\n initialLocation.pathname + initialLocation.search,\n this.linking.config\n );\n }\n }\n\n // There is no routeNode, so we will be showing the onboarding screen\n // In the meantime, just mock the routeInfo\n if (this.initialState) {\n this.rootState = this.initialState;\n this.routeInfo = this.getRouteInfo(this.initialState);\n } else {\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigations state change and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n requestAnimationFrame(\n () =>\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.()\n );\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!deepEqual(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: [],\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, initialLocation: URL | undefined) {\n const navigationRef = useNavigationContainerRef();\n useMemo(\n () => store.initialize(context, navigationRef, initialLocation),\n [context, initialLocation]\n );\n useExpoRouter();\n return store;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAIkC;AAClC,iEAAmD;AACnD,iCAA+E;AAE/E,uCAAgF;AAChF,+CAAgD;AAChD,0DAAuE;AAEvE,+DAA2E;AAE3E,0DAA2E;AAC3E,4CAAyC;AAEzC,8CAA2D;AAE3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAiC;IAChC,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAA0B;IACtC,SAAS,CAA0B;IACnC,SAAS,CAA0B;IACnC,SAAS,CAAyB;IAElC,aAAa,CAAoE;IACjF,yBAAyB,CAAc;IAEvC,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;IAC7C,gBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;IAEzC,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,eAAe,GAAG,6BAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,GAAG,mBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,GAAG,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,SAAS,GAAG,mBAAS,CAAC,IAAI,CAAC,IAAI,CA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AK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,eAAgC;IAC/F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EACL,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,EAC/D,CAAC,OAAO,EAAE,eAAe,CAAC,CAC3B,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AARD,0DAQC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\n\nimport { canGoBack, goBack, linkTo, push, replace, setParams } from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { deepEqual, getPathDataFromState } from '../fork/getPathFromState';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\n\n/**\n * 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.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking: ExpoLinkingOptions | undefined;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState: ResultState | undefined;\n rootState: ResultState | undefined;\n nextState: ResultState | undefined;\n routeInfo?: UrlObject | undefined;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n replace = replace.bind(this);\n setParams = setParams.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n initialLocation?: URL\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.routeInfo = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context, { ignoreEntryPoints: true });\n\n this.rootComponent = this.routeNode ? getQualifiedRouteComponent(this.routeNode) : Fragment;\n\n // Only error in production, in development we will show the onboarding screen\n if (!this.routeNode && process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n this.navigationRef = navigationRef;\n\n if (this.routeNode) {\n this.linking = getLinkingConfig(this.routeNode!);\n\n if (initialLocation) {\n this.linking.getInitialURL = () => initialLocation.toString();\n this.initialState = this.linking.getStateFromPath?.(\n initialLocation.pathname + initialLocation.search,\n this.linking.config\n );\n }\n }\n\n // There is no routeNode, so we will be showing the onboarding screen\n // In the meantime, just mock the routeInfo\n if (this.initialState) {\n this.rootState = this.initialState;\n this.routeInfo = this.getRouteInfo(this.initialState);\n } else {\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigations state change and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n requestAnimationFrame(\n () =>\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.()\n );\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!deepEqual(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: [],\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, initialLocation: URL | undefined) {\n const navigationRef = useNavigationContainerRef();\n useMemo(\n () => store.initialize(context, navigationRef, initialLocation),\n [context, initialLocation]\n );\n useExpoRouter();\n return store;\n}\n"]}
|
|
@@ -64,7 +64,7 @@ function setParams(params = {}) {
|
|
|
64
64
|
}
|
|
65
65
|
exports.setParams = setParams;
|
|
66
66
|
function linkTo(href, event) {
|
|
67
|
-
if ((0, url_1.
|
|
67
|
+
if ((0, url_1.shouldLinkExternally)(href)) {
|
|
68
68
|
Linking.openURL(href);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
@@ -126,7 +126,7 @@ function rewriteNavigationStateToParams(state, params = {}) {
|
|
|
126
126
|
if (!state)
|
|
127
127
|
return params;
|
|
128
128
|
// We Should always have at least one route in the state
|
|
129
|
-
const lastRoute = state.routes.
|
|
129
|
+
const lastRoute = state.routes[state.routes.length - 1];
|
|
130
130
|
params.screen = lastRoute.name;
|
|
131
131
|
// Weirdly, this always needs to be an object. If it's undefined, it won't work.
|
|
132
132
|
params.params = lastRoute.params ? JSON.parse(JSON.stringify(lastRoute.params)) : {};
|
|
@@ -148,7 +148,7 @@ function getNavigatePushAction(state, rootState) {
|
|
|
148
148
|
}
|
|
149
149
|
function getNavigateReplaceAction(state, parentState, lastNavigatorSupportingReplace = parentState) {
|
|
150
150
|
// We should always have at least one route in the state
|
|
151
|
-
const route = state.routes.
|
|
151
|
+
const route = state.routes[state.routes.length - 1];
|
|
152
152
|
// Only these navigators support replace
|
|
153
153
|
if (parentState.type === 'stack' || parentState.type === 'tab') {
|
|
154
154
|
lastNavigatorSupportingReplace = parentState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AAIxC,uCAAiD;AACjD,uCAAuC;AACvC,sCAAoD;AAEpD,SAAS,aAAa,CAAC,KAAkB;IACvC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QAClC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;KACH;AACH,CAAC;AAED,SAAgB,IAAI,CAAoB,GAAS;IAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC;AAFD,oBAEC;AAED,SAAgB,OAAO,CAAoB,GAAS;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC;AAFD,0BAEC;AAED,SAAgB,MAAM;IACpB,aAAa,CAAC,IAAI,CAAC,CAAC;IACpB,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC;AAHD,wBAGC;AAED,SAAgB,SAAS;IACvB,oEAAoE;IACpE,2EAA2E;IAC3E,8FAA8F;IAC9F,yEAAyE;IACzE,uCAAuC;IACvC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QACjC,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC,aAAa,E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O,IAAI,WAAW,CAAC,IAAI,KAAK,KAAK,EAAE;QAC9D,8BAA8B,GAAG,WAAW,CAAC;KAC9C;IAED,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/F,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC;IAE9E,wFAAwF;IACxF,IAAI,KAAK,CAAC,KAAK,IAAI,cAAc,IAAI,YAAY,CAAC,KAAK,EAAE;QACvD,OAAO,wBAAwB,CAC7B,KAAK,CAAC,KAAK,EACX,YAAY,CAAC,KAAY,EACzB,8BAA8B,CAC/B,CAAC;KACH;IAED,mFAAmF;IACnF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,8BAA8B,CAAC,KAAK,CAAC,CAAC;IAEjE,OAAO;QACL,IAAI,EAAE,8BAA8B,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC7E,MAAM,EAAE,8BAA8B,EAAE,GAAG;QAC3C,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { type NavigationAction, type NavigationState } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport type { RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { Href, resolveHref } from '../link/href';\nimport { resolve } from '../link/path';\nimport { hasUrlProtocolPrefix } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport function push(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url));\n}\n\nexport function replace(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'REPLACE');\n}\n\nexport function goBack(this: RouterStore) {\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function setParams(this: RouterStore, params: Record<string, string | number> = {}) {\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport function linkTo(this: RouterStore, href: string, event?: string) {\n if (hasUrlProtocolPrefix(href)) {\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n if (href.startsWith('.')) {\n // Resolve base path by merging the current segments with the params\n let base =\n this.routeInfo?.segments\n ?.map((segment) => {\n if (!segment.startsWith('[')) return segment;\n\n if (segment.startsWith('[...')) {\n segment = segment.slice(4, -1);\n const params = this.routeInfo?.params?.[segment];\n if (Array.isArray(params)) {\n return params.join('/');\n } else {\n return params?.split(',')?.join('/') ?? '';\n }\n } else {\n segment = segment.slice(1, -1);\n return this.routeInfo?.params?.[segment];\n }\n })\n .filter(Boolean)\n .join('/') ?? '/';\n\n if (!this.routeInfo?.isIndex) {\n base += '/..';\n }\n\n href = resolve(base, href);\n }\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n switch (event) {\n case 'REPLACE':\n return navigationRef.dispatch(getNavigateReplaceAction(state, rootState));\n default:\n return navigationRef.dispatch(getNavigatePushAction(state, rootState));\n }\n}\n\ntype NavigationParams = Partial<{\n screen: string;\n params: NavigationParams;\n}>;\n\nfunction rewriteNavigationStateToParams(\n state?: { routes: ResultState['routes'] },\n params: NavigationParams = {}\n) {\n if (!state) return params;\n // We Should always have at least one route in the state\n const lastRoute = state.routes.at(-1)!;\n params.screen = lastRoute.name;\n // Weirdly, this always needs to be an object. If it's undefined, it won't work.\n params.params = lastRoute.params ? JSON.parse(JSON.stringify(lastRoute.params)) : {};\n\n if (lastRoute.state) {\n rewriteNavigationStateToParams(lastRoute.state, params.params);\n }\n\n return JSON.parse(JSON.stringify(params));\n}\n\nfunction getNavigatePushAction(state: ResultState, rootState: NavigationState) {\n const { screen, params } = rewriteNavigationStateToParams(state);\n return {\n type: 'NAVIGATE',\n target: rootState.key,\n payload: {\n name: screen,\n params,\n },\n };\n}\n\nfunction getNavigateReplaceAction(\n state: ResultState,\n parentState: NavigationState,\n lastNavigatorSupportingReplace: NavigationState = parentState\n): NavigationAction {\n // We should always have at least one route in the state\n const route = state.routes.at(-1)!;\n\n // Only these navigators support replace\n if (parentState.type === 'stack' || parentState.type === 'tab') {\n lastNavigatorSupportingReplace = parentState;\n }\n\n const currentRoute = parentState.routes.find((parentRoute) => parentRoute.name === route.name);\n const routesAreEqual = parentState.routes[parentState.index] === currentRoute;\n\n // If there is nested state and the routes are equal, we should keep going down the tree\n if (route.state && routesAreEqual && currentRoute.state) {\n return getNavigateReplaceAction(\n route.state,\n currentRoute.state as any,\n lastNavigatorSupportingReplace\n );\n }\n\n // Either we reached the bottom of the state or the point where the routes diverged\n const { screen, params } = rewriteNavigationStateToParams(state);\n\n return {\n type: lastNavigatorSupportingReplace.type === 'stack' ? 'REPLACE' : 'JUMP_TO',\n target: lastNavigatorSupportingReplace?.key,\n payload: {\n name: screen,\n params,\n },\n };\n}\n"]}
|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M,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC;IAE9E,wFAAwF;IACxF,IAAI,KAAK,CAAC,KAAK,IAAI,cAAc,IAAI,YAAY,CAAC,KAAK,EAAE;QACvD,OAAO,wBAAwB,CAC7B,KAAK,CAAC,KAAK,EACX,YAAY,CAAC,KAAY,EACzB,8BAA8B,CAC/B,CAAC;KACH;IAED,mFAAmF;IACnF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,8BAA8B,CAAC,KAAK,CAAC,CAAC;IAEjE,OAAO;QACL,IAAI,EAAE,8BAA8B,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC7E,MAAM,EAAE,8BAA8B,EAAE,GAAG;QAC3C,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { type NavigationAction, type NavigationState } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport type { RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { Href, resolveHref } from '../link/href';\nimport { resolve } from '../link/path';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport function push(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url));\n}\n\nexport function replace(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'REPLACE');\n}\n\nexport function goBack(this: RouterStore) {\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function setParams(this: RouterStore, params: Record<string, string | number> = {}) {\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport function linkTo(this: RouterStore, href: string, event?: string) {\n if (shouldLinkExternally(href)) {\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n if (href.startsWith('.')) {\n // Resolve base path by merging the current segments with the params\n let base =\n this.routeInfo?.segments\n ?.map((segment) => {\n if (!segment.startsWith('[')) return segment;\n\n if (segment.startsWith('[...')) {\n segment = segment.slice(4, -1);\n const params = this.routeInfo?.params?.[segment];\n if (Array.isArray(params)) {\n return params.join('/');\n } else {\n return params?.split(',')?.join('/') ?? '';\n }\n } else {\n segment = segment.slice(1, -1);\n return this.routeInfo?.params?.[segment];\n }\n })\n .filter(Boolean)\n .join('/') ?? '/';\n\n if (!this.routeInfo?.isIndex) {\n base += '/..';\n }\n\n href = resolve(base, href);\n }\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n switch (event) {\n case 'REPLACE':\n return navigationRef.dispatch(getNavigateReplaceAction(state, rootState));\n default:\n return navigationRef.dispatch(getNavigatePushAction(state, rootState));\n }\n}\n\ntype NavigationParams = Partial<{\n screen: string;\n params: NavigationParams;\n}>;\n\nfunction rewriteNavigationStateToParams(\n state?: { routes: ResultState['routes'] },\n params: NavigationParams = {}\n) {\n if (!state) return params;\n // We Should always have at least one route in the state\n const lastRoute = state.routes[state.routes.length - 1]!;\n params.screen = lastRoute.name;\n // Weirdly, this always needs to be an object. If it's undefined, it won't work.\n params.params = lastRoute.params ? JSON.parse(JSON.stringify(lastRoute.params)) : {};\n\n if (lastRoute.state) {\n rewriteNavigationStateToParams(lastRoute.state, params.params);\n }\n\n return JSON.parse(JSON.stringify(params));\n}\n\nfunction getNavigatePushAction(state: ResultState, rootState: NavigationState) {\n const { screen, params } = rewriteNavigationStateToParams(state);\n return {\n type: 'NAVIGATE',\n target: rootState.key,\n payload: {\n name: screen,\n params,\n },\n };\n}\n\nfunction getNavigateReplaceAction(\n state: ResultState,\n parentState: NavigationState,\n lastNavigatorSupportingReplace: NavigationState = parentState\n): NavigationAction {\n // We should always have at least one route in the state\n const route = state.routes[state.routes.length - 1]!;\n\n // Only these navigators support replace\n if (parentState.type === 'stack' || parentState.type === 'tab') {\n lastNavigatorSupportingReplace = parentState;\n }\n\n const currentRoute = parentState.routes.find((parentRoute) => parentRoute.name === route.name);\n const routesAreEqual = parentState.routes[parentState.index] === currentRoute;\n\n // If there is nested state and the routes are equal, we should keep going down the tree\n if (route.state && routesAreEqual && currentRoute.state) {\n return getNavigateReplaceAction(\n route.state,\n currentRoute.state as any,\n lastNavigatorSupportingReplace\n );\n }\n\n // Either we reached the bottom of the state or the point where the routes diverged\n const { screen, params } = rewriteNavigationStateToParams(state);\n\n return {\n type: lastNavigatorSupportingReplace.type === 'stack' ? 'REPLACE' : 'JUMP_TO',\n target: lastNavigatorSupportingReplace?.key,\n payload: {\n name: screen,\n params,\n },\n };\n}\n"]}
|
package/build/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM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,KACxC,OAAO,CAAC,OAAO,CAAC,CAEpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAwBpB"}
|
package/build/hooks.js
CHANGED
|
@@ -86,11 +86,30 @@ exports.useGlobalSearchParams = useGlobalSearchParams;
|
|
|
86
86
|
* To observe updates even when the invoking route is not focused, use `useGlobalSearchParams()`.
|
|
87
87
|
*/
|
|
88
88
|
function useLocalSearchParams() {
|
|
89
|
-
|
|
89
|
+
const params = react_1.default.useContext(native_1.NavigationRouteContext)?.params ?? {};
|
|
90
|
+
return Object.fromEntries(Object.entries(params).map(([key, value]) => {
|
|
91
|
+
if (Array.isArray(value)) {
|
|
92
|
+
return [
|
|
93
|
+
key,
|
|
94
|
+
value.map((v) => {
|
|
95
|
+
try {
|
|
96
|
+
return decodeURIComponent(v);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return v;
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
try {
|
|
106
|
+
return [key, decodeURIComponent(value)];
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return [key, value];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
90
113
|
}
|
|
91
114
|
exports.useLocalSearchParams = useLocalSearchParams;
|
|
92
|
-
function useOptionalLocalRoute() {
|
|
93
|
-
const route = react_1.default.useContext(native_1.NavigationRouteContext);
|
|
94
|
-
return route;
|
|
95
|
-
}
|
|
96
115
|
//# sourceMappingURL=hooks.js.map
|
package/build/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings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,MAAM,IAAI,EAAE,CAAC;IACtE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO;gBACL,GAAG;gBACH,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACd,IAAI;wBACF,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;qBAC9B;oBAAC,MAAM;wBACN,OAAO,CAAC,CAAC;qBACV;gBACH,CAAC,CAAC;aACH,CAAC;SACH;aAAM;YACL,IAAI;gBACF,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAe,CAAC,CAAC,CAAC;aACnD;YAAC,MAAM;gBACN,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC,CAAC,CACiB,CAAC;AACxB,CAAC;AA1BD,oDA0BC","sourcesContent":["import { NavigationRouteContext } from '@react-navigation/native';\nimport React from 'react';\n\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './types';\n\ntype SearchParams = Record<string, string | string[]>;\n\nexport function useRootNavigationState() {\n return useStoreRootState();\n}\n\nexport function useRouteInfo() {\n return useStoreRouteInfo();\n}\n\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\nexport function useRouter(): Router {\n return React.useMemo(\n () => ({\n push: store.push,\n back: store.goBack,\n replace: store.replace,\n setParams: store.setParams,\n canGoBack: store.canGoBack,\n // TODO(EvanBacon): add `reload`\n }),\n []\n );\n}\n\n/**\n * @private\n * @returns the current global pathname with query params attached. This may change in the future to include the hostname from a predefined universal link, i.e. `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`\n */\nexport function useUnstableGlobalHref(): string {\n return useStoreRouteInfo().unstable_globalHref;\n}\n\n/**\n * Get a list of selected file segments for the currently selected route. Segments are not normalized, so they will be the same as the file path. e.g. /[id]?id=normal -> [\"[id]\"]\n *\n * `useSegments` can be typed using an abstract.\n * Consider the following file structure, and strictly typed `useSegments` function:\n *\n * ```md\n * - app\n * - [user]\n * - index.js\n * - followers.js\n * - settings.js\n * ```\n * This can be strictly typed using the following abstract:\n *\n * ```ts\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends string[] = string[]>(): TSegments {\n return useStoreRouteInfo().segments as TSegments;\n}\n\n/** @returns global selected pathname without query parameters. */\nexport function usePathname(): string {\n return useStoreRouteInfo().pathname;\n}\n\n/**\n * Get the globally selected query parameters, including dynamic path segments. This function will update even when the route is not focused.\n * Useful for analytics or other background operations that don't draw to the screen.\n *\n * When querying search params in a stack, opt-towards using `useLocalSearchParams` as these will only\n * update when the route is focused.\n *\n * @see `useLocalSearchParams`\n */\nexport function useGlobalSearchParams<\n TParams extends SearchParams = SearchParams,\n>(): Partial<TParams> {\n return useStoreRouteInfo().params as Partial<TParams>;\n}\n\n/**\n * Returns the URL search parameters for the contextually focused route. e.g. `/acme?foo=bar` -> `{ foo: \"bar\" }`.\n * This is useful for stacks where you may push a new screen that changes the query parameters.\n *\n * To observe updates even when the invoking route is not focused, use `useGlobalSearchParams()`.\n */\nexport function useLocalSearchParams<\n TParams extends SearchParams = SearchParams,\n>(): Partial<TParams> {\n const params = React.useContext(NavigationRouteContext)?.params ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as Partial<TParams>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/import-mode/index.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/import-mode/index.ts"],"names":[],"mappings":";AAAA,wBAAkF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/import-mode/index.ts"],"names":[],"mappings":";;AAAA,kBAAe,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/import-mode/index.ts"],"names":[],"mappings":";;AAAA,kBAAe,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAK,MAA0B,CAAC","sourcesContent":["export default process.env.EXPO_ROUTER_IMPORT_MODE || ('sync' as 'sync' | 'lazy');\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { RouteNode } from './Route';
|
|
2
2
|
export declare function loadStaticParamsAsync(route: RouteNode): Promise<RouteNode>;
|
|
3
|
+
export declare function assertStaticParams(route: Pick<RouteNode, 'contextKey' | 'dynamic'>, params: Record<string, string | string[]>): void;
|
|
3
4
|
//# sourceMappingURL=loadStaticParamsAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadStaticParamsAsync.d.ts","sourceRoot":"","sources":["../src/loadStaticParamsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"loadStaticParamsAsync.d.ts","sourceRoot":"","sources":["../src/loadStaticParamsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAC;AAE5D,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAMhF;AAgID,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,GAAG,SAAS,CAAC,EAChD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,QA2D1C"}
|