@tanstack/react-router 0.0.1-alpha.5 → 0.0.1-alpha.7
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/react-router/src/index.js +47 -32
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/cjs/router-core/build/esm/index.js +1313 -1238
- package/build/cjs/router-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +1358 -1282
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -29
- package/build/types/index.d.ts +4 -7
- package/build/umd/index.development.js +1368 -1287
- 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/index.tsx +37 -31
package/build/esm/index.js
CHANGED
|
@@ -70,23 +70,6 @@ function _extends$1() {
|
|
|
70
70
|
return _extends$1.apply(this, arguments);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function _extends() {
|
|
74
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
75
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
76
|
-
var source = arguments[i];
|
|
77
|
-
|
|
78
|
-
for (var key in source) {
|
|
79
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
80
|
-
target[key] = source[key];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return target;
|
|
86
|
-
};
|
|
87
|
-
return _extends.apply(this, arguments);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
73
|
/**
|
|
91
74
|
* Actions represent the type of change to a location value.
|
|
92
75
|
*
|
|
@@ -230,7 +213,7 @@ function createBrowserHistory(options) {
|
|
|
230
213
|
|
|
231
214
|
if (index == null) {
|
|
232
215
|
index = 0;
|
|
233
|
-
globalHistory.replaceState(_extends({}, globalHistory.state, {
|
|
216
|
+
globalHistory.replaceState(_extends$1({}, globalHistory.state, {
|
|
234
217
|
idx: index
|
|
235
218
|
}), '');
|
|
236
219
|
}
|
|
@@ -245,7 +228,7 @@ function createBrowserHistory(options) {
|
|
|
245
228
|
state = null;
|
|
246
229
|
}
|
|
247
230
|
|
|
248
|
-
return readOnly(_extends({
|
|
231
|
+
return readOnly(_extends$1({
|
|
249
232
|
pathname: location.pathname,
|
|
250
233
|
hash: '',
|
|
251
234
|
search: ''
|
|
@@ -479,7 +462,7 @@ function createHashHistory(options) {
|
|
|
479
462
|
|
|
480
463
|
if (index == null) {
|
|
481
464
|
index = 0;
|
|
482
|
-
globalHistory.replaceState(_extends({}, globalHistory.state, {
|
|
465
|
+
globalHistory.replaceState(_extends$1({}, globalHistory.state, {
|
|
483
466
|
idx: index
|
|
484
467
|
}), '');
|
|
485
468
|
}
|
|
@@ -506,7 +489,7 @@ function createHashHistory(options) {
|
|
|
506
489
|
state = null;
|
|
507
490
|
}
|
|
508
491
|
|
|
509
|
-
return readOnly(_extends({
|
|
492
|
+
return readOnly(_extends$1({
|
|
510
493
|
pathname: location.pathname,
|
|
511
494
|
hash: '',
|
|
512
495
|
search: ''
|
|
@@ -658,7 +641,7 @@ function createMemoryHistory(options) {
|
|
|
658
641
|
initialEntries = _options3$initialEntr === void 0 ? ['/'] : _options3$initialEntr,
|
|
659
642
|
initialIndex = _options3.initialIndex;
|
|
660
643
|
var entries = initialEntries.map(function (entry) {
|
|
661
|
-
var location = readOnly(_extends({
|
|
644
|
+
var location = readOnly(_extends$1({
|
|
662
645
|
pathname: '/',
|
|
663
646
|
search: '',
|
|
664
647
|
hash: '',
|
|
@@ -683,7 +666,7 @@ function createMemoryHistory(options) {
|
|
|
683
666
|
state = null;
|
|
684
667
|
}
|
|
685
668
|
|
|
686
|
-
return readOnly(_extends({
|
|
669
|
+
return readOnly(_extends$1({
|
|
687
670
|
pathname: location.pathname,
|
|
688
671
|
search: '',
|
|
689
672
|
hash: ''
|
|
@@ -894,1494 +877,1577 @@ function invariant(condition, message) {
|
|
|
894
877
|
throw new Error(value);
|
|
895
878
|
}
|
|
896
879
|
|
|
897
|
-
//
|
|
898
|
-
//
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
tmp,
|
|
903
|
-
str = '';
|
|
880
|
+
// type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
881
|
+
// k: infer I,
|
|
882
|
+
// ) => any
|
|
883
|
+
// ? I
|
|
884
|
+
// : never
|
|
904
885
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
886
|
+
/**
|
|
887
|
+
* This function returns `a` if `b` is deeply equal.
|
|
888
|
+
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
889
|
+
* This can be used for structural sharing between JSON values for example.
|
|
890
|
+
*/
|
|
891
|
+
function replaceEqualDeep(prev, next) {
|
|
892
|
+
if (prev === next) {
|
|
893
|
+
return prev;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
const array = Array.isArray(prev) && Array.isArray(next);
|
|
897
|
+
|
|
898
|
+
if (array || isPlainObject(prev) && isPlainObject(next)) {
|
|
899
|
+
const aSize = array ? prev.length : Object.keys(prev).length;
|
|
900
|
+
const bItems = array ? next : Object.keys(next);
|
|
901
|
+
const bSize = bItems.length;
|
|
902
|
+
const copy = array ? [] : {};
|
|
903
|
+
let equalItems = 0;
|
|
904
|
+
|
|
905
|
+
for (let i = 0; i < bSize; i++) {
|
|
906
|
+
const key = array ? i : bItems[i];
|
|
907
|
+
copy[key] = replaceEqualDeep(prev[key], next[key]);
|
|
908
|
+
|
|
909
|
+
if (copy[key] === prev[key]) {
|
|
910
|
+
equalItems++;
|
|
915
911
|
}
|
|
916
912
|
}
|
|
913
|
+
|
|
914
|
+
return aSize === bSize && equalItems === aSize ? prev : copy;
|
|
917
915
|
}
|
|
918
916
|
|
|
919
|
-
return
|
|
920
|
-
}
|
|
917
|
+
return next;
|
|
918
|
+
} // Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
921
919
|
|
|
922
|
-
function
|
|
923
|
-
if (!
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
if (str === 'true') return true;
|
|
927
|
-
return +str * 0 === 0 ? +str : str;
|
|
928
|
-
}
|
|
920
|
+
function isPlainObject(o) {
|
|
921
|
+
if (!hasObjectPrototype(o)) {
|
|
922
|
+
return false;
|
|
923
|
+
} // If has modified constructor
|
|
929
924
|
|
|
930
|
-
function decode(str) {
|
|
931
|
-
var tmp,
|
|
932
|
-
k,
|
|
933
|
-
out = {},
|
|
934
|
-
arr = str.split('&');
|
|
935
925
|
|
|
936
|
-
|
|
937
|
-
tmp = tmp.split('=');
|
|
938
|
-
k = tmp.shift();
|
|
926
|
+
const ctor = o.constructor;
|
|
939
927
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
out[k] = toValue(tmp.shift());
|
|
944
|
-
}
|
|
945
|
-
}
|
|
928
|
+
if (typeof ctor === 'undefined') {
|
|
929
|
+
return true;
|
|
930
|
+
} // If has modified prototype
|
|
946
931
|
|
|
947
|
-
|
|
932
|
+
|
|
933
|
+
const prot = ctor.prototype;
|
|
934
|
+
|
|
935
|
+
if (!hasObjectPrototype(prot)) {
|
|
936
|
+
return false;
|
|
937
|
+
} // If constructor does not have an Object-specific method
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
if (!prot.hasOwnProperty('isPrototypeOf')) {
|
|
941
|
+
return false;
|
|
942
|
+
} // Most likely a plain Object
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
return true;
|
|
948
946
|
}
|
|
949
947
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
}
|
|
948
|
+
function hasObjectPrototype(o) {
|
|
949
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
950
|
+
}
|
|
954
951
|
|
|
955
|
-
|
|
956
|
-
|
|
952
|
+
function last(arr) {
|
|
953
|
+
return arr[arr.length - 1];
|
|
954
|
+
}
|
|
955
|
+
function warning(cond, message) {
|
|
956
|
+
if (cond) {
|
|
957
|
+
if (typeof console !== 'undefined') console.warn(message);
|
|
958
|
+
|
|
959
|
+
try {
|
|
960
|
+
throw new Error(message);
|
|
961
|
+
} catch (_unused) {}
|
|
957
962
|
}
|
|
958
963
|
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
} // Strip the root from parentIds
|
|
964
|
+
return true;
|
|
965
|
+
}
|
|
962
966
|
|
|
967
|
+
function isFunction(d) {
|
|
968
|
+
return typeof d === 'function';
|
|
969
|
+
}
|
|
963
970
|
|
|
964
|
-
|
|
965
|
-
|
|
971
|
+
function functionalUpdate(updater, previous) {
|
|
972
|
+
if (isFunction(updater)) {
|
|
973
|
+
return updater(previous);
|
|
966
974
|
}
|
|
967
975
|
|
|
968
|
-
|
|
976
|
+
return updater;
|
|
977
|
+
}
|
|
969
978
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
979
|
+
function joinPaths(paths) {
|
|
980
|
+
return cleanPath(paths.filter(Boolean).join('/'));
|
|
981
|
+
}
|
|
982
|
+
function cleanPath(path) {
|
|
983
|
+
// remove double slashes
|
|
984
|
+
return path.replace(/\/{2,}/g, '/');
|
|
985
|
+
}
|
|
986
|
+
function trimPathLeft(path) {
|
|
987
|
+
return path === '/' ? path : path.replace(/^\/{1,}/, '');
|
|
988
|
+
}
|
|
989
|
+
function trimPathRight(path) {
|
|
990
|
+
return path === '/' ? path : path.replace(/\/{1,}$/, '');
|
|
991
|
+
}
|
|
992
|
+
function trimPath(path) {
|
|
993
|
+
return trimPathRight(trimPathLeft(path));
|
|
994
|
+
}
|
|
995
|
+
function resolvePath(basepath, base, to) {
|
|
996
|
+
base = base.replace(new RegExp("^" + basepath), '/');
|
|
997
|
+
to = to.replace(new RegExp("^" + basepath), '/');
|
|
998
|
+
let baseSegments = parsePathname(base);
|
|
999
|
+
const toSegments = parsePathname(to);
|
|
1000
|
+
toSegments.forEach((toSegment, index) => {
|
|
1001
|
+
if (toSegment.value === '/') {
|
|
1002
|
+
if (!index) {
|
|
1003
|
+
// Leading slash
|
|
1004
|
+
baseSegments = [toSegment];
|
|
1005
|
+
} else if (index === toSegments.length - 1) {
|
|
1006
|
+
// Trailing Slash
|
|
1007
|
+
baseSegments.push(toSegment);
|
|
1008
|
+
} else ;
|
|
1009
|
+
} else if (toSegment.value === '..') {
|
|
1010
|
+
var _last;
|
|
973
1011
|
|
|
974
|
-
|
|
975
|
-
|
|
1012
|
+
// Extra trailing slash? pop it off
|
|
1013
|
+
if (baseSegments.length > 1 && ((_last = last(baseSegments)) == null ? void 0 : _last.value) === '/') {
|
|
1014
|
+
baseSegments.pop();
|
|
1015
|
+
}
|
|
976
1016
|
|
|
977
|
-
|
|
978
|
-
|
|
1017
|
+
baseSegments.pop();
|
|
1018
|
+
} else if (toSegment.value === '.') {
|
|
1019
|
+
return;
|
|
1020
|
+
} else {
|
|
1021
|
+
baseSegments.push(toSegment);
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
const joined = joinPaths([basepath, ...baseSegments.map(d => d.value)]);
|
|
1025
|
+
return cleanPath(joined);
|
|
1026
|
+
}
|
|
1027
|
+
function parsePathname(pathname) {
|
|
1028
|
+
if (!pathname) {
|
|
1029
|
+
return [];
|
|
979
1030
|
}
|
|
980
1031
|
|
|
981
|
-
|
|
982
|
-
|
|
1032
|
+
pathname = cleanPath(pathname);
|
|
1033
|
+
const segments = [];
|
|
1034
|
+
|
|
1035
|
+
if (pathname.slice(0, 1) === '/') {
|
|
1036
|
+
pathname = pathname.substring(1);
|
|
1037
|
+
segments.push({
|
|
1038
|
+
type: 'pathname',
|
|
1039
|
+
value: '/'
|
|
1040
|
+
});
|
|
983
1041
|
}
|
|
984
1042
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
routeId: routeId,
|
|
989
|
-
path: path,
|
|
990
|
-
fullPath: fullPath,
|
|
991
|
-
options: options,
|
|
992
|
-
children,
|
|
993
|
-
addChildren: cb => createRouteConfig(options, cb(childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath)), false, parentId, parentPath)
|
|
994
|
-
};
|
|
995
|
-
};
|
|
996
|
-
const rootRouteId = '__root__';
|
|
997
|
-
// Source
|
|
998
|
-
// Detect if we're in the DOM
|
|
999
|
-
const isDOM$1 = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement); // This is the default history object if none is defined
|
|
1043
|
+
if (!pathname) {
|
|
1044
|
+
return segments;
|
|
1045
|
+
} // Remove empty segments and '.' segments
|
|
1000
1046
|
|
|
1001
|
-
const createDefaultHistory = () => isDOM$1 ? createBrowserHistory() : createMemoryHistory();
|
|
1002
1047
|
|
|
1003
|
-
|
|
1004
|
-
|
|
1048
|
+
const split = pathname.split('/').filter(Boolean);
|
|
1049
|
+
segments.push(...split.map(part => {
|
|
1050
|
+
if (part.startsWith('*')) {
|
|
1051
|
+
return {
|
|
1052
|
+
type: 'wildcard',
|
|
1053
|
+
value: part
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1005
1056
|
|
|
1006
|
-
|
|
1057
|
+
if (part.charAt(0) === ':') {
|
|
1058
|
+
return {
|
|
1059
|
+
type: 'param',
|
|
1060
|
+
value: part
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1007
1063
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1064
|
+
return {
|
|
1065
|
+
type: 'pathname',
|
|
1066
|
+
value: part
|
|
1067
|
+
};
|
|
1068
|
+
}));
|
|
1012
1069
|
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
routesById: {},
|
|
1021
|
-
location: undefined,
|
|
1022
|
-
allRouteInfo: undefined,
|
|
1023
|
-
//
|
|
1024
|
-
navigationPromise: Promise.resolve(),
|
|
1025
|
-
resolveNavigation: () => {},
|
|
1026
|
-
preloadCache: {},
|
|
1027
|
-
state: {
|
|
1028
|
-
status: 'idle',
|
|
1029
|
-
location: null,
|
|
1030
|
-
matches: [],
|
|
1031
|
-
actions: {},
|
|
1032
|
-
loaderData: {},
|
|
1033
|
-
lastUpdated: Date.now()
|
|
1034
|
-
},
|
|
1035
|
-
startedLoadingAt: Date.now(),
|
|
1036
|
-
subscribe: listener => {
|
|
1037
|
-
router.listeners.push(listener);
|
|
1038
|
-
return () => {
|
|
1039
|
-
router.listeners = router.listeners.filter(x => x !== listener);
|
|
1040
|
-
};
|
|
1041
|
-
},
|
|
1042
|
-
getRoute: id => {
|
|
1043
|
-
return router.routesById[id];
|
|
1044
|
-
},
|
|
1045
|
-
notify: () => {
|
|
1046
|
-
router.state = _extends$1({}, router.state);
|
|
1047
|
-
router.listeners.forEach(listener => listener());
|
|
1048
|
-
},
|
|
1049
|
-
mount: () => {
|
|
1050
|
-
const next = router.buildLocation({
|
|
1051
|
-
to: '.',
|
|
1052
|
-
search: true,
|
|
1053
|
-
hash: true
|
|
1054
|
-
}); // If the current location isn't updated, trigger a navigation
|
|
1055
|
-
// to the current location. Otherwise, load the current location.
|
|
1056
|
-
|
|
1057
|
-
if (next.href !== router.location.href) {
|
|
1058
|
-
return router.commitLocation(next, true);
|
|
1059
|
-
} else {
|
|
1060
|
-
return router.loadLocation();
|
|
1061
|
-
}
|
|
1062
|
-
},
|
|
1063
|
-
update: opts => {
|
|
1064
|
-
Object.assign(router.options, opts);
|
|
1065
|
-
const {
|
|
1066
|
-
basepath,
|
|
1067
|
-
routeConfig
|
|
1068
|
-
} = router.options;
|
|
1069
|
-
router.basepath = cleanPath("/" + (basepath != null ? basepath : ''));
|
|
1070
|
-
|
|
1071
|
-
if (routeConfig) {
|
|
1072
|
-
router.routesById = {};
|
|
1073
|
-
router.routeTree = router.buildRouteTree(routeConfig);
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
return router;
|
|
1077
|
-
},
|
|
1078
|
-
destroy: history.listen(event => {
|
|
1079
|
-
router.loadLocation(router.parseLocation(event.location, router.location));
|
|
1080
|
-
}),
|
|
1081
|
-
buildRouteTree: rootRouteConfig => {
|
|
1082
|
-
const recurseRoutes = (routeConfigs, parent) => {
|
|
1083
|
-
return routeConfigs.map(routeConfig => {
|
|
1084
|
-
const routeOptions = routeConfig.options;
|
|
1085
|
-
const route = createRoute(routeConfig, routeOptions, parent, router); // {
|
|
1086
|
-
// pendingMs: routeOptions.pendingMs ?? router.defaultPendingMs,
|
|
1087
|
-
// pendingMinMs: routeOptions.pendingMinMs ?? router.defaultPendingMinMs,
|
|
1088
|
-
// }
|
|
1089
|
-
|
|
1090
|
-
const existingRoute = router.routesById[route.routeId];
|
|
1091
|
-
|
|
1092
|
-
if (existingRoute) {
|
|
1093
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1094
|
-
console.warn("Duplicate routes found with id: " + String(route.routeId), router.routesById, route);
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
throw new Error();
|
|
1098
|
-
}
|
|
1099
|
-
router.routesById[route.routeId] = route;
|
|
1100
|
-
const children = routeConfig.children;
|
|
1101
|
-
route.childRoutes = children != null && children.length ? recurseRoutes(children, route) : undefined;
|
|
1102
|
-
return route;
|
|
1103
|
-
});
|
|
1104
|
-
};
|
|
1105
|
-
|
|
1106
|
-
const routes = recurseRoutes([rootRouteConfig]);
|
|
1107
|
-
return routes[0];
|
|
1108
|
-
},
|
|
1109
|
-
parseLocation: (location, previousLocation) => {
|
|
1110
|
-
var _location$hash$split$;
|
|
1111
|
-
|
|
1112
|
-
const parsedSearch = router.options.parseSearch(location.search);
|
|
1113
|
-
return {
|
|
1114
|
-
pathname: location.pathname,
|
|
1115
|
-
searchStr: location.search,
|
|
1116
|
-
search: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
|
|
1117
|
-
hash: (_location$hash$split$ = location.hash.split('#').reverse()[0]) != null ? _location$hash$split$ : '',
|
|
1118
|
-
href: "" + location.pathname + location.search + location.hash,
|
|
1119
|
-
state: location.state,
|
|
1120
|
-
key: location.key
|
|
1121
|
-
};
|
|
1122
|
-
},
|
|
1123
|
-
buildLocation: function buildLocation(dest) {
|
|
1124
|
-
var _dest$from, _router$basepath, _dest$to, _last, _dest$params, _dest$__preSearchFilt, _functionalUpdate, _dest$__preSearchFilt2, _dest$__postSearchFil;
|
|
1125
|
-
|
|
1126
|
-
if (dest === void 0) {
|
|
1127
|
-
dest = {};
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
// const resolvedFrom: Location = {
|
|
1131
|
-
// ...router.location,
|
|
1132
|
-
const fromPathname = dest.fromCurrent ? router.location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.location.pathname;
|
|
1133
|
-
|
|
1134
|
-
let pathname = _resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
|
|
1135
|
-
|
|
1136
|
-
const fromMatches = router.matchRoutes(router.location.pathname, {
|
|
1137
|
-
strictParseParams: true
|
|
1138
|
-
});
|
|
1139
|
-
const toMatches = router.matchRoutes(pathname);
|
|
1140
|
-
|
|
1141
|
-
const prevParams = _extends$1({}, (_last = last(fromMatches)) == null ? void 0 : _last.params);
|
|
1142
|
-
|
|
1143
|
-
let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
|
|
1144
|
-
|
|
1145
|
-
if (nextParams) {
|
|
1146
|
-
toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
|
|
1147
|
-
Object.assign({}, nextParams, fn(nextParams));
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
pathname = interpolatePath(pathname, nextParams != null ? nextParams : {}); // Pre filters first
|
|
1152
|
-
|
|
1153
|
-
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
|
|
1154
|
-
|
|
1155
|
-
const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
|
|
1156
|
-
: dest.search ? (_functionalUpdate = functionalUpdate(dest.search, preFilteredSearch)) != null ? _functionalUpdate : {} // Updater
|
|
1157
|
-
: (_dest$__preSearchFilt2 = dest.__preSearchFilters) != null && _dest$__preSearchFilt2.length ? preFilteredSearch // Preserve resolvedFrom filters
|
|
1158
|
-
: {}; // Then post filters
|
|
1159
|
-
|
|
1160
|
-
const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
|
|
1161
|
-
const search = replaceEqualDeep(router.location.search, postFilteredSearch);
|
|
1162
|
-
const searchStr = router.options.stringifySearch(search);
|
|
1163
|
-
let hash = dest.hash === true ? router.location.hash : functionalUpdate(dest.hash, router.location.hash);
|
|
1164
|
-
hash = hash ? "#" + hash : '';
|
|
1165
|
-
return {
|
|
1166
|
-
pathname,
|
|
1167
|
-
search,
|
|
1168
|
-
searchStr,
|
|
1169
|
-
state: router.location.state,
|
|
1170
|
-
hash,
|
|
1171
|
-
href: "" + pathname + searchStr + hash,
|
|
1172
|
-
key: dest.key
|
|
1173
|
-
};
|
|
1174
|
-
},
|
|
1175
|
-
commitLocation: (next, replace) => {
|
|
1176
|
-
const id = '' + Date.now() + Math.random();
|
|
1177
|
-
if (router.navigateTimeout) clearTimeout(router.navigateTimeout);
|
|
1178
|
-
let nextAction = 'replace';
|
|
1179
|
-
|
|
1180
|
-
if (!replace) {
|
|
1181
|
-
nextAction = 'push';
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
const isSameUrl = router.parseLocation(history.location).href === next.href;
|
|
1070
|
+
if (pathname.slice(-1) === '/') {
|
|
1071
|
+
pathname = pathname.substring(1);
|
|
1072
|
+
segments.push({
|
|
1073
|
+
type: 'pathname',
|
|
1074
|
+
value: '/'
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1185
1077
|
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1078
|
+
return segments;
|
|
1079
|
+
}
|
|
1080
|
+
function interpolatePath(path, params, leaveWildcard) {
|
|
1081
|
+
const interpolatedPathSegments = parsePathname(path);
|
|
1082
|
+
return joinPaths(interpolatedPathSegments.map(segment => {
|
|
1083
|
+
if (segment.value === '*' && !leaveWildcard) {
|
|
1084
|
+
return '';
|
|
1085
|
+
}
|
|
1189
1086
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
pathname: next.pathname,
|
|
1193
|
-
hash: next.hash,
|
|
1194
|
-
search: next.searchStr
|
|
1195
|
-
}, {
|
|
1196
|
-
id
|
|
1197
|
-
});
|
|
1198
|
-
} else {
|
|
1199
|
-
history.push({
|
|
1200
|
-
pathname: next.pathname,
|
|
1201
|
-
hash: next.hash,
|
|
1202
|
-
search: next.searchStr
|
|
1203
|
-
}, {
|
|
1204
|
-
id
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1087
|
+
if (segment.type === 'param') {
|
|
1088
|
+
var _segment$value$substr;
|
|
1207
1089
|
|
|
1208
|
-
|
|
1209
|
-
|
|
1090
|
+
return (_segment$value$substr = params[segment.value.substring(1)]) != null ? _segment$value$substr : '';
|
|
1091
|
+
}
|
|
1210
1092
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
return router.navigationPromise;
|
|
1217
|
-
},
|
|
1218
|
-
buildNext: opts => {
|
|
1219
|
-
const next = router.buildLocation(opts);
|
|
1220
|
-
const matches = router.matchRoutes(next.pathname);
|
|
1093
|
+
return segment.value;
|
|
1094
|
+
}));
|
|
1095
|
+
}
|
|
1096
|
+
function matchPathname(currentPathname, matchLocation) {
|
|
1097
|
+
const pathParams = matchByPath(currentPathname, matchLocation); // const searchMatched = matchBySearch(currentLocation.search, matchLocation)
|
|
1221
1098
|
|
|
1222
|
-
|
|
1223
|
-
|
|
1099
|
+
if (matchLocation.to && !pathParams) {
|
|
1100
|
+
return;
|
|
1101
|
+
} // if (matchLocation.search && !searchMatched) {
|
|
1102
|
+
// return
|
|
1103
|
+
// }
|
|
1224
1104
|
|
|
1225
|
-
return (_match$options$preSea = match.options.preSearchFilters) != null ? _match$options$preSea : [];
|
|
1226
|
-
}).flat().filter(Boolean);
|
|
1227
1105
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1106
|
+
return pathParams != null ? pathParams : {};
|
|
1107
|
+
}
|
|
1108
|
+
function matchByPath(from, matchLocation) {
|
|
1109
|
+
var _matchLocation$to;
|
|
1230
1110
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1111
|
+
const baseSegments = parsePathname(from);
|
|
1112
|
+
const routeSegments = parsePathname("" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*'));
|
|
1113
|
+
const params = {};
|
|
1233
1114
|
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
var _router$state$pending, _router$state$pending2;
|
|
1241
|
-
[...router.state.matches, ...((_router$state$pending = (_router$state$pending2 = router.state.pending) == null ? void 0 : _router$state$pending2.matches) != null ? _router$state$pending : [])].forEach(match => {
|
|
1242
|
-
match.cancel();
|
|
1243
|
-
});
|
|
1244
|
-
},
|
|
1245
|
-
loadLocation: async next => {
|
|
1246
|
-
const id = Math.random();
|
|
1247
|
-
router.startedLoadingAt = id;
|
|
1115
|
+
let isMatch = (() => {
|
|
1116
|
+
for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
|
|
1117
|
+
const baseSegment = baseSegments[i];
|
|
1118
|
+
const routeSegment = routeSegments[i];
|
|
1119
|
+
const isLastRouteSegment = i === routeSegments.length - 1;
|
|
1120
|
+
const isLastBaseSegment = i === baseSegments.length - 1;
|
|
1248
1121
|
|
|
1249
|
-
if (
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1122
|
+
if (routeSegment) {
|
|
1123
|
+
if (routeSegment.type === 'wildcard') {
|
|
1124
|
+
if (baseSegment != null && baseSegment.value) {
|
|
1125
|
+
params['*'] = joinPaths(baseSegments.slice(i).map(d => d.value));
|
|
1126
|
+
return true;
|
|
1127
|
+
}
|
|
1254
1128
|
|
|
1129
|
+
return false;
|
|
1130
|
+
}
|
|
1255
1131
|
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
} = _ref;
|
|
1132
|
+
if (routeSegment.type === 'pathname') {
|
|
1133
|
+
if (routeSegment.value === '/' && !(baseSegment != null && baseSegment.value)) {
|
|
1134
|
+
return true;
|
|
1135
|
+
}
|
|
1261
1136
|
|
|
1262
|
-
|
|
1263
|
-
|
|
1137
|
+
if (baseSegment) {
|
|
1138
|
+
if (matchLocation.caseSensitive) {
|
|
1139
|
+
if (routeSegment.value !== baseSegment.value) {
|
|
1140
|
+
return false;
|
|
1141
|
+
}
|
|
1142
|
+
} else if (routeSegment.value.toLowerCase() !== baseSegment.value.toLowerCase()) {
|
|
1143
|
+
return false;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1264
1146
|
}
|
|
1265
1147
|
|
|
1266
|
-
if (
|
|
1267
|
-
|
|
1148
|
+
if (!baseSegment) {
|
|
1149
|
+
return false;
|
|
1268
1150
|
}
|
|
1269
|
-
});
|
|
1270
|
-
router.removeActionQueue = []; // Cancel any pending matches
|
|
1271
1151
|
|
|
1272
|
-
|
|
1152
|
+
if (routeSegment.type === 'param') {
|
|
1153
|
+
if ((baseSegment == null ? void 0 : baseSegment.value) === '/') {
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1273
1156
|
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
router.state = _extends$1({}, router.state, {
|
|
1278
|
-
pending: {
|
|
1279
|
-
matches: unloadedMatches,
|
|
1280
|
-
location: router.location
|
|
1157
|
+
if (!baseSegment.value.startsWith(':')) {
|
|
1158
|
+
params[routeSegment.value.substring(1)] = baseSegment.value;
|
|
1159
|
+
}
|
|
1281
1160
|
}
|
|
1282
|
-
}
|
|
1283
|
-
router.notify(); // Load the matches
|
|
1284
|
-
|
|
1285
|
-
const matches = await router.loadMatches(unloadedMatches, {
|
|
1286
|
-
withPending: true
|
|
1287
|
-
});
|
|
1161
|
+
}
|
|
1288
1162
|
|
|
1289
|
-
if (
|
|
1290
|
-
|
|
1291
|
-
return router.navigationPromise;
|
|
1163
|
+
if (isLastRouteSegment && !isLastBaseSegment) {
|
|
1164
|
+
return !!matchLocation.fuzzy;
|
|
1292
1165
|
}
|
|
1166
|
+
}
|
|
1293
1167
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
return !matches.find(dd => dd.matchId === d.matchId);
|
|
1297
|
-
}).forEach(d => {
|
|
1298
|
-
d.__.onExit == null ? void 0 : d.__.onExit({
|
|
1299
|
-
params: d.params,
|
|
1300
|
-
search: d.routeSearch
|
|
1301
|
-
});
|
|
1302
|
-
});
|
|
1303
|
-
previousMatches.filter(d => {
|
|
1304
|
-
return matches.find(dd => dd.matchId === d.matchId);
|
|
1305
|
-
}).forEach(d => {
|
|
1306
|
-
d.options.onTransition == null ? void 0 : d.options.onTransition({
|
|
1307
|
-
params: d.params,
|
|
1308
|
-
search: d.routeSearch
|
|
1309
|
-
});
|
|
1310
|
-
});
|
|
1311
|
-
matches.filter(d => {
|
|
1312
|
-
return !previousMatches.find(dd => dd.matchId === d.matchId);
|
|
1313
|
-
}).forEach(d => {
|
|
1314
|
-
d.__.onExit = d.options.onMatch == null ? void 0 : d.options.onMatch({
|
|
1315
|
-
params: d.params,
|
|
1316
|
-
search: d.search
|
|
1317
|
-
});
|
|
1318
|
-
});
|
|
1319
|
-
router.state = _extends$1({}, router.state, {
|
|
1320
|
-
location: router.location,
|
|
1321
|
-
matches,
|
|
1322
|
-
pending: undefined
|
|
1323
|
-
});
|
|
1168
|
+
return true;
|
|
1169
|
+
})();
|
|
1324
1170
|
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
await Promise.all(matches.map(d => d.__.loaderPromise || Promise.resolve()));
|
|
1328
|
-
}
|
|
1171
|
+
return isMatch ? params : undefined;
|
|
1172
|
+
}
|
|
1329
1173
|
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1174
|
+
// @ts-nocheck
|
|
1175
|
+
// 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.
|
|
1176
|
+
function encode(obj, pfx) {
|
|
1177
|
+
var k,
|
|
1178
|
+
i,
|
|
1179
|
+
tmp,
|
|
1180
|
+
str = '';
|
|
1181
|
+
|
|
1182
|
+
for (k in obj) {
|
|
1183
|
+
if ((tmp = obj[k]) !== void 0) {
|
|
1184
|
+
if (Array.isArray(tmp)) {
|
|
1185
|
+
for (i = 0; i < tmp.length; i++) {
|
|
1186
|
+
str && (str += '&');
|
|
1187
|
+
str += encodeURIComponent(k) + '=' + encodeURIComponent(tmp[i]);
|
|
1188
|
+
}
|
|
1189
|
+
} else {
|
|
1190
|
+
str && (str += '&');
|
|
1191
|
+
str += encodeURIComponent(k) + '=' + encodeURIComponent(tmp);
|
|
1333
1192
|
}
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1334
1195
|
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
},
|
|
1338
|
-
cleanPreloadCache: () => {
|
|
1339
|
-
const now = Date.now();
|
|
1340
|
-
Object.keys(router.preloadCache).forEach(matchId => {
|
|
1341
|
-
const entry = router.preloadCache[matchId]; // Don't remove loading matches
|
|
1196
|
+
return (pfx || '') + str;
|
|
1197
|
+
}
|
|
1342
1198
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1199
|
+
function toValue(mix) {
|
|
1200
|
+
if (!mix) return '';
|
|
1201
|
+
var str = decodeURIComponent(mix);
|
|
1202
|
+
if (str === 'false') return false;
|
|
1203
|
+
if (str === 'true') return true;
|
|
1204
|
+
return +str * 0 === 0 ? +str : str;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
function decode(str) {
|
|
1208
|
+
var tmp,
|
|
1209
|
+
k,
|
|
1210
|
+
out = {},
|
|
1211
|
+
arr = str.split('&');
|
|
1346
1212
|
|
|
1213
|
+
while (tmp = arr.shift()) {
|
|
1214
|
+
tmp = tmp.split('=');
|
|
1215
|
+
k = tmp.shift();
|
|
1347
1216
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1217
|
+
if (out[k] !== void 0) {
|
|
1218
|
+
out[k] = [].concat(out[k], toValue(tmp.shift()));
|
|
1219
|
+
} else {
|
|
1220
|
+
out[k] = toValue(tmp.shift());
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1351
1223
|
|
|
1224
|
+
return out;
|
|
1225
|
+
}
|
|
1352
1226
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1227
|
+
function _extends() {
|
|
1228
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
1229
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1230
|
+
var source = arguments[i];
|
|
1231
|
+
|
|
1232
|
+
for (var key in source) {
|
|
1233
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1234
|
+
target[key] = source[key];
|
|
1235
|
+
}
|
|
1359
1236
|
}
|
|
1237
|
+
}
|
|
1360
1238
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
await router.loadMatches(matches, {
|
|
1366
|
-
preload: true,
|
|
1367
|
-
maxAge: loaderOpts.maxAge
|
|
1368
|
-
});
|
|
1369
|
-
return matches;
|
|
1370
|
-
},
|
|
1371
|
-
matchRoutes: (pathname, opts) => {
|
|
1372
|
-
var _router$state$pending3, _router$state$pending4;
|
|
1239
|
+
return target;
|
|
1240
|
+
};
|
|
1241
|
+
return _extends.apply(this, arguments);
|
|
1242
|
+
}
|
|
1373
1243
|
|
|
1374
|
-
|
|
1375
|
-
|
|
1244
|
+
function createRoute(routeConfig, options, parent, router) {
|
|
1245
|
+
const {
|
|
1246
|
+
id,
|
|
1247
|
+
routeId,
|
|
1248
|
+
path: routePath,
|
|
1249
|
+
fullPath
|
|
1250
|
+
} = routeConfig;
|
|
1376
1251
|
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1252
|
+
const action = router.state.actions[id] || (() => {
|
|
1253
|
+
router.state.actions[id] = {
|
|
1254
|
+
pending: [],
|
|
1255
|
+
submit: async (submission, actionOpts) => {
|
|
1256
|
+
var _actionOpts$invalidat;
|
|
1380
1257
|
|
|
1381
|
-
|
|
1258
|
+
if (!route) {
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1382
1261
|
|
|
1383
|
-
|
|
1384
|
-
|
|
1262
|
+
const invalidate = (_actionOpts$invalidat = actionOpts == null ? void 0 : actionOpts.invalidate) != null ? _actionOpts$invalidat : true;
|
|
1263
|
+
const actionState = {
|
|
1264
|
+
submittedAt: Date.now(),
|
|
1265
|
+
status: 'pending',
|
|
1266
|
+
submission
|
|
1267
|
+
};
|
|
1268
|
+
action.current = actionState;
|
|
1269
|
+
action.latest = actionState;
|
|
1270
|
+
action.pending.push(actionState);
|
|
1271
|
+
router.state = _extends({}, router.state, {
|
|
1272
|
+
currentAction: actionState,
|
|
1273
|
+
latestAction: actionState
|
|
1274
|
+
});
|
|
1275
|
+
router.notify();
|
|
1385
1276
|
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
let foundRoutes = [];
|
|
1277
|
+
try {
|
|
1278
|
+
const res = await (route.options.action == null ? void 0 : route.options.action(submission));
|
|
1279
|
+
actionState.data = res;
|
|
1390
1280
|
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1281
|
+
if (invalidate) {
|
|
1282
|
+
router.invalidateRoute({
|
|
1283
|
+
to: '.',
|
|
1284
|
+
fromCurrent: true
|
|
1285
|
+
});
|
|
1286
|
+
await router.reload();
|
|
1287
|
+
}
|
|
1394
1288
|
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1289
|
+
actionState.status = 'success';
|
|
1290
|
+
return res;
|
|
1291
|
+
} catch (err) {
|
|
1292
|
+
console.error(err);
|
|
1293
|
+
actionState.error = err;
|
|
1294
|
+
actionState.status = 'error';
|
|
1295
|
+
} finally {
|
|
1296
|
+
action.pending = action.pending.filter(d => d !== actionState);
|
|
1297
|
+
router.removeActionQueue.push({
|
|
1298
|
+
action,
|
|
1299
|
+
actionState
|
|
1300
|
+
});
|
|
1301
|
+
router.notify();
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
return router.state.actions[id];
|
|
1306
|
+
})();
|
|
1307
|
+
|
|
1308
|
+
let route = {
|
|
1309
|
+
routeId: id,
|
|
1310
|
+
routeRouteId: routeId,
|
|
1311
|
+
routePath,
|
|
1312
|
+
fullPath,
|
|
1313
|
+
options,
|
|
1314
|
+
router,
|
|
1315
|
+
childRoutes: undefined,
|
|
1316
|
+
parentRoute: parent,
|
|
1317
|
+
action,
|
|
1318
|
+
buildLink: options => {
|
|
1319
|
+
return router.buildLink(_extends({}, options, {
|
|
1320
|
+
from: fullPath
|
|
1321
|
+
}));
|
|
1322
|
+
},
|
|
1323
|
+
navigate: options => {
|
|
1324
|
+
return router.navigate(_extends({}, options, {
|
|
1325
|
+
from: fullPath
|
|
1326
|
+
}));
|
|
1327
|
+
},
|
|
1328
|
+
matchRoute: (matchLocation, opts) => {
|
|
1329
|
+
return router.matchRoute(_extends({}, matchLocation, {
|
|
1330
|
+
from: fullPath
|
|
1331
|
+
}), opts);
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
router.options.createRoute == null ? void 0 : router.options.createRoute({
|
|
1335
|
+
router,
|
|
1336
|
+
route
|
|
1337
|
+
});
|
|
1338
|
+
return route;
|
|
1339
|
+
}
|
|
1340
|
+
function cascadeLoaderData(matches) {
|
|
1341
|
+
matches.forEach((match, index) => {
|
|
1342
|
+
const parent = matches[index - 1];
|
|
1343
|
+
|
|
1344
|
+
if (parent) {
|
|
1345
|
+
match.loaderData = replaceEqualDeep(match.loaderData, _extends({}, parent.loaderData, match.routeLoaderData));
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1398
1349
|
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
});
|
|
1350
|
+
const rootRouteId = '__root__';
|
|
1351
|
+
const createRouteConfig = function createRouteConfig(options, children, isRoot, parentId, parentPath) {
|
|
1352
|
+
if (options === void 0) {
|
|
1353
|
+
options = {};
|
|
1354
|
+
}
|
|
1405
1355
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1356
|
+
if (isRoot === void 0) {
|
|
1357
|
+
isRoot = true;
|
|
1358
|
+
}
|
|
1408
1359
|
|
|
1409
|
-
|
|
1410
|
-
|
|
1360
|
+
if (isRoot) {
|
|
1361
|
+
options.path = rootRouteId;
|
|
1362
|
+
} // Strip the root from parentIds
|
|
1411
1363
|
|
|
1412
|
-
parsedParams = (_route$options$parseP = route.options.parseParams == null ? void 0 : route.options.parseParams(matchParams)) != null ? _route$options$parseP : matchParams;
|
|
1413
|
-
} catch (err) {
|
|
1414
|
-
if (opts != null && opts.strictParseParams) {
|
|
1415
|
-
throw err;
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
1364
|
|
|
1419
|
-
|
|
1420
|
-
|
|
1365
|
+
if (parentId === rootRouteId) {
|
|
1366
|
+
parentId = '';
|
|
1367
|
+
}
|
|
1421
1368
|
|
|
1422
|
-
|
|
1423
|
-
foundRoutes = [...parentRoutes, route];
|
|
1424
|
-
}
|
|
1369
|
+
let path = isRoot ? rootRouteId : options.path; // If the path is anything other than an index path, trim it up
|
|
1425
1370
|
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
};
|
|
1371
|
+
if (path && path !== '/') {
|
|
1372
|
+
path = trimPath(path);
|
|
1373
|
+
}
|
|
1430
1374
|
|
|
1431
|
-
|
|
1375
|
+
const routeId = path || options.id;
|
|
1376
|
+
let id = joinPaths([parentId, routeId]);
|
|
1432
1377
|
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1378
|
+
if (path === rootRouteId) {
|
|
1379
|
+
path = '/';
|
|
1380
|
+
}
|
|
1436
1381
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1382
|
+
if (id !== rootRouteId) {
|
|
1383
|
+
id = joinPaths(['/', id]);
|
|
1384
|
+
}
|
|
1439
1385
|
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1386
|
+
const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parentPath, path]));
|
|
1387
|
+
return {
|
|
1388
|
+
id: id,
|
|
1389
|
+
routeId: routeId,
|
|
1390
|
+
path: path,
|
|
1391
|
+
fullPath: fullPath,
|
|
1392
|
+
options: options,
|
|
1393
|
+
children,
|
|
1394
|
+
createChildren: cb => createRouteConfig(options, cb(childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath)), false, parentId, parentPath),
|
|
1395
|
+
addChildren: children => createRouteConfig(options, children, false, parentId, parentPath),
|
|
1396
|
+
createRoute: childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath)
|
|
1397
|
+
};
|
|
1398
|
+
};
|
|
1450
1399
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1400
|
+
const elementTypes = ['element', 'errorElement', 'catchElement', 'pendingElement'];
|
|
1401
|
+
function createRouteMatch(router, route, opts) {
|
|
1402
|
+
const routeMatch = _extends({}, route, opts, {
|
|
1403
|
+
router,
|
|
1404
|
+
routeSearch: {},
|
|
1405
|
+
search: {},
|
|
1406
|
+
childMatches: [],
|
|
1407
|
+
status: 'idle',
|
|
1408
|
+
routeLoaderData: {},
|
|
1409
|
+
loaderData: {},
|
|
1410
|
+
isPending: false,
|
|
1411
|
+
isFetching: false,
|
|
1412
|
+
isInvalid: false,
|
|
1413
|
+
getIsInvalid: () => {
|
|
1414
|
+
var _ref, _routeMatch$options$l;
|
|
1455
1415
|
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
return
|
|
1416
|
+
const now = Date.now();
|
|
1417
|
+
const maxAge = (_ref = (_routeMatch$options$l = routeMatch.options.loaderMaxAge) != null ? _routeMatch$options$l : router.options.defaultLoaderMaxAge) != null ? _ref : 0;
|
|
1418
|
+
return routeMatch.isInvalid || routeMatch.updatedAt + maxAge < now;
|
|
1459
1419
|
},
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1420
|
+
__: {
|
|
1421
|
+
abortController: new AbortController(),
|
|
1422
|
+
latestId: '',
|
|
1423
|
+
resolve: () => {},
|
|
1424
|
+
notify: () => {
|
|
1425
|
+
routeMatch.__.resolve();
|
|
1464
1426
|
|
|
1427
|
+
routeMatch.router.notify();
|
|
1428
|
+
},
|
|
1429
|
+
startPending: () => {
|
|
1430
|
+
var _routeMatch$options$p, _routeMatch$options$p2;
|
|
1465
1431
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
maxAge: loaderOpts == null ? void 0 : loaderOpts.maxAge,
|
|
1469
|
-
match
|
|
1470
|
-
};
|
|
1471
|
-
} // If the match is invalid, errored or idle, trigger it to load
|
|
1432
|
+
const pendingMs = (_routeMatch$options$p = routeMatch.options.pendingMs) != null ? _routeMatch$options$p : router.options.defaultPendingMs;
|
|
1433
|
+
const pendingMinMs = (_routeMatch$options$p2 = routeMatch.options.pendingMinMs) != null ? _routeMatch$options$p2 : router.options.defaultPendingMinMs;
|
|
1472
1434
|
|
|
1435
|
+
if (routeMatch.__.pendingTimeout || routeMatch.status !== 'loading' || typeof pendingMs === 'undefined') {
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1473
1438
|
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
} // If requested, start the pending timers
|
|
1439
|
+
routeMatch.__.pendingTimeout = setTimeout(() => {
|
|
1440
|
+
routeMatch.isPending = true;
|
|
1477
1441
|
|
|
1442
|
+
routeMatch.__.resolve();
|
|
1478
1443
|
|
|
1479
|
-
|
|
1480
|
-
|
|
1444
|
+
if (typeof pendingMinMs !== 'undefined') {
|
|
1445
|
+
routeMatch.__.pendingMinPromise = new Promise(r => routeMatch.__.pendingMinTimeout = setTimeout(r, pendingMinMs));
|
|
1446
|
+
}
|
|
1447
|
+
}, pendingMs);
|
|
1448
|
+
},
|
|
1449
|
+
cancelPending: () => {
|
|
1450
|
+
routeMatch.isPending = false;
|
|
1451
|
+
clearTimeout(routeMatch.__.pendingTimeout);
|
|
1452
|
+
clearTimeout(routeMatch.__.pendingMinTimeout);
|
|
1453
|
+
delete routeMatch.__.pendingMinPromise;
|
|
1454
|
+
},
|
|
1455
|
+
// setParentMatch: (parentMatch?: RouteMatch) => {
|
|
1456
|
+
// routeMatch.parentMatch = parentMatch
|
|
1457
|
+
// },
|
|
1458
|
+
// addChildMatch: (childMatch: RouteMatch) => {
|
|
1459
|
+
// if (
|
|
1460
|
+
// routeMatch.childMatches.find((d) => d.matchId === childMatch.matchId)
|
|
1461
|
+
// ) {
|
|
1462
|
+
// return
|
|
1463
|
+
// }
|
|
1464
|
+
// routeMatch.childMatches.push(childMatch)
|
|
1465
|
+
// },
|
|
1466
|
+
validate: () => {
|
|
1467
|
+
var _routeMatch$parentMat, _routeMatch$parentMat2;
|
|
1481
1468
|
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
router.notify();
|
|
1485
|
-
await Promise.all(matchPromises);
|
|
1486
|
-
return resolvedMatches;
|
|
1487
|
-
},
|
|
1488
|
-
invalidateRoute: opts => {
|
|
1489
|
-
var _router$state$pending5, _router$state$pending6;
|
|
1469
|
+
// Validate the search params and stabilize them
|
|
1470
|
+
const parentSearch = (_routeMatch$parentMat = (_routeMatch$parentMat2 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat2.search) != null ? _routeMatch$parentMat : router.location.search;
|
|
1490
1471
|
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
match.isInvalid = true;
|
|
1496
|
-
}
|
|
1497
|
-
});
|
|
1498
|
-
},
|
|
1499
|
-
reload: () => router._navigate({
|
|
1500
|
-
fromCurrent: true,
|
|
1501
|
-
replace: true,
|
|
1502
|
-
search: true
|
|
1503
|
-
}),
|
|
1504
|
-
resolvePath: (from, path) => {
|
|
1505
|
-
return _resolvePath(router.basepath, from, cleanPath(path));
|
|
1506
|
-
},
|
|
1507
|
-
matchRoute: (location, opts) => {
|
|
1508
|
-
var _location$from;
|
|
1472
|
+
try {
|
|
1473
|
+
const prevSearch = routeMatch.routeSearch;
|
|
1474
|
+
const validator = typeof routeMatch.options.validateSearch === 'object' ? routeMatch.options.validateSearch.parse : routeMatch.options.validateSearch;
|
|
1475
|
+
let nextSearch = replaceEqualDeep(prevSearch, validator == null ? void 0 : validator(parentSearch)); // Invalidate route matches when search param stability changes
|
|
1509
1476
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
});
|
|
1514
|
-
const next = router.buildNext(location);
|
|
1477
|
+
if (prevSearch !== nextSearch) {
|
|
1478
|
+
routeMatch.isInvalid = true;
|
|
1479
|
+
}
|
|
1515
1480
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1481
|
+
routeMatch.routeSearch = nextSearch;
|
|
1482
|
+
routeMatch.search = replaceEqualDeep(parentSearch, _extends({}, parentSearch, nextSearch));
|
|
1483
|
+
} catch (err) {
|
|
1484
|
+
console.error(err);
|
|
1485
|
+
const error = new Error('Invalid search params found', {
|
|
1486
|
+
cause: err
|
|
1487
|
+
});
|
|
1488
|
+
error.code = 'INVALID_SEARCH_PARAMS';
|
|
1489
|
+
routeMatch.status = 'error';
|
|
1490
|
+
routeMatch.error = error; // Do not proceed with loading the route
|
|
1518
1491
|
|
|
1519
|
-
|
|
1520
|
-
return false;
|
|
1492
|
+
return;
|
|
1521
1493
|
}
|
|
1522
|
-
|
|
1523
|
-
return !!matchPathname(router.state.pending.location.pathname, _extends$1({}, opts, {
|
|
1524
|
-
to: next.pathname
|
|
1525
|
-
}));
|
|
1526
1494
|
}
|
|
1527
|
-
|
|
1528
|
-
return !!matchPathname(router.state.location.pathname, _extends$1({}, opts, {
|
|
1529
|
-
to: next.pathname
|
|
1530
|
-
}));
|
|
1531
|
-
},
|
|
1532
|
-
_navigate: location => {
|
|
1533
|
-
const next = router.buildNext(location);
|
|
1534
|
-
return router.commitLocation(next, location.replace);
|
|
1535
|
-
},
|
|
1536
|
-
navigate: async _ref2 => {
|
|
1537
|
-
let {
|
|
1538
|
-
from,
|
|
1539
|
-
to = '.',
|
|
1540
|
-
search,
|
|
1541
|
-
hash,
|
|
1542
|
-
replace
|
|
1543
|
-
} = _ref2;
|
|
1544
|
-
// If this link simply reloads the current route,
|
|
1545
|
-
// make sure it has a new key so it will trigger a data refresh
|
|
1546
|
-
// If this `to` is a valid external URL, return
|
|
1547
|
-
// null for LinkUtils
|
|
1548
|
-
const toString = String(to);
|
|
1549
|
-
const fromString = String(from);
|
|
1550
|
-
let isExternal;
|
|
1551
|
-
|
|
1552
|
-
try {
|
|
1553
|
-
new URL("" + toString);
|
|
1554
|
-
isExternal = true;
|
|
1555
|
-
} catch (e) {}
|
|
1556
|
-
|
|
1557
|
-
invariant(!isExternal, 'Attempting to navigate to external url with router.navigate!');
|
|
1558
|
-
return router._navigate({
|
|
1559
|
-
from: fromString,
|
|
1560
|
-
to: toString,
|
|
1561
|
-
search,
|
|
1562
|
-
hash
|
|
1563
|
-
});
|
|
1564
1495
|
},
|
|
1565
|
-
|
|
1566
|
-
var
|
|
1567
|
-
|
|
1568
|
-
let {
|
|
1569
|
-
from,
|
|
1570
|
-
to = '.',
|
|
1571
|
-
search,
|
|
1572
|
-
params,
|
|
1573
|
-
hash,
|
|
1574
|
-
target,
|
|
1575
|
-
replace,
|
|
1576
|
-
activeOptions,
|
|
1577
|
-
preload,
|
|
1578
|
-
preloadMaxAge: userPreloadMaxAge,
|
|
1579
|
-
preloadDelay: userPreloadDelay,
|
|
1580
|
-
disabled
|
|
1581
|
-
} = _ref3;
|
|
1582
|
-
|
|
1583
|
-
// If this link simply reloads the current route,
|
|
1584
|
-
// make sure it has a new key so it will trigger a data refresh
|
|
1585
|
-
// If this `to` is a valid external URL, return
|
|
1586
|
-
// null for LinkUtils
|
|
1587
|
-
try {
|
|
1588
|
-
new URL("" + to);
|
|
1589
|
-
return {
|
|
1590
|
-
type: 'external',
|
|
1591
|
-
href: to
|
|
1592
|
-
};
|
|
1593
|
-
} catch (e) {}
|
|
1496
|
+
cancel: () => {
|
|
1497
|
+
var _routeMatch$__$abortC;
|
|
1594
1498
|
|
|
1595
|
-
|
|
1596
|
-
from,
|
|
1597
|
-
to,
|
|
1598
|
-
search,
|
|
1599
|
-
params,
|
|
1600
|
-
hash,
|
|
1601
|
-
replace
|
|
1602
|
-
};
|
|
1603
|
-
const next = router.buildNext(nextOpts);
|
|
1604
|
-
preload = (_preload = preload) != null ? _preload : router.options.defaultLinkPreload;
|
|
1605
|
-
const preloadMaxAge = (_ref4 = userPreloadMaxAge != null ? userPreloadMaxAge : router.options.defaultLinkPreloadMaxAge) != null ? _ref4 : 2000;
|
|
1606
|
-
const preloadDelay = (_ref5 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultLinkPreloadDelay) != null ? _ref5 : 50; // Compare path/hash for matches
|
|
1499
|
+
(_routeMatch$__$abortC = routeMatch.__.abortController) == null ? void 0 : _routeMatch$__$abortC.abort();
|
|
1607
1500
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1501
|
+
routeMatch.__.cancelPending();
|
|
1502
|
+
},
|
|
1503
|
+
invalidate: () => {
|
|
1504
|
+
routeMatch.isInvalid = true;
|
|
1505
|
+
},
|
|
1506
|
+
hasLoaders: () => {
|
|
1507
|
+
return !!(route.options.loader || route.options.import || elementTypes.some(d => typeof route.options[d] === 'function'));
|
|
1508
|
+
},
|
|
1509
|
+
load: async () => {
|
|
1510
|
+
const id = '' + Date.now() + Math.random();
|
|
1511
|
+
routeMatch.__.latestId = id; // If the match was in an error state, set it
|
|
1512
|
+
// to a loading state again. Otherwise, keep it
|
|
1513
|
+
// as loading or resolved
|
|
1613
1514
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1515
|
+
if (routeMatch.status === 'idle') {
|
|
1516
|
+
routeMatch.status = 'loading';
|
|
1517
|
+
} // We started loading the route, so it's no longer invalid
|
|
1616
1518
|
|
|
1617
|
-
const isActive = pathTest && hashTest; // The click handler
|
|
1618
1519
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1520
|
+
routeMatch.isInvalid = false;
|
|
1521
|
+
routeMatch.__.loadPromise = new Promise(async resolve => {
|
|
1522
|
+
// We are now fetching, even if it's in the background of a
|
|
1523
|
+
// resolved state
|
|
1524
|
+
routeMatch.isFetching = true;
|
|
1525
|
+
routeMatch.__.resolve = resolve;
|
|
1622
1526
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
} // All is well? Navigate!)
|
|
1527
|
+
const loaderPromise = (async () => {
|
|
1528
|
+
const importer = routeMatch.options.import; // First, run any importers
|
|
1626
1529
|
|
|
1530
|
+
if (importer) {
|
|
1531
|
+
routeMatch.__.importPromise = importer({
|
|
1532
|
+
params: routeMatch.params // search: routeMatch.search,
|
|
1627
1533
|
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1534
|
+
}).then(imported => {
|
|
1535
|
+
routeMatch.__ = _extends({}, routeMatch.__, imported);
|
|
1536
|
+
});
|
|
1537
|
+
} // Wait for the importer to finish before
|
|
1538
|
+
// attempting to load elements and data
|
|
1631
1539
|
|
|
1632
1540
|
|
|
1633
|
-
|
|
1634
|
-
if (preload && preloadMaxAge > 0) {
|
|
1635
|
-
router.loadRoute(nextOpts, {
|
|
1636
|
-
maxAge: preloadMaxAge
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
|
-
};
|
|
1541
|
+
await routeMatch.__.importPromise; // Next, load the elements and data in parallel
|
|
1640
1542
|
|
|
1641
|
-
|
|
1642
|
-
|
|
1543
|
+
routeMatch.__.elementsPromise = (async () => {
|
|
1544
|
+
// then run all element and data loaders in parallel
|
|
1545
|
+
// For each element type, potentially load it asynchronously
|
|
1546
|
+
await Promise.all(elementTypes.map(async type => {
|
|
1547
|
+
const routeElement = routeMatch.options[type];
|
|
1643
1548
|
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
}
|
|
1549
|
+
if (routeMatch.__[type]) {
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1648
1552
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1553
|
+
if (typeof routeElement === 'function') {
|
|
1554
|
+
const res = await routeElement(routeMatch);
|
|
1555
|
+
routeMatch.__[type] = res;
|
|
1556
|
+
} else {
|
|
1557
|
+
routeMatch.__[type] = routeMatch.options[type];
|
|
1558
|
+
}
|
|
1559
|
+
}));
|
|
1560
|
+
})();
|
|
1657
1561
|
|
|
1658
|
-
|
|
1659
|
-
|
|
1562
|
+
routeMatch.__.dataPromise = Promise.resolve().then(async () => {
|
|
1563
|
+
try {
|
|
1564
|
+
if (routeMatch.options.loader) {
|
|
1565
|
+
const data = await routeMatch.options.loader({
|
|
1566
|
+
params: routeMatch.params,
|
|
1567
|
+
search: routeMatch.routeSearch,
|
|
1568
|
+
signal: routeMatch.__.abortController.signal
|
|
1569
|
+
});
|
|
1570
|
+
|
|
1571
|
+
if (id !== routeMatch.__.latestId) {
|
|
1572
|
+
return routeMatch.__.loaderPromise;
|
|
1573
|
+
}
|
|
1660
1574
|
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
target.preloadTimeout = null;
|
|
1664
|
-
}
|
|
1665
|
-
};
|
|
1575
|
+
routeMatch.routeLoaderData = replaceEqualDeep(routeMatch.routeLoaderData, data);
|
|
1576
|
+
}
|
|
1666
1577
|
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
isActive,
|
|
1675
|
-
disabled
|
|
1676
|
-
};
|
|
1677
|
-
},
|
|
1678
|
-
__experimental__createSnapshot: () => {
|
|
1679
|
-
return _extends$1({}, router.state, {
|
|
1680
|
-
matches: router.state.matches.map(_ref6 => {
|
|
1681
|
-
let {
|
|
1682
|
-
routeLoaderData: loaderData,
|
|
1683
|
-
matchId
|
|
1684
|
-
} = _ref6;
|
|
1685
|
-
return {
|
|
1686
|
-
matchId,
|
|
1687
|
-
loaderData
|
|
1688
|
-
};
|
|
1689
|
-
})
|
|
1690
|
-
});
|
|
1691
|
-
}
|
|
1692
|
-
};
|
|
1693
|
-
router.location = router.parseLocation(history.location); // router.state.location = __experimental__snapshot?.location ?? router.location
|
|
1578
|
+
routeMatch.error = undefined;
|
|
1579
|
+
routeMatch.status = 'success';
|
|
1580
|
+
routeMatch.updatedAt = Date.now();
|
|
1581
|
+
} catch (err) {
|
|
1582
|
+
if (id !== routeMatch.__.latestId) {
|
|
1583
|
+
return routeMatch.__.loaderPromise;
|
|
1584
|
+
}
|
|
1694
1585
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1586
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1587
|
+
console.error(err);
|
|
1588
|
+
}
|
|
1697
1589
|
|
|
1698
|
-
|
|
1590
|
+
routeMatch.error = err;
|
|
1591
|
+
routeMatch.status = 'error';
|
|
1592
|
+
routeMatch.updatedAt = Date.now();
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1699
1595
|
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
function createRoute(routeConfig, options, parent, router) {
|
|
1703
|
-
// const id = (
|
|
1704
|
-
// options.path === rootRouteId
|
|
1705
|
-
// ? rootRouteId
|
|
1706
|
-
// : joinPaths([
|
|
1707
|
-
// parent!.id,
|
|
1708
|
-
// `${options.path?.replace(/(.)\/$/, '$1')}`,
|
|
1709
|
-
// ]).replace(new RegExp(`^${rootRouteId}`), '')
|
|
1710
|
-
// ) as TRouteInfo['id']
|
|
1711
|
-
const {
|
|
1712
|
-
id,
|
|
1713
|
-
routeId,
|
|
1714
|
-
path: routePath,
|
|
1715
|
-
fullPath
|
|
1716
|
-
} = routeConfig;
|
|
1596
|
+
try {
|
|
1597
|
+
await Promise.all([routeMatch.__.elementsPromise, routeMatch.__.dataPromise]);
|
|
1717
1598
|
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
submit: async (submission, actionOpts) => {
|
|
1722
|
-
var _actionOpts$invalidat;
|
|
1599
|
+
if (id !== routeMatch.__.latestId) {
|
|
1600
|
+
return routeMatch.__.loaderPromise;
|
|
1601
|
+
}
|
|
1723
1602
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1603
|
+
if (routeMatch.__.pendingMinPromise) {
|
|
1604
|
+
await routeMatch.__.pendingMinPromise;
|
|
1605
|
+
delete routeMatch.__.pendingMinPromise;
|
|
1606
|
+
}
|
|
1607
|
+
} finally {
|
|
1608
|
+
if (id !== routeMatch.__.latestId) {
|
|
1609
|
+
return routeMatch.__.loaderPromise;
|
|
1610
|
+
}
|
|
1727
1611
|
|
|
1728
|
-
|
|
1729
|
-
const actionState = {
|
|
1730
|
-
submittedAt: Date.now(),
|
|
1731
|
-
status: 'pending',
|
|
1732
|
-
submission
|
|
1733
|
-
};
|
|
1734
|
-
action.current = actionState;
|
|
1735
|
-
action.latest = actionState;
|
|
1736
|
-
action.pending.push(actionState);
|
|
1737
|
-
router.state = _extends$1({}, router.state, {
|
|
1738
|
-
currentAction: actionState,
|
|
1739
|
-
latestAction: actionState
|
|
1740
|
-
});
|
|
1741
|
-
router.notify();
|
|
1612
|
+
routeMatch.__.cancelPending();
|
|
1742
1613
|
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
actionState.data = res;
|
|
1614
|
+
routeMatch.isPending = false;
|
|
1615
|
+
routeMatch.isFetching = false;
|
|
1746
1616
|
|
|
1747
|
-
|
|
1748
|
-
router.invalidateRoute({
|
|
1749
|
-
to: '.',
|
|
1750
|
-
fromCurrent: true
|
|
1751
|
-
});
|
|
1752
|
-
await router.reload();
|
|
1617
|
+
routeMatch.__.notify();
|
|
1753
1618
|
}
|
|
1619
|
+
})();
|
|
1754
1620
|
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
actionState.status = 'error';
|
|
1761
|
-
} finally {
|
|
1762
|
-
action.pending = action.pending.filter(d => d !== actionState);
|
|
1763
|
-
router.removeActionQueue.push({
|
|
1764
|
-
action,
|
|
1765
|
-
actionState
|
|
1766
|
-
});
|
|
1767
|
-
router.notify();
|
|
1621
|
+
routeMatch.__.loaderPromise = loaderPromise;
|
|
1622
|
+
await loaderPromise;
|
|
1623
|
+
|
|
1624
|
+
if (id !== routeMatch.__.latestId) {
|
|
1625
|
+
return routeMatch.__.loaderPromise;
|
|
1768
1626
|
}
|
|
1769
|
-
}
|
|
1770
|
-
};
|
|
1771
|
-
return router.state.actions[id];
|
|
1772
|
-
})();
|
|
1773
1627
|
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1628
|
+
delete routeMatch.__.loaderPromise;
|
|
1629
|
+
});
|
|
1630
|
+
return await routeMatch.__.loadPromise;
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
|
|
1634
|
+
if (!routeMatch.hasLoaders()) {
|
|
1635
|
+
routeMatch.status = 'success';
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
return routeMatch;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
const defaultParseSearch = parseSearchWith(JSON.parse);
|
|
1642
|
+
const defaultStringifySearch = stringifySearchWith(JSON.stringify);
|
|
1643
|
+
function parseSearchWith(parser) {
|
|
1644
|
+
return searchStr => {
|
|
1645
|
+
if (searchStr.substring(0, 1) === '?') {
|
|
1646
|
+
searchStr = searchStr.substring(1);
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
let query = decode(searchStr); // Try to parse any query params that might be json
|
|
1650
|
+
|
|
1651
|
+
for (let key in query) {
|
|
1652
|
+
const value = query[key];
|
|
1653
|
+
|
|
1654
|
+
if (typeof value === 'string') {
|
|
1655
|
+
try {
|
|
1656
|
+
query[key] = parser(value);
|
|
1657
|
+
} catch (err) {//
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1798
1660
|
}
|
|
1661
|
+
|
|
1662
|
+
return query;
|
|
1799
1663
|
};
|
|
1800
|
-
router.options.createRoute == null ? void 0 : router.options.createRoute({
|
|
1801
|
-
router,
|
|
1802
|
-
route
|
|
1803
|
-
});
|
|
1804
|
-
return route;
|
|
1805
1664
|
}
|
|
1806
|
-
function
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
routeSearch: {},
|
|
1810
|
-
search: {},
|
|
1811
|
-
childMatches: [],
|
|
1812
|
-
status: 'idle',
|
|
1813
|
-
routeLoaderData: {},
|
|
1814
|
-
loaderData: {},
|
|
1815
|
-
isPending: false,
|
|
1816
|
-
isFetching: false,
|
|
1817
|
-
isInvalid: false,
|
|
1818
|
-
__: {
|
|
1819
|
-
abortController: new AbortController(),
|
|
1820
|
-
latestId: '',
|
|
1821
|
-
resolve: () => {},
|
|
1822
|
-
notify: () => {
|
|
1823
|
-
routeMatch.__.resolve();
|
|
1824
|
-
|
|
1825
|
-
routeMatch.router.notify();
|
|
1826
|
-
},
|
|
1827
|
-
startPending: () => {
|
|
1828
|
-
var _routeMatch$options$p, _routeMatch$options$p2;
|
|
1665
|
+
function stringifySearchWith(stringify) {
|
|
1666
|
+
return search => {
|
|
1667
|
+
search = _extends({}, search);
|
|
1829
1668
|
|
|
1830
|
-
|
|
1831
|
-
|
|
1669
|
+
if (search) {
|
|
1670
|
+
Object.keys(search).forEach(key => {
|
|
1671
|
+
const val = search[key];
|
|
1832
1672
|
|
|
1833
|
-
if (
|
|
1834
|
-
|
|
1673
|
+
if (typeof val === 'undefined' || val === undefined) {
|
|
1674
|
+
delete search[key];
|
|
1675
|
+
} else if (val && typeof val === 'object' && val !== null) {
|
|
1676
|
+
try {
|
|
1677
|
+
search[key] = stringify(val);
|
|
1678
|
+
} catch (err) {// silent
|
|
1679
|
+
}
|
|
1835
1680
|
}
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1836
1683
|
|
|
1837
|
-
|
|
1838
|
-
|
|
1684
|
+
const searchStr = encode(search).toString();
|
|
1685
|
+
return searchStr ? "?" + searchStr : '';
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1839
1688
|
|
|
1840
|
-
|
|
1689
|
+
var _window$document;
|
|
1690
|
+
// Detect if we're in the DOM
|
|
1691
|
+
const isServer = Boolean(typeof window === 'undefined' || !((_window$document = window.document) != null && _window$document.createElement)); // This is the default history object if none is defined
|
|
1841
1692
|
|
|
1842
|
-
|
|
1843
|
-
routeMatch.__.pendingMinPromise = new Promise(r => routeMatch.__.pendingMinTimeout = setTimeout(r, pendingMinMs));
|
|
1844
|
-
}
|
|
1845
|
-
}, pendingMs);
|
|
1846
|
-
},
|
|
1847
|
-
cancelPending: () => {
|
|
1848
|
-
routeMatch.isPending = false;
|
|
1849
|
-
clearTimeout(routeMatch.__.pendingTimeout);
|
|
1850
|
-
clearTimeout(routeMatch.__.pendingMinTimeout);
|
|
1851
|
-
delete routeMatch.__.pendingMinPromise;
|
|
1852
|
-
},
|
|
1853
|
-
// setParentMatch: (parentMatch?: RouteMatch) => {
|
|
1854
|
-
// routeMatch.parentMatch = parentMatch
|
|
1855
|
-
// },
|
|
1856
|
-
// addChildMatch: (childMatch: RouteMatch) => {
|
|
1857
|
-
// if (
|
|
1858
|
-
// routeMatch.childMatches.find((d) => d.matchId === childMatch.matchId)
|
|
1859
|
-
// ) {
|
|
1860
|
-
// return
|
|
1861
|
-
// }
|
|
1862
|
-
// routeMatch.childMatches.push(childMatch)
|
|
1863
|
-
// },
|
|
1864
|
-
validate: () => {
|
|
1865
|
-
var _routeMatch$parentMat, _routeMatch$parentMat2;
|
|
1693
|
+
const createDefaultHistory = () => !isServer ? createBrowserHistory() : createMemoryHistory();
|
|
1866
1694
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1695
|
+
function createRouter(userOptions) {
|
|
1696
|
+
var _userOptions$stringif, _userOptions$parseSea;
|
|
1869
1697
|
|
|
1870
|
-
|
|
1871
|
-
const prevSearch = routeMatch.routeSearch;
|
|
1872
|
-
let nextSearch = replaceEqualDeep(prevSearch, routeMatch.options.validateSearch == null ? void 0 : routeMatch.options.validateSearch(parentSearch)); // Invalidate route matches when search param stability changes
|
|
1698
|
+
const history = (userOptions == null ? void 0 : userOptions.history) || createDefaultHistory();
|
|
1873
1699
|
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1700
|
+
const originalOptions = _extends({
|
|
1701
|
+
defaultLoaderGcMaxAge: 5 * 60 * 1000,
|
|
1702
|
+
defaultLoaderMaxAge: 0,
|
|
1703
|
+
defaultLinkPreloadDelay: 50
|
|
1704
|
+
}, userOptions, {
|
|
1705
|
+
stringifySearch: (_userOptions$stringif = userOptions == null ? void 0 : userOptions.stringifySearch) != null ? _userOptions$stringif : defaultStringifySearch,
|
|
1706
|
+
parseSearch: (_userOptions$parseSea = userOptions == null ? void 0 : userOptions.parseSearch) != null ? _userOptions$parseSea : defaultParseSearch
|
|
1707
|
+
});
|
|
1877
1708
|
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1709
|
+
let router = {
|
|
1710
|
+
options: originalOptions,
|
|
1711
|
+
listeners: [],
|
|
1712
|
+
removeActionQueue: [],
|
|
1713
|
+
// Resolved after construction
|
|
1714
|
+
basepath: '',
|
|
1715
|
+
routeTree: undefined,
|
|
1716
|
+
routesById: {},
|
|
1717
|
+
location: undefined,
|
|
1718
|
+
allRouteInfo: undefined,
|
|
1719
|
+
//
|
|
1720
|
+
navigationPromise: Promise.resolve(),
|
|
1721
|
+
resolveNavigation: () => {},
|
|
1722
|
+
matchCache: {},
|
|
1723
|
+
state: {
|
|
1724
|
+
status: 'idle',
|
|
1725
|
+
location: null,
|
|
1726
|
+
matches: [],
|
|
1727
|
+
actions: {},
|
|
1728
|
+
loaderData: {},
|
|
1729
|
+
lastUpdated: Date.now(),
|
|
1730
|
+
isFetching: false,
|
|
1731
|
+
isPreloading: false
|
|
1732
|
+
},
|
|
1733
|
+
startedLoadingAt: Date.now(),
|
|
1734
|
+
subscribe: listener => {
|
|
1735
|
+
router.listeners.push(listener);
|
|
1736
|
+
return () => {
|
|
1737
|
+
router.listeners = router.listeners.filter(x => x !== listener);
|
|
1738
|
+
};
|
|
1739
|
+
},
|
|
1740
|
+
getRoute: id => {
|
|
1741
|
+
return router.routesById[id];
|
|
1742
|
+
},
|
|
1743
|
+
notify: () => {
|
|
1744
|
+
router.state = _extends({}, router.state, {
|
|
1745
|
+
isFetching: router.state.status === 'loading' || router.state.matches.some(d => d.isFetching),
|
|
1746
|
+
isPreloading: Object.values(router.matchCache).some(d => d.match.isFetching && !router.state.matches.find(dd => dd.matchId === d.match.matchId))
|
|
1747
|
+
});
|
|
1748
|
+
cascadeLoaderData(router.state.matches);
|
|
1749
|
+
router.listeners.forEach(listener => listener());
|
|
1750
|
+
},
|
|
1751
|
+
mount: () => {
|
|
1752
|
+
const next = router.buildLocation({
|
|
1753
|
+
to: '.',
|
|
1754
|
+
search: true,
|
|
1755
|
+
hash: true
|
|
1756
|
+
}); // If the current location isn't updated, trigger a navigation
|
|
1757
|
+
// to the current location. Otherwise, load the current location.
|
|
1888
1758
|
|
|
1889
|
-
|
|
1890
|
-
|
|
1759
|
+
if (next.href !== router.location.href) {
|
|
1760
|
+
router.commitLocation(next, true);
|
|
1761
|
+
} else {
|
|
1762
|
+
router.loadLocation();
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
const unsub = history.listen(event => {
|
|
1766
|
+
router.loadLocation(router.parseLocation(event.location, router.location));
|
|
1767
|
+
}); // addEventListener does not exist in React Native, but window does
|
|
1768
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1769
|
+
|
|
1770
|
+
if (!isServer && window.addEventListener) {
|
|
1771
|
+
// Listen to visibillitychange and focus
|
|
1772
|
+
window.addEventListener('visibilitychange', router.onFocus, false);
|
|
1773
|
+
window.addEventListener('focus', router.onFocus, false);
|
|
1891
1774
|
}
|
|
1775
|
+
|
|
1776
|
+
return () => {
|
|
1777
|
+
unsub(); // Be sure to unsubscribe if a new handler is set
|
|
1778
|
+
|
|
1779
|
+
window.removeEventListener('visibilitychange', router.onFocus);
|
|
1780
|
+
window.removeEventListener('focus', router.onFocus);
|
|
1781
|
+
};
|
|
1892
1782
|
},
|
|
1893
|
-
|
|
1894
|
-
|
|
1783
|
+
onFocus: () => {
|
|
1784
|
+
router.loadLocation();
|
|
1785
|
+
},
|
|
1786
|
+
update: opts => {
|
|
1787
|
+
Object.assign(router.options, opts);
|
|
1788
|
+
const {
|
|
1789
|
+
basepath,
|
|
1790
|
+
routeConfig
|
|
1791
|
+
} = router.options;
|
|
1792
|
+
router.basepath = cleanPath("/" + (basepath != null ? basepath : ''));
|
|
1895
1793
|
|
|
1896
|
-
(
|
|
1794
|
+
if (routeConfig) {
|
|
1795
|
+
router.routesById = {};
|
|
1796
|
+
router.routeTree = router.buildRouteTree(routeConfig);
|
|
1797
|
+
}
|
|
1897
1798
|
|
|
1898
|
-
|
|
1799
|
+
return router;
|
|
1899
1800
|
},
|
|
1900
|
-
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1801
|
+
buildRouteTree: rootRouteConfig => {
|
|
1802
|
+
const recurseRoutes = (routeConfigs, parent) => {
|
|
1803
|
+
return routeConfigs.map(routeConfig => {
|
|
1804
|
+
const routeOptions = routeConfig.options;
|
|
1805
|
+
const route = createRoute(routeConfig, routeOptions, parent, router); // {
|
|
1806
|
+
// pendingMs: routeOptions.pendingMs ?? router.defaultPendingMs,
|
|
1807
|
+
// pendingMinMs: routeOptions.pendingMinMs ?? router.defaultPendingMinMs,
|
|
1808
|
+
// }
|
|
1905
1809
|
|
|
1906
|
-
|
|
1907
|
-
routeMatch.status = 'loading';
|
|
1908
|
-
} // We started loading the route, so it's no longer invalid
|
|
1810
|
+
const existingRoute = router.routesById[route.routeId];
|
|
1909
1811
|
|
|
1812
|
+
if (existingRoute) {
|
|
1813
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1814
|
+
console.warn("Duplicate routes found with id: " + String(route.routeId), router.routesById, route);
|
|
1815
|
+
}
|
|
1910
1816
|
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1817
|
+
throw new Error();
|
|
1818
|
+
}
|
|
1819
|
+
router.routesById[route.routeId] = route;
|
|
1820
|
+
const children = routeConfig.children;
|
|
1821
|
+
route.childRoutes = children != null && children.length ? recurseRoutes(children, route) : undefined;
|
|
1822
|
+
return route;
|
|
1823
|
+
});
|
|
1824
|
+
};
|
|
1917
1825
|
|
|
1918
|
-
|
|
1919
|
-
|
|
1826
|
+
const routes = recurseRoutes([rootRouteConfig]);
|
|
1827
|
+
return routes[0];
|
|
1828
|
+
},
|
|
1829
|
+
parseLocation: (location, previousLocation) => {
|
|
1830
|
+
var _location$hash$split$;
|
|
1920
1831
|
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1832
|
+
const parsedSearch = router.options.parseSearch(location.search);
|
|
1833
|
+
return {
|
|
1834
|
+
pathname: location.pathname,
|
|
1835
|
+
searchStr: location.search,
|
|
1836
|
+
search: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
|
|
1837
|
+
hash: (_location$hash$split$ = location.hash.split('#').reverse()[0]) != null ? _location$hash$split$ : '',
|
|
1838
|
+
href: "" + location.pathname + location.search + location.hash,
|
|
1839
|
+
state: location.state,
|
|
1840
|
+
key: location.key
|
|
1841
|
+
};
|
|
1842
|
+
},
|
|
1843
|
+
buildLocation: function buildLocation(dest) {
|
|
1844
|
+
var _dest$from, _router$basepath, _dest$to, _last, _dest$params, _dest$__preSearchFilt, _functionalUpdate, _dest$__preSearchFilt2, _dest$__postSearchFil;
|
|
1924
1845
|
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1846
|
+
if (dest === void 0) {
|
|
1847
|
+
dest = {};
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
// const resolvedFrom: Location = {
|
|
1851
|
+
// ...router.location,
|
|
1852
|
+
const fromPathname = dest.fromCurrent ? router.location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.location.pathname;
|
|
1930
1853
|
|
|
1854
|
+
let pathname = resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
|
|
1931
1855
|
|
|
1932
|
-
|
|
1856
|
+
const fromMatches = router.matchRoutes(router.location.pathname, {
|
|
1857
|
+
strictParseParams: true
|
|
1858
|
+
});
|
|
1859
|
+
const toMatches = router.matchRoutes(pathname);
|
|
1860
|
+
|
|
1861
|
+
const prevParams = _extends({}, (_last = last(fromMatches)) == null ? void 0 : _last.params);
|
|
1933
1862
|
|
|
1934
|
-
|
|
1935
|
-
// then run all element and data loaders in parallel
|
|
1936
|
-
// For each element type, potentially load it asynchronously
|
|
1937
|
-
const elementTypes = ['element', 'errorElement', 'catchElement', 'pendingElement'];
|
|
1938
|
-
await Promise.all(elementTypes.map(async type => {
|
|
1939
|
-
const routeElement = routeMatch.options[type];
|
|
1863
|
+
let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
|
|
1940
1864
|
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1865
|
+
if (nextParams) {
|
|
1866
|
+
toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
|
|
1867
|
+
Object.assign({}, nextParams, fn(nextParams));
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1944
1870
|
|
|
1945
|
-
|
|
1946
|
-
const res = await routeElement(routeMatch);
|
|
1947
|
-
routeMatch.__[type] = res;
|
|
1948
|
-
} else {
|
|
1949
|
-
routeMatch.__[type] = routeMatch.options[type];
|
|
1950
|
-
}
|
|
1951
|
-
}));
|
|
1952
|
-
})();
|
|
1871
|
+
pathname = interpolatePath(pathname, nextParams != null ? nextParams : {}); // Pre filters first
|
|
1953
1872
|
|
|
1954
|
-
|
|
1955
|
-
try {
|
|
1956
|
-
const data = await (routeMatch.options.loader == null ? void 0 : routeMatch.options.loader({
|
|
1957
|
-
params: routeMatch.params,
|
|
1958
|
-
search: routeMatch.routeSearch,
|
|
1959
|
-
signal: routeMatch.__.abortController.signal
|
|
1960
|
-
}));
|
|
1873
|
+
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
|
|
1961
1874
|
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1875
|
+
const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
|
|
1876
|
+
: dest.search ? (_functionalUpdate = functionalUpdate(dest.search, preFilteredSearch)) != null ? _functionalUpdate : {} // Updater
|
|
1877
|
+
: (_dest$__preSearchFilt2 = dest.__preSearchFilters) != null && _dest$__preSearchFilt2.length ? preFilteredSearch // Preserve resolvedFrom filters
|
|
1878
|
+
: {}; // Then post filters
|
|
1965
1879
|
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1880
|
+
const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
|
|
1881
|
+
const search = replaceEqualDeep(router.location.search, postFilteredSearch);
|
|
1882
|
+
const searchStr = router.options.stringifySearch(search);
|
|
1883
|
+
let hash = dest.hash === true ? router.location.hash : functionalUpdate(dest.hash, router.location.hash);
|
|
1884
|
+
hash = hash ? "#" + hash : '';
|
|
1885
|
+
return {
|
|
1886
|
+
pathname,
|
|
1887
|
+
search,
|
|
1888
|
+
searchStr,
|
|
1889
|
+
state: router.location.state,
|
|
1890
|
+
hash,
|
|
1891
|
+
href: "" + pathname + searchStr + hash,
|
|
1892
|
+
key: dest.key
|
|
1893
|
+
};
|
|
1894
|
+
},
|
|
1895
|
+
commitLocation: (next, replace) => {
|
|
1896
|
+
const id = '' + Date.now() + Math.random();
|
|
1897
|
+
if (router.navigateTimeout) clearTimeout(router.navigateTimeout);
|
|
1898
|
+
let nextAction = 'replace';
|
|
1974
1899
|
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1900
|
+
if (!replace) {
|
|
1901
|
+
nextAction = 'push';
|
|
1902
|
+
}
|
|
1978
1903
|
|
|
1979
|
-
|
|
1980
|
-
routeMatch.status = 'error';
|
|
1981
|
-
routeMatch.updatedAt = Date.now();
|
|
1982
|
-
}
|
|
1983
|
-
});
|
|
1904
|
+
const isSameUrl = router.parseLocation(history.location).href === next.href;
|
|
1984
1905
|
|
|
1985
|
-
|
|
1986
|
-
|
|
1906
|
+
if (isSameUrl && !next.key) {
|
|
1907
|
+
nextAction = 'replace';
|
|
1908
|
+
}
|
|
1987
1909
|
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1910
|
+
if (nextAction === 'replace') {
|
|
1911
|
+
history.replace({
|
|
1912
|
+
pathname: next.pathname,
|
|
1913
|
+
hash: next.hash,
|
|
1914
|
+
search: next.searchStr
|
|
1915
|
+
}, {
|
|
1916
|
+
id
|
|
1917
|
+
});
|
|
1918
|
+
} else {
|
|
1919
|
+
history.push({
|
|
1920
|
+
pathname: next.pathname,
|
|
1921
|
+
hash: next.hash,
|
|
1922
|
+
search: next.searchStr
|
|
1923
|
+
}, {
|
|
1924
|
+
id
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1991
1927
|
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
delete routeMatch.__.pendingMinPromise;
|
|
1995
|
-
}
|
|
1996
|
-
} finally {
|
|
1997
|
-
if (id !== routeMatch.__.latestId) {
|
|
1998
|
-
return routeMatch.__.loaderPromise;
|
|
1999
|
-
}
|
|
1928
|
+
router.navigationPromise = new Promise(resolve => {
|
|
1929
|
+
const previousNavigationResolve = router.resolveNavigation;
|
|
2000
1930
|
|
|
2001
|
-
|
|
1931
|
+
router.resolveNavigation = () => {
|
|
1932
|
+
previousNavigationResolve();
|
|
1933
|
+
resolve();
|
|
1934
|
+
};
|
|
1935
|
+
});
|
|
1936
|
+
return router.navigationPromise;
|
|
1937
|
+
},
|
|
1938
|
+
buildNext: opts => {
|
|
1939
|
+
const next = router.buildLocation(opts);
|
|
1940
|
+
const matches = router.matchRoutes(next.pathname);
|
|
2002
1941
|
|
|
2003
|
-
|
|
2004
|
-
|
|
1942
|
+
const __preSearchFilters = matches.map(match => {
|
|
1943
|
+
var _match$options$preSea;
|
|
2005
1944
|
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
})();
|
|
1945
|
+
return (_match$options$preSea = match.options.preSearchFilters) != null ? _match$options$preSea : [];
|
|
1946
|
+
}).flat().filter(Boolean);
|
|
2009
1947
|
|
|
2010
|
-
|
|
2011
|
-
|
|
1948
|
+
const __postSearchFilters = matches.map(match => {
|
|
1949
|
+
var _match$options$postSe;
|
|
2012
1950
|
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
}
|
|
1951
|
+
return (_match$options$postSe = match.options.postSearchFilters) != null ? _match$options$postSe : [];
|
|
1952
|
+
}).flat().filter(Boolean);
|
|
2016
1953
|
|
|
2017
|
-
|
|
1954
|
+
return router.buildLocation(_extends({}, opts, {
|
|
1955
|
+
__preSearchFilters,
|
|
1956
|
+
__postSearchFilters
|
|
1957
|
+
}));
|
|
1958
|
+
},
|
|
1959
|
+
cancelMatches: () => {
|
|
1960
|
+
var _router$state$pending, _router$state$pending2;
|
|
1961
|
+
[...router.state.matches, ...((_router$state$pending = (_router$state$pending2 = router.state.pending) == null ? void 0 : _router$state$pending2.matches) != null ? _router$state$pending : [])].forEach(match => {
|
|
1962
|
+
match.cancel();
|
|
2018
1963
|
});
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
1964
|
+
},
|
|
1965
|
+
loadLocation: async next => {
|
|
1966
|
+
const id = Math.random();
|
|
1967
|
+
router.startedLoadingAt = id;
|
|
2022
1968
|
|
|
2023
|
-
|
|
2024
|
-
|
|
1969
|
+
if (next) {
|
|
1970
|
+
// Ingest the new location
|
|
1971
|
+
router.location = next;
|
|
1972
|
+
} // Clear out old actions
|
|
2025
1973
|
|
|
2026
|
-
function cascadeLoaderData(matches) {
|
|
2027
|
-
matches.forEach((match, index) => {
|
|
2028
|
-
const parent = matches[index - 1];
|
|
2029
1974
|
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
}
|
|
1975
|
+
router.removeActionQueue.forEach(_ref => {
|
|
1976
|
+
let {
|
|
1977
|
+
action,
|
|
1978
|
+
actionState
|
|
1979
|
+
} = _ref;
|
|
2035
1980
|
|
|
2036
|
-
|
|
2037
|
-
|
|
1981
|
+
if (router.state.currentAction === actionState) {
|
|
1982
|
+
router.state.currentAction = undefined;
|
|
1983
|
+
}
|
|
2038
1984
|
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
1985
|
+
if (action.current === actionState) {
|
|
1986
|
+
action.current = undefined;
|
|
1987
|
+
}
|
|
1988
|
+
});
|
|
1989
|
+
router.removeActionQueue = []; // Cancel any pending matches
|
|
2044
1990
|
|
|
1991
|
+
router.cancelMatches(); // Match the routes
|
|
2045
1992
|
|
|
2046
|
-
|
|
2047
|
-
|
|
1993
|
+
const matches = router.matchRoutes(location.pathname, {
|
|
1994
|
+
strictParseParams: true
|
|
1995
|
+
});
|
|
1996
|
+
router.state = _extends({}, router.state, {
|
|
1997
|
+
pending: {
|
|
1998
|
+
matches: matches,
|
|
1999
|
+
location: router.location
|
|
2000
|
+
},
|
|
2001
|
+
status: 'loading'
|
|
2002
|
+
});
|
|
2003
|
+
router.notify(); // Load the matches
|
|
2048
2004
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
if (segment.value === '*' && !leaveWildcard) {
|
|
2053
|
-
return '';
|
|
2054
|
-
}
|
|
2005
|
+
await router.loadMatches(matches, {
|
|
2006
|
+
withPending: true
|
|
2007
|
+
});
|
|
2055
2008
|
|
|
2056
|
-
|
|
2057
|
-
|
|
2009
|
+
if (router.startedLoadingAt !== id) {
|
|
2010
|
+
// Ignore side-effects of match loading
|
|
2011
|
+
return router.navigationPromise;
|
|
2012
|
+
}
|
|
2058
2013
|
|
|
2059
|
-
|
|
2060
|
-
|
|
2014
|
+
const previousMatches = router.state.matches;
|
|
2015
|
+
const exiting = [],
|
|
2016
|
+
staying = [];
|
|
2017
|
+
previousMatches.forEach(d => {
|
|
2018
|
+
if (matches.find(dd => dd.matchId === d.matchId)) {
|
|
2019
|
+
staying.push(d);
|
|
2020
|
+
} else {
|
|
2021
|
+
exiting.push(d);
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
const now = Date.now();
|
|
2025
|
+
exiting.forEach(d => {
|
|
2026
|
+
var _ref2, _d$options$loaderGcMa, _ref3, _d$options$loaderMaxA;
|
|
2061
2027
|
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2028
|
+
d.__.onExit == null ? void 0 : d.__.onExit({
|
|
2029
|
+
params: d.params,
|
|
2030
|
+
search: d.routeSearch
|
|
2031
|
+
}); // Clear idle error states when match leaves
|
|
2065
2032
|
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2033
|
+
if (d.status === 'error' && !d.isFetching) {
|
|
2034
|
+
d.status = 'idle';
|
|
2035
|
+
d.error = undefined;
|
|
2036
|
+
}
|
|
2069
2037
|
|
|
2070
|
-
|
|
2071
|
-
throw new Error(message);
|
|
2072
|
-
} catch (_unused) {}
|
|
2073
|
-
}
|
|
2038
|
+
const gc = Math.max((_ref2 = (_d$options$loaderGcMa = d.options.loaderGcMaxAge) != null ? _d$options$loaderGcMa : router.options.defaultLoaderGcMaxAge) != null ? _ref2 : 0, (_ref3 = (_d$options$loaderMaxA = d.options.loaderMaxAge) != null ? _d$options$loaderMaxA : router.options.defaultLoaderMaxAge) != null ? _ref3 : 0);
|
|
2074
2039
|
|
|
2075
|
-
|
|
2076
|
-
|
|
2040
|
+
if (gc > 0) {
|
|
2041
|
+
router.matchCache[d.matchId] = {
|
|
2042
|
+
gc: gc == Infinity ? Number.MAX_SAFE_INTEGER : now + gc,
|
|
2043
|
+
match: d
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2047
|
+
staying.forEach(d => {
|
|
2048
|
+
d.options.onTransition == null ? void 0 : d.options.onTransition({
|
|
2049
|
+
params: d.params,
|
|
2050
|
+
search: d.routeSearch
|
|
2051
|
+
});
|
|
2052
|
+
});
|
|
2053
|
+
const entering = matches.filter(d => {
|
|
2054
|
+
return !previousMatches.find(dd => dd.matchId === d.matchId);
|
|
2055
|
+
});
|
|
2056
|
+
entering.forEach(d => {
|
|
2057
|
+
d.__.onExit = d.options.onMatch == null ? void 0 : d.options.onMatch({
|
|
2058
|
+
params: d.params,
|
|
2059
|
+
search: d.search
|
|
2060
|
+
});
|
|
2061
|
+
});
|
|
2077
2062
|
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2063
|
+
if (matches.some(d => d.status === 'loading')) {
|
|
2064
|
+
router.notify();
|
|
2065
|
+
await Promise.all(matches.map(d => d.__.loaderPromise || Promise.resolve()));
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
if (router.startedLoadingAt !== id) {
|
|
2069
|
+
// Ignore side-effects of match loading
|
|
2070
|
+
return;
|
|
2071
|
+
}
|
|
2081
2072
|
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2073
|
+
router.state = _extends({}, router.state, {
|
|
2074
|
+
location: router.location,
|
|
2075
|
+
matches,
|
|
2076
|
+
pending: undefined,
|
|
2077
|
+
status: 'idle'
|
|
2078
|
+
});
|
|
2079
|
+
router.notify();
|
|
2080
|
+
router.resolveNavigation();
|
|
2081
|
+
},
|
|
2082
|
+
cleanMatchCache: () => {
|
|
2083
|
+
const now = Date.now();
|
|
2084
|
+
Object.keys(router.matchCache).forEach(matchId => {
|
|
2085
|
+
const entry = router.matchCache[matchId]; // Don't remove loading matches
|
|
2086
2086
|
|
|
2087
|
-
|
|
2088
|
-
|
|
2087
|
+
if (entry.match.status === 'loading') {
|
|
2088
|
+
return;
|
|
2089
|
+
} // Do not remove successful matches that are still valid
|
|
2089
2090
|
|
|
2090
|
-
function joinPaths(paths) {
|
|
2091
|
-
return cleanPath(paths.filter(Boolean).join('/'));
|
|
2092
|
-
}
|
|
2093
2091
|
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
}
|
|
2092
|
+
if (entry.gc > 0 && entry.gc > now) {
|
|
2093
|
+
return;
|
|
2094
|
+
} // Everything else gets removed
|
|
2098
2095
|
|
|
2099
|
-
function trimPathLeft(path) {
|
|
2100
|
-
return path === '/' ? path : path.replace(/^\/{1,}/, '');
|
|
2101
|
-
}
|
|
2102
2096
|
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
}
|
|
2097
|
+
delete router.matchCache[matchId];
|
|
2098
|
+
});
|
|
2099
|
+
},
|
|
2100
|
+
loadRoute: async function loadRoute(navigateOpts, loaderOpts) {
|
|
2101
|
+
if (navigateOpts === void 0) {
|
|
2102
|
+
navigateOpts = router.location;
|
|
2103
|
+
}
|
|
2106
2104
|
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2105
|
+
const next = router.buildNext(navigateOpts);
|
|
2106
|
+
const matches = router.matchRoutes(next.pathname, {
|
|
2107
|
+
strictParseParams: true
|
|
2108
|
+
});
|
|
2109
|
+
await router.loadMatches(matches, {
|
|
2110
|
+
preload: true,
|
|
2111
|
+
maxAge: loaderOpts.maxAge
|
|
2112
|
+
});
|
|
2113
|
+
return matches;
|
|
2114
|
+
},
|
|
2115
|
+
matchRoutes: (pathname, opts) => {
|
|
2116
|
+
var _router$state$pending3, _router$state$pending4;
|
|
2110
2117
|
|
|
2111
|
-
|
|
2112
|
-
|
|
2118
|
+
router.cleanMatchCache();
|
|
2119
|
+
const matches = [];
|
|
2113
2120
|
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2121
|
+
if (!router.routeTree) {
|
|
2122
|
+
return matches;
|
|
2123
|
+
}
|
|
2117
2124
|
|
|
2118
|
-
|
|
2119
|
-
for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
|
|
2120
|
-
const baseSegment = baseSegments[i];
|
|
2121
|
-
const routeSegment = routeSegments[i];
|
|
2122
|
-
const isLastRouteSegment = i === routeSegments.length - 1;
|
|
2123
|
-
const isLastBaseSegment = i === baseSegments.length - 1;
|
|
2125
|
+
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 : [])];
|
|
2124
2126
|
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
if (baseSegment != null && baseSegment.value) {
|
|
2128
|
-
params['*'] = joinPaths(baseSegments.slice(i).map(d => d.value));
|
|
2129
|
-
return true;
|
|
2130
|
-
}
|
|
2127
|
+
const recurse = async routes => {
|
|
2128
|
+
var _parentMatch$params, _router$options$filte, _foundRoute$childRout;
|
|
2131
2129
|
|
|
2132
|
-
|
|
2133
|
-
}
|
|
2130
|
+
const parentMatch = last(matches);
|
|
2131
|
+
let params = (_parentMatch$params = parentMatch == null ? void 0 : parentMatch.params) != null ? _parentMatch$params : {};
|
|
2132
|
+
const filteredRoutes = (_router$options$filte = router.options.filterRoutes == null ? void 0 : router.options.filterRoutes(routes)) != null ? _router$options$filte : routes;
|
|
2133
|
+
let foundRoutes = [];
|
|
2134
2134
|
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
}
|
|
2135
|
+
const findMatchInRoutes = (parentRoutes, routes) => {
|
|
2136
|
+
routes.some(route => {
|
|
2137
|
+
var _route$childRoutes, _route$childRoutes2, _route$options$caseSe;
|
|
2139
2138
|
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
if (routeSegment.value !== baseSegment.value) {
|
|
2143
|
-
return false;
|
|
2144
|
-
}
|
|
2145
|
-
} else if (routeSegment.value.toLowerCase() !== baseSegment.value.toLowerCase()) {
|
|
2146
|
-
return false;
|
|
2139
|
+
if (!route.routePath && (_route$childRoutes = route.childRoutes) != null && _route$childRoutes.length) {
|
|
2140
|
+
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
|
|
2147
2141
|
}
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
2142
|
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2143
|
+
const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
|
|
2144
|
+
const matchParams = matchPathname(pathname, {
|
|
2145
|
+
to: route.fullPath,
|
|
2146
|
+
fuzzy,
|
|
2147
|
+
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
2148
|
+
});
|
|
2154
2149
|
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
return false;
|
|
2158
|
-
}
|
|
2150
|
+
if (matchParams) {
|
|
2151
|
+
let parsedParams;
|
|
2159
2152
|
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2153
|
+
try {
|
|
2154
|
+
var _route$options$parseP;
|
|
2165
2155
|
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2156
|
+
parsedParams = (_route$options$parseP = route.options.parseParams == null ? void 0 : route.options.parseParams(matchParams)) != null ? _route$options$parseP : matchParams;
|
|
2157
|
+
} catch (err) {
|
|
2158
|
+
if (opts != null && opts.strictParseParams) {
|
|
2159
|
+
throw err;
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2170
2162
|
|
|
2171
|
-
|
|
2172
|
-
|
|
2163
|
+
params = _extends({}, params, parsedParams);
|
|
2164
|
+
}
|
|
2173
2165
|
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
// matchLocation: MatchLocation,
|
|
2178
|
-
// ) {
|
|
2179
|
-
// return !!(matchLocation.search && matchLocation.search(search))
|
|
2180
|
-
// }
|
|
2166
|
+
if (!!matchParams) {
|
|
2167
|
+
foundRoutes = [...parentRoutes, route];
|
|
2168
|
+
}
|
|
2181
2169
|
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2170
|
+
return !!foundRoutes.length;
|
|
2171
|
+
});
|
|
2172
|
+
return !!foundRoutes.length;
|
|
2173
|
+
};
|
|
2186
2174
|
|
|
2187
|
-
|
|
2188
|
-
const segments = [];
|
|
2175
|
+
findMatchInRoutes([], filteredRoutes);
|
|
2189
2176
|
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
type: 'pathname',
|
|
2194
|
-
value: '/'
|
|
2195
|
-
});
|
|
2196
|
-
}
|
|
2177
|
+
if (!foundRoutes.length) {
|
|
2178
|
+
return;
|
|
2179
|
+
}
|
|
2197
2180
|
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
} // Remove empty segments and '.' segments
|
|
2181
|
+
foundRoutes.forEach(foundRoute => {
|
|
2182
|
+
var _router$matchCache$ma;
|
|
2201
2183
|
|
|
2184
|
+
const interpolatedPath = interpolatePath(foundRoute.routePath, params);
|
|
2185
|
+
const matchId = interpolatePath(foundRoute.routeId, params, true);
|
|
2186
|
+
const match = existingMatches.find(d => d.matchId === matchId) || ((_router$matchCache$ma = router.matchCache[matchId]) == null ? void 0 : _router$matchCache$ma.match) || createRouteMatch(router, foundRoute, {
|
|
2187
|
+
matchId,
|
|
2188
|
+
params,
|
|
2189
|
+
pathname: joinPaths([pathname, interpolatedPath])
|
|
2190
|
+
});
|
|
2191
|
+
matches.push(match);
|
|
2192
|
+
});
|
|
2193
|
+
const foundRoute = last(foundRoutes);
|
|
2202
2194
|
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
return {
|
|
2207
|
-
type: 'wildcard',
|
|
2208
|
-
value: part
|
|
2195
|
+
if ((_foundRoute$childRout = foundRoute.childRoutes) != null && _foundRoute$childRout.length) {
|
|
2196
|
+
recurse(foundRoute.childRoutes);
|
|
2197
|
+
}
|
|
2209
2198
|
};
|
|
2210
|
-
}
|
|
2211
2199
|
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2200
|
+
recurse([router.routeTree]);
|
|
2201
|
+
cascadeLoaderData(matches);
|
|
2202
|
+
return matches;
|
|
2203
|
+
},
|
|
2204
|
+
loadMatches: async (resolvedMatches, loaderOpts) => {
|
|
2205
|
+
const now = Date.now();
|
|
2206
|
+
const matchPromises = resolvedMatches.map(async match => {
|
|
2207
|
+
// Validate the match (loads search params etc)
|
|
2208
|
+
match.__.validate(); // If the match doesn't have a loader, don't attempt to load it
|
|
2218
2209
|
|
|
2219
|
-
return {
|
|
2220
|
-
type: 'pathname',
|
|
2221
|
-
value: part
|
|
2222
|
-
};
|
|
2223
|
-
}));
|
|
2224
2210
|
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
type: 'pathname',
|
|
2229
|
-
value: '/'
|
|
2230
|
-
});
|
|
2231
|
-
}
|
|
2211
|
+
if (!match.hasLoaders()) {
|
|
2212
|
+
return;
|
|
2213
|
+
} // If this is a preload, add it to the preload cache
|
|
2232
2214
|
|
|
2233
|
-
return segments;
|
|
2234
|
-
}
|
|
2235
2215
|
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
toSegments.forEach((toSegment, index) => {
|
|
2242
|
-
if (toSegment.value === '/') {
|
|
2243
|
-
if (!index) {
|
|
2244
|
-
// Leading slash
|
|
2245
|
-
baseSegments = [toSegment];
|
|
2246
|
-
} else if (index === toSegments.length - 1) {
|
|
2247
|
-
// Trailing Slash
|
|
2248
|
-
baseSegments.push(toSegment);
|
|
2249
|
-
} else ;
|
|
2250
|
-
} else if (toSegment.value === '..') {
|
|
2251
|
-
var _last2;
|
|
2216
|
+
if (loaderOpts != null && loaderOpts.preload && (loaderOpts == null ? void 0 : loaderOpts.maxAge) > 0) {
|
|
2217
|
+
// If the match is currently active, don't preload it
|
|
2218
|
+
if (router.state.matches.find(d => d.matchId === match.matchId)) {
|
|
2219
|
+
return;
|
|
2220
|
+
}
|
|
2252
2221
|
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2222
|
+
router.matchCache[match.matchId] = {
|
|
2223
|
+
gc: now + loaderOpts.maxAge,
|
|
2224
|
+
// TODO: Should this use the route's maxAge?
|
|
2225
|
+
match
|
|
2226
|
+
};
|
|
2227
|
+
} // If the match is invalid, errored or idle, trigger it to load
|
|
2257
2228
|
|
|
2258
|
-
baseSegments.pop();
|
|
2259
|
-
} else if (toSegment.value === '.') {
|
|
2260
|
-
return;
|
|
2261
|
-
} else {
|
|
2262
|
-
baseSegments.push(toSegment);
|
|
2263
|
-
}
|
|
2264
|
-
});
|
|
2265
|
-
const joined = joinPaths([basepath, ...baseSegments.map(d => d.value)]);
|
|
2266
|
-
return cleanPath(joined);
|
|
2267
|
-
}
|
|
2268
|
-
function replaceEqualDeep(prev, next) {
|
|
2269
|
-
if (prev === next) {
|
|
2270
|
-
return prev;
|
|
2271
|
-
}
|
|
2272
2229
|
|
|
2273
|
-
|
|
2230
|
+
if (match.status === 'success' && match.getIsInvalid() || match.status === 'error' || match.status === 'idle') {
|
|
2231
|
+
match.load();
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
if (match.status === 'loading') {
|
|
2235
|
+
// If requested, start the pending timers
|
|
2236
|
+
if (loaderOpts != null && loaderOpts.withPending) match.__.startPending(); // Wait for the first sign of activity from the match
|
|
2237
|
+
// This might be completion, error, or a pending state
|
|
2238
|
+
|
|
2239
|
+
await match.__.loadPromise;
|
|
2240
|
+
}
|
|
2241
|
+
});
|
|
2242
|
+
router.notify();
|
|
2243
|
+
await Promise.all(matchPromises);
|
|
2244
|
+
},
|
|
2245
|
+
invalidateRoute: opts => {
|
|
2246
|
+
var _router$state$pending5, _router$state$pending6;
|
|
2274
2247
|
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2248
|
+
const next = router.buildNext(opts);
|
|
2249
|
+
const unloadedMatchIds = router.matchRoutes(next.pathname).map(d => d.matchId);
|
|
2250
|
+
[...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 => {
|
|
2251
|
+
if (unloadedMatchIds.includes(match.matchId)) {
|
|
2252
|
+
match.invalidate();
|
|
2253
|
+
}
|
|
2254
|
+
});
|
|
2255
|
+
},
|
|
2256
|
+
reload: () => router._navigate({
|
|
2257
|
+
fromCurrent: true,
|
|
2258
|
+
replace: true,
|
|
2259
|
+
search: true
|
|
2260
|
+
}),
|
|
2261
|
+
resolvePath: (from, path) => {
|
|
2262
|
+
return resolvePath(router.basepath, from, cleanPath(path));
|
|
2263
|
+
},
|
|
2264
|
+
matchRoute: (location, opts) => {
|
|
2265
|
+
var _location$from;
|
|
2281
2266
|
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2267
|
+
// const location = router.buildNext(opts)
|
|
2268
|
+
location = _extends({}, location, {
|
|
2269
|
+
to: location.to ? router.resolvePath((_location$from = location.from) != null ? _location$from : '', location.to) : undefined
|
|
2270
|
+
});
|
|
2271
|
+
const next = router.buildNext(location);
|
|
2285
2272
|
|
|
2286
|
-
if (
|
|
2287
|
-
|
|
2273
|
+
if (opts != null && opts.pending) {
|
|
2274
|
+
var _router$state$pending7;
|
|
2275
|
+
|
|
2276
|
+
if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
|
|
2277
|
+
return false;
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
|
|
2281
|
+
to: next.pathname
|
|
2282
|
+
}));
|
|
2288
2283
|
}
|
|
2289
|
-
}
|
|
2290
2284
|
|
|
2291
|
-
|
|
2292
|
-
|
|
2285
|
+
return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
|
|
2286
|
+
to: next.pathname
|
|
2287
|
+
}));
|
|
2288
|
+
},
|
|
2289
|
+
_navigate: location => {
|
|
2290
|
+
const next = router.buildNext(location);
|
|
2291
|
+
return router.commitLocation(next, location.replace);
|
|
2292
|
+
},
|
|
2293
|
+
navigate: async _ref4 => {
|
|
2294
|
+
let {
|
|
2295
|
+
from,
|
|
2296
|
+
to = '.',
|
|
2297
|
+
search,
|
|
2298
|
+
hash,
|
|
2299
|
+
replace,
|
|
2300
|
+
params
|
|
2301
|
+
} = _ref4;
|
|
2302
|
+
// If this link simply reloads the current route,
|
|
2303
|
+
// make sure it has a new key so it will trigger a data refresh
|
|
2304
|
+
// If this `to` is a valid external URL, return
|
|
2305
|
+
// null for LinkUtils
|
|
2306
|
+
const toString = String(to);
|
|
2307
|
+
const fromString = String(from);
|
|
2308
|
+
let isExternal;
|
|
2293
2309
|
|
|
2294
|
-
|
|
2295
|
-
|
|
2310
|
+
try {
|
|
2311
|
+
new URL("" + toString);
|
|
2312
|
+
isExternal = true;
|
|
2313
|
+
} catch (e) {}
|
|
2296
2314
|
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2315
|
+
invariant(!isExternal, 'Attempting to navigate to external url with router.navigate!');
|
|
2316
|
+
return router._navigate({
|
|
2317
|
+
from: fromString,
|
|
2318
|
+
to: toString,
|
|
2319
|
+
search,
|
|
2320
|
+
hash,
|
|
2321
|
+
replace,
|
|
2322
|
+
params
|
|
2323
|
+
});
|
|
2324
|
+
},
|
|
2325
|
+
buildLink: _ref5 => {
|
|
2326
|
+
var _preload, _ref6, _ref7, _ref8;
|
|
2301
2327
|
|
|
2328
|
+
let {
|
|
2329
|
+
from,
|
|
2330
|
+
to = '.',
|
|
2331
|
+
search,
|
|
2332
|
+
params,
|
|
2333
|
+
hash,
|
|
2334
|
+
target,
|
|
2335
|
+
replace,
|
|
2336
|
+
activeOptions,
|
|
2337
|
+
preload,
|
|
2338
|
+
preloadMaxAge: userPreloadMaxAge,
|
|
2339
|
+
preloadDelay: userPreloadDelay,
|
|
2340
|
+
disabled
|
|
2341
|
+
} = _ref5;
|
|
2302
2342
|
|
|
2303
|
-
|
|
2343
|
+
// If this link simply reloads the current route,
|
|
2344
|
+
// make sure it has a new key so it will trigger a data refresh
|
|
2345
|
+
// If this `to` is a valid external URL, return
|
|
2346
|
+
// null for LinkUtils
|
|
2347
|
+
try {
|
|
2348
|
+
new URL("" + to);
|
|
2349
|
+
return {
|
|
2350
|
+
type: 'external',
|
|
2351
|
+
href: to
|
|
2352
|
+
};
|
|
2353
|
+
} catch (e) {}
|
|
2304
2354
|
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2355
|
+
const nextOpts = {
|
|
2356
|
+
from,
|
|
2357
|
+
to,
|
|
2358
|
+
search,
|
|
2359
|
+
params,
|
|
2360
|
+
hash,
|
|
2361
|
+
replace
|
|
2362
|
+
};
|
|
2363
|
+
const next = router.buildNext(nextOpts);
|
|
2364
|
+
preload = (_preload = preload) != null ? _preload : router.options.defaultLinkPreload;
|
|
2365
|
+
const preloadMaxAge = (_ref6 = (_ref7 = userPreloadMaxAge != null ? userPreloadMaxAge : router.options.defaultLinkPreloadMaxAge) != null ? _ref7 : router.options.defaultLoaderGcMaxAge) != null ? _ref6 : 0;
|
|
2366
|
+
const preloadDelay = (_ref8 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultLinkPreloadDelay) != null ? _ref8 : 0; // Compare path/hash for matches
|
|
2308
2367
|
|
|
2368
|
+
const pathIsEqual = router.state.location.pathname === next.pathname;
|
|
2369
|
+
const currentPathSplit = router.state.location.pathname.split('/');
|
|
2370
|
+
const nextPathSplit = next.pathname.split('/');
|
|
2371
|
+
const pathIsFuzzyEqual = nextPathSplit.every((d, i) => d === currentPathSplit[i]);
|
|
2372
|
+
const hashIsEqual = router.state.location.hash === next.hash; // Combine the matches based on user options
|
|
2309
2373
|
|
|
2310
|
-
|
|
2374
|
+
const pathTest = activeOptions != null && activeOptions.exact ? pathIsEqual : pathIsFuzzyEqual;
|
|
2375
|
+
const hashTest = activeOptions != null && activeOptions.includeHash ? hashIsEqual : true; // The final "active" test
|
|
2311
2376
|
|
|
2312
|
-
|
|
2313
|
-
return false;
|
|
2314
|
-
} // If constructor does not have an Object-specific method
|
|
2377
|
+
const isActive = pathTest && hashTest; // The click handler
|
|
2315
2378
|
|
|
2379
|
+
const handleClick = e => {
|
|
2380
|
+
if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!target || target === '_self') && e.button === 0) {
|
|
2381
|
+
e.preventDefault();
|
|
2316
2382
|
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2383
|
+
if (pathIsEqual && !search && !hash) {
|
|
2384
|
+
router.invalidateRoute(nextOpts);
|
|
2385
|
+
} // All is well? Navigate!)
|
|
2320
2386
|
|
|
2321
2387
|
|
|
2322
|
-
|
|
2323
|
-
}
|
|
2388
|
+
router._navigate(nextOpts);
|
|
2389
|
+
}
|
|
2390
|
+
}; // The click handler
|
|
2324
2391
|
|
|
2325
|
-
function hasObjectPrototype(o) {
|
|
2326
|
-
return Object.prototype.toString.call(o) === '[object Object]';
|
|
2327
|
-
}
|
|
2328
2392
|
|
|
2329
|
-
const
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2393
|
+
const handleFocus = e => {
|
|
2394
|
+
if (preload && preloadMaxAge > 0) {
|
|
2395
|
+
router.loadRoute(nextOpts, {
|
|
2396
|
+
maxAge: preloadMaxAge
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
2399
|
+
};
|
|
2336
2400
|
|
|
2337
|
-
|
|
2401
|
+
const handleEnter = e => {
|
|
2402
|
+
const target = e.target || {};
|
|
2338
2403
|
|
|
2339
|
-
|
|
2340
|
-
|
|
2404
|
+
if (preload && preloadMaxAge > 0) {
|
|
2405
|
+
if (target.preloadTimeout) {
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2341
2408
|
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2409
|
+
target.preloadTimeout = setTimeout(() => {
|
|
2410
|
+
target.preloadTimeout = null;
|
|
2411
|
+
router.loadRoute(nextOpts, {
|
|
2412
|
+
maxAge: preloadMaxAge
|
|
2413
|
+
});
|
|
2414
|
+
}, preloadDelay);
|
|
2346
2415
|
}
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
|
-
return query;
|
|
2351
|
-
};
|
|
2352
|
-
}
|
|
2353
|
-
function stringifySearchWith(stringify) {
|
|
2354
|
-
return search => {
|
|
2355
|
-
search = _extends$1({}, search);
|
|
2416
|
+
};
|
|
2356
2417
|
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
const val = search[key];
|
|
2418
|
+
const handleLeave = e => {
|
|
2419
|
+
const target = e.target || {};
|
|
2360
2420
|
|
|
2361
|
-
if (
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
try {
|
|
2365
|
-
search[key] = stringify(val);
|
|
2366
|
-
} catch (err) {// silent
|
|
2367
|
-
}
|
|
2421
|
+
if (target.preloadTimeout) {
|
|
2422
|
+
clearTimeout(target.preloadTimeout);
|
|
2423
|
+
target.preloadTimeout = null;
|
|
2368
2424
|
}
|
|
2369
|
-
}
|
|
2370
|
-
}
|
|
2425
|
+
};
|
|
2371
2426
|
|
|
2372
|
-
|
|
2373
|
-
|
|
2427
|
+
return {
|
|
2428
|
+
type: 'internal',
|
|
2429
|
+
next,
|
|
2430
|
+
handleFocus,
|
|
2431
|
+
handleClick,
|
|
2432
|
+
handleEnter,
|
|
2433
|
+
handleLeave,
|
|
2434
|
+
isActive,
|
|
2435
|
+
disabled
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2374
2438
|
};
|
|
2439
|
+
router.location = router.parseLocation(history.location);
|
|
2440
|
+
router.state.location = router.location;
|
|
2441
|
+
router.update(userOptions); // Allow frameworks to hook into the router creation
|
|
2442
|
+
|
|
2443
|
+
router.options.createRouter == null ? void 0 : router.options.createRouter(router);
|
|
2444
|
+
return router;
|
|
2375
2445
|
}
|
|
2376
2446
|
|
|
2377
2447
|
function isCtrlEvent(e) {
|
|
2378
2448
|
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
2379
2449
|
}
|
|
2380
2450
|
|
|
2381
|
-
function last(arr) {
|
|
2382
|
-
return arr[arr.length - 1];
|
|
2383
|
-
}
|
|
2384
|
-
|
|
2385
2451
|
const _excluded = ["type", "children", "target", "activeProps", "inactiveProps", "activeOptions", "disabled", "hash", "search", "params", "to", "preload", "preloadDelay", "preloadMaxAge", "replace", "style", "className", "onClick", "onFocus", "onMouseEnter", "onMouseLeave", "onTouchStart", "onTouchEnd"],
|
|
2386
2452
|
_excluded2 = ["pending", "caseSensitive", "children"],
|
|
2387
2453
|
_excluded3 = ["children", "router"];
|
|
@@ -2451,9 +2517,9 @@ function createReactRouter(opts) {
|
|
|
2451
2517
|
}; // Get the active props
|
|
2452
2518
|
|
|
2453
2519
|
|
|
2454
|
-
const resolvedActiveProps = isActive ? (_functionalUpdate = functionalUpdate(activeProps)) != null ? _functionalUpdate : {} : {}; // Get the inactive props
|
|
2520
|
+
const resolvedActiveProps = isActive ? (_functionalUpdate = functionalUpdate(activeProps, {})) != null ? _functionalUpdate : {} : {}; // Get the inactive props
|
|
2455
2521
|
|
|
2456
|
-
const resolvedInactiveProps = isActive ? {} : (_functionalUpdate2 = functionalUpdate(inactiveProps)) != null ? _functionalUpdate2 : {};
|
|
2522
|
+
const resolvedInactiveProps = isActive ? {} : (_functionalUpdate2 = functionalUpdate(inactiveProps, {})) != null ? _functionalUpdate2 : {};
|
|
2457
2523
|
return _extends$2({}, resolvedActiveProps, resolvedInactiveProps, rest, {
|
|
2458
2524
|
href: disabled ? undefined : next.href,
|
|
2459
2525
|
onClick: composeHandlers([handleClick, onClick]),
|
|
@@ -2491,7 +2557,7 @@ function createReactRouter(opts) {
|
|
|
2491
2557
|
const params = route.matchRoute(rest, {
|
|
2492
2558
|
pending,
|
|
2493
2559
|
caseSensitive
|
|
2494
|
-
});
|
|
2560
|
+
});
|
|
2495
2561
|
|
|
2496
2562
|
if (!params) {
|
|
2497
2563
|
return null;
|
|
@@ -2505,6 +2571,10 @@ function createReactRouter(opts) {
|
|
|
2505
2571
|
const coreRouter = createRouter(_extends$2({}, opts, {
|
|
2506
2572
|
createRouter: router => {
|
|
2507
2573
|
const routerExt = {
|
|
2574
|
+
useState: () => {
|
|
2575
|
+
useRouterSubscription(router);
|
|
2576
|
+
return router.state;
|
|
2577
|
+
},
|
|
2508
2578
|
useRoute: routeId => {
|
|
2509
2579
|
const route = router.getRoute(routeId);
|
|
2510
2580
|
useRouterSubscription(router);
|
|
@@ -2512,6 +2582,7 @@ function createReactRouter(opts) {
|
|
|
2512
2582
|
return route;
|
|
2513
2583
|
},
|
|
2514
2584
|
useMatch: routeId => {
|
|
2585
|
+
useRouterSubscription(router);
|
|
2515
2586
|
invariant(routeId !== rootRouteId, "\"" + rootRouteId + "\" cannot be used with useMatch! Did you mean to useRoute(\"" + rootRouteId + "\")?");
|
|
2516
2587
|
|
|
2517
2588
|
const runtimeMatch = _useMatch();
|
|
@@ -2519,7 +2590,6 @@ function createReactRouter(opts) {
|
|
|
2519
2590
|
const match = router.state.matches.find(d => d.routeId === routeId);
|
|
2520
2591
|
invariant(match, "Could not find a match for route \"" + routeId + "\" being rendered in this component!");
|
|
2521
2592
|
invariant(runtimeMatch.routeId == (match == null ? void 0 : match.routeId), "useMatch('" + (match == null ? void 0 : match.routeId) + "') is being called in a component that is meant to render the '" + runtimeMatch.routeId + "' route. Did you mean to 'useRoute(" + (match == null ? void 0 : match.routeId) + ")' instead?");
|
|
2522
|
-
useRouterSubscription(router);
|
|
2523
2593
|
|
|
2524
2594
|
if (!match) {
|
|
2525
2595
|
invariant('Match not found!');
|
|
@@ -2550,10 +2620,10 @@ function RouterProvider(_ref2) {
|
|
|
2550
2620
|
rest = _objectWithoutPropertiesLoose(_ref2, _excluded3);
|
|
2551
2621
|
|
|
2552
2622
|
router.update(rest);
|
|
2553
|
-
|
|
2623
|
+
useRouterSubscription(router);
|
|
2554
2624
|
useLayoutEffect(() => {
|
|
2555
|
-
router.mount();
|
|
2556
|
-
}, []);
|
|
2625
|
+
return router.mount();
|
|
2626
|
+
}, [router]);
|
|
2557
2627
|
return /*#__PURE__*/React.createElement(routerContext.Provider, {
|
|
2558
2628
|
value: {
|
|
2559
2629
|
router
|
|
@@ -2562,38 +2632,43 @@ function RouterProvider(_ref2) {
|
|
|
2562
2632
|
value: router.state.matches
|
|
2563
2633
|
}, children != null ? children : /*#__PURE__*/React.createElement(Outlet, null)));
|
|
2564
2634
|
}
|
|
2635
|
+
|
|
2565
2636
|
function useRouter() {
|
|
2566
2637
|
const value = React.useContext(routerContext);
|
|
2567
2638
|
warning(!value, 'useRouter must be used inside a <Router> component!');
|
|
2568
2639
|
useRouterSubscription(value.router);
|
|
2569
2640
|
return value.router;
|
|
2570
2641
|
}
|
|
2642
|
+
|
|
2571
2643
|
function useMatches() {
|
|
2572
2644
|
return React.useContext(matchesContext);
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2645
|
+
} // function useParentMatches(): RouteMatch[] {
|
|
2646
|
+
// const router = useRouter()
|
|
2647
|
+
// const match = useMatch()
|
|
2648
|
+
// const matches = router.state.matches
|
|
2649
|
+
// return matches.slice(
|
|
2650
|
+
// 0,
|
|
2651
|
+
// matches.findIndex((d) => d.matchId === match.matchId) - 1,
|
|
2652
|
+
// )
|
|
2653
|
+
// }
|
|
2578
2654
|
|
|
2579
|
-
const matches = router.state.matches;
|
|
2580
|
-
return matches.slice(0, matches.findIndex(d => d.matchId === match.matchId) - 1);
|
|
2581
|
-
}
|
|
2582
2655
|
|
|
2583
2656
|
function _useMatch() {
|
|
2584
2657
|
var _useMatches;
|
|
2585
2658
|
|
|
2586
2659
|
return (_useMatches = useMatches()) == null ? void 0 : _useMatches[0];
|
|
2587
2660
|
}
|
|
2661
|
+
|
|
2588
2662
|
function Outlet() {
|
|
2589
|
-
var
|
|
2663
|
+
var _childMatch$options$c;
|
|
2590
2664
|
|
|
2591
2665
|
const router = useRouter();
|
|
2592
2666
|
const [, ...matches] = useMatches();
|
|
2593
2667
|
const childMatch = matches[0];
|
|
2594
2668
|
if (!childMatch) return null;
|
|
2595
|
-
|
|
2596
|
-
|
|
2669
|
+
|
|
2670
|
+
const element = (() => {
|
|
2671
|
+
var _childMatch$__$errorE, _ref4;
|
|
2597
2672
|
|
|
2598
2673
|
if (!childMatch) {
|
|
2599
2674
|
return null;
|
|
@@ -2610,7 +2685,7 @@ function Outlet() {
|
|
|
2610
2685
|
throw childMatch.error;
|
|
2611
2686
|
}
|
|
2612
2687
|
|
|
2613
|
-
return /*#__PURE__*/React.createElement(
|
|
2688
|
+
return /*#__PURE__*/React.createElement(DefaultErrorBoundary, {
|
|
2614
2689
|
error: childMatch.error
|
|
2615
2690
|
});
|
|
2616
2691
|
}
|
|
@@ -2622,17 +2697,18 @@ function Outlet() {
|
|
|
2622
2697
|
const pendingElement = (_childMatch$__$pendin = childMatch.__.pendingElement) != null ? _childMatch$__$pendin : router.options.defaultPendingElement;
|
|
2623
2698
|
|
|
2624
2699
|
if (childMatch.options.pendingMs || pendingElement) {
|
|
2625
|
-
var
|
|
2700
|
+
var _ref3;
|
|
2626
2701
|
|
|
2627
|
-
return (
|
|
2702
|
+
return (_ref3 = pendingElement) != null ? _ref3 : null;
|
|
2628
2703
|
}
|
|
2629
2704
|
}
|
|
2630
2705
|
|
|
2631
2706
|
return null;
|
|
2632
2707
|
}
|
|
2633
2708
|
|
|
2634
|
-
return (
|
|
2635
|
-
})()
|
|
2709
|
+
return (_ref4 = childMatch.__.element) != null ? _ref4 : router.options.defaultElement;
|
|
2710
|
+
})();
|
|
2711
|
+
|
|
2636
2712
|
const catchElement = (_childMatch$options$c = childMatch == null ? void 0 : childMatch.options.catchElement) != null ? _childMatch$options$c : router.options.defaultCatchElement;
|
|
2637
2713
|
return /*#__PURE__*/React.createElement(MatchesProvider, {
|
|
2638
2714
|
value: matches,
|
|
@@ -2668,7 +2744,7 @@ class CatchBoundary extends React.Component {
|
|
|
2668
2744
|
render() {
|
|
2669
2745
|
var _this$props$catchElem;
|
|
2670
2746
|
|
|
2671
|
-
const catchElement = (_this$props$catchElem = this.props.catchElement) != null ? _this$props$catchElem :
|
|
2747
|
+
const catchElement = (_this$props$catchElem = this.props.catchElement) != null ? _this$props$catchElem : DefaultErrorBoundary;
|
|
2672
2748
|
|
|
2673
2749
|
if (this.state.error) {
|
|
2674
2750
|
return typeof catchElement === 'function' ? catchElement(this.state) : catchElement;
|
|
@@ -2679,10 +2755,10 @@ class CatchBoundary extends React.Component {
|
|
|
2679
2755
|
|
|
2680
2756
|
}
|
|
2681
2757
|
|
|
2682
|
-
function
|
|
2758
|
+
function DefaultErrorBoundary(_ref5) {
|
|
2683
2759
|
let {
|
|
2684
2760
|
error
|
|
2685
|
-
} =
|
|
2761
|
+
} = _ref5;
|
|
2686
2762
|
return /*#__PURE__*/React.createElement("div", {
|
|
2687
2763
|
style: {
|
|
2688
2764
|
padding: '.5rem',
|
|
@@ -2716,7 +2792,7 @@ function DefaultCatchBoundary(_ref6) {
|
|
|
2716
2792
|
opacity: 0.5
|
|
2717
2793
|
}
|
|
2718
2794
|
}, "If you are the owner of this website, it's highly recommended that you configure your own custom Catch/Error boundaries for the router. You can optionally configure a boundary for each route."));
|
|
2719
|
-
}
|
|
2795
|
+
} // TODO: Add prompt
|
|
2720
2796
|
|
|
2721
|
-
export {
|
|
2797
|
+
export { DefaultErrorBoundary, MatchesProvider, Outlet, RouterProvider, cascadeLoaderData, cleanPath, createBrowserHistory, createHashHistory, createMemoryHistory, createReactRouter, createRoute, createRouteConfig, createRouteMatch, createRouter, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, invariant, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
|
|
2722
2798
|
//# sourceMappingURL=index.js.map
|