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