expo-router 5.0.6 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/arrow_down.png +0 -0
- package/build/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +3 -0
- package/build/ExpoRoot.js.map +1 -1
- package/build/exports.d.ts +1 -0
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js +3 -1
- package/build/exports.js.map +1 -1
- package/build/fork/getPathFromState-forks.js +1 -4
- package/build/fork/getPathFromState-forks.js.map +1 -1
- package/build/fork/getStateFromPath-forks.d.ts +2 -0
- package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
- package/build/fork/getStateFromPath-forks.js +14 -1
- package/build/fork/getStateFromPath-forks.js.map +1 -1
- package/build/fork/useLinking.d.ts.map +1 -1
- package/build/fork/useLinking.js +28 -6
- package/build/fork/useLinking.js.map +1 -1
- package/build/getReactNavigationConfig.d.ts.map +1 -1
- package/build/getReactNavigationConfig.js +8 -7
- package/build/getReactNavigationConfig.js.map +1 -1
- package/build/getRoutesCore.d.ts.map +1 -1
- package/build/getRoutesCore.js +6 -10
- package/build/getRoutesCore.js.map +1 -1
- package/build/getRoutesRedirects.d.ts.map +1 -1
- package/build/getRoutesRedirects.js +22 -16
- package/build/getRoutesRedirects.js.map +1 -1
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +6 -1
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +14 -0
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +41 -6
- package/build/global-state/routing.js.map +1 -1
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +5 -0
- package/build/hooks.js.map +1 -1
- package/build/imperative-api.d.ts +1 -0
- package/build/imperative-api.d.ts.map +1 -1
- package/build/imperative-api.js +9 -0
- package/build/imperative-api.js.map +1 -1
- package/build/layouts/TabsClient.d.ts +3 -1
- package/build/layouts/TabsClient.d.ts.map +1 -1
- package/build/layouts/TabsClient.js +2 -0
- package/build/layouts/TabsClient.js.map +1 -1
- package/build/matchers.d.ts +6 -3
- package/build/matchers.d.ts.map +1 -1
- package/build/matchers.js +15 -11
- package/build/matchers.js.map +1 -1
- package/build/rsc/middleware.d.ts.map +1 -1
- package/build/rsc/middleware.js +15 -27
- package/build/rsc/middleware.js.map +1 -1
- package/build/typed-routes/generate.js +5 -2
- package/build/typed-routes/generate.js.map +1 -1
- package/build/useFocusEffect.d.ts +2 -2
- package/build/useFocusEffect.js +2 -2
- package/build/useFocusEffect.js.map +1 -1
- package/build/views/Navigator.d.ts.map +1 -1
- package/build/views/Navigator.js +5 -2
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Sitemap.d.ts.map +1 -1
- package/build/views/Sitemap.js +56 -72
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/useSitemap.d.ts +12 -0
- package/build/views/useSitemap.d.ts.map +1 -0
- package/build/views/useSitemap.js +50 -0
- package/build/views/useSitemap.js.map +1 -0
- package/package.json +2 -2
- package/_async-server-import.js +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRoutesRedirects.js","sourceRoot":"","sources":["../src/getRoutesRedirects.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,wCA2BC;AAED,8CAiCC;AAED,
|
|
1
|
+
{"version":3,"file":"getRoutesRedirects.js","sourceRoot":"","sources":["../src/getRoutesRedirects.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,wCA2BC;AAED,8CAiCC;AAED,0CAoBC;AAED,wDAeC;AA7GD,sDAAwC;AACxC,iCAAsC;AAEtC,0EAA0D;AAG1D,yCAA8C;AAE9C,SAAgB,cAAc,CAC5B,GAA8B,EAC9B,SAAuC;IAEvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,SAAS,EAAE,CAAC;QAC1C,OAAO,GAA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,CAAC,KAAK,CAAC,CAAC;YAC9C,MAAM;QACR,CAAC;IACH,CAAC;IAED,OAAO,sBAAsB,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,sBAAsB,CAAC,IAAY,EAAE,MAAyC;IAC5F,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,WAAW,GAAG,IAAA,2BAAgB,EAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACvC,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["import * as Linking from 'expo-linking';\nimport { createElement } from 'react';\n\nimport { cleanPath } from './fork/getStateFromPath-forks';\nimport { RedirectConfig } from './getRoutesCore';\nimport type { StoreRedirects } from './global-state/router-store';\nimport { matchDynamicName } from './matchers';\n\nexport function applyRedirects(\n url: string | null | undefined,\n redirects: StoreRedirects[] | undefined\n): string | undefined | null {\n if (typeof url !== 'string' || !redirects) {\n return url;\n }\n\n const nextUrl = cleanPath(url);\n const redirect = redirects.find(([regex]) => regex.test(nextUrl));\n\n if (!redirect) {\n return url;\n }\n\n // If the redirect is external, open the URL\n if (redirect[2]) {\n let href = redirect[1].destination;\n if (href.startsWith('//') && process.env.EXPO_OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return href;\n }\n\n return applyRedirects(convertRedirect(url, redirect[1]), redirects);\n}\n\nexport function getRedirectModule(route: string) {\n return {\n default: function RedirectComponent() {\n // Use the store directly instead of useGlobalSearchParams.\n // Importing the hooks directly causes build errors on the server\n const params = require('./hooks').useGlobalSearchParams();\n\n // Replace dynamic parts of the route with the actual values from the params\n let href = route\n .split('/')\n .map((part) => {\n const dynamicName = matchDynamicName(part);\n if (!dynamicName) {\n return part;\n } else {\n const param = params[dynamicName.name];\n delete params[dynamicName.name];\n return param;\n }\n })\n .filter(Boolean)\n .join('/');\n\n // Add any remaining params as query string\n const queryString = new URLSearchParams(params as Record<string, any>).toString();\n\n if (queryString) {\n href += `?${queryString}`;\n }\n\n return createElement(require('./link/Link').Redirect, { href });\n },\n };\n}\n\nexport function convertRedirect(path: string, config: RedirectConfig) {\n const params: Record<string, string | string[]> = {};\n\n const parts = path.split('/');\n const sourceParts = config.source.split('/');\n\n for (const [index, sourcePart] of sourceParts.entries()) {\n const dynamicName = matchDynamicName(sourcePart);\n if (!dynamicName) {\n continue;\n } else if (!dynamicName.deep) {\n params[dynamicName.name] = parts[index];\n continue;\n } else {\n params[dynamicName.name] = parts.slice(index);\n break;\n }\n }\n\n return mergeVariablesWithPath(config.destination, params);\n}\n\nexport function mergeVariablesWithPath(path: string, params: Record<string, string | string[]>) {\n return path\n .split('/')\n .map((part) => {\n const dynamicName = matchDynamicName(part);\n if (!dynamicName) {\n return part;\n } else {\n const param = params[dynamicName.name];\n delete params[dynamicName.name];\n return param;\n }\n })\n .filter(Boolean)\n .join('/');\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-store.d.ts","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,iCAAiC,EACjC,eAAe,EACf,YAAY,EAEZ,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,aAAa,EAA6C,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"router-store.d.ts","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,iCAAiC,EACjC,eAAe,EACf,YAAY,EAEZ,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,aAAa,EAA6C,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAoB,MAAM,qBAAqB,CAAC;AAGjG,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAA2C,SAAS,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK1C,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AACnF,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG,OAAO,KAAK,CAAC;AAsBvC,eAAO,MAAM,KAAK;;;;;oBAaA,SAAS;;;;2BAYF,iBAAiB;;;CAiDzC,CAAC;AAEF,wBAAgB,QAAQ,CACtB,OAAO,EAAE,cAAc,EACvB,oBAAoB,EAAE,oBAAoB,EAC1C,SAAS,CAAC,EAAE,MAAM;;;;;oBAlEF,SAAS;;;;2BAYF,iBAAiB;;;EA2IzC;AAUD,wBAAgB,YAAY,cAE3B"}
|
|
@@ -44,6 +44,7 @@ const native_1 = require("@react-navigation/native");
|
|
|
44
44
|
const expo_constants_1 = __importDefault(require("expo-constants"));
|
|
45
45
|
const react_1 = require("react");
|
|
46
46
|
const react_native_1 = require("react-native");
|
|
47
|
+
const extractPathFromURL_1 = require("../fork/extractPathFromURL");
|
|
47
48
|
const getStateFromPath_forks_1 = require("../fork/getStateFromPath-forks");
|
|
48
49
|
const getLinkingConfig_1 = require("../getLinkingConfig");
|
|
49
50
|
const getReactNavigationConfig_1 = require("../getReactNavigationConfig");
|
|
@@ -157,7 +158,11 @@ function useStore(context, linkingConfigOptions, serverUrl) {
|
|
|
157
158
|
// If the initialURL is a string, we can prefetch the state and routeInfo, skipping React Navigation's async behavior.
|
|
158
159
|
const initialURL = linking?.getInitialURL?.();
|
|
159
160
|
if (typeof initialURL === 'string') {
|
|
160
|
-
|
|
161
|
+
let initialPath = (0, extractPathFromURL_1.extractExpoPathFromURL)(linking.prefixes, initialURL);
|
|
162
|
+
// It does not matter if the path starts with a `/` or not, but this keeps the behavior consistent
|
|
163
|
+
if (!initialPath.startsWith('/'))
|
|
164
|
+
initialPath = '/' + initialPath;
|
|
165
|
+
initialState = linking.getStateFromPath(initialPath, linking.config);
|
|
161
166
|
const initialRouteInfo = (0, routeInfo_1.getRouteInfoFromState)(initialState);
|
|
162
167
|
routeInfoCache.set(initialState, initialRouteInfo);
|
|
163
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Hb,4BAmFC;AAUD,oCAEC;AA5ND,qDAMkC;AAClC,oEAAuC;AACvC,iCAAiF;AACjF,+CAAwC;AAGxC,2EAAqE;AACrE,0DAAiG;AACjG,0EAAiE;AACjE,4CAAyC;AAEzC,2CAAiF;AAEjF,8CAA2D;AAC3D,sCAAoD;AACpD,8DAAgD;AAmBhD,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,EAAc;CACxB,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,OAAO,EAAuD,CAAC;AAE1F,IAAI,0BAA8C,CAAC;AACnD,IAAI,wBAAwB,GAAG,KAAK,CAAC;AAExB,QAAA,KAAK,GAAG;IACnB,kBAAkB;QA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f,SAAS,GAAG,IAAA,iCAAqB,EAAC,KAAK,CAAC,CAAC;QAEzC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;QACrD,IAAI,iBAAiB,EAAE,CAAC;YACtB,MAAM,QAAQ,GACZ,SAAS,CAAC,QAAQ,CAAC,MAAM,KAAK,iBAAiB,CAAC,QAAQ,CAAC,MAAM;gBAC/D,SAAS,CAAC,QAAQ,CAAC,KAAK,CACtB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,OAAO,CAClE;gBACD,SAAS,CAAC,kBAAkB,KAAK,iBAAiB,CAAC,kBAAkB,CAAC;YAExE,IAAI,QAAQ,EAAE,CAAC;gBACb,gFAAgF;gBAChF,SAAS,GAAG,iBAAiB,CAAC;YAChC,CAAC;QACH,CAAC;QAED,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n NavigationState,\n PartialState,\n useNavigationContainerRef,\n useStateForPath,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport { ComponentType, Fragment, useEffect, useSyncExternalStore } from 'react';\nimport { Platform } from 'react-native';\n\nimport { RouteNode } from '../Route';\nimport { routePatternToRegex } from '../fork/getStateFromPath-forks';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { parseRouteSegments } from '../getReactNavigationConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RedirectConfig } from '../getRoutesCore';\nimport { defaultRouteInfo, getRouteInfoFromState, UrlObject } from './routeInfo';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\nimport * as SplashScreen from '../views/Splash';\n\nexport type StoreRedirects = readonly [RegExp, RedirectConfig, boolean];\nexport type ReactNavigationState = NavigationState | PartialState<NavigationState>;\nexport type FocusedRouteState = NonNullable<ReturnType<typeof useStateForPath>>;\n\nexport type RouterStore = typeof store;\n\ntype StoreRef = {\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n routeNode: RouteNode | null;\n rootComponent: ComponentType<any>;\n state?: ReactNavigationState;\n linking?: ExpoLinkingOptions;\n config: any;\n redirects: StoreRedirects[];\n routeInfo?: UrlObject;\n};\n\nconst storeRef = {\n current: {} as StoreRef,\n};\n\nconst routeInfoCache = new WeakMap<FocusedRouteState | ReactNavigationState, UrlObject>();\n\nlet splashScreenAnimationFrame: number | undefined;\nlet hasAttemptedToHideSplash = false;\n\nexport const store = {\n shouldShowTutorial() {\n return !storeRef.current.routeNode && process.env.NODE_ENV === 'development';\n },\n get state() {\n return storeRef.current.state;\n },\n get navigationRef() {\n return storeRef.current.navigationRef;\n },\n get routeNode() {\n return storeRef.current.routeNode;\n },\n getRouteInfo(): UrlObject {\n return storeRef.current.routeInfo || defaultRouteInfo;\n },\n get redirects() {\n return storeRef.current.redirects || [];\n },\n get rootComponent() {\n return storeRef.current.rootComponent;\n },\n get linking() {\n return storeRef.current.linking;\n },\n setFocusedState(state: FocusedRouteState) {\n const routeInfo = getCachedRouteInfo(state);\n storeRef.current.routeInfo = routeInfo;\n },\n onReady() {\n if (!hasAttemptedToHideSplash) {\n hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n splashScreenAnimationFrame = requestAnimationFrame(() => {\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n storeRef.current.navigationRef.addListener('state', (e) => {\n if (!e.data.state) {\n return;\n }\n\n let isStale: boolean | undefined = false;\n let state: ReactNavigationState | undefined = e.data.state;\n\n while (!isStale && state) {\n isStale = state.stale;\n state =\n state.routes?.[\n 'index' in state && typeof state.index === 'number'\n ? state.index\n : state.routes.length - 1\n ]?.state;\n }\n\n storeRef.current.state = e.data.state;\n\n if (!isStale) {\n storeRef.current.routeInfo = getCachedRouteInfo(e.data.state);\n }\n\n for (const callback of routeInfoSubscribers) {\n callback();\n }\n });\n },\n assertIsReady() {\n if (!storeRef.current.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};\n\nexport function useStore(\n context: RequireContext,\n linkingConfigOptions: LinkingConfigOptions,\n serverUrl?: string\n) {\n const navigationRef = useNavigationContainerRef();\n const config = Constants.expoConfig?.extra?.router;\n\n let linking: ExpoLinkingOptions | undefined;\n let rootComponent: ComponentType<any> = Fragment;\n let initialState: ReactNavigationState | undefined;\n\n const routeNode = getRoutes(context, {\n ...config,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n const redirects: StoreRedirects[] = [config?.redirects, config?.rewrites]\n .filter(Boolean)\n .flat()\n .map((route) => {\n return [\n routePatternToRegex(parseRouteSegments(route.source)),\n route,\n shouldLinkExternally(route.destination),\n ];\n });\n\n if (routeNode) {\n // We have routes, so get the linking config and the root component\n linking = getLinkingConfig(routeNode, context, () => store.getRouteInfo(), {\n metaOnly: linkingConfigOptions.metaOnly,\n serverUrl,\n redirects,\n });\n rootComponent = getQualifiedRouteComponent(routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can prefetch the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n initialState = linking.getStateFromPath(initialURL, linking.config);\n const initialRouteInfo = getRouteInfoFromState(initialState);\n routeInfoCache.set(initialState as any, initialRouteInfo);\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n rootComponent = Fragment;\n }\n\n storeRef.current = {\n navigationRef,\n routeNode,\n config,\n rootComponent,\n linking,\n redirects,\n state: initialState,\n };\n\n if (initialState) {\n storeRef.current.routeInfo = getCachedRouteInfo(initialState);\n }\n\n useEffect(() => {\n return () => {\n // listener();\n\n if (splashScreenAnimationFrame) {\n cancelAnimationFrame(splashScreenAnimationFrame);\n splashScreenAnimationFrame = undefined;\n }\n };\n });\n\n return store;\n}\n\nconst routeInfoSubscribers = new Set<() => void>();\nconst routeInfoSubscribe = (callback: () => void) => {\n routeInfoSubscribers.add(callback);\n return () => {\n routeInfoSubscribers.delete(callback);\n };\n};\n\nexport function useRouteInfo() {\n return useSyncExternalStore(routeInfoSubscribe, store.getRouteInfo, store.getRouteInfo);\n}\n\nfunction getCachedRouteInfo(state: ReactNavigationState) {\n let routeInfo = routeInfoCache.get(state);\n\n if (!routeInfo) {\n routeInfo = getRouteInfoFromState(state);\n\n const previousRouteInfo = storeRef.current.routeInfo;\n if (previousRouteInfo) {\n const areEqual =\n routeInfo.segments.length === previousRouteInfo.segments.length &&\n routeInfo.segments.every(\n (segment, index) => previousRouteInfo.segments[index] === segment\n ) &&\n routeInfo.pathnameWithParams === previousRouteInfo.pathnameWithParams;\n\n if (areEqual) {\n // If they are equal, keep the previous route info for object reference equality\n routeInfo = previousRouteInfo;\n }\n }\n\n routeInfoCache.set(state, routeInfo);\n }\n\n return routeInfo;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIb,4BAwFC;AAUD,oCAEC;AAlOD,qDAMkC;AAClC,oEAAuC;AACvC,iCAAiF;AACjF,+CAAwC;AAGxC,mEAAoE;AACpE,2EAAqE;AACrE,0DAAiG;AACjG,0EAAiE;AACjE,4CAAyC;AAEzC,2CAAiF;AAEjF,8CAA2D;AAC3D,sCAAoD;AACpD,8DAAgD;AAmBhD,MAAM,QAAQ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AQ,CAAC,CAAC;IACnC,OAAO,GAAG,EAAE;QACV,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,SAAgB,YAAY;IAC1B,OAAO,IAAA,4BAAoB,EAAC,kBAAkB,EAAE,aAAK,CAAC,YAAY,EAAE,aAAK,CAAC,YAAY,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,kBAAkB,CAAC,KAA2B;IACrD,IAAI,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAE1C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,IAAA,iCAAqB,EAAC,KAAK,CAAC,CAAC;QAEzC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;QACrD,IAAI,iBAAiB,EAAE,CAAC;YACtB,MAAM,QAAQ,GACZ,SAAS,CAAC,QAAQ,CAAC,MAAM,KAAK,iBAAiB,CAAC,QAAQ,CAAC,MAAM;gBAC/D,SAAS,CAAC,QAAQ,CAAC,KAAK,CACtB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,OAAO,CAClE;gBACD,SAAS,CAAC,kBAAkB,KAAK,iBAAiB,CAAC,kBAAkB,CAAC;YAExE,IAAI,QAAQ,EAAE,CAAC;gBACb,gFAAgF;gBAChF,SAAS,GAAG,iBAAiB,CAAC;YAChC,CAAC;QACH,CAAC;QAED,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n NavigationState,\n PartialState,\n useNavigationContainerRef,\n useStateForPath,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport { ComponentType, Fragment, useEffect, useSyncExternalStore } from 'react';\nimport { Platform } from 'react-native';\n\nimport { RouteNode } from '../Route';\nimport { extractExpoPathFromURL } from '../fork/extractPathFromURL';\nimport { routePatternToRegex } from '../fork/getStateFromPath-forks';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { parseRouteSegments } from '../getReactNavigationConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RedirectConfig } from '../getRoutesCore';\nimport { defaultRouteInfo, getRouteInfoFromState, UrlObject } from './routeInfo';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\nimport * as SplashScreen from '../views/Splash';\n\nexport type StoreRedirects = readonly [RegExp, RedirectConfig, boolean];\nexport type ReactNavigationState = NavigationState | PartialState<NavigationState>;\nexport type FocusedRouteState = NonNullable<ReturnType<typeof useStateForPath>>;\n\nexport type RouterStore = typeof store;\n\ntype StoreRef = {\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n routeNode: RouteNode | null;\n rootComponent: ComponentType<any>;\n state?: ReactNavigationState;\n linking?: ExpoLinkingOptions;\n config: any;\n redirects: StoreRedirects[];\n routeInfo?: UrlObject;\n};\n\nconst storeRef = {\n current: {} as StoreRef,\n};\n\nconst routeInfoCache = new WeakMap<FocusedRouteState | ReactNavigationState, UrlObject>();\n\nlet splashScreenAnimationFrame: number | undefined;\nlet hasAttemptedToHideSplash = false;\n\nexport const store = {\n shouldShowTutorial() {\n return !storeRef.current.routeNode && process.env.NODE_ENV === 'development';\n },\n get state() {\n return storeRef.current.state;\n },\n get navigationRef() {\n return storeRef.current.navigationRef;\n },\n get routeNode() {\n return storeRef.current.routeNode;\n },\n getRouteInfo(): UrlObject {\n return storeRef.current.routeInfo || defaultRouteInfo;\n },\n get redirects() {\n return storeRef.current.redirects || [];\n },\n get rootComponent() {\n return storeRef.current.rootComponent;\n },\n get linking() {\n return storeRef.current.linking;\n },\n setFocusedState(state: FocusedRouteState) {\n const routeInfo = getCachedRouteInfo(state);\n storeRef.current.routeInfo = routeInfo;\n },\n onReady() {\n if (!hasAttemptedToHideSplash) {\n hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n splashScreenAnimationFrame = requestAnimationFrame(() => {\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n storeRef.current.navigationRef.addListener('state', (e) => {\n if (!e.data.state) {\n return;\n }\n\n let isStale: boolean | undefined = false;\n let state: ReactNavigationState | undefined = e.data.state;\n\n while (!isStale && state) {\n isStale = state.stale;\n state =\n state.routes?.[\n 'index' in state && typeof state.index === 'number'\n ? state.index\n : state.routes.length - 1\n ]?.state;\n }\n\n storeRef.current.state = e.data.state;\n\n if (!isStale) {\n storeRef.current.routeInfo = getCachedRouteInfo(e.data.state);\n }\n\n for (const callback of routeInfoSubscribers) {\n callback();\n }\n });\n },\n assertIsReady() {\n if (!storeRef.current.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};\n\nexport function useStore(\n context: RequireContext,\n linkingConfigOptions: LinkingConfigOptions,\n serverUrl?: string\n) {\n const navigationRef = useNavigationContainerRef();\n const config = Constants.expoConfig?.extra?.router;\n\n let linking: ExpoLinkingOptions | undefined;\n let rootComponent: ComponentType<any> = Fragment;\n let initialState: ReactNavigationState | undefined;\n\n const routeNode = getRoutes(context, {\n ...config,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n const redirects: StoreRedirects[] = [config?.redirects, config?.rewrites]\n .filter(Boolean)\n .flat()\n .map((route) => {\n return [\n routePatternToRegex(parseRouteSegments(route.source)),\n route,\n shouldLinkExternally(route.destination),\n ];\n });\n\n if (routeNode) {\n // We have routes, so get the linking config and the root component\n linking = getLinkingConfig(routeNode, context, () => store.getRouteInfo(), {\n metaOnly: linkingConfigOptions.metaOnly,\n serverUrl,\n redirects,\n });\n rootComponent = getQualifiedRouteComponent(routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can prefetch the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n let initialPath = extractExpoPathFromURL(linking.prefixes, initialURL);\n\n // It does not matter if the path starts with a `/` or not, but this keeps the behavior consistent\n if (!initialPath.startsWith('/')) initialPath = '/' + initialPath;\n\n initialState = linking.getStateFromPath(initialPath, linking.config);\n const initialRouteInfo = getRouteInfoFromState(initialState);\n routeInfoCache.set(initialState as any, initialRouteInfo);\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n rootComponent = Fragment;\n }\n\n storeRef.current = {\n navigationRef,\n routeNode,\n config,\n rootComponent,\n linking,\n redirects,\n state: initialState,\n };\n\n if (initialState) {\n storeRef.current.routeInfo = getCachedRouteInfo(initialState);\n }\n\n useEffect(() => {\n return () => {\n // listener();\n\n if (splashScreenAnimationFrame) {\n cancelAnimationFrame(splashScreenAnimationFrame);\n splashScreenAnimationFrame = undefined;\n }\n };\n });\n\n return store;\n}\n\nconst routeInfoSubscribers = new Set<() => void>();\nconst routeInfoSubscribe = (callback: () => void) => {\n routeInfoSubscribers.add(callback);\n return () => {\n routeInfoSubscribers.delete(callback);\n };\n};\n\nexport function useRouteInfo() {\n return useSyncExternalStore(routeInfoSubscribe, store.getRouteInfo, store.getRouteInfo);\n}\n\nfunction getCachedRouteInfo(state: ReactNavigationState) {\n let routeInfo = routeInfoCache.get(state);\n\n if (!routeInfo) {\n routeInfo = getRouteInfoFromState(state);\n\n const previousRouteInfo = storeRef.current.routeInfo;\n if (previousRouteInfo) {\n const areEqual =\n routeInfo.segments.length === previousRouteInfo.segments.length &&\n routeInfo.segments.every(\n (segment, index) => previousRouteInfo.segments[index] === segment\n ) &&\n routeInfo.pathnameWithParams === previousRouteInfo.pathnameWithParams;\n\n if (areEqual) {\n // If they are equal, keep the previous route info for object reference equality\n routeInfo = previousRouteInfo;\n }\n }\n\n routeInfoCache.set(state, routeInfo);\n }\n\n return routeInfo;\n}\n"]}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
import { NavigationAction } from '@react-navigation/native';
|
|
1
2
|
import { Href } from '../types';
|
|
2
3
|
import { SingularOptions } from '../useScreens';
|
|
4
|
+
export declare const routingQueue: {
|
|
5
|
+
queue: NavigationAction[];
|
|
6
|
+
subscribers: Set<() => void>;
|
|
7
|
+
subscribe(callback: () => void): () => void;
|
|
8
|
+
snapshot(): Readonly<{
|
|
9
|
+
type: string;
|
|
10
|
+
payload?: object;
|
|
11
|
+
source?: string;
|
|
12
|
+
target?: string;
|
|
13
|
+
}>[];
|
|
14
|
+
add(action: NavigationAction): void;
|
|
15
|
+
run(): void;
|
|
16
|
+
};
|
|
3
17
|
export type NavigationOptions = Omit<LinkToOptions, 'event'>;
|
|
4
18
|
export declare function navigate(url: Href, options?: NavigationOptions): void;
|
|
5
19
|
export declare function reload(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsC,MAAM,0BAA0B,CAAC;AAiBhG,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAWhD,eAAO,MAAM,YAAY;WACV,gBAAgB,EAAE;2BACJ,IAAI;wBACX,MAAM,IAAI;;;;;;;gBASlB,gBAAgB;;CAsB7B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAE7D,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE9D;AAED,wBAAgB,MAAM,SAGrB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE/D;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE1D;AAED,wBAAgB,OAAO,CAAC,KAAK,GAAE,MAAU,QAMxC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAEhE;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE7D;AAED,wBAAgB,UAAU,SAKzB;AAED,wBAAgB,MAAM,SAMrB;AAED,wBAAgB,SAAS,IAAI,OAAO,CAenC;AAED,wBAAgB,UAAU,IAAI,OAAO,CAmBpC;AAED,wBAAgB,SAAS,CACvB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAM,OAO/E;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,eAAe,CAAC;CACvC,CAAC;AAEF,wBAAgB,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,GAAE,aAAkB,QA6DrE"}
|
|
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.routingQueue = void 0;
|
|
36
37
|
exports.navigate = navigate;
|
|
37
38
|
exports.reload = reload;
|
|
38
39
|
exports.prefetch = prefetch;
|
|
@@ -60,6 +61,39 @@ function assertIsReady() {
|
|
|
60
61
|
throw new Error('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.');
|
|
61
62
|
}
|
|
62
63
|
}
|
|
64
|
+
exports.routingQueue = {
|
|
65
|
+
queue: [],
|
|
66
|
+
subscribers: new Set(),
|
|
67
|
+
subscribe(callback) {
|
|
68
|
+
exports.routingQueue.subscribers.add(callback);
|
|
69
|
+
return () => {
|
|
70
|
+
exports.routingQueue.subscribers.delete(callback);
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
snapshot() {
|
|
74
|
+
return exports.routingQueue.queue;
|
|
75
|
+
},
|
|
76
|
+
add(action) {
|
|
77
|
+
// Reset the identity of the queue.
|
|
78
|
+
if (exports.routingQueue.queue.length === 0) {
|
|
79
|
+
exports.routingQueue.queue = [];
|
|
80
|
+
}
|
|
81
|
+
exports.routingQueue.queue.push(action);
|
|
82
|
+
for (const callback of exports.routingQueue.subscribers) {
|
|
83
|
+
callback();
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
run() {
|
|
87
|
+
const queue = exports.routingQueue.queue;
|
|
88
|
+
if (queue.length === 0 || !router_store_1.store.navigationRef) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
exports.routingQueue.queue = [];
|
|
92
|
+
for (const action of queue) {
|
|
93
|
+
router_store_1.store.navigationRef.dispatch(action);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
63
97
|
function navigate(url, options) {
|
|
64
98
|
return linkTo((0, href_1.resolveHref)(url), { ...options, event: 'NAVIGATE' });
|
|
65
99
|
}
|
|
@@ -77,7 +111,7 @@ function dismiss(count = 1) {
|
|
|
77
111
|
if ((0, emitDomEvent_1.emitDomDismiss)(count)) {
|
|
78
112
|
return;
|
|
79
113
|
}
|
|
80
|
-
|
|
114
|
+
exports.routingQueue.add({ type: 'POP', payload: { count } });
|
|
81
115
|
}
|
|
82
116
|
function dismissTo(href, options) {
|
|
83
117
|
return linkTo((0, href_1.resolveHref)(href), { ...options, event: 'POP_TO' });
|
|
@@ -89,14 +123,14 @@ function dismissAll() {
|
|
|
89
123
|
if ((0, emitDomEvent_1.emitDomDismissAll)()) {
|
|
90
124
|
return;
|
|
91
125
|
}
|
|
92
|
-
|
|
126
|
+
exports.routingQueue.add({ type: 'POP_TO_TOP' });
|
|
93
127
|
}
|
|
94
128
|
function goBack() {
|
|
95
129
|
if ((0, emitDomEvent_1.emitDomGoBack)()) {
|
|
96
130
|
return;
|
|
97
131
|
}
|
|
98
132
|
assertIsReady();
|
|
99
|
-
|
|
133
|
+
exports.routingQueue.add({ type: 'GO_BACK' });
|
|
100
134
|
}
|
|
101
135
|
function canGoBack() {
|
|
102
136
|
if (dom_1.IS_DOM) {
|
|
@@ -172,7 +206,7 @@ function linkTo(originalHref, options = {}) {
|
|
|
172
206
|
console.error('Could not generate a valid navigation state for the given path: ' + href);
|
|
173
207
|
return;
|
|
174
208
|
}
|
|
175
|
-
|
|
209
|
+
exports.routingQueue.add(getNavigateAction(state, rootState, options.event, options.withAnchor, options.dangerouslySingular));
|
|
176
210
|
}
|
|
177
211
|
function getNavigateAction(actionState, navigationState, type = 'NAVIGATE', withAnchor, singular) {
|
|
178
212
|
/**
|
|
@@ -200,8 +234,9 @@ function getNavigateAction(actionState, navigationState, type = 'NAVIGATE', with
|
|
|
200
234
|
const didActionAndCurrentStateDiverge = actionStateRoute.name !== stateRoute.name ||
|
|
201
235
|
!childState ||
|
|
202
236
|
!nextNavigationState ||
|
|
203
|
-
|
|
204
|
-
|
|
237
|
+
(dynamicName &&
|
|
238
|
+
// @ts-expect-error: TODO(@kitten): This isn't properly typed, so the index access fails
|
|
239
|
+
actionStateRoute.params?.[dynamicName.name] !== stateRoute.params?.[dynamicName.name]);
|
|
205
240
|
if (didActionAndCurrentStateDiverge) {
|
|
206
241
|
break;
|
|
207
242
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,4BAEC;AAED,wBAGC;AAED,4BAEC;AAED,oBAEC;AAED,0BAMC;AAED,8BAEC;AAED,0BAEC;AAED,gCAKC;AAED,wBAMC;AAED,8BAeC;AAED,gCAmBC;AAED,8BAQC;AAwBD,wBA6DC;AAjND,kCAAkC;AAClC,sDAAwC;AACxC,+CAAwC;AAExC,iDAAuC;AACvC,gEAMuC;AAEvC,8DAAuD;AACvD,uCAA0E;AAC1E,0CAA+C;AAG/C,sCAAoD;AAEpD,SAAS,aAAa;IACpB,IAAI,CAAC,oBAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;IACJ,CAAC;AACH,CAAC;AAID,SAAgB,QAAQ,CAAC,GAAS,EAAE,OAA2B;IAC7D,OAAO,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AACrE,CAAC;AAED,SAAgB,MAAM;IACpB,yCAAyC;IACzC,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;AACzF,CAAC;AAED,SAAgB,QAAQ,CAAC,IAAU,EAAE,OAA2B;IAC9D,OAAO,MAAM,CAAC,IAAA,kBAAW,EAAC,IAAI,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AACrE,CAAC;AAED,SAAgB,IAAI,CAAC,GAAS,EAAE,OAA2B;IACzD,OAAO,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAA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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 { 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 { store } from './router-store';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../domComponents/emitDomEvent';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { applyRedirects } from '../getRoutesRedirects';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady() {\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(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload() {\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(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'PRELOAD' });\n}\n\nexport function push(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(count: number = 1) {\n if (emitDomDismiss(count)) {\n return;\n }\n\n store.navigationRef?.dispatch({ type: 'POP', payload: { count } });\n}\n\nexport function dismissTo(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll() {\n if (emitDomDismissAll()) {\n return;\n }\n store.navigationRef?.dispatch({ type: 'POP_TO_TOP' });\n}\n\nexport function goBack() {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady();\n store.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(): 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 (!store.navigationRef.isReady()) {\n return false;\n }\n return store.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(): 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 = store.state;\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 params: Record<string, undefined | string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady();\n return (store.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(originalHref: Href, options: LinkToOptions = {}) {\n originalHref = typeof originalHref == 'string' ? originalHref : resolveHref(originalHref);\n let href: string | undefined | null = 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();\n const navigationRef = store.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 (!store.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, store.getRouteInfo(), options);\n href = applyRedirects(href, store.redirects);\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 = store.linking.getStateFromPath!(href, store.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 (type === 'REPLACE' && navigationState.type === 'drawer') {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,4BAEC;AAED,wBAGC;AAED,4BAEC;AAED,oBAEC;AAED,0BAMC;AAED,8BAEC;AAED,0BAEC;AAED,gCAKC;AAED,wBAMC;AAED,8BAeC;AAED,gCAmBC;AAED,8BAQC;AAwBD,wBA6DC;AArPD,kCAAkC;AAClC,sDAAwC;AACxC,+CAAwC;AAExC,iDAAuC;AACvC,gEAMuC;AAEvC,8DAAuD;AACvD,uCAA0E;AAC1E,0CAA+C;AAG/C,sCAAoD;AAEpD,SAAS,aAAa;IACpB,IAAI,CAAC,oBAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;IACJ,CAAC;AACH,CAAC;AAEY,QAAA,YAAY,GAAG;IAC1B,KAAK,EAAE,EAAwB;IAC/B,WAAW,EAAE,IAAI,GAAG,EAAc;IAClC,SAAS,CAAC,QAAoB;QAC5B,oBAAY,CAAC,WAAW,CAAC,GAAG,CAAC,QAA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AAM,IAAI,IAAI,KAAK,SAAS,IAAI,eAAe,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACnE,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 { NavigationAction, 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 { store } from './router-store';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../domComponents/emitDomEvent';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { applyRedirects } from '../getRoutesRedirects';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady() {\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 const routingQueue = {\n queue: [] as NavigationAction[],\n subscribers: new Set<() => void>(),\n subscribe(callback: () => void) {\n routingQueue.subscribers.add(callback);\n return () => {\n routingQueue.subscribers.delete(callback);\n };\n },\n snapshot() {\n return routingQueue.queue;\n },\n add(action: NavigationAction) {\n // Reset the identity of the queue.\n if (routingQueue.queue.length === 0) {\n routingQueue.queue = [];\n }\n\n routingQueue.queue.push(action);\n for (const callback of routingQueue.subscribers) {\n callback();\n }\n },\n run() {\n const queue = routingQueue.queue;\n if (queue.length === 0 || !store.navigationRef) {\n return;\n }\n\n routingQueue.queue = [];\n for (const action of queue) {\n store.navigationRef.dispatch(action);\n }\n },\n};\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload() {\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(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'PRELOAD' });\n}\n\nexport function push(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(count: number = 1) {\n if (emitDomDismiss(count)) {\n return;\n }\n\n routingQueue.add({ type: 'POP', payload: { count } });\n}\n\nexport function dismissTo(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll() {\n if (emitDomDismissAll()) {\n return;\n }\n routingQueue.add({ type: 'POP_TO_TOP' });\n}\n\nexport function goBack() {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady();\n routingQueue.add({ type: 'GO_BACK' });\n}\n\nexport function canGoBack(): 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 (!store.navigationRef.isReady()) {\n return false;\n }\n return store.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(): 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 = store.state;\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 params: Record<string, undefined | string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady();\n return (store.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(originalHref: Href, options: LinkToOptions = {}) {\n originalHref = typeof originalHref == 'string' ? originalHref : resolveHref(originalHref);\n let href: string | undefined | null = 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();\n const navigationRef = store.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 (!store.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, store.getRouteInfo(), options);\n href = applyRedirects(href, store.redirects);\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 = store.linking.getStateFromPath!(href, store.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 routingQueue.add(\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 &&\n // @ts-expect-error: TODO(@kitten): This isn't properly typed, so the index access fails\n actionStateRoute.params?.[dynamicName.name] !== stateRoute.params?.[dynamicName.name]);\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 (type === 'REPLACE' && navigationState.type === 'drawer') {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
|
package/build/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","source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;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,OAAO,CAAC;AAEb;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,SAAS,KAAK,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,KAAK,EACpB,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;AAKnC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,OAAO,CAAC;AAEb;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,SAAS,KAAK,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;AAElF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,SAAS,KAAK,EACpB,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;AAiCnC,wBAAgB,eAAe,CAAC,EAAE,MAAc,EAAE;;CAAK,GAAG,eAAe,CAsBxE"}
|
package/build/hooks.js
CHANGED
|
@@ -114,6 +114,11 @@ function useGlobalSearchParams() {
|
|
|
114
114
|
function useLocalSearchParams() {
|
|
115
115
|
const params = react_1.default.use(Route_1.LocalRouteParamsContext) ?? {};
|
|
116
116
|
return Object.fromEntries(Object.entries(params).map(([key, value]) => {
|
|
117
|
+
// React Navigation doesn't remove "undefined" values from the params object, and you cannot remove them via
|
|
118
|
+
// navigation.setParams as it shallow merges. Hence, we hide them here
|
|
119
|
+
if (value === undefined) {
|
|
120
|
+
return [key, undefined];
|
|
121
|
+
}
|
|
117
122
|
if (Array.isArray(value)) {
|
|
118
123
|
return [
|
|
119
124
|
key,
|
package/build/hooks.js.map
CHANGED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,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 { NavigationProp, useNavigation } from '@react-navigation/native';\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { INTERNAL_SLOT_NAME } from './constants';\nimport { store, useRouteInfo } from './global-state/router-store';\nimport { router, Router } from './imperative-api';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\nexport { useRouteInfo };\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 useNavigation<NavigationProp<object, never, string>>()\n .getParent(INTERNAL_SLOT_NAME)!\n .getState();\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 router;\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 useRouteInfo().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 useRouteInfo().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 useRouteInfo().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 useRouteInfo().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.use(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;;;;;;AA4Bb,wDAIC;AAMD,8CAEC;AAMD,8DAEC;AAoBD,8BAEC;AAOD,sDAEC;AA2CD,kCAEC;AAmBD,kCAEC;AA4CD,sDAEC;AAyCD,oDA8BC;AAED,0CAsBC;AA5RD,qDAAyE;AACzE,kDAA0B;AAE1B,mCAAkD;AAClD,2CAAiD;AACjD,8DAAkE;AAIzD,6FAJO,2BAAY,OAIP;AAHrB,qDAAkD;AAKlD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,sBAAsB;IACpC,OAAO,IAAA,sBAAa,GAAyC;SAC1D,SAAS,CAAC,8BAAkB,CAAE;SAC9B,QAAQ,EAAE,CAAC;AAChB,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,uBAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB;IACnC,OAAO,IAAA,2BAAY,GAAE,CAAC,mBAAmB,CAAC;AAC5C,CAAC;AA2CD,SAAgB,WAAW;IACzB,OAAO,IAAA,2BAAY,GAAE,CAAC,QAAQ,CAAC;AACjC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,WAAW;IACzB,OAAO,IAAA,2BAAY,GAAE,CAAC,QAAQ,CAAC;AACjC,CAAC;AA4CD,SAAgB,qBAAqB;IACn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CAAC;YACjC,OAAO,CAAC,IAAI,CACV,iGAAiG,CAClG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,sDAAsD;IACtD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,qBAAqB,EAAE,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 { NavigationProp, useNavigation } from '@react-navigation/native';\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { INTERNAL_SLOT_NAME } from './constants';\nimport { store, useRouteInfo } from './global-state/router-store';\nimport { router, Router } from './imperative-api';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\nexport { useRouteInfo };\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 useNavigation<NavigationProp<object, never, string>>()\n .getParent(INTERNAL_SLOT_NAME)!\n .getState();\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 router;\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 useRouteInfo().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 useRouteInfo().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 useRouteInfo().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 useRouteInfo().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.use(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n // React Navigation doesn't remove \"undefined\" values from the params object, and you cannot remove them via\n // navigation.setParams as it shallow merges. Hence, we hide them here\n if (value === undefined) {\n return [key, undefined];\n }\n\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.d.ts","sourceRoot":"","sources":["../src/imperative-api.
|
|
1
|
+
{"version":3,"file":"imperative-api.d.ts","sourceRoot":"","sources":["../src/imperative-api.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQL,iBAAiB,EAOlB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAExD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB;;OAEG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;OAEG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB;;OAEG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACxD;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5D;;;;;;SAMK;IACL,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC3D;;;;OAIG;IACH,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;OAEG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7D;;;OAGG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB;;;;OAIG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B;;OAEG;IACH,SAAS,EAAE,CAAC,CAAC,SAAS,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC3E;;;OAGG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,MAapB,CAAC;AAEF,wBAAgB,oBAAoB,SAUnC"}
|
package/build/imperative-api.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.router = void 0;
|
|
4
|
+
exports.ImperativeApiEmitter = ImperativeApiEmitter;
|
|
5
|
+
const react_1 = require("react");
|
|
4
6
|
const routing_1 = require("./global-state/routing");
|
|
5
7
|
/**
|
|
6
8
|
* @hidden
|
|
@@ -19,4 +21,11 @@ exports.router = {
|
|
|
19
21
|
prefetch: routing_1.prefetch,
|
|
20
22
|
setParams: routing_1.setParams,
|
|
21
23
|
};
|
|
24
|
+
function ImperativeApiEmitter() {
|
|
25
|
+
const events = (0, react_1.useSyncExternalStore)(routing_1.routingQueue.subscribe, routing_1.routingQueue.snapshot, routing_1.routingQueue.snapshot);
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
27
|
+
routing_1.routingQueue.run();
|
|
28
|
+
}, [events]);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
22
31
|
//# sourceMappingURL=imperative-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imperative-api.js","sourceRoot":"","sources":["../src/imperative-api.
|
|
1
|
+
{"version":3,"file":"imperative-api.js","sourceRoot":"","sources":["../src/imperative-api.tsx"],"names":[],"mappings":";;;AAmHA,oDAUC;AA7HD,iCAAwD;AAExD,oDAegC;AAgFhC;;GAEG;AACU,QAAA,MAAM,GAAW;IAC5B,QAAQ,EAAR,kBAAQ;IACR,IAAI,EAAJ,cAAI;IACJ,OAAO,EAAP,iBAAO;IACP,UAAU,EAAV,oBAAU;IACV,SAAS,EAAT,mBAAS;IACT,UAAU,EAAV,oBAAU;IACV,OAAO,EAAP,iBAAO;IACP,IAAI,EAAE,GAAG,EAAE,CAAC,IAAA,gBAAM,GAAE;IACpB,SAAS,EAAT,mBAAS;IACT,MAAM,EAAN,gBAAM;IACN,QAAQ,EAAR,kBAAQ;IACR,SAAS,EAAE,mBAAgC;CAC5C,CAAC;AAEF,SAAgB,oBAAoB;IAClC,MAAM,MAAM,GAAG,IAAA,4BAAoB,EACjC,sBAAY,CAAC,SAAS,EACtB,sBAAY,CAAC,QAAQ,EACrB,sBAAY,CAAC,QAAQ,CACtB,CAAC;IACF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,sBAAY,CAAC,GAAG,EAAE,CAAC;IACrB,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { useEffect, useSyncExternalStore } from 'react';\n\nimport {\n canDismiss,\n canGoBack,\n dismiss,\n dismissAll,\n dismissTo,\n goBack,\n navigate,\n NavigationOptions,\n prefetch,\n push,\n reload,\n replace,\n routingQueue,\n setParams,\n} 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,\n push,\n dismiss,\n dismissAll,\n dismissTo,\n canDismiss,\n replace,\n back: () => goBack(),\n canGoBack,\n reload,\n prefetch,\n setParams: setParams as Router['setParams'],\n};\n\nexport function ImperativeApiEmitter() {\n const events = useSyncExternalStore(\n routingQueue.subscribe,\n routingQueue.snapshot,\n routingQueue.snapshot\n );\n useEffect(() => {\n routingQueue.run();\n }, [events]);\n return null;\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { BottomTabNavigationEventMap, BottomTabNavigationOptions } from '@react-
|
|
|
2
2
|
import { ParamListBase, TabNavigationState } from '@react-navigation/native';
|
|
3
3
|
import React, { ComponentProps } from 'react';
|
|
4
4
|
import { Href } from '../types';
|
|
5
|
+
import { Protected } from '../views/Protected';
|
|
5
6
|
declare const BottomTabNavigator: React.ComponentType<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
6
7
|
children: React.ReactNode;
|
|
7
8
|
layout?: ((props: {
|
|
@@ -156,10 +157,11 @@ declare const ExpoTabs: React.ForwardRefExoticComponent<Omit<Omit<import("@react
|
|
|
156
157
|
id?: undefined;
|
|
157
158
|
}, "children">> & React.RefAttributes<unknown>> & {
|
|
158
159
|
Screen: (props: import("..").ScreenProps<TabsProps, TabNavigationState<ParamListBase>, BottomTabNavigationEventMap>) => null;
|
|
159
|
-
Protected: typeof
|
|
160
|
+
Protected: typeof Protected;
|
|
160
161
|
};
|
|
161
162
|
declare const Tabs: ((props: ComponentProps<typeof ExpoTabs>) => React.JSX.Element) & {
|
|
162
163
|
Screen: (props: import("..").ScreenProps<TabsProps, TabNavigationState<ParamListBase>, BottomTabNavigationEventMap>) => null;
|
|
164
|
+
Protected: React.FunctionComponent<import("../views/Protected").ProtectedProps>;
|
|
163
165
|
};
|
|
164
166
|
export default Tabs;
|
|
165
167
|
//# sourceMappingURL=TabsClient.d.ts.map
|
|
@@ -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,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAK9C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;
|
|
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,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAK9C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAuC,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC;AAE3D,KAAK,SAAS,GAAG,0BAA0B,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CZ,CAAC;AAEH,QAAA,MAAM,IAAI,WACA,cAAc,CAAC,OAAO,QAAQ,CAAC;;;CAOxC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -10,6 +10,7 @@ const react_native_1 = require("react-native");
|
|
|
10
10
|
const withLayoutContext_1 = require("./withLayoutContext");
|
|
11
11
|
const Link_1 = require("../link/Link");
|
|
12
12
|
const TabRouter_1 = require("./TabRouter");
|
|
13
|
+
const Protected_1 = require("../views/Protected");
|
|
13
14
|
// This is the only way to access the navigator.
|
|
14
15
|
const BottomTabNavigator = (0, bottom_tabs_1.createBottomTabNavigator)().Navigator;
|
|
15
16
|
const ExpoTabs = (0, withLayoutContext_1.withLayoutContext)(BottomTabNavigator, (screens) => {
|
|
@@ -45,6 +46,7 @@ const Tabs = Object.assign((props) => {
|
|
|
45
46
|
return <ExpoTabs {...props} UNSTABLE_router={TabRouter_1.tabRouterOverride}/>;
|
|
46
47
|
}, {
|
|
47
48
|
Screen: ExpoTabs.Screen,
|
|
49
|
+
Protected: Protected_1.Protected,
|
|
48
50
|
});
|
|
49
51
|
exports.default = Tabs;
|
|
50
52
|
//# sourceMappingURL=TabsClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsClient.js","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAEb,+DAIuC;AAEvC,kDAA8C;AAC9C,+CAAmD;AAEnD,2DAAwD;AACxD,uCAAoC;AAEpC,2CAAgD;
|
|
1
|
+
{"version":3,"file":"TabsClient.js","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAEb,+DAIuC;AAEvC,kDAA8C;AAC9C,+CAAmD;AAEnD,2DAAwD;AACxD,uCAAoC;AAEpC,2CAAgD;AAChD,kDAA+C;AAE/C,gDAAgD;AAChD,MAAM,kBAAkB,GAAG,IAAA,sCAAwB,GAAE,CAAC,SAAS,CAAC;AAMhE,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAKhC,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;IAChC,oCAAoC;IACpC,OAAO,OAAO,CAAC,GAA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O,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CACxB,CAAC,KAAsC,EAAE,EAAE;IACzC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,6BAAiB,CAAC,EAAG,CAAC;AACrE,CAAC,EACD;IACE,MAAM,EAAE,QAAQ,CAAC,MAAM;IACvB,SAAS,EAAT,qBAAS;CACV,CACF,CAAC;AAEF,kBAAe,IAAI,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, { ComponentProps } from 'react';\nimport { Pressable, Platform } from 'react-native';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { Link } from '../link/Link';\nimport { Href } from '../types';\nimport { tabRouterOverride } from './TabRouter';\nimport { Protected } from '../views/Protected';\n\n// This is the only way to access the navigator.\nconst BottomTabNavigator = createBottomTabNavigator().Navigator;\n\nexport type BottomTabNavigator = typeof BottomTabNavigator;\n\ntype TabsProps = BottomTabNavigationOptions & { href?: Href | null };\n\nconst ExpoTabs = 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\nconst Tabs = Object.assign(\n (props: ComponentProps<typeof ExpoTabs>) => {\n return <ExpoTabs {...props} UNSTABLE_router={tabRouterOverride} />;\n },\n {\n Screen: ExpoTabs.Screen,\n Protected,\n }\n);\n\nexport default Tabs;\n"]}
|
package/build/matchers.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
interface DynamicNameMatch {
|
|
2
|
+
name: string;
|
|
3
|
+
deep: boolean;
|
|
4
|
+
}
|
|
1
5
|
/** Match `[page]` -> `page` */
|
|
2
|
-
export declare function matchDynamicName(name: string):
|
|
3
|
-
/** Match `[...page]` -> `page` */
|
|
4
|
-
export declare function matchDeepDynamicRouteName(name: string): string | undefined;
|
|
6
|
+
export declare function matchDynamicName(name: string): DynamicNameMatch | undefined;
|
|
5
7
|
/** Test `/` -> `page` */
|
|
6
8
|
export declare function testNotFound(name: string): boolean;
|
|
7
9
|
/** Match `(page)` -> `page` */
|
|
@@ -25,4 +27,5 @@ export declare function stripInvisibleSegmentsFromPath(path: string): string;
|
|
|
25
27
|
* - Routes can still use `+`, but it cannot be in the last segment.
|
|
26
28
|
*/
|
|
27
29
|
export declare function isTypedRoute(name: string): boolean;
|
|
30
|
+
export {};
|
|
28
31
|
//# sourceMappingURL=matchers.d.ts.map
|
package/build/matchers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../src/matchers.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../src/matchers.tsx"],"names":[],"mappings":"AAGA,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAED,+BAA+B;AAC/B,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAS3E;AAED,yBAAyB;AACzB,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,+BAA+B;AAC/B,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED,qCAAqC;AACrC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnE;AAED,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,sBAE/C;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQlD;AAED,+DAA+D;AAC/D,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,0CAA0C;AAC1C,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D;AAGD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU/D;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,WAExC"}
|