@react-navigation/native 7.0.0-alpha.0 → 7.0.0-alpha.10

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 (238) hide show
  1. package/lib/commonjs/Link.js +16 -9
  2. package/lib/commonjs/Link.js.map +1 -1
  3. package/lib/commonjs/LinkingContext.js +8 -7
  4. package/lib/commonjs/LinkingContext.js.map +1 -1
  5. package/lib/commonjs/LocaleDirContext.js +12 -0
  6. package/lib/commonjs/LocaleDirContext.js.map +1 -0
  7. package/lib/commonjs/NavigationContainer.js +68 -32
  8. package/lib/commonjs/NavigationContainer.js.map +1 -1
  9. package/lib/commonjs/ServerContainer.js +6 -8
  10. package/lib/commonjs/ServerContainer.js.map +1 -1
  11. package/lib/commonjs/ServerContext.js +4 -6
  12. package/lib/commonjs/ServerContext.js.map +1 -1
  13. package/lib/commonjs/UnhandledLinkingContext.js +20 -0
  14. package/lib/commonjs/UnhandledLinkingContext.js.map +1 -0
  15. package/lib/commonjs/__stubs__/createStackNavigator.js +19 -0
  16. package/lib/commonjs/__stubs__/createStackNavigator.js.map +1 -0
  17. package/lib/commonjs/__stubs__/window.js +79 -0
  18. package/lib/commonjs/__stubs__/window.js.map +1 -0
  19. package/lib/commonjs/createMemoryHistory.js +5 -8
  20. package/lib/commonjs/createMemoryHistory.js.map +1 -1
  21. package/lib/commonjs/createStaticNavigation.js +8 -8
  22. package/lib/commonjs/createStaticNavigation.js.map +1 -1
  23. package/lib/commonjs/extractPathFromURL.js +4 -4
  24. package/lib/commonjs/extractPathFromURL.js.map +1 -1
  25. package/lib/commonjs/index.js +33 -34
  26. package/lib/commonjs/index.js.map +1 -1
  27. package/lib/commonjs/theming/DarkTheme.js +5 -5
  28. package/lib/commonjs/theming/DarkTheme.js.map +1 -1
  29. package/lib/commonjs/theming/DefaultTheme.js +5 -5
  30. package/lib/commonjs/theming/DefaultTheme.js.map +1 -1
  31. package/lib/commonjs/theming/fonts.js +65 -0
  32. package/lib/commonjs/theming/fonts.js.map +1 -0
  33. package/lib/commonjs/types.js.map +1 -1
  34. package/lib/commonjs/useBackButton.js +4 -20
  35. package/lib/commonjs/useBackButton.js.map +1 -1
  36. package/lib/commonjs/useBackButton.native.js +27 -0
  37. package/lib/commonjs/useBackButton.native.js.map +1 -0
  38. package/lib/commonjs/useDocumentTitle.js +6 -6
  39. package/lib/commonjs/useDocumentTitle.js.map +1 -1
  40. package/lib/commonjs/useDocumentTitle.native.js +1 -1
  41. package/lib/commonjs/useDocumentTitle.native.js.map +1 -1
  42. package/lib/commonjs/useLinkBuilder.js +80 -0
  43. package/lib/commonjs/useLinkBuilder.js.map +1 -0
  44. package/lib/commonjs/useLinkProps.js +23 -27
  45. package/lib/commonjs/useLinkProps.js.map +1 -1
  46. package/lib/commonjs/useLinkTo.js +30 -0
  47. package/lib/commonjs/useLinkTo.js.map +1 -0
  48. package/lib/commonjs/useLinking.js +39 -40
  49. package/lib/commonjs/useLinking.js.map +1 -1
  50. package/lib/commonjs/useLinking.native.js +33 -27
  51. package/lib/commonjs/useLinking.native.js.map +1 -1
  52. package/lib/commonjs/useLocale.js +23 -0
  53. package/lib/commonjs/useLocale.js.map +1 -0
  54. package/lib/commonjs/useScrollToTop.js +9 -7
  55. package/lib/commonjs/useScrollToTop.js.map +1 -1
  56. package/lib/commonjs/useThenable.js +4 -3
  57. package/lib/commonjs/useThenable.js.map +1 -1
  58. package/lib/commonjs/useUnhandledLinking.js +75 -0
  59. package/lib/commonjs/useUnhandledLinking.js.map +1 -0
  60. package/lib/module/Link.js +13 -5
  61. package/lib/module/Link.js.map +1 -1
  62. package/lib/module/LinkingContext.js +5 -3
  63. package/lib/module/LinkingContext.js.map +1 -1
  64. package/lib/module/LocaleDirContext.js +4 -0
  65. package/lib/module/LocaleDirContext.js.map +1 -0
  66. package/lib/module/NavigationContainer.js +60 -23
  67. package/lib/module/NavigationContainer.js.map +1 -1
  68. package/lib/module/ServerContainer.js +2 -2
  69. package/lib/module/ServerContainer.js.map +1 -1
  70. package/lib/module/ServerContext.js +1 -2
  71. package/lib/module/ServerContext.js.map +1 -1
  72. package/lib/module/UnhandledLinkingContext.js +12 -0
  73. package/lib/module/UnhandledLinkingContext.js.map +1 -0
  74. package/lib/module/__stubs__/createStackNavigator.js +11 -0
  75. package/lib/module/__stubs__/createStackNavigator.js.map +1 -0
  76. package/lib/module/__stubs__/window.js +73 -0
  77. package/lib/module/__stubs__/window.js.map +1 -0
  78. package/lib/module/createMemoryHistory.js +5 -8
  79. package/lib/module/createMemoryHistory.js.map +1 -1
  80. package/lib/module/createStaticNavigation.js +5 -4
  81. package/lib/module/createStaticNavigation.js.map +1 -1
  82. package/lib/module/extractPathFromURL.js +4 -4
  83. package/lib/module/extractPathFromURL.js.map +1 -1
  84. package/lib/module/index.js +12 -12
  85. package/lib/module/index.js.map +1 -1
  86. package/lib/module/theming/DarkTheme.js +4 -3
  87. package/lib/module/theming/DarkTheme.js.map +1 -1
  88. package/lib/module/theming/DefaultTheme.js +4 -3
  89. package/lib/module/theming/DefaultTheme.js.map +1 -1
  90. package/lib/module/theming/fonts.js +59 -0
  91. package/lib/module/theming/fonts.js.map +1 -0
  92. package/lib/module/types.js.map +1 -1
  93. package/lib/module/useBackButton.js +3 -17
  94. package/lib/module/useBackButton.js.map +1 -1
  95. package/lib/module/useBackButton.native.js +19 -0
  96. package/lib/module/useBackButton.native.js.map +1 -0
  97. package/lib/module/useDocumentTitle.js +4 -4
  98. package/lib/module/useDocumentTitle.js.map +1 -1
  99. package/lib/module/useDocumentTitle.native.js +1 -1
  100. package/lib/module/useDocumentTitle.native.js.map +1 -1
  101. package/lib/module/{useLinkTools.js → useLinkBuilder.js} +11 -11
  102. package/lib/module/useLinkBuilder.js.map +1 -0
  103. package/lib/module/useLinkProps.js +20 -23
  104. package/lib/module/useLinkProps.js.map +1 -1
  105. package/lib/module/useLinkTo.js +23 -0
  106. package/lib/module/useLinkTo.js.map +1 -0
  107. package/lib/module/useLinking.js +33 -36
  108. package/lib/module/useLinking.js.map +1 -1
  109. package/lib/module/useLinking.native.js +29 -22
  110. package/lib/module/useLinking.native.js.map +1 -1
  111. package/lib/module/useLocale.js +16 -0
  112. package/lib/module/useLocale.js.map +1 -0
  113. package/lib/module/useScrollToTop.js +8 -6
  114. package/lib/module/useScrollToTop.js.map +1 -1
  115. package/lib/module/useThenable.js +2 -1
  116. package/lib/module/useThenable.js.map +1 -1
  117. package/lib/module/useUnhandledLinking.js +69 -0
  118. package/lib/module/useUnhandledLinking.js.map +1 -0
  119. package/lib/typescript/src/Link.d.ts +3 -3
  120. package/lib/typescript/src/Link.d.ts.map +1 -1
  121. package/lib/typescript/src/LinkingContext.d.ts +2 -3
  122. package/lib/typescript/src/LinkingContext.d.ts.map +1 -1
  123. package/lib/typescript/src/LocaleDirContext.d.ts +4 -0
  124. package/lib/typescript/src/LocaleDirContext.d.ts.map +1 -0
  125. package/lib/typescript/src/NavigationContainer.d.ts +6 -6
  126. package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
  127. package/lib/typescript/src/ServerContainer.d.ts +2 -3
  128. package/lib/typescript/src/ServerContainer.d.ts.map +1 -1
  129. package/lib/typescript/src/ServerContext.d.ts +1 -2
  130. package/lib/typescript/src/ServerContext.d.ts.map +1 -1
  131. package/lib/typescript/src/UnhandledLinkingContext.d.ts +6 -0
  132. package/lib/typescript/src/UnhandledLinkingContext.d.ts.map +1 -0
  133. package/lib/typescript/src/__stubs__/createStackNavigator.d.ts +32 -0
  134. package/lib/typescript/src/__stubs__/createStackNavigator.d.ts.map +1 -0
  135. package/lib/typescript/src/{__mocks__ → __stubs__}/window.d.ts +2 -3
  136. package/lib/typescript/src/__stubs__/window.d.ts.map +1 -0
  137. package/lib/typescript/src/createMemoryHistory.d.ts +1 -1
  138. package/lib/typescript/src/createMemoryHistory.d.ts.map +1 -1
  139. package/lib/typescript/src/createStaticNavigation.d.ts +3 -3
  140. package/lib/typescript/src/createStaticNavigation.d.ts.map +1 -1
  141. package/lib/typescript/src/extractPathFromURL.d.ts +1 -1
  142. package/lib/typescript/src/extractPathFromURL.d.ts.map +1 -1
  143. package/lib/typescript/src/index.d.ts +12 -12
  144. package/lib/typescript/src/index.d.ts.map +1 -1
  145. package/lib/typescript/src/theming/DarkTheme.d.ts +1 -2
  146. package/lib/typescript/src/theming/DarkTheme.d.ts.map +1 -1
  147. package/lib/typescript/src/theming/DefaultTheme.d.ts +1 -2
  148. package/lib/typescript/src/theming/DefaultTheme.d.ts.map +1 -1
  149. package/lib/typescript/src/theming/fonts.d.ts +53 -0
  150. package/lib/typescript/src/theming/fonts.d.ts.map +1 -0
  151. package/lib/typescript/src/types.d.ts +41 -11
  152. package/lib/typescript/src/types.d.ts.map +1 -1
  153. package/lib/typescript/src/useBackButton.d.ts +2 -2
  154. package/lib/typescript/src/useBackButton.d.ts.map +1 -1
  155. package/lib/typescript/src/useBackButton.native.d.ts +4 -0
  156. package/lib/typescript/src/useBackButton.native.d.ts.map +1 -0
  157. package/lib/typescript/src/useDocumentTitle.d.ts +1 -1
  158. package/lib/typescript/src/useDocumentTitle.d.ts.map +1 -1
  159. package/lib/typescript/src/useDocumentTitle.native.d.ts +1 -1
  160. package/lib/typescript/src/useDocumentTitle.native.d.ts.map +1 -1
  161. package/lib/typescript/src/useLinkBuilder.d.ts +25 -0
  162. package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -0
  163. package/lib/typescript/src/useLinkProps.d.ts +3 -3
  164. package/lib/typescript/src/useLinkProps.d.ts.map +1 -1
  165. package/lib/typescript/src/useLinkTo.d.ts +6 -0
  166. package/lib/typescript/src/useLinkTo.d.ts.map +1 -0
  167. package/lib/typescript/src/useLinking.d.ts +8 -20
  168. package/lib/typescript/src/useLinking.d.ts.map +1 -1
  169. package/lib/typescript/src/useLinking.native.d.ts +4 -20
  170. package/lib/typescript/src/useLinking.native.d.ts.map +1 -1
  171. package/lib/typescript/src/useLocale.d.ts +7 -0
  172. package/lib/typescript/src/useLocale.d.ts.map +1 -0
  173. package/lib/typescript/src/useScrollToTop.d.ts +1 -1
  174. package/lib/typescript/src/useScrollToTop.d.ts.map +1 -1
  175. package/lib/typescript/src/useThenable.d.ts +1 -1
  176. package/lib/typescript/src/useThenable.d.ts.map +1 -1
  177. package/lib/typescript/src/useUnhandledLinking.d.ts +7 -0
  178. package/lib/typescript/src/useUnhandledLinking.d.ts.map +1 -0
  179. package/package.json +15 -15
  180. package/src/Link.tsx +12 -3
  181. package/src/LinkingContext.tsx +9 -5
  182. package/src/LocaleDirContext.tsx +7 -0
  183. package/src/NavigationContainer.tsx +90 -36
  184. package/src/ServerContainer.tsx +2 -2
  185. package/src/ServerContext.tsx +1 -3
  186. package/src/UnhandledLinkingContext.tsx +18 -0
  187. package/src/{__mocks__ → __stubs__}/createStackNavigator.tsx +1 -3
  188. package/src/{__mocks__ → __stubs__}/window.tsx +8 -8
  189. package/src/createMemoryHistory.tsx +1 -1
  190. package/src/createStaticNavigation.tsx +8 -8
  191. package/src/extractPathFromURL.tsx +5 -2
  192. package/src/index.tsx +12 -12
  193. package/src/theming/DarkTheme.tsx +3 -3
  194. package/src/theming/DefaultTheme.tsx +3 -3
  195. package/src/theming/fonts.tsx +63 -0
  196. package/src/types.tsx +55 -11
  197. package/src/useBackButton.native.tsx +33 -0
  198. package/src/useBackButton.tsx +4 -26
  199. package/src/useDocumentTitle.native.tsx +1 -1
  200. package/src/useDocumentTitle.tsx +1 -1
  201. package/src/{useLinkTools.tsx → useLinkBuilder.tsx} +9 -9
  202. package/src/useLinkProps.tsx +27 -23
  203. package/src/useLinkTo.tsx +30 -0
  204. package/src/useLinking.native.tsx +28 -22
  205. package/src/useLinking.tsx +46 -44
  206. package/src/useLocale.tsx +18 -0
  207. package/src/useScrollToTop.tsx +14 -10
  208. package/src/useThenable.tsx +2 -1
  209. package/src/useUnhandledLinking.tsx +91 -0
  210. package/lib/commonjs/theming/ThemeContext.js +0 -16
  211. package/lib/commonjs/theming/ThemeContext.js.map +0 -1
  212. package/lib/commonjs/theming/ThemeProvider.js +0 -21
  213. package/lib/commonjs/theming/ThemeProvider.js.map +0 -1
  214. package/lib/commonjs/theming/useTheme.js +0 -16
  215. package/lib/commonjs/theming/useTheme.js.map +0 -1
  216. package/lib/commonjs/useLinkTools.js +0 -81
  217. package/lib/commonjs/useLinkTools.js.map +0 -1
  218. package/lib/module/theming/ThemeContext.js +0 -6
  219. package/lib/module/theming/ThemeContext.js.map +0 -1
  220. package/lib/module/theming/ThemeProvider.js +0 -12
  221. package/lib/module/theming/ThemeProvider.js.map +0 -1
  222. package/lib/module/theming/useTheme.js +0 -7
  223. package/lib/module/theming/useTheme.js.map +0 -1
  224. package/lib/module/useLinkTools.js.map +0 -1
  225. package/lib/typescript/src/__mocks__/createStackNavigator.d.ts +0 -57
  226. package/lib/typescript/src/__mocks__/createStackNavigator.d.ts.map +0 -1
  227. package/lib/typescript/src/__mocks__/window.d.ts.map +0 -1
  228. package/lib/typescript/src/theming/ThemeContext.d.ts +0 -5
  229. package/lib/typescript/src/theming/ThemeContext.d.ts.map +0 -1
  230. package/lib/typescript/src/theming/ThemeProvider.d.ts +0 -9
  231. package/lib/typescript/src/theming/ThemeProvider.d.ts.map +0 -1
  232. package/lib/typescript/src/theming/useTheme.d.ts +0 -2
  233. package/lib/typescript/src/theming/useTheme.d.ts.map +0 -1
  234. package/lib/typescript/src/useLinkTools.d.ts +0 -33
  235. package/lib/typescript/src/useLinkTools.d.ts.map +0 -1
  236. package/src/theming/ThemeContext.tsx +0 -10
  237. package/src/theming/ThemeProvider.tsx +0 -15
  238. package/src/theming/useTheme.tsx +0 -9
@@ -1,6 +1,6 @@
1
- import { NavigationAction } from '@react-navigation/core';
1
+ import { type NavigationAction } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
- import { GestureResponderEvent } from 'react-native';
3
+ import { type GestureResponderEvent } from 'react-native';
4
4
  export type Props<ParamList extends ReactNavigation.RootParamList, RouteName extends keyof ParamList = keyof ParamList> = ({
5
5
  screen: Extract<RouteName, string>;
6
6
  href?: string;
@@ -23,7 +23,7 @@ export type Props<ParamList extends ReactNavigation.RootParamList, RouteName ext
23
23
  * @param props.href Optional absolute path to use for the href (e.g. `/feeds/hot`).
24
24
  * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
25
25
  */
26
- export default function useLinkProps<ParamList extends ReactNavigation.RootParamList>({ screen, params, href, action }: Props<ParamList>): {
26
+ export declare function useLinkProps<ParamList extends ReactNavigation.RootParamList>({ screen, params, href, action, }: Props<ParamList>): {
27
27
  href: string | undefined;
28
28
  accessibilityRole: "link";
29
29
  onPress: (e?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useLinkProps.d.ts","sourceRoot":"","sources":["../../../src/useLinkProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAKjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAI/D,MAAM,MAAM,KAAK,CACf,SAAS,SAAS,eAAe,CAAC,aAAa,EAC/C,SAAS,SAAS,MAAM,SAAS,GAAG,MAAM,SAAS,IAEjD,CAAC;IACC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,GAAG,CAAC,SAAS,SAAS,SAAS,CAAC,SAAS,CAAC,GACvC;IAAE,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,CAAC,CAAC,GACtC;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AA+BN;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,SAAS,SAAS,eAAe,CAAC,aAAa,EAC/C,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC;;;kBAM5C,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB;EA6D9E"}
1
+ {"version":3,"file":"useLinkProps.d.ts","sourceRoot":"","sources":["../../../src/useLinkProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EAKtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAIpE,MAAM,MAAM,KAAK,CACf,SAAS,SAAS,eAAe,CAAC,aAAa,EAC/C,SAAS,SAAS,MAAM,SAAS,GAAG,MAAM,SAAS,IAEjD,CAAC;IACC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,GAAG,CAAC,SAAS,SAAS,SAAS,CAAC,SAAS,CAAC,GACvC;IAAE,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,CAAC,CAAC,GACtC;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AA+BN;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,SAAS,SAAS,eAAe,CAAC,aAAa,EAAE,EAC5E,MAAM,EACN,MAAM,EACN,IAAI,EACJ,MAAM,GACP,EAAE,KAAK,CAAC,SAAS,CAAC;;;kBAMX,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB;EA8D9E"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Helper to navigate to a screen using a href based on the linking options.
3
+ * @returns function that receives the href to navigate to.
4
+ */
5
+ export declare function useLinkTo(): (href: string) => void;
6
+ //# sourceMappingURL=useLinkTo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLinkTo.d.ts","sourceRoot":"","sources":["../../../src/useLinkTo.tsx"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,SAAS,WAKd,MAAM,UAehB"}
@@ -1,22 +1,18 @@
1
- import { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
1
+ import { type NavigationContainerRef, type ParamListBase } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
3
  import type { LinkingOptions } from './types';
4
+ /**
5
+ * Run async function in series as it's called.
6
+ */
7
+ export declare const series: (cb: () => Promise<void>) => () => void;
4
8
  type Options = LinkingOptions<ParamListBase>;
5
- export default function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, config, getStateFromPath, getPathFromState, getActionFromState, }: Options): {
9
+ export declare function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, config, getStateFromPath, getPathFromState, getActionFromState, }: Options, onUnhandledLinking: (lastUnhandledLining: string | undefined) => void): {
6
10
  getInitialState: () => PromiseLike<(Partial<Omit<Readonly<{
7
11
  key: string;
8
12
  index: number;
9
13
  routeNames: string[];
10
14
  history?: unknown[] | undefined;
11
- routes: (Readonly<{
12
- key: string;
13
- name: string;
14
- path?: string | undefined;
15
- }> & Readonly<{
16
- params?: Readonly<object | undefined>;
17
- }> & {
18
- state?: Readonly<any> | import("@react-navigation/core").PartialState<Readonly<any>> | undefined;
19
- })[];
15
+ routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
20
16
  type: string;
21
17
  stale: false;
22
18
  }>, "stale" | "routes">> & Readonly<{
@@ -28,15 +24,7 @@ export default function useLinking(ref: React.RefObject<NavigationContainerRef<P
28
24
  index: number;
29
25
  routeNames: string[];
30
26
  history?: unknown[] | undefined;
31
- routes: (Readonly<{
32
- key: string;
33
- name: string;
34
- path?: string | undefined;
35
- }> & Readonly<{
36
- params?: Readonly<object | undefined>;
37
- }> & {
38
- state?: Readonly<any> | import("@react-navigation/core").PartialState<Readonly<any>> | undefined;
39
- })[];
27
+ routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
40
28
  type: string;
41
29
  stale: false;
42
30
  }>, "stale" | "routes">> & Readonly<{
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../../src/useLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,sBAAsB,EAEtB,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAiF9C,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwTX"}
1
+ {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../../src/useLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA4C9C;;GAEG;AACH,eAAO,MAAM,MAAM,OAAQ,MAAM,QAAQ,IAAI,CAAC,eAO7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EAgVtE"}
@@ -1,22 +1,14 @@
1
- import { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
1
+ import { type NavigationContainerRef, type ParamListBase } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
3
  import type { LinkingOptions } from './types';
4
4
  type Options = LinkingOptions<ParamListBase>;
5
- export default function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, prefixes, filter, config, getInitialURL, subscribe, getStateFromPath, getActionFromState, }: Options): {
5
+ export declare function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, prefixes, filter, config, getInitialURL, subscribe, getStateFromPath, getActionFromState, }: Options, onUnhandledLinking: (lastUnhandledLining: string | undefined) => void): {
6
6
  getInitialState: () => PromiseLike<(Partial<Omit<Readonly<{
7
7
  key: string;
8
8
  index: number;
9
9
  routeNames: string[];
10
10
  history?: unknown[] | undefined;
11
- routes: (Readonly<{
12
- key: string;
13
- name: string;
14
- path?: string | undefined;
15
- }> & Readonly<{
16
- params?: Readonly<object | undefined>;
17
- }> & {
18
- state?: Readonly<any> | import("@react-navigation/core").PartialState<Readonly<any>> | undefined;
19
- })[];
11
+ routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
20
12
  type: string;
21
13
  stale: false;
22
14
  }>, "stale" | "routes">> & Readonly<{
@@ -28,15 +20,7 @@ export default function useLinking(ref: React.RefObject<NavigationContainerRef<P
28
20
  index: number;
29
21
  routeNames: string[];
30
22
  history?: unknown[] | undefined;
31
- routes: (Readonly<{
32
- key: string;
33
- name: string;
34
- path?: string | undefined;
35
- }> & Readonly<{
36
- params?: Readonly<object | undefined>;
37
- }> & {
38
- state?: Readonly<any> | import("@react-navigation/core").PartialState<Readonly<any>> | undefined;
39
- })[];
23
+ routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
40
24
  type: string;
41
25
  stale: false;
42
26
  }>, "stale" | "routes">> & Readonly<{
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../../src/useLinking.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACtB,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAI7C,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAQI,EACJ,SAmBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6JX"}
1
+ {"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../../src/useLinking.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAI7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAQI,EACJ,SAmBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EAkKtE"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hook to access the text direction specified in the `NavigationContainer`.
3
+ */
4
+ export declare function useLocale(): {
5
+ direction: import("./types").LocaleDirection;
6
+ };
7
+ //# sourceMappingURL=useLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/useLocale.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,SAAS;;EAUxB"}
@@ -22,6 +22,6 @@ type ScrollableWrapper = {
22
22
  } | {
23
23
  getNode(): ScrollableView;
24
24
  } | ScrollableView;
25
- export default function useScrollToTop(ref: React.RefObject<ScrollableWrapper>): void;
25
+ export declare function useScrollToTop(ref: React.RefObject<ScrollableWrapper>): void;
26
26
  export {};
27
27
  //# sourceMappingURL=useScrollToTop.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollToTop.d.ts","sourceRoot":"","sources":["../../../src/useScrollToTop.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,KAAK,aAAa,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpE,KAAK,cAAc,GACf;IAAE,WAAW,IAAI,IAAI,CAAA;CAAE,GACvB;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,GAC1C;IAAE,cAAc,CAAC,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC1E;IAAE,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAAC;AAE9D,KAAK,iBAAiB,GAClB;IAAE,kBAAkB,IAAI,KAAK,CAAC,SAAS,GAAG,UAAU,CAAA;CAAE,GACtD;IAAE,OAAO,IAAI,cAAc,CAAA;CAAE,GAC7B,cAAc,CAAC;AA8BnB,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,QAgExC"}
1
+ {"version":3,"file":"useScrollToTop.d.ts","sourceRoot":"","sources":["../../../src/useScrollToTop.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,KAAK,aAAa,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpE,KAAK,cAAc,GACf;IAAE,WAAW,IAAI,IAAI,CAAA;CAAE,GACvB;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,GAC1C;IAAE,cAAc,CAAC,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC1E;IAAE,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAAC;AAE9D,KAAK,iBAAiB,GAClB;IAAE,kBAAkB,IAAI,KAAK,CAAC,SAAS,GAAG,UAAU,CAAA;CAAE,GACtD;IAAE,OAAO,IAAI,cAAc,CAAA;CAAE,GAC7B,cAAc,CAAC;AA8BnB,wBAAgB,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,QAoErE"}
@@ -1,2 +1,2 @@
1
- export default function useThenable<T>(create: () => PromiseLike<T>): [boolean, T | undefined];
1
+ export declare function useThenable<T>(create: () => PromiseLike<T>): [boolean, T | undefined];
2
2
  //# sourceMappingURL=useThenable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useThenable.d.ts","sourceRoot":"","sources":["../../../src/useThenable.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,4BAsClE"}
1
+ {"version":3,"file":"useThenable.d.ts","sourceRoot":"","sources":["../../../src/useThenable.tsx"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,4BAuC1D"}
@@ -0,0 +1,7 @@
1
+ import { type NavigationState, type PartialState } from '@react-navigation/core';
2
+ export declare function UNSTABLE_useUnhandledLinking(): {
3
+ lastUnhandledLink: string | undefined;
4
+ getStateForRouteNamesChange: (currentState: NavigationState) => PartialState<NavigationState> | undefined;
5
+ clearUnhandledLink: () => void;
6
+ };
7
+ //# sourceMappingURL=useUnhandledLinking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUnhandledLinking.d.ts","sourceRoot":"","sources":["../../../src/useUnhandledLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AA2BhC,wBAAgB,4BAA4B;;gDAU1B,eAAe,KAC5B,aAAa,eAAe,CAAC,GAAG,SAAS;;EA+C7C"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/native",
3
3
  "description": "React Native integration for React Navigation",
4
- "version": "7.0.0-alpha.0",
4
+ "version": "7.0.0-alpha.10",
5
5
  "keywords": [
6
6
  "react-native",
7
7
  "react-navigation",
@@ -37,26 +37,26 @@
37
37
  "clean": "del lib"
38
38
  },
39
39
  "dependencies": {
40
- "@react-navigation/core": "^7.0.0-alpha.0",
40
+ "@react-navigation/core": "^7.0.0-alpha.9",
41
41
  "escape-string-regexp": "^4.0.0",
42
42
  "fast-deep-equal": "^3.1.3",
43
- "nanoid": "^3.1.23"
43
+ "nanoid": "3.3.7",
44
+ "use-latest-callback": "^0.1.9"
44
45
  },
45
46
  "devDependencies": {
46
- "@testing-library/react-native": "^11.5.0",
47
- "@types/react": "~18.0.26",
48
- "@types/react-dom": "~18.0.9",
49
- "@types/react-native": "~0.70.8",
50
- "del-cli": "^5.0.0",
51
- "react": "18.1.0",
47
+ "@testing-library/react-native": "^12.4.3",
48
+ "@types/react": "~18.2.45",
49
+ "@types/react-dom": "~18.0.11",
50
+ "del-cli": "^5.1.0",
51
+ "react": "18.2.0",
52
52
  "react-dom": "18.2.0",
53
- "react-native": "0.70.5",
54
- "react-native-builder-bob": "^0.20.3",
55
- "typescript": "^4.9.4"
53
+ "react-native": "0.73.2",
54
+ "react-native-builder-bob": "^0.23.2",
55
+ "typescript": "^5.3.3"
56
56
  },
57
57
  "peerDependencies": {
58
- "react": "*",
59
- "react-native": "*"
58
+ "react": ">= 18.2.0",
59
+ "react-native": ">= 0.72.0"
60
60
  },
61
61
  "react-native-builder-bob": {
62
62
  "source": "src",
@@ -72,5 +72,5 @@
72
72
  ]
73
73
  ]
74
74
  },
75
- "gitHead": "ad722b882e0c40b1d1bc025d70112ddb126f265e"
75
+ "gitHead": "38117089fff9341c72e0834ca8ec237e8186b63c"
76
76
  }
package/src/Link.tsx CHANGED
@@ -1,7 +1,13 @@
1
+ import { useTheme } from '@react-navigation/core';
1
2
  import * as React from 'react';
2
- import { GestureResponderEvent, Platform, Text, TextProps } from 'react-native';
3
+ import {
4
+ type GestureResponderEvent,
5
+ Platform,
6
+ Text,
7
+ type TextProps,
8
+ } from 'react-native';
3
9
 
4
- import useLinkProps, { Props as LinkProps } from './useLinkProps';
10
+ import { type Props as LinkProps, useLinkProps } from './useLinkProps';
5
11
 
6
12
  type Props<ParamList extends ReactNavigation.RootParamList> =
7
13
  LinkProps<ParamList> &
@@ -26,13 +32,15 @@ type Props<ParamList extends ReactNavigation.RootParamList> =
26
32
  * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
27
33
  * @param props.children Child elements to render the content.
28
34
  */
29
- export default function Link<ParamList extends ReactNavigation.RootParamList>({
35
+ export function Link<ParamList extends ReactNavigation.RootParamList>({
30
36
  screen,
31
37
  params,
32
38
  action,
33
39
  href,
40
+ style,
34
41
  ...rest
35
42
  }: Props<ParamList>) {
43
+ const { colors, fonts } = useTheme();
36
44
  // @ts-expect-error: This is already type-checked by the prop types
37
45
  const props = useLinkProps<ParamList>({ screen, params, action, href });
38
46
 
@@ -56,5 +64,6 @@ export default function Link<ParamList extends ReactNavigation.RootParamList>({
56
64
  web: { onClick: onPress } as any,
57
65
  default: { onPress },
58
66
  }),
67
+ style: [{ color: colors.primary }, fonts.regular, style],
59
68
  });
60
69
  }
@@ -3,10 +3,14 @@ import * as React from 'react';
3
3
 
4
4
  import type { LinkingOptions } from './types';
5
5
 
6
- const LinkingContext = React.createContext<{
7
- options: LinkingOptions<ParamListBase> | undefined;
8
- }>({ options: undefined });
6
+ const MISSING_CONTEXT_ERROR = "Couldn't find a LinkingContext context.";
9
7
 
10
- LinkingContext.displayName = 'LinkingContext';
8
+ export const LinkingContext = React.createContext<{
9
+ options?: LinkingOptions<ParamListBase>;
10
+ }>({
11
+ get options(): any {
12
+ throw new Error(MISSING_CONTEXT_ERROR);
13
+ },
14
+ });
11
15
 
12
- export default LinkingContext;
16
+ LinkingContext.displayName = 'LinkingContext';
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+
3
+ import type { LocaleDirection } from './types';
4
+
5
+ export const LocaleDirContext = React.createContext<LocaleDirection>('ltr');
6
+
7
+ LocaleDirContext.displayName = 'LocaleDirContext';
@@ -3,23 +3,32 @@ import {
3
3
  getActionFromState,
4
4
  getPathFromState,
5
5
  getStateFromPath,
6
- NavigationContainerProps,
7
- NavigationContainerRef,
8
- ParamListBase,
6
+ type NavigationContainerProps,
7
+ type NavigationContainerRef,
8
+ type NavigationState,
9
+ type ParamListBase,
9
10
  validatePathConfig,
10
11
  } from '@react-navigation/core';
11
12
  import * as React from 'react';
12
-
13
- import LinkingContext from './LinkingContext';
14
- import DefaultTheme from './theming/DefaultTheme';
15
- import ThemeProvider from './theming/ThemeProvider';
16
- import type { DocumentTitleOptions, LinkingOptions, Theme } from './types';
17
- import useBackButton from './useBackButton';
18
- import useDocumentTitle from './useDocumentTitle';
19
- import useLinking from './useLinking';
20
- import useThenable from './useThenable';
13
+ import { I18nManager } from 'react-native';
14
+ import useLatestCallback from 'use-latest-callback';
15
+
16
+ import { LinkingContext } from './LinkingContext';
17
+ import { LocaleDirContext } from './LocaleDirContext';
18
+ import { DefaultTheme } from './theming/DefaultTheme';
19
+ import type {
20
+ DocumentTitleOptions,
21
+ LinkingOptions,
22
+ LocaleDirection,
23
+ } from './types';
24
+ import { UnhandledLinkingContext } from './UnhandledLinkingContext';
25
+ import { useBackButton } from './useBackButton';
26
+ import { useDocumentTitle } from './useDocumentTitle';
27
+ import { useLinking } from './useLinking';
28
+ import { useThenable } from './useThenable';
21
29
 
22
30
  declare global {
31
+ // eslint-disable-next-line no-var
23
32
  var REACT_NAVIGATION_DEVTOOLS: WeakMap<
24
33
  NavigationContainerRef<any>,
25
34
  { readonly linking: LinkingOptions<any> }
@@ -29,7 +38,7 @@ declare global {
29
38
  global.REACT_NAVIGATION_DEVTOOLS = new WeakMap();
30
39
 
31
40
  type Props<ParamList extends {}> = NavigationContainerProps & {
32
- theme?: Theme;
41
+ direction?: LocaleDirection;
33
42
  linking?: LinkingOptions<ParamList>;
34
43
  fallback?: React.ReactNode;
35
44
  documentTitle?: DocumentTitleOptions;
@@ -43,7 +52,8 @@ type Props<ParamList extends {}> = NavigationContainerProps & {
43
52
  * @param props.onReady Callback which is called after the navigation tree mounts.
44
53
  * @param props.onStateChange Callback which is called with the latest navigation state when it changes.
45
54
  * @param props.onUnhandledAction Callback which is called when an action is not handled.
46
- * @param props.theme Theme object for the navigators.
55
+ * @param props.direction Text direction of the components. Defaults to `'ltr'`.
56
+ * @param props.theme Theme object for the UI elements.
47
57
  * @param props.linking Options for deep linking. Deep link handling is enabled when this prop is provided, unless `linking.enabled` is `false`.
48
58
  * @param props.fallback Fallback component to render until we have finished getting initial state when linking is enabled. Defaults to `null`.
49
59
  * @param props.documentTitle Options to configure the document title on Web. Updating document title is handled by default unless `documentTitle.enabled` is `false`.
@@ -52,10 +62,13 @@ type Props<ParamList extends {}> = NavigationContainerProps & {
52
62
  */
53
63
  function NavigationContainerInner(
54
64
  {
65
+ direction = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr',
55
66
  theme = DefaultTheme,
56
67
  linking,
57
68
  fallback = null,
58
69
  documentTitle,
70
+ onReady,
71
+ onStateChange,
59
72
  ...rest
60
73
  }: Props<ParamListBase>,
61
74
  ref?: React.Ref<NavigationContainerRef<ParamListBase> | null>
@@ -72,12 +85,52 @@ function NavigationContainerInner(
72
85
  useBackButton(refContainer);
73
86
  useDocumentTitle(refContainer, documentTitle);
74
87
 
75
- const { getInitialState } = useLinking(refContainer, {
76
- enabled: isLinkingEnabled,
77
- prefixes: [],
78
- ...linking,
88
+ const [lastUnhandledLink, setLastUnhandledLink] = React.useState<
89
+ string | undefined
90
+ >();
91
+
92
+ const { getInitialState } = useLinking(
93
+ refContainer,
94
+ {
95
+ enabled: isLinkingEnabled,
96
+ prefixes: [],
97
+ ...linking,
98
+ },
99
+ setLastUnhandledLink
100
+ );
101
+
102
+ const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);
103
+
104
+ const unhandledLinkingContext = React.useMemo(
105
+ () => ({ lastUnhandledLink, setLastUnhandledLink }),
106
+ [lastUnhandledLink, setLastUnhandledLink]
107
+ );
108
+
109
+ const onReadyForLinkingHandling = useLatestCallback(() => {
110
+ // If the screen path matches lastUnhandledLink, we do not track it
111
+ const path = refContainer.current?.getCurrentRoute()?.path;
112
+ setLastUnhandledLink((previousLastUnhandledLink) => {
113
+ if (previousLastUnhandledLink === path) {
114
+ return undefined;
115
+ }
116
+ return previousLastUnhandledLink;
117
+ });
118
+ onReady?.();
79
119
  });
80
120
 
121
+ const onStateChangeForLinkingHandling = useLatestCallback(
122
+ (state: Readonly<NavigationState> | undefined) => {
123
+ // If the screen path matches lastUnhandledLink, we do not track it
124
+ const path = refContainer.current?.getCurrentRoute()?.path;
125
+ setLastUnhandledLink((previousLastUnhandledLink) => {
126
+ if (previousLastUnhandledLink === path) {
127
+ return undefined;
128
+ }
129
+ return previousLastUnhandledLink;
130
+ });
131
+ onStateChange?.(state);
132
+ }
133
+ );
81
134
  // Add additional linking related info to the ref
82
135
  // This will be used by the devtools
83
136
  React.useEffect(() => {
@@ -102,8 +155,6 @@ function NavigationContainerInner(
102
155
 
103
156
  React.useImperativeHandle(ref, () => refContainer.current);
104
157
 
105
- const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);
106
-
107
158
  const isLinkingReady =
108
159
  rest.initialState != null || !isLinkingEnabled || isResolved;
109
160
 
@@ -114,26 +165,29 @@ function NavigationContainerInner(
114
165
  }
115
166
 
116
167
  return (
117
- <LinkingContext.Provider value={linkingContext}>
118
- <ThemeProvider value={theme}>
119
- <BaseNavigationContainer
120
- {...rest}
121
- initialState={
122
- rest.initialState == null ? initialState : rest.initialState
123
- }
124
- ref={refContainer}
125
- />
126
- </ThemeProvider>
127
- </LinkingContext.Provider>
168
+ <LocaleDirContext.Provider value={direction}>
169
+ <UnhandledLinkingContext.Provider value={unhandledLinkingContext}>
170
+ <LinkingContext.Provider value={linkingContext}>
171
+ <BaseNavigationContainer
172
+ {...rest}
173
+ theme={theme}
174
+ onReady={onReadyForLinkingHandling}
175
+ onStateChange={onStateChangeForLinkingHandling}
176
+ initialState={
177
+ rest.initialState == null ? initialState : rest.initialState
178
+ }
179
+ ref={refContainer}
180
+ />
181
+ </LinkingContext.Provider>
182
+ </UnhandledLinkingContext.Provider>
183
+ </LocaleDirContext.Provider>
128
184
  );
129
185
  }
130
186
 
131
- const NavigationContainer = React.forwardRef(NavigationContainerInner) as <
132
- RootParamList extends {} = ReactNavigation.RootParamList
133
- >(
187
+ export const NavigationContainer = React.forwardRef(
188
+ NavigationContainerInner
189
+ ) as <RootParamList extends {} = ReactNavigation.RootParamList>(
134
190
  props: Props<RootParamList> & {
135
191
  ref?: React.Ref<NavigationContainerRef<RootParamList>>;
136
192
  }
137
193
  ) => React.ReactElement;
138
-
139
- export default NavigationContainer;
@@ -1,7 +1,7 @@
1
1
  import { CurrentRenderContext } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
3
 
4
- import ServerContext, { ServerContextType } from './ServerContext';
4
+ import { ServerContext, type ServerContextType } from './ServerContext';
5
5
  import type { ServerContainerRef } from './types';
6
6
 
7
7
  type Props = ServerContextType & {
@@ -15,7 +15,7 @@ type Props = ServerContextType & {
15
15
  * @param props.children Child elements to render the content.
16
16
  * @param props.ref Ref object which contains helper methods.
17
17
  */
18
- export default React.forwardRef(function ServerContainer(
18
+ export const ServerContainer = React.forwardRef(function ServerContainer(
19
19
  { children, location }: Props,
20
20
  ref: React.Ref<ServerContainerRef>
21
21
  ) {
@@ -7,8 +7,6 @@ export type ServerContextType = {
7
7
  };
8
8
  };
9
9
 
10
- const ServerContext = React.createContext<ServerContextType | undefined>(
10
+ export const ServerContext = React.createContext<ServerContextType | undefined>(
11
11
  undefined
12
12
  );
13
-
14
- export default ServerContext;
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+
3
+ const MISSING_CONTEXT_ERROR =
4
+ "Couldn't find an UnhandledLinkingContext context.";
5
+
6
+ export const UnhandledLinkingContext = React.createContext<{
7
+ lastUnhandledLink: string | undefined;
8
+ setLastUnhandledLink: (lastUnhandledUrl: string | undefined) => void;
9
+ }>({
10
+ get lastUnhandledLink(): any {
11
+ throw new Error(MISSING_CONTEXT_ERROR);
12
+ },
13
+ get setLastUnhandledLink(): any {
14
+ throw new Error(MISSING_CONTEXT_ERROR);
15
+ },
16
+ });
17
+
18
+ UnhandledLinkingContext.displayName = 'UnhandledLinkingContext';
@@ -5,7 +5,7 @@ import {
5
5
  } from '@react-navigation/core';
6
6
  import * as React from 'react';
7
7
 
8
- const createStackNavigator = createNavigatorFactory((props) => {
8
+ export const createStackNavigator = createNavigatorFactory((props) => {
9
9
  const { state, descriptors, NavigationContent } = useNavigationBuilder(
10
10
  StackRouter,
11
11
  props
@@ -17,5 +17,3 @@ const createStackNavigator = createNavigatorFactory((props) => {
17
17
  </NavigationContent>
18
18
  );
19
19
  });
20
-
21
- export default createStackNavigator;
@@ -1,4 +1,4 @@
1
- const location = new URL('', 'http://example.com');
1
+ let location = new URL('', 'http://example.com');
2
2
 
3
3
  let listeners: (() => void)[] = [];
4
4
  let entries = [{ state: null, href: location.href }];
@@ -12,7 +12,7 @@ const history = {
12
12
  },
13
13
 
14
14
  pushState(state: any, _: string, path: string) {
15
- Object.assign(location, new URL(path, location.origin));
15
+ location = new URL(path, location.origin);
16
16
 
17
17
  currentState = state;
18
18
  entries = entries.slice(0, index + 1);
@@ -21,7 +21,7 @@ const history = {
21
21
  },
22
22
 
23
23
  replaceState(state: any, _: string, path: string) {
24
- Object.assign(location, new URL(path, location.origin));
24
+ location = new URL(path, location.origin);
25
25
 
26
26
  currentState = state;
27
27
  entries[index] = { state, href: location.href };
@@ -35,7 +35,7 @@ const history = {
35
35
  ) {
36
36
  index += n;
37
37
  const entry = entries[index];
38
- Object.assign(location, new URL(entry.href));
38
+ location = new URL(entry.href);
39
39
  currentState = entry.state;
40
40
  listeners.forEach((cb) => cb());
41
41
  }
@@ -63,9 +63,11 @@ const removeEventListener = (type: 'popstate', listener: () => void) => {
63
63
  }
64
64
  };
65
65
 
66
- const window = {
66
+ export const window = {
67
67
  document: { title: '' },
68
- location,
68
+ get location() {
69
+ return location;
70
+ },
69
71
  history,
70
72
  addEventListener,
71
73
  removeEventListener,
@@ -73,5 +75,3 @@ const window = {
73
75
  return window;
74
76
  },
75
77
  };
76
-
77
- export default window;
@@ -10,7 +10,7 @@ type HistoryRecord = {
10
10
  path: string;
11
11
  };
12
12
 
13
- export default function createMemoryHistory() {
13
+ export function createMemoryHistory() {
14
14
  let index = 0;
15
15
  let items: HistoryRecord[] = [];
16
16