@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,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
BaseNavigationContainer: true,
|
|
8
|
+
createNavigationContainerRef: true,
|
|
9
|
+
createNavigatorFactory: true,
|
|
10
|
+
CurrentRenderContext: true,
|
|
11
|
+
findFocusedRoute: true,
|
|
12
|
+
getActionFromState: true,
|
|
13
|
+
getFocusedRouteNameFromRoute: true,
|
|
14
|
+
getPathFromState: true,
|
|
15
|
+
getStateFromPath: true,
|
|
16
|
+
NavigationContainerRefContext: true,
|
|
17
|
+
NavigationContext: true,
|
|
18
|
+
NavigationHelpersContext: true,
|
|
19
|
+
NavigationRouteContext: true,
|
|
20
|
+
useFocusEffect: true,
|
|
21
|
+
useIsFocused: true,
|
|
22
|
+
useNavigation: true,
|
|
23
|
+
useNavigationBuilder: true,
|
|
24
|
+
useNavigationContainerRef: true,
|
|
25
|
+
useNavigationState: true,
|
|
26
|
+
useRoute: true,
|
|
27
|
+
validatePathConfig: true
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "BaseNavigationContainer", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return _BaseNavigationContainer.default;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "createNavigationContainerRef", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () {
|
|
38
|
+
return _createNavigationContainerRef.default;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "createNavigatorFactory", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () {
|
|
44
|
+
return _createNavigatorFactory.default;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "CurrentRenderContext", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () {
|
|
50
|
+
return _CurrentRenderContext.default;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(exports, "findFocusedRoute", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () {
|
|
56
|
+
return _findFocusedRoute.default;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, "getActionFromState", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () {
|
|
62
|
+
return _getActionFromState.default;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(exports, "getFocusedRouteNameFromRoute", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _getFocusedRouteNameFromRoute.default;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, "getPathFromState", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () {
|
|
74
|
+
return _getPathFromState.default;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, "getStateFromPath", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () {
|
|
80
|
+
return _getStateFromPath.default;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(exports, "NavigationContainerRefContext", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () {
|
|
86
|
+
return _NavigationContainerRefContext.default;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "NavigationContext", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return _NavigationContext.default;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, "NavigationHelpersContext", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () {
|
|
98
|
+
return _NavigationHelpersContext.default;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "NavigationRouteContext", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return _NavigationRouteContext.default;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, "useFocusEffect", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () {
|
|
110
|
+
return _useFocusEffect.default;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, "useIsFocused", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return _useIsFocused.default;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(exports, "useNavigation", {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function () {
|
|
122
|
+
return _useNavigation.default;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(exports, "useNavigationBuilder", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () {
|
|
128
|
+
return _useNavigationBuilder.default;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(exports, "useNavigationContainerRef", {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return _useNavigationContainerRef.default;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(exports, "useNavigationState", {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function () {
|
|
140
|
+
return _useNavigationState.default;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(exports, "useRoute", {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function () {
|
|
146
|
+
return _useRoute.default;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(exports, "validatePathConfig", {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function () {
|
|
152
|
+
return _validatePathConfig.default;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
var _BaseNavigationContainer = _interopRequireDefault(require("./BaseNavigationContainer"));
|
|
157
|
+
|
|
158
|
+
var _createNavigationContainerRef = _interopRequireDefault(require("./createNavigationContainerRef"));
|
|
159
|
+
|
|
160
|
+
var _createNavigatorFactory = _interopRequireDefault(require("./createNavigatorFactory"));
|
|
161
|
+
|
|
162
|
+
var _CurrentRenderContext = _interopRequireDefault(require("./CurrentRenderContext"));
|
|
163
|
+
|
|
164
|
+
var _findFocusedRoute = _interopRequireDefault(require("./findFocusedRoute"));
|
|
165
|
+
|
|
166
|
+
var _getActionFromState = _interopRequireDefault(require("./getActionFromState"));
|
|
167
|
+
|
|
168
|
+
var _getFocusedRouteNameFromRoute = _interopRequireDefault(require("./getFocusedRouteNameFromRoute"));
|
|
169
|
+
|
|
170
|
+
var _getPathFromState = _interopRequireDefault(require("./getPathFromState"));
|
|
171
|
+
|
|
172
|
+
var _getStateFromPath = _interopRequireDefault(require("./getStateFromPath"));
|
|
173
|
+
|
|
174
|
+
var _NavigationContainerRefContext = _interopRequireDefault(require("./NavigationContainerRefContext"));
|
|
175
|
+
|
|
176
|
+
var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
|
|
177
|
+
|
|
178
|
+
var _NavigationHelpersContext = _interopRequireDefault(require("./NavigationHelpersContext"));
|
|
179
|
+
|
|
180
|
+
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
|
|
181
|
+
|
|
182
|
+
var _types = require("./types");
|
|
183
|
+
|
|
184
|
+
Object.keys(_types).forEach(function (key) {
|
|
185
|
+
if (key === "default" || key === "__esModule") return;
|
|
186
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
187
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
188
|
+
Object.defineProperty(exports, key, {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function () {
|
|
191
|
+
return _types[key];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
var _useFocusEffect = _interopRequireDefault(require("./useFocusEffect"));
|
|
197
|
+
|
|
198
|
+
var _useIsFocused = _interopRequireDefault(require("./useIsFocused"));
|
|
199
|
+
|
|
200
|
+
var _useNavigation = _interopRequireDefault(require("./useNavigation"));
|
|
201
|
+
|
|
202
|
+
var _useNavigationBuilder = _interopRequireDefault(require("./useNavigationBuilder"));
|
|
203
|
+
|
|
204
|
+
var _useNavigationContainerRef = _interopRequireDefault(require("./useNavigationContainerRef"));
|
|
205
|
+
|
|
206
|
+
var _useNavigationState = _interopRequireDefault(require("./useNavigationState"));
|
|
207
|
+
|
|
208
|
+
var _useRoute = _interopRequireDefault(require("./useRoute"));
|
|
209
|
+
|
|
210
|
+
var _validatePathConfig = _interopRequireDefault(require("./validatePathConfig"));
|
|
211
|
+
|
|
212
|
+
var _routers = require("@react-navigation/routers");
|
|
213
|
+
|
|
214
|
+
Object.keys(_routers).forEach(function (key) {
|
|
215
|
+
if (key === "default" || key === "__esModule") return;
|
|
216
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
217
|
+
if (key in exports && exports[key] === _routers[key]) return;
|
|
218
|
+
Object.defineProperty(exports, key, {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function () {
|
|
221
|
+
return _routers[key];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
227
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export { default as BaseNavigationContainer } from './BaseNavigationContainer';\nexport { default as createNavigationContainerRef } from './createNavigationContainerRef';\nexport { default as createNavigatorFactory } from './createNavigatorFactory';\nexport { default as CurrentRenderContext } from './CurrentRenderContext';\nexport { default as findFocusedRoute } from './findFocusedRoute';\nexport { default as getActionFromState } from './getActionFromState';\nexport { default as getFocusedRouteNameFromRoute } from './getFocusedRouteNameFromRoute';\nexport { default as getPathFromState } from './getPathFromState';\nexport { default as getStateFromPath } from './getStateFromPath';\nexport { default as NavigationContainerRefContext } from './NavigationContainerRefContext';\nexport { default as NavigationContext } from './NavigationContext';\nexport { default as NavigationHelpersContext } from './NavigationHelpersContext';\nexport { default as NavigationRouteContext } from './NavigationRouteContext';\nexport * from './types';\nexport { default as useFocusEffect } from './useFocusEffect';\nexport { default as useIsFocused } from './useIsFocused';\nexport { default as useNavigation } from './useNavigation';\nexport { default as useNavigationBuilder } from './useNavigationBuilder';\nexport { default as useNavigationContainerRef } from './useNavigationContainerRef';\nexport { default as useNavigationState } from './useNavigationState';\nexport { default as useRoute } from './useRoute';\nexport { default as validatePathConfig } from './validatePathConfig';\nexport * from '@react-navigation/routers';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = isArrayEqual;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Compare two arrays with primitive values as the content.
|
|
10
|
+
* We need to make sure that both values and order match.
|
|
11
|
+
*/
|
|
12
|
+
function isArrayEqual(a, b) {
|
|
13
|
+
return a.length === b.length && a.every((it, index) => it === b[index]);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=isArrayEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["isArrayEqual.tsx"],"names":["isArrayEqual","a","b","length","every","it","index"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAsBC,CAAtB,EAAgCC,CAAhC,EAA0C;AACvD,SAAOD,CAAC,CAACE,MAAF,KAAaD,CAAC,CAACC,MAAf,IAAyBF,CAAC,CAACG,KAAF,CAAQ,CAACC,EAAD,EAAKC,KAAL,KAAeD,EAAE,KAAKH,CAAC,CAACI,KAAD,CAA/B,CAAhC;AACD","sourcesContent":["/**\n * Compare two arrays with primitive values as the content.\n * We need to make sure that both values and order match.\n */\nexport default function isArrayEqual(a: any[], b: any[]) {\n return a.length === b.length && a.every((it, index) => it === b[index]);\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PrivateValueStore = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
class PrivateValueStore {
|
|
11
|
+
constructor() {
|
|
12
|
+
_defineProperty(this, '', void 0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.PrivateValueStore = PrivateValueStore;
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["types.tsx"],"names":["PrivateValueStore"],"mappings":";;;;;;;;;AA2JO,MAAMA,iBAAN,CAAiC;AAAA;AAAA,0BAW5B,EAX4B;AAAA;;AAAA","sourcesContent":["import type {\n DefaultRouterOptions,\n InitialState,\n NavigationAction,\n NavigationState,\n ParamListBase,\n PartialState,\n Route,\n} from '@react-navigation/routers';\nimport type * as React from 'react';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace ReactNavigation {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface RootParamList {}\n }\n}\n\ntype Keyof<T extends {}> = Extract<keyof T, string>;\n\nexport type DefaultNavigatorOptions<\n ParamList extends ParamListBase,\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n> = DefaultRouterOptions<Keyof<ParamList>> & {\n /**\n * Children React Elements to extract the route configuration from.\n * Only `Screen`, `Group` and `React.Fragment` are supported as children.\n */\n children: React.ReactNode;\n /**\n * Event listeners for all the screens in the navigator.\n */\n screenListeners?:\n | ScreenListeners<State, EventMap>\n | ((props: {\n route: RouteProp<ParamList>;\n navigation: any;\n }) => ScreenListeners<State, EventMap>);\n /**\n * Default options for all screens under this navigator.\n */\n screenOptions?:\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamList>;\n navigation: any;\n }) => ScreenOptions);\n /**\n * Default options specified by the navigator.\n * It receives the custom options in the arguments if a function is specified.\n */\n defaultScreenOptions?:\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamList>;\n navigation: any;\n options: ScreenOptions;\n }) => ScreenOptions);\n};\n\nexport type EventMapBase = Record<\n string,\n { data?: any; canPreventDefault?: boolean }\n>;\n\nexport type EventMapCore<State extends NavigationState> = {\n focus: { data: undefined };\n blur: { data: undefined };\n state: { data: { state: State } };\n beforeRemove: { data: { action: NavigationAction }; canPreventDefault: true };\n};\n\nexport type EventArg<\n EventName extends string,\n CanPreventDefault extends boolean | undefined = false,\n Data = undefined\n> = {\n /**\n * Type of the event (e.g. `focus`, `blur`)\n */\n readonly type: EventName;\n readonly target?: string;\n} & (CanPreventDefault extends true\n ? {\n /**\n * Whether `event.preventDefault()` was called on this event object.\n */\n readonly defaultPrevented: boolean;\n /**\n * Prevent the default action which happens on this event.\n */\n preventDefault(): void;\n }\n : {}) &\n (undefined extends Data\n ? { readonly data?: Readonly<Data> }\n : { readonly data: Readonly<Data> });\n\nexport type EventListenerCallback<\n EventMap extends EventMapBase,\n EventName extends keyof EventMap\n> = (\n e: EventArg<\n Extract<EventName, string>,\n EventMap[EventName]['canPreventDefault'],\n EventMap[EventName]['data']\n >\n) => void;\n\nexport type EventConsumer<EventMap extends EventMapBase> = {\n /**\n * Subscribe to events from the parent navigator.\n *\n * @param type Type of the event (e.g. `focus`, `blur`)\n * @param callback Callback listener which is executed upon receiving the event.\n */\n addListener<EventName extends Keyof<EventMap>>(\n type: EventName,\n callback: EventListenerCallback<EventMap, EventName>\n ): () => void;\n removeListener<EventName extends Keyof<EventMap>>(\n type: EventName,\n callback: EventListenerCallback<EventMap, EventName>\n ): void;\n};\n\nexport type EventEmitter<EventMap extends EventMapBase> = {\n /**\n * Emit an event to child screens.\n *\n * @param options.type Type of the event (e.g. `focus`, `blur`)\n * @param [options.data] Optional information regarding the event.\n * @param [options.target] Key of the target route which should receive the event.\n * If not specified, all routes receive the event.\n */\n emit<EventName extends Keyof<EventMap>>(\n options: {\n type: EventName;\n target?: string;\n } & (EventMap[EventName]['canPreventDefault'] extends true\n ? { canPreventDefault: true }\n : {}) &\n (undefined extends EventMap[EventName]['data']\n ? { data?: EventMap[EventName]['data'] }\n : { data: EventMap[EventName]['data'] })\n ): EventArg<\n EventName,\n EventMap[EventName]['canPreventDefault'],\n EventMap[EventName]['data']\n >;\n};\n\nexport class PrivateValueStore<A, B, C> {\n /**\n * UGLY HACK! DO NOT USE THE TYPE!!!\n *\n * TypeScript requires a type to be used to be able to infer it.\n * The type should exist as its own without any operations such as union.\n * So we need to figure out a way to store this type in a property.\n * The problem with a normal property is that it shows up in intelliSense.\n * Adding private keyword works, but the annotation is stripped away in declaration.\n * Turns out if we use an empty string, it doesn't show up in intelliSense.\n */\n protected ''?: { a: A; b: B; c: C };\n}\n\ntype NavigationHelpersCommon<\n ParamList extends ParamListBase,\n State extends NavigationState = NavigationState\n> = {\n /**\n * Dispatch an action or an update function to the router.\n * The update function will receive the current state,\n *\n * @param action Action object or update function.\n */\n dispatch(\n action: NavigationAction | ((state: State) => NavigationAction)\n ): void;\n\n /**\n * Navigate to a route in current navigation tree.\n *\n * @param name Name of the route to navigate to.\n * @param [params] Params object for the route.\n */\n navigate<RouteName extends keyof ParamList>(\n ...args: undefined extends ParamList[RouteName]\n ? [screen: RouteName] | [screen: RouteName, params: ParamList[RouteName]]\n : [screen: RouteName, params: ParamList[RouteName]]\n ): void;\n\n /**\n * Navigate to a route in current navigation tree.\n *\n * @param route Object with `key` or `name` for the route to navigate to, and a `params` object.\n */\n navigate<RouteName extends keyof ParamList>(\n options:\n | { key: string; params?: ParamList[RouteName]; merge?: boolean }\n | {\n name: RouteName;\n key?: string;\n params: ParamList[RouteName];\n merge?: boolean;\n }\n ): void;\n\n /**\n * Reset the navigation state to the provided state.\n *\n * @param state Navigation state object.\n */\n reset(state: PartialState<State> | State): void;\n\n /**\n * Go back to the previous route in history.\n */\n goBack(): void;\n\n /**\n * Check if the screen is focused. The method returns `true` if focused, `false` otherwise.\n * Note that this method doesn't re-render screen when the focus changes. So don't use it in `render`.\n * To get notified of focus changes, use `addListener('focus', cb)` and `addListener('blur', cb)`.\n * To conditionally render content based on focus state, use the `useIsFocused` hook.\n */\n isFocused(): boolean;\n\n /**\n * Check if dispatching back action will be handled by navigation.\n * Note that this method doesn't re-render screen when the result changes. So don't use it in `render`.\n */\n canGoBack(): boolean;\n\n /**\n * Returns the navigation prop from the parent navigator,\n */\n getParent<T = NavigationProp<ParamListBase> | undefined>(): T;\n\n /**\n * Returns the navigator's state.\n * Note that this method doesn't re-render screen when the result changes. So don't use it in `render`.\n */\n getState(): State;\n} & PrivateValueStore<ParamList, keyof ParamList, {}>;\n\nexport type NavigationHelpers<\n ParamList extends ParamListBase,\n EventMap extends EventMapBase = {}\n> = NavigationHelpersCommon<ParamList> &\n EventEmitter<EventMap> & {\n /**\n * Update the param object for the route.\n * The new params will be shallow merged with the old one.\n *\n * @param params Params object for the current route.\n */\n setParams<RouteName extends keyof ParamList>(\n params: Partial<ParamList[RouteName]>\n ): void;\n };\n\nexport type NavigationContainerProps = {\n /**\n * Initial navigation state for the child navigators.\n */\n initialState?: InitialState;\n /**\n * Callback which is called with the latest navigation state when it changes.\n */\n onStateChange?: (state: NavigationState | undefined) => void;\n /**\n * Callback which is called when an action is not handled.\n */\n onUnhandledAction?: (action: NavigationAction) => void;\n /**\n * Whether this navigation container should be independent of parent containers.\n * If this is not set to `true`, this container cannot be nested inside another container.\n * Setting it to `true` disconnects any children navigators from parent container.\n */\n independent?: boolean;\n /**\n * Children elements to render.\n */\n children: React.ReactNode;\n};\n\nexport type NavigationProp<\n ParamList extends {},\n RouteName extends keyof ParamList = Keyof<ParamList>,\n State extends NavigationState = NavigationState<ParamList>,\n ScreenOptions extends {} = {},\n EventMap extends EventMapBase = {}\n> = NavigationHelpersCommon<ParamList, State> & {\n /**\n * Update the param object for the route.\n * The new params will be shallow merged with the old one.\n *\n * @param params Params object for the current route.\n */\n setParams(params: Partial<ParamList[RouteName]>): void;\n\n /**\n * Update the options for the route.\n * The options object will be shallow merged with default options object.\n *\n * @param options Options object for the route.\n */\n setOptions(options: Partial<ScreenOptions>): void;\n} & EventConsumer<EventMap & EventMapCore<State>> &\n PrivateValueStore<ParamList, RouteName, EventMap>;\n\nexport type RouteProp<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = Keyof<ParamList>\n> = Route<Extract<RouteName, string>, ParamList[RouteName]>;\n\nexport type CompositeNavigationProp<\n A extends NavigationProp<ParamListBase, string, any, any>,\n B extends NavigationHelpersCommon<ParamListBase, any>\n> = Omit<A & B, keyof NavigationProp<any>> &\n NavigationProp<\n /**\n * Param list from both navigation objects needs to be combined\n * For example, we should be able to navigate to screens in both A and B\n */\n (A extends NavigationHelpersCommon<infer T> ? T : never) &\n (B extends NavigationHelpersCommon<infer U> ? U : never),\n /**\n * The route name should refer to the route name specified in the first type\n * Ideally it should work for any of them, but it's not possible to infer that way\n */\n A extends NavigationProp<any, infer R> ? R : string,\n /**\n * The type of state should refer to the state specified in the first type\n */\n A extends NavigationProp<any, any, infer S> ? S : NavigationState,\n /**\n * Screen options from both navigation objects needs to be combined\n * This allows typechecking `setOptions`\n */\n (A extends NavigationProp<any, any, any, infer O> ? O : {}) &\n (B extends NavigationProp<any, any, any, infer P> ? P : {}),\n /**\n * Event consumer config should refer to the config specified in the first type\n * This allows typechecking `addListener`/`removeListener`\n */\n A extends NavigationProp<any, any, any, any, infer E> ? E : {}\n >;\n\nexport type CompositeScreenProps<\n A extends {\n navigation: NavigationProp<ParamListBase, string, any, any>;\n route: RouteProp<ParamListBase>;\n },\n B extends {\n navigation: NavigationHelpersCommon<ParamListBase, any>;\n }\n> = {\n navigation: CompositeNavigationProp<A['navigation'], B['navigation']>;\n route: A['route'];\n};\n\nexport type Descriptor<\n ScreenOptions extends {},\n Navigation extends NavigationProp<any, any, any, any, any>,\n Route extends RouteProp<any, any>\n> = {\n /**\n * Render the component associated with this route.\n */\n render(): JSX.Element;\n\n /**\n * Options for the route.\n */\n options: ScreenOptions;\n\n /**\n * Route object for the screen\n */\n route: Route;\n\n /**\n * Navigation object for the screen\n */\n navigation: Navigation;\n};\n\nexport type ScreenListeners<\n State extends NavigationState,\n EventMap extends EventMapBase\n> = Partial<\n {\n [EventName in keyof (EventMap &\n EventMapCore<State>)]: EventListenerCallback<EventMap, EventName>;\n }\n>;\n\nexport type RouteConfigComponent<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList\n> =\n | {\n /**\n * React component to render for this screen.\n */\n component: React.ComponentType<any>;\n getComponent?: never;\n children?: never;\n }\n | {\n /**\n * Lazily get a React component to render for this screen.\n */\n getComponent: () => React.ComponentType<any>;\n component?: never;\n children?: never;\n }\n | {\n /**\n * Render callback to render content of this screen.\n */\n children: (props: {\n route: RouteProp<ParamList, RouteName>;\n navigation: any;\n }) => React.ReactNode;\n component?: never;\n getComponent?: never;\n };\n\nexport type RouteConfig<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList,\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n> = {\n /**\n * Route name of this screen.\n */\n name: RouteName;\n\n /**\n * Navigator options for this screen.\n */\n options?:\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamList, RouteName>;\n navigation: any;\n }) => ScreenOptions);\n\n /**\n * Event listeners for this screen.\n */\n listeners?:\n | ScreenListeners<State, EventMap>\n | ((props: {\n route: RouteProp<ParamList, RouteName>;\n navigation: any;\n }) => ScreenListeners<State, EventMap>);\n\n /**\n * Function to return an unique ID for this screen.\n * Receives an object with the route params.\n * For a given screen name, there will always be only one screen corresponding to an ID.\n * If `undefined` is returned, it acts same as no `getId` being specified.\n */\n getId?: ({ params }: { params: ParamList[RouteName] }) => string | undefined;\n\n /**\n * Initial params object for the route.\n */\n initialParams?: Partial<ParamList[RouteName]>;\n} & RouteConfigComponent<ParamList, RouteName>;\n\nexport type RouteGroupConfig<\n ParamList extends ParamListBase,\n ScreenOptions extends {}\n> = {\n /**\n * Navigator options for this screen.\n */\n screenOptions?:\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamList, keyof ParamList>;\n navigation: any;\n }) => ScreenOptions);\n /**\n * Children React Elements to extract the route configuration from.\n * Only `Screen`, `Group` and `React.Fragment` are supported as children.\n */\n children: React.ReactNode;\n};\n\nexport type NavigationContainerEventMap = {\n /**\n * Event which fires when the navigation state changes.\n */\n state: {\n data: {\n /**\n * The updated state object after the state change.\n */\n state: NavigationState | PartialState<NavigationState> | undefined;\n };\n };\n /**\n * Event which fires when current options changes.\n */\n options: { data: { options: object } };\n /**\n * Event which fires when an action is dispatched.\n * Only intended for debugging purposes, don't use it for app logic.\n * This event will be emitted before state changes have been applied.\n */\n __unsafe_action__: {\n data: {\n /**\n * The action object which was dispatched.\n */\n action: NavigationAction;\n /**\n * Whether the action was a no-op, i.e. resulted any state changes.\n */\n noop: boolean;\n /**\n * Stack trace of the action, this will only be available during development.\n */\n stack: string | undefined;\n };\n };\n};\n\nexport type NavigationContainerRef<ParamList extends {}> =\n NavigationHelpers<ParamList> &\n EventConsumer<NavigationContainerEventMap> & {\n /**\n * Reset the navigation state of the root navigator to the provided state.\n *\n * @param state Navigation state object.\n */\n resetRoot(state?: PartialState<NavigationState> | NavigationState): void;\n /**\n * Get the rehydrated navigation state of the navigation tree.\n */\n getRootState(): NavigationState;\n /**\n * Get the currently focused navigation route.\n */\n getCurrentRoute(): Route<string> | undefined;\n /**\n * Get the currently focused route's options.\n */\n getCurrentOptions(): object | undefined;\n /**\n * Whether the navigation container is ready to handle actions.\n */\n isReady(): boolean;\n };\n\nexport type NavigationContainerRefWithCurrent<ParamList extends {}> =\n NavigationContainerRef<ParamList> & {\n current: NavigationContainerRef<ParamList> | null;\n };\n\nexport type TypedNavigator<\n ParamList extends ParamListBase,\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase,\n Navigator extends React.ComponentType<any>\n> = {\n /**\n * Navigator component which manages the child screens.\n */\n Navigator: React.ComponentType<\n Omit<\n React.ComponentProps<Navigator>,\n keyof DefaultNavigatorOptions<any, any, any, any>\n > &\n DefaultNavigatorOptions<ParamList, State, ScreenOptions, EventMap>\n >;\n /**\n * Component used for grouping multiple route configuration.\n */\n Group: React.ComponentType<RouteGroupConfig<ParamList, ScreenOptions>>;\n /**\n * Component used for specifying route configuration.\n */\n Screen: <RouteName extends keyof ParamList>(\n _: RouteConfig<ParamList, RouteName, State, ScreenOptions, EventMap>\n ) => null;\n};\n\nexport type NavigatorScreenParams<\n ParamList,\n State extends NavigationState = NavigationState\n> =\n | {\n screen?: never;\n params?: never;\n initial?: never;\n path?: string;\n state: PartialState<State> | State | undefined;\n }\n | {\n [RouteName in keyof ParamList]: undefined extends ParamList[RouteName]\n ? {\n screen: RouteName;\n params?: ParamList[RouteName];\n initial?: boolean;\n path?: string;\n state?: never;\n }\n : {\n screen: RouteName;\n params: ParamList[RouteName];\n initial?: boolean;\n path?: string;\n state?: never;\n };\n }[keyof ParamList];\n\nexport type PathConfig<ParamList extends {}> = {\n path?: string;\n exact?: boolean;\n parse?: Record<string, (value: string) => any>;\n stringify?: Record<string, (value: any) => string>;\n screens?: PathConfigMap<ParamList>;\n initialRouteName?: keyof ParamList;\n};\n\nexport type PathConfigMap<ParamList extends {}> = {\n [RouteName in keyof ParamList]?: NonNullable<\n ParamList[RouteName]\n > extends NavigatorScreenParams<infer T, any>\n ? string | PathConfig<T>\n : string | Omit<PathConfig<{}>, 'screens' | 'initialRouteName'>;\n};\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useChildListeners;
|
|
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
|
+
/**
|
|
15
|
+
* Hook which lets child navigators add action listeners.
|
|
16
|
+
*/
|
|
17
|
+
function useChildListeners() {
|
|
18
|
+
const {
|
|
19
|
+
current: listeners
|
|
20
|
+
} = React.useRef({
|
|
21
|
+
action: [],
|
|
22
|
+
focus: []
|
|
23
|
+
});
|
|
24
|
+
const addListener = React.useCallback((type, listener) => {
|
|
25
|
+
// @ts-expect-error: listener should be correct type according to `type`
|
|
26
|
+
listeners[type].push(listener);
|
|
27
|
+
return () => {
|
|
28
|
+
// @ts-expect-error: listener should be correct type according to `type`
|
|
29
|
+
const index = listeners[type].indexOf(listener);
|
|
30
|
+
listeners[type].splice(index, 1);
|
|
31
|
+
};
|
|
32
|
+
}, [listeners]);
|
|
33
|
+
return {
|
|
34
|
+
listeners,
|
|
35
|
+
addListener
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=useChildListeners.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useChildListeners.tsx"],"names":["useChildListeners","current","listeners","React","useRef","action","focus","addListener","useCallback","type","listener","push","index","indexOf","splice"],"mappings":";;;;;;;AAAA;;;;;;AAIA;AACA;AACA;AACe,SAASA,iBAAT,GAA6B;AAC1C,QAAM;AAAEC,IAAAA,OAAO,EAAEC;AAAX,MAAyBC,KAAK,CAACC,MAAN,CAI7B;AACAC,IAAAA,MAAM,EAAE,EADR;AAEAC,IAAAA,KAAK,EAAE;AAFP,GAJ6B,CAA/B;AASA,QAAMC,WAAW,GAAGJ,KAAK,CAACK,WAAN,CAClB,CAA8BC,IAA9B,EAAuCC,QAAvC,KAAoE;AAClE;AACAR,IAAAA,SAAS,CAACO,IAAD,CAAT,CAAgBE,IAAhB,CAAqBD,QAArB;AAEA,WAAO,MAAM;AACX;AACA,YAAME,KAAK,GAAGV,SAAS,CAACO,IAAD,CAAT,CAAgBI,OAAhB,CAAwBH,QAAxB,CAAd;AAEAR,MAAAA,SAAS,CAACO,IAAD,CAAT,CAAgBK,MAAhB,CAAuBF,KAAvB,EAA8B,CAA9B;AACD,KALD;AAMD,GAXiB,EAYlB,CAACV,SAAD,CAZkB,CAApB;AAeA,SAAO;AACLA,IAAAA,SADK;AAELK,IAAAA;AAFK,GAAP;AAID","sourcesContent":["import * as React from 'react';\n\nimport type { ListenerMap } from './NavigationBuilderContext';\n\n/**\n * Hook which lets child navigators add action listeners.\n */\nexport default function useChildListeners() {\n const { current: listeners } = React.useRef<\n {\n [K in keyof ListenerMap]: ListenerMap[K][];\n }\n >({\n action: [],\n focus: [],\n });\n\n const addListener = React.useCallback(\n <T extends keyof ListenerMap>(type: T, listener: ListenerMap[T]) => {\n // @ts-expect-error: listener should be correct type according to `type`\n listeners[type].push(listener);\n\n return () => {\n // @ts-expect-error: listener should be correct type according to `type`\n const index = listeners[type].indexOf(listener);\n\n listeners[type].splice(index, 1);\n };\n },\n [listeners]\n );\n\n return {\n listeners,\n addListener,\n };\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useComponent;
|
|
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
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
|
|
16
|
+
function useComponent(Component, props) {
|
|
17
|
+
const propsRef = React.useRef(props); // Normally refs shouldn't be mutated in render
|
|
18
|
+
// But we return a component which will be rendered
|
|
19
|
+
// So it's just for immediate consumption
|
|
20
|
+
|
|
21
|
+
propsRef.current = props;
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
propsRef.current = null;
|
|
24
|
+
});
|
|
25
|
+
return React.useRef(rest => {
|
|
26
|
+
const props = propsRef.current;
|
|
27
|
+
|
|
28
|
+
if (props === null) {
|
|
29
|
+
throw new Error('The returned component must be rendered in the same render phase as the hook.');
|
|
30
|
+
} // @ts-expect-error: the props should be fine here
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, rest));
|
|
34
|
+
}).current;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=useComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useComponent.tsx"],"names":["useComponent","Component","props","propsRef","React","useRef","current","useEffect","rest","Error"],"mappings":";;;;;;;AAAA;;;;;;;;AAEe,SAASA,YAAT,CAGbC,SAHa,EAGCC,KAHD,EAGW;AACxB,QAAMC,QAAQ,GAAGC,KAAK,CAACC,MAAN,CAAuBH,KAAvB,CAAjB,CADwB,CAGxB;AACA;AACA;;AACAC,EAAAA,QAAQ,CAACG,OAAT,GAAmBJ,KAAnB;AAEAE,EAAAA,KAAK,CAACG,SAAN,CAAgB,MAAM;AACpBJ,IAAAA,QAAQ,CAACG,OAAT,GAAmB,IAAnB;AACD,GAFD;AAIA,SAAOF,KAAK,CAACC,MAAN,CAAcG,IAAD,IAAkD;AACpE,UAAMN,KAAK,GAAGC,QAAQ,CAACG,OAAvB;;AAEA,QAAIJ,KAAK,KAAK,IAAd,EAAoB;AAClB,YAAM,IAAIO,KAAJ,CACJ,+EADI,CAAN;AAGD,KAPmE,CASpE;;;AACA,wBAAO,oBAAC,SAAD,eAAeP,KAAf,EAA0BM,IAA1B,EAAP;AACD,GAXM,EAWJF,OAXH;AAYD","sourcesContent":["import * as React from 'react';\n\nexport default function useComponent<\n T extends React.ComponentType<any>,\n P extends {}\n>(Component: T, props: P) {\n const propsRef = React.useRef<P | null>(props);\n\n // Normally refs shouldn't be mutated in render\n // But we return a component which will be rendered\n // So it's just for immediate consumption\n propsRef.current = props;\n\n React.useEffect(() => {\n propsRef.current = null;\n });\n\n return React.useRef((rest: Omit<React.ComponentProps<T>, keyof P>) => {\n const props = propsRef.current;\n\n if (props === null) {\n throw new Error(\n 'The returned component must be rendered in the same render phase as the hook.'\n );\n }\n\n // @ts-expect-error: the props should be fine here\n return <Component {...props} {...rest} />;\n }).current;\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useCurrentRender;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _CurrentRenderContext = _interopRequireDefault(require("./CurrentRenderContext"));
|
|
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
|
+
* Write the current options, so that server renderer can get current values
|
|
20
|
+
* Mutating values like this is not safe in async mode, but it doesn't apply to SSR
|
|
21
|
+
*/
|
|
22
|
+
function useCurrentRender({
|
|
23
|
+
state,
|
|
24
|
+
navigation,
|
|
25
|
+
descriptors
|
|
26
|
+
}) {
|
|
27
|
+
const current = React.useContext(_CurrentRenderContext.default);
|
|
28
|
+
|
|
29
|
+
if (current && navigation.isFocused()) {
|
|
30
|
+
current.options = descriptors[state.routes[state.index].key].options;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=useCurrentRender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useCurrentRender.tsx"],"names":["useCurrentRender","state","navigation","descriptors","current","React","useContext","CurrentRenderContext","isFocused","options","routes","index","key"],"mappings":";;;;;;;AACA;;AAEA;;;;;;;;AAiBA;AACA;AACA;AACA;AACe,SAASA,gBAAT,CAA0B;AACvCC,EAAAA,KADuC;AAEvCC,EAAAA,UAFuC;AAGvCC,EAAAA;AAHuC,CAA1B,EAIH;AACV,QAAMC,OAAO,GAAGC,KAAK,CAACC,UAAN,CAAiBC,6BAAjB,CAAhB;;AAEA,MAAIH,OAAO,IAAIF,UAAU,CAACM,SAAX,EAAf,EAAuC;AACrCJ,IAAAA,OAAO,CAACK,OAAR,GAAkBN,WAAW,CAACF,KAAK,CAACS,MAAN,CAAaT,KAAK,CAACU,KAAnB,EAA0BC,GAA3B,CAAX,CAA2CH,OAA7D;AACD;AACF","sourcesContent":["import type { NavigationState, ParamListBase } from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport CurrentRenderContext from './CurrentRenderContext';\nimport type {\n Descriptor,\n NavigationHelpers,\n NavigationProp,\n RouteProp,\n} from './types';\n\ntype Options = {\n state: NavigationState;\n navigation: NavigationHelpers<ParamListBase>;\n descriptors: Record<\n string,\n Descriptor<object, NavigationProp<ParamListBase>, RouteProp<ParamListBase>>\n >;\n};\n\n/**\n * Write the current options, so that server renderer can get current values\n * Mutating values like this is not safe in async mode, but it doesn't apply to SSR\n */\nexport default function useCurrentRender({\n state,\n navigation,\n descriptors,\n}: Options) {\n const current = React.useContext(CurrentRenderContext);\n\n if (current && navigation.isFocused()) {\n current.options = descriptors[state.routes[state.index].key].options;\n }\n}\n"]}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useDescriptors;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
|
|
11
|
+
|
|
12
|
+
var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
|
|
13
|
+
|
|
14
|
+
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
|
|
15
|
+
|
|
16
|
+
var _SceneView = _interopRequireDefault(require("./SceneView"));
|
|
17
|
+
|
|
18
|
+
var _useNavigationCache = _interopRequireDefault(require("./useNavigationCache"));
|
|
19
|
+
|
|
20
|
+
var _useRouteCache = _interopRequireDefault(require("./useRouteCache"));
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Hook to create descriptor objects for the child routes.
|
|
30
|
+
*
|
|
31
|
+
* A descriptor object provides 3 things:
|
|
32
|
+
* - Helper method to render a screen
|
|
33
|
+
* - Options specified by the screen for the navigator
|
|
34
|
+
* - Navigation object intended for the route
|
|
35
|
+
*/
|
|
36
|
+
function useDescriptors({
|
|
37
|
+
state,
|
|
38
|
+
screens,
|
|
39
|
+
navigation,
|
|
40
|
+
screenOptions,
|
|
41
|
+
defaultScreenOptions,
|
|
42
|
+
onAction,
|
|
43
|
+
getState,
|
|
44
|
+
setState,
|
|
45
|
+
addListener,
|
|
46
|
+
addKeyedListener,
|
|
47
|
+
onRouteFocus,
|
|
48
|
+
router,
|
|
49
|
+
emitter
|
|
50
|
+
}) {
|
|
51
|
+
const [options, setOptions] = React.useState({});
|
|
52
|
+
const {
|
|
53
|
+
onDispatchAction,
|
|
54
|
+
onOptionsChange,
|
|
55
|
+
stackRef
|
|
56
|
+
} = React.useContext(_NavigationBuilderContext.default);
|
|
57
|
+
const context = React.useMemo(() => ({
|
|
58
|
+
navigation,
|
|
59
|
+
onAction,
|
|
60
|
+
addListener,
|
|
61
|
+
addKeyedListener,
|
|
62
|
+
onRouteFocus,
|
|
63
|
+
onDispatchAction,
|
|
64
|
+
onOptionsChange,
|
|
65
|
+
stackRef
|
|
66
|
+
}), [navigation, onAction, addListener, addKeyedListener, onRouteFocus, onDispatchAction, onOptionsChange, stackRef]);
|
|
67
|
+
const navigations = (0, _useNavigationCache.default)({
|
|
68
|
+
state,
|
|
69
|
+
getState,
|
|
70
|
+
navigation,
|
|
71
|
+
setOptions,
|
|
72
|
+
router,
|
|
73
|
+
emitter
|
|
74
|
+
});
|
|
75
|
+
const routes = (0, _useRouteCache.default)(state.routes);
|
|
76
|
+
return routes.reduce((acc, route, i) => {
|
|
77
|
+
const config = screens[route.name];
|
|
78
|
+
const screen = config[1];
|
|
79
|
+
const navigation = navigations[route.key];
|
|
80
|
+
const optionsList = [// The default `screenOptions` passed to the navigator
|
|
81
|
+
screenOptions, // The `screenOptions` props passed to `Group` elements
|
|
82
|
+
...(config[0] ? config[0].filter(Boolean) : []), // The `options` prop passed to `Screen` elements,
|
|
83
|
+
screen.options, // The options set via `navigation.setOptions`
|
|
84
|
+
options[route.key]];
|
|
85
|
+
const customOptions = optionsList.reduce((acc, curr) => Object.assign(acc, typeof curr !== 'function' ? curr : curr({
|
|
86
|
+
route,
|
|
87
|
+
navigation
|
|
88
|
+
})), {});
|
|
89
|
+
const mergedOptions = { ...(typeof defaultScreenOptions === 'function' ? // @ts-expect-error: ts gives incorrect error here
|
|
90
|
+
defaultScreenOptions({
|
|
91
|
+
route,
|
|
92
|
+
navigation,
|
|
93
|
+
options: customOptions
|
|
94
|
+
}) : defaultScreenOptions),
|
|
95
|
+
...customOptions
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const clearOptions = () => setOptions(o => {
|
|
99
|
+
if (route.key in o) {
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
101
|
+
const {
|
|
102
|
+
[route.key]: _,
|
|
103
|
+
...rest
|
|
104
|
+
} = o;
|
|
105
|
+
return rest;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return o;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
acc[route.key] = {
|
|
112
|
+
route,
|
|
113
|
+
// @ts-expect-error: it's missing action helpers, fix later
|
|
114
|
+
navigation,
|
|
115
|
+
|
|
116
|
+
render() {
|
|
117
|
+
return /*#__PURE__*/React.createElement(_NavigationBuilderContext.default.Provider, {
|
|
118
|
+
key: route.key,
|
|
119
|
+
value: context
|
|
120
|
+
}, /*#__PURE__*/React.createElement(_NavigationContext.default.Provider, {
|
|
121
|
+
value: navigation
|
|
122
|
+
}, /*#__PURE__*/React.createElement(_NavigationRouteContext.default.Provider, {
|
|
123
|
+
value: route
|
|
124
|
+
}, /*#__PURE__*/React.createElement(_SceneView.default, {
|
|
125
|
+
navigation: navigation,
|
|
126
|
+
route: route,
|
|
127
|
+
screen: screen,
|
|
128
|
+
routeState: state.routes[i].state,
|
|
129
|
+
getState: getState,
|
|
130
|
+
setState: setState,
|
|
131
|
+
options: mergedOptions,
|
|
132
|
+
clearOptions: clearOptions
|
|
133
|
+
}))));
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
options: mergedOptions
|
|
137
|
+
};
|
|
138
|
+
return acc;
|
|
139
|
+
}, {});
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=useDescriptors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useDescriptors.tsx"],"names":["useDescriptors","state","screens","navigation","screenOptions","defaultScreenOptions","onAction","getState","setState","addListener","addKeyedListener","onRouteFocus","router","emitter","options","setOptions","React","useState","onDispatchAction","onOptionsChange","stackRef","useContext","NavigationBuilderContext","context","useMemo","navigations","routes","reduce","acc","route","i","config","name","screen","key","optionsList","filter","Boolean","customOptions","curr","Object","assign","mergedOptions","clearOptions","o","_","rest","render"],"mappings":";;;;;;;AAMA;;AAEA;;AAIA;;AACA;;AACA;;AAUA;;AACA;;;;;;;;AA+CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAKb;AACAC,EAAAA,KADA;AAEAC,EAAAA,OAFA;AAGAC,EAAAA,UAHA;AAIAC,EAAAA,aAJA;AAKAC,EAAAA,oBALA;AAMAC,EAAAA,QANA;AAOAC,EAAAA,QAPA;AAQAC,EAAAA,QARA;AASAC,EAAAA,WATA;AAUAC,EAAAA,gBAVA;AAWAC,EAAAA,YAXA;AAYAC,EAAAA,MAZA;AAaAC,EAAAA;AAbA,CALa,EAmB6B;AAC1C,QAAM,CAACC,OAAD,EAAUC,UAAV,IAAwBC,KAAK,CAACC,QAAN,CAAuC,EAAvC,CAA9B;AACA,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA,eAApB;AAAqCC,IAAAA;AAArC,MAAkDJ,KAAK,CAACK,UAAN,CACtDC,iCADsD,CAAxD;AAIA,QAAMC,OAAO,GAAGP,KAAK,CAACQ,OAAN,CACd,OAAO;AACLrB,IAAAA,UADK;AAELG,IAAAA,QAFK;AAGLG,IAAAA,WAHK;AAILC,IAAAA,gBAJK;AAKLC,IAAAA,YALK;AAMLO,IAAAA,gBANK;AAOLC,IAAAA,eAPK;AAQLC,IAAAA;AARK,GAAP,CADc,EAWd,CACEjB,UADF,EAEEG,QAFF,EAGEG,WAHF,EAIEC,gBAJF,EAKEC,YALF,EAMEO,gBANF,EAOEC,eAPF,EAQEC,QARF,CAXc,CAAhB;AAuBA,QAAMK,WAAW,GAAG,iCAAmD;AACrExB,IAAAA,KADqE;AAErEM,IAAAA,QAFqE;AAGrEJ,IAAAA,UAHqE;AAIrEY,IAAAA,UAJqE;AAKrEH,IAAAA,MALqE;AAMrEC,IAAAA;AANqE,GAAnD,CAApB;AASA,QAAMa,MAAM,GAAG,4BAAczB,KAAK,CAACyB,MAApB,CAAf;AAEA,SAAOA,MAAM,CAACC,MAAP,CAUL,CAACC,GAAD,EAAMC,KAAN,EAAaC,CAAb,KAAmB;AACnB,UAAMC,MAAM,GAAG7B,OAAO,CAAC2B,KAAK,CAACG,IAAP,CAAtB;AACA,UAAMC,MAAM,GAAGF,MAAM,CAAC,CAAD,CAArB;AACA,UAAM5B,UAAU,GAAGsB,WAAW,CAACI,KAAK,CAACK,GAAP,CAA9B;AAEA,UAAMC,WAAW,GAAG,CAClB;AACA/B,IAAAA,aAFkB,EAGlB;AACA,QAAK2B,MAAM,CAAC,CAAD,CAAN,GACDA,MAAM,CAAC,CAAD,CAAN,CAAUK,MAAV,CAAiBC,OAAjB,CADC,GAED,EAFJ,CAJkB,EAOlB;AACAJ,IAAAA,MAAM,CAACnB,OARW,EASlB;AACAA,IAAAA,OAAO,CAACe,KAAK,CAACK,GAAP,CAVW,CAApB;AAaA,UAAMI,aAAa,GAAGH,WAAW,CAACR,MAAZ,CACpB,CAACC,GAAD,EAAMW,IAAN,KACEC,MAAM,CAACC,MAAP,CACEb,GADF,EAEE,OAAOW,IAAP,KAAgB,UAAhB,GAA6BA,IAA7B,GAAoCA,IAAI,CAAC;AAAEV,MAAAA,KAAF;AAAS1B,MAAAA;AAAT,KAAD,CAF1C,CAFkB,EAMpB,EANoB,CAAtB;AASA,UAAMuC,aAAa,GAAG,EACpB,IAAI,OAAOrC,oBAAP,KAAgC,UAAhC,GACA;AACAA,MAAAA,oBAAoB,CAAC;AACnBwB,QAAAA,KADmB;AAEnB1B,QAAAA,UAFmB;AAGnBW,QAAAA,OAAO,EAAEwB;AAHU,OAAD,CAFpB,GAOAjC,oBAPJ,CADoB;AASpB,SAAGiC;AATiB,KAAtB;;AAYA,UAAMK,YAAY,GAAG,MACnB5B,UAAU,CAAE6B,CAAD,IAAO;AAChB,UAAIf,KAAK,CAACK,GAAN,IAAaU,CAAjB,EAAoB;AAClB;AACA,cAAM;AAAE,WAACf,KAAK,CAACK,GAAP,GAAaW,CAAf;AAAkB,aAAGC;AAArB,YAA8BF,CAApC;AACA,eAAOE,IAAP;AACD;;AAED,aAAOF,CAAP;AACD,KARS,CADZ;;AAWAhB,IAAAA,GAAG,CAACC,KAAK,CAACK,GAAP,CAAH,GAAiB;AACfL,MAAAA,KADe;AAEf;AACA1B,MAAAA,UAHe;;AAIf4C,MAAAA,MAAM,GAAG;AACP,4BACE,oBAAC,iCAAD,CAA0B,QAA1B;AAAmC,UAAA,GAAG,EAAElB,KAAK,CAACK,GAA9C;AAAmD,UAAA,KAAK,EAAEX;AAA1D,wBACE,oBAAC,0BAAD,CAAmB,QAAnB;AAA4B,UAAA,KAAK,EAAEpB;AAAnC,wBACE,oBAAC,+BAAD,CAAwB,QAAxB;AAAiC,UAAA,KAAK,EAAE0B;AAAxC,wBACE,oBAAC,kBAAD;AACE,UAAA,UAAU,EAAE1B,UADd;AAEE,UAAA,KAAK,EAAE0B,KAFT;AAGE,UAAA,MAAM,EAAEI,MAHV;AAIE,UAAA,UAAU,EAAEhC,KAAK,CAACyB,MAAN,CAAaI,CAAb,EAAgB7B,KAJ9B;AAKE,UAAA,QAAQ,EAAEM,QALZ;AAME,UAAA,QAAQ,EAAEC,QANZ;AAOE,UAAA,OAAO,EAAEkC,aAPX;AAQE,UAAA,YAAY,EAAEC;AARhB,UADF,CADF,CADF,CADF;AAkBD,OAvBc;;AAwBf7B,MAAAA,OAAO,EAAE4B;AAxBM,KAAjB;AA2BA,WAAOd,GAAP;AACD,GAxFM,EAwFJ,EAxFI,CAAP;AAyFD","sourcesContent":["import type {\n NavigationAction,\n NavigationState,\n ParamListBase,\n Router,\n} from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport NavigationBuilderContext, {\n AddKeyedListener,\n AddListener,\n} from './NavigationBuilderContext';\nimport NavigationContext from './NavigationContext';\nimport NavigationRouteContext from './NavigationRouteContext';\nimport SceneView from './SceneView';\nimport type {\n Descriptor,\n EventMapBase,\n NavigationHelpers,\n NavigationProp,\n RouteConfig,\n RouteProp,\n} from './types';\nimport type { NavigationEventEmitter } from './useEventEmitter';\nimport useNavigationCache from './useNavigationCache';\nimport useRouteCache from './useRouteCache';\n\nexport type ScreenConfigWithParent<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n> = [\n (ScreenOptionsOrCallback<ScreenOptions> | undefined)[] | undefined,\n RouteConfig<ParamListBase, string, State, ScreenOptions, EventMap>\n];\n\ntype ScreenOptionsOrCallback<ScreenOptions extends {}> =\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenOptions);\n\ntype Options<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n> = {\n state: State;\n screens: Record<\n string,\n ScreenConfigWithParent<State, ScreenOptions, EventMap>\n >;\n navigation: NavigationHelpers<ParamListBase>;\n screenOptions?: ScreenOptionsOrCallback<ScreenOptions>;\n defaultScreenOptions?:\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamListBase>;\n navigation: any;\n options: ScreenOptions;\n }) => ScreenOptions);\n onAction: (action: NavigationAction) => boolean;\n getState: () => State;\n setState: (state: State) => void;\n addListener: AddListener;\n addKeyedListener: AddKeyedListener;\n onRouteFocus: (key: string) => void;\n router: Router<State, NavigationAction>;\n emitter: NavigationEventEmitter<EventMap>;\n};\n\n/**\n * Hook to create descriptor objects for the child routes.\n *\n * A descriptor object provides 3 things:\n * - Helper method to render a screen\n * - Options specified by the screen for the navigator\n * - Navigation object intended for the route\n */\nexport default function useDescriptors<\n State extends NavigationState,\n ActionHelpers extends Record<string, () => void>,\n ScreenOptions extends {},\n EventMap extends EventMapBase\n>({\n state,\n screens,\n navigation,\n screenOptions,\n defaultScreenOptions,\n onAction,\n getState,\n setState,\n addListener,\n addKeyedListener,\n onRouteFocus,\n router,\n emitter,\n}: Options<State, ScreenOptions, EventMap>) {\n const [options, setOptions] = React.useState<Record<string, object>>({});\n const { onDispatchAction, onOptionsChange, stackRef } = React.useContext(\n NavigationBuilderContext\n );\n\n const context = React.useMemo(\n () => ({\n navigation,\n onAction,\n addListener,\n addKeyedListener,\n onRouteFocus,\n onDispatchAction,\n onOptionsChange,\n stackRef,\n }),\n [\n navigation,\n onAction,\n addListener,\n addKeyedListener,\n onRouteFocus,\n onDispatchAction,\n onOptionsChange,\n stackRef,\n ]\n );\n\n const navigations = useNavigationCache<State, ScreenOptions, EventMap>({\n state,\n getState,\n navigation,\n setOptions,\n router,\n emitter,\n });\n\n const routes = useRouteCache(state.routes);\n\n return routes.reduce<\n Record<\n string,\n Descriptor<\n ScreenOptions,\n NavigationProp<ParamListBase, string, State, ScreenOptions, EventMap> &\n ActionHelpers,\n RouteProp<ParamListBase>\n >\n >\n >((acc, route, i) => {\n const config = screens[route.name];\n const screen = config[1];\n const navigation = navigations[route.key];\n\n const optionsList = [\n // The default `screenOptions` passed to the navigator\n screenOptions,\n // The `screenOptions` props passed to `Group` elements\n ...((config[0]\n ? config[0].filter(Boolean)\n : []) as ScreenOptionsOrCallback<ScreenOptions>[]),\n // The `options` prop passed to `Screen` elements,\n screen.options,\n // The options set via `navigation.setOptions`\n options[route.key],\n ];\n\n const customOptions = optionsList.reduce<ScreenOptions>(\n (acc, curr) =>\n Object.assign(\n acc,\n typeof curr !== 'function' ? curr : curr({ route, navigation })\n ),\n {} as ScreenOptions\n );\n\n const mergedOptions = {\n ...(typeof defaultScreenOptions === 'function'\n ? // @ts-expect-error: ts gives incorrect error here\n defaultScreenOptions({\n route,\n navigation,\n options: customOptions,\n })\n : defaultScreenOptions),\n ...customOptions,\n };\n\n const clearOptions = () =>\n setOptions((o) => {\n if (route.key in o) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [route.key]: _, ...rest } = o;\n return rest;\n }\n\n return o;\n });\n\n acc[route.key] = {\n route,\n // @ts-expect-error: it's missing action helpers, fix later\n navigation,\n render() {\n return (\n <NavigationBuilderContext.Provider key={route.key} value={context}>\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <SceneView\n navigation={navigation}\n route={route}\n screen={screen}\n routeState={state.routes[i].state}\n getState={getState}\n setState={setState}\n options={mergedOptions}\n clearOptions={clearOptions}\n />\n </NavigationRouteContext.Provider>\n </NavigationContext.Provider>\n </NavigationBuilderContext.Provider>\n );\n },\n options: mergedOptions as ScreenOptions,\n };\n\n return acc;\n }, {});\n}\n"]}
|