@amazon-devices/react-navigation__routers 7.0.9000000000 → 8.0.9000000000-rn-83

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.
Files changed (75) hide show
  1. package/SystemBundles/b6cc62e27d70be8722b0e7aef9fd04a870d49127e6c724fe934d1f8ca4ff8177.bundle +1298 -0
  2. package/SystemBundles/b6cc62e27d70be8722b0e7aef9fd04a870d49127e6c724fe934d1f8ca4ff8177.map +373 -0
  3. package/SystemModules/amzn__react-navigation__routers-8.modules.txt +9 -0
  4. package/SystemModules/amzn__react-navigation__routers-8.private.modules.txt +1 -0
  5. package/SystemModules/keplerscript-system-bundle-config.json +4 -4
  6. package/kepler-compatibility.json +2 -2
  7. package/lib/module/BaseRouter.js +6 -4
  8. package/lib/module/BaseRouter.js.map +1 -1
  9. package/lib/module/CommonActions.js +48 -7
  10. package/lib/module/CommonActions.js.map +1 -1
  11. package/lib/module/DrawerRouter.js +6 -6
  12. package/lib/module/DrawerRouter.js.map +1 -1
  13. package/lib/module/StackRouter.js +261 -80
  14. package/lib/module/StackRouter.js.map +1 -1
  15. package/lib/module/TabRouter.js +117 -34
  16. package/lib/module/TabRouter.js.map +1 -1
  17. package/lib/module/createParamsFromAction.js +16 -0
  18. package/lib/module/createParamsFromAction.js.map +1 -0
  19. package/lib/module/createRouteFromAction.js +21 -0
  20. package/lib/module/createRouteFromAction.js.map +1 -0
  21. package/lib/module/index.js +8 -6
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/package.json +1 -0
  24. package/lib/module/types.js +2 -0
  25. package/lib/module/types.js.map +1 -1
  26. package/lib/typescript/package.json +1 -0
  27. package/lib/typescript/src/BaseRouter.d.ts +23 -20
  28. package/lib/typescript/src/BaseRouter.d.ts.map +1 -1
  29. package/lib/typescript/src/CommonActions.d.ts +66 -18
  30. package/lib/typescript/src/CommonActions.d.ts.map +1 -1
  31. package/lib/typescript/src/DrawerRouter.d.ts +18 -6
  32. package/lib/typescript/src/DrawerRouter.d.ts.map +1 -1
  33. package/lib/typescript/src/StackRouter.d.ts +73 -11
  34. package/lib/typescript/src/StackRouter.d.ts.map +1 -1
  35. package/lib/typescript/src/TabRouter.d.ts +24 -4
  36. package/lib/typescript/src/TabRouter.d.ts.map +1 -1
  37. package/lib/typescript/src/createParamsFromAction.d.ts +13 -0
  38. package/lib/typescript/src/createParamsFromAction.d.ts.map +1 -0
  39. package/lib/typescript/src/createRouteFromAction.d.ts +17 -0
  40. package/lib/typescript/src/createRouteFromAction.d.ts.map +1 -0
  41. package/lib/typescript/src/index.d.ts +4 -4
  42. package/lib/typescript/src/index.d.ts.map +1 -1
  43. package/lib/typescript/src/types.d.ts +1 -2
  44. package/lib/typescript/src/types.d.ts.map +1 -1
  45. package/oss-attribution/attribution.txt +0 -0
  46. package/oss-attribution/licenseInfos.json +1 -0
  47. package/package.json +80 -1
  48. package/src/BaseRouter.tsx +11 -6
  49. package/src/CommonActions.tsx +147 -56
  50. package/src/DrawerRouter.tsx +15 -13
  51. package/src/StackRouter.tsx +437 -199
  52. package/src/TabRouter.tsx +192 -53
  53. package/src/createParamsFromAction.tsx +22 -0
  54. package/src/createRouteFromAction.tsx +24 -0
  55. package/src/index.tsx +4 -4
  56. package/src/types.tsx +5 -5
  57. package/SystemBundles/b274ab157641de9520fe27a8e8049450e176a8ce2fedd3283fcb46c038bc6247.bundle +0 -3497
  58. package/SystemBundles/b274ab157641de9520fe27a8e8049450e176a8ce2fedd3283fcb46c038bc6247.map +0 -987
  59. package/SystemModules/amzn__react-navigation__routers-7.modules.txt +0 -21
  60. package/SystemModules/amzn__react-navigation__routers-7.private.modules.txt +0 -12
  61. package/THIRD_PARTY_NOTICES.txt +0 -24
  62. package/lib/commonjs/BaseRouter.js +0 -61
  63. package/lib/commonjs/BaseRouter.js.map +0 -1
  64. package/lib/commonjs/CommonActions.js +0 -53
  65. package/lib/commonjs/CommonActions.js.map +0 -1
  66. package/lib/commonjs/DrawerRouter.js +0 -154
  67. package/lib/commonjs/DrawerRouter.js.map +0 -1
  68. package/lib/commonjs/StackRouter.js +0 -310
  69. package/lib/commonjs/StackRouter.js.map +0 -1
  70. package/lib/commonjs/TabRouter.js +0 -253
  71. package/lib/commonjs/TabRouter.js.map +0 -1
  72. package/lib/commonjs/index.js +0 -80
  73. package/lib/commonjs/index.js.map +0 -1
  74. package/lib/commonjs/types.js +0 -6
  75. package/lib/commonjs/types.js.map +0 -1
@@ -7,72 +7,122 @@ type ResetState =
7
7
  routes: Omit<Route<string>, 'key'>[];
8
8
  });
9
9
 
10
+ type GoBackAction = {
11
+ type: 'GO_BACK';
12
+ source?: string;
13
+ target?: string;
14
+ };
15
+
16
+ type NavigateAction = {
17
+ type: 'NAVIGATE';
18
+ payload: {
19
+ name: string;
20
+ params?: object;
21
+ path?: string;
22
+ merge?: boolean;
23
+ pop?: boolean;
24
+ };
25
+ source?: string;
26
+ target?: string;
27
+ };
28
+
29
+ type NavigateDeprecatedAction = {
30
+ type: 'NAVIGATE_DEPRECATED';
31
+ payload: {
32
+ name: string;
33
+ params?: object;
34
+ merge?: boolean;
35
+ };
36
+ source?: string;
37
+ target?: string;
38
+ };
39
+
40
+ type ResetAction = {
41
+ type: 'RESET';
42
+ payload: ResetState | undefined;
43
+ source?: string;
44
+ target?: string;
45
+ };
46
+
47
+ type SetParamsAction = {
48
+ type: 'SET_PARAMS';
49
+ payload: { params?: object };
50
+ source?: string;
51
+ target?: string;
52
+ };
53
+
54
+ type ReplaceParamsAction = {
55
+ type: 'REPLACE_PARAMS';
56
+ payload: { params?: object };
57
+ source?: string;
58
+ target?: string;
59
+ };
60
+
61
+ type PreloadAction = {
62
+ type: 'PRELOAD';
63
+ payload: {
64
+ name: string;
65
+ params?: object;
66
+ };
67
+ source?: string;
68
+ target?: string;
69
+ };
70
+
10
71
  export type Action =
11
- | {
12
- type: 'GO_BACK';
13
- source?: string;
14
- target?: string;
15
- }
16
- | {
17
- type: 'NAVIGATE';
18
- payload:
19
- | {
20
- key: string;
21
- name?: undefined;
22
- params?: object;
23
- path?: string;
24
- merge?: boolean;
25
- }
26
- | {
27
- name: string;
28
- key?: string;
29
- params?: object;
30
- path?: string;
31
- merge?: boolean;
32
- };
33
- source?: string;
34
- target?: string;
35
- }
36
- | {
37
- type: 'RESET';
38
- payload: ResetState | undefined;
39
- source?: string;
40
- target?: string;
41
- }
42
- | {
43
- type: 'SET_PARAMS';
44
- payload: { params?: object };
45
- source?: string;
46
- target?: string;
47
- };
72
+ | GoBackAction
73
+ | NavigateAction
74
+ | NavigateDeprecatedAction
75
+ | ResetAction
76
+ | SetParamsAction
77
+ | ReplaceParamsAction
78
+ | PreloadAction;
48
79
 
49
80
  export function goBack(): Action {
50
81
  return { type: 'GO_BACK' };
51
82
  }
52
83
 
53
84
  export function navigate(
54
- options:
55
- | { key: string; params?: object; path?: string; merge?: boolean }
56
- | {
57
- name: string;
58
- key?: string;
59
- params?: object;
60
- path?: string;
61
- merge?: boolean;
62
- }
85
+ name: string,
86
+ params?: object,
87
+ options?: {
88
+ merge?: boolean;
89
+ pop?: boolean;
90
+ }
63
91
  ): Action;
64
- // eslint-disable-next-line no-redeclare
65
- export function navigate(name: string, params?: object): Action;
66
- // eslint-disable-next-line no-redeclare
92
+
93
+ export function navigate(options: {
94
+ name: string;
95
+ params?: object;
96
+ path?: string;
97
+ merge?: boolean;
98
+ pop?: boolean;
99
+ }): Action;
100
+
67
101
  export function navigate(...args: any): Action {
68
102
  if (typeof args[0] === 'string') {
69
- return { type: 'NAVIGATE', payload: { name: args[0], params: args[1] } };
103
+ const [name, params, options] = args;
104
+
105
+ if (typeof options === 'boolean') {
106
+ console.warn(
107
+ `Passing a boolean as the third argument to 'navigate' is deprecated. Pass '{ merge: true }' instead.`
108
+ );
109
+ }
110
+
111
+ return {
112
+ type: 'NAVIGATE',
113
+ payload: {
114
+ name,
115
+ params,
116
+ merge: typeof options === 'boolean' ? options : options?.merge,
117
+ pop: options?.pop,
118
+ },
119
+ };
70
120
  } else {
71
121
  const payload = args[0] || {};
72
122
 
73
- if (!payload.hasOwnProperty('key') && !payload.hasOwnProperty('name')) {
123
+ if (!('name' in payload)) {
74
124
  throw new Error(
75
- 'You need to specify name or key when calling navigate with an object as the argument. See https://reactnavigation.org/docs/navigation-actions#navigate for usage.'
125
+ 'You need to specify a name when calling navigate with an object as the argument. See https://reactnavigation.org/docs/navigation-actions#navigate for usage.'
76
126
  );
77
127
  }
78
128
 
@@ -80,10 +130,51 @@ export function navigate(...args: any): Action {
80
130
  }
81
131
  }
82
132
 
83
- export function reset(state: ResetState | undefined): Action {
84
- return { type: 'RESET', payload: state };
133
+ export function navigateDeprecated(
134
+ ...args:
135
+ | [name: string]
136
+ | [name: string, params: object | undefined]
137
+ | [options: { name: string; params?: object }]
138
+ ): Action {
139
+ if (typeof args[0] === 'string') {
140
+ return {
141
+ type: 'NAVIGATE_DEPRECATED',
142
+ payload: { name: args[0], params: args[1] },
143
+ };
144
+ } else {
145
+ const payload = args[0] || {};
146
+
147
+ if (!('name' in payload)) {
148
+ throw new Error(
149
+ 'You need to specify a name when calling navigateDeprecated with an object as the argument. See https://reactnavigation.org/docs/navigation-actions#navigatelegacy for usage.'
150
+ );
151
+ }
152
+
153
+ return { type: 'NAVIGATE_DEPRECATED', payload };
154
+ }
155
+ }
156
+
157
+ export function reset(state: ResetState | undefined) {
158
+ return { type: 'RESET', payload: state } as const satisfies ResetAction;
159
+ }
160
+
161
+ export function setParams(params: object) {
162
+ return {
163
+ type: 'SET_PARAMS',
164
+ payload: { params },
165
+ } as const satisfies SetParamsAction;
166
+ }
167
+
168
+ export function replaceParams(params: object) {
169
+ return {
170
+ type: 'REPLACE_PARAMS',
171
+ payload: { params },
172
+ } as const satisfies ReplaceParamsAction;
85
173
  }
86
174
 
87
- export function setParams(params: object): Action {
88
- return { type: 'SET_PARAMS', payload: { params } };
175
+ export function preload(name: string, params?: object) {
176
+ return {
177
+ type: 'PRELOAD',
178
+ payload: { name, params },
179
+ } as const satisfies PreloadAction;
89
180
  }
@@ -1,11 +1,12 @@
1
1
  import { nanoid } from 'nanoid/non-secure';
2
2
 
3
- import TabRouter, {
4
- TabActionHelpers,
3
+ import {
4
+ type TabActionHelpers,
5
5
  TabActions,
6
- TabActionType,
7
- TabNavigationState,
8
- TabRouterOptions,
6
+ type TabActionType,
7
+ type TabNavigationState,
8
+ TabRouter,
9
+ type TabRouterOptions,
9
10
  } from './TabRouter';
10
11
  import type {
11
12
  CommonNavigationAction,
@@ -68,18 +69,18 @@ export type DrawerActionHelpers<ParamList extends ParamListBase> =
68
69
 
69
70
  export const DrawerActions = {
70
71
  ...TabActions,
71
- openDrawer(): DrawerActionType {
72
- return { type: 'OPEN_DRAWER' };
72
+ openDrawer() {
73
+ return { type: 'OPEN_DRAWER' } as const satisfies DrawerActionType;
73
74
  },
74
- closeDrawer(): DrawerActionType {
75
- return { type: 'CLOSE_DRAWER' };
75
+ closeDrawer() {
76
+ return { type: 'CLOSE_DRAWER' } as const satisfies DrawerActionType;
76
77
  },
77
- toggleDrawer(): DrawerActionType {
78
- return { type: 'TOGGLE_DRAWER' };
78
+ toggleDrawer() {
79
+ return { type: 'TOGGLE_DRAWER' } as const satisfies DrawerActionType;
79
80
  },
80
81
  };
81
82
 
82
- export default function DrawerRouter({
83
+ export function DrawerRouter({
83
84
  defaultStatus = 'closed',
84
85
  ...rest
85
86
  }: DrawerRouterOptions): Router<
@@ -220,7 +221,8 @@ export default function DrawerRouter({
220
221
  return addDrawerToHistory(state);
221
222
 
222
223
  case 'JUMP_TO':
223
- case 'NAVIGATE': {
224
+ case 'NAVIGATE':
225
+ case 'NAVIGATE_DEPRECATED': {
224
226
  const result = router.getStateForAction(state, action, options);
225
227
 
226
228
  if (result != null && result.index !== state.index) {