expo-router 4.1.0-canary-20250221-ef26fed → 5.0.0-sdk-52-router-patches
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +10 -2
- package/build/ExpoRoot.js.map +1 -1
- package/build/fork/NavigationContainer.js.map +1 -1
- package/build/fork/getPathFromState-forks.d.ts.map +1 -1
- package/build/fork/getPathFromState-forks.js +0 -1
- package/build/fork/getPathFromState-forks.js.map +1 -1
- package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
- package/build/fork/getStateFromPath-forks.js +2 -1
- package/build/fork/getStateFromPath-forks.js.map +1 -1
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +4 -2
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/fork/native-stack/createNativeStackNavigator.d.ts +1 -1
- package/build/fork/native-stack/createNativeStackNavigator.d.ts.map +1 -1
- package/build/fork/native-stack/createNativeStackNavigator.js +1 -2
- package/build/fork/native-stack/createNativeStackNavigator.js.map +1 -1
- package/build/fork/useBackButton.d.ts +1 -1
- package/build/fork/useBackButton.d.ts.map +1 -1
- package/build/fork/useBackButton.js.map +1 -1
- package/build/fork/useDocumentTitle.d.ts +1 -1
- package/build/fork/useDocumentTitle.d.ts.map +1 -1
- package/build/fork/useDocumentTitle.js.map +1 -1
- package/build/fork/useLinking.d.ts +1 -1
- package/build/fork/useLinking.d.ts.map +1 -1
- package/build/fork/useLinking.js.map +1 -1
- package/build/getDevServer/index.native.d.ts.map +1 -1
- package/build/getDevServer/index.native.js +1 -1
- package/build/getDevServer/index.native.js.map +1 -1
- package/build/getLinkingConfig.d.ts +8 -2
- package/build/getLinkingConfig.d.ts.map +1 -1
- package/build/getLinkingConfig.js +10 -2
- package/build/getLinkingConfig.js.map +1 -1
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +7 -0
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +7 -25
- package/build/global-state/routing.js.map +1 -1
- package/build/head/ExpoHead.d.ts +1 -1
- package/build/head/ExpoHead.d.ts.map +1 -1
- package/build/head/ExpoHead.ios.d.ts.map +1 -1
- package/build/head/ExpoHead.ios.js +18 -3
- package/build/head/ExpoHead.ios.js.map +1 -1
- package/build/head/ExpoHead.js +3 -3
- package/build/head/ExpoHead.js.map +1 -1
- package/build/layouts/DrawerClient.d.ts +18 -40
- package/build/layouts/DrawerClient.d.ts.map +1 -1
- package/build/layouts/StackClient.d.ts +37 -43
- package/build/layouts/StackClient.d.ts.map +1 -1
- package/build/layouts/StackClient.js +176 -5
- package/build/layouts/StackClient.js.map +1 -1
- package/build/layouts/TabsClient.d.ts +18 -40
- package/build/layouts/TabsClient.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.d.ts +2 -2
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +8 -4
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +1 -1
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +2 -1
- package/build/link/Link.js.map +1 -1
- package/build/link/useLinkHooks.d.ts +8 -0
- package/build/link/useLinkHooks.d.ts.map +1 -1
- package/build/link/useLinkHooks.js.map +1 -1
- package/build/rsc/router/client.js +1 -1
- package/build/rsc/router/client.js.map +1 -1
- package/build/rsc/router/host.d.ts +5 -5
- package/build/rsc/router/host.d.ts.map +1 -1
- package/build/rsc/router/host.js.map +1 -1
- package/build/testing-library/index.d.ts +1 -1
- package/build/testing-library/index.d.ts.map +1 -1
- package/build/testing-library/index.js.map +1 -1
- package/build/testing-library/mock-config.d.ts +7 -2
- package/build/testing-library/mock-config.d.ts.map +1 -1
- package/build/ui/TabContext.d.ts +29 -19
- package/build/ui/TabContext.d.ts.map +1 -1
- package/build/ui/TabRouter.d.ts +1 -0
- package/build/ui/TabRouter.d.ts.map +1 -1
- package/build/ui/Tabs.d.ts +39 -30
- package/build/ui/Tabs.d.ts.map +1 -1
- package/build/ui/Tabs.js +12 -2
- package/build/ui/Tabs.js.map +1 -1
- package/build/ui/common.d.ts.map +1 -1
- package/build/ui/common.js +6 -8
- package/build/ui/common.js.map +1 -1
- package/build/ui/useComponent.d.ts +1 -1
- package/build/ui/useComponent.d.ts.map +1 -1
- package/build/ui/useComponent.js.map +1 -1
- package/build/useNavigation.d.ts.map +1 -1
- package/build/useNavigation.js +3 -1
- package/build/useNavigation.js.map +1 -1
- package/build/useScreens.d.ts +6 -4
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +38 -47
- package/build/useScreens.js.map +1 -1
- package/build/views/Navigator.d.ts +3 -2
- package/build/views/Navigator.d.ts.map +1 -1
- package/build/views/Navigator.js +3 -2
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Try.d.ts +1 -1
- package/package.json +19 -16
- package/vendor/react-helmet-async/LICENSE +201 -0
- package/vendor/react-helmet-async/README.md +205 -0
- package/vendor/react-helmet-async/lib/Dispatcher.d.ts +23 -0
- package/vendor/react-helmet-async/lib/HelmetData.d.ts +26 -0
- package/vendor/react-helmet-async/lib/Provider.d.ts +17 -0
- package/vendor/react-helmet-async/lib/client.d.ts +3 -0
- package/vendor/react-helmet-async/lib/constants.d.ts +58 -0
- package/vendor/react-helmet-async/lib/index.d.ts +38 -0
- package/vendor/react-helmet-async/lib/index.esm.js +798 -0
- package/vendor/react-helmet-async/lib/index.js +829 -0
- package/vendor/react-helmet-async/lib/server.d.ts +44 -0
- package/vendor/react-helmet-async/lib/types.d.ts +85 -0
- package/vendor/react-helmet-async/lib/utils.d.ts +33 -0
- package/vendor/react-helmet-async/package_original.json +49 -0
- package/vendor/react-helmet-async/vendor.md +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAAA,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n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport equal from 'fast-deep-equal';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n canGoBack,\n canDismiss,\n goBack,\n linkTo,\n navigate,\n dismiss,\n dismissAll,\n push,\n reload,\n replace,\n setParams,\n dismissTo,\n LinkToOptions,\n} from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { getPathDataFromState, getPathFromState } from '../fork/getPathFromState';\n// import { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { Href, RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport * as SplashScreen from '../views/Splash';\n\ntype ResultState = any;\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking?: ExpoLinkingOptions;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState?: ResultState;\n rootState?: ResultState;\n nextState?: ResultState;\n routeInfo?: UrlObject;\n splashScreenAnimationFrame?: number;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n dismiss = dismiss.bind(this);\n dismissTo = dismissTo.bind(this);\n replace = replace.bind(this);\n dismissAll = dismissAll.bind(this);\n canDismiss = canDismiss.bind(this);\n setParams = setParams.bind(this);\n navigate = navigate.bind(this);\n reload = reload.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n linkingConfigOptions: LinkingConfigOptions = {}\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context, {\n ...Constants.expoConfig?.extra?.router,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n // We always needs routeInfo, even if there are no routes. This can happen if:\n // - there are no routes (we are showing the onboarding screen)\n // - getInitialURL() is async\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n\n if (this.routeNode) {\n // We have routes, so get the linking config and the root component\n this.linking = getLinkingConfig(this, this.routeNode, context, linkingConfigOptions);\n this.rootComponent = getQualifiedRouteComponent(this.routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can preload the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = this.linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n this.rootState = this.linking.getStateFromPath?.(initialURL, this.linking.config);\n this.initialState = this.rootState;\n if (this.rootState) {\n this.routeInfo = this.getRouteInfo(this.rootState);\n }\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n this.rootComponent = Fragment;\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRef = navigationRef;\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n this.splashScreenAnimationFrame = requestAnimationFrame(() => {\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!equal(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: {},\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n shouldEncodeURISegment: false,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n\n cleanup() {\n if (this.splashScreenAnimationFrame) {\n cancelAnimationFrame(this.splashScreenAnimationFrame);\n }\n }\n\n getStateFromPath(href: Href, options: LinkToOptions = {}) {\n href = resolveHref(href);\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n return this.linking?.getStateFromPath?.(href, this.linking.config);\n }\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, options: LinkingConfigOptions) {\n const navigationRef = useNavigationContainerRef();\n useMemo(() => store.initialize(context, navigationRef, options), [context]);\n useExpoRouter();\n return store;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,qDAGkC;AAClC,oEAAuC;AACvC,sEAAoC;AACpC,iCAA+E;AAC/E,+CAAwC;AAExC,uCAcmB;AACnB,+CAAgD;AAChD,0DAAuE;AAEvE,+DAAkF;AAClF,0DAA0D;AAC1D,0DAAiG;AACjG,4CAAyC;AACzC,uCAA0E;AAE1E,8CAA2D;AAC3D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C,aAAa,CAAC,OAAO,EAAE,EAAE;QACjC,MAAM,YAAY,GAAG,aAAK,CAAC,aAAa,CAAC,YAAY,EAA4B,CAAC;QAElF,IAAI,aAAK,CAAC,SAAS,KAAK,YAAY,EAAE;YACpC,aAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACjC;KACF;AACH,CAAC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,OAA6B;IAC5F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AALD,0DAKC","sourcesContent":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport equal from 'fast-deep-equal';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n canGoBack,\n canDismiss,\n goBack,\n linkTo,\n navigate,\n dismiss,\n dismissAll,\n push,\n reload,\n replace,\n setParams,\n dismissTo,\n LinkToOptions,\n} from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { getPathDataFromState, getPathFromState } from '../fork/getPathFromState';\n// import { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { Href, RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport * as SplashScreen from '../views/Splash';\n\ntype ResultState = any;\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking?: ExpoLinkingOptions;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState?: ResultState;\n rootState?: ResultState;\n nextState?: ResultState;\n routeInfo?: UrlObject;\n splashScreenAnimationFrame?: number;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n dismiss = dismiss.bind(this);\n dismissTo = dismissTo.bind(this);\n replace = replace.bind(this);\n dismissAll = dismissAll.bind(this);\n canDismiss = canDismiss.bind(this);\n setParams = setParams.bind(this);\n navigate = navigate.bind(this);\n reload = reload.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n linkingConfigOptions: LinkingConfigOptions = {}\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context, {\n ...Constants.expoConfig?.extra?.router,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n // We always needs routeInfo, even if there are no routes. This can happen if:\n // - there are no routes (we are showing the onboarding screen)\n // - getInitialURL() is async\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n\n if (this.routeNode) {\n // We have routes, so get the linking config and the root component\n this.linking = getLinkingConfig(this, this.routeNode, context, linkingConfigOptions);\n\n this.rootComponent = getQualifiedRouteComponent(this.routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can preload the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = this.linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n this.rootState = this.linking.getStateFromPath?.(initialURL, this.linking.config);\n this.initialState = this.rootState;\n if (this.rootState) {\n this.routeInfo = this.getRouteInfo(this.rootState);\n }\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n this.rootComponent = Fragment;\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRef = navigationRef;\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n this.splashScreenAnimationFrame = requestAnimationFrame(() => {\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!equal(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: {},\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n shouldEncodeURISegment: false,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n\n cleanup() {\n if (this.splashScreenAnimationFrame) {\n cancelAnimationFrame(this.splashScreenAnimationFrame);\n }\n }\n\n getStateFromPath(href: Href, options: LinkToOptions = {}) {\n href = resolveHref(href);\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n return this.linking?.getStateFromPath?.(href, this.linking.config);\n }\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, options: LinkingConfigOptions) {\n const navigationRef = useNavigationContainerRef();\n useMemo(() => store.initialize(context, navigationRef, options), [context]);\n useExpoRouter();\n return store;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RouterStore } from './router-store';
|
|
2
2
|
import { Href } from '../types';
|
|
3
|
+
import { SingularOptions } from '../useScreens';
|
|
3
4
|
export type NavigationOptions = Omit<LinkToOptions, 'event'>;
|
|
4
5
|
export declare function navigate(this: RouterStore, url: Href, options?: NavigationOptions): any;
|
|
5
6
|
export declare function reload(this: RouterStore): void;
|
|
@@ -23,6 +24,12 @@ export type LinkToOptions = {
|
|
|
23
24
|
* Include the anchor when navigating to a new navigator
|
|
24
25
|
*/
|
|
25
26
|
withAnchor?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* When navigating in a Stack, remove all screen from the history that match the singular condition
|
|
29
|
+
*
|
|
30
|
+
* If used with `push`, the history will be filtered even if no navigation occurs.
|
|
31
|
+
*/
|
|
32
|
+
dangerouslySingular?: SingularOptions;
|
|
26
33
|
};
|
|
27
34
|
export declare function linkTo(this: RouterStore, href: string, options?: LinkToOptions): void;
|
|
28
35
|
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAWlD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAWhD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAE7D,wBAAgB,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,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,OAEnF;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,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;IAErB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,eAAe,CAAC;CACvC,CAAC;AAEF,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,QAoDlF"}
|
|
@@ -27,7 +27,6 @@ exports.linkTo = exports.setParams = exports.canDismiss = exports.canGoBack = ex
|
|
|
27
27
|
const native_1 = require("@react-navigation/native");
|
|
28
28
|
const dom_1 = require("expo/dom");
|
|
29
29
|
const Linking = __importStar(require("expo-linking"));
|
|
30
|
-
const non_secure_1 = require("nanoid/non-secure");
|
|
31
30
|
const react_native_1 = require("react-native");
|
|
32
31
|
const href_1 = require("../link/href");
|
|
33
32
|
const useDomComponentNavigation_1 = require("../link/useDomComponentNavigation");
|
|
@@ -151,10 +150,10 @@ function linkTo(href, options = {}) {
|
|
|
151
150
|
console.error('Could not generate a valid navigation state for the given path: ' + href);
|
|
152
151
|
return;
|
|
153
152
|
}
|
|
154
|
-
return navigationRef.dispatch(getNavigateAction(state, rootState, options.event, options.withAnchor));
|
|
153
|
+
return navigationRef.dispatch(getNavigateAction(state, rootState, options.event, options.withAnchor, options.dangerouslySingular));
|
|
155
154
|
}
|
|
156
155
|
exports.linkTo = linkTo;
|
|
157
|
-
function getNavigateAction(actionState, navigationState, type = 'NAVIGATE', withAnchor) {
|
|
156
|
+
function getNavigateAction(actionState, navigationState, type = 'NAVIGATE', withAnchor, singular) {
|
|
158
157
|
/**
|
|
159
158
|
* We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the
|
|
160
159
|
* lowest navigator is the target.
|
|
@@ -209,32 +208,14 @@ function getNavigateAction(actionState, navigationState, type = 'NAVIGATE', with
|
|
|
209
208
|
params = payload;
|
|
210
209
|
actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];
|
|
211
210
|
}
|
|
212
|
-
|
|
213
|
-
if (type === 'PUSH') {
|
|
214
|
-
// Only stack navigators have a push action, and even then we want to use NAVIGATE (see below)
|
|
211
|
+
if (type === 'PUSH' && navigationState.type !== 'stack') {
|
|
215
212
|
type = 'NAVIGATE';
|
|
216
|
-
/*
|
|
217
|
-
* The StackAction.PUSH does not work correctly with Expo Router.
|
|
218
|
-
*
|
|
219
|
-
* Expo Router provides a getId() function for every route, altering how React Navigation handles stack routing.
|
|
220
|
-
* 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)
|
|
221
|
-
* When you try and push to a screen with the same ID, no navigation will occur
|
|
222
|
-
* Refer to: https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L279-L290
|
|
223
|
-
*
|
|
224
|
-
* Expo Router needs to retain the default behavior of PUSH, consistently adding new screens to the stack, even if their IDs are identical.
|
|
225
|
-
*
|
|
226
|
-
* 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.
|
|
227
|
-
* By generating a unique new key, we ensure that the screen is always pushed onto the stack.
|
|
228
|
-
*
|
|
229
|
-
*/
|
|
230
|
-
if (navigationState.type === 'stack') {
|
|
231
|
-
rootPayload.params.__EXPO_ROUTER_key = `${rootPayload.name}-${(0, non_secure_1.nanoid)()}`; // @see https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L406-L407
|
|
232
|
-
}
|
|
233
213
|
}
|
|
234
|
-
if (navigationState.type === 'expo-tab') {
|
|
214
|
+
else if (navigationState.type === 'expo-tab') {
|
|
235
215
|
type = 'JUMP_TO';
|
|
236
216
|
}
|
|
237
|
-
if (type === 'REPLACE' &&
|
|
217
|
+
else if (type === 'REPLACE' &&
|
|
218
|
+
(navigationState.type === 'tab' || navigationState.type === 'drawer')) {
|
|
238
219
|
type = 'JUMP_TO';
|
|
239
220
|
}
|
|
240
221
|
if (withAnchor !== undefined) {
|
|
@@ -261,6 +242,7 @@ function getNavigateAction(actionState, navigationState, type = 'NAVIGATE', with
|
|
|
261
242
|
// key: rootPayload.key,
|
|
262
243
|
name: rootPayload.screen,
|
|
263
244
|
params: rootPayload.params,
|
|
245
|
+
singular,
|
|
264
246
|
},
|
|
265
247
|
};
|
|
266
248
|
}
|
|
@@ -1 +1 @@
|
|
|
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,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;KACH;AACH,CAAC;AAID,SAAgB,QAAQ,CAAoB,GAAS,EAAE,OAA2B;IAChF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AAC1E,CAAC;AAFD,4BAEC;AAED,SAAgB,MAAM;IACpB,yCAAyC;IACzC,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAA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F;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 dismissTo(this: RouterStore, href: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n if (emitDomDismissAll()) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n};\n\nexport function linkTo(this: RouterStore, href: string, options: LinkToOptions = {}) {\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(state, rootState, options.event, options.withAnchor)\n );\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: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n // 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,+CAAwC;AAIxC,uCAA0E;AAC1E,iFAM2C;AAC3C,0CAA+C;AAG/C,sCAAoD;AAEpD,SAAS,aAAa,CAAC,KAAkB;IACvC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QAClC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;KACH;AACH,CAAC;AAID,SAAgB,QAAQ,CAAoB,GAAS,EAAE,OAA2B;IAChF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CA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,CAAC;aAC1F;SACF;QACD;;;;;;;;WAQG;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;KAC1C;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,eAAe,CAAC,GAAG;QAC3B,OAAO,EAAE;YACP,wBAAwB;YACxB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,QAAQ;SACT;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StackActions, type NavigationState, PartialRoute } from '@react-navigation/native';\nimport { IS_DOM } from 'expo/dom';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { type RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../link/useDomComponentNavigation';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload(this: RouterStore) {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function push(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n if (emitDomDismiss(count)) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function dismissTo(this: RouterStore, href: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n if (emitDomDismissAll()) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, remove all screen from the history that match the singular condition\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n};\n\nexport function linkTo(this: RouterStore, href: string, options: LinkToOptions = {}) {\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(\n state,\n rootState,\n options.event,\n options.withAnchor,\n options.dangerouslySingular\n )\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean,\n singular?: SingularOptions\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n if (type === 'PUSH' && navigationState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n } else if (\n type === 'REPLACE' &&\n (navigationState.type === 'tab' || navigationState.type === 'drawer')\n ) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
|
package/build/head/ExpoHead.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoHead.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoHead.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAU,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE7E,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,GAAG;IAC5D,QAAQ,EAAE,OAAO,cAAc,CAAC;CAGjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoHead.ios.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"ExpoHead.ios.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":"AACA,OAAO,KAAc,MAAM,OAAO,CAAC;AA2TnC,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,iBAAiB,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG;IACzE,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC;CACI,CAAC"}
|
|
@@ -49,15 +49,30 @@ function serializedMetaChildren(meta) {
|
|
|
49
49
|
return {
|
|
50
50
|
type: 'title',
|
|
51
51
|
props: {
|
|
52
|
-
children:
|
|
52
|
+
children: child.props &&
|
|
53
|
+
typeof child.props === 'object' &&
|
|
54
|
+
'children' in child.props &&
|
|
55
|
+
typeof child.props.children === 'string'
|
|
56
|
+
? child.props.children
|
|
57
|
+
: undefined,
|
|
53
58
|
},
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
61
|
return {
|
|
57
62
|
type: 'meta',
|
|
58
63
|
props: {
|
|
59
|
-
property:
|
|
60
|
-
|
|
64
|
+
property: child.props &&
|
|
65
|
+
typeof child.props === 'object' &&
|
|
66
|
+
'property' in child.props &&
|
|
67
|
+
typeof child.props.property === 'string'
|
|
68
|
+
? child.props.property
|
|
69
|
+
: undefined,
|
|
70
|
+
content: child.props &&
|
|
71
|
+
typeof child.props === 'object' &&
|
|
72
|
+
'content' in child.props &&
|
|
73
|
+
typeof child.props.content === 'string'
|
|
74
|
+
? child.props.content
|
|
75
|
+
: undefined,
|
|
61
76
|
},
|
|
62
77
|
};
|
|
63
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoHead.ios.js","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":";;;;;;AAAA,qDAAwD;AACxD,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,CA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AG,eAAK,CAAC,QAAQ,CAAC;AAErC,SAAS,QAAQ,CAAC,KAA8B;IAC9C,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/native';\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: Record<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: React.PropsWithChildren) {\n return null;\n}\n\nHeadShim.Provider = React.Fragment;\n\n// Native Head is only enabled in bare iOS apps.\nexport const Head: ((props: React.PropsWithChildren) => 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,qDAAwD;AACxD,kDAAmC;AAEnC,qDAA0D;AAC1D,+BAAmD;AACnD,oCAAiG;AAEjG,SAAS,OAAO,CAAC,GAAW;IAC1B,OAAO,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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,KAA8B;IAC9C,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/native';\nimport React, { JSX } 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: Record<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:\n child.props &&\n typeof child.props === 'object' &&\n 'children' in child.props &&\n typeof child.props.children === 'string'\n ? child.props.children\n : undefined,\n },\n };\n }\n return {\n type: 'meta',\n props: {\n property:\n child.props &&\n typeof child.props === 'object' &&\n 'property' in child.props &&\n typeof child.props.property === 'string'\n ? child.props.property\n : undefined,\n content:\n child.props &&\n typeof child.props === 'object' &&\n 'content' in child.props &&\n typeof child.props.content === 'string'\n ? child.props.content\n : 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: React.PropsWithChildren) {\n return null;\n}\n\nHeadShim.Provider = React.Fragment;\n\n// Native Head is only enabled in bare iOS apps.\nexport const Head: ((props: React.PropsWithChildren) => React.ReactNode) & {\n Provider: React.ComponentType;\n} = ExpoHead ? HeadNative : HeadShim;\n"]}
|
package/build/head/ExpoHead.js
CHANGED
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Head = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const
|
|
8
|
+
const lib_1 = require("../../vendor/react-helmet-async/lib");
|
|
9
9
|
const Head = ({ children }) => {
|
|
10
|
-
return <
|
|
10
|
+
return <lib_1.Helmet>{children}</lib_1.Helmet>;
|
|
11
11
|
};
|
|
12
12
|
exports.Head = Head;
|
|
13
|
-
exports.Head.Provider =
|
|
13
|
+
exports.Head.Provider = lib_1.HelmetProvider;
|
|
14
14
|
//# sourceMappingURL=ExpoHead.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoHead.js","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;
|
|
1
|
+
{"version":3,"file":"ExpoHead.js","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,6DAA6E;AAEtE,MAAM,IAAI,GAEb,CAAC,EAAE,QAAQ,EAAsB,EAAE,EAAE;IACvC,OAAO,CAAC,YAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,YAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAJW,QAAA,IAAI,QAIf;AAEF,YAAI,CAAC,QAAQ,GAAG,oBAAc,CAAC","sourcesContent":["import React from 'react';\n\nimport { Helmet, HelmetProvider } from '../../vendor/react-helmet-async/lib';\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,14 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DrawerNavigationOptions, DrawerNavigationEventMap } from '@react-navigation/drawer';
|
|
3
3
|
import { DrawerNavigationState, ParamListBase } from '@react-navigation/native';
|
|
4
|
-
export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "
|
|
4
|
+
export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
5
5
|
children: import("react").ReactNode;
|
|
6
6
|
layout?: ((props: {
|
|
7
7
|
state: DrawerNavigationState<ParamListBase>;
|
|
8
8
|
navigation: import("@react-navigation/native").NavigationHelpers<ParamListBase, {}>;
|
|
9
9
|
descriptors: Record<string, import("@react-navigation/native").Descriptor<DrawerNavigationOptions, import("@react-navigation/native").NavigationProp<ParamListBase, string, string | undefined, DrawerNavigationState<ParamListBase>, DrawerNavigationOptions, DrawerNavigationEventMap>, import("@react-navigation/native").RouteProp<ParamListBase, string>>>;
|
|
10
10
|
children: import("react").ReactNode;
|
|
11
|
-
}) => import("react").ReactElement<
|
|
11
|
+
}) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>) | undefined;
|
|
12
12
|
screenListeners?: Partial<{
|
|
13
13
|
drawerItemPress: import("@react-navigation/native").EventListenerCallback<DrawerNavigationEventMap & import("@react-navigation/native").EventMapCore<DrawerNavigationState<ParamListBase>>, "drawerItemPress", true>;
|
|
14
14
|
transitionStart: import("@react-navigation/native").EventListenerCallback<DrawerNavigationEventMap & import("@react-navigation/native").EventMapCore<DrawerNavigationState<ParamListBase>>, "transitionStart", unknown>;
|
|
@@ -44,35 +44,24 @@ export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit
|
|
|
44
44
|
route: import("@react-navigation/native").RouteProp<ParamListBase, string>;
|
|
45
45
|
navigation: import("@react-navigation/drawer").DrawerNavigationProp<ParamListBase, string, undefined>;
|
|
46
46
|
theme: ReactNavigation.Theme;
|
|
47
|
-
children: import("react").ReactElement<
|
|
48
|
-
}) => import("react").ReactElement<
|
|
49
|
-
|
|
50
|
-
key: string;
|
|
51
|
-
index: number;
|
|
52
|
-
routeNames: string[];
|
|
53
|
-
history?: unknown[] | undefined;
|
|
54
|
-
routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
|
|
47
|
+
children: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
48
|
+
}) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>) | undefined;
|
|
49
|
+
UNSTABLE_router?: (<Action extends Readonly<{
|
|
55
50
|
type: string;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
routeNames: string[];
|
|
61
|
-
history?: unknown[] | undefined;
|
|
62
|
-
routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
|
|
63
|
-
type: string;
|
|
64
|
-
stale: false;
|
|
65
|
-
}>> | undefined) | undefined;
|
|
51
|
+
payload?: object | undefined;
|
|
52
|
+
source?: string | undefined;
|
|
53
|
+
target?: string | undefined;
|
|
54
|
+
}>>(original: import("@react-navigation/native").Router<DrawerNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<DrawerNavigationState<ParamListBase>, Action>>) | undefined;
|
|
66
55
|
} & {
|
|
67
56
|
id?: undefined;
|
|
68
|
-
}, "children"> & Partial<Pick<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "
|
|
57
|
+
}, "children"> & Partial<Pick<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
69
58
|
children: import("react").ReactNode;
|
|
70
59
|
layout?: ((props: {
|
|
71
60
|
state: DrawerNavigationState<ParamListBase>;
|
|
72
61
|
navigation: import("@react-navigation/native").NavigationHelpers<ParamListBase, {}>;
|
|
73
62
|
descriptors: Record<string, import("@react-navigation/native").Descriptor<DrawerNavigationOptions, import("@react-navigation/native").NavigationProp<ParamListBase, string, string | undefined, DrawerNavigationState<ParamListBase>, DrawerNavigationOptions, DrawerNavigationEventMap>, import("@react-navigation/native").RouteProp<ParamListBase, string>>>;
|
|
74
63
|
children: import("react").ReactNode;
|
|
75
|
-
}) => import("react").ReactElement<
|
|
64
|
+
}) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>) | undefined;
|
|
76
65
|
screenListeners?: Partial<{
|
|
77
66
|
drawerItemPress: import("@react-navigation/native").EventListenerCallback<DrawerNavigationEventMap & import("@react-navigation/native").EventMapCore<DrawerNavigationState<ParamListBase>>, "drawerItemPress", true>;
|
|
78
67
|
transitionStart: import("@react-navigation/native").EventListenerCallback<DrawerNavigationEventMap & import("@react-navigation/native").EventMapCore<DrawerNavigationState<ParamListBase>>, "transitionStart", unknown>;
|
|
@@ -108,25 +97,14 @@ export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit
|
|
|
108
97
|
route: import("@react-navigation/native").RouteProp<ParamListBase, string>;
|
|
109
98
|
navigation: import("@react-navigation/drawer").DrawerNavigationProp<ParamListBase, string, undefined>;
|
|
110
99
|
theme: ReactNavigation.Theme;
|
|
111
|
-
children: import("react").ReactElement<
|
|
112
|
-
}) => import("react").ReactElement<
|
|
113
|
-
|
|
114
|
-
key: string;
|
|
115
|
-
index: number;
|
|
116
|
-
routeNames: string[];
|
|
117
|
-
history?: unknown[] | undefined;
|
|
118
|
-
routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
|
|
119
|
-
type: string;
|
|
120
|
-
stale: false;
|
|
121
|
-
}>) => import("@react-navigation/native").PartialState<Readonly<{
|
|
122
|
-
key: string;
|
|
123
|
-
index: number;
|
|
124
|
-
routeNames: string[];
|
|
125
|
-
history?: unknown[] | undefined;
|
|
126
|
-
routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
|
|
100
|
+
children: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
101
|
+
}) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>) | undefined;
|
|
102
|
+
UNSTABLE_router?: (<Action extends Readonly<{
|
|
127
103
|
type: string;
|
|
128
|
-
|
|
129
|
-
|
|
104
|
+
payload?: object | undefined;
|
|
105
|
+
source?: string | undefined;
|
|
106
|
+
target?: string | undefined;
|
|
107
|
+
}>>(original: import("@react-navigation/native").Router<DrawerNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<DrawerNavigationState<ParamListBase>, Action>>) | undefined;
|
|
130
108
|
} & {
|
|
131
109
|
id?: undefined;
|
|
132
110
|
}, "children">> & import("react").RefAttributes<unknown>> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerClient.d.ts","sourceRoot":"","sources":["../../src/layouts/DrawerClient.tsx"],"names":[],"mappings":";AAEA,OAAO,EAEL,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMhF,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"DrawerClient.d.ts","sourceRoot":"","sources":["../../src/layouts/DrawerClient.tsx"],"names":[],"mappings":";AAEA,OAAO,EAEL,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMhF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKD,CAAC;AAEnB,eAAe,MAAM,CAAC"}
|