expo-router 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_ctx.d.ts +1 -3
- package/build/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +5 -2
- package/build/ExpoRoot.js.map +1 -1
- package/build/LocationProvider.d.ts +1 -1
- package/build/LocationProvider.d.ts.map +1 -1
- package/build/LocationProvider.js.map +1 -1
- package/build/fork/NavigationContainer.native.d.ts +0 -5
- package/build/fork/NavigationContainer.native.d.ts.map +1 -1
- package/build/fork/NavigationContainer.native.js.map +1 -1
- package/build/fork/getPathFromState.js +2 -1
- package/build/fork/getPathFromState.js.map +1 -1
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +1 -1
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/fork/react-native-web-container.d.ts +8 -0
- package/build/fork/react-native-web-container.d.ts.map +1 -0
- package/build/fork/react-native-web-container.js +6 -0
- package/build/fork/react-native-web-container.js.map +1 -0
- package/build/getRoutes.d.ts.map +1 -1
- package/build/getRoutes.js.map +1 -1
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +2 -2
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +1 -1
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +23 -12
- package/build/global-state/routing.js.map +1 -1
- package/build/global-state/sort-routes.d.ts.map +1 -1
- package/build/global-state/sort-routes.js.map +1 -1
- package/build/head/ExpoHead.ios.d.ts.map +1 -1
- package/build/head/ExpoHead.ios.js +1 -3
- package/build/head/ExpoHead.ios.js.map +1 -1
- package/build/hooks.js.map +1 -1
- package/build/layouts/Drawer.d.ts +59 -58
- package/build/layouts/Drawer.d.ts.map +1 -1
- package/build/layouts/Drawer.js +1 -1
- package/build/layouts/Drawer.js.map +1 -1
- package/build/layouts/Stack.d.ts +63 -62
- package/build/layouts/Stack.d.ts.map +1 -1
- package/build/layouts/Stack.js.map +1 -1
- package/build/layouts/Tabs.d.ts +65 -64
- package/build/layouts/Tabs.d.ts.map +1 -1
- package/build/layouts/Tabs.js +1 -1
- package/build/layouts/Tabs.js.map +1 -1
- package/build/layouts/withLayoutContext.d.ts +3 -2
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +1 -2
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +3 -4
- package/build/link/Link.js.map +1 -1
- package/build/link/stateOperations.d.ts.map +1 -1
- package/build/link/stateOperations.js +7 -0
- package/build/link/stateOperations.js.map +1 -1
- package/build/link/useLinkToPathProps.d.ts +1 -1
- package/build/link/useLinkToPathProps.js +1 -1
- package/build/link/useLinkToPathProps.js.map +1 -1
- package/build/loadStaticParamsAsync.js.map +1 -1
- package/build/onboard/Tutorial.d.ts.map +1 -1
- package/build/onboard/Tutorial.js +34 -21
- package/build/onboard/Tutorial.js.map +1 -1
- package/build/qualified-entry.js +1 -1
- package/build/qualified-entry.js.map +1 -1
- package/build/renderRootComponent.d.ts.map +1 -1
- package/build/renderRootComponent.js +8 -2
- package/build/renderRootComponent.js.map +1 -1
- package/build/static/getRootComponent.js +1 -1
- package/build/static/getRootComponent.js.map +1 -1
- package/build/static/renderStaticContent.d.ts.map +1 -1
- package/build/static/renderStaticContent.js +20 -20
- package/build/static/renderStaticContent.js.map +1 -1
- package/build/testing-library/index.d.ts.map +1 -1
- package/build/testing-library/index.js +2 -2
- package/build/testing-library/index.js.map +1 -1
- package/build/testing-library/require-context-ponyfill.d.ts.map +1 -1
- package/build/testing-library/require-context-ponyfill.js +4 -2
- package/build/testing-library/require-context-ponyfill.js.map +1 -1
- package/build/types.d.ts +1 -1
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/useScreens.d.ts +6 -2
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js.map +1 -1
- package/build/utils/mockState.d.ts.map +1 -1
- package/build/utils/mockState.js.map +1 -1
- package/build/views/EmptyRoute.js +1 -1
- package/build/views/EmptyRoute.js.map +1 -1
- package/build/views/ErrorBoundary.d.ts.map +1 -1
- package/build/views/ErrorBoundary.js +73 -48
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.js +1 -1
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Pressable.d.ts +25 -0
- package/build/views/Pressable.d.ts.map +1 -0
- package/build/views/Pressable.js +3 -0
- package/build/views/Pressable.js.map +1 -0
- package/build/views/Screen.js +1 -1
- package/build/views/Screen.js.map +1 -1
- package/build/views/Sitemap.d.ts.map +1 -1
- package/build/views/Sitemap.js +2 -2
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/SuspenseFallback.d.ts.map +1 -1
- package/build/views/SuspenseFallback.js.map +1 -1
- package/build/views/Toast.d.ts.map +1 -1
- package/build/views/Toast.js +11 -5
- package/build/views/Toast.js.map +1 -1
- package/build/views/Unmatched.js +1 -1
- package/build/views/Unmatched.js.map +1 -1
- package/package.json +5 -16
- package/build/fork/expo/createRoot.d.ts +0 -2
- package/build/fork/expo/createRoot.d.ts.map +0 -1
- package/build/fork/expo/createRoot.js +0 -2
- package/build/fork/expo/createRoot.js.map +0 -1
- package/build/fork/expo/createRoot.native.d.ts +0 -3
- package/build/fork/expo/createRoot.native.d.ts.map +0 -1
- package/build/fork/expo/createRoot.native.js +0 -9
- package/build/fork/expo/createRoot.native.js.map +0 -1
- package/build/fork/expo/registerRootComponent.d.ts +0 -16
- package/build/fork/expo/registerRootComponent.d.ts.map +0 -1
- package/build/fork/expo/registerRootComponent.js +0 -51
- package/build/fork/expo/registerRootComponent.js.map +0 -1
package/build/getRoutes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRoutes.js","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,MAAM,eAAe,CAAC;AACpD,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AAa,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;QAC7D,IAAI,aAAa,EAAE;YACjB,OAAO,KAAK,CAAC;SACd;QACD,+BAA+B;QAC/B,IAAI,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAC/B,MAAM,KAAK,GAAG,8BAA8B,CAAC,KAAK,CAAC,CAAC;YACpD,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,sBAAsB,CAAC,MAA0B;IACxD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE;QACnB,OAAO,IAAI,CAAC;KACb;IAED,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAE;QACnC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;KAClB;IAED,OAAO;QACL,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;YAChB,OAAO,EAAG,OAAO,CAAC,mBAAmB,CAAwC;iBAC1E,gBAAgB;SACpB,CAAC;QACF,8CAA8C;QAC9C,UAAU,EAAE,eAAe;QAC3B,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,MAAM;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import type { DynamicConvention, RouteNode } from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport {\n getNameFromFilePath,\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchGroupName,\n removeSupportedExtensions,\n stripGroupSegmentsFromPath,\n stripInvisibleSegmentsFromPath,\n} from './matchers';\nimport type { RequireContext } from './types';\n\nexport type FileNode = Pick<RouteNode, 'contextKey' | 'loadRoute'> & {\n /** Like `(tab)/index` */\n normalizedName: string;\n};\n\ntype TreeNode = {\n name: string;\n children: TreeNode[];\n parents: string[];\n /** null when there is no file in a folder. */\n node: FileNode | null;\n};\n\ntype Options = {\n ignore?: RegExp[];\n};\n\n/** Convert a flat map of file nodes into a nested tree of files. */\nexport function getRecursiveTree(files: FileNode[]): TreeNode {\n const tree = {\n name: '',\n children: [],\n parents: [],\n node: null,\n };\n\n for (const file of files) {\n // ['(tab)', 'settings', '[...another]']\n const parts = file.normalizedName.split('/');\n let currentNode: TreeNode = tree;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n\n if (i === parts.length - 1 && part === '_layout') {\n if (currentNode.node) {\n const overwritten = currentNode.node.contextKey;\n throw new Error(\n `Higher priority Layout Route \"${file.contextKey}\" overriding redundant Layout Route \"${overwritten}\". Remove the Layout Route \"${overwritten}\" to fix this.`\n );\n }\n continue;\n }\n\n const existing = currentNode.children.find((item) => item.name === part);\n if (existing) {\n currentNode = existing;\n } else {\n const newNode: TreeNode = {\n name: part,\n children: [],\n parents: [...currentNode.parents, currentNode.name],\n node: null,\n };\n currentNode.children.push(newNode);\n currentNode = newNode;\n }\n }\n currentNode.node = file;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assertDeprecatedFormat(tree);\n }\n\n return tree;\n}\n\nfunction assertDeprecatedFormat(tree: TreeNode) {\n for (const child of tree.children) {\n if (child.node && child.children.length && !child.node.normalizedName.endsWith('_layout')) {\n const ext = child.node.contextKey.split('.').pop();\n throw new Error(\n `Using deprecated Layout Route format: Move \\`./app/${child.node.normalizedName}.${ext}\\` to \\`./app/${child.node.normalizedName}/_layout.${ext}\\``\n );\n }\n assertDeprecatedFormat(child);\n }\n}\n\nfunction getTreeNodesAsRouteNodes(nodes: TreeNode[]): RouteNode[] {\n return nodes\n .map((node) => treeNodeToRouteNode(node))\n .flat()\n .filter(Boolean) as RouteNode[];\n}\n\nexport function generateDynamicFromSegment(name: string): DynamicConvention | null {\n const deepDynamicName = matchDeepDynamicRouteName(name);\n const dynamicName = deepDynamicName ?? matchDynamicName(name);\n\n return dynamicName ? { name: dynamicName, deep: !!deepDynamicName } : null;\n}\n\nexport function generateDynamic(name: string): RouteNode['dynamic'] {\n const description = name\n .split('/')\n .map((segment) => generateDynamicFromSegment(segment))\n .filter(Boolean) as DynamicConvention[];\n return description.length === 0 ? null : description;\n}\n\nfunction collapseRouteSegments(route: string) {\n return stripGroupSegmentsFromPath(route.replace(/\\/index$/, ''));\n}\n\n/**\n * Given a route node and a name representing the group name,\n * find the nearest child matching the name.\n *\n * Doesn't support slashes in the name.\n * Routes like `explore/(something)/index` will be matched against `explore`.\n *\n */\nfunction getDefaultInitialRoute(node: RouteNode, name: string) {\n return node.children.find((node) => collapseRouteSegments(node.route) === name);\n}\n\nfunction applyDefaultInitialRouteName(node: RouteNode): RouteNode {\n const groupName = matchGroupName(node.route);\n if (!node.children?.length) {\n return node;\n }\n\n // Guess at the initial route based on the group name.\n // TODO(EvanBacon): Perhaps we should attempt to warn when the group doesn't match any child routes.\n let initialRouteName = groupName ? getDefaultInitialRoute(node, groupName)?.route : undefined;\n const loaded = node.loadRoute();\n\n if (loaded?.unstable_settings) {\n // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.\n initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;\n\n if (groupName) {\n // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.\n const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;\n\n initialRouteName = groupSpecificInitialRouteName ?? initialRouteName;\n }\n }\n\n return {\n ...node,\n initialRouteName,\n };\n}\n\nfunction cloneGroupRoute(node: RouteNode, { name: nextName }: { name: string }): RouteNode {\n const groupName = `(${nextName})`;\n const parts = node.contextKey.split('/');\n parts[parts.length - 2] = groupName;\n\n return {\n ...node,\n route: groupName,\n contextKey: parts.join('/'),\n };\n}\n\nfunction folderNodeToRouteNode({ name, children }: TreeNode): RouteNode[] | null {\n // Empty folder, skip it.\n if (!children.length) {\n return null;\n }\n\n // When there's a directory, but no layout route file (with valid export), the child routes won't be grouped.\n // This pushes all children into the nearest layout route.\n return getTreeNodesAsRouteNodes(\n children.map((child) => {\n return {\n ...child,\n name: [name, child.name].filter(Boolean).join('/'),\n };\n })\n );\n}\n\nfunction fileNodeToRouteNode(tree: TreeNode): RouteNode[] | null {\n const { name, node, children } = tree;\n\n if (!node) throw new Error('node must be defined');\n\n const dynamic = generateDynamic(name);\n\n const groupName = matchGroupName(name);\n const multiGroup = groupName?.includes(',');\n\n const clones = multiGroup ? groupName!.split(',').map((v) => ({ name: v.trim() })) : null;\n\n // Assert duplicates:\n if (clones) {\n const names = new Set<string>();\n for (const clone of clones) {\n if (names.has(clone.name)) {\n throw new Error(\n `Array syntax cannot contain duplicate group name \"${clone.name}\" in \"${node.contextKey}\".`\n );\n }\n names.add(clone.name);\n }\n }\n\n const output = {\n loadRoute: node.loadRoute,\n route: name,\n contextKey: node.contextKey,\n children: getTreeNodesAsRouteNodes(children),\n dynamic,\n };\n\n if (Array.isArray(clones)) {\n return clones.map((clone) =>\n applyDefaultInitialRouteName(cloneGroupRoute({ ...output }, clone))\n );\n }\n\n return [\n applyDefaultInitialRouteName({\n loadRoute: node.loadRoute,\n route: name,\n contextKey: node.contextKey,\n children: getTreeNodesAsRouteNodes(children),\n dynamic,\n }),\n ];\n}\n\nfunction treeNodeToRouteNode(tree: TreeNode): RouteNode[] | null {\n if (tree.node) {\n return fileNodeToRouteNode(tree);\n }\n\n return folderNodeToRouteNode(tree);\n}\n\nfunction contextModuleToFileNodes(\n contextModule: RequireContext,\n 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 if (!contextModule(key)?.default) {\n return null;\n }\n }\n }\n const node: FileNode = {\n loadRoute() {\n return contextModule(key);\n },\n normalizedName: getNameFromFilePath(key),\n contextKey: key,\n };\n\n return node;\n } catch (error) {\n // Probably this won't stop metro from freaking out but it's worth a try.\n console.warn('Error loading route \"' + key + '\"', error);\n }\n return null;\n });\n\n return nodes.filter(Boolean) as FileNode[];\n}\n\nfunction hasCustomRootLayoutNode(routes: RouteNode[]) {\n if (routes.length !== 1) {\n return false;\n }\n // This could either be the root _layout or an app with a single file.\n const route = routes[0];\n\n if (route.route === '' && route.contextKey.match(/^\\.\\/_layout\\.([jt]sx?)$/)) {\n return true;\n }\n return false;\n}\n\nfunction treeNodesToRootRoute(treeNode: TreeNode): RouteNode | null {\n const routes = treeNodeToRouteNode(treeNode);\n return withOptionalRootLayout(routes);\n}\n\nfunction processKeys(files: string[], options: Options): string[] {\n const { ignore } = options;\n\n return files.filter((file) => {\n return !ignore?.some((pattern) => pattern.test(file));\n });\n}\n\n/**\n * Asserts if the require.context has files that share the same name but have different extensions. Exposed for testing.\n * @private\n */\nexport function assertDuplicateRoutes(filenames: string[]) {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n const duplicates = filenames\n .map((filename) => removeSupportedExtensions(filename))\n .reduce((acc, filename) => {\n acc[filename] = acc[filename] ? acc[filename] + 1 : 1;\n return acc;\n }, {} as Record<string, number>);\n\n Object.entries(duplicates).forEach(([filename, count]) => {\n if (count > 1) {\n throw new Error(`Multiple files match the route name \"${filename}\".`);\n }\n });\n}\n\n/** Given a Metro context module, return an array of nested routes. */\nexport function getRoutes(contextModule: RequireContext, options?: Options): RouteNode | null {\n const route = getExactRoutes(contextModule, options);\n\n // If there is no route, return an empty route.\n if (!route) {\n return null;\n }\n\n appendSitemapRoute(route);\n\n // Auto add not found route if it doesn't exist\n appendUnmatchedRoute(route);\n\n return route;\n}\n\nexport async function getRoutesAsync(\n contextModule: RequireContext,\n options?: Options\n): Promise<RouteNode | null> {\n const route = await getExactRoutesAsync(contextModule, options);\n if (!route) {\n return null;\n }\n\n appendSitemapRoute(route);\n\n // Auto add not found route if it doesn't exist\n appendUnmatchedRoute(route);\n\n return route;\n}\n\nfunction getIgnoreList(options?: Options) {\n const ignore: RegExp[] = [/^\\.\\/\\+html\\.[tj]sx?$/, ...(options?.ignore ?? [])];\n return ignore;\n}\n\n/** Get routes without unmatched or sitemap. */\nexport function getExactRoutes(contextModule: RequireContext, options?: Options): RouteNode | null {\n const treeNodes = contextModuleToTree(contextModule, options);\n const route = treeNodesToRootRoute(treeNodes);\n return route || null;\n}\n\nfunction contextModuleToTree(contextModule: RequireContext, options?: Options) {\n const allowed = processKeys(contextModule.keys(), {\n ...options,\n ignore: getIgnoreList(options),\n });\n assertDuplicateRoutes(allowed);\n const files = contextModuleToFileNodes(contextModule, allowed);\n return getRecursiveTree(files);\n}\n\nexport async function getExactRoutesAsync(\n contextModule: RequireContext,\n options?: Options\n): Promise<RouteNode | null> {\n const treeNodes = contextModuleToTree(contextModule, options);\n const route = treeNodesToRootRoute(treeNodes);\n return route || null;\n}\n\nfunction appendSitemapRoute(routes: RouteNode) {\n if (\n !routes.children.length ||\n // Allow overriding the sitemap route\n routes.children.some((route) => route.route === '_sitemap')\n ) {\n return routes;\n }\n const { Sitemap, getNavOptions } = require('./views/Sitemap');\n routes.children.push({\n loadRoute() {\n return { default: Sitemap, getNavOptions };\n },\n route: '_sitemap',\n contextKey: './_sitemap.tsx',\n generated: true,\n internal: true,\n dynamic: null,\n children: [],\n });\n return routes;\n}\n\nfunction appendUnmatchedRoute(routes: RouteNode) {\n // Auto add not found route if it doesn't exist\n const userDefinedDynamicRoute = getUserDefinedDeepDynamicRoute(routes);\n if (!userDefinedDynamicRoute) {\n routes.children.push({\n loadRoute() {\n return { default: require('./views/Unmatched').Unmatched };\n },\n route: '[...404]',\n contextKey: './[...404].tsx',\n dynamic: [{ name: '404', deep: true }],\n children: [],\n generated: true,\n internal: true,\n });\n }\n return routes;\n}\n\n/**\n * Exposed for testing.\n * @returns a top-level deep dynamic route if it exists, otherwise null.\n */\nexport function getUserDefinedDeepDynamicRoute(routes: RouteNode): RouteNode | null {\n // Auto add not found route if it doesn't exist\n for (const route of routes.children ?? []) {\n if (route.generated) continue;\n const opaqueRoute = stripInvisibleSegmentsFromPath(route.route);\n const isDeepDynamic = matchDeepDynamicRouteName(opaqueRoute);\n if (isDeepDynamic) {\n return route;\n }\n // Recurse through group routes\n if (matchGroupName(route.route)) {\n const child = getUserDefinedDeepDynamicRoute(route);\n if (child) {\n return child;\n }\n }\n }\n return null;\n}\n\nfunction withOptionalRootLayout(routes: RouteNode[] | null): RouteNode | null {\n if (!routes?.length) {\n return null;\n }\n\n if (hasCustomRootLayoutNode(routes)) {\n return routes[0];\n }\n\n return {\n loadRoute: () => ({\n default: (require('./views/Navigator') as typeof import('./views/Navigator'))\n .DefaultNavigator,\n }),\n // Generate a fake file name for the directory\n contextKey: './_layout.tsx',\n route: '',\n generated: true,\n dynamic: null,\n children: routes,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getRoutes.js","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,cAAc,EACd,yBAAyB,EACzB,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AAoBpB,oEAAoE;AACpE,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,MAAM,IAAI,GAAG;QACX,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,IAAI;KACX,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,wCAAwC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,WAAW,GAAa,IAAI,CAAC;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC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ACpB,CAAC;QACF,8CAA8C;QAC9C,UAAU,EAAE,eAAe;QAC3B,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,MAAM;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import type { DynamicConvention, RouteNode } from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport {\n getNameFromFilePath,\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchGroupName,\n removeSupportedExtensions,\n stripGroupSegmentsFromPath,\n stripInvisibleSegmentsFromPath,\n} from './matchers';\nimport type { RequireContext } from './types';\n\nexport type FileNode = Pick<RouteNode, 'contextKey' | 'loadRoute'> & {\n /** Like `(tab)/index` */\n normalizedName: string;\n};\n\ntype TreeNode = {\n name: string;\n children: TreeNode[];\n parents: string[];\n /** null when there is no file in a folder. */\n node: FileNode | null;\n};\n\ntype Options = {\n ignore?: RegExp[];\n};\n\n/** Convert a flat map of file nodes into a nested tree of files. */\nexport function getRecursiveTree(files: FileNode[]): TreeNode {\n const tree = {\n name: '',\n children: [],\n parents: [],\n node: null,\n };\n\n for (const file of files) {\n // ['(tab)', 'settings', '[...another]']\n const parts = file.normalizedName.split('/');\n let currentNode: TreeNode = tree;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n\n if (i === parts.length - 1 && part === '_layout') {\n if (currentNode.node) {\n const overwritten = currentNode.node.contextKey;\n throw new Error(\n `Higher priority Layout Route \"${file.contextKey}\" overriding redundant Layout Route \"${overwritten}\". Remove the Layout Route \"${overwritten}\" to fix this.`\n );\n }\n continue;\n }\n\n const existing = currentNode.children.find((item) => item.name === part);\n if (existing) {\n currentNode = existing;\n } else {\n const newNode: TreeNode = {\n name: part,\n children: [],\n parents: [...currentNode.parents, currentNode.name],\n node: null,\n };\n currentNode.children.push(newNode);\n currentNode = newNode;\n }\n }\n currentNode.node = file;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assertDeprecatedFormat(tree);\n }\n\n return tree;\n}\n\nfunction assertDeprecatedFormat(tree: TreeNode) {\n for (const child of tree.children) {\n if (child.node && child.children.length && !child.node.normalizedName.endsWith('_layout')) {\n const ext = child.node.contextKey.split('.').pop();\n throw new Error(\n `Using deprecated Layout Route format: Move \\`./app/${child.node.normalizedName}.${ext}\\` to \\`./app/${child.node.normalizedName}/_layout.${ext}\\``\n );\n }\n assertDeprecatedFormat(child);\n }\n}\n\nfunction getTreeNodesAsRouteNodes(nodes: TreeNode[]): RouteNode[] {\n return nodes\n .map((node) => treeNodeToRouteNode(node))\n .flat()\n .filter(Boolean) as RouteNode[];\n}\n\nexport function generateDynamicFromSegment(name: string): DynamicConvention | null {\n const deepDynamicName = matchDeepDynamicRouteName(name);\n const dynamicName = deepDynamicName ?? matchDynamicName(name);\n\n return dynamicName ? { name: dynamicName, deep: !!deepDynamicName } : null;\n}\n\nexport function generateDynamic(name: string): RouteNode['dynamic'] {\n const description = name\n .split('/')\n .map((segment) => generateDynamicFromSegment(segment))\n .filter(Boolean) as DynamicConvention[];\n return description.length === 0 ? null : description;\n}\n\nfunction collapseRouteSegments(route: string) {\n return stripGroupSegmentsFromPath(route.replace(/\\/index$/, ''));\n}\n\n/**\n * Given a route node and a name representing the group name,\n * find the nearest child matching the name.\n *\n * Doesn't support slashes in the name.\n * Routes like `explore/(something)/index` will be matched against `explore`.\n *\n */\nfunction getDefaultInitialRoute(node: RouteNode, name: string) {\n return node.children.find((node) => collapseRouteSegments(node.route) === name);\n}\n\nfunction applyDefaultInitialRouteName(node: RouteNode): RouteNode {\n const groupName = matchGroupName(node.route);\n if (!node.children?.length) {\n return node;\n }\n\n // Guess at the initial route based on the group name.\n // TODO(EvanBacon): Perhaps we should attempt to warn when the group doesn't match any child routes.\n let initialRouteName = groupName ? getDefaultInitialRoute(node, groupName)?.route : undefined;\n const loaded = node.loadRoute();\n\n if (loaded?.unstable_settings) {\n // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.\n initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;\n\n if (groupName) {\n // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.\n const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;\n\n initialRouteName = groupSpecificInitialRouteName ?? initialRouteName;\n }\n }\n\n return {\n ...node,\n initialRouteName,\n };\n}\n\nfunction cloneGroupRoute(node: RouteNode, { name: nextName }: { name: string }): RouteNode {\n const groupName = `(${nextName})`;\n const parts = node.contextKey.split('/');\n parts[parts.length - 2] = groupName;\n\n return {\n ...node,\n route: groupName,\n contextKey: parts.join('/'),\n };\n}\n\nfunction folderNodeToRouteNode({ name, children }: TreeNode): RouteNode[] | null {\n // Empty folder, skip it.\n if (!children.length) {\n return null;\n }\n\n // When there's a directory, but no layout route file (with valid export), the child routes won't be grouped.\n // This pushes all children into the nearest layout route.\n return getTreeNodesAsRouteNodes(\n children.map((child) => {\n return {\n ...child,\n name: [name, child.name].filter(Boolean).join('/'),\n };\n })\n );\n}\n\nfunction fileNodeToRouteNode(tree: TreeNode): RouteNode[] | null {\n const { name, node, children } = tree;\n\n if (!node) throw new Error('node must be defined');\n\n const dynamic = generateDynamic(name);\n\n const groupName = matchGroupName(name);\n const multiGroup = groupName?.includes(',');\n\n const clones = multiGroup ? groupName!.split(',').map((v) => ({ name: v.trim() })) : null;\n\n // Assert duplicates:\n if (clones) {\n const names = new Set<string>();\n for (const clone of clones) {\n if (names.has(clone.name)) {\n throw new Error(\n `Array syntax cannot contain duplicate group name \"${clone.name}\" in \"${node.contextKey}\".`\n );\n }\n names.add(clone.name);\n }\n }\n\n const output = {\n loadRoute: node.loadRoute,\n route: name,\n contextKey: node.contextKey,\n children: getTreeNodesAsRouteNodes(children),\n dynamic,\n };\n\n if (Array.isArray(clones)) {\n return clones.map((clone) =>\n applyDefaultInitialRouteName(cloneGroupRoute({ ...output }, clone))\n );\n }\n\n return [\n applyDefaultInitialRouteName({\n loadRoute: node.loadRoute,\n route: name,\n contextKey: node.contextKey,\n children: getTreeNodesAsRouteNodes(children),\n dynamic,\n }),\n ];\n}\n\nfunction treeNodeToRouteNode(tree: TreeNode): RouteNode[] | null {\n if (tree.node) {\n return fileNodeToRouteNode(tree);\n }\n\n return folderNodeToRouteNode(tree);\n}\n\nfunction contextModuleToFileNodes(\n contextModule: RequireContext,\n 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 if (!contextModule(key)?.default) {\n return null;\n }\n }\n }\n const node: FileNode = {\n loadRoute() {\n return contextModule(key);\n },\n normalizedName: getNameFromFilePath(key),\n contextKey: key,\n };\n\n return node;\n } catch (error) {\n // Probably this won't stop metro from freaking out but it's worth a try.\n console.warn('Error loading route \"' + key + '\"', error);\n }\n return null;\n });\n\n return nodes.filter(Boolean) as FileNode[];\n}\n\nfunction hasCustomRootLayoutNode(routes: RouteNode[]) {\n if (routes.length !== 1) {\n return false;\n }\n // This could either be the root _layout or an app with a single file.\n const route = routes[0];\n\n if (route.route === '' && route.contextKey.match(/^\\.\\/_layout\\.([jt]sx?)$/)) {\n return true;\n }\n return false;\n}\n\nfunction treeNodesToRootRoute(treeNode: TreeNode): RouteNode | null {\n const routes = treeNodeToRouteNode(treeNode);\n return withOptionalRootLayout(routes);\n}\n\nfunction processKeys(files: string[], options: Options): string[] {\n const { ignore } = options;\n\n return files.filter((file) => {\n return !ignore?.some((pattern) => pattern.test(file));\n });\n}\n\n/**\n * Asserts if the require.context has files that share the same name but have different extensions. Exposed for testing.\n * @private\n */\nexport function assertDuplicateRoutes(filenames: string[]) {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n const duplicates = filenames\n .map((filename) => removeSupportedExtensions(filename))\n .reduce(\n (acc, filename) => {\n acc[filename] = acc[filename] ? acc[filename] + 1 : 1;\n return acc;\n },\n {} as Record<string, number>\n );\n\n Object.entries(duplicates).forEach(([filename, count]) => {\n if (count > 1) {\n throw new Error(`Multiple files match the route name \"${filename}\".`);\n }\n });\n}\n\n/** Given a Metro context module, return an array of nested routes. */\nexport function getRoutes(contextModule: RequireContext, options?: Options): RouteNode | null {\n const route = getExactRoutes(contextModule, options);\n\n // If there is no route, return an empty route.\n if (!route) {\n return null;\n }\n\n appendSitemapRoute(route);\n\n // Auto add not found route if it doesn't exist\n appendUnmatchedRoute(route);\n\n return route;\n}\n\nexport async function getRoutesAsync(\n contextModule: RequireContext,\n options?: Options\n): Promise<RouteNode | null> {\n const route = await getExactRoutesAsync(contextModule, options);\n if (!route) {\n return null;\n }\n\n appendSitemapRoute(route);\n\n // Auto add not found route if it doesn't exist\n appendUnmatchedRoute(route);\n\n return route;\n}\n\nfunction getIgnoreList(options?: Options) {\n const ignore: RegExp[] = [/^\\.\\/\\+html\\.[tj]sx?$/, ...(options?.ignore ?? [])];\n return ignore;\n}\n\n/** Get routes without unmatched or sitemap. */\nexport function getExactRoutes(contextModule: RequireContext, options?: Options): RouteNode | null {\n const treeNodes = contextModuleToTree(contextModule, options);\n const route = treeNodesToRootRoute(treeNodes);\n return route || null;\n}\n\nfunction contextModuleToTree(contextModule: RequireContext, options?: Options) {\n const allowed = processKeys(contextModule.keys(), {\n ...options,\n ignore: getIgnoreList(options),\n });\n assertDuplicateRoutes(allowed);\n const files = contextModuleToFileNodes(contextModule, allowed);\n return getRecursiveTree(files);\n}\n\nexport async function getExactRoutesAsync(\n contextModule: RequireContext,\n options?: Options\n): Promise<RouteNode | null> {\n const treeNodes = contextModuleToTree(contextModule, options);\n const route = treeNodesToRootRoute(treeNodes);\n return route || null;\n}\n\nfunction appendSitemapRoute(routes: RouteNode) {\n if (\n !routes.children.length ||\n // Allow overriding the sitemap route\n routes.children.some((route) => route.route === '_sitemap')\n ) {\n return routes;\n }\n const { Sitemap, getNavOptions } = require('./views/Sitemap');\n routes.children.push({\n loadRoute() {\n return { default: Sitemap, getNavOptions };\n },\n route: '_sitemap',\n contextKey: './_sitemap.tsx',\n generated: true,\n internal: true,\n dynamic: null,\n children: [],\n });\n return routes;\n}\n\nfunction appendUnmatchedRoute(routes: RouteNode) {\n // Auto add not found route if it doesn't exist\n const userDefinedDynamicRoute = getUserDefinedDeepDynamicRoute(routes);\n if (!userDefinedDynamicRoute) {\n routes.children.push({\n loadRoute() {\n return { default: require('./views/Unmatched').Unmatched };\n },\n route: '[...404]',\n contextKey: './[...404].tsx',\n dynamic: [{ name: '404', deep: true }],\n children: [],\n generated: true,\n internal: true,\n });\n }\n return routes;\n}\n\n/**\n * Exposed for testing.\n * @returns a top-level deep dynamic route if it exists, otherwise null.\n */\nexport function getUserDefinedDeepDynamicRoute(routes: RouteNode): RouteNode | null {\n // Auto add not found route if it doesn't exist\n for (const route of routes.children ?? []) {\n if (route.generated) continue;\n const opaqueRoute = stripInvisibleSegmentsFromPath(route.route);\n const isDeepDynamic = matchDeepDynamicRouteName(opaqueRoute);\n if (isDeepDynamic) {\n return route;\n }\n // Recurse through group routes\n if (matchGroupName(route.route)) {\n const child = getUserDefinedDeepDynamicRoute(route);\n if (child) {\n return child;\n }\n }\n }\n return null;\n}\n\nfunction withOptionalRootLayout(routes: RouteNode[] | null): RouteNode | null {\n if (!routes?.length) {\n return null;\n }\n\n if (hasCustomRootLayoutNode(routes)) {\n return routes[0];\n }\n\n return {\n loadRoute: () => ({\n default: (require('./views/Navigator') as typeof import('./views/Navigator'))\n .DefaultNavigator,\n }),\n // Generate a fake file name for the directory\n contextKey: './_layout.tsx',\n route: '',\n generated: true,\n dynamic: null,\n children: routes,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-store.d.ts","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAGlC,MAA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AAE,iCAAiC,CAAC,eAAe,CAAC,aAAa,CAAC,EAC/E,eAAe,CAAC,EAAE,GAAG;IA4FvB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,cAAQ;IAWjD,YAAY,CAAC,KAAK,EAAE,WAAW;IAgB/B,kBAAkB;IAIlB,uEAAuE;IACvE,oBAAoB,eAAgB,MAAM,IAAI,mBAG5C;IACF,gBAAgB,eAAgB,MAAM,IAAI,mBAGxC;IACF,QAAQ,aAEN;IACF,iBAAiB,oBAEf;IACF,iBAAiB,kBAEf;CACH;AAED,eAAO,MAAM,KAAK,aAAoB,CAAC;AAEvC,wBAAgB,aAAa,gBAE5B;AAYD,wBAAgB,iBAAiB,gBAOhC;AAED,wBAAgB,iBAAiB,cAOhC;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,GAAG,SAAS,eAQhG"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useNavigationContainerRef, } from '@react-navigation/native';
|
|
2
2
|
import { useSyncExternalStore, useMemo, Fragment } from 'react';
|
|
3
|
+
import { canGoBack, goBack, linkTo, push, replace, setParams } from './routing';
|
|
4
|
+
import { getSortedRoutes } from './sort-routes';
|
|
3
5
|
import { getRouteInfoFromState } from '../LocationProvider';
|
|
4
6
|
import { deepEqual, getPathDataFromState } from '../fork/getPathFromState';
|
|
5
7
|
import { getLinkingConfig } from '../getLinkingConfig';
|
|
6
8
|
import { getRoutes } from '../getRoutes';
|
|
7
9
|
import { getQualifiedRouteComponent } from '../useScreens';
|
|
8
10
|
import { _internal_maybeHideAsync } from '../views/Splash';
|
|
9
|
-
import { canGoBack, goBack, linkTo, push, replace, setParams } from './routing';
|
|
10
|
-
import { getSortedRoutes } from './sort-routes';
|
|
11
11
|
/**
|
|
12
12
|
* 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.
|
|
13
13
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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ACzB,KAAK,CAAC,oBAAoB,EAC1B,KAAK,CAAC,iBAAiB,EACvB,KAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAuB,EAAE,eAAgC;IAC/F,MAAM,aAAa,GAAG,yBAAyB,EAAE,CAAC;IAClD,OAAO,CACL,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,EAC/D,CAAC,OAAO,EAAE,eAAe,CAAC,CAC3B,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\n\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';\nimport { _internal_maybeHideAsync } from '../views/Splash';\nimport { canGoBack, goBack, linkTo, push, replace, setParams } from './routing';\nimport { getSortedRoutes } from './sort-routes';\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 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(() => _internal_maybeHideAsync());\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,OAAO,EAGL,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAiB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAa,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAsB,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAi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AAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AACtF,CAAC;AAED,SAAS,kBAAkB;IACzB,IAAI,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QACjC,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,YAAY,EAA4B,CAAC;QAElF,IAAI,KAAK,CAAC,SAAS,KAAK,YAAY,EAAE;YACpC,KAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACjC;KACF;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,oBAAoB,CACzB,KAAK,CAAC,oBAAoB,EAC1B,KAAK,CAAC,iBAAiB,EACvB,KAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,oBAAoB,CACzB,KAAK,CAAC,oBAAoB,EAC1B,KAAK,CAAC,iBAAiB,EACvB,KAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAuB,EAAE,eAAgC;IAC/F,MAAM,aAAa,GAAG,yBAAyB,EAAE,CAAC;IAClD,OAAO,CACL,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,EAC/D,CAAC,OAAO,EAAE,eAAe,CAAC,CAC3B,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\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';\nimport { _internal_maybeHideAsync } from '../views/Splash';\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 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(() => _internal_maybeHideAsync());\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,7 +1,7 @@
|
|
|
1
1
|
import { getActionFromState } from '@react-navigation/core';
|
|
2
|
+
import type { RouterStore } from './router-store';
|
|
2
3
|
import { Href } from '../link/href';
|
|
3
4
|
import { NavigateAction } from '../link/stateOperations';
|
|
4
|
-
import type { RouterStore } from './router-store';
|
|
5
5
|
export declare function push(this: RouterStore, url: Href): any;
|
|
6
6
|
export declare function replace(this: RouterStore, url: Href): any;
|
|
7
7
|
export declare function goBack(this: RouterStore): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,kBAAkB,EAAgB,MAAM,wBAAwB,CAAC;AAIzF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,kBAAkB,EAAgB,MAAM,wBAAwB,CAAC;AAIzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AAEjD,OAAO,EACL,cAAc,EAKf,MAAM,yBAAyB,CAAC;AAWjC,wBAAgB,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,OAEhD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,OAEnD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAGvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUpD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAM,OAGxF;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,QA8GrE;AAED,uGAAuG;AACvG,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAC5C,MAAM,IAAI,cAAc,CAqB1B"}
|
|
@@ -21,7 +21,14 @@ export function goBack() {
|
|
|
21
21
|
this.navigationRef?.current?.goBack();
|
|
22
22
|
}
|
|
23
23
|
export function canGoBack() {
|
|
24
|
-
|
|
24
|
+
// Return a default value here if the navigation hasn't mounted yet.
|
|
25
|
+
// This can happen if the user calls `canGoBack` from the Root Layout route
|
|
26
|
+
// before mounting a navigator. This behavior exists due to React Navigation being dynamically
|
|
27
|
+
// constructed at runtime. We can get rid of this in the future if we use
|
|
28
|
+
// the static configuration internally.
|
|
29
|
+
if (!this.navigationRef.isReady()) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
25
32
|
return this.navigationRef?.current?.canGoBack() ?? false;
|
|
26
33
|
}
|
|
27
34
|
export function setParams(params = {}) {
|
|
@@ -68,18 +75,22 @@ export function linkTo(href, event) {
|
|
|
68
75
|
// Can perform naive movements
|
|
69
76
|
const knownOwnerState = getQualifiedStateForTopOfTargetState(rootState, state);
|
|
70
77
|
const nextRoute = findTopRouteForTarget(state);
|
|
71
|
-
|
|
78
|
+
// NOTE(EvanBacon): There's an issue where moving from "a -> b" is considered siblings:
|
|
79
|
+
// a. index (initialRouteName="index")
|
|
80
|
+
// b. stack/index
|
|
81
|
+
// However, the preservation approach doesn't work because it would be moving to a route with the same name.
|
|
82
|
+
// The next check will see if the current focused route has the same name as the next route, if so, then fallback on
|
|
83
|
+
// the default React Navigation logic.
|
|
84
|
+
if (findTopRouteForTarget(
|
|
85
|
+
// @ts-expect-error: stale types don't matter here
|
|
86
|
+
rootState)?.name !== nextRoute.name) {
|
|
72
87
|
if (event === 'REPLACE') {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
if (event === 'REPLACE') {
|
|
82
|
-
navigationRef.dispatch(StackActions.replace(nextRoute.name, nextRoute.params));
|
|
88
|
+
if (knownOwnerState.type === 'tab') {
|
|
89
|
+
navigationRef.dispatch(TabActions.jumpTo(nextRoute.name, nextRoute.params));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
navigationRef.dispatch(StackActions.replace(nextRoute.name, nextRoute.params));
|
|
93
|
+
}
|
|
83
94
|
}
|
|
84
95
|
else {
|
|
85
96
|
// NOTE: Not sure if we should pop or push here...
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,EAAQ,WAAW,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAEL,qBAAqB,EACrB,0BAA0B,EAC1B,oCAAoC,EACpC,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,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,MAAM,UAAU,IAAI,CAAoB,GAAS;IAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,OAAO,CAAoB,GAAS;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,MAAM;IACpB,aAAa,CAAC,IAAI,CAAC,CAAC;IACpB,IAAI,CAAC,aAAa,E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EAAE;QACX,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE;YAC5B,kCAAkC;YAClC,OAAO,KAAK,CAAC;SACd;QACD,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;YACzB,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;YACnB,eAAe;SAChB;aAAM,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE;YACjC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAUD,SAAS,iBAAiB,CAAC,GAAQ;IACjC,OAAO,SAAS,IAAI,GAAG,CAAC;AAC1B,CAAC","sourcesContent":["import { CommonActions, getActionFromState, StackActions } from '@react-navigation/core';\nimport { TabActions } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport { Href, resolveHref } from '../link/href';\nimport { resolve } from '../link/path';\nimport {\n NavigateAction,\n findTopRouteForTarget,\n getEarliestMismatchedRoute,\n getQualifiedStateForTopOfTargetState,\n isMovingToSiblingRoute,\n} from '../link/stateOperations';\nimport { hasUrlProtocolPrefix } from '../utils/url';\nimport type { RouterStore } from './router-store';\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 assertIsReady(this);\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 if (href.startsWith('.')) {\n let base =\n this.linking.getPathFromState?.(navigationRef.getRootState(), {\n screens: [],\n preserveGroups: true,\n }) ?? '';\n\n if (base && !base.endsWith('/')) {\n base += '/..';\n }\n href = resolve(base, href);\n }\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n // Ensure simple operations are used when moving between siblings\n // in the same navigator. This ensures that the state is not reset.\n // TODO: We may need to apply this at a larger scale in the future.\n if (isMovingToSiblingRoute(rootState, state)) {\n // Can perform naive movements\n const knownOwnerState = getQualifiedStateForTopOfTargetState(rootState, state)!;\n const nextRoute = findTopRouteForTarget(state);\n\n if (knownOwnerState.type === 'tab') {\n if (event === 'REPLACE') {\n navigationRef.dispatch(TabActions.jumpTo(nextRoute.name, nextRoute.params));\n } else {\n navigationRef.dispatch(CommonActions.navigate(nextRoute.name, nextRoute.params));\n }\n return;\n } else {\n if (event === 'REPLACE') {\n navigationRef.dispatch(StackActions.replace(nextRoute.name, nextRoute.params));\n } else {\n // NOTE: Not sure if we should pop or push here...\n navigationRef.dispatch(CommonActions.navigate(nextRoute.name, nextRoute.params));\n }\n return;\n }\n }\n\n // TODO: Advanced movements across multiple navigators\n\n const action = getActionFromState(state, this.linking.config);\n if (action) {\n // Here we have a navigation action to a nested screen, where we should ideally replace.\n // This request can only be fulfilled if the target is an initial route.\n // First, check if the action is fully initial routes.\n // Then find the nearest mismatched route in the existing state.\n // Finally, use the correct navigator-based action to replace the nested screens.\n // NOTE(EvanBacon): A future version of this will involve splitting the navigation request so we replace as much as possible, then push the remaining screens to fulfill the request.\n if (event === 'REPLACE' && isAbsoluteInitialRoute(action)) {\n const earliest = getEarliestMismatchedRoute(rootState, action.payload);\n if (earliest) {\n if (earliest.type === 'stack') {\n navigationRef.dispatch(StackActions.replace(earliest.name, earliest.params));\n } else {\n navigationRef.dispatch(TabActions.jumpTo(earliest.name, earliest.params));\n }\n return;\n } else {\n // This should never happen because moving to the same route would be handled earlier\n // in the sibling operations.\n }\n }\n\n // Ignore the replace event here since replace across\n // navigators is not supported.\n navigationRef.dispatch(action);\n } else {\n navigationRef.reset(state);\n }\n}\n\n/** @returns `true` if the action is moving to the first screen of all the navigators in the action. */\nexport function isAbsoluteInitialRoute(\n action: ReturnType<typeof getActionFromState>\n): action is NavigateAction {\n if (action?.type !== 'NAVIGATE') {\n return false;\n }\n\n let next = action.payload.params;\n // iterate all child screens and bail out if any are not initial.\n while (next) {\n if (!isNavigationState(next)) {\n // Not sure when this would happen\n return false;\n }\n if (next.initial === true) {\n next = next.params;\n // return true;\n } else if (next.initial === false) {\n return false;\n }\n }\n\n return true;\n}\n\ntype NavStateParams = {\n params?: NavStateParams;\n path: string;\n initial: boolean;\n screen: string;\n state: unknown;\n};\n\nfunction isNavigationState(obj: any): obj is NavStateParams {\n return 'initial' in obj;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAQ,WAAW,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAEL,qBAAqB,EACrB,0BAA0B,EAC1B,o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AI,KAAK,OAAO,EAAE;oBAC7B,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;iBAC9E;qBAAM;oBACL,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;iBAC3E;gBACD,OAAO;aACR;iBAAM;gBACL,qFAAqF;gBACrF,6BAA6B;aAC9B;SACF;QAED,qDAAqD;QACrD,+BAA+B;QAC/B,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KAChC;SAAM;QACL,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KAC5B;AACH,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,sBAAsB,CACpC,MAA6C;IAE7C,IAAI,MAAM,EAAE,IAAI,KAAK,UAAU,EAAE;QAC/B,OAAO,KAAK,CAAC;KACd;IAED,IAAI,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IACjC,iEAAiE;IACjE,OAAO,IAAI,EAAE;QACX,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE;YAC5B,kCAAkC;YAClC,OAAO,KAAK,CAAC;SACd;QACD,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;YACzB,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;YACnB,eAAe;SAChB;aAAM,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE;YACjC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAUD,SAAS,iBAAiB,CAAC,GAAQ;IACjC,OAAO,SAAS,IAAI,GAAG,CAAC;AAC1B,CAAC","sourcesContent":["import { CommonActions, getActionFromState, StackActions } from '@react-navigation/core';\nimport { TabActions } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport type { RouterStore } from './router-store';\nimport { Href, resolveHref } from '../link/href';\nimport { resolve } from '../link/path';\nimport {\n NavigateAction,\n findTopRouteForTarget,\n getEarliestMismatchedRoute,\n getQualifiedStateForTopOfTargetState,\n isMovingToSiblingRoute,\n} from '../link/stateOperations';\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 if (href.startsWith('.')) {\n let base =\n this.linking.getPathFromState?.(navigationRef.getRootState(), {\n screens: [],\n preserveGroups: true,\n }) ?? '';\n\n if (base && !base.endsWith('/')) {\n base += '/..';\n }\n href = resolve(base, href);\n }\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n // Ensure simple operations are used when moving between siblings\n // in the same navigator. This ensures that the state is not reset.\n // TODO: We may need to apply this at a larger scale in the future.\n if (isMovingToSiblingRoute(rootState, state)) {\n // Can perform naive movements\n const knownOwnerState = getQualifiedStateForTopOfTargetState(rootState, state)!;\n const nextRoute = findTopRouteForTarget(state);\n // NOTE(EvanBacon): There's an issue where moving from \"a -> b\" is considered siblings:\n // a. index (initialRouteName=\"index\")\n // b. stack/index\n // However, the preservation approach doesn't work because it would be moving to a route with the same name.\n // The next check will see if the current focused route has the same name as the next route, if so, then fallback on\n // the default React Navigation logic.\n if (\n findTopRouteForTarget(\n // @ts-expect-error: stale types don't matter here\n rootState\n )?.name !== nextRoute.name\n ) {\n if (event === 'REPLACE') {\n if (knownOwnerState.type === 'tab') {\n navigationRef.dispatch(TabActions.jumpTo(nextRoute.name, nextRoute.params));\n } else {\n navigationRef.dispatch(StackActions.replace(nextRoute.name, nextRoute.params));\n }\n } else {\n // NOTE: Not sure if we should pop or push here...\n navigationRef.dispatch(CommonActions.navigate(nextRoute.name, nextRoute.params));\n }\n return;\n }\n }\n\n // TODO: Advanced movements across multiple navigators\n\n const action = getActionFromState(state, this.linking.config);\n if (action) {\n // Here we have a navigation action to a nested screen, where we should ideally replace.\n // This request can only be fulfilled if the target is an initial route.\n // First, check if the action is fully initial routes.\n // Then find the nearest mismatched route in the existing state.\n // Finally, use the correct navigator-based action to replace the nested screens.\n // NOTE(EvanBacon): A future version of this will involve splitting the navigation request so we replace as much as possible, then push the remaining screens to fulfill the request.\n if (event === 'REPLACE' && isAbsoluteInitialRoute(action)) {\n const earliest = getEarliestMismatchedRoute(rootState, action.payload);\n if (earliest) {\n if (earliest.type === 'stack') {\n navigationRef.dispatch(StackActions.replace(earliest.name, earliest.params));\n } else {\n navigationRef.dispatch(TabActions.jumpTo(earliest.name, earliest.params));\n }\n return;\n } else {\n // This should never happen because moving to the same route would be handled earlier\n // in the sibling operations.\n }\n }\n\n // Ignore the replace event here since replace across\n // navigators is not supported.\n navigationRef.dispatch(action);\n } else {\n navigationRef.reset(state);\n }\n}\n\n/** @returns `true` if the action is moving to the first screen of all the navigators in the action. */\nexport function isAbsoluteInitialRoute(\n action: ReturnType<typeof getActionFromState>\n): action is NavigateAction {\n if (action?.type !== 'NAVIGATE') {\n return false;\n }\n\n let next = action.payload.params;\n // iterate all child screens and bail out if any are not initial.\n while (next) {\n if (!isNavigationState(next)) {\n // Not sure when this would happen\n return false;\n }\n if (next.initial === true) {\n next = next.params;\n // return true;\n } else if (next.initial === false) {\n return false;\n }\n }\n\n return true;\n}\n\ntype NavStateParams = {\n params?: NavStateParams;\n path: string;\n initial: boolean;\n screen: string;\n state: unknown;\n};\n\nfunction isNavigationState(obj: any): obj is NavStateParams {\n return 'initial' in obj;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-routes.d.ts","sourceRoot":"","sources":["../../src/global-state/sort-routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sort-routes.d.ts","sourceRoot":"","sources":["../../src/global-state/sort-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,kCAMhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-routes.js","sourceRoot":"","sources":["../../src/global-state/sort-routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sort-routes.js","sourceRoot":"","sources":["../../src/global-state/sort-routes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;KACpC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACrF,CAAC","sourcesContent":["import type { RouterStore } from './router-store';\nimport { sortRoutes } from '../Route';\n\nexport function getSortedRoutes(this: RouterStore) {\n if (!this.routeNode) {\n throw new Error('No routes found');\n }\n\n return this.routeNode.children.filter((route) => !route.internal).sort(sortRoutes);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoHead.ios.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoHead.ios.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAyS1B,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG;IAChF,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC;CACI,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { useIsFocused } from '@react-navigation/core';
|
|
2
|
-
import { useLocalSearchParams, useUnstableGlobalHref, usePathname, useSegments,
|
|
3
|
-
// @ts-ignore: hack
|
|
4
|
-
} from 'expo-router';
|
|
5
2
|
import React from 'react';
|
|
6
3
|
import { ExpoHead } from './ExpoHeadModule';
|
|
7
4
|
import { getStaticUrlFromExpoRouter } from './url';
|
|
5
|
+
import { useLocalSearchParams, useUnstableGlobalHref, usePathname, useSegments } from '../hooks';
|
|
8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AAE;gBACzB,OAAO,KAAK,CAAC;aACd;YACD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACpE;QACD,cAAc;QACd,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE;YAC5B,OAAO,CAAC,KAAK,CAAC,CAAC;SAChB;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE;YACjC,OAAO,KAAK,CAAC;SACd;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAChE;IACD,OAAO,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAED,UAAU,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;AAErC,SAAS,QAAQ,CAAC,KAAqC;IACrD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,QAAQ,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;AAEnC,gDAAgD;AAChD,MAAM,CAAC,MAAM,IAAI,GAEb,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC","sourcesContent":["import { useIsFocused } from '@react-navigation/core';\nimport {\n useLocalSearchParams,\n useUnstableGlobalHref,\n usePathname,\n useSegments,\n // @ts-ignore: hack\n} from 'expo-router';\nimport React from 'react';\n\nimport { ExpoHead, UserActivity } from './ExpoHeadModule';\nimport { getStaticUrlFromExpoRouter } from './url';\n\nfunction urlToId(url: string) {\n return url.replace(/[^a-zA-Z0-9]/g, '-');\n}\n\nfunction getLastSegment(path: string) {\n // Remove the extension\n const lastSegment = path.split('/').pop() ?? '';\n return lastSegment.replace(/\\.[^/.]+$/, '').split('?')[0];\n}\n\n// TODO: Use Head Provider to collect all props so only one Head is rendered for a given route.\n\nfunction useAddressableLink() {\n const pathname = useUnstableGlobalHref();\n const params = useLocalSearchParams<any>();\n const url = getStaticUrlFromExpoRouter(pathname);\n return { url, pathname, params };\n}\n\ntype MetaNode =\n | React.ReactPortal\n | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;\n\nfunction useMetaChildren(children: React.ReactNode) {\n return React.useMemo(() => {\n const renderableChildren: React.ReactNode[] = [];\n const metaChildren: MetaNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) {\n return;\n }\n if (typeof child.type === 'string') {\n metaChildren.push(child);\n } else {\n renderableChildren.push(child);\n }\n });\n\n return { children: renderableChildren, metaChildren };\n }, [children]);\n}\n\ntype SerializedMeta = {\n type: string;\n props: { [key: string]: string | undefined };\n};\n\nfunction serializedMetaChildren(meta: MetaNode[]): SerializedMeta[] {\n const validMeta = meta.filter((child) => child.type === 'meta' || child.type === 'title');\n\n return validMeta.map((child) => {\n if (child.type === 'title') {\n return {\n type: 'title',\n props: {\n children: typeof child.props.children === 'string' ? child.props.children : undefined,\n },\n };\n }\n return {\n type: 'meta',\n props: {\n property: typeof child.props.property === 'string' ? child.props.property : undefined,\n content: typeof child.props.content === 'string' ? child.props.content : undefined,\n },\n };\n });\n}\n\nfunction useActivityFromMetaChildren(meta: MetaNode[]) {\n const { url: href, pathname } = useAddressableLink();\n\n const previousMeta = React.useRef<SerializedMeta[]>([]);\n const cachedActivity = React.useRef<Partial<UserActivity>>({});\n\n const sortedMeta = React.useMemo(() => serializedMetaChildren(meta), [meta]);\n\n const url = React.useMemo(() => {\n const urlMeta = sortedMeta.find(\n (child) => child.type === 'meta' && child.props.property === 'og:url'\n );\n\n if (urlMeta) {\n // Support =`/foo/bar` -> `https://example.com/foo/bar`\n if (urlMeta.props.content?.startsWith('/')) {\n return getStaticUrlFromExpoRouter(urlMeta.props.content);\n }\n return urlMeta.props.content;\n }\n return href;\n }, [sortedMeta, href]);\n\n const title = React.useMemo(() => {\n const titleTag = sortedMeta.find((child) => child.type === 'title');\n if (titleTag) {\n return titleTag.props.children ?? '';\n }\n const titleMeta = sortedMeta.find(\n (child) => child.type === 'meta' && child.props.property === 'og:title'\n );\n if (titleMeta) {\n return titleMeta.props.content ?? '';\n }\n\n return getLastSegment(pathname);\n }, [sortedMeta, pathname]);\n\n const activity = React.useMemo(() => {\n if (\n !!previousMeta.current &&\n !!cachedActivity.current &&\n deepObjectCompare(previousMeta.current, sortedMeta)\n ) {\n return cachedActivity.current;\n }\n previousMeta.current = sortedMeta;\n\n const userActivity: Partial<UserActivity> = {};\n\n sortedMeta.forEach((child) => {\n if (\n // <meta />\n child.type === 'meta'\n ) {\n const { property, content } = child.props;\n\n switch (property) {\n case 'og:description':\n userActivity.description = content;\n break;\n // Custom properties\n case 'expo:handoff':\n userActivity.isEligibleForHandoff = isTruthy(content);\n break;\n case 'expo:spotlight':\n userActivity.isEligibleForSearch = isTruthy(content);\n break;\n }\n\n // // <meta name=\"keywords\" content=\"foo,bar,baz\" />\n // if ([\"keywords\"].includes(name)) {\n // userActivity.keywords = Array.isArray(content)\n // ? content\n // : content.split(\",\");\n // }\n }\n });\n\n cachedActivity.current = userActivity;\n return userActivity;\n }, [meta, pathname, href]);\n\n const parsedActivity: UserActivity = {\n keywords: [title],\n ...activity,\n title,\n webpageURL: url,\n activityType: ExpoHead!.activities.INDEXED_ROUTE,\n userInfo: {\n // TODO: This may need to be versioned in the future, e.g. `_v1` if we change the format.\n href,\n },\n };\n\n return parsedActivity;\n}\n\nfunction isTruthy(value: any): boolean {\n return [true, 'true'].includes(value);\n}\n\nfunction HeadNative(props: { children?: React.ReactNode }) {\n const isFocused = useIsFocused();\n if (!isFocused) {\n return <UnfocusedHead />;\n }\n return <FocusedHead {...props} />;\n}\n\nfunction UnfocusedHead(props: { children?: React.ReactNode }): JSX.Element {\n const { children } = useMetaChildren(props.children);\n return <>{children}</>;\n}\n\nfunction FocusedHead(props: { children?: React.ReactNode }): JSX.Element {\n const { metaChildren, children } = useMetaChildren(props.children);\n const activity = useActivityFromMetaChildren(metaChildren);\n useRegisterCurrentActivity(activity);\n return <>{children}</>;\n}\n\n// segments => activity\nconst activities: Map<string, UserActivity> = new Map();\n\nfunction useRegisterCurrentActivity(activity: UserActivity) {\n // ID is tied to Expo Router and agnostic of URLs to ensure dynamic parameters are not considered.\n // Using all segments ensures that cascading routes are considered.\n const activityId = urlToId(usePathname() || '/');\n const cascadingId = urlToId(useSegments().join('-') || '-');\n const activityIds = Array.from(activities.keys());\n const cascadingActivity: UserActivity = React.useMemo(() => {\n // Get all nested activities together, then update the id to match the current pathname.\n // This enables cases like `/user/[name]/post/[id]` to match all nesting, while still having a URL-specific ID, i.e. `/user/evanbacon/post/123`\n const cascadingActivity = activities.has(cascadingId)\n ? {\n ...activities.get(cascadingId),\n ...activity,\n id: activityId,\n }\n : {\n ...activity,\n id: activityId,\n };\n activities.set(cascadingId, cascadingActivity);\n\n return cascadingActivity;\n }, [cascadingId, activityId, activity, activityIds]);\n\n const previousActivity = React.useRef<UserActivity | null>(null);\n\n React.useEffect(() => {\n if (!cascadingActivity) {\n return () => {};\n }\n if (\n !!previousActivity.current &&\n deepObjectCompare(previousActivity.current, cascadingActivity)\n ) {\n return () => {};\n }\n\n previousActivity.current = cascadingActivity;\n if (!cascadingActivity.id) {\n throw new Error('Activity must have an ID');\n }\n\n // If no features are enabled, then skip registering the activity\n if (cascadingActivity.isEligibleForHandoff || cascadingActivity.isEligibleForSearch) {\n ExpoHead?.createActivity(cascadingActivity);\n }\n\n return () => {};\n }, [cascadingActivity]);\n\n React.useEffect(() => {\n return () => {\n if (activityId) {\n ExpoHead?.suspendActivity(activityId);\n }\n };\n }, [activityId]);\n}\n\nfunction deepObjectCompare(a: any, b: any) {\n if (typeof a !== typeof b) {\n return false;\n }\n if (typeof a === 'object') {\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false;\n }\n if (Array.isArray(a)) {\n if (a.length !== b.length) {\n return false;\n }\n return a.every((item, index) => deepObjectCompare(item, b[index]));\n }\n // handle null\n if (a === null || b === null) {\n return a === b;\n }\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n return aKeys.every((key) => deepObjectCompare(a[key], b[key]));\n }\n return a === b;\n}\n\nHeadNative.Provider = React.Fragment;\n\nfunction HeadShim(props: { children?: React.ReactNode }) {\n return null;\n}\n\nHeadShim.Provider = React.Fragment;\n\n// Native Head is only enabled in bare iOS apps.\nexport const Head: ((props: { children?: React.ReactNode }) => React.ReactNode) & {\n Provider: React.ComponentType;\n} = ExpoHead ? HeadNative : HeadShim;\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoHead.ios.js","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAgB,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEjG,SAAS,OAAO,CAAC,GAAW;IAC1B,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,uBAAuB;IACvB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IAChD,OAAO,WAAW,CAAC,O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K,CAAC,QAAQ,CAAC;AAErC,SAAS,QAAQ,CAAC,KAAqC;IACrD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,QAAQ,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;AAEnC,gDAAgD;AAChD,MAAM,CAAC,MAAM,IAAI,GAEb,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC","sourcesContent":["import { useIsFocused } from '@react-navigation/core';\nimport React from 'react';\n\nimport { ExpoHead, UserActivity } from './ExpoHeadModule';\nimport { getStaticUrlFromExpoRouter } from './url';\nimport { useLocalSearchParams, useUnstableGlobalHref, usePathname, useSegments } from '../hooks';\n\nfunction urlToId(url: string) {\n return url.replace(/[^a-zA-Z0-9]/g, '-');\n}\n\nfunction getLastSegment(path: string) {\n // Remove the extension\n const lastSegment = path.split('/').pop() ?? '';\n return lastSegment.replace(/\\.[^/.]+$/, '').split('?')[0];\n}\n\n// TODO: Use Head Provider to collect all props so only one Head is rendered for a given route.\n\nfunction useAddressableLink() {\n const pathname = useUnstableGlobalHref();\n const params = useLocalSearchParams<any>();\n const url = getStaticUrlFromExpoRouter(pathname);\n return { url, pathname, params };\n}\n\ntype MetaNode =\n | React.ReactPortal\n | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;\n\nfunction useMetaChildren(children: React.ReactNode) {\n return React.useMemo(() => {\n const renderableChildren: React.ReactNode[] = [];\n const metaChildren: MetaNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) {\n return;\n }\n if (typeof child.type === 'string') {\n metaChildren.push(child);\n } else {\n renderableChildren.push(child);\n }\n });\n\n return { children: renderableChildren, metaChildren };\n }, [children]);\n}\n\ntype SerializedMeta = {\n type: string;\n props: { [key: string]: string | undefined };\n};\n\nfunction serializedMetaChildren(meta: MetaNode[]): SerializedMeta[] {\n const validMeta = meta.filter((child) => child.type === 'meta' || child.type === 'title');\n\n return validMeta.map((child) => {\n if (child.type === 'title') {\n return {\n type: 'title',\n props: {\n children: typeof child.props.children === 'string' ? child.props.children : undefined,\n },\n };\n }\n return {\n type: 'meta',\n props: {\n property: typeof child.props.property === 'string' ? child.props.property : undefined,\n content: typeof child.props.content === 'string' ? child.props.content : undefined,\n },\n };\n });\n}\n\nfunction useActivityFromMetaChildren(meta: MetaNode[]) {\n const { url: href, pathname } = useAddressableLink();\n\n const previousMeta = React.useRef<SerializedMeta[]>([]);\n const cachedActivity = React.useRef<Partial<UserActivity>>({});\n\n const sortedMeta = React.useMemo(() => serializedMetaChildren(meta), [meta]);\n\n const url = React.useMemo(() => {\n const urlMeta = sortedMeta.find(\n (child) => child.type === 'meta' && child.props.property === 'og:url'\n );\n\n if (urlMeta) {\n // Support =`/foo/bar` -> `https://example.com/foo/bar`\n if (urlMeta.props.content?.startsWith('/')) {\n return getStaticUrlFromExpoRouter(urlMeta.props.content);\n }\n return urlMeta.props.content;\n }\n return href;\n }, [sortedMeta, href]);\n\n const title = React.useMemo(() => {\n const titleTag = sortedMeta.find((child) => child.type === 'title');\n if (titleTag) {\n return titleTag.props.children ?? '';\n }\n const titleMeta = sortedMeta.find(\n (child) => child.type === 'meta' && child.props.property === 'og:title'\n );\n if (titleMeta) {\n return titleMeta.props.content ?? '';\n }\n\n return getLastSegment(pathname);\n }, [sortedMeta, pathname]);\n\n const activity = React.useMemo(() => {\n if (\n !!previousMeta.current &&\n !!cachedActivity.current &&\n deepObjectCompare(previousMeta.current, sortedMeta)\n ) {\n return cachedActivity.current;\n }\n previousMeta.current = sortedMeta;\n\n const userActivity: Partial<UserActivity> = {};\n\n sortedMeta.forEach((child) => {\n if (\n // <meta />\n child.type === 'meta'\n ) {\n const { property, content } = child.props;\n\n switch (property) {\n case 'og:description':\n userActivity.description = content;\n break;\n // Custom properties\n case 'expo:handoff':\n userActivity.isEligibleForHandoff = isTruthy(content);\n break;\n case 'expo:spotlight':\n userActivity.isEligibleForSearch = isTruthy(content);\n break;\n }\n\n // // <meta name=\"keywords\" content=\"foo,bar,baz\" />\n // if ([\"keywords\"].includes(name)) {\n // userActivity.keywords = Array.isArray(content)\n // ? content\n // : content.split(\",\");\n // }\n }\n });\n\n cachedActivity.current = userActivity;\n return userActivity;\n }, [meta, pathname, href]);\n\n const parsedActivity: UserActivity = {\n keywords: [title],\n ...activity,\n title,\n webpageURL: url,\n activityType: ExpoHead!.activities.INDEXED_ROUTE,\n userInfo: {\n // TODO: This may need to be versioned in the future, e.g. `_v1` if we change the format.\n href,\n },\n };\n\n return parsedActivity;\n}\n\nfunction isTruthy(value: any): boolean {\n return [true, 'true'].includes(value);\n}\n\nfunction HeadNative(props: { children?: React.ReactNode }) {\n const isFocused = useIsFocused();\n if (!isFocused) {\n return <UnfocusedHead />;\n }\n return <FocusedHead {...props} />;\n}\n\nfunction UnfocusedHead(props: { children?: React.ReactNode }): JSX.Element {\n const { children } = useMetaChildren(props.children);\n return <>{children}</>;\n}\n\nfunction FocusedHead(props: { children?: React.ReactNode }): JSX.Element {\n const { metaChildren, children } = useMetaChildren(props.children);\n const activity = useActivityFromMetaChildren(metaChildren);\n useRegisterCurrentActivity(activity);\n return <>{children}</>;\n}\n\n// segments => activity\nconst activities: Map<string, UserActivity> = new Map();\n\nfunction useRegisterCurrentActivity(activity: UserActivity) {\n // ID is tied to Expo Router and agnostic of URLs to ensure dynamic parameters are not considered.\n // Using all segments ensures that cascading routes are considered.\n const activityId = urlToId(usePathname() || '/');\n const cascadingId = urlToId(useSegments().join('-') || '-');\n const activityIds = Array.from(activities.keys());\n const cascadingActivity: UserActivity = React.useMemo(() => {\n // Get all nested activities together, then update the id to match the current pathname.\n // This enables cases like `/user/[name]/post/[id]` to match all nesting, while still having a URL-specific ID, i.e. `/user/evanbacon/post/123`\n const cascadingActivity = activities.has(cascadingId)\n ? {\n ...activities.get(cascadingId),\n ...activity,\n id: activityId,\n }\n : {\n ...activity,\n id: activityId,\n };\n activities.set(cascadingId, cascadingActivity);\n\n return cascadingActivity;\n }, [cascadingId, activityId, activity, activityIds]);\n\n const previousActivity = React.useRef<UserActivity | null>(null);\n\n React.useEffect(() => {\n if (!cascadingActivity) {\n return () => {};\n }\n if (\n !!previousActivity.current &&\n deepObjectCompare(previousActivity.current, cascadingActivity)\n ) {\n return () => {};\n }\n\n previousActivity.current = cascadingActivity;\n if (!cascadingActivity.id) {\n throw new Error('Activity must have an ID');\n }\n\n // If no features are enabled, then skip registering the activity\n if (cascadingActivity.isEligibleForHandoff || cascadingActivity.isEligibleForSearch) {\n ExpoHead?.createActivity(cascadingActivity);\n }\n\n return () => {};\n }, [cascadingActivity]);\n\n React.useEffect(() => {\n return () => {\n if (activityId) {\n ExpoHead?.suspendActivity(activityId);\n }\n };\n }, [activityId]);\n}\n\nfunction deepObjectCompare(a: any, b: any) {\n if (typeof a !== typeof b) {\n return false;\n }\n if (typeof a === 'object') {\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false;\n }\n if (Array.isArray(a)) {\n if (a.length !== b.length) {\n return false;\n }\n return a.every((item, index) => deepObjectCompare(item, b[index]));\n }\n // handle null\n if (a === null || b === null) {\n return a === b;\n }\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n return aKeys.every((key) => deepObjectCompare(a[key], b[key]));\n }\n return a === b;\n}\n\nHeadNative.Provider = React.Fragment;\n\nfunction HeadShim(props: { children?: React.ReactNode }) {\n return null;\n}\n\nHeadShim.Provider = React.Fragment;\n\n// Native Head is only enabled in bare iOS apps.\nexport const Head: ((props: { children?: React.ReactNode }) => React.ReactNode) & {\n Provider: React.ComponentType;\n} = ExpoHead ? HeadNative : HeadShim;\n"]}
|
package/build/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAA4B,MAAM,0BAA0B,CAAC;AAC5F,OAAO,KAAK,MAAM,OAAO,CAAC;A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,MAAM,UAAU,eAAe;IAC7B,OAAO,qBAAqB,EAAW,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAGlC,OAAO,CAAC,qBAAqB,EAAE,EAAE,MAAM,IAAK,EAAU,CAAqB,CAAC;AAC9E,CAAC;AAED,SAAS,qBAAqB;IAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;IACvD,OAAO,KAAsB,CAAC;AAChC,CAAC","sourcesContent":["import { NavigationRouteContext, ParamListBase, RouteProp } from '@react-navigation/native';\nimport React from 'react';\n\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './types';\nimport { useDeprecated } from './useDeprecated';\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\n// Wraps useLinkTo to provide an API which is similar to the Link component.\nexport function useLink() {\n useDeprecated('`useLink()` is deprecated in favor of `useRouter()`');\n return useRouter();\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
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAA4B,MAAM,0BAA0B,CAAC;AAC5F,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,MAAM,UAAU,sBAAsB;IACpC,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AACrC,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,OAAO;IACrB,aAAa,CAAC,qDAAqD,CAAC,CAAC;IACrE,OAAO,SAAS,EAAE,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,KAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,MAAM;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,gCAAgC;KACjC,CAAC,EACF,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,iBAAiB,EAAE,CAAC,mBAAmB,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,iBAAiB,EAAE,CAAC,QAAqB,CAAC;AACnD,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,WAAW;IACzB,OAAO,iBAAiB,EAAE,CAAC,QAAQ,CAAC;AACtC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB;IAGnC,OAAO,iBAAiB,EAAE,CAAC,MAA0B,CAAC;AACxD,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,eAAe;IAC7B,OAAO,qBAAqB,EAAW,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAGlC,OAAO,CAAC,qBAAqB,EAAE,EAAE,MAAM,IAAK,EAAU,CAAqB,CAAC;AAC9E,CAAC;AAED,SAAS,qBAAqB;IAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;IACvD,OAAO,KAAsB,CAAC;AAChC,CAAC","sourcesContent":["import { NavigationRouteContext, ParamListBase, RouteProp } from '@react-navigation/native';\nimport React from 'react';\n\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './types';\nimport { useDeprecated } from './useDeprecated';\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\n// Wraps useLinkTo to provide an API which is similar to the Link component.\nexport function useLink() {\n useDeprecated('`useLink()` is deprecated in favor of `useRouter()`');\n return useRouter();\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/** @deprecated renamed to `useGlobalSearchParams` */\nexport function useSearchParams<TParams extends SearchParams = SearchParams>(): Partial<TParams> {\n return useGlobalSearchParams<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 return (useOptionalLocalRoute()?.params ?? ({} as any)) as Partial<TParams>;\n}\n\nfunction useOptionalLocalRoute<T extends RouteProp<ParamListBase>>(): T | undefined {\n const route = React.useContext(NavigationRouteContext);\n return route as T | undefined;\n}\n"]}
|