@react-navigation/core 8.0.0-alpha.4 → 8.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/NavigationBuilderContext.js.map +1 -1
- package/lib/module/NavigationIndependentTree.js +8 -4
- package/lib/module/NavigationIndependentTree.js.map +1 -1
- package/lib/module/NavigationProvider.js +14 -3
- package/lib/module/NavigationProvider.js.map +1 -1
- package/lib/module/NavigationStateContext.js.map +1 -1
- package/lib/module/SceneView.js +6 -39
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/StaticNavigation.js.map +1 -1
- package/lib/module/getPathFromState.js +24 -2
- package/lib/module/getPathFromState.js.map +1 -1
- package/lib/module/getStateFromPath.js +157 -72
- package/lib/module/getStateFromPath.js.map +1 -1
- package/lib/module/getStateFromRouteParams.js +24 -0
- package/lib/module/getStateFromRouteParams.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useIsFocused.js +7 -12
- package/lib/module/useIsFocused.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +71 -28
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/useOnRouteFocus.js.map +1 -1
- package/lib/typescript/src/NavigationBuilderContext.d.ts +5 -5
- package/lib/typescript/src/NavigationBuilderContext.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/NavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/NavigationProvider.d.ts +4 -4
- package/lib/typescript/src/NavigationProvider.d.ts.map +1 -1
- package/lib/typescript/src/NavigationStateContext.d.ts +3 -3
- package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -1
- package/lib/typescript/src/SceneView.d.ts.map +1 -1
- package/lib/typescript/src/StaticNavigation.d.ts +5 -5
- package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/findFocusedRoute.d.ts +3 -3
- package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
- package/lib/typescript/src/getActionFromState.d.ts +3 -3
- package/lib/typescript/src/getActionFromState.d.ts.map +1 -1
- package/lib/typescript/src/getPathFromState.d.ts +2 -2
- package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
- package/lib/typescript/src/getStateFromPath.d.ts +3 -3
- 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 +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +64 -64
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useDescriptors.d.ts +2 -2
- package/lib/typescript/src/useIsFocused.d.ts +3 -0
- package/lib/typescript/src/useIsFocused.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +17 -17
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts +15 -15
- package/lib/typescript/src/useOnAction.d.ts +6 -6
- package/lib/typescript/src/useOnAction.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/useRouteCache.d.ts +2 -2
- package/lib/typescript/src/utilities.d.ts +35 -3
- package/lib/typescript/src/utilities.d.ts.map +1 -1
- package/package.json +10 -8
- package/src/BaseNavigationContainer.tsx +1 -1
- package/src/NavigationBuilderContext.tsx +7 -8
- package/src/NavigationFocusedRouteStateContext.tsx +4 -4
- package/src/NavigationIndependentTree.tsx +8 -5
- package/src/NavigationProvider.tsx +17 -3
- package/src/NavigationStateContext.tsx +5 -6
- package/src/SceneView.tsx +6 -36
- package/src/StaticNavigation.tsx +13 -5
- package/src/findFocusedRoute.tsx +3 -3
- package/src/getActionFromState.tsx +7 -7
- package/src/getPathFromState.tsx +52 -8
- package/src/getStateFromPath.tsx +254 -96
- package/src/getStateFromRouteParams.tsx +60 -0
- package/src/index.tsx +1 -0
- package/src/types.tsx +164 -120
- package/src/useIsFocused.tsx +14 -21
- package/src/useNavigationBuilder.tsx +116 -41
- package/src/useOnAction.tsx +7 -7
- package/src/useOnRouteFocus.tsx +9 -11
- package/src/utilities.tsx +72 -4
|
@@ -13,40 +13,40 @@ export declare function useNavigationBuilder<State extends NavigationState, Rout
|
|
|
13
13
|
navigation: {
|
|
14
14
|
dispatch(action: Readonly<{
|
|
15
15
|
type: string;
|
|
16
|
-
payload?: object;
|
|
17
|
-
source?: string;
|
|
18
|
-
target?: string;
|
|
16
|
+
payload?: object | undefined;
|
|
17
|
+
source?: string | undefined;
|
|
18
|
+
target?: string | undefined;
|
|
19
19
|
}> | ((state: Readonly<Readonly<{
|
|
20
20
|
key: string;
|
|
21
21
|
index: number;
|
|
22
22
|
routeNames: string[];
|
|
23
|
-
history?: unknown[];
|
|
23
|
+
history?: unknown[] | undefined;
|
|
24
24
|
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
25
25
|
type: string;
|
|
26
26
|
stale: false;
|
|
27
27
|
}>>) => Readonly<{
|
|
28
28
|
type: string;
|
|
29
|
-
payload?: object;
|
|
30
|
-
source?: string;
|
|
31
|
-
target?: string;
|
|
29
|
+
payload?: object | undefined;
|
|
30
|
+
source?: string | undefined;
|
|
31
|
+
target?: string | undefined;
|
|
32
32
|
}>)): void;
|
|
33
33
|
navigate<RouteName extends string>(...args: RouteName extends unknown ? [screen: RouteName, params?: object | undefined, options?: {
|
|
34
|
-
merge?: boolean;
|
|
35
|
-
pop?: boolean;
|
|
34
|
+
merge?: boolean | undefined;
|
|
35
|
+
pop?: boolean | undefined;
|
|
36
36
|
} | undefined] : never): void;
|
|
37
37
|
navigate<RouteName extends string>(options: RouteName extends unknown ? {
|
|
38
38
|
name: RouteName;
|
|
39
39
|
params: object | undefined;
|
|
40
|
-
path?: string;
|
|
41
|
-
merge?: boolean;
|
|
42
|
-
pop?: boolean;
|
|
40
|
+
path?: string | undefined;
|
|
41
|
+
merge?: boolean | undefined;
|
|
42
|
+
pop?: boolean | undefined;
|
|
43
43
|
} : never): void;
|
|
44
44
|
preload<RouteName extends string>(...args: RouteName extends unknown ? [screen: RouteName, params?: object | undefined] : never): void;
|
|
45
45
|
reset(state: Readonly<{
|
|
46
46
|
key: string;
|
|
47
47
|
index: number;
|
|
48
48
|
routeNames: string[];
|
|
49
|
-
history?: unknown[];
|
|
49
|
+
history?: unknown[] | undefined;
|
|
50
50
|
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
51
51
|
type: string;
|
|
52
52
|
stale: false;
|
|
@@ -54,7 +54,7 @@ export declare function useNavigationBuilder<State extends NavigationState, Rout
|
|
|
54
54
|
key: string;
|
|
55
55
|
index: number;
|
|
56
56
|
routeNames: string[];
|
|
57
|
-
history?: unknown[];
|
|
57
|
+
history?: unknown[] | undefined;
|
|
58
58
|
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
59
59
|
type: string;
|
|
60
60
|
stale: false;
|
|
@@ -66,7 +66,7 @@ export declare function useNavigationBuilder<State extends NavigationState, Rout
|
|
|
66
66
|
key: string;
|
|
67
67
|
index: number;
|
|
68
68
|
routeNames: string[];
|
|
69
|
-
history?: unknown[];
|
|
69
|
+
history?: unknown[] | undefined;
|
|
70
70
|
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
71
71
|
type: string;
|
|
72
72
|
stale: false;
|
|
@@ -79,11 +79,11 @@ export declare function useNavigationBuilder<State extends NavigationState, Rout
|
|
|
79
79
|
descriptors: Record<string, import("./types").Descriptor<ScreenOptions, import("./types").NavigationProp<ParamListBase, string, State, ScreenOptions, EventMap, ActionHelpers>, Readonly<{
|
|
80
80
|
key: string;
|
|
81
81
|
name: string;
|
|
82
|
-
path?: string;
|
|
82
|
+
path?: string | undefined;
|
|
83
83
|
history?: {
|
|
84
84
|
type: "params";
|
|
85
85
|
params: object;
|
|
86
|
-
}[];
|
|
86
|
+
}[] | undefined;
|
|
87
87
|
} & Readonly<{
|
|
88
88
|
params?: Readonly<object | undefined>;
|
|
89
89
|
}>>>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigationBuilder.d.ts","sourceRoot":"","sources":["../../../src/useNavigationBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EAIjB,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,OAAO,EACL,KAAK,uBAAuB,EAI5B,iBAAiB,EAElB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useNavigationBuilder.d.ts","sourceRoot":"","sources":["../../../src/useNavigationBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EAIjB,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,OAAO,EACL,KAAK,uBAAuB,EAI5B,iBAAiB,EAElB,MAAM,SAAS,CAAC;AAwQjB;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,SAAS,eAAe,EAC7B,aAAa,SAAS,oBAAoB,EAC1C,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC,EAC5D,aAAa,SAAS,EAAE,EACxB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAEpC,YAAY,EAAE,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,aAAa,CAAC,EACnE,OAAO,EAAE,uBAAuB,CAC9B,aAAa,EACb,KAAK,EACL,aAAa,EACb,QAAQ,EACR,GAAG,CACJ,GACC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAusBhB"}
|
|
@@ -17,40 +17,40 @@ type Options<State extends NavigationState, Action extends NavigationAction> = {
|
|
|
17
17
|
export declare function useNavigationHelpers<State extends NavigationState, ActionHelpers extends Record<string, (...args: any) => void>, Action extends NavigationAction, EventMap extends Record<string, any>>({ onAction, onUnhandledAction, getState, emitter, router, stateRef, }: Options<State, Action>): {
|
|
18
18
|
dispatch(action: Readonly<{
|
|
19
19
|
type: string;
|
|
20
|
-
payload?: object;
|
|
21
|
-
source?: string;
|
|
22
|
-
target?: string;
|
|
20
|
+
payload?: object | undefined;
|
|
21
|
+
source?: string | undefined;
|
|
22
|
+
target?: string | undefined;
|
|
23
23
|
}> | ((state: Readonly<Readonly<{
|
|
24
24
|
key: string;
|
|
25
25
|
index: number;
|
|
26
26
|
routeNames: string[];
|
|
27
|
-
history?: unknown[];
|
|
27
|
+
history?: unknown[] | undefined;
|
|
28
28
|
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
29
29
|
type: string;
|
|
30
30
|
stale: false;
|
|
31
31
|
}>>) => Readonly<{
|
|
32
32
|
type: string;
|
|
33
|
-
payload?: object;
|
|
34
|
-
source?: string;
|
|
35
|
-
target?: string;
|
|
33
|
+
payload?: object | undefined;
|
|
34
|
+
source?: string | undefined;
|
|
35
|
+
target?: string | undefined;
|
|
36
36
|
}>)): void;
|
|
37
37
|
navigate<RouteName extends string>(...args: RouteName extends unknown ? [screen: RouteName, params?: object | undefined, options?: {
|
|
38
|
-
merge?: boolean;
|
|
39
|
-
pop?: boolean;
|
|
38
|
+
merge?: boolean | undefined;
|
|
39
|
+
pop?: boolean | undefined;
|
|
40
40
|
} | undefined] : never): void;
|
|
41
41
|
navigate<RouteName extends string>(options: RouteName extends unknown ? {
|
|
42
42
|
name: RouteName;
|
|
43
43
|
params: object | undefined;
|
|
44
|
-
path?: string;
|
|
45
|
-
merge?: boolean;
|
|
46
|
-
pop?: boolean;
|
|
44
|
+
path?: string | undefined;
|
|
45
|
+
merge?: boolean | undefined;
|
|
46
|
+
pop?: boolean | undefined;
|
|
47
47
|
} : never): void;
|
|
48
48
|
preload<RouteName extends string>(...args: RouteName extends unknown ? [screen: RouteName, params?: object | undefined] : never): void;
|
|
49
49
|
reset(state: Readonly<{
|
|
50
50
|
key: string;
|
|
51
51
|
index: number;
|
|
52
52
|
routeNames: string[];
|
|
53
|
-
history?: unknown[];
|
|
53
|
+
history?: unknown[] | undefined;
|
|
54
54
|
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
55
55
|
type: string;
|
|
56
56
|
stale: false;
|
|
@@ -58,7 +58,7 @@ export declare function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
58
58
|
key: string;
|
|
59
59
|
index: number;
|
|
60
60
|
routeNames: string[];
|
|
61
|
-
history?: unknown[];
|
|
61
|
+
history?: unknown[] | undefined;
|
|
62
62
|
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
63
63
|
type: string;
|
|
64
64
|
stale: false;
|
|
@@ -70,7 +70,7 @@ export declare function useNavigationHelpers<State extends NavigationState, Acti
|
|
|
70
70
|
key: string;
|
|
71
71
|
index: number;
|
|
72
72
|
routeNames: string[];
|
|
73
|
-
history?: unknown[];
|
|
73
|
+
history?: unknown[] | undefined;
|
|
74
74
|
routes: import("@react-navigation/routers").NavigationRoute<ParamListBase, string>[];
|
|
75
75
|
type: string;
|
|
76
76
|
stale: false;
|
|
@@ -2,11 +2,11 @@ import type { NavigationAction, NavigationState, PartialState, Router, RouterCon
|
|
|
2
2
|
import { type ChildActionListener, type ChildBeforeRemoveListener } from './NavigationBuilderContext';
|
|
3
3
|
import type { EventMapCore } from './types';
|
|
4
4
|
import type { NavigationEventEmitter } from './useEventEmitter';
|
|
5
|
-
type Options = {
|
|
6
|
-
router: Router<
|
|
7
|
-
key?: string;
|
|
8
|
-
getState: () =>
|
|
9
|
-
setState: (state:
|
|
5
|
+
type Options<State extends NavigationState> = {
|
|
6
|
+
router: Router<State, NavigationAction>;
|
|
7
|
+
key?: string | undefined;
|
|
8
|
+
getState: () => State;
|
|
9
|
+
setState: (state: State | PartialState<State>) => void;
|
|
10
10
|
actionListeners: ChildActionListener[];
|
|
11
11
|
beforeRemoveListeners: Record<string, ChildBeforeRemoveListener | undefined>;
|
|
12
12
|
routerConfigOptions: RouterConfigOptions;
|
|
@@ -21,6 +21,6 @@ type Options = {
|
|
|
21
21
|
*
|
|
22
22
|
* When the action handler handles as action, it returns `true`, otherwise `false`.
|
|
23
23
|
*/
|
|
24
|
-
export declare function useOnAction({ router, getState, setState, key, actionListeners, beforeRemoveListeners, routerConfigOptions, emitter, }: Options): (action: NavigationAction, visitedNavigators?: Set<string>) => boolean;
|
|
24
|
+
export declare function useOnAction<State extends NavigationState>({ router, getState, setState, key, actionListeners, beforeRemoveListeners, routerConfigOptions, emitter, }: Options<State>): (action: NavigationAction, visitedNavigators?: Set<string>) => boolean;
|
|
25
25
|
export {};
|
|
26
26
|
//# sourceMappingURL=useOnAction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnAction.d.ts","sourceRoot":"","sources":["../../../src/useOnAction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,MAAM,EACN,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAE/B,MA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,EAAE,OAAO,CAAC,KAAK,CAAC,YAiBH,gBAAgB,sBACL,GAAG,CAAC,MAAM,CAAC,aAuGnC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { NavigationAction, NavigationState, Router } from '@react-navigation/routers';
|
|
2
|
-
type Options<Action extends NavigationAction> = {
|
|
3
|
-
router: Router<
|
|
4
|
-
getState: () =>
|
|
5
|
-
setState: (state:
|
|
6
|
-
key?: string;
|
|
2
|
+
type Options<State extends NavigationState, Action extends NavigationAction> = {
|
|
3
|
+
router: Router<State, Action>;
|
|
4
|
+
getState: () => State;
|
|
5
|
+
setState: (state: State) => void;
|
|
6
|
+
key?: string | undefined;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Hook to handle focus actions for a route.
|
|
10
10
|
* Focus action needs to be treated specially, coz when a nested route is focused,
|
|
11
11
|
* the parent navigators also needs to be focused.
|
|
12
12
|
*/
|
|
13
|
-
export declare function useOnRouteFocus<Action extends NavigationAction>({ router, getState, key: sourceRouteKey, setState
|
|
13
|
+
export declare function useOnRouteFocus<State extends NavigationState, Action extends NavigationAction>({ router, getState, key: sourceRouteKey, setState }: Options<State, Action>): (key: string) => void;
|
|
14
14
|
export {};
|
|
15
15
|
//# sourceMappingURL=useOnRouteFocus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnRouteFocus.d.ts","sourceRoot":"","sources":["../../../src/useOnRouteFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,MAAM,EACP,MAAM,2BAA2B,CAAC;AAKnC,KAAK,OAAO,CAAC,MAAM,SAAS,gBAAgB,IAAI;
|
|
1
|
+
{"version":3,"file":"useOnRouteFocus.d.ts","sourceRoot":"","sources":["../../../src/useOnRouteFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,MAAM,EACP,MAAM,2BAA2B,CAAC;AAKnC,KAAK,OAAO,CAAC,KAAK,SAAS,eAAe,EAAE,MAAM,SAAS,gBAAgB,IAAI;IAC7E,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,KAAK,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,SAAS,eAAe,EAC7B,MAAM,SAAS,gBAAgB,EAC/B,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,SAMnE,MAAM,UAcf"}
|
|
@@ -12,11 +12,11 @@ export declare const CHILD_STATE: unique symbol;
|
|
|
12
12
|
export declare function useRouteCache<State extends NavigationState>(routes: State['routes']): Readonly<{
|
|
13
13
|
key: string;
|
|
14
14
|
name: string;
|
|
15
|
-
path?: string;
|
|
15
|
+
path?: string | undefined;
|
|
16
16
|
history?: {
|
|
17
17
|
type: "params";
|
|
18
18
|
params: object;
|
|
19
|
-
}[];
|
|
19
|
+
}[] | undefined;
|
|
20
20
|
} & Readonly<{
|
|
21
21
|
params?: Readonly<object | undefined>;
|
|
22
22
|
}>>[];
|
|
@@ -45,6 +45,21 @@ type ExtractSegmentParam<Segment extends string> = Segment extends `:${infer Par
|
|
|
45
45
|
} : Segment extends `:${infer Param}` ? {
|
|
46
46
|
[K in StripRegex<Param>]: string;
|
|
47
47
|
} : {};
|
|
48
|
+
export type StandardSchemaValidationResult<Output> = {
|
|
49
|
+
value: Output;
|
|
50
|
+
issues?: undefined;
|
|
51
|
+
} | {
|
|
52
|
+
value?: undefined;
|
|
53
|
+
issues: readonly unknown[];
|
|
54
|
+
};
|
|
55
|
+
export type StandardSchemaV1<Input = unknown, Output = Input> = {
|
|
56
|
+
readonly '~standard': {
|
|
57
|
+
readonly version: 1;
|
|
58
|
+
readonly vendor: string;
|
|
59
|
+
readonly validate: (value: Input) => StandardSchemaValidationResult<Output> | Promise<StandardSchemaValidationResult<Output>>;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export type QueryParamInput = string | string[] | null | undefined;
|
|
48
63
|
/**
|
|
49
64
|
* Extract path params from a path string.
|
|
50
65
|
* e.g. `/foo/:userId/:postId` -> `{ userId: string; postId: string }`
|
|
@@ -53,12 +68,29 @@ type ExtractSegmentParam<Segment extends string> = Segment extends `:${infer Par
|
|
|
53
68
|
*/
|
|
54
69
|
export type ExtractParamStrings<Path extends string> = Path extends `${infer Segment}/${infer Rest}` ? ExtractSegmentParam<Segment> & ExtractParamStrings<Rest> : ExtractSegmentParam<Path>;
|
|
55
70
|
/**
|
|
56
|
-
*
|
|
57
|
-
* Applies the return type of parse functions to the corresponding params.
|
|
71
|
+
* Get the type of params based on the `parse` config and the path pattern.
|
|
58
72
|
*/
|
|
59
73
|
export type ExtractParamsType<Params, Parse> = {
|
|
60
|
-
[K in keyof Params]: K extends keyof Parse ? Parse[K] extends (value: string) => infer R ? R : Params[K] : Params[K];
|
|
74
|
+
[K in keyof Params]: K extends keyof Parse ? Parse[K] extends StandardSchemaV1<unknown, infer R> ? R : Parse[K] extends (value: string) => infer R ? R : Params[K] : Params[K];
|
|
75
|
+
} & {
|
|
76
|
+
[K in QueryParamOptionalKeys<Params, Parse>]?: QueryParamValue<Parse[K]>;
|
|
77
|
+
} & {
|
|
78
|
+
[K in QueryParamRequiredKeys<Params, Parse>]: QueryParamValue<Parse[K]>;
|
|
61
79
|
};
|
|
80
|
+
type QueryParamValue<ParseValue> = ParseValue extends StandardSchemaV1<unknown, infer R> ? R : ParseValue extends (value: string) => infer R ? R : never;
|
|
81
|
+
/**
|
|
82
|
+
* For schema, it's optional if the output has `undefined`, otherwise required
|
|
83
|
+
* For parse function, it's always optional as it can't say if it's required or not
|
|
84
|
+
*/
|
|
85
|
+
type QueryParamOptionalKeys<Params, Parse> = {
|
|
86
|
+
[K in Exclude<keyof Parse, keyof Params>]: Parse[K] extends StandardSchemaV1<unknown, infer R> ? undefined extends R ? K : never : Parse[K] extends (value: string) => unknown ? K : never;
|
|
87
|
+
}[Exclude<keyof Parse, keyof Params>];
|
|
88
|
+
/**
|
|
89
|
+
* Exclude optional keys to get required keys
|
|
90
|
+
* For schema, it's required if the output doesn't have `undefined`, otherwise optional
|
|
91
|
+
* It doesn't include parse functions (as they are always optional)
|
|
92
|
+
*/
|
|
93
|
+
type QueryParamRequiredKeys<Params, Parse> = Exclude<Exclude<keyof Parse, keyof Params>, QueryParamOptionalKeys<Params, Parse>>;
|
|
62
94
|
/**
|
|
63
95
|
* Infer the path string from a linking config.
|
|
64
96
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../src/utilities.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CACnC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GAC1B,CAAC,GACD,KAAK,CAAC;AAEV,MAAM,MAAM,kBAAkB,CAAC,C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O,CAAC,CAAC,CAAC,SAAS;QAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GACpC,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC;QAAE,KAAK,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC,CAAA;SAAE,CAAA;KAAE,CAAC,GAC3D,CAAC,GACD,SAAS,GACX,SAAS;CAChB,CAAC,GACF,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/core",
|
|
3
3
|
"description": "Core utilities for building navigators",
|
|
4
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.5",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
7
7
|
"react-native",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"clean": "del lib"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@react-navigation/routers": "^8.0.0-alpha.
|
|
43
|
+
"@react-navigation/routers": "^8.0.0-alpha.3",
|
|
44
44
|
"escape-string-regexp": "^4.0.0",
|
|
45
45
|
"fast-deep-equal": "^3.1.3",
|
|
46
46
|
"nanoid": "^3.3.11",
|
|
@@ -51,16 +51,18 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@jest/globals": "^30.0.0",
|
|
54
|
-
"@testing-library/react-native": "^13.
|
|
55
|
-
"@types/react": "~19.
|
|
54
|
+
"@testing-library/react-native": "^13.3.3",
|
|
55
|
+
"@types/react": "~19.2.2",
|
|
56
56
|
"@types/react-is": "^19.0.0",
|
|
57
57
|
"@types/use-sync-external-store": "^1.5.0",
|
|
58
58
|
"del-cli": "^6.0.0",
|
|
59
59
|
"immer": "^10.1.1",
|
|
60
|
-
"react": "19.
|
|
60
|
+
"react": "19.2.0",
|
|
61
61
|
"react-native-builder-bob": "^0.40.12",
|
|
62
|
-
"react-test-renderer": "19.
|
|
63
|
-
"typescript": "^5.9.2"
|
|
62
|
+
"react-test-renderer": "19.2.0",
|
|
63
|
+
"typescript": "^5.9.2",
|
|
64
|
+
"valibot": "^1.2.0",
|
|
65
|
+
"zod": "^4.3.6"
|
|
64
66
|
},
|
|
65
67
|
"peerDependencies": {
|
|
66
68
|
"react": ">= 19.0.0"
|
|
@@ -83,5 +85,5 @@
|
|
|
83
85
|
]
|
|
84
86
|
]
|
|
85
87
|
},
|
|
86
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "4ac6c41c1f751fba9dd82db050865bc71f3310f5"
|
|
87
89
|
}
|
|
@@ -151,7 +151,7 @@ export const BaseNavigationContainer = React.forwardRef(
|
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
const resetRoot = useLatestCallback(
|
|
154
|
-
(state
|
|
154
|
+
(state: PartialState<NavigationState> | NavigationState) => {
|
|
155
155
|
const target = state?.key ?? keyedListeners.getState.root?.().key;
|
|
156
156
|
|
|
157
157
|
if (target == null) {
|
|
@@ -52,13 +52,12 @@ export type ChildBeforeRemoveListener = (action: NavigationAction) => boolean;
|
|
|
52
52
|
* Context which holds the required helpers needed to build nested navigators.
|
|
53
53
|
*/
|
|
54
54
|
export const NavigationBuilderContext = React.createContext<{
|
|
55
|
-
onAction?:
|
|
56
|
-
action: NavigationAction,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
onRouteFocus?: (key: string) => void;
|
|
55
|
+
onAction?:
|
|
56
|
+
| ((action: NavigationAction, visitedNavigators?: Set<string>) => boolean)
|
|
57
|
+
| undefined;
|
|
58
|
+
addListener?: AddListener | undefined;
|
|
59
|
+
addKeyedListener?: AddKeyedListener | undefined;
|
|
60
|
+
onRouteFocus?: ((key: string) => void) | undefined;
|
|
62
61
|
onDispatchAction: (action: NavigationAction, noop: boolean) => void;
|
|
63
62
|
onEmitEvent: (event: {
|
|
64
63
|
type: string;
|
|
@@ -69,7 +68,7 @@ export const NavigationBuilderContext = React.createContext<{
|
|
|
69
68
|
onOptionsChange: (options: object) => void;
|
|
70
69
|
scheduleUpdate: (callback: () => void) => void;
|
|
71
70
|
flushUpdates: () => void;
|
|
72
|
-
stackRef?: React.MutableRefObject<string | undefined
|
|
71
|
+
stackRef?: React.MutableRefObject<string | undefined> | undefined;
|
|
73
72
|
}>({
|
|
74
73
|
onDispatchAction: () => undefined,
|
|
75
74
|
onEmitEvent: () => undefined,
|
|
@@ -3,11 +3,11 @@ import * as React from 'react';
|
|
|
3
3
|
export type FocusedRouteState = {
|
|
4
4
|
routes: [
|
|
5
5
|
{
|
|
6
|
-
key?: string;
|
|
6
|
+
key?: string | undefined;
|
|
7
7
|
name: string;
|
|
8
|
-
params?: object;
|
|
9
|
-
path?: string;
|
|
10
|
-
state?: FocusedRouteState;
|
|
8
|
+
params?: object | undefined;
|
|
9
|
+
path?: string | undefined;
|
|
10
|
+
state?: FocusedRouteState | undefined;
|
|
11
11
|
},
|
|
12
12
|
];
|
|
13
13
|
};
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
NavigationRouteContext,
|
|
8
8
|
NavigationRouteNameContext,
|
|
9
9
|
} from './NavigationProvider';
|
|
10
|
+
import { IsFocusedContext } from './useIsFocused';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Component to make the child navigation container independent of parent containers.
|
|
@@ -21,11 +22,13 @@ export function NavigationIndependentTree({
|
|
|
21
22
|
<NamedRouteContextListContext.Provider value={undefined}>
|
|
22
23
|
<NavigationRouteContext.Provider value={undefined}>
|
|
23
24
|
<NavigationContext.Provider value={undefined}>
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
<IsFocusedContext.Provider value={undefined}>
|
|
26
|
+
<NavigationRouteNameContext.Provider value={undefined}>
|
|
27
|
+
<NavigationIndependentTreeContext.Provider value={true}>
|
|
28
|
+
{children}
|
|
29
|
+
</NavigationIndependentTreeContext.Provider>
|
|
30
|
+
</NavigationRouteNameContext.Provider>
|
|
31
|
+
</IsFocusedContext.Provider>
|
|
29
32
|
</NavigationContext.Provider>
|
|
30
33
|
</NavigationRouteContext.Provider>
|
|
31
34
|
</NamedRouteContextListContext.Provider>
|
|
@@ -2,6 +2,7 @@ import type { ParamListBase, Route } from '@react-navigation/routers';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
import type { NavigationProp } from './types';
|
|
5
|
+
import { FocusedRouteKeyContext, IsFocusedContext } from './useIsFocused';
|
|
5
6
|
import { useLazyValue } from './useLazyValue';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -48,14 +49,27 @@ export function NavigationProvider({ route, navigation, children }: Props) {
|
|
|
48
49
|
[NamedRouteContext, parents, route.name]
|
|
49
50
|
);
|
|
50
51
|
|
|
52
|
+
const parentIsFocused = React.useContext(IsFocusedContext);
|
|
53
|
+
const focusedRouteKey = React.useContext(FocusedRouteKeyContext);
|
|
54
|
+
|
|
55
|
+
// Mark route as focused only if:
|
|
56
|
+
// - It doesn't have a parent navigator
|
|
57
|
+
// - Parent navigator is focused
|
|
58
|
+
const isFocused =
|
|
59
|
+
parentIsFocused == null || parentIsFocused
|
|
60
|
+
? focusedRouteKey === route.key
|
|
61
|
+
: false;
|
|
62
|
+
|
|
51
63
|
return (
|
|
52
64
|
<NamedRouteContextListContext.Provider value={NamedRouteContextList}>
|
|
53
65
|
<NamedRouteContext.Provider value={route}>
|
|
54
66
|
<NavigationRouteContext.Provider value={route}>
|
|
55
67
|
<NavigationContext.Provider value={navigation}>
|
|
56
|
-
<
|
|
57
|
-
{
|
|
58
|
-
|
|
68
|
+
<IsFocusedContext.Provider value={isFocused}>
|
|
69
|
+
<NavigationRouteNameContext.Provider value={route.name}>
|
|
70
|
+
{children}
|
|
71
|
+
</NavigationRouteNameContext.Provider>
|
|
72
|
+
</IsFocusedContext.Provider>
|
|
59
73
|
</NavigationContext.Provider>
|
|
60
74
|
</NavigationRouteContext.Provider>
|
|
61
75
|
</NamedRouteContext.Provider>
|
|
@@ -5,8 +5,8 @@ const MISSING_CONTEXT_ERROR =
|
|
|
5
5
|
"Couldn't find a navigation context. Have you wrapped your app with 'NavigationContainer'? See https://reactnavigation.org/docs/getting-started for setup instructions.";
|
|
6
6
|
|
|
7
7
|
export const NavigationStateContext = React.createContext<{
|
|
8
|
-
isDefault?: true;
|
|
9
|
-
state?: NavigationState | PartialState<NavigationState
|
|
8
|
+
isDefault?: true | undefined;
|
|
9
|
+
state?: NavigationState | PartialState<NavigationState> | undefined;
|
|
10
10
|
getKey: () => string | undefined;
|
|
11
11
|
setKey: (key: string) => void;
|
|
12
12
|
getState: () => NavigationState | PartialState<NavigationState> | undefined;
|
|
@@ -14,10 +14,9 @@ export const NavigationStateContext = React.createContext<{
|
|
|
14
14
|
state: NavigationState | PartialState<NavigationState> | undefined
|
|
15
15
|
) => void;
|
|
16
16
|
getIsInitial: () => boolean;
|
|
17
|
-
addOptionsGetter?:
|
|
18
|
-
key: string,
|
|
19
|
-
|
|
20
|
-
) => void;
|
|
17
|
+
addOptionsGetter?:
|
|
18
|
+
| ((key: string, getter: () => object | undefined | null) => void)
|
|
19
|
+
| undefined;
|
|
21
20
|
}>({
|
|
22
21
|
isDefault: true,
|
|
23
22
|
|
package/src/SceneView.tsx
CHANGED
|
@@ -70,46 +70,16 @@ export function SceneView<
|
|
|
70
70
|
const state = getState();
|
|
71
71
|
|
|
72
72
|
const routes = state.routes.map((r) => {
|
|
73
|
-
if (r.key
|
|
74
|
-
return
|
|
73
|
+
if (r.key === route.key && r.state !== child) {
|
|
74
|
+
return {
|
|
75
|
+
...r,
|
|
76
|
+
state: child,
|
|
77
|
+
};
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// Before updating the state, cleanup any nested screen and state
|
|
80
|
-
// This will avoid the navigator trying to handle them again
|
|
81
|
-
if (
|
|
82
|
-
nextRoute.params &&
|
|
83
|
-
(('state' in nextRoute.params &&
|
|
84
|
-
typeof nextRoute.params.state === 'object' &&
|
|
85
|
-
nextRoute.params.state !== null) ||
|
|
86
|
-
('screen' in nextRoute.params &&
|
|
87
|
-
typeof nextRoute.params.screen === 'string'))
|
|
88
|
-
) {
|
|
89
|
-
// @ts-expect-error: we don't have correct type for params
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
-
const { state, screen, params, initial, ...rest } = nextRoute.params;
|
|
92
|
-
|
|
93
|
-
if (Object.keys(rest).length) {
|
|
94
|
-
return { ...nextRoute, params: rest };
|
|
95
|
-
} else {
|
|
96
|
-
const {
|
|
97
|
-
// We destructure the params to omit them
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
99
|
-
params,
|
|
100
|
-
...restRoute
|
|
101
|
-
} = nextRoute;
|
|
102
|
-
|
|
103
|
-
return restRoute;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return nextRoute;
|
|
80
|
+
return r;
|
|
108
81
|
});
|
|
109
82
|
|
|
110
|
-
// Make sure not to update state if routes haven't changed
|
|
111
|
-
// Otherwise this will result in params cleanup as well
|
|
112
|
-
// We only want to cleanup params when state changes - after they are used
|
|
113
83
|
if (!isArrayEqual(state.routes, routes)) {
|
|
114
84
|
setState({
|
|
115
85
|
...state,
|
package/src/StaticNavigation.tsx
CHANGED
|
@@ -28,6 +28,7 @@ import type {
|
|
|
28
28
|
InferParse,
|
|
29
29
|
InferPath,
|
|
30
30
|
KeysOf,
|
|
31
|
+
StandardSchemaV1,
|
|
31
32
|
UnionToIntersection,
|
|
32
33
|
ValidPathPattern,
|
|
33
34
|
} from './utilities';
|
|
@@ -147,7 +148,7 @@ type StaticScreenConfigLinkingAlias = {
|
|
|
147
148
|
*/
|
|
148
149
|
exact?: boolean;
|
|
149
150
|
/**
|
|
150
|
-
* An object mapping the param name to a function
|
|
151
|
+
* An object mapping the param name to a parser function or a Standard Schema.
|
|
151
152
|
*
|
|
152
153
|
* @example
|
|
153
154
|
* ```js
|
|
@@ -157,7 +158,11 @@ type StaticScreenConfigLinkingAlias = {
|
|
|
157
158
|
* }
|
|
158
159
|
* ```
|
|
159
160
|
*/
|
|
160
|
-
parse?: Record<
|
|
161
|
+
parse?: Record<
|
|
162
|
+
string,
|
|
163
|
+
| ((value: string) => unknown)
|
|
164
|
+
| StandardSchemaV1<string | string[] | null | undefined, unknown>
|
|
165
|
+
>;
|
|
161
166
|
/**
|
|
162
167
|
* An object mapping the param name to a function which converts the param value to a string.
|
|
163
168
|
* By default, all params are converted to strings using `String(value)`.
|
|
@@ -332,7 +337,10 @@ type StaticConfigScreens<
|
|
|
332
337
|
| StaticScreenConfig<
|
|
333
338
|
| {
|
|
334
339
|
path: string;
|
|
335
|
-
parse?: Record<
|
|
340
|
+
parse?: Record<
|
|
341
|
+
string,
|
|
342
|
+
((value: string) => any) | StandardSchemaV1<any, any>
|
|
343
|
+
>;
|
|
336
344
|
}
|
|
337
345
|
| string
|
|
338
346
|
| undefined,
|
|
@@ -722,7 +730,7 @@ type TreeForPathConfig = {
|
|
|
722
730
|
export function createPathConfigForStaticNavigation(
|
|
723
731
|
tree: TreeForPathConfig,
|
|
724
732
|
options?: {
|
|
725
|
-
initialRouteName?: string;
|
|
733
|
+
initialRouteName?: string | undefined;
|
|
726
734
|
},
|
|
727
735
|
auto?: boolean
|
|
728
736
|
): PathConfigMap<ParamListBase> | undefined {
|
|
@@ -731,7 +739,7 @@ export function createPathConfigForStaticNavigation(
|
|
|
731
739
|
|
|
732
740
|
const createPathConfigForTree = (
|
|
733
741
|
t: TreeForPathConfig,
|
|
734
|
-
o: { initialRouteName?: string } | undefined,
|
|
742
|
+
o: { initialRouteName?: string | undefined } | undefined,
|
|
735
743
|
// If a screen is a leaf node, but inside a screen with path,
|
|
736
744
|
// It should not be used for initial detection
|
|
737
745
|
skipInitialDetection: boolean
|
package/src/findFocusedRoute.tsx
CHANGED
|
@@ -2,10 +2,10 @@ import type { InitialState } from '@react-navigation/routers';
|
|
|
2
2
|
|
|
3
3
|
type Result =
|
|
4
4
|
| {
|
|
5
|
-
key?: string;
|
|
5
|
+
key?: string | undefined;
|
|
6
6
|
name: string;
|
|
7
|
-
params?: object;
|
|
8
|
-
path?: string;
|
|
7
|
+
params?: object | undefined;
|
|
8
|
+
path?: string | undefined;
|
|
9
9
|
}
|
|
10
10
|
| undefined;
|
|
11
11
|
|