expo-router 5.0.0-sdk-52-router-patches → 5.0.1-preview.1-canary-20250407-10a9b42

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 (82) hide show
  1. package/build/Route.d.ts +7 -1
  2. package/build/Route.d.ts.map +1 -1
  3. package/build/Route.js.map +1 -1
  4. package/build/exports.d.ts +1 -0
  5. package/build/exports.d.ts.map +1 -1
  6. package/build/exports.js.map +1 -1
  7. package/build/fork/getStateFromPath-forks.d.ts +3 -2
  8. package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
  9. package/build/fork/getStateFromPath-forks.js +24 -27
  10. package/build/fork/getStateFromPath-forks.js.map +1 -1
  11. package/build/fork/getStateFromPath.js +24 -19
  12. package/build/fork/getStateFromPath.js.map +1 -1
  13. package/build/getLinkingConfig.d.ts +3 -1
  14. package/build/getLinkingConfig.d.ts.map +1 -1
  15. package/build/getLinkingConfig.js +11 -7
  16. package/build/getLinkingConfig.js.map +1 -1
  17. package/build/getReactNavigationConfig.d.ts +1 -0
  18. package/build/getReactNavigationConfig.d.ts.map +1 -1
  19. package/build/getReactNavigationConfig.js +2 -1
  20. package/build/getReactNavigationConfig.js.map +1 -1
  21. package/build/getRoutes.d.ts.map +1 -1
  22. package/build/getRoutes.js +9 -1
  23. package/build/getRoutes.js.map +1 -1
  24. package/build/getRoutesCore.d.ts +16 -1
  25. package/build/getRoutesCore.d.ts.map +1 -1
  26. package/build/getRoutesCore.js +134 -11
  27. package/build/getRoutesCore.js.map +1 -1
  28. package/build/getRoutesRedirects.d.ts +12 -0
  29. package/build/getRoutesRedirects.d.ts.map +1 -0
  30. package/build/getRoutesRedirects.js +71 -0
  31. package/build/getRoutesRedirects.js.map +1 -0
  32. package/build/getRoutesSSR.d.ts.map +1 -1
  33. package/build/getRoutesSSR.js +9 -1
  34. package/build/getRoutesSSR.js.map +1 -1
  35. package/build/getServerManifest.d.ts +13 -1
  36. package/build/getServerManifest.d.ts.map +1 -1
  37. package/build/getServerManifest.js +27 -2
  38. package/build/getServerManifest.js.map +1 -1
  39. package/build/global-state/router-store.d.ts +4 -0
  40. package/build/global-state/router-store.d.ts.map +1 -1
  41. package/build/global-state/router-store.js +44 -2
  42. package/build/global-state/router-store.js.map +1 -1
  43. package/build/global-state/routing.d.ts +1 -1
  44. package/build/global-state/routing.d.ts.map +1 -1
  45. package/build/global-state/routing.js +7 -1
  46. package/build/global-state/routing.js.map +1 -1
  47. package/build/link/linking.d.ts +2 -1
  48. package/build/link/linking.d.ts.map +1 -1
  49. package/build/link/linking.js +14 -8
  50. package/build/link/linking.js.map +1 -1
  51. package/build/matchers.d.ts +3 -1
  52. package/build/matchers.d.ts.map +1 -1
  53. package/build/matchers.js +7 -2
  54. package/build/matchers.js.map +1 -1
  55. package/build/routes-manifest.d.ts +6 -2
  56. package/build/routes-manifest.d.ts.map +1 -1
  57. package/build/routes-manifest.js +1 -0
  58. package/build/routes-manifest.js.map +1 -1
  59. package/build/rsc/middleware.d.ts.map +1 -1
  60. package/build/rsc/middleware.js +6 -1
  61. package/build/rsc/middleware.js.map +1 -1
  62. package/build/rsc/router/create-expo-pages.d.ts +20 -0
  63. package/build/rsc/router/create-expo-pages.d.ts.map +1 -0
  64. package/build/rsc/router/create-expo-pages.js +22 -0
  65. package/build/rsc/router/create-expo-pages.js.map +1 -0
  66. package/build/rsc/router/expo-definedRouter.d.ts +1 -5
  67. package/build/rsc/router/expo-definedRouter.d.ts.map +1 -1
  68. package/build/rsc/router/expo-definedRouter.js +3 -2
  69. package/build/rsc/router/expo-definedRouter.js.map +1 -1
  70. package/build/rsc/router/noopRouter.d.ts +1 -5
  71. package/build/rsc/router/noopRouter.d.ts.map +1 -1
  72. package/build/rsc/router/noopRouter.js +2 -2
  73. package/build/rsc/router/noopRouter.js.map +1 -1
  74. package/build/static/getServerManifest.d.ts.map +1 -1
  75. package/build/static/getServerManifest.js +1 -0
  76. package/build/static/getServerManifest.js.map +1 -1
  77. package/build/useScreens.d.ts +4 -1
  78. package/build/useScreens.d.ts.map +1 -1
  79. package/build/useScreens.js +39 -34
  80. package/build/useScreens.js.map +1 -1
  81. package/package.json +7 -8
  82. package/plugin/options.json +33 -0
@@ -30,6 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.useInitializeExpoRouter = exports.useStoreRouteInfo = exports.useStoreRootState = exports.useExpoRouter = exports.store = exports.RouterStore = void 0;
31
31
  const native_1 = require("@react-navigation/native");
32
32
  const expo_constants_1 = __importDefault(require("expo-constants"));
33
+ const Linking = __importStar(require("expo-linking"));
33
34
  const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
34
35
  const react_1 = require("react");
35
36
  const react_native_1 = require("react-native");
@@ -37,11 +38,14 @@ const routing_1 = require("./routing");
37
38
  const sort_routes_1 = require("./sort-routes");
38
39
  const LocationProvider_1 = require("../LocationProvider");
39
40
  const getPathFromState_1 = require("../fork/getPathFromState");
40
- // import { ResultState } from '../fork/getStateFromPath';
41
+ const getStateFromPath_forks_1 = require("../fork/getStateFromPath-forks");
41
42
  const getLinkingConfig_1 = require("../getLinkingConfig");
43
+ const getReactNavigationConfig_1 = require("../getReactNavigationConfig");
42
44
  const getRoutes_1 = require("../getRoutes");
45
+ const getRoutesRedirects_1 = require("../getRoutesRedirects");
43
46
  const href_1 = require("../link/href");
44
47
  const useScreens_1 = require("../useScreens");
48
+ const url_1 = require("../utils/url");
45
49
  const SplashScreen = __importStar(require("../views/Splash"));
46
50
  /**
47
51
  * 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.
@@ -58,6 +62,9 @@ class RouterStore {
58
62
  nextState;
59
63
  routeInfo;
60
64
  splashScreenAnimationFrame;
65
+ // The expo-router config plugin
66
+ config;
67
+ redirects;
61
68
  navigationRef;
62
69
  navigationRefSubscription;
63
70
  rootStateSubscribers = new Set();
@@ -84,6 +91,18 @@ class RouterStore {
84
91
  this.navigationRefSubscription?.();
85
92
  this.rootStateSubscribers.clear();
86
93
  this.storeSubscribers.clear();
94
+ this.config = expo_constants_1.default.expoConfig?.extra?.router;
95
+ // On the client, there is no difference between redirects and rewrites
96
+ this.redirects = [this.config?.redirects, this.config?.rewrites]
97
+ .filter(Boolean)
98
+ .flat()
99
+ .map((route) => {
100
+ return [
101
+ (0, getStateFromPath_forks_1.routePatternToRegex)((0, getReactNavigationConfig_1.parseRouteSegments)(route.source)),
102
+ route,
103
+ (0, url_1.shouldLinkExternally)(route.destination),
104
+ ];
105
+ });
87
106
  this.routeNode = (0, getRoutes_1.getRoutes)(context, {
88
107
  ...expo_constants_1.default.expoConfig?.extra?.router,
89
108
  ignoreEntryPoints: true,
@@ -101,7 +120,10 @@ class RouterStore {
101
120
  };
102
121
  if (this.routeNode) {
103
122
  // We have routes, so get the linking config and the root component
104
- this.linking = (0, getLinkingConfig_1.getLinkingConfig)(this, this.routeNode, context, linkingConfigOptions);
123
+ this.linking = (0, getLinkingConfig_1.getLinkingConfig)(this, this.routeNode, context, {
124
+ ...expo_constants_1.default.expoConfig?.extra?.router,
125
+ ...linkingConfigOptions,
126
+ });
105
127
  this.rootComponent = (0, useScreens_1.getQualifiedRouteComponent)(this.routeNode);
106
128
  // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`
107
129
  // This will cause static rendering to fail, which once performs a single pass.
@@ -215,6 +237,26 @@ class RouterStore {
215
237
  href = (0, href_1.resolveHrefStringWithSegments)(href, this.routeInfo, options);
216
238
  return this.linking?.getStateFromPath?.(href, this.linking.config);
217
239
  }
240
+ applyRedirects(url) {
241
+ if (typeof url !== 'string') {
242
+ return url;
243
+ }
244
+ const nextUrl = (0, getStateFromPath_forks_1.cleanPath)(url);
245
+ const redirect = this.redirects?.find(([regex]) => regex.test(nextUrl));
246
+ if (!redirect) {
247
+ return url;
248
+ }
249
+ // If the redirect is external, open the URL
250
+ if (redirect[2]) {
251
+ let href = redirect[1].destination;
252
+ if (href.startsWith('//') && react_native_1.Platform.OS !== 'web') {
253
+ href = `https:${href}`;
254
+ }
255
+ Linking.openURL(href);
256
+ return;
257
+ }
258
+ return this.applyRedirects((0, getRoutesRedirects_1.convertRedirect)(url, redirect[1]));
259
+ }
218
260
  }
219
261
  exports.RouterStore = RouterStore;
220
262
  exports.store = new RouterStore();
@@ -1 +1 @@
1
- {"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,qDAGkC;AAClC,oEAAuC;AACvC,sEAAoC;AACpC,iCAA+E;AAC/E,+CAAwC;AAExC,uCAcmB;AACnB,+CAAgD;AAChD,0DAAuE;AAEvE,+DAAkF;AAClF,0DAA0D;AAC1D,0DAAiG;AACjG,4CAAyC;AACzC,uCAA0E;AAE1E,8CAA2D;AAC3D,8DAAgD;AAIhD;;;;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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AAO,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":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport equal from 'fast-deep-equal';\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 reload,\n replace,\n setParams,\n dismissTo,\n LinkToOptions,\n} from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { getPathDataFromState, getPathFromState } from '../fork/getPathFromState';\n// import { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { Href, RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport * as SplashScreen from '../views/Splash';\n\ntype ResultState = any;\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 dismissTo = dismissTo.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 reload = reload.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\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 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 (!equal(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 shouldEncodeURISegment: false,\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 getStateFromPath(href: Href, options: LinkToOptions = {}) {\n href = resolveHref(href);\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n return this.linking?.getStateFromPath?.(href, this.linking.config);\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,YAAY,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,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":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport equal from 'fast-deep-equal';\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 reload,\n replace,\n setParams,\n dismissTo,\n LinkToOptions,\n} from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { getPathDataFromState, getPathFromState } from '../fork/getPathFromState';\nimport { cleanPath, routePatternToRegex } from '../fork/getStateFromPath-forks';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { parseRouteSegments } from '../getReactNavigationConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RedirectConfig } from '../getRoutesCore';\nimport { convertRedirect } from '../getRoutesRedirects';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { Href, RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\nimport * as SplashScreen from '../views/Splash';\n\ntype ResultState = any;\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 // The expo-router config plugin\n config: any;\n redirects?: (readonly [RegExp, RedirectConfig, boolean])[];\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 dismissTo = dismissTo.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 reload = reload.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.config = Constants.expoConfig?.extra?.router;\n // On the client, there is no difference between redirects and rewrites\n this.redirects = [this.config?.redirects, this.config?.rewrites]\n .filter(Boolean)\n .flat()\n .map((route) => {\n return [\n routePatternToRegex(parseRouteSegments(route.source)),\n route,\n shouldLinkExternally(route.destination),\n ] as const;\n });\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, {\n ...Constants.expoConfig?.extra?.router,\n ...linkingConfigOptions,\n });\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 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 (!equal(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 shouldEncodeURISegment: false,\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 getStateFromPath(href: Href, options: LinkToOptions = {}) {\n href = resolveHref(href);\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n return this.linking?.getStateFromPath?.(href, this.linking.config);\n }\n\n applyRedirects<T extends string | null | undefined>(url: T): T | undefined {\n if (typeof url !== 'string') {\n return url;\n }\n\n const nextUrl = cleanPath(url);\n const redirect = this.redirects?.find(([regex]) => regex.test(nextUrl));\n\n if (!redirect) {\n return url;\n }\n\n // If the redirect is external, open the URL\n if (redirect[2]) {\n let href = redirect[1].destination as T & string;\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}` as T & string;\n }\n\n Linking.openURL(href);\n return;\n }\n\n return this.applyRedirects<T>(convertRedirect(url, redirect[1]) as T);\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"]}
@@ -31,5 +31,5 @@ export type LinkToOptions = {
31
31
  */
32
32
  dangerouslySingular?: SingularOptions;
33
33
  };
34
- export declare function linkTo(this: RouterStore, href: string, options?: LinkToOptions): void;
34
+ export declare function linkTo(this: RouterStore, originalHref: string, options?: LinkToOptions): void;
35
35
  //# sourceMappingURL=routing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAWlD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAWhD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAE7D,wBAAgB,Q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GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAM,OAOnE;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,eAAe,CAAC;CACvC,CAAC;AAEF,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,QA4D1F"}
@@ -120,7 +120,8 @@ function setParams(params = {}) {
120
120
  return (this.navigationRef?.current?.setParams)(params);
121
121
  }
122
122
  exports.setParams = setParams;
123
- function linkTo(href, options = {}) {
123
+ function linkTo(originalHref, options = {}) {
124
+ let href = originalHref;
124
125
  if ((0, useDomComponentNavigation_1.emitDomLinkEvent)(href, options)) {
125
126
  return;
126
127
  }
@@ -145,6 +146,11 @@ function linkTo(href, options = {}) {
145
146
  }
146
147
  const rootState = navigationRef.getRootState();
147
148
  href = (0, href_1.resolveHrefStringWithSegments)(href, this.routeInfo, options);
149
+ href = this.applyRedirects(href);
150
+ // If the href is undefined, it means that the redirect has already been handled the navigation
151
+ if (!href) {
152
+ return;
153
+ }
148
154
  const state = this.linking.getStateFromPath(href, this.linking.config);
149
155
  if (!state || state.routes.length === 0) {
150
156
  console.error('Could not generate a valid navigation state for the given path: ' + href);
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA4F;AAC5F,kCAAkC;AAClC,sDAAwC;AACxC,+CAAwC;AAIxC,uCAA0E;AAC1E,iFAM2C;AAC3C,0CAA+C;AAG/C,sCAAoD;AAEpD,SAAS,aAAa,CAAC,KAAkB;IACvC,IAAI,CAAC,KAAK,CAAC,aAA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AC;KAClB;IAED,IAAI,UAAU,KAAK,SAAS,EAAE;QAC5B,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE;YAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;gBACzC,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;aAC1F;SACF;QACD;;;;;;;;WAQG;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;KAC1C;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,eAAe,CAAC,GAAG;QAC3B,OAAO,EAAE;YACP,wBAAwB;YACxB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,QAAQ;SACT;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StackActions, type NavigationState, PartialRoute } from '@react-navigation/native';\nimport { IS_DOM } from 'expo/dom';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { type RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../link/useDomComponentNavigation';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload(this: RouterStore) {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function push(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n if (emitDomDismiss(count)) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function dismissTo(this: RouterStore, href: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n if (emitDomDismissAll()) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, remove all screen from the history that match the singular condition\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n};\n\nexport function linkTo(this: RouterStore, href: string, options: LinkToOptions = {}) {\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(\n state,\n rootState,\n options.event,\n options.withAnchor,\n options.dangerouslySingular\n )\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean,\n singular?: SingularOptions\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n if (type === 'PUSH' && navigationState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n } else if (\n type === 'REPLACE' &&\n (navigationState.type === 'tab' || navigationState.type === 'drawer')\n ) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA4F;AAC5F,kCAAkC;AAClC,sDAAwC;AACxC,+CAAwC;AAIxC,uCAA0E;AAC1E,iFAM2C;AAC3C,0CAA+C;AAG/C,sCAAoD;AAEpD,SAAS,aAAa,CAAC,KAAkB;IACvC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QAClC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;KACH;AACH,CAAC;AAID,SAAgB,QAAQ,CAAoB,GAAS,EAAE,OAA2B;IAChF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AAC1E,CAAC;AAFD,4BAEC;AAED,SAAgB,MAAM;IACpB,yCAAyC;IACzC,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;AACzF,CAAC;AAHD,wBAGC;AAED,SAAgB,IAAI,CAAoB,GAAS,EAAE,OAA2B;IAC5E,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAA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e,CAAC,GAAG;QAC3B,OAAO,EAAE;YACP,wBAAwB;YACxB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,QAAQ;SACT;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StackActions, type NavigationState, PartialRoute } from '@react-navigation/native';\nimport { IS_DOM } from 'expo/dom';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { type RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../link/useDomComponentNavigation';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload(this: RouterStore) {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function push(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n if (emitDomDismiss(count)) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function dismissTo(this: RouterStore, href: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n if (emitDomDismissAll()) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, remove all screen from the history that match the singular condition\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n};\n\nexport function linkTo(this: RouterStore, originalHref: string, options: LinkToOptions = {}) {\n let href: string | undefined = originalHref;\n\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n href = this.applyRedirects(href);\n\n // If the href is undefined, it means that the redirect has already been handled the navigation\n if (!href) {\n return;\n }\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(\n state,\n rootState,\n options.event,\n options.withAnchor,\n options.dangerouslySingular\n )\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean,\n singular?: SingularOptions\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n if (type === 'PUSH' && navigationState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n } else if (\n type === 'REPLACE' &&\n (navigationState.type === 'tab' || navigationState.type === 'drawer')\n ) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
@@ -1,9 +1,10 @@
1
1
  import { LinkingOptions } from '@react-navigation/native';
2
2
  import { getPathFromState } from '../fork/getPathFromState';
3
3
  import { getStateFromPath } from '../fork/getStateFromPath';
4
+ import { RouterStore } from '../global-state/router-store';
4
5
  import { NativeIntent } from '../types';
5
6
  export declare function getInitialURL(): ReturnType<NonNullable<LinkingOptions<Record<string, unknown>>['getInitialURL']>>;
6
7
  export declare function getRootURL(): string;
7
- export declare function addEventListener(nativeLinking?: NativeIntent): (listener: (url: string) => void) => () => void;
8
+ export declare function addEventListener(nativeLinking: NativeIntent | undefined, store: RouterStore): (listener: (url: string) => void) => () => void;
8
9
  export { getStateFromPath, getPathFromState };
9
10
  //# sourceMappingURL=linking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQ1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AASxC,wBAAgB,aAAa,IAAI,UAAU,CACzC,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CACtE,CA0BA;AAID,wBAAgB,UAAU,IAAI,MAAM,CAQnC;AAgBD,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,YAAY,oBACnC,MAAM,KAAK,IAAI,gBAiCxC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQ1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AASxC,wBAAgB,aAAa,IAAI,UAAU,CACzC,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CACtE,CA0BA;AAID,wBAAgB,UAAU,IAAI,MAAM,CAQnC;AAgBD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,YAAY,GAAG,SAAS,EAAE,KAAK,EAAE,WAAW,oBAClE,MAAM,KAAK,IAAI,gBAuCxC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
@@ -84,26 +84,32 @@ function parseExpoGoUrlFromListener(url) {
84
84
  }
85
85
  return url;
86
86
  }
87
- function addEventListener(nativeLinking) {
87
+ function addEventListener(nativeLinking, store) {
88
88
  return (listener) => {
89
89
  let callback;
90
90
  const legacySubscription = nativeLinking?.legacy_subscribe?.(listener);
91
91
  if (isExpoGo) {
92
92
  // This extra work is only done in the Expo Go app.
93
93
  callback = async ({ url }) => {
94
- url = parseExpoGoUrlFromListener(url);
95
- if (url && nativeLinking?.redirectSystemPath) {
96
- url = await nativeLinking.redirectSystemPath({ path: url, initial: false });
94
+ let href = parseExpoGoUrlFromListener(url);
95
+ href = store.applyRedirects(href);
96
+ if (href && nativeLinking?.redirectSystemPath) {
97
+ href = await nativeLinking.redirectSystemPath({ path: href, initial: false });
98
+ }
99
+ if (href) {
100
+ listener(href);
97
101
  }
98
- listener(url);
99
102
  };
100
103
  }
101
104
  else {
102
105
  callback = async ({ url }) => {
103
- if (url && nativeLinking?.redirectSystemPath) {
104
- url = await nativeLinking.redirectSystemPath({ path: url, initial: false });
106
+ let href = store.applyRedirects(url);
107
+ if (href && nativeLinking?.redirectSystemPath) {
108
+ href = await nativeLinking.redirectSystemPath({ path: href, initial: false });
109
+ }
110
+ if (href) {
111
+ listener(href);
105
112
  }
106
- listener(url);
107
113
  };
108
114
  }
109
115
  const subscription = Linking.addEventListener('url', callback);
@@ -1 +1 @@
1
- {"version":3,"file":"linking.js","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AACxC,+CAAwC;AAExC,mEAGoC;AACpC,+DAA4D;AAwGjC,iGAxGlB,mCAAgB,OAwGkB;AAvG3C,+DAA4D;AAuGnD,iGAvGA,mCAAgB,OAuGA;AAtGzB,mDAA8D;AAG9D,MAAM,QAAQ,GAAG,OAAO,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;AAEjF,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,8GAA8G;AAC9G,8EAA8E;AAC9E,SAAgB,aAAa;IAG3B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,EAAE,CAAC;KACX;IACD,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE;QAClD,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;KAC7B;IACD,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,mFAAmF;QACnF,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QACpC,OAAO,CACL,0BAA0B,CAAC,GAAG,CAAC;YAC/B,uFAAuF;YACvF,4DAA4D;YAC5D,UAAU,EAAE,CACb,CAAC;KACH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AAC,GAAG,CAAC,CAAC;gBAEtC,IAAI,GAAG,IAAI,aAAa,EAAE,kBAAkB,EAAE;oBAC5C,GAAG,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC7E;gBAED,QAAQ,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC;SACH;aAAM;YACL,QAAQ,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBAC3B,IAAI,GAAG,IAAI,aAAa,EAAE,kBAAkB,EAAE;oBAC5C,GAAG,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC7E;gBACD,QAAQ,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC;SACH;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE/D,OAAO,GAAG,EAAE;YACV,2FAA2F;YAC3F,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;YACzB,kBAAkB,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAlCD,4CAkCC","sourcesContent":["import { LinkingOptions } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport {\n parsePathAndParamsFromExpoGoLink,\n parsePathFromExpoGoLink,\n} from '../fork/extractPathFromURL';\nimport { getPathFromState } from '../fork/getPathFromState';\nimport { getStateFromPath } from '../fork/getStateFromPath';\nimport { getInitialURLWithTimeout } from '../fork/useLinking';\nimport { NativeIntent } from '../types';\n\nconst isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;\n\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.\nexport function getInitialURL(): ReturnType<\n NonNullable<LinkingOptions<Record<string, unknown>>['getInitialURL']>\n> {\n if (typeof window === 'undefined') {\n return '';\n }\n if (Platform.OS === 'web' && window.location?.href) {\n return window.location.href;\n }\n if (Platform.OS === 'ios') {\n // Use the new Expo API for iOS. This has better support for App Clips and handoff.\n const url = Linking.getLinkingURL();\n return (\n parseExpoGoUrlFromListener(url) ??\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n getRootURL()\n );\n }\n\n // TODO: Figure out if expo-linking on Android has full interop with the React Native implementation.\n return Promise.resolve(getInitialURLWithTimeout()).then(\n (url) =>\n parseExpoGoUrlFromListener(url) ??\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n getRootURL()\n );\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL(): string {\n if (_rootURL === undefined) {\n _rootURL = Linking.createURL('/');\n if (isExpoGo) {\n _rootURL = parsePathFromExpoGoLink(_rootURL);\n }\n }\n return _rootURL;\n}\n\n// Expo Go is weird and requires the root path to be `/--/`\nfunction parseExpoGoUrlFromListener<T extends string | null>(url: T): T {\n if (!url || !isExpoGo) {\n return url;\n }\n const { pathname, queryString } = parsePathAndParamsFromExpoGoLink(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (!pathname || pathname === '/') {\n return (getRootURL() + queryString) as T;\n }\n return url;\n}\n\nexport function addEventListener(nativeLinking?: NativeIntent) {\n return (listener: (url: string) => void) => {\n let callback: (({ url }: { url: string }) => void) | undefined;\n\n const legacySubscription = nativeLinking?.legacy_subscribe?.(listener);\n\n if (isExpoGo) {\n // This extra work is only done in the Expo Go app.\n callback = async ({ url }) => {\n url = parseExpoGoUrlFromListener(url);\n\n if (url && nativeLinking?.redirectSystemPath) {\n url = await nativeLinking.redirectSystemPath({ path: url, initial: false });\n }\n\n listener(url);\n };\n } else {\n callback = async ({ url }) => {\n if (url && nativeLinking?.redirectSystemPath) {\n url = await nativeLinking.redirectSystemPath({ path: url, initial: false });\n }\n listener(url);\n };\n }\n\n const subscription = Linking.addEventListener('url', callback);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n subscription?.remove?.();\n legacySubscription?.();\n };\n };\n}\n\nexport { getStateFromPath, getPathFromState };\n"]}
1
+ {"version":3,"file":"linking.js","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AACxC,+CAAwC;AAExC,mEAGoC;AACpC,+DAA4D;AA+GjC,iGA/GlB,mCAAgB,OA+GkB;AA9G3C,+DAA4D;AA8GnD,iGA9GA,mCAAgB,OA8GA;AA7GzB,mDAA8D;AAI9D,MAAM,QAAQ,GAAG,OAAO,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;AAEjF,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,8GAA8G;AAC9G,8EAA8E;AAC9E,SAAgB,aAAa;IAG3B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,EAAE,CAAC;KACX;IACD,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE;QAClD,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;KAC7B;IACD,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,mFAAmF;QACnF,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QACpC,OAAO,CACL,0BAA0B,CAAC,GAAG,CAAC;YAC/B,uFAAuF;YACvF,4DAA4D;YAC5D,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AE,EAAE;gBAC3B,IAAI,IAAI,GAAuB,0BAA0B,CAAC,GAAG,CAAC,CAAC;gBAC/D,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAClC,IAAI,IAAI,IAAI,aAAa,EAAE,kBAAkB,EAAE;oBAC7C,IAAI,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC/E;gBAED,IAAI,IAAI,EAAE;oBACR,QAAQ,CAAC,IAAI,CAAC,CAAC;iBAChB;YACH,CAAC,CAAC;SACH;aAAM;YACL,QAAQ,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBAC3B,IAAI,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;gBACrC,IAAI,IAAI,IAAI,aAAa,EAAE,kBAAkB,EAAE;oBAC7C,IAAI,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC/E;gBAED,IAAI,IAAI,EAAE;oBACR,QAAQ,CAAC,IAAI,CAAC,CAAC;iBAChB;YACH,CAAC,CAAC;SACH;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE/D,OAAO,GAAG,EAAE;YACV,2FAA2F;YAC3F,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;YACzB,kBAAkB,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAxCD,4CAwCC","sourcesContent":["import { LinkingOptions } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport {\n parsePathAndParamsFromExpoGoLink,\n parsePathFromExpoGoLink,\n} from '../fork/extractPathFromURL';\nimport { getPathFromState } from '../fork/getPathFromState';\nimport { getStateFromPath } from '../fork/getStateFromPath';\nimport { getInitialURLWithTimeout } from '../fork/useLinking';\nimport { RouterStore } from '../global-state/router-store';\nimport { NativeIntent } from '../types';\n\nconst isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;\n\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.\nexport function getInitialURL(): ReturnType<\n NonNullable<LinkingOptions<Record<string, unknown>>['getInitialURL']>\n> {\n if (typeof window === 'undefined') {\n return '';\n }\n if (Platform.OS === 'web' && window.location?.href) {\n return window.location.href;\n }\n if (Platform.OS === 'ios') {\n // Use the new Expo API for iOS. This has better support for App Clips and handoff.\n const url = Linking.getLinkingURL();\n return (\n parseExpoGoUrlFromListener(url) ??\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n getRootURL()\n );\n }\n\n // TODO: Figure out if expo-linking on Android has full interop with the React Native implementation.\n return Promise.resolve(getInitialURLWithTimeout()).then(\n (url) =>\n parseExpoGoUrlFromListener(url) ??\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n getRootURL()\n );\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL(): string {\n if (_rootURL === undefined) {\n _rootURL = Linking.createURL('/');\n if (isExpoGo) {\n _rootURL = parsePathFromExpoGoLink(_rootURL);\n }\n }\n return _rootURL;\n}\n\n// Expo Go is weird and requires the root path to be `/--/`\nfunction parseExpoGoUrlFromListener<T extends string | null>(url: T): T {\n if (!url || !isExpoGo) {\n return url;\n }\n const { pathname, queryString } = parsePathAndParamsFromExpoGoLink(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (!pathname || pathname === '/') {\n return (getRootURL() + queryString) as T;\n }\n return url;\n}\n\nexport function addEventListener(nativeLinking: NativeIntent | undefined, store: RouterStore) {\n return (listener: (url: string) => void) => {\n let callback: (({ url }: { url: string }) => void) | undefined;\n\n const legacySubscription = nativeLinking?.legacy_subscribe?.(listener);\n\n if (isExpoGo) {\n // This extra work is only done in the Expo Go app.\n callback = async ({ url }) => {\n let href: string | undefined = parseExpoGoUrlFromListener(url);\n href = store.applyRedirects(href);\n if (href && nativeLinking?.redirectSystemPath) {\n href = await nativeLinking.redirectSystemPath({ path: href, initial: false });\n }\n\n if (href) {\n listener(href);\n }\n };\n } else {\n callback = async ({ url }) => {\n let href = store.applyRedirects(url);\n if (href && nativeLinking?.redirectSystemPath) {\n href = await nativeLinking.redirectSystemPath({ path: href, initial: false });\n }\n\n if (href) {\n listener(href);\n }\n };\n }\n\n const subscription = Linking.addEventListener('url', callback);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n subscription?.remove?.();\n legacySubscription?.();\n };\n };\n}\n\nexport { getStateFromPath, getPathFromState };\n"]}
@@ -12,8 +12,10 @@ export declare function matchLastGroupName(name: string): string | undefined;
12
12
  export declare function matchArrayGroupName(name: string): string | undefined;
13
13
  export declare function getNameFromFilePath(name: string): string;
14
14
  export declare function getContextKey(name: string): string;
15
- /** Remove `.js`, `.ts`, `.jsx`, `.tsx` */
15
+ /** Remove `.js`, `.ts`, `.jsx`, `.tsx`, and the +api suffix */
16
16
  export declare function removeSupportedExtensions(name: string): string;
17
+ /** Remove `.js`, `.ts`, `.jsx`, `.tsx` */
18
+ export declare function removeFileSystemExtensions(name: string): string;
17
19
  export declare function removeFileSystemDots(filePath: string): string;
18
20
  export declare function stripGroupSegmentsFromPath(path: string): string;
19
21
  export declare function stripInvisibleSegmentsFromPath(path: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../src/matchers.tsx"],"names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AG,SAAS,CAE1E;AAED,yBAAyB;AACzB,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,+BAA+B;AAC/B,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED,qCAAqC;AACrC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnE;AAED,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,sBAE/C;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQlD;AAED,+DAA+D;AAC/D,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,0CAA0C;AAC1C,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D;AAGD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU/D;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,WAExC"}
package/build/matchers.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTypedRoute = exports.stripInvisibleSegmentsFromPath = exports.stripGroupSegmentsFromPath = exports.removeFileSystemDots = exports.removeSupportedExtensions = exports.getContextKey = exports.getNameFromFilePath = exports.matchArrayGroupName = exports.matchLastGroupName = exports.matchGroupName = exports.testNotFound = exports.matchDeepDynamicRouteName = exports.matchDynamicName = void 0;
3
+ exports.isTypedRoute = exports.stripInvisibleSegmentsFromPath = exports.stripGroupSegmentsFromPath = exports.removeFileSystemDots = exports.removeFileSystemExtensions = exports.removeSupportedExtensions = exports.getContextKey = exports.getNameFromFilePath = exports.matchArrayGroupName = exports.matchLastGroupName = exports.matchGroupName = exports.testNotFound = exports.matchDeepDynamicRouteName = exports.matchDynamicName = void 0;
4
4
  /** Match `[page]` -> `page` */
5
5
  function matchDynamicName(name) {
6
6
  // Don't match `...` or `[` or `]` inside the brackets
@@ -47,11 +47,16 @@ function getContextKey(name) {
47
47
  return normal.replace(/\/?_layout$/, '');
48
48
  }
49
49
  exports.getContextKey = getContextKey;
50
- /** Remove `.js`, `.ts`, `.jsx`, `.tsx` */
50
+ /** Remove `.js`, `.ts`, `.jsx`, `.tsx`, and the +api suffix */
51
51
  function removeSupportedExtensions(name) {
52
52
  return name.replace(/(\+api)?\.[jt]sx?$/g, '');
53
53
  }
54
54
  exports.removeSupportedExtensions = removeSupportedExtensions;
55
+ /** Remove `.js`, `.ts`, `.jsx`, `.tsx` */
56
+ function removeFileSystemExtensions(name) {
57
+ return name.replace(/\.[jt]sx?$/g, '');
58
+ }
59
+ exports.removeFileSystemExtensions = removeFileSystemExtensions;
55
60
  // Remove any amount of `./` and `../` from the start of the string
56
61
  function removeFileSystemDots(filePath) {
57
62
  return filePath.replace(/^(?:\.\.?\/)+/g, '');
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.js","sourceRoot":"","sources":["../src/matchers.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,sDAAsD;IACtD,6CAA6C;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC;AAJD,4CAIC;AAED,kCAAkC;AAClC,SAAgB,yBAAyB,CAAC,IAAY;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AA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O,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC;AAFD,oDAEC;AAED,SAAgB,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACjB,IAAI,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;YAC7B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAc,CAAC;SACjB,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAVD,gEAUC;AAED,SAAgB,8BAA8B,CAAC,IAAY;IACzD,OAAO,0BAA0B,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC;AAFD,wEAEC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,KAAK,IAAI,CAAC;AAC5F,CAAC;AAFD,oCAEC","sourcesContent":["/** Match `[page]` -> `page` */\nexport function matchDynamicName(name: string): string | undefined {\n // Don't match `...` or `[` or `]` inside the brackets\n // eslint-disable-next-line no-useless-escape\n return name.match(/^\\[([^[\\](?:\\.\\.\\.)]+?)\\]$/)?.[1];\n}\n\n/** Match `[...page]` -> `page` */\nexport function matchDeepDynamicRouteName(name: string): string | undefined {\n return name.match(/^\\[\\.\\.\\.([^/]+?)\\]$/)?.[1];\n}\n\n/** Test `/` -> `page` */\nexport function testNotFound(name: string): boolean {\n return /\\+not-found$/.test(name);\n}\n\n/** Match `(page)` -> `page` */\nexport function matchGroupName(name: string): string | undefined {\n return name.match(/^(?:[^\\\\(\\\\)])*?\\(([^\\\\/]+)\\).*?$/)?.[1];\n}\n\n/** Match `(app)/(page)` -> `page` */\nexport function matchLastGroupName(name: string): string | undefined {\n return name.match(/.*(?:\\/|^)\\(([^\\\\/\\s]+)\\)[^\\s]*$/)?.[1];\n}\n\n/** Match the first array group name `(a,b,c)/(d,c)` -> `'a,b,c'` */\nexport function matchArrayGroupName(name: string) {\n return name.match(/(?:[^\\\\(\\\\)])*?\\(([^\\\\/]+,[^\\\\/]+)\\).*?$/)?.[1];\n}\n\nexport function getNameFromFilePath(name: string): string {\n return removeSupportedExtensions(removeFileSystemDots(name));\n}\n\nexport function getContextKey(name: string): string {\n // The root path is `` (empty string) so always prepend `/` to ensure\n // there is some value.\n const normal = '/' + getNameFromFilePath(name);\n if (!normal.endsWith('_layout')) {\n return normal;\n }\n return normal.replace(/\\/?_layout$/, '');\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx` */\nexport function removeSupportedExtensions(name: string): string {\n return name.replace(/(\\+api)?\\.[jt]sx?$/g, '');\n}\n\n// Remove any amount of `./` and `../` from the start of the string\nexport function removeFileSystemDots(filePath: string): string {\n return filePath.replace(/^(?:\\.\\.?\\/)+/g, '');\n}\n\nexport function stripGroupSegmentsFromPath(path: string): string {\n return path\n .split('/')\n .reduce((acc, v) => {\n if (matchGroupName(v) == null) {\n acc.push(v);\n }\n return acc;\n }, [] as string[])\n .join('/');\n}\n\nexport function stripInvisibleSegmentsFromPath(path: string): string {\n return stripGroupSegmentsFromPath(path).replace(/\\/?index$/, '');\n}\n\n/**\n * Match:\n * - _layout files, +html, +not-found, string+api, etc\n * - Routes can still use `+`, but it cannot be in the last segment.\n */\nexport function isTypedRoute(name: string) {\n return !name.startsWith('+') && name.match(/(_layout|[^/]*?\\+[^/]*?)\\.[tj]sx?$/) === null;\n}\n"]}
1
+ {"version":3,"file":"matchers.js","sourceRoot":"","sources":["../src/matchers.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,sDAAsD;IACtD,6CAA6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a,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC;AARD,sCAQC;AAED,+DAA+D;AAC/D,SAAgB,yBAAyB,CAAC,IAAY;IACpD,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;AACjD,CAAC;AAFD,8DAEC;AAED,0CAA0C;AAC1C,SAAgB,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC;AAFD,gEAEC;AAED,mEAAmE;AACnE,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,OAAO,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC;AAFD,oDAEC;AAED,SAAgB,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACjB,IAAI,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;YAC7B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAc,CAAC;SACjB,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAVD,gEAUC;AAED,SAAgB,8BAA8B,CAAC,IAAY;IACzD,OAAO,0BAA0B,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC;AAFD,wEAEC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,KAAK,IAAI,CAAC;AAC5F,CAAC;AAFD,oCAEC","sourcesContent":["/** Match `[page]` -> `page` */\nexport function matchDynamicName(name: string): string | undefined {\n // Don't match `...` or `[` or `]` inside the brackets\n // eslint-disable-next-line no-useless-escape\n return name.match(/^\\[([^[\\](?:\\.\\.\\.)]+?)\\]$/)?.[1];\n}\n\n/** Match `[...page]` -> `page` */\nexport function matchDeepDynamicRouteName(name: string): string | undefined {\n return name.match(/^\\[\\.\\.\\.([^/]+?)\\]$/)?.[1];\n}\n\n/** Test `/` -> `page` */\nexport function testNotFound(name: string): boolean {\n return /\\+not-found$/.test(name);\n}\n\n/** Match `(page)` -> `page` */\nexport function matchGroupName(name: string): string | undefined {\n return name.match(/^(?:[^\\\\(\\\\)])*?\\(([^\\\\/]+)\\).*?$/)?.[1];\n}\n\n/** Match `(app)/(page)` -> `page` */\nexport function matchLastGroupName(name: string): string | undefined {\n return name.match(/.*(?:\\/|^)\\(([^\\\\/\\s]+)\\)[^\\s]*$/)?.[1];\n}\n\n/** Match the first array group name `(a,b,c)/(d,c)` -> `'a,b,c'` */\nexport function matchArrayGroupName(name: string) {\n return name.match(/(?:[^\\\\(\\\\)])*?\\(([^\\\\/]+,[^\\\\/]+)\\).*?$/)?.[1];\n}\n\nexport function getNameFromFilePath(name: string): string {\n return removeSupportedExtensions(removeFileSystemDots(name));\n}\n\nexport function getContextKey(name: string): string {\n // The root path is `` (empty string) so always prepend `/` to ensure\n // there is some value.\n const normal = '/' + getNameFromFilePath(name);\n if (!normal.endsWith('_layout')) {\n return normal;\n }\n return normal.replace(/\\/?_layout$/, '');\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx`, and the +api suffix */\nexport function removeSupportedExtensions(name: string): string {\n return name.replace(/(\\+api)?\\.[jt]sx?$/g, '');\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx` */\nexport function removeFileSystemExtensions(name: string): string {\n return name.replace(/\\.[jt]sx?$/g, '');\n}\n\n// Remove any amount of `./` and `../` from the start of the string\nexport function removeFileSystemDots(filePath: string): string {\n return filePath.replace(/^(?:\\.\\.?\\/)+/g, '');\n}\n\nexport function stripGroupSegmentsFromPath(path: string): string {\n return path\n .split('/')\n .reduce((acc, v) => {\n if (matchGroupName(v) == null) {\n acc.push(v);\n }\n return acc;\n }, [] as string[])\n .join('/');\n}\n\nexport function stripInvisibleSegmentsFromPath(path: string): string {\n return stripGroupSegmentsFromPath(path).replace(/\\/?index$/, '');\n}\n\n/**\n * Match:\n * - _layout files, +html, +not-found, string+api, etc\n * - Routes can still use `+`, but it cannot be in the last segment.\n */\nexport function isTypedRoute(name: string) {\n return !name.startsWith('+') && name.match(/(_layout|[^/]*?\\+[^/]*?)\\.[tj]sx?$/) === null;\n}\n"]}
@@ -1,15 +1,19 @@
1
- import { Options } from './getRoutesSSR';
2
- export { Options } from './getRoutes';
1
+ import { type Options } from './getRoutesSSR';
2
+ export { Options };
3
3
  export type RouteInfo<TRegex = string> = {
4
4
  file: string;
5
5
  page: string;
6
6
  namedRegex: TRegex;
7
7
  routeKeys: Record<string, string>;
8
+ permanent?: boolean;
9
+ methods?: string[];
8
10
  };
9
11
  export type ExpoRoutesManifestV1<TRegex = string> = {
10
12
  apiRoutes: RouteInfo<TRegex>[];
11
13
  htmlRoutes: RouteInfo<TRegex>[];
12
14
  notFoundRoutes: RouteInfo<TRegex>[];
15
+ redirects: RouteInfo<TRegex>[];
16
+ rewrites: RouteInfo<TRegex>[];
13
17
  };
14
18
  export declare function createRoutesManifest(paths: string[], options: Options): ExpoRoutesManifestV1 | null;
15
19
  //# sourceMappingURL=routes-manifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routes-manifest.d.ts","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAa,MAAM,gBAAgB,CAAC;AAIpD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,MAAM,SAAS,CAAC,MAAM,GAAG,MAAM,IAAI;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,S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BAAoB,CAClC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,OAAO,GACf,oBAAoB,GAAG,IAAI,CAe7B"}
@@ -17,6 +17,7 @@ function createRoutesManifest(paths, options) {
17
17
  const routeTree = (0, getRoutesSSR_1.getRoutes)(createMockContextModule(paths), {
18
18
  ...options,
19
19
  preserveApiRoutes: true,
20
+ preserveRedirectAndRewrites: true,
20
21
  ignoreRequireErrors: true,
21
22
  ignoreEntryPoints: true,
22
23
  platform: 'web',
@@ -1 +1 @@
1
- {"version":3,"file":"routes-manifest.js","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,sBAAsB;AACtB,iDAAoD;AACpD,2DAAwD;AAkBxD,SAAS,uBAAuB,CAAC,MAAgB,EAAE;IACjD,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,KAAI,CAAC,EAAE,CAAC,CAAC;IAElD,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE;QAC3C,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG;KACjB,CAAC,CAAC;IAEH,OAAO,aAA+B,CAAC;AACzC,CAAC;AAED,SAAgB,oBAAoB,CAClC,KAAe,EACf,OAAgB;IAEhB,mCAAmC;IACnC,MAAM,SAAS,GAAG,IAAA,wBAAS,EAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;QAC1D,GAAG,OAAO;QACV,iBAAiB,EAAE,IAAI;QACvB,mBAAmB,EAAE,IAAI;QACzB,iBAAiB,EAAE,IAAI;QACvB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAA,qCAAiB,EAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAjBD,oDAiBC","sourcesContent":["// This file runs in Node.js environments.\n// no relative imports\nimport { Options, getRoutes } from './getRoutesSSR';\nimport { getServerManifest } from './getServerManifest';\nimport { RequireContext } from './types';\n\nexport { Options } from './getRoutes';\n\nexport type RouteInfo<TRegex = string> = {\n file: string;\n page: string;\n namedRegex: TRegex;\n routeKeys: Record<string, string>;\n};\n\nexport type ExpoRoutesManifestV1<TRegex = string> = {\n apiRoutes: RouteInfo<TRegex>[];\n htmlRoutes: RouteInfo<TRegex>[];\n notFoundRoutes: RouteInfo<TRegex>[];\n};\n\nfunction createMockContextModule(map: string[] = []) {\n const contextModule = (key) => ({ default() {} });\n\n Object.defineProperty(contextModule, 'keys', {\n value: () => map,\n });\n\n return contextModule as RequireContext;\n}\n\nexport function createRoutesManifest(\n paths: string[],\n options: Options\n): ExpoRoutesManifestV1 | null {\n // TODO: Drop this part for Node.js\n const routeTree = getRoutes(createMockContextModule(paths), {\n ...options,\n preserveApiRoutes: true,\n ignoreRequireErrors: true,\n ignoreEntryPoints: true,\n platform: 'web',\n });\n\n if (!routeTree) {\n return null;\n }\n return getServerManifest(routeTree);\n}\n"]}
1
+ {"version":3,"file":"routes-manifest.js","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,sBAAsB;AACtB,iDAAyD;AACzD,2DAAwD;AAsBxD,SAAS,uBAAuB,CAAC,MAAgB,EAAE;IACjD,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,KAAI,CAAC,EAAE,CAAC,CAAC;IAElD,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE;QAC3C,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG;KACjB,CAAC,CAAC;IAEH,OAAO,aAA+B,CAAC;AACzC,CAAC;AAED,SAAgB,oBAAoB,CAClC,KAAe,EACf,OAAgB;IAEhB,mCAAmC;IACnC,MAAM,SAAS,GAAG,IAAA,wBAAS,EAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;QAC1D,GAAG,OAAO;QACV,iBAAiB,EAAE,IAAI;QACvB,2BAA2B,EAAE,IAAI;QACjC,mBAAmB,EAAE,IAAI;QACzB,iBAAiB,EAAE,IAAI;QACvB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAA,qCAAiB,EAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAlBD,oDAkBC","sourcesContent":["// This file runs in Node.js environments.\n// no relative imports\nimport { type Options, getRoutes } from './getRoutesSSR';\nimport { getServerManifest } from './getServerManifest';\nimport { type RequireContext } from './types';\n\nexport { Options };\n\nexport type RouteInfo<TRegex = string> = {\n file: string;\n page: string;\n namedRegex: TRegex;\n routeKeys: Record<string, string>;\n permanent?: boolean;\n methods?: string[];\n};\n\nexport type ExpoRoutesManifestV1<TRegex = string> = {\n apiRoutes: RouteInfo<TRegex>[];\n htmlRoutes: RouteInfo<TRegex>[];\n notFoundRoutes: RouteInfo<TRegex>[];\n redirects: RouteInfo<TRegex>[];\n rewrites: RouteInfo<TRegex>[];\n};\n\nfunction createMockContextModule(map: string[] = []) {\n const contextModule = (key) => ({ default() {} });\n\n Object.defineProperty(contextModule, 'keys', {\n value: () => map,\n });\n\n return contextModule as RequireContext;\n}\n\nexport function createRoutesManifest(\n paths: string[],\n options: Options\n): ExpoRoutesManifestV1 | null {\n // TODO: Drop this part for Node.js\n const routeTree = getRoutes(createMockContextModule(paths), {\n ...options,\n preserveApiRoutes: true,\n preserveRedirectAndRewrites: true,\n ignoreRequireErrors: true,\n ignoreEntryPoints: true,\n platform: 'web',\n });\n\n if (!routeTree) {\n return null;\n }\n return getServerManifest(routeTree);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAyEvE,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,MAAM,OAAO,CAAC,cAAc,6BAA6B,CAAC,CAAC,CAAC;CACrE,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,SAAS,EAClB,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,aAAa,GAC3F,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAmE9B;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAa9B"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AA0EvE,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,MAAM,OAAO,CAAC,cAAc,6BAA6B,CAAC,CAAC,CAAC;CACrE,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,SAAS,EAClB,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,aAAa,GAC3F,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAuE9B;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAa9B"}
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.renderRscAsync = exports.renderRscWithImportsAsync = void 0;
7
+ const expo_constants_1 = __importDefault(require("expo-constants"));
7
8
  const _async_server_import_1 = require("expo-router/_async-server-import");
8
9
  const node_path_1 = __importDefault(require("node:path"));
9
10
  const rsc_renderer_1 = require("./rsc-renderer");
@@ -44,7 +45,11 @@ async function renderRscWithImportsAsync(distFolder, imports, { body, platform,
44
45
  }
45
46
  const context = getRscRenderContext(platform);
46
47
  context['__expo_requestHeaders'] = headers;
47
- const entries = await imports.router();
48
+ const router = await imports.router();
49
+ const entries = router.default({
50
+ redirects: expo_constants_1.default.expoConfig?.extra?.router?.redirects,
51
+ rewrites: expo_constants_1.default.expoConfig?.extra?.router?.rewrites,
52
+ });
48
53
  const ssrManifest = await getSSRManifest(distFolder, platform);
49
54
  const actionManifest = await getServerActionManifest(distFolder, platform);
50
55
  return (0, rsc_renderer_1.renderRsc)({