expo-router 4.0.0-preview.8 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/assets/error.png +0 -0
  2. package/assets/file.png +0 -0
  3. package/assets/forward.png +0 -0
  4. package/assets/logotype.png +0 -0
  5. package/assets/pkg.png +0 -0
  6. package/assets/sitemap.png +0 -0
  7. package/build/ExpoRoot.js +2 -2
  8. package/build/ExpoRoot.js.map +1 -1
  9. package/build/doctor/index.d.ts +16 -0
  10. package/build/doctor/index.d.ts.map +1 -0
  11. package/build/doctor/index.js +66 -0
  12. package/build/doctor/index.js.map +1 -0
  13. package/build/exports.d.ts +1 -1
  14. package/build/exports.d.ts.map +1 -1
  15. package/build/exports.js +24 -2
  16. package/build/exports.js.map +1 -1
  17. package/build/fast-refresh.d.ts.map +1 -1
  18. package/build/fast-refresh.js.map +1 -1
  19. package/build/getRoutesCore.d.ts +1 -0
  20. package/build/getRoutesCore.d.ts.map +1 -1
  21. package/build/getRoutesCore.js +3 -1
  22. package/build/getRoutesCore.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 -2
  25. package/build/global-state/router-store.js.map +1 -1
  26. package/build/global-state/routing.d.ts.map +1 -1
  27. package/build/global-state/routing.js +4 -0
  28. package/build/global-state/routing.js.map +1 -1
  29. package/build/head/url.d.ts +1 -0
  30. package/build/head/url.d.ts.map +1 -1
  31. package/build/head/url.js +21 -4
  32. package/build/head/url.js.map +1 -1
  33. package/build/hooks.d.ts +90 -38
  34. package/build/hooks.d.ts.map +1 -1
  35. package/build/hooks.js +46 -39
  36. package/build/hooks.js.map +1 -1
  37. package/build/imperative-api.d.ts +58 -15
  38. package/build/imperative-api.d.ts.map +1 -1
  39. package/build/imperative-api.js.map +1 -1
  40. package/build/layouts/Drawer.d.ts +2 -142
  41. package/build/layouts/Drawer.d.ts.map +1 -1
  42. package/build/layouts/Drawer.js +8 -5
  43. package/build/layouts/Drawer.js.map +1 -1
  44. package/build/layouts/DrawerClient.d.ts +144 -0
  45. package/build/layouts/DrawerClient.d.ts.map +1 -0
  46. package/build/layouts/DrawerClient.js +10 -0
  47. package/build/layouts/DrawerClient.js.map +1 -0
  48. package/build/layouts/Stack.d.ts +2 -126
  49. package/build/layouts/Stack.d.ts.map +1 -1
  50. package/build/layouts/Stack.js +8 -6
  51. package/build/layouts/Stack.js.map +1 -1
  52. package/build/layouts/StackClient.d.ts +128 -0
  53. package/build/layouts/StackClient.d.ts.map +1 -0
  54. package/build/layouts/StackClient.js +10 -0
  55. package/build/layouts/StackClient.js.map +1 -0
  56. package/build/layouts/Tabs.d.ts +2 -134
  57. package/build/layouts/Tabs.d.ts.map +1 -1
  58. package/build/layouts/Tabs.js +5 -37
  59. package/build/layouts/Tabs.js.map +1 -1
  60. package/build/layouts/TabsClient.d.ts +136 -0
  61. package/build/layouts/TabsClient.d.ts.map +1 -0
  62. package/build/layouts/TabsClient.js +44 -0
  63. package/build/layouts/TabsClient.js.map +1 -0
  64. package/build/layouts/withLayoutContext.d.ts +4 -1
  65. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  66. package/build/layouts/withLayoutContext.js +4 -1
  67. package/build/layouts/withLayoutContext.js.map +1 -1
  68. package/build/link/Link.d.ts +48 -4
  69. package/build/link/Link.d.ts.map +1 -1
  70. package/build/link/Link.js +47 -3
  71. package/build/link/Link.js.map +1 -1
  72. package/build/link/href.d.ts +1 -1
  73. package/build/link/href.d.ts.map +1 -1
  74. package/build/link/href.js.map +1 -1
  75. package/build/link/useLinkHooks.d.ts +122 -29
  76. package/build/link/useLinkHooks.d.ts.map +1 -1
  77. package/build/link/useLinkHooks.js.map +1 -1
  78. package/build/onboard/Tutorial.d.ts.map +1 -1
  79. package/build/onboard/Tutorial.js +140 -86
  80. package/build/onboard/Tutorial.js.map +1 -1
  81. package/build/renderRootComponent.d.ts.map +1 -1
  82. package/build/renderRootComponent.js +1 -2
  83. package/build/renderRootComponent.js.map +1 -1
  84. package/build/rsc/exports.d.ts +3 -1
  85. package/build/rsc/exports.d.ts.map +1 -1
  86. package/build/rsc/exports.js +3 -1
  87. package/build/rsc/exports.js.map +1 -1
  88. package/build/rsc/middleware.d.ts +1 -1
  89. package/build/rsc/middleware.d.ts.map +1 -1
  90. package/build/rsc/middleware.js +2 -1
  91. package/build/rsc/middleware.js.map +1 -1
  92. package/build/rsc/router/client.d.ts +2 -2
  93. package/build/rsc/router/client.d.ts.map +1 -1
  94. package/build/rsc/router/client.js.map +1 -1
  95. package/build/rsc/router/host.d.ts.map +1 -1
  96. package/build/rsc/router/host.js +20 -15
  97. package/build/rsc/router/host.js.map +1 -1
  98. package/build/rsc/rsc-renderer.d.ts +1 -1
  99. package/build/rsc/rsc-renderer.d.ts.map +1 -1
  100. package/build/rsc/rsc-renderer.js +1 -1
  101. package/build/rsc/rsc-renderer.js.map +1 -1
  102. package/build/rsc/server.d.ts +3 -0
  103. package/build/rsc/server.d.ts.map +1 -1
  104. package/build/rsc/server.js +19 -1
  105. package/build/rsc/server.js.map +1 -1
  106. package/build/testing-library/context-stubs.d.ts.map +1 -1
  107. package/build/testing-library/context-stubs.js +3 -1
  108. package/build/testing-library/context-stubs.js.map +1 -1
  109. package/build/testing-library/mocks.js +14 -13
  110. package/build/testing-library/mocks.js.map +1 -1
  111. package/build/typed-routes/generate.d.ts +5 -1
  112. package/build/typed-routes/generate.d.ts.map +1 -1
  113. package/build/typed-routes/generate.js +129 -64
  114. package/build/typed-routes/generate.js.map +1 -1
  115. package/build/typed-routes/index.d.ts +5 -0
  116. package/build/typed-routes/index.d.ts.map +1 -1
  117. package/build/typed-routes/index.js +8 -3
  118. package/build/typed-routes/index.js.map +1 -1
  119. package/build/typed-routes/testSetup.d.ts +1 -1
  120. package/build/typed-routes/testSetup.d.ts.map +1 -1
  121. package/build/typed-routes/testSetup.js +29 -17
  122. package/build/typed-routes/testSetup.js.map +1 -1
  123. package/build/typed-routes/types.d.ts +43 -145
  124. package/build/typed-routes/types.d.ts.map +1 -1
  125. package/build/typed-routes/types.js.map +1 -1
  126. package/build/types.d.ts +33 -0
  127. package/build/types.d.ts.map +1 -1
  128. package/build/types.js.map +1 -1
  129. package/build/ui/TabContext.d.ts +158 -1
  130. package/build/ui/TabContext.d.ts.map +1 -1
  131. package/build/ui/TabContext.js +25 -1
  132. package/build/ui/TabContext.js.map +1 -1
  133. package/build/ui/TabList.d.ts +17 -1
  134. package/build/ui/TabList.d.ts.map +1 -1
  135. package/build/ui/TabList.js +16 -0
  136. package/build/ui/TabList.js.map +1 -1
  137. package/build/ui/TabSlot.d.ts +55 -5
  138. package/build/ui/TabSlot.d.ts.map +1 -1
  139. package/build/ui/TabSlot.js +38 -14
  140. package/build/ui/TabSlot.js.map +1 -1
  141. package/build/ui/TabTrigger.d.ts +65 -70
  142. package/build/ui/TabTrigger.d.ts.map +1 -1
  143. package/build/ui/TabTrigger.js +25 -1
  144. package/build/ui/TabTrigger.js.map +1 -1
  145. package/build/ui/Tabs.d.ts +89 -132
  146. package/build/ui/Tabs.d.ts.map +1 -1
  147. package/build/ui/Tabs.js +53 -8
  148. package/build/ui/Tabs.js.map +1 -1
  149. package/build/ui/common.d.ts +3 -3
  150. package/build/ui/common.d.ts.map +1 -1
  151. package/build/ui/common.js.map +1 -1
  152. package/build/useFocusEffect.d.ts +15 -6
  153. package/build/useFocusEffect.d.ts.map +1 -1
  154. package/build/useFocusEffect.js +15 -6
  155. package/build/useFocusEffect.js.map +1 -1
  156. package/build/useNavigation.d.ts +11 -5
  157. package/build/useNavigation.d.ts.map +1 -1
  158. package/build/useNavigation.js +11 -5
  159. package/build/useNavigation.js.map +1 -1
  160. package/build/utils/splash.d.ts +6 -0
  161. package/build/utils/splash.d.ts.map +1 -0
  162. package/build/utils/splash.js +51 -0
  163. package/build/utils/splash.js.map +1 -0
  164. package/build/utils/url.js +2 -2
  165. package/build/utils/url.js.map +1 -1
  166. package/build/views/Navigator.d.ts +6 -5
  167. package/build/views/Navigator.d.ts.map +1 -1
  168. package/build/views/Navigator.js +6 -5
  169. package/build/views/Navigator.js.map +1 -1
  170. package/build/views/Sitemap.d.ts.map +1 -1
  171. package/build/views/Sitemap.js +93 -46
  172. package/build/views/Sitemap.js.map +1 -1
  173. package/build/views/Splash.d.ts +1 -1
  174. package/build/views/Splash.d.ts.map +1 -1
  175. package/build/views/Splash.js +3 -13
  176. package/build/views/Splash.js.map +1 -1
  177. package/build/views/Try.d.ts +1 -1
  178. package/build/views/Try.d.ts.map +1 -1
  179. package/build/views/Try.js +1 -1
  180. package/build/views/Try.js.map +1 -1
  181. package/doctor.js +1 -0
  182. package/entry-classic.js +0 -6
  183. package/package.json +23 -24
  184. package/plugin/build/index.d.ts +2 -0
  185. package/plugin/options.json +74 -73
  186. package/plugin/src/index.ts +64 -0
  187. package/rsc/entry.js +0 -6
  188. package/rsc/headers.d.ts +3 -0
  189. package/rsc/headers.js +5 -0
  190. package/build/rsc/runtime.d.ts +0 -9
  191. package/build/rsc/runtime.d.ts.map +0 -1
  192. package/build/rsc/runtime.js +0 -36
  193. package/build/rsc/runtime.js.map +0 -1
  194. package/virtual-client-boundaries.js +0 -1
@@ -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,iEAAmD;AACnD,sEAAoC;AACpC,iCAA+E;AAC/E,+CAAwC;AAExC,uCAYmB;AACnB,+CAAgD;AAChD,0DAAuE;AAEvE,+DAAkF;AAClF,0DAA0D;AAC1D,0DAAiG;AACjG,4CAAyC;AAEzC,8CAA2D;AAI3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAsB;IACrB,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAAe;IAC3B,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AK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,OAA6B;IAC5F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AALD,0DAKC","sourcesContent":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport * as SplashScreen from 'expo-splash-screen';\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} 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 { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\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 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 this.rootComponent = getQualifiedRouteComponent(this.routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can preload the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = this.linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n this.rootState = this.linking.getStateFromPath?.(initialURL, this.linking.config);\n this.initialState = this.rootState;\n if (this.rootState) {\n this.routeInfo = this.getRouteInfo(this.rootState);\n }\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n this.rootComponent = Fragment;\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRef = navigationRef;\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n this.splashScreenAnimationFrame = requestAnimationFrame(() => {\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!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\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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,SAAS,KAAK,YAAY,EAAE;YACpC,aAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACjC;KACF;AACH,CAAC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,OAA6B;IAC5F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AALD,0DAKC","sourcesContent":["'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} 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 { 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 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 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\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, options: LinkingConfigOptions) {\n const navigationRef = useNavigationContainerRef();\n useMemo(() => store.initialize(context, navigationRef, options), [context]);\n useExpoRouter();\n return store;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"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;AAWhC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAE7D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,OAEjF;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAGvC;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,OAE7E;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,MAAM,QAKxD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,OAEhF;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,QAK3C;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAMvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAepD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,OAA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I,EAAE,WAAW,QAK3C;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAMvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAepD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAmBrD;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,WAAW,EACjB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,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;CACtB,CAAC;AAEF,wBAAgB,MAAM,CACpB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,EAAE,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAE,aAAkB,QA6C/D"}
@@ -28,6 +28,7 @@ const native_1 = require("@react-navigation/native");
28
28
  const dom_1 = require("expo/dom");
29
29
  const Linking = __importStar(require("expo-linking"));
30
30
  const non_secure_1 = require("nanoid/non-secure");
31
+ const react_native_1 = require("react-native");
31
32
  const href_1 = require("../link/href");
32
33
  const useDomComponentNavigation_1 = require("../link/useDomComponentNavigation");
33
34
  const matchers_1 = require("../matchers");
@@ -121,6 +122,9 @@ function linkTo(href, { event, relativeToDirectory, withAnchor } = {}) {
121
122
  return;
122
123
  }
123
124
  if ((0, url_1.shouldLinkExternally)(href)) {
125
+ if (href.startsWith('//') && react_native_1.Platform.OS !== 'web') {
126
+ href = `https:${href}`;
127
+ }
124
128
  Linking.openURL(href);
125
129
  return;
126
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;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K,IAAI,eAAe,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE;QAC/F,IAAI,GAAG,SAAS,CAAC;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;SAC3B;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 { nanoid } from 'nanoid/non-secure';\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 { 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 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 *\n */\n withAnchor?: boolean;\n};\n\nexport function linkTo(\n this: RouterStore,\n href: string,\n { event, relativeToDirectory, withAnchor }: LinkToOptions = {}\n) {\n if (emitDomLinkEvent(href, { event, relativeToDirectory, withAnchor })) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, relativeToDirectory);\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(getNavigateAction(state, rootState, event, withAnchor));\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean\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 = 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 // 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 // Expo Router uses only three actions, but these don't directly translate to all navigator actions\n if (type === 'PUSH') {\n // Only stack navigators have a push action, and even then we want to use NAVIGATE (see below)\n type = 'NAVIGATE';\n\n /*\n * The StackAction.PUSH does not work correctly with Expo Router.\n *\n * Expo Router provides a getId() function for every route, altering how React Navigation handles stack routing.\n * Ordinarily, PUSH always adds a new screen to the stack. However, with getId() present, it navigates to the screen with the matching ID instead (by moving the screen to the top of the stack)\n * When you try and push to a screen with the same ID, no navigation will occur\n * Refer to: https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L279-L290\n *\n * Expo Router needs to retain the default behavior of PUSH, consistently adding new screens to the stack, even if their IDs are identical.\n *\n * To resolve this issue, we switch to using a NAVIGATE action with a new key. In the navigate action, screens are matched by either key or getId() function.\n * By generating a unique new key, we ensure that the screen is always pushed onto the stack.\n *\n */\n if (navigationState.type === 'stack') {\n rootPayload.params.__EXPO_ROUTER_key = `${rootPayload.name}-${nanoid()}`; // @see https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L406-L407\n }\n }\n\n if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n }\n\n if (type === 'REPLACE' && (navigationState.type === 'tab' || navigationState.type === 'drawer')) {\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 },\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,kDAA2C;AAC3C,+CAAwC;AAIxC,uCAA0E;AAC1E,iFAM2C;AAC3C,0CAA+C;AAE/C,sCAAoD;AAEpD,SAAS,aAAa,CAAC,KAAkB;IACvC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QAClC,MA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,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;SAC3B;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 { nanoid } from 'nanoid/non-secure';\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 { 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 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 *\n */\n withAnchor?: boolean;\n};\n\nexport function linkTo(\n this: RouterStore,\n href: string,\n { event, relativeToDirectory, withAnchor }: LinkToOptions = {}\n) {\n if (emitDomLinkEvent(href, { event, relativeToDirectory, withAnchor })) {\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, relativeToDirectory);\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(getNavigateAction(state, rootState, event, withAnchor));\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean\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 = 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 // 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 // Expo Router uses only three actions, but these don't directly translate to all navigator actions\n if (type === 'PUSH') {\n // Only stack navigators have a push action, and even then we want to use NAVIGATE (see below)\n type = 'NAVIGATE';\n\n /*\n * The StackAction.PUSH does not work correctly with Expo Router.\n *\n * Expo Router provides a getId() function for every route, altering how React Navigation handles stack routing.\n * Ordinarily, PUSH always adds a new screen to the stack. However, with getId() present, it navigates to the screen with the matching ID instead (by moving the screen to the top of the stack)\n * When you try and push to a screen with the same ID, no navigation will occur\n * Refer to: https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L279-L290\n *\n * Expo Router needs to retain the default behavior of PUSH, consistently adding new screens to the stack, even if their IDs are identical.\n *\n * To resolve this issue, we switch to using a NAVIGATE action with a new key. In the navigate action, screens are matched by either key or getId() function.\n * By generating a unique new key, we ensure that the screen is always pushed onto the stack.\n *\n */\n if (navigationState.type === 'stack') {\n rootPayload.params.__EXPO_ROUTER_key = `${rootPayload.name}-${nanoid()}`; // @see https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L406-L407\n }\n }\n\n if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n }\n\n if (type === 'REPLACE' && (navigationState.type === 'tab' || navigationState.type === 'drawer')) {\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 },\n };\n}\n"]}
@@ -1,2 +1,3 @@
1
+ export declare function getOriginFromConstants(): string | null;
1
2
  export declare function getStaticUrlFromExpoRouter(pathname: string): string;
2
3
  //# sourceMappingURL=url.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":"AA+EA,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,UAI1D"}
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":"AAqEA,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAmBtD;AAeD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,UAI1D"}
package/build/head/url.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getStaticUrlFromExpoRouter = void 0;
6
+ exports.getStaticUrlFromExpoRouter = exports.getOriginFromConstants = void 0;
7
7
  const expo_constants_1 = __importDefault(require("expo-constants"));
8
8
  const protocolWarningString = `{ plugins: [["expo-router", { origin: "...<URL>..." }]] }`;
9
9
  /** `lodash.memoize` */
@@ -33,10 +33,12 @@ function sanitizeUrl(url) {
33
33
  return parsed.toString().replace(/\/$/, '');
34
34
  }
35
35
  const memoSanitizeUrl = memoize(sanitizeUrl);
36
- function getUrlFromConstants() {
36
+ function getHeadOriginFromConstants() {
37
37
  // This will require a rebuild in bare-workflow to update.
38
38
  const manifest = expo_constants_1.default.expoConfig;
39
- const origin = manifest?.extra?.router?.headOrigin ?? manifest?.extra?.router?.origin;
39
+ const origin = manifest?.extra?.router?.headOrigin ??
40
+ manifest?.extra?.router?.origin ??
41
+ manifest?.extra?.router?.generatedOrigin;
40
42
  if (!origin) {
41
43
  throwOrAlert(`Expo Head: Add the handoff origin to the Expo Config (requires rebuild). Add the Config Plugin ${protocolWarningString}, where \`origin\` is the hosted URL.`);
42
44
  // Fallback value that shouldn't be used for real.
@@ -49,6 +51,21 @@ function getUrlFromConstants() {
49
51
  // Return the development URL last so the user gets all production warnings first.
50
52
  return memoSanitizeUrl(origin);
51
53
  }
54
+ function getOriginFromConstants() {
55
+ // This will require a rebuild in bare-workflow to update.
56
+ const manifest = expo_constants_1.default.expoConfig;
57
+ const origin = manifest?.extra?.router?.headOrigin ??
58
+ manifest?.extra?.router?.origin ??
59
+ manifest?.extra?.router?.generatedOrigin;
60
+ if (!origin) {
61
+ throwOrAlert(`Expo RSC: Add the origin to the Expo Config (requires rebuild). Add the Config Plugin ${protocolWarningString}, where \`origin\` is the hosted URL.`);
62
+ // Fallback value that shouldn't be used for real.
63
+ return 'http://localhost:3000';
64
+ }
65
+ // Return the development URL last so the user gets all production warnings first.
66
+ return memoSanitizeUrl(origin);
67
+ }
68
+ exports.getOriginFromConstants = getOriginFromConstants;
52
69
  function throwOrAlert(msg) {
53
70
  // Production apps fatally crash which is often not helpful.
54
71
  if (
@@ -64,7 +81,7 @@ function throwOrAlert(msg) {
64
81
  function getStaticUrlFromExpoRouter(pathname) {
65
82
  // const host = "https://expo.io";
66
83
  // Append the URL we'd find in context
67
- return getUrlFromConstants() + pathname;
84
+ return getHeadOriginFromConstants() + pathname;
68
85
  }
69
86
  exports.getStaticUrlFromExpoRouter = getStaticUrlFromExpoRouter;
70
87
  //# sourceMappingURL=url.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;AAEvC,MAAM,qBAAqB,GAAG,2DAA2D,CAAC;AAE1F,uBAAuB;AACvB,SAAS,OAAO,CAAoC,EAAK;IACvD,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE;YACd,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;SACnB;QACD,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QACpB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAQ,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAE5B,wCAAwC;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AAC,QAAQ,KAAK,YAAY,EACrC;QACA,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,KAAK,CAAC,GAAG,CAAC,CAAC;KACZ;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;KACtB;AACH,CAAC;AAED,SAAgB,0BAA0B,CAAC,QAAgB;IACzD,kCAAkC;IAClC,sCAAsC;IACtC,OAAO,mBAAmB,EAAE,GAAG,QAAQ,CAAC;AAC1C,CAAC;AAJD,gEAIC","sourcesContent":["import Constants from 'expo-constants';\n\nconst protocolWarningString = `{ plugins: [[\"expo-router\", { origin: \"...<URL>...\" }]] }`;\n\n/** `lodash.memoize` */\nfunction memoize<T extends (...args: any[]) => any>(fn: T): T {\n const cache: Record<string, any> = {};\n return ((...args: any[]) => {\n const key = JSON.stringify(args);\n if (cache[key]) {\n return cache[key];\n }\n const result = fn(...args);\n cache[key] = result;\n return result;\n }) as any;\n}\n\nfunction sanitizeUrl(url: string): string {\n const parsed = new URL(url);\n\n // Allow empty protocol, http, and https\n const validProtocol =\n !parsed.protocol || parsed.protocol === 'http:' || parsed.protocol === 'https:';\n\n if (!validProtocol) {\n throwOrAlert(\n `Expo Head: Native origin has invalid protocol \"${parsed.protocol}\" for URL in Expo Config: ${protocolWarningString}.`\n );\n }\n\n parsed.pathname = '';\n parsed.search = '';\n parsed.hash = '';\n parsed.protocol ??= 'https:';\n\n return parsed.toString().replace(/\\/$/, '');\n}\n\nconst memoSanitizeUrl = memoize(sanitizeUrl);\n\nfunction getUrlFromConstants(): string | null {\n // This will require a rebuild in bare-workflow to update.\n const manifest = Constants.expoConfig;\n\n const origin = manifest?.extra?.router?.headOrigin ?? manifest?.extra?.router?.origin;\n\n if (!origin) {\n throwOrAlert(\n `Expo Head: Add the handoff origin to the Expo Config (requires rebuild). Add the Config Plugin ${protocolWarningString}, where \\`origin\\` is the hosted URL.`\n );\n // Fallback value that shouldn't be used for real.\n return 'https://expo.dev';\n }\n\n // Without this, the URL will go to an IP address which is not allowed.\n if (!origin.match(/^http(s)?:\\/\\//)) {\n console.warn(\n `Expo Head: origin \"${origin}\" is missing a \\`https://\\` protocol. ${protocolWarningString}.`\n );\n }\n\n // Return the development URL last so the user gets all production warnings first.\n return memoSanitizeUrl(origin);\n}\n\nfunction throwOrAlert(msg: string) {\n // Production apps fatally crash which is often not helpful.\n if (\n // @ts-ignore: process is defined\n process.env.NODE_ENV === 'production'\n ) {\n console.error(msg);\n alert(msg);\n } else {\n throw new Error(msg);\n }\n}\n\nexport function getStaticUrlFromExpoRouter(pathname: string) {\n // const host = \"https://expo.io\";\n // Append the URL we'd find in context\n return getUrlFromConstants() + pathname;\n}\n"]}
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;AAEvC,MAAM,qBAAqB,GAAG,2DAA2D,CAAC;AAE1F,uBAAuB;AACvB,SAAS,OAAO,CAAoC,EAAK;IACvD,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE;YACd,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;SACnB;QACD,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QACpB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAQ,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAE5B,wCAAwC;IACxC,MAAM,aAAa,GACjB,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAA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AU;QACnC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;QAC/B,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE;QACX,YAAY,CACV,yFAAyF,qBAAqB,uCAAuC,CACtJ,CAAC;QACF,kDAAkD;QAClD,OAAO,uBAAuB,CAAC;KAChC;IAED,kFAAkF;IAClF,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAnBD,wDAmBC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,4DAA4D;IAC5D;IACE,iCAAiC;IACjC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EACrC;QACA,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,KAAK,CAAC,GAAG,CAAC,CAAC;KACZ;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;KACtB;AACH,CAAC;AAED,SAAgB,0BAA0B,CAAC,QAAgB;IACzD,kCAAkC;IAClC,sCAAsC;IACtC,OAAO,0BAA0B,EAAE,GAAG,QAAQ,CAAC;AACjD,CAAC;AAJD,gEAIC","sourcesContent":["import Constants from 'expo-constants';\n\nconst protocolWarningString = `{ plugins: [[\"expo-router\", { origin: \"...<URL>...\" }]] }`;\n\n/** `lodash.memoize` */\nfunction memoize<T extends (...args: any[]) => any>(fn: T): T {\n const cache: Record<string, any> = {};\n return ((...args: any[]) => {\n const key = JSON.stringify(args);\n if (cache[key]) {\n return cache[key];\n }\n const result = fn(...args);\n cache[key] = result;\n return result;\n }) as any;\n}\n\nfunction sanitizeUrl(url: string): string {\n const parsed = new URL(url);\n\n // Allow empty protocol, http, and https\n const validProtocol =\n !parsed.protocol || parsed.protocol === 'http:' || parsed.protocol === 'https:';\n\n if (!validProtocol) {\n throwOrAlert(\n `Expo Head: Native origin has invalid protocol \"${parsed.protocol}\" for URL in Expo Config: ${protocolWarningString}.`\n );\n }\n\n parsed.pathname = '';\n parsed.search = '';\n parsed.hash = '';\n parsed.protocol ??= 'https:';\n\n return parsed.toString().replace(/\\/$/, '');\n}\n\nconst memoSanitizeUrl = memoize(sanitizeUrl);\n\nfunction getHeadOriginFromConstants(): string | null {\n // This will require a rebuild in bare-workflow to update.\n const manifest = Constants.expoConfig;\n\n const origin =\n manifest?.extra?.router?.headOrigin ??\n manifest?.extra?.router?.origin ??\n manifest?.extra?.router?.generatedOrigin;\n\n if (!origin) {\n throwOrAlert(\n `Expo Head: Add the handoff origin to the Expo Config (requires rebuild). Add the Config Plugin ${protocolWarningString}, where \\`origin\\` is the hosted URL.`\n );\n // Fallback value that shouldn't be used for real.\n return 'https://expo.dev';\n }\n\n // Without this, the URL will go to an IP address which is not allowed.\n if (!origin.match(/^http(s)?:\\/\\//)) {\n console.warn(\n `Expo Head: origin \"${origin}\" is missing a \\`https://\\` protocol. ${protocolWarningString}.`\n );\n }\n\n // Return the development URL last so the user gets all production warnings first.\n return memoSanitizeUrl(origin);\n}\n\nexport function getOriginFromConstants(): string | null {\n // This will require a rebuild in bare-workflow to update.\n const manifest = Constants.expoConfig;\n\n const origin =\n manifest?.extra?.router?.headOrigin ??\n manifest?.extra?.router?.origin ??\n manifest?.extra?.router?.generatedOrigin;\n\n if (!origin) {\n throwOrAlert(\n `Expo RSC: Add the origin to the Expo Config (requires rebuild). Add the Config Plugin ${protocolWarningString}, where \\`origin\\` is the hosted URL.`\n );\n // Fallback value that shouldn't be used for real.\n return 'http://localhost:3000';\n }\n\n // Return the development URL last so the user gets all production warnings first.\n return memoSanitizeUrl(origin);\n}\n\nfunction throwOrAlert(msg: string) {\n // Production apps fatally crash which is often not helpful.\n if (\n // @ts-ignore: process is defined\n process.env.NODE_ENV === 'production'\n ) {\n console.error(msg);\n alert(msg);\n } else {\n throw new Error(msg);\n }\n}\n\nexport function getStaticUrlFromExpoRouter(pathname: string) {\n // const host = \"https://expo.io\";\n // Append the URL we'd find in context\n return getHeadOriginFromConstants() + pathname;\n}\n"]}
package/build/hooks.d.ts CHANGED
@@ -1,20 +1,60 @@
1
1
  import { Router } from './imperative-api';
2
- import { RouteParams, RouteSegments, Routes, UnknownOutputParams } from './types';
3
- type SearchParams = Record<string, string | string[]>;
2
+ import { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';
3
+ /**
4
+ * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)
5
+ * of the navigator which contains the current screen.
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * import { useRootNavigationState } from 'expo-router';
10
+ *
11
+ * export default function Route() {
12
+ * const { routes } = useRootNavigationState();
13
+ *
14
+ * return <Text>{routes[0].name}</Text>;
15
+ * }
16
+ * ```
17
+ */
4
18
  export declare function useRootNavigationState(): any;
5
19
  export declare function useRouteInfo(): import("./LocationProvider").UrlObject;
6
- /** @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead, which returns a React `ref`. */
20
+ /**
21
+ * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,
22
+ * which returns a React `ref`.
23
+ */
7
24
  export declare function useRootNavigation(): import("@react-navigation/core").NavigationContainerRef<ReactNavigation.RootParamList> | null;
8
- /** @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null` if the `<NavigationContainer />` hasn't mounted yet. */
25
+ /**
26
+ * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`
27
+ * if the `<NavigationContainer />` hasn't mounted yet.
28
+ */
9
29
  export declare function useNavigationContainerRef(): import("@react-navigation/core").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
30
+ /**
31
+ *
32
+ * Returns the [Router](#router) object for imperative navigation.
33
+ *
34
+ * @example
35
+ *```tsx
36
+ * import { useRouter } from 'expo-router';
37
+ * import { Text } from 'react-native';
38
+ *
39
+ * export default function Route() {
40
+ * const router = useRouter();
41
+ *
42
+ * return (
43
+ * <Text onPress={() => router.push('/home')}>Go Home</Text>
44
+ * );
45
+ *}
46
+ * ```
47
+ */
10
48
  export declare function useRouter(): Router;
11
49
  /**
12
50
  * @private
13
- * @returns The current global pathname with query params attached. This may change in the future to include the hostname from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.
51
+ * @returns The current global pathname with query params attached. This may change in the future to include the hostname
52
+ * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.
14
53
  */
15
54
  export declare function useUnstableGlobalHref(): string;
16
55
  /**
17
- * Get a list of selected file segments for the currently selected route. Segments are not normalized, so they will be the same as the file path. For example: `/[id]?id=normal -> ["[id]"]`.
56
+ * Returns a list of selected file segments for the currently selected route. Segments are not normalized,
57
+ * so they will be the same as the file path. For example, `/[id]?id=normal` becomes `["[id]"]`.
18
58
  *
19
59
  * @example
20
60
  * ```tsx app/profile/[user].tsx
@@ -30,26 +70,28 @@ export declare function useUnstableGlobalHref(): string;
30
70
  * ```
31
71
  *
32
72
  *
33
- * `useSegments` can be typed using an abstract. Consider the following file structure, and strictly typed `useSegments` function:
73
+ * `useSegments` can be typed using an abstract. Consider the following file structure:
34
74
  *
35
75
  * ```md
36
76
  * - app
37
77
  * - [user]
38
- * - index.js
39
- * - followers.js
40
- * - settings.js
78
+ * - index.tsx
79
+ * - followers.tsx
80
+ * - settings.tsx
41
81
  * ```
42
82
  *
43
83
  *
44
- * This can be strictly typed using the following abstract:
84
+ * This can be strictly typed using the following abstract with `useSegments` hook:
45
85
  *
46
- * ```ts
86
+ * ```tsx
47
87
  * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()
48
88
  * ```
49
89
  */
50
- export declare function useSegments<TSegments extends Routes | RouteSegments<Routes> = Routes>(): TSegments extends string ? RouteSegments<TSegments> : TSegments;
90
+ export declare function useSegments<TSegments extends Route = Route>(): RouteSegments<TSegments>;
91
+ export declare function useSegments<TSegments extends RouteSegments<Route>>(): TSegments;
51
92
  /**
52
- * Global selected route location without search parameters. For example, `/acme?foo=bar` -> `/acme`. Segments will be normalized: `/[id]?id=normal` -> `/normal`.
93
+ * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.
94
+ * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.
53
95
  *
54
96
  * @example
55
97
  * ```tsx app/profile/[user].tsx
@@ -57,7 +99,7 @@ export declare function useSegments<TSegments extends Routes | RouteSegments<Rou
57
99
  * import { useSegments } from 'expo-router';
58
100
  *
59
101
  * export default function Route() {
60
- * // segments = ["profile", "[user]"]</b>
102
+ * // segments = ["profile", "[user]"]
61
103
  * const segments = useSegments();
62
104
  *
63
105
  * return <Text>Hello</Text>;
@@ -66,20 +108,17 @@ export declare function useSegments<TSegments extends Routes | RouteSegments<Rou
66
108
  */
67
109
  export declare function usePathname(): string;
68
110
  /**
69
- * @hidden
70
- */
71
- export declare function useGlobalSearchParams<TParams extends SearchParams = UnknownOutputParams>(): RouteParams<TParams>;
72
- /**
73
- * Get the globally selected query parameters, including dynamic path segments. This function will update even when the route is not focused.
74
- * Useful for analytics or other background operations that don't draw to the screen.
75
- *
76
- * When querying search params in a stack, opt-towards using [`useLocalSearchParams`](#uselocalsearchparams) as these will only update when the route is focused.
111
+ * Returns URL parameters for globally selected route, including dynamic path segments.
112
+ * This function updates even when the route is not focused. Useful for analytics or
113
+ * other background operations that don't draw to the screen.
77
114
  *
78
115
  * Route URL example: `acme://profile/baconbrix?extra=info`.
79
116
  *
80
- * > **Note:** See [local versus global search parameters](/router/reference/search-parameters/#local-versus-global-search-parameters) for usage
81
- * > information.
117
+ * When querying search params in a stack, opt-towards using
118
+ * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.
82
119
  *
120
+ * > **Note:** For usage information, see
121
+ * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).
83
122
  *
84
123
  * @example
85
124
  * ```tsx app/profile/[user].tsx
@@ -89,28 +128,41 @@ export declare function useGlobalSearchParams<TParams extends SearchParams = Unk
89
128
  * export default function Route() {
90
129
  * // user=baconbrix & extra=info
91
130
  * const { user, extra } = useGlobalSearchParams();
131
+ *
92
132
  * return <Text>User: {user}</Text>;
93
133
  * }
94
134
  * ```
95
- *
96
- */
97
- export declare function useGlobalSearchParams<TRoute extends Routes, TParams extends SearchParams = UnknownOutputParams>(): RouteParams<TRoute, TParams>;
98
- /**
99
- * @hidden
100
135
  */
101
- export declare function useLocalSearchParams<TParams extends SearchParams = UnknownOutputParams>(): RouteParams<TParams>;
136
+ export declare function useGlobalSearchParams<TParams extends UnknownOutputParams = UnknownOutputParams>(): TParams;
137
+ export declare function useGlobalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;
138
+ export declare function useGlobalSearchParams<TRoute extends Route, TParams extends UnknownOutputParams = UnknownOutputParams>(): RouteParams<TRoute> & TParams;
102
139
  /**
103
- * Returns the URL parameters for the contextually focused route. e.g. `/acme?foo=bar` -> `{ foo: "bar" }`.
104
- * This is useful for stacks where you may push a new screen that changes the query parameters.
105
- * For dynamic routes, both the route parameters and the search parameters are returned.
140
+ * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen
141
+ * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.
106
142
  *
107
- * To observe updates even when the invoking route is not focused, use `useGlobalSearchParams()`.
143
+ * Route URL example: `acme://profile/baconbrix?extra=info`.
144
+ *
145
+ * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).
146
+ *
147
+ * > **Note:** For usage information, see
148
+ * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).
149
+ *
150
+ * @example
151
+ * ```tsx app/profile/[user].tsx
152
+ * import { Text } from 'react-native';
153
+ * import { useLocalSearchParams } from 'expo-router';
108
154
  *
109
- * @see [`useGlobalSearchParams`](#useglobalsearchparams)
155
+ * export default function Route() {
156
+ * // user=baconbrix & extra=info
157
+ * const { user, extra } = useLocalSearchParams();
158
+ *
159
+ * return <Text>User: {user}</Text>;
160
+ * }
110
161
  */
111
- export declare function useLocalSearchParams<TRoute extends Routes, TParams extends SearchParams = UnknownOutputParams>(): RouteParams<TRoute, TParams>;
162
+ export declare function useLocalSearchParams<TParams extends UnknownOutputParams = UnknownOutputParams>(): TParams;
163
+ export declare function useLocalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;
164
+ export declare function useLocalSearchParams<TRoute extends Route, TParams extends UnknownOutputParams = UnknownOutputParams>(): RouteParams<TRoute> & TParams;
112
165
  export declare function useSearchParams({ global }?: {
113
166
  global?: boolean | undefined;
114
167
  }): URLSearchParams;
115
- export {};
116
168
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAElF,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AACtD,wBAAgB,sBAAsB,QAErC;AAED,wBAAgB,YAAY,2CAE3B;AAED,sHAAsH;AACtH,wBAAgB,iBAAiB,kGAEhC;AAED,uJAAuJ;AACvJ,wBAAgB,yBAAyB,sGAExC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAgBlC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,WAAW,CACzB,SAAS,SAAS,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,KACtD,SAAS,SAAS,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS,CAInE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,YAA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gB,WAAW,CAAC,SAAS,SAAS,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;AAKjF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,OAAO,CAAC;AACb,wBAAgB,qBAAqB,CAAC,MAAM,SAAS,KAAK,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;AACnF,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,KAAK,EACpB,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;AAKnC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,OAAO,CAAC;AACb,wBAAgB,oBAAoB,CAAC,MAAM,SAAS,KAAK,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;AAClF,wBAAgB,oBAAoB,CAClC,MAAM,SAAS,KAAK,EACpB,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;AA2BnC,wBAAgB,eAAe,CAAC,EAAE,MAAc,EAAE;;CAAK,GAAG,eAAe,CAsBxE"}
package/build/hooks.js CHANGED
@@ -8,6 +8,21 @@ exports.useSearchParams = exports.useLocalSearchParams = exports.useGlobalSearch
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const Route_1 = require("./Route");
10
10
  const router_store_1 = require("./global-state/router-store");
11
+ /**
12
+ * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)
13
+ * of the navigator which contains the current screen.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * import { useRootNavigationState } from 'expo-router';
18
+ *
19
+ * export default function Route() {
20
+ * const { routes } = useRootNavigationState();
21
+ *
22
+ * return <Text>{routes[0].name}</Text>;
23
+ * }
24
+ * ```
25
+ */
11
26
  function useRootNavigationState() {
12
27
  return (0, router_store_1.useStoreRootState)();
13
28
  }
@@ -16,16 +31,40 @@ function useRouteInfo() {
16
31
  return (0, router_store_1.useStoreRouteInfo)();
17
32
  }
18
33
  exports.useRouteInfo = useRouteInfo;
19
- /** @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead, which returns a React `ref`. */
34
+ /**
35
+ * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,
36
+ * which returns a React `ref`.
37
+ */
20
38
  function useRootNavigation() {
21
39
  return router_store_1.store.navigationRef.current;
22
40
  }
23
41
  exports.useRootNavigation = useRootNavigation;
24
- /** @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null` if the `<NavigationContainer />` hasn't mounted yet. */
42
+ /**
43
+ * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`
44
+ * if the `<NavigationContainer />` hasn't mounted yet.
45
+ */
25
46
  function useNavigationContainerRef() {
26
47
  return router_store_1.store.navigationRef;
27
48
  }
28
49
  exports.useNavigationContainerRef = useNavigationContainerRef;
50
+ /**
51
+ *
52
+ * Returns the [Router](#router) object for imperative navigation.
53
+ *
54
+ * @example
55
+ *```tsx
56
+ * import { useRouter } from 'expo-router';
57
+ * import { Text } from 'react-native';
58
+ *
59
+ * export default function Route() {
60
+ * const router = useRouter();
61
+ *
62
+ * return (
63
+ * <Text onPress={() => router.push('/home')}>Go Home</Text>
64
+ * );
65
+ *}
66
+ * ```
67
+ */
29
68
  function useRouter() {
30
69
  return react_1.default.useMemo(() => ({
31
70
  push: router_store_1.store.push,
@@ -43,52 +82,20 @@ function useRouter() {
43
82
  exports.useRouter = useRouter;
44
83
  /**
45
84
  * @private
46
- * @returns The current global pathname with query params attached. This may change in the future to include the hostname from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.
85
+ * @returns The current global pathname with query params attached. This may change in the future to include the hostname
86
+ * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.
47
87
  */
48
88
  function useUnstableGlobalHref() {
49
89
  return (0, router_store_1.useStoreRouteInfo)().unstable_globalHref;
50
90
  }
51
91
  exports.useUnstableGlobalHref = useUnstableGlobalHref;
52
- /**
53
- * Get a list of selected file segments for the currently selected route. Segments are not normalized, so they will be the same as the file path. For example: `/[id]?id=normal -> ["[id]"]`.
54
- *
55
- * @example
56
- * ```tsx app/profile/[user].tsx
57
- * import { Text } from 'react-native';
58
- * import { useSegments } from 'expo-router';
59
- *
60
- * export default function Route() {
61
- * // segments = ["profile", "[user]"]
62
- * const segments = useSegments();
63
- *
64
- * return <Text>Hello</Text>;
65
- * }
66
- * ```
67
- *
68
- *
69
- * `useSegments` can be typed using an abstract. Consider the following file structure, and strictly typed `useSegments` function:
70
- *
71
- * ```md
72
- * - app
73
- * - [user]
74
- * - index.js
75
- * - followers.js
76
- * - settings.js
77
- * ```
78
- *
79
- *
80
- * This can be strictly typed using the following abstract:
81
- *
82
- * ```ts
83
- * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()
84
- * ```
85
- */
86
92
  function useSegments() {
87
93
  return (0, router_store_1.useStoreRouteInfo)().segments;
88
94
  }
89
95
  exports.useSegments = useSegments;
90
96
  /**
91
- * Global selected route location without search parameters. For example, `/acme?foo=bar` -> `/acme`. Segments will be normalized: `/[id]?id=normal` -> `/normal`.
97
+ * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.
98
+ * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.
92
99
  *
93
100
  * @example
94
101
  * ```tsx app/profile/[user].tsx
@@ -96,7 +103,7 @@ exports.useSegments = useSegments;
96
103
  * import { useSegments } from 'expo-router';
97
104
  *
98
105
  * export default function Route() {
99
- * // segments = ["profile", "[user]"]</b>
106
+ * // segments = ["profile", "[user]"]
100
107
  * const segments = useSegments();
101
108
  *
102
109
  * return <Text>Hello</Text>;