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