@react-navigation/routers 8.0.0-alpha.1 → 8.0.0-alpha.10

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/routers",
3
3
  "description": "Routers to help build custom navigators",
4
- "version": "8.0.0-alpha.1",
4
+ "version": "8.0.0-alpha.10",
5
5
  "keywords": [
6
6
  "react",
7
7
  "react-native",
@@ -41,13 +41,13 @@
41
41
  "clean": "del lib"
42
42
  },
43
43
  "dependencies": {
44
- "nanoid": "^3.3.11"
44
+ "nanoid": "^5.1.7"
45
45
  },
46
46
  "devDependencies": {
47
- "@jest/globals": "^30.0.0",
48
- "del-cli": "^6.0.0",
49
- "react-native-builder-bob": "^0.40.12",
50
- "typescript": "^5.9.2"
47
+ "@jest/globals": "^30.3.0",
48
+ "del-cli": "^7.0.0",
49
+ "react-native-builder-bob": "^0.41.0",
50
+ "typescript": "^6.0.2"
51
51
  },
52
52
  "react-native-builder-bob": {
53
53
  "source": "src",
@@ -67,5 +67,5 @@
67
67
  ]
68
68
  ]
69
69
  },
70
- "gitHead": "9664da8fff3bd7ed575bf12ddfcc47b3a42be997"
70
+ "gitHead": "11b013e6d14d19aa56f1bcbd3255b4e19083cd6b"
71
71
  }
@@ -71,10 +71,12 @@ export const BaseRouter = {
71
71
  case 'RESET': {
72
72
  const nextState = action.payload as State | PartialState<State>;
73
73
 
74
+ const routeNamesSet = new Set(state.routeNames);
75
+
74
76
  if (
75
77
  nextState.routes.length === 0 ||
76
78
  nextState.routes.some(
77
- (route: { name: string }) => !state.routeNames.includes(route.name)
79
+ (route: { name: string }) => !routeNamesSet.has(route.name)
78
80
  )
79
81
  ) {
80
82
  return null;
@@ -83,9 +85,7 @@ export const BaseRouter = {
83
85
  if (nextState.stale === false) {
84
86
  if (
85
87
  state.routeNames.length !== nextState.routeNames.length ||
86
- nextState.routeNames.some(
87
- (name) => !state.routeNames.includes(name)
88
- )
88
+ nextState.routeNames.some((name) => !routeNamesSet.has(name))
89
89
  ) {
90
90
  return null;
91
91
  }
@@ -9,59 +9,59 @@ type ResetState =
9
9
 
10
10
  type GoBackAction = {
11
11
  type: 'GO_BACK';
12
- source?: string;
13
- target?: string;
12
+ source?: string | undefined;
13
+ target?: string | undefined;
14
14
  };
15
15
 
16
16
  type NavigateAction = {
17
17
  type: 'NAVIGATE';
18
18
  payload: {
19
19
  name: string;
20
- params?: object;
21
- path?: string;
22
- merge?: boolean;
23
- pop?: boolean;
20
+ params?: object | undefined;
21
+ path?: string | undefined;
22
+ merge?: boolean | undefined;
23
+ pop?: boolean | undefined;
24
24
  };
25
- source?: string;
26
- target?: string;
25
+ source?: string | undefined;
26
+ target?: string | undefined;
27
27
  };
28
28
 
29
29
  type ResetAction = {
30
30
  type: 'RESET';
31
- payload: ResetState | undefined;
32
- source?: string;
33
- target?: string;
31
+ payload: ResetState;
32
+ source?: string | undefined;
33
+ target?: string | undefined;
34
34
  };
35
35
 
36
36
  type SetParamsAction = {
37
37
  type: 'SET_PARAMS';
38
- payload: { params?: object };
39
- source?: string;
40
- target?: string;
38
+ payload: { params?: object | undefined };
39
+ source?: string | undefined;
40
+ target?: string | undefined;
41
41
  };
42
42
 
43
43
  type ReplaceParamsAction = {
44
44
  type: 'REPLACE_PARAMS';
45
- payload: { params?: object };
46
- source?: string;
47
- target?: string;
45
+ payload: { params?: object | undefined };
46
+ source?: string | undefined;
47
+ target?: string | undefined;
48
48
  };
49
49
 
50
50
  type PushParamsAction = {
51
51
  type: 'PUSH_PARAMS';
52
- payload: { params?: object };
53
- source?: string;
54
- target?: string;
52
+ payload: { params?: object | undefined };
53
+ source?: string | undefined;
54
+ target?: string | undefined;
55
55
  };
56
56
 
57
57
  type PreloadAction = {
58
58
  type: 'PRELOAD';
59
59
  payload: {
60
60
  name: string;
61
- params?: object;
61
+ params?: object | undefined;
62
62
  };
63
- source?: string;
64
- target?: string;
63
+ source?: string | undefined;
64
+ target?: string | undefined;
65
65
  };
66
66
 
67
67
  export type Action =
@@ -79,19 +79,21 @@ export function goBack(): Action {
79
79
 
80
80
  export function navigate(
81
81
  name: string,
82
- params?: object,
83
- options?: {
84
- merge?: boolean;
85
- pop?: boolean;
86
- }
82
+ params?: object | undefined,
83
+ options?:
84
+ | {
85
+ merge?: boolean | undefined;
86
+ pop?: boolean | undefined;
87
+ }
88
+ | undefined
87
89
  ): Action;
88
90
 
89
91
  export function navigate(options: {
90
92
  name: string;
91
- params?: object;
92
- path?: string;
93
- merge?: boolean;
94
- pop?: boolean;
93
+ params?: object | undefined;
94
+ path?: string | undefined;
95
+ merge?: boolean | undefined;
96
+ pop?: boolean | undefined;
95
97
  }): Action;
96
98
 
97
99
  export function navigate(...args: any): Action {
@@ -120,7 +122,7 @@ export function navigate(...args: any): Action {
120
122
  }
121
123
  }
122
124
 
123
- export function reset(state: ResetState | undefined) {
125
+ export function reset(state: ResetState) {
124
126
  return { type: 'RESET', payload: state } as const satisfies ResetAction;
125
127
  }
126
128
 
@@ -145,7 +147,7 @@ export function pushParams(params: object) {
145
147
  } as const satisfies PushParamsAction;
146
148
  }
147
149
 
148
- export function preload(name: string, params?: object) {
150
+ export function preload(name: string, params?: object | undefined) {
149
151
  return {
150
152
  type: 'PRELOAD',
151
153
  payload: { name, params },
@@ -20,12 +20,12 @@ export type DrawerActionType =
20
20
  | TabActionType
21
21
  | {
22
22
  type: 'OPEN_DRAWER' | 'CLOSE_DRAWER' | 'TOGGLE_DRAWER';
23
- source?: string;
24
- target?: string;
23
+ source?: string | undefined;
24
+ target?: string | undefined;
25
25
  };
26
26
 
27
27
  export type DrawerRouterOptions = TabRouterOptions & {
28
- defaultStatus?: DrawerStatus;
28
+ defaultStatus?: DrawerStatus | undefined;
29
29
  };
30
30
 
31
31
  export type DrawerNavigationState<ParamList extends ParamListBase> = Omit<