@amazon-devices/react-navigation__native 7.0.1759135970 → 8.0.9000000000

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 (230) hide show
  1. package/SystemBundles/0fc5c971c5cf41a0dab235bcc6d58e5c06d9aaff650fa9815b525f8b9bb70a03.bundle +9116 -0
  2. package/SystemBundles/0fc5c971c5cf41a0dab235bcc6d58e5c06d9aaff650fa9815b525f8b9bb70a03.map +3543 -0
  3. package/SystemModules/amzn__react-navigation__native-8.modules.txt +24 -0
  4. package/SystemModules/amzn__react-navigation__native-8.private.modules.txt +77 -0
  5. package/SystemModules/keplerscript-system-bundle-config.json +4 -4
  6. package/kepler-compatibility.json +2 -2
  7. package/lib/module/Link.js +31 -10
  8. package/lib/module/Link.js.map +1 -1
  9. package/lib/module/LinkingContext.js +7 -3
  10. package/lib/module/LinkingContext.js.map +1 -1
  11. package/lib/module/LocaleDirContext.js +6 -0
  12. package/lib/module/LocaleDirContext.js.map +1 -0
  13. package/lib/module/NavigationContainer.js +87 -59
  14. package/lib/module/NavigationContainer.js.map +1 -1
  15. package/lib/module/ServerContainer.js +20 -10
  16. package/lib/module/ServerContainer.js.map +1 -1
  17. package/lib/module/ServerContext.js +3 -2
  18. package/lib/module/ServerContext.js.map +1 -1
  19. package/lib/module/UnhandledLinkingContext.js +14 -0
  20. package/lib/module/UnhandledLinkingContext.js.map +1 -0
  21. package/lib/module/__stubs__/createStackNavigator.js +18 -0
  22. package/lib/module/__stubs__/createStackNavigator.js.map +1 -0
  23. package/lib/module/__stubs__/window.js +75 -0
  24. package/lib/module/__stubs__/window.js.map +1 -0
  25. package/lib/module/createMemoryHistory.js +19 -17
  26. package/lib/module/createMemoryHistory.js.map +1 -1
  27. package/lib/module/createStaticNavigation.js +54 -0
  28. package/lib/module/createStaticNavigation.js.map +1 -0
  29. package/lib/module/extractPathFromURL.js +6 -5
  30. package/lib/module/extractPathFromURL.js.map +1 -1
  31. package/lib/module/index.js +18 -13
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/package.json +1 -0
  34. package/lib/module/theming/DarkTheme.js +6 -3
  35. package/lib/module/theming/DarkTheme.js.map +1 -1
  36. package/lib/module/theming/DefaultTheme.js +6 -3
  37. package/lib/module/theming/DefaultTheme.js.map +1 -1
  38. package/lib/module/theming/fonts.js +61 -0
  39. package/lib/module/theming/fonts.js.map +1 -0
  40. package/lib/module/types.js +2 -0
  41. package/lib/module/types.js.map +1 -1
  42. package/lib/module/useBackButton.js +3 -1
  43. package/lib/module/useBackButton.js.map +1 -1
  44. package/lib/module/useBackButton.native.js +3 -1
  45. package/lib/module/useBackButton.native.js.map +1 -1
  46. package/lib/module/useDocumentTitle.js +6 -4
  47. package/lib/module/useDocumentTitle.js.map +1 -1
  48. package/lib/module/useDocumentTitle.native.js +4 -2
  49. package/lib/module/useDocumentTitle.native.js.map +1 -1
  50. package/lib/module/useLinkBuilder.js +71 -40
  51. package/lib/module/useLinkBuilder.js.map +1 -1
  52. package/lib/module/useLinkProps.js +41 -36
  53. package/lib/module/useLinkProps.js.map +1 -1
  54. package/lib/module/useLinkTo.js +18 -28
  55. package/lib/module/useLinkTo.js.map +1 -1
  56. package/lib/module/useLinking.js +47 -19
  57. package/lib/module/useLinking.js.map +1 -1
  58. package/lib/module/useLinking.native.js +33 -28
  59. package/lib/module/useLinking.native.js.map +1 -1
  60. package/lib/module/useLocale.js +18 -0
  61. package/lib/module/useLocale.js.map +1 -0
  62. package/lib/module/useRoutePath.js +30 -0
  63. package/lib/module/useRoutePath.js.map +1 -0
  64. package/lib/module/useScrollToTop.js +11 -7
  65. package/lib/module/useScrollToTop.js.map +1 -1
  66. package/lib/module/useThenable.js +4 -1
  67. package/lib/module/useThenable.js.map +1 -1
  68. package/lib/typescript/package.json +1 -0
  69. package/lib/typescript/src/Link.d.ts +8 -10
  70. package/lib/typescript/src/Link.d.ts.map +1 -1
  71. package/lib/typescript/src/LinkingContext.d.ts +2 -3
  72. package/lib/typescript/src/LinkingContext.d.ts.map +1 -1
  73. package/lib/typescript/src/LocaleDirContext.d.ts +4 -0
  74. package/lib/typescript/src/LocaleDirContext.d.ts.map +1 -0
  75. package/lib/typescript/src/NavigationContainer.d.ts +36 -13
  76. package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
  77. package/lib/typescript/src/ServerContainer.d.ts +2 -3
  78. package/lib/typescript/src/ServerContainer.d.ts.map +1 -1
  79. package/lib/typescript/src/ServerContext.d.ts +1 -2
  80. package/lib/typescript/src/ServerContext.d.ts.map +1 -1
  81. package/lib/typescript/src/UnhandledLinkingContext.d.ts +6 -0
  82. package/lib/typescript/src/UnhandledLinkingContext.d.ts.map +1 -0
  83. package/lib/typescript/src/__stubs__/createStackNavigator.d.ts +13 -0
  84. package/lib/typescript/src/__stubs__/createStackNavigator.d.ts.map +1 -0
  85. package/lib/typescript/src/{__mocks__ → __stubs__}/window.d.ts +5 -6
  86. package/lib/typescript/src/__stubs__/window.d.ts.map +1 -0
  87. package/lib/typescript/src/createMemoryHistory.d.ts +1 -1
  88. package/lib/typescript/src/createMemoryHistory.d.ts.map +1 -1
  89. package/lib/typescript/src/createStaticNavigation.d.ts +34 -0
  90. package/lib/typescript/src/createStaticNavigation.d.ts.map +1 -0
  91. package/lib/typescript/src/extractPathFromURL.d.ts +1 -1
  92. package/lib/typescript/src/extractPathFromURL.d.ts.map +1 -1
  93. package/lib/typescript/src/index.d.ts +15 -12
  94. package/lib/typescript/src/index.d.ts.map +1 -1
  95. package/lib/typescript/src/theming/DarkTheme.d.ts +1 -2
  96. package/lib/typescript/src/theming/DarkTheme.d.ts.map +1 -1
  97. package/lib/typescript/src/theming/DefaultTheme.d.ts +1 -2
  98. package/lib/typescript/src/theming/DefaultTheme.d.ts.map +1 -1
  99. package/lib/typescript/src/theming/fonts.d.ts +53 -0
  100. package/lib/typescript/src/theming/fonts.d.ts.map +1 -0
  101. package/lib/typescript/src/types.d.ts +35 -3
  102. package/lib/typescript/src/types.d.ts.map +1 -1
  103. package/lib/typescript/src/useBackButton.d.ts +1 -2
  104. package/lib/typescript/src/useBackButton.d.ts.map +1 -1
  105. package/lib/typescript/src/useBackButton.native.d.ts +1 -1
  106. package/lib/typescript/src/useBackButton.native.d.ts.map +1 -1
  107. package/lib/typescript/src/useDocumentTitle.d.ts +1 -1
  108. package/lib/typescript/src/useDocumentTitle.d.ts.map +1 -1
  109. package/lib/typescript/src/useDocumentTitle.native.d.ts +1 -1
  110. package/lib/typescript/src/useDocumentTitle.native.d.ts.map +1 -1
  111. package/lib/typescript/src/useLinkBuilder.d.ts +97 -3
  112. package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -1
  113. package/lib/typescript/src/useLinkProps.d.ts +23 -10
  114. package/lib/typescript/src/useLinkProps.d.ts.map +1 -1
  115. package/lib/typescript/src/useLinkTo.d.ts +6 -8
  116. package/lib/typescript/src/useLinkTo.d.ts.map +1 -1
  117. package/lib/typescript/src/useLinking.d.ts +5 -46
  118. package/lib/typescript/src/useLinking.d.ts.map +1 -1
  119. package/lib/typescript/src/useLinking.native.d.ts +11 -29
  120. package/lib/typescript/src/useLinking.native.d.ts.map +1 -1
  121. package/lib/typescript/src/useLocale.d.ts +7 -0
  122. package/lib/typescript/src/useLocale.d.ts.map +1 -0
  123. package/lib/typescript/src/useRoutePath.d.ts +7 -0
  124. package/lib/typescript/src/useRoutePath.d.ts.map +1 -0
  125. package/lib/typescript/src/useScrollToTop.d.ts +2 -2
  126. package/lib/typescript/src/useScrollToTop.d.ts.map +1 -1
  127. package/lib/typescript/src/useThenable.d.ts +1 -1
  128. package/lib/typescript/src/useThenable.d.ts.map +1 -1
  129. package/package.json +1 -1
  130. package/src/Link.tsx +36 -20
  131. package/src/LinkingContext.tsx +9 -5
  132. package/src/LocaleDirContext.tsx +7 -0
  133. package/src/NavigationContainer.tsx +128 -69
  134. package/src/ServerContainer.tsx +4 -3
  135. package/src/ServerContext.tsx +1 -3
  136. package/src/UnhandledLinkingContext.tsx +18 -0
  137. package/src/__stubs__/createStackNavigator.tsx +46 -0
  138. package/src/{__mocks__ → __stubs__}/window.tsx +8 -8
  139. package/src/createMemoryHistory.tsx +16 -11
  140. package/src/createStaticNavigation.tsx +109 -0
  141. package/src/extractPathFromURL.tsx +3 -3
  142. package/src/index.tsx +15 -12
  143. package/src/theming/DarkTheme.tsx +3 -3
  144. package/src/theming/DefaultTheme.tsx +3 -3
  145. package/src/theming/fonts.tsx +63 -0
  146. package/src/types.tsx +49 -3
  147. package/src/useBackButton.native.tsx +2 -2
  148. package/src/useBackButton.tsx +2 -2
  149. package/src/useDocumentTitle.native.tsx +2 -2
  150. package/src/useDocumentTitle.tsx +2 -2
  151. package/src/useLinkBuilder.tsx +100 -55
  152. package/src/useLinkProps.tsx +80 -50
  153. package/src/useLinkTo.tsx +13 -53
  154. package/src/useLinking.native.tsx +33 -31
  155. package/src/useLinking.tsx +70 -23
  156. package/src/useLocale.tsx +18 -0
  157. package/src/useRoutePath.tsx +34 -0
  158. package/src/useScrollToTop.tsx +16 -12
  159. package/src/useThenable.tsx +2 -1
  160. package/SystemBundles/8f36606502d3b658fa1ffc07fee4da0e39a8ce388742799c9ccdb66b39ef0362.bundle +0 -15196
  161. package/SystemBundles/8f36606502d3b658fa1ffc07fee4da0e39a8ce388742799c9ccdb66b39ef0362.map +0 -1
  162. package/SystemModules/amzn__react-navigation__native-7.modules.txt +0 -76
  163. package/SystemModules/amzn__react-navigation__native-7.private.modules.txt +0 -101
  164. package/THIRD_PARTY_NOTICES.txt +0 -24
  165. package/lib/commonjs/Link.js +0 -50
  166. package/lib/commonjs/Link.js.map +0 -1
  167. package/lib/commonjs/LinkingContext.js +0 -15
  168. package/lib/commonjs/LinkingContext.js.map +0 -1
  169. package/lib/commonjs/NavigationContainer.js +0 -109
  170. package/lib/commonjs/NavigationContainer.js.map +0 -1
  171. package/lib/commonjs/ServerContainer.js +0 -54
  172. package/lib/commonjs/ServerContainer.js.map +0 -1
  173. package/lib/commonjs/ServerContext.js +0 -12
  174. package/lib/commonjs/ServerContext.js.map +0 -1
  175. package/lib/commonjs/createMemoryHistory.js +0 -220
  176. package/lib/commonjs/createMemoryHistory.js.map +0 -1
  177. package/lib/commonjs/extractPathFromURL.js +0 -25
  178. package/lib/commonjs/extractPathFromURL.js.map +0 -1
  179. package/lib/commonjs/index.js +0 -129
  180. package/lib/commonjs/index.js.map +0 -1
  181. package/lib/commonjs/theming/DarkTheme.js +0 -19
  182. package/lib/commonjs/theming/DarkTheme.js.map +0 -1
  183. package/lib/commonjs/theming/DefaultTheme.js +0 -19
  184. package/lib/commonjs/theming/DefaultTheme.js.map +0 -1
  185. package/lib/commonjs/theming/ThemeContext.js +0 -15
  186. package/lib/commonjs/theming/ThemeContext.js.map +0 -1
  187. package/lib/commonjs/theming/ThemeProvider.js +0 -20
  188. package/lib/commonjs/theming/ThemeProvider.js.map +0 -1
  189. package/lib/commonjs/theming/useTheme.js +0 -16
  190. package/lib/commonjs/theming/useTheme.js.map +0 -1
  191. package/lib/commonjs/types.js +0 -6
  192. package/lib/commonjs/types.js.map +0 -1
  193. package/lib/commonjs/useBackButton.js +0 -11
  194. package/lib/commonjs/useBackButton.js.map +0 -1
  195. package/lib/commonjs/useBackButton.native.js +0 -27
  196. package/lib/commonjs/useBackButton.native.js.map +0 -1
  197. package/lib/commonjs/useDocumentTitle.js +0 -32
  198. package/lib/commonjs/useDocumentTitle.js.map +0 -1
  199. package/lib/commonjs/useDocumentTitle.native.js +0 -10
  200. package/lib/commonjs/useDocumentTitle.native.js.map +0 -1
  201. package/lib/commonjs/useLinkBuilder.js +0 -63
  202. package/lib/commonjs/useLinkBuilder.js.map +0 -1
  203. package/lib/commonjs/useLinkProps.js +0 -97
  204. package/lib/commonjs/useLinkProps.js.map +0 -1
  205. package/lib/commonjs/useLinkTo.js +0 -45
  206. package/lib/commonjs/useLinkTo.js.map +0 -1
  207. package/lib/commonjs/useLinking.js +0 -303
  208. package/lib/commonjs/useLinking.js.map +0 -1
  209. package/lib/commonjs/useLinking.native.js +0 -152
  210. package/lib/commonjs/useLinking.native.js.map +0 -1
  211. package/lib/commonjs/useScrollToTop.js +0 -95
  212. package/lib/commonjs/useScrollToTop.js.map +0 -1
  213. package/lib/commonjs/useThenable.js +0 -41
  214. package/lib/commonjs/useThenable.js.map +0 -1
  215. package/lib/module/theming/ThemeContext.js +0 -6
  216. package/lib/module/theming/ThemeContext.js.map +0 -1
  217. package/lib/module/theming/ThemeProvider.js +0 -11
  218. package/lib/module/theming/ThemeProvider.js.map +0 -1
  219. package/lib/module/theming/useTheme.js +0 -7
  220. package/lib/module/theming/useTheme.js.map +0 -1
  221. package/lib/typescript/src/__mocks__/window.d.ts.map +0 -1
  222. package/lib/typescript/src/theming/ThemeContext.d.ts +0 -5
  223. package/lib/typescript/src/theming/ThemeContext.d.ts.map +0 -1
  224. package/lib/typescript/src/theming/ThemeProvider.d.ts +0 -9
  225. package/lib/typescript/src/theming/ThemeProvider.d.ts.map +0 -1
  226. package/lib/typescript/src/theming/useTheme.d.ts +0 -2
  227. package/lib/typescript/src/theming/useTheme.d.ts.map +0 -1
  228. package/src/theming/ThemeContext.tsx +0 -10
  229. package/src/theming/ThemeProvider.tsx +0 -15
  230. package/src/theming/useTheme.tsx +0 -9
@@ -1,7 +1,8 @@
1
1
  import {
2
- EventArg,
3
- NavigationProp,
4
- useNavigation,
2
+ type EventArg,
3
+ NavigationContext,
4
+ type NavigationProp,
5
+ type ParamListBase,
5
6
  useRoute,
6
7
  } from '@amazon-devices/react-navigation__core';
7
8
  import * as React from 'react';
@@ -12,7 +13,7 @@ type ScrollOptions = { x?: number; y?: number; animated?: boolean };
12
13
  type ScrollableView =
13
14
  | { scrollToTop(): void }
14
15
  | { scrollTo(options: ScrollOptions): void }
15
- | { scrollToOffset(options: { offset?: number; animated?: boolean }): void }
16
+ | { scrollToOffset(options: { offset: number; animated?: boolean }): void }
16
17
  | { scrollResponderScrollTo(options: ScrollOptions): void };
17
18
 
18
19
  type ScrollableWrapper =
@@ -38,7 +39,7 @@ function getScrollableNode(ref: React.RefObject<ScrollableWrapper>) {
38
39
  // We need to use `getScrollResponder` to get access to the scroll responder
39
40
  return ref.current.getScrollResponder();
40
41
  } else if ('getNode' in ref.current) {
41
- // When a `ScrollView` is wraped in `Animated.createAnimatedComponent`
42
+ // When a `ScrollView` is wrapped in `Animated.createAnimatedComponent`
42
43
  // we need to use `getNode` to get the ref to the actual scrollview.
43
44
  // Note that `getNode` is deprecated in newer versions of react-native
44
45
  // this is why we check if we already have a scrollable node above.
@@ -48,16 +49,19 @@ function getScrollableNode(ref: React.RefObject<ScrollableWrapper>) {
48
49
  }
49
50
  }
50
51
 
51
- export default function useScrollToTop(
52
- ref: React.RefObject<ScrollableWrapper>
53
- ) {
54
- const navigation = useNavigation();
52
+ export function useScrollToTop(ref: React.RefObject<ScrollableWrapper>) {
53
+ const navigation = React.useContext(NavigationContext);
55
54
  const route = useRoute();
56
55
 
56
+ if (navigation === undefined) {
57
+ throw new Error(
58
+ "Couldn't find a navigation object. Is your component inside NavigationContainer?"
59
+ );
60
+ }
61
+
57
62
  React.useEffect(() => {
58
- let tabNavigations: NavigationProp<ReactNavigation.RootParamList>[] = [];
63
+ const tabNavigations: NavigationProp<ParamListBase>[] = [];
59
64
  let currentNavigation = navigation;
60
-
61
65
  // If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
62
66
  // So we need to find all the parent tab navigators and add the listeners there
63
67
  while (currentNavigation) {
@@ -76,7 +80,7 @@ export default function useScrollToTop(
76
80
  return tab.addListener(
77
81
  // We don't wanna import tab types here to avoid extra deps
78
82
  // in addition, there are multiple tab implementations
79
- // @ts-expect-error
83
+ // @ts-expect-error the `tabPress` event is only available when navigation type is tab
80
84
  'tabPress',
81
85
  (e: EventArg<'tabPress', true>) => {
82
86
  // We should scroll to top only when the screen is focused
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
 
3
- export default function useThenable<T>(create: () => PromiseLike<T>) {
3
+ export function useThenable<T>(create: () => PromiseLike<T>) {
4
4
  const [promise] = React.useState(create);
5
5
 
6
6
  let initialState: [boolean, T | undefined] = [false, undefined];
7
7
 
8
8
  // Check if our thenable is synchronous
9
+ // eslint-disable-next-line promise/catch-or-return, promise/always-return
9
10
  promise.then((result) => {
10
11
  initialState = [true, result];
11
12
  });