expo-router 3.5.20 → 3.5.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/fork/getStateFromPath.d.ts +4 -2
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +20 -4
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getLinkingConfig.d.ts +4 -3
- package/build/getLinkingConfig.d.ts.map +1 -1
- package/build/getLinkingConfig.js +3 -14
- package/build/getLinkingConfig.js.map +1 -1
- package/build/global-state/router-store.js +1 -1
- package/build/global-state/router-store.js.map +1 -1
- package/build/testing-library/index.d.ts.map +1 -1
- package/build/testing-library/index.js +0 -2
- package/build/testing-library/index.js.map +1 -1
- package/build/typed-routes/generate.d.ts.map +1 -1
- package/build/typed-routes/generate.js +7 -6
- package/build/typed-routes/generate.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PathConfigMap } from '@react-navigation/core';
|
|
2
2
|
import type { NavigationState, PartialState } from '@react-navigation/routers';
|
|
3
3
|
import { RouteNode } from '../Route';
|
|
4
|
+
import { RouterStore } from '../global-state/router-store';
|
|
4
5
|
type Options<ParamList extends object> = {
|
|
5
6
|
initialRouteName?: string;
|
|
6
7
|
screens: PathConfigMap<ParamList>;
|
|
@@ -43,8 +44,8 @@ export declare function getUrlWithReactNavigationConcessions(path: string, baseU
|
|
|
43
44
|
* @param path Path string to parse and convert, e.g. /foo/bar?count=42.
|
|
44
45
|
* @param options Extra options to fine-tune how to parse the path.
|
|
45
46
|
*/
|
|
46
|
-
export default function getStateFromPath<ParamList extends object>(path: string, options?: Options<ParamList>): ResultState | undefined;
|
|
47
|
-
export declare function getMatchableRouteConfigs<ParamList extends object>(options?: Options<ParamList
|
|
47
|
+
export default function getStateFromPath<ParamList extends object>(this: RouterStore | undefined, path: string, options?: Options<ParamList>): ResultState | undefined;
|
|
48
|
+
export declare function getMatchableRouteConfigs<ParamList extends object>(options?: Options<ParamList>, previousSegments?: string[]): {
|
|
48
49
|
configs: {
|
|
49
50
|
isInitial: boolean;
|
|
50
51
|
screen: string;
|
|
@@ -52,6 +53,7 @@ export declare function getMatchableRouteConfigs<ParamList extends object>(optio
|
|
|
52
53
|
path: string;
|
|
53
54
|
pattern: string;
|
|
54
55
|
routeNames: string[];
|
|
56
|
+
expandedRouteNames: string[];
|
|
55
57
|
parse?: ParseConfig | undefined;
|
|
56
58
|
hasChildren: boolean;
|
|
57
59
|
userReadableName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStateFromPath.d.ts","sourceRoot":"","sources":["../../src/fork/getStateFromPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAgB,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAK7F,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"getStateFromPath.d.ts","sourceRoot":"","sources":["../../src/fork/getStateFromPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAgB,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAK7F,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,KAAK,OAAO,CAAC,SAAS,SAAS,MAAM,IAAI;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACnC,CAAC;AAEF,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC,CAAC;AAgB1D,KAAK,kBAAkB,GAAG;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,eAAe,CAAC,GAAG;IACxD,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC;AAQF,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAM,GAAG,SAAqC;;;;;;;;EAuBxD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,SAAS,SAAS,MAAM,EAC/D,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAC3B,WAAW,GAAG,SAAS,CAIzB;AAED,wBAAgB,wBAAwB,CAAC,SAAS,SAAS,MAAM,EAC/D,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAC5B,gBAAgB,GAAE,MAAM,EAAO;;;;;;;;;;;;;;;EA6ChC;AA2rBD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAM,GAAG,SAAqC,UASxD"}
|
|
@@ -52,11 +52,11 @@ exports.getUrlWithReactNavigationConcessions = getUrlWithReactNavigationConcessi
|
|
|
52
52
|
* @param options Extra options to fine-tune how to parse the path.
|
|
53
53
|
*/
|
|
54
54
|
function getStateFromPath(path, options) {
|
|
55
|
-
const { initialRoutes, configs } = getMatchableRouteConfigs(options);
|
|
55
|
+
const { initialRoutes, configs } = getMatchableRouteConfigs(options, this?.routeInfo?.segments);
|
|
56
56
|
return getStateFromPathWithConfigs(path, configs, initialRoutes);
|
|
57
57
|
}
|
|
58
58
|
exports.default = getStateFromPath;
|
|
59
|
-
function getMatchableRouteConfigs(options) {
|
|
59
|
+
function getMatchableRouteConfigs(options, previousSegments = []) {
|
|
60
60
|
if (options) {
|
|
61
61
|
(0, validatePathConfig_1.default)(options);
|
|
62
62
|
}
|
|
@@ -85,7 +85,7 @@ function getMatchableRouteConfigs(options) {
|
|
|
85
85
|
isInitial: resolvedInitialPatterns.includes(config.routeNames.join('/')),
|
|
86
86
|
}));
|
|
87
87
|
// Sort in order of resolution. This is extremely important for the algorithm to work.
|
|
88
|
-
const configs = convertedWithInitial.sort(sortConfigs);
|
|
88
|
+
const configs = convertedWithInitial.sort((a, b) => sortConfigs(a, b, previousSegments));
|
|
89
89
|
// Assert any duplicates before we start parsing.
|
|
90
90
|
assertConfigDuplicates(configs);
|
|
91
91
|
return { configs, initialRoutes };
|
|
@@ -123,7 +123,7 @@ function assertConfigDuplicates(configs) {
|
|
|
123
123
|
});
|
|
124
124
|
}, {});
|
|
125
125
|
}
|
|
126
|
-
function sortConfigs(a, b) {
|
|
126
|
+
function sortConfigs(a, b, previousSegments = []) {
|
|
127
127
|
// Sort config so that:
|
|
128
128
|
// - the most exhaustive ones are always at the beginning
|
|
129
129
|
// - patterns with wildcard are always at the end
|
|
@@ -156,6 +156,19 @@ function sortConfigs(a, b) {
|
|
|
156
156
|
if (b.screen === 'index' || b.screen.match(/\/index$/)) {
|
|
157
157
|
bParts.push('index');
|
|
158
158
|
}
|
|
159
|
+
// When we navigate, we need to stay within groups as close as possible
|
|
160
|
+
// Hence, a route is sorted based upon is similiarity to the current state
|
|
161
|
+
const similarToPreviousA = previousSegments.filter((value, index) => {
|
|
162
|
+
return value === a.expandedRouteNames[index] && value.startsWith('(') && value.endsWith(')');
|
|
163
|
+
});
|
|
164
|
+
const similarToPreviousB = previousSegments.filter((value, index) => {
|
|
165
|
+
return value === b.expandedRouteNames[index] && value.startsWith('(') && value.endsWith(')');
|
|
166
|
+
});
|
|
167
|
+
if ((similarToPreviousA.length > 0 || similarToPreviousB.length > 0) &&
|
|
168
|
+
similarToPreviousA.length !== similarToPreviousB.length) {
|
|
169
|
+
// They both match to some degree, so pick the one that matches more
|
|
170
|
+
return similarToPreviousB.length - similarToPreviousA.length;
|
|
171
|
+
}
|
|
159
172
|
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
|
160
173
|
// if b is longer, b get higher priority
|
|
161
174
|
if (aParts[i] == null) {
|
|
@@ -453,6 +466,9 @@ const createConfigItem = (screen, routeNames, pattern, path, hasChildren, parse,
|
|
|
453
466
|
path,
|
|
454
467
|
// The routeNames array is mutated, so copy it to keep the current state
|
|
455
468
|
routeNames: [...routeNames],
|
|
469
|
+
expandedRouteNames: screen.includes('/')
|
|
470
|
+
? [...routeNames.slice(0, -1), ...screen.split('/')]
|
|
471
|
+
: [...routeNames],
|
|
456
472
|
parse,
|
|
457
473
|
userReadableName: [...routeNames.slice(0, -1), path || screen].join('/'),
|
|
458
474
|
hasChildren: !!hasChildren,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStateFromPath.js","sourceRoot":"","sources":["../../src/fork/getStateFromPath.ts"],"names":[],"mappings":";;;;;;AAEA,gFAA0C;AAE1C,yDAAsD;AACtD,8EAAsD;AAEtD,0CAAyE;AAqCzE,SAAgB,oCAAoC,CAClD,IAAY,EACZ,UAA8B,OAAO,CAAC,GAAG,CAAC,aAAa;IAEvD,IAAI,MAAW,CAAC;IAChB,IAAI;QACF,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;KACjD;IAAC,MAAM;QACN,gCAAgC;QAChC,OAAO;YACL,mBAAmB,EAAE,EAAE;YACvB,wBAAwB,EAAE,EAAE;YAC5B,GAAG,EAAE,IAAI;SACV,CAAC;KACH;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAEjC,sCAAsC;IACtC,OAAO;QACL,gDAAgD;QAChD,mBAAmB,EACjB,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,GAAG;QACjF,GAAG,EAAE,MAAM;KACZ,CAA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Content":["import { PathConfigMap } from '@react-navigation/core';\nimport type { InitialState, NavigationState, PartialState } from '@react-navigation/routers';\nimport escape from 'escape-string-regexp';\n\nimport { findFocusedRoute } from './findFocusedRoute';\nimport validatePathConfig from './validatePathConfig';\nimport { RouteNode } from '../Route';\nimport { matchGroupName, stripGroupSegmentsFromPath } from '../matchers';\n\ntype Options<ParamList extends object> = {\n initialRouteName?: string;\n screens: PathConfigMap<ParamList>;\n};\n\ntype ParseConfig = Record<string, (value: string) => any>;\n\ntype RouteConfig = {\n isInitial?: boolean;\n screen: string;\n regex?: RegExp;\n path: string;\n pattern: string;\n routeNames: string[];\n parse?: ParseConfig;\n hasChildren: boolean;\n userReadableName: string;\n _route?: RouteNode;\n};\n\ntype InitialRouteConfig = {\n initialRouteName: string;\n parentScreens: string[];\n};\n\nexport type ResultState = PartialState<NavigationState> & {\n state?: ResultState;\n};\n\ntype ParsedRoute = {\n name: string;\n path?: string;\n params?: Record<string, any>;\n};\n\nexport function getUrlWithReactNavigationConcessions(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n) {\n let parsed: URL;\n try {\n parsed = new URL(path, 'https://phony.example');\n } catch {\n // Do nothing with invalid URLs.\n return {\n nonstandardPathname: '',\n inputPathnameWithoutHash: '',\n url: null,\n };\n }\n\n const pathname = parsed.pathname;\n\n // Make sure there is a trailing slash\n return {\n // The slashes are at the end, not the beginning\n nonstandardPathname:\n stripBaseUrl(pathname, baseUrl).replace(/^\\/+/g, '').replace(/\\/+$/g, '') + '/',\n url: parsed,\n };\n}\n\n/**\n * Utility to parse a path string to initial state object accepted by the container.\n * This is useful for deep linking when we need to handle the incoming URL.\n *\n * @example\n * ```js\n * getStateFromPath(\n * '/chat/jane/42',\n * {\n * screens: {\n * Chat: {\n * path: 'chat/:author/:id',\n * parse: { id: Number }\n * }\n * }\n * }\n * )\n * ```\n * @param path Path string to parse and convert, e.g. /foo/bar?count=42.\n * @param options Extra options to fine-tune how to parse the path.\n */\nexport default function getStateFromPath<ParamList extends object>(\n path: string,\n options?: Options<ParamList>\n): ResultState | undefined {\n const { initialRoutes, configs } = getMatchableRouteConfigs(options);\n\n return getStateFromPathWithConfigs(path, configs, initialRoutes);\n}\n\nexport function getMatchableRouteConfigs<ParamList extends object>(options?: Options<ParamList>) {\n if (options) {\n validatePathConfig(options);\n }\n\n const screens = options?.screens;\n // Expo Router disallows usage without a linking config.\n if (!screens) {\n throw Error(\"You must pass a 'screens' object to 'getStateFromPath' to generate a path.\");\n }\n\n // This will be mutated...\n const initialRoutes: InitialRouteConfig[] = [];\n\n if (options?.initialRouteName) {\n initialRoutes.push({\n initialRouteName: options.initialRouteName,\n parentScreens: [],\n });\n }\n\n // Create a normalized configs array which will be easier to use.\n const converted = Object.keys(screens)\n .map((key) => createNormalizedConfigs(key, screens, [], initialRoutes))\n .flat();\n\n const resolvedInitialPatterns = initialRoutes.map((route) =>\n joinPaths(...route.parentScreens, route.initialRouteName)\n );\n\n const convertedWithInitial = converted.map((config) => ({\n ...config,\n // TODO(EvanBacon): Probably a safer way to do this\n // Mark initial routes to give them potential priority over other routes that match.\n isInitial: resolvedInitialPatterns.includes(config.routeNames.join('/')),\n }));\n\n // Sort in order of resolution. This is extremely important for the algorithm to work.\n const configs = convertedWithInitial.sort(sortConfigs);\n\n // Assert any duplicates before we start parsing.\n assertConfigDuplicates(configs);\n\n return { configs, initialRoutes };\n}\n\nfunction assertConfigDuplicates(configs: RouteConfig[]) {\n // Check for duplicate patterns in the config\n configs.reduce<Record<string, RouteConfig>>((acc, config) => {\n // NOTE(EvanBacon): Uses the regex pattern as key to detect duplicate slugs.\n const indexedKey = config.regex?.toString() ?? config.pattern;\n const alpha = acc[indexedKey];\n // NOTE(EvanBacon): Skips checking nodes that have children.\n if (alpha && !alpha.hasChildren && !config.hasChildren) {\n const a = alpha.routeNames;\n const b = config.routeNames;\n\n // It's not a problem if the path string omitted from a inner most screen\n // For example, it's ok if a path resolves to `A > B > C` or `A > B`\n const intersects =\n a.length > b.length ? b.every((it, i) => a[i] === it) : a.every((it, i) => b[i] === it);\n\n if (!intersects) {\n // NOTE(EvanBacon): Adds more context to the error message since we know about the\n // file-based routing.\n const last = config.pattern.split('/').pop();\n\n if (!last?.match(/^\\*not-found$/)) {\n const routeType = last?.startsWith(':')\n ? 'dynamic route'\n : last?.startsWith('*')\n ? 'dynamic-rest route'\n : 'route';\n throw new Error(\n `The ${routeType} pattern '${config.pattern || '/'}' resolves to both '${\n alpha.userReadableName\n }' and '${\n config.userReadableName\n }'. Patterns must be unique and cannot resolve to more than one route.`\n );\n }\n }\n }\n\n return Object.assign(acc, {\n [indexedKey]: config,\n });\n }, {});\n}\n\nfunction sortConfigs(a: RouteConfig, b: RouteConfig): number {\n // Sort config so that:\n // - the most exhaustive ones are always at the beginning\n // - patterns with wildcard are always at the end\n\n // If 2 patterns are same, move the one with less route names up\n // This is an error state, so it's only useful for consistent error messages\n if (a.pattern === b.pattern) {\n return b.routeNames.join('>').localeCompare(a.routeNames.join('>'));\n }\n\n // If one of the patterns starts with the other, it's more exhaustive\n // So move it up\n if (\n a.pattern.startsWith(b.pattern) &&\n // NOTE(EvanBacon): This is a hack to make sure that `*` is always at the end\n b.screen !== 'index'\n ) {\n return -1;\n }\n\n if (b.pattern.startsWith(a.pattern) && a.screen !== 'index') {\n return 1;\n }\n\n // NOTE(EvanBacon): Here we append `index` if the screen was `index` so the length is the same\n // as a slug or wildcard when nested more than one level deep.\n // This is so we can compare the length of the pattern, e.g. `foo/*` > `foo` vs `*` < ``.\n const aParts = a.pattern\n .split('/')\n // Strip out group names to ensure they don't affect the priority.\n .filter((part) => matchGroupName(part) == null);\n if (a.screen === 'index' || a.screen.match(/\\/index$/)) {\n aParts.push('index');\n }\n\n const bParts = b.pattern.split('/').filter((part) => matchGroupName(part) == null);\n if (b.screen === 'index' || b.screen.match(/\\/index$/)) {\n bParts.push('index');\n }\n\n for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {\n // if b is longer, b get higher priority\n if (aParts[i] == null) {\n return 1;\n }\n // if a is longer, a get higher priority\n if (bParts[i] == null) {\n return -1;\n }\n\n const aWildCard = aParts[i].startsWith('*');\n const bWildCard = bParts[i].startsWith('*');\n // if both are wildcard we compare next component\n if (aWildCard && bWildCard) {\n const aNotFound = aParts[i].match(/^[*]not-found$/);\n const bNotFound = bParts[i].match(/^[*]not-found$/);\n\n if (aNotFound && bNotFound) {\n continue;\n } else if (aNotFound) {\n return 1;\n } else if (bNotFound) {\n return -1;\n }\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aWildCard) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bWildCard) {\n return -1;\n }\n\n const aSlug = aParts[i].startsWith(':');\n const bSlug = bParts[i].startsWith(':');\n // if both are wildcard we compare next component\n if (aSlug && bSlug) {\n const aNotFound = aParts[i].match(/^[*]not-found$/);\n const bNotFound = bParts[i].match(/^[*]not-found$/);\n\n if (aNotFound && bNotFound) {\n continue;\n } else if (aNotFound) {\n return 1;\n } else if (bNotFound) {\n return -1;\n }\n\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aSlug) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bSlug) {\n return -1;\n }\n }\n\n // Sort initial routes with a higher priority than routes which will push more screens\n // this ensures shared routes go to the shortest path.\n if (a.isInitial && !b.isInitial) {\n return -1;\n }\n if (!a.isInitial && b.isInitial) {\n return 1;\n }\n\n return bParts.length - aParts.length;\n}\n\nfunction getStateFromEmptyPathWithConfigs(\n path: string,\n hash: string,\n configs: RouteConfig[],\n initialRoutes: InitialRouteConfig[]\n): ResultState | undefined {\n // We need to add special handling of empty path so navigation to empty path also works\n // When handling empty path, we should only look at the root level config\n\n // NOTE(EvanBacon): We only care about matching leaf nodes.\n const leafNodes = configs\n .filter((config) => !config.hasChildren)\n .map((value) => {\n return {\n ...value,\n // Collapse all levels of group segments before testing.\n // This enables `app/(one)/(two)/index.js` to be matched.\n path: stripGroupSegmentsFromPath(value.path),\n };\n });\n\n const match =\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node index routes that either don't have a regex or match an empty string.\n config.path === '' && (!config.regex || config.regex.test(''))\n ) ??\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node dynamic routes that match an empty string.\n config.path.startsWith(':') && config.regex!.test('')\n ) ??\n // NOTE(EvanBacon): Test leaf node deep dynamic routes that match a slash.\n // This should be done last to enable dynamic routes having a higher priority.\n leafNodes.find((config) => config.path.startsWith('*') && config.regex!.test('/'));\n\n if (!match) {\n return undefined;\n }\n\n const routes = match.routeNames.map((name) => {\n if (!match._route) {\n return { name };\n }\n return {\n name,\n _route: match._route,\n };\n });\n\n return createNestedStateObject(path, hash, routes, configs, initialRoutes);\n}\n\nfunction getStateFromPathWithConfigs(\n path: string,\n configs: RouteConfig[],\n initialRoutes: InitialRouteConfig[],\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n): ResultState | undefined {\n const formattedPaths = getUrlWithReactNavigationConcessions(path);\n\n if (!formattedPaths.url) return;\n\n let cleanPath =\n stripBaseUrl(stripGroupSegmentsFromPath(formattedPaths.url.pathname), baseUrl) +\n formattedPaths.url.search;\n\n if (!path.startsWith('/')) cleanPath = cleanPath.slice(1);\n\n if (formattedPaths.nonstandardPathname === '/') {\n return getStateFromEmptyPathWithConfigs(\n cleanPath,\n formattedPaths.url.hash.slice(1),\n configs,\n initialRoutes\n );\n }\n\n // We match the whole path against the regex instead of segments\n // This makes sure matches such as wildcard will catch any unmatched routes, even if nested\n const routes = matchAgainstConfigs(formattedPaths.nonstandardPathname, configs);\n\n if (routes == null) {\n return undefined;\n }\n // This will always be empty if full path matched\n return createNestedStateObject(\n cleanPath,\n formattedPaths.url.hash.slice(1),\n routes,\n configs,\n initialRoutes\n );\n}\n\nconst joinPaths = (...paths: string[]): string =>\n ([] as string[])\n .concat(...paths.map((p) => p.split('/')))\n .filter(Boolean)\n .join('/');\n\nfunction matchAgainstConfigs(remaining: string, configs: RouteConfig[]): ParsedRoute[] | undefined {\n let routes: ParsedRoute[] | undefined;\n let remainingPath = remaining;\n\n // Go through all configs, and see if the next path segment matches our regex\n for (const config of configs) {\n if (!config.regex) {\n continue;\n }\n\n const match = remainingPath.match(config.regex);\n\n // If our regex matches, we need to extract params from the path\n if (!match) {\n continue;\n }\n\n // TODO: Add support for wildcard routes\n const matchedParams = config.pattern\n ?.split('/')\n .filter((p) => p.match(/^[:*]/))\n .reduce<Record<string, any>>((acc, p, i) => {\n if (p.match(/^\\*/)) {\n return {\n ...acc,\n [p]: match![(i + 1) * 2], //?.replace(/\\//, \"\"),\n };\n }\n return Object.assign(acc, {\n // The param segments appear every second item starting from 2 in the regex match result.\n // This will only work if we ensure groups aren't included in the match.\n [p]: match![(i + 1) * 2]?.replace(/\\//, ''),\n });\n }, {});\n\n const routeFromName = (name: string) => {\n const config = configs.find((c) => c.screen === name);\n if (!config?.path) {\n return { name };\n }\n\n const segments = config.path.split('/');\n\n const params: Record<string, any> = {};\n\n segments\n .filter((p) => p.match(/^[:*]/))\n .forEach((p) => {\n let value = matchedParams[p];\n if (value) {\n if (p.match(/^\\*/)) {\n // Convert to an array before providing as a route.\n value = value?.split('/').filter(Boolean);\n }\n\n const key = p.replace(/^[:*]/, '').replace(/\\?$/, '');\n params[key] = config.parse?.[key] ? config.parse[key](value) : value;\n }\n });\n\n if (params && Object.keys(params).length) {\n return { name, params };\n }\n\n return { name };\n };\n\n routes = config.routeNames.map((name) => {\n if (!config._route) {\n return { ...routeFromName(name) };\n }\n return {\n ...routeFromName(name),\n _route: config._route,\n };\n });\n\n // TODO(EvanBacon): Maybe we should warn / assert if multiple slugs use the same param name.\n const combinedParams = routes.reduce<Record<string, any>>(\n (acc, r) => Object.assign(acc, r.params),\n {}\n );\n\n const hasCombinedParams = Object.keys(combinedParams).length > 0;\n\n // Combine all params so a route `[foo]/[bar]/other.js` has access to `{ foo, bar }`\n routes = routes.map((r) => {\n if (hasCombinedParams) {\n r.params = combinedParams;\n }\n return r;\n });\n\n remainingPath = remainingPath.replace(match[1], '');\n\n break;\n }\n\n return routes;\n}\n\nfunction equalHeritage(a: string[], b: string[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i].localeCompare(b[i]) !== 0) {\n return false;\n }\n }\n return true;\n}\n\nconst createNormalizedConfigs = (\n screen: string,\n routeConfig: PathConfigMap<object>,\n routeNames: string[] = [],\n initials: InitialRouteConfig[] = [],\n parentScreens: string[] = [],\n parentPattern?: string\n): RouteConfig[] => {\n const configs: RouteConfig[] = [];\n\n routeNames.push(screen);\n\n parentScreens.push(screen);\n\n const config = (routeConfig as any)[screen];\n\n if (typeof config === 'string') {\n // TODO: This should never happen with the addition of `_route`\n\n // If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern\n const pattern = parentPattern ? joinPaths(parentPattern, config) : config;\n\n configs.push(createConfigItem(screen, routeNames, pattern, config, false));\n } else if (typeof config === 'object') {\n let pattern: string | undefined;\n\n const { _route } = config;\n // if an object is specified as the value (e.g. Foo: { ... }),\n // it can have `path` property and\n // it could have `screens` prop which has nested configs\n if (typeof config.path === 'string') {\n if (config.exact && config.path === undefined) {\n throw new Error(\n \"A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.\"\n );\n }\n\n pattern =\n config.exact !== true\n ? joinPaths(parentPattern || '', config.path || '')\n : config.path || '';\n\n configs.push(\n createConfigItem(\n screen,\n routeNames,\n pattern!,\n config.path,\n config.screens ? !!Object.keys(config.screens)?.length : false,\n config.parse,\n _route\n )\n );\n }\n\n if (config.screens) {\n // property `initialRouteName` without `screens` has no purpose\n if (config.initialRouteName) {\n initials.push({\n initialRouteName: config.initialRouteName,\n parentScreens,\n });\n }\n\n Object.keys(config.screens).forEach((nestedConfig) => {\n const result = createNormalizedConfigs(\n nestedConfig,\n config.screens as PathConfigMap<object>,\n routeNames,\n initials,\n [...parentScreens],\n pattern ?? parentPattern\n );\n\n configs.push(...result);\n });\n }\n }\n\n routeNames.pop();\n\n return configs;\n};\n\nfunction formatRegexPattern(it: string): string {\n // Allow spaces in file path names.\n it = it.replace(' ', '%20');\n\n if (it.startsWith(':')) {\n // TODO: Remove unused match group\n return `(([^/]+\\\\/)${it.endsWith('?') ? '?' : ''})`;\n } else if (it.startsWith('*')) {\n return `((.*\\\\/)${it.endsWith('?') ? '?' : ''})`;\n }\n\n // Strip groups from the matcher\n if (matchGroupName(it) != null) {\n // Groups are optional segments\n // this enables us to match `/bar` and `/(foo)/bar` for the same route\n // NOTE(EvanBacon): Ignore this match in the regex to avoid capturing the group\n return `(?:${escape(it)}\\\\/)?`;\n }\n\n return escape(it) + `\\\\/`;\n}\n\nconst createConfigItem = (\n screen: string,\n routeNames: string[],\n pattern: string,\n path: string,\n hasChildren?: boolean,\n parse?: ParseConfig,\n _route?: any\n): RouteConfig => {\n // Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.\n pattern = pattern.split('/').filter(Boolean).join('/');\n\n const regex = pattern\n ? new RegExp(`^(${pattern.split('/').map(formatRegexPattern).join('')})$`)\n : undefined;\n\n return {\n screen,\n regex,\n pattern,\n path,\n // The routeNames array is mutated, so copy it to keep the current state\n routeNames: [...routeNames],\n parse,\n userReadableName: [...routeNames.slice(0, -1), path || screen].join('/'),\n hasChildren: !!hasChildren,\n _route,\n };\n};\n\nconst findParseConfigForRoute = (\n routeName: string,\n routeConfigs: RouteConfig[]\n): ParseConfig | undefined => {\n for (const config of routeConfigs) {\n if (routeName === config.routeNames[config.routeNames.length - 1]) {\n return config.parse;\n }\n }\n\n return undefined;\n};\n\n// Try to find an initial route connected with the one passed\nconst findInitialRoute = (\n routeName: string,\n parentScreens: string[],\n initialRoutes: InitialRouteConfig[]\n): string | undefined => {\n for (const config of initialRoutes) {\n if (equalHeritage(parentScreens, config.parentScreens)) {\n // If the parents are the same but the route name doesn't match the initial route\n // then we return the initial route.\n return routeName !== config.initialRouteName ? config.initialRouteName : undefined;\n }\n }\n return undefined;\n};\n\n// returns state object with values depending on whether\n// it is the end of state and if there is initialRoute for this level\nconst createStateObject = (\n route: ParsedRoute,\n isEmpty: boolean,\n initialRoute?: string\n): InitialState => {\n if (isEmpty) {\n if (initialRoute) {\n return {\n index: 1,\n routes: [{ name: initialRoute, params: route.params }, route],\n };\n }\n return {\n routes: [route],\n };\n }\n\n if (initialRoute) {\n return {\n index: 1,\n routes: [\n { name: initialRoute, params: route.params },\n { ...route, state: { routes: [] } },\n ],\n };\n }\n return {\n routes: [{ ...route, state: { routes: [] } }],\n };\n};\n\nconst createNestedStateObject = (\n path: string,\n hash: string | undefined,\n routes: ParsedRoute[],\n routeConfigs: RouteConfig[],\n initialRoutes: InitialRouteConfig[]\n) => {\n let route = routes.shift() as ParsedRoute;\n const parentScreens: string[] = [];\n\n let initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);\n\n parentScreens.push(route.name);\n\n const state: InitialState = createStateObject(route, routes.length === 0, initialRoute);\n\n if (routes.length > 0) {\n let nestedState = state;\n\n while ((route = routes.shift() as ParsedRoute)) {\n initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);\n\n const nestedStateIndex = nestedState.index || nestedState.routes.length - 1;\n\n nestedState.routes[nestedStateIndex].state = createStateObject(\n route,\n routes.length === 0,\n initialRoute\n );\n\n if (routes.length > 0) {\n nestedState = nestedState.routes[nestedStateIndex].state as InitialState;\n }\n\n parentScreens.push(route.name);\n }\n }\n\n route = findFocusedRoute(state) as ParsedRoute;\n\n // Remove groups from the path while preserving a trailing slash.\n route.path = path;\n\n const params = parseQueryParams(route.path, findParseConfigForRoute(route.name, routeConfigs));\n\n if (params) {\n route.params = Object.assign(Object.create(null), route.params) as Record<string, any>;\n for (const [name, value] of Object.entries(params)) {\n if (route.params?.[name]) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Route '/${route.name}' with param '${name}' was specified both in the path and as a param, removing from path`\n );\n }\n }\n\n if (!route.params?.[name]) {\n route.params[name] = value;\n continue;\n }\n }\n\n if (Object.keys(route.params).length === 0) {\n delete route.params;\n }\n }\n\n if (hash) {\n route.params = Object.assign(Object.create(null), route.params) as Record<string, any>;\n route.params['#'] = hash;\n }\n\n return state;\n};\n\nconst parseQueryParams = (path: string, parseConfig?: Record<string, (value: string) => any>) => {\n const query = path.split('?')[1];\n const searchParams = new URLSearchParams(query);\n const params = Object.fromEntries(\n // @ts-ignore: [Symbol.iterator] is indeed, available on every platform.\n searchParams\n );\n\n if (parseConfig) {\n Object.keys(params).forEach((name) => {\n if (Object.hasOwnProperty.call(parseConfig, name) && typeof params[name] === 'string') {\n params[name] = parseConfig[name](params[name] as string);\n }\n });\n }\n\n return Object.keys(params).length ? params : undefined;\n};\n\nconst baseUrlCache = new Map<string, RegExp>();\n\nfunction getBaseUrlRegex(baseUrl: string) {\n if (baseUrlCache.has(baseUrl)) {\n return baseUrlCache.get(baseUrl)!;\n }\n const regex = new RegExp(`^\\\\/?${escape(baseUrl)}`, 'g');\n baseUrlCache.set(baseUrl, regex);\n return regex;\n}\n\nexport function stripBaseUrl(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n) {\n if (process.env.NODE_ENV !== 'development') {\n if (baseUrl) {\n const reg = getBaseUrlRegex(baseUrl);\n return path.replace(/^\\/+/g, '/').replace(reg, '');\n }\n }\n return path;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getStateFromPath.js","sourceRoot":"","sources":["../../src/fork/getStateFromPath.ts"],"names":[],"mappings":";;;;;;AAEA,gFAA0C;AAE1C,yDAAsD;AACtD,8EAAsD;AAGtD,0CAAyE;AAsCzE,SAAgB,oCAAoC,CAClD,IAAY,EACZ,UAA8B,OAAO,CAAC,GAAG,CAAC,aAAa;IAEvD,IAAI,MAAW,CAAC;IAChB,IAAI;QACF,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;KACjD;IAAC,MAAM;QACN,gCAAgC;QAChC,OAAO;YACL,mBAAmB,EAAE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AAG,CAAC,aAAa;IAEvD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QAC1C,IAAI,OAAO,EAAE;YACX,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;YACrC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;SACpD;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAXD,oCAWC","sourcesContent":["import { PathConfigMap } from '@react-navigation/core';\nimport type { InitialState, NavigationState, PartialState } from '@react-navigation/routers';\nimport escape from 'escape-string-regexp';\n\nimport { findFocusedRoute } from './findFocusedRoute';\nimport validatePathConfig from './validatePathConfig';\nimport { RouteNode } from '../Route';\nimport { RouterStore } from '../global-state/router-store';\nimport { matchGroupName, stripGroupSegmentsFromPath } from '../matchers';\n\ntype Options<ParamList extends object> = {\n initialRouteName?: string;\n screens: PathConfigMap<ParamList>;\n};\n\ntype ParseConfig = Record<string, (value: string) => any>;\n\ntype RouteConfig = {\n isInitial?: boolean;\n screen: string;\n regex?: RegExp;\n path: string;\n pattern: string;\n routeNames: string[];\n expandedRouteNames: string[];\n parse?: ParseConfig;\n hasChildren: boolean;\n userReadableName: string;\n _route?: RouteNode;\n};\n\ntype InitialRouteConfig = {\n initialRouteName: string;\n parentScreens: string[];\n};\n\nexport type ResultState = PartialState<NavigationState> & {\n state?: ResultState;\n};\n\ntype ParsedRoute = {\n name: string;\n path?: string;\n params?: Record<string, any>;\n};\n\nexport function getUrlWithReactNavigationConcessions(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n) {\n let parsed: URL;\n try {\n parsed = new URL(path, 'https://phony.example');\n } catch {\n // Do nothing with invalid URLs.\n return {\n nonstandardPathname: '',\n inputPathnameWithoutHash: '',\n url: null,\n };\n }\n\n const pathname = parsed.pathname;\n\n // Make sure there is a trailing slash\n return {\n // The slashes are at the end, not the beginning\n nonstandardPathname:\n stripBaseUrl(pathname, baseUrl).replace(/^\\/+/g, '').replace(/\\/+$/g, '') + '/',\n url: parsed,\n };\n}\n\n/**\n * Utility to parse a path string to initial state object accepted by the container.\n * This is useful for deep linking when we need to handle the incoming URL.\n *\n * @example\n * ```js\n * getStateFromPath(\n * '/chat/jane/42',\n * {\n * screens: {\n * Chat: {\n * path: 'chat/:author/:id',\n * parse: { id: Number }\n * }\n * }\n * }\n * )\n * ```\n * @param path Path string to parse and convert, e.g. /foo/bar?count=42.\n * @param options Extra options to fine-tune how to parse the path.\n */\nexport default function getStateFromPath<ParamList extends object>(\n this: RouterStore | undefined,\n path: string,\n options?: Options<ParamList>\n): ResultState | undefined {\n const { initialRoutes, configs } = getMatchableRouteConfigs(options, this?.routeInfo?.segments);\n\n return getStateFromPathWithConfigs(path, configs, initialRoutes);\n}\n\nexport function getMatchableRouteConfigs<ParamList extends object>(\n options?: Options<ParamList>,\n previousSegments: string[] = []\n) {\n if (options) {\n validatePathConfig(options);\n }\n\n const screens = options?.screens;\n // Expo Router disallows usage without a linking config.\n if (!screens) {\n throw Error(\"You must pass a 'screens' object to 'getStateFromPath' to generate a path.\");\n }\n\n // This will be mutated...\n const initialRoutes: InitialRouteConfig[] = [];\n\n if (options?.initialRouteName) {\n initialRoutes.push({\n initialRouteName: options.initialRouteName,\n parentScreens: [],\n });\n }\n\n // Create a normalized configs array which will be easier to use.\n const converted = Object.keys(screens)\n .map((key) => createNormalizedConfigs(key, screens, [], initialRoutes))\n .flat();\n\n const resolvedInitialPatterns = initialRoutes.map((route) =>\n joinPaths(...route.parentScreens, route.initialRouteName)\n );\n\n const convertedWithInitial = converted.map((config) => ({\n ...config,\n // TODO(EvanBacon): Probably a safer way to do this\n // Mark initial routes to give them potential priority over other routes that match.\n isInitial: resolvedInitialPatterns.includes(config.routeNames.join('/')),\n }));\n\n // Sort in order of resolution. This is extremely important for the algorithm to work.\n const configs = convertedWithInitial.sort((a, b) => sortConfigs(a, b, previousSegments));\n\n // Assert any duplicates before we start parsing.\n assertConfigDuplicates(configs);\n\n return { configs, initialRoutes };\n}\n\nfunction assertConfigDuplicates(configs: RouteConfig[]) {\n // Check for duplicate patterns in the config\n configs.reduce<Record<string, RouteConfig>>((acc, config) => {\n // NOTE(EvanBacon): Uses the regex pattern as key to detect duplicate slugs.\n const indexedKey = config.regex?.toString() ?? config.pattern;\n const alpha = acc[indexedKey];\n // NOTE(EvanBacon): Skips checking nodes that have children.\n if (alpha && !alpha.hasChildren && !config.hasChildren) {\n const a = alpha.routeNames;\n const b = config.routeNames;\n\n // It's not a problem if the path string omitted from a inner most screen\n // For example, it's ok if a path resolves to `A > B > C` or `A > B`\n const intersects =\n a.length > b.length ? b.every((it, i) => a[i] === it) : a.every((it, i) => b[i] === it);\n\n if (!intersects) {\n // NOTE(EvanBacon): Adds more context to the error message since we know about the\n // file-based routing.\n const last = config.pattern.split('/').pop();\n\n if (!last?.match(/^\\*not-found$/)) {\n const routeType = last?.startsWith(':')\n ? 'dynamic route'\n : last?.startsWith('*')\n ? 'dynamic-rest route'\n : 'route';\n throw new Error(\n `The ${routeType} pattern '${config.pattern || '/'}' resolves to both '${\n alpha.userReadableName\n }' and '${\n config.userReadableName\n }'. Patterns must be unique and cannot resolve to more than one route.`\n );\n }\n }\n }\n\n return Object.assign(acc, {\n [indexedKey]: config,\n });\n }, {});\n}\n\nfunction sortConfigs(a: RouteConfig, b: RouteConfig, previousSegments: string[] = []): number {\n // Sort config so that:\n // - the most exhaustive ones are always at the beginning\n // - patterns with wildcard are always at the end\n\n // If 2 patterns are same, move the one with less route names up\n // This is an error state, so it's only useful for consistent error messages\n if (a.pattern === b.pattern) {\n return b.routeNames.join('>').localeCompare(a.routeNames.join('>'));\n }\n\n // If one of the patterns starts with the other, it's more exhaustive\n // So move it up\n if (\n a.pattern.startsWith(b.pattern) &&\n // NOTE(EvanBacon): This is a hack to make sure that `*` is always at the end\n b.screen !== 'index'\n ) {\n return -1;\n }\n\n if (b.pattern.startsWith(a.pattern) && a.screen !== 'index') {\n return 1;\n }\n\n // NOTE(EvanBacon): Here we append `index` if the screen was `index` so the length is the same\n // as a slug or wildcard when nested more than one level deep.\n // This is so we can compare the length of the pattern, e.g. `foo/*` > `foo` vs `*` < ``.\n const aParts = a.pattern\n .split('/')\n // Strip out group names to ensure they don't affect the priority.\n .filter((part) => matchGroupName(part) == null);\n if (a.screen === 'index' || a.screen.match(/\\/index$/)) {\n aParts.push('index');\n }\n\n const bParts = b.pattern.split('/').filter((part) => matchGroupName(part) == null);\n if (b.screen === 'index' || b.screen.match(/\\/index$/)) {\n bParts.push('index');\n }\n\n // When we navigate, we need to stay within groups as close as possible\n // Hence, a route is sorted based upon is similiarity to the current state\n const similarToPreviousA = previousSegments.filter((value, index) => {\n return value === a.expandedRouteNames[index] && value.startsWith('(') && value.endsWith(')');\n });\n\n const similarToPreviousB = previousSegments.filter((value, index) => {\n return value === b.expandedRouteNames[index] && value.startsWith('(') && value.endsWith(')');\n });\n\n if (\n (similarToPreviousA.length > 0 || similarToPreviousB.length > 0) &&\n similarToPreviousA.length !== similarToPreviousB.length\n ) {\n // They both match to some degree, so pick the one that matches more\n return similarToPreviousB.length - similarToPreviousA.length;\n }\n\n for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {\n // if b is longer, b get higher priority\n if (aParts[i] == null) {\n return 1;\n }\n // if a is longer, a get higher priority\n if (bParts[i] == null) {\n return -1;\n }\n\n const aWildCard = aParts[i].startsWith('*');\n const bWildCard = bParts[i].startsWith('*');\n // if both are wildcard we compare next component\n if (aWildCard && bWildCard) {\n const aNotFound = aParts[i].match(/^[*]not-found$/);\n const bNotFound = bParts[i].match(/^[*]not-found$/);\n\n if (aNotFound && bNotFound) {\n continue;\n } else if (aNotFound) {\n return 1;\n } else if (bNotFound) {\n return -1;\n }\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aWildCard) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bWildCard) {\n return -1;\n }\n\n const aSlug = aParts[i].startsWith(':');\n const bSlug = bParts[i].startsWith(':');\n // if both are wildcard we compare next component\n if (aSlug && bSlug) {\n const aNotFound = aParts[i].match(/^[*]not-found$/);\n const bNotFound = bParts[i].match(/^[*]not-found$/);\n\n if (aNotFound && bNotFound) {\n continue;\n } else if (aNotFound) {\n return 1;\n } else if (bNotFound) {\n return -1;\n }\n\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aSlug) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bSlug) {\n return -1;\n }\n }\n\n // Sort initial routes with a higher priority than routes which will push more screens\n // this ensures shared routes go to the shortest path.\n if (a.isInitial && !b.isInitial) {\n return -1;\n }\n if (!a.isInitial && b.isInitial) {\n return 1;\n }\n\n return bParts.length - aParts.length;\n}\n\nfunction getStateFromEmptyPathWithConfigs(\n path: string,\n hash: string,\n configs: RouteConfig[],\n initialRoutes: InitialRouteConfig[]\n): ResultState | undefined {\n // We need to add special handling of empty path so navigation to empty path also works\n // When handling empty path, we should only look at the root level config\n\n // NOTE(EvanBacon): We only care about matching leaf nodes.\n const leafNodes = configs\n .filter((config) => !config.hasChildren)\n .map((value) => {\n return {\n ...value,\n // Collapse all levels of group segments before testing.\n // This enables `app/(one)/(two)/index.js` to be matched.\n path: stripGroupSegmentsFromPath(value.path),\n };\n });\n\n const match =\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node index routes that either don't have a regex or match an empty string.\n config.path === '' && (!config.regex || config.regex.test(''))\n ) ??\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node dynamic routes that match an empty string.\n config.path.startsWith(':') && config.regex!.test('')\n ) ??\n // NOTE(EvanBacon): Test leaf node deep dynamic routes that match a slash.\n // This should be done last to enable dynamic routes having a higher priority.\n leafNodes.find((config) => config.path.startsWith('*') && config.regex!.test('/'));\n\n if (!match) {\n return undefined;\n }\n\n const routes = match.routeNames.map((name) => {\n if (!match._route) {\n return { name };\n }\n return {\n name,\n _route: match._route,\n };\n });\n\n return createNestedStateObject(path, hash, routes, configs, initialRoutes);\n}\n\nfunction getStateFromPathWithConfigs(\n path: string,\n configs: RouteConfig[],\n initialRoutes: InitialRouteConfig[],\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n): ResultState | undefined {\n const formattedPaths = getUrlWithReactNavigationConcessions(path);\n\n if (!formattedPaths.url) return;\n\n let cleanPath =\n stripBaseUrl(stripGroupSegmentsFromPath(formattedPaths.url.pathname), baseUrl) +\n formattedPaths.url.search;\n\n if (!path.startsWith('/')) cleanPath = cleanPath.slice(1);\n\n if (formattedPaths.nonstandardPathname === '/') {\n return getStateFromEmptyPathWithConfigs(\n cleanPath,\n formattedPaths.url.hash.slice(1),\n configs,\n initialRoutes\n );\n }\n\n // We match the whole path against the regex instead of segments\n // This makes sure matches such as wildcard will catch any unmatched routes, even if nested\n const routes = matchAgainstConfigs(formattedPaths.nonstandardPathname, configs);\n\n if (routes == null) {\n return undefined;\n }\n // This will always be empty if full path matched\n return createNestedStateObject(\n cleanPath,\n formattedPaths.url.hash.slice(1),\n routes,\n configs,\n initialRoutes\n );\n}\n\nconst joinPaths = (...paths: string[]): string =>\n ([] as string[])\n .concat(...paths.map((p) => p.split('/')))\n .filter(Boolean)\n .join('/');\n\nfunction matchAgainstConfigs(remaining: string, configs: RouteConfig[]): ParsedRoute[] | undefined {\n let routes: ParsedRoute[] | undefined;\n let remainingPath = remaining;\n\n // Go through all configs, and see if the next path segment matches our regex\n for (const config of configs) {\n if (!config.regex) {\n continue;\n }\n\n const match = remainingPath.match(config.regex);\n\n // If our regex matches, we need to extract params from the path\n if (!match) {\n continue;\n }\n\n // TODO: Add support for wildcard routes\n const matchedParams = config.pattern\n ?.split('/')\n .filter((p) => p.match(/^[:*]/))\n .reduce<Record<string, any>>((acc, p, i) => {\n if (p.match(/^\\*/)) {\n return {\n ...acc,\n [p]: match![(i + 1) * 2], //?.replace(/\\//, \"\"),\n };\n }\n return Object.assign(acc, {\n // The param segments appear every second item starting from 2 in the regex match result.\n // This will only work if we ensure groups aren't included in the match.\n [p]: match![(i + 1) * 2]?.replace(/\\//, ''),\n });\n }, {});\n\n const routeFromName = (name: string) => {\n const config = configs.find((c) => c.screen === name);\n if (!config?.path) {\n return { name };\n }\n\n const segments = config.path.split('/');\n\n const params: Record<string, any> = {};\n\n segments\n .filter((p) => p.match(/^[:*]/))\n .forEach((p) => {\n let value = matchedParams[p];\n if (value) {\n if (p.match(/^\\*/)) {\n // Convert to an array before providing as a route.\n value = value?.split('/').filter(Boolean);\n }\n\n const key = p.replace(/^[:*]/, '').replace(/\\?$/, '');\n params[key] = config.parse?.[key] ? config.parse[key](value) : value;\n }\n });\n\n if (params && Object.keys(params).length) {\n return { name, params };\n }\n\n return { name };\n };\n\n routes = config.routeNames.map((name) => {\n if (!config._route) {\n return { ...routeFromName(name) };\n }\n return {\n ...routeFromName(name),\n _route: config._route,\n };\n });\n\n // TODO(EvanBacon): Maybe we should warn / assert if multiple slugs use the same param name.\n const combinedParams = routes.reduce<Record<string, any>>(\n (acc, r) => Object.assign(acc, r.params),\n {}\n );\n\n const hasCombinedParams = Object.keys(combinedParams).length > 0;\n\n // Combine all params so a route `[foo]/[bar]/other.js` has access to `{ foo, bar }`\n routes = routes.map((r) => {\n if (hasCombinedParams) {\n r.params = combinedParams;\n }\n return r;\n });\n\n remainingPath = remainingPath.replace(match[1], '');\n\n break;\n }\n\n return routes;\n}\n\nfunction equalHeritage(a: string[], b: string[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i].localeCompare(b[i]) !== 0) {\n return false;\n }\n }\n return true;\n}\n\nconst createNormalizedConfigs = (\n screen: string,\n routeConfig: PathConfigMap<object>,\n routeNames: string[] = [],\n initials: InitialRouteConfig[] = [],\n parentScreens: string[] = [],\n parentPattern?: string\n): RouteConfig[] => {\n const configs: RouteConfig[] = [];\n\n routeNames.push(screen);\n\n parentScreens.push(screen);\n\n const config = (routeConfig as any)[screen];\n\n if (typeof config === 'string') {\n // TODO: This should never happen with the addition of `_route`\n\n // If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern\n const pattern = parentPattern ? joinPaths(parentPattern, config) : config;\n\n configs.push(createConfigItem(screen, routeNames, pattern, config, false));\n } else if (typeof config === 'object') {\n let pattern: string | undefined;\n\n const { _route } = config;\n // if an object is specified as the value (e.g. Foo: { ... }),\n // it can have `path` property and\n // it could have `screens` prop which has nested configs\n if (typeof config.path === 'string') {\n if (config.exact && config.path === undefined) {\n throw new Error(\n \"A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.\"\n );\n }\n\n pattern =\n config.exact !== true\n ? joinPaths(parentPattern || '', config.path || '')\n : config.path || '';\n\n configs.push(\n createConfigItem(\n screen,\n routeNames,\n pattern!,\n config.path,\n config.screens ? !!Object.keys(config.screens)?.length : false,\n config.parse,\n _route\n )\n );\n }\n\n if (config.screens) {\n // property `initialRouteName` without `screens` has no purpose\n if (config.initialRouteName) {\n initials.push({\n initialRouteName: config.initialRouteName,\n parentScreens,\n });\n }\n\n Object.keys(config.screens).forEach((nestedConfig) => {\n const result = createNormalizedConfigs(\n nestedConfig,\n config.screens as PathConfigMap<object>,\n routeNames,\n initials,\n [...parentScreens],\n pattern ?? parentPattern\n );\n\n configs.push(...result);\n });\n }\n }\n\n routeNames.pop();\n\n return configs;\n};\n\nfunction formatRegexPattern(it: string): string {\n // Allow spaces in file path names.\n it = it.replace(' ', '%20');\n\n if (it.startsWith(':')) {\n // TODO: Remove unused match group\n return `(([^/]+\\\\/)${it.endsWith('?') ? '?' : ''})`;\n } else if (it.startsWith('*')) {\n return `((.*\\\\/)${it.endsWith('?') ? '?' : ''})`;\n }\n\n // Strip groups from the matcher\n if (matchGroupName(it) != null) {\n // Groups are optional segments\n // this enables us to match `/bar` and `/(foo)/bar` for the same route\n // NOTE(EvanBacon): Ignore this match in the regex to avoid capturing the group\n return `(?:${escape(it)}\\\\/)?`;\n }\n\n return escape(it) + `\\\\/`;\n}\n\nconst createConfigItem = (\n screen: string,\n routeNames: string[],\n pattern: string,\n path: string,\n hasChildren?: boolean,\n parse?: ParseConfig,\n _route?: any\n): RouteConfig => {\n // Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.\n pattern = pattern.split('/').filter(Boolean).join('/');\n\n const regex = pattern\n ? new RegExp(`^(${pattern.split('/').map(formatRegexPattern).join('')})$`)\n : undefined;\n\n return {\n screen,\n regex,\n pattern,\n path,\n // The routeNames array is mutated, so copy it to keep the current state\n routeNames: [...routeNames],\n expandedRouteNames: screen.includes('/')\n ? [...routeNames.slice(0, -1), ...screen.split('/')]\n : [...routeNames],\n parse,\n userReadableName: [...routeNames.slice(0, -1), path || screen].join('/'),\n hasChildren: !!hasChildren,\n _route,\n };\n};\n\nconst findParseConfigForRoute = (\n routeName: string,\n routeConfigs: RouteConfig[]\n): ParseConfig | undefined => {\n for (const config of routeConfigs) {\n if (routeName === config.routeNames[config.routeNames.length - 1]) {\n return config.parse;\n }\n }\n\n return undefined;\n};\n\n// Try to find an initial route connected with the one passed\nconst findInitialRoute = (\n routeName: string,\n parentScreens: string[],\n initialRoutes: InitialRouteConfig[]\n): string | undefined => {\n for (const config of initialRoutes) {\n if (equalHeritage(parentScreens, config.parentScreens)) {\n // If the parents are the same but the route name doesn't match the initial route\n // then we return the initial route.\n return routeName !== config.initialRouteName ? config.initialRouteName : undefined;\n }\n }\n return undefined;\n};\n\n// returns state object with values depending on whether\n// it is the end of state and if there is initialRoute for this level\nconst createStateObject = (\n route: ParsedRoute,\n isEmpty: boolean,\n initialRoute?: string\n): InitialState => {\n if (isEmpty) {\n if (initialRoute) {\n return {\n index: 1,\n routes: [{ name: initialRoute, params: route.params }, route],\n };\n }\n return {\n routes: [route],\n };\n }\n\n if (initialRoute) {\n return {\n index: 1,\n routes: [\n { name: initialRoute, params: route.params },\n { ...route, state: { routes: [] } },\n ],\n };\n }\n return {\n routes: [{ ...route, state: { routes: [] } }],\n };\n};\n\nconst createNestedStateObject = (\n path: string,\n hash: string | undefined,\n routes: ParsedRoute[],\n routeConfigs: RouteConfig[],\n initialRoutes: InitialRouteConfig[]\n) => {\n let route = routes.shift() as ParsedRoute;\n const parentScreens: string[] = [];\n\n let initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);\n\n parentScreens.push(route.name);\n\n const state: InitialState = createStateObject(route, routes.length === 0, initialRoute);\n\n if (routes.length > 0) {\n let nestedState = state;\n\n while ((route = routes.shift() as ParsedRoute)) {\n initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);\n\n const nestedStateIndex = nestedState.index || nestedState.routes.length - 1;\n\n nestedState.routes[nestedStateIndex].state = createStateObject(\n route,\n routes.length === 0,\n initialRoute\n );\n\n if (routes.length > 0) {\n nestedState = nestedState.routes[nestedStateIndex].state as InitialState;\n }\n\n parentScreens.push(route.name);\n }\n }\n\n route = findFocusedRoute(state) as ParsedRoute;\n\n // Remove groups from the path while preserving a trailing slash.\n route.path = path;\n\n const params = parseQueryParams(route.path, findParseConfigForRoute(route.name, routeConfigs));\n\n if (params) {\n route.params = Object.assign(Object.create(null), route.params) as Record<string, any>;\n for (const [name, value] of Object.entries(params)) {\n if (route.params?.[name]) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Route '/${route.name}' with param '${name}' was specified both in the path and as a param, removing from path`\n );\n }\n }\n\n if (!route.params?.[name]) {\n route.params[name] = value;\n continue;\n }\n }\n\n if (Object.keys(route.params).length === 0) {\n delete route.params;\n }\n }\n\n if (hash) {\n route.params = Object.assign(Object.create(null), route.params) as Record<string, any>;\n route.params['#'] = hash;\n }\n\n return state;\n};\n\nconst parseQueryParams = (path: string, parseConfig?: Record<string, (value: string) => any>) => {\n const query = path.split('?')[1];\n const searchParams = new URLSearchParams(query);\n const params = Object.fromEntries(\n // @ts-ignore: [Symbol.iterator] is indeed, available on every platform.\n searchParams\n );\n\n if (parseConfig) {\n Object.keys(params).forEach((name) => {\n if (Object.hasOwnProperty.call(parseConfig, name) && typeof params[name] === 'string') {\n params[name] = parseConfig[name](params[name] as string);\n }\n });\n }\n\n return Object.keys(params).length ? params : undefined;\n};\n\nconst baseUrlCache = new Map<string, RegExp>();\n\nfunction getBaseUrlRegex(baseUrl: string) {\n if (baseUrlCache.has(baseUrl)) {\n return baseUrlCache.get(baseUrl)!;\n }\n const regex = new RegExp(`^\\\\/?${escape(baseUrl)}`, 'g');\n baseUrlCache.set(baseUrl, regex);\n return regex;\n}\n\nexport function stripBaseUrl(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n) {\n if (process.env.NODE_ENV !== 'development') {\n if (baseUrl) {\n const reg = getBaseUrlRegex(baseUrl);\n return path.replace(/^\\/+/g, '/').replace(reg, '');\n }\n }\n return path;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LinkingOptions } from '@react-navigation/native';
|
|
2
2
|
import { RouteNode } from './Route';
|
|
3
|
-
import {
|
|
3
|
+
import { RouterStore } from './global-state/router-store';
|
|
4
|
+
import { getInitialURL, getPathFromState, getStateFromPath } from './link/linking';
|
|
4
5
|
import { RequireContext } from './types';
|
|
5
6
|
export declare function getNavigationConfig(routes: RouteNode, metaOnly?: boolean): {
|
|
6
7
|
initialRouteName: string | undefined;
|
|
@@ -8,12 +9,12 @@ export declare function getNavigationConfig(routes: RouteNode, metaOnly?: boolea
|
|
|
8
9
|
};
|
|
9
10
|
export type ExpoLinkingOptions<T extends object = Record<string, unknown>> = LinkingOptions<T> & {
|
|
10
11
|
getPathFromState?: typeof getPathFromState;
|
|
12
|
+
getStateFromPath?: typeof getStateFromPath;
|
|
11
13
|
};
|
|
12
14
|
export type LinkingConfigOptions = {
|
|
13
15
|
metaOnly?: boolean;
|
|
14
16
|
serverUrl?: string;
|
|
15
17
|
getInitialURL?: typeof getInitialURL;
|
|
16
18
|
};
|
|
17
|
-
export declare function getLinkingConfig(routes: RouteNode, context: RequireContext, { metaOnly, serverUrl }?: LinkingConfigOptions): ExpoLinkingOptions;
|
|
18
|
-
export declare const stateCache: Map<string, any>;
|
|
19
|
+
export declare function getLinkingConfig(store: RouterStore, routes: RouteNode, context: RequireContext, { metaOnly, serverUrl }?: LinkingConfigOptions): ExpoLinkingOptions;
|
|
19
20
|
//# sourceMappingURL=getLinkingConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLinkingConfig.d.ts","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EAEL,aAAa,EACb,gBAAgB,
|
|
1
|
+
{"version":3,"file":"getLinkingConfig.d.ts","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAEL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAgB,cAAc,EAAE,MAAM,SAAS,CAAC;AAEvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,GAAE,OAAc;;;EAE9E;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG;IAC/F,gBAAgB,CAAC,EAAE,OAAO,gBAAgB,CAAC;IAC3C,gBAAgB,CAAC,EAAE,OAAO,gBAAgB,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,aAAa,CAAC;CACtC,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,cAAc,EACvB,EAAE,QAAe,EAAE,SAAS,EAAE,GAAE,oBAAyB,GACxD,kBAAkB,CA6DpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getLinkingConfig = exports.getNavigationConfig = void 0;
|
|
4
4
|
const native_1 = require("@react-navigation/native");
|
|
5
5
|
const expo_modules_core_1 = require("expo-modules-core");
|
|
6
6
|
const getReactNavigationConfig_1 = require("./getReactNavigationConfig");
|
|
@@ -9,7 +9,7 @@ function getNavigationConfig(routes, metaOnly = true) {
|
|
|
9
9
|
return (0, getReactNavigationConfig_1.getReactNavigationConfig)(routes, metaOnly);
|
|
10
10
|
}
|
|
11
11
|
exports.getNavigationConfig = getNavigationConfig;
|
|
12
|
-
function getLinkingConfig(routes, context, { metaOnly = true, serverUrl } = {}) {
|
|
12
|
+
function getLinkingConfig(store, routes, context, { metaOnly = true, serverUrl } = {}) {
|
|
13
13
|
// Returning `undefined` / `null from `getInitialURL` are valid values, so we need to track if it's been called.
|
|
14
14
|
let hasCachedInitialUrl = false;
|
|
15
15
|
let initialUrl;
|
|
@@ -55,7 +55,7 @@ function getLinkingConfig(routes, context, { metaOnly = true, serverUrl } = {})
|
|
|
55
55
|
return initialUrl;
|
|
56
56
|
},
|
|
57
57
|
subscribe: (0, linking_1.addEventListener)(nativeLinking),
|
|
58
|
-
getStateFromPath:
|
|
58
|
+
getStateFromPath: linking_1.getStateFromPath.bind(store),
|
|
59
59
|
getPathFromState(state, options) {
|
|
60
60
|
return ((0, linking_1.getPathFromState)(state, {
|
|
61
61
|
screens: {},
|
|
@@ -69,15 +69,4 @@ function getLinkingConfig(routes, context, { metaOnly = true, serverUrl } = {})
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
exports.getLinkingConfig = getLinkingConfig;
|
|
72
|
-
exports.stateCache = new Map();
|
|
73
|
-
/** We can reduce work by memoizing the state by the pathname. This only works because the options (linking config) theoretically never change. */
|
|
74
|
-
function getStateFromPathMemoized(path, options) {
|
|
75
|
-
const cached = exports.stateCache.get(path);
|
|
76
|
-
if (cached) {
|
|
77
|
-
return cached;
|
|
78
|
-
}
|
|
79
|
-
const result = (0, linking_1.getStateFromPath)(path, options);
|
|
80
|
-
exports.stateCache.set(path, result);
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
72
|
//# sourceMappingURL=getLinkingConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLinkingConfig.js","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":";;;AAAA,qDAA8E;AAC9E,yDAA6C;AAI7C,yEAAsE;
|
|
1
|
+
{"version":3,"file":"getLinkingConfig.js","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":";;;AAAA,qDAA8E;AAC9E,yDAA6C;AAI7C,yEAAsE;AAEtE,4CAKwB;AAGxB,SAAgB,mBAAmB,CAAC,MAAiB,EAAE,WAAoB,IAAI;IAC7E,OAAO,IAAA,mDAAwB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC;AAFD,kDAEC;AAaD,SAAgB,gBAAgB,CAC9B,KAAkB,EAClB,MAAiB,EACjB,OAAuB,EACvB,EAAE,QAAQ,GAAG,IAAI,EAAE,SAAS,KAA2B,EAAE;IAEzD,gHAAgH;IAChH,IAAI,mBAAmB,GAAG,KAAK,CAAC;IAChC,IAAI,UAAwD,CAAC;IAE7D,MAAM,gBAAgB,GAAG,OAAO;SAC7B,IAAI,EAAE;SACN,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,K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AAA,0BAAgB,EAAC,aAAa,CAAC;QAC1C,gBAAgB,EAAE,0BAAgB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C,gBAAgB,CAAC,KAAY,EAAE,OAA+C;YAC5E,OAAO,CACL,IAAA,0BAAgB,EAAC,KAAK,EAAE;gBACtB,OAAO,EAAE,EAAE;gBACX,GAAG,IAAI,CAAC,MAAM;gBACd,GAAG,OAAO;aACX,CAAC,IAAI,GAAG,CACV,CAAC;QACJ,CAAC;QACD,gEAAgE;QAChE,kDAAkD;QAClD,kBAAkB,EAAlB,2BAAkB;KACnB,CAAC;AACJ,CAAC;AAlED,4CAkEC","sourcesContent":["import { getActionFromState, LinkingOptions } from '@react-navigation/native';\nimport { Platform } from 'expo-modules-core';\n\nimport { RouteNode } from './Route';\nimport { State } from './fork/getPathFromState';\nimport { getReactNavigationConfig } from './getReactNavigationConfig';\nimport { RouterStore } from './global-state/router-store';\nimport {\n addEventListener,\n getInitialURL,\n getPathFromState,\n getStateFromPath,\n} from './link/linking';\nimport { NativeIntent, RequireContext } from './types';\n\nexport function getNavigationConfig(routes: RouteNode, metaOnly: boolean = true) {\n return getReactNavigationConfig(routes, metaOnly);\n}\n\nexport type ExpoLinkingOptions<T extends object = Record<string, unknown>> = LinkingOptions<T> & {\n getPathFromState?: typeof getPathFromState;\n getStateFromPath?: typeof getStateFromPath;\n};\n\nexport type LinkingConfigOptions = {\n metaOnly?: boolean;\n serverUrl?: string;\n getInitialURL?: typeof getInitialURL;\n};\n\nexport function getLinkingConfig(\n store: RouterStore,\n routes: RouteNode,\n context: RequireContext,\n { metaOnly = true, serverUrl }: LinkingConfigOptions = {}\n): ExpoLinkingOptions {\n // Returning `undefined` / `null from `getInitialURL` are valid values, so we need to track if it's been called.\n let hasCachedInitialUrl = false;\n let initialUrl: ReturnType<typeof getInitialURL> | undefined;\n\n const nativeLinkingKey = context\n .keys()\n .find((key) => key.match(/^\\.\\/\\+native-intent\\.[tj]sx?$/));\n const nativeLinking: NativeIntent | undefined = nativeLinkingKey\n ? context(nativeLinkingKey)\n : undefined;\n\n return {\n prefixes: [],\n config: getNavigationConfig(routes, metaOnly),\n // A custom getInitialURL is used on native to ensure the app always starts at\n // the root path if it's launched from something other than a deep link.\n // This helps keep the native functionality working like the web functionality.\n // For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`\n // then `/index` would be used on web and `/settings` would be used on native.\n getInitialURL() {\n // Expo Router calls `getInitialURL` twice, which may confuse the user if they provide a custom `getInitialURL`.\n // Therefor we memoize the result.\n if (!hasCachedInitialUrl) {\n if (Platform.OS === 'web') {\n initialUrl = serverUrl ?? getInitialURL();\n } else {\n initialUrl = serverUrl ?? getInitialURL();\n\n if (typeof initialUrl === 'string') {\n if (typeof nativeLinking?.redirectSystemPath === 'function') {\n initialUrl = nativeLinking.redirectSystemPath({ path: initialUrl, initial: true });\n }\n } else if (initialUrl) {\n initialUrl = initialUrl.then((url) => {\n if (url && typeof nativeLinking?.redirectSystemPath === 'function') {\n return nativeLinking.redirectSystemPath({ path: url, initial: true });\n }\n return url;\n });\n }\n }\n hasCachedInitialUrl = true;\n }\n return initialUrl;\n },\n subscribe: addEventListener(nativeLinking),\n getStateFromPath: getStateFromPath.bind(store),\n getPathFromState(state: State, options: Parameters<typeof getPathFromState>[1]) {\n return (\n getPathFromState(state, {\n screens: {},\n ...this.config,\n ...options,\n }) ?? '/'\n );\n },\n // Add all functions to ensure the types never need to fallback.\n // This is a convenience for usage in the package.\n getActionFromState,\n };\n}\n"]}
|
|
@@ -95,7 +95,7 @@ class RouterStore {
|
|
|
95
95
|
};
|
|
96
96
|
if (this.routeNode) {
|
|
97
97
|
// We have routes, so get the linking config and the root component
|
|
98
|
-
this.linking = (0, getLinkingConfig_1.getLinkingConfig)(this.routeNode, context, linkingConfigOptions);
|
|
98
|
+
this.linking = (0, getLinkingConfig_1.getLinkingConfig)(this, this.routeNode, context, linkingConfigOptions);
|
|
99
99
|
this.rootComponent = (0, useScreens_1.getQualifiedRouteComponent)(this.routeNode);
|
|
100
100
|
// By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`
|
|
101
101
|
// This will cause static rendering to fail, which once performs a single pass.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAIkC;AAClC,oEAAuC;AACvC,iEAAmD;AACnD,iCAA+E;AAC/E,+CAAwC;AAExC,uCAWmB;AACnB,+CAAgD;AAChD,0DAAuE;AAEvE,+DAA2E;AAE3E,0DAAiG;AACjG,4CAAyC;AAEzC,8CAA2D;AAE3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAsB;IACrB,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAAe;IAC3B,SAAS,CAAe;IACxB,SAAS,CAAe;IACxB,SAAS,CAAa;IACtB,0BAA0B,CAAU;IAEpC,aAAa,CAAoE;IACjF,yBAAyB,CAAc;IAEvC,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;IAC7C,gBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;IAEzC,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,eAAe,GAAG,6BAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,GAAG,mBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,GAAG,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,GAAG,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,UAAU,GAAG,oBAAU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GAAG,aAAK,CAAC,aAAa,CAAC,YAAY,EAA4B,CAAC;QAElF,IAAI,aAAK,CAAC,SAAS,KAAK,YAAY,EAAE;YACpC,aAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACjC;KACF;AACH,CAAC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,OAA6B;IAC5F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AALD,0DAKC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n canGoBack,\n canDismiss,\n goBack,\n linkTo,\n navigate,\n dismiss,\n dismissAll,\n push,\n replace,\n setParams,\n} 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, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking?: ExpoLinkingOptions;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState?: ResultState;\n rootState?: ResultState;\n nextState?: ResultState;\n routeInfo?: UrlObject;\n splashScreenAnimationFrame?: number;\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 dismiss = dismiss.bind(this);\n replace = replace.bind(this);\n dismissAll = dismissAll.bind(this);\n canDismiss = canDismiss.bind(this);\n setParams = setParams.bind(this);\n navigate = navigate.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n linkingConfigOptions: LinkingConfigOptions = {}\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context, {\n ...Constants.expoConfig?.extra?.router,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n // We always needs routeInfo, even if there are no routes. This can happen if:\n // - there are no routes (we are showing the onboarding screen)\n // - getInitialURL() is async\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n\n if (this.routeNode) {\n // We have routes, so get the linking config and the root component\n this.linking = getLinkingConfig(this.routeNode, context, linkingConfigOptions);\n this.rootComponent = getQualifiedRouteComponent(this.routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can preload the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = this.linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n this.rootState = this.linking.getStateFromPath?.(initialURL, this.linking.config);\n this.initialState = this.rootState;\n if (this.rootState) {\n this.routeInfo = this.getRouteInfo(this.rootState);\n }\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n this.rootComponent = Fragment;\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes 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.navigationRef = navigationRef;\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 this.splashScreenAnimationFrame = requestAnimationFrame(() => {\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!deepEqual(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: {},\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n\n cleanup() {\n if (this.splashScreenAnimationFrame) {\n cancelAnimationFrame(this.splashScreenAnimationFrame);\n }\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, options: LinkingConfigOptions) {\n const navigationRef = useNavigationContainerRef();\n useMemo(() => store.initialize(context, navigationRef, options), [context]);\n useExpoRouter();\n return store;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAIkC;AAClC,oEAAuC;AACvC,iEAAmD;AACnD,iCAA+E;AAC/E,+CAAwC;AAExC,uCAWmB;AACnB,+CAAgD;AAChD,0DAAuE;AAEvE,+DAA2E;AAE3E,0DAAiG;AACjG,4CAAyC;AAEzC,8CAA2D;AAE3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAsB;IACrB,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAAe;IAC3B,SAAS,CAAe;IACxB,SAAS,CAAe;IACxB,SAAS,CAAa;IACtB,0BAA0B,CAAU;IAEpC,aAAa,CAAoE;IACjF,yBAAyB,CAAc;IAEvC,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;IAC7C,gBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;IAEzC,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,eAAe,GAAG,6BAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,GAAG,mBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,GAA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AAC,aAAK,CAAC,gBAAgB,EAAE,aAAK,CAAC,QAAQ,EAAE,aAAK,CAAC,QAAQ,CAAC,CAAC;AACtF,CAAC;AAFD,sCAEC;AAED,SAAS,kBAAkB;IACzB,IAAI,aAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QACjC,MAAM,YAAY,GAAG,aAAK,CAAC,aAAa,CAAC,YAAY,EAA4B,CAAC;QAElF,IAAI,aAAK,CAAC,SAAS,KAAK,YAAY,EAAE;YACpC,aAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACjC;KACF;AACH,CAAC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,OAA6B;IAC5F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AALD,0DAKC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n canGoBack,\n canDismiss,\n goBack,\n linkTo,\n navigate,\n dismiss,\n dismissAll,\n push,\n replace,\n setParams,\n} 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, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking?: ExpoLinkingOptions;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState?: ResultState;\n rootState?: ResultState;\n nextState?: ResultState;\n routeInfo?: UrlObject;\n splashScreenAnimationFrame?: number;\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 dismiss = dismiss.bind(this);\n replace = replace.bind(this);\n dismissAll = dismissAll.bind(this);\n canDismiss = canDismiss.bind(this);\n setParams = setParams.bind(this);\n navigate = navigate.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n linkingConfigOptions: LinkingConfigOptions = {}\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context, {\n ...Constants.expoConfig?.extra?.router,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n // We always needs routeInfo, even if there are no routes. This can happen if:\n // - there are no routes (we are showing the onboarding screen)\n // - getInitialURL() is async\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n\n if (this.routeNode) {\n // We have routes, so get the linking config and the root component\n this.linking = getLinkingConfig(this, this.routeNode, context, linkingConfigOptions);\n this.rootComponent = getQualifiedRouteComponent(this.routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can preload the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = this.linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n this.rootState = this.linking.getStateFromPath?.(initialURL, this.linking.config);\n this.initialState = this.rootState;\n if (this.rootState) {\n this.routeInfo = this.getRouteInfo(this.rootState);\n }\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n this.rootComponent = Fragment;\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes 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.navigationRef = navigationRef;\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 this.splashScreenAnimationFrame = requestAnimationFrame(() => {\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!deepEqual(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: {},\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n\n cleanup() {\n if (this.splashScreenAnimationFrame) {\n cancelAnimationFrame(this.splashScreenAnimationFrame);\n }\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, options: LinkingConfigOptions) {\n const navigationRef = useNavigationContainerRef();\n useMemo(() => store.initialize(context, navigationRef, options), [context]);\n useExpoRouter();\n return store;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,CAAC;AAClB,OAAO,SAAS,CAAC;AAEjB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAO,MAAM,EAAwB,MAAM,+BAA+B,CAAC;AAGlF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGjF,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,CAAC;AAClB,OAAO,SAAS,CAAC;AAEjB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAO,MAAM,EAAwB,MAAM,+BAA+B,CAAC;AAGlF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGjF,OAAO,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,GAAE,mBAAwB,GAClE,MAAM,CAqCR;AAED,eAAO,MAAM,UAAU;IACrB,yDAAyD;mBAC1C,MAAM;IAIrB,yDAAyD;eAC9C,MAAM;IAIjB,6DAA6D;kBAC/C,MAAM;IAIpB,oDAAoD;gBACxC,MAAM;IAOlB,qEAAqE;;IAIrE,wEAAwE;sBACtD,OAAO,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM;IAMvD,qEAAqE;;CAItE,CAAC"}
|
|
@@ -27,7 +27,6 @@ Object.defineProperty(exports, "getMockConfig", { enumerable: true, get: functio
|
|
|
27
27
|
Object.defineProperty(exports, "getMockContext", { enumerable: true, get: function () { return mock_config_1.getMockContext; } });
|
|
28
28
|
const ExpoRoot_1 = require("../ExpoRoot");
|
|
29
29
|
const getPathFromState_1 = __importDefault(require("../fork/getPathFromState"));
|
|
30
|
-
const getLinkingConfig_1 = require("../getLinkingConfig");
|
|
31
30
|
const router_store_1 = require("../global-state/router-store");
|
|
32
31
|
const imperative_api_1 = require("../imperative-api");
|
|
33
32
|
// re-export everything
|
|
@@ -40,7 +39,6 @@ function renderRouter(context = './app', { initialUrl = '/', linking, ...options
|
|
|
40
39
|
const mockContext = (0, mock_config_1.getMockContext)(context);
|
|
41
40
|
// Force the render to be synchronous
|
|
42
41
|
process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';
|
|
43
|
-
getLinkingConfig_1.stateCache.clear();
|
|
44
42
|
const result = (0, react_native_1.render)(<ExpoRoot_1.ExpoRoot context={mockContext} location={initialUrl} linking={linking}/>, options);
|
|
45
43
|
/**
|
|
46
44
|
* This is a hack to ensure that React Navigation's state updates are processed before we run assertions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,oBAAkB;AAClB,mBAAiB;AAGjB,gEAAkF;AAClF,kDAA0B;AAE1B,+CAAiF;AAuCrD,8FAvCA,2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I,EAAE,CAAC,CAAC;QACzB,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,qBAAM,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;SAC/C;IACH,CAAC;IACD,qEAAqE;IACrE,SAAS;QACP,OAAO,uBAAM,CAAC,SAAS,EAAE,CAAC;IAC5B,CAAC;IACD,wEAAwE;IACxE,SAAS,CAAC,MAA8B,EAAE,IAAa;QACrD,uBAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,qBAAM,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;SAC/C;IACH,CAAC;IACD,qEAAqE;IACrE,UAAU;QACR,IAAA,kBAAG,EAAC,GAAG,EAAE,CAAC,uBAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAC","sourcesContent":["import './expect';\nimport './mocks';\n\nimport { NavigationState, PartialState } from '@react-navigation/native';\nimport { act, render, RenderResult, screen } from '@testing-library/react-native';\nimport React from 'react';\n\nimport { MockContextConfig, getMockConfig, getMockContext } from './mock-config';\nimport { ExpoRoot } from '../ExpoRoot';\nimport getPathFromState from '../fork/getPathFromState';\nimport { ExpoLinkingOptions } from '../getLinkingConfig';\nimport { store } from '../global-state/router-store';\nimport { router } from '../imperative-api';\n\n// re-export everything\nexport * from '@testing-library/react-native';\n\nafterAll(() => {\n store.cleanup();\n});\n\ntype RenderRouterOptions = Parameters<typeof render>[1] & {\n initialUrl?: any;\n linking?: Partial<ExpoLinkingOptions>;\n};\n\ntype Result = ReturnType<typeof render> & {\n getPathname(): string;\n getPathnameWithParams(): string;\n getSegments(): string[];\n getSearchParams(): Record<string, string | string[]>;\n getRouterState(): NavigationState<any> | PartialState<any>;\n};\n\ndeclare global {\n namespace jest {\n interface Matchers<R> {\n toHavePathname(pathname: string): R;\n toHavePathnameWithParams(pathname: string): R;\n toHaveSegments(segments: string[]): R;\n toHaveSearchParams(params: Record<string, string | string[]>): R;\n toHaveRouterState(state: NavigationState<any> | PartialState<any>): R;\n }\n }\n}\n\nexport { MockContextConfig, getMockConfig, getMockContext };\n\nexport function renderRouter(\n context: MockContextConfig = './app',\n { initialUrl = '/', linking, ...options }: RenderRouterOptions = {}\n): Result {\n jest.useFakeTimers();\n\n const mockContext = getMockContext(context);\n\n // Force the render to be synchronous\n process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';\n\n const result = render(\n <ExpoRoot context={mockContext} location={initialUrl} linking={linking} />,\n options\n );\n\n /**\n * This is a hack to ensure that React Navigation's state updates are processed before we run assertions.\n * Some updates are async and we need to wait for them to complete, otherwise will we get a false positive.\n * (that the app will briefly be in the right state, but then update to an invalid state)\n */\n store.subscribeToRootState(() => jest.runOnlyPendingTimers());\n\n return Object.assign(result, {\n getPathname(this: RenderResult): string {\n return store.routeInfoSnapshot().pathname;\n },\n getSegments(this: RenderResult): string[] {\n return store.routeInfoSnapshot().segments;\n },\n getSearchParams(this: RenderResult): Record<string, string | string[]> {\n return store.routeInfoSnapshot().params;\n },\n getPathnameWithParams(this: RenderResult): string {\n return getPathFromState(store.rootState!, store.linking!.config);\n },\n getRouterState(this: RenderResult) {\n return store.rootStateSnapshot();\n },\n });\n}\n\nexport const testRouter = {\n /** Navigate to the provided pathname and the pathname */\n navigate(path: string) {\n act(() => router.navigate(path));\n expect(screen).toHavePathnameWithParams(path);\n },\n /** Push the provided pathname and assert the pathname */\n push(path: string) {\n act(() => router.push(path));\n expect(screen).toHavePathnameWithParams(path);\n },\n /** Replace with provided pathname and assert the pathname */\n replace(path: string) {\n act(() => router.replace(path));\n expect(screen).toHavePathnameWithParams(path);\n },\n /** Go back in history and asset the new pathname */\n back(path?: string) {\n expect(router.canGoBack()).toBe(true);\n act(() => router.back());\n if (path) {\n expect(screen).toHavePathnameWithParams(path);\n }\n },\n /** If there's history that supports invoking the `back` function. */\n canGoBack() {\n return router.canGoBack();\n },\n /** Update the current route query params and assert the new pathname */\n setParams(params: Record<string, string>, path?: string) {\n router.setParams(params);\n if (path) {\n expect(screen).toHavePathnameWithParams(path);\n }\n },\n /** If there's history that supports invoking the `back` function. */\n dismissAll() {\n act(() => router.dismissAll());\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAO1C,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAO1C,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,cAAc,UAiChE"}
|
|
@@ -16,7 +16,7 @@ function getTypedRoutesDeclarationFile(ctx) {
|
|
|
16
16
|
ignoreEntryPoints: true,
|
|
17
17
|
ignoreRequireErrors: true,
|
|
18
18
|
importMode: 'async',
|
|
19
|
-
}), staticRoutes, dynamicRoutes, dynamicRouteContextKeys);
|
|
19
|
+
}), '', staticRoutes, dynamicRoutes, dynamicRouteContextKeys);
|
|
20
20
|
return `/* eslint-disable */
|
|
21
21
|
import * as Router from 'expo-router';
|
|
22
22
|
|
|
@@ -37,24 +37,25 @@ exports.getTypedRoutesDeclarationFile = getTypedRoutesDeclarationFile;
|
|
|
37
37
|
/**
|
|
38
38
|
* Walks a RouteNode tree and adds the routes to the provided sets
|
|
39
39
|
*/
|
|
40
|
-
function walkRouteNode(routeNode, staticRoutes, dynamicRoutes, dynamicRouteContextKeys) {
|
|
40
|
+
function walkRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, dynamicRouteContextKeys) {
|
|
41
41
|
if (!routeNode)
|
|
42
42
|
return;
|
|
43
|
-
addRouteNode(routeNode, staticRoutes, dynamicRoutes, dynamicRouteContextKeys);
|
|
43
|
+
addRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, dynamicRouteContextKeys);
|
|
44
|
+
parentRoutePath = `${(0, matchers_1.removeSupportedExtensions)(`${parentRoutePath}/${routeNode.route}`).replace(/\/?index$/, '')}`; // replace /index with /
|
|
44
45
|
for (const child of routeNode.children) {
|
|
45
|
-
walkRouteNode(child, staticRoutes, dynamicRoutes, dynamicRouteContextKeys);
|
|
46
|
+
walkRouteNode(child, parentRoutePath, staticRoutes, dynamicRoutes, dynamicRouteContextKeys);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Given a RouteNode, adds the route to the correct sets
|
|
50
51
|
* Modifies the RouteNode.route to be a typed-route string
|
|
51
52
|
*/
|
|
52
|
-
function addRouteNode(routeNode, staticRoutes, dynamicRoutes, dynamicRouteContextKeys) {
|
|
53
|
+
function addRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, dynamicRouteContextKeys) {
|
|
53
54
|
if (!routeNode?.route)
|
|
54
55
|
return;
|
|
55
56
|
if (!(0, matchers_1.isTypedRoute)(routeNode.route))
|
|
56
57
|
return;
|
|
57
|
-
let routePath = `${(0, matchers_1.removeSupportedExtensions)(routeNode.route).replace(/\/?index$/, '')}`; // replace /index with /
|
|
58
|
+
let routePath = `${parentRoutePath}/${(0, matchers_1.removeSupportedExtensions)(routeNode.route).replace(/\/?index$/, '')}`; // replace /index with /
|
|
58
59
|
if (!routePath.startsWith('/')) {
|
|
59
60
|
routePath = `/${routePath}`;
|
|
60
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":";;;AACA,4CAAyC;AACzC,0CAAsE;AAGtE,oCAAoC;AACpC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,6BAA6B;AAC7B,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,SAAgB,6BAA6B,CAAC,GAAmB;I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CAAC,YAAY,GAAG,CAAC,EAAE,YAAY,CAAC,CAAC;QACzC,QAAQ,CAAC,YAAY,GAAG,CAAC,EAAE,WAAW,CAAC,CAAC;IAC1C,CAAC;IAED,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACtB,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { RouteNode } from '../Route';\nimport { getRoutes } from '../getRoutes';\nimport { isTypedRoute, removeSupportedExtensions } from '../matchers';\nimport { RequireContext } from '../types';\n\n// /[...param1]/ - Match [...param1]\nconst CATCH_ALL = /\\[\\.\\.\\..+?\\]/g;\n// /[param1] - Match [param1]\nconst SLUG = /\\[.+?\\]/g;\n\nexport function getTypedRoutesDeclarationFile(ctx: RequireContext) {\n const staticRoutes = new Set<string>();\n const dynamicRoutes = new Set<string>();\n const dynamicRouteContextKeys = new Set<string>();\n\n walkRouteNode(\n getRoutes(ctx, {\n platformRoutes: false, // We don't need to generate platform specific routes\n ignoreEntryPoints: true,\n ignoreRequireErrors: true,\n importMode: 'async',\n }),\n '',\n staticRoutes,\n dynamicRoutes,\n dynamicRouteContextKeys\n );\n\n return `/* eslint-disable */\nimport * as Router from 'expo-router';\n\nexport * from 'expo-router';\n\ndeclare module 'expo-router' {\n export namespace ExpoRouter {\n export interface __routes<T extends string = string> extends Record<string, unknown> {\n StaticRoutes: ${setToUnionType(staticRoutes)};\n DynamicRoutes: ${setToUnionType(dynamicRoutes)};\n DynamicRouteTemplate: ${setToUnionType(dynamicRouteContextKeys)};\n }\n }\n}\n`;\n}\n\n/**\n * Walks a RouteNode tree and adds the routes to the provided sets\n */\nfunction walkRouteNode(\n routeNode: RouteNode | null,\n parentRoutePath: string,\n staticRoutes: Set<string>,\n dynamicRoutes: Set<string>,\n dynamicRouteContextKeys: Set<string>\n) {\n if (!routeNode) return;\n\n addRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, dynamicRouteContextKeys);\n\n parentRoutePath = `${removeSupportedExtensions(`${parentRoutePath}/${routeNode.route}`).replace(/\\/?index$/, '')}`; // replace /index with /\n\n for (const child of routeNode.children) {\n walkRouteNode(child, parentRoutePath, staticRoutes, dynamicRoutes, dynamicRouteContextKeys);\n }\n}\n\n/**\n * Given a RouteNode, adds the route to the correct sets\n * Modifies the RouteNode.route to be a typed-route string\n */\nfunction addRouteNode(\n routeNode: RouteNode | null,\n parentRoutePath: string,\n staticRoutes: Set<string>,\n dynamicRoutes: Set<string>,\n dynamicRouteContextKeys: Set<string>\n) {\n if (!routeNode?.route) return;\n if (!isTypedRoute(routeNode.route)) return;\n\n let routePath = `${parentRoutePath}/${removeSupportedExtensions(routeNode.route).replace(/\\/?index$/, '')}`; // replace /index with /\n\n if (!routePath.startsWith('/')) {\n routePath = `/${routePath}`;\n }\n\n if (routeNode.dynamic) {\n for (const path of generateCombinations(routePath)) {\n dynamicRouteContextKeys.add(path);\n dynamicRoutes.add(\n `${path.replaceAll(CATCH_ALL, '${string}').replaceAll(SLUG, '${Router.SingleRoutePart<T>}')}`\n );\n }\n } else {\n for (const combination of generateCombinations(routePath)) {\n staticRoutes.add(combination);\n }\n }\n}\n\n/**\n * Converts a Set to a TypeScript union type\n */\nconst setToUnionType = <T>(set: Set<T>) => {\n return set.size > 0\n ? [...set]\n .sort()\n .map((s) => `\\`${s}\\``)\n .join(' | ')\n : 'never';\n};\n\nfunction generateCombinations(pathname) {\n const groups = pathname.split('/').filter((part) => part.startsWith('(') && part.endsWith(')'));\n const combinations: string[] = [];\n\n function generate(currentIndex, currentPath) {\n if (currentIndex === groups.length) {\n combinations.push(currentPath.replace(/\\/{2,}/g, '/'));\n return;\n }\n\n const group = groups[currentIndex];\n const withoutGroup = currentPath.replace(`/${group}`, '');\n generate(currentIndex + 1, withoutGroup);\n generate(currentIndex + 1, currentPath);\n }\n\n generate(0, pathname);\n return combinations;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-router",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.22",
|
|
4
4
|
"description": "Expo Router is a file-based router for React Native and web applications.",
|
|
5
5
|
"author": "650 Industries, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"tsd": "^0.28.1"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@expo/metro-runtime": "3.2.
|
|
95
|
+
"@expo/metro-runtime": "3.2.2",
|
|
96
96
|
"@expo/server": "^0.4.0",
|
|
97
97
|
"@radix-ui/react-slot": "1.0.1",
|
|
98
98
|
"@react-navigation/bottom-tabs": "~6.5.7",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"react-native-helmet-async": "2.0.4",
|
|
103
103
|
"schema-utils": "^4.0.1"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "bdade2924f40eabd1944bb2c96623e3f90606aef"
|
|
106
106
|
}
|