@amazon-devices/react-navigation__routers 8.0.9000000000 → 8.0.9000000002

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.
@@ -1,1279 +0,0 @@
1
- var __BUNDLE_START_TIME__=globalThis.nativePerformanceNow?nativePerformanceNow():Date.now(),__DEV__=false,process=globalThis.process||{},__METRO_GLOBAL_PREFIX__='';process.env=process.env||{};process.env.NODE_ENV=process.env.NODE_ENV||"production";
2
- (function (global) {
3
- global._majorVersionToNoVersionIdMap["38c132d4a4bb76eedc80"] = "6cc26ebe1139d52af4d3";
4
- global._majorVersionToNoVersionIdMap["4aa609d49dd4d9fd69d8"] = "32fd789b2b4e67ba3679";
5
- global._majorVersionToNoVersionIdMap["6664264a195fd5e23d1d"] = "0060dd931905de8947f2";
6
- global._majorVersionToNoVersionIdMap["ab2268e7375692a18adc"] = "2b770725127b9776e940";
7
- global._majorVersionToNoVersionIdMap["2beefa0726d547efb6db"] = "b4b91107e9e069bf6a04";
8
- global._majorVersionToNoVersionIdMap["cdf36facce344b18753d"] = "dec21c689e6604dbbf6a";
9
- global._majorVersionToNoVersionIdMap["f37671f481d3442f7534"] = "1156635305634f3a14c7";
10
- global._majorVersionToNoVersionIdMap["c69c3cb84fab85c7ab0e"] = "0308dce3623ba6fd6f70";
11
- global._majorVersionToNoVersionIdMap["c39b5e831a38e3449d62"] = "38a8cc556e14fd685890";
12
- global._majorVersionToNoVersionIdMap["88041ddd5b5dffda940e"] = "1b0b28afa5b685260b1d";
13
- global._majorVersionToNoVersionIdMap["42552d18e7ae0181bd39"] = "2bee182fbe6f2aca641e";
14
- global._majorVersionToNoVersionIdMap["bb57842acdb83f2b3f2e"] = "eb7d4baa35301f5aed5f";
15
- global._majorVersionToNoVersionIdMap["9f3bb7c66a6d54b4f31f"] = "6770b45f91f2db97b2e2";
16
- global._majorVersionToNoVersionIdMap["6b91947bdfabfe9f3fcb"] = "46404a6d49463f9601d3";
17
- global._majorVersionToNoVersionIdMap["cd82459845fcc006200c"] = "cbb4d666ebd7ab852aa3";
18
- global._majorVersionToNoVersionIdMap["8ef843d324cbf8ceac15"] = "06a5a1d28ce3fd05c417";
19
- global._majorVersionToNoVersionIdMap["278cdd8bb8970d40410d"] = "fb17719fd282a08dfde9";
20
- global._majorVersionToNoVersionIdMap["9bc9fe221ec0ce458468"] = "8b1e20a6232a353c9981";
21
- global._majorVersionToNoVersionIdMap["e793a2a0d8af55b1360e"] = "5077535faaf552d97157";
22
- global._majorVersionToNoVersionIdMap["130dabfd918c0cb9f581"] = "04f3f6928f15baafd43b";
23
- global._majorVersionToNoVersionIdMap["bdff2caa69d04b792045"] = "39eca4bd16c398373cc4";
24
- global._majorVersionToNoVersionIdMap["b0bba4cced4da2c7d68d"] = "347ca45e3641dd48caa1";
25
- })(typeof globalThis !== 'undefined' ? globalThis : typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this);
26
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
27
- "use strict";
28
-
29
- Object.defineProperty(exports, "__esModule", {
30
- value: true
31
- });
32
- var _exportNames = {
33
- CommonActions: true,
34
- BaseRouter: true,
35
- DrawerActions: true,
36
- DrawerRouter: true,
37
- StackActions: true,
38
- StackRouter: true,
39
- TabActions: true,
40
- TabRouter: true
41
- };
42
- Object.defineProperty(exports, "BaseRouter", {
43
- enumerable: true,
44
- get: function () {
45
- return _$$_REQUIRE(_dependencyMap[0]).BaseRouter;
46
- }
47
- });
48
- exports.CommonActions = undefined;
49
- Object.defineProperty(exports, "DrawerActions", {
50
- enumerable: true,
51
- get: function () {
52
- return _$$_REQUIRE(_dependencyMap[1]).DrawerActions;
53
- }
54
- });
55
- Object.defineProperty(exports, "DrawerRouter", {
56
- enumerable: true,
57
- get: function () {
58
- return _$$_REQUIRE(_dependencyMap[1]).DrawerRouter;
59
- }
60
- });
61
- Object.defineProperty(exports, "StackActions", {
62
- enumerable: true,
63
- get: function () {
64
- return _$$_REQUIRE(_dependencyMap[2]).StackActions;
65
- }
66
- });
67
- Object.defineProperty(exports, "StackRouter", {
68
- enumerable: true,
69
- get: function () {
70
- return _$$_REQUIRE(_dependencyMap[2]).StackRouter;
71
- }
72
- });
73
- Object.defineProperty(exports, "TabActions", {
74
- enumerable: true,
75
- get: function () {
76
- return _$$_REQUIRE(_dependencyMap[3]).TabActions;
77
- }
78
- });
79
- Object.defineProperty(exports, "TabRouter", {
80
- enumerable: true,
81
- get: function () {
82
- return _$$_REQUIRE(_dependencyMap[3]).TabRouter;
83
- }
84
- });
85
- var CommonActions = _interopRequireWildcard(_$$_REQUIRE(_dependencyMap[4]));
86
- exports.CommonActions = CommonActions;
87
- Object.keys(_$$_REQUIRE(_dependencyMap[5])).forEach(function (key) {
88
- if (key === "default" || key === "__esModule") return;
89
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
90
- if (key in exports && exports[key] === _$$_REQUIRE(_dependencyMap[5])[key]) return;
91
- Object.defineProperty(exports, key, {
92
- enumerable: true,
93
- get: function () {
94
- return _$$_REQUIRE(_dependencyMap[5])[key];
95
- }
96
- });
97
- });
98
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
99
- },"c39b5e831a38e3449d62",["4aa609d49dd4d9fd69d8","ab2268e7375692a18adc","2beefa0726d547efb6db","cdf36facce344b18753d","6664264a195fd5e23d1d","42552d18e7ae0181bd39"]);
100
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
101
- "use strict";
102
-
103
- Object.defineProperty(exports, "__esModule", {
104
- value: true
105
- });
106
- exports.BaseRouter = undefined;
107
- /**
108
- * Base router object that can be used when writing custom routers.
109
- * This provides few helper methods to handle common actions such as `RESET`.
110
- */
111
- var BaseRouter = exports.BaseRouter = {
112
- getStateForAction(state, action) {
113
- switch (action.type) {
114
- case 'SET_PARAMS':
115
- case 'REPLACE_PARAMS':
116
- {
117
- var index = action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
118
- if (index === -1) {
119
- return null;
120
- }
121
- return {
122
- ...state,
123
- routes: state.routes.map((r, i) => i === index ? {
124
- ...r,
125
- params: action.type === 'REPLACE_PARAMS' ? action.payload.params : {
126
- ...r.params,
127
- ...action.payload.params
128
- }
129
- } : r)
130
- };
131
- }
132
- case 'RESET':
133
- {
134
- var nextState = action.payload;
135
- if (nextState.routes.length === 0 || nextState.routes.some(route => !state.routeNames.includes(route.name))) {
136
- return null;
137
- }
138
- if (nextState.stale === false) {
139
- if (state.routeNames.length !== nextState.routeNames.length || nextState.routeNames.some(name => !state.routeNames.includes(name))) {
140
- return null;
141
- }
142
- return {
143
- ...nextState,
144
- routes: nextState.routes.map(route => route.key ? route : {
145
- ...route,
146
- key: `${route.name}-${(0, _$$_REQUIRE(_dependencyMap[0]).nanoid)()}`
147
- })
148
- };
149
- }
150
- return nextState;
151
- }
152
- default:
153
- return null;
154
- }
155
- },
156
- shouldActionChangeFocus(action) {
157
- return action.type === 'NAVIGATE' || action.type === 'NAVIGATE_DEPRECATED';
158
- }
159
- };
160
- },"4aa609d49dd4d9fd69d8",["f9dacdfad56c8f57acc2"]);
161
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
162
- Object.defineProperty(exports, "__esModule", {
163
- value: true
164
- });
165
- exports.nanoid = exports.customAlphabet = undefined;
166
- var urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
167
- var customAlphabet = (alphabet, defaultSize = 21) => {
168
- return (size = defaultSize) => {
169
- var id = '';
170
- var i = size | 0;
171
- while (i--) {
172
- id += alphabet[Math.random() * alphabet.length | 0];
173
- }
174
- return id;
175
- };
176
- };
177
- exports.customAlphabet = customAlphabet;
178
- var nanoid = (size = 21) => {
179
- var id = '';
180
- var i = size | 0;
181
- while (i--) {
182
- id += urlAlphabet[Math.random() * 64 | 0];
183
- }
184
- return id;
185
- };
186
- exports.nanoid = nanoid;
187
- },"f9dacdfad56c8f57acc2",[]);
188
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
189
- "use strict";
190
-
191
- Object.defineProperty(exports, "__esModule", {
192
- value: true
193
- });
194
- exports.DrawerActions = undefined;
195
- exports.DrawerRouter = DrawerRouter;
196
- var DrawerActions = exports.DrawerActions = {
197
- ..._$$_REQUIRE(_dependencyMap[0]).TabActions,
198
- openDrawer() {
199
- return {
200
- type: 'OPEN_DRAWER'
201
- };
202
- },
203
- closeDrawer() {
204
- return {
205
- type: 'CLOSE_DRAWER'
206
- };
207
- },
208
- toggleDrawer() {
209
- return {
210
- type: 'TOGGLE_DRAWER'
211
- };
212
- }
213
- };
214
- function DrawerRouter({
215
- defaultStatus = 'closed',
216
- ...rest
217
- }) {
218
- var router = (0, _$$_REQUIRE(_dependencyMap[0]).TabRouter)(rest);
219
- var isDrawerInHistory = state => Boolean(state.history?.some(it => it.type === 'drawer'));
220
- var addDrawerToHistory = state => {
221
- if (isDrawerInHistory(state)) {
222
- return state;
223
- }
224
- return {
225
- ...state,
226
- history: [...state.history, {
227
- type: 'drawer',
228
- status: defaultStatus === 'open' ? 'closed' : 'open'
229
- }]
230
- };
231
- };
232
- var removeDrawerFromHistory = state => {
233
- if (!isDrawerInHistory(state)) {
234
- return state;
235
- }
236
- return {
237
- ...state,
238
- history: state.history.filter(it => it.type !== 'drawer')
239
- };
240
- };
241
- var openDrawer = state => {
242
- if (defaultStatus === 'open') {
243
- return removeDrawerFromHistory(state);
244
- }
245
- return addDrawerToHistory(state);
246
- };
247
- var closeDrawer = state => {
248
- if (defaultStatus === 'open') {
249
- return addDrawerToHistory(state);
250
- }
251
- return removeDrawerFromHistory(state);
252
- };
253
- return {
254
- ...router,
255
- type: 'drawer',
256
- getInitialState({
257
- routeNames,
258
- routeParamList,
259
- routeGetIdList
260
- }) {
261
- var state = router.getInitialState({
262
- routeNames,
263
- routeParamList,
264
- routeGetIdList
265
- });
266
- return {
267
- ...state,
268
- default: defaultStatus,
269
- stale: false,
270
- type: 'drawer',
271
- key: `drawer-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`
272
- };
273
- },
274
- getRehydratedState(partialState, {
275
- routeNames,
276
- routeParamList,
277
- routeGetIdList
278
- }) {
279
- if (partialState.stale === false) {
280
- return partialState;
281
- }
282
- var state = router.getRehydratedState(partialState, {
283
- routeNames,
284
- routeParamList,
285
- routeGetIdList
286
- });
287
- if (isDrawerInHistory(partialState)) {
288
- // Re-sync the drawer entry in history to correct it if it was wrong
289
- state = removeDrawerFromHistory(state);
290
- state = addDrawerToHistory(state);
291
- }
292
- return {
293
- ...state,
294
- default: defaultStatus,
295
- type: 'drawer',
296
- key: `drawer-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`
297
- };
298
- },
299
- getStateForRouteFocus(state, key) {
300
- var result = router.getStateForRouteFocus(state, key);
301
- return closeDrawer(result);
302
- },
303
- getStateForAction(state, action, options) {
304
- switch (action.type) {
305
- case 'OPEN_DRAWER':
306
- return openDrawer(state);
307
- case 'CLOSE_DRAWER':
308
- return closeDrawer(state);
309
- case 'TOGGLE_DRAWER':
310
- if (isDrawerInHistory(state)) {
311
- return removeDrawerFromHistory(state);
312
- }
313
- return addDrawerToHistory(state);
314
- case 'JUMP_TO':
315
- case 'NAVIGATE':
316
- case 'NAVIGATE_DEPRECATED':
317
- {
318
- var result = router.getStateForAction(state, action, options);
319
- if (result != null && result.index !== state.index) {
320
- return closeDrawer(result);
321
- }
322
- return result;
323
- }
324
- case 'GO_BACK':
325
- if (isDrawerInHistory(state)) {
326
- return removeDrawerFromHistory(state);
327
- }
328
- return router.getStateForAction(state, action, options);
329
- default:
330
- return router.getStateForAction(state, action, options);
331
- }
332
- },
333
- actionCreators: DrawerActions
334
- };
335
- }
336
- },"ab2268e7375692a18adc",["cdf36facce344b18753d","f9dacdfad56c8f57acc2"]);
337
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
338
- "use strict";
339
-
340
- Object.defineProperty(exports, "__esModule", {
341
- value: true
342
- });
343
- exports.TabActions = undefined;
344
- exports.TabRouter = TabRouter;
345
- var TYPE_ROUTE = 'route';
346
- var TabActions = exports.TabActions = {
347
- jumpTo(name, params) {
348
- return {
349
- type: 'JUMP_TO',
350
- payload: {
351
- name,
352
- params
353
- }
354
- };
355
- }
356
- };
357
- var getRouteHistory = (routes, index, backBehavior, initialRouteName) => {
358
- var history = [{
359
- type: TYPE_ROUTE,
360
- key: routes[index].key
361
- }];
362
- var initialRouteIndex;
363
- switch (backBehavior) {
364
- case 'order':
365
- for (var i = index; i > 0; i--) {
366
- history.unshift({
367
- type: TYPE_ROUTE,
368
- key: routes[i - 1].key
369
- });
370
- }
371
- break;
372
- case 'firstRoute':
373
- if (index !== 0) {
374
- history.unshift({
375
- type: TYPE_ROUTE,
376
- key: routes[0].key
377
- });
378
- }
379
- break;
380
- case 'initialRoute':
381
- initialRouteIndex = routes.findIndex(route => route.name === initialRouteName);
382
- initialRouteIndex = initialRouteIndex === -1 ? 0 : initialRouteIndex;
383
- if (index !== initialRouteIndex) {
384
- history.unshift({
385
- type: TYPE_ROUTE,
386
- key: routes[initialRouteIndex].key
387
- });
388
- }
389
- break;
390
- case 'history':
391
- case 'fullHistory':
392
- // The history will fill up on navigation
393
- break;
394
- }
395
- return history;
396
- };
397
- var changeIndex = (state, index, backBehavior, initialRouteName) => {
398
- var history = state.history;
399
- if (backBehavior === 'history' || backBehavior === 'fullHistory') {
400
- var currentRoute = state.routes[index];
401
- if (backBehavior === 'history') {
402
- // Remove the existing key from the history to de-duplicate it
403
- history = history.filter(it => it.type === 'route' ? it.key !== currentRoute.key : false);
404
- } else if (backBehavior === 'fullHistory') {
405
- var lastHistoryRouteItemIndex = history.findLastIndex(item => item.type === 'route');
406
- if (currentRoute.key === history[lastHistoryRouteItemIndex]?.key) {
407
- // For full-history, only remove if it matches the last route
408
- // Useful for drawer, if current route was in history, then drawer state changed
409
- // Then we only need to move the route to the front
410
- history = [...history.slice(0, lastHistoryRouteItemIndex), ...history.slice(lastHistoryRouteItemIndex + 1)];
411
- }
412
- }
413
- history = history.concat({
414
- type: TYPE_ROUTE,
415
- key: currentRoute.key,
416
- params: backBehavior === 'fullHistory' ? currentRoute.params : undefined
417
- });
418
- } else {
419
- history = getRouteHistory(state.routes, index, backBehavior, initialRouteName);
420
- }
421
- return {
422
- ...state,
423
- index,
424
- history
425
- };
426
- };
427
- function TabRouter({
428
- initialRouteName,
429
- backBehavior = 'firstRoute'
430
- }) {
431
- var router = {
432
- ..._$$_REQUIRE(_dependencyMap[0]).BaseRouter,
433
- type: 'tab',
434
- getInitialState({
435
- routeNames,
436
- routeParamList
437
- }) {
438
- var index = initialRouteName !== undefined && routeNames.includes(initialRouteName) ? routeNames.indexOf(initialRouteName) : 0;
439
- var routes = routeNames.map(name => ({
440
- name,
441
- key: `${name}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
442
- params: routeParamList[name]
443
- }));
444
- var history = getRouteHistory(routes, index, backBehavior, initialRouteName);
445
- return {
446
- stale: false,
447
- type: 'tab',
448
- key: `tab-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
449
- index,
450
- routeNames,
451
- history,
452
- routes,
453
- preloadedRouteKeys: []
454
- };
455
- },
456
- getRehydratedState(partialState, {
457
- routeNames,
458
- routeParamList
459
- }) {
460
- var state = partialState;
461
- if (state.stale === false) {
462
- return state;
463
- }
464
- var routes = routeNames.map(name => {
465
- var route = state.routes.find(r => r.name === name);
466
- return {
467
- ...route,
468
- name,
469
- key: route && route.name === name && route.key ? route.key : `${name}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
470
- params: routeParamList[name] !== undefined ? {
471
- ...routeParamList[name],
472
- ...(route ? route.params : undefined)
473
- } : route ? route.params : undefined
474
- };
475
- });
476
- var index = Math.min(Math.max(routeNames.indexOf(state.routes[state?.index ?? 0]?.name), 0), routes.length - 1);
477
- var routeKeys = routes.map(route => route.key);
478
- var history = state.history?.filter(it => routeKeys.includes(it.key)) ?? [];
479
- return changeIndex({
480
- stale: false,
481
- type: 'tab',
482
- key: `tab-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
483
- index,
484
- routeNames,
485
- history,
486
- routes,
487
- preloadedRouteKeys: state.preloadedRouteKeys?.filter(key => routeKeys.includes(key)) ?? []
488
- }, index, backBehavior, initialRouteName);
489
- },
490
- getStateForRouteNamesChange(state, {
491
- routeNames,
492
- routeParamList,
493
- routeKeyChanges
494
- }) {
495
- var routes = routeNames.map(name => state.routes.find(r => r.name === name && !routeKeyChanges.includes(r.name)) || {
496
- name,
497
- key: `${name}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
498
- params: routeParamList[name]
499
- });
500
- var index = Math.max(0, routeNames.indexOf(state.routes[state.index].name));
501
- var history = state.history.filter(
502
- // Type will always be 'route' for tabs, but could be different in a router extending this (e.g. drawer)
503
- it => it.type !== 'route' || routes.find(r => r.key === it.key));
504
- if (!history.length) {
505
- history = getRouteHistory(routes, index, backBehavior, initialRouteName);
506
- }
507
- return {
508
- ...state,
509
- history,
510
- routeNames,
511
- routes,
512
- index
513
- };
514
- },
515
- getStateForRouteFocus(state, key) {
516
- var index = state.routes.findIndex(r => r.key === key);
517
- if (index === -1 || index === state.index) {
518
- return state;
519
- }
520
- return changeIndex(state, index, backBehavior, initialRouteName);
521
- },
522
- getStateForAction(state, action, {
523
- routeParamList,
524
- routeGetIdList
525
- }) {
526
- switch (action.type) {
527
- case 'JUMP_TO':
528
- case 'NAVIGATE':
529
- case 'NAVIGATE_DEPRECATED':
530
- {
531
- var index = state.routes.findIndex(route => route.name === action.payload.name);
532
- if (index === -1) {
533
- return null;
534
- }
535
- var updatedState = changeIndex({
536
- ...state,
537
- routes: state.routes.map(route => {
538
- if (route.name !== action.payload.name) {
539
- return route;
540
- }
541
- var getId = routeGetIdList[route.name];
542
- var currentId = getId?.({
543
- params: route.params
544
- });
545
- var nextId = getId?.({
546
- params: action.payload.params
547
- });
548
- var key = currentId === nextId ? route.key : `${route.name}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`;
549
- var params;
550
- if ((action.type === 'NAVIGATE' || action.type === 'NAVIGATE_DEPRECATED') && action.payload.merge && currentId === nextId) {
551
- params = action.payload.params !== undefined || routeParamList[route.name] !== undefined ? {
552
- ...routeParamList[route.name],
553
- ...route.params,
554
- ...action.payload.params
555
- } : route.params;
556
- } else {
557
- params = (0, _$$_REQUIRE(_dependencyMap[2]).createParamsFromAction)({
558
- action,
559
- routeParamList
560
- });
561
- }
562
- var path = action.type === 'NAVIGATE' && action.payload.path != null ? action.payload.path : route.path;
563
- return params !== route.params || path !== route.path ? {
564
- ...route,
565
- key,
566
- path,
567
- params
568
- } : route;
569
- })
570
- }, index, backBehavior, initialRouteName);
571
- return {
572
- ...updatedState,
573
- preloadedRouteKeys: updatedState.preloadedRouteKeys.filter(key => key !== state.routes[updatedState.index].key)
574
- };
575
- }
576
- case 'SET_PARAMS':
577
- case 'REPLACE_PARAMS':
578
- {
579
- var nextState = _$$_REQUIRE(_dependencyMap[0]).BaseRouter.getStateForAction(state, action);
580
- if (nextState !== null) {
581
- var _index = nextState.index;
582
- if (_index != null) {
583
- var focusedRoute = nextState.routes[_index];
584
- var historyItemIndex = state.history.findLastIndex(item => item.key === focusedRoute.key);
585
- var updatedHistory = state.history;
586
- if (historyItemIndex !== -1) {
587
- updatedHistory = [...state.history];
588
- updatedHistory[historyItemIndex] = {
589
- ...updatedHistory[historyItemIndex],
590
- params: focusedRoute.params
591
- };
592
- }
593
- return {
594
- ...nextState,
595
- history: updatedHistory
596
- };
597
- }
598
- }
599
- return nextState;
600
- }
601
- case 'GO_BACK':
602
- {
603
- if (state.history.length === 1) {
604
- return null;
605
- }
606
- var previousHistoryItem = state.history[state.history.length - 2];
607
- var previousKey = previousHistoryItem?.key;
608
- var _index2 = state.routes.findLastIndex(route => route.key === previousKey);
609
- if (_index2 === -1) {
610
- return null;
611
- }
612
- var routes = state.routes;
613
- if (backBehavior === 'fullHistory' && routes[_index2].params !== previousHistoryItem.params) {
614
- routes = [...state.routes];
615
- routes[_index2] = {
616
- ...routes[_index2],
617
- params: previousHistoryItem.params
618
- };
619
- }
620
- return {
621
- ...state,
622
- routes,
623
- preloadedRouteKeys: state.preloadedRouteKeys.filter(key => key !== state.routes[_index2].key),
624
- history: state.history.slice(0, -1),
625
- index: _index2
626
- };
627
- }
628
- case 'PRELOAD':
629
- {
630
- var routeIndex = state.routes.findIndex(route => route.name === action.payload.name);
631
- if (routeIndex === -1) {
632
- return null;
633
- }
634
- var route = state.routes[routeIndex];
635
- var getId = routeGetIdList[route.name];
636
- var currentId = getId?.({
637
- params: route.params
638
- });
639
- var nextId = getId?.({
640
- params: action.payload.params
641
- });
642
- var key = currentId === nextId ? route.key : `${route.name}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`;
643
- var params = (0, _$$_REQUIRE(_dependencyMap[2]).createParamsFromAction)({
644
- action,
645
- routeParamList
646
- });
647
- var newRoute = params !== route.params ? {
648
- ...route,
649
- key,
650
- params
651
- } : route;
652
- return {
653
- ...state,
654
- preloadedRouteKeys: state.preloadedRouteKeys.filter(key => key !== route.key).concat(newRoute.key),
655
- routes: state.routes.map((route, index) => index === routeIndex ? newRoute : route),
656
- history: key === route.key ? state.history : state.history.filter(record => record.key !== route.key)
657
- };
658
- }
659
- default:
660
- return _$$_REQUIRE(_dependencyMap[0]).BaseRouter.getStateForAction(state, action);
661
- }
662
- },
663
- actionCreators: TabActions
664
- };
665
- return router;
666
- }
667
- },"cdf36facce344b18753d",["4aa609d49dd4d9fd69d8","f9dacdfad56c8f57acc2","f37671f481d3442f7534"]);
668
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
669
- "use strict";
670
-
671
- Object.defineProperty(exports, "__esModule", {
672
- value: true
673
- });
674
- exports.createParamsFromAction = createParamsFromAction;
675
- function createParamsFromAction({
676
- action,
677
- routeParamList
678
- }) {
679
- var _action$payload = action.payload,
680
- name = _action$payload.name,
681
- params = _action$payload.params;
682
- return routeParamList[name] !== undefined ? {
683
- ...routeParamList[name],
684
- ...params
685
- } : params;
686
- }
687
- },"f37671f481d3442f7534",[]);
688
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
689
- "use strict";
690
-
691
- Object.defineProperty(exports, "__esModule", {
692
- value: true
693
- });
694
- exports.StackActions = undefined;
695
- exports.StackRouter = StackRouter;
696
- var StackActions = exports.StackActions = {
697
- replace(name, params) {
698
- return {
699
- type: 'REPLACE',
700
- payload: {
701
- name,
702
- params
703
- }
704
- };
705
- },
706
- push(name, params) {
707
- return {
708
- type: 'PUSH',
709
- payload: {
710
- name,
711
- params
712
- }
713
- };
714
- },
715
- pop(count = 1) {
716
- return {
717
- type: 'POP',
718
- payload: {
719
- count
720
- }
721
- };
722
- },
723
- popToTop() {
724
- return {
725
- type: 'POP_TO_TOP'
726
- };
727
- },
728
- popTo(name, params, options) {
729
- if (typeof options === 'boolean') {
730
- console.warn(`Passing a boolean as the third argument to 'popTo' is deprecated. Pass '{ merge: true }' instead.`);
731
- }
732
- return {
733
- type: 'POP_TO',
734
- payload: {
735
- name,
736
- params,
737
- merge: typeof options === 'boolean' ? options : options?.merge
738
- }
739
- };
740
- }
741
- };
742
- function StackRouter(options) {
743
- var router = {
744
- ..._$$_REQUIRE(_dependencyMap[0]).BaseRouter,
745
- type: 'stack',
746
- getInitialState({
747
- routeNames,
748
- routeParamList
749
- }) {
750
- var initialRouteName = options.initialRouteName !== undefined && routeNames.includes(options.initialRouteName) ? options.initialRouteName : routeNames[0];
751
- return {
752
- stale: false,
753
- type: 'stack',
754
- key: `stack-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
755
- index: 0,
756
- routeNames,
757
- preloadedRoutes: [],
758
- routes: [{
759
- key: `${initialRouteName}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
760
- name: initialRouteName,
761
- params: routeParamList[initialRouteName]
762
- }]
763
- };
764
- },
765
- getRehydratedState(partialState, {
766
- routeNames,
767
- routeParamList
768
- }) {
769
- var state = partialState;
770
- if (state.stale === false) {
771
- return state;
772
- }
773
- var routes = state.routes.filter(route => routeNames.includes(route.name)).map(route => ({
774
- ...route,
775
- key: route.key || `${route.name}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
776
- params: routeParamList[route.name] !== undefined ? {
777
- ...routeParamList[route.name],
778
- ...route.params
779
- } : route.params
780
- }));
781
- var preloadedRoutes = state.preloadedRoutes?.filter(route => routeNames.includes(route.name)).map(route => ({
782
- ...route,
783
- key: route.key || `${route.name}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
784
- params: routeParamList[route.name] !== undefined ? {
785
- ...routeParamList[route.name],
786
- ...route.params
787
- } : route.params
788
- })) ?? [];
789
- if (routes.length === 0) {
790
- var initialRouteName = options.initialRouteName !== undefined ? options.initialRouteName : routeNames[0];
791
- routes.push({
792
- key: `${initialRouteName}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
793
- name: initialRouteName,
794
- params: routeParamList[initialRouteName]
795
- });
796
- }
797
- return {
798
- stale: false,
799
- type: 'stack',
800
- key: `stack-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
801
- index: routes.length - 1,
802
- routeNames,
803
- routes,
804
- preloadedRoutes
805
- };
806
- },
807
- getStateForRouteNamesChange(state, {
808
- routeNames,
809
- routeParamList,
810
- routeKeyChanges
811
- }) {
812
- var routes = state.routes.filter(route => routeNames.includes(route.name) && !routeKeyChanges.includes(route.name));
813
- if (routes.length === 0) {
814
- var initialRouteName = options.initialRouteName !== undefined && routeNames.includes(options.initialRouteName) ? options.initialRouteName : routeNames[0];
815
- routes.push({
816
- key: `${initialRouteName}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
817
- name: initialRouteName,
818
- params: routeParamList[initialRouteName]
819
- });
820
- }
821
- return {
822
- ...state,
823
- routeNames,
824
- routes,
825
- index: Math.min(state.index, routes.length - 1)
826
- };
827
- },
828
- getStateForRouteFocus(state, key) {
829
- var index = state.routes.findIndex(r => r.key === key);
830
- if (index === -1 || index === state.index) {
831
- return state;
832
- }
833
- return {
834
- ...state,
835
- index,
836
- routes: state.routes.slice(0, index + 1)
837
- };
838
- },
839
- getStateForAction(state, action, options) {
840
- var routeParamList = options.routeParamList;
841
- switch (action.type) {
842
- case 'REPLACE':
843
- {
844
- var currentIndex = action.target === state.key && action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
845
- if (currentIndex === -1) {
846
- return null;
847
- }
848
- if (!state.routeNames.includes(action.payload.name)) {
849
- return null;
850
- }
851
- var getId = options.routeGetIdList[action.payload.name];
852
- var id = getId?.({
853
- params: action.payload.params
854
- });
855
-
856
- // Re-use preloaded route if available
857
- var route = state.preloadedRoutes.find(route => route.name === action.payload.name && id === getId?.({
858
- params: route.params
859
- }));
860
- if (!route) {
861
- route = (0, _$$_REQUIRE(_dependencyMap[2]).createRouteFromAction)({
862
- action,
863
- routeParamList
864
- });
865
- }
866
- return {
867
- ...state,
868
- routes: state.routes.map((r, i) => i === currentIndex ? route : r),
869
- preloadedRoutes: state.preloadedRoutes.filter(r => r.key !== route.key)
870
- };
871
- }
872
- case 'PUSH':
873
- case 'NAVIGATE':
874
- {
875
- if (!state.routeNames.includes(action.payload.name)) {
876
- return null;
877
- }
878
- var _getId = options.routeGetIdList[action.payload.name];
879
- var _id = _getId?.({
880
- params: action.payload.params
881
- });
882
- var _route;
883
- if (_id !== undefined) {
884
- _route = state.routes.find(route => route.name === action.payload.name && _id === _getId?.({
885
- params: route.params
886
- }));
887
- } else {
888
- var currentRoute = state.routes[state.index];
889
-
890
- // If the route matches the current one, then navigate to it
891
- if (action.type === 'NAVIGATE' && action.payload.name === currentRoute.name) {
892
- _route = currentRoute;
893
- }
894
- }
895
- if (!_route) {
896
- _route = state.preloadedRoutes.find(route => route.name === action.payload.name && _id === _getId?.({
897
- params: route.params
898
- }));
899
- }
900
- var params;
901
- if (action.type === 'NAVIGATE' && action.payload.merge && _route) {
902
- params = action.payload.params !== undefined || routeParamList[action.payload.name] !== undefined ? {
903
- ...routeParamList[action.payload.name],
904
- ..._route.params,
905
- ...action.payload.params
906
- } : _route.params;
907
- } else {
908
- params = (0, _$$_REQUIRE(_dependencyMap[3]).createParamsFromAction)({
909
- action,
910
- routeParamList
911
- });
912
- }
913
- var routes;
914
- if (_route) {
915
- var routeKey = _route.key;
916
- routes = state.routes.filter(r => r.key !== routeKey);
917
- routes.push({
918
- ..._route,
919
- path: action.type === 'NAVIGATE' && action.payload.path !== undefined ? action.payload.path : _route.path,
920
- params
921
- });
922
- } else {
923
- routes = [...state.routes, {
924
- key: `${action.payload.name}-${(0, _$$_REQUIRE(_dependencyMap[1]).nanoid)()}`,
925
- name: action.payload.name,
926
- path: action.type === 'NAVIGATE' ? action.payload.path : undefined,
927
- params
928
- }];
929
- }
930
- return {
931
- ...state,
932
- index: routes.length - 1,
933
- preloadedRoutes: state.preloadedRoutes.filter(route => routes[routes.length - 1].key !== route.key),
934
- routes
935
- };
936
- }
937
- case 'NAVIGATE_DEPRECATED':
938
- {
939
- if (!state.routeNames.includes(action.payload.name)) {
940
- return null;
941
- }
942
- if (state.preloadedRoutes.find(route => route.name === action.payload.name && _id2 === _getId2?.({
943
- params: route.params
944
- }))) {
945
- return null;
946
- }
947
-
948
- // If the route already exists, navigate to that
949
- var index = -1;
950
- var _getId2 = options.routeGetIdList[action.payload.name];
951
- var _id2 = _getId2?.({
952
- params: action.payload.params
953
- });
954
- if (_id2 !== undefined) {
955
- index = state.routes.findIndex(route => route.name === action.payload.name && _id2 === _getId2?.({
956
- params: route.params
957
- }));
958
- } else if (state.routes[state.index].name === action.payload.name) {
959
- index = state.index;
960
- } else {
961
- index = state.routes.findLastIndex(route => route.name === action.payload.name);
962
- }
963
- if (index === -1) {
964
- var _routes = [...state.routes, (0, _$$_REQUIRE(_dependencyMap[2]).createRouteFromAction)({
965
- action,
966
- routeParamList
967
- })];
968
- return {
969
- ...state,
970
- routes: _routes,
971
- index: _routes.length - 1
972
- };
973
- }
974
- var _route2 = state.routes[index];
975
- var _params;
976
- if (action.payload.merge) {
977
- _params = action.payload.params !== undefined || routeParamList[_route2.name] !== undefined ? {
978
- ...routeParamList[_route2.name],
979
- ..._route2.params,
980
- ...action.payload.params
981
- } : _route2.params;
982
- } else {
983
- _params = (0, _$$_REQUIRE(_dependencyMap[3]).createParamsFromAction)({
984
- action,
985
- routeParamList
986
- });
987
- }
988
- return {
989
- ...state,
990
- index,
991
- routes: [...state.routes.slice(0, index), _params !== _route2.params ? {
992
- ..._route2,
993
- params: _params
994
- } : state.routes[index]]
995
- };
996
- }
997
- case 'POP':
998
- {
999
- var _currentIndex = action.target === state.key && action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
1000
- if (_currentIndex > 0) {
1001
- var count = Math.max(_currentIndex - action.payload.count + 1, 1);
1002
- var _routes2 = state.routes.slice(0, count).concat(state.routes.slice(_currentIndex + 1));
1003
- return {
1004
- ...state,
1005
- index: _routes2.length - 1,
1006
- routes: _routes2
1007
- };
1008
- }
1009
- return null;
1010
- }
1011
- case 'POP_TO_TOP':
1012
- return router.getStateForAction(state, {
1013
- type: 'POP',
1014
- payload: {
1015
- count: state.routes.length - 1
1016
- }
1017
- }, options);
1018
- case 'POP_TO':
1019
- {
1020
- var _currentIndex2 = action.target === state.key && action.source ? state.routes.findLastIndex(r => r.key === action.source) : state.index;
1021
- if (_currentIndex2 === -1) {
1022
- return null;
1023
- }
1024
- if (!state.routeNames.includes(action.payload.name)) {
1025
- return null;
1026
- }
1027
-
1028
- // If the route already exists, navigate to it
1029
- var _index = -1;
1030
- var _getId3 = options.routeGetIdList[action.payload.name];
1031
- var _id3 = _getId3?.({
1032
- params: action.payload.params
1033
- });
1034
- if (_id3 !== undefined) {
1035
- _index = state.routes.findIndex(route => route.name === action.payload.name && _id3 === _getId3?.({
1036
- params: route.params
1037
- }));
1038
- } else if (state.routes[_currentIndex2].name === action.payload.name) {
1039
- _index = _currentIndex2;
1040
- } else {
1041
- for (var i = _currentIndex2; i >= 0; i--) {
1042
- if (state.routes[i].name === action.payload.name) {
1043
- _index = i;
1044
- break;
1045
- }
1046
- }
1047
- }
1048
-
1049
- // If the route doesn't exist, remove the current route and add the new one
1050
- if (_index === -1) {
1051
- // Re-use preloaded route if available
1052
- var _route3 = state.preloadedRoutes.find(route => route.name === action.payload.name && _id3 === _getId3?.({
1053
- params: route.params
1054
- }));
1055
- if (!_route3) {
1056
- _route3 = (0, _$$_REQUIRE(_dependencyMap[2]).createRouteFromAction)({
1057
- action,
1058
- routeParamList
1059
- });
1060
- }
1061
- var _routes3 = state.routes.slice(0, _currentIndex2).concat(_route3);
1062
- return {
1063
- ...state,
1064
- index: _routes3.length - 1,
1065
- routes: _routes3,
1066
- preloadedRoutes: state.preloadedRoutes.filter(r => r.key !== _route3.key)
1067
- };
1068
- }
1069
- var _route4 = state.routes[_index];
1070
- var _params2;
1071
- if (action.payload.merge) {
1072
- _params2 = action.payload.params !== undefined || routeParamList[_route4.name] !== undefined ? {
1073
- ...routeParamList[_route4.name],
1074
- ..._route4.params,
1075
- ...action.payload.params
1076
- } : _route4.params;
1077
- } else {
1078
- _params2 = (0, _$$_REQUIRE(_dependencyMap[3]).createParamsFromAction)({
1079
- action,
1080
- routeParamList
1081
- });
1082
- }
1083
- return {
1084
- ...state,
1085
- index: _index,
1086
- routes: [...state.routes.slice(0, _index), _params2 !== _route4.params ? {
1087
- ..._route4,
1088
- params: _params2
1089
- } : state.routes[_index]]
1090
- };
1091
- }
1092
- case 'GO_BACK':
1093
- if (state.index > 0) {
1094
- return router.getStateForAction(state, {
1095
- type: 'POP',
1096
- payload: {
1097
- count: 1
1098
- },
1099
- target: action.target,
1100
- source: action.source
1101
- }, options);
1102
- }
1103
- return null;
1104
- case 'PRELOAD':
1105
- {
1106
- var _getId4 = options.routeGetIdList[action.payload.name];
1107
- var _id4 = _getId4?.({
1108
- params: action.payload.params
1109
- });
1110
- var _route5;
1111
- if (_id4 !== undefined) {
1112
- _route5 = state.routes.find(route => route.name === action.payload.name && _id4 === _getId4?.({
1113
- params: route.params
1114
- }));
1115
- }
1116
- if (_route5) {
1117
- return {
1118
- ...state,
1119
- routes: state.routes.map(r => {
1120
- if (r.key !== _route5?.key) {
1121
- return r;
1122
- }
1123
- return {
1124
- ...r,
1125
- params: (0, _$$_REQUIRE(_dependencyMap[3]).createParamsFromAction)({
1126
- action,
1127
- routeParamList
1128
- })
1129
- };
1130
- })
1131
- };
1132
- } else {
1133
- return {
1134
- ...state,
1135
- preloadedRoutes: state.preloadedRoutes.filter(r => r.name !== action.payload.name || _id4 !== _getId4?.({
1136
- params: r.params
1137
- })).concat((0, _$$_REQUIRE(_dependencyMap[2]).createRouteFromAction)({
1138
- action,
1139
- routeParamList
1140
- }))
1141
- };
1142
- }
1143
- }
1144
- default:
1145
- return _$$_REQUIRE(_dependencyMap[0]).BaseRouter.getStateForAction(state, action);
1146
- }
1147
- },
1148
- actionCreators: StackActions
1149
- };
1150
- return router;
1151
- }
1152
- },"2beefa0726d547efb6db",["4aa609d49dd4d9fd69d8","f9dacdfad56c8f57acc2","c69c3cb84fab85c7ab0e","f37671f481d3442f7534"]);
1153
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
1154
- "use strict";
1155
-
1156
- Object.defineProperty(exports, "__esModule", {
1157
- value: true
1158
- });
1159
- exports.createRouteFromAction = createRouteFromAction;
1160
- function createRouteFromAction({
1161
- action,
1162
- routeParamList
1163
- }) {
1164
- var name = action.payload.name;
1165
- return {
1166
- key: `${name}-${(0, _$$_REQUIRE(_dependencyMap[0]).nanoid)()}`,
1167
- name,
1168
- params: (0, _$$_REQUIRE(_dependencyMap[1]).createParamsFromAction)({
1169
- action,
1170
- routeParamList
1171
- })
1172
- };
1173
- }
1174
- },"c69c3cb84fab85c7ab0e",["f9dacdfad56c8f57acc2","f37671f481d3442f7534"]);
1175
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
1176
- "use strict";
1177
-
1178
- Object.defineProperty(exports, "__esModule", {
1179
- value: true
1180
- });
1181
- exports.goBack = goBack;
1182
- exports.navigate = navigate;
1183
- exports.navigateDeprecated = navigateDeprecated;
1184
- exports.preload = preload;
1185
- exports.replaceParams = replaceParams;
1186
- exports.reset = reset;
1187
- exports.setParams = setParams;
1188
- function goBack() {
1189
- return {
1190
- type: 'GO_BACK'
1191
- };
1192
- }
1193
- function navigate(...args) {
1194
- if (typeof args[0] === 'string') {
1195
- var name = args[0],
1196
- params = args[1],
1197
- options = args[2];
1198
- if (typeof options === 'boolean') {
1199
- console.warn(`Passing a boolean as the third argument to 'navigate' is deprecated. Pass '{ merge: true }' instead.`);
1200
- }
1201
- return {
1202
- type: 'NAVIGATE',
1203
- payload: {
1204
- name,
1205
- params,
1206
- merge: typeof options === 'boolean' ? options : options?.merge,
1207
- pop: options?.pop
1208
- }
1209
- };
1210
- } else {
1211
- var payload = args[0] || {};
1212
- if (!('name' in payload)) {
1213
- throw new Error('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.');
1214
- }
1215
- return {
1216
- type: 'NAVIGATE',
1217
- payload
1218
- };
1219
- }
1220
- }
1221
- function navigateDeprecated(...args) {
1222
- if (typeof args[0] === 'string') {
1223
- return {
1224
- type: 'NAVIGATE_DEPRECATED',
1225
- payload: {
1226
- name: args[0],
1227
- params: args[1]
1228
- }
1229
- };
1230
- } else {
1231
- var payload = args[0] || {};
1232
- if (!('name' in payload)) {
1233
- throw new Error('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.');
1234
- }
1235
- return {
1236
- type: 'NAVIGATE_DEPRECATED',
1237
- payload
1238
- };
1239
- }
1240
- }
1241
- function reset(state) {
1242
- return {
1243
- type: 'RESET',
1244
- payload: state
1245
- };
1246
- }
1247
- function setParams(params) {
1248
- return {
1249
- type: 'SET_PARAMS',
1250
- payload: {
1251
- params
1252
- }
1253
- };
1254
- }
1255
- function replaceParams(params) {
1256
- return {
1257
- type: 'REPLACE_PARAMS',
1258
- payload: {
1259
- params
1260
- }
1261
- };
1262
- }
1263
- function preload(name, params) {
1264
- return {
1265
- type: 'PRELOAD',
1266
- payload: {
1267
- name,
1268
- params
1269
- }
1270
- };
1271
- }
1272
- },"6664264a195fd5e23d1d",[]);
1273
- __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
1274
- "use strict";
1275
-
1276
- Object.defineProperty(exports, "__esModule", {
1277
- value: true
1278
- });
1279
- },"42552d18e7ae0181bd39",[]);