expo-router 5.0.2-preview.5 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/build/ExpoRoot.d.ts.map +1 -1
  2. package/build/ExpoRoot.js +19 -18
  3. package/build/ExpoRoot.js.map +1 -1
  4. package/build/constants.d.ts +2 -0
  5. package/build/constants.d.ts.map +1 -0
  6. package/build/constants.js +5 -0
  7. package/build/constants.js.map +1 -0
  8. package/build/{link/useDomComponentNavigation.d.ts → domComponents/emitDomEvent.d.ts} +2 -4
  9. package/build/domComponents/emitDomEvent.d.ts.map +1 -0
  10. package/build/domComponents/emitDomEvent.js +32 -0
  11. package/build/domComponents/emitDomEvent.js.map +1 -0
  12. package/build/domComponents/events.d.ts +6 -0
  13. package/build/domComponents/events.d.ts.map +1 -0
  14. package/build/domComponents/events.js +9 -0
  15. package/build/domComponents/events.js.map +1 -0
  16. package/build/domComponents/useDomComponentNavigation.d.ts +2 -0
  17. package/build/domComponents/useDomComponentNavigation.d.ts.map +1 -0
  18. package/build/domComponents/useDomComponentNavigation.js +37 -0
  19. package/build/domComponents/useDomComponentNavigation.js.map +1 -0
  20. package/build/fork/getStateFromPath.d.ts +1 -2
  21. package/build/fork/getStateFromPath.d.ts.map +1 -1
  22. package/build/fork/getStateFromPath.js +11 -5
  23. package/build/fork/getStateFromPath.js.map +1 -1
  24. package/build/getLinkingConfig.d.ts +6 -7
  25. package/build/getLinkingConfig.d.ts.map +1 -1
  26. package/build/getLinkingConfig.js +10 -9
  27. package/build/getLinkingConfig.js.map +1 -1
  28. package/build/getRoutesRedirects.d.ts +2 -0
  29. package/build/getRoutesRedirects.d.ts.map +1 -1
  30. package/build/getRoutesRedirects.js +56 -0
  31. package/build/getRoutesRedirects.js.map +1 -1
  32. package/build/global-state/routeInfo.d.ts +29 -4
  33. package/build/global-state/routeInfo.d.ts.map +1 -1
  34. package/build/global-state/routeInfo.js +124 -55
  35. package/build/global-state/routeInfo.js.map +1 -1
  36. package/build/global-state/router-store.d.ts +35 -83
  37. package/build/global-state/router-store.d.ts.map +1 -1
  38. package/build/global-state/router-store.js +138 -238
  39. package/build/global-state/router-store.js.map +1 -1
  40. package/build/global-state/routing.d.ts +13 -14
  41. package/build/global-state/routing.d.ts.map +1 -1
  42. package/build/global-state/routing.js +32 -30
  43. package/build/global-state/routing.js.map +1 -1
  44. package/build/global-state/storeContext.d.ts +29 -0
  45. package/build/global-state/storeContext.d.ts.map +1 -0
  46. package/build/global-state/storeContext.js +9 -0
  47. package/build/global-state/storeContext.js.map +1 -0
  48. package/build/hooks.d.ts +13 -4
  49. package/build/hooks.d.ts.map +1 -1
  50. package/build/hooks.js +13 -23
  51. package/build/hooks.js.map +1 -1
  52. package/build/imperative-api.d.ts.map +1 -1
  53. package/build/imperative-api.js +13 -13
  54. package/build/imperative-api.js.map +1 -1
  55. package/build/layouts/DrawerClient.d.ts +3 -2
  56. package/build/layouts/DrawerClient.d.ts.map +1 -1
  57. package/build/layouts/StackClient.d.ts +5 -2
  58. package/build/layouts/StackClient.d.ts.map +1 -1
  59. package/build/layouts/StackClient.js +2 -0
  60. package/build/layouts/StackClient.js.map +1 -1
  61. package/build/layouts/TabsClient.d.ts +3 -2
  62. package/build/layouts/TabsClient.d.ts.map +1 -1
  63. package/build/layouts/withLayoutContext.d.ts +6 -1
  64. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  65. package/build/layouts/withLayoutContext.js +28 -20
  66. package/build/layouts/withLayoutContext.js.map +1 -1
  67. package/build/link/linking.d.ts +2 -2
  68. package/build/link/linking.d.ts.map +1 -1
  69. package/build/link/linking.js +5 -4
  70. package/build/link/linking.js.map +1 -1
  71. package/build/link/useLinkToPathProps.d.ts.map +1 -1
  72. package/build/link/useLinkToPathProps.js +4 -5
  73. package/build/link/useLinkToPathProps.js.map +1 -1
  74. package/build/link/useLoadedNavigation.d.ts.map +1 -1
  75. package/build/link/useLoadedNavigation.js +2 -3
  76. package/build/link/useLoadedNavigation.js.map +1 -1
  77. package/build/primitives.d.ts.map +1 -1
  78. package/build/primitives.js +1 -0
  79. package/build/primitives.js.map +1 -1
  80. package/build/testing-library/index.d.ts +3 -3
  81. package/build/testing-library/index.d.ts.map +1 -1
  82. package/build/testing-library/index.js +5 -10
  83. package/build/testing-library/index.js.map +1 -1
  84. package/build/ui/common.d.ts.map +1 -1
  85. package/build/ui/common.js +4 -3
  86. package/build/ui/common.js.map +1 -1
  87. package/build/useNavigation.d.ts.map +1 -1
  88. package/build/useNavigation.js +47 -56
  89. package/build/useNavigation.js.map +1 -1
  90. package/build/useScreens.d.ts +2 -2
  91. package/build/useScreens.d.ts.map +1 -1
  92. package/build/useScreens.js +18 -3
  93. package/build/useScreens.js.map +1 -1
  94. package/build/views/Navigator.d.ts.map +1 -1
  95. package/build/views/Navigator.js +4 -4
  96. package/build/views/Navigator.js.map +1 -1
  97. package/build/views/Protected.d.ts +8 -0
  98. package/build/views/Protected.d.ts.map +1 -0
  99. package/build/views/Protected.js +11 -0
  100. package/build/views/Protected.js.map +1 -0
  101. package/build/views/Screen.d.ts +4 -0
  102. package/build/views/Screen.d.ts.map +1 -1
  103. package/build/views/Screen.js +52 -4
  104. package/build/views/Screen.js.map +1 -1
  105. package/build/views/Sitemap.js +5 -2
  106. package/build/views/Sitemap.js.map +1 -1
  107. package/package.json +3 -3
  108. package/build/link/useDomComponentNavigation.d.ts.map +0 -1
  109. package/build/link/useDomComponentNavigation.js +0 -68
  110. package/build/link/useDomComponentNavigation.js.map +0 -1
@@ -46,56 +46,57 @@ exports.canGoBack = canGoBack;
46
46
  exports.canDismiss = canDismiss;
47
47
  exports.setParams = setParams;
48
48
  exports.linkTo = linkTo;
49
- const native_1 = require("@react-navigation/native");
50
49
  const dom_1 = require("expo/dom");
51
50
  const Linking = __importStar(require("expo-linking"));
52
51
  const react_native_1 = require("react-native");
52
+ const router_store_1 = require("./router-store");
53
+ const emitDomEvent_1 = require("../domComponents/emitDomEvent");
54
+ const getRoutesRedirects_1 = require("../getRoutesRedirects");
53
55
  const href_1 = require("../link/href");
54
- const useDomComponentNavigation_1 = require("../link/useDomComponentNavigation");
55
56
  const matchers_1 = require("../matchers");
56
57
  const url_1 = require("../utils/url");
57
- function assertIsReady(store) {
58
- if (!store.navigationRef.isReady()) {
58
+ function assertIsReady() {
59
+ if (!router_store_1.store.navigationRef.isReady()) {
59
60
  throw new Error('Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.');
60
61
  }
61
62
  }
62
63
  function navigate(url, options) {
63
- return this.linkTo((0, href_1.resolveHref)(url), { ...options, event: 'NAVIGATE' });
64
+ return linkTo((0, href_1.resolveHref)(url), { ...options, event: 'NAVIGATE' });
64
65
  }
65
66
  function reload() {
66
67
  // TODO(EvanBacon): add `reload` support.
67
68
  throw new Error('The reload method is not implemented in the client-side router yet.');
68
69
  }
69
70
  function prefetch(href, options) {
70
- return linkTo.bind(this)((0, href_1.resolveHref)(href), { ...options, event: 'PRELOAD' });
71
+ return linkTo((0, href_1.resolveHref)(href), { ...options, event: 'PRELOAD' });
71
72
  }
72
73
  function push(url, options) {
73
- return this.linkTo((0, href_1.resolveHref)(url), { ...options, event: 'PUSH' });
74
+ return linkTo((0, href_1.resolveHref)(url), { ...options, event: 'PUSH' });
74
75
  }
75
- function dismiss(count) {
76
- if ((0, useDomComponentNavigation_1.emitDomDismiss)(count)) {
76
+ function dismiss(count = 1) {
77
+ if ((0, emitDomEvent_1.emitDomDismiss)(count)) {
77
78
  return;
78
79
  }
79
- this.navigationRef?.dispatch(native_1.StackActions.pop(count));
80
+ router_store_1.store.navigationRef?.dispatch({ type: 'POP', payload: { count } });
80
81
  }
81
82
  function dismissTo(href, options) {
82
- return this.linkTo((0, href_1.resolveHref)(href), { ...options, event: 'POP_TO' });
83
+ return linkTo((0, href_1.resolveHref)(href), { ...options, event: 'POP_TO' });
83
84
  }
84
85
  function replace(url, options) {
85
- return this.linkTo((0, href_1.resolveHref)(url), { ...options, event: 'REPLACE' });
86
+ return linkTo((0, href_1.resolveHref)(url), { ...options, event: 'REPLACE' });
86
87
  }
87
88
  function dismissAll() {
88
- if ((0, useDomComponentNavigation_1.emitDomDismissAll)()) {
89
+ if ((0, emitDomEvent_1.emitDomDismissAll)()) {
89
90
  return;
90
91
  }
91
- this.navigationRef?.dispatch(native_1.StackActions.popToTop());
92
+ router_store_1.store.navigationRef?.dispatch({ type: 'POP_TO_TOP' });
92
93
  }
93
94
  function goBack() {
94
- if ((0, useDomComponentNavigation_1.emitDomGoBack)()) {
95
+ if ((0, emitDomEvent_1.emitDomGoBack)()) {
95
96
  return;
96
97
  }
97
- assertIsReady(this);
98
- this.navigationRef?.current?.goBack();
98
+ assertIsReady();
99
+ router_store_1.store.navigationRef?.current?.goBack();
99
100
  }
100
101
  function canGoBack() {
101
102
  if (dom_1.IS_DOM) {
@@ -106,16 +107,16 @@ function canGoBack() {
106
107
  // before mounting a navigator. This behavior exists due to React Navigation being dynamically
107
108
  // constructed at runtime. We can get rid of this in the future if we use
108
109
  // the static configuration internally.
109
- if (!this.navigationRef.isReady()) {
110
+ if (!router_store_1.store.navigationRef.isReady()) {
110
111
  return false;
111
112
  }
112
- return this.navigationRef?.current?.canGoBack() ?? false;
113
+ return router_store_1.store.navigationRef?.current?.canGoBack() ?? false;
113
114
  }
114
115
  function canDismiss() {
115
116
  if (dom_1.IS_DOM) {
116
117
  throw new Error('canDismiss imperative method is not supported. Pass the property to the DOM component instead.');
117
118
  }
118
- let state = this.rootState;
119
+ let state = router_store_1.store.state;
119
120
  // Keep traversing down the state tree until we find a stack navigator that we can pop
120
121
  while (state) {
121
122
  if (state.type === 'stack' && state.routes.length > 1) {
@@ -128,15 +129,16 @@ function canDismiss() {
128
129
  return false;
129
130
  }
130
131
  function setParams(params = {}) {
131
- if ((0, useDomComponentNavigation_1.emitDomSetParams)(params)) {
132
+ if ((0, emitDomEvent_1.emitDomSetParams)(params)) {
132
133
  return;
133
134
  }
134
- assertIsReady(this);
135
- return (this.navigationRef?.current?.setParams)(params);
135
+ assertIsReady();
136
+ return (router_store_1.store.navigationRef?.current?.setParams)(params);
136
137
  }
137
138
  function linkTo(originalHref, options = {}) {
139
+ originalHref = typeof originalHref == 'string' ? originalHref : (0, href_1.resolveHref)(originalHref);
138
140
  let href = originalHref;
139
- if ((0, useDomComponentNavigation_1.emitDomLinkEvent)(href, options)) {
141
+ if ((0, emitDomEvent_1.emitDomLinkEvent)(href, options)) {
140
142
  return;
141
143
  }
142
144
  if ((0, url_1.shouldLinkExternally)(href)) {
@@ -146,12 +148,12 @@ function linkTo(originalHref, options = {}) {
146
148
  Linking.openURL(href);
147
149
  return;
148
150
  }
149
- assertIsReady(this);
150
- const navigationRef = this.navigationRef.current;
151
+ assertIsReady();
152
+ const navigationRef = router_store_1.store.navigationRef.current;
151
153
  if (navigationRef == null) {
152
154
  throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
153
155
  }
154
- if (!this.linking) {
156
+ if (!router_store_1.store.linking) {
155
157
  throw new Error('Attempted to link to route when no routes are present');
156
158
  }
157
159
  if (href === '..' || href === '../') {
@@ -159,13 +161,13 @@ function linkTo(originalHref, options = {}) {
159
161
  return;
160
162
  }
161
163
  const rootState = navigationRef.getRootState();
162
- href = (0, href_1.resolveHrefStringWithSegments)(href, this.routeInfo, options);
163
- href = this.applyRedirects(href);
164
+ href = (0, href_1.resolveHrefStringWithSegments)(href, router_store_1.store.getRouteInfo(), options);
165
+ href = (0, getRoutesRedirects_1.applyRedirects)(href, router_store_1.store.redirects);
164
166
  // If the href is undefined, it means that the redirect has already been handled the navigation
165
167
  if (!href) {
166
168
  return;
167
169
  }
168
- const state = this.linking.getStateFromPath(href, this.linking.config);
170
+ const state = router_store_1.store.linking.getStateFromPath(href, router_store_1.store.linking.config);
169
171
  if (!state || state.routes.length === 0) {
170
172
  console.error('Could not generate a valid navigation state for the given path: ' + href);
171
173
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"routing.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G;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,eAAe,CAAC,GAAG;QAC3B,OAAO,EAAE;YACP,wBAAwB;YACxB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,QAAQ;SACT;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StackActions, type NavigationState, PartialRoute } from '@react-navigation/native';\nimport { IS_DOM } from 'expo/dom';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { type RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../link/useDomComponentNavigation';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload(this: RouterStore) {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function prefetch(this: RouterStore, href: Href, options?: NavigationOptions) {\n return linkTo.bind(this)(resolveHref(href), { ...options, event: 'PRELOAD' });\n}\n\nexport function push(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n if (emitDomDismiss(count)) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function dismissTo(this: RouterStore, href: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n if (emitDomDismissAll()) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, undefined | string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, remove all screen from the history that match the singular condition\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n};\n\nexport function linkTo(this: RouterStore, originalHref: string, options: LinkToOptions = {}) {\n let href: string | undefined = originalHref;\n\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n href = this.applyRedirects(href);\n\n // If the href is undefined, it means that the redirect has already been handled the navigation\n if (!href) {\n return;\n }\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(\n state,\n rootState,\n options.event,\n options.withAnchor,\n options.dangerouslySingular\n )\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean,\n singular?: SingularOptions\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n // @ts-expect-error: TODO(@kitten): This isn't properly typed, so the index access fails\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n if (type === 'PUSH' && navigationState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n } else if (\n type === 'REPLACE' &&\n (navigationState.type === 'tab' || navigationState.type === 'drawer')\n ) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,4BAEC;AAED,wBAGC;AAED,4BAEC;AAED,oBAEC;AAED,0BAMC;AAED,8BAEC;AAED,0BAEC;AAED,gCAKC;AAED,wBAMC;AAED,8BAeC;AAED,gCAmBC;AAED,8BAQC;AAwBD,wBA6DC;AAjND,kCAAkC;AAClC,sDAAwC;AACxC,+CAAwC;AAExC,iDAAuC;AACvC,gEAMuC;AAEvC,8DAAuD;AACvD,uCAA0E;AAC1E,0CAA+C;AAG/C,sCAAoD;AAEpD,SAAS,aAAa;IACpB,IAAI,CAAC,oBAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;IACJ,CAAC;AACH,CAAC;AAID,SAAgB,QAAQ,CAAC,GAAS,EAAE,OAA2B;IAC7D,OAAO,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AACrE,CAAC;AAED,SAAgB,MAAM;IACpB,yCAAyC;IACzC,MAAM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AAU,CAAC;IACpB,CAAC;SAAM,IAAI,eAAe,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/C,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC;SAAM,IACL,IAAI,KAAK,SAAS;QAClB,CAAC,eAAe,CAAC,IAAI,KAAK,KAAK,IAAI,eAAe,CAAC,IAAI,KAAK,QAAQ,CAAC,EACrE,CAAC;QACD,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;gBAC1C,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;QACD;;;;;;;;WAQG;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,eAAe,CAAC,GAAG;QAC3B,OAAO,EAAE;YACP,wBAAwB;YACxB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,QAAQ;SACT;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { type NavigationState, PartialRoute } from '@react-navigation/native';\nimport { IS_DOM } from 'expo/dom';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { store } from './router-store';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../domComponents/emitDomEvent';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { applyRedirects } from '../getRoutesRedirects';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { SingularOptions } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady() {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload() {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function prefetch(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'PRELOAD' });\n}\n\nexport function push(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(count: number = 1) {\n if (emitDomDismiss(count)) {\n return;\n }\n\n store.navigationRef?.dispatch({ type: 'POP', payload: { count } });\n}\n\nexport function dismissTo(href: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(url: Href, options?: NavigationOptions) {\n return linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll() {\n if (emitDomDismissAll()) {\n return;\n }\n store.navigationRef?.dispatch({ type: 'POP_TO_TOP' });\n}\n\nexport function goBack() {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady();\n store.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!store.navigationRef.isReady()) {\n return false;\n }\n return store.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = store.state;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n params: Record<string, undefined | string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady();\n return (store.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n\n /**\n * When navigating in a Stack, remove all screen from the history that match the singular condition\n *\n * If used with `push`, the history will be filtered even if no navigation occurs.\n */\n dangerouslySingular?: SingularOptions;\n};\n\nexport function linkTo(originalHref: Href, options: LinkToOptions = {}) {\n originalHref = typeof originalHref == 'string' ? originalHref : resolveHref(originalHref);\n let href: string | undefined | null = originalHref;\n\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady();\n const navigationRef = store.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!store.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, store.getRouteInfo(), options);\n href = applyRedirects(href, store.redirects);\n\n // If the href is undefined, it means that the redirect has already been handled the navigation\n if (!href) {\n return;\n }\n\n const state = store.linking.getStateFromPath!(href, store.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(\n state,\n rootState,\n options.event,\n options.withAnchor,\n options.dangerouslySingular\n )\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean,\n singular?: SingularOptions\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n // @ts-expect-error: TODO(@kitten): This isn't properly typed, so the index access fails\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n if (type === 'PUSH' && navigationState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n } else if (\n type === 'REPLACE' &&\n (navigationState.type === 'tab' || navigationState.type === 'drawer')\n ) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n singular,\n },\n };\n}\n"]}
@@ -0,0 +1,29 @@
1
+ export declare const StoreContext: import("react").Context<{
2
+ shouldShowTutorial(): boolean;
3
+ readonly state: import("./router-store").ReactNavigationState | undefined;
4
+ readonly focusedState: import("@react-navigation/core/lib/typescript/src/NavigationFocusedRouteStateContext").FocusedRouteState | undefined;
5
+ readonly navigationRef: import("@react-navigation/core").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
6
+ readonly routeNode: import("../Route").RouteNode | null;
7
+ getRouteInfo(state?: import("./router-store").FocusedRouteState | import("./router-store").ReactNavigationState | undefined): import("./routeInfo").UrlObject;
8
+ readonly redirects: import("./router-store").StoreRedirects[];
9
+ readonly rootComponent: import("react").ComponentType<any>;
10
+ readonly linking: import("../getLinkingConfig").ExpoLinkingOptions | undefined;
11
+ setFocusedState(state: import("./router-store").FocusedRouteState): void;
12
+ onReady(): void;
13
+ assertIsReady(): void;
14
+ } | null>;
15
+ export declare const useExpoRouterStore: () => {
16
+ shouldShowTutorial(): boolean;
17
+ readonly state: import("./router-store").ReactNavigationState | undefined;
18
+ readonly focusedState: import("@react-navigation/core/lib/typescript/src/NavigationFocusedRouteStateContext").FocusedRouteState | undefined;
19
+ readonly navigationRef: import("@react-navigation/core").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
20
+ readonly routeNode: import("../Route").RouteNode | null;
21
+ getRouteInfo(state?: import("./router-store").FocusedRouteState | import("./router-store").ReactNavigationState | undefined): import("./routeInfo").UrlObject;
22
+ readonly redirects: import("./router-store").StoreRedirects[];
23
+ readonly rootComponent: import("react").ComponentType<any>;
24
+ readonly linking: import("../getLinkingConfig").ExpoLinkingOptions | undefined;
25
+ setFocusedState(state: import("./router-store").FocusedRouteState): void;
26
+ onReady(): void;
27
+ assertIsReady(): void;
28
+ };
29
+ //# sourceMappingURL=storeContext.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useExpoRouterStore = exports.StoreContext = void 0;
5
+ const react_1 = require("react");
6
+ exports.StoreContext = (0, react_1.createContext)(null);
7
+ const useExpoRouterStore = () => (0, react_1.use)(exports.StoreContext);
8
+ exports.useExpoRouterStore = useExpoRouterStore;
9
+ //# sourceMappingURL=storeContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storeContext.js","sourceRoot":"","sources":["../../src/global-state/storeContext.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AACb,iCAA2C;AAI9B,QAAA,YAAY,GAAG,IAAA,qBAAa,EAAqB,IAAI,CAAC,CAAC;AAE7D,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,IAAA,WAAG,EAAC,oBAAY,CAAE,CAAC;AAA9C,QAAA,kBAAkB,sBAA4B","sourcesContent":["'use client';\nimport { createContext, use } from 'react';\n\nimport { RouterStore } from './router-store';\n\nexport const StoreContext = createContext<RouterStore | null>(null);\n\nexport const useExpoRouterStore = () => use(StoreContext)!;\n"]}
package/build/hooks.d.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import { useRouteInfo } from './global-state/router-store';
1
2
  import { Router } from './imperative-api';
2
3
  import { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';
4
+ export { useRouteInfo };
3
5
  /**
4
6
  * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)
5
7
  * of the navigator which contains the current screen.
@@ -15,18 +17,25 @@ import { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types'
15
17
  * }
16
18
  * ```
17
19
  */
18
- export declare function useRootNavigationState(): any;
19
- export declare function useRouteInfo(): import("./LocationProvider").UrlObject;
20
+ export declare function useRootNavigationState(): Readonly<{
21
+ key: string;
22
+ index: number;
23
+ routeNames: string[];
24
+ history?: unknown[];
25
+ routes: import("@react-navigation/native").NavigationRoute<import("@react-navigation/native").ParamListBase, string>[];
26
+ type: string;
27
+ stale: false;
28
+ }>;
20
29
  /**
21
30
  * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,
22
31
  * which returns a React `ref`.
23
32
  */
24
- export declare function useRootNavigation(): import("@react-navigation/core").NavigationContainerRef<ReactNavigation.RootParamList> | null;
33
+ export declare function useRootNavigation(): import("@react-navigation/native").NavigationContainerRef<ReactNavigation.RootParamList> | null;
25
34
  /**
26
35
  * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`
27
36
  * if the `<NavigationContainer />` hasn't mounted yet.
28
37
  */
29
- export declare function useNavigationContainerRef(): import("@react-navigation/core").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
38
+ export declare function useNavigationContainerRef(): import("@react-navigation/native").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
30
39
  /**
31
40
  *
32
41
  * Returns the [Router](#router) object for imperative navigation.
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEjF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,QAErC;AAED,wBAAgB,YAAY,2CAE3B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,kGAEhC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,sGAExC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAkBlC;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,mBAA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8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useRouteInfo = void 0;
7
8
  exports.useRootNavigationState = useRootNavigationState;
8
- exports.useRouteInfo = useRouteInfo;
9
9
  exports.useRootNavigation = useRootNavigation;
10
10
  exports.useNavigationContainerRef = useNavigationContainerRef;
11
11
  exports.useRouter = useRouter;
@@ -15,9 +15,13 @@ exports.usePathname = usePathname;
15
15
  exports.useGlobalSearchParams = useGlobalSearchParams;
16
16
  exports.useLocalSearchParams = useLocalSearchParams;
17
17
  exports.useSearchParams = useSearchParams;
18
+ const native_1 = require("@react-navigation/native");
18
19
  const react_1 = __importDefault(require("react"));
19
20
  const Route_1 = require("./Route");
21
+ const constants_1 = require("./constants");
20
22
  const router_store_1 = require("./global-state/router-store");
23
+ Object.defineProperty(exports, "useRouteInfo", { enumerable: true, get: function () { return router_store_1.useRouteInfo; } });
24
+ const imperative_api_1 = require("./imperative-api");
21
25
  /**
22
26
  * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)
23
27
  * of the navigator which contains the current screen.
@@ -34,10 +38,9 @@ const router_store_1 = require("./global-state/router-store");
34
38
  * ```
35
39
  */
36
40
  function useRootNavigationState() {
37
- return (0, router_store_1.useStoreRootState)();
38
- }
39
- function useRouteInfo() {
40
- return (0, router_store_1.useStoreRouteInfo)();
41
+ return (0, native_1.useNavigation)()
42
+ .getParent(constants_1.INTERNAL_SLOT_NAME)
43
+ .getState();
41
44
  }
42
45
  /**
43
46
  * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,
@@ -72,20 +75,7 @@ function useNavigationContainerRef() {
72
75
  * ```
73
76
  */
74
77
  function useRouter() {
75
- return react_1.default.useMemo(() => ({
76
- back: router_store_1.store.goBack,
77
- canDismiss: router_store_1.store.canDismiss,
78
- canGoBack: router_store_1.store.canGoBack,
79
- dismiss: router_store_1.store.dismiss,
80
- dismissAll: router_store_1.store.dismissAll,
81
- dismissTo: router_store_1.store.dismissTo,
82
- navigate: router_store_1.store.navigate,
83
- prefetch: router_store_1.store.prefetch,
84
- push: router_store_1.store.push,
85
- reload: router_store_1.store.reload,
86
- replace: router_store_1.store.replace,
87
- setParams: router_store_1.store.setParams,
88
- }), []);
78
+ return imperative_api_1.router;
89
79
  }
90
80
  /**
91
81
  * @private
@@ -93,10 +83,10 @@ function useRouter() {
93
83
  * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.
94
84
  */
95
85
  function useUnstableGlobalHref() {
96
- return (0, router_store_1.useStoreRouteInfo)().unstable_globalHref;
86
+ return (0, router_store_1.useRouteInfo)().unstable_globalHref;
97
87
  }
98
88
  function useSegments() {
99
- return (0, router_store_1.useStoreRouteInfo)().segments;
89
+ return (0, router_store_1.useRouteInfo)().segments;
100
90
  }
101
91
  /**
102
92
  * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.
@@ -116,10 +106,10 @@ function useSegments() {
116
106
  * ```
117
107
  */
118
108
  function usePathname() {
119
- return (0, router_store_1.useStoreRouteInfo)().pathname;
109
+ return (0, router_store_1.useRouteInfo)().pathname;
120
110
  }
121
111
  function useGlobalSearchParams() {
122
- return (0, router_store_1.useStoreRouteInfo)().params;
112
+ return (0, router_store_1.useRouteInfo)().params;
123
113
  }
124
114
  function useLocalSearchParams() {
125
115
  const params = react_1.default.useContext(Route_1.LocalRouteParamsContext) ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAwBb,wDAEC;AAED,oCAEC;AAMD,8CAEC;AAMD,8DAEC;AAoBD,8BAkBC;AAOD,sDAEC;AA2CD,kCAEC;AAmBD,kCAEC;AA4CD,sDAEC;AAyCD,oDAwBC;AAED,0CAsBC;AApSD,kDAA0B;AAE1B,mCAAkD;AAClD,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IACH,CAAC;IAED,sDAAsD;IACtD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;IACzE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC9D,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,GAAG,KAAK,QAAQ;gBAAE,OAAO,EAAE,CAAC;YAChC,IAAI,GAAG,KAAK,QAAQ;gBAAE,OAAO,EAAE,CAAC;QAClC,CAAC;QAED,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,uBAAwB,SAAQ,eAAe;IACnD,GAAG;QACD,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './imperative-api';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\n/**\n * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)\n * of the navigator which contains the current screen.\n *\n * @example\n * ```tsx\n * import { useRootNavigationState } from 'expo-router';\n *\n * export default function Route() {\n * const { routes } = useRootNavigationState();\n *\n * return <Text>{routes[0].name}</Text>;\n * }\n * ```\n */\nexport function useRootNavigationState() {\n return useStoreRootState();\n}\n\nexport function useRouteInfo() {\n return useStoreRouteInfo();\n}\n\n/**\n * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,\n * which returns a React `ref`.\n */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/**\n * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`\n * if the `<NavigationContainer />` hasn't mounted yet.\n */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\n/**\n *\n * Returns the [Router](#router) object for imperative navigation.\n *\n * @example\n *```tsx\n * import { useRouter } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n * const router = useRouter();\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport function useRouter(): Router {\n return React.useMemo(\n () => ({\n back: store.goBack,\n canDismiss: store.canDismiss,\n canGoBack: store.canGoBack,\n dismiss: store.dismiss,\n dismissAll: store.dismissAll,\n dismissTo: store.dismissTo,\n navigate: store.navigate,\n prefetch: store.prefetch,\n push: store.push,\n reload: store.reload,\n replace: store.replace,\n setParams: store.setParams as Router['setParams'],\n }),\n []\n );\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname\n * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useStoreRouteInfo().unstable_globalHref;\n}\n\n/**\n * Returns a list of selected file segments for the currently selected route. Segments are not normalized,\n * so they will be the same as the file path. For example, `/[id]?id=normal` becomes `[\"[id]\"]`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useSegments } from 'expo-router';\n *\n * export default function Route() {\n * // segments = [\"profile\", \"[user]\"]\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n *\n *\n * `useSegments` can be typed using an abstract. Consider the following file structure:\n *\n * ```md\n * - app\n * - [user]\n * - index.tsx\n * - followers.tsx\n * - settings.tsx\n * ```\n *\n *\n * This can be strictly typed using the following abstract with `useSegments` hook:\n *\n * ```tsx\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends Route = Route>(): RouteSegments<TSegments>;\n\n/**\n * @hidden\n */\nexport function useSegments<TSegments extends RouteSegments<Route>>(): TSegments;\nexport function useSegments() {\n return useStoreRouteInfo().segments;\n}\n\n/**\n * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.\n * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { usePathname } from 'expo-router';\n *\n * export default function Route() {\n * // pathname = \"/profile/baconbrix\"\n * const pathname = usePathname();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useStoreRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns URL parameters for globally selected route, including dynamic path segments.\n * This function updates even when the route is not focused. Useful for analytics or\n * other background operations that don't draw to the screen.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * When querying search params in a stack, opt-towards using\n * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useGlobalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useGlobalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function useGlobalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useGlobalSearchParams() {\n return useStoreRouteInfo().params;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen\n * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useLocalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useLocalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n */\nexport function useLocalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useLocalSearchParams() {\n const params = React.useContext(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as any;\n}\n\nexport function useSearchParams({ global = false } = {}): URLSearchParams {\n const globalRef = React.useRef(global);\n if (process.env.NODE_ENV !== 'production') {\n if (global !== globalRef.current) {\n console.warn(\n `Detected change in 'global' option of useSearchParams. This value cannot change between renders`\n );\n }\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const params = global ? useGlobalSearchParams() : useLocalSearchParams();\n const entries = Object.entries(params).flatMap(([key, value]) => {\n if (global) {\n if (key === 'params') return [];\n if (key === 'screen') return [];\n }\n\n return Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]];\n });\n\n return new ReadOnlyURLSearchParams(entries);\n}\n\nclass ReadOnlyURLSearchParams extends URLSearchParams {\n set() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n append() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n delete() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n}\n"]}
1
+ {"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,oDAwBC;AAED,0CAsBC;AAtRD,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,CAA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","sourcesContent":["'use client';\n\nimport { NavigationProp, useNavigation } from '@react-navigation/native';\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { INTERNAL_SLOT_NAME } from './constants';\nimport { store, useRouteInfo } from './global-state/router-store';\nimport { router, Router } from './imperative-api';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\nexport { useRouteInfo };\n\n/**\n * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)\n * of the navigator which contains the current screen.\n *\n * @example\n * ```tsx\n * import { useRootNavigationState } from 'expo-router';\n *\n * export default function Route() {\n * const { routes } = useRootNavigationState();\n *\n * return <Text>{routes[0].name}</Text>;\n * }\n * ```\n */\nexport function useRootNavigationState() {\n return useNavigation<NavigationProp<object, never, string>>()\n .getParent(INTERNAL_SLOT_NAME)!\n .getState();\n}\n\n/**\n * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,\n * which returns a React `ref`.\n */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/**\n * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`\n * if the `<NavigationContainer />` hasn't mounted yet.\n */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\n/**\n *\n * Returns the [Router](#router) object for imperative navigation.\n *\n * @example\n *```tsx\n * import { useRouter } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n * const router = useRouter();\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport function useRouter(): Router {\n return router;\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname\n * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useRouteInfo().unstable_globalHref;\n}\n\n/**\n * Returns a list of selected file segments for the currently selected route. Segments are not normalized,\n * so they will be the same as the file path. For example, `/[id]?id=normal` becomes `[\"[id]\"]`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useSegments } from 'expo-router';\n *\n * export default function Route() {\n * // segments = [\"profile\", \"[user]\"]\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n *\n *\n * `useSegments` can be typed using an abstract. Consider the following file structure:\n *\n * ```md\n * - app\n * - [user]\n * - index.tsx\n * - followers.tsx\n * - settings.tsx\n * ```\n *\n *\n * This can be strictly typed using the following abstract with `useSegments` hook:\n *\n * ```tsx\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends Route = Route>(): RouteSegments<TSegments>;\n\n/**\n * @hidden\n */\nexport function useSegments<TSegments extends RouteSegments<Route>>(): TSegments;\nexport function useSegments() {\n return useRouteInfo().segments;\n}\n\n/**\n * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.\n * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { usePathname } from 'expo-router';\n *\n * export default function Route() {\n * // pathname = \"/profile/baconbrix\"\n * const pathname = usePathname();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns URL parameters for globally selected route, including dynamic path segments.\n * This function updates even when the route is not focused. Useful for analytics or\n * other background operations that don't draw to the screen.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * When querying search params in a stack, opt-towards using\n * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useGlobalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useGlobalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function useGlobalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useGlobalSearchParams() {\n return useRouteInfo().params;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen\n * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useLocalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useLocalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n */\nexport function useLocalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useLocalSearchParams() {\n const params = React.useContext(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as any;\n}\n\nexport function useSearchParams({ global = false } = {}): URLSearchParams {\n const globalRef = React.useRef(global);\n if (process.env.NODE_ENV !== 'production') {\n if (global !== globalRef.current) {\n console.warn(\n `Detected change in 'global' option of useSearchParams. This value cannot change between renders`\n );\n }\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const params = global ? useGlobalSearchParams() : useLocalSearchParams();\n const entries = Object.entries(params).flatMap(([key, value]) => {\n if (global) {\n if (key === 'params') return [];\n if (key === 'screen') return [];\n }\n\n return Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]];\n });\n\n return new ReadOnlyURLSearchParams(entries);\n}\n\nclass ReadOnlyURLSearchParams extends URLSearchParams {\n set() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n append() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n delete() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"imperative-api.d.ts","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAExD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB;;OAEG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;OAEG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB;;OAEG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACxD;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5D;;;;;;SAMK;IACL,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,E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K;IACL,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC3D;;;;OAIG;IACH,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;OAEG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7D;;;OAGG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB;;;;OAIG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B;;OAEG;IACH,SAAS,EAAE,CAAC,CAAC,SAAS,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC3E;;;OAGG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,MAapB,CAAC"}
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.router = void 0;
4
- const router_store_1 = require("./global-state/router-store");
4
+ const routing_1 = require("./global-state/routing");
5
5
  /**
6
6
  * @hidden
7
7
  */
8
8
  exports.router = {
9
- navigate: (href, options) => router_store_1.store.navigate(href, options),
10
- push: (href, options) => router_store_1.store.push(href, options),
11
- dismiss: (count) => router_store_1.store.dismiss(count),
12
- dismissAll: () => router_store_1.store.dismissAll(),
13
- dismissTo: (href, options) => router_store_1.store.dismissTo(href, options),
14
- canDismiss: () => router_store_1.store.canDismiss(),
15
- replace: (href, options) => router_store_1.store.replace(href, options),
16
- back: () => router_store_1.store.goBack(),
17
- canGoBack: () => router_store_1.store.canGoBack(),
18
- setParams: (params) => router_store_1.store.setParams(params),
19
- reload: () => router_store_1.store.reload(),
20
- prefetch: (name) => router_store_1.store.prefetch(name),
9
+ navigate: routing_1.navigate,
10
+ push: routing_1.push,
11
+ dismiss: routing_1.dismiss,
12
+ dismissAll: routing_1.dismissAll,
13
+ dismissTo: routing_1.dismissTo,
14
+ canDismiss: routing_1.canDismiss,
15
+ replace: routing_1.replace,
16
+ back: () => (0, routing_1.goBack)(),
17
+ canGoBack: routing_1.canGoBack,
18
+ reload: routing_1.reload,
19
+ prefetch: routing_1.prefetch,
20
+ setParams: routing_1.setParams,
21
21
  };
22
22
  //# sourceMappingURL=imperative-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"imperative-api.js","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":";;;AAAA,8DAAoD;AAiFpD;;GAEG;AACU,QAAA,MAAM,GAAW;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAC1D,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC;IAClD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IACxC,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC;IAC5D,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;IACxD,IAAI,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,SAAS,EAAE;IAClC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAK,CAAC,SAAS,CAAC,MAA6B,CAAC;IACrE,MAAM,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,MAAM,EAAE;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;CACzC,CAAC","sourcesContent":["import { store } from './global-state/router-store';\nimport { NavigationOptions } from './global-state/routing';\nimport { Href, Route, RouteInputParams } from './types';\n\n/**\n * Returns `router` object for imperative navigation API.\n *\n * @example\n *```tsx\n * import { router } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport type Router = {\n /**\n * Goes back in the navigation history.\n */\n back: () => void;\n /**\n * Navigates to a route in the navigator's history if it supports invoking the `back` function.\n */\n canGoBack: () => boolean;\n /**\n * Navigates to the provided [`href`](#href) using a push operation if possible.\n */\n push: (href: Href, options?: NavigationOptions) => void;\n /**\n * Navigates to the provided [`href`](#href).\n */\n navigate: (href: Href, options?: NavigationOptions) => void;\n /**\n * Navigates to route without appending to the history. Can be used with\n * [`useFocusEffect`](#usefocuseffecteffect-do_not_pass_a_second_prop)\n * to redirect imperatively to a new screen.\n *\n * @see [Using `useRouter()` hook](/router/reference/redirects/) to redirect.\n * */\n replace: (href: Href, options?: NavigationOptions) => void;\n /**\n * Navigates to the a stack lower than the current screen using the provided count if possible, otherwise 1.\n *\n * If the current screen is the only route, it will dismiss the entire stack.\n */\n dismiss: (count?: number) => void;\n /**\n * Dismisses screens until the provided href is reached. If the href is not found, it will instead replace the current screen with the provided `href`.\n */\n dismissTo: (href: Href, options?: NavigationOptions) => void;\n /**\n * Returns to the first screen in the closest stack. This is similar to\n * [`popToTop`](https://reactnavigation.org/docs/stack-actions/#poptotop) stack action.\n */\n dismissAll: () => void;\n /**\n * Checks if it is possible to dismiss the current screen. Returns `true` if the\n * router is within the stack with more than one screen in stack's history.\n *\n */\n canDismiss: () => boolean;\n /**\n * Updates the current route's query params.\n */\n setParams: <T extends Route>(params: Partial<RouteInputParams<T>>) => void;\n /**\n * Reloads the currently mounted route in experimental server mode. This can be used to re-fetch data.\n * @hidden\n */\n reload: () => void;\n /**\n * Prefetch a screen in the background before navigating to it\n */\n prefetch: (name: Href) => void;\n};\n\n/**\n * @hidden\n */\nexport const router: Router = {\n navigate: (href, options) => store.navigate(href, options),\n push: (href, options) => store.push(href, options),\n dismiss: (count) => store.dismiss(count),\n dismissAll: () => store.dismissAll(),\n dismissTo: (href, options) => store.dismissTo(href, options),\n canDismiss: () => store.canDismiss(),\n replace: (href, options) => store.replace(href, options),\n back: () => store.goBack(),\n canGoBack: () => store.canGoBack(),\n setParams: (params) => store.setParams(params as Record<string, any>),\n reload: () => store.reload(),\n prefetch: (name) => store.prefetch(name),\n};\n"]}
1
+ {"version":3,"file":"imperative-api.js","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":";;;AAAA,oDAcgC;AAgFhC;;GAEG;AACU,QAAA,MAAM,GAAW;IAC5B,QAAQ,EAAR,kBAAQ;IACR,IAAI,EAAJ,cAAI;IACJ,OAAO,EAAP,iBAAO;IACP,UAAU,EAAV,oBAAU;IACV,SAAS,EAAT,mBAAS;IACT,UAAU,EAAV,oBAAU;IACV,OAAO,EAAP,iBAAO;IACP,IAAI,EAAE,GAAG,EAAE,CAAC,IAAA,gBAAM,GAAE;IACpB,SAAS,EAAT,mBAAS;IACT,MAAM,EAAN,gBAAM;IACN,QAAQ,EAAR,kBAAQ;IACR,SAAS,EAAE,mBAAgC;CAC5C,CAAC","sourcesContent":["import {\n canDismiss,\n canGoBack,\n dismiss,\n dismissAll,\n dismissTo,\n goBack,\n navigate,\n NavigationOptions,\n prefetch,\n push,\n reload,\n replace,\n setParams,\n} from './global-state/routing';\nimport { Href, Route, RouteInputParams } from './types';\n\n/**\n * Returns `router` object for imperative navigation API.\n *\n * @example\n *```tsx\n * import { router } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport type Router = {\n /**\n * Goes back in the navigation history.\n */\n back: () => void;\n /**\n * Navigates to a route in the navigator's history if it supports invoking the `back` function.\n */\n canGoBack: () => boolean;\n /**\n * Navigates to the provided [`href`](#href) using a push operation if possible.\n */\n push: (href: Href, options?: NavigationOptions) => void;\n /**\n * Navigates to the provided [`href`](#href).\n */\n navigate: (href: Href, options?: NavigationOptions) => void;\n /**\n * Navigates to route without appending to the history. Can be used with\n * [`useFocusEffect`](#usefocuseffecteffect-do_not_pass_a_second_prop)\n * to redirect imperatively to a new screen.\n *\n * @see [Using `useRouter()` hook](/router/reference/redirects/) to redirect.\n * */\n replace: (href: Href, options?: NavigationOptions) => void;\n /**\n * Navigates to the a stack lower than the current screen using the provided count if possible, otherwise 1.\n *\n * If the current screen is the only route, it will dismiss the entire stack.\n */\n dismiss: (count?: number) => void;\n /**\n * Dismisses screens until the provided href is reached. If the href is not found, it will instead replace the current screen with the provided `href`.\n */\n dismissTo: (href: Href, options?: NavigationOptions) => void;\n /**\n * Returns to the first screen in the closest stack. This is similar to\n * [`popToTop`](https://reactnavigation.org/docs/stack-actions/#poptotop) stack action.\n */\n dismissAll: () => void;\n /**\n * Checks if it is possible to dismiss the current screen. Returns `true` if the\n * router is within the stack with more than one screen in stack's history.\n *\n */\n canDismiss: () => boolean;\n /**\n * Updates the current route's query params.\n */\n setParams: <T extends Route>(params: Partial<RouteInputParams<T>>) => void;\n /**\n * Reloads the currently mounted route in experimental server mode. This can be used to re-fetch data.\n * @hidden\n */\n reload: () => void;\n /**\n * Prefetch a screen in the background before navigating to it\n */\n prefetch: (name: Href) => void;\n};\n\n/**\n * @hidden\n */\nexport const router: Router = {\n navigate,\n push,\n dismiss,\n dismissAll,\n dismissTo,\n canDismiss,\n replace,\n back: () => goBack(),\n canGoBack,\n reload,\n prefetch,\n setParams: setParams as Router['setParams'],\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  import { DrawerNavigationOptions, DrawerNavigationEventMap } from '@react-navigation/drawer';
2
2
  import { DrawerNavigationState, ParamListBase } from '@react-navigation/native';
3
- export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
3
+ export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
4
4
  children: React.ReactNode;
5
5
  layout?: ((props: {
6
6
  state: DrawerNavigationState<ParamListBase>;
@@ -53,7 +53,7 @@ export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit
53
53
  }>>(original: import("@react-navigation/native").Router<DrawerNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<DrawerNavigationState<ParamListBase>, Action>>) | undefined;
54
54
  } & {
55
55
  id?: undefined;
56
- }, "children"> & Partial<Pick<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
56
+ }, "children"> & Partial<Pick<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
57
57
  children: React.ReactNode;
58
58
  layout?: ((props: {
59
59
  state: DrawerNavigationState<ParamListBase>;
@@ -108,6 +108,7 @@ export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit
108
108
  id?: undefined;
109
109
  }, "children">> & import("react").RefAttributes<unknown>> & {
110
110
  Screen: (props: import("..").ScreenProps<DrawerNavigationOptions, DrawerNavigationState<ParamListBase>, DrawerNavigationEventMap>) => null;
111
+ Protected: typeof import("../views/Protected").Protected;
111
112
  };
112
113
  export default Drawer;
113
114
  //# sourceMappingURL=DrawerClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerClient.d.ts","sourceRoot":"","sources":["../../src/layouts/DrawerClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMhF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKD,CAAC;AAEnB,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"DrawerClient.d.ts","sourceRoot":"","sources":["../../src/layouts/DrawerClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMhF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKD,CAAC;AAEnB,eAAe,MAAM,CAAC"}