@react-navigation/core 8.0.0-alpha.4 → 8.0.0-alpha.41
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/README.md +17 -14
- package/lib/module/BaseNavigationContainer.js +173 -90
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/ConsumedParamsContext.js +5 -0
- package/lib/module/ConsumedParamsContext.js.map +1 -0
- package/lib/module/DataLoading.js +129 -0
- package/lib/module/DataLoading.js.map +1 -0
- package/lib/module/NavigationBuilderContext.js +7 -10
- package/lib/module/NavigationBuilderContext.js.map +1 -1
- package/lib/module/NavigationIndependentTree.js +54 -9
- package/lib/module/NavigationIndependentTree.js.map +1 -1
- package/lib/module/NavigationProvider.js +37 -12
- package/lib/module/NavigationProvider.js.map +1 -1
- package/lib/module/NavigationRootContext.js +8 -0
- package/lib/module/NavigationRootContext.js.map +1 -0
- package/lib/module/NavigationStateContext.js +3 -0
- package/lib/module/NavigationStateContext.js.map +1 -1
- package/lib/module/PreventRemoveContext.js.map +1 -1
- package/lib/module/PreventRemoveProvider.js +40 -31
- package/lib/module/PreventRemoveProvider.js.map +1 -1
- package/lib/module/SceneView.js +29 -57
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/StaticNavigation.js +219 -67
- package/lib/module/StaticNavigation.js.map +1 -1
- package/lib/module/StaticTreeContext.js +5 -0
- package/lib/module/StaticTreeContext.js.map +1 -0
- package/lib/module/createNavigationContainerRef.js +7 -9
- package/lib/module/createNavigationContainerRef.js.map +1 -1
- package/lib/module/createNavigatorFactory.js +27 -5
- package/lib/module/createNavigatorFactory.js.map +1 -1
- package/lib/module/findFocusedRoute.js +7 -4
- package/lib/module/findFocusedRoute.js.map +1 -1
- package/lib/module/getActionFromState.js +45 -20
- package/lib/module/getActionFromState.js.map +1 -1
- package/lib/module/getPathFromState.js +204 -94
- package/lib/module/getPathFromState.js.map +1 -1
- package/lib/module/getPatternParts.js +61 -14
- package/lib/module/getPatternParts.js.map +1 -1
- package/lib/module/getStateFromPath.js +608 -272
- package/lib/module/getStateFromPath.js.map +1 -1
- package/lib/module/getStateFromRouteParams.js +23 -0
- package/lib/module/getStateFromRouteParams.js.map +1 -0
- package/lib/module/index.js +7 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +2 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/isRecordEqual.js +1 -1
- package/lib/module/isRecordEqual.js.map +1 -1
- package/lib/module/queryString.js +71 -0
- package/lib/module/queryString.js.map +1 -0
- package/lib/module/theming/useTheme.js +1 -1
- package/lib/module/theming/useTheme.js.map +1 -1
- package/lib/module/types.js +35 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useDescriptors.js +65 -25
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useEventEmitter.js +48 -33
- package/lib/module/useEventEmitter.js.map +1 -1
- package/lib/module/useFocusEffect.js +4 -2
- package/lib/module/useFocusEffect.js.map +1 -1
- package/lib/module/useFocusEvents.js +15 -5
- package/lib/module/useFocusEvents.js.map +1 -1
- package/lib/module/useFocusedListenersChildrenAdapter.js +3 -3
- package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
- package/lib/module/useIsFocused.js +8 -12
- package/lib/module/useIsFocused.js.map +1 -1
- package/lib/module/useKeyedChildListeners.js +5 -2
- package/lib/module/useKeyedChildListeners.js.map +1 -1
- package/lib/module/useLazyValue.js.map +1 -1
- package/lib/module/useNavigation.js +4 -17
- package/lib/module/useNavigation.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +244 -147
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +92 -89
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useNavigationHelpers.js +22 -29
- package/lib/module/useNavigationHelpers.js.map +1 -1
- package/lib/module/useNavigationIndependentTree.js +1 -1
- package/lib/module/useNavigationIndependentTree.js.map +1 -1
- package/lib/module/useNavigationState.js +158 -46
- package/lib/module/useNavigationState.js.map +1 -1
- package/lib/module/useOnAction.js +58 -11
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/useOnGetNavigation.js +26 -0
- package/lib/module/useOnGetNavigation.js.map +1 -0
- package/lib/module/useOnGetState.js +7 -4
- package/lib/module/useOnGetState.js.map +1 -1
- package/lib/module/useOnPreventRemove.js +40 -31
- package/lib/module/useOnPreventRemove.js.map +1 -1
- package/lib/module/useOnRouteFocus.js +2 -2
- package/lib/module/useOnRouteFocus.js.map +1 -1
- package/lib/module/useOptionsGetters.js +35 -27
- package/lib/module/useOptionsGetters.js.map +1 -1
- package/lib/module/usePreventRemove.js +11 -5
- package/lib/module/usePreventRemove.js.map +1 -1
- package/lib/module/usePreventRemoveContext.js +2 -2
- package/lib/module/usePreventRemoveContext.js.map +1 -1
- package/lib/module/useRegisterNavigator.js +3 -4
- package/lib/module/useRegisterNavigator.js.map +1 -1
- package/lib/module/useRoute.js +2 -0
- package/lib/module/useRoute.js.map +1 -1
- package/lib/module/useRouteCache.js +51 -35
- package/lib/module/useRouteCache.js.map +1 -1
- package/lib/module/useScheduleUpdate.js +12 -10
- package/lib/module/useScheduleUpdate.js.map +1 -1
- package/lib/module/useStateForPath.js +1 -1
- package/lib/module/useStateForPath.js.map +1 -1
- package/lib/module/useSyncState.js +37 -15
- package/lib/module/useSyncState.js.map +1 -1
- package/lib/module/validatePathConfig.js +50 -36
- package/lib/module/validatePathConfig.js.map +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts +6 -3
- package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/ConsumedParamsContext.d.ts +3 -0
- package/lib/typescript/src/ConsumedParamsContext.d.ts.map +1 -0
- package/lib/typescript/src/DataLoading.d.ts +21 -0
- package/lib/typescript/src/DataLoading.d.ts.map +1 -0
- package/lib/typescript/src/EnsureSingleNavigator.d.ts +1 -1
- package/lib/typescript/src/EnsureSingleNavigator.d.ts.map +1 -1
- package/lib/typescript/src/Group.d.ts +1 -1
- package/lib/typescript/src/Group.d.ts.map +1 -1
- package/lib/typescript/src/NavigationBuilderContext.d.ts +22 -14
- package/lib/typescript/src/NavigationBuilderContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationContainerRefContext.d.ts +1 -1
- package/lib/typescript/src/NavigationContainerRefContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationFocusedRouteStateContext.d.ts +4 -4
- package/lib/typescript/src/NavigationFocusedRouteStateContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationHelpersContext.d.ts +1 -1
- package/lib/typescript/src/NavigationHelpersContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/NavigationProvider.d.ts +21 -18
- package/lib/typescript/src/NavigationProvider.d.ts.map +1 -1
- package/lib/typescript/src/NavigationRootContext.d.ts +8 -0
- package/lib/typescript/src/NavigationRootContext.d.ts.map +1 -0
- package/lib/typescript/src/NavigationStateContext.d.ts +3 -3
- package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveContext.d.ts +1 -0
- package/lib/typescript/src/PreventRemoveContext.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts +1 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts.map +1 -1
- package/lib/typescript/src/SceneView.d.ts +5 -2
- package/lib/typescript/src/SceneView.d.ts.map +1 -1
- package/lib/typescript/src/Screen.d.ts +1 -1
- package/lib/typescript/src/Screen.d.ts.map +1 -1
- package/lib/typescript/src/StaticContainer.d.ts +1 -1
- package/lib/typescript/src/StaticContainer.d.ts.map +1 -1
- package/lib/typescript/src/StaticNavigation.d.ts +189 -111
- package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/StaticTreeContext.d.ts +4 -0
- package/lib/typescript/src/StaticTreeContext.d.ts.map +1 -0
- package/lib/typescript/src/createNavigationContainerRef.d.ts +1 -1
- package/lib/typescript/src/createNavigationContainerRef.d.ts.map +1 -1
- package/lib/typescript/src/createNavigatorFactory.d.ts +23 -5
- package/lib/typescript/src/createNavigatorFactory.d.ts.map +1 -1
- package/lib/typescript/src/findFocusedRoute.d.ts +3 -8
- package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
- package/lib/typescript/src/getActionFromState.d.ts +4 -4
- package/lib/typescript/src/getActionFromState.d.ts.map +1 -1
- package/lib/typescript/src/getPathFromState.d.ts +3 -3
- package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
- package/lib/typescript/src/getPatternParts.d.ts +5 -2
- package/lib/typescript/src/getPatternParts.d.ts.map +1 -1
- package/lib/typescript/src/getStateFromPath.d.ts +4 -7
- package/lib/typescript/src/getStateFromPath.d.ts.map +1 -1
- package/lib/typescript/src/getStateFromRouteParams.d.ts +3 -0
- package/lib/typescript/src/getStateFromRouteParams.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +36 -33
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/internal.d.ts +3 -0
- package/lib/typescript/src/internal.d.ts.map +1 -0
- package/lib/typescript/src/isRecordEqual.d.ts.map +1 -1
- package/lib/typescript/src/queryString.d.ts +5 -0
- package/lib/typescript/src/queryString.d.ts.map +1 -0
- package/lib/typescript/src/theming/ThemeContext.d.ts +1 -1
- package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -1
- package/lib/typescript/src/theming/ThemeProvider.d.ts +2 -2
- package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/theming/useTheme.d.ts +1 -1
- package/lib/typescript/src/theming/useTheme.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +265 -167
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useChildListeners.d.ts +3 -3
- package/lib/typescript/src/useChildListeners.d.ts.map +1 -1
- package/lib/typescript/src/useDescriptors.d.ts +13 -11
- package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/src/useEventEmitter.d.ts +2 -2
- package/lib/typescript/src/useEventEmitter.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEffect.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEvents.d.ts +2 -2
- package/lib/typescript/src/useFocusEvents.d.ts.map +1 -1
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +2 -2
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts.map +1 -1
- package/lib/typescript/src/useIsFocused.d.ts +4 -0
- package/lib/typescript/src/useIsFocused.d.ts.map +1 -1
- package/lib/typescript/src/useKeyedChildListeners.d.ts +4 -3
- package/lib/typescript/src/useKeyedChildListeners.d.ts.map +1 -1
- package/lib/typescript/src/useLazyValue.d.ts.map +1 -1
- package/lib/typescript/src/useNavigation.d.ts +4 -2
- package/lib/typescript/src/useNavigation.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +22 -63
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationCache.d.ts +6 -5
- package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationContainerRef.d.ts +1 -1
- package/lib/typescript/src/useNavigationContainerRef.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts +18 -58
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationState.d.ts +19 -3
- package/lib/typescript/src/useNavigationState.d.ts.map +1 -1
- package/lib/typescript/src/useOnAction.d.ts +9 -9
- package/lib/typescript/src/useOnAction.d.ts.map +1 -1
- package/lib/typescript/src/useOnGetNavigation.d.ts +12 -0
- package/lib/typescript/src/useOnGetNavigation.d.ts.map +1 -0
- package/lib/typescript/src/useOnGetState.d.ts +1 -1
- package/lib/typescript/src/useOnGetState.d.ts.map +1 -1
- package/lib/typescript/src/useOnPreventRemove.d.ts +5 -9
- package/lib/typescript/src/useOnPreventRemove.d.ts.map +1 -1
- package/lib/typescript/src/useOnRouteFocus.d.ts +6 -6
- package/lib/typescript/src/useOnRouteFocus.d.ts.map +1 -1
- package/lib/typescript/src/useOptionsGetters.d.ts +4 -4
- package/lib/typescript/src/useOptionsGetters.d.ts.map +1 -1
- package/lib/typescript/src/usePreventRemove.d.ts.map +1 -1
- package/lib/typescript/src/usePreventRemoveContext.d.ts +2 -1
- package/lib/typescript/src/usePreventRemoveContext.d.ts.map +1 -1
- package/lib/typescript/src/useRegisterNavigator.d.ts.map +1 -1
- package/lib/typescript/src/useRoute.d.ts +7 -3
- package/lib/typescript/src/useRoute.d.ts.map +1 -1
- package/lib/typescript/src/useRouteCache.d.ts +7 -12
- package/lib/typescript/src/useRouteCache.d.ts.map +1 -1
- package/lib/typescript/src/useScheduleUpdate.d.ts +5 -4
- package/lib/typescript/src/useScheduleUpdate.d.ts.map +1 -1
- package/lib/typescript/src/useStateForPath.d.ts +1 -1
- package/lib/typescript/src/useStateForPath.d.ts.map +1 -1
- package/lib/typescript/src/useSyncState.d.ts +1 -0
- package/lib/typescript/src/useSyncState.d.ts.map +1 -1
- package/lib/typescript/src/utilities.d.ts +79 -39
- package/lib/typescript/src/utilities.d.ts.map +1 -1
- package/lib/typescript/src/validatePathConfig.d.ts.map +1 -1
- package/package.json +26 -22
- package/src/BaseNavigationContainer.tsx +459 -332
- package/src/ConsumedParamsContext.tsx +5 -0
- package/src/DataLoading.tsx +206 -0
- package/src/NavigationBuilderContext.tsx +44 -25
- package/src/NavigationFocusedRouteStateContext.tsx +4 -4
- package/src/NavigationIndependentTree.tsx +60 -12
- package/src/NavigationProvider.tsx +59 -21
- package/src/NavigationRootContext.tsx +11 -0
- package/src/NavigationStateContext.tsx +6 -6
- package/src/PreventRemoveContext.tsx +1 -0
- package/src/PreventRemoveProvider.tsx +55 -56
- package/src/SceneView.tsx +31 -57
- package/src/StaticNavigation.tsx +715 -328
- package/src/StaticTreeContext.tsx +7 -0
- package/src/createNavigationContainerRef.tsx +12 -11
- package/src/createNavigatorFactory.tsx +92 -8
- package/src/findFocusedRoute.tsx +16 -16
- package/src/getActionFromState.tsx +87 -51
- package/src/getPathFromState.tsx +310 -134
- package/src/getPatternParts.tsx +98 -16
- package/src/getStateFromPath.tsx +971 -344
- package/src/getStateFromRouteParams.tsx +59 -0
- package/src/index.tsx +57 -6
- package/src/internal.tsx +2 -0
- package/src/isRecordEqual.tsx +3 -1
- package/src/queryString.ts +109 -0
- package/src/theming/useTheme.tsx +1 -1
- package/src/types.tsx +799 -377
- package/src/useDescriptors.tsx +151 -43
- package/src/useEventEmitter.tsx +53 -39
- package/src/useFocusEffect.tsx +5 -2
- package/src/useFocusEvents.tsx +19 -8
- package/src/useFocusedListenersChildrenAdapter.tsx +3 -3
- package/src/useIsFocused.tsx +18 -21
- package/src/useKeyedChildListeners.tsx +5 -2
- package/src/useLazyValue.tsx +2 -2
- package/src/useNavigation.tsx +9 -26
- package/src/useNavigationBuilder.tsx +370 -201
- package/src/useNavigationCache.tsx +148 -123
- package/src/useNavigationHelpers.tsx +27 -37
- package/src/useNavigationIndependentTree.tsx +1 -1
- package/src/useNavigationState.tsx +207 -69
- package/src/useOnAction.tsx +92 -18
- package/src/useOnGetNavigation.tsx +30 -0
- package/src/useOnGetState.tsx +8 -4
- package/src/useOnPreventRemove.tsx +78 -43
- package/src/useOnRouteFocus.tsx +11 -15
- package/src/useOptionsGetters.tsx +44 -30
- package/src/usePreventRemove.tsx +13 -5
- package/src/usePreventRemoveContext.tsx +2 -2
- package/src/useRegisterNavigator.tsx +4 -4
- package/src/useRoute.tsx +20 -6
- package/src/useRouteCache.tsx +57 -35
- package/src/useScheduleUpdate.tsx +13 -11
- package/src/useStateForPath.tsx +1 -1
- package/src/useSyncState.tsx +39 -15
- package/src/utilities.tsx +151 -35
- package/src/validatePathConfig.tsx +86 -57
- package/lib/module/CurrentRenderContext.js +0 -10
- package/lib/module/CurrentRenderContext.js.map +0 -1
- package/lib/module/NavigationMetaContext.js +0 -15
- package/lib/module/NavigationMetaContext.js.map +0 -1
- package/lib/module/checkSerializable.js +0 -46
- package/lib/module/checkSerializable.js.map +0 -1
- package/lib/module/useComponent.js +0 -34
- package/lib/module/useComponent.js.map +0 -1
- package/lib/module/useCurrentRender.js +0 -19
- package/lib/module/useCurrentRender.js.map +0 -1
- package/lib/typescript/src/CurrentRenderContext.d.ts +0 -9
- package/lib/typescript/src/CurrentRenderContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationMetaContext.d.ts +0 -12
- package/lib/typescript/src/NavigationMetaContext.d.ts.map +0 -1
- package/lib/typescript/src/checkSerializable.d.ts +0 -10
- package/lib/typescript/src/checkSerializable.d.ts.map +0 -1
- package/lib/typescript/src/useComponent.d.ts +0 -7
- package/lib/typescript/src/useComponent.d.ts.map +0 -1
- package/lib/typescript/src/useCurrentRender.d.ts +0 -14
- package/lib/typescript/src/useCurrentRender.d.ts.map +0 -1
- package/src/CurrentRenderContext.tsx +0 -9
- package/src/NavigationMetaContext.tsx +0 -14
- package/src/checkSerializable.tsx +0 -74
- package/src/useComponent.tsx +0 -37
- package/src/useCurrentRender.tsx +0 -31
package/src/useSyncState.tsx
CHANGED
|
@@ -24,12 +24,29 @@ const createStore = <T,>(getInitialState: () => T) => {
|
|
|
24
24
|
let isBatching = false;
|
|
25
25
|
let didUpdate = false;
|
|
26
26
|
|
|
27
|
+
const notify = () => {
|
|
28
|
+
let error: { value: unknown } | undefined;
|
|
29
|
+
|
|
30
|
+
listeners.forEach((listener) => {
|
|
31
|
+
try {
|
|
32
|
+
listener();
|
|
33
|
+
} catch (e) {
|
|
34
|
+
error = error ?? { value: e };
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (error) {
|
|
39
|
+
throw error.value;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
27
43
|
const setState = (newState: T) => {
|
|
28
44
|
state = deepFreeze(newState);
|
|
29
|
-
didUpdate = true;
|
|
30
45
|
|
|
31
|
-
if (
|
|
32
|
-
|
|
46
|
+
if (isBatching) {
|
|
47
|
+
didUpdate = true;
|
|
48
|
+
} else {
|
|
49
|
+
notify();
|
|
33
50
|
}
|
|
34
51
|
};
|
|
35
52
|
|
|
@@ -43,12 +60,16 @@ const createStore = <T,>(getInitialState: () => T) => {
|
|
|
43
60
|
|
|
44
61
|
const batchUpdates = (callback: () => void) => {
|
|
45
62
|
isBatching = true;
|
|
46
|
-
callback();
|
|
47
|
-
isBatching = false;
|
|
48
63
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
try {
|
|
65
|
+
callback();
|
|
66
|
+
} finally {
|
|
67
|
+
isBatching = false;
|
|
68
|
+
|
|
69
|
+
if (didUpdate) {
|
|
70
|
+
didUpdate = false;
|
|
71
|
+
notify();
|
|
72
|
+
}
|
|
52
73
|
}
|
|
53
74
|
};
|
|
54
75
|
|
|
@@ -87,21 +108,23 @@ export function useSyncState<T>(getInitialState: () => T) {
|
|
|
87
108
|
return unsubscribe;
|
|
88
109
|
}, [store]);
|
|
89
110
|
|
|
90
|
-
const
|
|
111
|
+
const pendingUpdates = useLazyValue(() => new Set<() => void>());
|
|
91
112
|
|
|
92
113
|
const scheduleUpdate = useLatestCallback((callback: () => void) => {
|
|
93
|
-
|
|
114
|
+
pendingUpdates.add(callback);
|
|
94
115
|
});
|
|
95
116
|
|
|
96
117
|
const flushUpdates = useLatestCallback(() => {
|
|
97
|
-
|
|
118
|
+
if (pendingUpdates.size !== 0) {
|
|
119
|
+
// Updates are queued child-first as insertion effects run bottom-up.
|
|
120
|
+
// The root navigator replaces the whole state while nested navigators merge into it.
|
|
121
|
+
// So we apply them root-first to avoid the root clobbering nested updates.
|
|
122
|
+
const callbacks = Array.from(pendingUpdates).reverse();
|
|
98
123
|
|
|
99
|
-
|
|
124
|
+
pendingUpdates.clear();
|
|
100
125
|
|
|
101
|
-
if (pendingUpdates.length !== 0) {
|
|
102
126
|
store.batchUpdates(() => {
|
|
103
|
-
|
|
104
|
-
for (const update of pendingUpdates) {
|
|
127
|
+
for (const update of callbacks) {
|
|
105
128
|
update();
|
|
106
129
|
}
|
|
107
130
|
});
|
|
@@ -114,6 +137,7 @@ export function useSyncState<T>(getInitialState: () => T) {
|
|
|
114
137
|
state,
|
|
115
138
|
getState: store.getState,
|
|
116
139
|
setState: store.setState,
|
|
140
|
+
subscribe: store.subscribe,
|
|
117
141
|
scheduleUpdate,
|
|
118
142
|
flushUpdates,
|
|
119
143
|
} as const;
|
package/src/utilities.tsx
CHANGED
|
@@ -15,6 +15,39 @@ export type KeysOf<T> = T extends {} ? keyof T : never;
|
|
|
15
15
|
*/
|
|
16
16
|
export type KeyOf<T extends {}> = Extract<keyof T, string>;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* TS only checks object literals for excess properties when they are not generic.
|
|
20
|
+
* When an object is captured as a generic type, unknown keys are not caught.
|
|
21
|
+
* This builds a type from the provided object where any key not in the allowed type has the type `never`.
|
|
22
|
+
* Checking the provided object against this type then produces an error for each unknown key.
|
|
23
|
+
*
|
|
24
|
+
* When `Provided` has a string index signature (e.g. a type built from `any`,
|
|
25
|
+
* whose `keyof` includes `string`), there are no specific excess keys to flag,
|
|
26
|
+
* so this resolves to an empty type to avoid marking every key as `never`.
|
|
27
|
+
*/
|
|
28
|
+
export type NoExcessObject<Provided, Allowed> = string extends keyof Provided
|
|
29
|
+
? {}
|
|
30
|
+
: Record<Exclude<keyof Provided, keyof Allowed>, never>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Check an object captured as a generic type against an allowed type,
|
|
34
|
+
* e.g. an object returned from a callback isn't checked for excess properties.
|
|
35
|
+
*/
|
|
36
|
+
export type NoExcessCallbackReturn<
|
|
37
|
+
Provided extends {},
|
|
38
|
+
Allowed extends {},
|
|
39
|
+
> = Allowed & Provided & NoExcessObject<Provided, Allowed>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Apply excess property checking to a value,
|
|
43
|
+
* or to the return value if the value is a function.
|
|
44
|
+
*/
|
|
45
|
+
export type NoExcessValue<Provided, Allowed extends {}> = Provided extends (
|
|
46
|
+
...args: never[]
|
|
47
|
+
) => infer Return
|
|
48
|
+
? (...args: never[]) => Allowed & NoExcessObject<Return, Allowed>
|
|
49
|
+
: NoExcessObject<Provided, Allowed>;
|
|
50
|
+
|
|
18
51
|
/**
|
|
19
52
|
* We get a union type when using keyof, but we want an intersection instead.
|
|
20
53
|
* https://stackoverflow.com/a/50375286/1665026
|
|
@@ -25,8 +58,6 @@ export type UnionToIntersection<U> = (
|
|
|
25
58
|
? I
|
|
26
59
|
: never;
|
|
27
60
|
|
|
28
|
-
export type UnknownToUndefined<T> = unknown extends T ? undefined : T;
|
|
29
|
-
|
|
30
61
|
/**
|
|
31
62
|
* Exclude undefined from a type.
|
|
32
63
|
* Similar to NonNullable but only excludes undefined, not null.
|
|
@@ -35,6 +66,33 @@ export type NotUndefined<T> = T extends undefined ? never : T;
|
|
|
35
66
|
|
|
36
67
|
export type AnyToUnknown<T> = 0 extends 1 & T ? unknown : T;
|
|
37
68
|
|
|
69
|
+
export type RequiredKeys<T extends object> = {
|
|
70
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
71
|
+
}[keyof T];
|
|
72
|
+
|
|
73
|
+
type OptionalKeys<T extends object> = Exclude<keyof T, RequiredKeys<T>>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Remove `| undefined` from the object type,
|
|
77
|
+
* and adjust the optionality of the keys based on the original type.
|
|
78
|
+
*/
|
|
79
|
+
export type NotUndefinedObject<
|
|
80
|
+
T extends object | undefined,
|
|
81
|
+
O extends object = NotUndefined<T>,
|
|
82
|
+
> = undefined extends T
|
|
83
|
+
? {
|
|
84
|
+
[K in RequiredKeys<O>]: O[K];
|
|
85
|
+
} & {
|
|
86
|
+
[K in OptionalKeys<O>]?: O[K] | undefined;
|
|
87
|
+
}
|
|
88
|
+
: T;
|
|
89
|
+
|
|
90
|
+
export type UndefinedIfAllOptional<T> = T extends object
|
|
91
|
+
? RequiredKeys<T> extends never
|
|
92
|
+
? T | undefined
|
|
93
|
+
: T
|
|
94
|
+
: T;
|
|
95
|
+
|
|
38
96
|
/**
|
|
39
97
|
* Check if a function type has arguments.
|
|
40
98
|
*/
|
|
@@ -62,61 +120,119 @@ type StripRegex<Param extends string> = Param extends `${infer Name}(${string})`
|
|
|
62
120
|
type ExtractSegmentParam<Segment extends string> =
|
|
63
121
|
Segment extends `:${infer Param}?`
|
|
64
122
|
? { [K in StripRegex<Param>]?: string }
|
|
65
|
-
: Segment extends `:${infer Param}`
|
|
123
|
+
: Segment extends `:${infer Param}${'+' | '*'}`
|
|
66
124
|
? { [K in StripRegex<Param>]: string }
|
|
67
|
-
: {}
|
|
125
|
+
: Segment extends `:${infer Param}`
|
|
126
|
+
? { [K in StripRegex<Param>]: string }
|
|
127
|
+
: {};
|
|
128
|
+
|
|
129
|
+
export type StandardSchemaValidationResult<Output> =
|
|
130
|
+
| { value: Output; issues?: undefined }
|
|
131
|
+
| { value?: undefined; issues: readonly unknown[] };
|
|
132
|
+
|
|
133
|
+
export type StandardSchemaV1<Input = unknown, Output = Input> = {
|
|
134
|
+
readonly '~standard': {
|
|
135
|
+
readonly version: 1;
|
|
136
|
+
readonly vendor: string;
|
|
137
|
+
readonly validate: (
|
|
138
|
+
value: Input
|
|
139
|
+
) =>
|
|
140
|
+
| StandardSchemaValidationResult<Output>
|
|
141
|
+
| Promise<StandardSchemaValidationResult<Output>>;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type QueryParamInput = string | string[] | null | undefined;
|
|
68
146
|
|
|
69
147
|
/**
|
|
70
148
|
* Extract path params from a path string.
|
|
71
149
|
* e.g. `/foo/:userId/:postId` -> `{ userId: string; postId: string }`
|
|
72
150
|
* Supports optional params with `?` suffix.
|
|
151
|
+
* Supports repeated params with `+` and `*` suffixes as strings.
|
|
73
152
|
* Params must start with `:` at the beginning of a segment (after `/`).
|
|
74
153
|
*/
|
|
75
|
-
|
|
154
|
+
type ExtractParamStrings<Path extends string> =
|
|
76
155
|
Path extends `${infer Segment}/${infer Rest}`
|
|
77
156
|
? ExtractSegmentParam<Segment> & ExtractParamStrings<Rest>
|
|
78
157
|
: ExtractSegmentParam<Path>;
|
|
79
158
|
|
|
80
159
|
/**
|
|
81
|
-
*
|
|
82
|
-
* Applies the return type of parse functions to the corresponding params.
|
|
160
|
+
* Get the type of params based on the `parse` config and the path pattern.
|
|
83
161
|
*/
|
|
84
|
-
|
|
162
|
+
type ExtractParamsType<Params, Parse> = {
|
|
163
|
+
/**
|
|
164
|
+
* Base param types from path pattern
|
|
165
|
+
* Refine the type based on standard schema, then parse function
|
|
166
|
+
* Otherwise, use the type from path pattern
|
|
167
|
+
*/
|
|
85
168
|
[K in keyof Params]: K extends keyof Parse
|
|
86
|
-
? Parse[K] extends
|
|
169
|
+
? Parse[K] extends StandardSchemaV1<unknown, infer R>
|
|
87
170
|
? R
|
|
88
|
-
:
|
|
171
|
+
: Parse[K] extends (value: string) => infer R
|
|
172
|
+
? R
|
|
173
|
+
: Params[K]
|
|
89
174
|
: Params[K];
|
|
90
|
-
}
|
|
175
|
+
} & // Query params are the parse keys not present in the path pattern. When there
|
|
176
|
+
// are none (the common case), skip building the query param mapped types.
|
|
177
|
+
([Exclude<keyof Parse, keyof Params>] extends [never]
|
|
178
|
+
? {}
|
|
179
|
+
: {
|
|
180
|
+
/**
|
|
181
|
+
* Optional param types not in path pattern (for query params)
|
|
182
|
+
*/
|
|
183
|
+
[K in QueryParamOptionalKeys<Params, Parse>]?: QueryParamValue<
|
|
184
|
+
Parse[K]
|
|
185
|
+
>;
|
|
186
|
+
} & {
|
|
187
|
+
/**
|
|
188
|
+
* Required param types not in path pattern (for query params)
|
|
189
|
+
*/
|
|
190
|
+
[K in QueryParamRequiredKeys<Params, Parse>]: QueryParamValue<Parse[K]>;
|
|
191
|
+
});
|
|
91
192
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
193
|
+
type QueryParamValue<ParseValue> =
|
|
194
|
+
ParseValue extends StandardSchemaV1<unknown, infer R>
|
|
195
|
+
? R
|
|
196
|
+
: ParseValue extends (value: string) => infer R
|
|
197
|
+
? R
|
|
198
|
+
: never;
|
|
98
199
|
|
|
99
200
|
/**
|
|
100
|
-
*
|
|
201
|
+
* For schema, it's optional if the output has `undefined`, otherwise required
|
|
202
|
+
* For parse function, it's always optional as it can't say if it's required or not
|
|
101
203
|
*/
|
|
102
|
-
|
|
204
|
+
type QueryParamOptionalKeys<Params, Parse> = {
|
|
205
|
+
[K in Exclude<keyof Parse, keyof Params>]: Parse[K] extends StandardSchemaV1<
|
|
206
|
+
unknown,
|
|
207
|
+
infer R
|
|
208
|
+
>
|
|
209
|
+
? undefined extends R
|
|
210
|
+
? K
|
|
211
|
+
: never
|
|
212
|
+
: Parse[K] extends (value: string) => unknown
|
|
213
|
+
? K
|
|
214
|
+
: never;
|
|
215
|
+
}[Exclude<keyof Parse, keyof Params>];
|
|
103
216
|
|
|
104
217
|
/**
|
|
105
|
-
*
|
|
218
|
+
* Exclude optional keys to get required keys
|
|
219
|
+
* For schema, it's required if the output doesn't have `undefined`, otherwise optional
|
|
220
|
+
* It doesn't include parse functions (as they are always optional)
|
|
106
221
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
222
|
+
type QueryParamRequiredKeys<Params, Parse> = Exclude<
|
|
223
|
+
Exclude<keyof Parse, keyof Params>,
|
|
224
|
+
QueryParamOptionalKeys<Params, Parse>
|
|
225
|
+
>;
|
|
226
|
+
|
|
227
|
+
export type InferParamsFromLinking<T> = T extends {
|
|
228
|
+
path: infer P extends string;
|
|
229
|
+
parse: infer Parse;
|
|
230
|
+
}
|
|
231
|
+
? UndefinedIfAllOptional<ExtractParamsType<ExtractParamStrings<P>, Parse>>
|
|
232
|
+
: T extends {
|
|
233
|
+
path: infer P extends string;
|
|
234
|
+
}
|
|
235
|
+
? UndefinedIfAllOptional<ExtractParamStrings<P>>
|
|
236
|
+
: T extends string
|
|
237
|
+
? UndefinedIfAllOptional<ExtractParamStrings<T>>
|
|
122
238
|
: undefined;
|
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const ROOT_VALIDATION_LIST = [
|
|
2
|
+
'- path (string)',
|
|
3
|
+
'- initialRouteName (string)',
|
|
4
|
+
'- screens (object)',
|
|
5
|
+
].join('\n');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const NESTED_VALIDATION_LIST = [
|
|
8
|
+
ROOT_VALIDATION_LIST,
|
|
9
|
+
'- alias (array)',
|
|
10
|
+
'- exact (boolean)',
|
|
11
|
+
'- stringify (object)',
|
|
12
|
+
'- parse (object)',
|
|
13
|
+
'- shared (boolean)',
|
|
14
|
+
].join('\n');
|
|
15
|
+
|
|
16
|
+
const getValidationType = (key: string, root: boolean) => {
|
|
17
|
+
switch (key) {
|
|
18
|
+
case 'path':
|
|
19
|
+
case 'initialRouteName':
|
|
20
|
+
return 'string';
|
|
21
|
+
case 'screens':
|
|
22
|
+
return 'object';
|
|
23
|
+
case 'alias':
|
|
24
|
+
return root ? undefined : 'array';
|
|
25
|
+
case 'exact':
|
|
26
|
+
case 'shared':
|
|
27
|
+
return root ? undefined : 'boolean';
|
|
28
|
+
case 'stringify':
|
|
29
|
+
case 'parse':
|
|
30
|
+
return root ? undefined : 'object';
|
|
31
|
+
default:
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
20
35
|
|
|
36
|
+
export function validatePathConfig(config: unknown, root = true) {
|
|
21
37
|
if (typeof config !== 'object' || config === null) {
|
|
22
38
|
throw new Error(
|
|
23
39
|
`Expected the configuration to be an object, but got ${JSON.stringify(
|
|
@@ -26,58 +42,71 @@ export function validatePathConfig(config: unknown, root = true) {
|
|
|
26
42
|
);
|
|
27
43
|
}
|
|
28
44
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
const pathConfig = config as Record<string, unknown>;
|
|
46
|
+
|
|
47
|
+
let validationErrors: string[] | undefined;
|
|
48
|
+
|
|
49
|
+
for (const key in pathConfig) {
|
|
50
|
+
const type = getValidationType(key, root);
|
|
51
|
+
|
|
52
|
+
if (type === undefined) {
|
|
53
|
+
(validationErrors ??= []).push(`- ${key} (extraneous)`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const value = pathConfig[key];
|
|
58
|
+
|
|
59
|
+
if (value === undefined) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (type === 'array') {
|
|
64
|
+
if (!Array.isArray(value)) {
|
|
65
|
+
(validationErrors ??= []).push(
|
|
66
|
+
`- ${key} (expected 'Array', got '${typeof value}')`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
} else if (typeof value !== type) {
|
|
70
|
+
(validationErrors ??= []).push(
|
|
71
|
+
`- ${key} (expected '${type}', got '${typeof value}')`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (validationErrors) {
|
|
56
77
|
throw new Error(
|
|
57
|
-
`Found invalid properties in the configuration:\n${
|
|
58
|
-
|
|
59
|
-
)}\n\nYou can only specify the following properties:\n${
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
`Found invalid properties in the configuration:\n${validationErrors.join(
|
|
79
|
+
'\n'
|
|
80
|
+
)}\n\nYou can only specify the following properties:\n${
|
|
81
|
+
root ? ROOT_VALIDATION_LIST : NESTED_VALIDATION_LIST
|
|
82
|
+
}\n\nIf you want to specify configuration for screens, you need to specify them under a 'screens' property.\n\nSee https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`
|
|
62
83
|
);
|
|
63
84
|
}
|
|
64
85
|
|
|
86
|
+
const path = pathConfig.path;
|
|
87
|
+
|
|
65
88
|
if (
|
|
66
89
|
root &&
|
|
67
|
-
'path' in
|
|
68
|
-
typeof
|
|
69
|
-
|
|
90
|
+
'path' in pathConfig &&
|
|
91
|
+
typeof path === 'string' &&
|
|
92
|
+
path.includes(':')
|
|
70
93
|
) {
|
|
71
94
|
throw new Error(
|
|
72
|
-
`Found invalid path '${
|
|
95
|
+
`Found invalid path '${path}'. The 'path' in the top-level configuration cannot contain patterns for params.`
|
|
73
96
|
);
|
|
74
97
|
}
|
|
75
98
|
|
|
76
|
-
|
|
77
|
-
|
|
99
|
+
const screens = pathConfig.screens;
|
|
100
|
+
|
|
101
|
+
if (screens && typeof screens === 'object') {
|
|
102
|
+
const screenConfig = screens as Record<string, unknown>;
|
|
103
|
+
|
|
104
|
+
for (const name in screenConfig) {
|
|
105
|
+
const value = screenConfig[name];
|
|
106
|
+
|
|
78
107
|
if (typeof value !== 'string') {
|
|
79
108
|
validatePathConfig(value, false);
|
|
80
109
|
}
|
|
81
|
-
}
|
|
110
|
+
}
|
|
82
111
|
}
|
|
83
112
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Context which holds the values for the current navigation tree.
|
|
7
|
-
* Intended for use in SSR. This is not safe to use on the client.
|
|
8
|
-
*/
|
|
9
|
-
export const CurrentRenderContext = /*#__PURE__*/React.createContext(undefined);
|
|
10
|
-
//# sourceMappingURL=CurrentRenderContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","CurrentRenderContext","createContext","undefined"],"sourceRoot":"../../src","sources":["CurrentRenderContext.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;;AAE9B;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,gBAAGD,KAAK,CAACE,aAAa,CAErDC,SAAS,CAAC","ignoreList":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Context with additional metadata to pass to child navigator in a screen.
|
|
7
|
-
* For example, child native stack to know it's inside native tabs.
|
|
8
|
-
* So it doesn't implement features such as `popToTop` that are handled by native tabs.
|
|
9
|
-
*
|
|
10
|
-
* Consumers should not make any assumptions about the shape of the object.
|
|
11
|
-
* It can be different depending on the navigator and may change without notice.
|
|
12
|
-
* This is not intended to be used by application code.
|
|
13
|
-
*/
|
|
14
|
-
export const NavigationMetaContext = /*#__PURE__*/React.createContext(undefined);
|
|
15
|
-
//# sourceMappingURL=NavigationMetaContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","NavigationMetaContext","createContext","undefined"],"sourceRoot":"../../src","sources":["NavigationMetaContext.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,gBAAGD,KAAK,CAACE,aAAa,CACtDC,SACF,CAAC","ignoreList":[]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const checkSerializableWithoutCircularReference = (o, seen, location) => {
|
|
4
|
-
if (o === undefined || o === null || typeof o === 'boolean' || typeof o === 'number' || typeof o === 'string') {
|
|
5
|
-
return {
|
|
6
|
-
serializable: true
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
if (Object.prototype.toString.call(o) !== '[object Object]' && !Array.isArray(o)) {
|
|
10
|
-
return {
|
|
11
|
-
serializable: false,
|
|
12
|
-
location,
|
|
13
|
-
reason: typeof o === 'function' ? 'Function' : String(o)
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
if (seen.has(o)) {
|
|
17
|
-
return {
|
|
18
|
-
serializable: false,
|
|
19
|
-
reason: 'Circular reference',
|
|
20
|
-
location
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
seen.add(o);
|
|
24
|
-
if (Array.isArray(o)) {
|
|
25
|
-
for (let i = 0; i < o.length; i++) {
|
|
26
|
-
const childResult = checkSerializableWithoutCircularReference(o[i], new Set(seen), [...location, i]);
|
|
27
|
-
if (!childResult.serializable) {
|
|
28
|
-
return childResult;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
for (const key in o) {
|
|
33
|
-
const childResult = checkSerializableWithoutCircularReference(o[key], new Set(seen), [...location, key]);
|
|
34
|
-
if (!childResult.serializable) {
|
|
35
|
-
return childResult;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
serializable: true
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
export function checkSerializable(o) {
|
|
44
|
-
return checkSerializableWithoutCircularReference(o, new Set(), []);
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=checkSerializable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["checkSerializableWithoutCircularReference","o","seen","location","undefined","serializable","Object","prototype","toString","call","Array","isArray","reason","String","has","add","i","length","childResult","Set","key","checkSerializable"],"sourceRoot":"../../src","sources":["checkSerializable.tsx"],"mappings":";;AAAA,MAAMA,yCAAyC,GAAGA,CAChDC,CAAyB,EACzBC,IAAc,EACdC,QAA6B,KAOtB;EACP,IACEF,CAAC,KAAKG,SAAS,IACfH,CAAC,KAAK,IAAI,IACV,OAAOA,CAAC,KAAK,SAAS,IACtB,OAAOA,CAAC,KAAK,QAAQ,IACrB,OAAOA,CAAC,KAAK,QAAQ,EACrB;IACA,OAAO;MAAEI,YAAY,EAAE;IAAK,CAAC;EAC/B;EAEA,IACEC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACR,CAAC,CAAC,KAAK,iBAAiB,IACvD,CAACS,KAAK,CAACC,OAAO,CAACV,CAAC,CAAC,EACjB;IACA,OAAO;MACLI,YAAY,EAAE,KAAK;MACnBF,QAAQ;MACRS,MAAM,EAAE,OAAOX,CAAC,KAAK,UAAU,GAAG,UAAU,GAAGY,MAAM,CAACZ,CAAC;IACzD,CAAC;EACH;EAEA,IAAIC,IAAI,CAACY,GAAG,CAACb,CAAC,CAAC,EAAE;IACf,OAAO;MACLI,YAAY,EAAE,KAAK;MACnBO,MAAM,EAAE,oBAAoB;MAC5BT;IACF,CAAC;EACH;EAEAD,IAAI,CAACa,GAAG,CAACd,CAAC,CAAC;EAEX,IAAIS,KAAK,CAACC,OAAO,CAACV,CAAC,CAAC,EAAE;IACpB,KAAK,IAAIe,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGf,CAAC,CAACgB,MAAM,EAAED,CAAC,EAAE,EAAE;MACjC,MAAME,WAAW,GAAGlB,yCAAyC,CAC3DC,CAAC,CAACe,CAAC,CAAC,EACJ,IAAIG,GAAG,CAAMjB,IAAI,CAAC,EAClB,CAAC,GAAGC,QAAQ,EAAEa,CAAC,CACjB,CAAC;MAED,IAAI,CAACE,WAAW,CAACb,YAAY,EAAE;QAC7B,OAAOa,WAAW;MACpB;IACF;EACF,CAAC,MAAM;IACL,KAAK,MAAME,GAAG,IAAInB,CAAC,EAAE;MACnB,MAAMiB,WAAW,GAAGlB,yCAAyC,CAC3DC,CAAC,CAACmB,GAAG,CAAC,EACN,IAAID,GAAG,CAAMjB,IAAI,CAAC,EAClB,CAAC,GAAGC,QAAQ,EAAEiB,GAAG,CACnB,CAAC;MAED,IAAI,CAACF,WAAW,CAACb,YAAY,EAAE;QAC7B,OAAOa,WAAW;MACpB;IACF;EACF;EAEA,OAAO;IAAEb,YAAY,EAAE;EAAK,CAAC;AAC/B,CAAC;AAED,OAAO,SAASgB,iBAAiBA,CAACpB,CAAyB,EAAE;EAC3D,OAAOD,yCAAyC,CAACC,CAAC,EAAE,IAAIkB,GAAG,CAAM,CAAC,EAAE,EAAE,CAAC;AACzE","ignoreList":[]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const NavigationContent = ({
|
|
6
|
-
render,
|
|
7
|
-
children
|
|
8
|
-
}) => {
|
|
9
|
-
return render(children);
|
|
10
|
-
};
|
|
11
|
-
export function useComponent(render) {
|
|
12
|
-
const renderRef = React.useRef(render);
|
|
13
|
-
|
|
14
|
-
// Normally refs shouldn't be mutated in render
|
|
15
|
-
// But we return a component which will be rendered
|
|
16
|
-
// So it's just for immediate consumption
|
|
17
|
-
renderRef.current = render;
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
renderRef.current = null;
|
|
20
|
-
});
|
|
21
|
-
return React.useRef(({
|
|
22
|
-
children
|
|
23
|
-
}) => {
|
|
24
|
-
const render = renderRef.current;
|
|
25
|
-
if (render === null) {
|
|
26
|
-
throw new Error('The returned component must be rendered in the same render phase as the hook.');
|
|
27
|
-
}
|
|
28
|
-
return /*#__PURE__*/_jsx(NavigationContent, {
|
|
29
|
-
render: render,
|
|
30
|
-
children: children
|
|
31
|
-
});
|
|
32
|
-
}).current;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=useComponent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","jsx","_jsx","NavigationContent","render","children","useComponent","renderRef","useRef","current","useEffect","Error"],"sourceRoot":"../../src","sources":["useComponent.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS/B,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC,MAAM;EAAEC;AAAgB,CAAC,KAAK;EACzD,OAAOD,MAAM,CAACC,QAAQ,CAAC;AACzB,CAAC;AAED,OAAO,SAASC,YAAYA,CAACF,MAAc,EAAE;EAC3C,MAAMG,SAAS,GAAGP,KAAK,CAACQ,MAAM,CAAgBJ,MAAM,CAAC;;EAErD;EACA;EACA;EACAG,SAAS,CAACE,OAAO,GAAGL,MAAM;EAE1BJ,KAAK,CAACU,SAAS,CAAC,MAAM;IACpBH,SAAS,CAACE,OAAO,GAAG,IAAI;EAC1B,CAAC,CAAC;EAEF,OAAOT,KAAK,CAACQ,MAAM,CAAC,CAAC;IAAEH;EAAwC,CAAC,KAAK;IACnE,MAAMD,MAAM,GAAGG,SAAS,CAACE,OAAO;IAEhC,IAAIL,MAAM,KAAK,IAAI,EAAE;MACnB,MAAM,IAAIO,KAAK,CACb,+EACF,CAAC;IACH;IAEA,oBAAOT,IAAA,CAACC,iBAAiB;MAACC,MAAM,EAAEA,MAAO;MAAAC,QAAA,EAAEA;IAAQ,CAAoB,CAAC;EAC1E,CAAC,CAAC,CAACI,OAAO;AACZ","ignoreList":[]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { CurrentRenderContext } from "./CurrentRenderContext.js";
|
|
5
|
-
/**
|
|
6
|
-
* Write the current options, so that server renderer can get current values
|
|
7
|
-
* Mutating values like this is not safe in async mode, but it doesn't apply to SSR
|
|
8
|
-
*/
|
|
9
|
-
export function useCurrentRender({
|
|
10
|
-
state,
|
|
11
|
-
navigation,
|
|
12
|
-
descriptors
|
|
13
|
-
}) {
|
|
14
|
-
const current = React.useContext(CurrentRenderContext);
|
|
15
|
-
if (current && navigation.isFocused()) {
|
|
16
|
-
current.options = descriptors[state.routes[state.index].key].options;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=useCurrentRender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","CurrentRenderContext","useCurrentRender","state","navigation","descriptors","current","useContext","isFocused","options","routes","index","key"],"sourceRoot":"../../src","sources":["useCurrentRender.tsx"],"mappings":";;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,oBAAoB,QAAQ,2BAAwB;AAiB7D;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAC;EAAEC,KAAK;EAAEC,UAAU;EAAEC;AAAqB,CAAC,EAAE;EAC5E,MAAMC,OAAO,GAAGN,KAAK,CAACO,UAAU,CAACN,oBAAoB,CAAC;EAEtD,IAAIK,OAAO,IAAIF,UAAU,CAACI,SAAS,CAAC,CAAC,EAAE;IACrCF,OAAO,CAACG,OAAO,GAAGJ,WAAW,CAACF,KAAK,CAACO,MAAM,CAACP,KAAK,CAACQ,KAAK,CAAC,CAACC,GAAG,CAAC,CAACH,OAAO;EACtE;AACF","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Context which holds the values for the current navigation tree.
|
|
4
|
-
* Intended for use in SSR. This is not safe to use on the client.
|
|
5
|
-
*/
|
|
6
|
-
export declare const CurrentRenderContext: React.Context<{
|
|
7
|
-
options?: object;
|
|
8
|
-
} | undefined>;
|
|
9
|
-
//# sourceMappingURL=CurrentRenderContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CurrentRenderContext.d.ts","sourceRoot":"","sources":["../../../src/CurrentRenderContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;GAGG;AACH,eAAO,MAAM,oBAAoB;cACnB,MAAM;cACR,CAAC"}
|