@react-navigation/routers 8.0.0-alpha.10 → 8.0.0-alpha.11
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/StackRouter.js +91 -23
- package/lib/module/StackRouter.js.map +1 -1
- package/lib/module/TabRouter.js +52 -11
- package/lib/module/TabRouter.js.map +1 -1
- package/lib/typescript/src/BaseRouter.d.ts +1 -1
- package/lib/typescript/src/BaseRouter.d.ts.map +1 -1
- package/lib/typescript/src/CommonActions.d.ts +1 -1
- package/lib/typescript/src/CommonActions.d.ts.map +1 -1
- package/lib/typescript/src/DrawerRouter.d.ts +2 -2
- package/lib/typescript/src/DrawerRouter.d.ts.map +1 -1
- package/lib/typescript/src/StackRouter.d.ts +2 -2
- package/lib/typescript/src/StackRouter.d.ts.map +1 -1
- package/lib/typescript/src/TabRouter.d.ts +2 -2
- package/lib/typescript/src/TabRouter.d.ts.map +1 -1
- package/lib/typescript/src/createParamsFromAction.d.ts +1 -1
- package/lib/typescript/src/createParamsFromAction.d.ts.map +1 -1
- package/lib/typescript/src/createRouteFromAction.d.ts +1 -1
- package/lib/typescript/src/createRouteFromAction.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +9 -9
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +3 -3
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/StackRouter.tsx +129 -17
- package/src/TabRouter.tsx +75 -14
- package/src/types.tsx +13 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackRouter.d.ts","sourceRoot":"","sources":["../../../src/StackRouter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,oBAAoB,EACpB,eAAe,EACf,aAAa,EAEb,MAAM,EACP,MAAM,
|
|
1
|
+
{"version":3,"file":"StackRouter.d.ts","sourceRoot":"","sources":["../../../src/StackRouter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,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AAC;IAE1B;;OAEG;IACH,QAAQ,IAAI,IAAI,CAAC;IAEjB;;;;;;;OAOG;IACH,KAAK,CAAC,SAAS,SAAS,MAAM,SAAS,EACrC,GAAG,IAAI,EAAE,SAAS,SAAS,OAAO,GAC9B,SAAS,SAAS,SAAS,CAAC,SAAS,CAAC,GACpC;QACE,MAAM,EAAE,SAAS;QACjB,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC;QAC7B,OAAO,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,OAAO,CAAA;SAAE;KAC9B,GACD;QACE,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC;QAC5B,OAAO,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,OAAO,CAAA;SAAE;KAC9B,GACH,KAAK,GACR,IAAI,CAAC;IAER;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,YAAY;kBACT,MAAM,WAAW,MAAM;;;;;;;eAM1B,MAAM,WAAW,MAAM;;;;;;;gBAMvB,MAAM;;;;;;;;;gBASL,MAAM,WAAW,MAAM,YAAY;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;;;;;;;;mBAUnD,OAAO;;;;;;CAMvB,CAAC;AA6FF,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,sGAsxBtD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DefaultRouterOptions, NavigationState, ParamListBase, Router } from './types';
|
|
1
|
+
import type { DefaultRouterOptions, NavigationState, ParamListBase, Router } from './types.js';
|
|
2
2
|
export type TabActionType = {
|
|
3
3
|
type: 'JUMP_TO';
|
|
4
4
|
payload: {
|
|
@@ -57,5 +57,5 @@ export declare const TabActions: {
|
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
-
export declare function TabRouter({ initialRouteName, backBehavior, }: TabRouterOptions): Router<TabNavigationState<ParamListBase>, import("./CommonActions").Action | TabActionType>;
|
|
60
|
+
export declare function TabRouter({ initialRouteName, backBehavior, }: TabRouterOptions): Router<TabNavigationState<ParamListBase>, import("./CommonActions.js").Action | TabActionType>;
|
|
61
61
|
//# sourceMappingURL=TabRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabRouter.d.ts","sourceRoot":"","sources":["../../../src/TabRouter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,oBAAoB,EACpB,eAAe,EACf,aAAa,EAGb,MAAM,EACP,MAAM,
|
|
1
|
+
{"version":3,"file":"TabRouter.d.ts","sourceRoot":"","sources":["../../../src/TabRouter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,oBAAoB,EACpB,eAAe,EACf,aAAa,EAGb,MAAM,EACP,MAAM,YAAS,CAAC;AAEjB,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IACvD,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,cAAc,GACd,OAAO,GACP,SAAS,GACT,aAAa,GACb,MAAM,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG;IACpD;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,SAAS,SAAS,aAAa,IAAI,IAAI,CACpE,eAAe,CAAC,SAAS,CAAC,EAC1B,SAAS,CACV,GAAG;IACF;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IACZ;;OAEG;IACH,OAAO,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,EAAE,CAAC;IACvE;;OAEG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,SAAS,SAAS,aAAa,IAAI;IAC9D;;;;;OAKG;IACH,MAAM,CAAC,SAAS,SAAS,MAAM,SAAS,EACtC,GAAG,IAAI,EAAE,SAAS,SAAS,OAAO,GAC9B,SAAS,SAAS,SAAS,CAAC,SAAS,CAAC,GACpC,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,GAClD,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,GACnD,KAAK,GACR,IAAI,CAAC;CACT,CAAC;AAIF,eAAO,MAAM,UAAU;iBACR,MAAM,WAAW,MAAM;;;;;;;CAMrC,CAAC;AA2IF,wBAAgB,SAAS,CAAC,EACxB,gBAAgB,EAChB,YAA2B,GAC5B,EAAE,gBAAgB,kGAiXlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createParamsFromAction.d.ts","sourceRoot":"","sources":["../../../src/createParamsFromAction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createParamsFromAction.d.ts","sourceRoot":"","sources":["../../../src/createParamsFromAction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAS,CAAC;AAE7C,KAAK,OAAO,GAAG;IACb,MAAM,EAAE;QACN,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;SAC7B,CAAC;KACH,CAAC;IACF,cAAc,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,OAAO,sBASzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRouteFromAction.d.ts","sourceRoot":"","sources":["../../../src/createRouteFromAction.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createRouteFromAction.d.ts","sourceRoot":"","sources":["../../../src/createRouteFromAction.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAS,CAAC;AAE7C,KAAK,OAAO,GAAG;IACb,MAAM,EAAE;QACN,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;SAC7B,CAAC;KACH,CAAC;IACF,cAAc,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,OAAO;;;;EAQxE"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as CommonActions from './CommonActions';
|
|
1
|
+
import * as CommonActions from './CommonActions.js';
|
|
2
2
|
export { CommonActions };
|
|
3
|
-
export { BaseRouter } from './BaseRouter';
|
|
4
|
-
export type { DrawerActionHelpers, DrawerActionType, DrawerNavigationState, DrawerRouterOptions, DrawerStatus, } from './DrawerRouter';
|
|
5
|
-
export { DrawerActions, DrawerRouter } from './DrawerRouter';
|
|
6
|
-
export type { StackActionHelpers, StackActionType, StackNavigationState, StackRouterOptions, } from './StackRouter';
|
|
7
|
-
export { StackActions, StackRouter } from './StackRouter';
|
|
8
|
-
export type { TabActionHelpers, TabActionType, TabNavigationState, TabRouterOptions, } from './TabRouter';
|
|
9
|
-
export { TabActions, TabRouter } from './TabRouter';
|
|
10
|
-
export * from './types';
|
|
3
|
+
export { BaseRouter } from './BaseRouter.js';
|
|
4
|
+
export type { DrawerActionHelpers, DrawerActionType, DrawerNavigationState, DrawerRouterOptions, DrawerStatus, } from './DrawerRouter.js';
|
|
5
|
+
export { DrawerActions, DrawerRouter } from './DrawerRouter.js';
|
|
6
|
+
export type { StackActionHelpers, StackActionType, StackNavigationState, StackRouterOptions, } from './StackRouter.js';
|
|
7
|
+
export { StackActions, StackRouter } from './StackRouter.js';
|
|
8
|
+
export type { TabActionHelpers, TabActionType, TabNavigationState, TabRouterOptions, } from './TabRouter.js';
|
|
9
|
+
export { TabActions, TabRouter } from './TabRouter.js';
|
|
10
|
+
export * from './types.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,oBAAiB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAC1C,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,GACb,MAAM,mBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AAC7D,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,kBAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AAC1D,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,gBAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AACpD,cAAc,YAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as CommonActions from './CommonActions';
|
|
1
|
+
import type * as CommonActions from './CommonActions.js';
|
|
2
2
|
export type CommonNavigationAction = CommonActions.Action;
|
|
3
3
|
export type NavigationRoute<ParamList extends ParamListBase, RouteName extends keyof ParamList> = Route<Extract<RouteName, string>, ParamList[RouteName]> & {
|
|
4
4
|
state?: NavigationState | PartialState<NavigationState> | undefined;
|
|
@@ -69,7 +69,7 @@ export type Route<RouteName extends string, Params extends unknown | object | un
|
|
|
69
69
|
type: 'params';
|
|
70
70
|
params: object;
|
|
71
71
|
}[] | undefined;
|
|
72
|
-
} &
|
|
72
|
+
} & (undefined extends Params ? {
|
|
73
73
|
/**
|
|
74
74
|
* Params for this route
|
|
75
75
|
*/
|
|
@@ -79,7 +79,7 @@ export type Route<RouteName extends string, Params extends unknown | object | un
|
|
|
79
79
|
* Params for this route
|
|
80
80
|
*/
|
|
81
81
|
params: Readonly<Params>;
|
|
82
|
-
}
|
|
82
|
+
})>;
|
|
83
83
|
export type ParamListBase = Record<string, object | undefined>;
|
|
84
84
|
export type NavigationAction = Readonly<{
|
|
85
85
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,aAAa,MAAM,oBAAiB,CAAC;AAEtD,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC,MAAM,CAAC;AAE1D,MAAM,MAAM,eAAe,CACzB,SAAS,SAAS,aAAa,EAC/B,SAAS,SAAS,MAAM,SAAS,IAC/B,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EA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BAAmB,GAAG;QAC7B;;;WAGG;QACH,eAAe,EAAE,MAAM,EAAE,CAAC;KAC3B,GACA,KAAK,CAAC;IAET;;;;;OAKG;IACH,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;IAExD;;;;;;;;OAQG;IACH,iBAAiB,CACf,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,mBAAmB,GAC3B,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAEtC;;;;OAIG;IACH,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAE3D;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACzC,CAAC"}
|
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.
|
|
4
|
+
"version": "8.0.0-alpha.11",
|
|
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": "^5.1.
|
|
44
|
+
"nanoid": "^5.1.11"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@jest/globals": "^
|
|
47
|
+
"@jest/globals": "^29.7.0",
|
|
48
48
|
"del-cli": "^7.0.0",
|
|
49
|
-
"react-native-builder-bob": "^0.
|
|
50
|
-
"typescript": "^6.0.
|
|
49
|
+
"react-native-builder-bob": "^0.42.1",
|
|
50
|
+
"typescript": "^6.0.3"
|
|
51
51
|
},
|
|
52
52
|
"react-native-builder-bob": {
|
|
53
53
|
"source": "src",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
]
|
|
68
68
|
]
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "9c6b764c575fdf7e3c27df37f820899dda9d4259"
|
|
71
71
|
}
|
package/src/StackRouter.tsx
CHANGED
|
@@ -289,6 +289,12 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
289
289
|
? options.initialRouteName
|
|
290
290
|
: routeNames[0];
|
|
291
291
|
|
|
292
|
+
if (initialRouteName == null) {
|
|
293
|
+
throw new Error(
|
|
294
|
+
"Couldn't initialize the stack navigator. Have you defined any screens?"
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
292
298
|
return {
|
|
293
299
|
stale: false,
|
|
294
300
|
type: 'stack',
|
|
@@ -333,6 +339,12 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
333
339
|
? options.initialRouteName
|
|
334
340
|
: routeNames[0];
|
|
335
341
|
|
|
342
|
+
if (initialRouteName == null) {
|
|
343
|
+
throw new Error(
|
|
344
|
+
"Couldn't initialize the stack navigator. Have you defined any screens?"
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
|
|
336
348
|
routes.push({
|
|
337
349
|
key: `${initialRouteName}-${nanoid()}`,
|
|
338
350
|
name: initialRouteName,
|
|
@@ -389,6 +401,12 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
389
401
|
? options.initialRouteName
|
|
390
402
|
: routeNames[0];
|
|
391
403
|
|
|
404
|
+
if (initialRouteName == null) {
|
|
405
|
+
throw new Error(
|
|
406
|
+
"Couldn't initialize the stack navigator. Have you defined any screens?"
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
392
410
|
routes.push({
|
|
393
411
|
key: `${initialRouteName}-${nanoid()}`,
|
|
394
412
|
name: initialRouteName,
|
|
@@ -498,6 +516,10 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
498
516
|
if (action.type === 'NAVIGATE') {
|
|
499
517
|
const currentRoute = routes[state.index];
|
|
500
518
|
|
|
519
|
+
if (currentRoute == null) {
|
|
520
|
+
throw new Error(`Couldn't find a route at index ${state.index}.`);
|
|
521
|
+
}
|
|
522
|
+
|
|
501
523
|
if (id !== undefined) {
|
|
502
524
|
if (
|
|
503
525
|
currentRoute.name === action.payload.name &&
|
|
@@ -508,6 +530,10 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
508
530
|
for (let i = routes.length - 1; i >= 0; i--) {
|
|
509
531
|
const r = routes[i];
|
|
510
532
|
|
|
533
|
+
if (r == null) {
|
|
534
|
+
throw new Error(`Couldn't find a route at index ${i}.`);
|
|
535
|
+
}
|
|
536
|
+
|
|
511
537
|
if (r.name !== action.payload.name) {
|
|
512
538
|
continue;
|
|
513
539
|
}
|
|
@@ -519,13 +545,21 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
519
545
|
|
|
520
546
|
if (r.history?.length) {
|
|
521
547
|
for (let j = r.history.length - 1; j >= 0; j--) {
|
|
548
|
+
const historyEntry = r.history[j];
|
|
549
|
+
|
|
550
|
+
if (historyEntry == null) {
|
|
551
|
+
throw new Error(
|
|
552
|
+
`Couldn't find a route history entry at index ${j}.`
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
|
|
522
556
|
if (
|
|
523
|
-
|
|
524
|
-
id === getId?.({ params:
|
|
557
|
+
historyEntry.type === 'params' &&
|
|
558
|
+
id === getId?.({ params: historyEntry.params })
|
|
525
559
|
) {
|
|
526
560
|
route = {
|
|
527
561
|
...r,
|
|
528
|
-
params:
|
|
562
|
+
params: historyEntry.params,
|
|
529
563
|
history: r.history.slice(0, j),
|
|
530
564
|
};
|
|
531
565
|
break;
|
|
@@ -632,14 +666,20 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
632
666
|
];
|
|
633
667
|
}
|
|
634
668
|
|
|
669
|
+
const lastRoute = nextRoutes[nextRoutes.length - 1];
|
|
670
|
+
|
|
671
|
+
if (lastRoute == null) {
|
|
672
|
+
throw new Error(
|
|
673
|
+
`Couldn't find a route at index ${nextRoutes.length - 1}.`
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
|
|
635
677
|
return retainRoutes(
|
|
636
678
|
state,
|
|
637
679
|
getStateWithRoutes(
|
|
638
680
|
state,
|
|
639
681
|
nextRoutes,
|
|
640
|
-
preloadedRoutes.filter(
|
|
641
|
-
(route) => nextRoutes[nextRoutes.length - 1].key !== route.key
|
|
642
|
-
)
|
|
682
|
+
preloadedRoutes.filter((route) => lastRoute.key !== route.key)
|
|
643
683
|
)
|
|
644
684
|
);
|
|
645
685
|
}
|
|
@@ -656,6 +696,10 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
656
696
|
|
|
657
697
|
let route = routes[currentIndex];
|
|
658
698
|
|
|
699
|
+
if (route == null) {
|
|
700
|
+
throw new Error(`Couldn't find a route at index ${currentIndex}.`);
|
|
701
|
+
}
|
|
702
|
+
|
|
659
703
|
/**
|
|
660
704
|
* When popping entries,
|
|
661
705
|
* - Pop entries from route.history
|
|
@@ -699,7 +743,16 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
699
743
|
|
|
700
744
|
count = count - removed;
|
|
701
745
|
currentIndex = nextRoutes.length - 1;
|
|
702
|
-
|
|
746
|
+
|
|
747
|
+
const currentRoute = nextRoutes[currentIndex];
|
|
748
|
+
|
|
749
|
+
if (currentRoute == null) {
|
|
750
|
+
throw new Error(
|
|
751
|
+
`Couldn't find a route at index ${currentIndex}.`
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
route = currentRoute;
|
|
703
756
|
}
|
|
704
757
|
}
|
|
705
758
|
|
|
@@ -712,6 +765,10 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
712
765
|
case 'POP_TO_TOP': {
|
|
713
766
|
let route = routes[0];
|
|
714
767
|
|
|
768
|
+
if (route == null) {
|
|
769
|
+
throw new Error("Couldn't find a route at index 0.");
|
|
770
|
+
}
|
|
771
|
+
|
|
715
772
|
if (state.index > 0 || route.history?.length) {
|
|
716
773
|
if (route.history?.length) {
|
|
717
774
|
route = {
|
|
@@ -751,6 +808,10 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
751
808
|
for (let i = currentIndex; i >= 0; i--) {
|
|
752
809
|
const r = routes[i];
|
|
753
810
|
|
|
811
|
+
if (r == null) {
|
|
812
|
+
throw new Error(`Couldn't find a route at index ${i}.`);
|
|
813
|
+
}
|
|
814
|
+
|
|
754
815
|
if (r.name !== action.payload.name) {
|
|
755
816
|
continue;
|
|
756
817
|
}
|
|
@@ -762,9 +823,17 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
762
823
|
|
|
763
824
|
if (r.history?.length) {
|
|
764
825
|
for (let j = r.history.length - 1; j >= 0; j--) {
|
|
826
|
+
const historyEntry = r.history[j];
|
|
827
|
+
|
|
828
|
+
if (historyEntry == null) {
|
|
829
|
+
throw new Error(
|
|
830
|
+
`Couldn't find a route history entry at index ${j}.`
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
|
|
765
834
|
if (
|
|
766
|
-
|
|
767
|
-
id === getId?.({ params:
|
|
835
|
+
historyEntry.type === 'params' &&
|
|
836
|
+
id === getId?.({ params: historyEntry.params })
|
|
768
837
|
) {
|
|
769
838
|
index = i;
|
|
770
839
|
historyIndex = j;
|
|
@@ -777,11 +846,29 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
777
846
|
}
|
|
778
847
|
}
|
|
779
848
|
}
|
|
780
|
-
} else if (routes[currentIndex].name === action.payload.name) {
|
|
781
|
-
index = currentIndex;
|
|
782
849
|
} else {
|
|
850
|
+
const currentRoute = routes[currentIndex];
|
|
851
|
+
|
|
852
|
+
if (currentRoute == null) {
|
|
853
|
+
throw new Error(
|
|
854
|
+
`Couldn't find a route at index ${currentIndex}.`
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
if (currentRoute.name === action.payload.name) {
|
|
859
|
+
index = currentIndex;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
if (id == null && index === -1) {
|
|
783
864
|
for (let i = currentIndex; i >= 0; i--) {
|
|
784
|
-
|
|
865
|
+
const route = routes[i];
|
|
866
|
+
|
|
867
|
+
if (route == null) {
|
|
868
|
+
throw new Error(`Couldn't find a route at index ${i}.`);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
if (route.name === action.payload.name) {
|
|
785
872
|
index = i;
|
|
786
873
|
break;
|
|
787
874
|
}
|
|
@@ -821,11 +908,23 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
821
908
|
|
|
822
909
|
const route = routes[index];
|
|
823
910
|
|
|
911
|
+
if (route == null) {
|
|
912
|
+
throw new Error(`Couldn't find a route at index ${index}.`);
|
|
913
|
+
}
|
|
914
|
+
|
|
824
915
|
let baseParams = route.params;
|
|
825
916
|
let history = route.history;
|
|
826
917
|
|
|
827
918
|
if (historyIndex !== undefined && route.history) {
|
|
828
|
-
|
|
919
|
+
const historyEntry = route.history[historyIndex];
|
|
920
|
+
|
|
921
|
+
if (historyEntry == null) {
|
|
922
|
+
throw new Error(
|
|
923
|
+
`Couldn't find a route history entry at index ${historyIndex}.`
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
baseParams = historyEntry.params;
|
|
829
928
|
history = route.history.slice(0, historyIndex);
|
|
830
929
|
}
|
|
831
930
|
|
|
@@ -851,13 +950,19 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
851
950
|
...routes.slice(0, index),
|
|
852
951
|
params !== baseParams || historyIndex !== undefined
|
|
853
952
|
? { ...route, params, history }
|
|
854
|
-
:
|
|
953
|
+
: route,
|
|
855
954
|
])
|
|
856
955
|
);
|
|
857
956
|
}
|
|
858
957
|
|
|
859
|
-
case 'GO_BACK':
|
|
860
|
-
|
|
958
|
+
case 'GO_BACK': {
|
|
959
|
+
const route = routes[state.index];
|
|
960
|
+
|
|
961
|
+
if (route == null) {
|
|
962
|
+
throw new Error(`Couldn't find a route at index ${state.index}.`);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
if (state.index > 0 || route.history?.length) {
|
|
861
966
|
return router.getStateForAction(
|
|
862
967
|
state,
|
|
863
968
|
{
|
|
@@ -871,9 +976,16 @@ export function StackRouter(options: StackRouterOptions) {
|
|
|
871
976
|
}
|
|
872
977
|
|
|
873
978
|
return null;
|
|
979
|
+
}
|
|
874
980
|
|
|
875
981
|
case 'RETAIN': {
|
|
876
|
-
const
|
|
982
|
+
const route = routes[state.index];
|
|
983
|
+
|
|
984
|
+
if (route == null) {
|
|
985
|
+
throw new Error(`Couldn't find a route at index ${state.index}.`);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
const routeKey = action.source ?? route.key;
|
|
877
989
|
|
|
878
990
|
if (!state.routes.some((route) => route.key === routeKey)) {
|
|
879
991
|
return null;
|
package/src/TabRouter.tsx
CHANGED
|
@@ -91,10 +91,16 @@ const getRouteHistory = (
|
|
|
91
91
|
backBehavior: BackBehavior,
|
|
92
92
|
initialRouteName: string | undefined
|
|
93
93
|
) => {
|
|
94
|
+
const route = routes[index];
|
|
95
|
+
|
|
96
|
+
if (route == null) {
|
|
97
|
+
throw new Error(`Couldn't find a route at index ${index}.`);
|
|
98
|
+
}
|
|
99
|
+
|
|
94
100
|
const history = [
|
|
95
101
|
{
|
|
96
102
|
type: TYPE_ROUTE,
|
|
97
|
-
key:
|
|
103
|
+
key: route.key,
|
|
98
104
|
},
|
|
99
105
|
];
|
|
100
106
|
|
|
@@ -103,17 +109,29 @@ const getRouteHistory = (
|
|
|
103
109
|
switch (backBehavior) {
|
|
104
110
|
case 'order':
|
|
105
111
|
for (let i = index; i > 0; i--) {
|
|
112
|
+
const route = routes[i - 1];
|
|
113
|
+
|
|
114
|
+
if (route == null) {
|
|
115
|
+
throw new Error(`Couldn't find a route at index ${i - 1}.`);
|
|
116
|
+
}
|
|
117
|
+
|
|
106
118
|
history.unshift({
|
|
107
119
|
type: TYPE_ROUTE,
|
|
108
|
-
key:
|
|
120
|
+
key: route.key,
|
|
109
121
|
});
|
|
110
122
|
}
|
|
111
123
|
break;
|
|
112
124
|
case 'firstRoute':
|
|
113
125
|
if (index !== 0) {
|
|
126
|
+
const route = routes[0];
|
|
127
|
+
|
|
128
|
+
if (route == null) {
|
|
129
|
+
throw new Error("Couldn't find a route at index 0.");
|
|
130
|
+
}
|
|
131
|
+
|
|
114
132
|
history.unshift({
|
|
115
133
|
type: TYPE_ROUTE,
|
|
116
|
-
key:
|
|
134
|
+
key: route.key,
|
|
117
135
|
});
|
|
118
136
|
}
|
|
119
137
|
break;
|
|
@@ -124,9 +142,17 @@ const getRouteHistory = (
|
|
|
124
142
|
initialRouteIndex = initialRouteIndex === -1 ? 0 : initialRouteIndex;
|
|
125
143
|
|
|
126
144
|
if (index !== initialRouteIndex) {
|
|
145
|
+
const route = routes[initialRouteIndex];
|
|
146
|
+
|
|
147
|
+
if (route == null) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
`Couldn't find a route at index ${initialRouteIndex}.`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
127
153
|
history.unshift({
|
|
128
154
|
type: TYPE_ROUTE,
|
|
129
|
-
key:
|
|
155
|
+
key: route.key,
|
|
130
156
|
});
|
|
131
157
|
}
|
|
132
158
|
break;
|
|
@@ -150,6 +176,10 @@ const changeIndex = (
|
|
|
150
176
|
if (backBehavior === 'history' || backBehavior === 'fullHistory') {
|
|
151
177
|
const currentRoute = state.routes[index];
|
|
152
178
|
|
|
179
|
+
if (currentRoute == null) {
|
|
180
|
+
throw new Error(`Couldn't find a route at index ${index}.`);
|
|
181
|
+
}
|
|
182
|
+
|
|
153
183
|
if (backBehavior === 'history') {
|
|
154
184
|
// Remove the existing key from the history to de-duplicate it
|
|
155
185
|
history = history.filter((it) =>
|
|
@@ -266,8 +296,9 @@ export function TabRouter({
|
|
|
266
296
|
} as Route<string>;
|
|
267
297
|
});
|
|
268
298
|
|
|
299
|
+
const currentRoute = state.routes[state.index ?? 0];
|
|
269
300
|
const index = Math.min(
|
|
270
|
-
Math.max(routeNames.indexOf(
|
|
301
|
+
Math.max(currentRoute ? routeNames.indexOf(currentRoute.name) : 0, 0),
|
|
271
302
|
routes.length - 1
|
|
272
303
|
);
|
|
273
304
|
|
|
@@ -311,10 +342,13 @@ export function TabRouter({
|
|
|
311
342
|
}
|
|
312
343
|
);
|
|
313
344
|
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
345
|
+
const currentRoute = state.routes[state.index];
|
|
346
|
+
|
|
347
|
+
if (currentRoute == null) {
|
|
348
|
+
throw new Error(`Couldn't find a route at index ${state.index}.`);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const index = Math.max(0, routeNames.indexOf(currentRoute.name));
|
|
318
352
|
|
|
319
353
|
let history = state.history.filter(
|
|
320
354
|
// Type will always be 'route' for tabs, but could be different in a router extending this (e.g. drawer)
|
|
@@ -414,10 +448,18 @@ export function TabRouter({
|
|
|
414
448
|
initialRouteName
|
|
415
449
|
);
|
|
416
450
|
|
|
451
|
+
const updatedRoute = updatedState.routes[updatedState.index];
|
|
452
|
+
|
|
453
|
+
if (updatedRoute == null) {
|
|
454
|
+
throw new Error(
|
|
455
|
+
`Couldn't find a route at index ${updatedState.index}.`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
417
459
|
return {
|
|
418
460
|
...updatedState,
|
|
419
461
|
preloadedRouteKeys: updatedState.preloadedRouteKeys.filter(
|
|
420
|
-
(key) => key !==
|
|
462
|
+
(key) => key !== updatedRoute.key
|
|
421
463
|
),
|
|
422
464
|
};
|
|
423
465
|
}
|
|
@@ -425,6 +467,10 @@ export function TabRouter({
|
|
|
425
467
|
case 'GO_BACK': {
|
|
426
468
|
const focusedRoute = state.routes[state.index];
|
|
427
469
|
|
|
470
|
+
if (focusedRoute == null) {
|
|
471
|
+
throw new Error(`Couldn't find a route at index ${state.index}.`);
|
|
472
|
+
}
|
|
473
|
+
|
|
428
474
|
if (state.history.length === 1 && !focusedRoute.history?.length) {
|
|
429
475
|
return null;
|
|
430
476
|
}
|
|
@@ -453,7 +499,12 @@ export function TabRouter({
|
|
|
453
499
|
}
|
|
454
500
|
|
|
455
501
|
const previousHistoryItem = state.history[state.history.length - 2];
|
|
456
|
-
|
|
502
|
+
|
|
503
|
+
if (previousHistoryItem == null) {
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const previousKey = previousHistoryItem.key;
|
|
457
508
|
const index = state.routes.findLastIndex(
|
|
458
509
|
(route) => route.key === previousKey
|
|
459
510
|
);
|
|
@@ -464,13 +515,19 @@ export function TabRouter({
|
|
|
464
515
|
|
|
465
516
|
let routes = state.routes;
|
|
466
517
|
|
|
518
|
+
const previousRoute = routes[index];
|
|
519
|
+
|
|
520
|
+
if (previousRoute == null) {
|
|
521
|
+
throw new Error(`Couldn't find a route at index ${index}.`);
|
|
522
|
+
}
|
|
523
|
+
|
|
467
524
|
if (
|
|
468
525
|
backBehavior === 'fullHistory' &&
|
|
469
|
-
|
|
526
|
+
previousRoute.params !== previousHistoryItem.params
|
|
470
527
|
) {
|
|
471
528
|
routes = [...state.routes];
|
|
472
529
|
routes[index] = {
|
|
473
|
-
...
|
|
530
|
+
...previousRoute,
|
|
474
531
|
params: previousHistoryItem.params,
|
|
475
532
|
};
|
|
476
533
|
}
|
|
@@ -479,7 +536,7 @@ export function TabRouter({
|
|
|
479
536
|
...state,
|
|
480
537
|
routes,
|
|
481
538
|
preloadedRouteKeys: state.preloadedRouteKeys.filter(
|
|
482
|
-
(key) => key !==
|
|
539
|
+
(key) => key !== previousRoute.key
|
|
483
540
|
),
|
|
484
541
|
history: state.history.slice(0, -1),
|
|
485
542
|
index,
|
|
@@ -497,6 +554,10 @@ export function TabRouter({
|
|
|
497
554
|
|
|
498
555
|
const route = state.routes[routeIndex];
|
|
499
556
|
|
|
557
|
+
if (route == null) {
|
|
558
|
+
throw new Error(`Couldn't find a route at index ${routeIndex}.`);
|
|
559
|
+
}
|
|
560
|
+
|
|
500
561
|
const getId = routeGetIdList[route.name];
|
|
501
562
|
|
|
502
563
|
const currentId = getId?.({ params: route.params });
|