@react-navigation/core 7.0.0-rc.9 → 7.0.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.
- package/lib/commonjs/BaseNavigationContainer.js +356 -0
- package/lib/commonjs/BaseNavigationContainer.js.map +1 -0
- package/lib/commonjs/CurrentRenderContext.js +15 -0
- package/lib/commonjs/DeprecatedNavigationInChildContext.js +14 -0
- package/lib/commonjs/EnsureSingleNavigator.js +43 -0
- package/lib/commonjs/Group.js +14 -0
- package/lib/commonjs/NavigationBuilderContext.js +17 -0
- package/lib/commonjs/NavigationContainerRefContext.js +14 -0
- package/lib/commonjs/NavigationContext.js +14 -0
- package/lib/commonjs/NavigationHelpersContext.js +15 -0
- package/lib/commonjs/NavigationIndependentTree.js +35 -0
- package/lib/commonjs/NavigationIndependentTreeContext.js +14 -0
- package/lib/commonjs/NavigationRouteContext.js +14 -0
- package/lib/commonjs/NavigationStateContext.js +29 -0
- package/lib/commonjs/PreventRemoveContext.js +16 -0
- package/lib/commonjs/PreventRemoveProvider.js +91 -0
- package/lib/commonjs/SceneView.js +96 -0
- package/lib/commonjs/Screen.js +14 -0
- package/lib/commonjs/StaticContainer.js +31 -0
- package/lib/commonjs/StaticNavigation.js +256 -0
- package/lib/commonjs/StaticNavigation.js.map +1 -0
- package/lib/commonjs/UnhandledActionContext.js +11 -0
- package/lib/commonjs/checkDuplicateRouteNames.js +25 -0
- package/lib/commonjs/checkSerializable.js +50 -0
- package/lib/commonjs/createNavigationContainerRef.js +69 -0
- package/lib/commonjs/createNavigatorFactory.js +34 -0
- package/lib/commonjs/deepFreeze.js +37 -0
- package/lib/commonjs/findFocusedRoute.js +15 -0
- package/lib/commonjs/getActionFromState.js +86 -0
- package/lib/commonjs/getFocusedRouteNameFromRoute.js +22 -0
- package/lib/commonjs/getPathFromState.js +218 -0
- package/lib/commonjs/getPathFromState.js.map +1 -0
- package/lib/commonjs/getStateFromPath.js +475 -0
- package/lib/commonjs/getStateFromPath.js.map +1 -0
- package/lib/commonjs/index.js +287 -0
- package/lib/commonjs/isArrayEqual.js +20 -0
- package/lib/commonjs/isRecordEqual.js +21 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/theming/ThemeContext.js +12 -0
- package/lib/commonjs/theming/ThemeProvider.js +21 -0
- package/lib/commonjs/theming/useTheme.js +18 -0
- package/lib/commonjs/types.js +27 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/useChildListeners.js +36 -0
- package/lib/commonjs/useComponent.js +40 -0
- package/lib/commonjs/useCurrentRender.js +25 -0
- package/lib/commonjs/useDescriptors.js +188 -0
- package/lib/commonjs/useEventEmitter.js +105 -0
- package/lib/commonjs/useFocusEffect.js +80 -0
- package/lib/commonjs/useFocusEvents.js +70 -0
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js +48 -0
- package/lib/commonjs/useIsFocused.js +28 -0
- package/lib/commonjs/useIsomorphicLayoutEffect.js +12 -0
- package/lib/commonjs/useIsomorphicLayoutEffect.native.js +9 -0
- package/lib/commonjs/useKeyedChildListeners.js +33 -0
- package/lib/commonjs/useLazyValue.js +17 -0
- package/lib/commonjs/useNavigation.js +27 -0
- package/lib/commonjs/useNavigationBuilder.js +492 -0
- package/lib/commonjs/useNavigationBuilder.js.map +1 -0
- package/lib/commonjs/useNavigationCache.js +162 -0
- package/lib/commonjs/useNavigationContainerRef.js +18 -0
- package/lib/commonjs/useNavigationHelpers.js +76 -0
- package/lib/commonjs/useNavigationIndependentTree.js +14 -0
- package/lib/commonjs/useNavigationState.js +26 -0
- package/lib/commonjs/useOnAction.js +106 -0
- package/lib/commonjs/useOnGetState.js +48 -0
- package/lib/commonjs/useOnPreventRemove.js +72 -0
- package/lib/commonjs/useOnRouteFocus.js +36 -0
- package/lib/commonjs/useOptionsGetters.js +78 -0
- package/lib/commonjs/usePreventRemove.js +48 -0
- package/lib/commonjs/usePreventRemoveContext.js +18 -0
- package/lib/commonjs/useRegisterNavigator.js +32 -0
- package/lib/commonjs/useRoute.js +23 -0
- package/lib/commonjs/useRouteCache.js +69 -0
- package/lib/commonjs/useSyncState.js +48 -0
- package/lib/commonjs/validatePathConfig.js +49 -0
- package/lib/commonjs/validatePathConfig.js.map +1 -0
- package/lib/module/BaseNavigationContainer.js +349 -0
- package/lib/module/BaseNavigationContainer.js.map +1 -0
- package/lib/module/CurrentRenderContext.js +10 -0
- package/lib/module/CurrentRenderContext.js.map +1 -0
- package/lib/module/DeprecatedNavigationInChildContext.js +9 -0
- package/lib/module/DeprecatedNavigationInChildContext.js.map +1 -0
- package/lib/module/EnsureSingleNavigator.js +36 -0
- package/lib/module/EnsureSingleNavigator.js.map +1 -0
- package/lib/module/Group.js +10 -0
- package/lib/module/Group.js.map +1 -0
- package/lib/module/NavigationBuilderContext.js +11 -0
- package/lib/module/NavigationBuilderContext.js.map +1 -0
- package/lib/module/NavigationContainerRefContext.js +8 -0
- package/lib/module/NavigationContainerRefContext.js.map +1 -0
- package/lib/module/NavigationContext.js +8 -0
- package/lib/module/NavigationContext.js.map +1 -0
- package/lib/module/NavigationHelpersContext.js +9 -0
- package/lib/module/NavigationHelpersContext.js.map +1 -0
- package/lib/module/NavigationIndependentTree.js +30 -0
- package/lib/module/NavigationIndependentTree.js.map +1 -0
- package/lib/module/NavigationIndependentTreeContext.js +9 -0
- package/lib/module/NavigationIndependentTreeContext.js.map +1 -0
- package/lib/module/NavigationRouteContext.js +9 -0
- package/lib/module/NavigationRouteContext.js.map +1 -0
- package/lib/module/NavigationStateContext.js +23 -0
- package/lib/module/NavigationStateContext.js.map +1 -0
- package/lib/module/PreventRemoveContext.js +11 -0
- package/lib/module/PreventRemoveContext.js.map +1 -0
- package/lib/module/PreventRemoveProvider.js +84 -0
- package/lib/module/PreventRemoveProvider.js.map +1 -0
- package/lib/module/SceneView.js +90 -0
- package/lib/module/SceneView.js.map +1 -0
- package/lib/module/Screen.js +10 -0
- package/lib/module/Screen.js.map +1 -0
- package/lib/module/StaticContainer.js +26 -0
- package/lib/module/StaticContainer.js.map +1 -0
- package/lib/module/StaticNavigation.js +249 -0
- package/lib/module/StaticNavigation.js.map +1 -0
- package/lib/module/UnhandledActionContext.js +5 -0
- package/lib/module/UnhandledActionContext.js.map +1 -0
- package/lib/module/checkDuplicateRouteNames.js +21 -0
- package/lib/module/checkDuplicateRouteNames.js.map +1 -0
- package/lib/module/checkSerializable.js +46 -0
- package/lib/module/checkSerializable.js.map +1 -0
- package/lib/module/createNavigationContainerRef.js +64 -0
- package/lib/module/createNavigationContainerRef.js.map +1 -0
- package/lib/module/createNavigatorFactory.js +31 -0
- package/lib/module/createNavigatorFactory.js.map +1 -0
- package/lib/module/deepFreeze.js +31 -0
- package/lib/module/deepFreeze.js.map +1 -0
- package/lib/module/findFocusedRoute.js +11 -0
- package/lib/module/findFocusedRoute.js.map +1 -0
- package/lib/module/getActionFromState.js +82 -0
- package/lib/module/getActionFromState.js.map +1 -0
- package/lib/module/getFocusedRouteNameFromRoute.js +18 -0
- package/lib/module/getFocusedRouteNameFromRoute.js.map +1 -0
- package/lib/module/getPathFromState.js +212 -0
- package/lib/module/getPathFromState.js.map +1 -0
- package/lib/module/getStateFromPath.js +468 -0
- package/lib/module/getStateFromPath.js.map +1 -0
- package/lib/module/index.js +36 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/isArrayEqual.js +16 -0
- package/lib/module/isArrayEqual.js.map +1 -0
- package/lib/module/isRecordEqual.js +17 -0
- package/lib/module/isRecordEqual.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/theming/ThemeContext.js +6 -0
- package/lib/module/theming/ThemeContext.js.map +1 -0
- package/lib/module/theming/ThemeProvider.js +15 -0
- package/lib/module/theming/ThemeProvider.js.map +1 -0
- package/lib/module/theming/useTheme.js +12 -0
- package/lib/module/theming/useTheme.js.map +1 -0
- package/lib/module/types.js +23 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useChildListeners.js +30 -0
- package/lib/module/useChildListeners.js.map +1 -0
- package/lib/module/useComponent.js +34 -0
- package/lib/module/useComponent.js.map +1 -0
- package/lib/module/useCurrentRender.js +19 -0
- package/lib/module/useCurrentRender.js.map +1 -0
- package/lib/module/useDescriptors.js +182 -0
- package/lib/module/useDescriptors.js.map +1 -0
- package/lib/module/useEventEmitter.js +99 -0
- package/lib/module/useEventEmitter.js.map +1 -0
- package/lib/module/useFocusEffect.js +74 -0
- package/lib/module/useFocusEffect.js.map +1 -0
- package/lib/module/useFocusEvents.js +64 -0
- package/lib/module/useFocusEvents.js.map +1 -0
- package/lib/module/useFocusedListenersChildrenAdapter.js +42 -0
- package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -0
- package/lib/module/useIsFocused.js +23 -0
- package/lib/module/useIsFocused.js.map +1 -0
- package/lib/module/useIsomorphicLayoutEffect.js +9 -0
- package/lib/module/useIsomorphicLayoutEffect.js.map +1 -0
- package/lib/module/useIsomorphicLayoutEffect.native.js +5 -0
- package/lib/module/useIsomorphicLayoutEffect.native.js.map +1 -0
- package/lib/module/useKeyedChildListeners.js +27 -0
- package/lib/module/useKeyedChildListeners.js.map +1 -0
- package/lib/module/useLazyValue.js +11 -0
- package/lib/module/useLazyValue.js.map +1 -0
- package/lib/module/useNavigation.js +21 -0
- package/lib/module/useNavigation.js.map +1 -0
- package/lib/module/useNavigationBuilder.js +486 -0
- package/lib/module/useNavigationBuilder.js.map +1 -0
- package/lib/module/useNavigationCache.js +156 -0
- package/lib/module/useNavigationCache.js.map +1 -0
- package/lib/module/useNavigationContainerRef.js +12 -0
- package/lib/module/useNavigationContainerRef.js.map +1 -0
- package/lib/module/useNavigationHelpers.js +70 -0
- package/lib/module/useNavigationHelpers.js.map +1 -0
- package/lib/module/useNavigationIndependentTree.js +8 -0
- package/lib/module/useNavigationIndependentTree.js.map +1 -0
- package/lib/module/useNavigationState.js +20 -0
- package/lib/module/useNavigationState.js.map +1 -0
- package/lib/module/useOnAction.js +100 -0
- package/lib/module/useOnAction.js.map +1 -0
- package/lib/module/useOnGetState.js +42 -0
- package/lib/module/useOnGetState.js.map +1 -0
- package/lib/module/useOnPreventRemove.js +64 -0
- package/lib/module/useOnPreventRemove.js.map +1 -0
- package/lib/module/useOnRouteFocus.js +30 -0
- package/lib/module/useOnRouteFocus.js.map +1 -0
- package/lib/module/useOptionsGetters.js +72 -0
- package/lib/module/useOptionsGetters.js.map +1 -0
- package/lib/module/usePreventRemove.js +42 -0
- package/lib/module/usePreventRemove.js.map +1 -0
- package/lib/module/usePreventRemoveContext.js +12 -0
- package/lib/module/usePreventRemoveContext.js.map +1 -0
- package/lib/module/useRegisterNavigator.js +27 -0
- package/lib/module/useRegisterNavigator.js.map +1 -0
- package/lib/module/useRoute.js +17 -0
- package/lib/module/useRoute.js.map +1 -0
- package/lib/module/useRouteCache.js +62 -0
- package/lib/module/useRouteCache.js.map +1 -0
- package/lib/module/useSyncState.js +42 -0
- package/lib/module/useSyncState.js.map +1 -0
- package/lib/module/validatePathConfig.js +45 -0
- package/lib/module/validatePathConfig.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/BaseNavigationContainer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/CurrentRenderContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DeprecatedNavigationInChildContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/EnsureSingleNavigator.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Group.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NavigationBuilderContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NavigationContainerRefContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NavigationContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NavigationHelpersContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NavigationIndependentTree.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NavigationIndependentTreeContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NavigationRouteContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NavigationStateContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/PreventRemoveContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/PreventRemoveProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/SceneView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/StaticContainer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/StaticNavigation.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/UnhandledActionContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/checkDuplicateRouteNames.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/checkSerializable.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/createNavigationContainerRef.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/createNavigatorFactory.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/deepFreeze.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/findFocusedRoute.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/getActionFromState.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/getFocusedRouteNameFromRoute.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/getPathFromState.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/getStateFromPath.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/isArrayEqual.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/isRecordEqual.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theming/ThemeContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theming/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theming/useTheme.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +702 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useChildListeners.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useCurrentRender.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useDescriptors.d.ts +133 -0
- package/lib/typescript/commonjs/src/useDescriptors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useEventEmitter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useFocusEffect.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useFocusEvents.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useFocusedListenersChildrenAdapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useIsFocused.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useIsomorphicLayoutEffect.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useKeyedChildListeners.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useLazyValue.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useNavigation.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useNavigationBuilder.d.ts +181 -0
- package/lib/typescript/commonjs/src/useNavigationBuilder.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useNavigationCache.d.ts +65 -0
- package/lib/typescript/commonjs/src/useNavigationCache.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useNavigationContainerRef.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useNavigationHelpers.d.ts +96 -0
- package/lib/typescript/commonjs/src/useNavigationHelpers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useNavigationIndependentTree.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useNavigationState.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useOnAction.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useOnGetState.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useOnPreventRemove.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useOnRouteFocus.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useOptionsGetters.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/usePreventRemove.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/usePreventRemoveContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useRegisterNavigator.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useRoute.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useRouteCache.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useSyncState.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/validatePathConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/BaseNavigationContainer.d.ts +17 -0
- package/lib/typescript/module/src/BaseNavigationContainer.d.ts.map +1 -0
- package/lib/typescript/module/src/CurrentRenderContext.d.ts +9 -0
- package/lib/typescript/module/src/CurrentRenderContext.d.ts.map +1 -0
- package/lib/typescript/module/src/DeprecatedNavigationInChildContext.d.ts +6 -0
- package/lib/typescript/module/src/DeprecatedNavigationInChildContext.d.ts.map +1 -0
- package/lib/typescript/module/src/EnsureSingleNavigator.d.ts +14 -0
- package/lib/typescript/module/src/EnsureSingleNavigator.d.ts.map +1 -0
- package/lib/typescript/module/src/Group.d.ts +7 -0
- package/lib/typescript/module/src/Group.d.ts.map +1 -0
- package/lib/typescript/module/src/NavigationBuilderContext.d.ts +34 -0
- package/lib/typescript/module/src/NavigationBuilderContext.d.ts.map +1 -0
- package/lib/typescript/module/src/NavigationContainerRefContext.d.ts +8 -0
- package/lib/typescript/module/src/NavigationContainerRefContext.d.ts.map +1 -0
- package/lib/typescript/module/src/NavigationContext.d.ts +8 -0
- package/lib/typescript/module/src/NavigationContext.d.ts.map +1 -0
- package/lib/typescript/module/src/NavigationHelpersContext.d.ts +9 -0
- package/lib/typescript/module/src/NavigationHelpersContext.d.ts.map +1 -0
- package/lib/typescript/module/src/NavigationIndependentTree.d.ts +8 -0
- package/lib/typescript/module/src/NavigationIndependentTree.d.ts.map +1 -0
- package/lib/typescript/module/src/NavigationIndependentTreeContext.d.ts +6 -0
- package/lib/typescript/module/src/NavigationIndependentTreeContext.d.ts.map +1 -0
- package/lib/typescript/module/src/NavigationRouteContext.d.ts +7 -0
- package/lib/typescript/module/src/NavigationRouteContext.d.ts.map +1 -0
- package/lib/typescript/module/src/NavigationStateContext.d.ts +13 -0
- package/lib/typescript/module/src/NavigationStateContext.d.ts.map +1 -0
- package/lib/typescript/module/src/PreventRemoveContext.d.ts +13 -0
- package/lib/typescript/module/src/PreventRemoveContext.d.ts.map +1 -0
- package/lib/typescript/module/src/PreventRemoveProvider.d.ts +10 -0
- package/lib/typescript/module/src/PreventRemoveProvider.d.ts.map +1 -0
- package/lib/typescript/module/src/SceneView.d.ts +21 -0
- package/lib/typescript/module/src/SceneView.d.ts.map +1 -0
- package/lib/typescript/module/src/Screen.d.ts +7 -0
- package/lib/typescript/module/src/Screen.d.ts.map +1 -0
- package/lib/typescript/module/src/StaticContainer.d.ts +6 -0
- package/lib/typescript/module/src/StaticContainer.d.ts.map +1 -0
- package/lib/typescript/module/src/StaticNavigation.d.ts +188 -0
- package/lib/typescript/module/src/StaticNavigation.d.ts.map +1 -0
- package/lib/typescript/module/src/UnhandledActionContext.d.ts +4 -0
- package/lib/typescript/module/src/UnhandledActionContext.d.ts.map +1 -0
- package/lib/typescript/module/src/checkDuplicateRouteNames.d.ts +3 -0
- package/lib/typescript/module/src/checkDuplicateRouteNames.d.ts.map +1 -0
- package/lib/typescript/module/src/checkSerializable.d.ts +10 -0
- package/lib/typescript/module/src/checkSerializable.d.ts.map +1 -0
- package/lib/typescript/module/src/createNavigationContainerRef.d.ts +4 -0
- package/lib/typescript/module/src/createNavigationContainerRef.d.ts.map +1 -0
- package/lib/typescript/module/src/createNavigatorFactory.d.ts +10 -0
- package/lib/typescript/module/src/createNavigatorFactory.d.ts.map +1 -0
- package/lib/typescript/module/src/deepFreeze.d.ts +3 -0
- package/lib/typescript/module/src/deepFreeze.d.ts.map +1 -0
- package/lib/typescript/module/src/findFocusedRoute.d.ts +5 -0
- package/lib/typescript/module/src/findFocusedRoute.d.ts.map +1 -0
- package/lib/typescript/module/src/getActionFromState.d.ts +17 -0
- package/lib/typescript/module/src/getActionFromState.d.ts.map +1 -0
- package/lib/typescript/module/src/getFocusedRouteNameFromRoute.d.ts +3 -0
- package/lib/typescript/module/src/getFocusedRouteNameFromRoute.d.ts.map +1 -0
- package/lib/typescript/module/src/getPathFromState.d.ts +40 -0
- package/lib/typescript/module/src/getPathFromState.d.ts.map +1 -0
- package/lib/typescript/module/src/getStateFromPath.d.ts +34 -0
- package/lib/typescript/module/src/getStateFromPath.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +34 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/isArrayEqual.d.ts +6 -0
- package/lib/typescript/module/src/isArrayEqual.d.ts.map +1 -0
- package/lib/typescript/module/src/isRecordEqual.d.ts +5 -0
- package/lib/typescript/module/src/isRecordEqual.d.ts.map +1 -0
- package/lib/typescript/module/src/theming/ThemeContext.d.ts +3 -0
- package/lib/typescript/module/src/theming/ThemeContext.d.ts.map +1 -0
- package/lib/typescript/module/src/theming/ThemeProvider.d.ts +8 -0
- package/lib/typescript/module/src/theming/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/module/src/theming/useTheme.d.ts +2 -0
- package/lib/typescript/module/src/theming/useTheme.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +702 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/lib/typescript/module/src/useChildListeners.d.ts +12 -0
- package/lib/typescript/module/src/useChildListeners.d.ts.map +1 -0
- package/lib/typescript/module/src/useComponent.d.ts +7 -0
- package/lib/typescript/module/src/useComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/useCurrentRender.d.ts +14 -0
- package/lib/typescript/module/src/useCurrentRender.d.ts.map +1 -0
- package/lib/typescript/module/src/useDescriptors.d.ts +133 -0
- package/lib/typescript/module/src/useDescriptors.d.ts.map +1 -0
- package/lib/typescript/module/src/useEventEmitter.d.ts +9 -0
- package/lib/typescript/module/src/useEventEmitter.d.ts.map +1 -0
- package/lib/typescript/module/src/useFocusEffect.d.ts +11 -0
- package/lib/typescript/module/src/useFocusEffect.d.ts.map +1 -0
- package/lib/typescript/module/src/useFocusEvents.d.ts +13 -0
- package/lib/typescript/module/src/useFocusEvents.d.ts.map +1 -0
- package/lib/typescript/module/src/useFocusedListenersChildrenAdapter.d.ts +13 -0
- package/lib/typescript/module/src/useFocusedListenersChildrenAdapter.d.ts.map +1 -0
- package/lib/typescript/module/src/useIsFocused.d.ts +6 -0
- package/lib/typescript/module/src/useIsFocused.d.ts.map +1 -0
- package/lib/typescript/module/src/useIsomorphicLayoutEffect.d.ts +6 -0
- package/lib/typescript/module/src/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/lib/typescript/module/src/useIsomorphicLayoutEffect.native.d.ts +3 -0
- package/lib/typescript/module/src/useIsomorphicLayoutEffect.native.d.ts.map +1 -0
- package/lib/typescript/module/src/useKeyedChildListeners.d.ts +12 -0
- package/lib/typescript/module/src/useKeyedChildListeners.d.ts.map +1 -0
- package/lib/typescript/module/src/useLazyValue.d.ts +2 -0
- package/lib/typescript/module/src/useLazyValue.d.ts.map +1 -0
- package/lib/typescript/module/src/useNavigation.d.ts +11 -0
- package/lib/typescript/module/src/useNavigation.d.ts.map +1 -0
- package/lib/typescript/module/src/useNavigationBuilder.d.ts +181 -0
- package/lib/typescript/module/src/useNavigationBuilder.d.ts.map +1 -0
- package/lib/typescript/module/src/useNavigationCache.d.ts +65 -0
- package/lib/typescript/module/src/useNavigationCache.d.ts.map +1 -0
- package/lib/typescript/module/src/useNavigationContainerRef.d.ts +3 -0
- package/lib/typescript/module/src/useNavigationContainerRef.d.ts.map +1 -0
- package/lib/typescript/module/src/useNavigationHelpers.d.ts +96 -0
- package/lib/typescript/module/src/useNavigationHelpers.d.ts.map +1 -0
- package/lib/typescript/module/src/useNavigationIndependentTree.d.ts +2 -0
- package/lib/typescript/module/src/useNavigationIndependentTree.d.ts.map +1 -0
- package/lib/typescript/module/src/useNavigationState.d.ts +10 -0
- package/lib/typescript/module/src/useNavigationState.d.ts.map +1 -0
- package/lib/typescript/module/src/useOnAction.d.ts +26 -0
- package/lib/typescript/module/src/useOnAction.d.ts.map +1 -0
- package/lib/typescript/module/src/useOnGetState.d.ts +9 -0
- package/lib/typescript/module/src/useOnGetState.d.ts.map +1 -0
- package/lib/typescript/module/src/useOnPreventRemove.d.ts +17 -0
- package/lib/typescript/module/src/useOnPreventRemove.d.ts.map +1 -0
- package/lib/typescript/module/src/useOnRouteFocus.d.ts +15 -0
- package/lib/typescript/module/src/useOnRouteFocus.d.ts.map +1 -0
- package/lib/typescript/module/src/useOptionsGetters.d.ts +13 -0
- package/lib/typescript/module/src/useOptionsGetters.d.ts.map +1 -0
- package/lib/typescript/module/src/usePreventRemove.d.ts +13 -0
- package/lib/typescript/module/src/usePreventRemove.d.ts.map +1 -0
- package/lib/typescript/module/src/usePreventRemoveContext.d.ts +5 -0
- package/lib/typescript/module/src/usePreventRemoveContext.d.ts.map +1 -0
- package/lib/typescript/module/src/useRegisterNavigator.d.ts +6 -0
- package/lib/typescript/module/src/useRegisterNavigator.d.ts.map +1 -0
- package/lib/typescript/module/src/useRoute.d.ts +9 -0
- package/lib/typescript/module/src/useRoute.d.ts.map +1 -0
- package/lib/typescript/module/src/useRouteCache.d.ts +14 -0
- package/lib/typescript/module/src/useRouteCache.d.ts.map +1 -0
- package/lib/typescript/module/src/useSyncState.d.ts +2 -0
- package/lib/typescript/module/src/useSyncState.d.ts.map +1 -0
- package/lib/typescript/module/src/validatePathConfig.d.ts +2 -0
- package/lib/typescript/module/src/validatePathConfig.d.ts.map +1 -0
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +18 -11
- package/src/BaseNavigationContainer.tsx +1 -1
- package/src/StaticNavigation.tsx +2 -0
- package/src/getPathFromState.tsx +20 -4
- package/src/getStateFromPath.tsx +124 -63
- package/src/types.tsx +33 -46
- package/src/useNavigationBuilder.tsx +18 -1
- package/src/validatePathConfig.tsx +1 -1
- package/lib/commonjs/BaseNavigationContainer.cjs +0 -356
- package/lib/commonjs/BaseNavigationContainer.cjs.map +0 -1
- package/lib/commonjs/CurrentRenderContext.cjs +0 -15
- package/lib/commonjs/DeprecatedNavigationInChildContext.cjs +0 -14
- package/lib/commonjs/EnsureSingleNavigator.cjs +0 -43
- package/lib/commonjs/Group.cjs +0 -14
- package/lib/commonjs/NavigationBuilderContext.cjs +0 -17
- package/lib/commonjs/NavigationContainerRefContext.cjs +0 -14
- package/lib/commonjs/NavigationContext.cjs +0 -14
- package/lib/commonjs/NavigationHelpersContext.cjs +0 -15
- package/lib/commonjs/NavigationIndependentTree.cjs +0 -35
- package/lib/commonjs/NavigationIndependentTreeContext.cjs +0 -14
- package/lib/commonjs/NavigationRouteContext.cjs +0 -14
- package/lib/commonjs/NavigationStateContext.cjs +0 -29
- package/lib/commonjs/PreventRemoveContext.cjs +0 -16
- package/lib/commonjs/PreventRemoveProvider.cjs +0 -91
- package/lib/commonjs/SceneView.cjs +0 -96
- package/lib/commonjs/Screen.cjs +0 -14
- package/lib/commonjs/StaticContainer.cjs +0 -31
- package/lib/commonjs/StaticNavigation.cjs +0 -255
- package/lib/commonjs/StaticNavigation.cjs.map +0 -1
- package/lib/commonjs/UnhandledActionContext.cjs +0 -11
- package/lib/commonjs/checkDuplicateRouteNames.cjs +0 -25
- package/lib/commonjs/checkSerializable.cjs +0 -50
- package/lib/commonjs/createNavigationContainerRef.cjs +0 -69
- package/lib/commonjs/createNavigatorFactory.cjs +0 -34
- package/lib/commonjs/deepFreeze.cjs +0 -37
- package/lib/commonjs/findFocusedRoute.cjs +0 -15
- package/lib/commonjs/getActionFromState.cjs +0 -86
- package/lib/commonjs/getFocusedRouteNameFromRoute.cjs +0 -22
- package/lib/commonjs/getPathFromState.cjs +0 -211
- package/lib/commonjs/getPathFromState.cjs.map +0 -1
- package/lib/commonjs/getStateFromPath.cjs +0 -438
- package/lib/commonjs/getStateFromPath.cjs.map +0 -1
- package/lib/commonjs/index.cjs +0 -287
- package/lib/commonjs/isArrayEqual.cjs +0 -20
- package/lib/commonjs/isRecordEqual.cjs +0 -21
- package/lib/commonjs/theming/ThemeContext.cjs +0 -12
- package/lib/commonjs/theming/ThemeProvider.cjs +0 -21
- package/lib/commonjs/theming/useTheme.cjs +0 -18
- package/lib/commonjs/types.cjs +0 -9
- package/lib/commonjs/types.cjs.map +0 -1
- package/lib/commonjs/useChildListeners.cjs +0 -36
- package/lib/commonjs/useComponent.cjs +0 -40
- package/lib/commonjs/useCurrentRender.cjs +0 -25
- package/lib/commonjs/useDescriptors.cjs +0 -188
- package/lib/commonjs/useEventEmitter.cjs +0 -105
- package/lib/commonjs/useFocusEffect.cjs +0 -80
- package/lib/commonjs/useFocusEvents.cjs +0 -70
- package/lib/commonjs/useFocusedListenersChildrenAdapter.cjs +0 -48
- package/lib/commonjs/useIsFocused.cjs +0 -28
- package/lib/commonjs/useIsomorphicLayoutEffect.cjs +0 -12
- package/lib/commonjs/useIsomorphicLayoutEffect.native.cjs +0 -9
- package/lib/commonjs/useKeyedChildListeners.cjs +0 -33
- package/lib/commonjs/useLazyValue.cjs +0 -17
- package/lib/commonjs/useNavigation.cjs +0 -27
- package/lib/commonjs/useNavigationBuilder.cjs +0 -478
- package/lib/commonjs/useNavigationBuilder.cjs.map +0 -1
- package/lib/commonjs/useNavigationCache.cjs +0 -162
- package/lib/commonjs/useNavigationContainerRef.cjs +0 -18
- package/lib/commonjs/useNavigationHelpers.cjs +0 -76
- package/lib/commonjs/useNavigationIndependentTree.cjs +0 -14
- package/lib/commonjs/useNavigationState.cjs +0 -26
- package/lib/commonjs/useOnAction.cjs +0 -106
- package/lib/commonjs/useOnGetState.cjs +0 -48
- package/lib/commonjs/useOnPreventRemove.cjs +0 -72
- package/lib/commonjs/useOnRouteFocus.cjs +0 -36
- package/lib/commonjs/useOptionsGetters.cjs +0 -78
- package/lib/commonjs/usePreventRemove.cjs +0 -48
- package/lib/commonjs/usePreventRemoveContext.cjs +0 -18
- package/lib/commonjs/useRegisterNavigator.cjs +0 -32
- package/lib/commonjs/useRoute.cjs +0 -23
- package/lib/commonjs/useRouteCache.cjs +0 -69
- package/lib/commonjs/useSyncState.cjs +0 -48
- package/lib/commonjs/validatePathConfig.cjs +0 -49
- package/lib/commonjs/validatePathConfig.cjs.map +0 -1
- package/lib/module/BaseNavigationContainer.mjs +0 -347
- package/lib/module/BaseNavigationContainer.mjs.map +0 -1
- package/lib/module/CurrentRenderContext.mjs +0 -8
- package/lib/module/CurrentRenderContext.mjs.map +0 -1
- package/lib/module/DeprecatedNavigationInChildContext.mjs +0 -7
- package/lib/module/DeprecatedNavigationInChildContext.mjs.map +0 -1
- package/lib/module/EnsureSingleNavigator.mjs +0 -34
- package/lib/module/EnsureSingleNavigator.mjs.map +0 -1
- package/lib/module/Group.mjs +0 -8
- package/lib/module/Group.mjs.map +0 -1
- package/lib/module/NavigationBuilderContext.mjs +0 -9
- package/lib/module/NavigationBuilderContext.mjs.map +0 -1
- package/lib/module/NavigationContainerRefContext.mjs +0 -6
- package/lib/module/NavigationContainerRefContext.mjs.map +0 -1
- package/lib/module/NavigationContext.mjs +0 -6
- package/lib/module/NavigationContext.mjs.map +0 -1
- package/lib/module/NavigationHelpersContext.mjs +0 -7
- package/lib/module/NavigationHelpersContext.mjs.map +0 -1
- package/lib/module/NavigationIndependentTree.mjs +0 -28
- package/lib/module/NavigationIndependentTree.mjs.map +0 -1
- package/lib/module/NavigationIndependentTreeContext.mjs +0 -7
- package/lib/module/NavigationIndependentTreeContext.mjs.map +0 -1
- package/lib/module/NavigationRouteContext.mjs +0 -7
- package/lib/module/NavigationRouteContext.mjs.map +0 -1
- package/lib/module/NavigationStateContext.mjs +0 -21
- package/lib/module/NavigationStateContext.mjs.map +0 -1
- package/lib/module/PreventRemoveContext.mjs +0 -9
- package/lib/module/PreventRemoveContext.mjs.map +0 -1
- package/lib/module/PreventRemoveProvider.mjs +0 -82
- package/lib/module/PreventRemoveProvider.mjs.map +0 -1
- package/lib/module/SceneView.mjs +0 -88
- package/lib/module/SceneView.mjs.map +0 -1
- package/lib/module/Screen.mjs +0 -8
- package/lib/module/Screen.mjs.map +0 -1
- package/lib/module/StaticContainer.mjs +0 -24
- package/lib/module/StaticContainer.mjs.map +0 -1
- package/lib/module/StaticNavigation.mjs +0 -246
- package/lib/module/StaticNavigation.mjs.map +0 -1
- package/lib/module/UnhandledActionContext.mjs +0 -3
- package/lib/module/UnhandledActionContext.mjs.map +0 -1
- package/lib/module/checkDuplicateRouteNames.mjs +0 -19
- package/lib/module/checkDuplicateRouteNames.mjs.map +0 -1
- package/lib/module/checkSerializable.mjs +0 -44
- package/lib/module/checkSerializable.mjs.map +0 -1
- package/lib/module/createNavigationContainerRef.mjs +0 -62
- package/lib/module/createNavigationContainerRef.mjs.map +0 -1
- package/lib/module/createNavigatorFactory.mjs +0 -29
- package/lib/module/createNavigatorFactory.mjs.map +0 -1
- package/lib/module/deepFreeze.mjs +0 -29
- package/lib/module/deepFreeze.mjs.map +0 -1
- package/lib/module/findFocusedRoute.mjs +0 -9
- package/lib/module/findFocusedRoute.mjs.map +0 -1
- package/lib/module/getActionFromState.mjs +0 -80
- package/lib/module/getActionFromState.mjs.map +0 -1
- package/lib/module/getFocusedRouteNameFromRoute.mjs +0 -16
- package/lib/module/getFocusedRouteNameFromRoute.mjs.map +0 -1
- package/lib/module/getPathFromState.mjs +0 -203
- package/lib/module/getPathFromState.mjs.map +0 -1
- package/lib/module/getStateFromPath.mjs +0 -429
- package/lib/module/getStateFromPath.mjs.map +0 -1
- package/lib/module/index.mjs +0 -34
- package/lib/module/index.mjs.map +0 -1
- package/lib/module/isArrayEqual.mjs +0 -14
- package/lib/module/isArrayEqual.mjs.map +0 -1
- package/lib/module/isRecordEqual.mjs +0 -15
- package/lib/module/isRecordEqual.mjs.map +0 -1
- package/lib/module/theming/ThemeContext.mjs +0 -4
- package/lib/module/theming/ThemeContext.mjs.map +0 -1
- package/lib/module/theming/ThemeProvider.mjs +0 -13
- package/lib/module/theming/ThemeProvider.mjs.map +0 -1
- package/lib/module/theming/useTheme.mjs +0 -10
- package/lib/module/theming/useTheme.mjs.map +0 -1
- package/lib/module/types.mjs +0 -2
- package/lib/module/types.mjs.map +0 -1
- package/lib/module/useChildListeners.mjs +0 -28
- package/lib/module/useChildListeners.mjs.map +0 -1
- package/lib/module/useComponent.mjs +0 -32
- package/lib/module/useComponent.mjs.map +0 -1
- package/lib/module/useCurrentRender.mjs +0 -17
- package/lib/module/useCurrentRender.mjs.map +0 -1
- package/lib/module/useDescriptors.mjs +0 -180
- package/lib/module/useDescriptors.mjs.map +0 -1
- package/lib/module/useEventEmitter.mjs +0 -97
- package/lib/module/useEventEmitter.mjs.map +0 -1
- package/lib/module/useFocusEffect.mjs +0 -72
- package/lib/module/useFocusEffect.mjs.map +0 -1
- package/lib/module/useFocusEvents.mjs +0 -62
- package/lib/module/useFocusEvents.mjs.map +0 -1
- package/lib/module/useFocusedListenersChildrenAdapter.mjs +0 -40
- package/lib/module/useFocusedListenersChildrenAdapter.mjs.map +0 -1
- package/lib/module/useIsFocused.mjs +0 -21
- package/lib/module/useIsFocused.mjs.map +0 -1
- package/lib/module/useIsomorphicLayoutEffect.mjs +0 -7
- package/lib/module/useIsomorphicLayoutEffect.mjs.map +0 -1
- package/lib/module/useIsomorphicLayoutEffect.native.mjs +0 -3
- package/lib/module/useIsomorphicLayoutEffect.native.mjs.map +0 -1
- package/lib/module/useKeyedChildListeners.mjs +0 -25
- package/lib/module/useKeyedChildListeners.mjs.map +0 -1
- package/lib/module/useLazyValue.mjs +0 -9
- package/lib/module/useLazyValue.mjs.map +0 -1
- package/lib/module/useNavigation.mjs +0 -19
- package/lib/module/useNavigation.mjs.map +0 -1
- package/lib/module/useNavigationBuilder.mjs +0 -470
- package/lib/module/useNavigationBuilder.mjs.map +0 -1
- package/lib/module/useNavigationCache.mjs +0 -154
- package/lib/module/useNavigationCache.mjs.map +0 -1
- package/lib/module/useNavigationContainerRef.mjs +0 -10
- package/lib/module/useNavigationContainerRef.mjs.map +0 -1
- package/lib/module/useNavigationHelpers.mjs +0 -68
- package/lib/module/useNavigationHelpers.mjs.map +0 -1
- package/lib/module/useNavigationIndependentTree.mjs +0 -6
- package/lib/module/useNavigationIndependentTree.mjs.map +0 -1
- package/lib/module/useNavigationState.mjs +0 -18
- package/lib/module/useNavigationState.mjs.map +0 -1
- package/lib/module/useOnAction.mjs +0 -98
- package/lib/module/useOnAction.mjs.map +0 -1
- package/lib/module/useOnGetState.mjs +0 -40
- package/lib/module/useOnGetState.mjs.map +0 -1
- package/lib/module/useOnPreventRemove.mjs +0 -62
- package/lib/module/useOnPreventRemove.mjs.map +0 -1
- package/lib/module/useOnRouteFocus.mjs +0 -28
- package/lib/module/useOnRouteFocus.mjs.map +0 -1
- package/lib/module/useOptionsGetters.mjs +0 -70
- package/lib/module/useOptionsGetters.mjs.map +0 -1
- package/lib/module/usePreventRemove.mjs +0 -40
- package/lib/module/usePreventRemove.mjs.map +0 -1
- package/lib/module/usePreventRemoveContext.mjs +0 -10
- package/lib/module/usePreventRemoveContext.mjs.map +0 -1
- package/lib/module/useRegisterNavigator.mjs +0 -25
- package/lib/module/useRegisterNavigator.mjs.map +0 -1
- package/lib/module/useRoute.mjs +0 -15
- package/lib/module/useRoute.mjs.map +0 -1
- package/lib/module/useRouteCache.mjs +0 -60
- package/lib/module/useRouteCache.mjs.map +0 -1
- package/lib/module/useSyncState.mjs +0 -40
- package/lib/module/useSyncState.mjs.map +0 -1
- package/lib/module/validatePathConfig.mjs +0 -43
- package/lib/module/validatePathConfig.mjs.map +0 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts.map +0 -1
- package/lib/typescript/src/CurrentRenderContext.d.ts.map +0 -1
- package/lib/typescript/src/DeprecatedNavigationInChildContext.d.ts.map +0 -1
- package/lib/typescript/src/EnsureSingleNavigator.d.ts.map +0 -1
- package/lib/typescript/src/Group.d.ts.map +0 -1
- package/lib/typescript/src/NavigationBuilderContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationContainerRefContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationHelpersContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +0 -1
- package/lib/typescript/src/NavigationIndependentTreeContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationRouteContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationStateContext.d.ts.map +0 -1
- package/lib/typescript/src/PreventRemoveContext.d.ts.map +0 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts.map +0 -1
- package/lib/typescript/src/SceneView.d.ts.map +0 -1
- package/lib/typescript/src/Screen.d.ts.map +0 -1
- package/lib/typescript/src/StaticContainer.d.ts.map +0 -1
- package/lib/typescript/src/StaticNavigation.d.ts.map +0 -1
- package/lib/typescript/src/UnhandledActionContext.d.ts.map +0 -1
- package/lib/typescript/src/checkDuplicateRouteNames.d.ts.map +0 -1
- package/lib/typescript/src/checkSerializable.d.ts.map +0 -1
- package/lib/typescript/src/createNavigationContainerRef.d.ts.map +0 -1
- package/lib/typescript/src/createNavigatorFactory.d.ts.map +0 -1
- package/lib/typescript/src/deepFreeze.d.ts.map +0 -1
- package/lib/typescript/src/findFocusedRoute.d.ts.map +0 -1
- package/lib/typescript/src/getActionFromState.d.ts.map +0 -1
- package/lib/typescript/src/getFocusedRouteNameFromRoute.d.ts.map +0 -1
- package/lib/typescript/src/getPathFromState.d.ts.map +0 -1
- package/lib/typescript/src/getStateFromPath.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/isArrayEqual.d.ts.map +0 -1
- package/lib/typescript/src/isRecordEqual.d.ts.map +0 -1
- package/lib/typescript/src/theming/ThemeContext.d.ts.map +0 -1
- package/lib/typescript/src/theming/ThemeProvider.d.ts.map +0 -1
- package/lib/typescript/src/theming/useTheme.d.ts.map +0 -1
- package/lib/typescript/src/types.d.ts +0 -695
- package/lib/typescript/src/types.d.ts.map +0 -1
- package/lib/typescript/src/useChildListeners.d.ts.map +0 -1
- package/lib/typescript/src/useComponent.d.ts.map +0 -1
- package/lib/typescript/src/useCurrentRender.d.ts.map +0 -1
- package/lib/typescript/src/useDescriptors.d.ts +0 -133
- package/lib/typescript/src/useDescriptors.d.ts.map +0 -1
- package/lib/typescript/src/useEventEmitter.d.ts.map +0 -1
- package/lib/typescript/src/useFocusEffect.d.ts.map +0 -1
- package/lib/typescript/src/useFocusEvents.d.ts.map +0 -1
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts.map +0 -1
- package/lib/typescript/src/useIsFocused.d.ts.map +0 -1
- package/lib/typescript/src/useIsomorphicLayoutEffect.d.ts.map +0 -1
- package/lib/typescript/src/useIsomorphicLayoutEffect.native.d.ts.map +0 -1
- package/lib/typescript/src/useKeyedChildListeners.d.ts.map +0 -1
- package/lib/typescript/src/useLazyValue.d.ts.map +0 -1
- package/lib/typescript/src/useNavigation.d.ts.map +0 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +0 -181
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +0 -1
- package/lib/typescript/src/useNavigationCache.d.ts +0 -65
- package/lib/typescript/src/useNavigationCache.d.ts.map +0 -1
- package/lib/typescript/src/useNavigationContainerRef.d.ts.map +0 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts +0 -96
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +0 -1
- package/lib/typescript/src/useNavigationIndependentTree.d.ts.map +0 -1
- package/lib/typescript/src/useNavigationState.d.ts.map +0 -1
- package/lib/typescript/src/useOnAction.d.ts.map +0 -1
- package/lib/typescript/src/useOnGetState.d.ts.map +0 -1
- package/lib/typescript/src/useOnPreventRemove.d.ts.map +0 -1
- package/lib/typescript/src/useOnRouteFocus.d.ts.map +0 -1
- package/lib/typescript/src/useOptionsGetters.d.ts.map +0 -1
- package/lib/typescript/src/usePreventRemove.d.ts.map +0 -1
- package/lib/typescript/src/usePreventRemoveContext.d.ts.map +0 -1
- package/lib/typescript/src/useRegisterNavigator.d.ts.map +0 -1
- package/lib/typescript/src/useRoute.d.ts.map +0 -1
- package/lib/typescript/src/useRouteCache.d.ts.map +0 -1
- package/lib/typescript/src/useSyncState.d.ts.map +0 -1
- package/lib/typescript/src/validatePathConfig.d.ts.map +0 -1
- package/lib/typescript/utils/usePrevious.d.ts +0 -6
- package/lib/typescript/utils/usePrevious.d.ts.map +0 -1
- /package/lib/commonjs/{CurrentRenderContext.cjs.map → CurrentRenderContext.js.map} +0 -0
- /package/lib/commonjs/{DeprecatedNavigationInChildContext.cjs.map → DeprecatedNavigationInChildContext.js.map} +0 -0
- /package/lib/commonjs/{EnsureSingleNavigator.cjs.map → EnsureSingleNavigator.js.map} +0 -0
- /package/lib/commonjs/{Group.cjs.map → Group.js.map} +0 -0
- /package/lib/commonjs/{NavigationBuilderContext.cjs.map → NavigationBuilderContext.js.map} +0 -0
- /package/lib/commonjs/{NavigationContainerRefContext.cjs.map → NavigationContainerRefContext.js.map} +0 -0
- /package/lib/commonjs/{NavigationContext.cjs.map → NavigationContext.js.map} +0 -0
- /package/lib/commonjs/{NavigationHelpersContext.cjs.map → NavigationHelpersContext.js.map} +0 -0
- /package/lib/commonjs/{NavigationIndependentTree.cjs.map → NavigationIndependentTree.js.map} +0 -0
- /package/lib/commonjs/{NavigationIndependentTreeContext.cjs.map → NavigationIndependentTreeContext.js.map} +0 -0
- /package/lib/commonjs/{NavigationRouteContext.cjs.map → NavigationRouteContext.js.map} +0 -0
- /package/lib/commonjs/{NavigationStateContext.cjs.map → NavigationStateContext.js.map} +0 -0
- /package/lib/commonjs/{PreventRemoveContext.cjs.map → PreventRemoveContext.js.map} +0 -0
- /package/lib/commonjs/{PreventRemoveProvider.cjs.map → PreventRemoveProvider.js.map} +0 -0
- /package/lib/commonjs/{SceneView.cjs.map → SceneView.js.map} +0 -0
- /package/lib/commonjs/{Screen.cjs.map → Screen.js.map} +0 -0
- /package/lib/commonjs/{StaticContainer.cjs.map → StaticContainer.js.map} +0 -0
- /package/lib/commonjs/{UnhandledActionContext.cjs.map → UnhandledActionContext.js.map} +0 -0
- /package/lib/commonjs/{checkDuplicateRouteNames.cjs.map → checkDuplicateRouteNames.js.map} +0 -0
- /package/lib/commonjs/{checkSerializable.cjs.map → checkSerializable.js.map} +0 -0
- /package/lib/commonjs/{createNavigationContainerRef.cjs.map → createNavigationContainerRef.js.map} +0 -0
- /package/lib/commonjs/{createNavigatorFactory.cjs.map → createNavigatorFactory.js.map} +0 -0
- /package/lib/commonjs/{deepFreeze.cjs.map → deepFreeze.js.map} +0 -0
- /package/lib/commonjs/{findFocusedRoute.cjs.map → findFocusedRoute.js.map} +0 -0
- /package/lib/commonjs/{getActionFromState.cjs.map → getActionFromState.js.map} +0 -0
- /package/lib/commonjs/{getFocusedRouteNameFromRoute.cjs.map → getFocusedRouteNameFromRoute.js.map} +0 -0
- /package/lib/commonjs/{index.cjs.map → index.js.map} +0 -0
- /package/lib/commonjs/{isArrayEqual.cjs.map → isArrayEqual.js.map} +0 -0
- /package/lib/commonjs/{isRecordEqual.cjs.map → isRecordEqual.js.map} +0 -0
- /package/lib/commonjs/theming/{ThemeContext.cjs.map → ThemeContext.js.map} +0 -0
- /package/lib/commonjs/theming/{ThemeProvider.cjs.map → ThemeProvider.js.map} +0 -0
- /package/lib/commonjs/theming/{useTheme.cjs.map → useTheme.js.map} +0 -0
- /package/lib/commonjs/{useChildListeners.cjs.map → useChildListeners.js.map} +0 -0
- /package/lib/commonjs/{useComponent.cjs.map → useComponent.js.map} +0 -0
- /package/lib/commonjs/{useCurrentRender.cjs.map → useCurrentRender.js.map} +0 -0
- /package/lib/commonjs/{useDescriptors.cjs.map → useDescriptors.js.map} +0 -0
- /package/lib/commonjs/{useEventEmitter.cjs.map → useEventEmitter.js.map} +0 -0
- /package/lib/commonjs/{useFocusEffect.cjs.map → useFocusEffect.js.map} +0 -0
- /package/lib/commonjs/{useFocusEvents.cjs.map → useFocusEvents.js.map} +0 -0
- /package/lib/commonjs/{useFocusedListenersChildrenAdapter.cjs.map → useFocusedListenersChildrenAdapter.js.map} +0 -0
- /package/lib/commonjs/{useIsFocused.cjs.map → useIsFocused.js.map} +0 -0
- /package/lib/commonjs/{useIsomorphicLayoutEffect.cjs.map → useIsomorphicLayoutEffect.js.map} +0 -0
- /package/lib/commonjs/{useIsomorphicLayoutEffect.native.cjs.map → useIsomorphicLayoutEffect.native.js.map} +0 -0
- /package/lib/commonjs/{useKeyedChildListeners.cjs.map → useKeyedChildListeners.js.map} +0 -0
- /package/lib/commonjs/{useLazyValue.cjs.map → useLazyValue.js.map} +0 -0
- /package/lib/commonjs/{useNavigation.cjs.map → useNavigation.js.map} +0 -0
- /package/lib/commonjs/{useNavigationCache.cjs.map → useNavigationCache.js.map} +0 -0
- /package/lib/commonjs/{useNavigationContainerRef.cjs.map → useNavigationContainerRef.js.map} +0 -0
- /package/lib/commonjs/{useNavigationHelpers.cjs.map → useNavigationHelpers.js.map} +0 -0
- /package/lib/commonjs/{useNavigationIndependentTree.cjs.map → useNavigationIndependentTree.js.map} +0 -0
- /package/lib/commonjs/{useNavigationState.cjs.map → useNavigationState.js.map} +0 -0
- /package/lib/commonjs/{useOnAction.cjs.map → useOnAction.js.map} +0 -0
- /package/lib/commonjs/{useOnGetState.cjs.map → useOnGetState.js.map} +0 -0
- /package/lib/commonjs/{useOnPreventRemove.cjs.map → useOnPreventRemove.js.map} +0 -0
- /package/lib/commonjs/{useOnRouteFocus.cjs.map → useOnRouteFocus.js.map} +0 -0
- /package/lib/commonjs/{useOptionsGetters.cjs.map → useOptionsGetters.js.map} +0 -0
- /package/lib/commonjs/{usePreventRemove.cjs.map → usePreventRemove.js.map} +0 -0
- /package/lib/commonjs/{usePreventRemoveContext.cjs.map → usePreventRemoveContext.js.map} +0 -0
- /package/lib/commonjs/{useRegisterNavigator.cjs.map → useRegisterNavigator.js.map} +0 -0
- /package/lib/commonjs/{useRoute.cjs.map → useRoute.js.map} +0 -0
- /package/lib/commonjs/{useRouteCache.cjs.map → useRouteCache.js.map} +0 -0
- /package/lib/commonjs/{useSyncState.cjs.map → useSyncState.js.map} +0 -0
- /package/lib/typescript/{src → commonjs/src}/BaseNavigationContainer.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/CurrentRenderContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/DeprecatedNavigationInChildContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/EnsureSingleNavigator.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Group.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/NavigationBuilderContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/NavigationContainerRefContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/NavigationContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/NavigationHelpersContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/NavigationIndependentTree.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/NavigationIndependentTreeContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/NavigationRouteContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/NavigationStateContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/PreventRemoveContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/PreventRemoveProvider.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/SceneView.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Screen.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/StaticContainer.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/StaticNavigation.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/UnhandledActionContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/checkDuplicateRouteNames.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/checkSerializable.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/createNavigationContainerRef.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/createNavigatorFactory.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/deepFreeze.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/findFocusedRoute.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/getActionFromState.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/getFocusedRouteNameFromRoute.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/getPathFromState.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/getStateFromPath.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/index.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/isArrayEqual.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/isRecordEqual.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/theming/ThemeContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/theming/ThemeProvider.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/theming/useTheme.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useChildListeners.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useComponent.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useCurrentRender.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useEventEmitter.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useFocusEffect.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useFocusEvents.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useFocusedListenersChildrenAdapter.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useIsFocused.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useIsomorphicLayoutEffect.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useIsomorphicLayoutEffect.native.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useKeyedChildListeners.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useLazyValue.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useNavigation.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useNavigationContainerRef.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useNavigationIndependentTree.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useNavigationState.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useOnAction.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useOnGetState.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useOnPreventRemove.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useOnRouteFocus.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useOptionsGetters.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/usePreventRemove.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/usePreventRemoveContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useRegisterNavigator.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useRoute.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useRouteCache.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/useSyncState.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/validatePathConfig.d.ts +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as queryString from 'query-string';
|
|
4
|
+
import { validatePathConfig } from "./validatePathConfig.js";
|
|
5
|
+
const getActiveRoute = state => {
|
|
6
|
+
const route = typeof state.index === 'number' ? state.routes[state.index] : state.routes[state.routes.length - 1];
|
|
7
|
+
if (route.state) {
|
|
8
|
+
return getActiveRoute(route.state);
|
|
9
|
+
}
|
|
10
|
+
return route;
|
|
11
|
+
};
|
|
12
|
+
const cachedNormalizedConfigs = new WeakMap();
|
|
13
|
+
const getNormalizedConfigs = options => {
|
|
14
|
+
if (!options?.screens) return {};
|
|
15
|
+
const cached = cachedNormalizedConfigs.get(options?.screens);
|
|
16
|
+
if (cached) return cached;
|
|
17
|
+
const normalizedConfigs = createNormalizedConfigs(options.screens);
|
|
18
|
+
cachedNormalizedConfigs.set(options.screens, normalizedConfigs);
|
|
19
|
+
return normalizedConfigs;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Utility to serialize a navigation state object to a path string.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* getPathFromState(
|
|
28
|
+
* {
|
|
29
|
+
* routes: [
|
|
30
|
+
* {
|
|
31
|
+
* name: 'Chat',
|
|
32
|
+
* params: { author: 'Jane', id: 42 },
|
|
33
|
+
* },
|
|
34
|
+
* ],
|
|
35
|
+
* },
|
|
36
|
+
* {
|
|
37
|
+
* screens: {
|
|
38
|
+
* Chat: {
|
|
39
|
+
* path: 'chat/:author/:id',
|
|
40
|
+
* stringify: { author: author => author.toLowerCase() }
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* )
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param state Navigation state to serialize.
|
|
48
|
+
* @param options Extra options to fine-tune how to serialize the path.
|
|
49
|
+
* @returns Path representing the state, e.g. /foo/bar?count=42.
|
|
50
|
+
*/
|
|
51
|
+
export function getPathFromState(state, options) {
|
|
52
|
+
if (state == null) {
|
|
53
|
+
throw Error("Got 'undefined' for the navigation state. You must pass a valid state object.");
|
|
54
|
+
}
|
|
55
|
+
if (options) {
|
|
56
|
+
validatePathConfig(options);
|
|
57
|
+
}
|
|
58
|
+
const configs = getNormalizedConfigs(options);
|
|
59
|
+
let path = '/';
|
|
60
|
+
let current = state;
|
|
61
|
+
const allParams = {};
|
|
62
|
+
while (current) {
|
|
63
|
+
let index = typeof current.index === 'number' ? current.index : 0;
|
|
64
|
+
let route = current.routes[index];
|
|
65
|
+
let pattern;
|
|
66
|
+
let focusedParams;
|
|
67
|
+
const focusedRoute = getActiveRoute(state);
|
|
68
|
+
let currentOptions = configs;
|
|
69
|
+
|
|
70
|
+
// Keep all the route names that appeared during going deeper in config in case the pattern is resolved to undefined
|
|
71
|
+
const nestedRouteNames = [];
|
|
72
|
+
let hasNext = true;
|
|
73
|
+
while (route.name in currentOptions && hasNext) {
|
|
74
|
+
pattern = currentOptions[route.name].pattern;
|
|
75
|
+
nestedRouteNames.push(route.name);
|
|
76
|
+
if (route.params) {
|
|
77
|
+
const stringify = currentOptions[route.name]?.stringify;
|
|
78
|
+
const currentParams = Object.fromEntries(Object.entries(route.params).map(([key, value]) => [key, stringify?.[key] ? stringify[key](value) : String(value)]));
|
|
79
|
+
if (pattern) {
|
|
80
|
+
Object.assign(allParams, currentParams);
|
|
81
|
+
}
|
|
82
|
+
if (focusedRoute === route) {
|
|
83
|
+
// If this is the focused route, keep the params for later use
|
|
84
|
+
// We save it here since it's been stringified already
|
|
85
|
+
focusedParams = {
|
|
86
|
+
...currentParams
|
|
87
|
+
};
|
|
88
|
+
pattern?.split('/').filter(p => p.startsWith(':'))
|
|
89
|
+
// eslint-disable-next-line no-loop-func
|
|
90
|
+
.forEach(p => {
|
|
91
|
+
const name = getParamName(p);
|
|
92
|
+
|
|
93
|
+
// Remove the params present in the pattern since we'll only use the rest for query string
|
|
94
|
+
if (focusedParams) {
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
96
|
+
delete focusedParams[name];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// If there is no `screens` property or no nested state, we return pattern
|
|
103
|
+
if (!currentOptions[route.name].screens || route.state === undefined) {
|
|
104
|
+
hasNext = false;
|
|
105
|
+
} else {
|
|
106
|
+
index = typeof route.state.index === 'number' ? route.state.index : route.state.routes.length - 1;
|
|
107
|
+
const nextRoute = route.state.routes[index];
|
|
108
|
+
const nestedConfig = currentOptions[route.name].screens;
|
|
109
|
+
|
|
110
|
+
// if there is config for next route name, we go deeper
|
|
111
|
+
if (nestedConfig && nextRoute.name in nestedConfig) {
|
|
112
|
+
route = nextRoute;
|
|
113
|
+
currentOptions = nestedConfig;
|
|
114
|
+
} else {
|
|
115
|
+
// If not, there is no sense in going deeper in config
|
|
116
|
+
hasNext = false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (pattern === undefined) {
|
|
121
|
+
pattern = nestedRouteNames.join('/');
|
|
122
|
+
}
|
|
123
|
+
if (currentOptions[route.name] !== undefined) {
|
|
124
|
+
path += pattern.split('/').map(p => {
|
|
125
|
+
const name = getParamName(p);
|
|
126
|
+
|
|
127
|
+
// We don't know what to show for wildcard patterns
|
|
128
|
+
// Showing the route name seems ok, though whatever we show here will be incorrect
|
|
129
|
+
// Since the page doesn't actually exist
|
|
130
|
+
if (p === '*') {
|
|
131
|
+
return route.name;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// If the path has a pattern for a param, put the param in the path
|
|
135
|
+
if (p.startsWith(':')) {
|
|
136
|
+
const value = allParams[name];
|
|
137
|
+
if (value === undefined && p.endsWith('?')) {
|
|
138
|
+
// Optional params without value assigned in route.params should be ignored
|
|
139
|
+
return '';
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Valid characters according to
|
|
143
|
+
// https://datatracker.ietf.org/doc/html/rfc3986#section-3.3 (see pchar definition)
|
|
144
|
+
return String(value).replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]/g, char => encodeURIComponent(char));
|
|
145
|
+
}
|
|
146
|
+
return encodeURIComponent(p);
|
|
147
|
+
}).join('/');
|
|
148
|
+
} else {
|
|
149
|
+
path += encodeURIComponent(route.name);
|
|
150
|
+
}
|
|
151
|
+
if (!focusedParams) {
|
|
152
|
+
focusedParams = focusedRoute.params;
|
|
153
|
+
}
|
|
154
|
+
if (route.state) {
|
|
155
|
+
path += '/';
|
|
156
|
+
} else if (focusedParams) {
|
|
157
|
+
for (const param in focusedParams) {
|
|
158
|
+
if (focusedParams[param] === 'undefined') {
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
160
|
+
delete focusedParams[param];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const query = queryString.stringify(focusedParams, {
|
|
164
|
+
sort: false
|
|
165
|
+
});
|
|
166
|
+
if (query) {
|
|
167
|
+
path += `?${query}`;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
current = route.state;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Remove multiple as well as trailing slashes
|
|
174
|
+
path = path.replace(/\/+/g, '/');
|
|
175
|
+
path = path.length > 1 ? path.replace(/\/$/, '') : path;
|
|
176
|
+
|
|
177
|
+
// Include the root path if specified
|
|
178
|
+
if (options?.path) {
|
|
179
|
+
path = joinPaths(options.path, path);
|
|
180
|
+
}
|
|
181
|
+
return path;
|
|
182
|
+
}
|
|
183
|
+
const getParamName = pattern => pattern.replace(/^:/, '').replace(/\?$/, '');
|
|
184
|
+
const joinPaths = (...paths) => [].concat(...paths.map(p => p.split('/'))).filter(Boolean).join('/');
|
|
185
|
+
const createConfigItem = (config, parentPattern) => {
|
|
186
|
+
if (typeof config === 'string') {
|
|
187
|
+
// If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern
|
|
188
|
+
const pattern = parentPattern ? joinPaths(parentPattern, config) : config;
|
|
189
|
+
return {
|
|
190
|
+
pattern
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (config.exact && config.path === undefined) {
|
|
194
|
+
throw new Error("A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// If an object is specified as the value (e.g. Foo: { ... }),
|
|
198
|
+
// It can have `path` property and `screens` prop which has nested configs
|
|
199
|
+
const pattern = config.exact !== true ? joinPaths(parentPattern || '', config.path || '') : config.path || '';
|
|
200
|
+
const screens = config.screens ? createNormalizedConfigs(config.screens, pattern) : undefined;
|
|
201
|
+
return {
|
|
202
|
+
// Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.
|
|
203
|
+
pattern: pattern?.split('/').filter(Boolean).join('/'),
|
|
204
|
+
stringify: config.stringify,
|
|
205
|
+
screens
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
const createNormalizedConfigs = (options, pattern) => Object.fromEntries(Object.entries(options).map(([name, c]) => {
|
|
209
|
+
const result = createConfigItem(c, pattern);
|
|
210
|
+
return [name, result];
|
|
211
|
+
}));
|
|
212
|
+
//# sourceMappingURL=getPathFromState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["queryString","validatePathConfig","getActiveRoute","state","route","index","routes","length","cachedNormalizedConfigs","WeakMap","getNormalizedConfigs","options","screens","cached","get","normalizedConfigs","createNormalizedConfigs","set","getPathFromState","Error","configs","path","current","allParams","pattern","focusedParams","focusedRoute","currentOptions","nestedRouteNames","hasNext","name","push","params","stringify","currentParams","Object","fromEntries","entries","map","key","value","String","assign","split","filter","p","startsWith","forEach","getParamName","undefined","nextRoute","nestedConfig","join","endsWith","replace","char","encodeURIComponent","param","query","sort","joinPaths","paths","concat","Boolean","createConfigItem","config","parentPattern","exact","c","result"],"sourceRoot":"../../src","sources":["getPathFromState.tsx"],"mappings":";;AAKA,OAAO,KAAKA,WAAW,MAAM,cAAc;AAG3C,SAASC,kBAAkB,QAAQ,yBAAsB;AAkBzD,MAAMC,cAAc,GAAIC,KAAY,IAAwC;EAC1E,MAAMC,KAAK,GACT,OAAOD,KAAK,CAACE,KAAK,KAAK,QAAQ,GAC3BF,KAAK,CAACG,MAAM,CAACH,KAAK,CAACE,KAAK,CAAC,GACzBF,KAAK,CAACG,MA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AE;EAEvB,MAAMT,OAAO,GAAGqD,MAAM,CAACrD,OAAO,GAC1BI,uBAAuB,CAACiD,MAAM,CAACrD,OAAO,EAAEY,OAAO,CAAC,GAChDyB,SAAS;EAEb,OAAO;IACL;IACAzB,OAAO,EAAEA,OAAO,EAAEmB,KAAK,CAAC,GAAG,CAAC,CAACC,MAAM,CAACmB,OAAO,CAAC,CAACX,IAAI,CAAC,GAAG,CAAC;IACtDnB,SAAS,EAAEgC,MAAM,CAAChC,SAAS;IAC3BrB;EACF,CAAC;AACH,CAAC;AAED,MAAMI,uBAAuB,GAAGA,CAC9BL,OAA8B,EAC9Ba,OAAgB,KAEhBW,MAAM,CAACC,WAAW,CAChBD,MAAM,CAACE,OAAO,CAAC1B,OAAO,CAAC,CAAC2B,GAAG,CAAC,CAAC,CAACR,IAAI,EAAEsC,CAAC,CAAC,KAAK;EACzC,MAAMC,MAAM,GAAGL,gBAAgB,CAACI,CAAC,EAAE5C,OAAO,CAAC;EAE3C,OAAO,CAACM,IAAI,EAAEuC,MAAM,CAAC;AACvB,CAAC,CACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import escape from 'escape-string-regexp';
|
|
4
|
+
import * as queryString from 'query-string';
|
|
5
|
+
import { findFocusedRoute } from "./findFocusedRoute.js";
|
|
6
|
+
import { validatePathConfig } from "./validatePathConfig.js";
|
|
7
|
+
/**
|
|
8
|
+
* Utility to parse a path string to initial state object accepted by the container.
|
|
9
|
+
* This is useful for deep linking when we need to handle the incoming URL.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* getStateFromPath(
|
|
14
|
+
* '/chat/jane/42',
|
|
15
|
+
* {
|
|
16
|
+
* screens: {
|
|
17
|
+
* Chat: {
|
|
18
|
+
* path: 'chat/:author/:id',
|
|
19
|
+
* parse: { id: Number }
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* )
|
|
24
|
+
* ```
|
|
25
|
+
* @param path Path string to parse and convert, e.g. /foo/bar?count=42.
|
|
26
|
+
* @param options Extra options to fine-tune how to parse the path.
|
|
27
|
+
*/
|
|
28
|
+
export function getStateFromPath(path, options) {
|
|
29
|
+
const {
|
|
30
|
+
initialRoutes,
|
|
31
|
+
configs,
|
|
32
|
+
configWithRegexes
|
|
33
|
+
} = getConfigResources(options);
|
|
34
|
+
const screens = options?.screens;
|
|
35
|
+
let remaining = path.replace(/\/+/g, '/') // Replace multiple slash (//) with single ones
|
|
36
|
+
.replace(/^\//, '') // Remove extra leading slash
|
|
37
|
+
.replace(/\?.*$/, ''); // Remove query params which we will handle later
|
|
38
|
+
|
|
39
|
+
// Make sure there is a trailing slash
|
|
40
|
+
remaining = remaining.endsWith('/') ? remaining : `${remaining}/`;
|
|
41
|
+
const prefix = options?.path?.replace(/^\//, ''); // Remove extra leading slash
|
|
42
|
+
|
|
43
|
+
if (prefix) {
|
|
44
|
+
// Make sure there is a trailing slash
|
|
45
|
+
const normalizedPrefix = prefix.endsWith('/') ? prefix : `${prefix}/`;
|
|
46
|
+
|
|
47
|
+
// If the path doesn't start with the prefix, it's not a match
|
|
48
|
+
if (!remaining.startsWith(normalizedPrefix)) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Remove the prefix from the path
|
|
53
|
+
remaining = remaining.replace(normalizedPrefix, '');
|
|
54
|
+
}
|
|
55
|
+
if (screens === undefined) {
|
|
56
|
+
// When no config is specified, use the path segments as route names
|
|
57
|
+
const routes = remaining.split('/').filter(Boolean).map(segment => {
|
|
58
|
+
const name = decodeURIComponent(segment);
|
|
59
|
+
return {
|
|
60
|
+
name
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
if (routes.length) {
|
|
64
|
+
return createNestedStateObject(path, routes, initialRoutes);
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (remaining === '/') {
|
|
69
|
+
// We need to add special handling of empty path so navigation to empty path also works
|
|
70
|
+
// When handling empty path, we should only look at the root level config
|
|
71
|
+
const match = configs.find(config => config.path === '' && config.routeNames.every(
|
|
72
|
+
// Make sure that none of the parent configs have a non-empty path defined
|
|
73
|
+
name => !configs.find(c => c.screen === name)?.path));
|
|
74
|
+
if (match) {
|
|
75
|
+
return createNestedStateObject(path, match.routeNames.map(name => ({
|
|
76
|
+
name
|
|
77
|
+
})), initialRoutes, configs);
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
let result;
|
|
82
|
+
let current;
|
|
83
|
+
|
|
84
|
+
// We match the whole path against the regex instead of segments
|
|
85
|
+
// This makes sure matches such as wildcard will catch any unmatched routes, even if nested
|
|
86
|
+
const {
|
|
87
|
+
routes,
|
|
88
|
+
remainingPath
|
|
89
|
+
} = matchAgainstConfigs(remaining, configWithRegexes);
|
|
90
|
+
if (routes !== undefined) {
|
|
91
|
+
// This will always be empty if full path matched
|
|
92
|
+
current = createNestedStateObject(path, routes, initialRoutes, configs);
|
|
93
|
+
remaining = remainingPath;
|
|
94
|
+
result = current;
|
|
95
|
+
}
|
|
96
|
+
if (current == null || result == null) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Reference to the last used config resources. This is used to avoid recomputing the config resources when the options are the same.
|
|
104
|
+
*/
|
|
105
|
+
const cachedConfigResources = new WeakMap();
|
|
106
|
+
function getConfigResources(options) {
|
|
107
|
+
if (!options) return prepareConfigResources();
|
|
108
|
+
const cached = cachedConfigResources.get(options);
|
|
109
|
+
if (cached) return cached;
|
|
110
|
+
const resources = prepareConfigResources(options);
|
|
111
|
+
cachedConfigResources.set(options, resources);
|
|
112
|
+
return resources;
|
|
113
|
+
}
|
|
114
|
+
function prepareConfigResources(options) {
|
|
115
|
+
if (options) {
|
|
116
|
+
validatePathConfig(options);
|
|
117
|
+
}
|
|
118
|
+
const initialRoutes = getInitialRoutes(options);
|
|
119
|
+
const configs = getNormalizedConfigs(initialRoutes, options?.screens);
|
|
120
|
+
checkForDuplicatedConfigs(configs);
|
|
121
|
+
const configWithRegexes = getConfigsWithRegexes(configs);
|
|
122
|
+
return {
|
|
123
|
+
initialRoutes,
|
|
124
|
+
configs,
|
|
125
|
+
configWithRegexes
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function getInitialRoutes(options) {
|
|
129
|
+
const initialRoutes = [];
|
|
130
|
+
if (options?.initialRouteName) {
|
|
131
|
+
initialRoutes.push({
|
|
132
|
+
initialRouteName: options.initialRouteName,
|
|
133
|
+
parentScreens: []
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return initialRoutes;
|
|
137
|
+
}
|
|
138
|
+
function getNormalizedConfigs(initialRoutes, screens = {}) {
|
|
139
|
+
// Create a normalized configs array which will be easier to use
|
|
140
|
+
return [].concat(...Object.keys(screens).map(key => createNormalizedConfigs(key, screens, [], initialRoutes, []))).sort((a, b) => {
|
|
141
|
+
// Sort config so that:
|
|
142
|
+
// - the most exhaustive ones are always at the beginning
|
|
143
|
+
// - patterns with wildcard are always at the end
|
|
144
|
+
|
|
145
|
+
// If 2 patterns are same, move the one with less route names up
|
|
146
|
+
// This is an error state, so it's only useful for consistent error messages
|
|
147
|
+
if (a.pattern === b.pattern) {
|
|
148
|
+
return b.routeNames.join('>').localeCompare(a.routeNames.join('>'));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// If one of the patterns starts with the other, it's more exhaustive
|
|
152
|
+
// So move it up
|
|
153
|
+
if (a.pattern.startsWith(b.pattern)) {
|
|
154
|
+
return -1;
|
|
155
|
+
}
|
|
156
|
+
if (b.pattern.startsWith(a.pattern)) {
|
|
157
|
+
return 1;
|
|
158
|
+
}
|
|
159
|
+
const aParts = a.pattern.split('/');
|
|
160
|
+
const bParts = b.pattern.split('/');
|
|
161
|
+
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
|
162
|
+
// if b is longer, b get higher priority
|
|
163
|
+
if (aParts[i] == null) {
|
|
164
|
+
return 1;
|
|
165
|
+
}
|
|
166
|
+
// if a is longer, a get higher priority
|
|
167
|
+
if (bParts[i] == null) {
|
|
168
|
+
return -1;
|
|
169
|
+
}
|
|
170
|
+
const aWildCard = aParts[i] === '*' || aParts[i].startsWith(':');
|
|
171
|
+
const bWildCard = bParts[i] === '*' || bParts[i].startsWith(':');
|
|
172
|
+
// if both are wildcard we compare next component
|
|
173
|
+
if (aWildCard && bWildCard) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
// if only a is wild card, b get higher priority
|
|
177
|
+
if (aWildCard) {
|
|
178
|
+
return 1;
|
|
179
|
+
}
|
|
180
|
+
// if only b is wild card, a get higher priority
|
|
181
|
+
if (bWildCard) {
|
|
182
|
+
return -1;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return bParts.length - aParts.length;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function checkForDuplicatedConfigs(configs) {
|
|
189
|
+
// Check for duplicate patterns in the config
|
|
190
|
+
configs.reduce((acc, config) => {
|
|
191
|
+
if (acc[config.pattern]) {
|
|
192
|
+
const a = acc[config.pattern].routeNames;
|
|
193
|
+
const b = config.routeNames;
|
|
194
|
+
|
|
195
|
+
// It's not a problem if the path string omitted from a inner most screen
|
|
196
|
+
// For example, it's ok if a path resolves to `A > B > C` or `A > B`
|
|
197
|
+
const intersects = a.length > b.length ? b.every((it, i) => a[i] === it) : a.every((it, i) => b[i] === it);
|
|
198
|
+
if (!intersects) {
|
|
199
|
+
throw new Error(`Found conflicting screens with the same pattern. The pattern '${config.pattern}' resolves to both '${a.join(' > ')}' and '${b.join(' > ')}'. Patterns must be unique and cannot resolve to more than one screen.`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return Object.assign(acc, {
|
|
203
|
+
[config.pattern]: config
|
|
204
|
+
});
|
|
205
|
+
}, {});
|
|
206
|
+
}
|
|
207
|
+
function getConfigsWithRegexes(configs) {
|
|
208
|
+
return configs.map(c => ({
|
|
209
|
+
...c,
|
|
210
|
+
// Add `$` to the regex to make sure it matches till end of the path and not just beginning
|
|
211
|
+
regex: c.regex ? new RegExp(c.regex.source + '$') : undefined
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
const joinPaths = (...paths) => [].concat(...paths.map(p => p.split('/'))).filter(Boolean).join('/');
|
|
215
|
+
const matchAgainstConfigs = (remaining, configs) => {
|
|
216
|
+
let routes;
|
|
217
|
+
let remainingPath = remaining;
|
|
218
|
+
|
|
219
|
+
// Go through all configs, and see if the next path segment matches our regex
|
|
220
|
+
for (const config of configs) {
|
|
221
|
+
if (!config.regex) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const match = remainingPath.match(config.regex);
|
|
225
|
+
|
|
226
|
+
// If our regex matches, we need to extract params from the path
|
|
227
|
+
if (match) {
|
|
228
|
+
const matchResult = config.pattern?.split('/').reduce((acc, p, index) => {
|
|
229
|
+
if (!p.startsWith(':')) {
|
|
230
|
+
return acc;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Path parameter so increment position for the segment
|
|
234
|
+
acc.pos += 1;
|
|
235
|
+
const decodedParamSegment = decodeURIComponent(
|
|
236
|
+
// The param segments appear every second item starting from 2 in the regex match result
|
|
237
|
+
match[(acc.pos + 1) * 2]
|
|
238
|
+
// Remove trailing slash
|
|
239
|
+
.replace(/\/$/, ''));
|
|
240
|
+
Object.assign(acc.matchedParams, {
|
|
241
|
+
[p]: Object.assign(acc.matchedParams[p] || {}, {
|
|
242
|
+
[index]: decodedParamSegment
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
return acc;
|
|
246
|
+
}, {
|
|
247
|
+
pos: -1,
|
|
248
|
+
matchedParams: {}
|
|
249
|
+
});
|
|
250
|
+
const matchedParams = matchResult.matchedParams || {};
|
|
251
|
+
routes = config.routeNames.map(name => {
|
|
252
|
+
const routeConfig = configs.find(c => {
|
|
253
|
+
// Check matching name AND pattern in case same screen is used at different levels in config
|
|
254
|
+
return c.screen === name && config.pattern.startsWith(c.pattern);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.
|
|
258
|
+
const normalizedPath = routeConfig?.path.split('/').filter(Boolean).join('/');
|
|
259
|
+
|
|
260
|
+
// Get the number of segments in the initial pattern
|
|
261
|
+
const numInitialSegments = routeConfig?.pattern
|
|
262
|
+
// Extract the prefix from the pattern by removing the ending path pattern (e.g pattern=`a/b/c/d` and normalizedPath=`c/d` becomes `a/b`)
|
|
263
|
+
.replace(new RegExp(`${escape(normalizedPath)}$`), '')?.split('/').length;
|
|
264
|
+
const params = normalizedPath?.split('/').reduce((acc, p, index) => {
|
|
265
|
+
if (!p.startsWith(':')) {
|
|
266
|
+
return acc;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Get the real index of the path parameter in the matched path
|
|
270
|
+
// by offsetting by the number of segments in the initial pattern
|
|
271
|
+
const offset = numInitialSegments ? numInitialSegments - 1 : 0;
|
|
272
|
+
const value = matchedParams[p]?.[index + offset];
|
|
273
|
+
if (value) {
|
|
274
|
+
const key = p.replace(/^:/, '').replace(/\?$/, '');
|
|
275
|
+
acc[key] = routeConfig?.parse?.[key] ? routeConfig.parse[key](value) : value;
|
|
276
|
+
}
|
|
277
|
+
return acc;
|
|
278
|
+
}, {});
|
|
279
|
+
if (params && Object.keys(params).length) {
|
|
280
|
+
return {
|
|
281
|
+
name,
|
|
282
|
+
params
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
name
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
remainingPath = remainingPath.replace(match[1], '');
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
routes,
|
|
295
|
+
remainingPath
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
const createNormalizedConfigs = (screen, routeConfig, routeNames = [], initials, parentScreens, parentPattern) => {
|
|
299
|
+
const configs = [];
|
|
300
|
+
routeNames.push(screen);
|
|
301
|
+
parentScreens.push(screen);
|
|
302
|
+
|
|
303
|
+
// @ts-expect-error: we can't strongly typecheck this for now
|
|
304
|
+
const config = routeConfig[screen];
|
|
305
|
+
if (typeof config === 'string') {
|
|
306
|
+
// If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern
|
|
307
|
+
const pattern = parentPattern ? joinPaths(parentPattern, config) : config;
|
|
308
|
+
configs.push(createConfigItem(screen, routeNames, pattern, config));
|
|
309
|
+
} else if (typeof config === 'object') {
|
|
310
|
+
let pattern;
|
|
311
|
+
|
|
312
|
+
// if an object is specified as the value (e.g. Foo: { ... }),
|
|
313
|
+
// it can have `path` property and
|
|
314
|
+
// it could have `screens` prop which has nested configs
|
|
315
|
+
if (typeof config.path === 'string') {
|
|
316
|
+
if (config.exact && config.path === undefined) {
|
|
317
|
+
throw new Error("A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.");
|
|
318
|
+
}
|
|
319
|
+
pattern = config.exact !== true ? joinPaths(parentPattern || '', config.path || '') : config.path || '';
|
|
320
|
+
configs.push(createConfigItem(screen, routeNames, pattern, config.path, config.parse));
|
|
321
|
+
}
|
|
322
|
+
if (config.screens) {
|
|
323
|
+
// property `initialRouteName` without `screens` has no purpose
|
|
324
|
+
if (config.initialRouteName) {
|
|
325
|
+
initials.push({
|
|
326
|
+
initialRouteName: config.initialRouteName,
|
|
327
|
+
parentScreens
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
Object.keys(config.screens).forEach(nestedConfig => {
|
|
331
|
+
const result = createNormalizedConfigs(nestedConfig, config.screens, routeNames, initials, [...parentScreens], pattern ?? parentPattern);
|
|
332
|
+
configs.push(...result);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
routeNames.pop();
|
|
337
|
+
return configs;
|
|
338
|
+
};
|
|
339
|
+
const createConfigItem = (screen, routeNames, pattern, path, parse) => {
|
|
340
|
+
// Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.
|
|
341
|
+
pattern = pattern.split('/').filter(Boolean).join('/');
|
|
342
|
+
const regex = pattern ? new RegExp(`^(${pattern.split('/').map(it => {
|
|
343
|
+
if (it.startsWith(':')) {
|
|
344
|
+
return `(([^/]+\\/)${it.endsWith('?') ? '?' : ''})`;
|
|
345
|
+
}
|
|
346
|
+
return `${it === '*' ? '.*' : escape(it)}\\/`;
|
|
347
|
+
}).join('')})`) : undefined;
|
|
348
|
+
return {
|
|
349
|
+
screen,
|
|
350
|
+
regex,
|
|
351
|
+
pattern,
|
|
352
|
+
path,
|
|
353
|
+
// The routeNames array is mutated, so copy it to keep the current state
|
|
354
|
+
routeNames: [...routeNames],
|
|
355
|
+
parse
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
const findParseConfigForRoute = (routeName, flatConfig) => {
|
|
359
|
+
for (const config of flatConfig) {
|
|
360
|
+
if (routeName === config.routeNames[config.routeNames.length - 1]) {
|
|
361
|
+
return config.parse;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return undefined;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// Try to find an initial route connected with the one passed
|
|
368
|
+
const findInitialRoute = (routeName, parentScreens, initialRoutes) => {
|
|
369
|
+
for (const config of initialRoutes) {
|
|
370
|
+
if (parentScreens.length === config.parentScreens.length) {
|
|
371
|
+
let sameParents = true;
|
|
372
|
+
for (let i = 0; i < parentScreens.length; i++) {
|
|
373
|
+
if (parentScreens[i].localeCompare(config.parentScreens[i]) !== 0) {
|
|
374
|
+
sameParents = false;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (sameParents) {
|
|
379
|
+
return routeName !== config.initialRouteName ? config.initialRouteName : undefined;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return undefined;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// returns state object with values depending on whether
|
|
387
|
+
// it is the end of state and if there is initialRoute for this level
|
|
388
|
+
const createStateObject = (initialRoute, route, isEmpty) => {
|
|
389
|
+
if (isEmpty) {
|
|
390
|
+
if (initialRoute) {
|
|
391
|
+
return {
|
|
392
|
+
index: 1,
|
|
393
|
+
routes: [{
|
|
394
|
+
name: initialRoute
|
|
395
|
+
}, route]
|
|
396
|
+
};
|
|
397
|
+
} else {
|
|
398
|
+
return {
|
|
399
|
+
routes: [route]
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
} else {
|
|
403
|
+
if (initialRoute) {
|
|
404
|
+
return {
|
|
405
|
+
index: 1,
|
|
406
|
+
routes: [{
|
|
407
|
+
name: initialRoute
|
|
408
|
+
}, {
|
|
409
|
+
...route,
|
|
410
|
+
state: {
|
|
411
|
+
routes: []
|
|
412
|
+
}
|
|
413
|
+
}]
|
|
414
|
+
};
|
|
415
|
+
} else {
|
|
416
|
+
return {
|
|
417
|
+
routes: [{
|
|
418
|
+
...route,
|
|
419
|
+
state: {
|
|
420
|
+
routes: []
|
|
421
|
+
}
|
|
422
|
+
}]
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
const createNestedStateObject = (path, routes, initialRoutes, flatConfig) => {
|
|
428
|
+
let route = routes.shift();
|
|
429
|
+
const parentScreens = [];
|
|
430
|
+
let initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
|
431
|
+
parentScreens.push(route.name);
|
|
432
|
+
const state = createStateObject(initialRoute, route, routes.length === 0);
|
|
433
|
+
if (routes.length > 0) {
|
|
434
|
+
let nestedState = state;
|
|
435
|
+
while (route = routes.shift()) {
|
|
436
|
+
initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
|
437
|
+
const nestedStateIndex = nestedState.index || nestedState.routes.length - 1;
|
|
438
|
+
nestedState.routes[nestedStateIndex].state = createStateObject(initialRoute, route, routes.length === 0);
|
|
439
|
+
if (routes.length > 0) {
|
|
440
|
+
nestedState = nestedState.routes[nestedStateIndex].state;
|
|
441
|
+
}
|
|
442
|
+
parentScreens.push(route.name);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
route = findFocusedRoute(state);
|
|
446
|
+
route.path = path;
|
|
447
|
+
const params = parseQueryParams(path, flatConfig ? findParseConfigForRoute(route.name, flatConfig) : undefined);
|
|
448
|
+
if (params) {
|
|
449
|
+
route.params = {
|
|
450
|
+
...route.params,
|
|
451
|
+
...params
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
return state;
|
|
455
|
+
};
|
|
456
|
+
const parseQueryParams = (path, parseConfig) => {
|
|
457
|
+
const query = path.split('?')[1];
|
|
458
|
+
const params = queryString.parse(query);
|
|
459
|
+
if (parseConfig) {
|
|
460
|
+
Object.keys(params).forEach(name => {
|
|
461
|
+
if (Object.hasOwnProperty.call(parseConfig, name) && typeof params[name] === 'string') {
|
|
462
|
+
params[name] = parseConfig[name](params[name]);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
return Object.keys(params).length ? params : undefined;
|
|
467
|
+
};
|
|
468
|
+
//# sourceMappingURL=getStateFromPath.js.map
|