@react-navigation/core 7.0.0-alpha.1 → 7.0.0-alpha.11

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 (350) hide show
  1. package/lib/commonjs/BaseNavigationContainer.js +25 -30
  2. package/lib/commonjs/BaseNavigationContainer.js.map +1 -1
  3. package/lib/commonjs/CurrentRenderContext.js +3 -4
  4. package/lib/commonjs/CurrentRenderContext.js.map +1 -1
  5. package/lib/commonjs/DeprecatedNavigationInChildContext.js +3 -4
  6. package/lib/commonjs/DeprecatedNavigationInChildContext.js.map +1 -1
  7. package/lib/commonjs/EnsureSingleNavigator.js +3 -4
  8. package/lib/commonjs/EnsureSingleNavigator.js.map +1 -1
  9. package/lib/commonjs/Group.js.map +1 -1
  10. package/lib/commonjs/NavigationBuilderContext.js +3 -4
  11. package/lib/commonjs/NavigationBuilderContext.js.map +1 -1
  12. package/lib/commonjs/NavigationContainerRefContext.js +3 -4
  13. package/lib/commonjs/NavigationContainerRefContext.js.map +1 -1
  14. package/lib/commonjs/NavigationContext.js +3 -4
  15. package/lib/commonjs/NavigationContext.js.map +1 -1
  16. package/lib/commonjs/NavigationHelpersContext.js +3 -4
  17. package/lib/commonjs/NavigationHelpersContext.js.map +1 -1
  18. package/lib/commonjs/NavigationIndependentTree.js +2 -2
  19. package/lib/commonjs/NavigationIndependentTree.js.map +1 -1
  20. package/lib/commonjs/NavigationIndependentTreeContext.js +3 -4
  21. package/lib/commonjs/NavigationIndependentTreeContext.js.map +1 -1
  22. package/lib/commonjs/NavigationRouteContext.js +3 -4
  23. package/lib/commonjs/NavigationRouteContext.js.map +1 -1
  24. package/lib/commonjs/NavigationStateContext.js +3 -4
  25. package/lib/commonjs/NavigationStateContext.js.map +1 -1
  26. package/lib/commonjs/PreventRemoveContext.js +8 -4
  27. package/lib/commonjs/PreventRemoveContext.js.map +1 -1
  28. package/lib/commonjs/PreventRemoveProvider.js +8 -10
  29. package/lib/commonjs/PreventRemoveProvider.js.map +1 -1
  30. package/lib/commonjs/SceneView.js +2 -2
  31. package/lib/commonjs/SceneView.js.map +1 -1
  32. package/lib/commonjs/Screen.js.map +1 -1
  33. package/lib/commonjs/StaticContainer.js +3 -4
  34. package/lib/commonjs/StaticContainer.js.map +1 -1
  35. package/lib/commonjs/StaticNavigation.js +34 -7
  36. package/lib/commonjs/StaticNavigation.js.map +1 -1
  37. package/lib/commonjs/UnhandledActionContext.js +3 -4
  38. package/lib/commonjs/UnhandledActionContext.js.map +1 -1
  39. package/lib/commonjs/checkDuplicateRouteNames.js +1 -2
  40. package/lib/commonjs/checkDuplicateRouteNames.js.map +1 -1
  41. package/lib/commonjs/checkSerializable.js.map +1 -1
  42. package/lib/commonjs/createNavigationContainerRef.js +1 -2
  43. package/lib/commonjs/createNavigationContainerRef.js.map +1 -1
  44. package/lib/commonjs/createNavigatorFactory.js +0 -3
  45. package/lib/commonjs/createNavigatorFactory.js.map +1 -1
  46. package/lib/commonjs/findFocusedRoute.js +2 -4
  47. package/lib/commonjs/findFocusedRoute.js.map +1 -1
  48. package/lib/commonjs/getActionFromState.js +6 -8
  49. package/lib/commonjs/getActionFromState.js.map +1 -1
  50. package/lib/commonjs/getFocusedRouteNameFromRoute.js +1 -1
  51. package/lib/commonjs/getFocusedRouteNameFromRoute.js.map +1 -1
  52. package/lib/commonjs/getPathFromState.js +25 -22
  53. package/lib/commonjs/getPathFromState.js.map +1 -1
  54. package/lib/commonjs/getStateFromPath.js +63 -21
  55. package/lib/commonjs/getStateFromPath.js.map +1 -1
  56. package/lib/commonjs/index.js +27 -3
  57. package/lib/commonjs/index.js.map +1 -1
  58. package/lib/commonjs/isArrayEqual.js.map +1 -1
  59. package/lib/commonjs/isRecordEqual.js.map +1 -1
  60. package/lib/commonjs/theming/ThemeContext.js +12 -0
  61. package/lib/commonjs/theming/ThemeContext.js.map +1 -0
  62. package/lib/commonjs/theming/ThemeProvider.js +20 -0
  63. package/lib/commonjs/theming/ThemeProvider.js.map +1 -0
  64. package/lib/commonjs/theming/useTheme.js +18 -0
  65. package/lib/commonjs/theming/useTheme.js.map +1 -0
  66. package/lib/commonjs/types.js.map +1 -1
  67. package/lib/commonjs/useChildListeners.js +2 -2
  68. package/lib/commonjs/useChildListeners.js.map +1 -1
  69. package/lib/commonjs/useComponent.js +2 -2
  70. package/lib/commonjs/useComponent.js.map +1 -1
  71. package/lib/commonjs/useCurrentRender.js +2 -2
  72. package/lib/commonjs/useCurrentRender.js.map +1 -1
  73. package/lib/commonjs/useDescriptors.js +83 -31
  74. package/lib/commonjs/useDescriptors.js.map +1 -1
  75. package/lib/commonjs/useEventEmitter.js +5 -6
  76. package/lib/commonjs/useEventEmitter.js.map +1 -1
  77. package/lib/commonjs/useFocusEffect.js +4 -2
  78. package/lib/commonjs/useFocusEffect.js.map +1 -1
  79. package/lib/commonjs/useFocusEvents.js +4 -4
  80. package/lib/commonjs/useFocusEvents.js.map +1 -1
  81. package/lib/commonjs/useFocusedListenersChildrenAdapter.js +3 -3
  82. package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -1
  83. package/lib/commonjs/useIsFocused.js +5 -4
  84. package/lib/commonjs/useIsFocused.js.map +1 -1
  85. package/lib/commonjs/useIsomorphicLayoutEffect.js +12 -0
  86. package/lib/commonjs/useIsomorphicLayoutEffect.js.map +1 -0
  87. package/lib/commonjs/useIsomorphicLayoutEffect.native.js +9 -0
  88. package/lib/commonjs/useIsomorphicLayoutEffect.native.js.map +1 -0
  89. package/lib/commonjs/useKeyedChildListeners.js +2 -2
  90. package/lib/commonjs/useKeyedChildListeners.js.map +1 -1
  91. package/lib/commonjs/useNavigation.js +2 -2
  92. package/lib/commonjs/useNavigation.js.map +1 -1
  93. package/lib/commonjs/useNavigationBuilder.js +81 -68
  94. package/lib/commonjs/useNavigationBuilder.js.map +1 -1
  95. package/lib/commonjs/useNavigationCache.js +57 -16
  96. package/lib/commonjs/useNavigationCache.js.map +1 -1
  97. package/lib/commonjs/useNavigationContainerRef.js +2 -2
  98. package/lib/commonjs/useNavigationContainerRef.js.map +1 -1
  99. package/lib/commonjs/useNavigationHelpers.js +4 -5
  100. package/lib/commonjs/useNavigationHelpers.js.map +1 -1
  101. package/lib/commonjs/useNavigationIndependentTree.js +2 -2
  102. package/lib/commonjs/useNavigationIndependentTree.js.map +1 -1
  103. package/lib/commonjs/useNavigationState.js +2 -2
  104. package/lib/commonjs/useNavigationState.js.map +1 -1
  105. package/lib/commonjs/useOnAction.js +6 -4
  106. package/lib/commonjs/useOnAction.js.map +1 -1
  107. package/lib/commonjs/useOnGetState.js +4 -5
  108. package/lib/commonjs/useOnGetState.js.map +1 -1
  109. package/lib/commonjs/useOnPreventRemove.js +5 -6
  110. package/lib/commonjs/useOnPreventRemove.js.map +1 -1
  111. package/lib/commonjs/useOnRouteFocus.js +2 -2
  112. package/lib/commonjs/useOnRouteFocus.js.map +1 -1
  113. package/lib/commonjs/useOptionsGetters.js +9 -10
  114. package/lib/commonjs/useOptionsGetters.js.map +1 -1
  115. package/lib/commonjs/usePreventRemove.js +5 -5
  116. package/lib/commonjs/usePreventRemove.js.map +1 -1
  117. package/lib/commonjs/usePreventRemoveContext.js +2 -2
  118. package/lib/commonjs/usePreventRemoveContext.js.map +1 -1
  119. package/lib/commonjs/useRegisterNavigator.js +2 -2
  120. package/lib/commonjs/useRegisterNavigator.js.map +1 -1
  121. package/lib/commonjs/useRoute.js +2 -2
  122. package/lib/commonjs/useRoute.js.map +1 -1
  123. package/lib/commonjs/useRouteCache.js +19 -16
  124. package/lib/commonjs/useRouteCache.js.map +1 -1
  125. package/lib/commonjs/useSyncState.js +27 -56
  126. package/lib/commonjs/useSyncState.js.map +1 -1
  127. package/lib/commonjs/validatePathConfig.js +37 -10
  128. package/lib/commonjs/validatePathConfig.js.map +1 -1
  129. package/lib/module/BaseNavigationContainer.js +22 -26
  130. package/lib/module/BaseNavigationContainer.js.map +1 -1
  131. package/lib/module/CurrentRenderContext.js.map +1 -1
  132. package/lib/module/DeprecatedNavigationInChildContext.js.map +1 -1
  133. package/lib/module/EnsureSingleNavigator.js.map +1 -1
  134. package/lib/module/Group.js.map +1 -1
  135. package/lib/module/NavigationBuilderContext.js.map +1 -1
  136. package/lib/module/NavigationContainerRefContext.js.map +1 -1
  137. package/lib/module/NavigationContext.js.map +1 -1
  138. package/lib/module/NavigationHelpersContext.js.map +1 -1
  139. package/lib/module/NavigationIndependentTree.js.map +1 -1
  140. package/lib/module/NavigationIndependentTreeContext.js.map +1 -1
  141. package/lib/module/NavigationRouteContext.js.map +1 -1
  142. package/lib/module/NavigationStateContext.js.map +1 -1
  143. package/lib/module/PreventRemoveContext.js.map +1 -1
  144. package/lib/module/PreventRemoveProvider.js +6 -8
  145. package/lib/module/PreventRemoveProvider.js.map +1 -1
  146. package/lib/module/SceneView.js.map +1 -1
  147. package/lib/module/Screen.js.map +1 -1
  148. package/lib/module/StaticContainer.js.map +1 -1
  149. package/lib/module/StaticNavigation.js +27 -5
  150. package/lib/module/StaticNavigation.js.map +1 -1
  151. package/lib/module/UnhandledActionContext.js.map +1 -1
  152. package/lib/module/checkDuplicateRouteNames.js +1 -2
  153. package/lib/module/checkDuplicateRouteNames.js.map +1 -1
  154. package/lib/module/checkSerializable.js.map +1 -1
  155. package/lib/module/createNavigationContainerRef.js.map +1 -1
  156. package/lib/module/createNavigatorFactory.js +0 -3
  157. package/lib/module/createNavigatorFactory.js.map +1 -1
  158. package/lib/module/findFocusedRoute.js +2 -4
  159. package/lib/module/findFocusedRoute.js.map +1 -1
  160. package/lib/module/getActionFromState.js +6 -8
  161. package/lib/module/getActionFromState.js.map +1 -1
  162. package/lib/module/getFocusedRouteNameFromRoute.js +1 -1
  163. package/lib/module/getFocusedRouteNameFromRoute.js.map +1 -1
  164. package/lib/module/getPathFromState.js +23 -20
  165. package/lib/module/getPathFromState.js.map +1 -1
  166. package/lib/module/getStateFromPath.js +61 -19
  167. package/lib/module/getStateFromPath.js.map +1 -1
  168. package/lib/module/index.js +4 -1
  169. package/lib/module/index.js.map +1 -1
  170. package/lib/module/isArrayEqual.js.map +1 -1
  171. package/lib/module/isRecordEqual.js.map +1 -1
  172. package/lib/module/theming/ThemeContext.js +4 -0
  173. package/lib/module/theming/ThemeContext.js.map +1 -0
  174. package/lib/module/theming/ThemeProvider.js +12 -0
  175. package/lib/module/theming/ThemeProvider.js.map +1 -0
  176. package/lib/module/theming/useTheme.js +10 -0
  177. package/lib/module/theming/useTheme.js.map +1 -0
  178. package/lib/module/types.js.map +1 -1
  179. package/lib/module/useChildListeners.js.map +1 -1
  180. package/lib/module/useComponent.js.map +1 -1
  181. package/lib/module/useCurrentRender.js.map +1 -1
  182. package/lib/module/useDescriptors.js +81 -29
  183. package/lib/module/useDescriptors.js.map +1 -1
  184. package/lib/module/useEventEmitter.js +3 -4
  185. package/lib/module/useEventEmitter.js.map +1 -1
  186. package/lib/module/useFocusEffect.js +2 -0
  187. package/lib/module/useFocusEffect.js.map +1 -1
  188. package/lib/module/useFocusEvents.js +2 -2
  189. package/lib/module/useFocusEvents.js.map +1 -1
  190. package/lib/module/useFocusedListenersChildrenAdapter.js +1 -1
  191. package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
  192. package/lib/module/useIsFocused.js.map +1 -1
  193. package/lib/module/useIsomorphicLayoutEffect.js +7 -0
  194. package/lib/module/useIsomorphicLayoutEffect.js.map +1 -0
  195. package/lib/module/useIsomorphicLayoutEffect.native.js +3 -0
  196. package/lib/module/useIsomorphicLayoutEffect.native.js.map +1 -0
  197. package/lib/module/useKeyedChildListeners.js.map +1 -1
  198. package/lib/module/useNavigation.js.map +1 -1
  199. package/lib/module/useNavigationBuilder.js +78 -66
  200. package/lib/module/useNavigationBuilder.js.map +1 -1
  201. package/lib/module/useNavigationCache.js +55 -14
  202. package/lib/module/useNavigationCache.js.map +1 -1
  203. package/lib/module/useNavigationContainerRef.js.map +1 -1
  204. package/lib/module/useNavigationHelpers.js +2 -3
  205. package/lib/module/useNavigationHelpers.js.map +1 -1
  206. package/lib/module/useNavigationIndependentTree.js.map +1 -1
  207. package/lib/module/useNavigationState.js.map +1 -1
  208. package/lib/module/useOnAction.js +4 -2
  209. package/lib/module/useOnAction.js.map +1 -1
  210. package/lib/module/useOnGetState.js +2 -3
  211. package/lib/module/useOnGetState.js.map +1 -1
  212. package/lib/module/useOnPreventRemove.js +3 -4
  213. package/lib/module/useOnPreventRemove.js.map +1 -1
  214. package/lib/module/useOnRouteFocus.js.map +1 -1
  215. package/lib/module/useOptionsGetters.js +7 -8
  216. package/lib/module/useOptionsGetters.js.map +1 -1
  217. package/lib/module/usePreventRemove.js +2 -2
  218. package/lib/module/usePreventRemove.js.map +1 -1
  219. package/lib/module/usePreventRemoveContext.js.map +1 -1
  220. package/lib/module/useRegisterNavigator.js.map +1 -1
  221. package/lib/module/useRoute.js.map +1 -1
  222. package/lib/module/useRouteCache.js +16 -12
  223. package/lib/module/useRouteCache.js.map +1 -1
  224. package/lib/module/useSyncState.js +25 -54
  225. package/lib/module/useSyncState.js.map +1 -1
  226. package/lib/module/validatePathConfig.js +37 -10
  227. package/lib/module/validatePathConfig.js.map +1 -1
  228. package/lib/typescript/src/BaseNavigationContainer.d.ts +2 -1
  229. package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
  230. package/lib/typescript/src/EnsureSingleNavigator.d.ts +1 -1
  231. package/lib/typescript/src/EnsureSingleNavigator.d.ts.map +1 -1
  232. package/lib/typescript/src/NavigationContext.d.ts +1 -17
  233. package/lib/typescript/src/NavigationContext.d.ts.map +1 -1
  234. package/lib/typescript/src/NavigationHelpersContext.d.ts +1 -1
  235. package/lib/typescript/src/NavigationHelpersContext.d.ts.map +1 -1
  236. package/lib/typescript/src/NavigationIndependentTree.d.ts +1 -1
  237. package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
  238. package/lib/typescript/src/NavigationRouteContext.d.ts +1 -1
  239. package/lib/typescript/src/NavigationRouteContext.d.ts.map +1 -1
  240. package/lib/typescript/src/NavigationStateContext.d.ts +2 -18
  241. package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -1
  242. package/lib/typescript/src/PreventRemoveProvider.d.ts +1 -1
  243. package/lib/typescript/src/PreventRemoveProvider.d.ts.map +1 -1
  244. package/lib/typescript/src/SceneView.d.ts +2 -2
  245. package/lib/typescript/src/SceneView.d.ts.map +1 -1
  246. package/lib/typescript/src/StaticNavigation.d.ts +12 -5
  247. package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
  248. package/lib/typescript/src/createNavigatorFactory.d.ts.map +1 -1
  249. package/lib/typescript/src/findFocusedRoute.d.ts +1 -9
  250. package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
  251. package/lib/typescript/src/getPathFromState.d.ts +1 -0
  252. package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
  253. package/lib/typescript/src/getStateFromPath.d.ts +1 -0
  254. package/lib/typescript/src/getStateFromPath.d.ts.map +1 -1
  255. package/lib/typescript/src/index.d.ts +5 -2
  256. package/lib/typescript/src/index.d.ts.map +1 -1
  257. package/lib/typescript/src/theming/ThemeContext.d.ts +3 -0
  258. package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -0
  259. package/lib/typescript/src/theming/ThemeProvider.d.ts +8 -0
  260. package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -0
  261. package/lib/typescript/src/theming/useTheme.d.ts +2 -0
  262. package/lib/typescript/src/theming/useTheme.d.ts.map +1 -0
  263. package/lib/typescript/src/types.d.ts +80 -1
  264. package/lib/typescript/src/types.d.ts.map +1 -1
  265. package/lib/typescript/src/useComponent.d.ts +1 -1
  266. package/lib/typescript/src/useComponent.d.ts.map +1 -1
  267. package/lib/typescript/src/useDescriptors.d.ts +107 -59
  268. package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
  269. package/lib/typescript/src/useFocusEffect.d.ts.map +1 -1
  270. package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +1 -1
  271. package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts.map +1 -1
  272. package/lib/typescript/src/useIsomorphicLayoutEffect.d.ts +6 -0
  273. package/lib/typescript/src/useIsomorphicLayoutEffect.d.ts.map +1 -0
  274. package/lib/typescript/src/useIsomorphicLayoutEffect.native.d.ts +3 -0
  275. package/lib/typescript/src/useIsomorphicLayoutEffect.native.d.ts.map +1 -0
  276. package/lib/typescript/src/useNavigation.d.ts +4 -1
  277. package/lib/typescript/src/useNavigation.d.ts.map +1 -1
  278. package/lib/typescript/src/useNavigationBuilder.d.ts +99 -63
  279. package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
  280. package/lib/typescript/src/useNavigationCache.d.ts +53 -3
  281. package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
  282. package/lib/typescript/src/useNavigationHelpers.d.ts +25 -55
  283. package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
  284. package/lib/typescript/src/useOnAction.d.ts +1 -1
  285. package/lib/typescript/src/useOnAction.d.ts.map +1 -1
  286. package/lib/typescript/src/useOnGetState.d.ts +1 -1
  287. package/lib/typescript/src/useOnGetState.d.ts.map +1 -1
  288. package/lib/typescript/src/useOnPreventRemove.d.ts +1 -1
  289. package/lib/typescript/src/useOnPreventRemove.d.ts.map +1 -1
  290. package/lib/typescript/src/usePreventRemove.d.ts +1 -1
  291. package/lib/typescript/src/usePreventRemove.d.ts.map +1 -1
  292. package/lib/typescript/src/useRouteCache.d.ts +1 -1
  293. package/lib/typescript/src/useRouteCache.d.ts.map +1 -1
  294. package/lib/typescript/src/useSyncState.d.ts +1 -4
  295. package/lib/typescript/src/useSyncState.d.ts.map +1 -1
  296. package/lib/typescript/src/validatePathConfig.d.ts +1 -1
  297. package/lib/typescript/src/validatePathConfig.d.ts.map +1 -1
  298. package/lib/typescript/utils/usePrevious.d.ts +6 -0
  299. package/lib/typescript/utils/usePrevious.d.ts.map +1 -0
  300. package/package.json +14 -14
  301. package/src/BaseNavigationContainer.tsx +35 -36
  302. package/src/Group.tsx +1 -1
  303. package/src/PreventRemoveProvider.tsx +4 -1
  304. package/src/SceneView.tsx +1 -1
  305. package/src/Screen.tsx +1 -1
  306. package/src/StaticNavigation.tsx +34 -32
  307. package/src/checkDuplicateRouteNames.tsx +1 -1
  308. package/src/createNavigationContainerRef.tsx +1 -1
  309. package/src/createNavigatorFactory.tsx +2 -4
  310. package/src/getActionFromState.tsx +1 -1
  311. package/src/getFocusedRouteNameFromRoute.tsx +3 -3
  312. package/src/getPathFromState.tsx +20 -12
  313. package/src/getStateFromPath.tsx +80 -19
  314. package/src/index.tsx +6 -3
  315. package/src/theming/ThemeContext.tsx +7 -0
  316. package/src/theming/ThemeProvider.tsx +14 -0
  317. package/src/theming/useTheme.tsx +15 -0
  318. package/src/types.tsx +133 -17
  319. package/src/useDescriptors.tsx +153 -59
  320. package/src/useFocusEffect.tsx +1 -0
  321. package/src/useFocusedListenersChildrenAdapter.tsx +2 -2
  322. package/src/useIsomorphicLayoutEffect.native.tsx +3 -0
  323. package/src/useIsomorphicLayoutEffect.tsx +7 -0
  324. package/src/useNavigation.tsx +4 -1
  325. package/src/useNavigationBuilder.tsx +123 -100
  326. package/src/useNavigationCache.tsx +91 -30
  327. package/src/useNavigationContainerRef.tsx +1 -1
  328. package/src/useNavigationHelpers.tsx +6 -7
  329. package/src/useOnAction.tsx +8 -3
  330. package/src/useOnGetState.tsx +1 -1
  331. package/src/useOnPreventRemove.tsx +1 -1
  332. package/src/useOptionsGetters.tsx +2 -2
  333. package/src/usePreventRemove.tsx +1 -1
  334. package/src/useRouteCache.tsx +17 -16
  335. package/src/useSyncState.tsx +31 -59
  336. package/src/validatePathConfig.tsx +58 -14
  337. package/lib/commonjs/fromEntries.js +0 -18
  338. package/lib/commonjs/fromEntries.js.map +0 -1
  339. package/lib/commonjs/useScheduleUpdate.js +0 -37
  340. package/lib/commonjs/useScheduleUpdate.js.map +0 -1
  341. package/lib/module/fromEntries.js +0 -12
  342. package/lib/module/fromEntries.js.map +0 -1
  343. package/lib/module/useScheduleUpdate.js +0 -27
  344. package/lib/module/useScheduleUpdate.js.map +0 -1
  345. package/lib/typescript/src/fromEntries.d.ts +0 -2
  346. package/lib/typescript/src/fromEntries.d.ts.map +0 -1
  347. package/lib/typescript/src/useScheduleUpdate.d.ts +0 -14
  348. package/lib/typescript/src/useScheduleUpdate.d.ts.map +0 -1
  349. package/src/fromEntries.tsx +0 -11
  350. package/src/useScheduleUpdate.tsx +0 -32
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  CommonActions,
3
- InitialState,
4
- NavigationAction,
5
- NavigationState,
6
- ParamListBase,
7
- PartialState,
8
- Route,
3
+ type InitialState,
4
+ type NavigationAction,
5
+ type NavigationState,
6
+ type ParamListBase,
7
+ type PartialState,
8
+ type Route,
9
9
  } from '@react-navigation/routers';
10
10
  import * as React from 'react';
11
11
  import useLatestCallback from 'use-latest-callback';
@@ -20,6 +20,7 @@ import { NavigationBuilderContext } from './NavigationBuilderContext';
20
20
  import { NavigationContainerRefContext } from './NavigationContainerRefContext';
21
21
  import { NavigationIndependentTreeContext } from './NavigationIndependentTreeContext';
22
22
  import { NavigationStateContext } from './NavigationStateContext';
23
+ import { ThemeProvider } from './theming/ThemeProvider';
23
24
  import type {
24
25
  NavigationContainerEventMap,
25
26
  NavigationContainerProps,
@@ -31,7 +32,6 @@ import { useEventEmitter } from './useEventEmitter';
31
32
  import { useKeyedChildListeners } from './useKeyedChildListeners';
32
33
  import { useNavigationIndependentTree } from './useNavigationIndependentTree';
33
34
  import { useOptionsGetters } from './useOptionsGetters';
34
- import { ScheduleUpdateContext } from './useScheduleUpdate';
35
35
  import { useSyncState } from './useSyncState';
36
36
 
37
37
  type State = NavigationState | PartialState<NavigationState> | undefined;
@@ -77,6 +77,7 @@ const getPartialState = (
77
77
  * @param props.onReady Callback which is called after the navigation tree mounts.
78
78
  * @param props.onStateChange Callback which is called with the latest navigation state when it changes.
79
79
  * @param props.onUnhandledAction Callback which is called when an action is not handled.
80
+ * @param props.theme Theme object for the UI elements.
80
81
  * @param props.children Child elements to render the content.
81
82
  * @param props.ref Ref object which refers to the navigation object containing helper methods.
82
83
  */
@@ -88,6 +89,7 @@ export const BaseNavigationContainer = React.forwardRef(
88
89
  onReady,
89
90
  onUnhandledAction,
90
91
  navigationInChildEnabled = false,
92
+ theme,
91
93
  children,
92
94
  }: NavigationContainerProps,
93
95
  ref?: React.Ref<NavigationContainerRef<ParamListBase>>
@@ -101,10 +103,9 @@ export const BaseNavigationContainer = React.forwardRef(
101
103
  );
102
104
  }
103
105
 
104
- const [state, getState, setState, scheduleUpdate, flushUpdates] =
105
- useSyncState<State>(() =>
106
- getPartialState(initialState == null ? undefined : initialState)
107
- );
106
+ const [state, getState, setState] = useSyncState<State>(() =>
107
+ getPartialState(initialState == null ? undefined : initialState)
108
+ );
108
109
 
109
110
  const isFirstMountRef = React.useRef<boolean>(true);
110
111
 
@@ -203,11 +204,14 @@ export const BaseNavigationContainer = React.forwardRef(
203
204
  isFocused: () => true,
204
205
  canGoBack,
205
206
  getParent: () => undefined,
206
- getState: () => stateRef.current,
207
+ getState,
207
208
  getRootState,
208
209
  getCurrentRoute,
209
210
  getCurrentOptions,
210
211
  isReady,
212
+ setOptions: () => {
213
+ throw new Error('Cannot call setOptions outside a screen');
214
+ },
211
215
  }),
212
216
  [
213
217
  canGoBack,
@@ -216,6 +220,7 @@ export const BaseNavigationContainer = React.forwardRef(
216
220
  getCurrentOptions,
217
221
  getCurrentRoute,
218
222
  getRootState,
223
+ getState,
219
224
  isReady,
220
225
  resetRoot,
221
226
  ]
@@ -260,11 +265,6 @@ export const BaseNavigationContainer = React.forwardRef(
260
265
  [addListener, addKeyedListener, onDispatchAction, onOptionsChange]
261
266
  );
262
267
 
263
- const scheduleContext = React.useMemo(
264
- () => ({ scheduleUpdate, flushUpdates }),
265
- [scheduleUpdate, flushUpdates]
266
- );
267
-
268
268
  const isInitialRef = React.useRef(true);
269
269
 
270
270
  const getIsInitial = React.useCallback(() => isInitialRef.current, []);
@@ -292,22 +292,21 @@ export const BaseNavigationContainer = React.forwardRef(
292
292
 
293
293
  const onReadyRef = React.useRef(onReady);
294
294
  const onStateChangeRef = React.useRef(onStateChange);
295
- const stateRef = React.useRef(state);
296
295
 
297
296
  React.useEffect(() => {
298
297
  isInitialRef.current = false;
299
298
  onStateChangeRef.current = onStateChange;
300
299
  onReadyRef.current = onReady;
301
- stateRef.current = state;
302
300
  });
303
301
 
304
- const isNavigationReady = isReady();
302
+ const onReadyCalledRef = React.useRef(false);
305
303
 
306
304
  React.useEffect(() => {
307
- if (isNavigationReady) {
305
+ if (!onReadyCalledRef.current && isReady()) {
306
+ onReadyCalledRef.current = true;
308
307
  onReadyRef.current?.();
309
308
  }
310
- }, [isNavigationReady]);
309
+ }, [state, isReady]);
311
310
 
312
311
  React.useEffect(() => {
313
312
  const hydratedState = getRootState();
@@ -433,21 +432,21 @@ export const BaseNavigationContainer = React.forwardRef(
433
432
  return (
434
433
  <NavigationIndependentTreeContext.Provider value={false}>
435
434
  <NavigationContainerRefContext.Provider value={navigation}>
436
- <ScheduleUpdateContext.Provider value={scheduleContext}>
437
- <NavigationBuilderContext.Provider value={builderContext}>
438
- <NavigationStateContext.Provider value={context}>
439
- <UnhandledActionContext.Provider
440
- value={onUnhandledAction ?? defaultOnUnhandledAction}
435
+ <NavigationBuilderContext.Provider value={builderContext}>
436
+ <NavigationStateContext.Provider value={context}>
437
+ <UnhandledActionContext.Provider
438
+ value={onUnhandledAction ?? defaultOnUnhandledAction}
439
+ >
440
+ <DeprecatedNavigationInChildContext.Provider
441
+ value={navigationInChildEnabled}
441
442
  >
442
- <DeprecatedNavigationInChildContext.Provider
443
- value={navigationInChildEnabled}
444
- >
445
- <EnsureSingleNavigator>{children}</EnsureSingleNavigator>
446
- </DeprecatedNavigationInChildContext.Provider>
447
- </UnhandledActionContext.Provider>
448
- </NavigationStateContext.Provider>
449
- </NavigationBuilderContext.Provider>
450
- </ScheduleUpdateContext.Provider>
443
+ <EnsureSingleNavigator>
444
+ <ThemeProvider value={theme}>{children}</ThemeProvider>
445
+ </EnsureSingleNavigator>
446
+ </DeprecatedNavigationInChildContext.Provider>
447
+ </UnhandledActionContext.Provider>
448
+ </NavigationStateContext.Provider>
449
+ </NavigationBuilderContext.Provider>
451
450
  </NavigationContainerRefContext.Provider>
452
451
  </NavigationIndependentTreeContext.Provider>
453
452
  );
package/src/Group.tsx CHANGED
@@ -7,7 +7,7 @@ import type { RouteGroupConfig } from './types';
7
7
  */
8
8
  export function Group<
9
9
  ParamList extends ParamListBase,
10
- ScreenOptions extends {}
10
+ ScreenOptions extends {},
11
11
  >(_: RouteGroupConfig<ParamList, ScreenOptions>) {
12
12
  /* istanbul ignore next */
13
13
  return null;
@@ -4,7 +4,10 @@ import useLatestCallback from 'use-latest-callback';
4
4
 
5
5
  import { NavigationHelpersContext } from './NavigationHelpersContext';
6
6
  import { NavigationRouteContext } from './NavigationRouteContext';
7
- import { PreventedRoutes, PreventRemoveContext } from './PreventRemoveContext';
7
+ import {
8
+ type PreventedRoutes,
9
+ PreventRemoveContext,
10
+ } from './PreventRemoveContext';
8
11
 
9
12
  type Props = {
10
13
  children: React.ReactNode;
package/src/SceneView.tsx CHANGED
@@ -35,7 +35,7 @@ type Props<State extends NavigationState, ScreenOptions extends {}> = {
35
35
  */
36
36
  export function SceneView<
37
37
  State extends NavigationState,
38
- ScreenOptions extends {}
38
+ ScreenOptions extends {},
39
39
  >({
40
40
  screen,
41
41
  route,
package/src/Screen.tsx CHANGED
@@ -10,7 +10,7 @@ export function Screen<
10
10
  RouteName extends keyof ParamList,
11
11
  State extends NavigationState,
12
12
  ScreenOptions extends {},
13
- EventMap extends EventMapBase
13
+ EventMap extends EventMapBase,
14
14
  >(_: RouteConfig<ParamList, RouteName, State, ScreenOptions, EventMap>) {
15
15
  /* istanbul ignore next */
16
16
  return null;
@@ -1,7 +1,7 @@
1
1
  import type { NavigationState, ParamListBase } from '@react-navigation/routers';
2
2
  import * as React from 'react';
3
+ import { isValidElementType } from 'react-is';
3
4
 
4
- import { fromEntries } from './fromEntries';
5
5
  import type {
6
6
  DefaultNavigatorOptions,
7
7
  EventMapBase,
@@ -22,7 +22,17 @@ type FlatType<T> = { [K in keyof T]: T[K] } & {};
22
22
  * keyof T doesn't work for union types. We can use distributive conditional types instead.
23
23
  * https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
24
24
  */
25
- type KeysOf<T> = T extends any ? keyof T : never;
25
+ type KeysOf<T> = T extends {} ? keyof T : never;
26
+
27
+ /**
28
+ * We get a union type when using keyof, but we want an intersection instead.
29
+ * https://stackoverflow.com/a/50375286/1665026
30
+ */
31
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
32
+ k: infer I
33
+ ) => void
34
+ ? I
35
+ : never;
26
36
 
27
37
  type UnknownToUndefined<T> = unknown extends T ? undefined : T;
28
38
 
@@ -31,23 +41,16 @@ type ParamsForScreenComponent<T> = T extends {
31
41
  }
32
42
  ? P
33
43
  : T extends React.ComponentType<{ route: { params: infer P } }>
34
- ? P
35
- : undefined;
44
+ ? P
45
+ : undefined;
36
46
 
37
47
  type ParamsForScreen<T> = T extends { screen: StaticNavigation<any, any, any> }
38
48
  ? NavigatorScreenParams<StaticParamList<T['screen']>> | undefined
39
49
  : T extends StaticNavigation<any, any, any>
40
- ? NavigatorScreenParams<StaticParamList<T>> | undefined
41
- : UnknownToUndefined<ParamsForScreenComponent<T>>;
50
+ ? NavigatorScreenParams<StaticParamList<T>> | undefined
51
+ : UnknownToUndefined<ParamsForScreenComponent<T>>;
42
52
 
43
- type ParamListForScreens<
44
- Screens extends StaticConfigScreens<
45
- ParamListBase,
46
- NavigationState,
47
- {},
48
- EventMapBase
49
- >
50
- > = {
53
+ type ParamListForScreens<Screens> = {
51
54
  [Key in KeysOf<Screens>]: ParamsForScreen<Screens[Key]>;
52
55
  };
53
56
 
@@ -63,7 +66,7 @@ type ParamListForGroups<
63
66
  >;
64
67
  };
65
68
  }>
66
- | undefined
69
+ | undefined,
67
70
  > = Groups extends {
68
71
  [key: string]: {
69
72
  screens: StaticConfigScreens<
@@ -74,14 +77,14 @@ type ParamListForGroups<
74
77
  >;
75
78
  };
76
79
  }
77
- ? ParamListForScreens<Groups[keyof Groups]['screens']>
80
+ ? ParamListForScreens<UnionToIntersection<Groups[keyof Groups]['screens']>>
78
81
  : {};
79
82
 
80
83
  type StaticConfigScreens<
81
84
  ParamList extends ParamListBase,
82
85
  State extends NavigationState,
83
86
  ScreenOptions extends {},
84
- EventMap extends EventMapBase
87
+ EventMap extends EventMapBase,
85
88
  > = {
86
89
  [key in keyof ParamList]:
87
90
  | React.ComponentType<any>
@@ -115,14 +118,7 @@ type StaticConfigScreens<
115
118
  * },
116
119
  * ```
117
120
  */
118
- linking?:
119
- | FlatType<
120
- Pick<
121
- PathConfig<ParamList>,
122
- 'path' | 'exact' | 'parse' | 'stringify'
123
- >
124
- >
125
- | string;
121
+ linking?: PathConfig<ParamList> | string;
126
122
  /**
127
123
  * Static navigation config or Component to render for the screen.
128
124
  */
@@ -134,7 +130,7 @@ type GroupConfig<
134
130
  ParamList extends ParamListBase,
135
131
  State extends NavigationState,
136
132
  ScreenOptions extends {},
137
- EventMap extends EventMapBase
133
+ EventMap extends EventMapBase,
138
134
  > = Omit<RouteGroupConfig<ParamList, ScreenOptions>, 'screens' | 'children'> & {
139
135
  /**
140
136
  * Callback to determine whether the screens in the group should be rendered or not.
@@ -152,7 +148,7 @@ export type StaticConfig<
152
148
  State extends NavigationState,
153
149
  ScreenOptions extends {},
154
150
  EventMap extends EventMapBase,
155
- Navigator extends React.ComponentType<{}>
151
+ Navigator extends React.ComponentType<{}>,
156
152
  > = Omit<
157
153
  Omit<
158
154
  React.ComponentProps<Navigator>,
@@ -201,7 +197,7 @@ export type StaticParamList<
201
197
  };
202
198
  };
203
199
  };
204
- }
200
+ },
205
201
  > = FlatType<
206
202
  ParamListForScreens<T['config']['screens']> &
207
203
  ParamListForGroups<T['config']['groups']>
@@ -246,7 +242,7 @@ const getItemsFromScreens = (
246
242
  useIf = _if;
247
243
  props = rest;
248
244
 
249
- if (typeof screen === 'function') {
245
+ if (isValidElementType(screen)) {
250
246
  component = screen;
251
247
  } else if ('config' in screen) {
252
248
  isNavigator = true;
@@ -255,7 +251,7 @@ const getItemsFromScreens = (
255
251
  `${name}Navigator`
256
252
  );
257
253
  }
258
- } else if (typeof item === 'function') {
254
+ } else if (isValidElementType(item)) {
259
255
  component = item;
260
256
  } else if ('config' in item) {
261
257
  isNavigator = true;
@@ -268,7 +264,7 @@ const getItemsFromScreens = (
268
264
  );
269
265
  }
270
266
 
271
- let element = isNavigator ? (
267
+ const element = isNavigator ? (
272
268
  React.createElement(component, {})
273
269
  ) : (
274
270
  <MemoizedScreen component={component} />
@@ -304,6 +300,12 @@ export function createComponentForStaticNavigation(
304
300
  const { Navigator, Group, Screen, config } = tree;
305
301
  const { screens, groups, ...rest } = config;
306
302
 
303
+ if (screens == null) {
304
+ throw new Error(
305
+ "Couldn't find a 'screens' property. Make sure to define your screens under a 'screens' property in the configuration."
306
+ );
307
+ }
308
+
307
309
  const items = getItemsFromScreens(Screen, screens);
308
310
 
309
311
  if (groups) {
@@ -369,7 +371,7 @@ export function createPathConfigForStaticNavigation(tree: {
369
371
  >;
370
372
  };
371
373
  }) {
372
- return fromEntries(
374
+ return Object.fromEntries(
373
375
  Object.entries(tree.config.screens)
374
376
  .map(([key, item]) => {
375
377
  const screenConfig: PathConfig<ParamListBase> = {};
@@ -7,7 +7,7 @@ export function checkDuplicateRouteNames(state: NavigationState) {
7
7
  location: string,
8
8
  state: NavigationState | PartialState<NavigationState>
9
9
  ) => {
10
- state.routes.forEach((route: typeof state.routes[0]) => {
10
+ state.routes.forEach((route: (typeof state.routes)[0]) => {
11
11
  const currentLocation = location
12
12
  ? `${location} > ${route.name}`
13
13
  : route.name;
@@ -10,7 +10,7 @@ export const NOT_INITIALIZED_ERROR =
10
10
  "The 'navigation' object hasn't been initialized yet. This might happen if you don't have a navigator mounted, or if the navigator hasn't finished mounting. See https://reactnavigation.org/docs/navigating-without-navigation-prop#handling-initialization for more details.";
11
11
 
12
12
  export function createNavigationContainerRef<
13
- ParamList extends {} = ReactNavigation.RootParamList
13
+ ParamList extends {} = ReactNavigation.RootParamList,
14
14
  >(): NavigationContainerRefWithCurrent<ParamList> {
15
15
  const methods = [
16
16
  ...Object.keys(CommonActions),
@@ -17,7 +17,7 @@ export function createNavigatorFactory<
17
17
  State extends NavigationState,
18
18
  ScreenOptions extends {},
19
19
  EventMap extends EventMapBase,
20
- NavigatorComponent extends React.ComponentType<any>
20
+ NavigatorComponent extends React.ComponentType<any>,
21
21
  >(Navigator: NavigatorComponent) {
22
22
  function createNavigator<ParamList extends ParamListBase>(): TypedNavigator<
23
23
  ParamList,
@@ -27,7 +27,6 @@ export function createNavigatorFactory<
27
27
  typeof Navigator
28
28
  >;
29
29
 
30
- // eslint-disable-next-line no-redeclare
31
30
  function createNavigator<
32
31
  ParamList extends ParamListBase,
33
32
  Config extends StaticConfig<
@@ -36,7 +35,7 @@ export function createNavigatorFactory<
36
35
  ScreenOptions,
37
36
  EventMap,
38
37
  typeof Navigator
39
- >
38
+ >,
40
39
  >(
41
40
  config: Config
42
41
  ): TypedNavigator<
@@ -47,7 +46,6 @@ export function createNavigatorFactory<
47
46
  typeof Navigator
48
47
  > & { config: Config };
49
48
 
50
- // eslint-disable-next-line no-redeclare
51
49
  function createNavigator(config?: any): any {
52
50
  if (config != null) {
53
51
  return {
@@ -65,7 +65,7 @@ export function getActionFromState(
65
65
  let config: ConfigItem | undefined = normalizedConfig?.screens?.[route?.name];
66
66
  let params = { ...route.params } as NavigatorScreenParams<ParamListBase>;
67
67
 
68
- let payload = route
68
+ const payload = route
69
69
  ? { name: route.name, path: route.path, params }
70
70
  : undefined;
71
71
 
@@ -20,9 +20,9 @@ export function getFocusedRouteNameFromRoute(
20
20
  : state.routes.length - 1)
21
21
  ].name
22
22
  : // If state doesn't exist, we need to default to `screen` param if available
23
- typeof params?.screen === 'string'
24
- ? params.screen
25
- : undefined;
23
+ typeof params?.screen === 'string'
24
+ ? params.screen
25
+ : undefined;
26
26
 
27
27
  return routeName;
28
28
  }
@@ -5,11 +5,11 @@ import type {
5
5
  } from '@react-navigation/routers';
6
6
  import * as queryString from 'query-string';
7
7
 
8
- import { fromEntries } from './fromEntries';
9
8
  import type { PathConfig, PathConfigMap } from './types';
10
9
  import { validatePathConfig } from './validatePathConfig';
11
10
 
12
11
  type Options<ParamList extends {}> = {
12
+ path?: string;
13
13
  initialRouteName?: string;
14
14
  screens: PathConfigMap<ParamList>;
15
15
  };
@@ -99,11 +99,11 @@ export function getPathFromState<ParamList extends {}>(
99
99
  let pattern: string | undefined;
100
100
 
101
101
  let focusedParams: Record<string, any> | undefined;
102
- let focusedRoute = getActiveRoute(state);
102
+ const focusedRoute = getActiveRoute(state);
103
103
  let currentOptions = configs;
104
104
 
105
105
  // Keep all the route names that appeared during going deeper in config in case the pattern is resolved to undefined
106
- let nestedRouteNames = [];
106
+ const nestedRouteNames = [];
107
107
 
108
108
  let hasNext = true;
109
109
 
@@ -115,7 +115,7 @@ export function getPathFromState<ParamList extends {}>(
115
115
  if (route.params) {
116
116
  const stringify = currentOptions[route.name]?.stringify;
117
117
 
118
- const currentParams = fromEntries(
118
+ const currentParams = Object.fromEntries(
119
119
  Object.entries(route.params).map(([key, value]) => [
120
120
  key,
121
121
  stringify?.[key] ? stringify[key](value) : String(value),
@@ -196,7 +196,12 @@ export function getPathFromState<ParamList extends {}>(
196
196
  return '';
197
197
  }
198
198
 
199
- return encodeURIComponent(value);
199
+ // Valid characters according to
200
+ // https://datatracker.ietf.org/doc/html/rfc3986#section-3.3 (see pchar definition)
201
+ return String(value).replace(
202
+ /[^A-Za-z0-9\-._~!$&'()*+,;=:@]/g,
203
+ (char) => encodeURIComponent(char)
204
+ );
200
205
  }
201
206
 
202
207
  return encodeURIComponent(p);
@@ -213,7 +218,7 @@ export function getPathFromState<ParamList extends {}>(
213
218
  if (route.state) {
214
219
  path += '/';
215
220
  } else if (focusedParams) {
216
- for (let param in focusedParams) {
221
+ for (const param in focusedParams) {
217
222
  if (focusedParams[param] === 'undefined') {
218
223
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
219
224
  delete focusedParams[param];
@@ -234,6 +239,11 @@ export function getPathFromState<ParamList extends {}>(
234
239
  path = path.replace(/\/+/g, '/');
235
240
  path = path.length > 1 ? path.replace(/\/$/, '') : path;
236
241
 
242
+ // Include the root path if specified
243
+ if (options?.path) {
244
+ path = joinPaths(options.path, path);
245
+ }
246
+
237
247
  return path;
238
248
  }
239
249
 
@@ -257,17 +267,15 @@ const createConfigItem = (
257
267
  return { pattern };
258
268
  }
259
269
 
260
- // If an object is specified as the value (e.g. Foo: { ... }),
261
- // It can have `path` property and `screens` prop which has nested configs
262
- let pattern: string | undefined;
263
-
264
270
  if (config.exact && config.path === undefined) {
265
271
  throw new Error(
266
272
  "A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`."
267
273
  );
268
274
  }
269
275
 
270
- pattern =
276
+ // If an object is specified as the value (e.g. Foo: { ... }),
277
+ // It can have `path` property and `screens` prop which has nested configs
278
+ const pattern =
271
279
  config.exact !== true
272
280
  ? joinPaths(parentPattern || '', config.path || '')
273
281
  : config.path || '';
@@ -288,7 +296,7 @@ const createNormalizedConfigs = (
288
296
  options: PathConfigMap<object>,
289
297
  pattern?: string
290
298
  ): Record<string, ConfigItem> =>
291
- fromEntries(
299
+ Object.fromEntries(
292
300
  Object.entries(options).map(([name, c]) => {
293
301
  const result = createConfigItem(c, pattern);
294
302