expo-router 4.0.0-preview.0 → 4.0.0-preview.2

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.
@@ -35,6 +35,7 @@ export declare class RouterStore {
35
35
  canDismiss: any;
36
36
  setParams: any;
37
37
  navigate: any;
38
+ reload: any;
38
39
  initialize(context: RequireContext, navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>, linkingConfigOptions?: LinkingConfigOptions): void;
39
40
  updateState(state: ResultState, nextState?: any): void;
40
41
  getRouteInfo(state: ResultState): UrlObject;
@@ -1 +1 @@
1
- {"version":3,"file":"router-store.d.ts","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAElC,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EAAiC,aAAa,EAAY,MAAM,OAAO,CAAC;AAgB/E,OAAO,EAAE,SAAS,EAAyB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAoB,MAAM,qBAAqB,CAAC;AAEjG,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,KAAK,WAAW,GAAG,GAAG,CAAC;AAEvB;;;;GAIG;AACH,qBAAa,WAAW;IACtB,SAAS,EAAG,SAAS,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAG,aAAa,CAAC;IAC9B,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,OAAO,CAAC,wBAAwB,CAAkB;IAElD,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,0BAA0B,CAAC,EAAE,MAAM,CAAC;IAEpC,aAAa,EAAG,iCAAiC,CAAC,eAAe,CAAC,a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BAG5C;IACF,gBAAgB,eAAgB,MAAM,IAAI,mBAGxC;IACF,QAAQ,aAEN;IACF,iBAAiB,YAEf;IACF,iBAAiB,kBAEf;IAEF,OAAO;CAKR;AAED,eAAO,MAAM,KAAK,aAAoB,CAAC;AAEvC,wBAAgB,aAAa,gBAE5B;AAYD,wBAAgB,iBAAiB,QAOhC;AAED,wBAAgB,iBAAiB,cAOhC;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,oBAAoB,eAK7F"}
@@ -71,6 +71,7 @@ class RouterStore {
71
71
  canDismiss = routing_1.canDismiss.bind(this);
72
72
  setParams = routing_1.setParams.bind(this);
73
73
  navigate = routing_1.navigate.bind(this);
74
+ reload = routing_1.reload.bind(this);
74
75
  initialize(context, navigationRef, linkingConfigOptions = {}) {
75
76
  // Clean up any previous state
76
77
  this.initialState = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAGkC;AAClC,oEAAuC;AACvC,iEAAmD;AACnD,sEAAoC;AACpC,iCAA+E;AAC/E,+CAAwC;AAExC,uCAWmB;AACnB,+CAAgD;AAChD,0DAAuE;AAEvE,+DAAkF;AAClF,0DAA0D;AAC1D,0DAAiG;AACjG,4CAAyC;AAEzC,8CAA2D;AAI3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAsB;IACrB,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAAe;IAC3B,SAAS,CAAe;IACxB,SAAS,CAAe;IACxB,SAAS,CAAa;IACtB,0BAA0B,CAAU;IAEpC,aAAa,CAAoE;IACjF,yBAAyB,CAAc;IAEvC,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;IAC7C,gBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;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,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AALD,0DAKC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport * as SplashScreen from 'expo-splash-screen';\nimport equal from 'fast-deep-equal';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n canGoBack,\n canDismiss,\n goBack,\n linkTo,\n navigate,\n dismiss,\n dismissAll,\n push,\n replace,\n setParams,\n} from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { getPathDataFromState, getPathFromState } from '../fork/getPathFromState';\n// import { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\n\ntype ResultState = any;\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking?: ExpoLinkingOptions;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState?: ResultState;\n rootState?: ResultState;\n nextState?: ResultState;\n routeInfo?: UrlObject;\n splashScreenAnimationFrame?: number;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n dismiss = dismiss.bind(this);\n replace = replace.bind(this);\n dismissAll = dismissAll.bind(this);\n canDismiss = canDismiss.bind(this);\n setParams = setParams.bind(this);\n navigate = navigate.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n linkingConfigOptions: LinkingConfigOptions = {}\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context, {\n ...Constants.expoConfig?.extra?.router,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n // We always needs routeInfo, even if there are no routes. This can happen if:\n // - there are no routes (we are showing the onboarding screen)\n // - getInitialURL() is async\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n\n if (this.routeNode) {\n // We have routes, so get the linking config and the root component\n this.linking = getLinkingConfig(this, this.routeNode, context, linkingConfigOptions);\n this.rootComponent = getQualifiedRouteComponent(this.routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can preload the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = this.linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n this.rootState = this.linking.getStateFromPath?.(initialURL, this.linking.config);\n this.initialState = this.rootState;\n if (this.rootState) {\n this.routeInfo = this.getRouteInfo(this.rootState);\n }\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n this.rootComponent = Fragment;\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRef = navigationRef;\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n this.splashScreenAnimationFrame = requestAnimationFrame(() => {\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!equal(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: {},\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n shouldEncodeURISegment: false,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n\n cleanup() {\n if (this.splashScreenAnimationFrame) {\n cancelAnimationFrame(this.splashScreenAnimationFrame);\n }\n }\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, options: LinkingConfigOptions) {\n const navigationRef = useNavigationContainerRef();\n useMemo(() => store.initialize(context, navigationRef, options), [context]);\n useExpoRouter();\n return store;\n}\n"]}
1
+ {"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAGkC;AAClC,oEAAuC;AACvC,iEAAmD;AACnD,sEAAoC;AACpC,iCAA+E;AAC/E,+CAAwC;AAExC,uCAYmB;AACnB,+CAAgD;AAChD,0DAAuE;AAEvE,+DAAkF;AAClF,0DAA0D;AAC1D,0DAAiG;AACjG,4CAAyC;AAEzC,8CAA2D;AAI3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;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iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,OAA6B;IAC5F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AALD,0DAKC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport * as SplashScreen from 'expo-splash-screen';\nimport equal from 'fast-deep-equal';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n canGoBack,\n canDismiss,\n goBack,\n linkTo,\n navigate,\n dismiss,\n dismissAll,\n push,\n reload,\n replace,\n setParams,\n} from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { getPathDataFromState, getPathFromState } from '../fork/getPathFromState';\n// import { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\n\ntype ResultState = any;\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking?: ExpoLinkingOptions;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState?: ResultState;\n rootState?: ResultState;\n nextState?: ResultState;\n routeInfo?: UrlObject;\n splashScreenAnimationFrame?: number;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n dismiss = dismiss.bind(this);\n replace = replace.bind(this);\n dismissAll = dismissAll.bind(this);\n canDismiss = canDismiss.bind(this);\n setParams = setParams.bind(this);\n navigate = navigate.bind(this);\n reload = reload.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n linkingConfigOptions: LinkingConfigOptions = {}\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context, {\n ...Constants.expoConfig?.extra?.router,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n // We always needs routeInfo, even if there are no routes. This can happen if:\n // - there are no routes (we are showing the onboarding screen)\n // - getInitialURL() is async\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n\n if (this.routeNode) {\n // We have routes, so get the linking config and the root component\n this.linking = getLinkingConfig(this, this.routeNode, context, linkingConfigOptions);\n this.rootComponent = getQualifiedRouteComponent(this.routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can preload the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = this.linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n this.rootState = this.linking.getStateFromPath?.(initialURL, this.linking.config);\n this.initialState = this.rootState;\n if (this.rootState) {\n this.routeInfo = this.getRouteInfo(this.rootState);\n }\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n this.rootComponent = Fragment;\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRef = navigationRef;\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n this.splashScreenAnimationFrame = requestAnimationFrame(() => {\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!equal(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: {},\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n shouldEncodeURISegment: false,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n\n cleanup() {\n if (this.splashScreenAnimationFrame) {\n cancelAnimationFrame(this.splashScreenAnimationFrame);\n }\n }\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, options: LinkingConfigOptions) {\n const navigationRef = useNavigationContainerRef();\n useMemo(() => store.initialize(context, navigationRef, options), [context]);\n useExpoRouter();\n return store;\n}\n"]}
@@ -2,6 +2,7 @@ import { type RouterStore } from './router-store';
2
2
  import { Href } from '../types';
3
3
  export type NavigationOptions = Omit<LinkToOptions, 'event'>;
4
4
  export declare function navigate(this: RouterStore, url: Href, options?: NavigationOptions): any;
5
+ export declare function reload(this: RouterStore): void;
5
6
  export declare function push(this: RouterStore, url: Href, options?: NavigationOptions): any;
6
7
  export declare function dismiss(this: RouterStore, count?: number): void;
7
8
  export declare function replace(this: RouterStore, url: Href, options?: NavigationOptions): any;
@@ -1 +1 @@
1
- {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAWhC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAE7D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,OAEjF;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,OAE7E;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,MAAM,QAExD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,OAEhF;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,QAE3C;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAGvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUpD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAcrD;AAED,wBAAgB,S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BAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAGvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUpD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAcrD;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,WAAW,EACjB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAM,OAInE;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,MAAM,CACpB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,EAAE,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAE,aAAkB,QAqC/D"}
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.linkTo = exports.setParams = exports.canDismiss = exports.canGoBack = exports.goBack = exports.dismissAll = exports.replace = exports.dismiss = exports.push = exports.navigate = void 0;
26
+ exports.linkTo = exports.setParams = exports.canDismiss = exports.canGoBack = exports.goBack = exports.dismissAll = exports.replace = exports.dismiss = exports.push = exports.reload = exports.navigate = void 0;
27
27
  const native_1 = require("@react-navigation/native");
28
28
  const Linking = __importStar(require("expo-linking"));
29
29
  const non_secure_1 = require("nanoid/non-secure");
@@ -39,6 +39,11 @@ function navigate(url, options) {
39
39
  return this.linkTo((0, href_1.resolveHref)(url), { ...options, event: 'NAVIGATE' });
40
40
  }
41
41
  exports.navigate = navigate;
42
+ function reload() {
43
+ // TODO(EvanBacon): add `reload` support.
44
+ throw new Error('The reload method is not implemented in the client-side router yet.');
45
+ }
46
+ exports.reload = reload;
42
47
  function push(url, options) {
43
48
  return this.linkTo((0, href_1.resolveHref)(url), { ...options, event: 'PUSH' });
44
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA4F;AAC5F,sDAAwC;AACxC,kDAA2C;AAI3C,uCAA0E;AAC1E,0CAA+C;AAE/C,sCAAoD;AAEpD,SAAS,aAAa,CAAC,KAAkB;IACvC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QAClC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;KACH;AACH,CAAC;AAID,SAAgB,QAAQ,CAAoB,GAAS,EAAE,OAA2B;IAChF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AAC1E,CAAC;AAFD,4BAEC;AAED,SAAgB,IAAI,CAAoB,GAAS,EAAE,OAA2B;IAC5E,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AACtE,CAAC;AAFD,oBAEC;AAED,SAAgB,OAAO,CAAoB,KAAc;IACvD,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,qBAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AACxD,CAAC;AAFD,0BAEC;AAED,SAAgB,OAAO,CAAoB,GAAS,EAAE,OAA2B;IAC/E,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AACzE,CAAC;AAF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GAAG;QAC3B,OAAO,EAAE;YACP,wBAAwB;YACxB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;SAC3B;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StackActions, type NavigationState, PartialRoute } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\nimport { nanoid } from 'nanoid/non-secure';\n\nimport { type RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function push(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, string | number | (string | number)[]> = {}\n) {\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n *\n */\n withAnchor?: boolean;\n};\n\nexport function linkTo(\n this: RouterStore,\n href: string,\n { event, relativeToDirectory, withAnchor }: LinkToOptions = {}\n) {\n if (shouldLinkExternally(href)) {\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, relativeToDirectory);\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(getNavigateAction(state, rootState, event, withAnchor));\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n // Expo Router uses only three actions, but these don't directly translate to all navigator actions\n if (type === 'PUSH') {\n // Only stack navigators have a push action, and even then we want to use NAVIGATE (see below)\n type = 'NAVIGATE';\n\n /*\n * The StackAction.PUSH does not work correctly with Expo Router.\n *\n * Expo Router provides a getId() function for every route, altering how React Navigation handles stack routing.\n * Ordinarily, PUSH always adds a new screen to the stack. However, with getId() present, it navigates to the screen with the matching ID instead (by moving the screen to the top of the stack)\n * When you try and push to a screen with the same ID, no navigation will occur\n * Refer to: https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L279-L290\n *\n * Expo Router needs to retain the default behavior of PUSH, consistently adding new screens to the stack, even if their IDs are identical.\n *\n * To resolve this issue, we switch to using a NAVIGATE action with a new key. In the navigate action, screens are matched by either key or getId() function.\n * By generating a unique new key, we ensure that the screen is always pushed onto the stack.\n *\n */\n if (navigationState.type === 'stack') {\n rootPayload.params.__EXPO_ROUTER_key = `${rootPayload.name}-${nanoid()}`; // @see https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L406-L407\n }\n }\n\n if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n }\n\n if (type === 'REPLACE' && (navigationState.type === 'tab' || navigationState.type === 'drawer')) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":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MAAM,EAAE,WAAW,CAAC,MAAM;SAC3B;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StackActions, type NavigationState, PartialRoute } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\nimport { nanoid } from 'nanoid/non-secure';\n\nimport { type RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload(this: RouterStore) {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function push(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, string | number | (string | number)[]> = {}\n) {\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n *\n */\n withAnchor?: boolean;\n};\n\nexport function linkTo(\n this: RouterStore,\n href: string,\n { event, relativeToDirectory, withAnchor }: LinkToOptions = {}\n) {\n if (shouldLinkExternally(href)) {\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, relativeToDirectory);\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(getNavigateAction(state, rootState, event, withAnchor));\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n // Expo Router uses only three actions, but these don't directly translate to all navigator actions\n if (type === 'PUSH') {\n // Only stack navigators have a push action, and even then we want to use NAVIGATE (see below)\n type = 'NAVIGATE';\n\n /*\n * The StackAction.PUSH does not work correctly with Expo Router.\n *\n * Expo Router provides a getId() function for every route, altering how React Navigation handles stack routing.\n * Ordinarily, PUSH always adds a new screen to the stack. However, with getId() present, it navigates to the screen with the matching ID instead (by moving the screen to the top of the stack)\n * When you try and push to a screen with the same ID, no navigation will occur\n * Refer to: https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L279-L290\n *\n * Expo Router needs to retain the default behavior of PUSH, consistently adding new screens to the stack, even if their IDs are identical.\n *\n * To resolve this issue, we switch to using a NAVIGATE action with a new key. In the navigate action, screens are matched by either key or getId() function.\n * By generating a unique new key, we ensure that the screen is always pushed onto the stack.\n *\n */\n if (navigationState.type === 'stack') {\n rootPayload.params.__EXPO_ROUTER_key = `${rootPayload.name}-${nanoid()}`; // @see https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L406-L407\n }\n }\n\n if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n }\n\n if (type === 'REPLACE' && (navigationState.type === 'tab' || navigationState.type === 'drawer')) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n },\n };\n}\n"]}
package/build/hooks.js CHANGED
@@ -36,7 +36,7 @@ function useRouter() {
36
36
  setParams: router_store_1.store.setParams,
37
37
  canGoBack: router_store_1.store.canGoBack,
38
38
  navigate: router_store_1.store.navigate,
39
- // TODO(EvanBacon): add `reload`
39
+ reload: router_store_1.store.reload,
40
40
  }), []);
41
41
  }
42
42
  exports.useRouter = useRouter;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,mCAAkD;AAClD,8DAA0F;AAK1F,SAAgB,sBAAsB;IACpC,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAFD,wDAEC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAFD,oCAEC;AAED,sHAAsH;AACtH,SAAgB,iBAAiB;IAC/B,OAAO,oBAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AACrC,CAAC;AAFD,8CAEC;AAED,uJAAuJ;AACvJ,SAAgB,yBAAyB;IACvC,OAAO,oBAAK,CAAC,aAAa,CAAC;AAC7B,CAAC;AAFD,8DAEC;AAED,SAAgB,SAAS;IACvB,OAAO,eAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,oBAAK,CAAC,IAAI;QAChB,OAAO,EAAE,oBAAK,CAAC,OAAO;QACtB,UAAU,EAAE,oBAAK,CAAC,UAAU;QAC5B,UAAU,EAAE,oBAAK,CAAC,UAAU;QAC5B,IAAI,EAAE,oBAAK,CAAC,MAAM;QAClB,OAAO,EAAE,oBAAK,CAAC,OAAO;QACtB,SAAS,EAAE,oBAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,oBAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,oBAAK,CAAC,QAAQ;QACxB,gCAAgC;KACjC,CAAC,EACF,EAAE,CACH,CAAC;AACJ,CAAC;AAhBD,8BAgBC;AAED;;;GAGG;AACH,SAAgB,qBAAqB;IACnC,OAAO,IAAA,gCAA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sContext } from './Route';\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './imperative-api';\nimport { RouteParams, RouteSegments, Routes, UnknownOutputParams } from './types';\n\ntype SearchParams = Record<string, string | string[]>;\nexport function useRootNavigationState() {\n return useStoreRootState();\n}\n\nexport function useRouteInfo() {\n return useStoreRouteInfo();\n}\n\n/** @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead, which returns a React `ref`. */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/** @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null` if the `<NavigationContainer />` hasn't mounted yet. */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\nexport function useRouter(): Router {\n return React.useMemo(\n () => ({\n push: store.push,\n dismiss: store.dismiss,\n dismissAll: store.dismissAll,\n canDismiss: store.canDismiss,\n back: store.goBack,\n replace: store.replace,\n setParams: store.setParams,\n canGoBack: store.canGoBack,\n navigate: store.navigate,\n // TODO(EvanBacon): add `reload`\n }),\n []\n );\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useStoreRouteInfo().unstable_globalHref;\n}\n\n/**\n * Get a list of selected file segments for the currently selected route. Segments are not normalized, so they will be the same as the file path. For example: `/[id]?id=normal -> [\"[id]\"]`.\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, and strictly typed `useSegments` function:\n *\n * ```md\n * - app\n * - [user]\n * - index.js\n * - followers.js\n * - settings.js\n * ```\n *\n *\n * This can be strictly typed using the following abstract:\n *\n * ```ts\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<\n TSegments extends Routes | RouteSegments<Routes> = Routes,\n>(): TSegments extends string ? RouteSegments<TSegments> : TSegments {\n return useStoreRouteInfo().segments as TSegments extends string\n ? RouteSegments<TSegments>\n : TSegments;\n}\n\n/**\n * Global selected route location without search parameters. For example, `/acme?foo=bar` -> `/acme`. Segments will be normalized: `/[id]?id=normal` -> `/normal`.\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]\"]</b>\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useStoreRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TParams>;\n/**\n * Get the globally selected query parameters, including dynamic path segments. This function will update even when the route is not focused.\n * Useful for analytics or other background operations that don't draw to the screen.\n *\n * When querying search params in a stack, opt-towards using [`useLocalSearchParams`](#uselocalsearchparams) as these will only update when the route is focused.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * > **Note:** See [local versus global search parameters](/router/reference/search-parameters/#local-versus-global-search-parameters) for usage\n * > information.\n *\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 * return <Text>User: {user}</Text>;\n * }\n * ```\n *\n */\nexport function useGlobalSearchParams<\n TRoute extends Routes,\n TParams extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TRoute, TParams>;\nexport function useGlobalSearchParams<\n TParams1 extends SearchParams | Routes = UnknownOutputParams,\n TParams2 extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TParams1, TParams2> {\n return useStoreRouteInfo().params as RouteParams<TParams1, TParams2>;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TParams>;\n/**\n * Returns the URL parameters for the contextually focused route. e.g. `/acme?foo=bar` -> `{ foo: \"bar\" }`.\n * This is useful for stacks where you may push a new screen that changes the query parameters.\n * For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * To observe updates even when the invoking route is not focused, use `useGlobalSearchParams()`.\n *\n * @see [`useGlobalSearchParams`](#useglobalsearchparams)\n */\nexport function useLocalSearchParams<\n TRoute extends Routes,\n TParams extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TRoute, TParams>;\nexport function useLocalSearchParams<\n TParams1 extends SearchParams | Routes = UnknownOutputParams,\n TParams2 extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TParams1, TParams2> {\n const params = React.useContext(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as RouteParams<TParams1, TParams2>;\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,kDAA0B;AAE1B,mCAAkD;AAClD,8DAA0F;AAK1F,SAAgB,sBAAsB;IACpC,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAFD,wDAEC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAFD,oCAEC;AAED,sHAAsH;AACtH,SAAgB,iBAAiB;IAC/B,OAAO,oBAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AACrC,CAAC;AAFD,8CAEC;AAED,uJAAuJ;AACvJ,SAAgB,yBAAyB;IACvC,OAAO,oBAAK,CAAC,aAAa,CAAC;AAC7B,CAAC;AAFD,8DAEC;AAED,SAAgB,SAAS;IACvB,OAAO,eAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,oBAAK,CAAC,IAAI;QAChB,OAAO,EAAE,oBAAK,CAAC,OAAO;QACtB,UAAU,EAAE,oBAAK,CAAC,UAAU;QAC5B,UAAU,EAAE,oBAAK,CAAC,UAAU;QAC5B,IAAI,EAAE,oBAAK,CAAC,MAAM;QAClB,OAAO,EAAE,oBAAK,CAAC,OAAO;QACtB,SAAS,EAAE,oBAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,oBAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,oBAAK,CAAC,QAAQ;QACxB,MAAM,EAAE,oBAAK,CAAC,MAAM;KACrB,CAAC,EACF,EAAE,CACH,CAAC;AACJ,CAAC;AAhBD,8BAgBC;AAED;;;GAGG;AACH,SAAgB,qBAAqB;IACnC,OAAO,IAAA,gCAAiB,GAAE,CAAC,mBAAmB,CAAC;AACjD,CAA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C,MAAM,CAAC,CAAC;IACvC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAI,MAAM,KAAK,SAAS,CAAC,OAAO,EAAE;YAChC,OAAO,CAAC,IAAI,CACV,iGAAiG,CAClG,CAAC;SACH;KACF;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;YACV,IAAI,GAAG,KAAK,QAAQ;gBAAE,OAAO,EAAE,CAAC;YAChC,IAAI,GAAG,KAAK,QAAQ;gBAAE,OAAO,EAAE,CAAC;SACjC;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;AAtBD,0CAsBC;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":["import React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './imperative-api';\nimport { RouteParams, RouteSegments, Routes, UnknownOutputParams } from './types';\n\ntype SearchParams = Record<string, string | string[]>;\nexport function useRootNavigationState() {\n return useStoreRootState();\n}\n\nexport function useRouteInfo() {\n return useStoreRouteInfo();\n}\n\n/** @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead, which returns a React `ref`. */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/** @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null` if the `<NavigationContainer />` hasn't mounted yet. */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\nexport function useRouter(): Router {\n return React.useMemo(\n () => ({\n push: store.push,\n dismiss: store.dismiss,\n dismissAll: store.dismissAll,\n canDismiss: store.canDismiss,\n back: store.goBack,\n replace: store.replace,\n setParams: store.setParams,\n canGoBack: store.canGoBack,\n navigate: store.navigate,\n reload: store.reload,\n }),\n []\n );\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useStoreRouteInfo().unstable_globalHref;\n}\n\n/**\n * Get a list of selected file segments for the currently selected route. Segments are not normalized, so they will be the same as the file path. For example: `/[id]?id=normal -> [\"[id]\"]`.\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, and strictly typed `useSegments` function:\n *\n * ```md\n * - app\n * - [user]\n * - index.js\n * - followers.js\n * - settings.js\n * ```\n *\n *\n * This can be strictly typed using the following abstract:\n *\n * ```ts\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<\n TSegments extends Routes | RouteSegments<Routes> = Routes,\n>(): TSegments extends string ? RouteSegments<TSegments> : TSegments {\n return useStoreRouteInfo().segments as TSegments extends string\n ? RouteSegments<TSegments>\n : TSegments;\n}\n\n/**\n * Global selected route location without search parameters. For example, `/acme?foo=bar` -> `/acme`. Segments will be normalized: `/[id]?id=normal` -> `/normal`.\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]\"]</b>\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useStoreRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TParams>;\n/**\n * Get the globally selected query parameters, including dynamic path segments. This function will update even when the route is not focused.\n * Useful for analytics or other background operations that don't draw to the screen.\n *\n * When querying search params in a stack, opt-towards using [`useLocalSearchParams`](#uselocalsearchparams) as these will only update when the route is focused.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * > **Note:** See [local versus global search parameters](/router/reference/search-parameters/#local-versus-global-search-parameters) for usage\n * > information.\n *\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 * return <Text>User: {user}</Text>;\n * }\n * ```\n *\n */\nexport function useGlobalSearchParams<\n TRoute extends Routes,\n TParams extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TRoute, TParams>;\nexport function useGlobalSearchParams<\n TParams1 extends SearchParams | Routes = UnknownOutputParams,\n TParams2 extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TParams1, TParams2> {\n return useStoreRouteInfo().params as RouteParams<TParams1, TParams2>;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TParams>;\n/**\n * Returns the URL parameters for the contextually focused route. e.g. `/acme?foo=bar` -> `{ foo: \"bar\" }`.\n * This is useful for stacks where you may push a new screen that changes the query parameters.\n * For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * To observe updates even when the invoking route is not focused, use `useGlobalSearchParams()`.\n *\n * @see [`useGlobalSearchParams`](#useglobalsearchparams)\n */\nexport function useLocalSearchParams<\n TRoute extends Routes,\n TParams extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TRoute, TParams>;\nexport function useLocalSearchParams<\n TParams1 extends SearchParams | Routes = UnknownOutputParams,\n TParams2 extends SearchParams = UnknownOutputParams,\n>(): RouteParams<TParams1, TParams2> {\n const params = React.useContext(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as RouteParams<TParams1, TParams2>;\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"]}
@@ -19,6 +19,11 @@ export type Router = {
19
19
  canDismiss: () => boolean;
20
20
  /** Update the current route query params. */
21
21
  setParams: <T extends Routes>(params: Partial<RouteParamInput<T>>) => void;
22
+ /**
23
+ * Reload the currently mounted route in experimental server mode. This can be used to re-fetch data.
24
+ * @hidden
25
+ */
26
+ reload: () => void;
22
27
  };
23
28
  /**
24
29
  * @hidden
@@ -1 +1 @@
1
- {"version":3,"file":"imperative-api.d.ts","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,MAAM,MAAM,GAAG;IACnB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,qEAAqE;IACrE,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,wEAAwE;IACxE,IAAI,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACtF,qCAAqC;IACrC,QAAQ,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC1F,0DAA0D;IAC1D,OAAO,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACzF,0HAA0H;IAC1H,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,wDAAwD;IAC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IAAI,CAAC;IACvB,yFAAyF;IACzF,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,6CAA6C;IAC7C,SAAS,EAAE,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAE3E;;;OAGG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,MAWpB,CAAC"}
@@ -15,5 +15,6 @@ exports.router = {
15
15
  back: () => router_store_1.store.goBack(),
16
16
  canGoBack: () => router_store_1.store.canGoBack(),
17
17
  setParams: (params) => router_store_1.store.setParams(params),
18
+ reload: () => router_store_1.store.reload(),
18
19
  };
19
20
  //# sourceMappingURL=imperative-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"imperative-api.js","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":";;;AAAA,8DAAoD;AAyBpD;;GAEG;AACU,QAAA,MAAM,GAAW;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAC1D,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC;IAClD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IACxC,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;IACxD,IAAI,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,SAAS,EAAE;IAClC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAK,CAAC,SAAS,CAAC,MAAM,CAAC;CAC/C,CAAC","sourcesContent":["import { store } from './global-state/router-store';\nimport { NavigationOptions } from './global-state/routing';\nimport { Href, RouteParamInput, Routes } from './types';\n\nexport type Router = {\n /** Go back in the history. */\n back: () => void;\n /** If there's history that supports invoking the `back` function. */\n canGoBack: () => boolean;\n /** Navigate to the provided href using a push operation if possible. */\n push: <T extends string | object>(href: Href<T>, options?: NavigationOptions) => void;\n /** Navigate to the provided href. */\n navigate: <T extends string | object>(href: Href<T>, options?: NavigationOptions) => void;\n /** Navigate to route without appending to the history. */\n replace: <T extends string | object>(href: Href<T>, options?: NavigationOptions) => void;\n /** Navigate to a screen with a stack lower than the current screen. Using the provided count if possible, otherwise 1. */\n dismiss: (count?: number) => void;\n /** Navigate to first screen within the lowest stack. */\n dismissAll: () => void;\n /** If there's history that supports invoking the `dismiss` and `dismissAll` function. */\n canDismiss: () => boolean;\n /** Update the current route query params. */\n setParams: <T extends Routes>(params: Partial<RouteParamInput<T>>) => void;\n};\n\n/**\n * @hidden\n */\nexport const router: Router = {\n navigate: (href, options) => store.navigate(href, options),\n push: (href, options) => store.push(href, options),\n dismiss: (count) => store.dismiss(count),\n dismissAll: () => store.dismissAll(),\n canDismiss: () => store.canDismiss(),\n replace: (href, options) => store.replace(href, options),\n back: () => store.goBack(),\n canGoBack: () => store.canGoBack(),\n setParams: (params) => store.setParams(params),\n};\n"]}
1
+ {"version":3,"file":"imperative-api.js","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":";;;AAAA,8DAAoD;AA+BpD;;GAEG;AACU,QAAA,MAAM,GAAW;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAC1D,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC;IAClD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IACxC,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;IACxD,IAAI,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,SAAS,EAAE;IAClC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAK,CAAC,SAAS,CAAC,MAAM,CAAC;IAC9C,MAAM,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,MAAM,EAAE;CAC7B,CAAC","sourcesContent":["import { store } from './global-state/router-store';\nimport { NavigationOptions } from './global-state/routing';\nimport { Href, RouteParamInput, Routes } from './types';\n\nexport type Router = {\n /** Go back in the history. */\n back: () => void;\n /** If there's history that supports invoking the `back` function. */\n canGoBack: () => boolean;\n /** Navigate to the provided href using a push operation if possible. */\n push: <T extends string | object>(href: Href<T>, options?: NavigationOptions) => void;\n /** Navigate to the provided href. */\n navigate: <T extends string | object>(href: Href<T>, options?: NavigationOptions) => void;\n /** Navigate to route without appending to the history. */\n replace: <T extends string | object>(href: Href<T>, options?: NavigationOptions) => void;\n /** Navigate to a screen with a stack lower than the current screen. Using the provided count if possible, otherwise 1. */\n dismiss: (count?: number) => void;\n /** Navigate to first screen within the lowest stack. */\n dismissAll: () => void;\n /** If there's history that supports invoking the `dismiss` and `dismissAll` function. */\n canDismiss: () => boolean;\n /** Update the current route query params. */\n setParams: <T extends Routes>(params: Partial<RouteParamInput<T>>) => void;\n\n /**\n * Reload the currently mounted route in experimental server mode. This can be used to re-fetch data.\n * @hidden\n */\n reload: () => void;\n};\n\n/**\n * @hidden\n */\nexport const router: Router = {\n navigate: (href, options) => store.navigate(href, options),\n push: (href, options) => store.push(href, options),\n dismiss: (count) => store.dismiss(count),\n dismissAll: () => store.dismissAll(),\n canDismiss: () => store.canDismiss(),\n replace: (href, options) => store.replace(href, options),\n back: () => store.goBack(),\n canGoBack: () => store.canGoBack(),\n setParams: (params) => store.setParams(params),\n reload: () => store.reload(),\n};\n"]}
@@ -13,7 +13,6 @@ import type { Router as ClassicExpoRouterType } from '../../imperative-api';
13
13
  import type { LinkProps as ClassicLinkProps, LinkComponent } from '../../link/Link.js';
14
14
  import type { Href } from '../../types.js';
15
15
  export declare function useRouter_UNSTABLE(): ClassicExpoRouterType & RouteProps & {
16
- reload: () => void;
17
16
  forward: () => void;
18
17
  prefetch: <T extends string | object>(href: Href<T>) => void;
19
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/rsc/router/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH,OAAO,KAAK,EAGV,SAAS,EAET,oBAAoB,EAGrB,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,IAAI,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGvF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AA+O3C,wBAAgB,kBAAkB,IAAI,qBAAqB,GACzD,UAAU,GAAG;IACX,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,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E,SAAS,IAAI,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGvF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AA+O3C,wBAAgB,kBAAkB,IAAI,qBAAqB,GACzD,UAAU,GAAG;IACX,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAC9D,CAyFF;AAoDD,KAAK,UAAU,GAAG,CAAC,SAAS;IAC1B,MAAM;IACN,SAAS;QACP,OAAO;QACP,MAAM,EAAE;KACT;CACF,CAAC,EAAE,CAAC;AAGL,KAAK,UAAU,GAAG;IAChB,UAAU,CAAC,EAAE,UAAU;IACvB,iBAAiB,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D,CAAC;AAIF,wBAAgB,MAAM,CAAC,EAAE,UAAgC,EAAE;;CAAA;;;;;;;;;;;;;;;;;;gBAU1D;AAKD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE;;GAgB3F;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG;IACvE,IAAI,EAAE,MAAM,CAAC;CAMd,GAAG,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC,CAAC;AAE1D,eAAO,MAAM,IAAI,eAAyD,CAAC"}
@@ -180,7 +180,7 @@ const InnerRouter = ({ routerData }) => {
180
180
  }
181
181
  else {
182
182
  // TODO: Native
183
- console.log('window.scrollTo is not available');
183
+ // console.log('window.scrollTo is not available');
184
184
  }
185
185
  });
186
186
  const children = componentIds.reduceRight((acc, id) => (0, react_1.createElement)(RouterSlot, { route, routerData, cachedRef, id, fallback: acc }, acc), null);
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/rsc/router/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,CAAC;;;;AAEb,qDAAyD;AACzD,iCAae;AAUf,+CAAoC;AAEpC,2CAA8E;AAE9E,uCAAgE;AAIhE,0CAA8C;AAC9C,0DAA4E;AAG5E,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC1C,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE;QACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;SAC7C;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAc,EAAE;IAC1C,IAAK,UAAkB,CAAC,mBAAmB,EAAE;QAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;KAC9C;IACD,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;IAC7C,IAAI,YAAY,CAAC,GAAG,CAAC,0BAAc,CAAC,EAAE;QACpC,OAAO,CAAC,IAAI,CAAC,qBAAqB,0BAAc,eAAe,CAAC,CAAC;KAClE;IACD,OAAO;QACL,IAAI,EAAE,kBAAkB,CAAC,QAAQ,CAAC;QAClC,KAAK,EAAE,YAAY,CAAC,QAAQ,EAAE;QAC9B,IAAI;KACL,CAAC;AACJ,CAAC,CAAC;AACF,MAAM,OAAO,GAAG,GAAG,EAAE,CAC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IACxD,IAAI;IACJ,gDAAgD;IAChD,2DAA2D;IAC3D,IAAI;IACJ,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n * Copyright © 2024 2023 Daishi Kato\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * https://github.com/dai-shi/waku/blob/3d1cc7d714b67b142c847e879c30f0724fc457a7/packages/waku/src/router/client.ts#L1\n */\n\n'use client';\n\nimport { Slot as ReactSlot } from '@radix-ui/react-slot';\nimport {\n startTransition,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useTransition,\n createElement,\n createContext,\n useState,\n Fragment,\n forwardRef,\n useMemo,\n} from 'react';\nimport type {\n ComponentProps,\n FunctionComponent,\n ReactNode,\n MutableRefObject,\n AnchorHTMLAttributes,\n MouseEvent,\n ForwardedRef,\n} from 'react';\nimport { Text } from 'react-native';\n\nimport { PARAM_KEY_SKIP, getComponentIds, getInputString } from './common.js';\nimport type { RouteProps } from './common.js';\nimport { prefetchRSC, Root, Slot, useRefetch } from './host.js';\nimport type { NavigationOptions } from '../../global-state/routing.js';\nimport type { Router as ClassicExpoRouterType } from '../../imperative-api';\nimport type { LinkProps as ClassicLinkProps, LinkComponent } from '../../link/Link.js';\nimport { resolveHref } from '../../link/href';\nimport { useInteropClassName, useHrefAttrs } from '../../link/useLinkHooks';\nimport type { Href } from '../../types.js';\n\nconst normalizeRoutePath = (path: string) => {\n for (const suffix of ['/', '/index.html']) {\n if (path.endsWith(suffix)) {\n return path.slice(0, -suffix.length) || '/';\n }\n }\n return path;\n};\n\nconst parseRoute = (url: URL): RouteProps => {\n if ((globalThis as any).__EXPO_ROUTER_404__) {\n return { path: '/404', query: '', hash: '' };\n }\n const { pathname, searchParams, hash } = url;\n if (searchParams.has(PARAM_KEY_SKIP)) {\n console.warn(`The search param \"${PARAM_KEY_SKIP}\" is reserved`);\n }\n return {\n path: normalizeRoutePath(pathname),\n query: searchParams.toString(),\n hash,\n };\n};\nconst getHref = () =>\n process.env.EXPO_OS === 'web'\n ? window.location.href\n : // TODO: This is hardcoded on native to simplify the initial PR.\n 'http://localhost:8081/';\n\ntype ChangeRoute = (\n route: RouteProps,\n options?: {\n checkCache?: boolean;\n skipRefetch?: boolean;\n }\n) => void;\n\ntype PrefetchRoute = (route: RouteProps) => void;\n\nconst equalRouteProps = (a: RouteProps, b: RouteProps) => {\n if (a.path !== b.path) {\n return false;\n }\n if (a.query !== b.query) {\n return false;\n }\n return true;\n};\n\nconst RouterContext = createContext<{\n route: RouteProps;\n changeRoute: ChangeRoute;\n prefetchRoute: PrefetchRoute;\n} | null>(null);\n\nconst InnerRouter = ({ routerData }: { routerData: RouterData }) => {\n const refetch = useRefetch();\n\n const initialRouteRef = useRef<RouteProps>();\n if (!initialRouteRef.current) {\n initialRouteRef.current = parseRoute(new URL(getHref()));\n }\n const [route, setRoute] = useState(() => ({\n // This is the first initialization of the route, and it has\n // to ignore the hash, because on server side there is none.\n // Otherwise there will be a hydration error.\n // The client side route, including the hash, will be updated in the effect below.\n ...initialRouteRef.current!,\n hash: '',\n }));\n\n // Update the route post-load to include the current hash.\n useEffect(() => {\n const initialRoute = initialRouteRef.current!;\n setRoute((prev) => {\n if (\n prev.path === initialRoute.path &&\n prev.query === initialRoute.query &&\n prev.hash === initialRoute.hash\n ) {\n return prev;\n }\n return initialRoute;\n });\n }, []);\n\n const componentIds = getComponentIds(route.path);\n\n // const refetchRoute = () => {\n // const loc = parseRoute(new URL(getHref()));\n // const input = getInputString(loc.path);\n // refetch(input, loc.query);\n // refetch(input, JSON.stringify({ query: route.query }));\n // };\n // globalThis.__EXPO_REFETCH_ROUTE_NO_CACHE__ = refetchRoute;\n\n const [cached, setCached] = useState<Record<string, RouteProps>>(() => {\n return Object.fromEntries(componentIds.map((id) => [id, route]));\n });\n const cachedRef = useRef(cached);\n useEffect(() => {\n cachedRef.current = cached;\n }, [cached]);\n\n const changeRoute: ChangeRoute = useCallback(\n (route, options) => {\n const { checkCache, skipRefetch } = options || {};\n startTransition(() => {\n setRoute(route);\n });\n const componentIds = getComponentIds(route.path);\n if (\n checkCache &&\n componentIds.every((id) => {\n const cachedLoc = cachedRef.current[id];\n return cachedLoc && equalRouteProps(cachedLoc, route);\n })\n ) {\n return; // everything is cached\n }\n const shouldSkip = routerData[0];\n const skip = getSkipList(shouldSkip, componentIds, route, cachedRef.current);\n if (componentIds.every((id) => skip.includes(id))) {\n return; // everything is skipped\n }\n const input = getInputString(route.path);\n if (!skipRefetch) {\n refetch(input, JSON.stringify({ query: route.query, skip }));\n }\n startTransition(() => {\n setCached((prev) => ({\n ...prev,\n ...Object.fromEntries(\n componentIds.flatMap((id) => (skip.includes(id) ? [] : [[id, route]]))\n ),\n }));\n });\n },\n [refetch, routerData]\n );\n\n const prefetchRoute: PrefetchRoute = useCallback(\n (route) => {\n const componentIds = getComponentIds(route.path);\n const shouldSkip = routerData[0];\n const skip = getSkipList(shouldSkip, componentIds, route, cachedRef.current);\n if (componentIds.every((id) => skip.includes(id))) {\n return; // everything is cached\n }\n const input = getInputString(route.path);\n prefetchRSC(input, JSON.stringify({ query: route.query, skip }));\n (globalThis as any).__EXPO_ROUTER_PREFETCH__?.(route.path);\n },\n [routerData]\n );\n\n useEffect(() => {\n const callback = () => {\n const route = parseRoute(new URL(getHref()));\n changeRoute(route, { checkCache: true });\n };\n if (window.addEventListener) {\n window.addEventListener('popstate', callback);\n return () => {\n window.removeEventListener('popstate', callback);\n };\n }\n return () => {};\n }, [changeRoute]);\n\n useEffect(() => {\n const callback = (pathname: string, searchParamsString: string) => {\n const url = new URL(getHref());\n url.pathname = pathname;\n url.search = searchParamsString;\n url.hash = '';\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(parseRoute(url), { skipRefetch: true });\n };\n // eslint-disable-next-line no-multi-assign\n const listeners = (routerData[1] ||= new Set());\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n }, [changeRoute, routerData]);\n\n useEffect(() => {\n const { hash } = window.location;\n const { state } = getHistory();\n const element = hash && document.getElementById(hash.slice(1));\n if (window.scrollTo) {\n window.scrollTo({\n left: 0,\n top: element ? element.getBoundingClientRect().top + window.scrollY : 0,\n behavior: state?.expo_new_path ? 'instant' : 'auto',\n });\n } else {\n // TODO: Native\n console.log('window.scrollTo is not available');\n }\n });\n\n const children = componentIds.reduceRight(\n (acc: ReactNode, id) =>\n createElement(RouterSlot, { route, routerData, cachedRef, id, fallback: acc }, acc),\n null\n );\n\n return createElement(\n RouterContext.Provider,\n { value: { route, changeRoute, prefetchRoute } },\n children\n );\n};\n\nfunction getHistory() {\n if (process.env.EXPO_OS === 'web') {\n return window.history;\n }\n // Native shim\n return {\n pushState: () => {},\n replaceState: () => {},\n back: () => {},\n forward: () => {},\n state: {},\n };\n}\n\nexport function useRouter_UNSTABLE(): ClassicExpoRouterType &\n RouteProps & {\n reload: () => void;\n forward: () => void;\n prefetch: <T extends string | object>(href: Href<T>) => void;\n } {\n const router = useContext(RouterContext);\n if (!router) {\n throw new Error('Missing Router');\n }\n const { route, changeRoute, prefetchRoute } = router;\n const push: ClassicExpoRouterType['push'] = useCallback(\n <T extends string | object>(href: Href<T>, options?: NavigationOptions) => {\n if (options) {\n // TODO(Bacon): Implement options\n console.warn(\n 'options prop of router.push() is not supported in React Server Components yet'\n );\n }\n\n const url = new URL(resolveHref(href), getHref());\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(parseRoute(url));\n },\n [changeRoute]\n );\n const replace: ClassicExpoRouterType['replace'] = useCallback(\n <T extends string | object>(href: Href<T>, options?: NavigationOptions) => {\n if (options) {\n // TODO(Bacon): Implement options\n console.warn(\n 'options prop of router.replace() is not supported in React Server Components yet'\n );\n }\n\n const url = new URL(resolveHref(href), getHref());\n getHistory().replaceState(getHistory().state, '', url);\n changeRoute(parseRoute(url));\n },\n [changeRoute]\n );\n const reload = useCallback(() => {\n const url = new URL(getHref());\n changeRoute(parseRoute(url));\n }, [changeRoute]);\n const back = useCallback(() => {\n // FIXME is this correct?\n getHistory().back();\n }, []);\n const forward = useCallback(() => {\n // FIXME is this correct?\n getHistory().forward();\n }, []);\n const prefetch = useCallback(\n <T extends string | object>(href: Href<T>) => {\n const url = new URL(resolveHref(href), getHref());\n prefetchRoute(parseRoute(url));\n },\n [prefetchRoute]\n );\n return {\n ...route,\n canDismiss() {\n throw new Error('router.canDismiss() is not supported in React Server Components yet');\n },\n canGoBack() {\n throw new Error('router.canGoBack() is not supported in React Server Components yet');\n },\n dismiss() {\n throw new Error('router.dismiss() is not supported in React Server Components yet');\n },\n dismissAll() {\n throw new Error('router.dismissAll() is not supported in React Server Components yet');\n },\n setParams() {\n throw new Error('router.setParams() is not supported in React Server Components yet');\n },\n\n // TODO: The behavior here is not the same as before.\n navigate: push,\n push,\n replace,\n reload,\n back,\n forward,\n prefetch,\n };\n}\n\nconst RouterSlot = ({\n route,\n routerData,\n cachedRef,\n id,\n fallback,\n children,\n}: {\n route: RouteProps;\n routerData: RouterData;\n cachedRef: MutableRefObject<Record<string, RouteProps>>;\n id: string;\n fallback?: ReactNode;\n children?: ReactNode;\n}) => {\n // const unstable_shouldRenderPrev = (_err: unknown) => {\n // const shouldSkip = routerData[0];\n // const skip = getSkipList(shouldSkip, [id], route, cachedRef.current);\n // return skip.length > 0;\n // };\n return createElement(Slot, { id, fallback }, children);\n};\n\nconst getSkipList = (\n shouldSkip: ShouldSkip | undefined,\n componentIds: readonly string[],\n route: RouteProps,\n cached: Record<string, RouteProps>\n): string[] => {\n const shouldSkipObj = Object.fromEntries(shouldSkip || []);\n return componentIds.filter((id) => {\n const prevProps = cached[id];\n if (!prevProps) {\n return false;\n }\n const shouldCheck = shouldSkipObj[id];\n if (!shouldCheck) {\n return false;\n }\n if (shouldCheck[0] && route.path !== prevProps.path) {\n return false;\n }\n if (shouldCheck[0] && route.query !== prevProps.query) {\n return false;\n }\n return true;\n });\n};\n\n// TODO revisit shouldSkip API\ntype ShouldSkip = (readonly [\n string,\n readonly [\n boolean, // if we compare path\n string[], // searchParams keys to compare\n ],\n])[];\n\n// Note: The router data must be a stable mutable object (array).\ntype RouterData = [\n shouldSkip?: ShouldSkip,\n locationListeners?: Set<(path: string, query: string) => void>,\n];\n\nconst DEFAULT_ROUTER_DATA: RouterData = [];\n\nexport function Router({ routerData = DEFAULT_ROUTER_DATA }) {\n const route = parseRoute(new URL(getHref()));\n const initialInput = getInputString(route.path);\n const initialParams = JSON.stringify({ query: route.query });\n const unstable_onFetchData = () => {};\n return createElement(\n Root as FunctionComponent<Omit<ComponentProps<typeof Root>, 'children'>>,\n { initialInput, initialParams, unstable_onFetchData },\n createElement(InnerRouter, { routerData })\n );\n}\n\nconst notAvailableInServer = (name: string) => () => {\n throw new Error(`${name} is not in the server`);\n};\n/**\n * ServerRouter for SSR\n * This is not a public API.\n */\nexport function ServerRouter({ children, route }: { children: ReactNode; route: RouteProps }) {\n return createElement(\n Fragment,\n null,\n createElement(\n RouterContext.Provider,\n {\n value: {\n route,\n changeRoute: notAvailableInServer('changeRoute'),\n prefetchRoute: notAvailableInServer('prefetchRoute'),\n },\n },\n children\n )\n );\n}\n\nexport type LinkProps<T extends string | object> = ClassicLinkProps<T> & {\n href: string;\n // pending?: ReactNode;\n // notPending?: ReactNode;\n\n // unstable_prefetchOnEnter?: boolean;\n // unstable_prefetchOnView?: boolean;\n} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>;\n\nexport const Link = forwardRef(ExpoRouterLink) as unknown as LinkComponent;\n\nLink.resolveHref = resolveHref;\n\nfunction ExpoRouterLink(\n {\n href,\n replace,\n push,\n // TODO: This does not prevent default on the anchor tag.\n relativeToDirectory,\n asChild,\n rel,\n target,\n download,\n // pending,\n // notPending,\n // unstable_prefetchOnEnter,\n // unstable_prefetchOnView,\n children,\n ...props\n }: LinkProps<any>,\n ref: ForwardedRef<Text>\n) {\n // Mutate the style prop to add the className on web.\n const style = useInteropClassName(props);\n\n // If not passing asChild, we need to forward the props to the anchor tag using React Native Web's `hrefAttrs`.\n const hrefAttrs = useHrefAttrs({ asChild, rel, target, download });\n\n const resolvedHref = useMemo(() => {\n if (href == null) {\n throw new Error('Link: href is required');\n }\n return resolveHref(href);\n }, [href]);\n\n const router = useContext(RouterContext);\n const changeRoute = router\n ? router.changeRoute\n : () => {\n throw new Error('Missing Router');\n };\n const prefetchRoute = router\n ? router.prefetchRoute\n : () => {\n throw new Error('Missing Router');\n };\n // TODO: Implement support for pending states in the future.\n const [, startTransition] = useTransition();\n // const elementRef = useRef<HTMLAnchorElement>();\n\n // useEffect(() => {\n // if (unstable_prefetchOnView && process.env.EXPO_OS === 'web' && ref.current) {\n // const observer = new IntersectionObserver(\n // (entries) => {\n // entries.forEach((entry) => {\n // if (entry.isIntersecting) {\n // const url = new URL(resolvedHref, getHref());\n // if (router && url.href !== getHref()) {\n // const route = parseRoute(url);\n // router.prefetchRoute(route);\n // }\n // }\n // });\n // },\n // { threshold: 0.1 }\n // );\n\n // observer.observe(ref.current);\n\n // return () => {\n // observer.disconnect();\n // };\n // }\n // return () => {};\n // }, [unstable_prefetchOnView, router, resolvedHref]);\n\n const onClick = (event: MouseEvent<HTMLAnchorElement>) => {\n event.preventDefault();\n const url = new URL(resolvedHref, getHref());\n // TODO: Use in-memory route for native platforms.\n // if (url.href !== getHref()) {\n const route = parseRoute(url);\n prefetchRoute(route);\n startTransition(() => {\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(route);\n });\n // }\n props.onClick?.(event);\n };\n // const onMouseEnter = unstable_prefetchOnEnter\n // ? (event: MouseEvent<HTMLAnchorElement>) => {\n // const url = new URL(to, getHref());\n // if (url.href !== getHref()) {\n // const route = parseRoute(url);\n // prefetchRoute(route);\n // }\n // props.onMouseEnter?.(event);\n // }\n // : props.onMouseEnter;\n\n const Element = asChild ? ReactSlot : Text;\n\n const ele = createElement(\n // @ts-expect-error\n Element,\n {\n ...hrefAttrs,\n ...props,\n style,\n href: resolvedHref,\n onPress: onClick,\n // onMouseEnter,\n ref,\n },\n children\n );\n // if (isPending && pending !== undefined) {\n // return createElement(Fragment, null, ele, pending);\n // }\n // if (!isPending && notPending !== undefined) {\n // return createElement(Fragment, null, ele, notPending);\n // }\n return ele;\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/rsc/router/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,CAAC;;;;AAEb,qDAAyD;AACzD,iCAae;AAUf,+CAAoC;AAEpC,2CAA8E;AAE9E,uCAAgE;AAIhE,0CAA8C;AAC9C,0DAA4E;AAG5E,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC1C,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE;QACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;SAC7C;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAc,EAAE;IAC1C,IAAK,UAAkB,CAAC,mBAAmB,EAAE;QAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;KAC9C;IACD,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;IAC7C,IAAI,YAAY,CAAC,GAAG,CAAC,0BAAc,CAAC,EAAE;QACpC,OAAO,CAAC,IAAI,CAAC,qBAAqB,0BAAc,eAAe,CAAC,CAAC;KAClE;IACD,OAAO;QACL,IAAI,EAAE,kBAA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;QAClB,OAAO,EAAE,OAAO;QAChB,gBAAgB;QAChB,GAAG;KACJ,EACD,QAAQ,CACT,CAAC;IACF,4CAA4C;IAC5C,wDAAwD;IACxD,IAAI;IACJ,gDAAgD;IAChD,2DAA2D;IAC3D,IAAI;IACJ,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n * Copyright © 2024 2023 Daishi Kato\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * https://github.com/dai-shi/waku/blob/3d1cc7d714b67b142c847e879c30f0724fc457a7/packages/waku/src/router/client.ts#L1\n */\n\n'use client';\n\nimport { Slot as ReactSlot } from '@radix-ui/react-slot';\nimport {\n startTransition,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useTransition,\n createElement,\n createContext,\n useState,\n Fragment,\n forwardRef,\n useMemo,\n} from 'react';\nimport type {\n ComponentProps,\n FunctionComponent,\n ReactNode,\n MutableRefObject,\n AnchorHTMLAttributes,\n MouseEvent,\n ForwardedRef,\n} from 'react';\nimport { Text } from 'react-native';\n\nimport { PARAM_KEY_SKIP, getComponentIds, getInputString } from './common.js';\nimport type { RouteProps } from './common.js';\nimport { prefetchRSC, Root, Slot, useRefetch } from './host.js';\nimport type { NavigationOptions } from '../../global-state/routing.js';\nimport type { Router as ClassicExpoRouterType } from '../../imperative-api';\nimport type { LinkProps as ClassicLinkProps, LinkComponent } from '../../link/Link.js';\nimport { resolveHref } from '../../link/href';\nimport { useInteropClassName, useHrefAttrs } from '../../link/useLinkHooks';\nimport type { Href } from '../../types.js';\n\nconst normalizeRoutePath = (path: string) => {\n for (const suffix of ['/', '/index.html']) {\n if (path.endsWith(suffix)) {\n return path.slice(0, -suffix.length) || '/';\n }\n }\n return path;\n};\n\nconst parseRoute = (url: URL): RouteProps => {\n if ((globalThis as any).__EXPO_ROUTER_404__) {\n return { path: '/404', query: '', hash: '' };\n }\n const { pathname, searchParams, hash } = url;\n if (searchParams.has(PARAM_KEY_SKIP)) {\n console.warn(`The search param \"${PARAM_KEY_SKIP}\" is reserved`);\n }\n return {\n path: normalizeRoutePath(pathname),\n query: searchParams.toString(),\n hash,\n };\n};\nconst getHref = () =>\n process.env.EXPO_OS === 'web'\n ? window.location.href\n : // TODO: This is hardcoded on native to simplify the initial PR.\n 'http://localhost:8081/';\n\ntype ChangeRoute = (\n route: RouteProps,\n options?: {\n checkCache?: boolean;\n skipRefetch?: boolean;\n }\n) => void;\n\ntype PrefetchRoute = (route: RouteProps) => void;\n\nconst equalRouteProps = (a: RouteProps, b: RouteProps) => {\n if (a.path !== b.path) {\n return false;\n }\n if (a.query !== b.query) {\n return false;\n }\n return true;\n};\n\nconst RouterContext = createContext<{\n route: RouteProps;\n changeRoute: ChangeRoute;\n prefetchRoute: PrefetchRoute;\n} | null>(null);\n\nconst InnerRouter = ({ routerData }: { routerData: RouterData }) => {\n const refetch = useRefetch();\n\n const initialRouteRef = useRef<RouteProps>();\n if (!initialRouteRef.current) {\n initialRouteRef.current = parseRoute(new URL(getHref()));\n }\n const [route, setRoute] = useState(() => ({\n // This is the first initialization of the route, and it has\n // to ignore the hash, because on server side there is none.\n // Otherwise there will be a hydration error.\n // The client side route, including the hash, will be updated in the effect below.\n ...initialRouteRef.current!,\n hash: '',\n }));\n\n // Update the route post-load to include the current hash.\n useEffect(() => {\n const initialRoute = initialRouteRef.current!;\n setRoute((prev) => {\n if (\n prev.path === initialRoute.path &&\n prev.query === initialRoute.query &&\n prev.hash === initialRoute.hash\n ) {\n return prev;\n }\n return initialRoute;\n });\n }, []);\n\n const componentIds = getComponentIds(route.path);\n\n // const refetchRoute = () => {\n // const loc = parseRoute(new URL(getHref()));\n // const input = getInputString(loc.path);\n // refetch(input, loc.query);\n // refetch(input, JSON.stringify({ query: route.query }));\n // };\n // globalThis.__EXPO_REFETCH_ROUTE_NO_CACHE__ = refetchRoute;\n\n const [cached, setCached] = useState<Record<string, RouteProps>>(() => {\n return Object.fromEntries(componentIds.map((id) => [id, route]));\n });\n const cachedRef = useRef(cached);\n useEffect(() => {\n cachedRef.current = cached;\n }, [cached]);\n\n const changeRoute: ChangeRoute = useCallback(\n (route, options) => {\n const { checkCache, skipRefetch } = options || {};\n startTransition(() => {\n setRoute(route);\n });\n const componentIds = getComponentIds(route.path);\n if (\n checkCache &&\n componentIds.every((id) => {\n const cachedLoc = cachedRef.current[id];\n return cachedLoc && equalRouteProps(cachedLoc, route);\n })\n ) {\n return; // everything is cached\n }\n const shouldSkip = routerData[0];\n const skip = getSkipList(shouldSkip, componentIds, route, cachedRef.current);\n if (componentIds.every((id) => skip.includes(id))) {\n return; // everything is skipped\n }\n const input = getInputString(route.path);\n if (!skipRefetch) {\n refetch(input, JSON.stringify({ query: route.query, skip }));\n }\n startTransition(() => {\n setCached((prev) => ({\n ...prev,\n ...Object.fromEntries(\n componentIds.flatMap((id) => (skip.includes(id) ? [] : [[id, route]]))\n ),\n }));\n });\n },\n [refetch, routerData]\n );\n\n const prefetchRoute: PrefetchRoute = useCallback(\n (route) => {\n const componentIds = getComponentIds(route.path);\n const shouldSkip = routerData[0];\n const skip = getSkipList(shouldSkip, componentIds, route, cachedRef.current);\n if (componentIds.every((id) => skip.includes(id))) {\n return; // everything is cached\n }\n const input = getInputString(route.path);\n prefetchRSC(input, JSON.stringify({ query: route.query, skip }));\n (globalThis as any).__EXPO_ROUTER_PREFETCH__?.(route.path);\n },\n [routerData]\n );\n\n useEffect(() => {\n const callback = () => {\n const route = parseRoute(new URL(getHref()));\n changeRoute(route, { checkCache: true });\n };\n if (window.addEventListener) {\n window.addEventListener('popstate', callback);\n return () => {\n window.removeEventListener('popstate', callback);\n };\n }\n return () => {};\n }, [changeRoute]);\n\n useEffect(() => {\n const callback = (pathname: string, searchParamsString: string) => {\n const url = new URL(getHref());\n url.pathname = pathname;\n url.search = searchParamsString;\n url.hash = '';\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(parseRoute(url), { skipRefetch: true });\n };\n // eslint-disable-next-line no-multi-assign\n const listeners = (routerData[1] ||= new Set());\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n }, [changeRoute, routerData]);\n\n useEffect(() => {\n const { hash } = window.location;\n const { state } = getHistory();\n const element = hash && document.getElementById(hash.slice(1));\n if (window.scrollTo) {\n window.scrollTo({\n left: 0,\n top: element ? element.getBoundingClientRect().top + window.scrollY : 0,\n behavior: state?.expo_new_path ? 'instant' : 'auto',\n });\n } else {\n // TODO: Native\n // console.log('window.scrollTo is not available');\n }\n });\n\n const children = componentIds.reduceRight(\n (acc: ReactNode, id) =>\n createElement(RouterSlot, { route, routerData, cachedRef, id, fallback: acc }, acc),\n null\n );\n\n return createElement(\n RouterContext.Provider,\n { value: { route, changeRoute, prefetchRoute } },\n children\n );\n};\n\nfunction getHistory() {\n if (process.env.EXPO_OS === 'web') {\n return window.history;\n }\n // Native shim\n return {\n pushState: () => {},\n replaceState: () => {},\n back: () => {},\n forward: () => {},\n state: {},\n };\n}\n\nexport function useRouter_UNSTABLE(): ClassicExpoRouterType &\n RouteProps & {\n forward: () => void;\n prefetch: <T extends string | object>(href: Href<T>) => void;\n } {\n const router = useContext(RouterContext);\n if (!router) {\n throw new Error('Missing Router');\n }\n const { route, changeRoute, prefetchRoute } = router;\n const push: ClassicExpoRouterType['push'] = useCallback(\n <T extends string | object>(href: Href<T>, options?: NavigationOptions) => {\n if (options) {\n // TODO(Bacon): Implement options\n console.warn(\n 'options prop of router.push() is not supported in React Server Components yet'\n );\n }\n\n const url = new URL(resolveHref(href), getHref());\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(parseRoute(url));\n },\n [changeRoute]\n );\n const replace: ClassicExpoRouterType['replace'] = useCallback(\n <T extends string | object>(href: Href<T>, options?: NavigationOptions) => {\n if (options) {\n // TODO(Bacon): Implement options\n console.warn(\n 'options prop of router.replace() is not supported in React Server Components yet'\n );\n }\n\n const url = new URL(resolveHref(href), getHref());\n getHistory().replaceState(getHistory().state, '', url);\n changeRoute(parseRoute(url));\n },\n [changeRoute]\n );\n const reload = useCallback(() => {\n const url = new URL(getHref());\n changeRoute(parseRoute(url));\n }, [changeRoute]);\n const back = useCallback(() => {\n // FIXME is this correct?\n getHistory().back();\n }, []);\n const forward = useCallback(() => {\n // FIXME is this correct?\n getHistory().forward();\n }, []);\n const prefetch = useCallback(\n <T extends string | object>(href: Href<T>) => {\n const url = new URL(resolveHref(href), getHref());\n prefetchRoute(parseRoute(url));\n },\n [prefetchRoute]\n );\n return {\n ...route,\n canDismiss() {\n throw new Error('router.canDismiss() is not supported in React Server Components yet');\n },\n canGoBack() {\n throw new Error('router.canGoBack() is not supported in React Server Components yet');\n },\n dismiss() {\n throw new Error('router.dismiss() is not supported in React Server Components yet');\n },\n dismissAll() {\n throw new Error('router.dismissAll() is not supported in React Server Components yet');\n },\n setParams() {\n throw new Error('router.setParams() is not supported in React Server Components yet');\n },\n\n // TODO: The behavior here is not the same as before.\n navigate: push,\n push,\n replace,\n reload,\n back,\n forward,\n prefetch,\n };\n}\n\nconst RouterSlot = ({\n route,\n routerData,\n cachedRef,\n id,\n fallback,\n children,\n}: {\n route: RouteProps;\n routerData: RouterData;\n cachedRef: MutableRefObject<Record<string, RouteProps>>;\n id: string;\n fallback?: ReactNode;\n children?: ReactNode;\n}) => {\n // const unstable_shouldRenderPrev = (_err: unknown) => {\n // const shouldSkip = routerData[0];\n // const skip = getSkipList(shouldSkip, [id], route, cachedRef.current);\n // return skip.length > 0;\n // };\n return createElement(Slot, { id, fallback }, children);\n};\n\nconst getSkipList = (\n shouldSkip: ShouldSkip | undefined,\n componentIds: readonly string[],\n route: RouteProps,\n cached: Record<string, RouteProps>\n): string[] => {\n const shouldSkipObj = Object.fromEntries(shouldSkip || []);\n return componentIds.filter((id) => {\n const prevProps = cached[id];\n if (!prevProps) {\n return false;\n }\n const shouldCheck = shouldSkipObj[id];\n if (!shouldCheck) {\n return false;\n }\n if (shouldCheck[0] && route.path !== prevProps.path) {\n return false;\n }\n if (shouldCheck[0] && route.query !== prevProps.query) {\n return false;\n }\n return true;\n });\n};\n\n// TODO revisit shouldSkip API\ntype ShouldSkip = (readonly [\n string,\n readonly [\n boolean, // if we compare path\n string[], // searchParams keys to compare\n ],\n])[];\n\n// Note: The router data must be a stable mutable object (array).\ntype RouterData = [\n shouldSkip?: ShouldSkip,\n locationListeners?: Set<(path: string, query: string) => void>,\n];\n\nconst DEFAULT_ROUTER_DATA: RouterData = [];\n\nexport function Router({ routerData = DEFAULT_ROUTER_DATA }) {\n const route = parseRoute(new URL(getHref()));\n const initialInput = getInputString(route.path);\n const initialParams = JSON.stringify({ query: route.query });\n const unstable_onFetchData = () => {};\n return createElement(\n Root as FunctionComponent<Omit<ComponentProps<typeof Root>, 'children'>>,\n { initialInput, initialParams, unstable_onFetchData },\n createElement(InnerRouter, { routerData })\n );\n}\n\nconst notAvailableInServer = (name: string) => () => {\n throw new Error(`${name} is not in the server`);\n};\n/**\n * ServerRouter for SSR\n * This is not a public API.\n */\nexport function ServerRouter({ children, route }: { children: ReactNode; route: RouteProps }) {\n return createElement(\n Fragment,\n null,\n createElement(\n RouterContext.Provider,\n {\n value: {\n route,\n changeRoute: notAvailableInServer('changeRoute'),\n prefetchRoute: notAvailableInServer('prefetchRoute'),\n },\n },\n children\n )\n );\n}\n\nexport type LinkProps<T extends string | object> = ClassicLinkProps<T> & {\n href: string;\n // pending?: ReactNode;\n // notPending?: ReactNode;\n\n // unstable_prefetchOnEnter?: boolean;\n // unstable_prefetchOnView?: boolean;\n} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>;\n\nexport const Link = forwardRef(ExpoRouterLink) as unknown as LinkComponent;\n\nLink.resolveHref = resolveHref;\n\nfunction ExpoRouterLink(\n {\n href,\n replace,\n push,\n // TODO: This does not prevent default on the anchor tag.\n relativeToDirectory,\n asChild,\n rel,\n target,\n download,\n // pending,\n // notPending,\n // unstable_prefetchOnEnter,\n // unstable_prefetchOnView,\n children,\n ...props\n }: LinkProps<any>,\n ref: ForwardedRef<Text>\n) {\n // Mutate the style prop to add the className on web.\n const style = useInteropClassName(props);\n\n // If not passing asChild, we need to forward the props to the anchor tag using React Native Web's `hrefAttrs`.\n const hrefAttrs = useHrefAttrs({ asChild, rel, target, download });\n\n const resolvedHref = useMemo(() => {\n if (href == null) {\n throw new Error('Link: href is required');\n }\n return resolveHref(href);\n }, [href]);\n\n const router = useContext(RouterContext);\n const changeRoute = router\n ? router.changeRoute\n : () => {\n throw new Error('Missing Router');\n };\n const prefetchRoute = router\n ? router.prefetchRoute\n : () => {\n throw new Error('Missing Router');\n };\n // TODO: Implement support for pending states in the future.\n const [, startTransition] = useTransition();\n // const elementRef = useRef<HTMLAnchorElement>();\n\n // useEffect(() => {\n // if (unstable_prefetchOnView && process.env.EXPO_OS === 'web' && ref.current) {\n // const observer = new IntersectionObserver(\n // (entries) => {\n // entries.forEach((entry) => {\n // if (entry.isIntersecting) {\n // const url = new URL(resolvedHref, getHref());\n // if (router && url.href !== getHref()) {\n // const route = parseRoute(url);\n // router.prefetchRoute(route);\n // }\n // }\n // });\n // },\n // { threshold: 0.1 }\n // );\n\n // observer.observe(ref.current);\n\n // return () => {\n // observer.disconnect();\n // };\n // }\n // return () => {};\n // }, [unstable_prefetchOnView, router, resolvedHref]);\n\n const onClick = (event: MouseEvent<HTMLAnchorElement>) => {\n event.preventDefault();\n const url = new URL(resolvedHref, getHref());\n // TODO: Use in-memory route for native platforms.\n // if (url.href !== getHref()) {\n const route = parseRoute(url);\n prefetchRoute(route);\n startTransition(() => {\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(route);\n });\n // }\n props.onClick?.(event);\n };\n // const onMouseEnter = unstable_prefetchOnEnter\n // ? (event: MouseEvent<HTMLAnchorElement>) => {\n // const url = new URL(to, getHref());\n // if (url.href !== getHref()) {\n // const route = parseRoute(url);\n // prefetchRoute(route);\n // }\n // props.onMouseEnter?.(event);\n // }\n // : props.onMouseEnter;\n\n const Element = asChild ? ReactSlot : Text;\n\n const ele = createElement(\n // @ts-expect-error\n Element,\n {\n ...hrefAttrs,\n ...props,\n style,\n href: resolvedHref,\n onPress: onClick,\n // onMouseEnter,\n ref,\n },\n children\n );\n // if (isPending && pending !== undefined) {\n // return createElement(Fragment, null, ele, pending);\n // }\n // if (!isPending && notPending !== undefined) {\n // return createElement(Fragment, null, ele, notPending);\n // }\n return ele;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-router",
3
- "version": "4.0.0-preview.0",
3
+ "version": "4.0.0-preview.2",
4
4
  "description": "Expo Router is a file-based router for React Native and web applications.",
5
5
  "author": "650 Industries, Inc.",
6
6
  "license": "MIT",
@@ -108,11 +108,11 @@
108
108
  "@react-navigation/native": "7.0.0-rc.20",
109
109
  "@react-navigation/native-stack": "7.0.0-rc.28",
110
110
  "client-only": "^0.0.1",
111
- "expo-splash-screen": "0.28.0",
111
+ "expo-splash-screen": "0.28.2",
112
112
  "react-helmet-async": "^1.3.0",
113
113
  "react-native-helmet-async": "2.0.4",
114
114
  "schema-utils": "^4.0.1",
115
115
  "server-only": "^0.0.1"
116
116
  },
117
- "gitHead": "685ebb8a213326cb33c80281ca8756b374ccb63d"
117
+ "gitHead": "5ad642a63afa9190ceb4e57dd52c8bdf71d93dd8"
118
118
  }