expo-router 1.5.3 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/_entry.tsx +1 -1
  2. package/_error.js +6 -0
  3. package/_html-ctx.tsx +1 -1
  4. package/build/ExpoRoot.d.ts.map +1 -1
  5. package/build/LocationProvider.d.ts +6 -12
  6. package/build/LocationProvider.d.ts.map +1 -1
  7. package/build/exports.d.ts +1 -2
  8. package/build/exports.d.ts.map +1 -1
  9. package/build/fork/findFocusedRoute.d.ts +1 -1
  10. package/build/fork/useLinking.native.d.ts +2 -2
  11. package/build/link/stateOperations.d.ts +3 -3
  12. package/build/link/useLinkToPath.d.ts.map +1 -1
  13. package/build/link/useRouter.d.ts.map +1 -1
  14. package/build/navigationStore/index.d.ts +82 -0
  15. package/build/navigationStore/index.d.ts.map +1 -0
  16. package/build/{static/useServerState.d.ts → navigationStore/initialState.d.ts} +9 -8
  17. package/build/navigationStore/initialState.d.ts.map +1 -0
  18. package/build/static/renderStaticContent.d.ts.map +1 -1
  19. package/build/useScreens.d.ts +1 -1
  20. package/build/useScreens.d.ts.map +1 -1
  21. package/build/views/Sitemap.d.ts.map +1 -1
  22. package/index.d.ts +3 -1
  23. package/package.json +3 -2
  24. package/src/ExpoRoot.tsx +27 -26
  25. package/src/LocationProvider.tsx +3 -149
  26. package/src/exports.ts +3 -2
  27. package/src/link/useHref.ts +1 -1
  28. package/src/link/useLinkToPath.ts +13 -15
  29. package/src/link/useLoadedNavigation.ts +6 -6
  30. package/src/link/useRouter.ts +2 -4
  31. package/src/navigationStore/index.ts +215 -0
  32. package/src/navigationStore/initialState.ts +23 -0
  33. package/src/static/renderStaticContent.tsx +5 -7
  34. package/src/useScreens.tsx +1 -6
  35. package/src/views/Sitemap.tsx +17 -6
  36. package/src/views/Unmatched.tsx +1 -1
  37. package/types/global.d.ts +29 -0
  38. package/types/index.d.ts +3 -0
  39. package/types/react-native-web.d.ts +299 -0
  40. package/build/NavigationContainer.d.ts +0 -8
  41. package/build/NavigationContainer.d.ts.map +0 -1
  42. package/build/link/useLinkingContext.d.ts +0 -7
  43. package/build/link/useLinkingContext.d.ts.map +0 -1
  44. package/build/onboard/useTutorial.d.ts +0 -4
  45. package/build/onboard/useTutorial.d.ts.map +0 -1
  46. package/build/static/useServerState.d.ts.map +0 -1
  47. package/build/static/useServerState.native.d.ts +0 -2
  48. package/build/static/useServerState.native.d.ts.map +0 -1
  49. package/build/useInitialRootState.d.ts +0 -42
  50. package/build/useInitialRootState.d.ts.map +0 -1
  51. package/build/useInitialRootState.native.d.ts +0 -3
  52. package/build/useInitialRootState.native.d.ts.map +0 -1
  53. package/build/useInitialRootStateContext.d.ts +0 -13
  54. package/build/useInitialRootStateContext.d.ts.map +0 -1
  55. package/build/useRootNavigation.d.ts +0 -9
  56. package/build/useRootNavigation.d.ts.map +0 -1
  57. package/build/useRootRouteNodeContext.d.ts +0 -11
  58. package/build/useRootRouteNodeContext.d.ts.map +0 -1
  59. package/src/NavigationContainer.tsx +0 -43
  60. package/src/link/useLinkingContext.ts +0 -35
  61. package/src/onboard/useTutorial.tsx +0 -45
  62. package/src/static/useServerState.native.ts +0 -4
  63. package/src/static/useServerState.ts +0 -52
  64. package/src/useInitialRootState.native.tsx +0 -35
  65. package/src/useInitialRootState.tsx +0 -16
  66. package/src/useInitialRootStateContext.tsx +0 -46
  67. package/src/useRootNavigation.ts +0 -42
  68. package/src/useRootRouteNodeContext.tsx +0 -40
  69. package/types/react-native.d.ts +0 -179
  70. /package/{metro-require.d.ts → types/metro-require.d.ts} +0 -0
package/_entry.tsx CHANGED
@@ -1,4 +1,4 @@
1
- /// <reference path="metro-require.d.ts" />
1
+ /// <reference types="./index" />
2
2
 
3
3
  import "@expo/metro-runtime";
4
4
 
package/_error.js ADDED
@@ -0,0 +1,6 @@
1
+ // import "@expo/metro-runtime";
2
+
3
+ import { LogBoxInspectorContainer } from "@expo/metro-runtime/build/error-overlay/ErrorOverlay";
4
+ import { registerRootComponent } from "expo";
5
+
6
+ registerRootComponent(LogBoxInspectorContainer);
package/_html-ctx.tsx CHANGED
@@ -1,4 +1,4 @@
1
- /// <reference path="metro-require.d.ts" />
1
+ /// <reference types="./index" />
2
2
 
3
3
  /** Optionally import `app/+html.js` file. */
4
4
  export const ctx = require.context(
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoRoot.d.ts","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA6BzC,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,eAahE"}
1
+ {"version":3,"file":"ExpoRoot.d.ts","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAwBzC,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,eAahE"}
@@ -1,25 +1,19 @@
1
- import React from "react";
1
+ import { State } from "./fork/getPathFromState";
2
2
  type SearchParams = Record<string, string | string[]>;
3
3
  type UrlObject = {
4
4
  pathname: string;
5
5
  readonly params: SearchParams;
6
6
  segments: string[];
7
7
  };
8
+ export declare function getRouteInfoFromState(getPathFromState: (state: State, asPath: boolean) => {
9
+ path: string;
10
+ params: any;
11
+ }, state: State): UrlObject;
12
+ export declare function compareRouteInfo(a: UrlObject, b: UrlObject): boolean;
8
13
  export declare function compareUrlSearchParams(a: SearchParams, b: SearchParams): boolean;
9
14
  export declare function getNormalizedStatePath({ path: statePath, params, }: {
10
15
  path: string;
11
16
  params: any;
12
17
  }): Omit<UrlObject, "pathname">;
13
- export declare function LocationProvider({ children }: {
14
- children: React.ReactNode;
15
- }): JSX.Element;
16
- /** @returns Currently selected route as a normalized string without search parameters. e.g. `/acme?foo=bar` -> `/acme`. Segments will be normalized: `/[id]?id=normal` -> `/normal` */
17
- export declare function usePathname(): string;
18
- /** @returns Current URL Search Parameters. */
19
- export declare function useSearchParams<TParams extends SearchParams = SearchParams>(): Partial<TParams>;
20
- /** @returns Current URL Search Parameters that only update when the path matches the current route. */
21
- export declare function useLocalSearchParams<TParams extends SearchParams = SearchParams>(): Partial<TParams>;
22
- /** @returns Array of selected segments. */
23
- export declare function useSegments(): string[];
24
18
  export {};
25
19
  //# sourceMappingURL=LocationProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocationProvider.d.ts","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AA0BF,wBAAgB,sBAAsB,CACpC,CAAC,EAAE,YAAY,EACf,CAAC,EAAE,YAAY,GACd,OAAO,CAET;AAwFD,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EAAE,SAAS,EACf,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAgB9B;AAQD,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,eAM3E;AAcD,uLAAuL;AACvL,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,8CAA8C;AAC9C,wBAAgB,eAAe,CAC7B,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAEpB;AAED,uGAAuG;AACvG,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAEpB;AAED,2CAA2C;AAC3C,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAEtC"}
1
+ {"version":3,"file":"LocationProvider.d.ts","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAa,MAAM,yBAAyB,CAAC;AAE3D,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,CAChB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,OAAO,KACZ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,EAClC,KAAK,EAAE,KAAK,GACX,SAAS,CAOX;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,WAO1D;AAED,wBAAgB,sBAAsB,CACpC,CAAC,EAAE,YAAY,EACf,CAAC,EAAE,YAAY,GACd,OAAO,CAET;AAGD,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EAAE,SAAS,EACf,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAgB9B"}
@@ -1,6 +1,6 @@
1
1
  import { Navigator, Slot } from "./views/Navigator";
2
2
  export { useRouter } from "./link/useRouter";
3
- export { usePathname, useLocalSearchParams, useSearchParams, useSegments, } from "./LocationProvider";
3
+ export { usePathname, useLocalSearchParams, useSearchParams, useSegments, useRootNavigation, useRootNavigationState, } from "./navigationStore";
4
4
  export { Link, Redirect } from "./link/Link";
5
5
  export { withLayoutContext } from "./layouts/withLayoutContext";
6
6
  export { Navigator, Slot };
@@ -10,6 +10,5 @@ export { ErrorBoundaryProps } from "./views/Try";
10
10
  export { ErrorBoundary } from "./views/ErrorBoundary";
11
11
  export { SplashScreen } from "./views/Splash";
12
12
  export { useNavigation } from "./useNavigation";
13
- export { useRootNavigation, useRootNavigationState } from "./useRootNavigation";
14
13
  export { useFocusEffect } from "./useFocusEffect";
15
14
  //# sourceMappingURL=exports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAG3B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAG3B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -16,7 +16,7 @@ export declare function findFocusedRoute(state: InitialState): (Omit<import("@re
16
16
  })[];
17
17
  type: string;
18
18
  stale: false;
19
- }>, "routes" | "stale">> & {
19
+ }>, "stale" | "routes">> & {
20
20
  routes: (Omit<import("@react-navigation/routers").Route<string, object | undefined>, "key"> & any)[];
21
21
  }> | undefined;
22
22
  }) | undefined;
@@ -19,7 +19,7 @@ export default function useLinking(ref: React.RefObject<NavigationContainerRef<P
19
19
  })[];
20
20
  type: string;
21
21
  stale: false;
22
- }>, "routes" | "stale">> & Readonly<{
22
+ }>, "stale" | "routes">> & Readonly<{
23
23
  stale?: true | undefined;
24
24
  routes: import("@react-navigation/core").PartialRoute<import("@react-navigation/core").Route<string, object | undefined>>[];
25
25
  }> & {
@@ -39,7 +39,7 @@ export default function useLinking(ref: React.RefObject<NavigationContainerRef<P
39
39
  })[];
40
40
  type: string;
41
41
  stale: false;
42
- }>, "routes" | "stale">> & Readonly<{
42
+ }>, "stale" | "routes">> & Readonly<{
43
43
  stale?: true | undefined;
44
44
  routes: import("@react-navigation/core").PartialRoute<import("@react-navigation/core").Route<string, object | undefined>>[];
45
45
  }> & any) | undefined;
@@ -30,7 +30,7 @@ export declare function findTopRouteForTarget(state: ResultState): Omit<import("
30
30
  })[];
31
31
  type: string;
32
32
  stale: false;
33
- }>, "routes" | "stale">> & {
33
+ }>, "stale" | "routes">> & {
34
34
  routes: (Omit<import("@react-navigation/native").Route<string, object | undefined>, "key"> & any)[];
35
35
  }> | undefined;
36
36
  };
@@ -52,7 +52,7 @@ export declare function getQualifiedStateForTopOfTargetState(rootState: InitialS
52
52
  })[];
53
53
  type: string;
54
54
  stale: false;
55
- }>, "routes" | "stale">> & {
55
+ }>, "stale" | "routes">> & {
56
56
  routes: (Omit<import("@react-navigation/native").Route<string, object | undefined>, "key"> & {
57
57
  state?: Readonly<Partial<Omit<Readonly<{
58
58
  key: string;
@@ -70,7 +70,7 @@ export declare function getQualifiedStateForTopOfTargetState(rootState: InitialS
70
70
  })[];
71
71
  type: string;
72
72
  stale: false;
73
- }>, "routes" | "stale">> & any> | undefined;
73
+ }>, "stale" | "routes">> & any> | undefined;
74
74
  })[];
75
75
  }>;
76
76
  export declare function getEarliestMismatchedRoute<T extends ParamListBase>(rootState: NavigationState<T> | undefined, actionParams: NavigateActionParams): {
@@ -1 +1 @@
1
- {"version":3,"file":"useLinkToPath.d.ts","sourceRoot":"","sources":["../../src/link/useLinkToPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAGnB,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EAKL,cAAc,EACf,MAAM,mBAAmB,CAAC;AAe3B,wBAAgB,aAAa,WAKlB,MAAM,UAAU,MAAM,UAmHhC;AAED,uGAAuG;AACvG,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAC5C,MAAM,IAAI,cAAc,CAqB1B"}
1
+ {"version":3,"file":"useLinkToPath.d.ts","sourceRoot":"","sources":["../../src/link/useLinkToPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAEnB,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EAKL,cAAc,EACf,MAAM,mBAAmB,CAAC;AAe3B,wBAAgB,aAAa,WAIlB,MAAM,UAAU,MAAM,UAmHhC;AAED,uGAAuG;AACvG,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAC5C,MAAM,IAAI,cAAc,CAqB1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRouter.d.ts","sourceRoot":"","sources":["../../src/link/useRouter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAe,MAAM,QAAQ,CAAC;AAM3C,wBAAgB,OAAO,WAGtB;AAED,KAAK,MAAM,GAAG;IACZ,qCAAqC;IACrC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC3B,0DAA0D;IAC1D,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,6CAA6C;IAC7C,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,wBAAgB,SAAS,IAAI,MAAM,CA+BlC"}
1
+ {"version":3,"file":"useRouter.d.ts","sourceRoot":"","sources":["../../src/link/useRouter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAe,MAAM,QAAQ,CAAC;AAM3C,wBAAgB,OAAO,WAGtB;AAED,KAAK,MAAM,GAAG;IACZ,qCAAqC;IACrC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC3B,0DAA0D;IAC1D,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,6CAA6C;IAC7C,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,wBAAgB,SAAS,IAAI,MAAM,CA6BlC"}
@@ -0,0 +1,82 @@
1
+ import { LinkingOptions, NavigationState, ParamListBase, PartialState } from "@react-navigation/native";
2
+ import React from "react";
3
+ import { RouteNode } from "../Route";
4
+ import getPathFromState from "../fork/getPathFromState";
5
+ import { ResultState } from "../fork/getStateFromPath";
6
+ import { RequireContext } from "../types";
7
+ export declare const navigationRef: import("@react-navigation/native").NavigationContainerRefWithCurrent<Record<string, unknown>>;
8
+ type SearchParams = Record<string, string | string[]>;
9
+ type UrlObject = {
10
+ pathname: string;
11
+ readonly params: SearchParams;
12
+ segments: string[];
13
+ };
14
+ export declare class NavigationStore {
15
+ subscriptionMap: Map<string, Set<() => void>>;
16
+ ssrLocation: URL | undefined;
17
+ navigationRef: import("@react-navigation/native").NavigationContainerRefWithCurrent<Record<string, unknown>>;
18
+ routeNode: RouteNode;
19
+ linking: LinkingOptions<object>;
20
+ rootState: NavigationState | PartialState<NavigationState> | undefined;
21
+ initialRootState: ResultState | undefined;
22
+ url: URL;
23
+ routeInfo: UrlObject;
24
+ shouldShowTutorial: boolean;
25
+ _onReady?: () => void;
26
+ constructor(ssrLocation?: URL);
27
+ initialise: (context: RequireContext, onReady: () => void) => void;
28
+ handleRouteInfoChange: (data?: NavigationState | PartialState<NavigationState>) => void;
29
+ onReady: () => void;
30
+ notifiySubscribers: (topic: string) => void;
31
+ subscribeFactory: (key: string) => (callback: () => void) => () => void;
32
+ subscribeRouteInfo: (callback: () => void) => () => void;
33
+ subscribeRootState: (callback: () => void) => () => void;
34
+ }
35
+ export declare const NavigationStoreContext: React.Context<NavigationStore>;
36
+ export declare function useNavigationStore(context: RequireContext): NavigationStore & {
37
+ shouldShowSplash: boolean;
38
+ };
39
+ export declare function useRootNavigation(): import("@react-navigation/native").NavigationContainerRefWithCurrent<Record<string, unknown>>;
40
+ export declare function useLinkingContext(): Required<Omit<LinkingOptions<ParamListBase>, "filter" | "enabled">> & {
41
+ getPathFromState: typeof getPathFromState;
42
+ };
43
+ export declare function useRootNavigationState(): Readonly<{
44
+ key: string;
45
+ index: number;
46
+ routeNames: string[];
47
+ history?: unknown[] | undefined;
48
+ routes: (Readonly<{
49
+ key: string;
50
+ name: string;
51
+ path?: string | undefined;
52
+ }> & Readonly<{
53
+ params?: Readonly<object | undefined>;
54
+ }> & {
55
+ state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
56
+ })[];
57
+ type: string;
58
+ stale: false;
59
+ }> | PartialState<Readonly<{
60
+ key: string;
61
+ index: number;
62
+ routeNames: string[];
63
+ history?: unknown[] | undefined;
64
+ routes: (Readonly<{
65
+ key: string;
66
+ name: string;
67
+ path?: string | undefined;
68
+ }> & Readonly<{
69
+ params?: Readonly<object | undefined>;
70
+ }> & {
71
+ state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
72
+ })[];
73
+ type: string;
74
+ stale: false;
75
+ }>> | undefined;
76
+ export declare function useRouteInfo(): UrlObject;
77
+ export declare function useSegments(): string[];
78
+ export declare function usePathname(): string;
79
+ export declare function useSearchParams(): SearchParams;
80
+ export declare function useLocalSearchParams<TParams extends SearchParams = SearchParams>(): Partial<TParams>;
81
+ export {};
82
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigationStore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,aAAa,EACb,YAAY,EAGb,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,gBAEN,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,aAAa,+FAC+B,CAAC;AAE1D,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,qBAAa,eAAe;IAC1B,eAAe,wBAA6B,IAAI,GAI7C;IAEH,WAAW,EAAE,GAAG,GAAG,SAAS,CAAC;IAE7B,aAAa,gGAAiB;IAC9B,SAAS,EAAG,SAAS,CAAC;IACtB,OAAO,EAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACjC,SAAS,EAAE,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC;IACvE,gBAAgB,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C,GAAG,EAAG,GAAG,CAAC;IACV,SAAS,EAAG,SAAS,CAAC;IAEtB,kBAAkB,UAAS;IAC3B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;gBAEV,WAAW,CAAC,EAAE,GAAG;IAI7B,UAAU,YAAa,cAAc,WAAW,MAAM,IAAI,UAoBxD;IAEF,qBAAqB,UACZ,eAAe,GAAG,aAAa,eAAe,CAAC,UA6BtD;IAEF,OAAO,aAWL;IAEF,kBAAkB,UAAW,MAAM,UAIjC;IAEF,gBAAgB,QAAS,MAAM,gBACX,MAAM,IAAI,gBAM5B;IAEF,kBAAkB,aARE,MAAM,IAAI,gBAQ0B;IACxD,kBAAkB,aATE,MAAM,IAAI,gBAS0B;CACzD;AAED,eAAO,MAAM,sBAAsB,gCAElC,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc;;EAezD;AAED,wBAAgB,iBAAiB,kGAEhC;AAED,wBAAgB,iBAAiB;sBASX,uBAAuB;EAE5C;AAED,wBAAgB,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAOrC;AAED,wBAAgB,YAAY,cAO3B;AAED,wBAAgB,WAAW,aAE1B;AAED,wBAAgB,WAAW,WAE1B;AAED,wBAAgB,eAAe,iBAE9B;AAED,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAEpB"}
@@ -1,4 +1,5 @@
1
- export declare function useServerState(): (Partial<Omit<Readonly<{
1
+ import { LinkingOptions } from "@react-navigation/native";
2
+ export declare function getInitialState(linking: LinkingOptions<object>, ssrLocation?: URL): (Partial<Omit<Readonly<{
2
3
  key: string;
3
4
  index: number;
4
5
  routeNames: string[];
@@ -10,13 +11,13 @@ export declare function useServerState(): (Partial<Omit<Readonly<{
10
11
  }> & Readonly<{
11
12
  params?: Readonly<object | undefined>;
12
13
  }> & {
13
- state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
14
+ state?: Readonly<any> | import("@react-navigation/native").PartialState<Readonly<any>> | undefined;
14
15
  })[];
15
16
  type: string;
16
17
  stale: false;
17
- }>, "routes" | "stale">> & Readonly<{
18
+ }>, "stale" | "routes">> & Readonly<{
18
19
  stale?: true | undefined;
19
- routes: import("@react-navigation/routers").PartialRoute<import("@react-navigation/routers").Route<string, object | undefined>>[];
20
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
20
21
  }> & {
21
22
  state?: (Partial<Omit<Readonly<{
22
23
  key: string;
@@ -30,13 +31,13 @@ export declare function useServerState(): (Partial<Omit<Readonly<{
30
31
  }> & Readonly<{
31
32
  params?: Readonly<object | undefined>;
32
33
  }> & {
33
- state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
34
+ state?: Readonly<any> | import("@react-navigation/native").PartialState<Readonly<any>> | undefined;
34
35
  })[];
35
36
  type: string;
36
37
  stale: false;
37
- }>, "routes" | "stale">> & Readonly<{
38
+ }>, "stale" | "routes">> & Readonly<{
38
39
  stale?: true | undefined;
39
- routes: import("@react-navigation/routers").PartialRoute<import("@react-navigation/routers").Route<string, object | undefined>>[];
40
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
40
41
  }> & any) | undefined;
41
42
  }) | undefined;
42
- //# sourceMappingURL=useServerState.d.ts.map
43
+ //# sourceMappingURL=initialState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initialState.d.ts","sourceRoot":"","sources":["../../src/navigationStore/initialState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,wBAAgB,eAAe,CAC7B,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAC/B,WAAW,CAAC,EAAE,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAkBlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderStaticContent.d.ts","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAUtD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,CA6CtD;AA0BD,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"renderStaticContent.d.ts","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWtD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,CA+CtD;AA0BD,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -19,7 +19,7 @@ export type ScreenProps<TOptions extends Record<string, any> = Record<string, an
19
19
  */
20
20
  export declare function useSortedScreens(order: ScreenProps[]): React.ReactNode[];
21
21
  /** Wrap the component with various enhancements and add access to child routes. */
22
- export declare function getQualifiedRouteComponent(value: RouteNode): React.ComponentType<any> | React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<unknown>>;
22
+ export declare function getQualifiedRouteComponent(value: RouteNode): React.ComponentType<any> | React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
23
23
  /** @returns a function which provides a screen id that matches the dynamic route name in params. */
24
24
  export declare function createGetIdForRoute(route: Pick<RouteNode, "dynamic" | "route">): (({ params }: {
25
25
  params?: Record<string, any> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useScreens.d.ts","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAIL,SAAS,EAGV,MAAM,SAAS,CAAC;AAMjB,MAAM,MAAM,WAAW,CACrB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IACxD;IACF,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACvC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAGnB,SAAS,CAAC,EAAE,GAAG,CAAC;CACjB,CAAC;AA8DF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAUxE;AA6BD,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,kIA2E1D;AAED,oGAAoG;AACpG,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;;sCA0B5C"}
1
+ {"version":3,"file":"useScreens.d.ts","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAIL,SAAS,EAGV,MAAM,SAAS,CAAC;AAMjB,MAAM,MAAM,WAAW,CACrB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IACxD;IACF,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACvC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAGnB,SAAS,CAAC,EAAE,GAAG,CAAC;CACjB,CAAC;AA8DF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAUxE;AA6BD,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,+GAuE1D;AAED,oGAAoG;AACpG,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;;sCA0B5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"Sitemap.d.ts","sourceRoot":"","sources":["../../src/views/Sitemap.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AA2B9E,wBAAgB,aAAa,IAAI,4BAA4B,CAqB5D;AAED,wBAAgB,OAAO,gBA6BtB"}
1
+ {"version":3,"file":"Sitemap.d.ts","sourceRoot":"","sources":["../../src/views/Sitemap.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAsC9E,wBAAgB,aAAa,IAAI,4BAA4B,CAqB5D;AAED,wBAAgB,OAAO,gBA6BtB"}
package/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- /// <reference types="./types/react-native" />
1
+ /// <reference types="./types/global" />
2
+ /// <reference types="./types/react-native-web" />
3
+ /// <reference types="./types/metro-require" />
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "expo-router",
3
- "version": "1.5.3",
3
+ "version": "1.6.0",
4
4
  "main": "src/index.tsx",
5
5
  "types": "build/index.d.ts",
6
6
  "files": [
7
+ "_error.js",
7
8
  "_entry.tsx",
8
9
  "_html-ctx.tsx",
9
10
  "assets",
@@ -92,7 +93,7 @@
92
93
  },
93
94
  "dependencies": {
94
95
  "@bacons/react-views": "^1.1.3",
95
- "@expo/metro-runtime": "2.0.6",
96
+ "@expo/metro-runtime": "2.1.0",
96
97
  "@radix-ui/react-slot": "^1.0.0",
97
98
  "@react-navigation/bottom-tabs": "~6.5.7",
98
99
  "@react-navigation/native": "~6.1.6",
package/src/ExpoRoot.tsx CHANGED
@@ -2,14 +2,9 @@ import { StatusBar } from "expo-status-bar";
2
2
  import React from "react";
3
3
  import { SafeAreaProvider } from "react-native-safe-area-context";
4
4
 
5
- import { NavigationContainer } from "./NavigationContainer";
6
- import { useTutorial } from "./onboard/useTutorial";
5
+ import UpstreamNavigationContainer from "./fork/NavigationContainer";
6
+ import { useNavigationStore } from "./navigationStore";
7
7
  import { RequireContext } from "./types";
8
- import { InitialRootStateProvider } from "./useInitialRootStateContext";
9
- import {
10
- RootRouteNodeProvider,
11
- useRootRouteNodeContext,
12
- } from "./useRootRouteNodeContext";
13
8
  import { getQualifiedRouteComponent } from "./useScreens";
14
9
  import { SplashScreen } from "./views/Splash";
15
10
 
@@ -49,27 +44,33 @@ export function ExpoRoot({ context }: { context: RequireContext }) {
49
44
  }
50
45
 
51
46
  function ContextNavigator({ context }: { context: RequireContext }) {
52
- if (process.env.NODE_ENV !== "production") {
53
- // eslint-disable-next-line react-hooks/rules-of-hooks
54
- const Tutorial = useTutorial(context);
55
- if (Tutorial) {
56
- SplashScreen.hideAsync();
57
- return <Tutorial />;
58
- }
47
+ const {
48
+ shouldShowTutorial,
49
+ shouldShowSplash,
50
+ linking,
51
+ navigationRef,
52
+ onReady,
53
+ routeNode,
54
+ } = useNavigationStore(context);
55
+
56
+ if (shouldShowTutorial) {
57
+ const Tutorial = require("./onboard/Tutorial").Tutorial;
58
+ SplashScreen.hideAsync();
59
+ return <Tutorial />;
59
60
  }
60
61
 
62
+ const Component = getQualifiedRouteComponent(routeNode);
63
+
61
64
  return (
62
- <RootRouteNodeProvider context={context}>
63
- <NavigationContainer>
64
- <InitialRootStateProvider>
65
- <RootRoute />
66
- </InitialRootStateProvider>
67
- </NavigationContainer>
68
- </RootRouteNodeProvider>
65
+ <>
66
+ {shouldShowSplash && <SplashScreen />}
67
+ <UpstreamNavigationContainer
68
+ linking={linking}
69
+ ref={navigationRef}
70
+ onReady={onReady}
71
+ >
72
+ <Component />
73
+ </UpstreamNavigationContainer>
74
+ </>
69
75
  );
70
76
  }
71
-
72
- function RootRoute() {
73
- const Component = getQualifiedRouteComponent(useRootRouteNodeContext());
74
- return <Component />;
75
- }
@@ -1,15 +1,4 @@
1
- import { useRoute } from "@react-navigation/native";
2
- import React from "react";
3
-
4
- import { getNavigationContainerRef } from "./NavigationContainer";
5
- import getPathFromState, {
6
- deepEqual,
7
- getPathDataFromState,
8
- State,
9
- } from "./fork/getPathFromState";
10
- import { useLinkingContext } from "./link/useLinkingContext";
11
- import { useServerState } from "./static/useServerState";
12
- import { useInitialRootStateContext } from "./useInitialRootStateContext";
1
+ import { State, deepEqual } from "./fork/getPathFromState";
13
2
 
14
3
  type SearchParams = Record<string, string | string[]>;
15
4
 
@@ -19,7 +8,7 @@ type UrlObject = {
19
8
  segments: string[];
20
9
  };
21
10
 
22
- function getRouteInfoFromState(
11
+ export function getRouteInfoFromState(
23
12
  getPathFromState: (
24
13
  state: State,
25
14
  asPath: boolean
@@ -34,7 +23,7 @@ function getRouteInfoFromState(
34
23
  };
35
24
  }
36
25
 
37
- function compareRouteInfo(a: UrlObject, b: UrlObject) {
26
+ export function compareRouteInfo(a: UrlObject, b: UrlObject) {
38
27
  return (
39
28
  a.segments.length === b.segments.length &&
40
29
  a.segments.every((segment, index) => segment === b.segments[index]) &&
@@ -50,91 +39,6 @@ export function compareUrlSearchParams(
50
39
  return deepEqual(a, b);
51
40
  }
52
41
 
53
- function useSafeInitialRootState() {
54
- const serverState = useServerState();
55
- const initialRootState = useInitialRootStateContext();
56
-
57
- return React.useMemo(() => {
58
- if (serverState) {
59
- return serverState;
60
- }
61
-
62
- // Check if "is ready" to prevent `console.error`s
63
- if (getNavigationContainerRef().isReady()) {
64
- return getNavigationContainerRef().getRootState() ?? initialRootState;
65
- }
66
-
67
- return initialRootState;
68
- }, []);
69
- }
70
-
71
- function useUrlObject(): UrlObject {
72
- const getPathFromState = useGetPathFromState();
73
-
74
- const [routeInfo, setRouteInfo] = React.useState<UrlObject>(
75
- getRouteInfoFromState(
76
- getPathFromState,
77
- // If the root state (from upstream) is not ready, use the hacky initial state.
78
- // Initial state can be generate because it assumes the linking configuration never changes.
79
- useSafeInitialRootState()
80
- )
81
- );
82
-
83
- const routeInfoRef = React.useRef(routeInfo);
84
-
85
- React.useEffect(() => {
86
- routeInfoRef.current = routeInfo;
87
- }, [routeInfo]);
88
-
89
- const maybeUpdateRouteInfo = React.useCallback(
90
- (state: State) => {
91
- // The state can be undefined when hot reloading a Layout Route on native.
92
- if (!state) {
93
- return;
94
- }
95
- // Prevent unnecessary updates
96
- const newRouteInfo = getRouteInfoFromState(getPathFromState, state);
97
- if (!compareRouteInfo(routeInfoRef.current, newRouteInfo)) {
98
- setRouteInfo(newRouteInfo);
99
- }
100
- },
101
- [
102
- // TODO: This probably never changes
103
- getPathFromState,
104
- ]
105
- );
106
-
107
- React.useEffect(() => {
108
- const rootNavigation = getNavigationContainerRef();
109
-
110
- return rootNavigation.addListener("state", ({ data }) => {
111
- // Attempt to use the complete state from the root, otherwise this will default to
112
- // sending events from the nearest layout.
113
- const navigationState =
114
- rootNavigation.getRootState() ?? (data.state as unknown as State);
115
- // NOTE(EvanBacon): It's probably worth asserting if the root state is missing here.
116
- maybeUpdateRouteInfo(navigationState);
117
- });
118
- }, [maybeUpdateRouteInfo]);
119
-
120
- return routeInfo;
121
- }
122
-
123
- function useGetPathFromState() {
124
- const linking = useLinkingContext();
125
-
126
- return React.useCallback(
127
- (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {
128
- return getPathDataFromState(state, {
129
- ...linking.config,
130
- preserveDynamicRoutes: asPath,
131
- preserveGroups: asPath,
132
- });
133
- },
134
- [linking]
135
- );
136
- }
137
-
138
42
  // TODO: Split up getPathFromState to return all this info at once.
139
43
  export function getNormalizedStatePath({
140
44
  path: statePath,
@@ -159,53 +63,3 @@ export function getNormalizedStatePath({
159
63
  }, {} as SearchParams),
160
64
  };
161
65
  }
162
-
163
- const LocationContext = React.createContext<UrlObject | undefined>(undefined);
164
-
165
- if (process.env.NODE_ENV !== "production") {
166
- LocationContext.displayName = "LocationContext";
167
- }
168
-
169
- export function LocationProvider({ children }: { children: React.ReactNode }) {
170
- return (
171
- <LocationContext.Provider value={useUrlObject()}>
172
- {children}
173
- </LocationContext.Provider>
174
- );
175
- }
176
-
177
- function useLocation() {
178
- const location = React.useContext(LocationContext);
179
-
180
- if (!location) {
181
- throw new Error(
182
- "Location context is missing. Make sure you are rendering a <LocationProvider />."
183
- );
184
- }
185
-
186
- return location;
187
- }
188
-
189
- /** @returns Currently selected route as a normalized string without search parameters. e.g. `/acme?foo=bar` -> `/acme`. Segments will be normalized: `/[id]?id=normal` -> `/normal` */
190
- export function usePathname(): string {
191
- return useLocation().pathname;
192
- }
193
-
194
- /** @returns Current URL Search Parameters. */
195
- export function useSearchParams<
196
- TParams extends SearchParams = SearchParams
197
- >(): Partial<TParams> {
198
- return useLocation().params as Partial<TParams>;
199
- }
200
-
201
- /** @returns Current URL Search Parameters that only update when the path matches the current route. */
202
- export function useLocalSearchParams<
203
- TParams extends SearchParams = SearchParams
204
- >(): Partial<TParams> {
205
- return (useRoute()?.params ?? ({} as any)) as Partial<TParams>;
206
- }
207
-
208
- /** @returns Array of selected segments. */
209
- export function useSegments(): string[] {
210
- return useLocation().segments;
211
- }
package/src/exports.ts CHANGED
@@ -7,7 +7,9 @@ export {
7
7
  useLocalSearchParams,
8
8
  useSearchParams,
9
9
  useSegments,
10
- } from "./LocationProvider";
10
+ useRootNavigation,
11
+ useRootNavigationState,
12
+ } from "./navigationStore";
11
13
  export { Link, Redirect } from "./link/Link";
12
14
 
13
15
  export { withLayoutContext } from "./layouts/withLayoutContext";
@@ -24,5 +26,4 @@ export { SplashScreen } from "./views/Splash";
24
26
 
25
27
  // React Navigation
26
28
  export { useNavigation } from "./useNavigation";
27
- export { useRootNavigation, useRootNavigationState } from "./useRootNavigation";
28
29
  export { useFocusEffect } from "./useFocusEffect";
@@ -1,5 +1,5 @@
1
1
  import { HrefObject } from "./href";
2
- import { usePathname, useSearchParams, useSegments } from "../LocationProvider";
2
+ import { usePathname, useSearchParams, useSegments } from "../navigationStore";
3
3
 
4
4
  /** @deprecated */
5
5
  type RouteInfo = Omit<Required<HrefObject>, "query"> & {