@tanstack/router-core 0.0.1-beta.25 → 0.0.1-beta.29
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/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -2
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/{packages/router-core/src/index.js → index.js} +22 -6
- package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
- package/build/cjs/{packages/router-core/src/path.js → path.js} +6 -30
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/{packages/router-core/src/qss.js → qss.js} +8 -13
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/{packages/router-core/src/route.js → route.js} +7 -16
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/{packages/router-core/src/routeConfig.js → routeConfig.js} +13 -12
- package/build/cjs/routeConfig.js.map +1 -0
- package/build/cjs/{packages/router-core/src/routeMatch.js → routeMatch.js} +15 -35
- package/build/cjs/routeMatch.js.map +1 -0
- package/build/cjs/{packages/router-core/src/router.js → router.js} +103 -159
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +7 -10
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/{packages/router-core/src/utils.js → utils.js} +10 -24
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +156 -1116
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +160 -154
- package/build/types/index.d.ts +53 -40
- package/build/umd/index.development.js +151 -294
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/link.ts +2 -2
- package/src/path.ts +2 -2
- package/src/route.ts +8 -5
- package/src/routeConfig.ts +77 -63
- package/src/routeInfo.ts +11 -6
- package/src/routeMatch.ts +1 -1
- package/src/router.ts +114 -51
- package/src/utils.ts +2 -2
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
- package/build/cjs/node_modules/history/index.js +0 -815
- package/build/cjs/node_modules/history/index.js.map +0 -1
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
- package/build/cjs/packages/router-core/src/path.js.map +0 -1
- package/build/cjs/packages/router-core/src/qss.js.map +0 -1
- package/build/cjs/packages/router-core/src/route.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js.map +0 -1
- package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
- package/build/cjs/packages/router-core/src/utils.js.map +0 -1
package/build/esm/index.js
CHANGED
|
@@ -8,829 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
for (var key in source) {
|
|
17
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
|
-
target[key] = source[key];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return target;
|
|
24
|
-
};
|
|
25
|
-
return _extends$1.apply(this, arguments);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Actions represent the type of change to a location value.
|
|
30
|
-
*
|
|
31
|
-
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#action
|
|
32
|
-
*/
|
|
33
|
-
var Action;
|
|
34
|
-
|
|
35
|
-
(function (Action) {
|
|
36
|
-
/**
|
|
37
|
-
* A POP indicates a change to an arbitrary index in the history stack, such
|
|
38
|
-
* as a back or forward navigation. It does not describe the direction of the
|
|
39
|
-
* navigation, only that the current index changed.
|
|
40
|
-
*
|
|
41
|
-
* Note: This is the default action for newly created history objects.
|
|
42
|
-
*/
|
|
43
|
-
Action["Pop"] = "POP";
|
|
44
|
-
/**
|
|
45
|
-
* A PUSH indicates a new entry being added to the history stack, such as when
|
|
46
|
-
* a link is clicked and a new page loads. When this happens, all subsequent
|
|
47
|
-
* entries in the stack are lost.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
Action["Push"] = "PUSH";
|
|
51
|
-
/**
|
|
52
|
-
* A REPLACE indicates the entry at the current index in the history stack
|
|
53
|
-
* being replaced by a new one.
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
Action["Replace"] = "REPLACE";
|
|
57
|
-
})(Action || (Action = {}));
|
|
58
|
-
|
|
59
|
-
var readOnly = process.env.NODE_ENV !== "production" ? function (obj) {
|
|
60
|
-
return Object.freeze(obj);
|
|
61
|
-
} : function (obj) {
|
|
62
|
-
return obj;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
function warning$1(cond, message) {
|
|
66
|
-
if (!cond) {
|
|
67
|
-
// eslint-disable-next-line no-console
|
|
68
|
-
if (typeof console !== 'undefined') console.warn(message);
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
// Welcome to debugging history!
|
|
72
|
-
//
|
|
73
|
-
// This error is thrown as a convenience so you can more easily
|
|
74
|
-
// find the source for a warning that appears in the console by
|
|
75
|
-
// enabling "pause on exceptions" in your JavaScript debugger.
|
|
76
|
-
throw new Error(message); // eslint-disable-next-line no-empty
|
|
77
|
-
} catch (e) {}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
var BeforeUnloadEventType = 'beforeunload';
|
|
82
|
-
var HashChangeEventType = 'hashchange';
|
|
83
|
-
var PopStateEventType = 'popstate';
|
|
84
|
-
/**
|
|
85
|
-
* Browser history stores the location in regular URLs. This is the standard for
|
|
86
|
-
* most web apps, but it requires some configuration on the server to ensure you
|
|
87
|
-
* serve the same app at multiple URLs.
|
|
88
|
-
*
|
|
89
|
-
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
function createBrowserHistory(options) {
|
|
93
|
-
if (options === void 0) {
|
|
94
|
-
options = {};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
var _options = options,
|
|
98
|
-
_options$window = _options.window,
|
|
99
|
-
window = _options$window === void 0 ? document.defaultView : _options$window;
|
|
100
|
-
var globalHistory = window.history;
|
|
101
|
-
|
|
102
|
-
function getIndexAndLocation() {
|
|
103
|
-
var _window$location = window.location,
|
|
104
|
-
pathname = _window$location.pathname,
|
|
105
|
-
search = _window$location.search,
|
|
106
|
-
hash = _window$location.hash;
|
|
107
|
-
var state = globalHistory.state || {};
|
|
108
|
-
return [state.idx, readOnly({
|
|
109
|
-
pathname: pathname,
|
|
110
|
-
search: search,
|
|
111
|
-
hash: hash,
|
|
112
|
-
state: state.usr || null,
|
|
113
|
-
key: state.key || 'default'
|
|
114
|
-
})];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
var blockedPopTx = null;
|
|
118
|
-
|
|
119
|
-
function handlePop() {
|
|
120
|
-
if (blockedPopTx) {
|
|
121
|
-
blockers.call(blockedPopTx);
|
|
122
|
-
blockedPopTx = null;
|
|
123
|
-
} else {
|
|
124
|
-
var nextAction = Action.Pop;
|
|
125
|
-
|
|
126
|
-
var _getIndexAndLocation = getIndexAndLocation(),
|
|
127
|
-
nextIndex = _getIndexAndLocation[0],
|
|
128
|
-
nextLocation = _getIndexAndLocation[1];
|
|
129
|
-
|
|
130
|
-
if (blockers.length) {
|
|
131
|
-
if (nextIndex != null) {
|
|
132
|
-
var delta = index - nextIndex;
|
|
133
|
-
|
|
134
|
-
if (delta) {
|
|
135
|
-
// Revert the POP
|
|
136
|
-
blockedPopTx = {
|
|
137
|
-
action: nextAction,
|
|
138
|
-
location: nextLocation,
|
|
139
|
-
retry: function retry() {
|
|
140
|
-
go(delta * -1);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
go(delta);
|
|
144
|
-
}
|
|
145
|
-
} else {
|
|
146
|
-
// Trying to POP to a location with no index. We did not create
|
|
147
|
-
// this location, so we can't effectively block the navigation.
|
|
148
|
-
process.env.NODE_ENV !== "production" ? warning$1(false, // TODO: Write up a doc that explains our blocking strategy in
|
|
149
|
-
// detail and link to it here so people can understand better what
|
|
150
|
-
// is going on and how to avoid it.
|
|
151
|
-
"You are trying to block a POP navigation to a location that was not " + "created by the history library. The block will fail silently in " + "production, but in general you should do all navigation with the " + "history library (instead of using window.history.pushState directly) " + "to avoid this situation.") : void 0;
|
|
152
|
-
}
|
|
153
|
-
} else {
|
|
154
|
-
applyTx(nextAction);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
window.addEventListener(PopStateEventType, handlePop);
|
|
160
|
-
var action = Action.Pop;
|
|
161
|
-
|
|
162
|
-
var _getIndexAndLocation2 = getIndexAndLocation(),
|
|
163
|
-
index = _getIndexAndLocation2[0],
|
|
164
|
-
location = _getIndexAndLocation2[1];
|
|
165
|
-
|
|
166
|
-
var listeners = createEvents();
|
|
167
|
-
var blockers = createEvents();
|
|
168
|
-
|
|
169
|
-
if (index == null) {
|
|
170
|
-
index = 0;
|
|
171
|
-
globalHistory.replaceState(_extends$1({}, globalHistory.state, {
|
|
172
|
-
idx: index
|
|
173
|
-
}), '');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function createHref(to) {
|
|
177
|
-
return typeof to === 'string' ? to : createPath(to);
|
|
178
|
-
} // state defaults to `null` because `window.history.state` does
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
function getNextLocation(to, state) {
|
|
182
|
-
if (state === void 0) {
|
|
183
|
-
state = null;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return readOnly(_extends$1({
|
|
187
|
-
pathname: location.pathname,
|
|
188
|
-
hash: '',
|
|
189
|
-
search: ''
|
|
190
|
-
}, typeof to === 'string' ? parsePath(to) : to, {
|
|
191
|
-
state: state,
|
|
192
|
-
key: createKey()
|
|
193
|
-
}));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function getHistoryStateAndUrl(nextLocation, index) {
|
|
197
|
-
return [{
|
|
198
|
-
usr: nextLocation.state,
|
|
199
|
-
key: nextLocation.key,
|
|
200
|
-
idx: index
|
|
201
|
-
}, createHref(nextLocation)];
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function allowTx(action, location, retry) {
|
|
205
|
-
return !blockers.length || (blockers.call({
|
|
206
|
-
action: action,
|
|
207
|
-
location: location,
|
|
208
|
-
retry: retry
|
|
209
|
-
}), false);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function applyTx(nextAction) {
|
|
213
|
-
action = nextAction;
|
|
214
|
-
|
|
215
|
-
var _getIndexAndLocation3 = getIndexAndLocation();
|
|
216
|
-
|
|
217
|
-
index = _getIndexAndLocation3[0];
|
|
218
|
-
location = _getIndexAndLocation3[1];
|
|
219
|
-
listeners.call({
|
|
220
|
-
action: action,
|
|
221
|
-
location: location
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function push(to, state) {
|
|
226
|
-
var nextAction = Action.Push;
|
|
227
|
-
var nextLocation = getNextLocation(to, state);
|
|
228
|
-
|
|
229
|
-
function retry() {
|
|
230
|
-
push(to, state);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
234
|
-
var _getHistoryStateAndUr = getHistoryStateAndUrl(nextLocation, index + 1),
|
|
235
|
-
historyState = _getHistoryStateAndUr[0],
|
|
236
|
-
url = _getHistoryStateAndUr[1]; // TODO: Support forced reloading
|
|
237
|
-
// try...catch because iOS limits us to 100 pushState calls :/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
try {
|
|
241
|
-
globalHistory.pushState(historyState, '', url);
|
|
242
|
-
} catch (error) {
|
|
243
|
-
// They are going to lose state here, but there is no real
|
|
244
|
-
// way to warn them about it since the page will refresh...
|
|
245
|
-
window.location.assign(url);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
applyTx(nextAction);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function replace(to, state) {
|
|
253
|
-
var nextAction = Action.Replace;
|
|
254
|
-
var nextLocation = getNextLocation(to, state);
|
|
255
|
-
|
|
256
|
-
function retry() {
|
|
257
|
-
replace(to, state);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
261
|
-
var _getHistoryStateAndUr2 = getHistoryStateAndUrl(nextLocation, index),
|
|
262
|
-
historyState = _getHistoryStateAndUr2[0],
|
|
263
|
-
url = _getHistoryStateAndUr2[1]; // TODO: Support forced reloading
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
globalHistory.replaceState(historyState, '', url);
|
|
267
|
-
applyTx(nextAction);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function go(delta) {
|
|
272
|
-
globalHistory.go(delta);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
var history = {
|
|
276
|
-
get action() {
|
|
277
|
-
return action;
|
|
278
|
-
},
|
|
279
|
-
|
|
280
|
-
get location() {
|
|
281
|
-
return location;
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
createHref: createHref,
|
|
285
|
-
push: push,
|
|
286
|
-
replace: replace,
|
|
287
|
-
go: go,
|
|
288
|
-
back: function back() {
|
|
289
|
-
go(-1);
|
|
290
|
-
},
|
|
291
|
-
forward: function forward() {
|
|
292
|
-
go(1);
|
|
293
|
-
},
|
|
294
|
-
listen: function listen(listener) {
|
|
295
|
-
return listeners.push(listener);
|
|
296
|
-
},
|
|
297
|
-
block: function block(blocker) {
|
|
298
|
-
var unblock = blockers.push(blocker);
|
|
299
|
-
|
|
300
|
-
if (blockers.length === 1) {
|
|
301
|
-
window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return function () {
|
|
305
|
-
unblock(); // Remove the beforeunload listener so the document may
|
|
306
|
-
// still be salvageable in the pagehide event.
|
|
307
|
-
// See https://html.spec.whatwg.org/#unloading-documents
|
|
308
|
-
|
|
309
|
-
if (!blockers.length) {
|
|
310
|
-
window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
return history;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Hash history stores the location in window.location.hash. This makes it ideal
|
|
319
|
-
* for situations where you don't want to send the location to the server for
|
|
320
|
-
* some reason, either because you do cannot configure it or the URL space is
|
|
321
|
-
* reserved for something else.
|
|
322
|
-
*
|
|
323
|
-
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
|
|
324
|
-
*/
|
|
325
|
-
|
|
326
|
-
function createHashHistory(options) {
|
|
327
|
-
if (options === void 0) {
|
|
328
|
-
options = {};
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
var _options2 = options,
|
|
332
|
-
_options2$window = _options2.window,
|
|
333
|
-
window = _options2$window === void 0 ? document.defaultView : _options2$window;
|
|
334
|
-
var globalHistory = window.history;
|
|
335
|
-
|
|
336
|
-
function getIndexAndLocation() {
|
|
337
|
-
var _parsePath = parsePath(window.location.hash.substr(1)),
|
|
338
|
-
_parsePath$pathname = _parsePath.pathname,
|
|
339
|
-
pathname = _parsePath$pathname === void 0 ? '/' : _parsePath$pathname,
|
|
340
|
-
_parsePath$search = _parsePath.search,
|
|
341
|
-
search = _parsePath$search === void 0 ? '' : _parsePath$search,
|
|
342
|
-
_parsePath$hash = _parsePath.hash,
|
|
343
|
-
hash = _parsePath$hash === void 0 ? '' : _parsePath$hash;
|
|
344
|
-
|
|
345
|
-
var state = globalHistory.state || {};
|
|
346
|
-
return [state.idx, readOnly({
|
|
347
|
-
pathname: pathname,
|
|
348
|
-
search: search,
|
|
349
|
-
hash: hash,
|
|
350
|
-
state: state.usr || null,
|
|
351
|
-
key: state.key || 'default'
|
|
352
|
-
})];
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
var blockedPopTx = null;
|
|
356
|
-
|
|
357
|
-
function handlePop() {
|
|
358
|
-
if (blockedPopTx) {
|
|
359
|
-
blockers.call(blockedPopTx);
|
|
360
|
-
blockedPopTx = null;
|
|
361
|
-
} else {
|
|
362
|
-
var nextAction = Action.Pop;
|
|
363
|
-
|
|
364
|
-
var _getIndexAndLocation4 = getIndexAndLocation(),
|
|
365
|
-
nextIndex = _getIndexAndLocation4[0],
|
|
366
|
-
nextLocation = _getIndexAndLocation4[1];
|
|
367
|
-
|
|
368
|
-
if (blockers.length) {
|
|
369
|
-
if (nextIndex != null) {
|
|
370
|
-
var delta = index - nextIndex;
|
|
371
|
-
|
|
372
|
-
if (delta) {
|
|
373
|
-
// Revert the POP
|
|
374
|
-
blockedPopTx = {
|
|
375
|
-
action: nextAction,
|
|
376
|
-
location: nextLocation,
|
|
377
|
-
retry: function retry() {
|
|
378
|
-
go(delta * -1);
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
go(delta);
|
|
382
|
-
}
|
|
383
|
-
} else {
|
|
384
|
-
// Trying to POP to a location with no index. We did not create
|
|
385
|
-
// this location, so we can't effectively block the navigation.
|
|
386
|
-
process.env.NODE_ENV !== "production" ? warning$1(false, // TODO: Write up a doc that explains our blocking strategy in
|
|
387
|
-
// detail and link to it here so people can understand better
|
|
388
|
-
// what is going on and how to avoid it.
|
|
389
|
-
"You are trying to block a POP navigation to a location that was not " + "created by the history library. The block will fail silently in " + "production, but in general you should do all navigation with the " + "history library (instead of using window.history.pushState directly) " + "to avoid this situation.") : void 0;
|
|
390
|
-
}
|
|
391
|
-
} else {
|
|
392
|
-
applyTx(nextAction);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
window.addEventListener(PopStateEventType, handlePop); // popstate does not fire on hashchange in IE 11 and old (trident) Edge
|
|
398
|
-
// https://developer.mozilla.org/de/docs/Web/API/Window/popstate_event
|
|
399
|
-
|
|
400
|
-
window.addEventListener(HashChangeEventType, function () {
|
|
401
|
-
var _getIndexAndLocation5 = getIndexAndLocation(),
|
|
402
|
-
nextLocation = _getIndexAndLocation5[1]; // Ignore extraneous hashchange events.
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (createPath(nextLocation) !== createPath(location)) {
|
|
406
|
-
handlePop();
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
var action = Action.Pop;
|
|
410
|
-
|
|
411
|
-
var _getIndexAndLocation6 = getIndexAndLocation(),
|
|
412
|
-
index = _getIndexAndLocation6[0],
|
|
413
|
-
location = _getIndexAndLocation6[1];
|
|
414
|
-
|
|
415
|
-
var listeners = createEvents();
|
|
416
|
-
var blockers = createEvents();
|
|
417
|
-
|
|
418
|
-
if (index == null) {
|
|
419
|
-
index = 0;
|
|
420
|
-
globalHistory.replaceState(_extends$1({}, globalHistory.state, {
|
|
421
|
-
idx: index
|
|
422
|
-
}), '');
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function getBaseHref() {
|
|
426
|
-
var base = document.querySelector('base');
|
|
427
|
-
var href = '';
|
|
428
|
-
|
|
429
|
-
if (base && base.getAttribute('href')) {
|
|
430
|
-
var url = window.location.href;
|
|
431
|
-
var hashIndex = url.indexOf('#');
|
|
432
|
-
href = hashIndex === -1 ? url : url.slice(0, hashIndex);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
return href;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
function createHref(to) {
|
|
439
|
-
return getBaseHref() + '#' + (typeof to === 'string' ? to : createPath(to));
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
function getNextLocation(to, state) {
|
|
443
|
-
if (state === void 0) {
|
|
444
|
-
state = null;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
return readOnly(_extends$1({
|
|
448
|
-
pathname: location.pathname,
|
|
449
|
-
hash: '',
|
|
450
|
-
search: ''
|
|
451
|
-
}, typeof to === 'string' ? parsePath(to) : to, {
|
|
452
|
-
state: state,
|
|
453
|
-
key: createKey()
|
|
454
|
-
}));
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
function getHistoryStateAndUrl(nextLocation, index) {
|
|
458
|
-
return [{
|
|
459
|
-
usr: nextLocation.state,
|
|
460
|
-
key: nextLocation.key,
|
|
461
|
-
idx: index
|
|
462
|
-
}, createHref(nextLocation)];
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
function allowTx(action, location, retry) {
|
|
466
|
-
return !blockers.length || (blockers.call({
|
|
467
|
-
action: action,
|
|
468
|
-
location: location,
|
|
469
|
-
retry: retry
|
|
470
|
-
}), false);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
function applyTx(nextAction) {
|
|
474
|
-
action = nextAction;
|
|
475
|
-
|
|
476
|
-
var _getIndexAndLocation7 = getIndexAndLocation();
|
|
477
|
-
|
|
478
|
-
index = _getIndexAndLocation7[0];
|
|
479
|
-
location = _getIndexAndLocation7[1];
|
|
480
|
-
listeners.call({
|
|
481
|
-
action: action,
|
|
482
|
-
location: location
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
function push(to, state) {
|
|
487
|
-
var nextAction = Action.Push;
|
|
488
|
-
var nextLocation = getNextLocation(to, state);
|
|
489
|
-
|
|
490
|
-
function retry() {
|
|
491
|
-
push(to, state);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
process.env.NODE_ENV !== "production" ? warning$1(nextLocation.pathname.charAt(0) === '/', "Relative pathnames are not supported in hash history.push(" + JSON.stringify(to) + ")") : void 0;
|
|
495
|
-
|
|
496
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
497
|
-
var _getHistoryStateAndUr3 = getHistoryStateAndUrl(nextLocation, index + 1),
|
|
498
|
-
historyState = _getHistoryStateAndUr3[0],
|
|
499
|
-
url = _getHistoryStateAndUr3[1]; // TODO: Support forced reloading
|
|
500
|
-
// try...catch because iOS limits us to 100 pushState calls :/
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
try {
|
|
504
|
-
globalHistory.pushState(historyState, '', url);
|
|
505
|
-
} catch (error) {
|
|
506
|
-
// They are going to lose state here, but there is no real
|
|
507
|
-
// way to warn them about it since the page will refresh...
|
|
508
|
-
window.location.assign(url);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
applyTx(nextAction);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function replace(to, state) {
|
|
516
|
-
var nextAction = Action.Replace;
|
|
517
|
-
var nextLocation = getNextLocation(to, state);
|
|
518
|
-
|
|
519
|
-
function retry() {
|
|
520
|
-
replace(to, state);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
process.env.NODE_ENV !== "production" ? warning$1(nextLocation.pathname.charAt(0) === '/', "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(to) + ")") : void 0;
|
|
524
|
-
|
|
525
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
526
|
-
var _getHistoryStateAndUr4 = getHistoryStateAndUrl(nextLocation, index),
|
|
527
|
-
historyState = _getHistoryStateAndUr4[0],
|
|
528
|
-
url = _getHistoryStateAndUr4[1]; // TODO: Support forced reloading
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
globalHistory.replaceState(historyState, '', url);
|
|
532
|
-
applyTx(nextAction);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
function go(delta) {
|
|
537
|
-
globalHistory.go(delta);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
var history = {
|
|
541
|
-
get action() {
|
|
542
|
-
return action;
|
|
543
|
-
},
|
|
544
|
-
|
|
545
|
-
get location() {
|
|
546
|
-
return location;
|
|
547
|
-
},
|
|
548
|
-
|
|
549
|
-
createHref: createHref,
|
|
550
|
-
push: push,
|
|
551
|
-
replace: replace,
|
|
552
|
-
go: go,
|
|
553
|
-
back: function back() {
|
|
554
|
-
go(-1);
|
|
555
|
-
},
|
|
556
|
-
forward: function forward() {
|
|
557
|
-
go(1);
|
|
558
|
-
},
|
|
559
|
-
listen: function listen(listener) {
|
|
560
|
-
return listeners.push(listener);
|
|
561
|
-
},
|
|
562
|
-
block: function block(blocker) {
|
|
563
|
-
var unblock = blockers.push(blocker);
|
|
564
|
-
|
|
565
|
-
if (blockers.length === 1) {
|
|
566
|
-
window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
return function () {
|
|
570
|
-
unblock(); // Remove the beforeunload listener so the document may
|
|
571
|
-
// still be salvageable in the pagehide event.
|
|
572
|
-
// See https://html.spec.whatwg.org/#unloading-documents
|
|
573
|
-
|
|
574
|
-
if (!blockers.length) {
|
|
575
|
-
window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
return history;
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Memory history stores the current location in memory. It is designed for use
|
|
584
|
-
* in stateful non-browser environments like tests and React Native.
|
|
585
|
-
*
|
|
586
|
-
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#creatememoryhistory
|
|
587
|
-
*/
|
|
588
|
-
|
|
589
|
-
function createMemoryHistory(options) {
|
|
590
|
-
if (options === void 0) {
|
|
591
|
-
options = {};
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
var _options3 = options,
|
|
595
|
-
_options3$initialEntr = _options3.initialEntries,
|
|
596
|
-
initialEntries = _options3$initialEntr === void 0 ? ['/'] : _options3$initialEntr,
|
|
597
|
-
initialIndex = _options3.initialIndex;
|
|
598
|
-
var entries = initialEntries.map(function (entry) {
|
|
599
|
-
var location = readOnly(_extends$1({
|
|
600
|
-
pathname: '/',
|
|
601
|
-
search: '',
|
|
602
|
-
hash: '',
|
|
603
|
-
state: null,
|
|
604
|
-
key: createKey()
|
|
605
|
-
}, typeof entry === 'string' ? parsePath(entry) : entry));
|
|
606
|
-
process.env.NODE_ENV !== "production" ? warning$1(location.pathname.charAt(0) === '/', "Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: " + JSON.stringify(entry) + ")") : void 0;
|
|
607
|
-
return location;
|
|
608
|
-
});
|
|
609
|
-
var index = clamp(initialIndex == null ? entries.length - 1 : initialIndex, 0, entries.length - 1);
|
|
610
|
-
var action = Action.Pop;
|
|
611
|
-
var location = entries[index];
|
|
612
|
-
var listeners = createEvents();
|
|
613
|
-
var blockers = createEvents();
|
|
614
|
-
|
|
615
|
-
function createHref(to) {
|
|
616
|
-
return typeof to === 'string' ? to : createPath(to);
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
function getNextLocation(to, state) {
|
|
620
|
-
if (state === void 0) {
|
|
621
|
-
state = null;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
return readOnly(_extends$1({
|
|
625
|
-
pathname: location.pathname,
|
|
626
|
-
search: '',
|
|
627
|
-
hash: ''
|
|
628
|
-
}, typeof to === 'string' ? parsePath(to) : to, {
|
|
629
|
-
state: state,
|
|
630
|
-
key: createKey()
|
|
631
|
-
}));
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
function allowTx(action, location, retry) {
|
|
635
|
-
return !blockers.length || (blockers.call({
|
|
636
|
-
action: action,
|
|
637
|
-
location: location,
|
|
638
|
-
retry: retry
|
|
639
|
-
}), false);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
function applyTx(nextAction, nextLocation) {
|
|
643
|
-
action = nextAction;
|
|
644
|
-
location = nextLocation;
|
|
645
|
-
listeners.call({
|
|
646
|
-
action: action,
|
|
647
|
-
location: location
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
function push(to, state) {
|
|
652
|
-
var nextAction = Action.Push;
|
|
653
|
-
var nextLocation = getNextLocation(to, state);
|
|
654
|
-
|
|
655
|
-
function retry() {
|
|
656
|
-
push(to, state);
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
process.env.NODE_ENV !== "production" ? warning$1(location.pathname.charAt(0) === '/', "Relative pathnames are not supported in memory history.push(" + JSON.stringify(to) + ")") : void 0;
|
|
660
|
-
|
|
661
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
662
|
-
index += 1;
|
|
663
|
-
entries.splice(index, entries.length, nextLocation);
|
|
664
|
-
applyTx(nextAction, nextLocation);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
function replace(to, state) {
|
|
669
|
-
var nextAction = Action.Replace;
|
|
670
|
-
var nextLocation = getNextLocation(to, state);
|
|
671
|
-
|
|
672
|
-
function retry() {
|
|
673
|
-
replace(to, state);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
process.env.NODE_ENV !== "production" ? warning$1(location.pathname.charAt(0) === '/', "Relative pathnames are not supported in memory history.replace(" + JSON.stringify(to) + ")") : void 0;
|
|
677
|
-
|
|
678
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
679
|
-
entries[index] = nextLocation;
|
|
680
|
-
applyTx(nextAction, nextLocation);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
function go(delta) {
|
|
685
|
-
var nextIndex = clamp(index + delta, 0, entries.length - 1);
|
|
686
|
-
var nextAction = Action.Pop;
|
|
687
|
-
var nextLocation = entries[nextIndex];
|
|
688
|
-
|
|
689
|
-
function retry() {
|
|
690
|
-
go(delta);
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
694
|
-
index = nextIndex;
|
|
695
|
-
applyTx(nextAction, nextLocation);
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
var history = {
|
|
700
|
-
get index() {
|
|
701
|
-
return index;
|
|
702
|
-
},
|
|
703
|
-
|
|
704
|
-
get action() {
|
|
705
|
-
return action;
|
|
706
|
-
},
|
|
707
|
-
|
|
708
|
-
get location() {
|
|
709
|
-
return location;
|
|
710
|
-
},
|
|
711
|
-
|
|
712
|
-
createHref: createHref,
|
|
713
|
-
push: push,
|
|
714
|
-
replace: replace,
|
|
715
|
-
go: go,
|
|
716
|
-
back: function back() {
|
|
717
|
-
go(-1);
|
|
718
|
-
},
|
|
719
|
-
forward: function forward() {
|
|
720
|
-
go(1);
|
|
721
|
-
},
|
|
722
|
-
listen: function listen(listener) {
|
|
723
|
-
return listeners.push(listener);
|
|
724
|
-
},
|
|
725
|
-
block: function block(blocker) {
|
|
726
|
-
return blockers.push(blocker);
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
return history;
|
|
730
|
-
} ////////////////////////////////////////////////////////////////////////////////
|
|
731
|
-
// UTILS
|
|
732
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
733
|
-
|
|
734
|
-
function clamp(n, lowerBound, upperBound) {
|
|
735
|
-
return Math.min(Math.max(n, lowerBound), upperBound);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
function promptBeforeUnload(event) {
|
|
739
|
-
// Cancel the event.
|
|
740
|
-
event.preventDefault(); // Chrome (and legacy IE) requires returnValue to be set.
|
|
741
|
-
|
|
742
|
-
event.returnValue = '';
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
function createEvents() {
|
|
746
|
-
var handlers = [];
|
|
747
|
-
return {
|
|
748
|
-
get length() {
|
|
749
|
-
return handlers.length;
|
|
750
|
-
},
|
|
751
|
-
|
|
752
|
-
push: function push(fn) {
|
|
753
|
-
handlers.push(fn);
|
|
754
|
-
return function () {
|
|
755
|
-
handlers = handlers.filter(function (handler) {
|
|
756
|
-
return handler !== fn;
|
|
757
|
-
});
|
|
758
|
-
};
|
|
759
|
-
},
|
|
760
|
-
call: function call(arg) {
|
|
761
|
-
handlers.forEach(function (fn) {
|
|
762
|
-
return fn && fn(arg);
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
function createKey() {
|
|
769
|
-
return Math.random().toString(36).substr(2, 8);
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* Creates a string URL path from the given pathname, search, and hash components.
|
|
773
|
-
*
|
|
774
|
-
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createpath
|
|
775
|
-
*/
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
function createPath(_ref) {
|
|
779
|
-
var _ref$pathname = _ref.pathname,
|
|
780
|
-
pathname = _ref$pathname === void 0 ? '/' : _ref$pathname,
|
|
781
|
-
_ref$search = _ref.search,
|
|
782
|
-
search = _ref$search === void 0 ? '' : _ref$search,
|
|
783
|
-
_ref$hash = _ref.hash,
|
|
784
|
-
hash = _ref$hash === void 0 ? '' : _ref$hash;
|
|
785
|
-
if (search && search !== '?') pathname += search.charAt(0) === '?' ? search : '?' + search;
|
|
786
|
-
if (hash && hash !== '#') pathname += hash.charAt(0) === '#' ? hash : '#' + hash;
|
|
787
|
-
return pathname;
|
|
788
|
-
}
|
|
789
|
-
/**
|
|
790
|
-
* Parses a string URL path into its separate pathname, search, and hash components.
|
|
791
|
-
*
|
|
792
|
-
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#parsepath
|
|
793
|
-
*/
|
|
794
|
-
|
|
795
|
-
function parsePath(path) {
|
|
796
|
-
var parsedPath = {};
|
|
797
|
-
|
|
798
|
-
if (path) {
|
|
799
|
-
var hashIndex = path.indexOf('#');
|
|
800
|
-
|
|
801
|
-
if (hashIndex >= 0) {
|
|
802
|
-
parsedPath.hash = path.substr(hashIndex);
|
|
803
|
-
path = path.substr(0, hashIndex);
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
var searchIndex = path.indexOf('?');
|
|
807
|
-
|
|
808
|
-
if (searchIndex >= 0) {
|
|
809
|
-
parsedPath.search = path.substr(searchIndex);
|
|
810
|
-
path = path.substr(0, searchIndex);
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
if (path) {
|
|
814
|
-
parsedPath.pathname = path;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
return parsedPath;
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
var isProduction = process.env.NODE_ENV === 'production';
|
|
822
|
-
var prefix = 'Invariant failed';
|
|
823
|
-
function invariant(condition, message) {
|
|
824
|
-
if (condition) {
|
|
825
|
-
return;
|
|
826
|
-
}
|
|
827
|
-
if (isProduction) {
|
|
828
|
-
throw new Error(prefix);
|
|
829
|
-
}
|
|
830
|
-
var provided = typeof message === 'function' ? message() : message;
|
|
831
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
832
|
-
throw new Error(value);
|
|
833
|
-
}
|
|
11
|
+
import { createMemoryHistory, createBrowserHistory } from 'history';
|
|
12
|
+
export { createBrowserHistory, createHashHistory, createMemoryHistory } from 'history';
|
|
13
|
+
import invariant from 'tiny-invariant';
|
|
14
|
+
export { default as invariant } from 'tiny-invariant';
|
|
834
15
|
|
|
835
16
|
/**
|
|
836
17
|
* This function returns `a` if `b` is deeply equal.
|
|
@@ -841,87 +22,73 @@ function replaceEqualDeep(prev, next) {
|
|
|
841
22
|
if (prev === next) {
|
|
842
23
|
return prev;
|
|
843
24
|
}
|
|
844
|
-
|
|
845
25
|
const array = Array.isArray(prev) && Array.isArray(next);
|
|
846
|
-
|
|
847
26
|
if (array || isPlainObject(prev) && isPlainObject(next)) {
|
|
848
27
|
const aSize = array ? prev.length : Object.keys(prev).length;
|
|
849
28
|
const bItems = array ? next : Object.keys(next);
|
|
850
29
|
const bSize = bItems.length;
|
|
851
30
|
const copy = array ? [] : {};
|
|
852
31
|
let equalItems = 0;
|
|
853
|
-
|
|
854
32
|
for (let i = 0; i < bSize; i++) {
|
|
855
33
|
const key = array ? i : bItems[i];
|
|
856
34
|
copy[key] = replaceEqualDeep(prev[key], next[key]);
|
|
857
|
-
|
|
858
35
|
if (copy[key] === prev[key]) {
|
|
859
36
|
equalItems++;
|
|
860
37
|
}
|
|
861
38
|
}
|
|
862
|
-
|
|
863
39
|
return aSize === bSize && equalItems === aSize ? prev : copy;
|
|
864
40
|
}
|
|
865
|
-
|
|
866
41
|
return next;
|
|
867
|
-
}
|
|
42
|
+
}
|
|
868
43
|
|
|
44
|
+
// Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
869
45
|
function isPlainObject(o) {
|
|
870
46
|
if (!hasObjectPrototype(o)) {
|
|
871
47
|
return false;
|
|
872
|
-
}
|
|
873
|
-
|
|
48
|
+
}
|
|
874
49
|
|
|
50
|
+
// If has modified constructor
|
|
875
51
|
const ctor = o.constructor;
|
|
876
|
-
|
|
877
52
|
if (typeof ctor === 'undefined') {
|
|
878
53
|
return true;
|
|
879
|
-
}
|
|
880
|
-
|
|
54
|
+
}
|
|
881
55
|
|
|
56
|
+
// If has modified prototype
|
|
882
57
|
const prot = ctor.prototype;
|
|
883
|
-
|
|
884
58
|
if (!hasObjectPrototype(prot)) {
|
|
885
59
|
return false;
|
|
886
|
-
}
|
|
887
|
-
|
|
60
|
+
}
|
|
888
61
|
|
|
62
|
+
// If constructor does not have an Object-specific method
|
|
889
63
|
if (!prot.hasOwnProperty('isPrototypeOf')) {
|
|
890
64
|
return false;
|
|
891
|
-
}
|
|
892
|
-
|
|
65
|
+
}
|
|
893
66
|
|
|
67
|
+
// Most likely a plain Object
|
|
894
68
|
return true;
|
|
895
69
|
}
|
|
896
|
-
|
|
897
70
|
function hasObjectPrototype(o) {
|
|
898
71
|
return Object.prototype.toString.call(o) === '[object Object]';
|
|
899
72
|
}
|
|
900
|
-
|
|
901
73
|
function last(arr) {
|
|
902
74
|
return arr[arr.length - 1];
|
|
903
75
|
}
|
|
904
76
|
function warning(cond, message) {
|
|
905
77
|
if (cond) {
|
|
906
78
|
if (typeof console !== 'undefined') console.warn(message);
|
|
907
|
-
|
|
908
79
|
try {
|
|
909
80
|
throw new Error(message);
|
|
910
81
|
} catch (_unused) {}
|
|
911
82
|
}
|
|
912
|
-
|
|
913
83
|
return true;
|
|
914
84
|
}
|
|
915
|
-
|
|
916
85
|
function isFunction(d) {
|
|
917
86
|
return typeof d === 'function';
|
|
918
87
|
}
|
|
919
|
-
|
|
920
88
|
function functionalUpdate(updater, previous) {
|
|
921
89
|
if (isFunction(updater)) {
|
|
922
90
|
return updater(previous);
|
|
923
91
|
}
|
|
924
|
-
|
|
925
92
|
return updater;
|
|
926
93
|
}
|
|
927
94
|
function pick(parent, keys) {
|
|
@@ -963,12 +130,10 @@ function resolvePath(basepath, base, to) {
|
|
|
963
130
|
} else ;
|
|
964
131
|
} else if (toSegment.value === '..') {
|
|
965
132
|
var _last;
|
|
966
|
-
|
|
967
133
|
// Extra trailing slash? pop it off
|
|
968
134
|
if (baseSegments.length > 1 && ((_last = last(baseSegments)) == null ? void 0 : _last.value) === '/') {
|
|
969
135
|
baseSegments.pop();
|
|
970
136
|
}
|
|
971
|
-
|
|
972
137
|
baseSegments.pop();
|
|
973
138
|
} else if (toSegment.value === '.') {
|
|
974
139
|
return;
|
|
@@ -983,10 +148,8 @@ function parsePathname(pathname) {
|
|
|
983
148
|
if (!pathname) {
|
|
984
149
|
return [];
|
|
985
150
|
}
|
|
986
|
-
|
|
987
151
|
pathname = cleanPath(pathname);
|
|
988
152
|
const segments = [];
|
|
989
|
-
|
|
990
153
|
if (pathname.slice(0, 1) === '/') {
|
|
991
154
|
pathname = pathname.substring(1);
|
|
992
155
|
segments.push({
|
|
@@ -994,12 +157,11 @@ function parsePathname(pathname) {
|
|
|
994
157
|
value: '/'
|
|
995
158
|
});
|
|
996
159
|
}
|
|
997
|
-
|
|
998
160
|
if (!pathname) {
|
|
999
161
|
return segments;
|
|
1000
|
-
}
|
|
1001
|
-
|
|
162
|
+
}
|
|
1002
163
|
|
|
164
|
+
// Remove empty segments and '.' segments
|
|
1003
165
|
const split = pathname.split('/').filter(Boolean);
|
|
1004
166
|
segments.push(...split.map(part => {
|
|
1005
167
|
if (part.startsWith('*')) {
|
|
@@ -1008,20 +170,17 @@ function parsePathname(pathname) {
|
|
|
1008
170
|
value: part
|
|
1009
171
|
};
|
|
1010
172
|
}
|
|
1011
|
-
|
|
1012
|
-
if (part.charAt(0) === ':') {
|
|
173
|
+
if (part.charAt(0) === '$') {
|
|
1013
174
|
return {
|
|
1014
175
|
type: 'param',
|
|
1015
176
|
value: part
|
|
1016
177
|
};
|
|
1017
178
|
}
|
|
1018
|
-
|
|
1019
179
|
return {
|
|
1020
180
|
type: 'pathname',
|
|
1021
181
|
value: part
|
|
1022
182
|
};
|
|
1023
183
|
}));
|
|
1024
|
-
|
|
1025
184
|
if (pathname.slice(-1) === '/') {
|
|
1026
185
|
pathname = pathname.substring(1);
|
|
1027
186
|
segments.push({
|
|
@@ -1029,7 +188,6 @@ function parsePathname(pathname) {
|
|
|
1029
188
|
value: '/'
|
|
1030
189
|
});
|
|
1031
190
|
}
|
|
1032
|
-
|
|
1033
191
|
return segments;
|
|
1034
192
|
}
|
|
1035
193
|
function interpolatePath(path, params, leaveWildcard) {
|
|
@@ -1038,54 +196,45 @@ function interpolatePath(path, params, leaveWildcard) {
|
|
|
1038
196
|
if (segment.value === '*' && !leaveWildcard) {
|
|
1039
197
|
return '';
|
|
1040
198
|
}
|
|
1041
|
-
|
|
1042
199
|
if (segment.type === 'param') {
|
|
1043
200
|
var _segment$value$substr;
|
|
1044
|
-
|
|
1045
201
|
return (_segment$value$substr = params[segment.value.substring(1)]) != null ? _segment$value$substr : '';
|
|
1046
202
|
}
|
|
1047
|
-
|
|
1048
203
|
return segment.value;
|
|
1049
204
|
}));
|
|
1050
205
|
}
|
|
1051
206
|
function matchPathname(currentPathname, matchLocation) {
|
|
1052
|
-
const pathParams = matchByPath(currentPathname, matchLocation);
|
|
207
|
+
const pathParams = matchByPath(currentPathname, matchLocation);
|
|
208
|
+
// const searchMatched = matchBySearch(currentLocation.search, matchLocation)
|
|
1053
209
|
|
|
1054
210
|
if (matchLocation.to && !pathParams) {
|
|
1055
211
|
return;
|
|
1056
212
|
}
|
|
1057
|
-
|
|
1058
213
|
return pathParams != null ? pathParams : {};
|
|
1059
214
|
}
|
|
1060
215
|
function matchByPath(from, matchLocation) {
|
|
1061
216
|
var _matchLocation$to;
|
|
1062
|
-
|
|
1063
217
|
const baseSegments = parsePathname(from);
|
|
1064
218
|
const routeSegments = parsePathname("" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*'));
|
|
1065
219
|
const params = {};
|
|
1066
|
-
|
|
1067
220
|
let isMatch = (() => {
|
|
1068
221
|
for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
|
|
1069
222
|
const baseSegment = baseSegments[i];
|
|
1070
223
|
const routeSegment = routeSegments[i];
|
|
1071
224
|
const isLastRouteSegment = i === routeSegments.length - 1;
|
|
1072
225
|
const isLastBaseSegment = i === baseSegments.length - 1;
|
|
1073
|
-
|
|
1074
226
|
if (routeSegment) {
|
|
1075
227
|
if (routeSegment.type === 'wildcard') {
|
|
1076
228
|
if (baseSegment != null && baseSegment.value) {
|
|
1077
229
|
params['*'] = joinPaths(baseSegments.slice(i).map(d => d.value));
|
|
1078
230
|
return true;
|
|
1079
231
|
}
|
|
1080
|
-
|
|
1081
232
|
return false;
|
|
1082
233
|
}
|
|
1083
|
-
|
|
1084
234
|
if (routeSegment.type === 'pathname') {
|
|
1085
235
|
if (routeSegment.value === '/' && !(baseSegment != null && baseSegment.value)) {
|
|
1086
236
|
return true;
|
|
1087
237
|
}
|
|
1088
|
-
|
|
1089
238
|
if (baseSegment) {
|
|
1090
239
|
if (matchLocation.caseSensitive) {
|
|
1091
240
|
if (routeSegment.value !== baseSegment.value) {
|
|
@@ -1096,41 +245,36 @@ function matchByPath(from, matchLocation) {
|
|
|
1096
245
|
}
|
|
1097
246
|
}
|
|
1098
247
|
}
|
|
1099
|
-
|
|
1100
248
|
if (!baseSegment) {
|
|
1101
249
|
return false;
|
|
1102
250
|
}
|
|
1103
|
-
|
|
1104
251
|
if (routeSegment.type === 'param') {
|
|
1105
252
|
if ((baseSegment == null ? void 0 : baseSegment.value) === '/') {
|
|
1106
253
|
return false;
|
|
1107
254
|
}
|
|
1108
|
-
|
|
1109
|
-
if (!baseSegment.value.startsWith(':')) {
|
|
255
|
+
if (baseSegment.value.charAt(0) !== '$') {
|
|
1110
256
|
params[routeSegment.value.substring(1)] = baseSegment.value;
|
|
1111
257
|
}
|
|
1112
258
|
}
|
|
1113
259
|
}
|
|
1114
|
-
|
|
1115
260
|
if (isLastRouteSegment && !isLastBaseSegment) {
|
|
1116
261
|
return !!matchLocation.fuzzy;
|
|
1117
262
|
}
|
|
1118
263
|
}
|
|
1119
|
-
|
|
1120
264
|
return true;
|
|
1121
265
|
})();
|
|
1122
|
-
|
|
1123
266
|
return isMatch ? params : undefined;
|
|
1124
267
|
}
|
|
1125
268
|
|
|
1126
269
|
// @ts-nocheck
|
|
270
|
+
|
|
1127
271
|
// qss has been slightly modified and inlined here for our use cases (and compression's sake). We've included it as a hard dependency for MIT license attribution.
|
|
272
|
+
|
|
1128
273
|
function encode(obj, pfx) {
|
|
1129
274
|
var k,
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
275
|
+
i,
|
|
276
|
+
tmp,
|
|
277
|
+
str = '';
|
|
1134
278
|
for (k in obj) {
|
|
1135
279
|
if ((tmp = obj[k]) !== void 0) {
|
|
1136
280
|
if (Array.isArray(tmp)) {
|
|
@@ -1144,10 +288,8 @@ function encode(obj, pfx) {
|
|
|
1144
288
|
}
|
|
1145
289
|
}
|
|
1146
290
|
}
|
|
1147
|
-
|
|
1148
291
|
return (pfx || '') + str;
|
|
1149
292
|
}
|
|
1150
|
-
|
|
1151
293
|
function toValue(mix) {
|
|
1152
294
|
if (!mix) return '';
|
|
1153
295
|
var str = decodeURIComponent(mix);
|
|
@@ -1156,24 +298,20 @@ function toValue(mix) {
|
|
|
1156
298
|
if (str.charAt(0) === '0') return str;
|
|
1157
299
|
return +str * 0 === 0 ? +str : str;
|
|
1158
300
|
}
|
|
1159
|
-
|
|
1160
301
|
function decode(str) {
|
|
1161
302
|
var tmp,
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
303
|
+
k,
|
|
304
|
+
out = {},
|
|
305
|
+
arr = str.split('&');
|
|
1166
306
|
while (tmp = arr.shift()) {
|
|
1167
307
|
tmp = tmp.split('=');
|
|
1168
308
|
k = tmp.shift();
|
|
1169
|
-
|
|
1170
309
|
if (out[k] !== void 0) {
|
|
1171
310
|
out[k] = [].concat(out[k], toValue(tmp.shift()));
|
|
1172
311
|
} else {
|
|
1173
312
|
out[k] = toValue(tmp.shift());
|
|
1174
313
|
}
|
|
1175
314
|
}
|
|
1176
|
-
|
|
1177
315
|
return out;
|
|
1178
316
|
}
|
|
1179
317
|
|
|
@@ -1181,14 +319,12 @@ function _extends() {
|
|
|
1181
319
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
1182
320
|
for (var i = 1; i < arguments.length; i++) {
|
|
1183
321
|
var source = arguments[i];
|
|
1184
|
-
|
|
1185
322
|
for (var key in source) {
|
|
1186
323
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1187
324
|
target[key] = source[key];
|
|
1188
325
|
}
|
|
1189
326
|
}
|
|
1190
327
|
}
|
|
1191
|
-
|
|
1192
328
|
return target;
|
|
1193
329
|
};
|
|
1194
330
|
return _extends.apply(this, arguments);
|
|
@@ -1201,23 +337,18 @@ function createRoute(routeConfig, options, parent, router) {
|
|
|
1201
337
|
path: routePath,
|
|
1202
338
|
fullPath
|
|
1203
339
|
} = routeConfig;
|
|
1204
|
-
|
|
1205
340
|
const action = router.state.actions[id] || (() => {
|
|
1206
341
|
router.state.actions[id] = {
|
|
1207
342
|
submissions: [],
|
|
1208
343
|
submit: async (submission, actionOpts) => {
|
|
1209
344
|
var _actionOpts$invalidat;
|
|
1210
|
-
|
|
1211
345
|
if (!route) {
|
|
1212
346
|
return;
|
|
1213
347
|
}
|
|
1214
|
-
|
|
1215
348
|
const invalidate = (_actionOpts$invalidat = actionOpts == null ? void 0 : actionOpts.invalidate) != null ? _actionOpts$invalidat : true;
|
|
1216
|
-
|
|
1217
349
|
if (!(actionOpts != null && actionOpts.multi)) {
|
|
1218
350
|
action.submissions = action.submissions.filter(d => d.isMulti);
|
|
1219
351
|
}
|
|
1220
|
-
|
|
1221
352
|
const actionState = {
|
|
1222
353
|
submittedAt: Date.now(),
|
|
1223
354
|
status: 'pending',
|
|
@@ -1228,11 +359,9 @@ function createRoute(routeConfig, options, parent, router) {
|
|
|
1228
359
|
action.latest = actionState;
|
|
1229
360
|
action.submissions.push(actionState);
|
|
1230
361
|
router.notify();
|
|
1231
|
-
|
|
1232
362
|
try {
|
|
1233
363
|
const res = await (route.options.action == null ? void 0 : route.options.action(submission));
|
|
1234
364
|
actionState.data = res;
|
|
1235
|
-
|
|
1236
365
|
if (invalidate) {
|
|
1237
366
|
router.invalidateRoute({
|
|
1238
367
|
to: '.',
|
|
@@ -1240,10 +369,10 @@ function createRoute(routeConfig, options, parent, router) {
|
|
|
1240
369
|
});
|
|
1241
370
|
await router.reload();
|
|
1242
371
|
}
|
|
1243
|
-
|
|
1244
372
|
actionState.status = 'success';
|
|
1245
373
|
return res;
|
|
1246
374
|
} catch (err) {
|
|
375
|
+
console.log('tanner');
|
|
1247
376
|
console.error(err);
|
|
1248
377
|
actionState.error = err;
|
|
1249
378
|
actionState.status = 'error';
|
|
@@ -1254,7 +383,6 @@ function createRoute(routeConfig, options, parent, router) {
|
|
|
1254
383
|
};
|
|
1255
384
|
return router.state.actions[id];
|
|
1256
385
|
})();
|
|
1257
|
-
|
|
1258
386
|
const loader = router.state.loaders[id] || (() => {
|
|
1259
387
|
router.state.loaders[id] = {
|
|
1260
388
|
pending: [],
|
|
@@ -1262,33 +390,32 @@ function createRoute(routeConfig, options, parent, router) {
|
|
|
1262
390
|
if (!route) {
|
|
1263
391
|
return;
|
|
1264
392
|
}
|
|
1265
|
-
|
|
1266
393
|
const loaderState = {
|
|
1267
394
|
loadedAt: Date.now(),
|
|
1268
395
|
loaderContext
|
|
1269
396
|
};
|
|
1270
397
|
loader.current = loaderState;
|
|
1271
398
|
loader.latest = loaderState;
|
|
1272
|
-
loader.pending.push(loaderState);
|
|
399
|
+
loader.pending.push(loaderState);
|
|
400
|
+
|
|
401
|
+
// router.state = {
|
|
1273
402
|
// ...router.state,
|
|
1274
403
|
// currentAction: loaderState,
|
|
1275
404
|
// latestAction: loaderState,
|
|
1276
405
|
// }
|
|
1277
406
|
|
|
1278
407
|
router.notify();
|
|
1279
|
-
|
|
1280
408
|
try {
|
|
1281
409
|
return await (route.options.loader == null ? void 0 : route.options.loader(loaderContext));
|
|
1282
410
|
} finally {
|
|
1283
|
-
loader.pending = loader.pending.filter(d => d !== loaderState);
|
|
1284
|
-
|
|
411
|
+
loader.pending = loader.pending.filter(d => d !== loaderState);
|
|
412
|
+
// router.removeActionQueue.push({ loader, loaderState })
|
|
1285
413
|
router.notify();
|
|
1286
414
|
}
|
|
1287
415
|
}
|
|
1288
416
|
};
|
|
1289
417
|
return router.state.loaders[id];
|
|
1290
418
|
})();
|
|
1291
|
-
|
|
1292
419
|
let route = {
|
|
1293
420
|
routeInfo: undefined,
|
|
1294
421
|
routeId: id,
|
|
@@ -1329,37 +456,31 @@ const createRouteConfig = function createRouteConfig(options, children, isRoot,
|
|
|
1329
456
|
if (options === void 0) {
|
|
1330
457
|
options = {};
|
|
1331
458
|
}
|
|
1332
|
-
|
|
1333
459
|
if (isRoot === void 0) {
|
|
1334
460
|
isRoot = true;
|
|
1335
461
|
}
|
|
1336
|
-
|
|
1337
462
|
if (isRoot) {
|
|
1338
463
|
options.path = rootRouteId;
|
|
1339
|
-
}
|
|
1340
|
-
|
|
464
|
+
}
|
|
1341
465
|
|
|
466
|
+
// Strip the root from parentIds
|
|
1342
467
|
if (parentId === rootRouteId) {
|
|
1343
468
|
parentId = '';
|
|
1344
469
|
}
|
|
470
|
+
let path = isRoot ? rootRouteId : options.path;
|
|
1345
471
|
|
|
1346
|
-
|
|
1347
|
-
|
|
472
|
+
// If the path is anything other than an index path, trim it up
|
|
1348
473
|
if (path && path !== '/') {
|
|
1349
474
|
path = trimPath(path);
|
|
1350
475
|
}
|
|
1351
|
-
|
|
1352
476
|
const routeId = path || options.id;
|
|
1353
477
|
let id = joinPaths([parentId, routeId]);
|
|
1354
|
-
|
|
1355
478
|
if (path === rootRouteId) {
|
|
1356
479
|
path = '/';
|
|
1357
480
|
}
|
|
1358
|
-
|
|
1359
481
|
if (id !== rootRouteId) {
|
|
1360
482
|
id = joinPaths(['/', id]);
|
|
1361
483
|
}
|
|
1362
|
-
|
|
1363
484
|
const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parentPath, path]));
|
|
1364
485
|
return {
|
|
1365
486
|
id: id,
|
|
@@ -1368,9 +489,11 @@ const createRouteConfig = function createRouteConfig(options, children, isRoot,
|
|
|
1368
489
|
fullPath: fullPath,
|
|
1369
490
|
options: options,
|
|
1370
491
|
children,
|
|
1371
|
-
createChildren: cb => createRouteConfig(options, cb(childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath)), false, parentId, parentPath),
|
|
1372
492
|
addChildren: children => createRouteConfig(options, children, false, parentId, parentPath),
|
|
1373
|
-
createRoute: childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath)
|
|
493
|
+
createRoute: childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath),
|
|
494
|
+
generate: () => {
|
|
495
|
+
invariant(false, "routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. ");
|
|
496
|
+
}
|
|
1374
497
|
};
|
|
1375
498
|
};
|
|
1376
499
|
|
|
@@ -1398,31 +521,26 @@ function createRouteMatch(router, route, opts) {
|
|
|
1398
521
|
resolve: () => {},
|
|
1399
522
|
notify: () => {
|
|
1400
523
|
routeMatch.__.resolve();
|
|
1401
|
-
|
|
1402
524
|
routeMatch.router.notify();
|
|
1403
525
|
},
|
|
1404
526
|
validate: () => {
|
|
1405
527
|
var _routeMatch$parentMat, _routeMatch$parentMat2;
|
|
1406
|
-
|
|
1407
528
|
// Validate the search params and stabilize them
|
|
1408
529
|
const parentSearch = (_routeMatch$parentMat = (_routeMatch$parentMat2 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat2.search) != null ? _routeMatch$parentMat : router.location.search;
|
|
1409
|
-
|
|
1410
530
|
try {
|
|
1411
531
|
var _validator;
|
|
1412
|
-
|
|
1413
532
|
const prevSearch = routeMatch.routeSearch;
|
|
1414
533
|
const validator = typeof routeMatch.options.validateSearch === 'object' ? routeMatch.options.validateSearch.parse : routeMatch.options.validateSearch;
|
|
1415
|
-
let nextSearch = replaceEqualDeep(prevSearch, (_validator = validator == null ? void 0 : validator(parentSearch)) != null ? _validator : {});
|
|
534
|
+
let nextSearch = replaceEqualDeep(prevSearch, (_validator = validator == null ? void 0 : validator(parentSearch)) != null ? _validator : {});
|
|
1416
535
|
|
|
536
|
+
// Invalidate route matches when search param stability changes
|
|
1417
537
|
if (prevSearch !== nextSearch) {
|
|
1418
538
|
routeMatch.isInvalid = true;
|
|
1419
539
|
}
|
|
1420
|
-
|
|
1421
540
|
routeMatch.routeSearch = nextSearch;
|
|
1422
541
|
routeMatch.search = replaceEqualDeep(parentSearch, _extends({}, parentSearch, nextSearch));
|
|
1423
542
|
componentTypes.map(async type => {
|
|
1424
543
|
const component = routeMatch.options[type];
|
|
1425
|
-
|
|
1426
544
|
if (typeof routeMatch.__[type] !== 'function') {
|
|
1427
545
|
routeMatch.__[type] = component;
|
|
1428
546
|
}
|
|
@@ -1434,15 +552,14 @@ function createRouteMatch(router, route, opts) {
|
|
|
1434
552
|
});
|
|
1435
553
|
error.code = 'INVALID_SEARCH_PARAMS';
|
|
1436
554
|
routeMatch.status = 'error';
|
|
1437
|
-
routeMatch.error = error;
|
|
1438
|
-
|
|
555
|
+
routeMatch.error = error;
|
|
556
|
+
// Do not proceed with loading the route
|
|
1439
557
|
return;
|
|
1440
558
|
}
|
|
1441
559
|
}
|
|
1442
560
|
},
|
|
1443
561
|
cancel: () => {
|
|
1444
562
|
var _routeMatch$__$abortC;
|
|
1445
|
-
|
|
1446
563
|
(_routeMatch$__$abortC = routeMatch.__.abortController) == null ? void 0 : _routeMatch$__$abortC.abort();
|
|
1447
564
|
},
|
|
1448
565
|
invalidate: () => {
|
|
@@ -1451,27 +568,26 @@ function createRouteMatch(router, route, opts) {
|
|
|
1451
568
|
hasLoaders: () => {
|
|
1452
569
|
return !!(route.options.loader || componentTypes.some(d => {
|
|
1453
570
|
var _route$options$d;
|
|
1454
|
-
|
|
1455
571
|
return (_route$options$d = route.options[d]) == null ? void 0 : _route$options$d.preload;
|
|
1456
572
|
}));
|
|
1457
573
|
},
|
|
1458
574
|
load: async loaderOpts => {
|
|
1459
575
|
const now = Date.now();
|
|
1460
|
-
const minMaxAge = loaderOpts != null && loaderOpts.preload ? Math.max(loaderOpts == null ? void 0 : loaderOpts.maxAge, loaderOpts == null ? void 0 : loaderOpts.gcMaxAge) : 0;
|
|
576
|
+
const minMaxAge = loaderOpts != null && loaderOpts.preload ? Math.max(loaderOpts == null ? void 0 : loaderOpts.maxAge, loaderOpts == null ? void 0 : loaderOpts.gcMaxAge) : 0;
|
|
1461
577
|
|
|
578
|
+
// If this is a preload, add it to the preload cache
|
|
1462
579
|
if (loaderOpts != null && loaderOpts.preload && minMaxAge > 0) {
|
|
1463
580
|
// If the match is currently active, don't preload it
|
|
1464
581
|
if (router.state.matches.find(d => d.matchId === routeMatch.matchId)) {
|
|
1465
582
|
return;
|
|
1466
583
|
}
|
|
1467
|
-
|
|
1468
584
|
router.matchCache[routeMatch.matchId] = {
|
|
1469
585
|
gc: now + loaderOpts.gcMaxAge,
|
|
1470
586
|
match: routeMatch
|
|
1471
587
|
};
|
|
1472
|
-
}
|
|
1473
|
-
|
|
588
|
+
}
|
|
1474
589
|
|
|
590
|
+
// If the match is invalid, errored or idle, trigger it to load
|
|
1475
591
|
if (routeMatch.status === 'success' && routeMatch.getIsInvalid() || routeMatch.status === 'error' || routeMatch.status === 'idle') {
|
|
1476
592
|
const maxAge = loaderOpts != null && loaderOpts.preload ? loaderOpts == null ? void 0 : loaderOpts.maxAge : undefined;
|
|
1477
593
|
await routeMatch.fetch({
|
|
@@ -1482,53 +598,47 @@ function createRouteMatch(router, route, opts) {
|
|
|
1482
598
|
fetch: async opts => {
|
|
1483
599
|
const loadId = '' + Date.now() + Math.random();
|
|
1484
600
|
routeMatch.__.latestId = loadId;
|
|
1485
|
-
|
|
1486
601
|
const checkLatest = async () => {
|
|
1487
602
|
if (loadId !== routeMatch.__.latestId) {
|
|
1488
603
|
// warning(true, 'Data loader is out of date!')
|
|
1489
604
|
return new Promise(() => {});
|
|
1490
605
|
}
|
|
1491
|
-
};
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
// If the match was in an error state, set it
|
|
1492
609
|
// to a loading state again. Otherwise, keep it
|
|
1493
610
|
// as loading or resolved
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
611
|
if (routeMatch.status === 'idle') {
|
|
1497
612
|
routeMatch.status = 'loading';
|
|
1498
|
-
}
|
|
1499
|
-
|
|
613
|
+
}
|
|
1500
614
|
|
|
615
|
+
// We started loading the route, so it's no longer invalid
|
|
1501
616
|
routeMatch.isInvalid = false;
|
|
1502
617
|
routeMatch.__.loadPromise = new Promise(async resolve => {
|
|
1503
618
|
// We are now fetching, even if it's in the background of a
|
|
1504
619
|
// resolved state
|
|
1505
620
|
routeMatch.isFetching = true;
|
|
1506
621
|
routeMatch.__.resolve = resolve;
|
|
1507
|
-
|
|
1508
622
|
routeMatch.__.componentsPromise = (async () => {
|
|
1509
623
|
// then run all component and data loaders in parallel
|
|
1510
624
|
// For each component type, potentially load it asynchronously
|
|
625
|
+
|
|
1511
626
|
await Promise.all(componentTypes.map(async type => {
|
|
1512
627
|
var _routeMatch$__$type;
|
|
1513
|
-
|
|
1514
628
|
const component = routeMatch.options[type];
|
|
1515
|
-
|
|
1516
629
|
if ((_routeMatch$__$type = routeMatch.__[type]) != null && _routeMatch$__$type.preload) {
|
|
1517
630
|
routeMatch.__[type] = await router.options.loadComponent(component);
|
|
1518
631
|
}
|
|
1519
632
|
}));
|
|
1520
633
|
})();
|
|
1521
|
-
|
|
1522
634
|
routeMatch.__.dataPromise = Promise.resolve().then(async () => {
|
|
1523
635
|
try {
|
|
1524
636
|
var _ref, _ref2, _opts$maxAge;
|
|
1525
|
-
|
|
1526
637
|
if (routeMatch.options.loader) {
|
|
1527
638
|
const data = await router.loadMatchData(routeMatch);
|
|
1528
639
|
await checkLatest();
|
|
1529
640
|
routeMatch.routeLoaderData = replaceEqualDeep(routeMatch.routeLoaderData, data);
|
|
1530
641
|
}
|
|
1531
|
-
|
|
1532
642
|
routeMatch.error = undefined;
|
|
1533
643
|
routeMatch.status = 'success';
|
|
1534
644
|
routeMatch.updatedAt = Date.now();
|
|
@@ -1536,26 +646,21 @@ function createRouteMatch(router, route, opts) {
|
|
|
1536
646
|
return routeMatch.routeLoaderData;
|
|
1537
647
|
} catch (err) {
|
|
1538
648
|
await checkLatest();
|
|
1539
|
-
|
|
1540
649
|
if (process.env.NODE_ENV !== 'production') {
|
|
1541
650
|
console.error(err);
|
|
1542
651
|
}
|
|
1543
|
-
|
|
1544
652
|
routeMatch.error = err;
|
|
1545
653
|
routeMatch.status = 'error';
|
|
1546
654
|
routeMatch.updatedAt = Date.now();
|
|
1547
655
|
throw err;
|
|
1548
656
|
}
|
|
1549
657
|
});
|
|
1550
|
-
|
|
1551
658
|
const after = async () => {
|
|
1552
659
|
await checkLatest();
|
|
1553
660
|
routeMatch.isFetching = false;
|
|
1554
661
|
delete routeMatch.__.loadPromise;
|
|
1555
|
-
|
|
1556
662
|
routeMatch.__.notify();
|
|
1557
663
|
};
|
|
1558
|
-
|
|
1559
664
|
try {
|
|
1560
665
|
await Promise.all([routeMatch.__.componentsPromise, routeMatch.__.dataPromise.catch(() => {})]);
|
|
1561
666
|
after();
|
|
@@ -1567,11 +672,9 @@ function createRouteMatch(router, route, opts) {
|
|
|
1567
672
|
await checkLatest();
|
|
1568
673
|
}
|
|
1569
674
|
});
|
|
1570
|
-
|
|
1571
675
|
if (!routeMatch.hasLoaders()) {
|
|
1572
676
|
routeMatch.status = 'success';
|
|
1573
677
|
}
|
|
1574
|
-
|
|
1575
678
|
return routeMatch;
|
|
1576
679
|
}
|
|
1577
680
|
|
|
@@ -1582,42 +685,39 @@ function parseSearchWith(parser) {
|
|
|
1582
685
|
if (searchStr.substring(0, 1) === '?') {
|
|
1583
686
|
searchStr = searchStr.substring(1);
|
|
1584
687
|
}
|
|
688
|
+
let query = decode(searchStr);
|
|
1585
689
|
|
|
1586
|
-
|
|
1587
|
-
|
|
690
|
+
// Try to parse any query params that might be json
|
|
1588
691
|
for (let key in query) {
|
|
1589
692
|
const value = query[key];
|
|
1590
|
-
|
|
1591
693
|
if (typeof value === 'string') {
|
|
1592
694
|
try {
|
|
1593
695
|
query[key] = parser(value);
|
|
1594
|
-
} catch (err) {
|
|
696
|
+
} catch (err) {
|
|
697
|
+
//
|
|
1595
698
|
}
|
|
1596
699
|
}
|
|
1597
700
|
}
|
|
1598
|
-
|
|
1599
701
|
return query;
|
|
1600
702
|
};
|
|
1601
703
|
}
|
|
1602
704
|
function stringifySearchWith(stringify) {
|
|
1603
705
|
return search => {
|
|
1604
706
|
search = _extends({}, search);
|
|
1605
|
-
|
|
1606
707
|
if (search) {
|
|
1607
708
|
Object.keys(search).forEach(key => {
|
|
1608
709
|
const val = search[key];
|
|
1609
|
-
|
|
1610
710
|
if (typeof val === 'undefined' || val === undefined) {
|
|
1611
711
|
delete search[key];
|
|
1612
712
|
} else if (val && typeof val === 'object' && val !== null) {
|
|
1613
713
|
try {
|
|
1614
714
|
search[key] = stringify(val);
|
|
1615
|
-
} catch (err) {
|
|
715
|
+
} catch (err) {
|
|
716
|
+
// silent
|
|
1616
717
|
}
|
|
1617
718
|
}
|
|
1618
719
|
});
|
|
1619
720
|
}
|
|
1620
|
-
|
|
1621
721
|
const searchStr = encode(search).toString();
|
|
1622
722
|
return searchStr ? "?" + searchStr : '';
|
|
1623
723
|
};
|
|
@@ -1625,10 +725,10 @@ function stringifySearchWith(stringify) {
|
|
|
1625
725
|
|
|
1626
726
|
var _window$document;
|
|
1627
727
|
// Detect if we're in the DOM
|
|
1628
|
-
const isServer = typeof window === 'undefined' || !((_window$document = window.document) != null && _window$document.createElement);
|
|
728
|
+
const isServer = typeof window === 'undefined' || !((_window$document = window.document) != null && _window$document.createElement);
|
|
1629
729
|
|
|
730
|
+
// This is the default history object if none is defined
|
|
1630
731
|
const createDefaultHistory = () => isServer ? createMemoryHistory() : createBrowserHistory();
|
|
1631
|
-
|
|
1632
732
|
function getInitialRouterState() {
|
|
1633
733
|
return {
|
|
1634
734
|
status: 'idle',
|
|
@@ -1641,22 +741,19 @@ function getInitialRouterState() {
|
|
|
1641
741
|
isPreloading: false
|
|
1642
742
|
};
|
|
1643
743
|
}
|
|
1644
|
-
|
|
1645
744
|
function createRouter(userOptions) {
|
|
1646
745
|
var _userOptions$stringif, _userOptions$parseSea;
|
|
1647
|
-
|
|
1648
746
|
const history = (userOptions == null ? void 0 : userOptions.history) || createDefaultHistory();
|
|
1649
|
-
|
|
1650
747
|
const originalOptions = _extends({
|
|
1651
748
|
defaultLoaderGcMaxAge: 5 * 60 * 1000,
|
|
1652
749
|
defaultLoaderMaxAge: 0,
|
|
1653
750
|
defaultPreloadMaxAge: 2000,
|
|
1654
|
-
defaultPreloadDelay: 50
|
|
751
|
+
defaultPreloadDelay: 50,
|
|
752
|
+
context: undefined
|
|
1655
753
|
}, userOptions, {
|
|
1656
754
|
stringifySearch: (_userOptions$stringif = userOptions == null ? void 0 : userOptions.stringifySearch) != null ? _userOptions$stringif : defaultStringifySearch,
|
|
1657
755
|
parseSearch: (_userOptions$parseSea = userOptions == null ? void 0 : userOptions.parseSearch) != null ? _userOptions$parseSea : defaultParseSearch
|
|
1658
756
|
});
|
|
1659
|
-
|
|
1660
757
|
let router = {
|
|
1661
758
|
types: undefined,
|
|
1662
759
|
// public api
|
|
@@ -1664,13 +761,11 @@ function createRouter(userOptions) {
|
|
|
1664
761
|
options: originalOptions,
|
|
1665
762
|
listeners: [],
|
|
1666
763
|
// Resolved after construction
|
|
1667
|
-
context: {},
|
|
1668
764
|
basepath: '',
|
|
1669
765
|
routeTree: undefined,
|
|
1670
766
|
routesById: {},
|
|
1671
767
|
location: undefined,
|
|
1672
768
|
//
|
|
1673
|
-
navigationPromise: Promise.resolve(),
|
|
1674
769
|
resolveNavigation: () => {},
|
|
1675
770
|
matchCache: {},
|
|
1676
771
|
state: getInitialRouterState(),
|
|
@@ -1691,29 +786,37 @@ function createRouter(userOptions) {
|
|
|
1691
786
|
notify: () => {
|
|
1692
787
|
const isFetching = router.state.status === 'loading' || router.state.matches.some(d => d.isFetching);
|
|
1693
788
|
const isPreloading = Object.values(router.matchCache).some(d => d.match.isFetching && !router.state.matches.find(dd => dd.matchId === d.match.matchId));
|
|
1694
|
-
|
|
1695
789
|
if (router.state.isFetching !== isFetching || router.state.isPreloading !== isPreloading) {
|
|
1696
790
|
router.state = _extends({}, router.state, {
|
|
1697
791
|
isFetching,
|
|
1698
792
|
isPreloading
|
|
1699
793
|
});
|
|
1700
794
|
}
|
|
1701
|
-
|
|
1702
795
|
cascadeLoaderData(router.state.matches);
|
|
1703
796
|
router.listeners.forEach(listener => listener(router));
|
|
1704
797
|
},
|
|
1705
|
-
|
|
1706
|
-
return
|
|
1707
|
-
|
|
1708
|
-
|
|
798
|
+
dehydrate: () => {
|
|
799
|
+
return {
|
|
800
|
+
location: router.location,
|
|
801
|
+
state: _extends({}, pick(router.state, ['status', 'location', 'lastUpdated', 'location']), {
|
|
802
|
+
matches: router.state.matches.map(match => pick(match, ['matchId', 'status', 'routeLoaderData', 'loaderData', 'isInvalid', 'invalidAt']))
|
|
803
|
+
}),
|
|
804
|
+
context: router.options.context
|
|
805
|
+
};
|
|
1709
806
|
},
|
|
1710
|
-
|
|
807
|
+
hydrate: dehydratedState => {
|
|
808
|
+
// Update the location
|
|
809
|
+
router.location = dehydratedState.location;
|
|
810
|
+
|
|
811
|
+
// Update the context
|
|
812
|
+
router.options.context = dehydratedState.context;
|
|
813
|
+
|
|
1711
814
|
// Match the routes
|
|
1712
815
|
const matches = router.matchRoutes(router.location.pathname, {
|
|
1713
816
|
strictParseParams: true
|
|
1714
817
|
});
|
|
1715
818
|
matches.forEach((match, index) => {
|
|
1716
|
-
const dehydratedMatch = dehydratedState.matches[index];
|
|
819
|
+
const dehydratedMatch = dehydratedState.state.matches[index];
|
|
1717
820
|
invariant(dehydratedMatch, 'Oh no! Dehydrated route matches did not match the active state of the router 😬');
|
|
1718
821
|
Object.assign(match, dehydratedMatch);
|
|
1719
822
|
});
|
|
@@ -1727,32 +830,29 @@ function createRouter(userOptions) {
|
|
|
1727
830
|
to: '.',
|
|
1728
831
|
search: true,
|
|
1729
832
|
hash: true
|
|
1730
|
-
});
|
|
1731
|
-
// to the current location. Otherwise, load the current location.
|
|
1732
|
-
|
|
833
|
+
});
|
|
1733
834
|
|
|
835
|
+
// If the current location isn't updated, trigger a navigation
|
|
836
|
+
// to the current location. Otherwise, load the current location.
|
|
1734
837
|
if (next.href !== router.location.href) {
|
|
1735
838
|
router.__.commitLocation(next, true);
|
|
1736
839
|
}
|
|
1737
|
-
|
|
1738
840
|
if (!router.state.matches.length) {
|
|
1739
841
|
router.load();
|
|
1740
842
|
}
|
|
1741
|
-
|
|
1742
843
|
const unsub = router.history.listen(event => {
|
|
1743
844
|
router.load(router.__.parseLocation(event.location, router.location));
|
|
1744
|
-
});
|
|
1745
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
845
|
+
});
|
|
1746
846
|
|
|
847
|
+
// addEventListener does not exist in React Native, but window does
|
|
848
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1747
849
|
if (!isServer && window.addEventListener) {
|
|
1748
850
|
// Listen to visibillitychange and focus
|
|
1749
851
|
window.addEventListener('visibilitychange', router.onFocus, false);
|
|
1750
852
|
window.addEventListener('focus', router.onFocus, false);
|
|
1751
853
|
}
|
|
1752
|
-
|
|
1753
854
|
return () => {
|
|
1754
855
|
unsub();
|
|
1755
|
-
|
|
1756
856
|
if (!isServer && window.removeEventListener) {
|
|
1757
857
|
// Be sure to unsubscribe if a new handler is set
|
|
1758
858
|
window.removeEventListener('visibilitychange', router.onFocus);
|
|
@@ -1765,28 +865,23 @@ function createRouter(userOptions) {
|
|
|
1765
865
|
},
|
|
1766
866
|
update: opts => {
|
|
1767
867
|
const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
|
|
1768
|
-
|
|
1769
868
|
if (!router.location || newHistory) {
|
|
1770
869
|
if (opts != null && opts.history) {
|
|
1771
870
|
router.history = opts.history;
|
|
1772
871
|
}
|
|
1773
|
-
|
|
1774
872
|
router.location = router.__.parseLocation(router.history.location);
|
|
1775
873
|
router.state.location = router.location;
|
|
1776
874
|
}
|
|
1777
|
-
|
|
1778
875
|
Object.assign(router.options, opts);
|
|
1779
876
|
const {
|
|
1780
877
|
basepath,
|
|
1781
878
|
routeConfig
|
|
1782
879
|
} = router.options;
|
|
1783
880
|
router.basepath = cleanPath("/" + (basepath != null ? basepath : ''));
|
|
1784
|
-
|
|
1785
881
|
if (routeConfig) {
|
|
1786
882
|
router.routesById = {};
|
|
1787
883
|
router.routeTree = router.__.buildRouteTree(routeConfig);
|
|
1788
884
|
}
|
|
1789
|
-
|
|
1790
885
|
return router;
|
|
1791
886
|
},
|
|
1792
887
|
cancelMatches: () => {
|
|
@@ -1798,31 +893,18 @@ function createRouter(userOptions) {
|
|
|
1798
893
|
load: async next => {
|
|
1799
894
|
const id = Math.random();
|
|
1800
895
|
router.startedLoadingAt = id;
|
|
1801
|
-
|
|
1802
896
|
if (next) {
|
|
1803
897
|
// Ingest the new location
|
|
1804
898
|
router.location = next;
|
|
1805
|
-
}
|
|
1806
|
-
|
|
899
|
+
}
|
|
1807
900
|
|
|
1808
|
-
|
|
901
|
+
// Cancel any pending matches
|
|
902
|
+
router.cancelMatches();
|
|
1809
903
|
|
|
904
|
+
// Match the routes
|
|
1810
905
|
const matches = router.matchRoutes(router.location.pathname, {
|
|
1811
906
|
strictParseParams: true
|
|
1812
|
-
});
|
|
1813
|
-
|
|
1814
|
-
try {
|
|
1815
|
-
await Promise.all(matches.map(match => match.options.beforeLoad == null ? void 0 : match.options.beforeLoad({
|
|
1816
|
-
context: router.context
|
|
1817
|
-
})));
|
|
1818
|
-
} catch (err) {
|
|
1819
|
-
if (err != null && err.then) {
|
|
1820
|
-
await new Promise(() => {});
|
|
1821
|
-
}
|
|
1822
|
-
|
|
1823
|
-
throw err;
|
|
1824
|
-
}
|
|
1825
|
-
|
|
907
|
+
});
|
|
1826
908
|
if (typeof document !== 'undefined') {
|
|
1827
909
|
router.state = _extends({}, router.state, {
|
|
1828
910
|
pending: {
|
|
@@ -1839,18 +921,29 @@ function createRouter(userOptions) {
|
|
|
1839
921
|
});
|
|
1840
922
|
}
|
|
1841
923
|
|
|
1842
|
-
|
|
924
|
+
// Check if each match middleware to see if the route can be accessed
|
|
925
|
+
try {
|
|
926
|
+
await Promise.all(matches.map(match => match.options.beforeLoad == null ? void 0 : match.options.beforeLoad({
|
|
927
|
+
router: router,
|
|
928
|
+
match
|
|
929
|
+
})));
|
|
930
|
+
} catch (err) {
|
|
931
|
+
if (err != null && err.then) {
|
|
932
|
+
await new Promise(() => {});
|
|
933
|
+
}
|
|
934
|
+
throw err;
|
|
935
|
+
}
|
|
936
|
+
router.notify();
|
|
1843
937
|
|
|
938
|
+
// Load the matches
|
|
1844
939
|
await router.loadMatches(matches);
|
|
1845
|
-
|
|
1846
940
|
if (router.startedLoadingAt !== id) {
|
|
1847
941
|
// Ignore side-effects of match loading
|
|
1848
942
|
return router.navigationPromise;
|
|
1849
943
|
}
|
|
1850
|
-
|
|
1851
944
|
const previousMatches = router.state.matches;
|
|
1852
945
|
const exiting = [],
|
|
1853
|
-
|
|
946
|
+
staying = [];
|
|
1854
947
|
previousMatches.forEach(d => {
|
|
1855
948
|
if (matches.find(dd => dd.matchId === d.matchId)) {
|
|
1856
949
|
staying.push(d);
|
|
@@ -1864,19 +957,17 @@ function createRouter(userOptions) {
|
|
|
1864
957
|
const now = Date.now();
|
|
1865
958
|
exiting.forEach(d => {
|
|
1866
959
|
var _ref, _d$options$loaderGcMa, _ref2, _d$options$loaderMaxA;
|
|
1867
|
-
|
|
1868
960
|
d.__.onExit == null ? void 0 : d.__.onExit({
|
|
1869
961
|
params: d.params,
|
|
1870
962
|
search: d.routeSearch
|
|
1871
|
-
});
|
|
963
|
+
});
|
|
1872
964
|
|
|
965
|
+
// Clear idle error states when match leaves
|
|
1873
966
|
if (d.status === 'error' && !d.isFetching) {
|
|
1874
967
|
d.status = 'idle';
|
|
1875
968
|
d.error = undefined;
|
|
1876
969
|
}
|
|
1877
|
-
|
|
1878
970
|
const gc = Math.max((_ref = (_d$options$loaderGcMa = d.options.loaderGcMaxAge) != null ? _d$options$loaderGcMa : router.options.defaultLoaderGcMaxAge) != null ? _ref : 0, (_ref2 = (_d$options$loaderMaxA = d.options.loaderMaxAge) != null ? _d$options$loaderMaxA : router.options.defaultLoaderMaxAge) != null ? _ref2 : 0);
|
|
1879
|
-
|
|
1880
971
|
if (gc > 0) {
|
|
1881
972
|
router.matchCache[d.matchId] = {
|
|
1882
973
|
gc: gc == Infinity ? Number.MAX_SAFE_INTEGER : now + gc,
|
|
@@ -1897,12 +988,10 @@ function createRouter(userOptions) {
|
|
|
1897
988
|
});
|
|
1898
989
|
delete router.matchCache[d.matchId];
|
|
1899
990
|
});
|
|
1900
|
-
|
|
1901
991
|
if (router.startedLoadingAt !== id) {
|
|
1902
992
|
// Ignore side-effects of match loading
|
|
1903
993
|
return;
|
|
1904
994
|
}
|
|
1905
|
-
|
|
1906
995
|
matches.forEach(match => {
|
|
1907
996
|
// Clear actions
|
|
1908
997
|
if (match.action) {
|
|
@@ -1922,18 +1011,19 @@ function createRouter(userOptions) {
|
|
|
1922
1011
|
cleanMatchCache: () => {
|
|
1923
1012
|
const now = Date.now();
|
|
1924
1013
|
Object.keys(router.matchCache).forEach(matchId => {
|
|
1925
|
-
const entry = router.matchCache[matchId];
|
|
1014
|
+
const entry = router.matchCache[matchId];
|
|
1926
1015
|
|
|
1016
|
+
// Don't remove loading matches
|
|
1927
1017
|
if (entry.match.status === 'loading') {
|
|
1928
1018
|
return;
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1019
|
+
}
|
|
1931
1020
|
|
|
1021
|
+
// Do not remove successful matches that are still valid
|
|
1932
1022
|
if (entry.gc > 0 && entry.gc > now) {
|
|
1933
1023
|
return;
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1024
|
+
}
|
|
1936
1025
|
|
|
1026
|
+
// Everything else gets removed
|
|
1937
1027
|
delete router.matchCache[matchId];
|
|
1938
1028
|
});
|
|
1939
1029
|
},
|
|
@@ -1941,7 +1031,6 @@ function createRouter(userOptions) {
|
|
|
1941
1031
|
if (navigateOpts === void 0) {
|
|
1942
1032
|
navigateOpts = router.location;
|
|
1943
1033
|
}
|
|
1944
|
-
|
|
1945
1034
|
const next = router.buildNext(navigateOpts);
|
|
1946
1035
|
const matches = router.matchRoutes(next.pathname, {
|
|
1947
1036
|
strictParseParams: true
|
|
@@ -1951,11 +1040,9 @@ function createRouter(userOptions) {
|
|
|
1951
1040
|
},
|
|
1952
1041
|
preloadRoute: async function preloadRoute(navigateOpts, loaderOpts) {
|
|
1953
1042
|
var _ref3, _ref4, _loaderOpts$maxAge, _ref5, _ref6, _loaderOpts$gcMaxAge;
|
|
1954
|
-
|
|
1955
1043
|
if (navigateOpts === void 0) {
|
|
1956
1044
|
navigateOpts = router.location;
|
|
1957
1045
|
}
|
|
1958
|
-
|
|
1959
1046
|
const next = router.buildNext(navigateOpts);
|
|
1960
1047
|
const matches = router.matchRoutes(next.pathname, {
|
|
1961
1048
|
strictParseParams: true
|
|
@@ -1969,90 +1056,70 @@ function createRouter(userOptions) {
|
|
|
1969
1056
|
},
|
|
1970
1057
|
matchRoutes: (pathname, opts) => {
|
|
1971
1058
|
var _router$state$pending3, _router$state$pending4;
|
|
1972
|
-
|
|
1973
1059
|
router.cleanMatchCache();
|
|
1974
1060
|
const matches = [];
|
|
1975
|
-
|
|
1976
1061
|
if (!router.routeTree) {
|
|
1977
1062
|
return matches;
|
|
1978
1063
|
}
|
|
1979
|
-
|
|
1980
1064
|
const existingMatches = [...router.state.matches, ...((_router$state$pending3 = (_router$state$pending4 = router.state.pending) == null ? void 0 : _router$state$pending4.matches) != null ? _router$state$pending3 : [])];
|
|
1981
|
-
|
|
1982
1065
|
const recurse = async routes => {
|
|
1983
1066
|
var _parentMatch$params, _router$options$filte, _foundRoute$childRout;
|
|
1984
|
-
|
|
1985
1067
|
const parentMatch = last(matches);
|
|
1986
1068
|
let params = (_parentMatch$params = parentMatch == null ? void 0 : parentMatch.params) != null ? _parentMatch$params : {};
|
|
1987
1069
|
const filteredRoutes = (_router$options$filte = router.options.filterRoutes == null ? void 0 : router.options.filterRoutes(routes)) != null ? _router$options$filte : routes;
|
|
1988
1070
|
let foundRoutes = [];
|
|
1989
|
-
|
|
1990
1071
|
const findMatchInRoutes = (parentRoutes, routes) => {
|
|
1991
1072
|
routes.some(route => {
|
|
1992
1073
|
var _route$childRoutes, _route$childRoutes2, _route$options$caseSe;
|
|
1993
|
-
|
|
1994
1074
|
if (!route.routePath && (_route$childRoutes = route.childRoutes) != null && _route$childRoutes.length) {
|
|
1995
1075
|
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
|
|
1996
1076
|
}
|
|
1997
|
-
|
|
1998
1077
|
const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
|
|
1999
1078
|
const matchParams = matchPathname(pathname, {
|
|
2000
1079
|
to: route.fullPath,
|
|
2001
1080
|
fuzzy,
|
|
2002
1081
|
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
2003
1082
|
});
|
|
2004
|
-
|
|
2005
1083
|
if (matchParams) {
|
|
2006
1084
|
let parsedParams;
|
|
2007
|
-
|
|
2008
1085
|
try {
|
|
2009
1086
|
var _route$options$parseP;
|
|
2010
|
-
|
|
2011
1087
|
parsedParams = (_route$options$parseP = route.options.parseParams == null ? void 0 : route.options.parseParams(matchParams)) != null ? _route$options$parseP : matchParams;
|
|
2012
1088
|
} catch (err) {
|
|
2013
1089
|
if (opts != null && opts.strictParseParams) {
|
|
2014
1090
|
throw err;
|
|
2015
1091
|
}
|
|
2016
1092
|
}
|
|
2017
|
-
|
|
2018
1093
|
params = _extends({}, params, parsedParams);
|
|
2019
1094
|
}
|
|
2020
|
-
|
|
2021
1095
|
if (!!matchParams) {
|
|
2022
1096
|
foundRoutes = [...parentRoutes, route];
|
|
2023
1097
|
}
|
|
2024
|
-
|
|
2025
1098
|
return !!foundRoutes.length;
|
|
2026
1099
|
});
|
|
2027
1100
|
return !!foundRoutes.length;
|
|
2028
1101
|
};
|
|
2029
|
-
|
|
2030
1102
|
findMatchInRoutes([], filteredRoutes);
|
|
2031
|
-
|
|
2032
1103
|
if (!foundRoutes.length) {
|
|
2033
1104
|
return;
|
|
2034
1105
|
}
|
|
2035
|
-
|
|
2036
1106
|
foundRoutes.forEach(foundRoute => {
|
|
2037
1107
|
var _router$matchCache$ma;
|
|
2038
|
-
|
|
2039
1108
|
const interpolatedPath = interpolatePath(foundRoute.routePath, params);
|
|
2040
1109
|
const matchId = interpolatePath(foundRoute.routeId, params, true);
|
|
2041
1110
|
const match = existingMatches.find(d => d.matchId === matchId) || ((_router$matchCache$ma = router.matchCache[matchId]) == null ? void 0 : _router$matchCache$ma.match) || createRouteMatch(router, foundRoute, {
|
|
2042
1111
|
parentMatch,
|
|
2043
1112
|
matchId,
|
|
2044
1113
|
params,
|
|
2045
|
-
pathname: joinPaths([
|
|
1114
|
+
pathname: joinPaths([router.basepath, interpolatedPath])
|
|
2046
1115
|
});
|
|
2047
1116
|
matches.push(match);
|
|
2048
1117
|
});
|
|
2049
1118
|
const foundRoute = last(foundRoutes);
|
|
2050
|
-
|
|
2051
1119
|
if ((_foundRoute$childRout = foundRoute.childRoutes) != null && _foundRoute$childRout.length) {
|
|
2052
1120
|
recurse(foundRoute.childRoutes);
|
|
2053
1121
|
}
|
|
2054
1122
|
};
|
|
2055
|
-
|
|
2056
1123
|
recurse([router.routeTree]);
|
|
2057
1124
|
cascadeLoaderData(matches);
|
|
2058
1125
|
return matches;
|
|
@@ -2061,14 +1128,11 @@ function createRouter(userOptions) {
|
|
|
2061
1128
|
const matchPromises = resolvedMatches.map(async match => {
|
|
2062
1129
|
// Validate the match (loads search params etc)
|
|
2063
1130
|
match.__.validate();
|
|
2064
|
-
|
|
2065
1131
|
match.load(loaderOpts);
|
|
2066
1132
|
const search = match.search;
|
|
2067
|
-
|
|
2068
1133
|
if (search.__data && search.__data.matchId !== match.matchId) {
|
|
2069
1134
|
return;
|
|
2070
1135
|
}
|
|
2071
|
-
|
|
2072
1136
|
if (match.__.loadPromise) {
|
|
2073
1137
|
// Wait for the first sign of activity from the match
|
|
2074
1138
|
await match.__.loadPromise;
|
|
@@ -2080,7 +1144,6 @@ function createRouter(userOptions) {
|
|
|
2080
1144
|
loadMatchData: async routeMatch => {
|
|
2081
1145
|
if (isServer || !router.options.useServerData) {
|
|
2082
1146
|
var _await$routeMatch$opt;
|
|
2083
|
-
|
|
2084
1147
|
return (_await$routeMatch$opt = await (routeMatch.options.loader == null ? void 0 : routeMatch.options.loader({
|
|
2085
1148
|
// parentLoaderPromise: routeMatch.parentMatch?.__.dataPromise,
|
|
2086
1149
|
params: routeMatch.params,
|
|
@@ -2096,21 +1159,30 @@ function createRouter(userOptions) {
|
|
|
2096
1159
|
}
|
|
2097
1160
|
})
|
|
2098
1161
|
});
|
|
2099
|
-
const res = await fetch(next.href, {
|
|
2100
|
-
method: 'GET' // signal: routeMatch.__.abortController.signal,
|
|
2101
1162
|
|
|
1163
|
+
// Refresh:
|
|
1164
|
+
// '/dashboard'
|
|
1165
|
+
// '/dashboard/invoices/'
|
|
1166
|
+
// '/dashboard/invoices/123'
|
|
1167
|
+
|
|
1168
|
+
// New:
|
|
1169
|
+
// '/dashboard/invoices/456'
|
|
1170
|
+
|
|
1171
|
+
// TODO: batch requests when possible
|
|
1172
|
+
|
|
1173
|
+
const res = await fetch(next.href, {
|
|
1174
|
+
method: 'GET'
|
|
1175
|
+
// signal: routeMatch.__.abortController.signal,
|
|
2102
1176
|
});
|
|
2103
1177
|
|
|
2104
1178
|
if (res.ok) {
|
|
2105
1179
|
return res.json();
|
|
2106
1180
|
}
|
|
2107
|
-
|
|
2108
1181
|
throw new Error('Failed to fetch match data');
|
|
2109
1182
|
}
|
|
2110
1183
|
},
|
|
2111
1184
|
invalidateRoute: opts => {
|
|
2112
1185
|
var _router$state$pending5, _router$state$pending6;
|
|
2113
|
-
|
|
2114
1186
|
const next = router.buildNext(opts);
|
|
2115
1187
|
const unloadedMatchIds = router.matchRoutes(next.pathname).map(d => d.matchId);
|
|
2116
1188
|
[...router.state.matches, ...((_router$state$pending5 = (_router$state$pending6 = router.state.pending) == null ? void 0 : _router$state$pending6.matches) != null ? _router$state$pending5 : [])].forEach(match => {
|
|
@@ -2129,25 +1201,21 @@ function createRouter(userOptions) {
|
|
|
2129
1201
|
},
|
|
2130
1202
|
matchRoute: (location, opts) => {
|
|
2131
1203
|
var _location$from;
|
|
2132
|
-
|
|
2133
1204
|
// const location = router.buildNext(opts)
|
|
1205
|
+
|
|
2134
1206
|
location = _extends({}, location, {
|
|
2135
1207
|
to: location.to ? router.resolvePath((_location$from = location.from) != null ? _location$from : '', location.to) : undefined
|
|
2136
1208
|
});
|
|
2137
1209
|
const next = router.buildNext(location);
|
|
2138
|
-
|
|
2139
1210
|
if (opts != null && opts.pending) {
|
|
2140
1211
|
var _router$state$pending7;
|
|
2141
|
-
|
|
2142
1212
|
if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
|
|
2143
1213
|
return false;
|
|
2144
1214
|
}
|
|
2145
|
-
|
|
2146
1215
|
return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
|
|
2147
1216
|
to: next.pathname
|
|
2148
1217
|
}));
|
|
2149
1218
|
}
|
|
2150
|
-
|
|
2151
1219
|
return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
|
|
2152
1220
|
to: next.pathname
|
|
2153
1221
|
}));
|
|
@@ -2163,17 +1231,16 @@ function createRouter(userOptions) {
|
|
|
2163
1231
|
} = _ref7;
|
|
2164
1232
|
// If this link simply reloads the current route,
|
|
2165
1233
|
// make sure it has a new key so it will trigger a data refresh
|
|
1234
|
+
|
|
2166
1235
|
// If this `to` is a valid external URL, return
|
|
2167
1236
|
// null for LinkUtils
|
|
2168
1237
|
const toString = String(to);
|
|
2169
1238
|
const fromString = String(from);
|
|
2170
1239
|
let isExternal;
|
|
2171
|
-
|
|
2172
1240
|
try {
|
|
2173
1241
|
new URL("" + toString);
|
|
2174
1242
|
isExternal = true;
|
|
2175
1243
|
} catch (e) {}
|
|
2176
|
-
|
|
2177
1244
|
invariant(!isExternal, 'Attempting to navigate to external url with router.navigate!');
|
|
2178
1245
|
return router.__.navigate({
|
|
2179
1246
|
from: fromString,
|
|
@@ -2186,7 +1253,6 @@ function createRouter(userOptions) {
|
|
|
2186
1253
|
},
|
|
2187
1254
|
buildLink: _ref8 => {
|
|
2188
1255
|
var _preload, _ref9;
|
|
2189
|
-
|
|
2190
1256
|
let {
|
|
2191
1257
|
from,
|
|
2192
1258
|
to = '.',
|
|
@@ -2202,11 +1268,12 @@ function createRouter(userOptions) {
|
|
|
2202
1268
|
preloadDelay: userPreloadDelay,
|
|
2203
1269
|
disabled
|
|
2204
1270
|
} = _ref8;
|
|
2205
|
-
|
|
2206
1271
|
// If this link simply reloads the current route,
|
|
2207
1272
|
// make sure it has a new key so it will trigger a data refresh
|
|
1273
|
+
|
|
2208
1274
|
// If this `to` is a valid external URL, return
|
|
2209
1275
|
// null for LinkUtils
|
|
1276
|
+
|
|
2210
1277
|
try {
|
|
2211
1278
|
new URL("" + to);
|
|
2212
1279
|
return {
|
|
@@ -2214,7 +1281,6 @@ function createRouter(userOptions) {
|
|
|
2214
1281
|
href: to
|
|
2215
1282
|
};
|
|
2216
1283
|
} catch (e) {}
|
|
2217
|
-
|
|
2218
1284
|
const nextOpts = {
|
|
2219
1285
|
from,
|
|
2220
1286
|
to,
|
|
@@ -2225,33 +1291,35 @@ function createRouter(userOptions) {
|
|
|
2225
1291
|
};
|
|
2226
1292
|
const next = router.buildNext(nextOpts);
|
|
2227
1293
|
preload = (_preload = preload) != null ? _preload : router.options.defaultPreload;
|
|
2228
|
-
const preloadDelay = (_ref9 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultPreloadDelay) != null ? _ref9 : 0;
|
|
1294
|
+
const preloadDelay = (_ref9 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultPreloadDelay) != null ? _ref9 : 0;
|
|
2229
1295
|
|
|
1296
|
+
// Compare path/hash for matches
|
|
2230
1297
|
const pathIsEqual = router.state.location.pathname === next.pathname;
|
|
2231
1298
|
const currentPathSplit = router.state.location.pathname.split('/');
|
|
2232
1299
|
const nextPathSplit = next.pathname.split('/');
|
|
2233
1300
|
const pathIsFuzzyEqual = nextPathSplit.every((d, i) => d === currentPathSplit[i]);
|
|
2234
|
-
const hashIsEqual = router.state.location.hash === next.hash;
|
|
2235
|
-
|
|
1301
|
+
const hashIsEqual = router.state.location.hash === next.hash;
|
|
1302
|
+
// Combine the matches based on user options
|
|
2236
1303
|
const pathTest = activeOptions != null && activeOptions.exact ? pathIsEqual : pathIsFuzzyEqual;
|
|
2237
|
-
const hashTest = activeOptions != null && activeOptions.includeHash ? hashIsEqual : true;
|
|
1304
|
+
const hashTest = activeOptions != null && activeOptions.includeHash ? hashIsEqual : true;
|
|
2238
1305
|
|
|
2239
|
-
|
|
1306
|
+
// The final "active" test
|
|
1307
|
+
const isActive = pathTest && hashTest;
|
|
2240
1308
|
|
|
1309
|
+
// The click handler
|
|
2241
1310
|
const handleClick = e => {
|
|
2242
1311
|
if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!target || target === '_self') && e.button === 0) {
|
|
2243
1312
|
e.preventDefault();
|
|
2244
|
-
|
|
2245
1313
|
if (pathIsEqual && !search && !hash) {
|
|
2246
1314
|
router.invalidateRoute(nextOpts);
|
|
2247
|
-
}
|
|
2248
|
-
|
|
1315
|
+
}
|
|
2249
1316
|
|
|
1317
|
+
// All is well? Navigate!)
|
|
2250
1318
|
router.__.navigate(nextOpts);
|
|
2251
1319
|
}
|
|
2252
|
-
};
|
|
2253
|
-
|
|
1320
|
+
};
|
|
2254
1321
|
|
|
1322
|
+
// The click handler
|
|
2255
1323
|
const handleFocus = e => {
|
|
2256
1324
|
if (preload) {
|
|
2257
1325
|
router.preloadRoute(nextOpts, {
|
|
@@ -2260,15 +1328,12 @@ function createRouter(userOptions) {
|
|
|
2260
1328
|
});
|
|
2261
1329
|
}
|
|
2262
1330
|
};
|
|
2263
|
-
|
|
2264
1331
|
const handleEnter = e => {
|
|
2265
1332
|
const target = e.target || {};
|
|
2266
|
-
|
|
2267
1333
|
if (preload) {
|
|
2268
1334
|
if (target.preloadTimeout) {
|
|
2269
1335
|
return;
|
|
2270
1336
|
}
|
|
2271
|
-
|
|
2272
1337
|
target.preloadTimeout = setTimeout(() => {
|
|
2273
1338
|
target.preloadTimeout = null;
|
|
2274
1339
|
router.preloadRoute(nextOpts, {
|
|
@@ -2278,16 +1343,13 @@ function createRouter(userOptions) {
|
|
|
2278
1343
|
}, preloadDelay);
|
|
2279
1344
|
}
|
|
2280
1345
|
};
|
|
2281
|
-
|
|
2282
1346
|
const handleLeave = e => {
|
|
2283
1347
|
const target = e.target || {};
|
|
2284
|
-
|
|
2285
1348
|
if (target.preloadTimeout) {
|
|
2286
1349
|
clearTimeout(target.preloadTimeout);
|
|
2287
1350
|
target.preloadTimeout = null;
|
|
2288
1351
|
}
|
|
2289
1352
|
};
|
|
2290
|
-
|
|
2291
1353
|
return {
|
|
2292
1354
|
type: 'internal',
|
|
2293
1355
|
next,
|
|
@@ -2301,21 +1363,15 @@ function createRouter(userOptions) {
|
|
|
2301
1363
|
},
|
|
2302
1364
|
buildNext: opts => {
|
|
2303
1365
|
const next = router.__.buildLocation(opts);
|
|
2304
|
-
|
|
2305
1366
|
const matches = router.matchRoutes(next.pathname);
|
|
2306
|
-
|
|
2307
1367
|
const __preSearchFilters = matches.map(match => {
|
|
2308
1368
|
var _match$options$preSea;
|
|
2309
|
-
|
|
2310
1369
|
return (_match$options$preSea = match.options.preSearchFilters) != null ? _match$options$preSea : [];
|
|
2311
1370
|
}).flat().filter(Boolean);
|
|
2312
|
-
|
|
2313
1371
|
const __postSearchFilters = matches.map(match => {
|
|
2314
1372
|
var _match$options$postSe;
|
|
2315
|
-
|
|
2316
1373
|
return (_match$options$postSe = match.options.postSearchFilters) != null ? _match$options$postSe : [];
|
|
2317
1374
|
}).flat().filter(Boolean);
|
|
2318
|
-
|
|
2319
1375
|
return router.__.buildLocation(_extends({}, opts, {
|
|
2320
1376
|
__preSearchFilters,
|
|
2321
1377
|
__postSearchFilters
|
|
@@ -2328,12 +1384,10 @@ function createRouter(userOptions) {
|
|
|
2328
1384
|
const routeOptions = routeConfig.options;
|
|
2329
1385
|
const route = createRoute(routeConfig, routeOptions, parent, router);
|
|
2330
1386
|
const existingRoute = router.routesById[route.routeId];
|
|
2331
|
-
|
|
2332
1387
|
if (existingRoute) {
|
|
2333
1388
|
if (process.env.NODE_ENV !== 'production') {
|
|
2334
1389
|
console.warn("Duplicate routes found with id: " + String(route.routeId), router.routesById, route);
|
|
2335
1390
|
}
|
|
2336
|
-
|
|
2337
1391
|
throw new Error();
|
|
2338
1392
|
}
|
|
2339
1393
|
router.routesById[route.routeId] = route;
|
|
@@ -2342,13 +1396,11 @@ function createRouter(userOptions) {
|
|
|
2342
1396
|
return route;
|
|
2343
1397
|
});
|
|
2344
1398
|
};
|
|
2345
|
-
|
|
2346
1399
|
const routes = recurseRoutes([rootRouteConfig]);
|
|
2347
1400
|
return routes[0];
|
|
2348
1401
|
},
|
|
2349
1402
|
parseLocation: (location, previousLocation) => {
|
|
2350
1403
|
var _location$hash$split$;
|
|
2351
|
-
|
|
2352
1404
|
const parsedSearch = router.options.parseSearch(location.search);
|
|
2353
1405
|
return {
|
|
2354
1406
|
pathname: location.pathname,
|
|
@@ -2366,41 +1418,36 @@ function createRouter(userOptions) {
|
|
|
2366
1418
|
},
|
|
2367
1419
|
buildLocation: function buildLocation(dest) {
|
|
2368
1420
|
var _dest$from, _router$basepath, _dest$to, _last, _dest$params, _dest$__preSearchFilt, _functionalUpdate, _dest$__preSearchFilt2, _dest$__postSearchFil;
|
|
2369
|
-
|
|
2370
1421
|
if (dest === void 0) {
|
|
2371
1422
|
dest = {};
|
|
2372
1423
|
}
|
|
2373
|
-
|
|
2374
1424
|
// const resolvedFrom: Location = {
|
|
2375
1425
|
// ...router.location,
|
|
2376
1426
|
const fromPathname = dest.fromCurrent ? router.location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.location.pathname;
|
|
2377
|
-
|
|
2378
1427
|
let pathname = resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
|
|
2379
|
-
|
|
2380
1428
|
const fromMatches = router.matchRoutes(router.location.pathname, {
|
|
2381
1429
|
strictParseParams: true
|
|
2382
1430
|
});
|
|
2383
1431
|
const toMatches = router.matchRoutes(pathname);
|
|
2384
|
-
|
|
2385
1432
|
const prevParams = _extends({}, (_last = last(fromMatches)) == null ? void 0 : _last.params);
|
|
2386
|
-
|
|
2387
1433
|
let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
|
|
2388
|
-
|
|
2389
1434
|
if (nextParams) {
|
|
2390
1435
|
toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
|
|
2391
1436
|
Object.assign({}, nextParams, fn(nextParams));
|
|
2392
1437
|
});
|
|
2393
1438
|
}
|
|
1439
|
+
pathname = interpolatePath(pathname, nextParams != null ? nextParams : {});
|
|
2394
1440
|
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.location.search) : router.location.search; // Then the link/navigate function
|
|
1441
|
+
// Pre filters first
|
|
1442
|
+
const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.location.search) : router.location.search;
|
|
2398
1443
|
|
|
1444
|
+
// Then the link/navigate function
|
|
2399
1445
|
const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
|
|
2400
1446
|
: dest.search ? (_functionalUpdate = functionalUpdate(dest.search, preFilteredSearch)) != null ? _functionalUpdate : {} // Updater
|
|
2401
1447
|
: (_dest$__preSearchFilt2 = dest.__preSearchFilters) != null && _dest$__preSearchFilt2.length ? preFilteredSearch // Preserve resolvedFrom filters
|
|
2402
|
-
: {};
|
|
1448
|
+
: {};
|
|
2403
1449
|
|
|
1450
|
+
// Then post filters
|
|
2404
1451
|
const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
|
|
2405
1452
|
const search = replaceEqualDeep(router.location.search, postFilteredSearch);
|
|
2406
1453
|
const searchStr = router.options.stringifySearch(search);
|
|
@@ -2420,17 +1467,13 @@ function createRouter(userOptions) {
|
|
|
2420
1467
|
const id = '' + Date.now() + Math.random();
|
|
2421
1468
|
if (router.navigateTimeout) clearTimeout(router.navigateTimeout);
|
|
2422
1469
|
let nextAction = 'replace';
|
|
2423
|
-
|
|
2424
1470
|
if (!replace) {
|
|
2425
1471
|
nextAction = 'push';
|
|
2426
1472
|
}
|
|
2427
|
-
|
|
2428
1473
|
const isSameUrl = router.__.parseLocation(history.location).href === next.href;
|
|
2429
|
-
|
|
2430
1474
|
if (isSameUrl && !next.key) {
|
|
2431
1475
|
nextAction = 'replace';
|
|
2432
1476
|
}
|
|
2433
|
-
|
|
2434
1477
|
if (nextAction === 'replace') {
|
|
2435
1478
|
history.replace({
|
|
2436
1479
|
pathname: next.pathname,
|
|
@@ -2448,38 +1491,35 @@ function createRouter(userOptions) {
|
|
|
2448
1491
|
id
|
|
2449
1492
|
});
|
|
2450
1493
|
}
|
|
2451
|
-
|
|
2452
1494
|
router.navigationPromise = new Promise(resolve => {
|
|
2453
1495
|
const previousNavigationResolve = router.resolveNavigation;
|
|
2454
|
-
|
|
2455
1496
|
router.resolveNavigation = () => {
|
|
2456
1497
|
previousNavigationResolve();
|
|
2457
1498
|
resolve();
|
|
1499
|
+
delete router.navigationPromise;
|
|
2458
1500
|
};
|
|
2459
1501
|
});
|
|
2460
1502
|
return router.navigationPromise;
|
|
2461
1503
|
}
|
|
2462
1504
|
}
|
|
2463
1505
|
};
|
|
2464
|
-
router.update(userOptions);
|
|
1506
|
+
router.update(userOptions);
|
|
2465
1507
|
|
|
1508
|
+
// Allow frameworks to hook into the router creation
|
|
2466
1509
|
router.options.createRouter == null ? void 0 : router.options.createRouter(router);
|
|
2467
1510
|
return router;
|
|
2468
1511
|
}
|
|
2469
|
-
|
|
2470
1512
|
function isCtrlEvent(e) {
|
|
2471
1513
|
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
2472
1514
|
}
|
|
2473
|
-
|
|
2474
1515
|
function cascadeLoaderData(matches) {
|
|
2475
1516
|
matches.forEach((match, index) => {
|
|
2476
1517
|
const parent = matches[index - 1];
|
|
2477
|
-
|
|
2478
1518
|
if (parent) {
|
|
2479
1519
|
match.loaderData = replaceEqualDeep(match.loaderData, _extends({}, parent.loaderData, match.routeLoaderData));
|
|
2480
1520
|
}
|
|
2481
1521
|
});
|
|
2482
1522
|
}
|
|
2483
1523
|
|
|
2484
|
-
export { cleanPath,
|
|
1524
|
+
export { cleanPath, createRoute, createRouteConfig, createRouteMatch, createRouter, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
|
|
2485
1525
|
//# sourceMappingURL=index.js.map
|