@react-navigation/core 6.4.3 → 6.4.5

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 (351) hide show
  1. package/lib/commonjs/BaseNavigationContainer.js +17 -69
  2. package/lib/commonjs/BaseNavigationContainer.js.map +1 -1
  3. package/lib/commonjs/CurrentRenderContext.js +0 -4
  4. package/lib/commonjs/CurrentRenderContext.js.map +1 -1
  5. package/lib/commonjs/EnsureSingleNavigator.js +1 -12
  6. package/lib/commonjs/EnsureSingleNavigator.js.map +1 -1
  7. package/lib/commonjs/Group.js +0 -1
  8. package/lib/commonjs/Group.js.map +1 -1
  9. package/lib/commonjs/NavigationBuilderContext.js +0 -4
  10. package/lib/commonjs/NavigationBuilderContext.js.map +1 -1
  11. package/lib/commonjs/NavigationContainerRefContext.js +0 -4
  12. package/lib/commonjs/NavigationContainerRefContext.js.map +1 -1
  13. package/lib/commonjs/NavigationContext.js +0 -4
  14. package/lib/commonjs/NavigationContext.js.map +1 -1
  15. package/lib/commonjs/NavigationHelpersContext.js +0 -4
  16. package/lib/commonjs/NavigationHelpersContext.js.map +1 -1
  17. package/lib/commonjs/NavigationRouteContext.js +0 -4
  18. package/lib/commonjs/NavigationRouteContext.js.map +1 -1
  19. package/lib/commonjs/NavigationStateContext.js +0 -12
  20. package/lib/commonjs/NavigationStateContext.js.map +1 -1
  21. package/lib/commonjs/PreventRemoveContext.js +0 -4
  22. package/lib/commonjs/PreventRemoveContext.js.map +1 -1
  23. package/lib/commonjs/PreventRemoveProvider.js +3 -21
  24. package/lib/commonjs/PreventRemoveProvider.js.map +1 -1
  25. package/lib/commonjs/SceneView.js +8 -13
  26. package/lib/commonjs/SceneView.js.map +1 -1
  27. package/lib/commonjs/Screen.js +0 -1
  28. package/lib/commonjs/Screen.js.map +1 -1
  29. package/lib/commonjs/StaticContainer.js +0 -10
  30. package/lib/commonjs/StaticContainer.js.map +1 -1
  31. package/lib/commonjs/UnhandledActionContext.js +0 -4
  32. package/lib/commonjs/UnhandledActionContext.js.map +1 -1
  33. package/lib/commonjs/checkDuplicateRouteNames.js +0 -5
  34. package/lib/commonjs/checkDuplicateRouteNames.js.map +1 -1
  35. package/lib/commonjs/checkSerializable.js +0 -9
  36. package/lib/commonjs/checkSerializable.js.map +1 -1
  37. package/lib/commonjs/createNavigationContainerRef.js +0 -13
  38. package/lib/commonjs/createNavigationContainerRef.js.map +1 -1
  39. package/lib/commonjs/createNavigatorFactory.js +0 -5
  40. package/lib/commonjs/createNavigatorFactory.js.map +1 -1
  41. package/lib/commonjs/findFocusedRoute.js +5 -10
  42. package/lib/commonjs/findFocusedRoute.js.map +1 -1
  43. package/lib/commonjs/fromEntries.js +0 -3
  44. package/lib/commonjs/fromEntries.js.map +1 -1
  45. package/lib/commonjs/getActionFromState.js +11 -22
  46. package/lib/commonjs/getActionFromState.js.map +1 -1
  47. package/lib/commonjs/getFocusedRouteNameFromRoute.js +7 -8
  48. package/lib/commonjs/getFocusedRouteNameFromRoute.js.map +1 -1
  49. package/lib/commonjs/getPathFromState.js +25 -55
  50. package/lib/commonjs/getPathFromState.js.map +1 -1
  51. package/lib/commonjs/getStateFromPath.js +48 -105
  52. package/lib/commonjs/getStateFromPath.js.map +1 -1
  53. package/lib/commonjs/index.js +0 -30
  54. package/lib/commonjs/index.js.map +1 -1
  55. package/lib/commonjs/isArrayEqual.js +0 -3
  56. package/lib/commonjs/isArrayEqual.js.map +1 -1
  57. package/lib/commonjs/isRecordEqual.js +0 -4
  58. package/lib/commonjs/isRecordEqual.js.map +1 -1
  59. package/lib/commonjs/types.js +3 -5
  60. package/lib/commonjs/types.js.map +1 -1
  61. package/lib/commonjs/useChildListeners.js +0 -5
  62. package/lib/commonjs/useChildListeners.js.map +1 -1
  63. package/lib/commonjs/useComponent.js +3 -9
  64. package/lib/commonjs/useComponent.js.map +1 -1
  65. package/lib/commonjs/useCurrentRender.js +0 -7
  66. package/lib/commonjs/useCurrentRender.js.map +1 -1
  67. package/lib/commonjs/useDescriptors.js +11 -21
  68. package/lib/commonjs/useDescriptors.js.map +1 -1
  69. package/lib/commonjs/useEventEmitter.js +2 -24
  70. package/lib/commonjs/useEventEmitter.js.map +1 -1
  71. package/lib/commonjs/useFocusEffect.js +2 -20
  72. package/lib/commonjs/useFocusEffect.js.map +1 -1
  73. package/lib/commonjs/useFocusEvents.js +9 -15
  74. package/lib/commonjs/useFocusEvents.js.map +1 -1
  75. package/lib/commonjs/useFocusedListenersChildrenAdapter.js +0 -8
  76. package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -1
  77. package/lib/commonjs/useIsFocused.js +0 -8
  78. package/lib/commonjs/useIsFocused.js.map +1 -1
  79. package/lib/commonjs/useKeyedChildListeners.js +0 -4
  80. package/lib/commonjs/useKeyedChildListeners.js.map +1 -1
  81. package/lib/commonjs/useNavigation.js +3 -11
  82. package/lib/commonjs/useNavigation.js.map +1 -1
  83. package/lib/commonjs/useNavigationBuilder.js +34 -91
  84. package/lib/commonjs/useNavigationBuilder.js.map +1 -1
  85. package/lib/commonjs/useNavigationCache.js +18 -30
  86. package/lib/commonjs/useNavigationCache.js.map +1 -1
  87. package/lib/commonjs/useNavigationContainerRef.js +0 -8
  88. package/lib/commonjs/useNavigationContainerRef.js.map +1 -1
  89. package/lib/commonjs/useNavigationHelpers.js +4 -18
  90. package/lib/commonjs/useNavigationHelpers.js.map +1 -1
  91. package/lib/commonjs/useNavigationState.js +5 -9
  92. package/lib/commonjs/useNavigationState.js.map +1 -1
  93. package/lib/commonjs/useOnAction.js +8 -25
  94. package/lib/commonjs/useOnAction.js.map +1 -1
  95. package/lib/commonjs/useOnGetState.js +6 -16
  96. package/lib/commonjs/useOnGetState.js.map +1 -1
  97. package/lib/commonjs/useOnPreventRemove.js +9 -24
  98. package/lib/commonjs/useOnPreventRemove.js.map +1 -1
  99. package/lib/commonjs/useOnRouteFocus.js +0 -8
  100. package/lib/commonjs/useOnRouteFocus.js.map +1 -1
  101. package/lib/commonjs/useOptionsGetters.js +5 -24
  102. package/lib/commonjs/useOptionsGetters.js.map +1 -1
  103. package/lib/commonjs/usePreventRemove.js +0 -11
  104. package/lib/commonjs/usePreventRemove.js.map +1 -1
  105. package/lib/commonjs/usePreventRemoveContext.js +0 -8
  106. package/lib/commonjs/usePreventRemoveContext.js.map +1 -1
  107. package/lib/commonjs/useRegisterNavigator.js +0 -8
  108. package/lib/commonjs/useRegisterNavigator.js.map +1 -1
  109. package/lib/commonjs/useRoute.js +0 -8
  110. package/lib/commonjs/useRoute.js.map +1 -1
  111. package/lib/commonjs/useRouteCache.js +1 -10
  112. package/lib/commonjs/useRouteCache.js.map +1 -1
  113. package/lib/commonjs/useScheduleUpdate.js +1 -8
  114. package/lib/commonjs/useScheduleUpdate.js.map +1 -1
  115. package/lib/commonjs/useSyncState.js +9 -17
  116. package/lib/commonjs/useSyncState.js.map +1 -1
  117. package/lib/commonjs/validatePathConfig.js +0 -7
  118. package/lib/commonjs/validatePathConfig.js.map +1 -1
  119. package/lib/module/BaseNavigationContainer.js +17 -46
  120. package/lib/module/BaseNavigationContainer.js.map +1 -1
  121. package/lib/module/CurrentRenderContext.js +1 -1
  122. package/lib/module/CurrentRenderContext.js.map +1 -1
  123. package/lib/module/EnsureSingleNavigator.js +1 -7
  124. package/lib/module/EnsureSingleNavigator.js.map +1 -1
  125. package/lib/module/Group.js.map +1 -1
  126. package/lib/module/NavigationBuilderContext.js +0 -1
  127. package/lib/module/NavigationBuilderContext.js.map +1 -1
  128. package/lib/module/NavigationContainerRefContext.js +0 -1
  129. package/lib/module/NavigationContainerRefContext.js.map +1 -1
  130. package/lib/module/NavigationContext.js +0 -1
  131. package/lib/module/NavigationContext.js.map +1 -1
  132. package/lib/module/NavigationHelpersContext.js +0 -1
  133. package/lib/module/NavigationHelpersContext.js.map +1 -1
  134. package/lib/module/NavigationRouteContext.js +1 -1
  135. package/lib/module/NavigationRouteContext.js.map +1 -1
  136. package/lib/module/NavigationStateContext.js +0 -6
  137. package/lib/module/NavigationStateContext.js.map +1 -1
  138. package/lib/module/PreventRemoveContext.js +1 -0
  139. package/lib/module/PreventRemoveContext.js.map +1 -1
  140. package/lib/module/PreventRemoveProvider.js +3 -12
  141. package/lib/module/PreventRemoveProvider.js.map +1 -1
  142. package/lib/module/SceneView.js +8 -5
  143. package/lib/module/SceneView.js.map +1 -1
  144. package/lib/module/Screen.js.map +1 -1
  145. package/lib/module/StaticContainer.js +1 -6
  146. package/lib/module/StaticContainer.js.map +1 -1
  147. package/lib/module/UnhandledActionContext.js.map +1 -1
  148. package/lib/module/checkDuplicateRouteNames.js +0 -4
  149. package/lib/module/checkDuplicateRouteNames.js.map +1 -1
  150. package/lib/module/checkSerializable.js +0 -8
  151. package/lib/module/checkSerializable.js.map +1 -1
  152. package/lib/module/createNavigationContainerRef.js +0 -10
  153. package/lib/module/createNavigationContainerRef.js.map +1 -1
  154. package/lib/module/createNavigatorFactory.js +0 -2
  155. package/lib/module/createNavigatorFactory.js.map +1 -1
  156. package/lib/module/findFocusedRoute.js +5 -9
  157. package/lib/module/findFocusedRoute.js.map +1 -1
  158. package/lib/module/fromEntries.js +0 -2
  159. package/lib/module/fromEntries.js.map +1 -1
  160. package/lib/module/getActionFromState.js +11 -21
  161. package/lib/module/getActionFromState.js.map +1 -1
  162. package/lib/module/getFocusedRouteNameFromRoute.js +7 -6
  163. package/lib/module/getFocusedRouteNameFromRoute.js.map +1 -1
  164. package/lib/module/getPathFromState.js +25 -49
  165. package/lib/module/getPathFromState.js.map +1 -1
  166. package/lib/module/getStateFromPath.js +48 -98
  167. package/lib/module/getStateFromPath.js.map +1 -1
  168. package/lib/module/index.js.map +1 -1
  169. package/lib/module/isArrayEqual.js +0 -2
  170. package/lib/module/isArrayEqual.js.map +1 -1
  171. package/lib/module/isRecordEqual.js +0 -3
  172. package/lib/module/isRecordEqual.js.map +1 -1
  173. package/lib/module/types.js +3 -3
  174. package/lib/module/types.js.map +1 -1
  175. package/lib/module/useChildListeners.js +0 -2
  176. package/lib/module/useChildListeners.js.map +1 -1
  177. package/lib/module/useComponent.js +3 -6
  178. package/lib/module/useComponent.js.map +1 -1
  179. package/lib/module/useCurrentRender.js +0 -2
  180. package/lib/module/useCurrentRender.js.map +1 -1
  181. package/lib/module/useDescriptors.js +11 -11
  182. package/lib/module/useDescriptors.js.map +1 -1
  183. package/lib/module/useEventEmitter.js +2 -21
  184. package/lib/module/useEventEmitter.js.map +1 -1
  185. package/lib/module/useFocusEffect.js +2 -15
  186. package/lib/module/useFocusEffect.js.map +1 -1
  187. package/lib/module/useFocusEvents.js +9 -10
  188. package/lib/module/useFocusEvents.js.map +1 -1
  189. package/lib/module/useFocusedListenersChildrenAdapter.js +0 -3
  190. package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
  191. package/lib/module/useIsFocused.js +1 -3
  192. package/lib/module/useIsFocused.js.map +1 -1
  193. package/lib/module/useKeyedChildListeners.js +0 -1
  194. package/lib/module/useKeyedChildListeners.js.map +1 -1
  195. package/lib/module/useNavigation.js +3 -5
  196. package/lib/module/useNavigation.js.map +1 -1
  197. package/lib/module/useNavigationBuilder.js +37 -63
  198. package/lib/module/useNavigationBuilder.js.map +1 -1
  199. package/lib/module/useNavigationCache.js +18 -24
  200. package/lib/module/useNavigationCache.js.map +1 -1
  201. package/lib/module/useNavigationContainerRef.js +0 -2
  202. package/lib/module/useNavigationContainerRef.js.map +1 -1
  203. package/lib/module/useNavigationHelpers.js +4 -9
  204. package/lib/module/useNavigationHelpers.js.map +1 -1
  205. package/lib/module/useNavigationState.js +5 -4
  206. package/lib/module/useNavigationState.js.map +1 -1
  207. package/lib/module/useOnAction.js +8 -19
  208. package/lib/module/useOnAction.js.map +1 -1
  209. package/lib/module/useOnGetState.js +6 -8
  210. package/lib/module/useOnGetState.js.map +1 -1
  211. package/lib/module/useOnPreventRemove.js +9 -14
  212. package/lib/module/useOnPreventRemove.js.map +1 -1
  213. package/lib/module/useOnRouteFocus.js +0 -3
  214. package/lib/module/useOnRouteFocus.js.map +1 -1
  215. package/lib/module/useOptionsGetters.js +5 -17
  216. package/lib/module/useOptionsGetters.js.map +1 -1
  217. package/lib/module/usePreventRemove.js +1 -2
  218. package/lib/module/usePreventRemove.js.map +1 -1
  219. package/lib/module/usePreventRemoveContext.js +0 -2
  220. package/lib/module/usePreventRemoveContext.js.map +1 -1
  221. package/lib/module/useRegisterNavigator.js +1 -3
  222. package/lib/module/useRegisterNavigator.js.map +1 -1
  223. package/lib/module/useRoute.js +0 -3
  224. package/lib/module/useRoute.js.map +1 -1
  225. package/lib/module/useRouteCache.js +1 -6
  226. package/lib/module/useRouteCache.js.map +1 -1
  227. package/lib/module/useScheduleUpdate.js +1 -3
  228. package/lib/module/useScheduleUpdate.js.map +1 -1
  229. package/lib/module/useSyncState.js +9 -13
  230. package/lib/module/useSyncState.js.map +1 -1
  231. package/lib/module/validatePathConfig.js +0 -6
  232. package/lib/module/validatePathConfig.js.map +1 -1
  233. package/lib/typescript/src/BaseNavigationContainer.d.ts +1 -0
  234. package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -0
  235. package/lib/typescript/src/CurrentRenderContext.d.ts +1 -0
  236. package/lib/typescript/src/CurrentRenderContext.d.ts.map +1 -0
  237. package/lib/typescript/src/EnsureSingleNavigator.d.ts +1 -0
  238. package/lib/typescript/src/EnsureSingleNavigator.d.ts.map +1 -0
  239. package/lib/typescript/src/Group.d.ts +1 -0
  240. package/lib/typescript/src/Group.d.ts.map +1 -0
  241. package/lib/typescript/src/NavigationBuilderContext.d.ts +1 -0
  242. package/lib/typescript/src/NavigationBuilderContext.d.ts.map +1 -0
  243. package/lib/typescript/src/NavigationContainerRefContext.d.ts +1 -0
  244. package/lib/typescript/src/NavigationContainerRefContext.d.ts.map +1 -0
  245. package/lib/typescript/src/NavigationContext.d.ts +1 -0
  246. package/lib/typescript/src/NavigationContext.d.ts.map +1 -0
  247. package/lib/typescript/src/NavigationHelpersContext.d.ts +1 -0
  248. package/lib/typescript/src/NavigationHelpersContext.d.ts.map +1 -0
  249. package/lib/typescript/src/NavigationRouteContext.d.ts +1 -0
  250. package/lib/typescript/src/NavigationRouteContext.d.ts.map +1 -0
  251. package/lib/typescript/src/NavigationStateContext.d.ts +1 -0
  252. package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -0
  253. package/lib/typescript/src/PreventRemoveContext.d.ts +1 -0
  254. package/lib/typescript/src/PreventRemoveContext.d.ts.map +1 -0
  255. package/lib/typescript/src/PreventRemoveProvider.d.ts +1 -0
  256. package/lib/typescript/src/PreventRemoveProvider.d.ts.map +1 -0
  257. package/lib/typescript/src/SceneView.d.ts +1 -0
  258. package/lib/typescript/src/SceneView.d.ts.map +1 -0
  259. package/lib/typescript/src/Screen.d.ts +1 -0
  260. package/lib/typescript/src/Screen.d.ts.map +1 -0
  261. package/lib/typescript/src/StaticContainer.d.ts +1 -0
  262. package/lib/typescript/src/StaticContainer.d.ts.map +1 -0
  263. package/lib/typescript/src/UnhandledActionContext.d.ts +1 -0
  264. package/lib/typescript/src/UnhandledActionContext.d.ts.map +1 -0
  265. package/lib/typescript/src/checkDuplicateRouteNames.d.ts +1 -0
  266. package/lib/typescript/src/checkDuplicateRouteNames.d.ts.map +1 -0
  267. package/lib/typescript/src/checkSerializable.d.ts +1 -0
  268. package/lib/typescript/src/checkSerializable.d.ts.map +1 -0
  269. package/lib/typescript/src/createNavigationContainerRef.d.ts +1 -0
  270. package/lib/typescript/src/createNavigationContainerRef.d.ts.map +1 -0
  271. package/lib/typescript/src/createNavigatorFactory.d.ts +1 -0
  272. package/lib/typescript/src/createNavigatorFactory.d.ts.map +1 -0
  273. package/lib/typescript/src/findFocusedRoute.d.ts +1 -0
  274. package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -0
  275. package/lib/typescript/src/fromEntries.d.ts +1 -0
  276. package/lib/typescript/src/fromEntries.d.ts.map +1 -0
  277. package/lib/typescript/src/getActionFromState.d.ts +1 -0
  278. package/lib/typescript/src/getActionFromState.d.ts.map +1 -0
  279. package/lib/typescript/src/getFocusedRouteNameFromRoute.d.ts +1 -0
  280. package/lib/typescript/src/getFocusedRouteNameFromRoute.d.ts.map +1 -0
  281. package/lib/typescript/src/getPathFromState.d.ts +1 -0
  282. package/lib/typescript/src/getPathFromState.d.ts.map +1 -0
  283. package/lib/typescript/src/getStateFromPath.d.ts +1 -0
  284. package/lib/typescript/src/getStateFromPath.d.ts.map +1 -0
  285. package/lib/typescript/src/index.d.ts +1 -0
  286. package/lib/typescript/src/index.d.ts.map +1 -0
  287. package/lib/typescript/src/isArrayEqual.d.ts +1 -0
  288. package/lib/typescript/src/isArrayEqual.d.ts.map +1 -0
  289. package/lib/typescript/src/isRecordEqual.d.ts +1 -0
  290. package/lib/typescript/src/isRecordEqual.d.ts.map +1 -0
  291. package/lib/typescript/src/types.d.ts +1 -0
  292. package/lib/typescript/src/types.d.ts.map +1 -0
  293. package/lib/typescript/src/useChildListeners.d.ts +1 -0
  294. package/lib/typescript/src/useChildListeners.d.ts.map +1 -0
  295. package/lib/typescript/src/useComponent.d.ts +1 -0
  296. package/lib/typescript/src/useComponent.d.ts.map +1 -0
  297. package/lib/typescript/src/useCurrentRender.d.ts +1 -0
  298. package/lib/typescript/src/useCurrentRender.d.ts.map +1 -0
  299. package/lib/typescript/src/useDescriptors.d.ts +1 -0
  300. package/lib/typescript/src/useDescriptors.d.ts.map +1 -0
  301. package/lib/typescript/src/useEventEmitter.d.ts +1 -0
  302. package/lib/typescript/src/useEventEmitter.d.ts.map +1 -0
  303. package/lib/typescript/src/useFocusEffect.d.ts +1 -0
  304. package/lib/typescript/src/useFocusEffect.d.ts.map +1 -0
  305. package/lib/typescript/src/useFocusEvents.d.ts +1 -0
  306. package/lib/typescript/src/useFocusEvents.d.ts.map +1 -0
  307. package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +1 -0
  308. package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts.map +1 -0
  309. package/lib/typescript/src/useIsFocused.d.ts +1 -0
  310. package/lib/typescript/src/useIsFocused.d.ts.map +1 -0
  311. package/lib/typescript/src/useKeyedChildListeners.d.ts +1 -0
  312. package/lib/typescript/src/useKeyedChildListeners.d.ts.map +1 -0
  313. package/lib/typescript/src/useNavigation.d.ts +1 -0
  314. package/lib/typescript/src/useNavigation.d.ts.map +1 -0
  315. package/lib/typescript/src/useNavigationBuilder.d.ts +1 -0
  316. package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -0
  317. package/lib/typescript/src/useNavigationCache.d.ts +1 -0
  318. package/lib/typescript/src/useNavigationCache.d.ts.map +1 -0
  319. package/lib/typescript/src/useNavigationContainerRef.d.ts +1 -0
  320. package/lib/typescript/src/useNavigationContainerRef.d.ts.map +1 -0
  321. package/lib/typescript/src/useNavigationHelpers.d.ts +1 -0
  322. package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -0
  323. package/lib/typescript/src/useNavigationState.d.ts +1 -0
  324. package/lib/typescript/src/useNavigationState.d.ts.map +1 -0
  325. package/lib/typescript/src/useOnAction.d.ts +1 -0
  326. package/lib/typescript/src/useOnAction.d.ts.map +1 -0
  327. package/lib/typescript/src/useOnGetState.d.ts +1 -0
  328. package/lib/typescript/src/useOnGetState.d.ts.map +1 -0
  329. package/lib/typescript/src/useOnPreventRemove.d.ts +1 -0
  330. package/lib/typescript/src/useOnPreventRemove.d.ts.map +1 -0
  331. package/lib/typescript/src/useOnRouteFocus.d.ts +1 -0
  332. package/lib/typescript/src/useOnRouteFocus.d.ts.map +1 -0
  333. package/lib/typescript/src/useOptionsGetters.d.ts +1 -0
  334. package/lib/typescript/src/useOptionsGetters.d.ts.map +1 -0
  335. package/lib/typescript/src/usePreventRemove.d.ts +1 -0
  336. package/lib/typescript/src/usePreventRemove.d.ts.map +1 -0
  337. package/lib/typescript/src/usePreventRemoveContext.d.ts +1 -0
  338. package/lib/typescript/src/usePreventRemoveContext.d.ts.map +1 -0
  339. package/lib/typescript/src/useRegisterNavigator.d.ts +1 -0
  340. package/lib/typescript/src/useRegisterNavigator.d.ts.map +1 -0
  341. package/lib/typescript/src/useRoute.d.ts +1 -0
  342. package/lib/typescript/src/useRoute.d.ts.map +1 -0
  343. package/lib/typescript/src/useRouteCache.d.ts +1 -0
  344. package/lib/typescript/src/useRouteCache.d.ts.map +1 -0
  345. package/lib/typescript/src/useScheduleUpdate.d.ts +1 -0
  346. package/lib/typescript/src/useScheduleUpdate.d.ts.map +1 -0
  347. package/lib/typescript/src/useSyncState.d.ts +1 -0
  348. package/lib/typescript/src/useSyncState.d.ts.map +1 -0
  349. package/lib/typescript/src/validatePathConfig.d.ts +1 -0
  350. package/lib/typescript/src/validatePathConfig.d.ts.map +1 -0
  351. package/package.json +5 -5
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useFocusEffect;
7
-
8
7
  var React = _interopRequireWildcard(require("react"));
9
-
10
8
  var _useNavigation = _interopRequireDefault(require("./useNavigation"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
12
  /**
19
13
  * Hook to run an effect in a focused screen, similar to `React.useEffect`.
20
14
  * This can be used to perform side-effects such as fetching data or subscribing to events.
@@ -24,26 +18,20 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
24
18
  */
25
19
  function useFocusEffect(effect) {
26
20
  const navigation = (0, _useNavigation.default)();
27
-
28
21
  if (arguments[1] !== undefined) {
29
22
  const message = "You passed a second argument to 'useFocusEffect', but it only accepts one argument. " + "If you want to pass a dependency array, you can use 'React.useCallback':\n\n" + 'useFocusEffect(\n' + ' React.useCallback(() => {\n' + ' // Your code here\n' + ' }, [depA, depB])\n' + ');\n\n' + 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';
30
23
  console.error(message);
31
24
  }
32
-
33
25
  React.useEffect(() => {
34
26
  let isFocused = false;
35
27
  let cleanup;
36
-
37
28
  const callback = () => {
38
29
  const destroy = effect();
39
-
40
30
  if (destroy === undefined || typeof destroy === 'function') {
41
31
  return destroy;
42
32
  }
43
-
44
33
  if (process.env.NODE_ENV !== 'production') {
45
34
  let message = 'An effect function must not return anything besides a function, which is used for clean-up.';
46
-
47
35
  if (destroy === null) {
48
36
  message += " You returned 'null'. If your effect does not require clean-up, return 'undefined' (or nothing).";
49
37
  } else if (typeof destroy.then === 'function') {
@@ -51,28 +39,24 @@ function useFocusEffect(effect) {
51
39
  } else {
52
40
  message += ` You returned '${JSON.stringify(destroy)}'.`;
53
41
  }
54
-
55
42
  console.error(message);
56
43
  }
57
- }; // We need to run the effect on intial render/dep changes if the screen is focused
58
-
44
+ };
59
45
 
46
+ // We need to run the effect on intial render/dep changes if the screen is focused
60
47
  if (navigation.isFocused()) {
61
48
  cleanup = callback();
62
49
  isFocused = true;
63
50
  }
64
-
65
51
  const unsubscribeFocus = navigation.addListener('focus', () => {
66
52
  // If callback was already called for focus, avoid calling it again
67
53
  // The focus event may also fire on intial render, so we guard against runing the effect twice
68
54
  if (isFocused) {
69
55
  return;
70
56
  }
71
-
72
57
  if (cleanup !== undefined) {
73
58
  cleanup();
74
59
  }
75
-
76
60
  cleanup = callback();
77
61
  isFocused = true;
78
62
  });
@@ -80,7 +64,6 @@ function useFocusEffect(effect) {
80
64
  if (cleanup !== undefined) {
81
65
  cleanup();
82
66
  }
83
-
84
67
  cleanup = undefined;
85
68
  isFocused = false;
86
69
  });
@@ -88,7 +71,6 @@ function useFocusEffect(effect) {
88
71
  if (cleanup !== undefined) {
89
72
  cleanup();
90
73
  }
91
-
92
74
  unsubscribeFocus();
93
75
  unsubscribeBlur();
94
76
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useFocusEffect","effect","navigation","useNavigation","arguments","undefined","message","console","error","React","useEffect","isFocused","cleanup","callback","destroy","process","env","NODE_ENV","then","JSON","stringify","unsubscribeFocus","addListener","unsubscribeBlur"],"sources":["useFocusEffect.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport useNavigation from './useNavigation';\n\ntype EffectCallback = () => undefined | void | (() => void);\n\n/**\n * Hook to run an effect in a focused screen, similar to `React.useEffect`.\n * This can be used to perform side-effects such as fetching data or subscribing to events.\n * The passed callback should be wrapped in `React.useCallback` to avoid running the effect too often.\n *\n * @param callback Memoized callback containing the effect, should optionally return a cleanup function.\n */\nexport default function useFocusEffect(effect: EffectCallback) {\n const navigation = useNavigation();\n\n if (arguments[1] !== undefined) {\n const message =\n \"You passed a second argument to 'useFocusEffect', but it only accepts one argument. \" +\n \"If you want to pass a dependency array, you can use 'React.useCallback':\\n\\n\" +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' // Your code here\\n' +\n ' }, [depA, depB])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n\n console.error(message);\n }\n\n React.useEffect(() => {\n let isFocused = false;\n let cleanup: undefined | void | (() => void);\n\n const callback = () => {\n const destroy = effect();\n\n if (destroy === undefined || typeof destroy === 'function') {\n return destroy;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n let message =\n 'An effect function must not return anything besides a function, which is used for clean-up.';\n\n if (destroy === null) {\n message +=\n \" You returned 'null'. If your effect does not require clean-up, return 'undefined' (or nothing).\";\n } else if (typeof (destroy as any).then === 'function') {\n message +=\n \"\\n\\nIt looks like you wrote 'useFocusEffect(async () => ...)' or returned a Promise. \" +\n 'Instead, write the async function inside your effect ' +\n 'and call it immediately:\\n\\n' +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' async function fetchData() {\\n' +\n ' // You can await here\\n' +\n ' const response = await MyAPI.getData(someId);\\n' +\n ' // ...\\n' +\n ' }\\n\\n' +\n ' fetchData();\\n' +\n ' }, [someId])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n } else {\n message += ` You returned '${JSON.stringify(destroy)}'.`;\n }\n\n console.error(message);\n }\n };\n\n // We need to run the effect on intial render/dep changes if the screen is focused\n if (navigation.isFocused()) {\n cleanup = callback();\n isFocused = true;\n }\n\n const unsubscribeFocus = navigation.addListener('focus', () => {\n // If callback was already called for focus, avoid calling it again\n // The focus event may also fire on intial render, so we guard against runing the effect twice\n if (isFocused) {\n return;\n }\n\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = callback();\n isFocused = true;\n });\n\n const unsubscribeBlur = navigation.addListener('blur', () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = undefined;\n isFocused = false;\n });\n\n return () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n unsubscribeFocus();\n unsubscribeBlur();\n };\n }, [effect, navigation]);\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAwBC,MAAxB,EAAgD;EAC7D,MAAMC,UAAU,GAAG,IAAAC,sBAAA,GAAnB;;EAEA,IAAIC,SAAS,CAAC,CAAD,CAAT,KAAiBC,SAArB,EAAgC;IAC9B,MAAMC,OAAO,GACX,yFACA,8EADA,GAEA,mBAFA,GAGA,+BAHA,GAIA,yBAJA,GAKA,sBALA,GAMA,QANA,GAOA,oEARF;IAUAC,OAAO,CAACC,KAAR,CAAcF,OAAd;EACD;;EAEDG,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpB,IAAIC,SAAS,GAAG,KAAhB;IACA,IAAIC,OAAJ;;IAEA,MAAMC,QAAQ,GAAG,MAAM;MACrB,MAAMC,OAAO,GAAGb,MAAM,EAAtB;;MAEA,IAAIa,OAAO,KAAKT,SAAZ,IAAyB,OAAOS,OAAP,KAAmB,UAAhD,EAA4D;QAC1D,OAAOA,OAAP;MACD;;MAED,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;QACzC,IAAIX,OAAO,GACT,6FADF;;QAGA,IAAIQ,OAAO,KAAK,IAAhB,EAAsB;UACpBR,OAAO,IACL,kGADF;QAED,CAHD,MAGO,IAAI,OAAQQ,OAAD,CAAiBI,IAAxB,KAAiC,UAArC,EAAiD;UACtDZ,OAAO,IACL,0FACA,uDADA,GAEA,8BAFA,GAGA,mBAHA,GAIA,+BAJA,GAKA,oCALA,GAMA,+BANA,GAOA,uDAPA,GAQA,gBARA,GASA,WATA,GAUA,oBAVA,GAWA,kBAXA,GAYA,QAZA,GAaA,oEAdF;QAeD,CAhBM,MAgBA;UACLA,OAAO,IAAK,kBAAiBa,IAAI,CAACC,SAAL,CAAeN,OAAf,CAAwB,IAArD;QACD;;QAEDP,OAAO,CAACC,KAAR,CAAcF,OAAd;MACD;IACF,CApCD,CAJoB,CA0CpB;;;IACA,IAAIJ,UAAU,CAACS,SAAX,EAAJ,EAA4B;MAC1BC,OAAO,GAAGC,QAAQ,EAAlB;MACAF,SAAS,GAAG,IAAZ;IACD;;IAED,MAAMU,gBAAgB,GAAGnB,UAAU,CAACoB,WAAX,CAAuB,OAAvB,EAAgC,MAAM;MAC7D;MACA;MACA,IAAIX,SAAJ,EAAe;QACb;MACD;;MAED,IAAIC,OAAO,KAAKP,SAAhB,EAA2B;QACzBO,OAAO;MACR;;MAEDA,OAAO,GAAGC,QAAQ,EAAlB;MACAF,SAAS,GAAG,IAAZ;IACD,CAbwB,CAAzB;IAeA,MAAMY,eAAe,GAAGrB,UAAU,CAACoB,WAAX,CAAuB,MAAvB,EAA+B,MAAM;MAC3D,IAAIV,OAAO,KAAKP,SAAhB,EAA2B;QACzBO,OAAO;MACR;;MAEDA,OAAO,GAAGP,SAAV;MACAM,SAAS,GAAG,KAAZ;IACD,CAPuB,CAAxB;IASA,OAAO,MAAM;MACX,IAAIC,OAAO,KAAKP,SAAhB,EAA2B;QACzBO,OAAO;MACR;;MAEDS,gBAAgB;MAChBE,eAAe;IAChB,CAPD;EAQD,CAhFD,EAgFG,CAACtB,MAAD,EAASC,UAAT,CAhFH;AAiFD"}
1
+ {"version":3,"names":["useFocusEffect","effect","navigation","useNavigation","arguments","undefined","message","console","error","React","useEffect","isFocused","cleanup","callback","destroy","process","env","NODE_ENV","then","JSON","stringify","unsubscribeFocus","addListener","unsubscribeBlur"],"sourceRoot":"../../src","sources":["useFocusEffect.tsx"],"mappings":";;;;;;AAAA;AAEA;AAA4C;AAAA;AAAA;AAI5C;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAc,CAACC,MAAsB,EAAE;EAC7D,MAAMC,UAAU,GAAG,IAAAC,sBAAa,GAAE;EAElC,IAAIC,SAAS,CAAC,CAAC,CAAC,KAAKC,SAAS,EAAE;IAC9B,MAAMC,OAAO,GACX,sFAAsF,GACtF,8EAA8E,GAC9E,mBAAmB,GACnB,+BAA+B,GAC/B,yBAAyB,GACzB,sBAAsB,GACtB,QAAQ,GACR,oEAAoE;IAEtEC,OAAO,CAACC,KAAK,CAACF,OAAO,CAAC;EACxB;EAEAG,KAAK,CAACC,SAAS,CAAC,MAAM;IACpB,IAAIC,SAAS,GAAG,KAAK;IACrB,IAAIC,OAAwC;IAE5C,MAAMC,QAAQ,GAAG,MAAM;MACrB,MAAMC,OAAO,GAAGb,MAAM,EAAE;MAExB,IAAIa,OAAO,KAAKT,SAAS,IAAI,OAAOS,OAAO,KAAK,UAAU,EAAE;QAC1D,OAAOA,OAAO;MAChB;MAEA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAIX,OAAO,GACT,6FAA6F;QAE/F,IAAIQ,OAAO,KAAK,IAAI,EAAE;UACpBR,OAAO,IACL,kGAAkG;QACtG,CAAC,MAAM,IAAI,OAAQQ,OAAO,CAASI,IAAI,KAAK,UAAU,EAAE;UACtDZ,OAAO,IACL,uFAAuF,GACvF,uDAAuD,GACvD,8BAA8B,GAC9B,mBAAmB,GACnB,+BAA+B,GAC/B,oCAAoC,GACpC,+BAA+B,GAC/B,uDAAuD,GACvD,gBAAgB,GAChB,WAAW,GACX,oBAAoB,GACpB,kBAAkB,GAClB,QAAQ,GACR,oEAAoE;QACxE,CAAC,MAAM;UACLA,OAAO,IAAK,kBAAiBa,IAAI,CAACC,SAAS,CAACN,OAAO,CAAE,IAAG;QAC1D;QAEAP,OAAO,CAACC,KAAK,CAACF,OAAO,CAAC;MACxB;IACF,CAAC;;IAED;IACA,IAAIJ,UAAU,CAACS,SAAS,EAAE,EAAE;MAC1BC,OAAO,GAAGC,QAAQ,EAAE;MACpBF,SAAS,GAAG,IAAI;IAClB;IAEA,MAAMU,gBAAgB,GAAGnB,UAAU,CAACoB,WAAW,CAAC,OAAO,EAAE,MAAM;MAC7D;MACA;MACA,IAAIX,SAAS,EAAE;QACb;MACF;MAEA,IAAIC,OAAO,KAAKP,SAAS,EAAE;QACzBO,OAAO,EAAE;MACX;MAEAA,OAAO,GAAGC,QAAQ,EAAE;MACpBF,SAAS,GAAG,IAAI;IAClB,CAAC,CAAC;IAEF,MAAMY,eAAe,GAAGrB,UAAU,CAACoB,WAAW,CAAC,MAAM,EAAE,MAAM;MAC3D,IAAIV,OAAO,KAAKP,SAAS,EAAE;QACzBO,OAAO,EAAE;MACX;MAEAA,OAAO,GAAGP,SAAS;MACnBM,SAAS,GAAG,KAAK;IACnB,CAAC,CAAC;IAEF,OAAO,MAAM;MACX,IAAIC,OAAO,KAAKP,SAAS,EAAE;QACzBO,OAAO,EAAE;MACX;MAEAS,gBAAgB,EAAE;MAClBE,eAAe,EAAE;IACnB,CAAC;EACH,CAAC,EAAE,CAACtB,MAAM,EAAEC,UAAU,CAAC,CAAC;AAC1B"}
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useFocusEvents;
7
-
8
7
  var React = _interopRequireWildcard(require("react"));
9
-
10
8
  var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
12
  /**
19
13
  * Hook to take care of emitting `focus` and `blur` events.
20
14
  */
@@ -25,9 +19,10 @@ function useFocusEvents(_ref) {
25
19
  } = _ref;
26
20
  const navigation = React.useContext(_NavigationContext.default);
27
21
  const lastFocusedKeyRef = React.useRef();
28
- const currentFocusedKey = state.routes[state.index].key; // When the parent screen changes its focus state, we also need to change child's focus
29
- // Coz the child screen can't be focused if the parent screen is out of focus
22
+ const currentFocusedKey = state.routes[state.index].key;
30
23
 
24
+ // When the parent screen changes its focus state, we also need to change child's focus
25
+ // Coz the child screen can't be focused if the parent screen is out of focus
31
26
  React.useEffect(() => navigation === null || navigation === void 0 ? void 0 : navigation.addListener('focus', () => {
32
27
  lastFocusedKeyRef.current = currentFocusedKey;
33
28
  emitter.emit({
@@ -44,27 +39,26 @@ function useFocusEvents(_ref) {
44
39
  }), [currentFocusedKey, emitter, navigation]);
45
40
  React.useEffect(() => {
46
41
  const lastFocusedKey = lastFocusedKeyRef.current;
47
- lastFocusedKeyRef.current = currentFocusedKey; // We wouldn't have `lastFocusedKey` on initial mount
48
- // Fire focus event for the current route on mount if there's no parent navigator
42
+ lastFocusedKeyRef.current = currentFocusedKey;
49
43
 
44
+ // We wouldn't have `lastFocusedKey` on initial mount
45
+ // Fire focus event for the current route on mount if there's no parent navigator
50
46
  if (lastFocusedKey === undefined && !navigation) {
51
47
  emitter.emit({
52
48
  type: 'focus',
53
49
  target: currentFocusedKey
54
50
  });
55
- } // We should only emit events when the focused key changed and navigator is focused
56
- // When navigator is not focused, screens inside shouldn't receive focused status either
57
-
51
+ }
58
52
 
53
+ // We should only emit events when the focused key changed and navigator is focused
54
+ // When navigator is not focused, screens inside shouldn't receive focused status either
59
55
  if (lastFocusedKey === currentFocusedKey || !(navigation ? navigation.isFocused() : true)) {
60
56
  return;
61
57
  }
62
-
63
58
  if (lastFocusedKey === undefined) {
64
59
  // Only fire events after initial mount
65
60
  return;
66
61
  }
67
-
68
62
  emitter.emit({
69
63
  type: 'blur',
70
64
  target: lastFocusedKey
@@ -1 +1 @@
1
- {"version":3,"names":["useFocusEvents","state","emitter","navigation","React","useContext","NavigationContext","lastFocusedKeyRef","useRef","currentFocusedKey","routes","index","key","useEffect","addListener","current","emit","type","target","undefined","lastFocusedKey","isFocused"],"sources":["useFocusEvents.tsx"],"sourcesContent":["import type { NavigationState } from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationContext from './NavigationContext';\nimport type { EventMapCore } from './types';\nimport type { NavigationEventEmitter } from './useEventEmitter';\n\ntype Options<State extends NavigationState> = {\n state: State;\n emitter: NavigationEventEmitter<EventMapCore<State>>;\n};\n\n/**\n * Hook to take care of emitting `focus` and `blur` events.\n */\nexport default function useFocusEvents<State extends NavigationState>({\n state,\n emitter,\n}: Options<State>) {\n const navigation = React.useContext(NavigationContext);\n const lastFocusedKeyRef = React.useRef<string | undefined>();\n\n const currentFocusedKey = state.routes[state.index].key;\n\n // When the parent screen changes its focus state, we also need to change child's focus\n // Coz the child screen can't be focused if the parent screen is out of focus\n React.useEffect(\n () =>\n navigation?.addListener('focus', () => {\n lastFocusedKeyRef.current = currentFocusedKey;\n emitter.emit({ type: 'focus', target: currentFocusedKey });\n }),\n [currentFocusedKey, emitter, navigation]\n );\n\n React.useEffect(\n () =>\n navigation?.addListener('blur', () => {\n lastFocusedKeyRef.current = undefined;\n emitter.emit({ type: 'blur', target: currentFocusedKey });\n }),\n [currentFocusedKey, emitter, navigation]\n );\n\n React.useEffect(() => {\n const lastFocusedKey = lastFocusedKeyRef.current;\n\n lastFocusedKeyRef.current = currentFocusedKey;\n\n // We wouldn't have `lastFocusedKey` on initial mount\n // Fire focus event for the current route on mount if there's no parent navigator\n if (lastFocusedKey === undefined && !navigation) {\n emitter.emit({ type: 'focus', target: currentFocusedKey });\n }\n\n // We should only emit events when the focused key changed and navigator is focused\n // When navigator is not focused, screens inside shouldn't receive focused status either\n if (\n lastFocusedKey === currentFocusedKey ||\n !(navigation ? navigation.isFocused() : true)\n ) {\n return;\n }\n\n if (lastFocusedKey === undefined) {\n // Only fire events after initial mount\n return;\n }\n\n emitter.emit({ type: 'blur', target: lastFocusedKey });\n emitter.emit({ type: 'focus', target: currentFocusedKey });\n }, [currentFocusedKey, emitter, navigation]);\n}\n"],"mappings":";;;;;;;AACA;;AAEA;;;;;;;;AASA;AACA;AACA;AACe,SAASA,cAAT,OAGI;EAAA,IAHmD;IACpEC,KADoE;IAEpEC;EAFoE,CAGnD;EACjB,MAAMC,UAAU,GAAGC,KAAK,CAACC,UAAN,CAAiBC,0BAAjB,CAAnB;EACA,MAAMC,iBAAiB,GAAGH,KAAK,CAACI,MAAN,EAA1B;EAEA,MAAMC,iBAAiB,GAAGR,KAAK,CAACS,MAAN,CAAaT,KAAK,CAACU,KAAnB,EAA0BC,GAApD,CAJiB,CAMjB;EACA;;EACAR,KAAK,CAACS,SAAN,CACE,MACEV,UADF,aACEA,UADF,uBACEA,UAAU,CAAEW,WAAZ,CAAwB,OAAxB,EAAiC,MAAM;IACrCP,iBAAiB,CAACQ,OAAlB,GAA4BN,iBAA5B;IACAP,OAAO,CAACc,IAAR,CAAa;MAAEC,IAAI,EAAE,OAAR;MAAiBC,MAAM,EAAET;IAAzB,CAAb;EACD,CAHD,CAFJ,EAME,CAACA,iBAAD,EAAoBP,OAApB,EAA6BC,UAA7B,CANF;EASAC,KAAK,CAACS,SAAN,CACE,MACEV,UADF,aACEA,UADF,uBACEA,UAAU,CAAEW,WAAZ,CAAwB,MAAxB,EAAgC,MAAM;IACpCP,iBAAiB,CAACQ,OAAlB,GAA4BI,SAA5B;IACAjB,OAAO,CAACc,IAAR,CAAa;MAAEC,IAAI,EAAE,MAAR;MAAgBC,MAAM,EAAET;IAAxB,CAAb;EACD,CAHD,CAFJ,EAME,CAACA,iBAAD,EAAoBP,OAApB,EAA6BC,UAA7B,CANF;EASAC,KAAK,CAACS,SAAN,CAAgB,MAAM;IACpB,MAAMO,cAAc,GAAGb,iBAAiB,CAACQ,OAAzC;IAEAR,iBAAiB,CAACQ,OAAlB,GAA4BN,iBAA5B,CAHoB,CAKpB;IACA;;IACA,IAAIW,cAAc,KAAKD,SAAnB,IAAgC,CAAChB,UAArC,EAAiD;MAC/CD,OAAO,CAACc,IAAR,CAAa;QAAEC,IAAI,EAAE,OAAR;QAAiBC,MAAM,EAAET;MAAzB,CAAb;IACD,CATmB,CAWpB;IACA;;;IACA,IACEW,cAAc,KAAKX,iBAAnB,IACA,EAAEN,UAAU,GAAGA,UAAU,CAACkB,SAAX,EAAH,GAA4B,IAAxC,CAFF,EAGE;MACA;IACD;;IAED,IAAID,cAAc,KAAKD,SAAvB,EAAkC;MAChC;MACA;IACD;;IAEDjB,OAAO,CAACc,IAAR,CAAa;MAAEC,IAAI,EAAE,MAAR;MAAgBC,MAAM,EAAEE;IAAxB,CAAb;IACAlB,OAAO,CAACc,IAAR,CAAa;MAAEC,IAAI,EAAE,OAAR;MAAiBC,MAAM,EAAET;IAAzB,CAAb;EACD,CA3BD,EA2BG,CAACA,iBAAD,EAAoBP,OAApB,EAA6BC,UAA7B,CA3BH;AA4BD"}
1
+ {"version":3,"names":["useFocusEvents","state","emitter","navigation","React","useContext","NavigationContext","lastFocusedKeyRef","useRef","currentFocusedKey","routes","index","key","useEffect","addListener","current","emit","type","target","undefined","lastFocusedKey","isFocused"],"sourceRoot":"../../src","sources":["useFocusEvents.tsx"],"mappings":";;;;;;AACA;AAEA;AAAoD;AAAA;AAAA;AASpD;AACA;AACA;AACe,SAASA,cAAc,OAGnB;EAAA,IAHmD;IACpEC,KAAK;IACLC;EACc,CAAC;EACf,MAAMC,UAAU,GAAGC,KAAK,CAACC,UAAU,CAACC,0BAAiB,CAAC;EACtD,MAAMC,iBAAiB,GAAGH,KAAK,CAACI,MAAM,EAAsB;EAE5D,MAAMC,iBAAiB,GAAGR,KAAK,CAACS,MAAM,CAACT,KAAK,CAACU,KAAK,CAAC,CAACC,GAAG;;EAEvD;EACA;EACAR,KAAK,CAACS,SAAS,CACb,MACEV,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEW,WAAW,CAAC,OAAO,EAAE,MAAM;IACrCP,iBAAiB,CAACQ,OAAO,GAAGN,iBAAiB;IAC7CP,OAAO,CAACc,IAAI,CAAC;MAAEC,IAAI,EAAE,OAAO;MAAEC,MAAM,EAAET;IAAkB,CAAC,CAAC;EAC5D,CAAC,CAAC,EACJ,CAACA,iBAAiB,EAAEP,OAAO,EAAEC,UAAU,CAAC,CACzC;EAEDC,KAAK,CAACS,SAAS,CACb,MACEV,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEW,WAAW,CAAC,MAAM,EAAE,MAAM;IACpCP,iBAAiB,CAACQ,OAAO,GAAGI,SAAS;IACrCjB,OAAO,CAACc,IAAI,CAAC;MAAEC,IAAI,EAAE,MAAM;MAAEC,MAAM,EAAET;IAAkB,CAAC,CAAC;EAC3D,CAAC,CAAC,EACJ,CAACA,iBAAiB,EAAEP,OAAO,EAAEC,UAAU,CAAC,CACzC;EAEDC,KAAK,CAACS,SAAS,CAAC,MAAM;IACpB,MAAMO,cAAc,GAAGb,iBAAiB,CAACQ,OAAO;IAEhDR,iBAAiB,CAACQ,OAAO,GAAGN,iBAAiB;;IAE7C;IACA;IACA,IAAIW,cAAc,KAAKD,SAAS,IAAI,CAAChB,UAAU,EAAE;MAC/CD,OAAO,CAACc,IAAI,CAAC;QAAEC,IAAI,EAAE,OAAO;QAAEC,MAAM,EAAET;MAAkB,CAAC,CAAC;IAC5D;;IAEA;IACA;IACA,IACEW,cAAc,KAAKX,iBAAiB,IACpC,EAAEN,UAAU,GAAGA,UAAU,CAACkB,SAAS,EAAE,GAAG,IAAI,CAAC,EAC7C;MACA;IACF;IAEA,IAAID,cAAc,KAAKD,SAAS,EAAE;MAChC;MACA;IACF;IAEAjB,OAAO,CAACc,IAAI,CAAC;MAAEC,IAAI,EAAE,MAAM;MAAEC,MAAM,EAAEE;IAAe,CAAC,CAAC;IACtDlB,OAAO,CAACc,IAAI,CAAC;MAAEC,IAAI,EAAE,OAAO;MAAEC,MAAM,EAAET;IAAkB,CAAC,CAAC;EAC5D,CAAC,EAAE,CAACA,iBAAiB,EAAEP,OAAO,EAAEC,UAAU,CAAC,CAAC;AAC9C"}
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useFocusedListenersChildrenAdapter;
7
-
8
7
  var React = _interopRequireWildcard(require("react"));
9
-
10
8
  var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
12
  /**
19
13
  * Hook for passing focus callback to children
20
14
  */
@@ -33,7 +27,6 @@ function useFocusedListenersChildrenAdapter(_ref) {
33
27
  handled,
34
28
  result
35
29
  } = listener(callback);
36
-
37
30
  if (handled) {
38
31
  return {
39
32
  handled,
@@ -41,7 +34,6 @@ function useFocusedListenersChildrenAdapter(_ref) {
41
34
  };
42
35
  }
43
36
  }
44
-
45
37
  return {
46
38
  handled: true,
47
39
  result: callback(navigation)
@@ -1 +1 @@
1
- {"version":3,"names":["useFocusedListenersChildrenAdapter","navigation","focusedListeners","addListener","React","useContext","NavigationBuilderContext","listener","useCallback","callback","isFocused","handled","result","useEffect"],"sources":["useFocusedListenersChildrenAdapter.tsx"],"sourcesContent":["import type { ParamListBase } from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationBuilderContext, {\n FocusedNavigationCallback,\n FocusedNavigationListener,\n} from './NavigationBuilderContext';\nimport type { NavigationHelpers } from './types';\n\ntype Options = {\n navigation: NavigationHelpers<ParamListBase>;\n focusedListeners: FocusedNavigationListener[];\n};\n\n/**\n * Hook for passing focus callback to children\n */\nexport default function useFocusedListenersChildrenAdapter({\n navigation,\n focusedListeners,\n}: Options) {\n const { addListener } = React.useContext(NavigationBuilderContext);\n\n const listener = React.useCallback(\n (callback: FocusedNavigationCallback<any>) => {\n if (navigation.isFocused()) {\n for (const listener of focusedListeners) {\n const { handled, result } = listener(callback);\n\n if (handled) {\n return { handled, result };\n }\n }\n\n return { handled: true, result: callback(navigation) };\n } else {\n return { handled: false, result: null };\n }\n },\n [focusedListeners, navigation]\n );\n\n React.useEffect(\n () => addListener?.('focus', listener),\n [addListener, listener]\n );\n}\n"],"mappings":";;;;;;;AACA;;AAEA;;;;;;;;AAWA;AACA;AACA;AACe,SAASA,kCAAT,OAGH;EAAA,IAH+C;IACzDC,UADyD;IAEzDC;EAFyD,CAG/C;EACV,MAAM;IAAEC;EAAF,IAAkBC,KAAK,CAACC,UAAN,CAAiBC,iCAAjB,CAAxB;EAEA,MAAMC,QAAQ,GAAGH,KAAK,CAACI,WAAN,CACdC,QAAD,IAA8C;IAC5C,IAAIR,UAAU,CAACS,SAAX,EAAJ,EAA4B;MAC1B,KAAK,MAAMH,QAAX,IAAuBL,gBAAvB,EAAyC;QACvC,MAAM;UAAES,OAAF;UAAWC;QAAX,IAAsBL,QAAQ,CAACE,QAAD,CAApC;;QAEA,IAAIE,OAAJ,EAAa;UACX,OAAO;YAAEA,OAAF;YAAWC;UAAX,CAAP;QACD;MACF;;MAED,OAAO;QAAED,OAAO,EAAE,IAAX;QAAiBC,MAAM,EAAEH,QAAQ,CAACR,UAAD;MAAjC,CAAP;IACD,CAVD,MAUO;MACL,OAAO;QAAEU,OAAO,EAAE,KAAX;QAAkBC,MAAM,EAAE;MAA1B,CAAP;IACD;EACF,CAfc,EAgBf,CAACV,gBAAD,EAAmBD,UAAnB,CAhBe,CAAjB;EAmBAG,KAAK,CAACS,SAAN,CACE,MAAMV,WAAN,aAAMA,WAAN,uBAAMA,WAAW,CAAG,OAAH,EAAYI,QAAZ,CADnB,EAEE,CAACJ,WAAD,EAAcI,QAAd,CAFF;AAID"}
1
+ {"version":3,"names":["useFocusedListenersChildrenAdapter","navigation","focusedListeners","addListener","React","useContext","NavigationBuilderContext","listener","useCallback","callback","isFocused","handled","result","useEffect"],"sourceRoot":"../../src","sources":["useFocusedListenersChildrenAdapter.tsx"],"mappings":";;;;;;AACA;AAEA;AAGoC;AAAA;AAAA;AAQpC;AACA;AACA;AACe,SAASA,kCAAkC,OAG9C;EAAA,IAH+C;IACzDC,UAAU;IACVC;EACO,CAAC;EACR,MAAM;IAAEC;EAAY,CAAC,GAAGC,KAAK,CAACC,UAAU,CAACC,iCAAwB,CAAC;EAElE,MAAMC,QAAQ,GAAGH,KAAK,CAACI,WAAW,CAC/BC,QAAwC,IAAK;IAC5C,IAAIR,UAAU,CAACS,SAAS,EAAE,EAAE;MAC1B,KAAK,MAAMH,QAAQ,IAAIL,gBAAgB,EAAE;QACvC,MAAM;UAAES,OAAO;UAAEC;QAAO,CAAC,GAAGL,QAAQ,CAACE,QAAQ,CAAC;QAE9C,IAAIE,OAAO,EAAE;UACX,OAAO;YAAEA,OAAO;YAAEC;UAAO,CAAC;QAC5B;MACF;MAEA,OAAO;QAAED,OAAO,EAAE,IAAI;QAAEC,MAAM,EAAEH,QAAQ,CAACR,UAAU;MAAE,CAAC;IACxD,CAAC,MAAM;MACL,OAAO;QAAEU,OAAO,EAAE,KAAK;QAAEC,MAAM,EAAE;MAAK,CAAC;IACzC;EACF,CAAC,EACD,CAACV,gBAAgB,EAAED,UAAU,CAAC,CAC/B;EAEDG,KAAK,CAACS,SAAS,CACb,MAAMV,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAG,OAAO,EAAEI,QAAQ,CAAC,EACtC,CAACJ,WAAW,EAAEI,QAAQ,CAAC,CACxB;AACH"}
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useIsFocused;
7
-
8
7
  var React = _interopRequireWildcard(require("react"));
9
-
10
8
  var _useNavigation = _interopRequireDefault(require("./useNavigation"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
12
  /**
19
13
  * Hook to get the current focus state of the screen. Returns a `true` if screen is focused, otherwise `false`.
20
14
  * This can be used if a component needs to render something based on the focus state.
@@ -23,7 +17,6 @@ function useIsFocused() {
23
17
  const navigation = (0, _useNavigation.default)();
24
18
  const [isFocused, setIsFocused] = (0, React.useState)(navigation.isFocused);
25
19
  const valueToReturn = navigation.isFocused();
26
-
27
20
  if (isFocused !== valueToReturn) {
28
21
  // If the value has changed since the last render, we need to update it.
29
22
  // This could happen if we missed an update from the event listeners during re-render.
@@ -32,7 +25,6 @@ function useIsFocused() {
32
25
  // This is the same logic as in https://github.com/facebook/react/tree/master/packages/use-subscription
33
26
  setIsFocused(valueToReturn);
34
27
  }
35
-
36
28
  React.useEffect(() => {
37
29
  const unsubscribeFocus = navigation.addListener('focus', () => setIsFocused(true));
38
30
  const unsubscribeBlur = navigation.addListener('blur', () => setIsFocused(false));
@@ -1 +1 @@
1
- {"version":3,"names":["useIsFocused","navigation","useNavigation","isFocused","setIsFocused","useState","valueToReturn","React","useEffect","unsubscribeFocus","addListener","unsubscribeBlur","useDebugValue"],"sources":["useIsFocused.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useState } from 'react';\n\nimport useNavigation from './useNavigation';\n\n/**\n * Hook to get the current focus state of the screen. Returns a `true` if screen is focused, otherwise `false`.\n * This can be used if a component needs to render something based on the focus state.\n */\nexport default function useIsFocused(): boolean {\n const navigation = useNavigation();\n const [isFocused, setIsFocused] = useState(navigation.isFocused);\n\n const valueToReturn = navigation.isFocused();\n\n if (isFocused !== valueToReturn) {\n // If the value has changed since the last render, we need to update it.\n // This could happen if we missed an update from the event listeners during re-render.\n // React will process this update immediately, so the old subscription value won't be committed.\n // It is still nice to avoid returning a mismatched value though, so let's override the return value.\n // This is the same logic as in https://github.com/facebook/react/tree/master/packages/use-subscription\n setIsFocused(valueToReturn);\n }\n\n React.useEffect(() => {\n const unsubscribeFocus = navigation.addListener('focus', () =>\n setIsFocused(true)\n );\n\n const unsubscribeBlur = navigation.addListener('blur', () =>\n setIsFocused(false)\n );\n\n return () => {\n unsubscribeFocus();\n unsubscribeBlur();\n };\n }, [navigation]);\n\n React.useDebugValue(valueToReturn);\n\n return valueToReturn;\n}\n"],"mappings":";;;;;;;AAAA;;AAGA;;;;;;;;AAEA;AACA;AACA;AACA;AACe,SAASA,YAAT,GAAiC;EAC9C,MAAMC,UAAU,GAAG,IAAAC,sBAAA,GAAnB;EACA,MAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4B,IAAAC,cAAA,EAASJ,UAAU,CAACE,SAApB,CAAlC;EAEA,MAAMG,aAAa,GAAGL,UAAU,CAACE,SAAX,EAAtB;;EAEA,IAAIA,SAAS,KAAKG,aAAlB,EAAiC;IAC/B;IACA;IACA;IACA;IACA;IACAF,YAAY,CAACE,aAAD,CAAZ;EACD;;EAEDC,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpB,MAAMC,gBAAgB,GAAGR,UAAU,CAACS,WAAX,CAAuB,OAAvB,EAAgC,MACvDN,YAAY,CAAC,IAAD,CADW,CAAzB;IAIA,MAAMO,eAAe,GAAGV,UAAU,CAACS,WAAX,CAAuB,MAAvB,EAA+B,MACrDN,YAAY,CAAC,KAAD,CADU,CAAxB;IAIA,OAAO,MAAM;MACXK,gBAAgB;MAChBE,eAAe;IAChB,CAHD;EAID,CAbD,EAaG,CAACV,UAAD,CAbH;EAeAM,KAAK,CAACK,aAAN,CAAoBN,aAApB;EAEA,OAAOA,aAAP;AACD"}
1
+ {"version":3,"names":["useIsFocused","navigation","useNavigation","isFocused","setIsFocused","useState","valueToReturn","React","useEffect","unsubscribeFocus","addListener","unsubscribeBlur","useDebugValue"],"sourceRoot":"../../src","sources":["useIsFocused.tsx"],"mappings":";;;;;;AAAA;AAGA;AAA4C;AAAA;AAAA;AAE5C;AACA;AACA;AACA;AACe,SAASA,YAAY,GAAY;EAC9C,MAAMC,UAAU,GAAG,IAAAC,sBAAa,GAAE;EAClC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAG,IAAAC,cAAQ,EAACJ,UAAU,CAACE,SAAS,CAAC;EAEhE,MAAMG,aAAa,GAAGL,UAAU,CAACE,SAAS,EAAE;EAE5C,IAAIA,SAAS,KAAKG,aAAa,EAAE;IAC/B;IACA;IACA;IACA;IACA;IACAF,YAAY,CAACE,aAAa,CAAC;EAC7B;EAEAC,KAAK,CAACC,SAAS,CAAC,MAAM;IACpB,MAAMC,gBAAgB,GAAGR,UAAU,CAACS,WAAW,CAAC,OAAO,EAAE,MACvDN,YAAY,CAAC,IAAI,CAAC,CACnB;IAED,MAAMO,eAAe,GAAGV,UAAU,CAACS,WAAW,CAAC,MAAM,EAAE,MACrDN,YAAY,CAAC,KAAK,CAAC,CACpB;IAED,OAAO,MAAM;MACXK,gBAAgB,EAAE;MAClBE,eAAe,EAAE;IACnB,CAAC;EACH,CAAC,EAAE,CAACV,UAAU,CAAC,CAAC;EAEhBM,KAAK,CAACK,aAAa,CAACN,aAAa,CAAC;EAElC,OAAOA,aAAa;AACtB"}
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useKeyedChildListeners;
7
-
8
7
  var React = _interopRequireWildcard(require("react"));
9
-
10
8
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
-
12
9
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
-
14
10
  /**
15
11
  * Hook which lets child navigators add getters to be called for obtaining rehydrated state.
16
12
  */
@@ -1 +1 @@
1
- {"version":3,"names":["useKeyedChildListeners","current","keyedListeners","React","useRef","Object","assign","create","getState","beforeRemove","addKeyedListener","useCallback","type","key","listener","undefined"],"sources":["useKeyedChildListeners.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport type { KeyedListenerMap } from './NavigationBuilderContext';\n\n/**\n * Hook which lets child navigators add getters to be called for obtaining rehydrated state.\n */\nexport default function useKeyedChildListeners() {\n const { current: keyedListeners } = React.useRef<{\n [K in keyof KeyedListenerMap]: Record<\n string,\n KeyedListenerMap[K] | undefined\n >;\n }>(\n Object.assign(Object.create(null), {\n getState: {},\n beforeRemove: {},\n })\n );\n\n const addKeyedListener = React.useCallback(\n <T extends keyof KeyedListenerMap>(\n type: T,\n key: string,\n listener: KeyedListenerMap[T]\n ) => {\n // @ts-expect-error: according to ref stated above you can use `key` to index type\n keyedListeners[type][key] = listener;\n\n return () => {\n // @ts-expect-error: according to ref stated above you can use `key` to index type\n keyedListeners[type][key] = undefined;\n };\n },\n [keyedListeners]\n );\n\n return {\n keyedListeners,\n addKeyedListener,\n };\n}\n"],"mappings":";;;;;;;AAAA;;;;;;AAIA;AACA;AACA;AACe,SAASA,sBAAT,GAAkC;EAC/C,MAAM;IAAEC,OAAO,EAAEC;EAAX,IAA8BC,KAAK,CAACC,MAAN,CAMlCC,MAAM,CAACC,MAAP,CAAcD,MAAM,CAACE,MAAP,CAAc,IAAd,CAAd,EAAmC;IACjCC,QAAQ,EAAE,EADuB;IAEjCC,YAAY,EAAE;EAFmB,CAAnC,CANkC,CAApC;EAYA,MAAMC,gBAAgB,GAAGP,KAAK,CAACQ,WAAN,CACvB,CACEC,IADF,EAEEC,GAFF,EAGEC,QAHF,KAIK;IACH;IACAZ,cAAc,CAACU,IAAD,CAAd,CAAqBC,GAArB,IAA4BC,QAA5B;IAEA,OAAO,MAAM;MACX;MACAZ,cAAc,CAACU,IAAD,CAAd,CAAqBC,GAArB,IAA4BE,SAA5B;IACD,CAHD;EAID,CAbsB,EAcvB,CAACb,cAAD,CAduB,CAAzB;EAiBA,OAAO;IACLA,cADK;IAELQ;EAFK,CAAP;AAID"}
1
+ {"version":3,"names":["useKeyedChildListeners","current","keyedListeners","React","useRef","Object","assign","create","getState","beforeRemove","addKeyedListener","useCallback","type","key","listener","undefined"],"sourceRoot":"../../src","sources":["useKeyedChildListeners.tsx"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAI/B;AACA;AACA;AACe,SAASA,sBAAsB,GAAG;EAC/C,MAAM;IAAEC,OAAO,EAAEC;EAAe,CAAC,GAAGC,KAAK,CAACC,MAAM,CAM9CC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAAC,IAAI,CAAC,EAAE;IACjCC,QAAQ,EAAE,CAAC,CAAC;IACZC,YAAY,EAAE,CAAC;EACjB,CAAC,CAAC,CACH;EAED,MAAMC,gBAAgB,GAAGP,KAAK,CAACQ,WAAW,CACxC,CACEC,IAAO,EACPC,GAAW,EACXC,QAA6B,KAC1B;IACH;IACAZ,cAAc,CAACU,IAAI,CAAC,CAACC,GAAG,CAAC,GAAGC,QAAQ;IAEpC,OAAO,MAAM;MACX;MACAZ,cAAc,CAACU,IAAI,CAAC,CAACC,GAAG,CAAC,GAAGE,SAAS;IACvC,CAAC;EACH,CAAC,EACD,CAACb,cAAc,CAAC,CACjB;EAED,OAAO;IACLA,cAAc;IACdQ;EACF,CAAC;AACH"}
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useNavigation;
7
-
8
7
  var React = _interopRequireWildcard(require("react"));
9
-
10
8
  var _NavigationContainerRefContext = _interopRequireDefault(require("./NavigationContainerRefContext"));
11
-
12
9
  var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
13
  /**
21
14
  * Hook to access the navigation prop of the parent screen anywhere.
22
15
  *
@@ -25,12 +18,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
25
18
  function useNavigation() {
26
19
  const root = React.useContext(_NavigationContainerRefContext.default);
27
20
  const navigation = React.useContext(_NavigationContext.default);
28
-
29
21
  if (navigation === undefined && root === undefined) {
30
22
  throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
31
- } // FIXME: Figure out a better way to do this
32
-
23
+ }
33
24
 
34
- return navigation !== null && navigation !== void 0 ? navigation : root;
25
+ // FIXME: Figure out a better way to do this
26
+ return navigation ?? root;
35
27
  }
36
28
  //# sourceMappingURL=useNavigation.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useNavigation","root","React","useContext","NavigationContainerRefContext","navigation","NavigationContext","undefined","Error"],"sources":["useNavigation.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport NavigationContainerRefContext from './NavigationContainerRefContext';\nimport NavigationContext from './NavigationContext';\nimport type { NavigationProp } from './types';\n\n/**\n * Hook to access the navigation prop of the parent screen anywhere.\n *\n * @returns Navigation prop of the parent screen.\n */\nexport default function useNavigation<\n T = NavigationProp<ReactNavigation.RootParamList>\n>(): T {\n const root = React.useContext(NavigationContainerRefContext);\n const navigation = React.useContext(NavigationContext);\n\n if (navigation === undefined && root === undefined) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n // FIXME: Figure out a better way to do this\n return (navigation ?? root) as unknown as T;\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;;;;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,GAER;EACL,MAAMC,IAAI,GAAGC,KAAK,CAACC,UAAN,CAAiBC,sCAAjB,CAAb;EACA,MAAMC,UAAU,GAAGH,KAAK,CAACC,UAAN,CAAiBG,0BAAjB,CAAnB;;EAEA,IAAID,UAAU,KAAKE,SAAf,IAA4BN,IAAI,KAAKM,SAAzC,EAAoD;IAClD,MAAM,IAAIC,KAAJ,CACJ,kFADI,CAAN;EAGD,CARI,CAUL;;;EACA,OAAQH,UAAR,aAAQA,UAAR,cAAQA,UAAR,GAAsBJ,IAAtB;AACD"}
1
+ {"version":3,"names":["useNavigation","root","React","useContext","NavigationContainerRefContext","navigation","NavigationContext","undefined","Error"],"sourceRoot":"../../src","sources":["useNavigation.tsx"],"mappings":";;;;;;AAAA;AAEA;AACA;AAAoD;AAAA;AAAA;AAGpD;AACA;AACA;AACA;AACA;AACe,SAASA,aAAa,GAE9B;EACL,MAAMC,IAAI,GAAGC,KAAK,CAACC,UAAU,CAACC,sCAA6B,CAAC;EAC5D,MAAMC,UAAU,GAAGH,KAAK,CAACC,UAAU,CAACG,0BAAiB,CAAC;EAEtD,IAAID,UAAU,KAAKE,SAAS,IAAIN,IAAI,KAAKM,SAAS,EAAE;IAClD,MAAM,IAAIC,KAAK,CACb,kFAAkF,CACnF;EACH;;EAEA;EACA,OAAQH,UAAU,IAAIJ,IAAI;AAC5B"}