expo-router 3.1.2 → 3.2.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 (127) hide show
  1. package/build/ExpoRoot.d.ts.map +1 -1
  2. package/build/ExpoRoot.js +57 -15
  3. package/build/ExpoRoot.js.map +1 -1
  4. package/build/LocationProvider.d.ts +3 -2
  5. package/build/LocationProvider.d.ts.map +1 -1
  6. package/build/LocationProvider.js +17 -5
  7. package/build/LocationProvider.js.map +1 -1
  8. package/build/Route.d.ts +1 -0
  9. package/build/Route.d.ts.map +1 -1
  10. package/build/Route.js +1 -1
  11. package/build/Route.js.map +1 -1
  12. package/build/fork/NavigationContainer.native.js +5 -3
  13. package/build/fork/NavigationContainer.native.js.map +1 -1
  14. package/build/fork/extractPathFromURL.d.ts.map +1 -1
  15. package/build/fork/extractPathFromURL.js +17 -16
  16. package/build/fork/extractPathFromURL.js.map +1 -1
  17. package/build/fork/getPathFromState.d.ts +1 -1
  18. package/build/fork/getPathFromState.d.ts.map +1 -1
  19. package/build/fork/getPathFromState.js +10 -35
  20. package/build/fork/getPathFromState.js.map +1 -1
  21. package/build/fork/getStateFromPath.d.ts +2 -2
  22. package/build/fork/getStateFromPath.d.ts.map +1 -1
  23. package/build/fork/getStateFromPath.js +59 -48
  24. package/build/fork/getStateFromPath.js.map +1 -1
  25. package/build/getDevServer/index.d.ts +0 -3
  26. package/build/getDevServer/index.d.ts.map +1 -1
  27. package/build/getDevServer/index.js +1 -28
  28. package/build/getDevServer/index.js.map +1 -1
  29. package/build/getReactNavigationConfig.d.ts.map +1 -1
  30. package/build/getReactNavigationConfig.js +3 -0
  31. package/build/getReactNavigationConfig.js.map +1 -1
  32. package/build/getRoutes.d.ts +1 -2
  33. package/build/getRoutes.d.ts.map +1 -1
  34. package/build/getRoutes.js +51 -49
  35. package/build/getRoutes.js.map +1 -1
  36. package/build/getServerManifest.d.ts +4 -0
  37. package/build/getServerManifest.d.ts.map +1 -1
  38. package/build/getServerManifest.js +6 -5
  39. package/build/getServerManifest.js.map +1 -1
  40. package/build/global-state/router-store.d.ts.map +1 -1
  41. package/build/global-state/router-store.js +28 -2
  42. package/build/global-state/router-store.js.map +1 -1
  43. package/build/global-state/routing.d.ts +0 -4
  44. package/build/global-state/routing.d.ts.map +1 -1
  45. package/build/global-state/routing.js +75 -95
  46. package/build/global-state/routing.js.map +1 -1
  47. package/build/head/ExpoHead.ios.js +4 -4
  48. package/build/head/ExpoHead.ios.js.map +1 -1
  49. package/build/head/ExpoHead.js +1 -1
  50. package/build/head/ExpoHead.js.map +1 -1
  51. package/build/head/url.d.ts.map +1 -1
  52. package/build/head/url.js +5 -6
  53. package/build/head/url.js.map +1 -1
  54. package/build/layouts/Tabs.js +2 -2
  55. package/build/layouts/Tabs.js.map +1 -1
  56. package/build/layouts/withLayoutContext.js +1 -1
  57. package/build/layouts/withLayoutContext.js.map +1 -1
  58. package/build/link/Link.d.ts +54 -1
  59. package/build/link/Link.d.ts.map +1 -1
  60. package/build/link/Link.js +54 -12
  61. package/build/link/Link.js.map +1 -1
  62. package/build/link/useLinkToPathProps.js +2 -2
  63. package/build/link/useLinkToPathProps.js.map +1 -1
  64. package/build/matchers.js +1 -1
  65. package/build/matchers.js.map +1 -1
  66. package/build/onboard/Tutorial.js +41 -34
  67. package/build/onboard/Tutorial.js.map +1 -1
  68. package/build/qualified-entry.js +3 -2
  69. package/build/qualified-entry.js.map +1 -1
  70. package/build/renderRootComponent.d.ts.map +1 -1
  71. package/build/renderRootComponent.js +28 -4
  72. package/build/renderRootComponent.js.map +1 -1
  73. package/build/routes-manifest.d.ts +1 -0
  74. package/build/routes-manifest.d.ts.map +1 -1
  75. package/build/routes-manifest.js.map +1 -1
  76. package/build/sortRoutes.d.ts.map +1 -1
  77. package/build/sortRoutes.js +21 -2
  78. package/build/sortRoutes.js.map +1 -1
  79. package/build/static/html.js +11 -9
  80. package/build/static/html.js.map +1 -1
  81. package/build/static/renderStaticContent.d.ts +39 -2
  82. package/build/static/renderStaticContent.d.ts.map +1 -1
  83. package/build/static/renderStaticContent.js +28 -6
  84. package/build/static/renderStaticContent.js.map +1 -1
  85. package/build/testing-library/index.js +2 -2
  86. package/build/testing-library/index.js.map +1 -1
  87. package/build/testing-library/mocks.d.ts +1 -3
  88. package/build/testing-library/mocks.d.ts.map +1 -1
  89. package/build/testing-library/mocks.js +7 -5
  90. package/build/testing-library/mocks.js.map +1 -1
  91. package/build/testing-library/require-context-ponyfill.js +3 -3
  92. package/build/testing-library/require-context-ponyfill.js.map +1 -1
  93. package/build/useScreens.js +19 -16
  94. package/build/useScreens.js.map +1 -1
  95. package/build/views/EmptyRoute.js +5 -2
  96. package/build/views/EmptyRoute.js.map +1 -1
  97. package/build/views/ErrorBoundary.js +43 -28
  98. package/build/views/ErrorBoundary.js.map +1 -1
  99. package/build/views/Navigator.js +16 -10
  100. package/build/views/Navigator.js.map +1 -1
  101. package/build/views/Sitemap.js +49 -35
  102. package/build/views/Sitemap.js.map +1 -1
  103. package/build/views/Splash.d.ts +1 -27
  104. package/build/views/Splash.d.ts.map +1 -1
  105. package/build/views/Splash.js +2 -112
  106. package/build/views/Splash.js.map +1 -1
  107. package/build/views/SuspenseFallback.js +3 -2
  108. package/build/views/SuspenseFallback.js.map +1 -1
  109. package/build/views/Toast.js +23 -18
  110. package/build/views/Toast.js.map +1 -1
  111. package/build/views/Try.js +1 -1
  112. package/build/views/Try.js.map +1 -1
  113. package/build/views/Unmatched.js +29 -17
  114. package/build/views/Unmatched.js.map +1 -1
  115. package/ios/ExpoHead.podspec +1 -1
  116. package/package.json +7 -18
  117. package/build/fork/react-native-web-container.d.ts +0 -8
  118. package/build/fork/react-native-web-container.d.ts.map +0 -1
  119. package/build/fork/react-native-web-container.js +0 -8
  120. package/build/fork/react-native-web-container.js.map +0 -1
  121. package/build/link/stateOperations.d.ts +0 -81
  122. package/build/link/stateOperations.d.ts.map +0 -1
  123. package/build/link/stateOperations.js +0 -105
  124. package/build/link/stateOperations.js.map +0 -1
  125. package/types/global.d.ts +0 -38
  126. package/types/metro-require.d.ts +0 -52
  127. package/types/react-native-web.d.ts +0 -295
@@ -1 +1 @@
1
- {"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;AAAA,qDAIkC;AAClC,iCAA+E;AAE/E,uCAAgF;AAChF,+CAAgD;AAChD,0DAAuE;AAEvE,+DAA2E;AAE3E,0DAA2E;AAC3E,4CAAyC;AAEzC,8CAA2D;AAC3D,4CAA2D;AAE3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAiC;IAChC,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAA0B;IACtC,SAAS,CAA0B;IACnC,SAAS,CAA0B;IACnC,SAAS,CAAyB;IAElC,aAAa,CAAoE;IACjF,yBAAyB,CAAc;IAEvC,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;IAC7C,gBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;IAEzC,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,eAAe,GAAG,6BAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,GAAG,mBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,GAAG,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,SAAS,GAAG,mBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjC,UAAU,CACR,OAAuB,EACvB,aAA+E,EAC/E,eAAqB;QAErB,8BAA8B;QAC9B,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,SA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UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,EAC/D,CAAC,OAAO,EAAE,eAAe,CAAC,CAC3B,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AARD,0DAQC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\n\nimport { canGoBack, goBack, linkTo, push, replace, setParams } from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { deepEqual, getPathDataFromState } from '../fork/getPathFromState';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport { _internal_maybeHideAsync } from '../views/Splash';\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking: ExpoLinkingOptions | undefined;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState: ResultState | undefined;\n rootState: ResultState | undefined;\n nextState: ResultState | undefined;\n routeInfo?: UrlObject | undefined;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n replace = replace.bind(this);\n setParams = setParams.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n initialLocation?: URL\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.routeInfo = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context);\n\n this.rootComponent = this.routeNode ? getQualifiedRouteComponent(this.routeNode) : Fragment;\n\n // Only error in production, in development we will show the onboarding screen\n if (!this.routeNode && process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n this.navigationRef = navigationRef;\n\n if (this.routeNode) {\n this.linking = getLinkingConfig(this.routeNode!);\n\n if (initialLocation) {\n this.linking.getInitialURL = () => initialLocation.toString();\n this.initialState = this.linking.getStateFromPath?.(\n initialLocation.pathname + initialLocation.search,\n this.linking.config\n );\n }\n }\n\n // There is no routeNode, so we will be showing the onboarding screen\n // In the meantime, just mock the routeInfo\n if (this.initialState) {\n this.rootState = this.initialState;\n this.routeInfo = this.getRouteInfo(this.initialState);\n } else {\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n params: {},\n segments: [],\n };\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigations state change and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n requestAnimationFrame(() => _internal_maybeHideAsync());\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!deepEqual(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: [],\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, initialLocation: URL | undefined) {\n const navigationRef = useNavigationContainerRef();\n useMemo(\n () => store.initialize(context, navigationRef, initialLocation),\n [context, initialLocation]\n );\n useExpoRouter();\n return store;\n}\n"]}
1
+ {"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAIkC;AAClC,iEAAmD;AACnD,iCAA+E;AAE/E,uCAAgF;AAChF,+CAAgD;AAChD,0DAAuE;AAEvE,+DAA2E;AAE3E,0DAA2E;AAC3E,4CAAyC;AAEzC,8CAA2D;AAE3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAiC;IAChC,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAA0B;IACtC,SAAS,CAA0B;IACnC,SAAS,CAA0B;IACnC,SAAS,CAAyB;IAElC,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,CA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AA,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,eAAgC;IAC/F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EACL,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,EAC/D,CAAC,OAAO,EAAE,eAAe,CAAC,CAC3B,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AARD,0DAQC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\n\nimport { canGoBack, goBack, linkTo, push, replace, setParams } from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { deepEqual, getPathDataFromState } from '../fork/getPathFromState';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking: ExpoLinkingOptions | undefined;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState: ResultState | undefined;\n rootState: ResultState | undefined;\n nextState: ResultState | undefined;\n routeInfo?: UrlObject | undefined;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n replace = replace.bind(this);\n setParams = setParams.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n initialLocation?: URL\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.routeInfo = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context);\n\n this.rootComponent = this.routeNode ? getQualifiedRouteComponent(this.routeNode) : Fragment;\n\n // Only error in production, in development we will show the onboarding screen\n if (!this.routeNode && process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n this.navigationRef = navigationRef;\n\n if (this.routeNode) {\n this.linking = getLinkingConfig(this.routeNode!);\n\n if (initialLocation) {\n this.linking.getInitialURL = () => initialLocation.toString();\n this.initialState = this.linking.getStateFromPath?.(\n initialLocation.pathname + initialLocation.search,\n this.linking.config\n );\n }\n }\n\n // There is no routeNode, so we will be showing the onboarding screen\n // In the meantime, just mock the routeInfo\n if (this.initialState) {\n this.rootState = this.initialState;\n this.routeInfo = this.getRouteInfo(this.initialState);\n } else {\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigations state change and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n requestAnimationFrame(\n () =>\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.()\n );\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!deepEqual(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: [],\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, initialLocation: URL | undefined) {\n const navigationRef = useNavigationContainerRef();\n useMemo(\n () => store.initialize(context, navigationRef, initialLocation),\n [context, initialLocation]\n );\n useExpoRouter();\n return store;\n}\n"]}
@@ -1,13 +1,9 @@
1
- import { getActionFromState } from '@react-navigation/core';
2
1
  import type { RouterStore } from './router-store';
3
2
  import { Href } from '../link/href';
4
- import { NavigateAction } from '../link/stateOperations';
5
3
  export declare function push(this: RouterStore, url: Href): any;
6
4
  export declare function replace(this: RouterStore, url: Href): any;
7
5
  export declare function goBack(this: RouterStore): void;
8
6
  export declare function canGoBack(this: RouterStore): boolean;
9
7
  export declare function setParams(this: RouterStore, params?: Record<string, string | number>): any;
10
8
  export declare function linkTo(this: RouterStore, href: string, event?: string): void;
11
- /** @returns `true` if the action is moving to the first screen of all the navigators in the action. */
12
- export declare function isAbsoluteInitialRoute(action: ReturnType<typeof getActionFromState>): action is NavigateAction;
13
9
  //# sourceMappingURL=routing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,kBAAkB,EA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D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAM,OAGxF;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,QAqErE"}
@@ -23,13 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.isAbsoluteInitialRoute = exports.linkTo = exports.setParams = exports.canGoBack = exports.goBack = exports.replace = exports.push = void 0;
27
- const core_1 = require("@react-navigation/core");
28
- const native_1 = require("@react-navigation/native");
26
+ exports.linkTo = exports.setParams = exports.canGoBack = exports.goBack = exports.replace = exports.push = void 0;
29
27
  const Linking = __importStar(require("expo-linking"));
30
28
  const href_1 = require("../link/href");
31
29
  const path_1 = require("../link/path");
32
- const stateOperations_1 = require("../link/stateOperations");
33
30
  const url_1 = require("../utils/url");
34
31
  function assertIsReady(store) {
35
32
  if (!store.navigationRef.isReady()) {
@@ -83,111 +80,94 @@ function linkTo(href, event) {
83
80
  navigationRef.goBack();
84
81
  return;
85
82
  }
86
- if (href.startsWith('.')) {
87
- let base = this.linking.getPathFromState?.(navigationRef.getRootState(), {
88
- screens: [],
89
- preserveGroups: true,
90
- }) ?? '';
91
- if (base && !base.endsWith('/')) {
92
- base += '/..';
93
- }
94
- href = (0, path_1.resolve)(base, href);
95
- }
96
- const state = this.linking.getStateFromPath(href, this.linking.config);
97
- if (!state) {
98
- console.error('Could not generate a valid navigation state for the given path: ' + href);
99
- return;
100
- }
101
83
  const rootState = navigationRef.getRootState();
102
- // Ensure simple operations are used when moving between siblings
103
- // in the same navigator. This ensures that the state is not reset.
104
- // TODO: We may need to apply this at a larger scale in the future.
105
- if ((0, stateOperations_1.isMovingToSiblingRoute)(rootState, state)) {
106
- // Can perform naive movements
107
- const knownOwnerState = (0, stateOperations_1.getQualifiedStateForTopOfTargetState)(rootState, state);
108
- const nextRoute = (0, stateOperations_1.findTopRouteForTarget)(state);
109
- // NOTE(EvanBacon): There's an issue where moving from "a -> b" is considered siblings:
110
- // a. index (initialRouteName="index")
111
- // b. stack/index
112
- // However, the preservation approach doesn't work because it would be moving to a route with the same name.
113
- // The next check will see if the current focused route has the same name as the next route, if so, then fallback on
114
- // the default React Navigation logic.
115
- if ((0, stateOperations_1.findTopRouteForTarget)(
116
- // @ts-expect-error: stale types don't matter here
117
- rootState)?.name !== nextRoute.name) {
118
- if (event === 'REPLACE') {
119
- if (knownOwnerState.type === 'tab') {
120
- navigationRef.dispatch(native_1.TabActions.jumpTo(nextRoute.name, nextRoute.params));
84
+ if (href.startsWith('.')) {
85
+ // Resolve base path by merging the current segments with the params
86
+ let base = this.routeInfo?.segments
87
+ ?.map((segment) => {
88
+ if (!segment.startsWith('['))
89
+ return segment;
90
+ if (segment.startsWith('[...')) {
91
+ segment = segment.slice(4, -1);
92
+ const params = this.routeInfo?.params?.[segment];
93
+ if (Array.isArray(params)) {
94
+ return params.join('/');
121
95
  }
122
96
  else {
123
- navigationRef.dispatch(core_1.StackActions.replace(nextRoute.name, nextRoute.params));
97
+ return params?.split(',')?.join('/') ?? '';
124
98
  }
125
99
  }
126
100
  else {
127
- // NOTE: Not sure if we should pop or push here...
128
- navigationRef.dispatch(core_1.CommonActions.navigate(nextRoute.name, nextRoute.params));
101
+ segment = segment.slice(1, -1);
102
+ return this.routeInfo?.params?.[segment];
129
103
  }
130
- return;
104
+ })
105
+ .filter(Boolean)
106
+ .join('/') ?? '/';
107
+ if (!this.routeInfo?.isIndex) {
108
+ base += '/..';
131
109
  }
110
+ href = (0, path_1.resolve)(base, href);
132
111
  }
133
- // TODO: Advanced movements across multiple navigators
134
- const action = (0, core_1.getActionFromState)(state, this.linking.config);
135
- if (action) {
136
- // Here we have a navigation action to a nested screen, where we should ideally replace.
137
- // This request can only be fulfilled if the target is an initial route.
138
- // First, check if the action is fully initial routes.
139
- // Then find the nearest mismatched route in the existing state.
140
- // Finally, use the correct navigator-based action to replace the nested screens.
141
- // NOTE(EvanBacon): A future version of this will involve splitting the navigation request so we replace as much as possible, then push the remaining screens to fulfill the request.
142
- if (event === 'REPLACE' && isAbsoluteInitialRoute(action)) {
143
- const earliest = (0, stateOperations_1.getEarliestMismatchedRoute)(rootState, action.payload);
144
- if (earliest) {
145
- if (earliest.type === 'stack') {
146
- navigationRef.dispatch(core_1.StackActions.replace(earliest.name, earliest.params));
147
- }
148
- else {
149
- navigationRef.dispatch(native_1.TabActions.jumpTo(earliest.name, earliest.params));
150
- }
151
- return;
152
- }
153
- else {
154
- // This should never happen because moving to the same route would be handled earlier
155
- // in the sibling operations.
156
- }
157
- }
158
- // Ignore the replace event here since replace across
159
- // navigators is not supported.
160
- navigationRef.dispatch(action);
112
+ const state = this.linking.getStateFromPath(href, this.linking.config);
113
+ if (!state || state.routes.length === 0) {
114
+ console.error('Could not generate a valid navigation state for the given path: ' + href);
115
+ return;
161
116
  }
162
- else {
163
- navigationRef.reset(state);
117
+ switch (event) {
118
+ case 'REPLACE':
119
+ return navigationRef.dispatch(getNavigateReplaceAction(state, rootState));
120
+ default:
121
+ return navigationRef.dispatch(getNavigatePushAction(state, rootState));
164
122
  }
165
123
  }
166
124
  exports.linkTo = linkTo;
167
- /** @returns `true` if the action is moving to the first screen of all the navigators in the action. */
168
- function isAbsoluteInitialRoute(action) {
169
- if (action?.type !== 'NAVIGATE') {
170
- return false;
125
+ function rewriteNavigationStateToParams(state, params = {}) {
126
+ if (!state)
127
+ return params;
128
+ // We Should always have at least one route in the state
129
+ const lastRoute = state.routes.at(-1);
130
+ params.screen = lastRoute.name;
131
+ // Weirdly, this always needs to be an object. If it's undefined, it won't work.
132
+ params.params = lastRoute.params ? JSON.parse(JSON.stringify(lastRoute.params)) : {};
133
+ if (lastRoute.state) {
134
+ rewriteNavigationStateToParams(lastRoute.state, params.params);
171
135
  }
172
- let next = action.payload.params;
173
- // iterate all child screens and bail out if any are not initial.
174
- while (next) {
175
- if (!isNavigationState(next)) {
176
- // Not sure when this would happen
177
- return false;
178
- }
179
- if (next.initial === true) {
180
- next = next.params;
181
- // return true;
182
- }
183
- else if (next.initial === false) {
184
- return false;
185
- }
186
- }
187
- return true;
136
+ return JSON.parse(JSON.stringify(params));
188
137
  }
189
- exports.isAbsoluteInitialRoute = isAbsoluteInitialRoute;
190
- function isNavigationState(obj) {
191
- return 'initial' in obj;
138
+ function getNavigatePushAction(state, rootState) {
139
+ const { screen, params } = rewriteNavigationStateToParams(state);
140
+ return {
141
+ type: 'NAVIGATE',
142
+ target: rootState.key,
143
+ payload: {
144
+ name: screen,
145
+ params,
146
+ },
147
+ };
148
+ }
149
+ function getNavigateReplaceAction(state, parentState, lastNavigatorSupportingReplace = parentState) {
150
+ // We should always have at least one route in the state
151
+ const route = state.routes.at(-1);
152
+ // Only these navigators support replace
153
+ if (parentState.type === 'stack' || parentState.type === 'tab') {
154
+ lastNavigatorSupportingReplace = parentState;
155
+ }
156
+ const currentRoute = parentState.routes.find((parentRoute) => parentRoute.name === route.name);
157
+ const routesAreEqual = parentState.routes[parentState.index] === currentRoute;
158
+ // If there is nested state and the routes are equal, we should keep going down the tree
159
+ if (route.state && routesAreEqual && currentRoute.state) {
160
+ return getNavigateReplaceAction(route.state, currentRoute.state, lastNavigatorSupportingReplace);
161
+ }
162
+ // Either we reached the bottom of the state or the point where the routes diverged
163
+ const { screen, params } = rewriteNavigationStateToParams(state);
164
+ return {
165
+ type: lastNavigatorSupportingReplace.type === 'stack' ? 'REPLACE' : 'JUMP_TO',
166
+ target: lastNavigatorSupportingReplace?.key,
167
+ payload: {
168
+ name: screen,
169
+ params,
170
+ },
171
+ };
192
172
  }
193
173
  //# sourceMappingURL=routing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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,SAAS,IAAI,GAAG,CAAC;AAC1B,CAAC","sourcesContent":["import { CommonActions, getActionFromState, StackActions } from '@react-navigation/core';\nimport { TabActions } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport type { RouterStore } from './router-store';\nimport { Href, resolveHref } from '../link/href';\nimport { resolve } from '../link/path';\nimport {\n NavigateAction,\n findTopRouteForTarget,\n getEarliestMismatchedRoute,\n getQualifiedStateForTopOfTargetState,\n isMovingToSiblingRoute,\n} from '../link/stateOperations';\nimport { hasUrlProtocolPrefix } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport function push(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url));\n}\n\nexport function replace(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'REPLACE');\n}\n\nexport function goBack(this: RouterStore) {\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function setParams(this: RouterStore, params: Record<string, string | number> = {}) {\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport function linkTo(this: RouterStore, href: string, event?: string) {\n if (hasUrlProtocolPrefix(href)) {\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n if (href.startsWith('.')) {\n let base =\n this.linking.getPathFromState?.(navigationRef.getRootState(), {\n screens: [],\n preserveGroups: true,\n }) ?? '';\n\n if (base && !base.endsWith('/')) {\n base += '/..';\n }\n href = resolve(base, href);\n }\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n // Ensure simple operations are used when moving between siblings\n // in the same navigator. This ensures that the state is not reset.\n // TODO: We may need to apply this at a larger scale in the future.\n if (isMovingToSiblingRoute(rootState, state)) {\n // Can perform naive movements\n const knownOwnerState = getQualifiedStateForTopOfTargetState(rootState, state)!;\n const nextRoute = findTopRouteForTarget(state);\n // NOTE(EvanBacon): There's an issue where moving from \"a -> b\" is considered siblings:\n // a. index (initialRouteName=\"index\")\n // b. stack/index\n // However, the preservation approach doesn't work because it would be moving to a route with the same name.\n // The next check will see if the current focused route has the same name as the next route, if so, then fallback on\n // the default React Navigation logic.\n if (\n findTopRouteForTarget(\n // @ts-expect-error: stale types don't matter here\n rootState\n )?.name !== nextRoute.name\n ) {\n if (event === 'REPLACE') {\n if (knownOwnerState.type === 'tab') {\n navigationRef.dispatch(TabActions.jumpTo(nextRoute.name, nextRoute.params));\n } else {\n navigationRef.dispatch(StackActions.replace(nextRoute.name, nextRoute.params));\n }\n } else {\n // NOTE: Not sure if we should pop or push here...\n navigationRef.dispatch(CommonActions.navigate(nextRoute.name, nextRoute.params));\n }\n return;\n }\n }\n\n // TODO: Advanced movements across multiple navigators\n\n const action = getActionFromState(state, this.linking.config);\n if (action) {\n // Here we have a navigation action to a nested screen, where we should ideally replace.\n // This request can only be fulfilled if the target is an initial route.\n // First, check if the action is fully initial routes.\n // Then find the nearest mismatched route in the existing state.\n // Finally, use the correct navigator-based action to replace the nested screens.\n // NOTE(EvanBacon): A future version of this will involve splitting the navigation request so we replace as much as possible, then push the remaining screens to fulfill the request.\n if (event === 'REPLACE' && isAbsoluteInitialRoute(action)) {\n const earliest = getEarliestMismatchedRoute(rootState, action.payload);\n if (earliest) {\n if (earliest.type === 'stack') {\n navigationRef.dispatch(StackActions.replace(earliest.name, earliest.params));\n } else {\n navigationRef.dispatch(TabActions.jumpTo(earliest.name, earliest.params));\n }\n return;\n } else {\n // This should never happen because moving to the same route would be handled earlier\n // in the sibling operations.\n }\n }\n\n // Ignore the replace event here since replace across\n // navigators is not supported.\n navigationRef.dispatch(action);\n } else {\n navigationRef.reset(state);\n }\n}\n\n/** @returns `true` if the action is moving to the first screen of all the navigators in the action. */\nexport function isAbsoluteInitialRoute(\n action: ReturnType<typeof getActionFromState>\n): action is NavigateAction {\n if (action?.type !== 'NAVIGATE') {\n return false;\n }\n\n let next = action.payload.params;\n // iterate all child screens and bail out if any are not initial.\n while (next) {\n if (!isNavigationState(next)) {\n // Not sure when this would happen\n return false;\n }\n if (next.initial === true) {\n next = next.params;\n // return true;\n } else if (next.initial === false) {\n return false;\n }\n }\n\n return true;\n}\n\ntype NavStateParams = {\n params?: NavStateParams;\n path: string;\n initial: boolean;\n screen: string;\n state: unknown;\n};\n\nfunction isNavigationState(obj: any): obj is NavStateParams {\n return 'initial' in obj;\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AAIxC,uCAAiD;AACjD,uCAAuC;AACvC,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;AAED,SAAgB,IAAI,CAAoB,GAAS;IAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,CAAC,CAAC;AACvC,CAA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7E,MAAM,EAAE,8BAA8B,EAAE,GAAG;QAC3C,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { type NavigationAction, type NavigationState } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport type { RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { Href, resolveHref } from '../link/href';\nimport { resolve } from '../link/path';\nimport { hasUrlProtocolPrefix } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport function push(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url));\n}\n\nexport function replace(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'REPLACE');\n}\n\nexport function goBack(this: RouterStore) {\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function setParams(this: RouterStore, params: Record<string, string | number> = {}) {\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport function linkTo(this: RouterStore, href: string, event?: string) {\n if (hasUrlProtocolPrefix(href)) {\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n if (href.startsWith('.')) {\n // Resolve base path by merging the current segments with the params\n let base =\n this.routeInfo?.segments\n ?.map((segment) => {\n if (!segment.startsWith('[')) return segment;\n\n if (segment.startsWith('[...')) {\n segment = segment.slice(4, -1);\n const params = this.routeInfo?.params?.[segment];\n if (Array.isArray(params)) {\n return params.join('/');\n } else {\n return params?.split(',')?.join('/') ?? '';\n }\n } else {\n segment = segment.slice(1, -1);\n return this.routeInfo?.params?.[segment];\n }\n })\n .filter(Boolean)\n .join('/') ?? '/';\n\n if (!this.routeInfo?.isIndex) {\n base += '/..';\n }\n\n href = resolve(base, href);\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 switch (event) {\n case 'REPLACE':\n return navigationRef.dispatch(getNavigateReplaceAction(state, rootState));\n default:\n return navigationRef.dispatch(getNavigatePushAction(state, rootState));\n }\n}\n\ntype NavigationParams = Partial<{\n screen: string;\n params: NavigationParams;\n}>;\n\nfunction rewriteNavigationStateToParams(\n state?: { routes: ResultState['routes'] },\n params: NavigationParams = {}\n) {\n if (!state) return params;\n // We Should always have at least one route in the state\n const lastRoute = state.routes.at(-1)!;\n params.screen = lastRoute.name;\n // Weirdly, this always needs to be an object. If it's undefined, it won't work.\n params.params = lastRoute.params ? JSON.parse(JSON.stringify(lastRoute.params)) : {};\n\n if (lastRoute.state) {\n rewriteNavigationStateToParams(lastRoute.state, params.params);\n }\n\n return JSON.parse(JSON.stringify(params));\n}\n\nfunction getNavigatePushAction(state: ResultState, rootState: NavigationState) {\n const { screen, params } = rewriteNavigationStateToParams(state);\n return {\n type: 'NAVIGATE',\n target: rootState.key,\n payload: {\n name: screen,\n params,\n },\n };\n}\n\nfunction getNavigateReplaceAction(\n state: ResultState,\n parentState: NavigationState,\n lastNavigatorSupportingReplace: NavigationState = parentState\n): NavigationAction {\n // We should always have at least one route in the state\n const route = state.routes.at(-1)!;\n\n // Only these navigators support replace\n if (parentState.type === 'stack' || parentState.type === 'tab') {\n lastNavigatorSupportingReplace = parentState;\n }\n\n const currentRoute = parentState.routes.find((parentRoute) => parentRoute.name === route.name);\n const routesAreEqual = parentState.routes[parentState.index] === currentRoute;\n\n // If there is nested state and the routes are equal, we should keep going down the tree\n if (route.state && routesAreEqual && currentRoute.state) {\n return getNavigateReplaceAction(\n route.state,\n currentRoute.state as any,\n lastNavigatorSupportingReplace\n );\n }\n\n // Either we reached the bottom of the state or the point where the routes diverged\n const { screen, params } = rewriteNavigationStateToParams(state);\n\n return {\n type: lastNavigatorSupportingReplace.type === 'stack' ? 'REPLACE' : 'JUMP_TO',\n target: lastNavigatorSupportingReplace?.key,\n payload: {\n name: screen,\n params,\n },\n };\n}\n"]}
@@ -144,19 +144,19 @@ function isTruthy(value) {
144
144
  function HeadNative(props) {
145
145
  const isFocused = (0, core_1.useIsFocused)();
146
146
  if (!isFocused) {
147
- return react_1.default.createElement(UnfocusedHead, null);
147
+ return <UnfocusedHead />;
148
148
  }
149
- return react_1.default.createElement(FocusedHead, { ...props });
149
+ return <FocusedHead {...props}/>;
150
150
  }
151
151
  function UnfocusedHead(props) {
152
152
  const { children } = useMetaChildren(props.children);
153
- return react_1.default.createElement(react_1.default.Fragment, null, children);
153
+ return <>{children}</>;
154
154
  }
155
155
  function FocusedHead(props) {
156
156
  const { metaChildren, children } = useMetaChildren(props.children);
157
157
  const activity = useActivityFromMetaChildren(metaChildren);
158
158
  useRegisterCurrentActivity(activity);
159
- return react_1.default.createElement(react_1.default.Fragment, null, children);
159
+ return <>{children}</>;
160
160
  }
161
161
  // segments => activity
162
162
  const activities = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoHead.ios.js","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":";;;;;;AAAA,iDAAsD;AACtD,kDAA0B;AAE1B,qDAA0D;AAC1D,+BAAmD;AACnD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,CAAC;QAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE;YACjC,OAAO,KAAK,CAAC;SACd;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAChE;IACD,OAAO,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAED,UAAU,CAAC,QAAQ,GAAG,eAAK,CAAC,QAAQ,CAAC;AAErC,SAAS,QAAQ,CAAC,KAAqC;IACrD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,QAAQ,CAAC,QAAQ,GAAG,eAAK,CAAC,QAAQ,CAAC;AAEnC,gDAAgD;AACnC,QAAA,IAAI,GAEb,yBAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC","sourcesContent":["import { useIsFocused } from '@react-navigation/core';\nimport React from 'react';\n\nimport { ExpoHead, UserActivity } from './ExpoHeadModule';\nimport { getStaticUrlFromExpoRouter } from './url';\nimport { useLocalSearchParams, useUnstableGlobalHref, usePathname, useSegments } from '../hooks';\n\nfunction urlToId(url: string) {\n return url.replace(/[^a-zA-Z0-9]/g, '-');\n}\n\nfunction getLastSegment(path: string) {\n // Remove the extension\n const lastSegment = path.split('/').pop() ?? '';\n return lastSegment.replace(/\\.[^/.]+$/, '').split('?')[0];\n}\n\n// TODO: Use Head Provider to collect all props so only one Head is rendered for a given route.\n\nfunction useAddressableLink() {\n const pathname = useUnstableGlobalHref();\n const params = useLocalSearchParams<any>();\n const url = getStaticUrlFromExpoRouter(pathname);\n return { url, pathname, params };\n}\n\ntype MetaNode =\n | React.ReactPortal\n | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;\n\nfunction useMetaChildren(children: React.ReactNode) {\n return React.useMemo(() => {\n const renderableChildren: React.ReactNode[] = [];\n const metaChildren: MetaNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) {\n return;\n }\n if (typeof child.type === 'string') {\n metaChildren.push(child);\n } else {\n renderableChildren.push(child);\n }\n });\n\n return { children: renderableChildren, metaChildren };\n }, [children]);\n}\n\ntype SerializedMeta = {\n type: string;\n props: { [key: string]: string | undefined };\n};\n\nfunction serializedMetaChildren(meta: MetaNode[]): SerializedMeta[] {\n const validMeta = meta.filter((child) => child.type === 'meta' || child.type === 'title');\n\n return validMeta.map((child) => {\n if (child.type === 'title') {\n return {\n type: 'title',\n props: {\n children: typeof child.props.children === 'string' ? child.props.children : undefined,\n },\n };\n }\n return {\n type: 'meta',\n props: {\n property: typeof child.props.property === 'string' ? child.props.property : undefined,\n content: typeof child.props.content === 'string' ? child.props.content : undefined,\n },\n };\n });\n}\n\nfunction useActivityFromMetaChildren(meta: MetaNode[]) {\n const { url: href, pathname } = useAddressableLink();\n\n const previousMeta = React.useRef<SerializedMeta[]>([]);\n const cachedActivity = React.useRef<Partial<UserActivity>>({});\n\n const sortedMeta = React.useMemo(() => serializedMetaChildren(meta), [meta]);\n\n const url = React.useMemo(() => {\n const urlMeta = sortedMeta.find(\n (child) => child.type === 'meta' && child.props.property === 'og:url'\n );\n\n if (urlMeta) {\n // Support =`/foo/bar` -> `https://example.com/foo/bar`\n if (urlMeta.props.content?.startsWith('/')) {\n return getStaticUrlFromExpoRouter(urlMeta.props.content);\n }\n return urlMeta.props.content;\n }\n return href;\n }, [sortedMeta, href]);\n\n const title = React.useMemo(() => {\n const titleTag = sortedMeta.find((child) => child.type === 'title');\n if (titleTag) {\n return titleTag.props.children ?? '';\n }\n const titleMeta = sortedMeta.find(\n (child) => child.type === 'meta' && child.props.property === 'og:title'\n );\n if (titleMeta) {\n return titleMeta.props.content ?? '';\n }\n\n return getLastSegment(pathname);\n }, [sortedMeta, pathname]);\n\n const activity = React.useMemo(() => {\n if (\n !!previousMeta.current &&\n !!cachedActivity.current &&\n deepObjectCompare(previousMeta.current, sortedMeta)\n ) {\n return cachedActivity.current;\n }\n previousMeta.current = sortedMeta;\n\n const userActivity: Partial<UserActivity> = {};\n\n sortedMeta.forEach((child) => {\n if (\n // <meta />\n child.type === 'meta'\n ) {\n const { property, content } = child.props;\n\n switch (property) {\n case 'og:description':\n userActivity.description = content;\n break;\n // Custom properties\n case 'expo:handoff':\n userActivity.isEligibleForHandoff = isTruthy(content);\n break;\n case 'expo:spotlight':\n userActivity.isEligibleForSearch = isTruthy(content);\n break;\n }\n\n // // <meta name=\"keywords\" content=\"foo,bar,baz\" />\n // if ([\"keywords\"].includes(name)) {\n // userActivity.keywords = Array.isArray(content)\n // ? content\n // : content.split(\",\");\n // }\n }\n });\n\n cachedActivity.current = userActivity;\n return userActivity;\n }, [meta, pathname, href]);\n\n const parsedActivity: UserActivity = {\n keywords: [title],\n ...activity,\n title,\n webpageURL: url,\n activityType: ExpoHead!.activities.INDEXED_ROUTE,\n userInfo: {\n // TODO: This may need to be versioned in the future, e.g. `_v1` if we change the format.\n href,\n },\n };\n\n return parsedActivity;\n}\n\nfunction isTruthy(value: any): boolean {\n return [true, 'true'].includes(value);\n}\n\nfunction HeadNative(props: { children?: React.ReactNode }) {\n const isFocused = useIsFocused();\n if (!isFocused) {\n return <UnfocusedHead />;\n }\n return <FocusedHead {...props} />;\n}\n\nfunction UnfocusedHead(props: { children?: React.ReactNode }): JSX.Element {\n const { children } = useMetaChildren(props.children);\n return <>{children}</>;\n}\n\nfunction FocusedHead(props: { children?: React.ReactNode }): JSX.Element {\n const { metaChildren, children } = useMetaChildren(props.children);\n const activity = useActivityFromMetaChildren(metaChildren);\n useRegisterCurrentActivity(activity);\n return <>{children}</>;\n}\n\n// segments => activity\nconst activities: Map<string, UserActivity> = new Map();\n\nfunction useRegisterCurrentActivity(activity: UserActivity) {\n // ID is tied to Expo Router and agnostic of URLs to ensure dynamic parameters are not considered.\n // Using all segments ensures that cascading routes are considered.\n const activityId = urlToId(usePathname() || '/');\n const cascadingId = urlToId(useSegments().join('-') || '-');\n const activityIds = Array.from(activities.keys());\n const cascadingActivity: UserActivity = React.useMemo(() => {\n // Get all nested activities together, then update the id to match the current pathname.\n // This enables cases like `/user/[name]/post/[id]` to match all nesting, while still having a URL-specific ID, i.e. `/user/evanbacon/post/123`\n const cascadingActivity = activities.has(cascadingId)\n ? {\n ...activities.get(cascadingId),\n ...activity,\n id: activityId,\n }\n : {\n ...activity,\n id: activityId,\n };\n activities.set(cascadingId, cascadingActivity);\n\n return cascadingActivity;\n }, [cascadingId, activityId, activity, activityIds]);\n\n const previousActivity = React.useRef<UserActivity | null>(null);\n\n React.useEffect(() => {\n if (!cascadingActivity) {\n return () => {};\n }\n if (\n !!previousActivity.current &&\n deepObjectCompare(previousActivity.current, cascadingActivity)\n ) {\n return () => {};\n }\n\n previousActivity.current = cascadingActivity;\n if (!cascadingActivity.id) {\n throw new Error('Activity must have an ID');\n }\n\n // If no features are enabled, then skip registering the activity\n if (cascadingActivity.isEligibleForHandoff || cascadingActivity.isEligibleForSearch) {\n ExpoHead?.createActivity(cascadingActivity);\n }\n\n return () => {};\n }, [cascadingActivity]);\n\n React.useEffect(() => {\n return () => {\n if (activityId) {\n ExpoHead?.suspendActivity(activityId);\n }\n };\n }, [activityId]);\n}\n\nfunction deepObjectCompare(a: any, b: any) {\n if (typeof a !== typeof b) {\n return false;\n }\n if (typeof a === 'object') {\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false;\n }\n if (Array.isArray(a)) {\n if (a.length !== b.length) {\n return false;\n }\n return a.every((item, index) => deepObjectCompare(item, b[index]));\n }\n // handle null\n if (a === null || b === null) {\n return a === b;\n }\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n return aKeys.every((key) => deepObjectCompare(a[key], b[key]));\n }\n return a === b;\n}\n\nHeadNative.Provider = React.Fragment;\n\nfunction HeadShim(props: { children?: React.ReactNode }) {\n return null;\n}\n\nHeadShim.Provider = React.Fragment;\n\n// Native Head is only enabled in bare iOS apps.\nexport const Head: ((props: { children?: React.ReactNode }) => React.ReactNode) & {\n Provider: React.ComponentType;\n} = ExpoHead ? HeadNative : HeadShim;\n"]}
1
+ {"version":3,"file":"ExpoHead.ios.js","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":";;;;;;AAAA,iDAAsD;AACtD,kDAA0B;AAE1B,qDAA0D;AAC1D,+BAAmD;AACnD,oCAAiG;AAEjG,SAAS,OAAO,CAAC,GAAW;IAC1B,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,uBAAuB;IACvB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IAChD,OAAO,WAAW,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,+FAA+F;AAE/F,SAAS,kBAAkB;IACzB,MAAM,QAAQ,GAAG,IAAA,6BAAqB,GAAE,CAAC;IACzC,MAAM,MAAM,GAAG,IAAA,4BAAoB,GAAO,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAA,gCAA0B,EAAC,QAAQ,CAAC,CAAC;IACjD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC;AAMD,SAAS,eAAe,CAAC,QAAyB;IAChD,OAAO,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxB,MAAM,kBAAkB,GAAsB,EAAE,CAAC;QACjD,MAAM,YAAY,GAAe,EAAE,CAAC;QAEpC,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YACzC,IAAI,CAAC,eAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE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C,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACpE;QACD,cAAc;QACd,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE;YAC5B,OAAO,CAAC,KAAK,CAAC,CAAC;SAChB;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE;YACjC,OAAO,KAAK,CAAC;SACd;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAChE;IACD,OAAO,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAED,UAAU,CAAC,QAAQ,GAAG,eAAK,CAAC,QAAQ,CAAC;AAErC,SAAS,QAAQ,CAAC,KAAqC;IACrD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,QAAQ,CAAC,QAAQ,GAAG,eAAK,CAAC,QAAQ,CAAC;AAEnC,gDAAgD;AACnC,QAAA,IAAI,GAEb,yBAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC","sourcesContent":["import { useIsFocused } from '@react-navigation/core';\nimport React from 'react';\n\nimport { ExpoHead, UserActivity } from './ExpoHeadModule';\nimport { getStaticUrlFromExpoRouter } from './url';\nimport { useLocalSearchParams, useUnstableGlobalHref, usePathname, useSegments } from '../hooks';\n\nfunction urlToId(url: string) {\n return url.replace(/[^a-zA-Z0-9]/g, '-');\n}\n\nfunction getLastSegment(path: string) {\n // Remove the extension\n const lastSegment = path.split('/').pop() ?? '';\n return lastSegment.replace(/\\.[^/.]+$/, '').split('?')[0];\n}\n\n// TODO: Use Head Provider to collect all props so only one Head is rendered for a given route.\n\nfunction useAddressableLink() {\n const pathname = useUnstableGlobalHref();\n const params = useLocalSearchParams<any>();\n const url = getStaticUrlFromExpoRouter(pathname);\n return { url, pathname, params };\n}\n\ntype MetaNode =\n | React.ReactPortal\n | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;\n\nfunction useMetaChildren(children: React.ReactNode) {\n return React.useMemo(() => {\n const renderableChildren: React.ReactNode[] = [];\n const metaChildren: MetaNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) {\n return;\n }\n if (typeof child.type === 'string') {\n metaChildren.push(child);\n } else {\n renderableChildren.push(child);\n }\n });\n\n return { children: renderableChildren, metaChildren };\n }, [children]);\n}\n\ntype SerializedMeta = {\n type: string;\n props: { [key: string]: string | undefined };\n};\n\nfunction serializedMetaChildren(meta: MetaNode[]): SerializedMeta[] {\n const validMeta = meta.filter((child) => child.type === 'meta' || child.type === 'title');\n\n return validMeta.map((child) => {\n if (child.type === 'title') {\n return {\n type: 'title',\n props: {\n children: typeof child.props.children === 'string' ? child.props.children : undefined,\n },\n };\n }\n return {\n type: 'meta',\n props: {\n property: typeof child.props.property === 'string' ? child.props.property : undefined,\n content: typeof child.props.content === 'string' ? child.props.content : undefined,\n },\n };\n });\n}\n\nfunction useActivityFromMetaChildren(meta: MetaNode[]) {\n const { url: href, pathname } = useAddressableLink();\n\n const previousMeta = React.useRef<SerializedMeta[]>([]);\n const cachedActivity = React.useRef<Partial<UserActivity>>({});\n\n const sortedMeta = React.useMemo(() => serializedMetaChildren(meta), [meta]);\n\n const url = React.useMemo(() => {\n const urlMeta = sortedMeta.find(\n (child) => child.type === 'meta' && child.props.property === 'og:url'\n );\n\n if (urlMeta) {\n // Support =`/foo/bar` -> `https://example.com/foo/bar`\n if (urlMeta.props.content?.startsWith('/')) {\n return getStaticUrlFromExpoRouter(urlMeta.props.content);\n }\n return urlMeta.props.content;\n }\n return href;\n }, [sortedMeta, href]);\n\n const title = React.useMemo(() => {\n const titleTag = sortedMeta.find((child) => child.type === 'title');\n if (titleTag) {\n return titleTag.props.children ?? '';\n }\n const titleMeta = sortedMeta.find(\n (child) => child.type === 'meta' && child.props.property === 'og:title'\n );\n if (titleMeta) {\n return titleMeta.props.content ?? '';\n }\n\n return getLastSegment(pathname);\n }, [sortedMeta, pathname]);\n\n const activity = React.useMemo(() => {\n if (\n !!previousMeta.current &&\n !!cachedActivity.current &&\n deepObjectCompare(previousMeta.current, sortedMeta)\n ) {\n return cachedActivity.current;\n }\n previousMeta.current = sortedMeta;\n\n const userActivity: Partial<UserActivity> = {};\n\n sortedMeta.forEach((child) => {\n if (\n // <meta />\n child.type === 'meta'\n ) {\n const { property, content } = child.props;\n\n switch (property) {\n case 'og:description':\n userActivity.description = content;\n break;\n // Custom properties\n case 'expo:handoff':\n userActivity.isEligibleForHandoff = isTruthy(content);\n break;\n case 'expo:spotlight':\n userActivity.isEligibleForSearch = isTruthy(content);\n break;\n }\n\n // // <meta name=\"keywords\" content=\"foo,bar,baz\" />\n // if ([\"keywords\"].includes(name)) {\n // userActivity.keywords = Array.isArray(content)\n // ? content\n // : content.split(\",\");\n // }\n }\n });\n\n cachedActivity.current = userActivity;\n return userActivity;\n }, [meta, pathname, href]);\n\n const parsedActivity: UserActivity = {\n keywords: [title],\n ...activity,\n title,\n webpageURL: url,\n activityType: ExpoHead!.activities.INDEXED_ROUTE,\n userInfo: {\n // TODO: This may need to be versioned in the future, e.g. `_v1` if we change the format.\n href,\n },\n };\n\n return parsedActivity;\n}\n\nfunction isTruthy(value: any): boolean {\n return [true, 'true'].includes(value);\n}\n\nfunction HeadNative(props: { children?: React.ReactNode }) {\n const isFocused = useIsFocused();\n if (!isFocused) {\n return <UnfocusedHead />;\n }\n return <FocusedHead {...props} />;\n}\n\nfunction UnfocusedHead(props: { children?: React.ReactNode }): JSX.Element {\n const { children } = useMetaChildren(props.children);\n return <>{children}</>;\n}\n\nfunction FocusedHead(props: { children?: React.ReactNode }): JSX.Element {\n const { metaChildren, children } = useMetaChildren(props.children);\n const activity = useActivityFromMetaChildren(metaChildren);\n useRegisterCurrentActivity(activity);\n return <>{children}</>;\n}\n\n// segments => activity\nconst activities: Map<string, UserActivity> = new Map();\n\nfunction useRegisterCurrentActivity(activity: UserActivity) {\n // ID is tied to Expo Router and agnostic of URLs to ensure dynamic parameters are not considered.\n // Using all segments ensures that cascading routes are considered.\n const activityId = urlToId(usePathname() || '/');\n const cascadingId = urlToId(useSegments().join('-') || '-');\n const activityIds = Array.from(activities.keys());\n const cascadingActivity: UserActivity = React.useMemo(() => {\n // Get all nested activities together, then update the id to match the current pathname.\n // This enables cases like `/user/[name]/post/[id]` to match all nesting, while still having a URL-specific ID, i.e. `/user/evanbacon/post/123`\n const cascadingActivity = activities.has(cascadingId)\n ? {\n ...activities.get(cascadingId),\n ...activity,\n id: activityId,\n }\n : {\n ...activity,\n id: activityId,\n };\n activities.set(cascadingId, cascadingActivity);\n\n return cascadingActivity;\n }, [cascadingId, activityId, activity, activityIds]);\n\n const previousActivity = React.useRef<UserActivity | null>(null);\n\n React.useEffect(() => {\n if (!cascadingActivity) {\n return () => {};\n }\n if (\n !!previousActivity.current &&\n deepObjectCompare(previousActivity.current, cascadingActivity)\n ) {\n return () => {};\n }\n\n previousActivity.current = cascadingActivity;\n if (!cascadingActivity.id) {\n throw new Error('Activity must have an ID');\n }\n\n // If no features are enabled, then skip registering the activity\n if (cascadingActivity.isEligibleForHandoff || cascadingActivity.isEligibleForSearch) {\n ExpoHead?.createActivity(cascadingActivity);\n }\n\n return () => {};\n }, [cascadingActivity]);\n\n React.useEffect(() => {\n return () => {\n if (activityId) {\n ExpoHead?.suspendActivity(activityId);\n }\n };\n }, [activityId]);\n}\n\nfunction deepObjectCompare(a: any, b: any) {\n if (typeof a !== typeof b) {\n return false;\n }\n if (typeof a === 'object') {\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false;\n }\n if (Array.isArray(a)) {\n if (a.length !== b.length) {\n return false;\n }\n return a.every((item, index) => deepObjectCompare(item, b[index]));\n }\n // handle null\n if (a === null || b === null) {\n return a === b;\n }\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n return aKeys.every((key) => deepObjectCompare(a[key], b[key]));\n }\n return a === b;\n}\n\nHeadNative.Provider = React.Fragment;\n\nfunction HeadShim(props: { children?: React.ReactNode }) {\n return null;\n}\n\nHeadShim.Provider = React.Fragment;\n\n// Native Head is only enabled in bare iOS apps.\nexport const Head: ((props: { children?: React.ReactNode }) => React.ReactNode) & {\n Provider: React.ComponentType;\n} = ExpoHead ? HeadNative : HeadShim;\n"]}
@@ -7,7 +7,7 @@ exports.Head = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const react_helmet_async_1 = require("react-helmet-async");
9
9
  const Head = ({ children }) => {
10
- return react_1.default.createElement(react_helmet_async_1.Helmet, null, children);
10
+ return <react_helmet_async_1.Helmet>{children}</react_helmet_async_1.Helmet>;
11
11
  };
12
12
  exports.Head = Head;
13
13
  exports.Head.Provider = react_helmet_async_1.HelmetProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoHead.js","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2DAA4D;AAErD,MAAM,IAAI,GAEb,CAAC,EAAE,QAAQ,EAAsB,EAAE,EAAE;IACvC,OAAO,8BAAC,2BAAM,QAAE,QAAQ,CAAU,CAAC;AACrC,CAAC,CAAC;AAJW,QAAA,IAAI,QAIf;AAEF,YAAI,CAAC,QAAQ,GAAG,mCAAc,CAAC","sourcesContent":["import React from 'react';\nimport { Helmet, HelmetProvider } from 'react-helmet-async';\n\nexport const Head: React.FC<{ children?: React.ReactNode }> & {\n Provider: typeof HelmetProvider;\n} = ({ children }: { children?: any }) => {\n return <Helmet>{children}</Helmet>;\n};\n\nHead.Provider = HelmetProvider;\n"]}
1
+ {"version":3,"file":"ExpoHead.js","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2DAA4D;AAErD,MAAM,IAAI,GAEb,CAAC,EAAE,QAAQ,EAAsB,EAAE,EAAE;IACvC,OAAO,CAAC,2BAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,2BAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAJW,QAAA,IAAI,QAIf;AAEF,YAAI,CAAC,QAAQ,GAAG,mCAAc,CAAC","sourcesContent":["import React from 'react';\nimport { Helmet, HelmetProvider } from 'react-helmet-async';\n\nexport const Head: React.FC<{ children?: React.ReactNode }> & {\n Provider: typeof HelmetProvider;\n} = ({ children }: { children?: any }) => {\n return <Helmet>{children}</Helmet>;\n};\n\nHead.Provider = HelmetProvider;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":"AAgFA,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,UAI1D"}
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":"AA+EA,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,UAI1D"}
package/build/head/url.js CHANGED
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getStaticUrlFromExpoRouter = void 0;
7
7
  const expo_constants_1 = __importDefault(require("expo-constants"));
8
- const url_parse_1 = __importDefault(require("url-parse"));
9
8
  const protocolWarningString = `{ plugins: [["expo-router", { origin: "...<URL>..." }]] }`;
10
9
  /** `lodash.memoize` */
11
10
  function memoize(fn) {
@@ -21,16 +20,16 @@ function memoize(fn) {
21
20
  });
22
21
  }
23
22
  function sanitizeUrl(url) {
24
- const parsed = new url_parse_1.default(url);
23
+ const parsed = new URL(url);
25
24
  // Allow empty protocol, http, and https
26
25
  const validProtocol = !parsed.protocol || parsed.protocol === 'http:' || parsed.protocol === 'https:';
27
26
  if (!validProtocol) {
28
27
  throwOrAlert(`Expo Head: Native origin has invalid protocol "${parsed.protocol}" for URL in Expo Config: ${protocolWarningString}.`);
29
28
  }
30
- parsed.set('pathname', '');
31
- parsed.set('query', {});
32
- parsed.set('hash', undefined);
33
- parsed.set('protocol', parsed.protocol ?? 'https:');
29
+ parsed.pathname = '';
30
+ parsed.search = '';
31
+ parsed.hash = '';
32
+ parsed.protocol ??= 'https:';
34
33
  return parsed.toString().replace(/\/$/, '');
35
34
  }
36
35
  const memoSanitizeUrl = memoize(sanitizeUrl);
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;AACvC,0DAA4B;AAE5B,MAAM,qBAAqB,GAAG,2DAA2D,CAAC;AAE1F,uBAAuB;AACvB,SAAS,OAAO,CAAoC,EAAK;IACvD,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,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,mBAAG,CAAC,GAAG,CAAC,CAAC;IAE5B,wCAAwC;IACxC,MAAM,aAAa,GACjB,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,C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C,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';\nimport URL from 'url-parse';\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: { [key: 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.set('pathname', '');\n parsed.set('query', {});\n parsed.set('hash', undefined);\n parsed.set('protocol', 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,GAA2B,EAAE,CAAC;IACzC,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,QA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,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: { [key: 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"]}
@@ -27,8 +27,8 @@ exports.Tabs = (0, withLayoutContext_1.withLayoutContext)(BottomTabNavigator, (s
27
27
  if (href == null) {
28
28
  return null;
29
29
  }
30
- const children = react_native_1.Platform.OS === 'web' ? props.children : react_1.default.createElement(react_native_1.Pressable, null, props.children);
31
- return (react_1.default.createElement(Link_1.Link, { ...props, style: [{ display: 'flex' }, props.style], href: href, asChild: react_native_1.Platform.OS !== 'web', children: children }));
30
+ const children = react_native_1.Platform.OS === 'web' ? props.children : <react_native_1.Pressable>{props.children}</react_native_1.Pressable>;
31
+ return (<Link_1.Link {...props} style={[{ display: 'flex' }, props.style]} href={href} asChild={react_native_1.Platform.OS !== 'web'} children={children}/>);
32
32
  },
33
33
  },
34
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../src/layouts/Tabs.tsx"],"names":[],"mappings":";;;;;;AAAA,+DAIuC;AAEvC,kDAA0B;AAC1B,+CAAmD;AAEnD,2DAAwD;AACxD,uCAAoC;AAGpC,gDAAgD;AAChD,MAAM,kBAAkB,GAAG,IAAA,sCAAwB,GAAE,CAAC,SAAS,CAAC;AAEnD,QAAA,IAAI,GAAG,IAAA,qCAAiB,EAKnC,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;IAChC,oCAAoC;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5B,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,EAAE;YAC9E,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;YAC5C,IAAI,OAAO,CAAC,YAAY,EAAE;gBACxB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;aACnE;YACD,OAAO;gBACL,GAAG,MAAM;gBACT,OAAO,EAAE;oBACP,GAAG,OAAO;oBACV,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;wBACtB,IAAI,IAAI,IAAI,IAAI,EAAE;4BAChB,OAAO,IAAI,CAAC;yBACb;wBACD,MAAM,QAAQ,GACZ,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,8BAAC,wBAAS,QAAE,KAAK,CAAC,QAAQ,CAAa,CAAC;wBACnF,OAAO,CACL,8BAAC,WAAI,OACC,KAAK,EACT,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,EACzC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAC9B,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;oBACJ,CAAC;iBACF;aACF,CAAC;SACH;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,kBAAe,YAAI,CAAC","sourcesContent":["import {\n BottomTabNavigationEventMap,\n BottomTabNavigationOptions,\n createBottomTabNavigator,\n} from '@react-navigation/bottom-tabs';\nimport { ParamListBase, TabNavigationState } from '@react-navigation/native';\nimport React from 'react';\nimport { Pressable, Platform } from 'react-native';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { Link } from '../link/Link';\nimport { Href } from '../link/href';\n\n// This is the only way to access the navigator.\nconst BottomTabNavigator = createBottomTabNavigator().Navigator;\n\nexport const Tabs = withLayoutContext<\n BottomTabNavigationOptions & { href?: Href | null },\n typeof BottomTabNavigator,\n TabNavigationState<ParamListBase>,\n BottomTabNavigationEventMap\n>(BottomTabNavigator, (screens) => {\n // Support the `href` shortcut prop.\n return screens.map((screen) => {\n if (typeof screen.options !== 'function' && screen.options?.href !== undefined) {\n const { href, ...options } = screen.options;\n if (options.tabBarButton) {\n throw new Error('Cannot use `href` and `tabBarButton` together.');\n }\n return {\n ...screen,\n options: {\n ...options,\n tabBarButton: (props) => {\n if (href == null) {\n return null;\n }\n const children =\n Platform.OS === 'web' ? props.children : <Pressable>{props.children}</Pressable>;\n return (\n <Link\n {...props}\n style={[{ display: 'flex' }, props.style]}\n href={href}\n asChild={Platform.OS !== 'web'}\n children={children}\n />\n );\n },\n },\n };\n }\n return screen;\n });\n});\n\nexport default Tabs;\n"]}
1
+ {"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../src/layouts/Tabs.tsx"],"names":[],"mappings":";;;;;;AAAA,+DAIuC;AAEvC,kDAA0B;AAC1B,+CAAmD;AAEnD,2DAAwD;AACxD,uCAAoC;AAGpC,gDAAgD;AAChD,MAAM,kBAAkB,GAAG,IAAA,sCAAwB,GAAE,CAAC,SAAS,CAAC;AAEnD,QAAA,IAAI,GAAG,IAAA,qCAAiB,EAKnC,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;IAChC,oCAAoC;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5B,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,EAAE;YAC9E,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;YAC5C,IAAI,OAAO,CAAC,YAAY,EAAE;gBACxB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;aACnE;YACD,OAAO;gBACL,GAAG,MAAM;gBACT,OAAO,EAAE;oBACP,GAAG,OAAO;oBACV,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;wBACtB,IAAI,IAAI,IAAI,IAAI,EAAE;4BAChB,OAAO,IAAI,CAAC;yBACb;wBACD,MAAM,QAAQ,GACZ,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,wBAAS,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAS,CAAC,CAAC;wBACnF,OAAO,CACL,CAAC,WAAI,CACH,IAAI,KAAK,CAAC,CACV,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAC1C,IAAI,CAAC,CAAC,IAAI,CAAC,CACX,OAAO,CAAC,CAAC,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAC/B,QAAQ,CAAC,CAAC,QAAQ,CAAC,EACnB,CACH,CAAC;oBACJ,CAAC;iBACF;aACF,CAAC;SACH;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,kBAAe,YAAI,CAAC","sourcesContent":["import {\n BottomTabNavigationEventMap,\n BottomTabNavigationOptions,\n createBottomTabNavigator,\n} from '@react-navigation/bottom-tabs';\nimport { ParamListBase, TabNavigationState } from '@react-navigation/native';\nimport React from 'react';\nimport { Pressable, Platform } from 'react-native';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { Link } from '../link/Link';\nimport { Href } from '../link/href';\n\n// This is the only way to access the navigator.\nconst BottomTabNavigator = createBottomTabNavigator().Navigator;\n\nexport const Tabs = withLayoutContext<\n BottomTabNavigationOptions & { href?: Href | null },\n typeof BottomTabNavigator,\n TabNavigationState<ParamListBase>,\n BottomTabNavigationEventMap\n>(BottomTabNavigator, (screens) => {\n // Support the `href` shortcut prop.\n return screens.map((screen) => {\n if (typeof screen.options !== 'function' && screen.options?.href !== undefined) {\n const { href, ...options } = screen.options;\n if (options.tabBarButton) {\n throw new Error('Cannot use `href` and `tabBarButton` together.');\n }\n return {\n ...screen,\n options: {\n ...options,\n tabBarButton: (props) => {\n if (href == null) {\n return null;\n }\n const children =\n Platform.OS === 'web' ? props.children : <Pressable>{props.children}</Pressable>;\n return (\n <Link\n {...props}\n style={[{ display: 'flex' }, props.style]}\n href={href}\n asChild={Platform.OS !== 'web'}\n children={children}\n />\n );\n },\n },\n };\n }\n return screen;\n });\n});\n\nexport default Tabs;\n"]}
@@ -62,7 +62,7 @@ function withLayoutContext(Nav, processor) {
62
62
  }
63
63
  return (
64
64
  // @ts-expect-error
65
- react_1.default.createElement(Nav, { ...props, id: contextKey, ref: ref, children: sorted }));
65
+ <Nav {...props} id={contextKey} ref={ref} children={sorted}/>);
66
66
  });
67
67
  // @ts-expect-error
68
68
  Navigator.Screen = Screen_1.Screen;