expo-router 5.2.0-canary-20250613-b29d676-2 → 5.2.0-canary-20250701-6a945c5

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 (130) hide show
  1. package/build/ExpoRoot.d.ts.map +1 -1
  2. package/build/ExpoRoot.js +13 -7
  3. package/build/ExpoRoot.js.map +1 -1
  4. package/build/exports.d.ts +2 -0
  5. package/build/exports.d.ts.map +1 -1
  6. package/build/exports.js +5 -1
  7. package/build/exports.js.map +1 -1
  8. package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
  9. package/build/fork/getStateFromPath-forks.js +4 -1
  10. package/build/fork/getStateFromPath-forks.js.map +1 -1
  11. package/build/getRoutes.d.ts +1 -1
  12. package/build/getRoutes.d.ts.map +1 -1
  13. package/build/getRoutes.js +14 -6
  14. package/build/getRoutes.js.map +1 -1
  15. package/build/getRoutesCore.d.ts +7 -2
  16. package/build/getRoutesCore.d.ts.map +1 -1
  17. package/build/getRoutesCore.js +86 -58
  18. package/build/getRoutesCore.js.map +1 -1
  19. package/build/getRoutesRedirects.d.ts +2 -2
  20. package/build/getRoutesRedirects.d.ts.map +1 -1
  21. package/build/getRoutesRedirects.js +18 -24
  22. package/build/getRoutesRedirects.js.map +1 -1
  23. package/build/getRoutesSSR.d.ts +1 -1
  24. package/build/getRoutesSSR.d.ts.map +1 -1
  25. package/build/getRoutesSSR.js +2 -3
  26. package/build/getRoutesSSR.js.map +1 -1
  27. package/build/global-state/router-store.d.ts +52 -1
  28. package/build/global-state/router-store.d.ts.map +1 -1
  29. package/build/global-state/router-store.js +22 -1
  30. package/build/global-state/router-store.js.map +1 -1
  31. package/build/global-state/routing.d.ts +1 -0
  32. package/build/global-state/routing.d.ts.map +1 -1
  33. package/build/global-state/routing.js +3 -2
  34. package/build/global-state/routing.js.map +1 -1
  35. package/build/global-state/storeContext.d.ts +50 -0
  36. package/build/global-state/storeContext.d.ts.map +1 -1
  37. package/build/hooks.d.ts.map +1 -1
  38. package/build/hooks.js +33 -1
  39. package/build/hooks.js.map +1 -1
  40. package/build/layouts/StackClient.d.ts.map +1 -1
  41. package/build/layouts/StackClient.js +39 -2
  42. package/build/layouts/StackClient.js.map +1 -1
  43. package/build/link/BaseExpoRouterLink.d.ts +3 -0
  44. package/build/link/BaseExpoRouterLink.d.ts.map +1 -0
  45. package/build/link/BaseExpoRouterLink.js +63 -0
  46. package/build/link/BaseExpoRouterLink.js.map +1 -0
  47. package/build/link/ExpoLink.d.ts +3 -0
  48. package/build/link/ExpoLink.d.ts.map +1 -0
  49. package/build/link/ExpoLink.js +23 -0
  50. package/build/link/ExpoLink.js.map +1 -0
  51. package/build/link/Link.d.ts +63 -78
  52. package/build/link/Link.d.ts.map +1 -1
  53. package/build/link/Link.js +81 -99
  54. package/build/link/Link.js.map +1 -1
  55. package/build/link/LinkWithPreview.d.ts +36 -0
  56. package/build/link/LinkWithPreview.d.ts.map +1 -0
  57. package/build/link/LinkWithPreview.js +192 -0
  58. package/build/link/LinkWithPreview.js.map +1 -0
  59. package/build/link/Redirect.d.ts +58 -0
  60. package/build/link/Redirect.d.ts.map +1 -0
  61. package/build/link/Redirect.js +46 -0
  62. package/build/link/Redirect.js.map +1 -0
  63. package/build/link/preview/HrefPreview.d.ts +5 -0
  64. package/build/link/preview/HrefPreview.d.ts.map +1 -0
  65. package/build/link/preview/HrefPreview.js +99 -0
  66. package/build/link/preview/HrefPreview.js.map +1 -0
  67. package/build/link/preview/LinkPreviewContext.d.ts +7 -0
  68. package/build/link/preview/LinkPreviewContext.d.ts.map +1 -0
  69. package/build/link/preview/LinkPreviewContext.js +21 -0
  70. package/build/link/preview/LinkPreviewContext.js.map +1 -0
  71. package/build/link/preview/PreviewRouteContext.d.ts +22 -0
  72. package/build/link/preview/PreviewRouteContext.d.ts.map +1 -0
  73. package/build/link/preview/PreviewRouteContext.js +28 -0
  74. package/build/link/preview/PreviewRouteContext.js.map +1 -0
  75. package/build/link/preview/native.d.ts +31 -0
  76. package/build/link/preview/native.d.ts.map +1 -0
  77. package/build/link/preview/native.js +53 -0
  78. package/build/link/preview/native.js.map +1 -0
  79. package/build/link/preview/useNextScreenId.d.ts +3 -0
  80. package/build/link/preview/useNextScreenId.d.ts.map +1 -0
  81. package/build/link/preview/useNextScreenId.js +42 -0
  82. package/build/link/preview/useNextScreenId.js.map +1 -0
  83. package/build/link/useLinkHooks.d.ts +3 -2
  84. package/build/link/useLinkHooks.d.ts.map +1 -1
  85. package/build/link/useLinkHooks.js +1 -0
  86. package/build/link/useLinkHooks.js.map +1 -1
  87. package/build/modal/Modal.d.ts +82 -0
  88. package/build/modal/Modal.d.ts.map +1 -0
  89. package/build/modal/Modal.js +82 -0
  90. package/build/modal/Modal.js.map +1 -0
  91. package/build/modal/ModalComponent.d.ts +7 -0
  92. package/build/modal/ModalComponent.d.ts.map +1 -0
  93. package/build/modal/ModalComponent.js +10 -0
  94. package/build/modal/ModalComponent.js.map +1 -0
  95. package/build/modal/ModalContext.d.ts +22 -0
  96. package/build/modal/ModalContext.d.ts.map +1 -0
  97. package/build/modal/ModalContext.js +150 -0
  98. package/build/modal/ModalContext.js.map +1 -0
  99. package/build/typed-routes/generate.js +1 -1
  100. package/build/typed-routes/generate.js.map +1 -1
  101. package/build/useFocusEffect.d.ts.map +1 -1
  102. package/build/useFocusEffect.js +5 -3
  103. package/build/useFocusEffect.js.map +1 -1
  104. package/build/useScreens.js +1 -1
  105. package/build/useScreens.js.map +1 -1
  106. package/build/utils/stack.d.ts +5 -0
  107. package/build/utils/stack.d.ts.map +1 -0
  108. package/build/utils/stack.js +10 -0
  109. package/build/utils/stack.js.map +1 -0
  110. package/build/views/Screen.d.ts.map +1 -1
  111. package/build/views/Screen.js +13 -40
  112. package/build/views/Screen.js.map +1 -1
  113. package/build/views/Unmatched.d.ts.map +1 -1
  114. package/build/views/Unmatched.js +9 -3
  115. package/build/views/Unmatched.js.map +1 -1
  116. package/build/views/useSafeLayoutEffect.d.ts +3 -0
  117. package/build/views/useSafeLayoutEffect.d.ts.map +1 -0
  118. package/build/views/useSafeLayoutEffect.js +6 -0
  119. package/build/views/useSafeLayoutEffect.js.map +1 -0
  120. package/expo-module.config.json +1 -1
  121. package/ios/ExpoHead.podspec +1 -1
  122. package/ios/LinkPreview/LinkPreviewNativeActionView.swift +12 -0
  123. package/ios/LinkPreview/LinkPreviewNativeModule.swift +50 -0
  124. package/ios/LinkPreview/LinkPreviewNativeNavigation.h +18 -0
  125. package/ios/LinkPreview/LinkPreviewNativeNavigation.mm +108 -0
  126. package/ios/LinkPreview/LinkPreviewNativePreviewView.swift +15 -0
  127. package/ios/LinkPreview/LinkPreviewNativeTriggerView.swift +9 -0
  128. package/ios/LinkPreview/LinkPreviewNativeView.swift +193 -0
  129. package/package.json +6 -6
  130. package/plugin/options.json +29 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIgnoreList = exports.extrapolateGroups = exports.generateDynamic = void 0;
3
+ exports.extrapolateGroups = exports.generateDynamic = void 0;
4
4
  exports.getRoutes = getRoutes;
5
5
  exports.getExactRoutes = getExactRoutes;
6
6
  const getRoutesCore_1 = require("./getRoutesCore");
@@ -18,7 +18,7 @@ const getRoutesCore_1 = require("./getRoutesCore");
18
18
  */
19
19
  function getRoutes(contextModule, options = {}) {
20
20
  return (0, getRoutesCore_1.getRoutes)(contextModule, {
21
- getSystemRoute({ route, type }, defaults) {
21
+ getSystemRoute({ route, type, defaults }) {
22
22
  if (route === '' && type === 'layout') {
23
23
  // Root layout when no layout is defined.
24
24
  return {
@@ -84,5 +84,4 @@ function getExactRoutes(contextModule, options = {}) {
84
84
  var getRoutesCore_2 = require("./getRoutesCore");
85
85
  Object.defineProperty(exports, "generateDynamic", { enumerable: true, get: function () { return getRoutesCore_2.generateDynamic; } });
86
86
  Object.defineProperty(exports, "extrapolateGroups", { enumerable: true, get: function () { return getRoutesCore_2.extrapolateGroups; } });
87
- Object.defineProperty(exports, "getIgnoreList", { enumerable: true, get: function () { return getRoutesCore_2.getIgnoreList; } });
88
87
  //# sourceMappingURL=getRoutesSSR.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRoutesSSR.js","sourceRoot":"","sources":["../src/getRoutesSSR.ts"],"names":[],"mappings":";;;AAiBA,8BAuDC;AAED,wCAQC;AAjFD,mDAA0F;AAI1F;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CAAC,aAA6B,EAAE,UAAmB,EAAE;IAC5E,OAAO,IAAA,yBAAa,EAAC,aAAa,EAAE;QAClC,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ;YACtC,IAAI,KAAK,KAAK,EAAE,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtC,yCAAyC;gBACzC,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;wBAChB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;qBACpB,CAAC;oBACF,8CAA8C;oBAC9C,UAAU,EAAE,sCAAsC;oBAClD,KAAK,EAAE,EAAE;oBACT,SAAS,EAAE,IAAI;oBACf,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,EAAE;iBACb,CAAC;YACJ,CAAC;iBAAM,IAAI,KAAK,KAAK,UAAU,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;gBACpD,OAAO;oBACL,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;wBAChB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;qBACpB,CAAC;oBACF,KAAK,EAAE,UAAU;oBACjB,IAAI,EAAE,OAAO;oBACb,UAAU,EAAE,oCAAoC;oBAChD,SAAS,EAAE,IAAI;oBACf,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,EAAE;iBACb,CAAC;YACJ,CAAC;iBAAM,IAAI,KAAK,KAAK,YAAY,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;gBACtD,OAAO;oBACL,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;wBAChB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;qBACpB,CAAC;oBACF,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,YAAY;oBACnB,UAAU,EAAE,sCAAsC;oBAClD,SAAS,EAAE,IAAI;oBACf,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;oBAC7D,QAAQ,EAAE,EAAE;iBACb,CAAC;YACJ,CAAC;iBAAM,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,SAAS,CAAC,IAAI,QAAQ,EAAE,CAAC;gBACnE,OAAO;oBACL,GAAG,QAAQ;oBACX,SAAS;wBACP,OAAO,OAAO,CAAC,sBAAsB,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBAClE,CAAC;iBACF,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,cAAc,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;QACD,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,cAAc,CAC5B,aAA6B,EAC7B,UAAmB,EAAE;IAErB,OAAO,SAAS,CAAC,aAAa,EAAE;QAC9B,GAAG,OAAO;QACV,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;AACL,CAAC;AAED,iDAAoF;AAA3E,gHAAA,eAAe,OAAA;AAAE,kHAAA,iBAAiB,OAAA;AAAE,8GAAA,aAAa,OAAA","sourcesContent":["import type { RouteNode } from './Route';\nimport { getRoutes as getRoutesCore, type Options as OptionsCore } from './getRoutesCore';\nimport type { RequireContext } from './types';\n\nexport type Options = Omit<OptionsCore, 'getSystemRoute'>;\n/**\n * Given a Metro context module, return an array of nested routes.\n *\n * This is a two step process:\n * 1. Convert the RequireContext keys (file paths) into a directory tree.\n * - This should extrapolate array syntax into multiple routes\n * - Routes are given a specificity score\n * 2. Flatten the directory tree into routes\n * - Routes in directories without _layout files are hoisted to the nearest _layout\n * - The name of the route is relative to the nearest _layout\n * - If multiple routes have the same name, the most specific route is used\n */\nexport function getRoutes(contextModule: RequireContext, options: Options = {}): RouteNode | null {\n return getRoutesCore(contextModule, {\n getSystemRoute({ route, type }, defaults) {\n if (route === '' && type === 'layout') {\n // Root layout when no layout is defined.\n return {\n type: 'layout',\n loadRoute: () => ({\n default: () => null,\n }),\n // Generate a fake file name for the directory\n contextKey: 'expo-router/build/views/Navigator.js',\n route: '',\n generated: true,\n dynamic: null,\n children: [],\n };\n } else if (route === '_sitemap' && type === 'route') {\n return {\n loadRoute: () => ({\n default: () => null,\n }),\n route: '_sitemap',\n type: 'route',\n contextKey: 'expo-router/build/views/Sitemap.js',\n generated: true,\n internal: true,\n dynamic: null,\n children: [],\n };\n } else if (route === '+not-found' && type === 'route') {\n return {\n loadRoute: () => ({\n default: () => null,\n }),\n type: 'route',\n route: '+not-found',\n contextKey: 'expo-router/build/views/Unmatched.js',\n generated: true,\n internal: true,\n dynamic: [{ name: '+not-found', deep: true, notFound: true }],\n children: [],\n };\n } else if ((type === 'redirect' || type === 'rewrite') && defaults) {\n return {\n ...defaults,\n loadRoute() {\n return require('./getRoutesRedirects').getRedirectModule(route);\n },\n };\n }\n throw new Error(`Unknown system route: ${route} and type: ${type}`);\n },\n ...options,\n });\n}\n\nexport function getExactRoutes(\n contextModule: RequireContext,\n options: Options = {}\n): RouteNode | null {\n return getRoutes(contextModule, {\n ...options,\n skipGenerated: true,\n });\n}\n\nexport { generateDynamic, extrapolateGroups, getIgnoreList } from './getRoutesCore';\n"]}
1
+ {"version":3,"file":"getRoutesSSR.js","sourceRoot":"","sources":["../src/getRoutesSSR.ts"],"names":[],"mappings":";;;AAiBA,8BAuDC;AAED,wCAQC;AAjFD,mDAA0F;AAI1F;;;;;;;;;;;G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oBACd,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;oBAC7D,QAAQ,EAAE,EAAE;iBACb,CAAC;YACJ,CAAC;iBAAM,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,SAAS,CAAC,IAAI,QAAQ,EAAE,CAAC;gBACnE,OAAO;oBACL,GAAG,QAAQ;oBACX,SAAS;wBACP,OAAO,OAAO,CAAC,sBAAsB,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBAClE,CAAC;iBACF,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,cAAc,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;QACD,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,cAAc,CAC5B,aAA6B,EAC7B,UAAmB,EAAE;IAErB,OAAO,SAAS,CAAC,aAAa,EAAE;QAC9B,GAAG,OAAO;QACV,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;AACL,CAAC;AAED,iDAAqE;AAA5D,gHAAA,eAAe,OAAA;AAAE,kHAAA,iBAAiB,OAAA","sourcesContent":["import type { RouteNode } from './Route';\nimport { getRoutes as getRoutesCore, type Options as OptionsCore } from './getRoutesCore';\nimport type { RequireContext } from './types';\n\nexport type Options = Omit<OptionsCore, 'getSystemRoute'>;\n/**\n * Given a Metro context module, return an array of nested routes.\n *\n * This is a two step process:\n * 1. Convert the RequireContext keys (file paths) into a directory tree.\n * - This should extrapolate array syntax into multiple routes\n * - Routes are given a specificity score\n * 2. Flatten the directory tree into routes\n * - Routes in directories without _layout files are hoisted to the nearest _layout\n * - The name of the route is relative to the nearest _layout\n * - If multiple routes have the same name, the most specific route is used\n */\nexport function getRoutes(contextModule: RequireContext, options: Options = {}): RouteNode | null {\n return getRoutesCore(contextModule, {\n getSystemRoute({ route, type, defaults }) {\n if (route === '' && type === 'layout') {\n // Root layout when no layout is defined.\n return {\n type: 'layout',\n loadRoute: () => ({\n default: () => null,\n }),\n // Generate a fake file name for the directory\n contextKey: 'expo-router/build/views/Navigator.js',\n route: '',\n generated: true,\n dynamic: null,\n children: [],\n };\n } else if (route === '_sitemap' && type === 'route') {\n return {\n loadRoute: () => ({\n default: () => null,\n }),\n route: '_sitemap',\n type: 'route',\n contextKey: 'expo-router/build/views/Sitemap.js',\n generated: true,\n internal: true,\n dynamic: null,\n children: [],\n };\n } else if (route === '+not-found' && type === 'route') {\n return {\n loadRoute: () => ({\n default: () => null,\n }),\n type: 'route',\n route: '+not-found',\n contextKey: 'expo-router/build/views/Unmatched.js',\n generated: true,\n internal: true,\n dynamic: [{ name: '+not-found', deep: true, notFound: true }],\n children: [],\n };\n } else if ((type === 'redirect' || type === 'rewrite') && defaults) {\n return {\n ...defaults,\n loadRoute() {\n return require('./getRoutesRedirects').getRedirectModule(route);\n },\n };\n }\n throw new Error(`Unknown system route: ${route} and type: ${type}`);\n },\n ...options,\n });\n}\n\nexport function getExactRoutes(\n contextModule: RequireContext,\n options: Options = {}\n): RouteNode | null {\n return getRoutes(contextModule, {\n ...options,\n skipGenerated: true,\n });\n}\n\nexport { generateDynamic, extrapolateGroups } from './getRoutesCore';\n"]}
@@ -4,7 +4,8 @@ import { RouteNode } from '../Route';
4
4
  import { ExpoLinkingOptions, LinkingConfigOptions } from '../getLinkingConfig';
5
5
  import { RedirectConfig } from '../getRoutesCore';
6
6
  import { UrlObject } from './routeInfo';
7
- import { RequireContext } from '../types';
7
+ import { RequireContext, type Href } from '../types';
8
+ import { type LinkToOptions } from './routing';
8
9
  export type StoreRedirects = readonly [RegExp, RedirectConfig, boolean];
9
10
  export type ReactNavigationState = NavigationState | PartialState<NavigationState>;
10
11
  export type FocusedRouteState = NonNullable<ReturnType<typeof useStateForPath>>;
@@ -17,6 +18,31 @@ export declare const store: {
17
18
  getRouteInfo(): UrlObject;
18
19
  readonly redirects: StoreRedirects[];
19
20
  readonly rootComponent: ComponentType<any>;
21
+ getStateForHref(href: Href, options?: LinkToOptions): (Partial<Omit<Readonly<{
22
+ key: string;
23
+ index: number;
24
+ routeNames: string[];
25
+ history?: unknown[];
26
+ routes: import("@react-navigation/native").NavigationRoute<import("@react-navigation/native").ParamListBase, string>[];
27
+ type: string;
28
+ stale: false;
29
+ }>, "stale" | "routes">> & Readonly<{
30
+ stale?: true;
31
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
32
+ }> & {
33
+ state?: Partial<Omit<Readonly<{
34
+ key: string;
35
+ index: number;
36
+ routeNames: string[];
37
+ history?: unknown[];
38
+ routes: import("@react-navigation/native").NavigationRoute<import("@react-navigation/native").ParamListBase, string>[];
39
+ type: string;
40
+ stale: false;
41
+ }>, "stale" | "routes">> & Readonly<{
42
+ stale?: true;
43
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
44
+ }> & /*elided*/ any;
45
+ }) | undefined;
20
46
  readonly linking: ExpoLinkingOptions | undefined;
21
47
  setFocusedState(state: FocusedRouteState): void;
22
48
  onReady(): void;
@@ -30,6 +56,31 @@ export declare function useStore(context: RequireContext, linkingConfigOptions:
30
56
  getRouteInfo(): UrlObject;
31
57
  readonly redirects: StoreRedirects[];
32
58
  readonly rootComponent: ComponentType<any>;
59
+ getStateForHref(href: Href, options?: LinkToOptions): (Partial<Omit<Readonly<{
60
+ key: string;
61
+ index: number;
62
+ routeNames: string[];
63
+ history?: unknown[];
64
+ routes: import("@react-navigation/native").NavigationRoute<import("@react-navigation/native").ParamListBase, string>[];
65
+ type: string;
66
+ stale: false;
67
+ }>, "stale" | "routes">> & Readonly<{
68
+ stale?: true;
69
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
70
+ }> & {
71
+ state?: Partial<Omit<Readonly<{
72
+ key: string;
73
+ index: number;
74
+ routeNames: string[];
75
+ history?: unknown[];
76
+ routes: import("@react-navigation/native").NavigationRoute<import("@react-navigation/native").ParamListBase, string>[];
77
+ type: string;
78
+ stale: false;
79
+ }>, "stale" | "routes">> & Readonly<{
80
+ stale?: true;
81
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
82
+ }> & /*elided*/ any;
83
+ }) | undefined;
33
84
  readonly linking: ExpoLinkingOptions | undefined;
34
85
  setFocusedState(state: FocusedRouteState): void;
35
86
  onReady(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"router-store.d.ts","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,iCAAiC,EACjC,eAAe,EACf,YAAY,EAEZ,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,aAAa,EAA6C,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAoB,MAAM,qBAAqB,CAAC;AAGjG,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAA2C,SAAS,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK1C,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AACnF,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG,OAAO,KAAK,CAAC;AAsBvC,eAAO,MAAM,KAAK;;;;;oBAaA,SAAS;;;;2BAYF,iBAAiB;;;CAiDzC,CAAC;AAEF,wBAAgB,QAAQ,CACtB,OAAO,EAAE,cAAc,EACvB,oBAA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F,SAAS;;;0BASH,IAAI,YAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;2BAS5B,iBAAiB;;;EA4IzC;AAUD,wBAAgB,YAAY,IAAI,SAAS,CAmBxC"}
@@ -50,7 +50,9 @@ const getLinkingConfig_1 = require("../getLinkingConfig");
50
50
  const getReactNavigationConfig_1 = require("../getReactNavigationConfig");
51
51
  const getRoutes_1 = require("../getRoutes");
52
52
  const routeInfo_1 = require("./routeInfo");
53
+ const href_1 = require("../link/href");
53
54
  const useScreens_1 = require("../useScreens");
55
+ const PreviewRouteContext_1 = require("../link/preview/PreviewRouteContext");
54
56
  const url_1 = require("../utils/url");
55
57
  const SplashScreen = __importStar(require("../views/Splash"));
56
58
  const storeRef = {
@@ -81,6 +83,11 @@ exports.store = {
81
83
  get rootComponent() {
82
84
  return storeRef.current.rootComponent;
83
85
  },
86
+ getStateForHref(href, options) {
87
+ href = (0, href_1.resolveHref)(href);
88
+ href = (0, href_1.resolveHrefStringWithSegments)(href, exports.store.getRouteInfo(), options);
89
+ return this.linking?.getStateFromPath(href, this.linking.config);
90
+ },
84
91
  get linking() {
85
92
  return storeRef.current.linking;
86
93
  },
@@ -134,6 +141,7 @@ function useStore(context, linkingConfigOptions, serverUrl) {
134
141
  ...config,
135
142
  ignoreEntryPoints: true,
136
143
  platform: react_native_1.Platform.OS,
144
+ preserveRedirectAndRewrites: true,
137
145
  });
138
146
  const redirects = [config?.redirects, config?.rewrites]
139
147
  .filter(Boolean)
@@ -206,7 +214,20 @@ const routeInfoSubscribe = (callback) => {
206
214
  };
207
215
  };
208
216
  function useRouteInfo() {
209
- return (0, react_1.useSyncExternalStore)(routeInfoSubscribe, exports.store.getRouteInfo, exports.store.getRouteInfo);
217
+ const routeInfo = (0, react_1.useSyncExternalStore)(routeInfoSubscribe, exports.store.getRouteInfo, exports.store.getRouteInfo);
218
+ const { isPreview, segments, params, pathname } = (0, PreviewRouteContext_1.usePreviewInfo)();
219
+ if (isPreview) {
220
+ return {
221
+ pathname: pathname ?? '',
222
+ segments: segments ?? [],
223
+ unstable_globalHref: '',
224
+ params: params ?? {},
225
+ searchParams: new URLSearchParams(),
226
+ pathnameWithParams: pathname ?? '',
227
+ isIndex: false,
228
+ };
229
+ }
230
+ return routeInfo;
210
231
  }
211
232
  function getCachedRouteInfo(state) {
212
233
  let routeInfo = routeInfoCache.get(state);
@@ -1 +1 @@
1
- {"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIb,4BAwFC;AAUD,oCAEC;AAlOD,qDAMkC;AAClC,oEAAuC;AACvC,iCAAiF;AACjF,+CAAwC;AAGxC,mEAAoE;AACpE,2EAAqE;AACrE,0DAAiG;AACjG,0EAAiE;AACjE,4CAAyC;AAEzC,2CAAiF;AAEjF,8CAA2D;AAC3D,sCAAoD;AACpD,8DAAgD;AAmBhD,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,EAAc;CACxB,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,OAAO,EAAuD,CAAC;AAE1F,IAAI,0BAA8C,CAAC;AACnD,IAAI,wBAAwB,GAAG,KAAK,CAAC;AAExB,QAAA,KAAK,GAAG;IACnB,kBAAkB;QAChB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;IAC/E,CAAC;IACD,IAAI,KAAK;QACP,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;IAChC,CAAC;IACD,IAAI,aAAa;QACf,OAAO,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;IACxC,CAAC;IACD,IAAI,SAAS;QACX,OAAO,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;IACpC,CAAC;IACD,YAAY;QACV,OAAO,QAAQ,CAAC,OAAO,CAAC,SAAS,IAAI,4BAAg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K,iBAAiB,CAAC,QAAQ,CAAC,MAAM;gBAC/D,SAAS,CAAC,QAAQ,CAAC,KAAK,CACtB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,OAAO,CAClE;gBACD,SAAS,CAAC,kBAAkB,KAAK,iBAAiB,CAAC,kBAAkB,CAAC;YAExE,IAAI,QAAQ,EAAE,CAAC;gBACb,gFAAgF;gBAChF,SAAS,GAAG,iBAAiB,CAAC;YAChC,CAAC;QACH,CAAC;QAED,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n NavigationState,\n PartialState,\n useNavigationContainerRef,\n useStateForPath,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport { ComponentType, Fragment, useEffect, useSyncExternalStore } from 'react';\nimport { Platform } from 'react-native';\n\nimport { RouteNode } from '../Route';\nimport { extractExpoPathFromURL } from '../fork/extractPathFromURL';\nimport { routePatternToRegex } from '../fork/getStateFromPath-forks';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { parseRouteSegments } from '../getReactNavigationConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RedirectConfig } from '../getRoutesCore';\nimport { defaultRouteInfo, getRouteInfoFromState, UrlObject } from './routeInfo';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\nimport * as SplashScreen from '../views/Splash';\n\nexport type StoreRedirects = readonly [RegExp, RedirectConfig, boolean];\nexport type ReactNavigationState = NavigationState | PartialState<NavigationState>;\nexport type FocusedRouteState = NonNullable<ReturnType<typeof useStateForPath>>;\n\nexport type RouterStore = typeof store;\n\ntype StoreRef = {\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n routeNode: RouteNode | null;\n rootComponent: ComponentType<any>;\n state?: ReactNavigationState;\n linking?: ExpoLinkingOptions;\n config: any;\n redirects: StoreRedirects[];\n routeInfo?: UrlObject;\n};\n\nconst storeRef = {\n current: {} as StoreRef,\n};\n\nconst routeInfoCache = new WeakMap<FocusedRouteState | ReactNavigationState, UrlObject>();\n\nlet splashScreenAnimationFrame: number | undefined;\nlet hasAttemptedToHideSplash = false;\n\nexport const store = {\n shouldShowTutorial() {\n return !storeRef.current.routeNode && process.env.NODE_ENV === 'development';\n },\n get state() {\n return storeRef.current.state;\n },\n get navigationRef() {\n return storeRef.current.navigationRef;\n },\n get routeNode() {\n return storeRef.current.routeNode;\n },\n getRouteInfo(): UrlObject {\n return storeRef.current.routeInfo || defaultRouteInfo;\n },\n get redirects() {\n return storeRef.current.redirects || [];\n },\n get rootComponent() {\n return storeRef.current.rootComponent;\n },\n get linking() {\n return storeRef.current.linking;\n },\n setFocusedState(state: FocusedRouteState) {\n const routeInfo = getCachedRouteInfo(state);\n storeRef.current.routeInfo = routeInfo;\n },\n onReady() {\n if (!hasAttemptedToHideSplash) {\n hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n splashScreenAnimationFrame = requestAnimationFrame(() => {\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n storeRef.current.navigationRef.addListener('state', (e) => {\n if (!e.data.state) {\n return;\n }\n\n let isStale: boolean | undefined = false;\n let state: ReactNavigationState | undefined = e.data.state;\n\n while (!isStale && state) {\n isStale = state.stale;\n state =\n state.routes?.[\n 'index' in state && typeof state.index === 'number'\n ? state.index\n : state.routes.length - 1\n ]?.state;\n }\n\n storeRef.current.state = e.data.state;\n\n if (!isStale) {\n storeRef.current.routeInfo = getCachedRouteInfo(e.data.state);\n }\n\n for (const callback of routeInfoSubscribers) {\n callback();\n }\n });\n },\n assertIsReady() {\n if (!storeRef.current.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n },\n};\n\nexport function useStore(\n context: RequireContext,\n linkingConfigOptions: LinkingConfigOptions,\n serverUrl?: string\n) {\n const navigationRef = useNavigationContainerRef();\n const config = Constants.expoConfig?.extra?.router;\n\n let linking: ExpoLinkingOptions | undefined;\n let rootComponent: ComponentType<any> = Fragment;\n let initialState: ReactNavigationState | undefined;\n\n const routeNode = getRoutes(context, {\n ...config,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n const redirects: StoreRedirects[] = [config?.redirects, config?.rewrites]\n .filter(Boolean)\n .flat()\n .map((route) => {\n return [\n routePatternToRegex(parseRouteSegments(route.source)),\n route,\n shouldLinkExternally(route.destination),\n ];\n });\n\n if (routeNode) {\n // We have routes, so get the linking config and the root component\n linking = getLinkingConfig(routeNode, context, () => store.getRouteInfo(), {\n metaOnly: linkingConfigOptions.metaOnly,\n serverUrl,\n redirects,\n });\n rootComponent = getQualifiedRouteComponent(routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can prefetch the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n let initialPath = extractExpoPathFromURL(linking.prefixes, initialURL);\n\n // It does not matter if the path starts with a `/` or not, but this keeps the behavior consistent\n if (!initialPath.startsWith('/')) initialPath = '/' + initialPath;\n\n initialState = linking.getStateFromPath(initialPath, linking.config);\n const initialRouteInfo = getRouteInfoFromState(initialState);\n routeInfoCache.set(initialState as any, initialRouteInfo);\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n rootComponent = Fragment;\n }\n\n storeRef.current = {\n navigationRef,\n routeNode,\n config,\n rootComponent,\n linking,\n redirects,\n state: initialState,\n };\n\n if (initialState) {\n storeRef.current.routeInfo = getCachedRouteInfo(initialState);\n }\n\n useEffect(() => {\n return () => {\n // listener();\n\n if (splashScreenAnimationFrame) {\n cancelAnimationFrame(splashScreenAnimationFrame);\n splashScreenAnimationFrame = undefined;\n }\n };\n });\n\n return store;\n}\n\nconst routeInfoSubscribers = new Set<() => void>();\nconst routeInfoSubscribe = (callback: () => void) => {\n routeInfoSubscribers.add(callback);\n return () => {\n routeInfoSubscribers.delete(callback);\n };\n};\n\nexport function useRouteInfo() {\n return useSyncExternalStore(routeInfoSubscribe, store.getRouteInfo, store.getRouteInfo);\n}\n\nfunction getCachedRouteInfo(state: ReactNavigationState) {\n let routeInfo = routeInfoCache.get(state);\n\n if (!routeInfo) {\n routeInfo = getRouteInfoFromState(state);\n\n const previousRouteInfo = storeRef.current.routeInfo;\n if (previousRouteInfo) {\n const areEqual =\n routeInfo.segments.length === previousRouteInfo.segments.length &&\n routeInfo.segments.every(\n (segment, index) => previousRouteInfo.segments[index] === segment\n ) &&\n routeInfo.pathnameWithParams === previousRouteInfo.pathnameWithParams;\n\n if (areEqual) {\n // If they are equal, keep the previous route info for object reference equality\n routeInfo = previousRouteInfo;\n }\n }\n\n routeInfoCache.set(state, routeInfo);\n }\n\n return routeInfo;\n}\n"]}
1
+ {"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyIb,4BAyFC;AAUD,oCAmBC;AA7PD,qDAMkC;AAClC,oEAAuC;AACvC,iCAAiF;AACjF,+CAAwC;AAGxC,mEAAoE;AACpE,2EAAqE;AACrE,0DAAiG;AACjG,0EAAiE;AACjE,4CAAyC;AAEzC,2CAAiF;AACjF,uCAA0E;AAE1E,8CAA2D;AAE3D,6EAAqE;AACrE,sCAAoD;AACpD,8DAAgD;AAmBhD,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,E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CAAC,OAAO,CAAC,SAAS,CAAC;QACrD,IAAI,iBAAiB,EAAE,CAAC;YACtB,MAAM,QAAQ,GACZ,SAAS,CAAC,QAAQ,CAAC,MAAM,KAAK,iBAAiB,CAAC,QAAQ,CAAC,MAAM;gBAC/D,SAAS,CAAC,QAAQ,CAAC,KAAK,CACtB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,OAAO,CAClE;gBACD,SAAS,CAAC,kBAAkB,KAAK,iBAAiB,CAAC,kBAAkB,CAAC;YAExE,IAAI,QAAQ,EAAE,CAAC;gBACb,gFAAgF;gBAChF,SAAS,GAAG,iBAAiB,CAAC;YAChC,CAAC;QACH,CAAC;QAED,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n NavigationState,\n PartialState,\n useNavigationContainerRef,\n useStateForPath,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport { ComponentType, Fragment, useEffect, useSyncExternalStore } from 'react';\nimport { Platform } from 'react-native';\n\nimport { RouteNode } from '../Route';\nimport { extractExpoPathFromURL } from '../fork/extractPathFromURL';\nimport { routePatternToRegex } from '../fork/getStateFromPath-forks';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { parseRouteSegments } from '../getReactNavigationConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RedirectConfig } from '../getRoutesCore';\nimport { defaultRouteInfo, getRouteInfoFromState, UrlObject } from './routeInfo';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { RequireContext, type Href } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport { type LinkToOptions } from './routing';\nimport { usePreviewInfo } from '../link/preview/PreviewRouteContext';\nimport { shouldLinkExternally } from '../utils/url';\nimport * as SplashScreen from '../views/Splash';\n\nexport type StoreRedirects = readonly [RegExp, RedirectConfig, boolean];\nexport type ReactNavigationState = NavigationState | PartialState<NavigationState>;\nexport type FocusedRouteState = NonNullable<ReturnType<typeof useStateForPath>>;\n\nexport type RouterStore = typeof store;\n\ntype StoreRef = {\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n routeNode: RouteNode | null;\n rootComponent: ComponentType<any>;\n state?: ReactNavigationState;\n linking?: ExpoLinkingOptions;\n config: any;\n redirects: StoreRedirects[];\n routeInfo?: UrlObject;\n};\n\nconst storeRef = {\n current: {} as StoreRef,\n};\n\nconst routeInfoCache = new WeakMap<FocusedRouteState | ReactNavigationState, UrlObject>();\n\nlet splashScreenAnimationFrame: number | undefined;\nlet hasAttemptedToHideSplash = false;\n\nexport const store = {\n shouldShowTutorial() {\n return !storeRef.current.routeNode && process.env.NODE_ENV === 'development';\n },\n get state() {\n return storeRef.current.state;\n },\n get navigationRef() {\n return storeRef.current.navigationRef;\n },\n get routeNode() {\n return storeRef.current.routeNode;\n },\n getRouteInfo(): UrlObject {\n return storeRef.current.routeInfo || defaultRouteInfo;\n },\n get redirects() {\n return storeRef.current.redirects || [];\n },\n get rootComponent() {\n return storeRef.current.rootComponent;\n },\n getStateForHref(href: Href, options?: LinkToOptions) {\n href = resolveHref(href);\n\n href = resolveHrefStringWithSegments(href, store.getRouteInfo(), options);\n return this.linking?.getStateFromPath!(href, this.linking.config);\n },\n get linking() {\n return storeRef.current.linking;\n },\n setFocusedState(state: FocusedRouteState) {\n const routeInfo = getCachedRouteInfo(state);\n storeRef.current.routeInfo = routeInfo;\n },\n onReady() {\n if (!hasAttemptedToHideSplash) {\n hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n splashScreenAnimationFrame = requestAnimationFrame(() => {\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n storeRef.current.navigationRef.addListener('state', (e) => {\n if (!e.data.state) {\n return;\n }\n\n let isStale: boolean | undefined = false;\n let state: ReactNavigationState | undefined = e.data.state;\n\n while (!isStale && state) {\n isStale = state.stale;\n state =\n state.routes?.[\n 'index' in state && typeof state.index === 'number'\n ? state.index\n : state.routes.length - 1\n ]?.state;\n }\n\n storeRef.current.state = e.data.state;\n\n if (!isStale) {\n storeRef.current.routeInfo = getCachedRouteInfo(e.data.state);\n }\n\n for (const callback of routeInfoSubscribers) {\n callback();\n }\n });\n },\n assertIsReady() {\n if (!storeRef.current.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n },\n};\n\nexport function useStore(\n context: RequireContext,\n linkingConfigOptions: LinkingConfigOptions,\n serverUrl?: string\n) {\n const navigationRef = useNavigationContainerRef();\n const config = Constants.expoConfig?.extra?.router;\n\n let linking: ExpoLinkingOptions | undefined;\n let rootComponent: ComponentType<any> = Fragment;\n let initialState: ReactNavigationState | undefined;\n\n const routeNode = getRoutes(context, {\n ...config,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n preserveRedirectAndRewrites: true,\n });\n\n const redirects: StoreRedirects[] = [config?.redirects, config?.rewrites]\n .filter(Boolean)\n .flat()\n .map((route) => {\n return [\n routePatternToRegex(parseRouteSegments(route.source)),\n route,\n shouldLinkExternally(route.destination),\n ];\n });\n\n if (routeNode) {\n // We have routes, so get the linking config and the root component\n linking = getLinkingConfig(routeNode, context, () => store.getRouteInfo(), {\n metaOnly: linkingConfigOptions.metaOnly,\n serverUrl,\n redirects,\n });\n rootComponent = getQualifiedRouteComponent(routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can prefetch the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n let initialPath = extractExpoPathFromURL(linking.prefixes, initialURL);\n\n // It does not matter if the path starts with a `/` or not, but this keeps the behavior consistent\n if (!initialPath.startsWith('/')) initialPath = '/' + initialPath;\n\n initialState = linking.getStateFromPath(initialPath, linking.config);\n const initialRouteInfo = getRouteInfoFromState(initialState);\n routeInfoCache.set(initialState as any, initialRouteInfo);\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n rootComponent = Fragment;\n }\n\n storeRef.current = {\n navigationRef,\n routeNode,\n config,\n rootComponent,\n linking,\n redirects,\n state: initialState,\n };\n\n if (initialState) {\n storeRef.current.routeInfo = getCachedRouteInfo(initialState);\n }\n\n useEffect(() => {\n return () => {\n // listener();\n\n if (splashScreenAnimationFrame) {\n cancelAnimationFrame(splashScreenAnimationFrame);\n splashScreenAnimationFrame = undefined;\n }\n };\n });\n\n return store;\n}\n\nconst routeInfoSubscribers = new Set<() => void>();\nconst routeInfoSubscribe = (callback: () => void) => {\n routeInfoSubscribers.add(callback);\n return () => {\n routeInfoSubscribers.delete(callback);\n };\n};\n\nexport function useRouteInfo(): UrlObject {\n const routeInfo = useSyncExternalStore(\n routeInfoSubscribe,\n store.getRouteInfo,\n store.getRouteInfo\n );\n const { isPreview, segments, params, pathname } = usePreviewInfo();\n if (isPreview) {\n return {\n pathname: pathname ?? '',\n segments: segments ?? [],\n unstable_globalHref: '',\n params: params ?? {},\n searchParams: new URLSearchParams(),\n pathnameWithParams: pathname ?? '',\n isIndex: false,\n };\n }\n return routeInfo;\n}\n\nfunction getCachedRouteInfo(state: ReactNavigationState) {\n let routeInfo = routeInfoCache.get(state);\n\n if (!routeInfo) {\n routeInfo = getRouteInfoFromState(state);\n\n const previousRouteInfo = storeRef.current.routeInfo;\n if (previousRouteInfo) {\n const areEqual =\n routeInfo.segments.length === previousRouteInfo.segments.length &&\n routeInfo.segments.every(\n (segment, index) => previousRouteInfo.segments[index] === segment\n ) &&\n routeInfo.pathnameWithParams === previousRouteInfo.pathnameWithParams;\n\n if (areEqual) {\n // If they are equal, keep the previous route info for object reference equality\n routeInfo = previousRouteInfo;\n }\n }\n\n routeInfoCache.set(state, routeInfo);\n }\n\n return routeInfo;\n}\n"]}
@@ -44,6 +44,7 @@ export type LinkToOptions = {
44
44
  * If used with `push`, the history will be filtered even if no navigation occurs.
45
45
  */
46
46
  dangerouslySingular?: SingularOptions;
47
+ __internal__PreviewKey?: string;
47
48
  };
48
49
  export declare function linkTo(originalHref: Href, options?: LinkToOptions): void;
49
50
  //# sourceMappingURL=routing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsC,MAAM,0BAA0B,CAAC;AAiBhG,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAWhD,eAAO,MAAM,YAAY;WACV,gBAAgB,EAAE;2BACJ,IAAI;wBACX,MAAM,IAAI;;;;;;;gBASlB,gBAAgB;;CAsB7B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAE7D,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE9D;AAED,wBAAgB,MAAM,SAGrB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE/D;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE1D;AAED,wBAAgB,OAAO,CAAC,KAAK,GAAE,MAAU,QAMxC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAEhE;AAED,wBAAgB,OAAO,CAAC,GAAG,EA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AE,iBAAiB,QAE/D;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE1D;AAED,wBAAgB,OAAO,CAAC,KAAK,GAAE,MAAU,QAMxC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAEhE;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE7D;AAED,wBAAgB,UAAU,SAKzB;AAED,wBAAgB,MAAM,SAMrB;AAED,wBAAgB,SAAS,IAAI,OAAO,CAenC;AAED,wBAAgB,UAAU,IAAI,OAAO,CAmBpC;AAED,wBAAgB,SAAS,CACvB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAM,OAO/E;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,eAAe,CAAC;IAEtC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,wBAAgB,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,GAAE,aAAkB,QA8DrE"}
@@ -206,9 +206,9 @@ function linkTo(originalHref, options = {}) {
206
206
  console.error('Could not generate a valid navigation state for the given path: ' + href);
207
207
  return;
208
208
  }
209
- exports.routingQueue.add(getNavigateAction(state, rootState, options.event, options.withAnchor, options.dangerouslySingular));
209
+ exports.routingQueue.add(getNavigateAction(state, rootState, options.event, options.withAnchor, options.dangerouslySingular, options.__internal__PreviewKey));
210
210
  }
211
- function getNavigateAction(actionState, navigationState, type = 'NAVIGATE', withAnchor, singular) {
211
+ function getNavigateAction(actionState, navigationState, type = 'NAVIGATE', withAnchor, singular, previewKey) {
212
212
  /**
213
213
  * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the
214
214
  * lowest navigator is the target.
@@ -299,6 +299,7 @@ function getNavigateAction(actionState, navigationState, type = 'NAVIGATE', with
299
299
  name: rootPayload.screen,
300
300
  params: rootPayload.params,
301
301
  singular,
302
+ previewKey,
302
303
  },
303
304
  };
304
305
  }
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,4BAEC;AAED,wBAGC;AAED,4BAEC;AAED,oBAEC;AAED,0BAMC;AAED,8BAEC;AAED,0BAEC;AAED,gCAKC;AAED,wBAMC;AAED,8BAeC;AAED,gCAmBC;AAED,8BAQC;AAwBD,wBA6DC;AArPD,kCAAkC;AAClC,sDAAwC;AACxC,+CAAwC;AAExC,iDAAuC;AACvC,gEAMuC;AAEvC,8DAAuD;AACvD,uCAA0E;AAC1E,0CAA+C;AAG/C,sCAAoD;AAEpD,SAAS,aAAa;IACpB,IAAI,CAAC,oBAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;IACJ,CAAC;AACH,CAAC;AAEY,QAAA,YAAY,GAAG;IAC1B,KAAK,EAAE,EAAwB;IAC/B,WAAW,EAAE,IAAI,GAAG,EAAc;IAClC,SAAS,CAAC,QAAoB;QAC5B,oBAAY,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvC,OAAO,GAAG,EAAE;YACV,oBAAY,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC,CAAC;IACJ,CAAC;IACD,QAAQ;QACN,OAAO,oBAAY,CAAC,KAAK,CAAC;IAC5B,CAAC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CAAC,OAAO,EAAE,CAAC;YAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;gBAC1C,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;QACD;;;;;;;;WAQG;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,eAAe,CAAC,GAAG;QAC3B,OAAO,EAAE;YACP,wBAAwB;YACxB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,QAAQ;SACT;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { NavigationAction, type NavigationState, PartialRoute } from '@react-navigation/native';\nimport { IS_DOM } from 'expo/dom';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { store } from './router-store';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../domComponents/emitDomEvent';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { applyRedirects } from '../getRoutesRedirects';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady() {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport const routingQueue = {\n queue: [] as NavigationAction[],\n subscribers: new Set<() => void>(),\n subscribe(callback: () => void) {\n routingQueue.subscribers.add(callback);\n return () => {\n routingQueue.subscribers.delete(callback);\n };\n },\n snapshot() {\n return routingQueue.queue;\n },\n add(action: NavigationAction) {\n // Reset the identity of the queue.\n if (routingQueue.queue.length === 0) {\n routingQueue.queue = [];\n }\n\n routingQueue.queue.push(action);\n for (const callback of routingQueue.subscribers) {\n callback();\n }\n },\n run() {\n const queue = routingQueue.queue;\n if (queue.length === 0 || !store.navigationRef) {\n return;\n }\n\n routingQueue.queue = [];\n for (const action of queue) {\n store.navigationRef.dispatch(action);\n }\n },\n};\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload() {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function prefetch(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'PRELOAD' });\n}\n\nexport function push(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(count: number = 1) {\n if (emitDomDismiss(count)) {\n return;\n }\n\n routingQueue.add({ type: 'POP', payload: { count } });\n}\n\nexport function dismissTo(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll() {\n if (emitDomDismissAll()) {\n return;\n }\n routingQueue.add({ type: 'POP_TO_TOP' });\n}\n\nexport function goBack() {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady();\n routingQueue.add({ type: 'GO_BACK' });\n}\n\nexport function canGoBack(): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!store.navigationRef.isReady()) {\n return false;\n }\n return store.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = store.state;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n params: Record<string, undefined | string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady();\n return (store.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, remove all screen from the history that match the singular condition\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n};\n\nexport function linkTo(originalHref: Href, options: LinkToOptions = {}) {\n originalHref = typeof originalHref == 'string' ? originalHref : resolveHref(originalHref);\n let href: string | undefined | null = originalHref;\n\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady();\n const navigationRef = store.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!store.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, store.getRouteInfo(), options);\n href = applyRedirects(href, store.redirects);\n\n // If the href is undefined, it means that the redirect has already been handled the navigation\n if (!href) {\n return;\n }\n\n const state = store.linking.getStateFromPath!(href, store.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n routingQueue.add(\n getNavigateAction(\n state,\n rootState,\n options.event,\n options.withAnchor,\n options.dangerouslySingular\n )\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean,\n singular?: SingularOptions\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName &&\n // @ts-expect-error: TODO(@kitten): This isn't properly typed, so the index access fails\n actionStateRoute.params?.[dynamicName.name] !== stateRoute.params?.[dynamicName.name]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n if (type === 'PUSH' && navigationState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n } else if (type === 'REPLACE' && navigationState.type === 'drawer') {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,4BAEC;AAED,wBAGC;AAED,4BAEC;AAED,oBAEC;AAED,0BAMC;AAED,8BAEC;AAED,0BAEC;AAED,gCAKC;AAED,wBAMC;AAED,8BAeC;AAED,gCAmBC;AAED,8BAQC;AA0BD,wBA8DC;AA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expo/dom';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { store } from './router-store';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../domComponents/emitDomEvent';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { applyRedirects } from '../getRoutesRedirects';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady() {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport const routingQueue = {\n queue: [] as NavigationAction[],\n subscribers: new Set<() => void>(),\n subscribe(callback: () => void) {\n routingQueue.subscribers.add(callback);\n return () => {\n routingQueue.subscribers.delete(callback);\n };\n },\n snapshot() {\n return routingQueue.queue;\n },\n add(action: NavigationAction) {\n // Reset the identity of the queue.\n if (routingQueue.queue.length === 0) {\n routingQueue.queue = [];\n }\n\n routingQueue.queue.push(action);\n for (const callback of routingQueue.subscribers) {\n callback();\n }\n },\n run() {\n const queue = routingQueue.queue;\n if (queue.length === 0 || !store.navigationRef) {\n return;\n }\n\n routingQueue.queue = [];\n for (const action of queue) {\n store.navigationRef.dispatch(action);\n }\n },\n};\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload() {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function prefetch(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'PRELOAD' });\n}\n\nexport function push(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(count: number = 1) {\n if (emitDomDismiss(count)) {\n return;\n }\n\n routingQueue.add({ type: 'POP', payload: { count } });\n}\n\nexport function dismissTo(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll() {\n if (emitDomDismissAll()) {\n return;\n }\n routingQueue.add({ type: 'POP_TO_TOP' });\n}\n\nexport function goBack() {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady();\n routingQueue.add({ type: 'GO_BACK' });\n}\n\nexport function canGoBack(): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!store.navigationRef.isReady()) {\n return false;\n }\n return store.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = store.state;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n params: Record<string, undefined | string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady();\n return (store.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, remove all screen from the history that match the singular condition\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n\n __internal__PreviewKey?: string;\n};\n\nexport function linkTo(originalHref: Href, options: LinkToOptions = {}) {\n originalHref = typeof originalHref == 'string' ? originalHref : resolveHref(originalHref);\n let href: string | undefined | null = originalHref;\n\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady();\n const navigationRef = store.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!store.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, store.getRouteInfo(), options);\n href = applyRedirects(href, store.redirects);\n\n // If the href is undefined, it means that the redirect has already been handled the navigation\n if (!href) {\n return;\n }\n\n const state = store.linking.getStateFromPath!(href, store.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n routingQueue.add(\n getNavigateAction(\n state,\n rootState,\n options.event,\n options.withAnchor,\n options.dangerouslySingular,\n options.__internal__PreviewKey\n )\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean,\n singular?: SingularOptions,\n previewKey?: string\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName &&\n // @ts-expect-error: TODO(@kitten): This isn't properly typed, so the index access fails\n actionStateRoute.params?.[dynamicName.name] !== stateRoute.params?.[dynamicName.name]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n if (type === 'PUSH' && navigationState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n } else if (type === 'REPLACE' && navigationState.type === 'drawer') {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n previewKey,\n },\n };\n}\n"]}
@@ -6,6 +6,31 @@ export declare const StoreContext: import("react").Context<{
6
6
  getRouteInfo(): import("./routeInfo").UrlObject;
7
7
  readonly redirects: import("./router-store").StoreRedirects[];
8
8
  readonly rootComponent: import("react").ComponentType<any>;
9
+ getStateForHref(href: import("..").Href, options?: import("./routing").LinkToOptions): (Partial<Omit<Readonly<{
10
+ key: string;
11
+ index: number;
12
+ routeNames: string[];
13
+ history?: unknown[];
14
+ routes: import("@react-navigation/routers").NavigationRoute<import("@react-navigation/routers").ParamListBase, string>[];
15
+ type: string;
16
+ stale: false;
17
+ }>, "stale" | "routes">> & Readonly<{
18
+ stale?: true;
19
+ routes: import("@react-navigation/routers").PartialRoute<import("@react-navigation/routers").Route<string, object | undefined>>[];
20
+ }> & {
21
+ state?: Partial<Omit<Readonly<{
22
+ key: string;
23
+ index: number;
24
+ routeNames: string[];
25
+ history?: unknown[];
26
+ routes: import("@react-navigation/routers").NavigationRoute<import("@react-navigation/routers").ParamListBase, string>[];
27
+ type: string;
28
+ stale: false;
29
+ }>, "stale" | "routes">> & Readonly<{
30
+ stale?: true;
31
+ routes: import("@react-navigation/routers").PartialRoute<import("@react-navigation/routers").Route<string, object | undefined>>[];
32
+ }> & /*elided*/ any;
33
+ }) | undefined;
9
34
  readonly linking: import("../getLinkingConfig").ExpoLinkingOptions | undefined;
10
35
  setFocusedState(state: import("./router-store").FocusedRouteState): void;
11
36
  onReady(): void;
@@ -19,6 +44,31 @@ export declare const useExpoRouterStore: () => {
19
44
  getRouteInfo(): import("./routeInfo").UrlObject;
20
45
  readonly redirects: import("./router-store").StoreRedirects[];
21
46
  readonly rootComponent: import("react").ComponentType<any>;
47
+ getStateForHref(href: import("..").Href, options?: import("./routing").LinkToOptions): (Partial<Omit<Readonly<{
48
+ key: string;
49
+ index: number;
50
+ routeNames: string[];
51
+ history?: unknown[];
52
+ routes: import("@react-navigation/routers").NavigationRoute<import("@react-navigation/routers").ParamListBase, string>[];
53
+ type: string;
54
+ stale: false;
55
+ }>, "stale" | "routes">> & Readonly<{
56
+ stale?: true;
57
+ routes: import("@react-navigation/routers").PartialRoute<import("@react-navigation/routers").Route<string, object | undefined>>[];
58
+ }> & {
59
+ state?: Partial<Omit<Readonly<{
60
+ key: string;
61
+ index: number;
62
+ routeNames: string[];
63
+ history?: unknown[];
64
+ routes: import("@react-navigation/routers").NavigationRoute<import("@react-navigation/routers").ParamListBase, string>[];
65
+ type: string;
66
+ stale: false;
67
+ }>, "stale" | "routes">> & Readonly<{
68
+ stale?: true;
69
+ routes: import("@react-navigation/routers").PartialRoute<import("@react-navigation/routers").Route<string, object | undefined>>[];
70
+ }> & /*elided*/ any;
71
+ }) | undefined;
22
72
  readonly linking: import("../getLinkingConfig").ExpoLinkingOptions | undefined;
23
73
  setFocusedState(state: import("./router-store").FocusedRouteState): void;
24
74
  onReady(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"storeContext.d.ts","sourceRoot":"","sources":["../../src/global-state/storeContext.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY;;;;;;;;;;;;SAA0C,CAAC;AAEpE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;CAA2B,CAAC"}
1
+ {"version":3,"file":"storeContext.d.ts","sourceRoot":"","sources":["../../src/global-state/storeContext.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA0C,CAAC;AAEpE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA2B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAOA,OAAO,EAAS,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAU,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB;;;;;;;;GAIrC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,oGAEhC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,wGAExC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,KAAK,GAAG,KAAK,KAAK,aAAa,CAAC,SAAS,CAAC,CAAC;AAEzF;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;AAKjF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,OAAO,CAAC;AAEb;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,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MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,KAAK,GAAG,KAAK,KAAK,aAAa,CAAC,SAAS,CAAC,CAAC;AAEzF;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;AAKjF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,OAAO,CAAC;AAEb;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,SAAS,KAAK,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,KAAK,EACpB,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;AAKnC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,OAAO,CAAC;AAEb;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,SAAS,KAAK,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;AAElF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,SAAS,KAAK,EACpB,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;AAkCnC,wBAAgB,eAAe,CAAC,EAAE,MAAc,EAAE;;CAAK,GAAG,eAAe,CAsBxE"}
package/build/hooks.js CHANGED
@@ -22,6 +22,7 @@ const constants_1 = require("./constants");
22
22
  const router_store_1 = require("./global-state/router-store");
23
23
  Object.defineProperty(exports, "useRouteInfo", { enumerable: true, get: function () { return router_store_1.useRouteInfo; } });
24
24
  const imperative_api_1 = require("./imperative-api");
25
+ const PreviewRouteContext_1 = require("./link/preview/PreviewRouteContext");
25
26
  /**
26
27
  * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)
27
28
  * of the navigator which contains the current screen.
@@ -56,6 +57,32 @@ function useRootNavigation() {
56
57
  function useNavigationContainerRef() {
57
58
  return router_store_1.store.navigationRef;
58
59
  }
60
+ const displayWarningForProp = (prop) => {
61
+ if (process.env.NODE_ENV !== 'production') {
62
+ console.warn(`router.${prop} should not be used in a previewed screen. To fix this issue, wrap navigation calls with 'if (!isPreview) { ... }'.`);
63
+ }
64
+ };
65
+ const createNOOPWithWarning = (prop) => () => displayWarningForProp(prop);
66
+ const routerWithWarnings = {
67
+ back: createNOOPWithWarning('back'),
68
+ canGoBack: () => {
69
+ displayWarningForProp('canGoBack');
70
+ return false;
71
+ },
72
+ push: createNOOPWithWarning('push'),
73
+ navigate: createNOOPWithWarning('navigate'),
74
+ replace: createNOOPWithWarning('replace'),
75
+ dismiss: createNOOPWithWarning('dismiss'),
76
+ dismissTo: createNOOPWithWarning('dismissTo'),
77
+ dismissAll: createNOOPWithWarning('dismissAll'),
78
+ canDismiss: () => {
79
+ displayWarningForProp('canDismiss');
80
+ return false;
81
+ },
82
+ setParams: createNOOPWithWarning('setParams'),
83
+ reload: createNOOPWithWarning('reload'),
84
+ prefetch: createNOOPWithWarning('prefetch'),
85
+ };
59
86
  /**
60
87
  *
61
88
  * Returns the [Router](#router) object for imperative navigation.
@@ -75,6 +102,10 @@ function useNavigationContainerRef() {
75
102
  * ```
76
103
  */
77
104
  function useRouter() {
105
+ const { isPreview } = (0, PreviewRouteContext_1.usePreviewInfo)();
106
+ if (isPreview) {
107
+ return routerWithWarnings;
108
+ }
78
109
  return imperative_api_1.router;
79
110
  }
80
111
  /**
@@ -113,7 +144,8 @@ function useGlobalSearchParams() {
113
144
  }
114
145
  function useLocalSearchParams() {
115
146
  const params = react_1.default.use(Route_1.LocalRouteParamsContext) ?? {};
116
- return Object.fromEntries(Object.entries(params).map(([key, value]) => {
147
+ const { params: previewParams } = (0, PreviewRouteContext_1.usePreviewInfo)();
148
+ return Object.fromEntries(Object.entries(previewParams ?? params).map(([key, value]) => {
117
149
  // React Navigation doesn't remove "undefined" values from the params object, and you cannot remove them via
118
150
  // navigation.setParams as it shallow merges. Hence, we hide them here
119
151
  if (value === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AA4Bb,wDAIC;AAMD,8CAEC;AAMD,8DAEC;AAoBD,8BAEC;AAOD,sDAEC;AA2CD,kCAEC;AAmBD,kCAEC;AA4CD,sDAEC;AAyCD,oDA8BC;AAED,0CAsBC;AA5RD,qDAAyE;AACzE,kDAA0B;AAE1B,mCAAkD;AAClD,2CAAiD;AACjD,8DAAkE;AAIzD,6FAJO,2BAAY,OAIP;AAHrB,qDAAkD;AAKlD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,sBAAsB;IACpC,OAAO,IAAA,sBAAa,GAAyC;SAC1D,SAAS,CAAC,8BAAkB,CAAE;SAC9B,QAAQ,EAAE,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,oBAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,SAAgB,yBAAyB;IACvC,OAAO,oBAAK,CAAC,aAAa,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,SAAS;IACvB,OAAO,uBAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB;IACnC,OAAO,IAAA,2BAAY,GAAE,CAAC,mBAAmB,CAAC;AAC5C,CAAC;AA2CD,SAAgB,WAAW;IACzB,OAAO,IAAA,2BAAY,GAAE,CAAC,QAA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useNavigation } from '@react-navigation/native';\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { INTERNAL_SLOT_NAME } from './constants';\nimport { store, useRouteInfo } from './global-state/router-store';\nimport { router, Router } from './imperative-api';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\nexport { useRouteInfo };\n\n/**\n * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)\n * of the navigator which contains the current screen.\n *\n * @example\n * ```tsx\n * import { useRootNavigationState } from 'expo-router';\n *\n * export default function Route() {\n * const { routes } = useRootNavigationState();\n *\n * return <Text>{routes[0].name}</Text>;\n * }\n * ```\n */\nexport function useRootNavigationState() {\n return useNavigation<NavigationProp<object, never, string>>()\n .getParent(INTERNAL_SLOT_NAME)!\n .getState();\n}\n\n/**\n * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,\n * which returns a React `ref`.\n */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/**\n * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`\n * if the `<NavigationContainer />` hasn't mounted yet.\n */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\n/**\n *\n * Returns the [Router](#router) object for imperative navigation.\n *\n * @example\n *```tsx\n * import { useRouter } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n * const router = useRouter();\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport function useRouter(): Router {\n return router;\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname\n * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useRouteInfo().unstable_globalHref;\n}\n\n/**\n * Returns a list of selected file segments for the currently selected route. Segments are not normalized,\n * so they will be the same as the file path. For example, `/[id]?id=normal` becomes `[\"[id]\"]`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useSegments } from 'expo-router';\n *\n * export default function Route() {\n * // segments = [\"profile\", \"[user]\"]\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n *\n *\n * `useSegments` can be typed using an abstract. Consider the following file structure:\n *\n * ```md\n * - app\n * - [user]\n * - index.tsx\n * - followers.tsx\n * - settings.tsx\n * ```\n *\n *\n * This can be strictly typed using the following abstract with `useSegments` hook:\n *\n * ```tsx\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends Route = Route>(): RouteSegments<TSegments>;\n\n/**\n * @hidden\n */\nexport function useSegments<TSegments extends RouteSegments<Route>>(): TSegments;\nexport function useSegments() {\n return useRouteInfo().segments;\n}\n\n/**\n * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.\n * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { usePathname } from 'expo-router';\n *\n * export default function Route() {\n * // pathname = \"/profile/baconbrix\"\n * const pathname = usePathname();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns URL parameters for globally selected route, including dynamic path segments.\n * This function updates even when the route is not focused. Useful for analytics or\n * other background operations that don't draw to the screen.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * When querying search params in a stack, opt-towards using\n * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useGlobalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useGlobalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function useGlobalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useGlobalSearchParams() {\n return useRouteInfo().params;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen\n * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useLocalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useLocalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n */\nexport function useLocalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useLocalSearchParams() {\n const params = React.use(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n // React Navigation doesn't remove \"undefined\" values from the params object, and you cannot remove them via\n // navigation.setParams as it shallow merges. Hence, we hide them here\n if (value === undefined) {\n return [key, undefined];\n }\n\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as any;\n}\n\nexport function useSearchParams({ global = false } = {}): URLSearchParams {\n const globalRef = React.useRef(global);\n if (process.env.NODE_ENV !== 'production') {\n if (global !== globalRef.current) {\n console.warn(\n `Detected change in 'global' option of useSearchParams. This value cannot change between renders`\n );\n }\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const params = global ? useGlobalSearchParams() : useLocalSearchParams();\n const entries = Object.entries(params).flatMap(([key, value]) => {\n if (global) {\n if (key === 'params') return [];\n if (key === 'screen') return [];\n }\n\n return Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]];\n });\n\n return new ReadOnlyURLSearchParams(entries);\n}\n\nclass ReadOnlyURLSearchParams extends URLSearchParams {\n set() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n append() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n delete() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n}\n"]}
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AA6Bb,wDAIC;AAMD,8CAEC;AAMD,8DAEC;AAmDD,8BAMC;AAOD,sDAEC;AA2CD,kCAEC;AAmBD,kCAEC;AA4CD,sDAEC;AAyCD,oDA+BC;AAED,0CAsBC;AAjUD,qDAAyE;AACzE,kDAA0B;AAE1B,mCAAkD;AAClD,2CAAiD;AACjD,8DAAkE;AAKzD,6FALO,2BAAY,OAKP;AAJrB,qDAAkD;AAClD,4EAAoE;AAKpE;;;;;;;;;;;;;;GAcG;AACH,SAAgB,sBAAsB;IACpC,OAAO,IAAA,sBAAa,GAAyC;SAC1D,SAAS,CAAC,8BAAkB,CAAE;SAC9B,QAAQ,EAAE,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,oBAAK,CAAC,aAAa,CAA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;IAEH,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,uBAAwB,SAAQ,eAAe;IACnD,GAAG;QACD,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["'use client';\n\nimport { NavigationProp, useNavigation } from '@react-navigation/native';\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { INTERNAL_SLOT_NAME } from './constants';\nimport { store, useRouteInfo } from './global-state/router-store';\nimport { router, Router } from './imperative-api';\nimport { usePreviewInfo } from './link/preview/PreviewRouteContext';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\nexport { useRouteInfo };\n\n/**\n * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)\n * of the navigator which contains the current screen.\n *\n * @example\n * ```tsx\n * import { useRootNavigationState } from 'expo-router';\n *\n * export default function Route() {\n * const { routes } = useRootNavigationState();\n *\n * return <Text>{routes[0].name}</Text>;\n * }\n * ```\n */\nexport function useRootNavigationState() {\n return useNavigation<NavigationProp<object, never, string>>()\n .getParent(INTERNAL_SLOT_NAME)!\n .getState();\n}\n\n/**\n * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,\n * which returns a React `ref`.\n */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/**\n * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`\n * if the `<NavigationContainer />` hasn't mounted yet.\n */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\nconst displayWarningForProp = (prop: string) => {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `router.${prop} should not be used in a previewed screen. To fix this issue, wrap navigation calls with 'if (!isPreview) { ... }'.`\n );\n }\n};\n\nconst createNOOPWithWarning = (prop: string) => () => displayWarningForProp(prop);\n\nconst routerWithWarnings: Router = {\n back: createNOOPWithWarning('back'),\n canGoBack: () => {\n displayWarningForProp('canGoBack');\n return false;\n },\n push: createNOOPWithWarning('push'),\n navigate: createNOOPWithWarning('navigate'),\n replace: createNOOPWithWarning('replace'),\n dismiss: createNOOPWithWarning('dismiss'),\n dismissTo: createNOOPWithWarning('dismissTo'),\n dismissAll: createNOOPWithWarning('dismissAll'),\n canDismiss: () => {\n displayWarningForProp('canDismiss');\n return false;\n },\n setParams: createNOOPWithWarning('setParams'),\n reload: createNOOPWithWarning('reload'),\n prefetch: createNOOPWithWarning('prefetch'),\n};\n\n/**\n *\n * Returns the [Router](#router) object for imperative navigation.\n *\n * @example\n *```tsx\n * import { useRouter } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n * const router = useRouter();\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport function useRouter(): Router {\n const { isPreview } = usePreviewInfo();\n if (isPreview) {\n return routerWithWarnings;\n }\n return router;\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname\n * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useRouteInfo().unstable_globalHref;\n}\n\n/**\n * Returns a list of selected file segments for the currently selected route. Segments are not normalized,\n * so they will be the same as the file path. For example, `/[id]?id=normal` becomes `[\"[id]\"]`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useSegments } from 'expo-router';\n *\n * export default function Route() {\n * // segments = [\"profile\", \"[user]\"]\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n *\n *\n * `useSegments` can be typed using an abstract. Consider the following file structure:\n *\n * ```md\n * - app\n * - [user]\n * - index.tsx\n * - followers.tsx\n * - settings.tsx\n * ```\n *\n *\n * This can be strictly typed using the following abstract with `useSegments` hook:\n *\n * ```tsx\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends Route = Route>(): RouteSegments<TSegments>;\n\n/**\n * @hidden\n */\nexport function useSegments<TSegments extends RouteSegments<Route>>(): TSegments;\nexport function useSegments() {\n return useRouteInfo().segments;\n}\n\n/**\n * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.\n * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { usePathname } from 'expo-router';\n *\n * export default function Route() {\n * // pathname = \"/profile/baconbrix\"\n * const pathname = usePathname();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns URL parameters for globally selected route, including dynamic path segments.\n * This function updates even when the route is not focused. Useful for analytics or\n * other background operations that don't draw to the screen.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * When querying search params in a stack, opt-towards using\n * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useGlobalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useGlobalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function useGlobalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useGlobalSearchParams() {\n return useRouteInfo().params;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen\n * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useLocalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useLocalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n */\nexport function useLocalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useLocalSearchParams() {\n const params = React.use(LocalRouteParamsContext) ?? {};\n const { params: previewParams } = usePreviewInfo();\n return Object.fromEntries(\n Object.entries(previewParams ?? params).map(([key, value]) => {\n // React Navigation doesn't remove \"undefined\" values from the params object, and you cannot remove them via\n // navigation.setParams as it shallow merges. Hence, we hide them here\n if (value === undefined) {\n return [key, undefined];\n }\n\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as any;\n}\n\nexport function useSearchParams({ global = false } = {}): URLSearchParams {\n const globalRef = React.useRef(global);\n if (process.env.NODE_ENV !== 'production') {\n if (global !== globalRef.current) {\n console.warn(\n `Detected change in 'global' option of useSearchParams. This value cannot change between renders`\n );\n }\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const params = global ? useGlobalSearchParams() : useLocalSearchParams();\n const entries = Object.entries(params).flatMap(([key, value]) => {\n if (global) {\n if (key === 'params') return [];\n if (key === 'screen') return [];\n }\n\n return Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]];\n });\n\n return new ReadOnlyURLSearchParams(entries);\n}\n\nclass ReadOnlyURLSearchParams extends URLSearchParams {\n set() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n append() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n delete() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"StackClient.d.ts","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,aAAa,EAKb,WAAW,IAAI,aAAa,EAE5B,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAE7B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAM/C,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKU,CAAC;AAcxB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,cAAc,CAAC,OAAO,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAuN9F,CAAC;AA8DF,QAAA,MAAM,KAAK,WACD,cAAc,CAAC,OAAO,OAAO,CAAC;YAIV,CACxB,KAAK,EAAE,cAAc,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG;QAAE,QAA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