@react-navigation/core 6.0.1 → 6.1.1

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 (147) hide show
  1. package/lib/commonjs/BaseNavigationContainer.js +17 -12
  2. package/lib/commonjs/BaseNavigationContainer.js.map +1 -1
  3. package/lib/commonjs/CurrentRenderContext.js.map +1 -1
  4. package/lib/commonjs/EnsureSingleNavigator.js +5 -4
  5. package/lib/commonjs/EnsureSingleNavigator.js.map +1 -1
  6. package/lib/commonjs/NavigationContainerRefContext.js.map +1 -1
  7. package/lib/commonjs/NavigationContext.js.map +1 -1
  8. package/lib/commonjs/NavigationHelpersContext.js.map +1 -1
  9. package/lib/commonjs/NavigationRouteContext.js.map +1 -1
  10. package/lib/commonjs/SceneView.js +11 -10
  11. package/lib/commonjs/SceneView.js.map +1 -1
  12. package/lib/commonjs/UnhandledActionContext.js.map +1 -1
  13. package/lib/commonjs/createNavigationContainerRef.js +64 -16
  14. package/lib/commonjs/createNavigationContainerRef.js.map +1 -1
  15. package/lib/commonjs/createNavigatorFactory.js +1 -1
  16. package/lib/commonjs/createNavigatorFactory.js.map +1 -1
  17. package/lib/commonjs/fromEntries.js +3 -1
  18. package/lib/commonjs/fromEntries.js.map +1 -1
  19. package/lib/commonjs/getActionFromState.js +2 -1
  20. package/lib/commonjs/getActionFromState.js.map +1 -1
  21. package/lib/commonjs/getPathFromState.js +13 -3
  22. package/lib/commonjs/getPathFromState.js.map +1 -1
  23. package/lib/commonjs/getStateFromPath.js +12 -2
  24. package/lib/commonjs/getStateFromPath.js.map +1 -1
  25. package/lib/commonjs/index.js +24 -24
  26. package/lib/commonjs/isArrayEqual.js +9 -1
  27. package/lib/commonjs/isArrayEqual.js.map +1 -1
  28. package/lib/commonjs/isRecordEqual.js +25 -0
  29. package/lib/commonjs/isRecordEqual.js.map +1 -0
  30. package/lib/commonjs/types.js.map +1 -1
  31. package/lib/commonjs/useChildListeners.js.map +1 -1
  32. package/lib/commonjs/useCurrentRender.js +6 -5
  33. package/lib/commonjs/useCurrentRender.js.map +1 -1
  34. package/lib/commonjs/useDescriptors.js +18 -17
  35. package/lib/commonjs/useDescriptors.js.map +1 -1
  36. package/lib/commonjs/useEventEmitter.js +7 -6
  37. package/lib/commonjs/useEventEmitter.js.map +1 -1
  38. package/lib/commonjs/useFocusEvents.js +5 -4
  39. package/lib/commonjs/useFocusEvents.js.map +1 -1
  40. package/lib/commonjs/useFocusedListenersChildrenAdapter.js +5 -4
  41. package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -1
  42. package/lib/commonjs/useKeyedChildListeners.js.map +1 -1
  43. package/lib/commonjs/useNavigationBuilder.js +51 -20
  44. package/lib/commonjs/useNavigationBuilder.js.map +1 -1
  45. package/lib/commonjs/useNavigationCache.js +17 -10
  46. package/lib/commonjs/useNavigationCache.js.map +1 -1
  47. package/lib/commonjs/useNavigationHelpers.js +10 -7
  48. package/lib/commonjs/useNavigationHelpers.js.map +1 -1
  49. package/lib/commonjs/useOnAction.js +13 -11
  50. package/lib/commonjs/useOnAction.js.map +1 -1
  51. package/lib/commonjs/useOnGetState.js +5 -4
  52. package/lib/commonjs/useOnGetState.js.map +1 -1
  53. package/lib/commonjs/useOnPreventRemove.js +6 -5
  54. package/lib/commonjs/useOnPreventRemove.js.map +1 -1
  55. package/lib/commonjs/useOnRouteFocus.js +7 -6
  56. package/lib/commonjs/useOnRouteFocus.js.map +1 -1
  57. package/lib/commonjs/useOptionsGetters.js +6 -5
  58. package/lib/commonjs/useOptionsGetters.js.map +1 -1
  59. package/lib/commonjs/useRegisterNavigator.js +1 -1
  60. package/lib/commonjs/useRegisterNavigator.js.map +1 -1
  61. package/lib/commonjs/useRouteCache.js +1 -1
  62. package/lib/commonjs/useScheduleUpdate.js +1 -1
  63. package/lib/commonjs/validatePathConfig.js +5 -2
  64. package/lib/commonjs/validatePathConfig.js.map +1 -1
  65. package/lib/module/BaseNavigationContainer.js +17 -12
  66. package/lib/module/BaseNavigationContainer.js.map +1 -1
  67. package/lib/module/CurrentRenderContext.js.map +1 -1
  68. package/lib/module/EnsureSingleNavigator.js +4 -3
  69. package/lib/module/EnsureSingleNavigator.js.map +1 -1
  70. package/lib/module/NavigationContainerRefContext.js.map +1 -1
  71. package/lib/module/NavigationContext.js.map +1 -1
  72. package/lib/module/NavigationHelpersContext.js.map +1 -1
  73. package/lib/module/NavigationRouteContext.js.map +1 -1
  74. package/lib/module/SceneView.js +11 -10
  75. package/lib/module/SceneView.js.map +1 -1
  76. package/lib/module/UnhandledActionContext.js.map +1 -1
  77. package/lib/module/createNavigationContainerRef.js +63 -15
  78. package/lib/module/createNavigationContainerRef.js.map +1 -1
  79. package/lib/module/createNavigatorFactory.js +1 -1
  80. package/lib/module/createNavigatorFactory.js.map +1 -1
  81. package/lib/module/fromEntries.js +3 -1
  82. package/lib/module/fromEntries.js.map +1 -1
  83. package/lib/module/getActionFromState.js +2 -1
  84. package/lib/module/getActionFromState.js.map +1 -1
  85. package/lib/module/getPathFromState.js +13 -3
  86. package/lib/module/getPathFromState.js.map +1 -1
  87. package/lib/module/getStateFromPath.js +12 -2
  88. package/lib/module/getStateFromPath.js.map +1 -1
  89. package/lib/module/isArrayEqual.js +9 -1
  90. package/lib/module/isArrayEqual.js.map +1 -1
  91. package/lib/module/isRecordEqual.js +18 -0
  92. package/lib/module/isRecordEqual.js.map +1 -0
  93. package/lib/module/types.js.map +1 -1
  94. package/lib/module/useChildListeners.js.map +1 -1
  95. package/lib/module/useCurrentRender.js +6 -5
  96. package/lib/module/useCurrentRender.js.map +1 -1
  97. package/lib/module/useDescriptors.js +18 -17
  98. package/lib/module/useDescriptors.js.map +1 -1
  99. package/lib/module/useEventEmitter.js +7 -6
  100. package/lib/module/useEventEmitter.js.map +1 -1
  101. package/lib/module/useFocusEvents.js +5 -4
  102. package/lib/module/useFocusEvents.js.map +1 -1
  103. package/lib/module/useFocusedListenersChildrenAdapter.js +5 -4
  104. package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
  105. package/lib/module/useKeyedChildListeners.js.map +1 -1
  106. package/lib/module/useNavigationBuilder.js +50 -20
  107. package/lib/module/useNavigationBuilder.js.map +1 -1
  108. package/lib/module/useNavigationCache.js +17 -10
  109. package/lib/module/useNavigationCache.js.map +1 -1
  110. package/lib/module/useNavigationHelpers.js +10 -7
  111. package/lib/module/useNavigationHelpers.js.map +1 -1
  112. package/lib/module/useOnAction.js +13 -11
  113. package/lib/module/useOnAction.js.map +1 -1
  114. package/lib/module/useOnGetState.js +5 -4
  115. package/lib/module/useOnGetState.js.map +1 -1
  116. package/lib/module/useOnPreventRemove.js +6 -5
  117. package/lib/module/useOnPreventRemove.js.map +1 -1
  118. package/lib/module/useOnRouteFocus.js +7 -6
  119. package/lib/module/useOnRouteFocus.js.map +1 -1
  120. package/lib/module/useOptionsGetters.js +6 -5
  121. package/lib/module/useOptionsGetters.js.map +1 -1
  122. package/lib/module/useRegisterNavigator.js +1 -1
  123. package/lib/module/useRegisterNavigator.js.map +1 -1
  124. package/lib/module/validatePathConfig.js +5 -2
  125. package/lib/module/validatePathConfig.js.map +1 -1
  126. package/lib/typescript/src/isRecordEqual.d.ts +4 -0
  127. package/lib/typescript/src/types.d.ts +11 -0
  128. package/lib/typescript/src/useDescriptors.d.ts +5 -4
  129. package/package.json +5 -5
  130. package/src/BaseNavigationContainer.tsx +4 -3
  131. package/src/CurrentRenderContext.tsx +3 -2
  132. package/src/EnsureSingleNavigator.tsx +7 -8
  133. package/src/NavigationContainerRefContext.tsx +3 -4
  134. package/src/NavigationContext.tsx +3 -2
  135. package/src/NavigationHelpersContext.tsx +3 -2
  136. package/src/NavigationRouteContext.tsx +3 -2
  137. package/src/UnhandledActionContext.tsx +3 -4
  138. package/src/createNavigationContainerRef.tsx +63 -12
  139. package/src/createNavigatorFactory.tsx +1 -1
  140. package/src/isArrayEqual.tsx +9 -1
  141. package/src/isRecordEqual.tsx +20 -0
  142. package/src/types.tsx +19 -6
  143. package/src/useChildListeners.tsx +3 -5
  144. package/src/useDescriptors.tsx +8 -7
  145. package/src/useKeyedChildListeners.tsx +6 -8
  146. package/src/useNavigationBuilder.tsx +89 -27
  147. package/src/useRegisterNavigator.tsx +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["useDescriptors.tsx"],"names":["React","NavigationBuilderContext","NavigationContext","NavigationRouteContext","SceneView","useNavigationCache","useRouteCache","useDescriptors","state","screens","navigation","screenOptions","defaultScreenOptions","onAction","getState","setState","addListener","addKeyedListener","onRouteFocus","router","emitter","options","setOptions","useState","onDispatchAction","onOptionsChange","stackRef","useContext","context","useMemo","navigations","routes","reduce","acc","route","i","config","name","screen","key","optionsList","filter","Boolean","customOptions","curr","Object","assign","mergedOptions","clearOptions","o","_","rest","render"],"mappings":"AAMA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,wBAAP,MAGO,4BAHP;AAIA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,SAAP,MAAsB,aAAtB;AAUA,OAAOC,kBAAP,MAA+B,sBAA/B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;;AA+CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAT,CAKb;AACAC,EAAAA,KADA;AAEAC,EAAAA,OAFA;AAGAC,EAAAA,UAHA;AAIAC,EAAAA,aAJA;AAKAC,EAAAA,oBALA;AAMAC,EAAAA,QANA;AAOAC,EAAAA,QAPA;AAQAC,EAAAA,QARA;AASAC,EAAAA,WATA;AAUAC,EAAAA,gBAVA;AAWAC,EAAAA,YAXA;AAYAC,EAAAA,MAZA;AAaAC,EAAAA;AAbA,CALa,EAmB6B;AAC1C,QAAM,CAACC,OAAD,EAAUC,UAAV,IAAwBtB,KAAK,CAACuB,QAAN,CAAuC,EAAvC,CAA9B;AACA,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA,eAApB;AAAqCC,IAAA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AGE,UAAA,MAAM,EAAEI,MAHV;AAIE,UAAA,UAAU,EAAE9B,KAAK,CAACuB,MAAN,CAAaI,CAAb,EAAgB3B,KAJ9B;AAKE,UAAA,QAAQ,EAAEM,QALZ;AAME,UAAA,QAAQ,EAAEC,QANZ;AAOE,UAAA,OAAO,EAAEgC,aAPX;AAQE,UAAA,YAAY,EAAEC;AARhB,UADF,CADF,CADF,CADF;AAkBD,OAvBc;;AAwBf3B,MAAAA,OAAO,EAAE0B;AAxBM,KAAjB;AA2BA,WAAOd,GAAP;AACD,GAxFM,EAwFJ,EAxFI,CAAP;AAyFD","sourcesContent":["import type {\n NavigationAction,\n NavigationState,\n ParamListBase,\n Router,\n} from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationBuilderContext, {\n AddKeyedListener,\n AddListener,\n} from './NavigationBuilderContext';\nimport NavigationContext from './NavigationContext';\nimport NavigationRouteContext from './NavigationRouteContext';\nimport SceneView from './SceneView';\nimport type {\n Descriptor,\n EventMapBase,\n NavigationHelpers,\n NavigationProp,\n RouteConfig,\n RouteProp,\n} from './types';\nimport type { NavigationEventEmitter } from './useEventEmitter';\nimport useNavigationCache from './useNavigationCache';\nimport useRouteCache from './useRouteCache';\n\nexport type ScreenConfigWithParent<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n> = [\n (ScreenOptionsOrCallback<ScreenOptions> | undefined)[] | undefined,\n RouteConfig<ParamListBase, string, State, ScreenOptions, EventMap>\n];\n\ntype ScreenOptionsOrCallback<ScreenOptions extends {}> =\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenOptions);\n\ntype Options<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n> = {\n state: State;\n screens: Record<\n string,\n ScreenConfigWithParent<State, ScreenOptions, EventMap>\n >;\n navigation: NavigationHelpers<ParamListBase>;\n screenOptions?: ScreenOptionsOrCallback<ScreenOptions>;\n defaultScreenOptions?:\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamListBase>;\n navigation: any;\n options: ScreenOptions;\n }) => ScreenOptions);\n onAction: (action: NavigationAction) => boolean;\n getState: () => State;\n setState: (state: State) => void;\n addListener: AddListener;\n addKeyedListener: AddKeyedListener;\n onRouteFocus: (key: string) => void;\n router: Router<State, NavigationAction>;\n emitter: NavigationEventEmitter<EventMap>;\n};\n\n/**\n * Hook to create descriptor objects for the child routes.\n *\n * A descriptor object provides 3 things:\n * - Helper method to render a screen\n * - Options specified by the screen for the navigator\n * - Navigation object intended for the route\n */\nexport default function useDescriptors<\n State extends NavigationState,\n ActionHelpers extends Record<string, () => void>,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n>({\n state,\n screens,\n navigation,\n screenOptions,\n defaultScreenOptions,\n onAction,\n getState,\n setState,\n addListener,\n addKeyedListener,\n onRouteFocus,\n router,\n emitter,\n}: Options<State, ScreenOptions, EventMap>) {\n const [options, setOptions] = React.useState<Record<string, object>>({});\n const { onDispatchAction, onOptionsChange, stackRef } = React.useContext(\n NavigationBuilderContext\n );\n\n const context = React.useMemo(\n () => ({\n navigation,\n onAction,\n addListener,\n addKeyedListener,\n onRouteFocus,\n onDispatchAction,\n onOptionsChange,\n stackRef,\n }),\n [\n navigation,\n onAction,\n addListener,\n addKeyedListener,\n onRouteFocus,\n onDispatchAction,\n onOptionsChange,\n stackRef,\n ]\n );\n\n const navigations = useNavigationCache<State, ScreenOptions, EventMap>({\n state,\n getState,\n navigation,\n setOptions,\n router,\n emitter,\n });\n\n const routes = useRouteCache(state.routes);\n\n return routes.reduce<\n Record<\n string,\n Descriptor<\n ScreenOptions,\n NavigationProp<ParamListBase, string, State, ScreenOptions, EventMap> &\n ActionHelpers,\n RouteProp<ParamListBase>\n >\n >\n >((acc, route, i) => {\n const config = screens[route.name];\n const screen = config[1];\n const navigation = navigations[route.key];\n\n const optionsList = [\n // The default `screenOptions` passed to the navigator\n screenOptions,\n // The `screenOptions` props passed to `Group` elements\n ...((config[0]\n ? config[0].filter(Boolean)\n : []) as ScreenOptionsOrCallback<ScreenOptions>[]),\n // The `options` prop passed to `Screen` elements,\n screen.options,\n // The options set via `navigation.setOptions`\n options[route.key],\n ];\n\n const customOptions = optionsList.reduce<ScreenOptions>(\n (acc, curr) =>\n Object.assign(\n acc,\n typeof curr !== 'function' ? curr : curr({ route, navigation })\n ),\n {} as ScreenOptions\n );\n\n const mergedOptions = {\n ...(typeof defaultScreenOptions === 'function'\n ? // @ts-expect-error: ts gives incorrect error here\n defaultScreenOptions({\n route,\n navigation,\n options: customOptions,\n })\n : defaultScreenOptions),\n ...customOptions,\n };\n\n const clearOptions = () =>\n setOptions((o) => {\n if (route.key in o) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [route.key]: _, ...rest } = o;\n return rest;\n }\n\n return o;\n });\n\n acc[route.key] = {\n route,\n // @ts-expect-error: it's missing action helpers, fix later\n navigation,\n render() {\n return (\n <NavigationBuilderContext.Provider key={route.key} value={context}>\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <SceneView\n navigation={navigation}\n route={route}\n screen={screen}\n routeState={state.routes[i].state}\n getState={getState}\n setState={setState}\n options={mergedOptions}\n clearOptions={clearOptions}\n />\n </NavigationRouteContext.Provider>\n </NavigationContext.Provider>\n </NavigationBuilderContext.Provider>\n );\n },\n options: mergedOptions as ScreenOptions,\n };\n\n return acc;\n }, {});\n}\n"]}
1
+ {"version":3,"sources":["useDescriptors.tsx"],"names":["React","NavigationBuilderContext","NavigationContext","NavigationRouteContext","SceneView","useNavigationCache","useRouteCache","useDescriptors","state","screens","navigation","screenOptions","defaultScreenOptions","onAction","getState","setState","addListener","addKeyedListener","onRouteFocus","router","emitter","options","setOptions","useState","onDispatchAction","onOptionsChange","stackRef","useContext","context","useMemo","navigations","routes","reduce","acc","route","i","config","name","screen","props","key","optionsList","filter","Boolean","customOptions","curr","Object","assign","mergedOptions","clearOptions","o","_","rest","render"],"mappings":"AA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AAYA,UAAMK,YAAY,GAAG,MACnB3B,UAAU,CAAE4B,CAAD,IAAO;AAChB,UAAIhB,KAAK,CAACM,GAAN,IAAaU,CAAjB,EAAoB;AAClB;AACA,cAAM;AAAE,WAAChB,KAAK,CAACM,GAAP,GAAaW,CAAf;AAAkB,aAAGC;AAArB,YAA8BF,CAApC;AACA,eAAOE,IAAP;AACD;;AAED,aAAOF,CAAP;AACD,KARS,CADZ;;AAWAjB,IAAAA,GAAG,CAACC,KAAK,CAACM,GAAP,CAAH,GAAiB;AACfN,MAAAA,KADe;AAEf;AACAxB,MAAAA,UAHe;;AAIf2C,MAAAA,MAAM,GAAG;AACP,4BACE,oBAAC,wBAAD,CAA0B,QAA1B;AAAmC,UAAA,GAAG,EAAEnB,KAAK,CAACM,GAA9C;AAAmD,UAAA,KAAK,EAAEZ;AAA1D,wBACE,oBAAC,iBAAD,CAAmB,QAAnB;AAA4B,UAAA,KAAK,EAAElB;AAAnC,wBACE,oBAAC,sBAAD,CAAwB,QAAxB;AAAiC,UAAA,KAAK,EAAEwB;AAAxC,wBACE,oBAAC,SAAD;AACE,UAAA,UAAU,EAAExB,UADd;AAEE,UAAA,KAAK,EAAEwB,KAFT;AAGE,UAAA,MAAM,EAAEI,MAHV;AAIE,UAAA,UAAU,EAAE9B,KAAK,CAACuB,MAAN,CAAaI,CAAb,EAAgB3B,KAJ9B;AAKE,UAAA,QAAQ,EAAEM,QALZ;AAME,UAAA,QAAQ,EAAEC,QANZ;AAOE,UAAA,OAAO,EAAEiC,aAPX;AAQE,UAAA,YAAY,EAAEC;AARhB,UADF,CADF,CADF,CADF;AAkBD,OAvBc;;AAwBf5B,MAAAA,OAAO,EAAE2B;AAxBM,KAAjB;AA2BA,WAAOf,GAAP;AACD,GAxFM,EAwFJ,EAxFI,CAAP;AAyFD","sourcesContent":["import type {\n NavigationAction,\n NavigationState,\n ParamListBase,\n Router,\n} from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationBuilderContext, {\n AddKeyedListener,\n AddListener,\n} from './NavigationBuilderContext';\nimport NavigationContext from './NavigationContext';\nimport NavigationRouteContext from './NavigationRouteContext';\nimport SceneView from './SceneView';\nimport type {\n Descriptor,\n EventMapBase,\n NavigationHelpers,\n NavigationProp,\n RouteConfig,\n RouteProp,\n} from './types';\nimport type { NavigationEventEmitter } from './useEventEmitter';\nimport useNavigationCache from './useNavigationCache';\nimport useRouteCache from './useRouteCache';\n\nexport type ScreenConfigWithParent<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n> = {\n keys: (string | undefined)[];\n options: (ScreenOptionsOrCallback<ScreenOptions> | undefined)[] | undefined;\n props: RouteConfig<ParamListBase, string, State, ScreenOptions, EventMap>;\n};\n\ntype ScreenOptionsOrCallback<ScreenOptions extends {}> =\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenOptions);\n\ntype Options<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n> = {\n state: State;\n screens: Record<\n string,\n ScreenConfigWithParent<State, ScreenOptions, EventMap>\n >;\n navigation: NavigationHelpers<ParamListBase>;\n screenOptions?: ScreenOptionsOrCallback<ScreenOptions>;\n defaultScreenOptions?:\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamListBase>;\n navigation: any;\n options: ScreenOptions;\n }) => ScreenOptions);\n onAction: (action: NavigationAction) => boolean;\n getState: () => State;\n setState: (state: State) => void;\n addListener: AddListener;\n addKeyedListener: AddKeyedListener;\n onRouteFocus: (key: string) => void;\n router: Router<State, NavigationAction>;\n emitter: NavigationEventEmitter<EventMap>;\n};\n\n/**\n * Hook to create descriptor objects for the child routes.\n *\n * A descriptor object provides 3 things:\n * - Helper method to render a screen\n * - Options specified by the screen for the navigator\n * - Navigation object intended for the route\n */\nexport default function useDescriptors<\n State extends NavigationState,\n ActionHelpers extends Record<string, () => void>,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n>({\n state,\n screens,\n navigation,\n screenOptions,\n defaultScreenOptions,\n onAction,\n getState,\n setState,\n addListener,\n addKeyedListener,\n onRouteFocus,\n router,\n emitter,\n}: Options<State, ScreenOptions, EventMap>) {\n const [options, setOptions] = React.useState<Record<string, object>>({});\n const { onDispatchAction, onOptionsChange, stackRef } = React.useContext(\n NavigationBuilderContext\n );\n\n const context = React.useMemo(\n () => ({\n navigation,\n onAction,\n addListener,\n addKeyedListener,\n onRouteFocus,\n onDispatchAction,\n onOptionsChange,\n stackRef,\n }),\n [\n navigation,\n onAction,\n addListener,\n addKeyedListener,\n onRouteFocus,\n onDispatchAction,\n onOptionsChange,\n stackRef,\n ]\n );\n\n const navigations = useNavigationCache<State, ScreenOptions, EventMap>({\n state,\n getState,\n navigation,\n setOptions,\n router,\n emitter,\n });\n\n const routes = useRouteCache(state.routes);\n\n return routes.reduce<\n Record<\n string,\n Descriptor<\n ScreenOptions,\n NavigationProp<ParamListBase, string, State, ScreenOptions, EventMap> &\n ActionHelpers,\n RouteProp<ParamListBase>\n >\n >\n >((acc, route, i) => {\n const config = screens[route.name];\n const screen = config.props;\n const navigation = navigations[route.key];\n\n const optionsList = [\n // The default `screenOptions` passed to the navigator\n screenOptions,\n // The `screenOptions` props passed to `Group` elements\n ...((config.options\n ? config.options.filter(Boolean)\n : []) as ScreenOptionsOrCallback<ScreenOptions>[]),\n // The `options` prop passed to `Screen` elements,\n screen.options,\n // The options set via `navigation.setOptions`\n options[route.key],\n ];\n\n const customOptions = optionsList.reduce<ScreenOptions>(\n (acc, curr) =>\n Object.assign(\n acc,\n typeof curr !== 'function' ? curr : curr({ route, navigation })\n ),\n {} as ScreenOptions\n );\n\n const mergedOptions = {\n ...(typeof defaultScreenOptions === 'function'\n ? // @ts-expect-error: ts gives incorrect error here\n defaultScreenOptions({\n route,\n navigation,\n options: customOptions,\n })\n : defaultScreenOptions),\n ...customOptions,\n };\n\n const clearOptions = () =>\n setOptions((o) => {\n if (route.key in o) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [route.key]: _, ...rest } = o;\n return rest;\n }\n\n return o;\n });\n\n acc[route.key] = {\n route,\n // @ts-expect-error: it's missing action helpers, fix later\n navigation,\n render() {\n return (\n <NavigationBuilderContext.Provider key={route.key} value={context}>\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <SceneView\n navigation={navigation}\n route={route}\n screen={screen}\n routeState={state.routes[i].state}\n getState={getState}\n setState={setState}\n options={mergedOptions}\n clearOptions={clearOptions}\n />\n </NavigationRouteContext.Provider>\n </NavigationContext.Provider>\n </NavigationBuilderContext.Provider>\n );\n },\n options: mergedOptions as ScreenOptions,\n };\n\n return acc;\n }, {});\n}\n"]}
@@ -33,14 +33,15 @@ export default function useEventEmitter(listen) {
33
33
  removeListener
34
34
  };
35
35
  }, []);
36
- const emit = React.useCallback(({
37
- type,
38
- data,
39
- target,
40
- canPreventDefault
41
- }) => {
36
+ const emit = React.useCallback(_ref => {
42
37
  var _items$target, _listenRef$current;
43
38
 
39
+ let {
40
+ type,
41
+ data,
42
+ target,
43
+ canPreventDefault
44
+ } = _ref;
44
45
  const items = listeners.current[type] || {}; // Copy the current list of callbacks in case they are mutated during execution
45
46
 
46
47
  const callbacks = target !== undefined ? (_items$target = items[target]) === null || _items$target === void 0 ? void 0 : _items$target.slice() : [].concat(...Object.keys(items).map(t => items[t])).filter((cb, i, self) => self.lastIndexOf(cb) === i);
@@ -1 +1 @@
1
- {"version":3,"sources":["useEventEmitter.tsx"],"names":["React","useEventEmitter","listen","listenRef","useRef","useEffect","current","listeners","create","useCallback","target","removeListener","type","callback","callbacks","undefined","index","indexOf","splice","addListener","push","emit","data","canPreventDefault","items","slice","concat","Object","keys","map","t","filter","cb","i","self","lastIndexOf","event","defineProperty","enumerable","get","defaultPrevented","defineProperties","preventDefault","value","forEach","useMemo"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;;AAWA;AACA;AACA;AACA,eAAe,SAASC,eAAT,CACbC,MADa,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,KAAxB,EAA+B;AAC7BI,QAAAA,gBAAgB,EAAE;AAChBF,UAAAA,UAAU,EAAE,IADI;;AAEhBC,UAAAA,GAAG,GAAG;AACJ,mBAAOC,gBAAP;AACD;;AAJe,SADW;AAO7BE,QAAAA,cAAc,EAAE;AACdJ,UAAAA,UAAU,EAAE,IADE;;AAEdK,UAAAA,KAAK,GAAG;AACNH,YAAAA,gBAAgB,GAAG,IAAnB;AACD;;AAJa;AAPa,OAA/B;AAcD;;AAED,0BAAArC,SAAS,CAACG,OAAV,+EAAAH,SAAS,EAAWiC,KAAX,CAAT;AAEAtB,IAAAA,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAE8B,OAAX,CAAoBZ,EAAD,IAAQA,EAAE,CAACI,KAAD,CAA7B;AAEA,WAAOA,KAAP;AACD,GAtEU,EAuEX,EAvEW,CAAb;AA0EA,SAAOpC,KAAK,CAAC6C,OAAN,CAAc,OAAO;AAAErC,IAAAA,MAAF;AAAUa,IAAAA;AAAV,GAAP,CAAd,EAAwC,CAACb,MAAD,EAASa,IAAT,CAAxC,CAAP;AACD","sourcesContent":["import * as React from 'react';\n\nimport type { EventArg, EventConsumer, EventEmitter } from './types';\n\nexport type NavigationEventEmitter<T extends Record<string, any>> =\n EventEmitter<T> & {\n create: (target: string) => EventConsumer<T>;\n };\n\ntype Listeners = ((e: any) => void)[];\n\n/**\n * Hook to manage the event system used by the navigator to notify screens of various events.\n */\nexport default function useEventEmitter<T extends Record<string, any>>(\n listen?: (e: any) => void\n): NavigationEventEmitter<T> {\n const listenRef = React.useRef(listen);\n\n React.useEffect(() => {\n listenRef.current = listen;\n });\n\n const listeners = React.useRef<Record<string, Record<string, Listeners>>>({});\n\n const create = React.useCallback((target: string) => {\n const removeListener = (type: string, callback: (data: any) => void) => {\n const callbacks = listeners.current[type]\n ? listeners.current[type][target]\n : undefined;\n\n if (!callbacks) {\n return;\n }\n\n const index = callbacks.indexOf(callback);\n\n callbacks.splice(index, 1);\n };\n\n const addListener = (type: string, callback: (data: any) => void) => {\n listeners.current[type] = listeners.current[type] || {};\n listeners.current[type][target] = listeners.current[type][target] || [];\n listeners.current[type][target].push(callback);\n\n return () => removeListener(type, callback);\n };\n\n return {\n addListener,\n removeListener,\n };\n }, []);\n\n const emit = React.useCallback(\n ({\n type,\n data,\n target,\n canPreventDefault,\n }: {\n type: string;\n data?: any;\n target?: string;\n canPreventDefault?: boolean;\n }) => {\n const items = listeners.current[type] || {};\n\n // Copy the current list of callbacks in case they are mutated during execution\n const callbacks =\n target !== undefined\n ? items[target]?.slice()\n : ([] as Listeners)\n .concat(...Object.keys(items).map((t) => items[t]))\n .filter((cb, i, self) => self.lastIndexOf(cb) === i);\n\n const event: EventArg<any, any, any> = {\n get type() {\n return type;\n },\n };\n\n if (target !== undefined) {\n Object.defineProperty(event, 'target', {\n enumerable: true,\n get() {\n return target;\n },\n });\n }\n\n if (data !== undefined) {\n Object.defineProperty(event, 'data', {\n enumerable: true,\n get() {\n return data;\n },\n });\n }\n\n if (canPreventDefault) {\n let defaultPrevented = false;\n\n Object.defineProperties(event, {\n defaultPrevented: {\n enumerable: true,\n get() {\n return defaultPrevented;\n },\n },\n preventDefault: {\n enumerable: true,\n value() {\n defaultPrevented = true;\n },\n },\n });\n }\n\n listenRef.current?.(event);\n\n callbacks?.forEach((cb) => cb(event));\n\n return event as any;\n },\n []\n );\n\n return React.useMemo(() => ({ create, emit }), [create, emit]);\n}\n"]}
1
+ {"version":3,"sources":["useEventEmitter.tsx"],"names":["React","useEventEmitter","listen","listenRef","useRef","useEffect","current","listeners","create","useCallback","target","removeListener","type","callback","callbacks","undefined","index","indexOf","splice","addListener","push","emit","data","canPreventDefault","items","slice","concat","Object","keys","map","t","filter","cb","i","self","lastIndexOf","event","defineProperty","enumerable","get","defaultPrevented","defineProperties","preventDefault","value","forEach","useMemo"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;;AAWA;AACA;AACA;AACA,eAAe,SAASC,e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,CAACc,gBAAP,CAAwBL,KAAxB,EAA+B;AAC7BI,QAAAA,gBAAgB,EAAE;AAChBF,UAAAA,UAAU,EAAE,IADI;;AAEhBC,UAAAA,GAAG,GAAG;AACJ,mBAAOC,gBAAP;AACD;;AAJe,SADW;AAO7BE,QAAAA,cAAc,EAAE;AACdJ,UAAAA,UAAU,EAAE,IADE;;AAEdK,UAAAA,KAAK,GAAG;AACNH,YAAAA,gBAAgB,GAAG,IAAnB;AACD;;AAJa;AAPa,OAA/B;AAcD;;AAED,0BAAArC,SAAS,CAACG,OAAV,+EAAAH,SAAS,EAAWiC,KAAX,CAAT;AAEAtB,IAAAA,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAE8B,OAAX,CAAoBZ,EAAD,IAAQA,EAAE,CAACI,KAAD,CAA7B;AAEA,WAAOA,KAAP;AACD,GAtEU,EAuEX,EAvEW,CAAb;AA0EA,SAAOpC,KAAK,CAAC6C,OAAN,CAAc,OAAO;AAAErC,IAAAA,MAAF;AAAUa,IAAAA;AAAV,GAAP,CAAd,EAAwC,CAACb,MAAD,EAASa,IAAT,CAAxC,CAAP;AACD","sourcesContent":["import * as React from 'react';\n\nimport type { EventArg, EventConsumer, EventEmitter } from './types';\n\nexport type NavigationEventEmitter<T extends Record<string, any>> =\n EventEmitter<T> & {\n create: (target: string) => EventConsumer<T>;\n };\n\ntype Listeners = ((e: any) => void)[];\n\n/**\n * Hook to manage the event system used by the navigator to notify screens of various events.\n */\nexport default function useEventEmitter<T extends Record<string, any>>(\n listen?: (e: any) => void\n): NavigationEventEmitter<T> {\n const listenRef = React.useRef(listen);\n\n React.useEffect(() => {\n listenRef.current = listen;\n });\n\n const listeners = React.useRef<Record<string, Record<string, Listeners>>>({});\n\n const create = React.useCallback((target: string) => {\n const removeListener = (type: string, callback: (data: any) => void) => {\n const callbacks = listeners.current[type]\n ? listeners.current[type][target]\n : undefined;\n\n if (!callbacks) {\n return;\n }\n\n const index = callbacks.indexOf(callback);\n\n callbacks.splice(index, 1);\n };\n\n const addListener = (type: string, callback: (data: any) => void) => {\n listeners.current[type] = listeners.current[type] || {};\n listeners.current[type][target] = listeners.current[type][target] || [];\n listeners.current[type][target].push(callback);\n\n return () => removeListener(type, callback);\n };\n\n return {\n addListener,\n removeListener,\n };\n }, []);\n\n const emit = React.useCallback(\n ({\n type,\n data,\n target,\n canPreventDefault,\n }: {\n type: string;\n data?: any;\n target?: string;\n canPreventDefault?: boolean;\n }) => {\n const items = listeners.current[type] || {};\n\n // Copy the current list of callbacks in case they are mutated during execution\n const callbacks =\n target !== undefined\n ? items[target]?.slice()\n : ([] as Listeners)\n .concat(...Object.keys(items).map((t) => items[t]))\n .filter((cb, i, self) => self.lastIndexOf(cb) === i);\n\n const event: EventArg<any, any, any> = {\n get type() {\n return type;\n },\n };\n\n if (target !== undefined) {\n Object.defineProperty(event, 'target', {\n enumerable: true,\n get() {\n return target;\n },\n });\n }\n\n if (data !== undefined) {\n Object.defineProperty(event, 'data', {\n enumerable: true,\n get() {\n return data;\n },\n });\n }\n\n if (canPreventDefault) {\n let defaultPrevented = false;\n\n Object.defineProperties(event, {\n defaultPrevented: {\n enumerable: true,\n get() {\n return defaultPrevented;\n },\n },\n preventDefault: {\n enumerable: true,\n value() {\n defaultPrevented = true;\n },\n },\n });\n }\n\n listenRef.current?.(event);\n\n callbacks?.forEach((cb) => cb(event));\n\n return event as any;\n },\n []\n );\n\n return React.useMemo(() => ({ create, emit }), [create, emit]);\n}\n"]}
@@ -4,10 +4,11 @@ import NavigationContext from './NavigationContext';
4
4
  /**
5
5
  * Hook to take care of emitting `focus` and `blur` events.
6
6
  */
7
- export default function useFocusEvents({
8
- state,
9
- emitter
10
- }) {
7
+ export default function useFocusEvents(_ref) {
8
+ let {
9
+ state,
10
+ emitter
11
+ } = _ref;
11
12
  const navigation = React.useContext(NavigationContext);
12
13
  const lastFocusedKeyRef = React.useRef();
13
14
  const currentFocusedKey = state.routes[state.index].key; // When the parent screen changes its focus state, we also need to change child's focus
@@ -1 +1 @@
1
- {"version":3,"sources":["useFocusEvents.tsx"],"names":["React","NavigationContext","useFocusEvents","state","emitter","navigation","useContext","lastFocusedKeyRef","useRef","currentFocusedKey","routes","index","key","useEffect","addListener","current","emit","type","target","undefined","lastFocusedKey","isFocused"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,iBAAP,MAA8B,qBAA9B;;AASA;AACA;AACA;AACA,eAAe,SAASC,cAAT,CAAuD;AACpEC,EAAAA,KADoE;AAEpEC,EAAAA;AAFoE,CAAvD,EAGI;AACjB,QAAMC,UAAU,GAAGL,KAAK,CAACM,UAAN,CAAiBL,iBAAjB,CAAnB;AACA,QAAMM,iBAAiB,GAAGP,KAAK,CAACQ,MAAN,EAA1B;AAEA,QAAMC,iBAAiB,GAAGN,KAAK,CAACO,MAAN,CAAaP,KAAK,CAACQ,KAAnB,EAA0BC,GAApD,CAJiB,CAMjB;AACA;;AACAZ,EAAAA,KAAK,CAACa,SAAN,CACE,MACER,UADF,aACEA,UADF,uBACEA,UAAU,CAAES,WAAZ,CAAwB,OAAxB,EAAiC,MAAM;AACrCP,IAAAA,iBAAiB,CAACQ,OAAlB,GAA4BN,iBAA5B;AACAL,IAAAA,OAAO,CAACY,IAAR,CAAa;AAAEC,MAAAA,IAAI,EAAE,OAAR;AAAiBC,MAAAA,MAAM,EAAET;AAAzB,KAAb;AACD,GAHD,CAFJ,EAME,CAACA,iBAAD,EAAoBL,OAApB,EAA6BC,UAA7B,CANF;AASAL,EAAAA,KAAK,CAACa,SAAN,CACE,MACER,UADF,aACEA,UADF,uBACEA,UAAU,CAAES,WAAZ,CAAwB,MAAxB,EAAgC,MAAM;AACpCP,IAAAA,iBAAiB,CAACQ,OAAlB,GAA4BI,SAA5B;AACAf,IAAAA,OAAO,CAACY,IAAR,CAAa;AAAEC,MAAAA,IAAI,EAAE,MAAR;AAAgBC,MAAAA,MAAM,EAAET;AAAxB,KAAb;AACD,GAHD,CAFJ,EAME,CAACA,iBAAD,EAAoBL,OAApB,EAA6BC,UAA7B,CANF;AASAL,EAAAA,KAAK,CAACa,SAAN,CAAgB,MAAM;AACpB,UAAMO,cAAc,GAAGb,iBAAiB,CAACQ,OAAzC;AAEAR,IAAAA,iBAAiB,CAACQ,OAAlB,GAA4BN,iBAA5B,CAHoB,CAKpB;AACA;;AACA,QAAIW,cAAc,KAAKD,SAAnB,IAAgC,CAACd,UAArC,EAAiD;AAC/CD,MAAAA,OAAO,CAACY,IAAR,CAAa;AAAEC,QAAAA,IAAI,EAAE,OAAR;AAAiBC,QAAAA,MAAM,EAAET;AAAzB,OAAb;AACD,KATmB,CAWpB;AACA;;;AACA,QACEW,cAAc,KAAKX,iBAAnB,IACA,EAAEJ,UAAU,GAAGA,UAAU,CAACgB,SAAX,EAAH,GAA4B,IAAxC,CAFF,EAGE;AACA;AACD;;AAED,QAAID,cAAc,KAAKD,SAAvB,EAAkC;AAChC;AACA;AACD;;AAEDf,IAAAA,OAAO,CAACY,IAAR,CAAa;AAAEC,MAAAA,IAAI,EAAE,MAAR;AAAgBC,MAAAA,MAAM,EAAEE;AAAxB,KAAb;AACAhB,IAAAA,OAAO,CAACY,IAAR,CAAa;AAAEC,MAAAA,IAAI,EAAE,OAAR;AAAiBC,MAAAA,MAAM,EAAET;AAAzB,KAAb;AACD,GA3BD,EA2BG,CAACA,iBAAD,EAAoBL,OAApB,EAA6BC,UAA7B,CA3BH;AA4BD","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"]}
1
+ {"version":3,"sources":["useFocusEvents.tsx"],"names":["React","NavigationContext","useFocusEvents","state","emitter","navigation","useContext","lastFocusedKeyRef","useRef","currentFocusedKey","routes","index","key","useEffect","addListener","current","emit","type","target","undefined","lastFocusedKey","isFocused"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,iBAAP,MAA8B,qBAA9B;;AASA;AACA;AACA;AACA,eAAe,SAASC,cAAT,OAGI;AAAA,MAHmD;AACpEC,IAAAA,KADoE;AAEpEC,IAAAA;AAFoE,GAGnD;AACjB,Q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,MAAM,EAAET;AAAzB,OAAb;AACD,KATmB,CAWpB;AACA;;;AACA,QACEW,cAAc,KAAKX,iBAAnB,IACA,EAAEJ,UAAU,GAAGA,UAAU,CAACgB,SAAX,EAAH,GAA4B,IAAxC,CAFF,EAGE;AACA;AACD;;AAED,QAAID,cAAc,KAAKD,SAAvB,EAAkC;AAChC;AACA;AACD;;AAEDf,IAAAA,OAAO,CAACY,IAAR,CAAa;AAAEC,MAAAA,IAAI,EAAE,MAAR;AAAgBC,MAAAA,MAAM,EAAEE;AAAxB,KAAb;AACAhB,IAAAA,OAAO,CAACY,IAAR,CAAa;AAAEC,MAAAA,IAAI,EAAE,OAAR;AAAiBC,MAAAA,MAAM,EAAET;AAAzB,KAAb;AACD,GA3BD,EA2BG,CAACA,iBAAD,EAAoBL,OAApB,EAA6BC,UAA7B,CA3BH;AA4BD","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"]}
@@ -4,10 +4,11 @@ import NavigationBuilderContext from './NavigationBuilderContext';
4
4
  /**
5
5
  * Hook for passing focus callback to children
6
6
  */
7
- export default function useFocusedListenersChildrenAdapter({
8
- navigation,
9
- focusedListeners
10
- }) {
7
+ export default function useFocusedListenersChildrenAdapter(_ref) {
8
+ let {
9
+ navigation,
10
+ focusedListeners
11
+ } = _ref;
11
12
  const {
12
13
  addListener
13
14
  } = React.useContext(NavigationBuilderContext);
@@ -1 +1 @@
1
- {"version":3,"sources":["useFocusedListenersChildrenAdapter.tsx"],"names":["React","NavigationBuilderContext","useFocusedListenersChildrenAdapter","navigation","focusedListeners","addListener","useContext","listener","useCallback","callback","isFocused","handled","result","useEffect"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,wBAAP,MAGO,4BAHP;;AAWA;AACA;AACA;AACA,eAAe,SAASC,kCAAT,CAA4C;AACzDC,EAAAA,UADyD;AAEzDC,EAAAA;AAFyD,CAA5C,EAGH;AACV,QAAM;AAAEC,IAAAA;AAAF,MAAkBL,KAAK,CAACM,UAAN,CAAiBL,wBAAjB,CAAxB;AAEA,QAAMM,QAAQ,GAAGP,KAAK,CAACQ,WAAN,CACdC,QAAD,IAA8C;AAC5C,QAAIN,UAAU,CAACO,SAAX,EAAJ,EAA4B;AAC1B,WAAK,MAAMH,QAAX,IAAuBH,gBAAvB,EAAyC;AACvC,cAAM;AAAEO,UAAAA,OAAF;AAAWC,UAAAA;AAAX,YAAsBL,QAAQ,CAACE,QAAD,CAApC;;AAEA,YAAIE,OAAJ,EAAa;AACX,iBAAO;AAAEA,YAAAA,OAAF;AAAWC,YAAAA;AAAX,WAAP;AACD;AACF;;AAED,aAAO;AAAED,QAAAA,OAAO,EAAE,IAAX;AAAiBC,QAAAA,MAAM,EAAEH,QAAQ,CAACN,UAAD;AAAjC,OAAP;AACD,KAVD,MAUO;AACL,aAAO;AAAEQ,QAAAA,OAAO,EAAE,KAAX;AAAkBC,QAAAA,MAAM,EAAE;AAA1B,OAAP;AACD;AACF,GAfc,EAgBf,CAACR,gBAAD,EAAmBD,UAAnB,CAhBe,CAAjB;AAmBAH,EAAAA,KAAK,CAACa,SAAN,CACE,MAAMR,WAAN,aAAMA,WAAN,uBAAMA,WAAW,CAAG,OAAH,EAAYE,QAAZ,CADnB,EAEE,CAACF,WAAD,EAAcE,QAAd,CAFF;AAID","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"]}
1
+ {"version":3,"sources":["useFocusedListenersChildrenAdapter.tsx"],"names":["React","NavigationBuilderContext","useFocusedListenersChildrenAdapter","navigation","focusedListeners","addListener","useContext","listener","useCallback","callback","isFocused","handled","result","useEffect"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,wBAAP,MAGO,4BAHP;;AAWA;AACA;AACA;AACA,eAAe,SAASC,kCAAT,OAGH;AAAA,MAH+C;AACzDC,IAAAA,UADyD;AAEzDC,IAAAA;AAFyD,GAG/C;AACV,QAAM;AAAEC,IAAAA;AAAF,MAAkBL,KAAK,CAACM,UAAN,CAAiBL,wBAAjB,CAAxB;AAEA,QAAMM,QAAQ,GAAGP,KAAK,CAACQ,WAAN,CACdC,QAAD,IAA8C;AAC5C,QAAIN,UAAU,CAACO,SAAX,EAAJ,EAA4B;AAC1B,WAAK,MAAMH,QAAX,IAAuBH,gBAAvB,EAAyC;AACvC,cAAM;AAAEO,UAAAA,OAAF;AAAWC,UAAAA;AAAX,YAAsBL,QAAQ,CAACE,QAAD,CAApC;;AAEA,YAAIE,OAAJ,EAAa;AACX,iBAAO;AAAEA,YAAAA,OAAF;AAAWC,YAAAA;AAAX,WAAP;AACD;AACF;;AAED,aAAO;AAAED,QAAAA,OAAO,EAAE,IAAX;AAAiBC,QAAAA,MAAM,EAAEH,QAAQ,CAACN,UAAD;AAAjC,OAAP;AACD,KAVD,MAUO;AACL,aAAO;AAAEQ,QAAAA,OAAO,EAAE,KAAX;AAAkBC,QAAAA,MAAM,EAAE;AAA1B,OAAP;AACD;AACF,GAfc,EAgBf,CAACR,gBAAD,EAAmBD,UAAnB,CAhBe,CAAjB;AAmBAH,EAAAA,KAAK,CAACa,SAAN,CACE,MAAMR,WAAN,aAAMA,WAAN,uBAAMA,WAAW,CAAG,OAAH,EAAYE,QAAZ,CADnB,EAEE,CAACF,WAAD,EAAcE,QAAd,CAFF;AAID","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"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["useKeyedChildListeners.tsx"],"names":["React","useKeyedChildListeners","current","keyedListeners","useRef","getState","beforeRemove","addKeyedListener","useCallback","type","key","listener","undefined"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;;AAIA;AACA;AACA;AACA,eAAe,SAASC,sBAAT,GAAkC;AAC/C,QAAM;AAAEC,IAAAA,OAAO,EAAEC;AAAX,MAA8BH,KAAK,CAACI,MAAN,CAOlC;AACAC,IAAAA,QAAQ,EAAE,EADV;AAEAC,IAAAA,YAAY,EAAE;AAFd,GAPkC,CAApC;AAYA,QAAMC,gBAAgB,GAAGP,KAAK,CAACQ,WAAN,CACvB,CACEC,IADF,EAEEC,GAFF,EAGEC,QAHF,KAIK;AACHR,IAAAA,cAAc,CAACM,IAAD,CAAd,CAAqBC,GAArB,IAA4BC,QAA5B;AAEA,WAAO,MAAM;AACXR,MAAAA,cAAc,CAACM,IAAD,CAAd,CAAqBC,GAArB,IAA4BE,SAA5B;AACD,KAFD;AAGD,GAXsB,EAYvB,CAACT,cAAD,CAZuB,CAAzB;AAeA,SAAO;AACLA,IAAAA,cADK;AAELI,IAAAA;AAFK,GAAP;AAID","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 {\n [K in keyof KeyedListenerMap]: Record<\n string,\n KeyedListenerMap[K] | undefined\n >;\n }\n >({\n getState: {},\n beforeRemove: {},\n });\n\n const addKeyedListener = React.useCallback(\n <T extends keyof KeyedListenerMap>(\n type: T,\n key: string,\n listener: KeyedListenerMap[T]\n ) => {\n keyedListeners[type][key] = listener;\n\n return () => {\n keyedListeners[type][key] = undefined;\n };\n },\n [keyedListeners]\n );\n\n return {\n keyedListeners,\n addKeyedListener,\n };\n}\n"]}
1
+ {"version":3,"sources":["useKeyedChildListeners.tsx"],"names":["React","useKeyedChildListeners","current","keyedListeners","useRef","getState","beforeRemove","addKeyedListener","useCallback","type","key","listener","undefined"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;;AAIA;AACA;AACA;AACA,eAAe,SAASC,sBAAT,GAAkC;AAC/C,QAAM;AAAEC,IAAAA,OAAO,EAAEC;AAAX,MAA8BH,KAAK,CAACI,MAAN,CAKjC;AACDC,IAAAA,QAAQ,EAAE,EADT;AAEDC,IAAAA,YAAY,EAAE;AAFb,GALiC,CAApC;AAUA,QAAMC,gBAAgB,GAAGP,KAAK,CAACQ,WAAN,CACvB,CACEC,IADF,EAEEC,GAFF,EAGEC,QAHF,KAIK;AACHR,IAAAA,cAAc,CAACM,IAAD,CAAd,CAAqBC,GAArB,IAA4BC,QAA5B;AAEA,WAAO,MAAM;AACXR,MAAAA,cAAc,CAACM,IAAD,CAAd,CAAqBC,GAArB,IAA4BE,SAA5B;AACD,KAFD;AAGD,GAXsB,EAYvB,CAACT,cAAD,CAZuB,CAAzB;AAeA,SAAO;AACLA,IAAAA,cADK;AAELI,IAAAA;AAFK,GAAP;AAID","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 getState: {},\n beforeRemove: {},\n });\n\n const addKeyedListener = React.useCallback(\n <T extends keyof KeyedListenerMap>(\n type: T,\n key: string,\n listener: KeyedListenerMap[T]\n ) => {\n keyedListeners[type][key] = listener;\n\n return () => {\n keyedListeners[type][key] = undefined;\n };\n },\n [keyedListeners]\n );\n\n return {\n keyedListeners,\n addKeyedListener,\n };\n}\n"]}
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  import { isValidElementType } from 'react-is';
4
4
  import Group from './Group';
5
5
  import isArrayEqual from './isArrayEqual';
6
+ import isRecordEqual from './isRecordEqual';
6
7
  import NavigationHelpersContext from './NavigationHelpersContext';
7
8
  import NavigationRouteContext from './NavigationRouteContext';
8
9
  import NavigationStateContext from './NavigationStateContext';
@@ -26,12 +27,15 @@ import useScheduleUpdate from './useScheduleUpdate'; // This is to make TypeScri
26
27
 
27
28
  PrivateValueStore;
28
29
 
30
+ const isValidKey = key => key === undefined || typeof key === 'string' && key !== '';
29
31
  /**
30
32
  * Extract route config object from React children elements.
31
33
  *
32
34
  * @param children React Elements to extract the config from.
33
35
  */
34
- const getRouteConfigsFromChildren = (children, options) => {
36
+
37
+
38
+ const getRouteConfigsFromChildren = (children, groupKey, groupOptions) => {
35
39
  const configs = React.Children.toArray(children).reduce((acc, child) => {
36
40
  var _child$type, _child$props;
37
41
 
@@ -39,14 +43,26 @@ const getRouteConfigsFromChildren = (children, options) => {
39
43
  if (child.type === Screen) {
40
44
  // We can only extract the config from `Screen` elements
41
45
  // If something else was rendered, it's probably a bug
42
- acc.push([options, child.props]);
46
+ if (!isValidKey(child.props.navigationKey)) {
47
+ throw new Error(`Got an invalid 'navigationKey' prop (${JSON.stringify(child.props.navigationKey)}) for the screen '${child.props.name}'. It must be a non-empty string or 'undefined'.`);
48
+ }
49
+
50
+ acc.push({
51
+ keys: [groupKey, child.props.navigationKey],
52
+ options: groupOptions,
53
+ props: child.props
54
+ });
43
55
  return acc;
44
56
  }
45
57
 
46
58
  if (child.type === React.Fragment || child.type === Group) {
47
- // When we encounter a fragment or group, we need to dive into its children to extract the configs
59
+ if (!isValidKey(child.props.navigationKey)) {
60
+ throw new Error(`Got an invalid 'navigationKey' prop (${JSON.stringify(child.props.navigationKey)}) for the group. It must be a non-empty string or 'undefined'.`);
61
+ } // When we encounter a fragment or group, we need to dive into its children to extract the configs
48
62
  // This is handy to conditionally define a group of screens
49
- acc.push(...getRouteConfigsFromChildren(child.props.children, child.type !== Group ? options : options != null ? [...options, child.props.screenOptions] : [child.props.screenOptions]));
63
+
64
+
65
+ acc.push(...getRouteConfigsFromChildren(child.props.children, child.props.navigationKey, child.type !== Group ? groupOptions : groupOptions != null ? [...groupOptions, child.props.screenOptions] : [child.props.screenOptions]));
50
66
  return acc;
51
67
  }
52
68
  }
@@ -61,7 +77,7 @@ const getRouteConfigsFromChildren = (children, options) => {
61
77
  children,
62
78
  component,
63
79
  getComponent
64
- } = config[1];
80
+ } = config.props;
65
81
 
66
82
  if (typeof name !== 'string' || !name) {
67
83
  throw new Error(`Got an invalid name (${JSON.stringify(name)}) for the screen. It must be a non-empty string.`);
@@ -92,11 +108,15 @@ const getRouteConfigsFromChildren = (children, options) => {
92
108
  throw new Error(`Got an invalid value for 'getComponent' prop for the screen '${name}'. It must be a function returning a React Component.`);
93
109
  }
94
110
 
95
- if (typeof component === 'function' && component.name === 'component') {
96
- // Inline anonymous functions passed in the `component` prop will have the name of the prop
97
- // It's relatively safe to assume that it's not a component since it should also have PascalCase name
98
- // We won't catch all scenarios here, but this should catch a good chunk of incorrect use.
99
- console.warn(`Looks like you're passing an inline function for 'component' prop for the screen '${name}' (e.g. component={() => <SomeComponent />}). Passing an inline function will cause the component state to be lost on re-render and cause perf issues since it's re-created every render. You can pass the function as children to 'Screen' instead to achieve the desired behaviour.`);
111
+ if (typeof component === 'function') {
112
+ if (component.name === 'component') {
113
+ // Inline anonymous functions passed in the `component` prop will have the name of the prop
114
+ // It's relatively safe to assume that it's not a component since it should also have PascalCase name
115
+ // We won't catch all scenarios here, but this should catch a good chunk of incorrect use.
116
+ console.warn(`Looks like you're passing an inline function for 'component' prop for the screen '${name}' (e.g. component={() => <SomeComponent />}). Passing an inline function will cause the component state to be lost on re-render and cause perf issues since it's re-created every render. You can pass the function as children to 'Screen' instead to achieve the desired behaviour.`);
117
+ } else if (/^[a-z]/.test(component.name)) {
118
+ console.warn(`Got a component with the name '${component.name}' for the screen '${name}'. React Components must start with an uppercase letter. If you're passing a regular function and not a component, pass it as children to 'Screen' instead. Otherwise capitalize your component's name.`);
119
+ }
100
120
  }
101
121
  } else {
102
122
  throw new Error(`Couldn't find a 'component', 'getComponent' or 'children' prop for the screen '${name}'. This can happen if you passed 'undefined'. You likely forgot to export your component from the file it's defined in, or mixed up default import and named import when importing.`);
@@ -132,23 +152,27 @@ export default function useNavigationBuilder(createRouter, options) {
132
152
  }));
133
153
  const routeConfigs = getRouteConfigsFromChildren(children);
134
154
  const screens = routeConfigs.reduce((acc, config) => {
135
- if (config[1].name in acc) {
136
- throw new Error(`A navigator cannot contain multiple 'Screen' components with the same name (found duplicate screen named '${config[1].name}')`);
155
+ if (config.props.name in acc) {
156
+ throw new Error(`A navigator cannot contain multiple 'Screen' components with the same name (found duplicate screen named '${config.props.name}')`);
137
157
  }
138
158
 
139
- acc[config[1].name] = config;
159
+ acc[config.props.name] = config;
160
+ return acc;
161
+ }, {});
162
+ const routeNames = routeConfigs.map(config => config.props.name);
163
+ const routeKeyList = routeNames.reduce((acc, curr) => {
164
+ acc[curr] = screens[curr].keys.map(key => key !== null && key !== void 0 ? key : '').join(':');
140
165
  return acc;
141
166
  }, {});
142
- const routeNames = routeConfigs.map(config => config[1].name);
143
167
  const routeParamList = routeNames.reduce((acc, curr) => {
144
168
  const {
145
169
  initialParams
146
- } = screens[curr][1];
170
+ } = screens[curr].props;
147
171
  acc[curr] = initialParams;
148
172
  return acc;
149
173
  }, {});
150
174
  const routeGetIdList = routeNames.reduce((acc, curr) => Object.assign(acc, {
151
- [curr]: screens[curr][1].getId
175
+ [curr]: screens[curr].props.getId
152
176
  }), {});
153
177
 
154
178
  if (!routeNames.length) {
@@ -188,7 +212,7 @@ export default function useNavigationBuilder(createRouter, options) {
188
212
 
189
213
  const {
190
214
  initialParams
191
- } = screens[curr][1];
215
+ } = screens[curr].props;
192
216
  const initialParamsFromParams = (route === null || route === void 0 ? void 0 : (_route$params = route.params) === null || _route$params === void 0 ? void 0 : _route$params.state) == null && (route === null || route === void 0 ? void 0 : (_route$params2 = route.params) === null || _route$params2 === void 0 ? void 0 : _route$params2.initial) !== false && (route === null || route === void 0 ? void 0 : (_route$params3 = route.params) === null || _route$params3 === void 0 ? void 0 : _route$params3.screen) === curr ? route.params.params : undefined;
193
217
  acc[curr] = initialParams !== undefined || initialParamsFromParams !== undefined ? { ...initialParams,
194
218
  ...initialParamsFromParams
@@ -221,18 +245,24 @@ export default function useNavigationBuilder(createRouter, options) {
221
245
  // eslint-disable-next-line react-hooks/exhaustive-deps
222
246
 
223
247
  }, [currentState, router, isStateValid]);
248
+ const previousRouteKeyListRef = React.useRef(routeKeyList);
249
+ React.useEffect(() => {
250
+ previousRouteKeyListRef.current = routeKeyList;
251
+ });
252
+ const previousRouteKeyList = previousRouteKeyListRef.current;
224
253
  let state = // If the state isn't initialized, or stale, use the state we initialized instead
225
254
  // The state won't update until there's a change needed in the state we have initalized locally
226
255
  // So it'll be `undefined` or stale until the first navigation event happens
227
256
  isStateInitialized(currentState) ? currentState : initializedState;
228
257
  let nextState = state;
229
258
 
230
- if (!isArrayEqual(state.routeNames, routeNames)) {
259
+ if (!isArrayEqual(state.routeNames, routeNames) || !isRecordEqual(routeKeyList, previousRouteKeyList)) {
231
260
  // When the list of route names change, the router should handle it to remove invalid routes
232
261
  nextState = router.getStateForRouteNamesChange(state, {
233
262
  routeNames,
234
263
  routeParamList,
235
- routeGetIdList
264
+ routeGetIdList,
265
+ routeKeyChanges: Object.keys(routeKeyList).filter(name => previousRouteKeyList.hasOwnProperty(name) && routeKeyList[name] !== previousRouteKeyList[name])
236
266
  });
237
267
  }
238
268
 
@@ -342,7 +372,7 @@ export default function useNavigationBuilder(createRouter, options) {
342
372
  ...[screenListeners, ...routeNames.map(name => {
343
373
  const {
344
374
  listeners
345
- } = screens[name][1];
375
+ } = screens[name].props;
346
376
  return listeners;
347
377
  })].map(listeners => {
348
378
  const map = typeof listeners === 'function' ? listeners({
@@ -1 +1 @@
1
- {"version":3,"sources":["useNavigationBuilder.tsx"],"names":["CommonActions","React","isValidElementType","Group","isArrayEqual","NavigationHelpersContext","NavigationRouteContext","NavigationStateContext","Screen","PrivateValueStore","useChildListeners","useComponent","useCurrentRender","useDescriptors","useEventEmitter","useFocusedListenersChildrenAdapter","useFocusEvents","useKeyedChildListeners","useNavigationHelpers","useOnAction","useOnGetState","useOnRouteFocus","useRegisterNavigator","useScheduleUpdate","getRouteConfigsFromChildren","children","options","configs","Children","toArray","reduce","acc","child","isValidElement","type","push","props","Fragment","screenOptions","Error","name","JSON","stringify","String","process","env","NODE_ENV","forEach","config","component","getComponent","undefined","console","warn","useNavigationBuilder","createRouter","navigatorKey","route","useContext","screenListeners","rest","current","router","useRef","params","state","initial","screen","initialRouteName","routeConfigs","screens","routeNames","map","routeParamList","curr","initialParams","routeGetIdList","Object","assign","getId","length","isStateValid","useCallback","isStateInitialized","stale","currentState","getState","getCurrentState","setState","setCurrentState","setKey","getKey","getIsInitial","stateCleanedUp","cleanUpState","initializedState","isFirstStateInitialization","useMemo","initialRouteParamList","initialParamsFromParams","getInitialState","getRehydratedState","nextState","getStateForRouteNamesChange","previousNestedParamsRef","useEffect","previousParams","action","reset","navigate","path","updatedState","getStateForAction","shouldUpdate","setTimeout","initializedStateRef","emitter","e","target","routes","find","key","index","keys","filter","navigation","descriptors","listeners","concat","cb","i","self","lastIndexOf","listener","emit","data","childListeners","addListener","keyedListeners","addKeyedListener","onAction","actionListeners","beforeRemoveListeners","beforeRemove","routerConfigOptions","onRouteFocus","focusedListeners","focus","getStateListeners","defaultScreenOptions","NavigationContent","Provider","value"],"mappings":"AAAA,SACEA,aADF,QAWO,2BAXP;AAYA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,kBAAT,QAAmC,UAAnC;AAEA,OAAOC,KAAP,MAAkB,SAAlB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,wBAAP,MAAqC,4BAArC;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAKEC,iBALF,QAOO,SAPP;AAQA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,cAAP,MAAuD,kBAAvD;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,kCAAP,MAA+C,sCAA/C;AACA,OAAOC,cAAP,MAA2B,kBAA3B;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,iBAAP,MAA8B,qBAA9B,C,CAEA;AACA;;AACAd,iBAAiB;;AAO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EAAE3B;AADiE,GAApC,CAAtC;AAIA,SAAO;AACL5D,IAAAA,KADK;AAEL4D,IAAAA,UAFK;AAGLC,IAAAA,WAHK;AAILwB,IAAAA;AAJK,GAAP;AAMD","sourcesContent":["import {\n CommonActions,\n DefaultRouterOptions,\n NavigationAction,\n NavigationState,\n ParamListBase,\n PartialState,\n Route,\n Router,\n RouterConfigOptions,\n RouterFactory,\n} from '@react-navigation/routers';\nimport * as React from 'react';\nimport { isValidElementType } from 'react-is';\n\nimport Group from './Group';\nimport isArrayEqual from './isArrayEqual';\nimport NavigationHelpersContext from './NavigationHelpersContext';\nimport NavigationRouteContext from './NavigationRouteContext';\nimport NavigationStateContext from './NavigationStateContext';\nimport Screen from './Screen';\nimport {\n DefaultNavigatorOptions,\n EventMapBase,\n EventMapCore,\n NavigatorScreenParams,\n PrivateValueStore,\n RouteConfig,\n} from './types';\nimport useChildListeners from './useChildListeners';\nimport useComponent from './useComponent';\nimport useCurrentRender from './useCurrentRender';\nimport useDescriptors, { ScreenConfigWithParent } from './useDescriptors';\nimport useEventEmitter from './useEventEmitter';\nimport useFocusedListenersChildrenAdapter from './useFocusedListenersChildrenAdapter';\nimport useFocusEvents from './useFocusEvents';\nimport useKeyedChildListeners from './useKeyedChildListeners';\nimport useNavigationHelpers from './useNavigationHelpers';\nimport useOnAction from './useOnAction';\nimport useOnGetState from './useOnGetState';\nimport useOnRouteFocus from './useOnRouteFocus';\nimport useRegisterNavigator from './useRegisterNavigator';\nimport useScheduleUpdate from './useScheduleUpdate';\n\n// This is to make TypeScript compiler happy\n// eslint-disable-next-line babel/no-unused-expressions\nPrivateValueStore;\n\ntype NavigatorRoute<State extends NavigationState> = {\n key: string;\n params?: NavigatorScreenParams<ParamListBase, State>;\n};\n\n/**\n * Extract route config object from React children elements.\n *\n * @param children React Elements to extract the config from.\n */\nconst getRouteConfigsFromChildren = <\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n>(\n children: React.ReactNode,\n options?: ScreenConfigWithParent<State, ScreenOptions, EventMap>[0]\n) => {\n const configs = React.Children.toArray(children).reduce<\n ScreenConfigWithParent<State, ScreenOptions, EventMap>[]\n >((acc, child) => {\n if (React.isValidElement(child)) {\n if (child.type === Screen) {\n // We can only extract the config from `Screen` elements\n // If something else was rendered, it's probably a bug\n acc.push([\n options,\n child.props as RouteConfig<\n ParamListBase,\n string,\n State,\n ScreenOptions,\n EventMap\n >,\n ]);\n return acc;\n }\n\n if (child.type === React.Fragment || child.type === Group) {\n // When we encounter a fragment or group, we need to dive into its children to extract the configs\n // This is handy to conditionally define a group of screens\n acc.push(\n ...getRouteConfigsFromChildren<State, ScreenOptions, EventMap>(\n child.props.children,\n child.type !== Group\n ? options\n : options != null\n ? [...options, child.props.screenOptions]\n : [child.props.screenOptions]\n )\n );\n return acc;\n }\n }\n\n throw new Error(\n `A navigator can only contain 'Screen', 'Group' or 'React.Fragment' as its direct children (found ${\n React.isValidElement(child)\n ? `'${\n typeof child.type === 'string' ? child.type : child.type?.name\n }'${\n child.props?.name ? ` for the screen '${child.props.name}'` : ''\n }`\n : typeof child === 'object'\n ? JSON.stringify(child)\n : `'${String(child)}'`\n }). To render this component in the navigator, pass it in the 'component' prop to 'Screen'.`\n );\n }, []);\n\n if (process.env.NODE_ENV !== 'production') {\n configs.forEach((config) => {\n const { name, children, component, getComponent } = config[1];\n\n if (typeof name !== 'string' || !name) {\n throw new Error(\n `Got an invalid name (${JSON.stringify(\n name\n )}) for the screen. It must be a non-empty string.`\n );\n }\n\n if (\n children != null ||\n component !== undefined ||\n getComponent !== undefined\n ) {\n if (children != null && component !== undefined) {\n throw new Error(\n `Got both 'component' and 'children' props for the screen '${name}'. You must pass only one of them.`\n );\n }\n\n if (children != null && getComponent !== undefined) {\n throw new Error(\n `Got both 'getComponent' and 'children' props for the screen '${name}'. You must pass only one of them.`\n );\n }\n\n if (component !== undefined && getComponent !== undefined) {\n throw new Error(\n `Got both 'component' and 'getComponent' props for the screen '${name}'. You must pass only one of them.`\n );\n }\n\n if (children != null && typeof children !== 'function') {\n throw new Error(\n `Got an invalid value for 'children' prop for the screen '${name}'. It must be a function returning a React Element.`\n );\n }\n\n if (component !== undefined && !isValidElementType(component)) {\n throw new Error(\n `Got an invalid value for 'component' prop for the screen '${name}'. It must be a valid React Component.`\n );\n }\n\n if (getComponent !== undefined && typeof getComponent !== 'function') {\n throw new Error(\n `Got an invalid value for 'getComponent' prop for the screen '${name}'. It must be a function returning a React Component.`\n );\n }\n\n if (typeof component === 'function' && component.name === 'component') {\n // Inline anonymous functions passed in the `component` prop will have the name of the prop\n // It's relatively safe to assume that it's not a component since it should also have PascalCase name\n // We won't catch all scenarios here, but this should catch a good chunk of incorrect use.\n console.warn(\n `Looks like you're passing an inline function for 'component' prop for the screen '${name}' (e.g. component={() => <SomeComponent />}). Passing an inline function will cause the component state to be lost on re-render and cause perf issues since it's re-created every render. You can pass the function as children to 'Screen' instead to achieve the desired behaviour.`\n );\n }\n } else {\n throw new Error(\n `Couldn't find a 'component', 'getComponent' or 'children' prop for the screen '${name}'. This can happen if you passed 'undefined'. You likely forgot to export your component from the file it's defined in, or mixed up default import and named import when importing.`\n );\n }\n });\n }\n\n return configs;\n};\n\n/**\n * Hook for building navigators.\n *\n * @param createRouter Factory method which returns router object.\n * @param options Options object containing `children` and additional options for the router.\n * @returns An object containing `state`, `navigation`, `descriptors` objects.\n */\nexport default function useNavigationBuilder<\n State extends NavigationState,\n RouterOptions extends DefaultRouterOptions,\n ActionHelpers extends Record<string, () => void>,\n ScreenOptions extends {},\n EventMap extends Record<string, any>\n>(\n createRouter: RouterFactory<State, any, RouterOptions>,\n options: DefaultNavigatorOptions<\n ParamListBase,\n State,\n ScreenOptions,\n EventMap\n > &\n RouterOptions\n) {\n const navigatorKey = useRegisterNavigator();\n\n const route = React.useContext(NavigationRouteContext) as\n | NavigatorRoute<State>\n | undefined;\n\n const { children, screenListeners, ...rest } = options;\n const { current: router } = React.useRef<Router<State, any>>(\n createRouter({\n ...(rest as unknown as RouterOptions),\n ...(route?.params &&\n route.params.state == null &&\n route.params.initial !== false &&\n typeof route.params.screen === 'string'\n ? { initialRouteName: route.params.screen }\n : null),\n })\n );\n\n const routeConfigs =\n getRouteConfigsFromChildren<State, ScreenOptions, EventMap>(children);\n\n const screens = routeConfigs.reduce<\n Record<string, ScreenConfigWithParent<State, ScreenOptions, EventMap>>\n >((acc, config) => {\n if (config[1].name in acc) {\n throw new Error(\n `A navigator cannot contain multiple 'Screen' components with the same name (found duplicate screen named '${config[1].name}')`\n );\n }\n\n acc[config[1].name] = config;\n return acc;\n }, {});\n\n const routeNames = routeConfigs.map((config) => config[1].name);\n const routeParamList = routeNames.reduce<Record<string, object | undefined>>(\n (acc, curr) => {\n const { initialParams } = screens[curr][1];\n acc[curr] = initialParams;\n return acc;\n },\n {}\n );\n const routeGetIdList = routeNames.reduce<\n RouterConfigOptions['routeGetIdList']\n >(\n (acc, curr) =>\n Object.assign(acc, {\n [curr]: screens[curr][1].getId,\n }),\n {}\n );\n\n if (!routeNames.length) {\n throw new Error(\n \"Couldn't find any screens for the navigator. Have you defined any screens as its children?\"\n );\n }\n\n const isStateValid = React.useCallback(\n (state) => state.type === undefined || state.type === router.type,\n [router.type]\n );\n\n const isStateInitialized = React.useCallback(\n (state) =>\n state !== undefined && state.stale === false && isStateValid(state),\n [isStateValid]\n );\n\n const {\n state: currentState,\n getState: getCurrentState,\n setState: setCurrentState,\n setKey,\n getKey,\n getIsInitial,\n } = React.useContext(NavigationStateContext);\n\n const stateCleanedUp = React.useRef(false);\n\n const cleanUpState = React.useCallback(() => {\n setCurrentState(undefined);\n stateCleanedUp.current = true;\n }, [setCurrentState]);\n\n const setState = React.useCallback(\n (state: NavigationState | PartialState<NavigationState> | undefined) => {\n if (stateCleanedUp.current) {\n // State might have been already cleaned up due to unmount\n // We do not want to expose API allowing to override this\n // This would lead to old data preservation on main navigator unmount\n return;\n }\n setCurrentState(state);\n },\n [setCurrentState]\n );\n\n const [initializedState, isFirstStateInitialization] = React.useMemo(() => {\n const initialRouteParamList = routeNames.reduce<\n Record<string, object | undefined>\n >((acc, curr) => {\n const { initialParams } = screens[curr][1];\n const initialParamsFromParams =\n route?.params?.state == null &&\n route?.params?.initial !== false &&\n route?.params?.screen === curr\n ? route.params.params\n : undefined;\n\n acc[curr] =\n initialParams !== undefined || initialParamsFromParams !== undefined\n ? {\n ...initialParams,\n ...initialParamsFromParams,\n }\n : undefined;\n\n return acc;\n }, {});\n\n // If the current state isn't initialized on first render, we initialize it\n // We also need to re-initialize it if the state passed from parent was changed (maybe due to reset)\n // Otherwise assume that the state was provided as initial state\n // So we need to rehydrate it to make it usable\n if (\n (currentState === undefined || !isStateValid(currentState)) &&\n route?.params?.state == null\n ) {\n return [\n router.getInitialState({\n routeNames,\n routeParamList: initialRouteParamList,\n routeGetIdList,\n }),\n true,\n ];\n } else {\n return [\n router.getRehydratedState(\n route?.params?.state ?? (currentState as PartialState<State>),\n {\n routeNames,\n routeParamList: initialRouteParamList,\n routeGetIdList,\n }\n ),\n false,\n ];\n }\n // We explicitly don't include routeNames, route.params etc. in the dep list\n // below. We want to avoid forcing a new state to be calculated in those cases\n // Instead, we handle changes to these in the nextState code below. Note\n // that some changes to routeConfigs are explicitly ignored, such as changes\n // to initialParams\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentState, router, isStateValid]);\n\n let state =\n // If the state isn't initialized, or stale, use the state we initialized instead\n // The state won't update until there's a change needed in the state we have initalized locally\n // So it'll be `undefined` or stale until the first navigation event happens\n isStateInitialized(currentState)\n ? (currentState as State)\n : (initializedState as State);\n\n let nextState: State = state;\n\n if (!isArrayEqual(state.routeNames, routeNames)) {\n // When the list of route names change, the router should handle it to remove invalid routes\n nextState = router.getStateForRouteNamesChange(state, {\n routeNames,\n routeParamList,\n routeGetIdList,\n });\n }\n\n const previousNestedParamsRef = React.useRef(route?.params);\n\n React.useEffect(() => {\n previousNestedParamsRef.current = route?.params;\n }, [route?.params]);\n\n if (route?.params) {\n const previousParams = previousNestedParamsRef.current;\n\n let action: CommonActions.Action | undefined;\n\n if (\n typeof route.params.state === 'object' &&\n route.params.state != null &&\n route.params !== previousParams\n ) {\n // If the route was updated with new state, we should reset to it\n action = CommonActions.reset(route.params.state);\n } else if (\n typeof route.params.screen === 'string' &&\n ((route.params.initial === false && isFirstStateInitialization) ||\n route.params !== previousParams)\n ) {\n // If the route was updated with new screen name and/or params, we should navigate there\n action = CommonActions.navigate({\n name: route.params.screen,\n params: route.params.params,\n path: route.params.path,\n });\n }\n\n // The update should be limited to current navigator only, so we call the router manually\n const updatedState = action\n ? router.getStateForAction(nextState, action, {\n routeNames,\n routeParamList,\n routeGetIdList,\n })\n : null;\n\n nextState =\n updatedState !== null\n ? router.getRehydratedState(updatedState, {\n routeNames,\n routeParamList,\n routeGetIdList,\n })\n : nextState;\n }\n\n const shouldUpdate = state !== nextState;\n\n useScheduleUpdate(() => {\n if (shouldUpdate) {\n // If the state needs to be updated, we'll schedule an update\n setState(nextState);\n }\n });\n\n // The up-to-date state will come in next render, but we don't need to wait for it\n // We can't use the outdated state since the screens have changed, which will cause error due to mismatched config\n // So we override the state object we return to use the latest state as soon as possible\n state = nextState;\n\n React.useEffect(() => {\n setKey(navigatorKey);\n\n if (!getIsInitial()) {\n // If it's not initial render, we need to update the state\n // This will make sure that our container gets notifier of state changes due to new mounts\n // This is necessary for proper screen tracking, URL updates etc.\n setState(nextState);\n }\n\n return () => {\n // We need to clean up state for this navigator on unmount\n // We do it in a timeout because we need to detect if another navigator mounted in the meantime\n // For example, if another navigator has started rendering, we should skip cleanup\n // Otherwise, our cleanup step will cleanup state for the other navigator and re-initialize it\n setTimeout(() => {\n if (getCurrentState() !== undefined && getKey() === navigatorKey) {\n cleanUpState();\n }\n }, 0);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // We initialize this ref here to avoid a new getState getting initialized\n // whenever initializedState changes. We want getState to have access to the\n // latest initializedState, but don't need it to change when that happens\n const initializedStateRef = React.useRef<State>();\n initializedStateRef.current = initializedState;\n\n const getState = React.useCallback((): State => {\n const currentState = getCurrentState();\n\n return isStateInitialized(currentState)\n ? (currentState as State)\n : (initializedStateRef.current as State);\n }, [getCurrentState, isStateInitialized]);\n\n const emitter = useEventEmitter<EventMapCore<State>>((e) => {\n let routeNames = [];\n\n let route: Route<string> | undefined;\n\n if (e.target) {\n route = state.routes.find((route) => route.key === e.target);\n\n if (route?.name) {\n routeNames.push(route.name);\n }\n } else {\n route = state.routes[state.index];\n routeNames.push(\n ...Object.keys(screens).filter((name) => route?.name === name)\n );\n }\n\n if (route == null) {\n return;\n }\n\n const navigation = descriptors[route.key].navigation;\n\n const listeners = ([] as (((e: any) => void) | undefined)[])\n .concat(\n // Get an array of listeners for all screens + common listeners on navigator\n ...[\n screenListeners,\n ...routeNames.map((name) => {\n const { listeners } = screens[name][1];\n return listeners;\n }),\n ].map((listeners) => {\n const map =\n typeof listeners === 'function'\n ? listeners({ route: route as any, navigation })\n : listeners;\n\n return map\n ? Object.keys(map)\n .filter((type) => type === e.type)\n .map((type) => map?.[type])\n : undefined;\n })\n )\n // We don't want same listener to be called multiple times for same event\n // So we remove any duplicate functions from the array\n .filter((cb, i, self) => cb && self.lastIndexOf(cb) === i);\n\n listeners.forEach((listener) => listener?.(e));\n });\n\n useFocusEvents({ state, emitter });\n\n React.useEffect(() => {\n emitter.emit({ type: 'state', data: { state } });\n }, [emitter, state]);\n\n const { listeners: childListeners, addListener } = useChildListeners();\n\n const { keyedListeners, addKeyedListener } = useKeyedChildListeners();\n\n const onAction = useOnAction({\n router,\n getState,\n setState,\n key: route?.key,\n actionListeners: childListeners.action,\n beforeRemoveListeners: keyedListeners.beforeRemove,\n routerConfigOptions: {\n routeNames,\n routeParamList,\n routeGetIdList,\n },\n emitter,\n });\n\n const onRouteFocus = useOnRouteFocus({\n router,\n key: route?.key,\n getState,\n setState,\n });\n\n const navigation = useNavigationHelpers<\n State,\n ActionHelpers,\n NavigationAction,\n EventMap\n >({\n onAction,\n getState,\n emitter,\n router,\n });\n\n useFocusedListenersChildrenAdapter({\n navigation,\n focusedListeners: childListeners.focus,\n });\n\n useOnGetState({\n getState,\n getStateListeners: keyedListeners.getState,\n });\n\n const descriptors = useDescriptors<\n State,\n ActionHelpers,\n ScreenOptions,\n EventMap\n >({\n state,\n screens,\n navigation,\n screenOptions: options.screenOptions,\n defaultScreenOptions: options.defaultScreenOptions,\n onAction,\n getState,\n setState,\n onRouteFocus,\n addListener,\n addKeyedListener,\n router,\n // @ts-expect-error: this should have both core and custom events, but too much work right now\n emitter,\n });\n\n useCurrentRender({\n state,\n navigation,\n descriptors,\n });\n\n const NavigationContent = useComponent(NavigationHelpersContext.Provider, {\n value: navigation,\n });\n\n return {\n state,\n navigation,\n descriptors,\n NavigationContent,\n };\n}\n"]}
1
+ {"version":3,"sources":["useNavigationBuilder.tsx"],"names":["CommonActions","React","isValidElementType","Group","isArrayEqual","isRecordEqual","NavigationHelpersContext","NavigationRouteContext","NavigationStateContext","Screen","PrivateValueStore","useChildListeners","useComponent","useCurrentRender","useDescriptors","useEventEmitter","useFocusedListenersChildrenAdapter","useFocusEvents","useKeyedChildListeners","useNavigationHelpers","useOnAction","useOnGetState","useOnRouteFocus","useRegisterNavigator","useScheduleUpdate","isValidKey","key","undefined","getRouteConfigsFromChildren","children","groupKey","groupOptions","configs","Children","toArray","reduce","acc","child","isValidElement","type","props","navigationKey","Error","JSON","stringify","name","push","keys","options","Fragment","screenOptions","String","process","env","NODE_ENV","forEach","config","component","getComponent","console","warn","test","useNavigationBuilder","createRouter","navigatorKey","route","useContext","screenListeners","rest","current","router","useRef","params","state","initial","screen","initialRouteName","routeConfigs","screens","routeNames","map","routeKeyList","curr","join","routeParamList","initialParams","routeGetIdList","Object","assign","getId","length","isStateValid","useCallback","isStateInitialized","stale","currentState","getState","getCurrentState","setState","setCurrentState","setKey","getKey","getIsInitial","stateCleanedUp","cleanUpState","initializedState","isFirstStateInitialization","useMemo","initialRouteParamList","initialParamsFromParams","getInitialState","getRehydratedState","previousRouteKeyListRef","useEffect","previousRouteKeyList","nextState","getStateForRouteNamesChange","routeKeyChanges","filter","hasOwnProperty","previousNestedParamsRef","previousParams","action","reset","navigate","path","updatedState","getStateForAction","shouldUpdate","setTimeout","initializedStateRef","emitter","e","target","routes","find","index","navigation","descriptors","listeners","concat","cb","i","self","lastIndexOf","listener","emit","data","childListeners","addListener","keyedListeners","addKeyedListener","onAction","actionListeners","beforeRemoveListeners","beforeRemove","routerConfigOptions","onRouteFocus","focusedListeners","focus","getStateListeners","defaultScreenOptions","NavigationContent","Provider","value"],"mappings":"AAAA,SACEA,aADF,QAWO,2BAXP;AAYA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,kBAAT,QAAmC,UAAnC;AAEA,OAAOC,KAAP,MAAkB,SAAlB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,wBAAP,MAAqC,4BAArC;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAKEC,iBALF,QAOO,SAPP;AAQA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,cAAP,MAAuD,kBAAvD;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,kCAAP,MAA+C,sCAA/C;AACA,OAAOC,cAAP,MAA2B,kBAA3B;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,iBAAP,MAA8B,qBAA9B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D;AAFtB,GAAD,CAAb;AAKA,QAAM0C,WAAW,GAAG5H,cAAc,CAKhC;AACA2D,IAAAA,KADA;AAEAK,IAAAA,OAFA;AAGA2D,IAAAA,UAHA;AAIAvF,IAAAA,aAAa,EAAEF,OAAO,CAACE,aAJvB;AAKA+G,IAAAA,oBAAoB,EAAEjH,OAAO,CAACiH,oBAL9B;AAMAT,IAAAA,QANA;AAOAxD,IAAAA,QAPA;AAQAE,IAAAA,QARA;AASA2D,IAAAA,YATA;AAUAR,IAAAA,WAVA;AAWAE,IAAAA,gBAXA;AAYAjF,IAAAA,MAZA;AAaA;AACA6D,IAAAA;AAdA,GALgC,CAAlC;AAsBAtH,EAAAA,gBAAgB,CAAC;AACf4D,IAAAA,KADe;AAEfgE,IAAAA,UAFe;AAGfC,IAAAA;AAHe,GAAD,CAAhB;AAMA,QAAMwB,iBAAiB,GAAGtJ,YAAY,CAACN,wBAAwB,CAAC6J,QAA1B,EAAoC;AACxEC,IAAAA,KAAK,EAAE3B;AADiE,GAApC,CAAtC;AAIA,SAAO;AACLhE,IAAAA,KADK;AAELgE,IAAAA,UAFK;AAGLC,IAAAA,WAHK;AAILwB,IAAAA;AAJK,GAAP;AAMD","sourcesContent":["import {\n CommonActions,\n DefaultRouterOptions,\n NavigationAction,\n NavigationState,\n ParamListBase,\n PartialState,\n Route,\n Router,\n RouterConfigOptions,\n RouterFactory,\n} from '@react-navigation/routers';\nimport * as React from 'react';\nimport { isValidElementType } from 'react-is';\n\nimport Group from './Group';\nimport isArrayEqual from './isArrayEqual';\nimport isRecordEqual from './isRecordEqual';\nimport NavigationHelpersContext from './NavigationHelpersContext';\nimport NavigationRouteContext from './NavigationRouteContext';\nimport NavigationStateContext from './NavigationStateContext';\nimport Screen from './Screen';\nimport {\n DefaultNavigatorOptions,\n EventMapBase,\n EventMapCore,\n NavigatorScreenParams,\n PrivateValueStore,\n RouteConfig,\n} from './types';\nimport useChildListeners from './useChildListeners';\nimport useComponent from './useComponent';\nimport useCurrentRender from './useCurrentRender';\nimport useDescriptors, { ScreenConfigWithParent } from './useDescriptors';\nimport useEventEmitter from './useEventEmitter';\nimport useFocusedListenersChildrenAdapter from './useFocusedListenersChildrenAdapter';\nimport useFocusEvents from './useFocusEvents';\nimport useKeyedChildListeners from './useKeyedChildListeners';\nimport useNavigationHelpers from './useNavigationHelpers';\nimport useOnAction from './useOnAction';\nimport useOnGetState from './useOnGetState';\nimport useOnRouteFocus from './useOnRouteFocus';\nimport useRegisterNavigator from './useRegisterNavigator';\nimport useScheduleUpdate from './useScheduleUpdate';\n\n// This is to make TypeScript compiler happy\n// eslint-disable-next-line babel/no-unused-expressions\nPrivateValueStore;\n\ntype NavigatorRoute<State extends NavigationState> = {\n key: string;\n params?: NavigatorScreenParams<ParamListBase, State>;\n};\n\nconst isValidKey = (key: unknown) =>\n key === undefined || (typeof key === 'string' && key !== '');\n\n/**\n * Extract route config object from React children elements.\n *\n * @param children React Elements to extract the config from.\n */\nconst getRouteConfigsFromChildren = <\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n>(\n children: React.ReactNode,\n groupKey?: string,\n groupOptions?: ScreenConfigWithParent<\n State,\n ScreenOptions,\n EventMap\n >['options']\n) => {\n const configs = React.Children.toArray(children).reduce<\n ScreenConfigWithParent<State, ScreenOptions, EventMap>[]\n >((acc, child) => {\n if (React.isValidElement(child)) {\n if (child.type === Screen) {\n // We can only extract the config from `Screen` elements\n // If something else was rendered, it's probably a bug\n\n if (!isValidKey(child.props.navigationKey)) {\n throw new Error(\n `Got an invalid 'navigationKey' prop (${JSON.stringify(\n child.props.navigationKey\n )}) for the screen '${\n child.props.name\n }'. It must be a non-empty string or 'undefined'.`\n );\n }\n\n acc.push({\n keys: [groupKey, child.props.navigationKey],\n options: groupOptions,\n props: child.props as RouteConfig<\n ParamListBase,\n string,\n State,\n ScreenOptions,\n EventMap\n >,\n });\n return acc;\n }\n\n if (child.type === React.Fragment || child.type === Group) {\n if (!isValidKey(child.props.navigationKey)) {\n throw new Error(\n `Got an invalid 'navigationKey' prop (${JSON.stringify(\n child.props.navigationKey\n )}) for the group. It must be a non-empty string or 'undefined'.`\n );\n }\n\n // When we encounter a fragment or group, we need to dive into its children to extract the configs\n // This is handy to conditionally define a group of screens\n acc.push(\n ...getRouteConfigsFromChildren<State, ScreenOptions, EventMap>(\n child.props.children,\n child.props.navigationKey,\n child.type !== Group\n ? groupOptions\n : groupOptions != null\n ? [...groupOptions, child.props.screenOptions]\n : [child.props.screenOptions]\n )\n );\n return acc;\n }\n }\n\n throw new Error(\n `A navigator can only contain 'Screen', 'Group' or 'React.Fragment' as its direct children (found ${\n React.isValidElement(child)\n ? `'${\n typeof child.type === 'string' ? child.type : child.type?.name\n }'${\n child.props?.name ? ` for the screen '${child.props.name}'` : ''\n }`\n : typeof child === 'object'\n ? JSON.stringify(child)\n : `'${String(child)}'`\n }). To render this component in the navigator, pass it in the 'component' prop to 'Screen'.`\n );\n }, []);\n\n if (process.env.NODE_ENV !== 'production') {\n configs.forEach((config) => {\n const { name, children, component, getComponent } = config.props;\n\n if (typeof name !== 'string' || !name) {\n throw new Error(\n `Got an invalid name (${JSON.stringify(\n name\n )}) for the screen. It must be a non-empty string.`\n );\n }\n\n if (\n children != null ||\n component !== undefined ||\n getComponent !== undefined\n ) {\n if (children != null && component !== undefined) {\n throw new Error(\n `Got both 'component' and 'children' props for the screen '${name}'. You must pass only one of them.`\n );\n }\n\n if (children != null && getComponent !== undefined) {\n throw new Error(\n `Got both 'getComponent' and 'children' props for the screen '${name}'. You must pass only one of them.`\n );\n }\n\n if (component !== undefined && getComponent !== undefined) {\n throw new Error(\n `Got both 'component' and 'getComponent' props for the screen '${name}'. You must pass only one of them.`\n );\n }\n\n if (children != null && typeof children !== 'function') {\n throw new Error(\n `Got an invalid value for 'children' prop for the screen '${name}'. It must be a function returning a React Element.`\n );\n }\n\n if (component !== undefined && !isValidElementType(component)) {\n throw new Error(\n `Got an invalid value for 'component' prop for the screen '${name}'. It must be a valid React Component.`\n );\n }\n\n if (getComponent !== undefined && typeof getComponent !== 'function') {\n throw new Error(\n `Got an invalid value for 'getComponent' prop for the screen '${name}'. It must be a function returning a React Component.`\n );\n }\n\n if (typeof component === 'function') {\n if (component.name === 'component') {\n // Inline anonymous functions passed in the `component` prop will have the name of the prop\n // It's relatively safe to assume that it's not a component since it should also have PascalCase name\n // We won't catch all scenarios here, but this should catch a good chunk of incorrect use.\n console.warn(\n `Looks like you're passing an inline function for 'component' prop for the screen '${name}' (e.g. component={() => <SomeComponent />}). Passing an inline function will cause the component state to be lost on re-render and cause perf issues since it's re-created every render. You can pass the function as children to 'Screen' instead to achieve the desired behaviour.`\n );\n } else if (/^[a-z]/.test(component.name)) {\n console.warn(\n `Got a component with the name '${component.name}' for the screen '${name}'. React Components must start with an uppercase letter. If you're passing a regular function and not a component, pass it as children to 'Screen' instead. Otherwise capitalize your component's name.`\n );\n }\n }\n } else {\n throw new Error(\n `Couldn't find a 'component', 'getComponent' or 'children' prop for the screen '${name}'. This can happen if you passed 'undefined'. You likely forgot to export your component from the file it's defined in, or mixed up default import and named import when importing.`\n );\n }\n });\n }\n\n return configs;\n};\n\n/**\n * Hook for building navigators.\n *\n * @param createRouter Factory method which returns router object.\n * @param options Options object containing `children` and additional options for the router.\n * @returns An object containing `state`, `navigation`, `descriptors` objects.\n */\nexport default function useNavigationBuilder<\n State extends NavigationState,\n RouterOptions extends DefaultRouterOptions,\n ActionHelpers extends Record<string, () => void>,\n ScreenOptions extends {},\n EventMap extends Record<string, any>\n>(\n createRouter: RouterFactory<State, any, RouterOptions>,\n options: DefaultNavigatorOptions<\n ParamListBase,\n State,\n ScreenOptions,\n EventMap\n > &\n RouterOptions\n) {\n const navigatorKey = useRegisterNavigator();\n\n const route = React.useContext(NavigationRouteContext) as\n | NavigatorRoute<State>\n | undefined;\n\n const { children, screenListeners, ...rest } = options;\n const { current: router } = React.useRef<Router<State, any>>(\n createRouter({\n ...(rest as unknown as RouterOptions),\n ...(route?.params &&\n route.params.state == null &&\n route.params.initial !== false &&\n typeof route.params.screen === 'string'\n ? { initialRouteName: route.params.screen }\n : null),\n })\n );\n\n const routeConfigs = getRouteConfigsFromChildren<\n State,\n ScreenOptions,\n EventMap\n >(children);\n\n const screens = routeConfigs.reduce<\n Record<string, ScreenConfigWithParent<State, ScreenOptions, EventMap>>\n >((acc, config) => {\n if (config.props.name in acc) {\n throw new Error(\n `A navigator cannot contain multiple 'Screen' components with the same name (found duplicate screen named '${config.props.name}')`\n );\n }\n\n acc[config.props.name] = config;\n return acc;\n }, {});\n\n const routeNames = routeConfigs.map((config) => config.props.name);\n const routeKeyList = routeNames.reduce<Record<string, React.Key | undefined>>(\n (acc, curr) => {\n acc[curr] = screens[curr].keys.map((key) => key ?? '').join(':');\n return acc;\n },\n {}\n );\n const routeParamList = routeNames.reduce<Record<string, object | undefined>>(\n (acc, curr) => {\n const { initialParams } = screens[curr].props;\n acc[curr] = initialParams;\n return acc;\n },\n {}\n );\n const routeGetIdList = routeNames.reduce<\n RouterConfigOptions['routeGetIdList']\n >(\n (acc, curr) =>\n Object.assign(acc, {\n [curr]: screens[curr].props.getId,\n }),\n {}\n );\n\n if (!routeNames.length) {\n throw new Error(\n \"Couldn't find any screens for the navigator. Have you defined any screens as its children?\"\n );\n }\n\n const isStateValid = React.useCallback(\n (state) => state.type === undefined || state.type === router.type,\n [router.type]\n );\n\n const isStateInitialized = React.useCallback(\n (state) =>\n state !== undefined && state.stale === false && isStateValid(state),\n [isStateValid]\n );\n\n const {\n state: currentState,\n getState: getCurrentState,\n setState: setCurrentState,\n setKey,\n getKey,\n getIsInitial,\n } = React.useContext(NavigationStateContext);\n\n const stateCleanedUp = React.useRef(false);\n\n const cleanUpState = React.useCallback(() => {\n setCurrentState(undefined);\n stateCleanedUp.current = true;\n }, [setCurrentState]);\n\n const setState = React.useCallback(\n (state: NavigationState | PartialState<NavigationState> | undefined) => {\n if (stateCleanedUp.current) {\n // State might have been already cleaned up due to unmount\n // We do not want to expose API allowing to override this\n // This would lead to old data preservation on main navigator unmount\n return;\n }\n setCurrentState(state);\n },\n [setCurrentState]\n );\n\n const [initializedState, isFirstStateInitialization] = React.useMemo(() => {\n const initialRouteParamList = routeNames.reduce<\n Record<string, object | undefined>\n >((acc, curr) => {\n const { initialParams } = screens[curr].props;\n const initialParamsFromParams =\n route?.params?.state == null &&\n route?.params?.initial !== false &&\n route?.params?.screen === curr\n ? route.params.params\n : undefined;\n\n acc[curr] =\n initialParams !== undefined || initialParamsFromParams !== undefined\n ? {\n ...initialParams,\n ...initialParamsFromParams,\n }\n : undefined;\n\n return acc;\n }, {});\n\n // If the current state isn't initialized on first render, we initialize it\n // We also need to re-initialize it if the state passed from parent was changed (maybe due to reset)\n // Otherwise assume that the state was provided as initial state\n // So we need to rehydrate it to make it usable\n if (\n (currentState === undefined || !isStateValid(currentState)) &&\n route?.params?.state == null\n ) {\n return [\n router.getInitialState({\n routeNames,\n routeParamList: initialRouteParamList,\n routeGetIdList,\n }),\n true,\n ];\n } else {\n return [\n router.getRehydratedState(\n route?.params?.state ?? (currentState as PartialState<State>),\n {\n routeNames,\n routeParamList: initialRouteParamList,\n routeGetIdList,\n }\n ),\n false,\n ];\n }\n // We explicitly don't include routeNames, route.params etc. in the dep list\n // below. We want to avoid forcing a new state to be calculated in those cases\n // Instead, we handle changes to these in the nextState code below. Note\n // that some changes to routeConfigs are explicitly ignored, such as changes\n // to initialParams\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentState, router, isStateValid]);\n\n const previousRouteKeyListRef = React.useRef(routeKeyList);\n\n React.useEffect(() => {\n previousRouteKeyListRef.current = routeKeyList;\n });\n\n const previousRouteKeyList = previousRouteKeyListRef.current;\n\n let state =\n // If the state isn't initialized, or stale, use the state we initialized instead\n // The state won't update until there's a change needed in the state we have initalized locally\n // So it'll be `undefined` or stale until the first navigation event happens\n isStateInitialized(currentState)\n ? (currentState as State)\n : (initializedState as State);\n\n let nextState: State = state;\n\n if (\n !isArrayEqual(state.routeNames, routeNames) ||\n !isRecordEqual(routeKeyList, previousRouteKeyList)\n ) {\n // When the list of route names change, the router should handle it to remove invalid routes\n nextState = router.getStateForRouteNamesChange(state, {\n routeNames,\n routeParamList,\n routeGetIdList,\n routeKeyChanges: Object.keys(routeKeyList).filter(\n (name) =>\n previousRouteKeyList.hasOwnProperty(name) &&\n routeKeyList[name] !== previousRouteKeyList[name]\n ),\n });\n }\n\n const previousNestedParamsRef = React.useRef(route?.params);\n\n React.useEffect(() => {\n previousNestedParamsRef.current = route?.params;\n }, [route?.params]);\n\n if (route?.params) {\n const previousParams = previousNestedParamsRef.current;\n\n let action: CommonActions.Action | undefined;\n\n if (\n typeof route.params.state === 'object' &&\n route.params.state != null &&\n route.params !== previousParams\n ) {\n // If the route was updated with new state, we should reset to it\n action = CommonActions.reset(route.params.state);\n } else if (\n typeof route.params.screen === 'string' &&\n ((route.params.initial === false && isFirstStateInitialization) ||\n route.params !== previousParams)\n ) {\n // If the route was updated with new screen name and/or params, we should navigate there\n action = CommonActions.navigate({\n name: route.params.screen,\n params: route.params.params,\n path: route.params.path,\n });\n }\n\n // The update should be limited to current navigator only, so we call the router manually\n const updatedState = action\n ? router.getStateForAction(nextState, action, {\n routeNames,\n routeParamList,\n routeGetIdList,\n })\n : null;\n\n nextState =\n updatedState !== null\n ? router.getRehydratedState(updatedState, {\n routeNames,\n routeParamList,\n routeGetIdList,\n })\n : nextState;\n }\n\n const shouldUpdate = state !== nextState;\n\n useScheduleUpdate(() => {\n if (shouldUpdate) {\n // If the state needs to be updated, we'll schedule an update\n setState(nextState);\n }\n });\n\n // The up-to-date state will come in next render, but we don't need to wait for it\n // We can't use the outdated state since the screens have changed, which will cause error due to mismatched config\n // So we override the state object we return to use the latest state as soon as possible\n state = nextState;\n\n React.useEffect(() => {\n setKey(navigatorKey);\n\n if (!getIsInitial()) {\n // If it's not initial render, we need to update the state\n // This will make sure that our container gets notifier of state changes due to new mounts\n // This is necessary for proper screen tracking, URL updates etc.\n setState(nextState);\n }\n\n return () => {\n // We need to clean up state for this navigator on unmount\n // We do it in a timeout because we need to detect if another navigator mounted in the meantime\n // For example, if another navigator has started rendering, we should skip cleanup\n // Otherwise, our cleanup step will cleanup state for the other navigator and re-initialize it\n setTimeout(() => {\n if (getCurrentState() !== undefined && getKey() === navigatorKey) {\n cleanUpState();\n }\n }, 0);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // We initialize this ref here to avoid a new getState getting initialized\n // whenever initializedState changes. We want getState to have access to the\n // latest initializedState, but don't need it to change when that happens\n const initializedStateRef = React.useRef<State>();\n initializedStateRef.current = initializedState;\n\n const getState = React.useCallback((): State => {\n const currentState = getCurrentState();\n\n return isStateInitialized(currentState)\n ? (currentState as State)\n : (initializedStateRef.current as State);\n }, [getCurrentState, isStateInitialized]);\n\n const emitter = useEventEmitter<EventMapCore<State>>((e) => {\n let routeNames = [];\n\n let route: Route<string> | undefined;\n\n if (e.target) {\n route = state.routes.find((route) => route.key === e.target);\n\n if (route?.name) {\n routeNames.push(route.name);\n }\n } else {\n route = state.routes[state.index];\n routeNames.push(\n ...Object.keys(screens).filter((name) => route?.name === name)\n );\n }\n\n if (route == null) {\n return;\n }\n\n const navigation = descriptors[route.key].navigation;\n\n const listeners = ([] as (((e: any) => void) | undefined)[])\n .concat(\n // Get an array of listeners for all screens + common listeners on navigator\n ...[\n screenListeners,\n ...routeNames.map((name) => {\n const { listeners } = screens[name].props;\n return listeners;\n }),\n ].map((listeners) => {\n const map =\n typeof listeners === 'function'\n ? listeners({ route: route as any, navigation })\n : listeners;\n\n return map\n ? Object.keys(map)\n .filter((type) => type === e.type)\n .map((type) => map?.[type])\n : undefined;\n })\n )\n // We don't want same listener to be called multiple times for same event\n // So we remove any duplicate functions from the array\n .filter((cb, i, self) => cb && self.lastIndexOf(cb) === i);\n\n listeners.forEach((listener) => listener?.(e));\n });\n\n useFocusEvents({ state, emitter });\n\n React.useEffect(() => {\n emitter.emit({ type: 'state', data: { state } });\n }, [emitter, state]);\n\n const { listeners: childListeners, addListener } = useChildListeners();\n\n const { keyedListeners, addKeyedListener } = useKeyedChildListeners();\n\n const onAction = useOnAction({\n router,\n getState,\n setState,\n key: route?.key,\n actionListeners: childListeners.action,\n beforeRemoveListeners: keyedListeners.beforeRemove,\n routerConfigOptions: {\n routeNames,\n routeParamList,\n routeGetIdList,\n },\n emitter,\n });\n\n const onRouteFocus = useOnRouteFocus({\n router,\n key: route?.key,\n getState,\n setState,\n });\n\n const navigation = useNavigationHelpers<\n State,\n ActionHelpers,\n NavigationAction,\n EventMap\n >({\n onAction,\n getState,\n emitter,\n router,\n });\n\n useFocusedListenersChildrenAdapter({\n navigation,\n focusedListeners: childListeners.focus,\n });\n\n useOnGetState({\n getState,\n getStateListeners: keyedListeners.getState,\n });\n\n const descriptors = useDescriptors<\n State,\n ActionHelpers,\n ScreenOptions,\n EventMap\n >({\n state,\n screens,\n navigation,\n screenOptions: options.screenOptions,\n defaultScreenOptions: options.defaultScreenOptions,\n onAction,\n getState,\n setState,\n onRouteFocus,\n addListener,\n addKeyedListener,\n router,\n // @ts-expect-error: this should have both core and custom events, but too much work right now\n emitter,\n });\n\n useCurrentRender({\n state,\n navigation,\n descriptors,\n });\n\n const NavigationContent = useComponent(NavigationHelpersContext.Provider, {\n value: navigation,\n });\n\n return {\n state,\n navigation,\n descriptors,\n NavigationContent,\n };\n}\n"]}
@@ -7,14 +7,15 @@ import NavigationBuilderContext from './NavigationBuilderContext';
7
7
  * It's important to cache them to make sure navigation objects don't change between renders.
8
8
  * This lets us apply optimizations like `React.memo` to minimize re-rendering screens.
9
9
  */
10
- export default function useNavigationCache({
11
- state,
12
- getState,
13
- navigation,
14
- setOptions,
15
- router,
16
- emitter
17
- }) {
10
+ export default function useNavigationCache(_ref) {
11
+ let {
12
+ state,
13
+ getState,
14
+ navigation,
15
+ setOptions,
16
+ router,
17
+ emitter
18
+ } = _ref;
18
19
  const {
19
20
  stackRef
20
21
  } = React.useContext(NavigationBuilderContext); // Cache object which holds navigation objects for each screen
@@ -71,8 +72,14 @@ export default function useNavigationCache({
71
72
  };
72
73
 
73
74
  const helpers = Object.keys(actions).reduce((acc, name) => {
74
- acc[name] = (...args) => withStack(() => // @ts-expect-error: name is a valid key, but TypeScript is dumb
75
- dispatch(actions[name](...args)));
75
+ acc[name] = function () {
76
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
77
+ args[_key] = arguments[_key];
78
+ }
79
+
80
+ return withStack(() => // @ts-expect-error: name is a valid key, but TypeScript is dumb
81
+ dispatch(actions[name](...args)));
82
+ };
76
83
 
77
84
  return acc;
78
85
  }, {});