expo-router 5.0.2-preview.3 → 5.0.2-preview.5
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.js +1 -1
- package/build/ExpoRoot.js.map +1 -1
- package/build/Route.js +1 -1
- package/build/Route.js.map +1 -1
- package/build/exports.d.ts +1 -0
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js.map +1 -1
- package/build/fast-refresh.d.ts.map +1 -1
- package/build/fast-refresh.js +1 -0
- package/build/fast-refresh.js.map +1 -1
- package/build/fork/getStateFromPath.js +1 -0
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/global-state/router-store.d.ts +14 -14
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +1 -1
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +6 -6
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +1 -0
- package/build/global-state/routing.js.map +1 -1
- package/build/head/ExpoHead.ios.js.map +1 -1
- package/build/hooks.js +1 -1
- package/build/hooks.js.map +1 -1
- package/build/imperative-api.js.map +1 -1
- package/build/layouts/DrawerClient.js +1 -1
- package/build/layouts/DrawerClient.js.map +1 -1
- package/build/layouts/StackClient.js +1 -1
- package/build/layouts/StackClient.js.map +1 -1
- package/build/layouts/TabsClient.d.ts.map +1 -1
- package/build/layouts/TabsClient.js +2 -1
- package/build/layouts/TabsClient.js.map +1 -1
- package/build/link/Link.js +1 -1
- package/build/link/Link.js.map +1 -1
- package/build/link/useDomComponentNavigation.d.ts +1 -1
- package/build/link/useDomComponentNavigation.d.ts.map +1 -1
- package/build/link/useDomComponentNavigation.js.map +1 -1
- package/build/link/useLinkHooks.d.ts +3 -4
- package/build/link/useLinkHooks.d.ts.map +1 -1
- package/build/link/useLinkHooks.js.map +1 -1
- package/build/routes-manifest.js +1 -1
- package/build/routes-manifest.js.map +1 -1
- package/build/rsc/entry.js +7 -1
- package/build/rsc/entry.js.map +1 -1
- package/build/rsc/middleware.js +1 -1
- package/build/rsc/middleware.js.map +1 -1
- package/build/rsc/router/client.js +10 -1
- package/build/rsc/router/client.js.map +1 -1
- package/build/rsc/router/host.d.ts.map +1 -1
- package/build/rsc/router/host.js +10 -1
- package/build/rsc/router/host.js.map +1 -1
- package/build/rsc/rsc-renderer.d.ts.map +1 -1
- package/build/rsc/rsc-renderer.js.map +1 -1
- package/build/static/getRootComponent.js +1 -1
- package/build/static/getRootComponent.js.map +1 -1
- package/build/static/renderStaticContent.d.ts.map +1 -1
- package/build/static/renderStaticContent.js +1 -0
- package/build/static/renderStaticContent.js.map +1 -1
- package/build/testing-library/mocks.d.ts +1 -0
- package/build/testing-library/mocks.js +2 -0
- package/build/testing-library/mocks.js.map +1 -1
- package/build/ts-declarations/expo-router-internal-globals.d.ts +9 -0
- package/build/ts-declarations/expo-router-internal-globals.d.ts.map +1 -0
- package/build/ts-declarations/expo-router-internal-globals.js +4 -0
- package/build/ts-declarations/expo-router-internal-globals.js.map +1 -0
- package/build/typed-routes/index.d.ts +6 -2
- package/build/typed-routes/index.d.ts.map +1 -1
- package/build/typed-routes/index.js +3 -1
- package/build/typed-routes/index.js.map +1 -1
- package/build/useFocusEffect.js +1 -1
- package/build/useFocusEffect.js.map +1 -1
- package/build/useNavigation.js +1 -1
- package/build/useNavigation.js.map +1 -1
- package/build/useScreens.d.ts +2 -2
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +1 -1
- package/build/useScreens.js.map +1 -1
- package/build/views/EmptyRoute.js +1 -1
- package/build/views/EmptyRoute.js.map +1 -1
- package/build/views/ErrorBoundary.js +1 -1
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.js +1 -1
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Screen.js +1 -1
- package/build/views/Screen.js.map +1 -1
- package/build/views/Sitemap.js +1 -1
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/Splash.js +1 -1
- package/build/views/Splash.js.map +1 -1
- package/build/views/Toast.js +2 -2
- package/build/views/Toast.js.map +1 -1
- package/build/views/Try.js +1 -1
- package/build/views/Try.js.map +1 -1
- package/build/views/Unmatched.js +1 -1
- package/build/views/Unmatched.js.map +1 -1
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,4BAEC;AAED,wBAGC;AAED,4BAEC;AAED,oBAEC;AAED,0BAKC;AAED,8BAEC;AAED,0BAEC;AAED,gCAKC;AAED,wBAMC;AAED,8BAeC;AAED,gCAmBC;AAED,8BASC;AAwBD,wBA4DC;AAhND,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,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;IACJ,CAAC;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;AAED,SAAgB,MAAM;IACpB,yCAAyC;IACzC,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;AACzF,CAAC;AAED,SAAgB,QAAQ,CAAoB,IAAU,EAAE,OAA2B;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAA,kBAAW,EAAC,IAAI,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,C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AAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;gBAC1C,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;QACD;;;;;;;;WAQG;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;IAC3C,CAAC;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 prefetch(this: RouterStore, href: Href, options?: NavigationOptions) {\n return linkTo.bind(this)(resolveHref(href), { ...options, event: 'PRELOAD' });\n}\n\nexport function push(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n if (emitDomDismiss(count)) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function dismissTo(this: RouterStore, href: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n if (emitDomDismissAll()) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, remove all screen from the history that match the singular condition\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n};\n\nexport function linkTo(this: RouterStore, originalHref: string, options: LinkToOptions = {}) {\n let href: string | undefined = originalHref;\n\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n href = this.applyRedirects(href);\n\n // If the href is undefined, it means that the redirect has already been handled the navigation\n if (!href) {\n return;\n }\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(\n state,\n rootState,\n options.event,\n options.withAnchor,\n options.dangerouslySingular\n )\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean,\n singular?: SingularOptions\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n if (type === 'PUSH' && navigationState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n } else if (\n type === 'REPLACE' &&\n (navigationState.type === 'tab' || navigationState.type === 'drawer')\n ) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,4BAEC;AAED,wBAGC;AAED,4BAEC;AAED,oBAEC;AAED,0BAKC;AAED,8BAEC;AAED,0BAEC;AAED,gCAKC;AAED,wBAMC;AAED,8BAeC;AAED,gCAmBC;AAED,8BASC;AAwBD,wBA4DC;AAhND,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,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;IACJ,CAAC;AACH,CAAC;AAID,SAAgB,QAAQ,CAAoB,GAAS,EAAE,OAA2B;IAChF,OAAO,IAAI,CAA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MAAM,IAAI,eAAe,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACxD,IAAI,GAAG,UAAU,CAAC;IACpB,CAAC;SAAM,IAAI,eAAe,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/C,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC;SAAM,IACL,IAAI,KAAK,SAAS;QAClB,CAAC,eAAe,CAAC,IAAI,KAAK,KAAK,IAAI,eAAe,CAAC,IAAI,KAAK,QAAQ,CAAC,EACrE,CAAC;QACD,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;gBAC1C,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;QACD;;;;;;;;WAQG;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;IAC3C,CAAC;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 prefetch(this: RouterStore, href: Href, options?: NavigationOptions) {\n return linkTo.bind(this)(resolveHref(href), { ...options, event: 'PRELOAD' });\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, undefined | string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, remove all screen from the history that match the singular condition\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n};\n\nexport function linkTo(this: RouterStore, originalHref: string, options: LinkToOptions = {}) {\n let href: string | undefined = originalHref;\n\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n href = this.applyRedirects(href);\n\n // If the href is undefined, it means that the redirect has already been handled the navigation\n if (!href) {\n return;\n }\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(\n state,\n rootState,\n options.event,\n options.withAnchor,\n options.dangerouslySingular\n )\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean,\n singular?: SingularOptions\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n // @ts-expect-error: TODO(@kitten): This isn't properly typed, so the index access fails\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n if (type === 'PUSH' && navigationState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n } else if (\n type === 'REPLACE' &&\n (navigationState.type === 'tab' || navigationState.type === 'drawer')\n ) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoHead.ios.js","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":";;;;;;AAAA,qDAAwD;AACxD,kDAAmC;AAEnC,qDAA0D;AAC1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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"]}
|
|
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,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED,SA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AC;YACrB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC1B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACrE,CAAC;QACD,cAAc;QACd,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;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,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;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;IACjE,CAAC;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): boolean {\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/hooks.js
CHANGED
package/build/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAwBb,wDAEC;AAED,oCAEC;AAMD,8CAEC;AAMD,8DAEC;AAoBD,8BAkBC;AAOD,sDAEC;AA2CD,kCAEC;AAmBD,kCAEC;AA4CD,sDAEC;AAyCD,oDAwBC;AAED,0CAsBC;AApSD,kDAA0B;AAE1B,mCAAkD;AAClD,8DAA0F;AAI1F;;;;;;;;;;;;;;GAcG;AACH,SAAgB,sBAAsB;IACpC,OAAO,IAAA,gCAAiB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AE,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;IACzE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC9D,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,GAAG,KAAK,QAAQ;gBAAE,OAAO,EAAE,CAAC;YAChC,IAAI,GAAG,KAAK,QAAQ;gBAAE,OAAO,EAAE,CAAC;QAClC,CAAC;QAED,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,uBAAwB,SAAQ,eAAe;IACnD,GAAG;QACD,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './imperative-api';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\n/**\n * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)\n * of the navigator which contains the current screen.\n *\n * @example\n * ```tsx\n * import { useRootNavigationState } from 'expo-router';\n *\n * export default function Route() {\n * const { routes } = useRootNavigationState();\n *\n * return <Text>{routes[0].name}</Text>;\n * }\n * ```\n */\nexport function useRootNavigationState() {\n return useStoreRootState();\n}\n\nexport function useRouteInfo() {\n return useStoreRouteInfo();\n}\n\n/**\n * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,\n * which returns a React `ref`.\n */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/**\n * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`\n * if the `<NavigationContainer />` hasn't mounted yet.\n */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\n/**\n *\n * Returns the [Router](#router) object for imperative navigation.\n *\n * @example\n *```tsx\n * import { useRouter } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n * const router = useRouter();\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport function useRouter(): Router {\n return React.useMemo(\n () => ({\n back: store.goBack,\n canDismiss: store.canDismiss,\n canGoBack: store.canGoBack,\n dismiss: store.dismiss,\n dismissAll: store.dismissAll,\n dismissTo: store.dismissTo,\n navigate: store.navigate,\n prefetch: store.prefetch,\n push: store.push,\n reload: store.reload,\n replace: store.replace,\n setParams: store.setParams,\n }),\n []\n );\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname\n * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useStoreRouteInfo().unstable_globalHref;\n}\n\n/**\n * Returns a list of selected file segments for the currently selected route. Segments are not normalized,\n * so they will be the same as the file path. For example, `/[id]?id=normal` becomes `[\"[id]\"]`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useSegments } from 'expo-router';\n *\n * export default function Route() {\n * // segments = [\"profile\", \"[user]\"]\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n *\n *\n * `useSegments` can be typed using an abstract. Consider the following file structure:\n *\n * ```md\n * - app\n * - [user]\n * - index.tsx\n * - followers.tsx\n * - settings.tsx\n * ```\n *\n *\n * This can be strictly typed using the following abstract with `useSegments` hook:\n *\n * ```tsx\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends Route = Route>(): RouteSegments<TSegments>;\n\n/**\n * @hidden\n */\nexport function useSegments<TSegments extends RouteSegments<Route>>(): TSegments;\nexport function useSegments() {\n return useStoreRouteInfo().segments;\n}\n\n/**\n * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.\n * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { usePathname } from 'expo-router';\n *\n * export default function Route() {\n * // pathname = \"/profile/baconbrix\"\n * const pathname = usePathname();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useStoreRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns URL parameters for globally selected route, including dynamic path segments.\n * This function updates even when the route is not focused. Useful for analytics or\n * other background operations that don't draw to the screen.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * When querying search params in a stack, opt-towards using\n * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useGlobalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useGlobalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function useGlobalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useGlobalSearchParams() {\n return useStoreRouteInfo().params;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen\n * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useLocalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useLocalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n */\nexport function useLocalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useLocalSearchParams() {\n const params = React.useContext(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as any;\n}\n\nexport function useSearchParams({ global = false } = {}): URLSearchParams {\n const globalRef = React.useRef(global);\n if (process.env.NODE_ENV !== 'production') {\n if (global !== globalRef.current) {\n console.warn(\n `Detected change in 'global' option of useSearchParams. This value cannot change between renders`\n );\n }\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const params = global ? useGlobalSearchParams() : useLocalSearchParams();\n const entries = Object.entries(params).flatMap(([key, value]) => {\n if (global) {\n if (key === 'params') return [];\n if (key === 'screen') return [];\n }\n\n return Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]];\n });\n\n return new ReadOnlyURLSearchParams(entries);\n}\n\nclass ReadOnlyURLSearchParams extends URLSearchParams {\n set() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n append() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n delete() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAwBb,wDAEC;AAED,oCAEC;AAMD,8CAEC;AAMD,8DAEC;AAoBD,8BAkBC;AAOD,sDAEC;AA2CD,kCAEC;AAmBD,kCAEC;AA4CD,sDAEC;AAyCD,oDAwBC;AAED,0CAsBC;AApSD,kDAA0B;AAE1B,mCAAkD;AAClD,8DAA0F;AAI1F;;;;;;;;;;;;;;GAcG;AACH,SAAgB,sBAAsB;IACpC,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,oBAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,SAAgB,yBAAyB;IACvC,OAAO,oBAAK,CAAC,aAAa,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,SAAS;IACvB,OAAO,eAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,oBAAK,CAAC,MAAM;QAClB,UAAU,EAAE,oBAAK,CAAC,UAAU;QAC5B,SAAS,EAAE,oBAAK,CAAC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AAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,uBAAwB,SAAQ,eAAe;IACnD,GAAG;QACD,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './imperative-api';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\n/**\n * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)\n * of the navigator which contains the current screen.\n *\n * @example\n * ```tsx\n * import { useRootNavigationState } from 'expo-router';\n *\n * export default function Route() {\n * const { routes } = useRootNavigationState();\n *\n * return <Text>{routes[0].name}</Text>;\n * }\n * ```\n */\nexport function useRootNavigationState() {\n return useStoreRootState();\n}\n\nexport function useRouteInfo() {\n return useStoreRouteInfo();\n}\n\n/**\n * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,\n * which returns a React `ref`.\n */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/**\n * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`\n * if the `<NavigationContainer />` hasn't mounted yet.\n */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\n/**\n *\n * Returns the [Router](#router) object for imperative navigation.\n *\n * @example\n *```tsx\n * import { useRouter } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n * const router = useRouter();\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport function useRouter(): Router {\n return React.useMemo(\n () => ({\n back: store.goBack,\n canDismiss: store.canDismiss,\n canGoBack: store.canGoBack,\n dismiss: store.dismiss,\n dismissAll: store.dismissAll,\n dismissTo: store.dismissTo,\n navigate: store.navigate,\n prefetch: store.prefetch,\n push: store.push,\n reload: store.reload,\n replace: store.replace,\n setParams: store.setParams as Router['setParams'],\n }),\n []\n );\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname\n * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useStoreRouteInfo().unstable_globalHref;\n}\n\n/**\n * Returns a list of selected file segments for the currently selected route. Segments are not normalized,\n * so they will be the same as the file path. For example, `/[id]?id=normal` becomes `[\"[id]\"]`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useSegments } from 'expo-router';\n *\n * export default function Route() {\n * // segments = [\"profile\", \"[user]\"]\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n *\n *\n * `useSegments` can be typed using an abstract. Consider the following file structure:\n *\n * ```md\n * - app\n * - [user]\n * - index.tsx\n * - followers.tsx\n * - settings.tsx\n * ```\n *\n *\n * This can be strictly typed using the following abstract with `useSegments` hook:\n *\n * ```tsx\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends Route = Route>(): RouteSegments<TSegments>;\n\n/**\n * @hidden\n */\nexport function useSegments<TSegments extends RouteSegments<Route>>(): TSegments;\nexport function useSegments() {\n return useStoreRouteInfo().segments;\n}\n\n/**\n * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.\n * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { usePathname } from 'expo-router';\n *\n * export default function Route() {\n * // pathname = \"/profile/baconbrix\"\n * const pathname = usePathname();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useStoreRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns URL parameters for globally selected route, including dynamic path segments.\n * This function updates even when the route is not focused. Useful for analytics or\n * other background operations that don't draw to the screen.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * When querying search params in a stack, opt-towards using\n * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useGlobalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useGlobalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function useGlobalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useGlobalSearchParams() {\n return useStoreRouteInfo().params;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen\n * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useLocalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useLocalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n */\nexport function useLocalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useLocalSearchParams() {\n const params = React.useContext(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as any;\n}\n\nexport function useSearchParams({ global = false } = {}): URLSearchParams {\n const globalRef = React.useRef(global);\n if (process.env.NODE_ENV !== 'production') {\n if (global !== globalRef.current) {\n console.warn(\n `Detected change in 'global' option of useSearchParams. This value cannot change between renders`\n );\n }\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const params = global ? useGlobalSearchParams() : useLocalSearchParams();\n const entries = Object.entries(params).flatMap(([key, value]) => {\n if (global) {\n if (key === 'params') return [];\n if (key === 'screen') return [];\n }\n\n return Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]];\n });\n\n return new ReadOnlyURLSearchParams(entries);\n}\n\nclass ReadOnlyURLSearchParams extends URLSearchParams {\n set() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n append() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n delete() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imperative-api.js","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":";;;AAAA,8DA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,EAAE,OAAO,CAAC;IAClD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IACxC,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC;IAC5D,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;IACxD,IAAI,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,SAAS,EAAE;IAClC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAK,CAAC,SAAS,CAAC,MAA6B,CAAC;IACrE,MAAM,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,MAAM,EAAE;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;CACzC,CAAC","sourcesContent":["import { store } from './global-state/router-store';\nimport { NavigationOptions } from './global-state/routing';\nimport { Href, Route, RouteInputParams } from './types';\n\n/**\n * Returns `router` object for imperative navigation API.\n *\n * @example\n *```tsx\n * import { router } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport type Router = {\n /**\n * Goes back in the navigation history.\n */\n back: () => void;\n /**\n * Navigates to a route in the navigator's history if it supports invoking the `back` function.\n */\n canGoBack: () => boolean;\n /**\n * Navigates to the provided [`href`](#href) using a push operation if possible.\n */\n push: (href: Href, options?: NavigationOptions) => void;\n /**\n * Navigates to the provided [`href`](#href).\n */\n navigate: (href: Href, options?: NavigationOptions) => void;\n /**\n * Navigates to route without appending to the history. Can be used with\n * [`useFocusEffect`](#usefocuseffecteffect-do_not_pass_a_second_prop)\n * to redirect imperatively to a new screen.\n *\n * @see [Using `useRouter()` hook](/router/reference/redirects/) to redirect.\n * */\n replace: (href: Href, options?: NavigationOptions) => void;\n /**\n * Navigates to the a stack lower than the current screen using the provided count if possible, otherwise 1.\n *\n * If the current screen is the only route, it will dismiss the entire stack.\n */\n dismiss: (count?: number) => void;\n /**\n * Dismisses screens until the provided href is reached. If the href is not found, it will instead replace the current screen with the provided `href`.\n */\n dismissTo: (href: Href, options?: NavigationOptions) => void;\n /**\n * Returns to the first screen in the closest stack. This is similar to\n * [`popToTop`](https://reactnavigation.org/docs/stack-actions/#poptotop) stack action.\n */\n dismissAll: () => void;\n /**\n * Checks if it is possible to dismiss the current screen. Returns `true` if the\n * router is within the stack with more than one screen in stack's history.\n *\n */\n canDismiss: () => boolean;\n /**\n * Updates the current route's query params.\n */\n setParams: <T extends Route>(params: Partial<RouteInputParams<T>>) => void;\n /**\n * Reloads the currently mounted route in experimental server mode. This can be used to re-fetch data.\n * @hidden\n */\n reload: () => void;\n /**\n * Prefetch a screen in the background before navigating to it\n */\n prefetch: (name: Href) => void;\n};\n\n/**\n * @hidden\n */\nexport const router: Router = {\n navigate: (href, options) => store.navigate(href, options),\n push: (href, options) => store.push(href, options),\n dismiss: (count) => store.dismiss(count),\n dismissAll: () => store.dismissAll(),\n dismissTo: (href, options) => store.dismissTo(href, options),\n canDismiss: () => store.canDismiss(),\n replace: (href, options) => store.replace(href, options),\n back: () => store.goBack(),\n canGoBack: () => store.canGoBack(),\n setParams: (params) => store.setParams(params as Record<string, any>),\n reload: () => store.reload(),\n prefetch: (name) => store.prefetch(name),\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerClient.js","sourceRoot":"","sources":["../../src/layouts/DrawerClient.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"DrawerClient.js","sourceRoot":"","sources":["../../src/layouts/DrawerClient.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAEb,qDAIkC;AAGlC,2DAAwD;AAExD,MAAM,eAAe,GAAG,IAAA,8BAAqB,GAAE,CAAC,SAAS,CAAC;AAE7C,QAAA,MAAM,GAAG,IAAA,qCAAiB,EAKrC,eAAe,CAAC,CAAC;AAEnB,kBAAe,cAAM,CAAC","sourcesContent":["'use client';\n\nimport {\n createDrawerNavigator,\n DrawerNavigationOptions,\n DrawerNavigationEventMap,\n} from '@react-navigation/drawer';\nimport { DrawerNavigationState, ParamListBase } from '@react-navigation/native';\n\nimport { withLayoutContext } from './withLayoutContext';\n\nconst DrawerNavigator = createDrawerNavigator().Navigator;\n\nexport const Drawer = withLayoutContext<\n DrawerNavigationOptions,\n typeof DrawerNavigator,\n DrawerNavigationState<ParamListBase>,\n DrawerNavigationEventMap\n>(DrawerNavigator);\n\nexport default Drawer;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackClient.js","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;AACb,qDAWkC;AAClC,iEAIwC;AAGxC,2DAAwD;AACxD,8CAA+D;AAI/D,MAAM,oBAAoB,GAAG,IAAA,yCAA0B,GAAE,CAAC,SAAS,CAAC;AAEpE,MAAM,OAAO,GAAG,IAAA,qCAAiB,EAK/B,oBAAoB,CAAC,CAAC;AAExB,SAAS,aAAa,CACpB,MAAwB;IAExB,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,MAAM;QACtB,MAAM,CAAC,IAAI,KAAK,UAAU;QAC1B,MAAM,CAAC,IAAI,KAAK,KAAK;QACrB,MAAM,CAAC,IAAI,KAAK,YAAY;QAC5B,MAAM,CAAC,IAAI,KAAK,SAAS,CAC1B,CAAC;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E;QACtC,8CAA8C;QAC9C,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,qDAAqD;QACrD,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,KAAK;QACR,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC;QACxB,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,CAAC,KAAqC,EAAE,EAAE;IACxC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,2BAAmB,CAAC,EAAG,CAAC;AACtE,CAAC,EACD;IACE,MAAM,EAAE,OAAO,CAAC,MAEP;CACV,CACF,CAAC;AAEF,kBAAe,KAAK,CAAC;AAEd,MAAM,WAAW,GAAyB,CAAC,OAAO,EAAE,EAAE;IAC3D,MAAM,MAAM,GAAG,IAAA,oBAAa,EAAC,OAAO,CAAC,CAAC;IACtC,OAAO;QACL,GAAG,MAAM;QACT,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC;KAC/B,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB","sourcesContent":["'use client';\nimport {\n CommonNavigationAction,\n NavigationAction,\n ParamListBase,\n PartialRoute,\n PartialState,\n Route,\n RouterConfigOptions,\n StackRouter as RNStackRouter,\n StackActionType,\n StackNavigationState,\n} from '@react-navigation/native';\nimport {\n NativeStackNavigationEventMap,\n NativeStackNavigationOptions,\n createNativeStackNavigator,\n} from '@react-navigation/native-stack';\nimport { ComponentProps } from 'react';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { SingularOptions, getSingularId } from '../useScreens';\n\ntype GetId = NonNullable<RouterConfigOptions['routeGetIdList'][string]>;\n\nconst NativeStackNavigator = createNativeStackNavigator().Navigator;\n\nconst RNStack = withLayoutContext<\n NativeStackNavigationOptions,\n typeof NativeStackNavigator,\n StackNavigationState<ParamListBase>,\n NativeStackNavigationEventMap\n>(NativeStackNavigator);\n\nfunction isStackAction(\n action: NavigationAction\n): action is StackActionType | Extract<CommonNavigationAction, { type: 'NAVIGATE' }> {\n return (\n action.type === 'PUSH' ||\n action.type === 'NAVIGATE' ||\n action.type === 'POP' ||\n action.type === 'POP_TO_TOP' ||\n action.type === 'REPLACE'\n );\n}\n\n/**\n * React Navigation matches a screen by its name or a 'getID' function that uniquely identifies a screen.\n * When a screen has been uniquely identified, the Stack can only have one instance of that screen.\n *\n * Expo Router allows for a screen to be matched by name and path params, a 'getID' function or a singular id.\n *\n * Instead of reimplementing the entire StackRouter, we can override the getStateForAction method to handle the singular screen logic.\n *\n */\nexport const stackRouterOverride: NonNullable<ComponentProps<typeof RNStack>['UNSTABLE_router']> = (\n original\n) => {\n return {\n getStateForAction: (state, action, options) => {\n if (action.target && action.target !== state.key) {\n return null;\n }\n\n if (!isStackAction(action)) {\n return original.getStateForAction(state, action, options);\n }\n\n // The dynamic getId added to an action, `router.push('screen', { singular: true })`\n const actionSingularOptions =\n action.payload && 'singular' in action.payload\n ? (action.payload.singular as SingularOptions)\n : undefined;\n\n // Handle if 'getID' or 'singular' is set.\n function getIdFunction(fn?: GetId): GetId | undefined {\n // Actions can be fired by the user, so we do need to validate their structure.\n if (\n !('payload' in action) ||\n !action.payload ||\n !('name' in action.payload) ||\n typeof action.payload.name !== 'string'\n ) {\n return;\n }\n\n const name = action.payload.name;\n\n return (\n // The dynamic singular added to an action, `router.push('screen', { singular: () => 'id' })`\n getActionSingularIdFn(actionSingularOptions, name) ||\n // The static getId added as a prop to `<Screen singular />` or `<Screen getId={} />`\n options.routeGetIdList[name] ||\n // The custom singular added by Expo Router to support its concept of `navigate`\n fn\n );\n }\n\n switch (action.type) {\n case 'PUSH': {\n /**\n * PUSH should always push\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction(),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n case 'NAVIGATE': {\n /**\n * NAVIGATE should push unless the current name & route params of the current and target screen match.\n * Search params and hashes should be ignored.\n *\n * If the name, route params & search params match, no action is taken.\n * If both the name and route params match, the screen is replaced.\n * If the name / route params do not match, the screen is pushed.\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction((options) => {\n return getSingularId(action.payload.name, options);\n }),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n default: {\n return original.getStateForAction(state, action, options);\n }\n }\n },\n };\n};\n\nfunction getActionSingularIdFn(\n actionGetId: SingularOptions | undefined,\n name: string\n): GetId | undefined {\n if (typeof actionGetId === 'function') {\n return (options) => actionGetId(name, options.params ?? {});\n } else if (actionGetId === true) {\n return (options) => getSingularId(name, options);\n }\n\n return undefined;\n}\n\n/**\n * If there is a dynamic singular on an action, then we need to filter the state to only have singular screens.\n * As multiples may have been added before we did the singular navigation.\n */\nfunction filterSingular<\n T extends\n | StackNavigationState<ParamListBase>\n | PartialState<StackNavigationState<ParamListBase>>\n | null,\n>(state: T, singular: SingularOptions): T {\n if (!state || !singular) {\n return state;\n }\n\n if (!state.routes) {\n return state;\n }\n\n const currentIndex = state.index || state.routes.length - 1;\n const current = state.routes[currentIndex];\n const name = current.name;\n\n const getId = getActionSingularIdFn(singular, name);\n\n if (!getId) {\n return state;\n }\n\n const id = getId({ params: current.params });\n\n if (!id) {\n return state;\n }\n\n // TypeScript needs a type assertion here for the filter to work.\n let routes = state.routes as PartialRoute<Route<string, object | undefined>>[];\n routes = routes.filter((route, index) => {\n // If the route is the current route, keep it.\n if (index === currentIndex) {\n return true;\n }\n\n // Remove all other routes with the same name and id.\n return name !== route.name || id !== getId({ params: route.params });\n });\n\n return {\n ...state,\n index: routes.length - 1,\n routes,\n };\n}\n\nconst Stack = Object.assign(\n (props: ComponentProps<typeof RNStack>) => {\n return <RNStack {...props} UNSTABLE_router={stackRouterOverride} />;\n },\n {\n Screen: RNStack.Screen as (\n props: ComponentProps<typeof RNStack.Screen> & { singular?: boolean }\n ) => null,\n }\n);\n\nexport default Stack;\n\nexport const StackRouter: typeof RNStackRouter = (options) => {\n const router = RNStackRouter(options);\n return {\n ...router,\n ...stackRouterOverride(router),\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"StackClient.js","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AACb,qDAWkC;AAClC,iEAIwC;AAGxC,2DAAwD;AACxD,8CAA+D;AAI/D,MAAM,oBAAoB,GAAG,IAAA,yCAA0B,GAAE,CAAC,SAAS,CAAC;AAEpE,MAAM,OAAO,GAAG,IAAA,qCAAiB,EAK/B,oBAAoB,CAAC,CAAC;AAExB,SAAS,aAAa,CACpB,MAAwB;IAExB,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,MAAM;QACtB,MAAM,CAAC,IAAI,KAAK,UAAU;QAC1B,MAAM,CAAC,IAAI,KAAK,KAAK;QACrB,M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C;IAC/E,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACtC,8CAA8C;QAC9C,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,qDAAqD;QACrD,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,KAAK;QACR,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC;QACxB,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,CAAC,KAAqC,EAAE,EAAE;IACxC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,2BAAmB,CAAC,EAAG,CAAC;AACtE,CAAC,EACD;IACE,MAAM,EAAE,OAAO,CAAC,MAEP;CACV,CACF,CAAC;AAEF,kBAAe,KAAK,CAAC;AAEd,MAAM,WAAW,GAAyB,CAAC,OAAO,EAAE,EAAE;IAC3D,MAAM,MAAM,GAAG,IAAA,oBAAa,EAAC,OAAO,CAAC,CAAC;IACtC,OAAO;QACL,GAAG,MAAM;QACT,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC;KAC/B,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB","sourcesContent":["'use client';\nimport {\n CommonNavigationAction,\n NavigationAction,\n ParamListBase,\n PartialRoute,\n PartialState,\n Route,\n RouterConfigOptions,\n StackRouter as RNStackRouter,\n StackActionType,\n StackNavigationState,\n} from '@react-navigation/native';\nimport {\n NativeStackNavigationEventMap,\n NativeStackNavigationOptions,\n createNativeStackNavigator,\n} from '@react-navigation/native-stack';\nimport { ComponentProps } from 'react';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { SingularOptions, getSingularId } from '../useScreens';\n\ntype GetId = NonNullable<RouterConfigOptions['routeGetIdList'][string]>;\n\nconst NativeStackNavigator = createNativeStackNavigator().Navigator;\n\nconst RNStack = withLayoutContext<\n NativeStackNavigationOptions,\n typeof NativeStackNavigator,\n StackNavigationState<ParamListBase>,\n NativeStackNavigationEventMap\n>(NativeStackNavigator);\n\nfunction isStackAction(\n action: NavigationAction\n): action is StackActionType | Extract<CommonNavigationAction, { type: 'NAVIGATE' }> {\n return (\n action.type === 'PUSH' ||\n action.type === 'NAVIGATE' ||\n action.type === 'POP' ||\n action.type === 'POP_TO_TOP' ||\n action.type === 'REPLACE'\n );\n}\n\n/**\n * React Navigation matches a screen by its name or a 'getID' function that uniquely identifies a screen.\n * When a screen has been uniquely identified, the Stack can only have one instance of that screen.\n *\n * Expo Router allows for a screen to be matched by name and path params, a 'getID' function or a singular id.\n *\n * Instead of reimplementing the entire StackRouter, we can override the getStateForAction method to handle the singular screen logic.\n *\n */\nexport const stackRouterOverride: NonNullable<ComponentProps<typeof RNStack>['UNSTABLE_router']> = (\n original\n) => {\n return {\n getStateForAction: (state, action, options) => {\n if (action.target && action.target !== state.key) {\n return null;\n }\n\n if (!isStackAction(action)) {\n return original.getStateForAction(state, action, options);\n }\n\n // The dynamic getId added to an action, `router.push('screen', { singular: true })`\n const actionSingularOptions =\n action.payload && 'singular' in action.payload\n ? (action.payload.singular as SingularOptions)\n : undefined;\n\n // Handle if 'getID' or 'singular' is set.\n function getIdFunction(fn?: GetId): GetId | undefined {\n // Actions can be fired by the user, so we do need to validate their structure.\n if (\n !('payload' in action) ||\n !action.payload ||\n !('name' in action.payload) ||\n typeof action.payload.name !== 'string'\n ) {\n return;\n }\n\n const name = action.payload.name;\n\n return (\n // The dynamic singular added to an action, `router.push('screen', { singular: () => 'id' })`\n getActionSingularIdFn(actionSingularOptions, name) ||\n // The static getId added as a prop to `<Screen singular />` or `<Screen getId={} />`\n options.routeGetIdList[name] ||\n // The custom singular added by Expo Router to support its concept of `navigate`\n fn\n );\n }\n\n switch (action.type) {\n case 'PUSH': {\n /**\n * PUSH should always push\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction(),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n case 'NAVIGATE': {\n /**\n * NAVIGATE should push unless the current name & route params of the current and target screen match.\n * Search params and hashes should be ignored.\n *\n * If the name, route params & search params match, no action is taken.\n * If both the name and route params match, the screen is replaced.\n * If the name / route params do not match, the screen is pushed.\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction((options) => {\n return getSingularId(action.payload.name, options);\n }),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n default: {\n return original.getStateForAction(state, action, options);\n }\n }\n },\n };\n};\n\nfunction getActionSingularIdFn(\n actionGetId: SingularOptions | undefined,\n name: string\n): GetId | undefined {\n if (typeof actionGetId === 'function') {\n return (options) => actionGetId(name, options.params ?? {});\n } else if (actionGetId === true) {\n return (options) => getSingularId(name, options);\n }\n\n return undefined;\n}\n\n/**\n * If there is a dynamic singular on an action, then we need to filter the state to only have singular screens.\n * As multiples may have been added before we did the singular navigation.\n */\nfunction filterSingular<\n T extends\n | StackNavigationState<ParamListBase>\n | PartialState<StackNavigationState<ParamListBase>>\n | null,\n>(state: T, singular: SingularOptions): T {\n if (!state || !singular) {\n return state;\n }\n\n if (!state.routes) {\n return state;\n }\n\n const currentIndex = state.index || state.routes.length - 1;\n const current = state.routes[currentIndex];\n const name = current.name;\n\n const getId = getActionSingularIdFn(singular, name);\n\n if (!getId) {\n return state;\n }\n\n const id = getId({ params: current.params });\n\n if (!id) {\n return state;\n }\n\n // TypeScript needs a type assertion here for the filter to work.\n let routes = state.routes as PartialRoute<Route<string, object | undefined>>[];\n routes = routes.filter((route, index) => {\n // If the route is the current route, keep it.\n if (index === currentIndex) {\n return true;\n }\n\n // Remove all other routes with the same name and id.\n return name !== route.name || id !== getId({ params: route.params });\n });\n\n return {\n ...state,\n index: routes.length - 1,\n routes,\n };\n}\n\nconst Stack = Object.assign(\n (props: ComponentProps<typeof RNStack>) => {\n return <RNStack {...props} UNSTABLE_router={stackRouterOverride} />;\n },\n {\n Screen: RNStack.Screen as (\n props: ComponentProps<typeof RNStack.Screen> & { singular?: boolean }\n ) => null,\n }\n);\n\nexport default Stack;\n\nexport const StackRouter: typeof RNStackRouter = (options) => {\n const router = RNStackRouter(options);\n return {\n ...router,\n ...stackRouterOverride(router),\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsClient.d.ts","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKhC,KAAK,SAAS,GAAG,0BAA0B,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"TabsClient.d.ts","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKhC,KAAK,SAAS,GAAG,0BAA0B,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Cf,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
3
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
@@ -25,6 +25,7 @@ exports.Tabs = (0, withLayoutContext_1.withLayoutContext)(BottomTabNavigator, (s
|
|
|
25
25
|
options: {
|
|
26
26
|
...options,
|
|
27
27
|
tabBarItemStyle: href == null ? { display: 'none' } : options.tabBarItemStyle,
|
|
28
|
+
// @ts-expect-error: TODO(@kitten): This isn't properly typed
|
|
28
29
|
tabBarButton: (props) => {
|
|
29
30
|
if (href == null) {
|
|
30
31
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsClient.js","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"TabsClient.js","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AAEb,+DAIuC;AAEvC,kDAA0B;AAC1B,+CAAmD;AAEnD,2DAAwD;AACxD,uCAAoC;AAGpC,gDAAgD;AAChD,MAAM,kBAAkB,GAAG,IAAA,sCAAwB,GAAE,CAAC,SAAS,CAAC;AAInD,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,CAAC;YAC/E,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;YAC5C,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;YACpE,CAAC;YACD,OAAO;gBACL,GAAG,MAAM;gBACT,OAAO,EAAE;oBACP,GAAG,OAAO;oBACV,eAAe,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe;oBAC7E,6DAA6D;oBAC7D,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;wBACtB,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;4BACjB,OAAO,IAAI,CAAC;wBACd,CAAC;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,+FAA+F;wBAC/F,0EAA0E;wBAC1E,OAAO,CACL,CAAC,WAAI,CACH,IAAK,KAAa,CAAC,CACnB,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,KAAY,CAAC,CAAC,CACjD,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;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,kBAAe,YAAI,CAAC","sourcesContent":["'use client';\n\nimport {\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 '../types';\n\n// This is the only way to access the navigator.\nconst BottomTabNavigator = createBottomTabNavigator().Navigator;\n\ntype TabsProps = BottomTabNavigationOptions & { href?: Href | null };\n\nexport const Tabs = withLayoutContext<\n TabsProps,\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 tabBarItemStyle: href == null ? { display: 'none' } : options.tabBarItemStyle,\n // @ts-expect-error: TODO(@kitten): This isn't properly typed\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 // TODO: React Navigation types these props as Animated.WithAnimatedValue<StyleProp<ViewStyle>>\n // While Link expects a TextStyle. We need to reconcile these types.\n return (\n <Link\n {...(props as any)}\n style={[{ display: 'flex' }, props.style as any]}\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"]}
|
package/build/link/Link.js
CHANGED
package/build/link/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AA+Eb,4BAUC;AAxFD,wFAAwF;AACxF,mCAAmC;AACnC,iCAA8F;AAC9F,+CAAqE;AAErE,iCAAqC;AACrC,8EAAsD;AACtD,oCAAqC;AAErC,sDAAmD;AACnD,iDAA8F;AAC9F,0CAAuC;AACvC,qCAAkC;AA2ClC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAiB;IAC/E,MAAM,MAAM,GAAG,IAAA,iBAAS,GAAE,CAAC;IAC3B,IAAA,+BAAc,EAAC,GAAG,EAAE;QAClB,IAAI,CAAC;YACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,mBAAmB,EAAE,UAAU,EAAE,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC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;KAC9B,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,CAAC,CAAwD,EAAE,EAAE;QAC3E,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,WAAI,CAAC,CAAC,CAAC,mBAAI,CAAC;IAExC,6HAA6H;IAC7H,MAAM,OAAO,GAAG,CACd,CAAC,SAAS,CACR,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,IAAI,KAAK,CAAC,CACV,IAAI,SAAS,CAAC,CACd,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,IAAI,uBAAQ,CAAC,MAAM,CAAC;QAClB,GAAG,EAAE;YACH,OAAO,EAAE,OAAO;SACV;QACR,OAAO,EAAE,EAAE,OAAO,EAAE;KACrB,CAAC,CAAC,EACH,CACH,CAAC;IAEF,OAAO,QAAQ,CAAC,CAAC,CAAC,CAChB,EACE;MAAA,CAAC,mBAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EACrB;MAAA,CAAC,OAAO,CACV;IAAA,GAAG,CACJ,CAAC,CAAC,CAAC,CACF,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { PropsWithChildren, forwardRef, useMemo, MouseEvent, ForwardedRef, JSX } from 'react';\nimport { Text, GestureResponderEvent, Platform } from 'react-native';\n\nimport { resolveHref } from './href';\nimport useLinkToPathProps from './useLinkToPathProps';\nimport { useRouter } from '../hooks';\nimport { Href } from '../types';\nimport { useFocusEffect } from '../useFocusEffect';\nimport { useInteropClassName, useHrefAttrs, LinkProps, WebAnchorProps } from './useLinkHooks';\nimport { Prefetch } from '../Prefetch';\nimport { Slot } from '../ui/Slot';\n\nexport interface LinkComponent {\n (props: PropsWithChildren<LinkProps>): JSX.Element;\n /** Helper method to resolve an Href object into a string. */\n resolveHref: (href: Href) => string;\n}\n\nexport type RedirectProps = {\n /**\n * The path of the route to navigate to. It can either be:\n * - **string**: A full path like `/profile/settings` or a relative path like `../settings`.\n * - **object**: An object with a `pathname` and optional `params`. The `pathname` can be\n * a full path like `/profile/settings` or a relative path like `../settings`. The\n * params can be an object of key-value pairs.\n *\n * @example\n * ```tsx Dynamic\n * import { Redirect } from 'expo-router';\n *\n * export default function RedirectToAbout() {\n * return (\n * <Redirect href=\"/about\">About</Link>\n * );\n *}\n * ```\n */\n href: Href;\n\n /**\n * Relative URL references are either relative to the directory or the document.\n * By default, relative paths are relative to the document.\n *\n * @see [Resolving relative references in Mozilla's documentation](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Replaces the initial screen with the current route.\n */\n withAnchor?: boolean;\n};\n\n/**\n * Redirects to the `href` as soon as the component is mounted.\n *\n * @example\n * ```tsx\n * import { View, Text } from 'react-native';\n * import { Redirect } from 'expo-router';\n *\n * export default function Page() {\n * const { user } = useAuth();\n *\n * if (!user) {\n * return <Redirect href=\"/login\" />;\n * }\n *\n * return (\n * <View>\n * <Text>Welcome Back!</Text>\n * </View>\n * );\n * }\n * ```\n */\nexport function Redirect({ href, relativeToDirectory, withAnchor }: RedirectProps) {\n const router = useRouter();\n useFocusEffect(() => {\n try {\n router.replace(href, { relativeToDirectory, withAnchor });\n } catch (error) {\n console.error(error);\n }\n });\n return null;\n}\n\n/**\n * Component that renders a link using [`href`](#href) to another route.\n * By default, it accepts children and wraps them in a `<Text>` component.\n *\n * Uses an anchor tag (`<a>`) on web and performs a client-side navigation to preserve\n * the state of the website and navigate faster. The web-only attributes such as `target`,\n * `rel`, and `download` are supported and passed to the anchor tag on web. See\n * [`WebAnchorProps`](#webanchorprops) for more details.\n *\n * > **Note**: Client-side navigation works with both single-page apps,\n * and [static-rendering](/router/reference/static-rendering/).\n *\n * @example\n * ```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link href=\"/about\">About</Link>\n * </View>\n * );\n *}\n * ```\n */\nexport const Link = forwardRef(ExpoRouterLink) as unknown as LinkComponent;\n\nLink.resolveHref = resolveHref;\n\nfunction ExpoRouterLink(\n {\n href,\n replace,\n push,\n dismissTo,\n // TODO: This does not prevent default on the anchor tag.\n relativeToDirectory,\n asChild,\n rel,\n target,\n download,\n withAnchor,\n dangerouslySingular: singular,\n prefetch,\n ...rest\n }: LinkProps,\n ref: ForwardedRef<Text>\n) {\n // Mutate the style prop to add the className on web.\n const style = useInteropClassName(rest);\n\n // If not passing asChild, we need to forward the props to the anchor tag using React Native Web's `hrefAttrs`.\n const hrefAttrs = useHrefAttrs({ asChild, rel, target, download });\n\n const resolvedHref = useMemo(() => {\n if (href == null) {\n throw new Error('Link: href is required');\n }\n return resolveHref(href);\n }, [href]);\n\n let event;\n if (push) event = 'PUSH';\n if (replace) event = 'REPLACE';\n if (dismissTo) event = 'POP_TO';\n\n const props = useLinkToPathProps({\n href: resolvedHref,\n event,\n relativeToDirectory,\n withAnchor,\n dangerouslySingular: singular,\n });\n\n const onPress = (e: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n props.onPress(e);\n };\n\n const Component = asChild ? Slot : Text;\n\n // Avoid using createElement directly, favoring JSX, to allow tools like NativeWind to perform custom JSX handling on native.\n const element = (\n <Component\n ref={ref}\n {...props}\n {...hrefAttrs}\n {...rest}\n style={style}\n {...Platform.select({\n web: {\n onClick: onPress,\n } as any,\n default: { onPress },\n })}\n />\n );\n\n return prefetch ? (\n <>\n <Prefetch href={href} />\n {element}\n </>\n ) : (\n element\n );\n}\n\nexport { LinkProps, WebAnchorProps };\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RouterStore } from '../global-state/router-store';
|
|
2
2
|
import type { LinkToOptions } from '../global-state/routing';
|
|
3
|
-
export declare function emitDomSetParams(params?: Record<string, string | number | (string | number)[]>): boolean;
|
|
3
|
+
export declare function emitDomSetParams(params?: Record<string, undefined | string | number | (string | number)[]>): boolean;
|
|
4
4
|
export declare function emitDomDismiss(count?: number): boolean;
|
|
5
5
|
export declare function emitDomGoBack(): boolean;
|
|
6
6
|
export declare function emitDomDismissAll(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDomComponentNavigation.d.ts","sourceRoot":"","sources":["../../src/link/useDomComponentNavigation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAiB7D,wBAAgB,gBAAgB,CAC9B,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAM,
|
|
1
|
+
{"version":3,"file":"useDomComponentNavigation.d.ts","sourceRoot":"","sources":["../../src/link/useDomComponentNavigation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAiB7D,wBAAgB,gBAAgB,CAC9B,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAM,WAG/E;AAED,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,WAE5C;AAED,wBAAgB,aAAa,YAE5B;AAED,wBAAgB,iBAAiB,YAEhC;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,WAEpE;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,WAAW,QAyB3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDomComponentNavigation.js","sourceRoot":"","sources":["../../src/link/useDomComponentNavigation.ts"],"names":[],"mappings":";;;;;AAqBA,4CAIC;AAED,wCAEC;AAED,sCAEC;AAED,8CAEC;AAED,4CAEC;AAED,8DAyBC;AApED,4CAA4D;AAC5D,kDAA0B;AAK1B,MAAM,gBAAgB,GAAG,eAAe,CAAC;AACzC,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAC/C,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAC3C,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAEpD,SAAS,YAAY,CAAC,IAAY,EAAE,OAAY,EAAE;IAChD,oFAAoF;IACpF,IAAI,OAAO,kBAAkB,KAAK,WAAW,EAAE,CAAC;QAC7C,MAAc,CAAC,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,gBAAgB,CAC9B,
|
|
1
|
+
{"version":3,"file":"useDomComponentNavigation.js","sourceRoot":"","sources":["../../src/link/useDomComponentNavigation.ts"],"names":[],"mappings":";;;;;AAqBA,4CAIC;AAED,wCAEC;AAED,sCAEC;AAED,8CAEC;AAED,4CAEC;AAED,8DAyBC;AApED,4CAA4D;AAC5D,kDAA0B;AAK1B,MAAM,gBAAgB,GAAG,eAAe,CAAC;AACzC,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAC/C,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAC3C,MAAM,sBAAsB,GAAG,oBAA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CAAC,OAAO,CAAC,CAAC;oBACtC,MAAM;gBACR,KAAK,uBAAuB;oBAC1B,KAAK,CAAC,UAAU,EAAE,CAAC;oBACnB,MAAM;gBACR,KAAK,mBAAmB;oBACtB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAC1B,MAAM;gBACR,KAAK,gBAAgB;oBACnB,KAAK,CAAC,MAAM,EAAE,CAAC;oBACf,MAAM;gBACR,KAAK,sBAAsB;oBACzB,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC7B,MAAM;YACV,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { addGlobalDomEventListener } from 'expo/dom/global';\nimport React from 'react';\n\nimport type { RouterStore } from '../global-state/router-store';\nimport type { LinkToOptions } from '../global-state/routing';\n\nconst ROUTER_LINK_TYPE = '$$router_link';\nconst ROUTER_DISMISS_ALL_TYPE = '$$router_dismissAll';\nconst ROUTER_DISMISS_TYPE = '$$router_dismiss';\nconst ROUTER_BACK_TYPE = '$$router_goBack';\nconst ROUTER_SET_PARAMS_TYPE = '$$router_setParams';\n\nfunction emitDomEvent(type: string, data: any = {}) {\n // @ts-expect-error: ReactNativeWebView is a global variable injected by the WebView\n if (typeof ReactNativeWebView !== 'undefined') {\n (window as any).ReactNativeWebView.postMessage(JSON.stringify({ type, data }));\n return true;\n }\n return false;\n}\n\nexport function emitDomSetParams(\n params: Record<string, undefined | string | number | (string | number)[]> = {}\n) {\n return emitDomEvent(ROUTER_SET_PARAMS_TYPE, { params });\n}\n\nexport function emitDomDismiss(count?: number) {\n return emitDomEvent(ROUTER_DISMISS_TYPE, { count });\n}\n\nexport function emitDomGoBack() {\n return emitDomEvent(ROUTER_BACK_TYPE);\n}\n\nexport function emitDomDismissAll() {\n return emitDomEvent(ROUTER_DISMISS_ALL_TYPE);\n}\n\nexport function emitDomLinkEvent(href: string, options: LinkToOptions) {\n return emitDomEvent(ROUTER_LINK_TYPE, { href, options });\n}\n\nexport function useDomComponentNavigation(store: RouterStore) {\n React.useEffect(() => {\n if (process.env.EXPO_OS === 'web') {\n return () => {};\n }\n return addGlobalDomEventListener<any>(({ type, data }) => {\n switch (type) {\n case ROUTER_LINK_TYPE:\n store.linkTo(data.href, data.options);\n break;\n case ROUTER_DISMISS_ALL_TYPE:\n store.dismissAll();\n break;\n case ROUTER_DISMISS_TYPE:\n store.dismiss(data.count);\n break;\n case ROUTER_BACK_TYPE:\n store.goBack();\n break;\n case ROUTER_SET_PARAMS_TYPE:\n store.setParams(data.params);\n break;\n }\n });\n }, [store]);\n}\n"]}
|
|
@@ -160,8 +160,8 @@ export interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {
|
|
|
160
160
|
*/
|
|
161
161
|
push?: boolean;
|
|
162
162
|
/**
|
|
163
|
-
* While in a stack, this will dismiss screens until the provided href is reached. If the href is not found,
|
|
164
|
-
* it will instead replace the current screen with the provided href
|
|
163
|
+
* While in a stack, this will dismiss screens until the provided `href` is reached. If the href is not found,
|
|
164
|
+
* it will instead replace the current screen with the provided `href`.
|
|
165
165
|
*
|
|
166
166
|
* @example
|
|
167
167
|
*```tsx
|
|
@@ -183,7 +183,7 @@ export interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {
|
|
|
183
183
|
* On web, this sets the HTML `class` directly.
|
|
184
184
|
*/
|
|
185
185
|
className?: string;
|
|
186
|
-
onPress?: (
|
|
186
|
+
onPress?: (event: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => void;
|
|
187
187
|
/**
|
|
188
188
|
* Relative URL references are either relative to the directory or the document.
|
|
189
189
|
* By default, relative paths are relative to the document.
|
|
@@ -203,7 +203,6 @@ export interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {
|
|
|
203
203
|
*/
|
|
204
204
|
dangerouslySingular?: SingularOptions;
|
|
205
205
|
/**
|
|
206
|
-
* Preloads the route when the component is rendered on a focused screen.
|
|
207
206
|
* Prefetches the route when the component is rendered on a focused screen.
|
|
208
207
|
*/
|
|
209
208
|
prefetch?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinkHooks.d.ts","sourceRoot":"","sources":["../../src/link/useLinkHooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,UAAU,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAErE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAGF,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,cAAc;IACxE;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,IAAI,EAAE,IAAI,CAAC;IAGX;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;;;;;;;;;;;;OAiBG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM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