@react-navigation/core 6.0.2
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/LICENSE +21 -0
- package/README.md +38 -0
- package/lib/commonjs/BaseNavigationContainer.js +393 -0
- package/lib/commonjs/BaseNavigationContainer.js.map +1 -0
- package/lib/commonjs/CurrentRenderContext.js +21 -0
- package/lib/commonjs/CurrentRenderContext.js.map +1 -0
- package/lib/commonjs/EnsureSingleNavigator.js +53 -0
- package/lib/commonjs/EnsureSingleNavigator.js.map +1 -0
- package/lib/commonjs/Group.js +15 -0
- package/lib/commonjs/Group.js.map +1 -0
- package/lib/commonjs/NavigationBuilderContext.js +23 -0
- package/lib/commonjs/NavigationBuilderContext.js.map +1 -0
- package/lib/commonjs/NavigationContainerRefContext.js +20 -0
- package/lib/commonjs/NavigationContainerRefContext.js.map +1 -0
- package/lib/commonjs/NavigationContext.js +20 -0
- package/lib/commonjs/NavigationContext.js.map +1 -0
- package/lib/commonjs/NavigationHelpersContext.js +21 -0
- package/lib/commonjs/NavigationHelpersContext.js.map +1 -0
- package/lib/commonjs/NavigationRouteContext.js +20 -0
- package/lib/commonjs/NavigationRouteContext.js.map +1 -0
- package/lib/commonjs/NavigationStateContext.js +42 -0
- package/lib/commonjs/NavigationStateContext.js.map +1 -0
- package/lib/commonjs/SceneView.js +97 -0
- package/lib/commonjs/SceneView.js.map +1 -0
- package/lib/commonjs/Screen.js +15 -0
- package/lib/commonjs/Screen.js.map +1 -0
- package/lib/commonjs/StaticContainer.js +43 -0
- package/lib/commonjs/StaticContainer.js.map +1 -0
- package/lib/commonjs/UnhandledActionContext.js +17 -0
- package/lib/commonjs/UnhandledActionContext.js.map +1 -0
- package/lib/commonjs/checkDuplicateRouteNames.js +31 -0
- package/lib/commonjs/checkDuplicateRouteNames.js.map +1 -0
- package/lib/commonjs/checkSerializable.js +59 -0
- package/lib/commonjs/checkSerializable.js.map +1 -0
- package/lib/commonjs/createNavigationContainerRef.js +82 -0
- package/lib/commonjs/createNavigationContainerRef.js.map +1 -0
- package/lib/commonjs/createNavigatorFactory.js +34 -0
- package/lib/commonjs/createNavigatorFactory.js.map +1 -0
- package/lib/commonjs/findFocusedRoute.js +22 -0
- package/lib/commonjs/findFocusedRoute.js.map +1 -0
- package/lib/commonjs/fromEntries.js +19 -0
- package/lib/commonjs/fromEntries.js.map +1 -0
- package/lib/commonjs/getActionFromState.js +99 -0
- package/lib/commonjs/getActionFromState.js.map +1 -0
- package/lib/commonjs/getFocusedRouteNameFromRoute.js +23 -0
- package/lib/commonjs/getFocusedRouteNameFromRoute.js.map +1 -0
- package/lib/commonjs/getPathFromState.js +238 -0
- package/lib/commonjs/getPathFromState.js.map +1 -0
- package/lib/commonjs/getStateFromPath.js +450 -0
- package/lib/commonjs/getStateFromPath.js.map +1 -0
- package/lib/commonjs/index.js +227 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/isArrayEqual.js +15 -0
- package/lib/commonjs/isArrayEqual.js.map +1 -0
- package/lib/commonjs/types.js +18 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/useChildListeners.js +38 -0
- package/lib/commonjs/useChildListeners.js.map +1 -0
- package/lib/commonjs/useComponent.js +36 -0
- package/lib/commonjs/useComponent.js.map +1 -0
- package/lib/commonjs/useCurrentRender.js +33 -0
- package/lib/commonjs/useCurrentRender.js.map +1 -0
- package/lib/commonjs/useDescriptors.js +141 -0
- package/lib/commonjs/useDescriptors.js.map +1 -0
- package/lib/commonjs/useEventEmitter.js +118 -0
- package/lib/commonjs/useEventEmitter.js.map +1 -0
- package/lib/commonjs/useFocusEffect.js +97 -0
- package/lib/commonjs/useFocusEffect.js.map +1 -0
- package/lib/commonjs/useFocusEvents.js +77 -0
- package/lib/commonjs/useFocusEvents.js.map +1 -0
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js +57 -0
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -0
- package/lib/commonjs/useIsFocused.js +47 -0
- package/lib/commonjs/useIsFocused.js.map +1 -0
- package/lib/commonjs/useKeyedChildListeners.js +35 -0
- package/lib/commonjs/useKeyedChildListeners.js.map +1 -0
- package/lib/commonjs/useNavigation.js +36 -0
- package/lib/commonjs/useNavigation.js.map +1 -0
- package/lib/commonjs/useNavigationBuilder.js +480 -0
- package/lib/commonjs/useNavigationBuilder.js.map +1 -0
- package/lib/commonjs/useNavigationCache.js +122 -0
- package/lib/commonjs/useNavigationCache.js.map +1 -0
- package/lib/commonjs/useNavigationContainerRef.js +27 -0
- package/lib/commonjs/useNavigationContainerRef.js.map +1 -0
- package/lib/commonjs/useNavigationHelpers.js +77 -0
- package/lib/commonjs/useNavigationHelpers.js.map +1 -0
- package/lib/commonjs/useNavigationState.js +41 -0
- package/lib/commonjs/useNavigationState.js.map +1 -0
- package/lib/commonjs/useOnAction.js +118 -0
- package/lib/commonjs/useOnAction.js.map +1 -0
- package/lib/commonjs/useOnGetState.js +60 -0
- package/lib/commonjs/useOnGetState.js.map +1 -0
- package/lib/commonjs/useOnPreventRemove.js +89 -0
- package/lib/commonjs/useOnPreventRemove.js.map +1 -0
- package/lib/commonjs/useOnRouteFocus.js +45 -0
- package/lib/commonjs/useOnRouteFocus.js.map +1 -0
- package/lib/commonjs/useOptionsGetters.js +99 -0
- package/lib/commonjs/useOptionsGetters.js.map +1 -0
- package/lib/commonjs/useRegisterNavigator.js +40 -0
- package/lib/commonjs/useRegisterNavigator.js.map +1 -0
- package/lib/commonjs/useRoute.js +32 -0
- package/lib/commonjs/useRoute.js.map +1 -0
- package/lib/commonjs/useRouteCache.js +61 -0
- package/lib/commonjs/useRouteCache.js.map +1 -0
- package/lib/commonjs/useScheduleUpdate.js +44 -0
- package/lib/commonjs/useScheduleUpdate.js.map +1 -0
- package/lib/commonjs/useSyncState.js +76 -0
- package/lib/commonjs/useSyncState.js.map +1 -0
- package/lib/commonjs/validatePathConfig.js +31 -0
- package/lib/commonjs/validatePathConfig.js.map +1 -0
- package/lib/module/BaseNavigationContainer.js +360 -0
- package/lib/module/BaseNavigationContainer.js.map +1 -0
- package/lib/module/CurrentRenderContext.js +9 -0
- package/lib/module/CurrentRenderContext.js.map +1 -0
- package/lib/module/EnsureSingleNavigator.js +38 -0
- package/lib/module/EnsureSingleNavigator.js.map +1 -0
- package/lib/module/Group.js +8 -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/NavigationRouteContext.js +8 -0
- package/lib/module/NavigationRouteContext.js.map +1 -0
- package/lib/module/NavigationStateContext.js +27 -0
- package/lib/module/NavigationStateContext.js.map +1 -0
- package/lib/module/SceneView.js +80 -0
- package/lib/module/SceneView.js.map +1 -0
- package/lib/module/Screen.js +8 -0
- package/lib/module/Screen.js.map +1 -0
- package/lib/module/StaticContainer.js +30 -0
- package/lib/module/StaticContainer.js.map +1 -0
- package/lib/module/UnhandledActionContext.js +4 -0
- package/lib/module/UnhandledActionContext.js.map +1 -0
- package/lib/module/checkDuplicateRouteNames.js +24 -0
- package/lib/module/checkDuplicateRouteNames.js.map +1 -0
- package/lib/module/checkSerializable.js +52 -0
- package/lib/module/checkSerializable.js.map +1 -0
- package/lib/module/createNavigationContainerRef.js +71 -0
- package/lib/module/createNavigationContainerRef.js.map +1 -0
- package/lib/module/createNavigatorFactory.js +24 -0
- package/lib/module/createNavigatorFactory.js.map +1 -0
- package/lib/module/findFocusedRoute.js +15 -0
- package/lib/module/findFocusedRoute.js.map +1 -0
- package/lib/module/fromEntries.js +12 -0
- package/lib/module/fromEntries.js.map +1 -0
- package/lib/module/getActionFromState.js +92 -0
- package/lib/module/getActionFromState.js.map +1 -0
- package/lib/module/getFocusedRouteNameFromRoute.js +15 -0
- package/lib/module/getFocusedRouteNameFromRoute.js.map +1 -0
- package/lib/module/getPathFromState.js +223 -0
- package/lib/module/getPathFromState.js.map +1 -0
- package/lib/module/getStateFromPath.js +434 -0
- package/lib/module/getStateFromPath.js.map +1 -0
- package/lib/module/index.js +24 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/isArrayEqual.js +8 -0
- package/lib/module/isArrayEqual.js.map +1 -0
- package/lib/module/types.js +9 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useChildListeners.js +27 -0
- package/lib/module/useChildListeners.js.map +1 -0
- package/lib/module/useComponent.js +24 -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 +122 -0
- package/lib/module/useDescriptors.js.map +1 -0
- package/lib/module/useEventEmitter.js +107 -0
- package/lib/module/useEventEmitter.js.map +1 -0
- package/lib/module/useFocusEffect.js +83 -0
- package/lib/module/useFocusEffect.js.map +1 -0
- package/lib/module/useFocusEvents.js +63 -0
- package/lib/module/useFocusEvents.js.map +1 -0
- package/lib/module/useFocusedListenersChildrenAdapter.js +43 -0
- package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -0
- package/lib/module/useIsFocused.js +34 -0
- package/lib/module/useIsFocused.js.map +1 -0
- package/lib/module/useKeyedChildListeners.js +24 -0
- package/lib/module/useKeyedChildListeners.js.map +1 -0
- package/lib/module/useNavigation.js +21 -0
- package/lib/module/useNavigation.js.map +1 -0
- package/lib/module/useNavigationBuilder.js +443 -0
- package/lib/module/useNavigationBuilder.js.map +1 -0
- package/lib/module/useNavigationCache.js +107 -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 +59 -0
- package/lib/module/useNavigationHelpers.js.map +1 -0
- package/lib/module/useNavigationState.js +27 -0
- package/lib/module/useNavigationState.js.map +1 -0
- package/lib/module/useOnAction.js +103 -0
- package/lib/module/useOnAction.js.map +1 -0
- package/lib/module/useOnGetState.js +43 -0
- package/lib/module/useOnGetState.js.map +1 -0
- package/lib/module/useOnPreventRemove.js +68 -0
- package/lib/module/useOnPreventRemove.js.map +1 -0
- package/lib/module/useOnRouteFocus.js +31 -0
- package/lib/module/useOnRouteFocus.js.map +1 -0
- package/lib/module/useOptionsGetters.js +83 -0
- package/lib/module/useOptionsGetters.js.map +1 -0
- package/lib/module/useRegisterNavigator.js +27 -0
- package/lib/module/useRegisterNavigator.js.map +1 -0
- package/lib/module/useRoute.js +18 -0
- package/lib/module/useRoute.js.map +1 -0
- package/lib/module/useRouteCache.js +47 -0
- package/lib/module/useRouteCache.js.map +1 -0
- package/lib/module/useScheduleUpdate.js +29 -0
- package/lib/module/useScheduleUpdate.js.map +1 -0
- package/lib/module/useSyncState.js +64 -0
- package/lib/module/useSyncState.js.map +1 -0
- package/lib/module/validatePathConfig.js +24 -0
- package/lib/module/validatePathConfig.js.map +1 -0
- package/lib/typescript/src/BaseNavigationContainer.d.ts +14 -0
- package/lib/typescript/src/CurrentRenderContext.d.ts +9 -0
- package/lib/typescript/src/EnsureSingleNavigator.d.ts +13 -0
- package/lib/typescript/src/Group.d.ts +6 -0
- package/lib/typescript/src/NavigationBuilderContext.d.ts +34 -0
- package/lib/typescript/src/NavigationContainerRefContext.d.ts +8 -0
- package/lib/typescript/src/NavigationContext.d.ts +24 -0
- package/lib/typescript/src/NavigationHelpersContext.d.ts +9 -0
- package/lib/typescript/src/NavigationRouteContext.d.ts +7 -0
- package/lib/typescript/src/NavigationStateContext.d.ts +45 -0
- package/lib/typescript/src/SceneView.d.ts +21 -0
- package/lib/typescript/src/Screen.d.ts +6 -0
- package/lib/typescript/src/StaticContainer.d.ts +7 -0
- package/lib/typescript/src/UnhandledActionContext.d.ts +4 -0
- package/lib/typescript/src/checkDuplicateRouteNames.d.ts +2 -0
- package/lib/typescript/src/checkSerializable.d.ts +9 -0
- package/lib/typescript/src/createNavigationContainerRef.d.ts +3 -0
- package/lib/typescript/src/createNavigatorFactory.d.ts +11 -0
- package/lib/typescript/src/findFocusedRoute.d.ts +22 -0
- package/lib/typescript/src/fromEntries.d.ts +1 -0
- package/lib/typescript/src/getActionFromState.d.ts +16 -0
- package/lib/typescript/src/getFocusedRouteNameFromRoute.d.ts +2 -0
- package/lib/typescript/src/getPathFromState.d.ts +38 -0
- package/lib/typescript/src/getStateFromPath.d.ts +32 -0
- package/lib/typescript/src/index.d.ts +23 -0
- package/lib/typescript/src/isArrayEqual.d.ts +5 -0
- package/lib/typescript/src/types.d.ts +485 -0
- package/lib/typescript/src/useChildListeners.d.ts +11 -0
- package/lib/typescript/src/useComponent.d.ts +2 -0
- package/lib/typescript/src/useCurrentRender.d.ts +13 -0
- package/lib/typescript/src/useDescriptors.d.ts +89 -0
- package/lib/typescript/src/useEventEmitter.d.ts +8 -0
- package/lib/typescript/src/useFocusEffect.d.ts +10 -0
- package/lib/typescript/src/useFocusEvents.d.ts +12 -0
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +12 -0
- package/lib/typescript/src/useIsFocused.d.ts +5 -0
- package/lib/typescript/src/useKeyedChildListeners.d.ts +11 -0
- package/lib/typescript/src/useNavigation.d.ts +7 -0
- package/lib/typescript/src/useNavigationBuilder.d.ts +223 -0
- package/lib/typescript/src/useNavigationCache.d.ts +19 -0
- package/lib/typescript/src/useNavigationContainerRef.d.ts +2 -0
- package/lib/typescript/src/useNavigationHelpers.d.ts +174 -0
- package/lib/typescript/src/useNavigationState.d.ts +9 -0
- package/lib/typescript/src/useOnAction.d.ts +25 -0
- package/lib/typescript/src/useOnGetState.d.ts +8 -0
- package/lib/typescript/src/useOnPreventRemove.d.ts +16 -0
- package/lib/typescript/src/useOnRouteFocus.d.ts +14 -0
- package/lib/typescript/src/useOptionsGetters.d.ts +12 -0
- package/lib/typescript/src/useRegisterNavigator.d.ts +5 -0
- package/lib/typescript/src/useRoute.d.ts +8 -0
- package/lib/typescript/src/useRouteCache.d.ts +13 -0
- package/lib/typescript/src/useScheduleUpdate.d.ts +13 -0
- package/lib/typescript/src/useSyncState.d.ts +4 -0
- package/lib/typescript/src/validatePathConfig.d.ts +1 -0
- package/package.json +73 -0
- package/src/BaseNavigationContainer.tsx +453 -0
- package/src/CurrentRenderContext.tsx +10 -0
- package/src/EnsureSingleNavigator.tsx +53 -0
- package/src/Group.tsx +14 -0
- package/src/NavigationBuilderContext.tsx +70 -0
- package/src/NavigationContainerRefContext.tsx +14 -0
- package/src/NavigationContext.tsx +12 -0
- package/src/NavigationHelpersContext.tsx +13 -0
- package/src/NavigationRouteContext.tsx +10 -0
- package/src/NavigationStateContext.tsx +39 -0
- package/src/SceneView.tsx +134 -0
- package/src/Screen.tsx +17 -0
- package/src/StaticContainer.tsx +29 -0
- package/src/UnhandledActionContext.tsx +9 -0
- package/src/checkDuplicateRouteNames.tsx +33 -0
- package/src/checkSerializable.tsx +74 -0
- package/src/createNavigationContainerRef.tsx +97 -0
- package/src/createNavigatorFactory.tsx +40 -0
- package/src/findFocusedRoute.tsx +13 -0
- package/src/fromEntries.tsx +13 -0
- package/src/getActionFromState.tsx +154 -0
- package/src/getFocusedRouteNameFromRoute.tsx +28 -0
- package/src/getPathFromState.tsx +297 -0
- package/src/getStateFromPath.tsx +575 -0
- package/src/index.tsx +23 -0
- package/src/isArrayEqual.tsx +7 -0
- package/src/types.tsx +645 -0
- package/src/useChildListeners.tsx +37 -0
- package/src/useComponent.tsx +30 -0
- package/src/useCurrentRender.tsx +35 -0
- package/src/useDescriptors.tsx +229 -0
- package/src/useEventEmitter.tsx +130 -0
- package/src/useFocusEffect.tsx +112 -0
- package/src/useFocusEvents.tsx +73 -0
- package/src/useFocusedListenersChildrenAdapter.tsx +47 -0
- package/src/useIsFocused.tsx +43 -0
- package/src/useKeyedChildListeners.tsx +40 -0
- package/src/useNavigation.tsx +26 -0
- package/src/useNavigationBuilder.tsx +640 -0
- package/src/useNavigationCache.tsx +159 -0
- package/src/useNavigationContainerRef.tsx +17 -0
- package/src/useNavigationHelpers.tsx +98 -0
- package/src/useNavigationState.tsx +41 -0
- package/src/useOnAction.tsx +166 -0
- package/src/useOnGetState.tsx +47 -0
- package/src/useOnPreventRemove.tsx +99 -0
- package/src/useOnRouteFocus.tsx +47 -0
- package/src/useOptionsGetters.tsx +98 -0
- package/src/useRegisterNavigator.tsx +29 -0
- package/src/useRoute.tsx +22 -0
- package/src/useRouteCache.tsx +55 -0
- package/src/useScheduleUpdate.tsx +32 -0
- package/src/useSyncState.tsx +74 -0
- package/src/validatePathConfig.tsx +32 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useOnRouteFocus;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Hook to handle focus actions for a route.
|
|
20
|
+
* Focus action needs to be treated specially, coz when a nested route is focused,
|
|
21
|
+
* the parent navigators also needs to be focused.
|
|
22
|
+
*/
|
|
23
|
+
function useOnRouteFocus({
|
|
24
|
+
router,
|
|
25
|
+
getState,
|
|
26
|
+
key: sourceRouteKey,
|
|
27
|
+
setState
|
|
28
|
+
}) {
|
|
29
|
+
const {
|
|
30
|
+
onRouteFocus: onRouteFocusParent
|
|
31
|
+
} = React.useContext(_NavigationBuilderContext.default);
|
|
32
|
+
return React.useCallback(key => {
|
|
33
|
+
const state = getState();
|
|
34
|
+
const result = router.getStateForRouteFocus(state, key);
|
|
35
|
+
|
|
36
|
+
if (result !== state) {
|
|
37
|
+
setState(result);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (onRouteFocusParent !== undefined && sourceRouteKey !== undefined) {
|
|
41
|
+
onRouteFocusParent(sourceRouteKey);
|
|
42
|
+
}
|
|
43
|
+
}, [getState, onRouteFocusParent, router, setState, sourceRouteKey]);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=useOnRouteFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useOnRouteFocus.tsx"],"names":["useOnRouteFocus","router","getState","key","sourceRouteKey","setState","onRouteFocus","onRouteFocusParent","React","useContext","NavigationBuilderContext","useCallback","state","result","getStateForRouteFocus","undefined"],"mappings":";;;;;;;AAKA;;AAEA;;;;;;;;AASA;AACA;AACA;AACA;AACA;AACe,SAASA,eAAT,CAA0D;AACvEC,EAAAA,MADuE;AAEvEC,EAAAA,QAFuE;AAGvEC,EAAAA,GAAG,EAAEC,cAHkE;AAIvEC,EAAAA;AAJuE,CAA1D,EAKK;AAClB,QAAM;AAAEC,IAAAA,YAAY,EAAEC;AAAhB,MAAuCC,KAAK,CAACC,UAAN,CAC3CC,iCAD2C,CAA7C;AAIA,SAAOF,KAAK,CAACG,WAAN,CACJR,GAAD,IAAiB;AACf,UAAMS,KAAK,GAAGV,QAAQ,EAAtB;AACA,UAAMW,MAAM,GAAGZ,MAAM,CAACa,qBAAP,CAA6BF,KAA7B,EAAoCT,GAApC,CAAf;;AAEA,QAAIU,MAAM,KAAKD,KAAf,EAAsB;AACpBP,MAAAA,QAAQ,CAACQ,MAAD,CAAR;AACD;;AAED,QAAIN,kBAAkB,KAAKQ,SAAvB,IAAoCX,cAAc,KAAKW,SAA3D,EAAsE;AACpER,MAAAA,kBAAkB,CAACH,cAAD,CAAlB;AACD;AACF,GAZI,EAaL,CAACF,QAAD,EAAWK,kBAAX,EAA+BN,MAA/B,EAAuCI,QAAvC,EAAiDD,cAAjD,CAbK,CAAP;AAeD","sourcesContent":["import type {\n NavigationAction,\n NavigationState,\n Router,\n} from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationBuilderContext from './NavigationBuilderContext';\n\ntype Options<Action extends NavigationAction> = {\n router: Router<NavigationState, Action>;\n getState: () => NavigationState;\n setState: (state: NavigationState) => void;\n key?: string;\n};\n\n/**\n * Hook to handle focus actions for a route.\n * Focus action needs to be treated specially, coz when a nested route is focused,\n * the parent navigators also needs to be focused.\n */\nexport default function useOnRouteFocus<Action extends NavigationAction>({\n router,\n getState,\n key: sourceRouteKey,\n setState,\n}: Options<Action>) {\n const { onRouteFocus: onRouteFocusParent } = React.useContext(\n NavigationBuilderContext\n );\n\n return React.useCallback(\n (key: string) => {\n const state = getState();\n const result = router.getStateForRouteFocus(state, key);\n\n if (result !== state) {\n setState(result);\n }\n\n if (onRouteFocusParent !== undefined && sourceRouteKey !== undefined) {\n onRouteFocusParent(sourceRouteKey);\n }\n },\n [getState, onRouteFocusParent, router, setState, sourceRouteKey]\n );\n}\n"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useOptionsGetters;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
|
|
11
|
+
|
|
12
|
+
var _NavigationStateContext = _interopRequireDefault(require("./NavigationStateContext"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
function useOptionsGetters({
|
|
21
|
+
key,
|
|
22
|
+
options,
|
|
23
|
+
navigation
|
|
24
|
+
}) {
|
|
25
|
+
const optionsRef = React.useRef(options);
|
|
26
|
+
const optionsGettersFromChildRef = React.useRef({});
|
|
27
|
+
const {
|
|
28
|
+
onOptionsChange
|
|
29
|
+
} = React.useContext(_NavigationBuilderContext.default);
|
|
30
|
+
const {
|
|
31
|
+
addOptionsGetter: parentAddOptionsGetter
|
|
32
|
+
} = React.useContext(_NavigationStateContext.default);
|
|
33
|
+
const optionsChangeListener = React.useCallback(() => {
|
|
34
|
+
var _navigation$isFocused;
|
|
35
|
+
|
|
36
|
+
const isFocused = (_navigation$isFocused = navigation === null || navigation === void 0 ? void 0 : navigation.isFocused()) !== null && _navigation$isFocused !== void 0 ? _navigation$isFocused : true;
|
|
37
|
+
const hasChildren = Object.keys(optionsGettersFromChildRef.current).length;
|
|
38
|
+
|
|
39
|
+
if (isFocused && !hasChildren) {
|
|
40
|
+
var _optionsRef$current;
|
|
41
|
+
|
|
42
|
+
onOptionsChange((_optionsRef$current = optionsRef.current) !== null && _optionsRef$current !== void 0 ? _optionsRef$current : {});
|
|
43
|
+
}
|
|
44
|
+
}, [navigation, onOptionsChange]);
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
optionsRef.current = options;
|
|
47
|
+
optionsChangeListener();
|
|
48
|
+
return navigation === null || navigation === void 0 ? void 0 : navigation.addListener('focus', optionsChangeListener);
|
|
49
|
+
}, [navigation, options, optionsChangeListener]);
|
|
50
|
+
const getOptionsFromListener = React.useCallback(() => {
|
|
51
|
+
for (let key in optionsGettersFromChildRef.current) {
|
|
52
|
+
if (optionsGettersFromChildRef.current.hasOwnProperty(key)) {
|
|
53
|
+
var _optionsGettersFromCh, _optionsGettersFromCh2;
|
|
54
|
+
|
|
55
|
+
const result = (_optionsGettersFromCh = (_optionsGettersFromCh2 = optionsGettersFromChildRef.current)[key]) === null || _optionsGettersFromCh === void 0 ? void 0 : _optionsGettersFromCh.call(_optionsGettersFromCh2); // null means unfocused route
|
|
56
|
+
|
|
57
|
+
if (result !== null) {
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return null;
|
|
64
|
+
}, []);
|
|
65
|
+
const getCurrentOptions = React.useCallback(() => {
|
|
66
|
+
var _navigation$isFocused2;
|
|
67
|
+
|
|
68
|
+
const isFocused = (_navigation$isFocused2 = navigation === null || navigation === void 0 ? void 0 : navigation.isFocused()) !== null && _navigation$isFocused2 !== void 0 ? _navigation$isFocused2 : true;
|
|
69
|
+
|
|
70
|
+
if (!isFocused) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const optionsFromListener = getOptionsFromListener();
|
|
75
|
+
|
|
76
|
+
if (optionsFromListener !== null) {
|
|
77
|
+
return optionsFromListener;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return optionsRef.current;
|
|
81
|
+
}, [navigation, getOptionsFromListener]);
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
return parentAddOptionsGetter === null || parentAddOptionsGetter === void 0 ? void 0 : parentAddOptionsGetter(key, getCurrentOptions);
|
|
84
|
+
}, [getCurrentOptions, parentAddOptionsGetter, key]);
|
|
85
|
+
const addOptionsGetter = React.useCallback((key, getter) => {
|
|
86
|
+
optionsGettersFromChildRef.current[key] = getter;
|
|
87
|
+
optionsChangeListener();
|
|
88
|
+
return () => {
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
90
|
+
delete optionsGettersFromChildRef.current[key];
|
|
91
|
+
optionsChangeListener();
|
|
92
|
+
};
|
|
93
|
+
}, [optionsChangeListener]);
|
|
94
|
+
return {
|
|
95
|
+
addOptionsGetter,
|
|
96
|
+
getCurrentOptions
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=useOptionsGetters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useOptionsGetters.tsx"],"names":["useOptionsGetters","key","options","navigation","optionsRef","React","useRef","optionsGettersFromChildRef","onOptionsChange","useContext","NavigationBuilderContext","addOptionsGetter","parentAddOptionsGetter","NavigationStateContext","optionsChangeListener","useCallback","isFocused","hasChildren","Object","keys","current","length","useEffect","addListener","getOptionsFromListener","hasOwnProperty","result","getCurrentOptions","optionsFromListener","getter"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;;;;;;;AASe,SAASA,iBAAT,CAA2B;AACxCC,EAAAA,GADwC;AAExCC,EAAAA,OAFwC;AAGxCC,EAAAA;AAHwC,CAA3B,EAIH;AACV,QAAMC,UAAU,GAAGC,KAAK,CAACC,MAAN,CAAiCJ,OAAjC,CAAnB;AACA,QAAMK,0BAA0B,GAAGF,KAAK,CAACC,MAAN,CAEjC,EAFiC,CAAnC;AAIA,QAAM;AAAEE,IAAAA;AAAF,MAAsBH,KAAK,CAACI,UAAN,CAAiBC,iCAAjB,CAA5B;AACA,QAAM;AAAEC,IAAAA,gBAAgB,EAAEC;AAApB,MAA+CP,KAAK,CAACI,UAAN,CACnDI,+BADmD,CAArD;AAIA,QAAMC,qBAAqB,GAAGT,KAAK,CAACU,WAAN,CAAkB,MAAM;AAAA;;AACpD,UAAMC,SAAS,4BAAGb,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEa,SAAZ,EAAH,yEAA8B,IAA7C;AACA,UAAMC,WAAW,GAAGC,MAAM,CAACC,IAAP,CAAYZ,0BAA0B,CAACa,OAAvC,EAAgDC,MAApE;;AAEA,QAAIL,SAAS,IAAI,CAACC,WAAlB,EAA+B;AAAA;;AAC7BT,MAAAA,eAAe,wBAACJ,UAAU,CAACgB,OAAZ,qEAAuB,EAAvB,CAAf;AACD;AACF,GAP6B,EAO3B,CAACjB,UAAD,EAAaK,eAAb,CAP2B,CAA9B;AASAH,EAAAA,KAAK,CAACiB,SAAN,CAAgB,MAAM;AACpBlB,IAAAA,UAAU,CAACgB,OAAX,GAAqBlB,OAArB;AACAY,IAAAA,qBAAqB;AAErB,WAAOX,UAAP,aAAOA,UAAP,uBAAOA,UAAU,CAAEoB,WAAZ,CAAwB,OAAxB,EAAiCT,qBAAjC,CAAP;AACD,GALD,EAKG,CAACX,UAAD,EAAaD,OAAb,EAAsBY,qBAAtB,CALH;AAOA,QAAMU,sBAAsB,GAAGnB,KAAK,CAACU,WAAN,CAAkB,MAAM;AACrD,SAAK,IAAId,GAAT,IAAgBM,0BAA0B,CAACa,OAA3C,EAAoD;AAClD,UAAIb,0BAA0B,CAACa,OAA3B,CAAmCK,cAAnC,CAAkDxB,GAAlD,CAAJ,EAA4D;AAAA;;AAC1D,cAAMyB,MAAM,4BAAG,0BAAAnB,0BAA0B,CAACa,OAA3B,EAAmCnB,GAAnC,CAAH,0DAAG,kDAAf,CAD0D,CAG1D;;AACA,YAAIyB,MAAM,KAAK,IAAf,EAAqB;AACnB,iBAAOA,MAAP;AACD;AACF;AACF;;AAED,WAAO,IAAP;AACD,GAb8B,EAa5B,EAb4B,CAA/B;AAeA,QAAMC,iBAAiB,GAAGtB,KAAK,CAACU,WAAN,CAAkB,MAAM;AAAA;;AAChD,UAAMC,SAAS,6BAAGb,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEa,SAAZ,EAAH,2EAA8B,IAA7C;;AAEA,QAAI,CAACA,SAAL,EAAgB;AACd,aAAO,IAAP;AACD;;AAED,UAAMY,mBAAmB,GAAGJ,sBAAsB,EAAlD;;AAEA,QAAII,mBAAmB,KAAK,IAA5B,EAAkC;AAChC,aAAOA,mBAAP;AACD;;AAED,WAAOxB,UAAU,CAACgB,OAAlB;AACD,GAdyB,EAcvB,CAACjB,UAAD,EAAaqB,sBAAb,CAduB,CAA1B;AAgBAnB,EAAAA,KAAK,CAACiB,SAAN,CAAgB,MAAM;AACpB,WAAOV,sBAAP,aAAOA,sBAAP,uBAAOA,sBAAsB,CAAGX,GAAH,EAAS0B,iBAAT,CAA7B;AACD,GAFD,EAEG,CAACA,iBAAD,EAAoBf,sBAApB,EAA4CX,GAA5C,CAFH;AAIA,QAAMU,gBAAgB,GAAGN,KAAK,CAACU,WAAN,CACvB,CAACd,GAAD,EAAc4B,MAAd,KAA0D;AACxDtB,IAAAA,0BAA0B,CAACa,OAA3B,CAAmCnB,GAAnC,IAA0C4B,MAA1C;AACAf,IAAAA,qBAAqB;AAErB,WAAO,MAAM;AACX;AACA,aAAOP,0BAA0B,CAACa,OAA3B,CAAmCnB,GAAnC,CAAP;AACAa,MAAAA,qBAAqB;AACtB,KAJD;AAKD,GAVsB,EAWvB,CAACA,qBAAD,CAXuB,CAAzB;AAcA,SAAO;AACLH,IAAAA,gBADK;AAELgB,IAAAA;AAFK,GAAP;AAID","sourcesContent":["import type { ParamListBase } from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationBuilderContext from './NavigationBuilderContext';\nimport NavigationStateContext from './NavigationStateContext';\nimport type { NavigationProp } from './types';\n\ntype Options = {\n key?: string;\n navigation?: NavigationProp<ParamListBase>;\n options?: object | undefined;\n};\n\nexport default function useOptionsGetters({\n key,\n options,\n navigation,\n}: Options) {\n const optionsRef = React.useRef<object | undefined>(options);\n const optionsGettersFromChildRef = React.useRef<\n Record<string, () => object | undefined | null>\n >({});\n\n const { onOptionsChange } = React.useContext(NavigationBuilderContext);\n const { addOptionsGetter: parentAddOptionsGetter } = React.useContext(\n NavigationStateContext\n );\n\n const optionsChangeListener = React.useCallback(() => {\n const isFocused = navigation?.isFocused() ?? true;\n const hasChildren = Object.keys(optionsGettersFromChildRef.current).length;\n\n if (isFocused && !hasChildren) {\n onOptionsChange(optionsRef.current ?? {});\n }\n }, [navigation, onOptionsChange]);\n\n React.useEffect(() => {\n optionsRef.current = options;\n optionsChangeListener();\n\n return navigation?.addListener('focus', optionsChangeListener);\n }, [navigation, options, optionsChangeListener]);\n\n const getOptionsFromListener = React.useCallback(() => {\n for (let key in optionsGettersFromChildRef.current) {\n if (optionsGettersFromChildRef.current.hasOwnProperty(key)) {\n const result = optionsGettersFromChildRef.current[key]?.();\n\n // null means unfocused route\n if (result !== null) {\n return result;\n }\n }\n }\n\n return null;\n }, []);\n\n const getCurrentOptions = React.useCallback(() => {\n const isFocused = navigation?.isFocused() ?? true;\n\n if (!isFocused) {\n return null;\n }\n\n const optionsFromListener = getOptionsFromListener();\n\n if (optionsFromListener !== null) {\n return optionsFromListener;\n }\n\n return optionsRef.current;\n }, [navigation, getOptionsFromListener]);\n\n React.useEffect(() => {\n return parentAddOptionsGetter?.(key!, getCurrentOptions);\n }, [getCurrentOptions, parentAddOptionsGetter, key]);\n\n const addOptionsGetter = React.useCallback(\n (key: string, getter: () => object | undefined | null) => {\n optionsGettersFromChildRef.current[key] = getter;\n optionsChangeListener();\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete optionsGettersFromChildRef.current[key];\n optionsChangeListener();\n };\n },\n [optionsChangeListener]\n );\n\n return {\n addOptionsGetter,\n getCurrentOptions,\n };\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useRegisterNavigator;
|
|
7
|
+
|
|
8
|
+
var _nonSecure = require("nanoid/non-secure");
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _EnsureSingleNavigator = require("./EnsureSingleNavigator");
|
|
13
|
+
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Register a navigator in the parent context (either a navigation container or a screen).
|
|
20
|
+
* This is used to prevent multiple navigators under a single container or screen.
|
|
21
|
+
*/
|
|
22
|
+
function useRegisterNavigator() {
|
|
23
|
+
const [key] = React.useState(() => (0, _nonSecure.nanoid)());
|
|
24
|
+
const container = React.useContext(_EnsureSingleNavigator.SingleNavigatorContext);
|
|
25
|
+
|
|
26
|
+
if (container === undefined) {
|
|
27
|
+
throw new Error("Couldn't register the navigator. Have you wrapped your app with 'NavigationContainer'?\n\nThis can also happen if there are multiple copies of '@react-navigation' packages installed.");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
const {
|
|
32
|
+
register,
|
|
33
|
+
unregister
|
|
34
|
+
} = container;
|
|
35
|
+
register(key);
|
|
36
|
+
return () => unregister(key);
|
|
37
|
+
}, [container, key]);
|
|
38
|
+
return key;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=useRegisterNavigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useRegisterNavigator.tsx"],"names":["useRegisterNavigator","key","React","useState","container","useContext","SingleNavigatorContext","undefined","Error","useEffect","register","unregister"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;AACA;AACe,SAASA,oBAAT,GAAgC;AAC7C,QAAM,CAACC,GAAD,IAAQC,KAAK,CAACC,QAAN,CAAe,MAAM,wBAArB,CAAd;AACA,QAAMC,SAAS,GAAGF,KAAK,CAACG,UAAN,CAAiBC,6CAAjB,CAAlB;;AAEA,MAAIF,SAAS,KAAKG,SAAlB,EAA6B;AAC3B,UAAM,IAAIC,KAAJ,CACJ,wLADI,CAAN;AAGD;;AAEDN,EAAAA,KAAK,CAACO,SAAN,CAAgB,MAAM;AACpB,UAAM;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QAA2BP,SAAjC;AAEAM,IAAAA,QAAQ,CAACT,GAAD,CAAR;AAEA,WAAO,MAAMU,UAAU,CAACV,GAAD,CAAvB;AACD,GAND,EAMG,CAACG,SAAD,EAAYH,GAAZ,CANH;AAQA,SAAOA,GAAP;AACD","sourcesContent":["import { nanoid } from 'nanoid/non-secure';\nimport * as React from 'react';\n\nimport { SingleNavigatorContext } from './EnsureSingleNavigator';\n\n/**\n * Register a navigator in the parent context (either a navigation container or a screen).\n * This is used to prevent multiple navigators under a single container or screen.\n */\nexport default function useRegisterNavigator() {\n const [key] = React.useState(() => nanoid());\n const container = React.useContext(SingleNavigatorContext);\n\n if (container === undefined) {\n throw new Error(\n \"Couldn't register the navigator. Have you wrapped your app with 'NavigationContainer'?\\n\\nThis can also happen if there are multiple copies of '@react-navigation' packages installed.\"\n );\n }\n\n React.useEffect(() => {\n const { register, unregister } = container;\n\n register(key);\n\n return () => unregister(key);\n }, [container, key]);\n\n return key;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useRoute;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Hook to access the route prop of the parent screen anywhere.
|
|
20
|
+
*
|
|
21
|
+
* @returns Route prop of the parent screen.
|
|
22
|
+
*/
|
|
23
|
+
function useRoute() {
|
|
24
|
+
const route = React.useContext(_NavigationRouteContext.default);
|
|
25
|
+
|
|
26
|
+
if (route === undefined) {
|
|
27
|
+
throw new Error("Couldn't find a route object. Is your component inside a screen in a navigator?");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return route;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=useRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useRoute.tsx"],"names":["useRoute","route","React","useContext","NavigationRouteContext","undefined","Error"],"mappings":";;;;;;;AACA;;AAEA;;;;;;;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,QAAT,GAA2D;AACxE,QAAMC,KAAK,GAAGC,KAAK,CAACC,UAAN,CAAiBC,+BAAjB,CAAd;;AAEA,MAAIH,KAAK,KAAKI,SAAd,EAAyB;AACvB,UAAM,IAAIC,KAAJ,CACJ,iFADI,CAAN;AAGD;;AAED,SAAOL,KAAP;AACD","sourcesContent":["import type { ParamListBase } from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationRouteContext from './NavigationRouteContext';\nimport type { RouteProp } from './types';\n\n/**\n * Hook to access the route prop of the parent screen anywhere.\n *\n * @returns Route prop of the parent screen.\n */\nexport default function useRoute<T extends RouteProp<ParamListBase>>(): T {\n const route = React.useContext(NavigationRouteContext);\n\n if (route === undefined) {\n throw new Error(\n \"Couldn't find a route object. Is your component inside a screen in a navigator?\"\n );\n }\n\n return route as T;\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useRouteCache;
|
|
7
|
+
exports.CHILD_STATE = void 0;
|
|
8
|
+
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Utilites such as `getFocusedRouteNameFromRoute` need to access state.
|
|
17
|
+
* So we need a way to suppress the warning for those use cases.
|
|
18
|
+
* This is fine since they are internal utilities and this is not public API.
|
|
19
|
+
*/
|
|
20
|
+
const CHILD_STATE = Symbol('CHILD_STATE');
|
|
21
|
+
/**
|
|
22
|
+
* Hook to cache route props for each screen in the navigator.
|
|
23
|
+
* This lets add warnings and modifications to the route object but keep references between renders.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
exports.CHILD_STATE = CHILD_STATE;
|
|
27
|
+
|
|
28
|
+
function useRouteCache(routes) {
|
|
29
|
+
// Cache object which holds route objects for each screen
|
|
30
|
+
const cache = React.useMemo(() => ({
|
|
31
|
+
current: new Map()
|
|
32
|
+
}), []);
|
|
33
|
+
|
|
34
|
+
if (process.env.NODE_ENV === 'production') {
|
|
35
|
+
// We don't want the overhead of creating extra maps every render in prod
|
|
36
|
+
return routes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
cache.current = routes.reduce((acc, route) => {
|
|
40
|
+
const previous = cache.current.get(route);
|
|
41
|
+
|
|
42
|
+
if (previous) {
|
|
43
|
+
// If a cached route object already exists, reuse it
|
|
44
|
+
acc.set(route, previous);
|
|
45
|
+
} else {
|
|
46
|
+
const {
|
|
47
|
+
state,
|
|
48
|
+
...proxy
|
|
49
|
+
} = route;
|
|
50
|
+
Object.defineProperty(proxy, CHILD_STATE, {
|
|
51
|
+
enumerable: false,
|
|
52
|
+
value: state
|
|
53
|
+
});
|
|
54
|
+
acc.set(route, proxy);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return acc;
|
|
58
|
+
}, new Map());
|
|
59
|
+
return Array.from(cache.current.values());
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=useRouteCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useRouteCache.tsx"],"names":["CHILD_STATE","Symbol","useRouteCache","routes","cache","React","useMemo","current","Map","process","env","NODE_ENV","reduce","acc","route","previous","get","set","state","proxy","Object","defineProperty","enumerable","value","Array","from","values"],"mappings":";;;;;;;;AAKA;;;;;;AAMA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAGC,MAAM,CAAC,aAAD,CAA1B;AAEP;AACA;AACA;AACA;;;;AACe,SAASC,aAAT,CACbC,MADa,EAEb;AACA;AACA,QAAMC,KAAK,GAAGC,KAAK,CAACC,OAAN,CAAc,OAAO;AAAEC,IAAAA,OAAO,EAAE,IAAIC,GAAJ;AAAX,GAAP,CAAd,EAA4D,EAA5D,CAAd;;AAEA,MAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;AACA,WAAOR,MAAP;AACD;;AAEDC,EAAAA,KAAK,CAACG,OAAN,GAAgBJ,MAAM,CAACS,MAAP,CAAc,CAACC,GAAD,EAAMC,KAAN,KAAgB;AAC5C,UAAMC,QAAQ,GAAGX,KAAK,CAACG,OAAN,CAAcS,GAAd,CAAkBF,KAAlB,CAAjB;;AAEA,QAAIC,QAAJ,EAAc;AACZ;AACAF,MAAAA,GAAG,CAACI,GAAJ,CAAQH,KAAR,EAAeC,QAAf;AACD,KAHD,MAGO;AACL,YAAM;AAAEG,QAAAA,KAAF;AAAS,WAAGC;AAAZ,UAAsBL,KAA5B;AAEAM,MAAAA,MAAM,CAACC,cAAP,CAAsBF,KAAtB,EAA6BnB,WAA7B,EAA0C;AACxCsB,QAAAA,UAAU,EAAE,KAD4B;AAExCC,QAAAA,KAAK,EAAEL;AAFiC,OAA1C;AAKAL,MAAAA,GAAG,CAACI,GAAJ,CAAQH,KAAR,EAAeK,KAAf;AACD;;AAED,WAAON,GAAP;AACD,GAlBe,EAkBb,IAAIL,GAAJ,EAlBa,CAAhB;AAoBA,SAAOgB,KAAK,CAACC,IAAN,CAAWrB,KAAK,CAACG,OAAN,CAAcmB,MAAd,EAAX,CAAP;AACD","sourcesContent":["import type {\n NavigationState,\n ParamListBase,\n Route,\n} from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport type { RouteProp } from './types';\n\ntype RouteCache = Map<Route<string>, RouteProp<ParamListBase>>;\n\n/**\n * Utilites such as `getFocusedRouteNameFromRoute` need to access state.\n * So we need a way to suppress the warning for those use cases.\n * This is fine since they are internal utilities and this is not public API.\n */\nexport const CHILD_STATE = Symbol('CHILD_STATE');\n\n/**\n * Hook to cache route props for each screen in the navigator.\n * This lets add warnings and modifications to the route object but keep references between renders.\n */\nexport default function useRouteCache<State extends NavigationState>(\n routes: State['routes']\n) {\n // Cache object which holds route objects for each screen\n const cache = React.useMemo(() => ({ current: new Map() as RouteCache }), []);\n\n if (process.env.NODE_ENV === 'production') {\n // We don't want the overhead of creating extra maps every render in prod\n return routes;\n }\n\n cache.current = routes.reduce((acc, route) => {\n const previous = cache.current.get(route);\n\n if (previous) {\n // If a cached route object already exists, reuse it\n acc.set(route, previous);\n } else {\n const { state, ...proxy } = route;\n\n Object.defineProperty(proxy, CHILD_STATE, {\n enumerable: false,\n value: state,\n });\n\n acc.set(route, proxy);\n }\n\n return acc;\n }, new Map() as RouteCache);\n\n return Array.from(cache.current.values());\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useScheduleUpdate;
|
|
7
|
+
exports.ScheduleUpdateContext = void 0;
|
|
8
|
+
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
|
|
15
|
+
const MISSING_CONTEXT_ERROR = "Couldn't find a schedule context.";
|
|
16
|
+
const ScheduleUpdateContext = /*#__PURE__*/React.createContext({
|
|
17
|
+
scheduleUpdate() {
|
|
18
|
+
throw new Error(MISSING_CONTEXT_ERROR);
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
flushUpdates() {
|
|
22
|
+
throw new Error(MISSING_CONTEXT_ERROR);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* When screen config changes, we want to update the navigator in the same update phase.
|
|
28
|
+
* However, navigation state is in the root component and React won't let us update it from a child.
|
|
29
|
+
* This is a workaround for that, the scheduled update is stored in the ref without actually calling setState.
|
|
30
|
+
* It lets all subsequent updates access the latest state so it stays correct.
|
|
31
|
+
* Then we call setState during after the component updates.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
exports.ScheduleUpdateContext = ScheduleUpdateContext;
|
|
35
|
+
|
|
36
|
+
function useScheduleUpdate(callback) {
|
|
37
|
+
const {
|
|
38
|
+
scheduleUpdate,
|
|
39
|
+
flushUpdates
|
|
40
|
+
} = React.useContext(ScheduleUpdateContext);
|
|
41
|
+
scheduleUpdate(callback);
|
|
42
|
+
React.useEffect(flushUpdates);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=useScheduleUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useScheduleUpdate.tsx"],"names":["MISSING_CONTEXT_ERROR","ScheduleUpdateContext","React","createContext","scheduleUpdate","Error","flushUpdates","useScheduleUpdate","callback","useContext","useEffect"],"mappings":";;;;;;;;AAAA;;;;;;AAEA,MAAMA,qBAAqB,GAAG,mCAA9B;AAEO,MAAMC,qBAAqB,gBAAGC,KAAK,CAACC,aAAN,CAGlC;AACDC,EAAAA,cAAc,GAAG;AACf,UAAM,IAAIC,KAAJ,CAAUL,qBAAV,CAAN;AACD,GAHA;;AAIDM,EAAAA,YAAY,GAAG;AACb,UAAM,IAAID,KAAJ,CAAUL,qBAAV,CAAN;AACD;;AANA,CAHkC,CAA9B;AAYP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACe,SAASO,iBAAT,CAA2BC,QAA3B,EAAiD;AAC9D,QAAM;AAAEJ,IAAAA,cAAF;AAAkBE,IAAAA;AAAlB,MAAmCJ,KAAK,CAACO,UAAN,CACvCR,qBADuC,CAAzC;AAIAG,EAAAA,cAAc,CAACI,QAAD,CAAd;AAEAN,EAAAA,KAAK,CAACQ,SAAN,CAAgBJ,YAAhB;AACD","sourcesContent":["import * as React from 'react';\n\nconst MISSING_CONTEXT_ERROR = \"Couldn't find a schedule context.\";\n\nexport const ScheduleUpdateContext = React.createContext<{\n scheduleUpdate: (callback: () => void) => void;\n flushUpdates: () => void;\n}>({\n scheduleUpdate() {\n throw new Error(MISSING_CONTEXT_ERROR);\n },\n flushUpdates() {\n throw new Error(MISSING_CONTEXT_ERROR);\n },\n});\n\n/**\n * When screen config changes, we want to update the navigator in the same update phase.\n * However, navigation state is in the root component and React won't let us update it from a child.\n * This is a workaround for that, the scheduled update is stored in the ref without actually calling setState.\n * It lets all subsequent updates access the latest state so it stays correct.\n * Then we call setState during after the component updates.\n */\nexport default function useScheduleUpdate(callback: () => void) {\n const { scheduleUpdate, flushUpdates } = React.useContext(\n ScheduleUpdateContext\n );\n\n scheduleUpdate(callback);\n\n React.useEffect(flushUpdates);\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useSyncState;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
|
|
14
|
+
const UNINTIALIZED_STATE = {};
|
|
15
|
+
/**
|
|
16
|
+
* This is definitely not compatible with concurrent mode, but we don't have a solution for sync state yet.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
function useSyncState(initialState) {
|
|
20
|
+
const stateRef = React.useRef(UNINTIALIZED_STATE);
|
|
21
|
+
const isSchedulingRef = React.useRef(false);
|
|
22
|
+
const isMountedRef = React.useRef(true);
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
isMountedRef.current = true;
|
|
25
|
+
return () => {
|
|
26
|
+
isMountedRef.current = false;
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
if (stateRef.current === UNINTIALIZED_STATE) {
|
|
31
|
+
stateRef.current = // @ts-expect-error: initialState is a function, but TypeScript doesn't think so
|
|
32
|
+
typeof initialState === 'function' ? initialState() : initialState;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const [trackingState, setTrackingState] = React.useState(stateRef.current);
|
|
36
|
+
const getState = React.useCallback(() => stateRef.current, []);
|
|
37
|
+
const setState = React.useCallback(state => {
|
|
38
|
+
if (state === stateRef.current || !isMountedRef.current) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
stateRef.current = state;
|
|
43
|
+
|
|
44
|
+
if (!isSchedulingRef.current) {
|
|
45
|
+
setTrackingState(state);
|
|
46
|
+
}
|
|
47
|
+
}, []);
|
|
48
|
+
const scheduleUpdate = React.useCallback(callback => {
|
|
49
|
+
isSchedulingRef.current = true;
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
callback();
|
|
53
|
+
} finally {
|
|
54
|
+
isSchedulingRef.current = false;
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
const flushUpdates = React.useCallback(() => {
|
|
58
|
+
if (!isMountedRef.current) {
|
|
59
|
+
return;
|
|
60
|
+
} // Make sure that the tracking state is up-to-date.
|
|
61
|
+
// We call it unconditionally, but React should skip the update if state is unchanged.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
setTrackingState(stateRef.current);
|
|
65
|
+
}, []); // If we're rendering and the tracking state is out of date, update it immediately
|
|
66
|
+
// This will make sure that our updates are applied as early as possible.
|
|
67
|
+
|
|
68
|
+
if (trackingState !== stateRef.current) {
|
|
69
|
+
setTrackingState(stateRef.current);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const state = stateRef.current;
|
|
73
|
+
React.useDebugValue(state);
|
|
74
|
+
return [state, getState, setState, scheduleUpdate, flushUpdates];
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=useSyncState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useSyncState.tsx"],"names":["UNINTIALIZED_STATE","useSyncState","initialState","stateRef","React","useRef","isSchedulingRef","isMountedRef","useEffect","current","trackingState","setTrackingState","useState","getState","useCallback","setState","state","scheduleUpdate","callback","flushUpdates","useDebugValue"],"mappings":";;;;;;;AAAA;;;;;;AAEA,MAAMA,kBAAkB,GAAG,EAA3B;AAEA;AACA;AACA;;AACe,SAASC,YAAT,CAAyBC,YAAzB,EAAuD;AACpE,QAAMC,QAAQ,GAAGC,KAAK,CAACC,MAAN,CAAgBL,kBAAhB,CAAjB;AACA,QAAMM,eAAe,GAAGF,KAAK,CAACC,MAAN,CAAa,KAAb,CAAxB;AACA,QAAME,YAAY,GAAGH,KAAK,CAACC,MAAN,CAAa,IAAb,CAArB;AAEAD,EAAAA,KAAK,CAACI,SAAN,CAAgB,MAAM;AACpBD,IAAAA,YAAY,CAACE,OAAb,GAAuB,IAAvB;AAEA,WAAO,MAAM;AACXF,MAAAA,YAAY,CAACE,OAAb,GAAuB,KAAvB;AACD,KAFD;AAGD,GAND,EAMG,EANH;;AAQA,MAAIN,QAAQ,CAACM,OAAT,KAAqBT,kBAAzB,EAA6C;AAC3CG,IAAAA,QAAQ,CAACM,OAAT,GACE;AACA,WAAOP,YAAP,KAAwB,UAAxB,GAAqCA,YAAY,EAAjD,GAAsDA,YAFxD;AAGD;;AAED,QAAM,CAACQ,aAAD,EAAgBC,gBAAhB,IAAoCP,KAAK,CAACQ,QAAN,CAAeT,QAAQ,CAACM,OAAxB,CAA1C;AAEA,QAAMI,QAAQ,GAAGT,KAAK,CAACU,WAAN,CAAkB,MAAMX,QAAQ,CAACM,OAAjC,EAA0C,EAA1C,CAAjB;AAEA,QAAMM,QAAQ,GAAGX,KAAK,CAACU,WAAN,CAAmBE,KAAD,IAAc;AAC/C,QAAIA,KAAK,KAAKb,QAAQ,CAACM,OAAnB,IAA8B,CAACF,YAAY,CAACE,OAAhD,EAAyD;AACvD;AACD;;AAEDN,IAAAA,QAAQ,CAACM,OAAT,GAAmBO,KAAnB;;AAEA,QAAI,CAACV,eAAe,CAACG,OAArB,EAA8B;AAC5BE,MAAAA,gBAAgB,CAACK,KAAD,CAAhB;AACD;AACF,GAVgB,EAUd,EAVc,CAAjB;AAYA,QAAMC,cAAc,GAAGb,KAAK,CAACU,WAAN,CAAmBI,QAAD,IAA0B;AACjEZ,IAAAA,eAAe,CAACG,OAAhB,GAA0B,IAA1B;;AAEA,QAAI;AACFS,MAAAA,QAAQ;AACT,KAFD,SAEU;AACRZ,MAAAA,eAAe,CAACG,OAAhB,GAA0B,KAA1B;AACD;AACF,GARsB,EAQpB,EARoB,CAAvB;AAUA,QAAMU,YAAY,GAAGf,KAAK,CAACU,WAAN,CAAkB,MAAM;AAC3C,QAAI,CAACP,YAAY,CAACE,OAAlB,EAA2B;AACzB;AACD,KAH0C,CAK3C;AACA;;;AACAE,IAAAA,gBAAgB,CAACR,QAAQ,CAACM,OAAV,CAAhB;AACD,GARoB,EAQlB,EARkB,CAArB,CA7CoE,CAuDpE;AACA;;AACA,MAAIC,aAAa,KAAKP,QAAQ,CAACM,OAA/B,EAAwC;AACtCE,IAAAA,gBAAgB,CAACR,QAAQ,CAACM,OAAV,CAAhB;AACD;;AAED,QAAMO,KAAK,GAAGb,QAAQ,CAACM,OAAvB;AAEAL,EAAAA,KAAK,CAACgB,aAAN,CAAoBJ,KAApB;AAEA,SAAO,CAACA,KAAD,EAAQH,QAAR,EAAkBE,QAAlB,EAA4BE,cAA5B,EAA4CE,YAA5C,CAAP;AACD","sourcesContent":["import * as React from 'react';\n\nconst UNINTIALIZED_STATE = {};\n\n/**\n * This is definitely not compatible with concurrent mode, but we don't have a solution for sync state yet.\n */\nexport default function useSyncState<T>(initialState?: (() => T) | T) {\n const stateRef = React.useRef<T>(UNINTIALIZED_STATE as any);\n const isSchedulingRef = React.useRef(false);\n const isMountedRef = React.useRef(true);\n\n React.useEffect(() => {\n isMountedRef.current = true;\n\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n if (stateRef.current === UNINTIALIZED_STATE) {\n stateRef.current =\n // @ts-expect-error: initialState is a function, but TypeScript doesn't think so\n typeof initialState === 'function' ? initialState() : initialState;\n }\n\n const [trackingState, setTrackingState] = React.useState(stateRef.current);\n\n const getState = React.useCallback(() => stateRef.current, []);\n\n const setState = React.useCallback((state: T) => {\n if (state === stateRef.current || !isMountedRef.current) {\n return;\n }\n\n stateRef.current = state;\n\n if (!isSchedulingRef.current) {\n setTrackingState(state);\n }\n }, []);\n\n const scheduleUpdate = React.useCallback((callback: () => void) => {\n isSchedulingRef.current = true;\n\n try {\n callback();\n } finally {\n isSchedulingRef.current = false;\n }\n }, []);\n\n const flushUpdates = React.useCallback(() => {\n if (!isMountedRef.current) {\n return;\n }\n\n // Make sure that the tracking state is up-to-date.\n // We call it unconditionally, but React should skip the update if state is unchanged.\n setTrackingState(stateRef.current);\n }, []);\n\n // If we're rendering and the tracking state is out of date, update it immediately\n // This will make sure that our updates are applied as early as possible.\n if (trackingState !== stateRef.current) {\n setTrackingState(stateRef.current);\n }\n\n const state = stateRef.current;\n\n React.useDebugValue(state);\n\n return [state, getState, setState, scheduleUpdate, flushUpdates] as const;\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = validatePathConfig;
|
|
7
|
+
|
|
8
|
+
const formatToList = items => items.map(key => `- ${key}`).join('\n');
|
|
9
|
+
|
|
10
|
+
function validatePathConfig(config, root = true) {
|
|
11
|
+
const validKeys = ['initialRouteName', 'screens'];
|
|
12
|
+
|
|
13
|
+
if (!root) {
|
|
14
|
+
validKeys.push('path', 'exact', 'stringify', 'parse');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const invalidKeys = Object.keys(config).filter(key => !validKeys.includes(key));
|
|
18
|
+
|
|
19
|
+
if (invalidKeys.length) {
|
|
20
|
+
throw new Error(`Found invalid properties in the configuration:\n${formatToList(invalidKeys)}\n\nDid you forget to specify them under a 'screens' property?\n\nYou can only specify the following properties:\n${formatToList(validKeys)}\n\nSee https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (config.screens) {
|
|
24
|
+
Object.entries(config.screens).forEach(([_, value]) => {
|
|
25
|
+
if (typeof value !== 'string') {
|
|
26
|
+
validatePathConfig(value, false);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=validatePathConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["validatePathConfig.tsx"],"names":["formatToList","items","map","key","join","validatePathConfig","config","root","validKeys","push","invalidKeys","Object","keys","filter","includes","length","Error","screens","entries","forEach","_","value"],"mappings":";;;;;;;AAAA,MAAMA,YAAY,GAAIC,KAAD,IACnBA,KAAK,CAACC,GAAN,CAAWC,GAAD,IAAU,KAAIA,GAAI,EAA5B,EAA+BC,IAA/B,CAAoC,IAApC,CADF;;AAGe,SAASC,kBAAT,CAA4BC,MAA5B,EAAyCC,IAAI,GAAG,IAAhD,EAAsD;AACnE,QAAMC,SAAS,GAAG,CAAC,kBAAD,EAAqB,SAArB,CAAlB;;AAEA,MAAI,CAACD,IAAL,EAAW;AACTC,IAAAA,SAAS,CAACC,IAAV,CAAe,MAAf,EAAuB,OAAvB,EAAgC,WAAhC,EAA6C,OAA7C;AACD;;AAED,QAAMC,WAAW,GAAGC,MAAM,CAACC,IAAP,CAAYN,MAAZ,EAAoBO,MAApB,CACjBV,GAAD,IAAS,CAACK,SAAS,CAACM,QAAV,CAAmBX,GAAnB,CADQ,CAApB;;AAIA,MAAIO,WAAW,CAACK,MAAhB,EAAwB;AACtB,UAAM,IAAIC,KAAJ,CACH,mDAAkDhB,YAAY,CAC7DU,WAD6D,CAE7D,qHAAoHV,YAAY,CAChIQ,SADgI,CAEhI,wHALE,CAAN;AAOD;;AAED,MAAIF,MAAM,CAACW,OAAX,EAAoB;AAClBN,IAAAA,MAAM,CAACO,OAAP,CAAeZ,MAAM,CAACW,OAAtB,EAA+BE,OAA/B,CAAuC,CAAC,CAACC,CAAD,EAAIC,KAAJ,CAAD,KAAgB;AACrD,UAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAC7BhB,QAAAA,kBAAkB,CAACgB,KAAD,EAAQ,KAAR,CAAlB;AACD;AACF,KAJD;AAKD;AACF","sourcesContent":["const formatToList = (items: string[]) =>\n items.map((key) => `- ${key}`).join('\\n');\n\nexport default function validatePathConfig(config: any, root = true) {\n const validKeys = ['initialRouteName', 'screens'];\n\n if (!root) {\n validKeys.push('path', 'exact', 'stringify', 'parse');\n }\n\n const invalidKeys = Object.keys(config).filter(\n (key) => !validKeys.includes(key)\n );\n\n if (invalidKeys.length) {\n throw new Error(\n `Found invalid properties in the configuration:\\n${formatToList(\n invalidKeys\n )}\\n\\nDid you forget to specify them under a 'screens' property?\\n\\nYou can only specify the following properties:\\n${formatToList(\n validKeys\n )}\\n\\nSee https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`\n );\n }\n\n if (config.screens) {\n Object.entries(config.screens).forEach(([_, value]) => {\n if (typeof value !== 'string') {\n validatePathConfig(value, false);\n }\n });\n }\n}\n"]}
|