expo-router 56.2.0 → 56.2.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 (154) hide show
  1. package/android/build.gradle +2 -2
  2. package/build/ExpoRoot.d.ts.map +1 -1
  3. package/build/ExpoRoot.js +7 -1
  4. package/build/ExpoRoot.js.map +1 -1
  5. package/build/getRoutesCore.d.ts.map +1 -1
  6. package/build/getRoutesCore.js +27 -17
  7. package/build/getRoutesCore.js.map +1 -1
  8. package/build/global-state/store.d.ts.map +1 -1
  9. package/build/global-state/store.js +1 -2
  10. package/build/global-state/store.js.map +1 -1
  11. package/build/hooks/index.d.ts +14 -0
  12. package/build/hooks/index.d.ts.map +1 -0
  13. package/build/hooks/index.js +30 -0
  14. package/build/hooks/index.js.map +1 -0
  15. package/build/hooks/useCurrentRouteInfo.d.ts +7 -0
  16. package/build/hooks/useCurrentRouteInfo.d.ts.map +1 -0
  17. package/build/hooks/useCurrentRouteInfo.js +18 -0
  18. package/build/hooks/useCurrentRouteInfo.js.map +1 -0
  19. package/build/hooks/useGlobalSearchParams.d.ts +37 -0
  20. package/build/hooks/useGlobalSearchParams.d.ts.map +1 -0
  21. package/build/hooks/useGlobalSearchParams.js +9 -0
  22. package/build/hooks/useGlobalSearchParams.js.map +1 -0
  23. package/build/hooks/useLoaderData.d.ts +23 -0
  24. package/build/hooks/useLoaderData.d.ts.map +1 -0
  25. package/build/hooks/useLoaderData.js +70 -0
  26. package/build/hooks/useLoaderData.js.map +1 -0
  27. package/build/hooks/useLocalSearchParams.d.ts +34 -0
  28. package/build/hooks/useLocalSearchParams.d.ts.map +1 -0
  29. package/build/hooks/useLocalSearchParams.js +44 -0
  30. package/build/hooks/useLocalSearchParams.js.map +1 -0
  31. package/build/hooks/useNavigationContainerRef.d.ts +6 -0
  32. package/build/hooks/useNavigationContainerRef.d.ts.map +1 -0
  33. package/build/hooks/useNavigationContainerRef.js +13 -0
  34. package/build/hooks/useNavigationContainerRef.js.map +1 -0
  35. package/build/hooks/usePathname.d.ts +19 -0
  36. package/build/hooks/usePathname.d.ts.map +1 -0
  37. package/build/hooks/usePathname.js +26 -0
  38. package/build/hooks/usePathname.js.map +1 -0
  39. package/build/hooks/useRootNavigation.d.ts +6 -0
  40. package/build/hooks/useRootNavigation.d.ts.map +1 -0
  41. package/build/hooks/useRootNavigation.js +13 -0
  42. package/build/hooks/useRootNavigation.js.map +1 -0
  43. package/build/hooks/useRootNavigationState.d.ts +18 -0
  44. package/build/hooks/useRootNavigationState.d.ts.map +1 -0
  45. package/build/hooks/useRootNavigationState.js +32 -0
  46. package/build/hooks/useRootNavigationState.js.map +1 -0
  47. package/build/hooks/useRouter.d.ts +21 -0
  48. package/build/hooks/useRouter.d.ts.map +1 -0
  49. package/build/hooks/useRouter.js +58 -0
  50. package/build/hooks/useRouter.js.map +1 -0
  51. package/build/hooks/useSearchParams.d.ts +4 -0
  52. package/build/hooks/useSearchParams.d.ts.map +1 -0
  53. package/build/hooks/useSearchParams.js +43 -0
  54. package/build/hooks/useSearchParams.js.map +1 -0
  55. package/build/hooks/useSegments.d.ts +42 -0
  56. package/build/hooks/useSegments.d.ts.map +1 -0
  57. package/build/hooks/useSegments.js +9 -0
  58. package/build/hooks/useSegments.js.map +1 -0
  59. package/build/hooks/useUnstableGlobalHref.d.ts +7 -0
  60. package/build/hooks/useUnstableGlobalHref.d.ts.map +1 -0
  61. package/build/hooks/useUnstableGlobalHref.js +14 -0
  62. package/build/hooks/useUnstableGlobalHref.js.map +1 -0
  63. package/build/internal/routing.d.ts +1 -1
  64. package/build/internal/routing.d.ts.map +1 -1
  65. package/build/internal/routing.js +2 -1
  66. package/build/internal/routing.js.map +1 -1
  67. package/build/internal/rsc.d.ts +1 -1
  68. package/build/internal/rsc.d.ts.map +1 -1
  69. package/build/internal/rsc.js +2 -1
  70. package/build/internal/rsc.js.map +1 -1
  71. package/build/layouts/stack-utils/StackTitle.d.ts.map +1 -1
  72. package/build/layouts/stack-utils/StackTitle.js +3 -1
  73. package/build/layouts/stack-utils/StackTitle.js.map +1 -1
  74. package/build/loaders/LoaderCache.d.ts +5 -0
  75. package/build/loaders/LoaderCache.d.ts.map +1 -1
  76. package/build/loaders/LoaderCache.js +32 -0
  77. package/build/loaders/LoaderCache.js.map +1 -1
  78. package/build/native-tabs/NativeTabsView.shared.d.ts +2 -2
  79. package/build/native-tabs/NativeTabsView.shared.d.ts.map +1 -1
  80. package/build/native-tabs/common/elements.d.ts +40 -2
  81. package/build/native-tabs/common/elements.d.ts.map +1 -1
  82. package/build/native-tabs/common/elements.js +3 -0
  83. package/build/native-tabs/common/elements.js.map +1 -1
  84. package/build/native-tabs/utils/materialIconConverter.android.d.ts +2 -2
  85. package/build/native-tabs/utils/materialIconConverter.android.d.ts.map +1 -1
  86. package/build/native-tabs/utils/materialIconConverter.android.js.map +1 -1
  87. package/build/native-tabs/utils/materialIconConverter.d.ts +2 -2
  88. package/build/native-tabs/utils/materialIconConverter.d.ts.map +1 -1
  89. package/build/native-tabs/utils/materialIconConverter.js.map +1 -1
  90. package/build/native-tabs/utils/optionsIconConverter.android.d.ts.map +1 -1
  91. package/build/native-tabs/utils/optionsIconConverter.android.js +22 -3
  92. package/build/native-tabs/utils/optionsIconConverter.android.js.map +1 -1
  93. package/build/rsc/router/client.d.ts.map +1 -1
  94. package/build/rsc/router/client.js +11 -3
  95. package/build/rsc/router/client.js.map +1 -1
  96. package/build/rsc/router/common.d.ts +1 -1
  97. package/build/rsc/router/common.d.ts.map +1 -1
  98. package/build/rsc/router/common.js +4 -12
  99. package/build/rsc/router/common.js.map +1 -1
  100. package/build/rsc/router/host.d.ts.map +1 -1
  101. package/build/rsc/router/host.js +2 -3
  102. package/build/rsc/router/host.js.map +1 -1
  103. package/build/rsc/router/idMinting.d.ts +31 -0
  104. package/build/rsc/router/idMinting.d.ts.map +1 -0
  105. package/build/rsc/router/idMinting.js +32 -0
  106. package/build/rsc/router/idMinting.js.map +1 -0
  107. package/build/ts-declarations/expo-router-internal-globals.d.ts +11 -1
  108. package/build/ts-declarations/expo-router-internal-globals.d.ts.map +1 -1
  109. package/build/ts-declarations/expo-router-internal-globals.js.map +1 -1
  110. package/build/useScreens.d.ts.map +1 -1
  111. package/build/useScreens.js +3 -2
  112. package/build/useScreens.js.map +1 -1
  113. package/expo-module.config.json +1 -1
  114. package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0.module → 56.2.2/expo.modules.router-56.2.2.module} +7 -7
  115. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.2/expo.modules.router-56.2.2.module.md5 +1 -0
  116. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.2/expo.modules.router-56.2.2.module.sha1 +1 -0
  117. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.2/expo.modules.router-56.2.2.module.sha256 +1 -0
  118. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.2/expo.modules.router-56.2.2.module.sha512 +1 -0
  119. package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0.pom → 56.2.2/expo.modules.router-56.2.2.pom} +1 -1
  120. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.2/expo.modules.router-56.2.2.pom.md5 +1 -0
  121. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.2/expo.modules.router-56.2.2.pom.sha1 +1 -0
  122. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.2/expo.modules.router-56.2.2.pom.sha256 +1 -0
  123. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.2/expo.modules.router-56.2.2.pom.sha512 +1 -0
  124. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml +4 -4
  125. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.md5 +1 -1
  126. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.sha1 +1 -1
  127. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.sha256 +1 -1
  128. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.sha512 +1 -1
  129. package/package.json +15 -15
  130. package/plugin/tsconfig.tsbuildinfo +1 -0
  131. package/vendor/react-helmet-async/lib/index.esm.js +1 -1
  132. package/vendor/react-helmet-async/lib/index.js +1 -1
  133. package/build/hooks.d.ts +0 -212
  134. package/build/hooks.d.ts.map +0 -1
  135. package/build/hooks.js +0 -313
  136. package/build/hooks.js.map +0 -1
  137. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.0/expo.modules.router-56.2.0.module.md5 +0 -1
  138. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.0/expo.modules.router-56.2.0.module.sha1 +0 -1
  139. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.0/expo.modules.router-56.2.0.module.sha256 +0 -1
  140. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.0/expo.modules.router-56.2.0.module.sha512 +0 -1
  141. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.0/expo.modules.router-56.2.0.pom.md5 +0 -1
  142. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.0/expo.modules.router-56.2.0.pom.sha1 +0 -1
  143. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.0/expo.modules.router-56.2.0.pom.sha256 +0 -1
  144. package/local-maven-repo/expo/modules/router/expo.modules.router/56.2.0/expo.modules.router-56.2.0.pom.sha512 +0 -1
  145. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0-sources.jar → 56.2.2/expo.modules.router-56.2.2-sources.jar} +0 -0
  146. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0-sources.jar.md5 → 56.2.2/expo.modules.router-56.2.2-sources.jar.md5} +0 -0
  147. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0-sources.jar.sha1 → 56.2.2/expo.modules.router-56.2.2-sources.jar.sha1} +0 -0
  148. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0-sources.jar.sha256 → 56.2.2/expo.modules.router-56.2.2-sources.jar.sha256} +0 -0
  149. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0-sources.jar.sha512 → 56.2.2/expo.modules.router-56.2.2-sources.jar.sha512} +0 -0
  150. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0.aar → 56.2.2/expo.modules.router-56.2.2.aar} +0 -0
  151. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0.aar.md5 → 56.2.2/expo.modules.router-56.2.2.aar.md5} +0 -0
  152. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0.aar.sha1 → 56.2.2/expo.modules.router-56.2.2.aar.sha1} +0 -0
  153. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0.aar.sha256 → 56.2.2/expo.modules.router-56.2.2.aar.sha256} +0 -0
  154. /package/local-maven-repo/expo/modules/router/expo.modules.router/{56.2.0/expo.modules.router-56.2.0.aar.sha512 → 56.2.2/expo.modules.router-56.2.2.aar.sha512} +0 -0
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns route info for a screen it is called from.
3
+ *
4
+ * @experimental
5
+ */
6
+ export declare function useCurrentRouteInfo(): import("../global-state/getRouteInfoFromState").UrlObject | undefined;
7
+ //# sourceMappingURL=useCurrentRouteInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentRouteInfo.d.ts","sourceRoot":"","sources":["../../src/hooks/useCurrentRouteInfo.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,mBAAmB,0EAIlC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useCurrentRouteInfo = useCurrentRouteInfo;
5
+ const react_1 = require("react");
6
+ const routeInfoCache_1 = require("../global-state/routeInfoCache");
7
+ const native_1 = require("../react-navigation/native");
8
+ /**
9
+ * Returns route info for a screen it is called from.
10
+ *
11
+ * @experimental
12
+ */
13
+ function useCurrentRouteInfo() {
14
+ const state = (0, native_1.useStateForPath)();
15
+ const routeInfo = (0, react_1.useMemo)(() => (state ? (0, routeInfoCache_1.getCachedRouteInfo)(state) : undefined), [state]);
16
+ return routeInfo;
17
+ }
18
+ //# sourceMappingURL=useCurrentRouteInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentRouteInfo.js","sourceRoot":"","sources":["../../src/hooks/useCurrentRouteInfo.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAYb,kDAIC;AAdD,iCAAgC;AAEhC,mEAAoE;AACpE,uDAA6D;AAE7D;;;;GAIG;AACH,SAAgB,mBAAmB;IACjC,MAAM,KAAK,GAAG,IAAA,wBAAe,GAAE,CAAC;IAChC,MAAM,SAAS,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,mCAAkB,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1F,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { getCachedRouteInfo } from '../global-state/routeInfoCache';\nimport { useStateForPath } from '../react-navigation/native';\n\n/**\n * Returns route info for a screen it is called from.\n *\n * @experimental\n */\nexport function useCurrentRouteInfo() {\n const state = useStateForPath();\n const routeInfo = useMemo(() => (state ? getCachedRouteInfo(state) : undefined), [state]);\n return routeInfo;\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import type { RouteParams, RoutePath, UnknownOutputParams } from '../types';
2
+ /**
3
+ * @hidden
4
+ */
5
+ export declare function useGlobalSearchParams<TParams extends UnknownOutputParams = UnknownOutputParams>(): TParams;
6
+ /**
7
+ * @hidden
8
+ */
9
+ export declare function useGlobalSearchParams<TRoute extends RoutePath>(): RouteParams<TRoute>;
10
+ /**
11
+ * Returns URL parameters for globally selected route, including dynamic path segments.
12
+ * This function updates even when the route is not focused. Useful for analytics or
13
+ * other background operations that don't draw to the screen.
14
+ *
15
+ * Route URL example: `acme://profile/baconbrix?extra=info`.
16
+ *
17
+ * When querying search params in a stack, opt-towards using
18
+ * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.
19
+ *
20
+ * > **Note:** For usage information, see
21
+ * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).
22
+ *
23
+ * @example
24
+ * ```tsx app/profile/[user].tsx
25
+ * import { Text } from 'react-native';
26
+ * import { useGlobalSearchParams } from 'expo-router';
27
+ *
28
+ * export default function Route() {
29
+ * // user=baconbrix & extra=info
30
+ * const { user, extra } = useGlobalSearchParams();
31
+ *
32
+ * return <Text>User: {user}</Text>;
33
+ * }
34
+ * ```
35
+ */
36
+ export declare function useGlobalSearchParams<TRoute extends RoutePath, TParams extends UnknownOutputParams = UnknownOutputParams>(): RouteParams<TRoute> & TParams;
37
+ //# sourceMappingURL=useGlobalSearchParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGlobalSearchParams.d.ts","sourceRoot":"","sources":["../../src/hooks/useGlobalSearchParams.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE5E;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,OAAO,CAAC;AAEb;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,SAAS,SAAS,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,SAAS,EACxB,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useGlobalSearchParams = useGlobalSearchParams;
5
+ const useRouteInfo_1 = require("../global-state/useRouteInfo");
6
+ function useGlobalSearchParams() {
7
+ return (0, useRouteInfo_1.useRouteInfo)().params;
8
+ }
9
+ //# sourceMappingURL=useGlobalSearchParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGlobalSearchParams.js","sourceRoot":"","sources":["../../src/hooks/useGlobalSearchParams.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AA+Cb,sDAEC;AA/CD,+DAA4D;AA6C5D,SAAgB,qBAAqB;IACnC,OAAO,IAAA,2BAAY,GAAE,CAAC,MAAM,CAAC;AAC/B,CAAC","sourcesContent":["'use client';\n\nimport { useRouteInfo } from '../global-state/useRouteInfo';\nimport type { RouteParams, RoutePath, UnknownOutputParams } from '../types';\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 RoutePath>(): 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 RoutePath,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useGlobalSearchParams() {\n return useRouteInfo().params;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { LoaderFunction } from 'expo-server';
2
+ type LoaderFunctionResult<T extends LoaderFunction<any>> = T extends LoaderFunction<infer R> ? R : unknown;
3
+ /**
4
+ * Returns the result of the `loader` function for the calling route.
5
+ *
6
+ * @example
7
+ * ```tsx app/profile/[user].tsx
8
+ * import { Text } from 'react-native';
9
+ * import { useLoaderData } from 'expo-router';
10
+ *
11
+ * export function loader() {
12
+ * return Promise.resolve({ foo: 'bar' }};
13
+ * }
14
+ *
15
+ * export default function Route() {
16
+ * const data = useLoaderData<typeof loader>(); // { foo: 'bar' }
17
+ *
18
+ * return <Text>Data: {JSON.stringify(data)}</Text>;
19
+ * }
20
+ */
21
+ export declare function useLoaderData<T extends LoaderFunction<any> = any>(): LoaderFunctionResult<T>;
22
+ export {};
23
+ //# sourceMappingURL=useLoaderData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLoaderData.d.ts","sourceRoot":"","sources":["../../src/hooks/useLoaderData.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAYlD,KAAK,oBAAoB,CAAC,CAAC,SAAS,cAAc,CAAC,GAAG,CAAC,IACrD,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,cAAc,CAAC,GAAG,CAAC,GAAG,GAAG,KAAK,oBAAoB,CAAC,CAAC,CAAC,CA8C5F"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useLoaderData = useLoaderData;
5
+ const react_1 = require("react");
6
+ const Route_1 = require("../Route");
7
+ const getRouteInfoFromState_1 = require("../global-state/getRouteInfoFromState");
8
+ const LoaderCache_1 = require("../loaders/LoaderCache");
9
+ const ServerDataLoaderContext_1 = require("../loaders/ServerDataLoaderContext");
10
+ const getLoaderData_1 = require("../loaders/getLoaderData");
11
+ const utils_1 = require("../loaders/utils");
12
+ const native_1 = require("../react-navigation/native");
13
+ const useScreens_1 = require("../useScreens");
14
+ /**
15
+ * Returns the result of the `loader` function for the calling route.
16
+ *
17
+ * @example
18
+ * ```tsx app/profile/[user].tsx
19
+ * import { Text } from 'react-native';
20
+ * import { useLoaderData } from 'expo-router';
21
+ *
22
+ * export function loader() {
23
+ * return Promise.resolve({ foo: 'bar' }};
24
+ * }
25
+ *
26
+ * export default function Route() {
27
+ * const data = useLoaderData<typeof loader>(); // { foo: 'bar' }
28
+ *
29
+ * return <Text>Data: {JSON.stringify(data)}</Text>;
30
+ * }
31
+ */
32
+ function useLoaderData() {
33
+ const serverDataLoaderContext = (0, react_1.use)(ServerDataLoaderContext_1.ServerDataLoaderContext);
34
+ const loaderCache = (0, react_1.use)(LoaderCache_1.LoaderCacheContext);
35
+ // Subscribe before any early returns so a later `loader-invalidate` re-renders this hook even
36
+ // when the initial render was satisfied by `ServerDataLoaderContext` or `__EXPO_ROUTER_LOADER_DATA__`.
37
+ // Returning early before subscribing would also change hook order on the next render once
38
+ // invalidation deletes the injected global.
39
+ (0, react_1.useSyncExternalStore)(loaderCache.subscribe, loaderCache.getSnapshot, loaderCache.getSnapshot);
40
+ const stateForPath = (0, native_1.useStateForPath)();
41
+ const contextKey = (0, Route_1.useContextKey)();
42
+ const resolvedPath = (0, react_1.useMemo)(() => {
43
+ const routeInfo = (0, getRouteInfoFromState_1.getRouteInfoFromState)(stateForPath);
44
+ const contextPath = contextKey.startsWith('/') ? contextKey.slice(1) : contextKey;
45
+ const resolvedPathname = `/${(0, useScreens_1.getSingularId)(contextPath, { params: routeInfo.params })}`;
46
+ const searchString = routeInfo.searchParams?.toString() || '';
47
+ return searchString ? `${resolvedPathname}?${searchString}` : resolvedPathname;
48
+ }, [contextKey, stateForPath]);
49
+ // First invocation of this hook will happen server-side, so we look up the loaded data from context
50
+ if (serverDataLoaderContext) {
51
+ return serverDataLoaderContext[resolvedPath];
52
+ }
53
+ // The second invocation happens after the client has hydrated on initial load, so we look up the data injected
54
+ // by `<PreloadedDataScript />` using `globalThis.__EXPO_ROUTER_LOADER_DATA__`
55
+ if (typeof window !== 'undefined' && globalThis.__EXPO_ROUTER_LOADER_DATA__) {
56
+ if (globalThis.__EXPO_ROUTER_LOADER_DATA__[resolvedPath]) {
57
+ return globalThis.__EXPO_ROUTER_LOADER_DATA__[resolvedPath];
58
+ }
59
+ }
60
+ const result = (0, getLoaderData_1.getLoaderData)({
61
+ resolvedPath,
62
+ cache: loaderCache,
63
+ fetcher: utils_1.fetchLoader,
64
+ });
65
+ if (result instanceof Promise) {
66
+ return (0, react_1.use)(result);
67
+ }
68
+ return result;
69
+ }
70
+ //# sourceMappingURL=useLoaderData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLoaderData.js","sourceRoot":"","sources":["../../src/hooks/useLoaderData.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAmCb,sCA8CC;AA9ED,iCAA2D;AAE3D,oCAAyC;AACzC,iFAA8E;AAC9E,wDAA4D;AAC5D,gFAA6E;AAC7E,4DAAyD;AACzD,4CAA+C;AAC/C,uDAA6D;AAC7D,8CAA8C;AAK9C;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,aAAa;IAC3B,MAAM,uBAAuB,GAAG,IAAA,WAAG,EAAC,iDAAuB,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,IAAA,WAAG,EAAC,gCAAkB,CAAC,CAAC;IAE5C,8FAA8F;IAC9F,uGAAuG;IACvG,0FAA0F;IAC1F,4CAA4C;IAC5C,IAAA,4BAAoB,EAAC,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAE9F,MAAM,YAAY,GAAG,IAAA,wBAAe,GAAE,CAAC;IACvC,MAAM,UAAU,GAAG,IAAA,qBAAa,GAAE,CAAC;IAEnC,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,MAAM,SAAS,GAAG,IAAA,6CAAqB,EAAC,YAAY,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QAClF,MAAM,gBAAgB,GAAG,IAAI,IAAA,0BAAa,EAAC,WAAW,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;QACxF,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAE9D,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,gBAAgB,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACjF,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;IAE/B,oGAAoG;IACpG,IAAI,uBAAuB,EAAE,CAAC;QAC5B,OAAO,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,+GAA+G;IAC/G,8EAA8E;IAC9E,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,UAAU,CAAC,2BAA2B,EAAE,CAAC;QAC5E,IAAI,UAAU,CAAC,2BAA2B,CAAC,YAAY,CAAC,EAAE,CAAC;YACzD,OAAO,UAAU,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,6BAAa,EAA0B;QACpD,YAAY;QACZ,KAAK,EAAE,WAAW;QAClB,OAAO,EAAE,mBAAW;KACrB,CAAC,CAAC;IAEH,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;QAC9B,OAAO,IAAA,WAAG,EAAC,MAAM,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["'use client';\n\nimport type { LoaderFunction } from 'expo-server';\nimport { use, useMemo, useSyncExternalStore } from 'react';\n\nimport { useContextKey } from '../Route';\nimport { getRouteInfoFromState } from '../global-state/getRouteInfoFromState';\nimport { LoaderCacheContext } from '../loaders/LoaderCache';\nimport { ServerDataLoaderContext } from '../loaders/ServerDataLoaderContext';\nimport { getLoaderData } from '../loaders/getLoaderData';\nimport { fetchLoader } from '../loaders/utils';\nimport { useStateForPath } from '../react-navigation/native';\nimport { getSingularId } from '../useScreens';\n\ntype LoaderFunctionResult<T extends LoaderFunction<any>> =\n T extends LoaderFunction<infer R> ? R : unknown;\n\n/**\n * Returns the result of the `loader` function for the calling route.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useLoaderData } from 'expo-router';\n *\n * export function loader() {\n * return Promise.resolve({ foo: 'bar' }};\n * }\n *\n * export default function Route() {\n * const data = useLoaderData<typeof loader>(); // { foo: 'bar' }\n *\n * return <Text>Data: {JSON.stringify(data)}</Text>;\n * }\n */\nexport function useLoaderData<T extends LoaderFunction<any> = any>(): LoaderFunctionResult<T> {\n const serverDataLoaderContext = use(ServerDataLoaderContext);\n const loaderCache = use(LoaderCacheContext);\n\n // Subscribe before any early returns so a later `loader-invalidate` re-renders this hook even\n // when the initial render was satisfied by `ServerDataLoaderContext` or `__EXPO_ROUTER_LOADER_DATA__`.\n // Returning early before subscribing would also change hook order on the next render once\n // invalidation deletes the injected global.\n useSyncExternalStore(loaderCache.subscribe, loaderCache.getSnapshot, loaderCache.getSnapshot);\n\n const stateForPath = useStateForPath();\n const contextKey = useContextKey();\n\n const resolvedPath = useMemo(() => {\n const routeInfo = getRouteInfoFromState(stateForPath);\n const contextPath = contextKey.startsWith('/') ? contextKey.slice(1) : contextKey;\n const resolvedPathname = `/${getSingularId(contextPath, { params: routeInfo.params })}`;\n const searchString = routeInfo.searchParams?.toString() || '';\n\n return searchString ? `${resolvedPathname}?${searchString}` : resolvedPathname;\n }, [contextKey, stateForPath]);\n\n // First invocation of this hook will happen server-side, so we look up the loaded data from context\n if (serverDataLoaderContext) {\n return serverDataLoaderContext[resolvedPath];\n }\n\n // The second invocation happens after the client has hydrated on initial load, so we look up the data injected\n // by `<PreloadedDataScript />` using `globalThis.__EXPO_ROUTER_LOADER_DATA__`\n if (typeof window !== 'undefined' && globalThis.__EXPO_ROUTER_LOADER_DATA__) {\n if (globalThis.__EXPO_ROUTER_LOADER_DATA__[resolvedPath]) {\n return globalThis.__EXPO_ROUTER_LOADER_DATA__[resolvedPath];\n }\n }\n\n const result = getLoaderData<LoaderFunctionResult<T>>({\n resolvedPath,\n cache: loaderCache,\n fetcher: fetchLoader,\n });\n\n if (result instanceof Promise) {\n return use(result);\n }\n\n return result;\n}\n"]}
@@ -0,0 +1,34 @@
1
+ import type { RouteParams, RoutePath, UnknownOutputParams } from '../types';
2
+ /**
3
+ * @hidden
4
+ */
5
+ export declare function useLocalSearchParams<TParams extends UnknownOutputParams = UnknownOutputParams>(): TParams;
6
+ /**
7
+ * @hidden
8
+ */
9
+ export declare function useLocalSearchParams<TRoute extends RoutePath>(): RouteParams<TRoute>;
10
+ /**
11
+ * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen
12
+ * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.
13
+ *
14
+ * Route URL example: `acme://profile/baconbrix?extra=info`.
15
+ *
16
+ * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).
17
+ *
18
+ * > **Note:** For usage information, see
19
+ * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).
20
+ *
21
+ * @example
22
+ * ```tsx app/profile/[user].tsx
23
+ * import { Text } from 'react-native';
24
+ * import { useLocalSearchParams } from 'expo-router';
25
+ *
26
+ * export default function Route() {
27
+ * // user=baconbrix & extra=info
28
+ * const { user, extra } = useLocalSearchParams();
29
+ *
30
+ * return <Text>User: {user}</Text>;
31
+ * }
32
+ */
33
+ export declare function useLocalSearchParams<TRoute extends RoutePath, TParams extends UnknownOutputParams = UnknownOutputParams>(): RouteParams<TRoute> & TParams;
34
+ //# sourceMappingURL=useLocalSearchParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocalSearchParams.d.ts","sourceRoot":"","sources":["../../src/hooks/useLocalSearchParams.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE5E;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,OAAO,CAAC;AAEb;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,SAAS,SAAS,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,SAAS,SAAS,EACxB,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,KACtD,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useLocalSearchParams = useLocalSearchParams;
8
+ const react_1 = __importDefault(require("react"));
9
+ const Route_1 = require("../Route");
10
+ const PreviewRouteContext_1 = require("../link/preview/PreviewRouteContext");
11
+ function useLocalSearchParams() {
12
+ const params = react_1.default.use(Route_1.LocalRouteParamsContext) ?? {};
13
+ const { params: previewParams } = (0, PreviewRouteContext_1.usePreviewInfo)();
14
+ return Object.fromEntries(Object.entries(previewParams ?? params).map(([key, value]) => {
15
+ // React Navigation doesn't remove `undefined` values from the params object, and you cannot remove them via
16
+ // `navigation.setParams()` as it shallow merges. Hence, we hide them here. We also pass `null` through unchanged
17
+ // for the same reason; running it through `decodeURIComponent()` would otherwise stringify it to `null`.
18
+ if (value == null) {
19
+ return [key, value];
20
+ }
21
+ if (Array.isArray(value)) {
22
+ return [
23
+ key,
24
+ value.map((v) => {
25
+ try {
26
+ return decodeURIComponent(v);
27
+ }
28
+ catch {
29
+ return v;
30
+ }
31
+ }),
32
+ ];
33
+ }
34
+ else {
35
+ try {
36
+ return [key, decodeURIComponent(value)];
37
+ }
38
+ catch {
39
+ return [key, value];
40
+ }
41
+ }
42
+ }));
43
+ }
44
+ //# sourceMappingURL=useLocalSearchParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocalSearchParams.js","sourceRoot":"","sources":["../../src/hooks/useLocalSearchParams.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AA+Cb,oDAgCC;AA7ED,kDAA0B;AAE1B,oCAAmD;AACnD,6EAAqE;AA0CrE,SAAgB,oBAAoB;IAClC,MAAM,MAAM,GAAG,eAAK,CAAC,GAAG,CAAC,+BAAuB,CAAC,IAAI,EAAE,CAAC;IACxD,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,oCAAc,GAAE,CAAC;IACnD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,aAAa,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC3D,4GAA4G;QAC5G,iHAAiH;QACjH,yGAAyG;QACzG,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtB,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO;gBACL,GAAG;gBACH,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACd,IAAI,CAAC;wBACH,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;oBAC/B,CAAC;oBAAC,MAAM,CAAC;wBACP,OAAO,CAAC,CAAC;oBACX,CAAC;gBACH,CAAC,CAAC;aACH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAe,CAAC,CAAC,CAAC;YACpD,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CACI,CAAC;AACX,CAAC","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from '../Route';\nimport { usePreviewInfo } from '../link/preview/PreviewRouteContext';\nimport type { RouteParams, RoutePath, UnknownOutputParams } from '../types';\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 RoutePath>(): 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 RoutePath,\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. We also pass `null` through unchanged\n // for the same reason; running it through `decodeURIComponent()` would otherwise stringify it to `null`.\n if (value == null) {\n return [key, value];\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"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`
3
+ * if the `<NavigationContainer />` hasn't mounted yet.
4
+ */
5
+ export declare function useNavigationContainerRef(): import("../react-navigation").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
6
+ //# sourceMappingURL=useNavigationContainerRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNavigationContainerRef.d.ts","sourceRoot":"","sources":["../../src/hooks/useNavigationContainerRef.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,yBAAyB,mGAExC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useNavigationContainerRef = useNavigationContainerRef;
5
+ const store_1 = require("../global-state/store");
6
+ /**
7
+ * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`
8
+ * if the `<NavigationContainer />` hasn't mounted yet.
9
+ */
10
+ function useNavigationContainerRef() {
11
+ return store_1.store.navigationRef;
12
+ }
13
+ //# sourceMappingURL=useNavigationContainerRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNavigationContainerRef.js","sourceRoot":"","sources":["../../src/hooks/useNavigationContainerRef.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAQb,8DAEC;AARD,iDAA8C;AAE9C;;;GAGG;AACH,SAAgB,yBAAyB;IACvC,OAAO,aAAK,CAAC,aAAa,CAAC;AAC7B,CAAC","sourcesContent":["'use client';\n\nimport { store } from '../global-state/store';\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"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.
3
+ * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.
4
+ *
5
+ * @example
6
+ * ```tsx app/profile/[user].tsx
7
+ * import { Text } from 'react-native';
8
+ * import { usePathname } from 'expo-router';
9
+ *
10
+ * export default function Route() {
11
+ * // pathname = "/profile/baconbrix"
12
+ * const pathname = usePathname();
13
+ *
14
+ * return <Text>Pathname: {pathname}</Text>;
15
+ * }
16
+ * ```
17
+ */
18
+ export declare function usePathname(): string;
19
+ //# sourceMappingURL=usePathname.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePathname.d.ts","sourceRoot":"","sources":["../../src/hooks/usePathname.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.usePathname = usePathname;
5
+ const useRouteInfo_1 = require("../global-state/useRouteInfo");
6
+ /**
7
+ * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.
8
+ * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.
9
+ *
10
+ * @example
11
+ * ```tsx app/profile/[user].tsx
12
+ * import { Text } from 'react-native';
13
+ * import { usePathname } from 'expo-router';
14
+ *
15
+ * export default function Route() {
16
+ * // pathname = "/profile/baconbrix"
17
+ * const pathname = usePathname();
18
+ *
19
+ * return <Text>Pathname: {pathname}</Text>;
20
+ * }
21
+ * ```
22
+ */
23
+ function usePathname() {
24
+ return (0, useRouteInfo_1.useRouteInfo)().pathname;
25
+ }
26
+ //# sourceMappingURL=usePathname.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePathname.js","sourceRoot":"","sources":["../../src/hooks/usePathname.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAqBb,kCAEC;AArBD,+DAA4D;AAE5D;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,WAAW;IACzB,OAAO,IAAA,2BAAY,GAAE,CAAC,QAAQ,CAAC;AACjC,CAAC","sourcesContent":["'use client';\n\nimport { useRouteInfo } from '../global-state/useRouteInfo';\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>Pathname: {pathname}</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useRouteInfo().pathname;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,
3
+ * which returns a React `ref`.
4
+ */
5
+ export declare function useRootNavigation(): import("../react-navigation").NavigationContainerRef<ReactNavigation.RootParamList> | null;
6
+ //# sourceMappingURL=useRootNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRootNavigation.d.ts","sourceRoot":"","sources":["../../src/hooks/useRootNavigation.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,iBAAiB,+FAEhC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useRootNavigation = useRootNavigation;
5
+ const store_1 = require("../global-state/store");
6
+ /**
7
+ * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,
8
+ * which returns a React `ref`.
9
+ */
10
+ function useRootNavigation() {
11
+ return store_1.store.navigationRef.current;
12
+ }
13
+ //# sourceMappingURL=useRootNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRootNavigation.js","sourceRoot":"","sources":["../../src/hooks/useRootNavigation.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAQb,8CAEC;AARD,iDAA8C;AAE9C;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,aAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AACrC,CAAC","sourcesContent":["'use client';\n\nimport { store } from '../global-state/store';\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"]}
@@ -0,0 +1,18 @@
1
+ import type { NavigationState } from '../react-navigation/native';
2
+ /**
3
+ * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)
4
+ * of the navigator which contains the current screen.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import { useRootNavigationState } from 'expo-router';
9
+ *
10
+ * export default function Route() {
11
+ * const { routes } = useRootNavigationState();
12
+ *
13
+ * return <Text>{routes[0].name}</Text>;
14
+ * }
15
+ * ```
16
+ */
17
+ export declare function useRootNavigationState(): NavigationState;
18
+ //# sourceMappingURL=useRootNavigationState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRootNavigationState.d.ts","sourceRoot":"","sources":["../../src/hooks/useRootNavigationState.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGlF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,IAAI,eAAe,CAWxD"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useRootNavigationState = useRootNavigationState;
5
+ const constants_1 = require("../constants");
6
+ const native_1 = require("../react-navigation/native");
7
+ /**
8
+ * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)
9
+ * of the navigator which contains the current screen.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * import { useRootNavigationState } from 'expo-router';
14
+ *
15
+ * export default function Route() {
16
+ * const { routes } = useRootNavigationState();
17
+ *
18
+ * return <Text>{routes[0].name}</Text>;
19
+ * }
20
+ * ```
21
+ */
22
+ function useRootNavigationState() {
23
+ const parent =
24
+ // We assume that this is called from routes in __root
25
+ // Users cannot customize the generated Sitemap or NotFound routes, so we should be safe
26
+ (0, native_1.useNavigation)().getParent(constants_1.INTERNAL_SLOT_NAME);
27
+ if (!parent) {
28
+ throw new Error('useRootNavigationState was called from a generated route. This is likely a bug in Expo Router.');
29
+ }
30
+ return parent.getState();
31
+ }
32
+ //# sourceMappingURL=useRootNavigationState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRootNavigationState.js","sourceRoot":"","sources":["../../src/hooks/useRootNavigationState.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAqBb,wDAWC;AA9BD,4CAAkD;AAElD,uDAA2D;AAE3D;;;;;;;;;;;;;;GAcG;AACH,SAAgB,sBAAsB;IACpC,MAAM,MAAM;IACV,sDAAsD;IACtD,wFAAwF;IACxF,IAAA,sBAAa,GAAyC,CAAC,SAAS,CAAC,8BAAkB,CAAC,CAAC;IACvF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["'use client';\n\nimport { INTERNAL_SLOT_NAME } from '../constants';\nimport type { NavigationProp, NavigationState } from '../react-navigation/native';\nimport { useNavigation } from '../react-navigation/native';\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(): NavigationState {\n const parent =\n // We assume that this is called from routes in __root\n // Users cannot customize the generated Sitemap or NotFound routes, so we should be safe\n useNavigation<NavigationProp<object, never, string>>().getParent(INTERNAL_SLOT_NAME);\n if (!parent) {\n throw new Error(\n 'useRootNavigationState was called from a generated route. This is likely a bug in Expo Router.'\n );\n }\n return parent.getState();\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { ImperativeRouter } from '../imperative-api';
2
+ /**
3
+ *
4
+ * Returns the [Router](#router) object for imperative navigation.
5
+ *
6
+ * @example
7
+ *```tsx
8
+ * import { useRouter } from 'expo-router';
9
+ * import { Text } from 'react-native';
10
+ *
11
+ * export default function Route() {
12
+ * const router = useRouter();
13
+ *
14
+ * return (
15
+ * <Text onPress={() => router.push('/home')}>Go Home</Text>
16
+ * );
17
+ *}
18
+ * ```
19
+ */
20
+ export declare function useRouter(): ImperativeRouter;
21
+ //# sourceMappingURL=useRouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRouter.d.ts","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAmC1D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,IAAI,gBAAgB,CAM5C"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useRouter = useRouter;
5
+ const imperative_api_1 = require("../imperative-api");
6
+ const PreviewRouteContext_1 = require("../link/preview/PreviewRouteContext");
7
+ const displayWarningForProp = (prop) => {
8
+ if (process.env.NODE_ENV !== 'production') {
9
+ console.warn(`router.${prop} should not be used in a previewed screen. To fix this issue, wrap navigation calls with 'if (!isPreview) { ... }'.`);
10
+ }
11
+ };
12
+ const createNOOPWithWarning = (prop) => () => displayWarningForProp(prop);
13
+ const routerWithWarnings = {
14
+ back: createNOOPWithWarning('back'),
15
+ canGoBack: () => {
16
+ displayWarningForProp('canGoBack');
17
+ return false;
18
+ },
19
+ push: createNOOPWithWarning('push'),
20
+ navigate: createNOOPWithWarning('navigate'),
21
+ replace: createNOOPWithWarning('replace'),
22
+ dismiss: createNOOPWithWarning('dismiss'),
23
+ dismissTo: createNOOPWithWarning('dismissTo'),
24
+ dismissAll: createNOOPWithWarning('dismissAll'),
25
+ canDismiss: () => {
26
+ displayWarningForProp('canDismiss');
27
+ return false;
28
+ },
29
+ setParams: createNOOPWithWarning('setParams'),
30
+ reload: createNOOPWithWarning('reload'),
31
+ prefetch: createNOOPWithWarning('prefetch'),
32
+ };
33
+ /**
34
+ *
35
+ * Returns the [Router](#router) object for imperative navigation.
36
+ *
37
+ * @example
38
+ *```tsx
39
+ * import { useRouter } from 'expo-router';
40
+ * import { Text } from 'react-native';
41
+ *
42
+ * export default function Route() {
43
+ * const router = useRouter();
44
+ *
45
+ * return (
46
+ * <Text onPress={() => router.push('/home')}>Go Home</Text>
47
+ * );
48
+ *}
49
+ * ```
50
+ */
51
+ function useRouter() {
52
+ const { isPreview } = (0, PreviewRouteContext_1.usePreviewInfo)();
53
+ if (isPreview) {
54
+ return routerWithWarnings;
55
+ }
56
+ return imperative_api_1.router;
57
+ }
58
+ //# sourceMappingURL=useRouter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRouter.js","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAuDb,8BAMC;AA1DD,sDAA2C;AAC3C,6EAAqE;AAErE,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC7C,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QAC1C,OAAO,CAAC,IAAI,CACV,UAAU,IAAI,qHAAqH,CACpI,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;AAElF,MAAM,kBAAkB,GAAqB;IAC3C,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC;IACnC,SAAS,EAAE,GAAG,EAAE;QACd,qBAAqB,CAAC,WAAW,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC;IACnC,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;IAC3C,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC;IACzC,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC;IACzC,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC;IAC7C,UAAU,EAAE,qBAAqB,CAAC,YAAY,CAAC;IAC/C,UAAU,EAAE,GAAG,EAAE;QACf,qBAAqB,CAAC,YAAY,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC;IAC7C,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC;IACvC,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,SAAS;IACvB,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,oCAAc,GAAE,CAAC;IACvC,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,OAAO,uBAAM,CAAC;AAChB,CAAC","sourcesContent":["'use client';\n\nimport type { ImperativeRouter } from '../imperative-api';\nimport { router } from '../imperative-api';\nimport { usePreviewInfo } from '../link/preview/PreviewRouteContext';\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: ImperativeRouter = {\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(): ImperativeRouter {\n const { isPreview } = usePreviewInfo();\n if (isPreview) {\n return routerWithWarnings;\n }\n return router;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare function useSearchParams({ global }?: {
2
+ global?: boolean | undefined;
3
+ }): URLSearchParams;
4
+ //# sourceMappingURL=useSearchParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSearchParams.d.ts","sourceRoot":"","sources":["../../src/hooks/useSearchParams.ts"],"names":[],"mappings":"AAQA,wBAAgB,eAAe,CAAC,EAAE,MAAc,EAAE;;CAAK,GAAG,eAAe,CAsBxE"}