expo-router 5.1.0 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
  2. package/build/fork/getStateFromPath-forks.js +4 -1
  3. package/build/fork/getStateFromPath-forks.js.map +1 -1
  4. package/build/getRoutes.d.ts +1 -1
  5. package/build/getRoutes.d.ts.map +1 -1
  6. package/build/getRoutes.js +14 -6
  7. package/build/getRoutes.js.map +1 -1
  8. package/build/getRoutesCore.d.ts +7 -2
  9. package/build/getRoutesCore.d.ts.map +1 -1
  10. package/build/getRoutesCore.js +86 -58
  11. package/build/getRoutesCore.js.map +1 -1
  12. package/build/getRoutesRedirects.d.ts +2 -2
  13. package/build/getRoutesRedirects.d.ts.map +1 -1
  14. package/build/getRoutesRedirects.js +18 -24
  15. package/build/getRoutesRedirects.js.map +1 -1
  16. package/build/getRoutesSSR.d.ts +1 -1
  17. package/build/getRoutesSSR.d.ts.map +1 -1
  18. package/build/getRoutesSSR.js +2 -3
  19. package/build/getRoutesSSR.js.map +1 -1
  20. package/build/global-state/routeInfo.d.ts.map +1 -1
  21. package/build/global-state/routeInfo.js +21 -1
  22. package/build/global-state/routeInfo.js.map +1 -1
  23. package/build/global-state/router-store.d.ts.map +1 -1
  24. package/build/global-state/router-store.js +1 -0
  25. package/build/global-state/router-store.js.map +1 -1
  26. package/build/layouts/StackClient.d.ts.map +1 -1
  27. package/build/layouts/StackClient.js +152 -65
  28. package/build/layouts/StackClient.js.map +1 -1
  29. package/build/link/Link.d.ts +1 -56
  30. package/build/link/Link.d.ts.map +1 -1
  31. package/build/link/Link.js +3 -39
  32. package/build/link/Link.js.map +1 -1
  33. package/build/link/Redirect.d.ts +59 -0
  34. package/build/link/Redirect.d.ts.map +1 -0
  35. package/build/link/Redirect.js +43 -0
  36. package/build/link/Redirect.js.map +1 -0
  37. package/build/typed-routes/generate.js +1 -1
  38. package/build/typed-routes/generate.js.map +1 -1
  39. package/build/useFocusEffect.d.ts.map +1 -1
  40. package/build/useFocusEffect.js +5 -3
  41. package/build/useFocusEffect.js.map +1 -1
  42. package/build/useScreens.d.ts +1 -3
  43. package/build/useScreens.d.ts.map +1 -1
  44. package/build/useScreens.js +2 -2
  45. package/build/useScreens.js.map +1 -1
  46. package/build/utils/stack.d.ts +5 -0
  47. package/build/utils/stack.d.ts.map +1 -0
  48. package/build/utils/stack.js +10 -0
  49. package/build/utils/stack.js.map +1 -0
  50. package/build/views/Screen.d.ts.map +1 -1
  51. package/build/views/Screen.js +13 -40
  52. package/build/views/Screen.js.map +1 -1
  53. package/build/views/Unmatched.d.ts.map +1 -1
  54. package/build/views/Unmatched.js +9 -3
  55. package/build/views/Unmatched.js.map +1 -1
  56. package/build/views/useSafeLayoutEffect.d.ts +3 -0
  57. package/build/views/useSafeLayoutEffect.d.ts.map +1 -0
  58. package/build/views/useSafeLayoutEffect.js +6 -0
  59. package/build/views/useSafeLayoutEffect.js.map +1 -0
  60. package/package.json +3 -3
  61. package/plugin/options.json +29 -1
  62. package/plugin/tsconfig.tsbuildinfo +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"getStateFromPath-forks.d.ts","sourceRoot":"","sources":["../../src/fork/getStateFromPath-forks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGhG,MAAM,MAAM,WAAW,GAAG;IACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACtC,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,O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BnF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAK5F;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAM,GAAG,SAAqC,UAQxD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE;;UAjNhD,QAAQ,GAAG,SAAS,GAAG,QAAQ;sBACnB,MAAM;aACf,OAAO;gBACJ,OAAO;iBACN,OAAO;wBACA,MAAM,EAAE;WACrB,MAAM,EAAE;qBACE,MAAM;;;;;;;;cA0OxB;AAED,wBAAgB,eAAe,CAAC,aAAa,EAAE,kBAAkB,EAAE,IAKhD,QAAQ,WAAW,iBAMrC;AAQD,wBAAgB,oBAAoB,CAAC,gBAAgB,GAAE,MAAM,EAAO,IACtC,GAAG,WAAW,EAAE,GAAG,WAAW,YA2J3D;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,EAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC,EACpD,IAAI,CAAC,EAAE,MAAM,iDA4Bd;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,UAUrC;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,UAelD"}
@@ -404,7 +404,10 @@ function routePatternToRegex(pattern) {
404
404
  return new RegExp(`^(${pattern
405
405
  .split('/')
406
406
  .map((it) => {
407
- if (it.startsWith(':')) {
407
+ if (it.startsWith('(') && it.endsWith(')')) {
408
+ return `${it}?`;
409
+ }
410
+ else if (it.startsWith(':')) {
408
411
  return `(([^/]+\\/)${it.endsWith('?') ? '?' : ''})`;
409
412
  }
410
413
  return `${it === '*' ? '.*' : (0, escape_string_regexp_1.default)(it)}\\/`;
@@ -1 +1 @@
1
- {"version":3,"file":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O;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QACV,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QACtD,CAAC;QAED,OAAO,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,8BAAM,EAAC,EAAE,CAAC,KAAK,CAAC;IAChD,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,GAAG,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { InitialState } from '@react-navigation/native';\nimport escape from 'escape-string-regexp';\nimport * as queryString from 'query-string';\n\nimport type { InitialRouteConfig, Options, ParsedRoute, RouteConfig } from './getStateFromPath';\nimport { matchGroupName, stripGroupSegmentsFromPath } from '../matchers';\n\nexport type ExpoOptions = {\n previousSegments?: string[];\n};\n\nexport type ExpoRouteConfig = {\n type: 'static' | 'dynamic' | 'layout';\n userReadableName: string;\n isIndex: boolean;\n isInitial?: boolean;\n hasChildren: boolean;\n expandedRouteNames: string[];\n parts: string[];\n staticPartCount: number;\n};\n\n/**\n * In Expo Router, the params are available at all levels of the routing config\n * @param routes\n * @returns\n */\nexport function populateParams(routes?: ParsedRoute[], params?: Record<string, any>) {\n if (!routes || !params || Object.keys(params).length === 0) return;\n\n for (const route of routes) {\n Object.assign(route, { params });\n }\n\n return routes;\n}\n\nexport function safelyDecodeURIComponent(str: string) {\n try {\n return decodeURIComponent(str);\n } catch {\n return str;\n }\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 path,\n cleanUrl: '',\n nonstandardPathname: '',\n url: new URL('https://phony.example'),\n };\n }\n\n const pathname = parsed.pathname;\n const withoutBaseUrl = stripBaseUrl(pathname, baseUrl);\n const pathWithoutGroups = stripGroupSegmentsFromPath(stripBaseUrl(path, baseUrl));\n\n // Make sure there is a trailing slash\n return {\n // The slashes are at the end, not the beginning\n path,\n nonstandardPathname: withoutBaseUrl.replace(/^\\/+/g, '').replace(/\\/+$/g, '') + '/',\n url: parsed,\n pathWithoutGroups,\n };\n}\n\nexport function createConfig(\n screen: string,\n pattern: string,\n routeNames: string[],\n config: Record<string, any> = {}\n): Omit<ExpoRouteConfig, 'isInitial'> {\n const parts: string[] = [];\n let isDynamic = false;\n const isIndex = screen === 'index' || screen.endsWith('/index');\n let staticPartCount = 0;\n\n for (const part of pattern.split('/')) {\n if (part) {\n // If any part is dynamic, then the route is dynamic\n const isDynamicPart =\n part.startsWith(':') || part.startsWith('*') || part.includes('*not-found');\n\n isDynamic ||= isDynamicPart;\n\n if (!matchGroupName(part)) {\n parts.push(part);\n\n if (!isDynamicPart) {\n staticPartCount++;\n }\n }\n }\n }\n\n const hasChildren = config.screens ? !!Object.keys(config.screens)?.length : false;\n const type = hasChildren ? 'layout' : isDynamic ? 'dynamic' : 'static';\n\n if (isIndex) {\n parts.push('index');\n staticPartCount++;\n }\n\n return {\n type,\n isIndex,\n hasChildren,\n parts,\n staticPartCount,\n userReadableName: [...routeNames.slice(0, -1), config.path || screen].join('/'),\n // Don't include the __root route name\n expandedRouteNames: routeNames.slice(1).flatMap((name) => {\n return name.split('/');\n }),\n };\n}\n\nexport function assertScreens(options?: Options<object>): asserts options is Options<object> {\n if (!options?.screens) {\n throw Error(\"You must pass a 'screens' object to 'getStateFromPath' to generate a path.\");\n }\n}\n\nexport function configRegExp(config: RouteConfig) {\n return config.pattern\n ? new RegExp(`^(${config.pattern.split('/').map(formatRegexPattern).join('')})$`)\n : undefined;\n}\n\nexport function isDynamicPart(p: string) {\n return p.length > 1 && (p.startsWith(':') || p.startsWith('*'));\n}\n\nexport function replacePart(p: string) {\n return p.replace(/^[:*]/, '').replace(/\\?$/, '');\n}\n\nexport function getParamValue(p: string, value: string) {\n if (p.startsWith('*')) {\n const values = value.split('/').filter((v) => v !== '');\n return values.length === 0 && p.endsWith('?') ? undefined : values;\n } else {\n return value;\n }\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\nexport function handleUrlParams(route: ParsedRoute, params?: queryString.ParsedQuery) {\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\nexport function spreadParamsAcrossAllStates(state: InitialState, params?: Record<string, any>) {\n while (state) {\n const route = state.routes[0];\n (route as any).params = Object.assign({}, route.params, params);\n }\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 return path.replace(/^\\/+/g, '/').replace(new RegExp(`^\\\\/?${escape(baseUrl)}`, 'g'), '');\n }\n }\n return path;\n}\n\nexport function matchForEmptyPath(configs: RouteConfig[]) {\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 return match;\n}\n\nexport function appendIsInitial(initialRoutes: InitialRouteConfig[]) {\n const resolvedInitialPatterns = initialRoutes.map((route) =>\n joinPaths(...route.parentScreens, route.initialRouteName)\n );\n\n return function (config: RouteConfig) {\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 config.isInitial = resolvedInitialPatterns.includes(config.routeNames.join('/'));\n return config;\n };\n}\n\nconst joinPaths = (...paths: string[]): string =>\n ([] as string[])\n .concat(...paths.map((p) => p.split('/')))\n .filter(Boolean)\n .join('/');\n\nexport function getRouteConfigSorter(previousSegments: string[] = []) {\n return function sortConfigs(a: RouteConfig, b: RouteConfig) {\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 /*\n * If one of the patterns starts with the other, it is earlier in the config sorting.\n * However, configs are a mix of route configs and layout configs\n * e.g There will be a config for `/(group)`, but maybe there isn't a `/(group)/index.tsx`\n *\n * This is because you can navigate to a directory and its navigator will determine the route\n * These routes should be later in the config sorting, as their patterns are very open\n * and will prevent routes from being matched\n *\n * Therefore before we compare segment parts, we force these layout configs later in the sorting\n *\n * NOTE(marklawlor): Is this a feature we want? I'm unsure if this is a gimmick or a feature.\n */\n if (a.pattern.startsWith(b.pattern) && !b.isIndex) {\n return -1;\n }\n\n if (b.pattern.startsWith(a.pattern) && !a.isIndex) {\n return 1;\n }\n\n /*\n * Static routes should always be higher than dynamic and layout routes.\n */\n if (a.type === 'static' && b.type !== 'static') {\n return -1;\n } else if (a.type !== 'static' && b.type === 'static') {\n return 1;\n }\n\n /*\n * If the routes have any static segments, the one the most static segments should be higher\n */\n if (a.staticPartCount !== b.staticPartCount) {\n return b.staticPartCount - a.staticPartCount;\n }\n\n /*\n * If both are static/dynamic or a layout file, then we check group similarity\n */\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 // One matches more than the other, so pick the one that matches more\n return similarToPreviousB.length - similarToPreviousA.length;\n }\n\n /*\n * If there is not difference in similarity, then each non-group segment is compared against each other\n */\n for (let i = 0; i < Math.max(a.parts.length, b.parts.length); i++) {\n // if b is longer, b get higher priority\n if (a.parts[i] == null) {\n return 1;\n }\n // if a is longer, a get higher priority\n if (b.parts[i] == null) {\n return -1;\n }\n\n const aWildCard = a.parts[i].startsWith('*');\n const bWildCard = b.parts[i].startsWith('*');\n // if both are wildcard we compare next component\n if (aWildCard && bWildCard) {\n const aNotFound = a.parts[i].match(/^[*]not-found$/);\n const bNotFound = b.parts[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 = a.parts[i].startsWith(':');\n const bSlug = b.parts[i].startsWith(':');\n // if both are wildcard we compare next component\n if (aSlug && bSlug) {\n const aNotFound = a.parts[i].match(/^[*]not-found$/);\n const bNotFound = b.parts[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 /*\n * Both configs are identical in specificity and segments count/type\n * Try and sort by initial instead.\n *\n * TODO: We don't differentiate between the default initialRoute and group specific default routes\n *\n * const unstable_settings = {\n * \"group\": {\n * initialRouteName: \"article\"\n * }\n * }\n *\n * \"article\" will be ranked higher because its an initialRoute for a group - even if not your not currently in\n * that group. The current work around is to ways provide initialRouteName for all groups\n */\n if (a.isInitial && !b.isInitial) {\n return -1;\n } else if (!a.isInitial && b.isInitial) {\n return 1;\n }\n\n return b.parts.length - a.parts.length;\n };\n}\n\nexport function parseQueryParams(\n path: string,\n route: ParsedRoute,\n parseConfig?: Record<string, (value: string) => any>,\n hash?: string\n) {\n const searchParams = new URL(path, 'https://phony.example').searchParams;\n const params: Record<string, string | string[]> = Object.create(null);\n\n if (hash) {\n params['#'] = hash.slice(1);\n }\n\n for (const name of searchParams.keys()) {\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 } else {\n const values = parseConfig?.hasOwnProperty(name)\n ? searchParams.getAll(name).map((value) => parseConfig[name](value))\n : searchParams.getAll(name);\n\n // searchParams.getAll returns an array.\n // if we only have a single value, and its not an array param, we need to extract the value\n params[name] = values.length === 1 ? values[0] : values;\n }\n }\n\n return Object.keys(params).length ? params : undefined;\n}\n\nexport function cleanPath(path: string) {\n path = path\n // let remaining = path\n // END FORK\n .replace(/\\/+/g, '/') // Replace multiple slash (//) with single ones\n .replace(/^\\//, '') // Remove extra leading slash\n .replace(/\\?.*$/, ''); // Remove query params which we will handle later\n\n // Make sure there is a trailing slash\n return path.endsWith('/') ? path : `${path}/`;\n}\n\nexport function routePatternToRegex(pattern: string) {\n return new RegExp(\n `^(${pattern\n .split('/')\n .map((it) => {\n if (it.startsWith(':')) {\n return `(([^/]+\\\\/)${it.endsWith('?') ? '?' : ''})`;\n }\n\n return `${it === '*' ? '.*' : escape(it)}\\\\/`;\n })\n .join('')})`\n );\n}\n"]}
1
+ {"version":3,"file":"getStateFromPath-forks.js","sourceRoot":"","sources":["../../src/fork/getStateFromPath-forks.ts"],"names":[],"mappings":";;;;;AA2BA,wCAQC;AAED,4DAMC;AAED,oFA6BC;AAED,oCAiDC;AAED,sCAIC;AAED,oCAIC;AAED,sCAEC;AAED,kCAEC;AAED,sCAOC;AAwBD,0CAsBC;AAED,kEAKC;AAED,oCAUC;AAED,8CAgCC;AAED,0CAWC;AAQD,oDA4JC;AAED,4CAgCC;AAED,8BAUC;AAED,kDAeC;AA5eD,gFAA0C;AAI1C,0CAAyE;AAiBzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,MAAsB,EAAE,MAA4B;IACjF,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEnE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,wBAAwB,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AAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC;AAED,SAAgB,SAAS,CAAC,IAAY;IACpC,IAAI,GAAG,IAAI;QACT,uBAAuB;QACvB,WAAW;SACV,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,+CAA+C;SACpE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,6BAA6B;SAChD,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,iDAAiD;IAE1E,sCAAsC;IACtC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;AAChD,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAAe;IACjD,OAAO,IAAI,MAAM,CACf,KAAK,OAAO;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QACV,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3C,OAAO,GAAG,EAAE,GAAG,CAAC;QAClB,CAAC;aAAM,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QACtD,CAAC;QAED,OAAO,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,8BAAM,EAAC,EAAE,CAAC,KAAK,CAAC;IAChD,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,GAAG,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { InitialState } from '@react-navigation/native';\nimport escape from 'escape-string-regexp';\nimport * as queryString from 'query-string';\n\nimport type { InitialRouteConfig, Options, ParsedRoute, RouteConfig } from './getStateFromPath';\nimport { matchGroupName, stripGroupSegmentsFromPath } from '../matchers';\n\nexport type ExpoOptions = {\n previousSegments?: string[];\n};\n\nexport type ExpoRouteConfig = {\n type: 'static' | 'dynamic' | 'layout';\n userReadableName: string;\n isIndex: boolean;\n isInitial?: boolean;\n hasChildren: boolean;\n expandedRouteNames: string[];\n parts: string[];\n staticPartCount: number;\n};\n\n/**\n * In Expo Router, the params are available at all levels of the routing config\n * @param routes\n * @returns\n */\nexport function populateParams(routes?: ParsedRoute[], params?: Record<string, any>) {\n if (!routes || !params || Object.keys(params).length === 0) return;\n\n for (const route of routes) {\n Object.assign(route, { params });\n }\n\n return routes;\n}\n\nexport function safelyDecodeURIComponent(str: string) {\n try {\n return decodeURIComponent(str);\n } catch {\n return str;\n }\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 path,\n cleanUrl: '',\n nonstandardPathname: '',\n url: new URL('https://phony.example'),\n };\n }\n\n const pathname = parsed.pathname;\n const withoutBaseUrl = stripBaseUrl(pathname, baseUrl);\n const pathWithoutGroups = stripGroupSegmentsFromPath(stripBaseUrl(path, baseUrl));\n\n // Make sure there is a trailing slash\n return {\n // The slashes are at the end, not the beginning\n path,\n nonstandardPathname: withoutBaseUrl.replace(/^\\/+/g, '').replace(/\\/+$/g, '') + '/',\n url: parsed,\n pathWithoutGroups,\n };\n}\n\nexport function createConfig(\n screen: string,\n pattern: string,\n routeNames: string[],\n config: Record<string, any> = {}\n): Omit<ExpoRouteConfig, 'isInitial'> {\n const parts: string[] = [];\n let isDynamic = false;\n const isIndex = screen === 'index' || screen.endsWith('/index');\n let staticPartCount = 0;\n\n for (const part of pattern.split('/')) {\n if (part) {\n // If any part is dynamic, then the route is dynamic\n const isDynamicPart =\n part.startsWith(':') || part.startsWith('*') || part.includes('*not-found');\n\n isDynamic ||= isDynamicPart;\n\n if (!matchGroupName(part)) {\n parts.push(part);\n\n if (!isDynamicPart) {\n staticPartCount++;\n }\n }\n }\n }\n\n const hasChildren = config.screens ? !!Object.keys(config.screens)?.length : false;\n const type = hasChildren ? 'layout' : isDynamic ? 'dynamic' : 'static';\n\n if (isIndex) {\n parts.push('index');\n staticPartCount++;\n }\n\n return {\n type,\n isIndex,\n hasChildren,\n parts,\n staticPartCount,\n userReadableName: [...routeNames.slice(0, -1), config.path || screen].join('/'),\n // Don't include the __root route name\n expandedRouteNames: routeNames.slice(1).flatMap((name) => {\n return name.split('/');\n }),\n };\n}\n\nexport function assertScreens(options?: Options<object>): asserts options is Options<object> {\n if (!options?.screens) {\n throw Error(\"You must pass a 'screens' object to 'getStateFromPath' to generate a path.\");\n }\n}\n\nexport function configRegExp(config: RouteConfig) {\n return config.pattern\n ? new RegExp(`^(${config.pattern.split('/').map(formatRegexPattern).join('')})$`)\n : undefined;\n}\n\nexport function isDynamicPart(p: string) {\n return p.length > 1 && (p.startsWith(':') || p.startsWith('*'));\n}\n\nexport function replacePart(p: string) {\n return p.replace(/^[:*]/, '').replace(/\\?$/, '');\n}\n\nexport function getParamValue(p: string, value: string) {\n if (p.startsWith('*')) {\n const values = value.split('/').filter((v) => v !== '');\n return values.length === 0 && p.endsWith('?') ? undefined : values;\n } else {\n return value;\n }\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\nexport function handleUrlParams(route: ParsedRoute, params?: queryString.ParsedQuery) {\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\nexport function spreadParamsAcrossAllStates(state: InitialState, params?: Record<string, any>) {\n while (state) {\n const route = state.routes[0];\n (route as any).params = Object.assign({}, route.params, params);\n }\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 return path.replace(/^\\/+/g, '/').replace(new RegExp(`^\\\\/?${escape(baseUrl)}`, 'g'), '');\n }\n }\n return path;\n}\n\nexport function matchForEmptyPath(configs: RouteConfig[]) {\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 return match;\n}\n\nexport function appendIsInitial(initialRoutes: InitialRouteConfig[]) {\n const resolvedInitialPatterns = initialRoutes.map((route) =>\n joinPaths(...route.parentScreens, route.initialRouteName)\n );\n\n return function (config: RouteConfig) {\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 config.isInitial = resolvedInitialPatterns.includes(config.routeNames.join('/'));\n return config;\n };\n}\n\nconst joinPaths = (...paths: string[]): string =>\n ([] as string[])\n .concat(...paths.map((p) => p.split('/')))\n .filter(Boolean)\n .join('/');\n\nexport function getRouteConfigSorter(previousSegments: string[] = []) {\n return function sortConfigs(a: RouteConfig, b: RouteConfig) {\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 /*\n * If one of the patterns starts with the other, it is earlier in the config sorting.\n * However, configs are a mix of route configs and layout configs\n * e.g There will be a config for `/(group)`, but maybe there isn't a `/(group)/index.tsx`\n *\n * This is because you can navigate to a directory and its navigator will determine the route\n * These routes should be later in the config sorting, as their patterns are very open\n * and will prevent routes from being matched\n *\n * Therefore before we compare segment parts, we force these layout configs later in the sorting\n *\n * NOTE(marklawlor): Is this a feature we want? I'm unsure if this is a gimmick or a feature.\n */\n if (a.pattern.startsWith(b.pattern) && !b.isIndex) {\n return -1;\n }\n\n if (b.pattern.startsWith(a.pattern) && !a.isIndex) {\n return 1;\n }\n\n /*\n * Static routes should always be higher than dynamic and layout routes.\n */\n if (a.type === 'static' && b.type !== 'static') {\n return -1;\n } else if (a.type !== 'static' && b.type === 'static') {\n return 1;\n }\n\n /*\n * If the routes have any static segments, the one the most static segments should be higher\n */\n if (a.staticPartCount !== b.staticPartCount) {\n return b.staticPartCount - a.staticPartCount;\n }\n\n /*\n * If both are static/dynamic or a layout file, then we check group similarity\n */\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 // One matches more than the other, so pick the one that matches more\n return similarToPreviousB.length - similarToPreviousA.length;\n }\n\n /*\n * If there is not difference in similarity, then each non-group segment is compared against each other\n */\n for (let i = 0; i < Math.max(a.parts.length, b.parts.length); i++) {\n // if b is longer, b get higher priority\n if (a.parts[i] == null) {\n return 1;\n }\n // if a is longer, a get higher priority\n if (b.parts[i] == null) {\n return -1;\n }\n\n const aWildCard = a.parts[i].startsWith('*');\n const bWildCard = b.parts[i].startsWith('*');\n // if both are wildcard we compare next component\n if (aWildCard && bWildCard) {\n const aNotFound = a.parts[i].match(/^[*]not-found$/);\n const bNotFound = b.parts[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 = a.parts[i].startsWith(':');\n const bSlug = b.parts[i].startsWith(':');\n // if both are wildcard we compare next component\n if (aSlug && bSlug) {\n const aNotFound = a.parts[i].match(/^[*]not-found$/);\n const bNotFound = b.parts[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 /*\n * Both configs are identical in specificity and segments count/type\n * Try and sort by initial instead.\n *\n * TODO: We don't differentiate between the default initialRoute and group specific default routes\n *\n * const unstable_settings = {\n * \"group\": {\n * initialRouteName: \"article\"\n * }\n * }\n *\n * \"article\" will be ranked higher because its an initialRoute for a group - even if not your not currently in\n * that group. The current work around is to ways provide initialRouteName for all groups\n */\n if (a.isInitial && !b.isInitial) {\n return -1;\n } else if (!a.isInitial && b.isInitial) {\n return 1;\n }\n\n return b.parts.length - a.parts.length;\n };\n}\n\nexport function parseQueryParams(\n path: string,\n route: ParsedRoute,\n parseConfig?: Record<string, (value: string) => any>,\n hash?: string\n) {\n const searchParams = new URL(path, 'https://phony.example').searchParams;\n const params: Record<string, string | string[]> = Object.create(null);\n\n if (hash) {\n params['#'] = hash.slice(1);\n }\n\n for (const name of searchParams.keys()) {\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 } else {\n const values = parseConfig?.hasOwnProperty(name)\n ? searchParams.getAll(name).map((value) => parseConfig[name](value))\n : searchParams.getAll(name);\n\n // searchParams.getAll returns an array.\n // if we only have a single value, and its not an array param, we need to extract the value\n params[name] = values.length === 1 ? values[0] : values;\n }\n }\n\n return Object.keys(params).length ? params : undefined;\n}\n\nexport function cleanPath(path: string) {\n path = path\n // let remaining = path\n // END FORK\n .replace(/\\/+/g, '/') // Replace multiple slash (//) with single ones\n .replace(/^\\//, '') // Remove extra leading slash\n .replace(/\\?.*$/, ''); // Remove query params which we will handle later\n\n // Make sure there is a trailing slash\n return path.endsWith('/') ? path : `${path}/`;\n}\n\nexport function routePatternToRegex(pattern: string) {\n return new RegExp(\n `^(${pattern\n .split('/')\n .map((it) => {\n if (it.startsWith('(') && it.endsWith(')')) {\n return `${it}?`;\n } else if (it.startsWith(':')) {\n return `(([^/]+\\\\/)${it.endsWith('?') ? '?' : ''})`;\n }\n\n return `${it === '*' ? '.*' : escape(it)}\\\\/`;\n })\n .join('')})`\n );\n}\n"]}
@@ -16,5 +16,5 @@ export type Options = Omit<OptionsCore, 'getSystemRoute'>;
16
16
  */
17
17
  export declare function getRoutes(contextModule: RequireContext, options?: Options): RouteNode | null;
18
18
  export declare function getExactRoutes(contextModule: RequireContext, options?: Options): RouteNode | null;
19
- export { generateDynamic, extrapolateGroups, getIgnoreList } from './getRoutesCore';
19
+ export { generateDynamic, extrapolateGroups } from './getRoutesCore';
20
20
  //# sourceMappingURL=getRoutes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRoutes.d.ts","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAA8B,KAAK,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAC1D;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,cAAc,EAAE,OAAO,GAAE,OAAY,GAAG,SAAS,GAAG,IAAI,CAyDhG;AAED,wBAAgB,cAAc,CAC5B,aAAa,EAAE,cAAc,EAC7B,OAAO,GAAE,OAAY,GACpB,SAAS,GAAG,IAAI,CAKlB;AAED,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"getRoutes.d.ts","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAA8B,KAAK,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAC1D;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,cAAc,EAAE,OAAO,GAAE,OAAY,GAAG,SAAS,GAAG,IAAI,CAmEhG;AAED,wBAAgB,cAAc,CAC5B,aAAa,EAAE,cAAc,EAC7B,OAAO,GAAE,OAAY,GACpB,SAAS,GAAG,IAAI,CAKlB;AAED,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIgnoreList = exports.extrapolateGroups = exports.generateDynamic = void 0;
3
+ exports.extrapolateGroups = exports.generateDynamic = void 0;
4
4
  exports.getRoutes = getRoutes;
5
5
  exports.getExactRoutes = getExactRoutes;
6
6
  const getRoutesCore_1 = require("./getRoutesCore");
@@ -18,7 +18,7 @@ const getRoutesCore_1 = require("./getRoutesCore");
18
18
  */
19
19
  function getRoutes(contextModule, options = {}) {
20
20
  return (0, getRoutesCore_1.getRoutes)(contextModule, {
21
- getSystemRoute({ route, type }, defaults) {
21
+ getSystemRoute({ route, type, defaults, redirectConfig, rewriteConfig }) {
22
22
  if (route === '' && type === 'layout') {
23
23
  // Root layout when no layout is defined.
24
24
  return {
@@ -64,15 +64,24 @@ function getRoutes(contextModule, options = {}) {
64
64
  children: [],
65
65
  };
66
66
  }
67
- else if ((type === 'redirect' || type === 'rewrite') && defaults) {
67
+ else if (type === 'redirect' && redirectConfig && defaults) {
68
68
  return {
69
69
  ...defaults,
70
70
  loadRoute() {
71
- return require('./getRoutesRedirects').getRedirectModule(route);
71
+ return require('./getRoutesRedirects').getRedirectModule(redirectConfig);
72
72
  },
73
73
  };
74
74
  }
75
- throw new Error(`Unknown system route: ${route} and type: ${type}`);
75
+ else if (type === 'rewrite' && rewriteConfig && defaults) {
76
+ return {
77
+ ...defaults,
78
+ loadRoute() {
79
+ // TODO: Replace with rewrite module
80
+ return require('./getRoutesRedirects').getRedirectModule(rewriteConfig);
81
+ },
82
+ };
83
+ }
84
+ throw new Error(`Unknown system route: ${route} and type: ${type} and redirectConfig: ${redirectConfig} and rewriteConfig: ${rewriteConfig}`);
76
85
  },
77
86
  ...options,
78
87
  });
@@ -86,5 +95,4 @@ function getExactRoutes(contextModule, options = {}) {
86
95
  var getRoutesCore_2 = require("./getRoutesCore");
87
96
  Object.defineProperty(exports, "generateDynamic", { enumerable: true, get: function () { return getRoutesCore_2.generateDynamic; } });
88
97
  Object.defineProperty(exports, "extrapolateGroups", { enumerable: true, get: function () { return getRoutesCore_2.extrapolateGroups; } });
89
- Object.defineProperty(exports, "getIgnoreList", { enumerable: true, get: function () { return getRoutesCore_2.getIgnoreList; } });
90
98
  //# sourceMappingURL=getRoutes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRoutes.js","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":";;;AAiBA,8BAyDC;AAED,wCAQC;AAnFD,mDAA0F;AAI1F;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CAAC,aAA6B,EAAE,UAAmB,EAAE;IAC5E,OAAO,IAAA,yBAAa,EAAC,aAAa,EAAE;QAClC,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ;YACtC,IAAI,KAAK,KAAK,EAAE,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtC,yCAAyC;gBACzC,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;wBAChB,OAAO,EAAG,OAAO,CAAC,mBAAmB,CAAwC;6BAC1E,gBAAgB;qBACpB,CAAC;oBACF,8CAA8C;oBAC9C,UAAU,EAAE,sCAAsC;oBAClD,KAAK,EAAE,EAAE;oBACT,SAAS,EAAE,IAAI;oBACf,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,EAAE;iBACb,CAAC;YACJ,CAAC;iBAAM,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AAC,CAAC;QACtE,CAAC;QACD,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,cAAc,CAC5B,aAA6B,EAC7B,UAAmB,EAAE;IAErB,OAAO,SAAS,CAAC,aAAa,EAAE;QAC9B,GAAG,OAAO;QACV,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;AACL,CAAC;AAED,iDAAoF;AAA3E,gHAAA,eAAe,OAAA;AAAE,kHAAA,iBAAiB,OAAA;AAAE,8GAAA,aAAa,OAAA","sourcesContent":["import type { RouteNode } from './Route';\nimport { getRoutes as getRoutesCore, type Options as OptionsCore } from './getRoutesCore';\nimport type { RequireContext } from './types';\n\nexport type Options = Omit<OptionsCore, 'getSystemRoute'>;\n/**\n * Given a Metro context module, return an array of nested routes.\n *\n * This is a two step process:\n * 1. Convert the RequireContext keys (file paths) into a directory tree.\n * - This should extrapolate array syntax into multiple routes\n * - Routes are given a specificity score\n * 2. Flatten the directory tree into routes\n * - Routes in directories without _layout files are hoisted to the nearest _layout\n * - The name of the route is relative to the nearest _layout\n * - If multiple routes have the same name, the most specific route is used\n */\nexport function getRoutes(contextModule: RequireContext, options: Options = {}): RouteNode | null {\n return getRoutesCore(contextModule, {\n getSystemRoute({ route, type }, defaults) {\n if (route === '' && type === 'layout') {\n // Root layout when no layout is defined.\n return {\n type: 'layout',\n loadRoute: () => ({\n default: (require('./views/Navigator') as typeof import('./views/Navigator'))\n .DefaultNavigator,\n }),\n // Generate a fake file name for the directory\n contextKey: 'expo-router/build/views/Navigator.js',\n route: '',\n generated: true,\n dynamic: null,\n children: [],\n };\n } else if (route === '_sitemap' && type === 'route') {\n return {\n loadRoute() {\n const { Sitemap, getNavOptions } = require('./views/Sitemap');\n return { default: Sitemap, getNavOptions };\n },\n route: '_sitemap',\n type: 'route',\n contextKey: 'expo-router/build/views/Sitemap.js',\n generated: true,\n internal: true,\n dynamic: null,\n children: [],\n };\n } else if (route === '+not-found' && type === 'route') {\n return {\n loadRoute() {\n return { default: require('./views/Unmatched').Unmatched };\n },\n type: 'route',\n route: '+not-found',\n contextKey: 'expo-router/build/views/Unmatched.js',\n generated: true,\n internal: true,\n dynamic: [{ name: '+not-found', deep: true, notFound: true }],\n children: [],\n };\n } else if ((type === 'redirect' || type === 'rewrite') && defaults) {\n return {\n ...defaults,\n loadRoute() {\n return require('./getRoutesRedirects').getRedirectModule(route);\n },\n };\n }\n throw new Error(`Unknown system route: ${route} and type: ${type}`);\n },\n ...options,\n });\n}\n\nexport function getExactRoutes(\n contextModule: RequireContext,\n options: Options = {}\n): RouteNode | null {\n return getRoutes(contextModule, {\n ...options,\n skipGenerated: true,\n });\n}\n\nexport { generateDynamic, extrapolateGroups, getIgnoreList } from './getRoutesCore';\n"]}
1
+ {"version":3,"file":"getRoutes.js","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":";;;AAiBA,8BAmEC;AAED,wCAQC;AA7FD,mDAA0F;AAI1F;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CAAC,aAA6B,EAAE,UAAmB,EAAE;IAC5E,OAAO,IAAA,yBAAa,EAAC,aAAa,EAAE;QAClC,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE;YACrE,IAAI,KAAK,KAAK,EAAE,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtC,yCAAyC;gBACzC,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;wBAChB,OAAO,EAAG,OAAO,CAAC,mBAAmB,CAAwC;6BAC1E,gBAAgB;qBACpB,CAAC;oBACF,8CAA8C;oBAC9C,UAAU,EAAE,sCAAsC;oBAClD,KAAK,EAAE,EAAE;oBACT,SAAS,EAAE,IAAI;oBACf,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,EAAE;iBACb,CAAC;YACJ,CAAC;iBAAM,IAAI,KAAK,KAAK,UAAU,IAAI,IAAI,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oCAAoC;wBACpC,OAAO,OAAO,CAAC,sBAAsB,CAAC,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;oBAC1E,CAAC;iBACF,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,KAAK,CACb,yBAAyB,KAAK,cAAc,IAAI,wBAAwB,cAAc,uBAAuB,aAAa,EAAE,CAC7H,CAAC;QACJ,CAAC;QACD,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,cAAc,CAC5B,aAA6B,EAC7B,UAAmB,EAAE;IAErB,OAAO,SAAS,CAAC,aAAa,EAAE;QAC9B,GAAG,OAAO;QACV,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;AACL,CAAC;AAED,iDAAqE;AAA5D,gHAAA,eAAe,OAAA;AAAE,kHAAA,iBAAiB,OAAA","sourcesContent":["import type { RouteNode } from './Route';\nimport { getRoutes as getRoutesCore, type Options as OptionsCore } from './getRoutesCore';\nimport type { RequireContext } from './types';\n\nexport type Options = Omit<OptionsCore, 'getSystemRoute'>;\n/**\n * Given a Metro context module, return an array of nested routes.\n *\n * This is a two step process:\n * 1. Convert the RequireContext keys (file paths) into a directory tree.\n * - This should extrapolate array syntax into multiple routes\n * - Routes are given a specificity score\n * 2. Flatten the directory tree into routes\n * - Routes in directories without _layout files are hoisted to the nearest _layout\n * - The name of the route is relative to the nearest _layout\n * - If multiple routes have the same name, the most specific route is used\n */\nexport function getRoutes(contextModule: RequireContext, options: Options = {}): RouteNode | null {\n return getRoutesCore(contextModule, {\n getSystemRoute({ route, type, defaults, redirectConfig, rewriteConfig }) {\n if (route === '' && type === 'layout') {\n // Root layout when no layout is defined.\n return {\n type: 'layout',\n loadRoute: () => ({\n default: (require('./views/Navigator') as typeof import('./views/Navigator'))\n .DefaultNavigator,\n }),\n // Generate a fake file name for the directory\n contextKey: 'expo-router/build/views/Navigator.js',\n route: '',\n generated: true,\n dynamic: null,\n children: [],\n };\n } else if (route === '_sitemap' && type === 'route') {\n return {\n loadRoute() {\n const { Sitemap, getNavOptions } = require('./views/Sitemap');\n return { default: Sitemap, getNavOptions };\n },\n route: '_sitemap',\n type: 'route',\n contextKey: 'expo-router/build/views/Sitemap.js',\n generated: true,\n internal: true,\n dynamic: null,\n children: [],\n };\n } else if (route === '+not-found' && type === 'route') {\n return {\n loadRoute() {\n return { default: require('./views/Unmatched').Unmatched };\n },\n type: 'route',\n route: '+not-found',\n contextKey: 'expo-router/build/views/Unmatched.js',\n generated: true,\n internal: true,\n dynamic: [{ name: '+not-found', deep: true, notFound: true }],\n children: [],\n };\n } else if (type === 'redirect' && redirectConfig && defaults) {\n return {\n ...defaults,\n loadRoute() {\n return require('./getRoutesRedirects').getRedirectModule(redirectConfig);\n },\n };\n } else if (type === 'rewrite' && rewriteConfig && defaults) {\n return {\n ...defaults,\n loadRoute() {\n // TODO: Replace with rewrite module\n return require('./getRoutesRedirects').getRedirectModule(rewriteConfig);\n },\n };\n }\n throw new Error(\n `Unknown system route: ${route} and type: ${type} and redirectConfig: ${redirectConfig} and rewriteConfig: ${rewriteConfig}`\n );\n },\n ...options,\n });\n}\n\nexport function getExactRoutes(\n contextModule: RequireContext,\n options: Options = {}\n): RouteNode | null {\n return getRoutes(contextModule, {\n ...options,\n skipGenerated: true,\n });\n}\n\nexport { generateDynamic, extrapolateGroups } from './getRoutesCore';\n"]}
@@ -16,11 +16,16 @@ export type Options = {
16
16
  rewrites?: RewriteConfig[];
17
17
  preserveRedirectAndRewrites?: boolean;
18
18
  /** Get the system route for a location. Useful for shimming React Native imports in SSR environments. */
19
- getSystemRoute: (route: Pick<RouteNode, 'route' | 'type'>, defaults?: RouteNode) => RouteNode;
19
+ getSystemRoute: (route: Pick<RouteNode, 'route' | 'type'> & {
20
+ defaults?: RouteNode;
21
+ redirectConfig?: RedirectConfig;
22
+ rewriteConfig?: RewriteConfig;
23
+ }) => RouteNode;
20
24
  };
21
25
  export type RedirectConfig = {
22
26
  source: string;
23
27
  destination: string;
28
+ destinationContextKey: string;
24
29
  permanent?: boolean;
25
30
  methods?: string[];
26
31
  external?: boolean;
@@ -28,6 +33,7 @@ export type RedirectConfig = {
28
33
  export type RewriteConfig = {
29
34
  source: string;
30
35
  destination: string;
36
+ destinationContextKey: string;
31
37
  methods?: string[];
32
38
  };
33
39
  /**
@@ -43,7 +49,6 @@ export type RewriteConfig = {
43
49
  * - If multiple routes have the same name, the most specific route is used
44
50
  */
45
51
  export declare function getRoutes(contextModule: RequireContext, options: Options): RouteNode | null;
46
- export declare function getIgnoreList(options?: Options): RegExp[];
47
52
  /**
48
53
  * Generates a set of strings which have the router array syntax extrapolated.
49
54
  *
@@ -1 +1 @@
1
- {"version":3,"file":"getRoutesCore.d.ts","sourceRoot":"","sources":["../src/getRoutesCore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAW5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAE3B,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC,yGAAyG;IACzG,cAAc,EAAE,CAAC,KAAK,EAAE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F;AA8iBD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,GAAG,CAAC,MAAM,CAAC,CAwBzF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAAE,GAAG,IAAI,CAgBxE"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRoutes = getRoutes;
4
- exports.getIgnoreList = getIgnoreList;
5
4
  exports.extrapolateGroups = extrapolateGroups;
6
5
  exports.generateDynamic = generateDynamic;
7
6
  const matchers_1 = require("./matchers");
@@ -53,32 +52,40 @@ function getDirectoryTree(contextModule, options) {
53
52
  const redirects = {};
54
53
  const rewrites = {};
55
54
  let validRedirectDestinations;
55
+ const getValidDestinations = () => {
56
+ // Loop over contexts once and cache the valid destinations
57
+ validRedirectDestinations ??= contextKeys.map((key) => {
58
+ return {
59
+ contextKey: key,
60
+ nameWithoutInvisible: getNameWithoutInvisibleSegmentsFromRedirectPath((0, matchers_1.removeSupportedExtensions)(key)),
61
+ };
62
+ });
63
+ return validRedirectDestinations;
64
+ };
56
65
  // If we are keeping redirects as valid routes, then we need to add them to the contextKeys
57
66
  // This is useful for generating a sitemap with redirects, or static site generation that includes redirects
58
67
  if (options.preserveRedirectAndRewrites) {
59
68
  if (options.redirects) {
60
69
  for (const redirect of options.redirects) {
61
- // Remove the leading `./` or `/`
62
- const source = redirect.source.replace(/^\.?\//, '');
70
+ const sourceContextKey = getSourceContextKeyFromRedirectSource(redirect.source);
71
+ const sourceName = getNameFromRedirectPath(redirect.source);
63
72
  const isExternalRedirect = (0, url_1.shouldLinkExternally)(redirect.destination);
64
- const targetDestination = isExternalRedirect
73
+ const targetDestinationName = isExternalRedirect
65
74
  ? redirect.destination
66
- : (0, matchers_1.stripInvisibleSegmentsFromPath)((0, matchers_1.removeFileSystemDots)((0, matchers_1.removeFileSystemExtensions)(redirect.destination.replace(/^\.?\/?/, ''))));
67
- const normalizedSource = (0, matchers_1.removeFileSystemDots)((0, matchers_1.removeSupportedExtensions)(source));
68
- if (ignoreList.some((regex) => regex.test(normalizedSource))) {
75
+ : getNameWithoutInvisibleSegmentsFromRedirectPath(redirect.destination);
76
+ if (ignoreList.some((regex) => regex.test(sourceContextKey))) {
69
77
  continue;
70
78
  }
71
- // Loop over this once and cache the valid destinations
72
- validRedirectDestinations ??= contextKeys.map((key) => {
73
- return [
74
- (0, matchers_1.stripInvisibleSegmentsFromPath)((0, matchers_1.removeFileSystemDots)((0, matchers_1.removeSupportedExtensions)(key))),
75
- key,
76
- ];
77
- });
79
+ const validDestination = isExternalRedirect
80
+ ? undefined
81
+ : getValidDestinations().find((key) => key.nameWithoutInvisible === targetDestinationName);
78
82
  const destination = isExternalRedirect
79
- ? targetDestination
80
- : validRedirectDestinations.find((key) => key[0] === targetDestination)?.[1];
81
- if (!destination) {
83
+ ? targetDestinationName
84
+ : validDestination?.nameWithoutInvisible;
85
+ const destinationContextKey = isExternalRedirect
86
+ ? targetDestinationName
87
+ : validDestination?.contextKey;
88
+ if (!destinationContextKey || destination === undefined) {
82
89
  /*
83
90
  * Only throw the error when we are preserving the api routes
84
91
  * When doing a static export, API routes will not exist so the redirect destination may not exist.
@@ -90,11 +97,11 @@ function getDirectoryTree(contextModule, options) {
90
97
  }
91
98
  continue;
92
99
  }
93
- const fakeContextKey = (0, matchers_1.removeFileSystemDots)((0, matchers_1.removeSupportedExtensions)(source));
94
- contextKeys.push(fakeContextKey);
95
- redirects[fakeContextKey] = {
96
- source,
100
+ contextKeys.push(sourceContextKey);
101
+ redirects[sourceName] = {
102
+ source: sourceName,
97
103
  destination,
104
+ destinationContextKey,
98
105
  permanent: Boolean(redirect.permanent),
99
106
  external: isExternalRedirect,
100
107
  methods: redirect.methods,
@@ -103,22 +110,16 @@ function getDirectoryTree(contextModule, options) {
103
110
  }
104
111
  if (options.rewrites) {
105
112
  for (const rewrite of options.rewrites) {
106
- // Remove the leading `./` or `/`
107
- const source = rewrite.source.replace(/^\.?\//, '');
108
- const targetDestination = (0, matchers_1.stripInvisibleSegmentsFromPath)((0, matchers_1.removeFileSystemDots)((0, matchers_1.removeSupportedExtensions)(rewrite.destination)));
109
- const normalizedSource = (0, matchers_1.removeFileSystemDots)((0, matchers_1.removeSupportedExtensions)(source));
110
- if (ignoreList.some((regex) => regex.test(normalizedSource))) {
113
+ const sourceContextKey = getSourceContextKeyFromRedirectSource(rewrite.source);
114
+ const sourceName = getNameFromRedirectPath(rewrite.source);
115
+ const targetDestinationName = getNameFromRedirectPath(rewrite.destination);
116
+ if (ignoreList.some((regex) => regex.test(sourceContextKey))) {
111
117
  continue;
112
118
  }
113
- // Loop over this once and cache the valid destinations
114
- validRedirectDestinations ??= contextKeys.map((key) => {
115
- return [
116
- (0, matchers_1.stripInvisibleSegmentsFromPath)((0, matchers_1.removeFileSystemDots)((0, matchers_1.removeSupportedExtensions)(key))),
117
- key,
118
- ];
119
- });
120
- const destination = validRedirectDestinations.find((key) => key[0] === targetDestination)?.[1];
121
- if (!destination) {
119
+ const validDestination = getValidDestinations().find((key) => key.nameWithoutInvisible === targetDestinationName);
120
+ const destination = validDestination?.nameWithoutInvisible;
121
+ const destinationContextKey = validDestination?.contextKey;
122
+ if (!destinationContextKey || destination === undefined) {
122
123
  /*
123
124
  * Only throw the error when we are preserving the api routes
124
125
  * When doing a static export, API routes will not exist so the redirect destination may not exist.
@@ -126,17 +127,21 @@ function getDirectoryTree(contextModule, options) {
126
127
  * `expo export` swallows this error.
127
128
  */
128
129
  if (options.preserveApiRoutes) {
129
- throw new Error(`Redirect destination "${rewrite.destination}" does not exist.`);
130
+ throw new Error(`Rewrite destination "${rewrite.destination}" does not exist.`);
130
131
  }
131
132
  continue;
132
133
  }
133
- // Add a fake context key
134
- const fakeContextKey = `./${source}.tsx`;
135
- contextKeys.push(fakeContextKey);
136
- rewrites[fakeContextKey] = { source, destination, methods: rewrite.methods };
134
+ contextKeys.push(sourceContextKey);
135
+ rewrites[sourceName] = {
136
+ source: sourceName,
137
+ destination,
138
+ destinationContextKey,
139
+ methods: rewrite.methods,
140
+ };
137
141
  }
138
142
  }
139
143
  }
144
+ const processedRedirectsRewrites = new Set();
140
145
  for (const filePath of contextKeys) {
141
146
  if (ignoreList.some((regex) => regex.test(filePath))) {
142
147
  continue;
@@ -187,33 +192,47 @@ function getDirectoryTree(contextModule, options) {
187
192
  children: [], // While we are building the directory tree, we don't know the node's children just yet. This is added during hoisting
188
193
  };
189
194
  if (meta.isRedirect) {
190
- node.destinationContextKey = redirects[filePath].destination;
191
- node.permanent = redirects[filePath].permanent;
195
+ if (processedRedirectsRewrites.has(meta.route)) {
196
+ continue;
197
+ }
198
+ const redirect = redirects[meta.route];
199
+ node.destinationContextKey = redirect.destinationContextKey;
200
+ node.permanent = redirect.permanent;
192
201
  node.generated = true;
193
202
  if (node.type === 'route') {
194
203
  node = options.getSystemRoute({
195
204
  type: 'redirect',
196
- route: (0, matchers_1.removeFileSystemDots)((0, matchers_1.removeSupportedExtensions)(node.destinationContextKey)),
197
- }, node);
205
+ route: redirect.destination,
206
+ defaults: node,
207
+ redirectConfig: redirect,
208
+ });
198
209
  }
199
- if (redirects[filePath].methods) {
200
- node.methods = redirects[filePath].methods;
210
+ if (redirect.methods) {
211
+ node.methods = redirect.methods;
201
212
  }
202
213
  node.type = 'redirect';
214
+ processedRedirectsRewrites.add(meta.route);
203
215
  }
204
216
  if (meta.isRewrite) {
205
- node.destinationContextKey = rewrites[filePath].destination;
217
+ if (processedRedirectsRewrites.has(meta.route)) {
218
+ continue;
219
+ }
220
+ const rewrite = rewrites[meta.route];
221
+ node.destinationContextKey = rewrite.destinationContextKey;
206
222
  node.generated = true;
207
223
  if (node.type === 'route') {
208
224
  node = options.getSystemRoute({
209
225
  type: 'rewrite',
210
- route: (0, matchers_1.removeFileSystemDots)((0, matchers_1.removeSupportedExtensions)(node.destinationContextKey)),
211
- }, node);
226
+ route: rewrite.destination,
227
+ defaults: node,
228
+ rewriteConfig: rewrite,
229
+ });
212
230
  }
213
- if (redirects[filePath].methods) {
214
- node.methods = redirects[filePath].methods;
231
+ if (rewrite.methods) {
232
+ node.methods = rewrite.methods;
215
233
  }
216
234
  node.type = 'rewrite';
235
+ processedRedirectsRewrites.add(meta.route);
217
236
  }
218
237
  if (process.env.NODE_ENV === 'development') {
219
238
  // If the user has set the `EXPO_ROUTER_IMPORT_MODE` to `sync` then we should
@@ -341,6 +360,22 @@ function getDirectoryTree(contextModule, options) {
341
360
  }
342
361
  return rootDirectory;
343
362
  }
363
+ function getNameFromRedirectPath(path) {
364
+ // Removing only the filesystem extensions, to be able to handle +api, +html
365
+ return ((0, matchers_1.removeFileSystemExtensions)((0, matchers_1.removeFileSystemDots)(path))
366
+ // Remove the leading `/`
367
+ .replace(/^\//, ''));
368
+ }
369
+ function getNameWithoutInvisibleSegmentsFromRedirectPath(path) {
370
+ return (0, matchers_1.stripInvisibleSegmentsFromPath)(getNameFromRedirectPath(path));
371
+ }
372
+ // Creates fake context key for redirects and rewrites
373
+ function getSourceContextKeyFromRedirectSource(source) {
374
+ const name = getNameFromRedirectPath(source);
375
+ const prefix = './';
376
+ const suffix = /\.[tj]sx?$/.test(name) ? '' : '.js'; // Ensure it has a file extension
377
+ return `${prefix}${name}${suffix}`;
378
+ }
344
379
  /**
345
380
  * Flatten the directory tree into routes, hoisting routes to the nearest _layout.
346
381
  */
@@ -445,13 +480,6 @@ function getFileMeta(originalKey, options, redirects, rewrites) {
445
480
  isRewrite: key in rewrites,
446
481
  };
447
482
  }
448
- function getIgnoreList(options) {
449
- const ignore = [/^\.\/\+html\.[tj]sx?$/, ...(options?.ignore ?? [])];
450
- if (options?.preserveApiRoutes !== true) {
451
- ignore.push(/\+api\.[tj]sx?$/);
452
- }
453
- return ignore;
454
- }
455
483
  /**
456
484
  * Generates a set of strings which have the router array syntax extrapolated.
457
485
  *