@tanstack/react-router 0.0.1-beta.28 → 0.0.1-beta.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -5
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/{react-router/src/index.js → index.js} +63 -124
- package/build/cjs/index.js.map +1 -0
- package/build/esm/index.js +76 -2601
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +115 -33
- package/build/types/index.d.ts +10 -19
- package/build/umd/index.development.js +204 -389
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +3 -3
- package/src/index.tsx +60 -50
- package/build/cjs/react-router/src/index.js.map +0 -1
- package/build/cjs/router-core/build/esm/index.js +0 -2530
- package/build/cjs/router-core/build/esm/index.js.map +0 -1
|
@@ -38,56 +38,39 @@
|
|
|
38
38
|
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
39
39
|
for (var i = 1; i < arguments.length; i++) {
|
|
40
40
|
var source = arguments[i];
|
|
41
|
-
|
|
42
41
|
for (var key in source) {
|
|
43
42
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
44
43
|
target[key] = source[key];
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
|
-
|
|
49
47
|
return target;
|
|
50
48
|
};
|
|
51
49
|
return _extends$2.apply(this, arguments);
|
|
52
50
|
}
|
|
53
|
-
|
|
54
51
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
55
52
|
if (source == null) return {};
|
|
56
53
|
var target = {};
|
|
57
54
|
var sourceKeys = Object.keys(source);
|
|
58
55
|
var key, i;
|
|
59
|
-
|
|
60
56
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
61
57
|
key = sourceKeys[i];
|
|
62
58
|
if (excluded.indexOf(key) >= 0) continue;
|
|
63
59
|
target[key] = source[key];
|
|
64
60
|
}
|
|
65
|
-
|
|
66
61
|
return target;
|
|
67
62
|
}
|
|
68
63
|
|
|
69
|
-
/**
|
|
70
|
-
* router-core
|
|
71
|
-
*
|
|
72
|
-
* Copyright (c) TanStack
|
|
73
|
-
*
|
|
74
|
-
* This source code is licensed under the MIT license found in the
|
|
75
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
76
|
-
*
|
|
77
|
-
* @license MIT
|
|
78
|
-
*/
|
|
79
64
|
function _extends$1() {
|
|
80
65
|
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
81
66
|
for (var i = 1; i < arguments.length; i++) {
|
|
82
67
|
var source = arguments[i];
|
|
83
|
-
|
|
84
68
|
for (var key in source) {
|
|
85
69
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
86
70
|
target[key] = source[key];
|
|
87
71
|
}
|
|
88
72
|
}
|
|
89
73
|
}
|
|
90
|
-
|
|
91
74
|
return target;
|
|
92
75
|
};
|
|
93
76
|
return _extends$1.apply(this, arguments);
|
|
@@ -883,6 +866,7 @@
|
|
|
883
866
|
|
|
884
867
|
return parsedPath;
|
|
885
868
|
}
|
|
869
|
+
|
|
886
870
|
var prefix = 'Invariant failed';
|
|
887
871
|
function invariant(condition, message) {
|
|
888
872
|
if (condition) {
|
|
@@ -893,6 +877,17 @@
|
|
|
893
877
|
throw new Error(value);
|
|
894
878
|
}
|
|
895
879
|
|
|
880
|
+
/**
|
|
881
|
+
* router-core
|
|
882
|
+
*
|
|
883
|
+
* Copyright (c) TanStack
|
|
884
|
+
*
|
|
885
|
+
* This source code is licensed under the MIT license found in the
|
|
886
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
887
|
+
*
|
|
888
|
+
* @license MIT
|
|
889
|
+
*/
|
|
890
|
+
|
|
896
891
|
/**
|
|
897
892
|
* This function returns `a` if `b` is deeply equal.
|
|
898
893
|
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
@@ -902,87 +897,73 @@
|
|
|
902
897
|
if (prev === next) {
|
|
903
898
|
return prev;
|
|
904
899
|
}
|
|
905
|
-
|
|
906
900
|
const array = Array.isArray(prev) && Array.isArray(next);
|
|
907
|
-
|
|
908
901
|
if (array || isPlainObject(prev) && isPlainObject(next)) {
|
|
909
902
|
const aSize = array ? prev.length : Object.keys(prev).length;
|
|
910
903
|
const bItems = array ? next : Object.keys(next);
|
|
911
904
|
const bSize = bItems.length;
|
|
912
905
|
const copy = array ? [] : {};
|
|
913
906
|
let equalItems = 0;
|
|
914
|
-
|
|
915
907
|
for (let i = 0; i < bSize; i++) {
|
|
916
908
|
const key = array ? i : bItems[i];
|
|
917
909
|
copy[key] = replaceEqualDeep(prev[key], next[key]);
|
|
918
|
-
|
|
919
910
|
if (copy[key] === prev[key]) {
|
|
920
911
|
equalItems++;
|
|
921
912
|
}
|
|
922
913
|
}
|
|
923
|
-
|
|
924
914
|
return aSize === bSize && equalItems === aSize ? prev : copy;
|
|
925
915
|
}
|
|
926
|
-
|
|
927
916
|
return next;
|
|
928
|
-
}
|
|
917
|
+
}
|
|
929
918
|
|
|
919
|
+
// Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
930
920
|
function isPlainObject(o) {
|
|
931
921
|
if (!hasObjectPrototype(o)) {
|
|
932
922
|
return false;
|
|
933
|
-
}
|
|
934
|
-
|
|
923
|
+
}
|
|
935
924
|
|
|
925
|
+
// If has modified constructor
|
|
936
926
|
const ctor = o.constructor;
|
|
937
|
-
|
|
938
927
|
if (typeof ctor === 'undefined') {
|
|
939
928
|
return true;
|
|
940
|
-
}
|
|
941
|
-
|
|
929
|
+
}
|
|
942
930
|
|
|
931
|
+
// If has modified prototype
|
|
943
932
|
const prot = ctor.prototype;
|
|
944
|
-
|
|
945
933
|
if (!hasObjectPrototype(prot)) {
|
|
946
934
|
return false;
|
|
947
|
-
}
|
|
948
|
-
|
|
935
|
+
}
|
|
949
936
|
|
|
937
|
+
// If constructor does not have an Object-specific method
|
|
950
938
|
if (!prot.hasOwnProperty('isPrototypeOf')) {
|
|
951
939
|
return false;
|
|
952
|
-
}
|
|
953
|
-
|
|
940
|
+
}
|
|
954
941
|
|
|
942
|
+
// Most likely a plain Object
|
|
955
943
|
return true;
|
|
956
944
|
}
|
|
957
|
-
|
|
958
945
|
function hasObjectPrototype(o) {
|
|
959
946
|
return Object.prototype.toString.call(o) === '[object Object]';
|
|
960
947
|
}
|
|
961
|
-
|
|
962
948
|
function last(arr) {
|
|
963
949
|
return arr[arr.length - 1];
|
|
964
950
|
}
|
|
965
951
|
function warning(cond, message) {
|
|
966
952
|
if (cond) {
|
|
967
953
|
if (typeof console !== 'undefined') console.warn(message);
|
|
968
|
-
|
|
969
954
|
try {
|
|
970
955
|
throw new Error(message);
|
|
971
956
|
} catch (_unused) {}
|
|
972
957
|
}
|
|
973
|
-
|
|
974
958
|
return true;
|
|
975
959
|
}
|
|
976
|
-
|
|
977
960
|
function isFunction(d) {
|
|
978
961
|
return typeof d === 'function';
|
|
979
962
|
}
|
|
980
|
-
|
|
981
963
|
function functionalUpdate(updater, previous) {
|
|
982
964
|
if (isFunction(updater)) {
|
|
983
965
|
return updater(previous);
|
|
984
966
|
}
|
|
985
|
-
|
|
986
967
|
return updater;
|
|
987
968
|
}
|
|
988
969
|
function pick(parent, keys) {
|
|
@@ -1024,12 +1005,10 @@
|
|
|
1024
1005
|
} else ;
|
|
1025
1006
|
} else if (toSegment.value === '..') {
|
|
1026
1007
|
var _last;
|
|
1027
|
-
|
|
1028
1008
|
// Extra trailing slash? pop it off
|
|
1029
1009
|
if (baseSegments.length > 1 && ((_last = last(baseSegments)) == null ? void 0 : _last.value) === '/') {
|
|
1030
1010
|
baseSegments.pop();
|
|
1031
1011
|
}
|
|
1032
|
-
|
|
1033
1012
|
baseSegments.pop();
|
|
1034
1013
|
} else if (toSegment.value === '.') {
|
|
1035
1014
|
return;
|
|
@@ -1044,10 +1023,8 @@
|
|
|
1044
1023
|
if (!pathname) {
|
|
1045
1024
|
return [];
|
|
1046
1025
|
}
|
|
1047
|
-
|
|
1048
1026
|
pathname = cleanPath(pathname);
|
|
1049
1027
|
const segments = [];
|
|
1050
|
-
|
|
1051
1028
|
if (pathname.slice(0, 1) === '/') {
|
|
1052
1029
|
pathname = pathname.substring(1);
|
|
1053
1030
|
segments.push({
|
|
@@ -1055,12 +1032,11 @@
|
|
|
1055
1032
|
value: '/'
|
|
1056
1033
|
});
|
|
1057
1034
|
}
|
|
1058
|
-
|
|
1059
1035
|
if (!pathname) {
|
|
1060
1036
|
return segments;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1037
|
+
}
|
|
1063
1038
|
|
|
1039
|
+
// Remove empty segments and '.' segments
|
|
1064
1040
|
const split = pathname.split('/').filter(Boolean);
|
|
1065
1041
|
segments.push(...split.map(part => {
|
|
1066
1042
|
if (part.startsWith('*')) {
|
|
@@ -1069,20 +1045,17 @@
|
|
|
1069
1045
|
value: part
|
|
1070
1046
|
};
|
|
1071
1047
|
}
|
|
1072
|
-
|
|
1073
1048
|
if (part.charAt(0) === '$') {
|
|
1074
1049
|
return {
|
|
1075
1050
|
type: 'param',
|
|
1076
1051
|
value: part
|
|
1077
1052
|
};
|
|
1078
1053
|
}
|
|
1079
|
-
|
|
1080
1054
|
return {
|
|
1081
1055
|
type: 'pathname',
|
|
1082
1056
|
value: part
|
|
1083
1057
|
};
|
|
1084
1058
|
}));
|
|
1085
|
-
|
|
1086
1059
|
if (pathname.slice(-1) === '/') {
|
|
1087
1060
|
pathname = pathname.substring(1);
|
|
1088
1061
|
segments.push({
|
|
@@ -1090,7 +1063,6 @@
|
|
|
1090
1063
|
value: '/'
|
|
1091
1064
|
});
|
|
1092
1065
|
}
|
|
1093
|
-
|
|
1094
1066
|
return segments;
|
|
1095
1067
|
}
|
|
1096
1068
|
function interpolatePath(path, params, leaveWildcard) {
|
|
@@ -1099,54 +1071,45 @@
|
|
|
1099
1071
|
if (segment.value === '*' && !leaveWildcard) {
|
|
1100
1072
|
return '';
|
|
1101
1073
|
}
|
|
1102
|
-
|
|
1103
1074
|
if (segment.type === 'param') {
|
|
1104
1075
|
var _segment$value$substr;
|
|
1105
|
-
|
|
1106
1076
|
return (_segment$value$substr = params[segment.value.substring(1)]) != null ? _segment$value$substr : '';
|
|
1107
1077
|
}
|
|
1108
|
-
|
|
1109
1078
|
return segment.value;
|
|
1110
1079
|
}));
|
|
1111
1080
|
}
|
|
1112
1081
|
function matchPathname(currentPathname, matchLocation) {
|
|
1113
|
-
const pathParams = matchByPath(currentPathname, matchLocation);
|
|
1082
|
+
const pathParams = matchByPath(currentPathname, matchLocation);
|
|
1083
|
+
// const searchMatched = matchBySearch(currentLocation.search, matchLocation)
|
|
1114
1084
|
|
|
1115
1085
|
if (matchLocation.to && !pathParams) {
|
|
1116
1086
|
return;
|
|
1117
1087
|
}
|
|
1118
|
-
|
|
1119
1088
|
return pathParams != null ? pathParams : {};
|
|
1120
1089
|
}
|
|
1121
1090
|
function matchByPath(from, matchLocation) {
|
|
1122
1091
|
var _matchLocation$to;
|
|
1123
|
-
|
|
1124
1092
|
const baseSegments = parsePathname(from);
|
|
1125
1093
|
const routeSegments = parsePathname("" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*'));
|
|
1126
1094
|
const params = {};
|
|
1127
|
-
|
|
1128
1095
|
let isMatch = (() => {
|
|
1129
1096
|
for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
|
|
1130
1097
|
const baseSegment = baseSegments[i];
|
|
1131
1098
|
const routeSegment = routeSegments[i];
|
|
1132
1099
|
const isLastRouteSegment = i === routeSegments.length - 1;
|
|
1133
1100
|
const isLastBaseSegment = i === baseSegments.length - 1;
|
|
1134
|
-
|
|
1135
1101
|
if (routeSegment) {
|
|
1136
1102
|
if (routeSegment.type === 'wildcard') {
|
|
1137
1103
|
if (baseSegment != null && baseSegment.value) {
|
|
1138
1104
|
params['*'] = joinPaths(baseSegments.slice(i).map(d => d.value));
|
|
1139
1105
|
return true;
|
|
1140
1106
|
}
|
|
1141
|
-
|
|
1142
1107
|
return false;
|
|
1143
1108
|
}
|
|
1144
|
-
|
|
1145
1109
|
if (routeSegment.type === 'pathname') {
|
|
1146
1110
|
if (routeSegment.value === '/' && !(baseSegment != null && baseSegment.value)) {
|
|
1147
1111
|
return true;
|
|
1148
1112
|
}
|
|
1149
|
-
|
|
1150
1113
|
if (baseSegment) {
|
|
1151
1114
|
if (matchLocation.caseSensitive) {
|
|
1152
1115
|
if (routeSegment.value !== baseSegment.value) {
|
|
@@ -1157,41 +1120,36 @@
|
|
|
1157
1120
|
}
|
|
1158
1121
|
}
|
|
1159
1122
|
}
|
|
1160
|
-
|
|
1161
1123
|
if (!baseSegment) {
|
|
1162
1124
|
return false;
|
|
1163
1125
|
}
|
|
1164
|
-
|
|
1165
1126
|
if (routeSegment.type === 'param') {
|
|
1166
1127
|
if ((baseSegment == null ? void 0 : baseSegment.value) === '/') {
|
|
1167
1128
|
return false;
|
|
1168
1129
|
}
|
|
1169
|
-
|
|
1170
1130
|
if (baseSegment.value.charAt(0) !== '$') {
|
|
1171
1131
|
params[routeSegment.value.substring(1)] = baseSegment.value;
|
|
1172
1132
|
}
|
|
1173
1133
|
}
|
|
1174
1134
|
}
|
|
1175
|
-
|
|
1176
1135
|
if (isLastRouteSegment && !isLastBaseSegment) {
|
|
1177
1136
|
return !!matchLocation.fuzzy;
|
|
1178
1137
|
}
|
|
1179
1138
|
}
|
|
1180
|
-
|
|
1181
1139
|
return true;
|
|
1182
1140
|
})();
|
|
1183
|
-
|
|
1184
1141
|
return isMatch ? params : undefined;
|
|
1185
1142
|
}
|
|
1186
1143
|
|
|
1187
1144
|
// @ts-nocheck
|
|
1145
|
+
|
|
1188
1146
|
// 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.
|
|
1147
|
+
|
|
1189
1148
|
function encode(obj, pfx) {
|
|
1190
1149
|
var k,
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1150
|
+
i,
|
|
1151
|
+
tmp,
|
|
1152
|
+
str = '';
|
|
1195
1153
|
for (k in obj) {
|
|
1196
1154
|
if ((tmp = obj[k]) !== void 0) {
|
|
1197
1155
|
if (Array.isArray(tmp)) {
|
|
@@ -1205,10 +1163,8 @@
|
|
|
1205
1163
|
}
|
|
1206
1164
|
}
|
|
1207
1165
|
}
|
|
1208
|
-
|
|
1209
1166
|
return (pfx || '') + str;
|
|
1210
1167
|
}
|
|
1211
|
-
|
|
1212
1168
|
function toValue(mix) {
|
|
1213
1169
|
if (!mix) return '';
|
|
1214
1170
|
var str = decodeURIComponent(mix);
|
|
@@ -1217,24 +1173,20 @@
|
|
|
1217
1173
|
if (str.charAt(0) === '0') return str;
|
|
1218
1174
|
return +str * 0 === 0 ? +str : str;
|
|
1219
1175
|
}
|
|
1220
|
-
|
|
1221
1176
|
function decode(str) {
|
|
1222
1177
|
var tmp,
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1178
|
+
k,
|
|
1179
|
+
out = {},
|
|
1180
|
+
arr = str.split('&');
|
|
1227
1181
|
while (tmp = arr.shift()) {
|
|
1228
1182
|
tmp = tmp.split('=');
|
|
1229
1183
|
k = tmp.shift();
|
|
1230
|
-
|
|
1231
1184
|
if (out[k] !== void 0) {
|
|
1232
1185
|
out[k] = [].concat(out[k], toValue(tmp.shift()));
|
|
1233
1186
|
} else {
|
|
1234
1187
|
out[k] = toValue(tmp.shift());
|
|
1235
1188
|
}
|
|
1236
1189
|
}
|
|
1237
|
-
|
|
1238
1190
|
return out;
|
|
1239
1191
|
}
|
|
1240
1192
|
|
|
@@ -1242,14 +1194,12 @@
|
|
|
1242
1194
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
1243
1195
|
for (var i = 1; i < arguments.length; i++) {
|
|
1244
1196
|
var source = arguments[i];
|
|
1245
|
-
|
|
1246
1197
|
for (var key in source) {
|
|
1247
1198
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1248
1199
|
target[key] = source[key];
|
|
1249
1200
|
}
|
|
1250
1201
|
}
|
|
1251
1202
|
}
|
|
1252
|
-
|
|
1253
1203
|
return target;
|
|
1254
1204
|
};
|
|
1255
1205
|
return _extends.apply(this, arguments);
|
|
@@ -1262,23 +1212,18 @@
|
|
|
1262
1212
|
path: routePath,
|
|
1263
1213
|
fullPath
|
|
1264
1214
|
} = routeConfig;
|
|
1265
|
-
|
|
1266
1215
|
const action = router.state.actions[id] || (() => {
|
|
1267
1216
|
router.state.actions[id] = {
|
|
1268
1217
|
submissions: [],
|
|
1269
1218
|
submit: async (submission, actionOpts) => {
|
|
1270
1219
|
var _actionOpts$invalidat;
|
|
1271
|
-
|
|
1272
1220
|
if (!route) {
|
|
1273
1221
|
return;
|
|
1274
1222
|
}
|
|
1275
|
-
|
|
1276
1223
|
const invalidate = (_actionOpts$invalidat = actionOpts == null ? void 0 : actionOpts.invalidate) != null ? _actionOpts$invalidat : true;
|
|
1277
|
-
|
|
1278
1224
|
if (!(actionOpts != null && actionOpts.multi)) {
|
|
1279
1225
|
action.submissions = action.submissions.filter(d => d.isMulti);
|
|
1280
1226
|
}
|
|
1281
|
-
|
|
1282
1227
|
const actionState = {
|
|
1283
1228
|
submittedAt: Date.now(),
|
|
1284
1229
|
status: 'pending',
|
|
@@ -1289,11 +1234,9 @@
|
|
|
1289
1234
|
action.latest = actionState;
|
|
1290
1235
|
action.submissions.push(actionState);
|
|
1291
1236
|
router.notify();
|
|
1292
|
-
|
|
1293
1237
|
try {
|
|
1294
1238
|
const res = await (route.options.action == null ? void 0 : route.options.action(submission));
|
|
1295
1239
|
actionState.data = res;
|
|
1296
|
-
|
|
1297
1240
|
if (invalidate) {
|
|
1298
1241
|
router.invalidateRoute({
|
|
1299
1242
|
to: '.',
|
|
@@ -1301,10 +1244,10 @@
|
|
|
1301
1244
|
});
|
|
1302
1245
|
await router.reload();
|
|
1303
1246
|
}
|
|
1304
|
-
|
|
1305
1247
|
actionState.status = 'success';
|
|
1306
1248
|
return res;
|
|
1307
1249
|
} catch (err) {
|
|
1250
|
+
console.log('tanner');
|
|
1308
1251
|
console.error(err);
|
|
1309
1252
|
actionState.error = err;
|
|
1310
1253
|
actionState.status = 'error';
|
|
@@ -1315,7 +1258,6 @@
|
|
|
1315
1258
|
};
|
|
1316
1259
|
return router.state.actions[id];
|
|
1317
1260
|
})();
|
|
1318
|
-
|
|
1319
1261
|
const loader = router.state.loaders[id] || (() => {
|
|
1320
1262
|
router.state.loaders[id] = {
|
|
1321
1263
|
pending: [],
|
|
@@ -1323,33 +1265,32 @@
|
|
|
1323
1265
|
if (!route) {
|
|
1324
1266
|
return;
|
|
1325
1267
|
}
|
|
1326
|
-
|
|
1327
1268
|
const loaderState = {
|
|
1328
1269
|
loadedAt: Date.now(),
|
|
1329
1270
|
loaderContext
|
|
1330
1271
|
};
|
|
1331
1272
|
loader.current = loaderState;
|
|
1332
1273
|
loader.latest = loaderState;
|
|
1333
|
-
loader.pending.push(loaderState);
|
|
1274
|
+
loader.pending.push(loaderState);
|
|
1275
|
+
|
|
1276
|
+
// router.state = {
|
|
1334
1277
|
// ...router.state,
|
|
1335
1278
|
// currentAction: loaderState,
|
|
1336
1279
|
// latestAction: loaderState,
|
|
1337
1280
|
// }
|
|
1338
1281
|
|
|
1339
1282
|
router.notify();
|
|
1340
|
-
|
|
1341
1283
|
try {
|
|
1342
1284
|
return await (route.options.loader == null ? void 0 : route.options.loader(loaderContext));
|
|
1343
1285
|
} finally {
|
|
1344
|
-
loader.pending = loader.pending.filter(d => d !== loaderState);
|
|
1345
|
-
|
|
1286
|
+
loader.pending = loader.pending.filter(d => d !== loaderState);
|
|
1287
|
+
// router.removeActionQueue.push({ loader, loaderState })
|
|
1346
1288
|
router.notify();
|
|
1347
1289
|
}
|
|
1348
1290
|
}
|
|
1349
1291
|
};
|
|
1350
1292
|
return router.state.loaders[id];
|
|
1351
1293
|
})();
|
|
1352
|
-
|
|
1353
1294
|
let route = {
|
|
1354
1295
|
routeInfo: undefined,
|
|
1355
1296
|
routeId: id,
|
|
@@ -1390,37 +1331,31 @@
|
|
|
1390
1331
|
if (options === void 0) {
|
|
1391
1332
|
options = {};
|
|
1392
1333
|
}
|
|
1393
|
-
|
|
1394
1334
|
if (isRoot === void 0) {
|
|
1395
1335
|
isRoot = true;
|
|
1396
1336
|
}
|
|
1397
|
-
|
|
1398
1337
|
if (isRoot) {
|
|
1399
1338
|
options.path = rootRouteId;
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1339
|
+
}
|
|
1402
1340
|
|
|
1341
|
+
// Strip the root from parentIds
|
|
1403
1342
|
if (parentId === rootRouteId) {
|
|
1404
1343
|
parentId = '';
|
|
1405
1344
|
}
|
|
1345
|
+
let path = isRoot ? rootRouteId : options.path;
|
|
1406
1346
|
|
|
1407
|
-
|
|
1408
|
-
|
|
1347
|
+
// If the path is anything other than an index path, trim it up
|
|
1409
1348
|
if (path && path !== '/') {
|
|
1410
1349
|
path = trimPath(path);
|
|
1411
1350
|
}
|
|
1412
|
-
|
|
1413
1351
|
const routeId = path || options.id;
|
|
1414
1352
|
let id = joinPaths([parentId, routeId]);
|
|
1415
|
-
|
|
1416
1353
|
if (path === rootRouteId) {
|
|
1417
1354
|
path = '/';
|
|
1418
1355
|
}
|
|
1419
|
-
|
|
1420
1356
|
if (id !== rootRouteId) {
|
|
1421
1357
|
id = joinPaths(['/', id]);
|
|
1422
1358
|
}
|
|
1423
|
-
|
|
1424
1359
|
const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parentPath, path]));
|
|
1425
1360
|
return {
|
|
1426
1361
|
id: id,
|
|
@@ -1461,31 +1396,26 @@
|
|
|
1461
1396
|
resolve: () => {},
|
|
1462
1397
|
notify: () => {
|
|
1463
1398
|
routeMatch.__.resolve();
|
|
1464
|
-
|
|
1465
1399
|
routeMatch.router.notify();
|
|
1466
1400
|
},
|
|
1467
1401
|
validate: () => {
|
|
1468
1402
|
var _routeMatch$parentMat, _routeMatch$parentMat2;
|
|
1469
|
-
|
|
1470
1403
|
// Validate the search params and stabilize them
|
|
1471
1404
|
const parentSearch = (_routeMatch$parentMat = (_routeMatch$parentMat2 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat2.search) != null ? _routeMatch$parentMat : router.location.search;
|
|
1472
|
-
|
|
1473
1405
|
try {
|
|
1474
1406
|
var _validator;
|
|
1475
|
-
|
|
1476
1407
|
const prevSearch = routeMatch.routeSearch;
|
|
1477
1408
|
const validator = typeof routeMatch.options.validateSearch === 'object' ? routeMatch.options.validateSearch.parse : routeMatch.options.validateSearch;
|
|
1478
|
-
let nextSearch = replaceEqualDeep(prevSearch, (_validator = validator == null ? void 0 : validator(parentSearch)) != null ? _validator : {});
|
|
1409
|
+
let nextSearch = replaceEqualDeep(prevSearch, (_validator = validator == null ? void 0 : validator(parentSearch)) != null ? _validator : {});
|
|
1479
1410
|
|
|
1411
|
+
// Invalidate route matches when search param stability changes
|
|
1480
1412
|
if (prevSearch !== nextSearch) {
|
|
1481
1413
|
routeMatch.isInvalid = true;
|
|
1482
1414
|
}
|
|
1483
|
-
|
|
1484
1415
|
routeMatch.routeSearch = nextSearch;
|
|
1485
1416
|
routeMatch.search = replaceEqualDeep(parentSearch, _extends({}, parentSearch, nextSearch));
|
|
1486
1417
|
componentTypes.map(async type => {
|
|
1487
1418
|
const component = routeMatch.options[type];
|
|
1488
|
-
|
|
1489
1419
|
if (typeof routeMatch.__[type] !== 'function') {
|
|
1490
1420
|
routeMatch.__[type] = component;
|
|
1491
1421
|
}
|
|
@@ -1497,15 +1427,14 @@
|
|
|
1497
1427
|
});
|
|
1498
1428
|
error.code = 'INVALID_SEARCH_PARAMS';
|
|
1499
1429
|
routeMatch.status = 'error';
|
|
1500
|
-
routeMatch.error = error;
|
|
1501
|
-
|
|
1430
|
+
routeMatch.error = error;
|
|
1431
|
+
// Do not proceed with loading the route
|
|
1502
1432
|
return;
|
|
1503
1433
|
}
|
|
1504
1434
|
}
|
|
1505
1435
|
},
|
|
1506
1436
|
cancel: () => {
|
|
1507
1437
|
var _routeMatch$__$abortC;
|
|
1508
|
-
|
|
1509
1438
|
(_routeMatch$__$abortC = routeMatch.__.abortController) == null ? void 0 : _routeMatch$__$abortC.abort();
|
|
1510
1439
|
},
|
|
1511
1440
|
invalidate: () => {
|
|
@@ -1514,27 +1443,26 @@
|
|
|
1514
1443
|
hasLoaders: () => {
|
|
1515
1444
|
return !!(route.options.loader || componentTypes.some(d => {
|
|
1516
1445
|
var _route$options$d;
|
|
1517
|
-
|
|
1518
1446
|
return (_route$options$d = route.options[d]) == null ? void 0 : _route$options$d.preload;
|
|
1519
1447
|
}));
|
|
1520
1448
|
},
|
|
1521
1449
|
load: async loaderOpts => {
|
|
1522
1450
|
const now = Date.now();
|
|
1523
|
-
const minMaxAge = loaderOpts != null && loaderOpts.preload ? Math.max(loaderOpts == null ? void 0 : loaderOpts.maxAge, loaderOpts == null ? void 0 : loaderOpts.gcMaxAge) : 0;
|
|
1451
|
+
const minMaxAge = loaderOpts != null && loaderOpts.preload ? Math.max(loaderOpts == null ? void 0 : loaderOpts.maxAge, loaderOpts == null ? void 0 : loaderOpts.gcMaxAge) : 0;
|
|
1524
1452
|
|
|
1453
|
+
// If this is a preload, add it to the preload cache
|
|
1525
1454
|
if (loaderOpts != null && loaderOpts.preload && minMaxAge > 0) {
|
|
1526
1455
|
// If the match is currently active, don't preload it
|
|
1527
1456
|
if (router.state.matches.find(d => d.matchId === routeMatch.matchId)) {
|
|
1528
1457
|
return;
|
|
1529
1458
|
}
|
|
1530
|
-
|
|
1531
1459
|
router.matchCache[routeMatch.matchId] = {
|
|
1532
1460
|
gc: now + loaderOpts.gcMaxAge,
|
|
1533
1461
|
match: routeMatch
|
|
1534
1462
|
};
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1463
|
+
}
|
|
1537
1464
|
|
|
1465
|
+
// If the match is invalid, errored or idle, trigger it to load
|
|
1538
1466
|
if (routeMatch.status === 'success' && routeMatch.getIsInvalid() || routeMatch.status === 'error' || routeMatch.status === 'idle') {
|
|
1539
1467
|
const maxAge = loaderOpts != null && loaderOpts.preload ? loaderOpts == null ? void 0 : loaderOpts.maxAge : undefined;
|
|
1540
1468
|
await routeMatch.fetch({
|
|
@@ -1545,53 +1473,47 @@
|
|
|
1545
1473
|
fetch: async opts => {
|
|
1546
1474
|
const loadId = '' + Date.now() + Math.random();
|
|
1547
1475
|
routeMatch.__.latestId = loadId;
|
|
1548
|
-
|
|
1549
1476
|
const checkLatest = async () => {
|
|
1550
1477
|
if (loadId !== routeMatch.__.latestId) {
|
|
1551
1478
|
// warning(true, 'Data loader is out of date!')
|
|
1552
1479
|
return new Promise(() => {});
|
|
1553
1480
|
}
|
|
1554
|
-
};
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
// If the match was in an error state, set it
|
|
1555
1484
|
// to a loading state again. Otherwise, keep it
|
|
1556
1485
|
// as loading or resolved
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
1486
|
if (routeMatch.status === 'idle') {
|
|
1560
1487
|
routeMatch.status = 'loading';
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1488
|
+
}
|
|
1563
1489
|
|
|
1490
|
+
// We started loading the route, so it's no longer invalid
|
|
1564
1491
|
routeMatch.isInvalid = false;
|
|
1565
1492
|
routeMatch.__.loadPromise = new Promise(async resolve => {
|
|
1566
1493
|
// We are now fetching, even if it's in the background of a
|
|
1567
1494
|
// resolved state
|
|
1568
1495
|
routeMatch.isFetching = true;
|
|
1569
1496
|
routeMatch.__.resolve = resolve;
|
|
1570
|
-
|
|
1571
1497
|
routeMatch.__.componentsPromise = (async () => {
|
|
1572
1498
|
// then run all component and data loaders in parallel
|
|
1573
1499
|
// For each component type, potentially load it asynchronously
|
|
1500
|
+
|
|
1574
1501
|
await Promise.all(componentTypes.map(async type => {
|
|
1575
1502
|
var _routeMatch$__$type;
|
|
1576
|
-
|
|
1577
1503
|
const component = routeMatch.options[type];
|
|
1578
|
-
|
|
1579
1504
|
if ((_routeMatch$__$type = routeMatch.__[type]) != null && _routeMatch$__$type.preload) {
|
|
1580
1505
|
routeMatch.__[type] = await router.options.loadComponent(component);
|
|
1581
1506
|
}
|
|
1582
1507
|
}));
|
|
1583
1508
|
})();
|
|
1584
|
-
|
|
1585
1509
|
routeMatch.__.dataPromise = Promise.resolve().then(async () => {
|
|
1586
1510
|
try {
|
|
1587
1511
|
var _ref, _ref2, _opts$maxAge;
|
|
1588
|
-
|
|
1589
1512
|
if (routeMatch.options.loader) {
|
|
1590
1513
|
const data = await router.loadMatchData(routeMatch);
|
|
1591
1514
|
await checkLatest();
|
|
1592
1515
|
routeMatch.routeLoaderData = replaceEqualDeep(routeMatch.routeLoaderData, data);
|
|
1593
1516
|
}
|
|
1594
|
-
|
|
1595
1517
|
routeMatch.error = undefined;
|
|
1596
1518
|
routeMatch.status = 'success';
|
|
1597
1519
|
routeMatch.updatedAt = Date.now();
|
|
@@ -1599,26 +1521,21 @@
|
|
|
1599
1521
|
return routeMatch.routeLoaderData;
|
|
1600
1522
|
} catch (err) {
|
|
1601
1523
|
await checkLatest();
|
|
1602
|
-
|
|
1603
1524
|
{
|
|
1604
1525
|
console.error(err);
|
|
1605
1526
|
}
|
|
1606
|
-
|
|
1607
1527
|
routeMatch.error = err;
|
|
1608
1528
|
routeMatch.status = 'error';
|
|
1609
1529
|
routeMatch.updatedAt = Date.now();
|
|
1610
1530
|
throw err;
|
|
1611
1531
|
}
|
|
1612
1532
|
});
|
|
1613
|
-
|
|
1614
1533
|
const after = async () => {
|
|
1615
1534
|
await checkLatest();
|
|
1616
1535
|
routeMatch.isFetching = false;
|
|
1617
1536
|
delete routeMatch.__.loadPromise;
|
|
1618
|
-
|
|
1619
1537
|
routeMatch.__.notify();
|
|
1620
1538
|
};
|
|
1621
|
-
|
|
1622
1539
|
try {
|
|
1623
1540
|
await Promise.all([routeMatch.__.componentsPromise, routeMatch.__.dataPromise.catch(() => {})]);
|
|
1624
1541
|
after();
|
|
@@ -1630,11 +1547,9 @@
|
|
|
1630
1547
|
await checkLatest();
|
|
1631
1548
|
}
|
|
1632
1549
|
});
|
|
1633
|
-
|
|
1634
1550
|
if (!routeMatch.hasLoaders()) {
|
|
1635
1551
|
routeMatch.status = 'success';
|
|
1636
1552
|
}
|
|
1637
|
-
|
|
1638
1553
|
return routeMatch;
|
|
1639
1554
|
}
|
|
1640
1555
|
|
|
@@ -1645,42 +1560,39 @@
|
|
|
1645
1560
|
if (searchStr.substring(0, 1) === '?') {
|
|
1646
1561
|
searchStr = searchStr.substring(1);
|
|
1647
1562
|
}
|
|
1563
|
+
let query = decode(searchStr);
|
|
1648
1564
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1565
|
+
// Try to parse any query params that might be json
|
|
1651
1566
|
for (let key in query) {
|
|
1652
1567
|
const value = query[key];
|
|
1653
|
-
|
|
1654
1568
|
if (typeof value === 'string') {
|
|
1655
1569
|
try {
|
|
1656
1570
|
query[key] = parser(value);
|
|
1657
|
-
} catch (err) {
|
|
1571
|
+
} catch (err) {
|
|
1572
|
+
//
|
|
1658
1573
|
}
|
|
1659
1574
|
}
|
|
1660
1575
|
}
|
|
1661
|
-
|
|
1662
1576
|
return query;
|
|
1663
1577
|
};
|
|
1664
1578
|
}
|
|
1665
1579
|
function stringifySearchWith(stringify) {
|
|
1666
1580
|
return search => {
|
|
1667
1581
|
search = _extends({}, search);
|
|
1668
|
-
|
|
1669
1582
|
if (search) {
|
|
1670
1583
|
Object.keys(search).forEach(key => {
|
|
1671
1584
|
const val = search[key];
|
|
1672
|
-
|
|
1673
1585
|
if (typeof val === 'undefined' || val === undefined) {
|
|
1674
1586
|
delete search[key];
|
|
1675
1587
|
} else if (val && typeof val === 'object' && val !== null) {
|
|
1676
1588
|
try {
|
|
1677
1589
|
search[key] = stringify(val);
|
|
1678
|
-
} catch (err) {
|
|
1590
|
+
} catch (err) {
|
|
1591
|
+
// silent
|
|
1679
1592
|
}
|
|
1680
1593
|
}
|
|
1681
1594
|
});
|
|
1682
1595
|
}
|
|
1683
|
-
|
|
1684
1596
|
const searchStr = encode(search).toString();
|
|
1685
1597
|
return searchStr ? "?" + searchStr : '';
|
|
1686
1598
|
};
|
|
@@ -1688,10 +1600,10 @@
|
|
|
1688
1600
|
|
|
1689
1601
|
var _window$document;
|
|
1690
1602
|
// Detect if we're in the DOM
|
|
1691
|
-
const isServer = typeof window === 'undefined' || !((_window$document = window.document) != null && _window$document.createElement);
|
|
1603
|
+
const isServer = typeof window === 'undefined' || !((_window$document = window.document) != null && _window$document.createElement);
|
|
1692
1604
|
|
|
1605
|
+
// This is the default history object if none is defined
|
|
1693
1606
|
const createDefaultHistory = () => isServer ? createMemoryHistory() : createBrowserHistory();
|
|
1694
|
-
|
|
1695
1607
|
function getInitialRouterState() {
|
|
1696
1608
|
return {
|
|
1697
1609
|
status: 'idle',
|
|
@@ -1704,22 +1616,19 @@
|
|
|
1704
1616
|
isPreloading: false
|
|
1705
1617
|
};
|
|
1706
1618
|
}
|
|
1707
|
-
|
|
1708
1619
|
function createRouter(userOptions) {
|
|
1709
1620
|
var _userOptions$stringif, _userOptions$parseSea;
|
|
1710
|
-
|
|
1711
1621
|
const history = (userOptions == null ? void 0 : userOptions.history) || createDefaultHistory();
|
|
1712
|
-
|
|
1713
1622
|
const originalOptions = _extends({
|
|
1714
1623
|
defaultLoaderGcMaxAge: 5 * 60 * 1000,
|
|
1715
1624
|
defaultLoaderMaxAge: 0,
|
|
1716
1625
|
defaultPreloadMaxAge: 2000,
|
|
1717
|
-
defaultPreloadDelay: 50
|
|
1626
|
+
defaultPreloadDelay: 50,
|
|
1627
|
+
context: undefined
|
|
1718
1628
|
}, userOptions, {
|
|
1719
1629
|
stringifySearch: (_userOptions$stringif = userOptions == null ? void 0 : userOptions.stringifySearch) != null ? _userOptions$stringif : defaultStringifySearch,
|
|
1720
1630
|
parseSearch: (_userOptions$parseSea = userOptions == null ? void 0 : userOptions.parseSearch) != null ? _userOptions$parseSea : defaultParseSearch
|
|
1721
1631
|
});
|
|
1722
|
-
|
|
1723
1632
|
let router = {
|
|
1724
1633
|
types: undefined,
|
|
1725
1634
|
// public api
|
|
@@ -1727,13 +1636,11 @@
|
|
|
1727
1636
|
options: originalOptions,
|
|
1728
1637
|
listeners: [],
|
|
1729
1638
|
// Resolved after construction
|
|
1730
|
-
context: {},
|
|
1731
1639
|
basepath: '',
|
|
1732
1640
|
routeTree: undefined,
|
|
1733
1641
|
routesById: {},
|
|
1734
1642
|
location: undefined,
|
|
1735
1643
|
//
|
|
1736
|
-
navigationPromise: Promise.resolve(),
|
|
1737
1644
|
resolveNavigation: () => {},
|
|
1738
1645
|
matchCache: {},
|
|
1739
1646
|
state: getInitialRouterState(),
|
|
@@ -1754,29 +1661,37 @@
|
|
|
1754
1661
|
notify: () => {
|
|
1755
1662
|
const isFetching = router.state.status === 'loading' || router.state.matches.some(d => d.isFetching);
|
|
1756
1663
|
const isPreloading = Object.values(router.matchCache).some(d => d.match.isFetching && !router.state.matches.find(dd => dd.matchId === d.match.matchId));
|
|
1757
|
-
|
|
1758
1664
|
if (router.state.isFetching !== isFetching || router.state.isPreloading !== isPreloading) {
|
|
1759
1665
|
router.state = _extends({}, router.state, {
|
|
1760
1666
|
isFetching,
|
|
1761
1667
|
isPreloading
|
|
1762
1668
|
});
|
|
1763
1669
|
}
|
|
1764
|
-
|
|
1765
1670
|
cascadeLoaderData(router.state.matches);
|
|
1766
1671
|
router.listeners.forEach(listener => listener(router));
|
|
1767
1672
|
},
|
|
1768
|
-
|
|
1769
|
-
return
|
|
1770
|
-
|
|
1771
|
-
|
|
1673
|
+
dehydrate: () => {
|
|
1674
|
+
return {
|
|
1675
|
+
location: router.location,
|
|
1676
|
+
state: _extends({}, pick(router.state, ['status', 'location', 'lastUpdated', 'location']), {
|
|
1677
|
+
matches: router.state.matches.map(match => pick(match, ['matchId', 'status', 'routeLoaderData', 'loaderData', 'isInvalid', 'invalidAt']))
|
|
1678
|
+
}),
|
|
1679
|
+
context: router.options.context
|
|
1680
|
+
};
|
|
1772
1681
|
},
|
|
1773
|
-
|
|
1682
|
+
hydrate: dehydratedState => {
|
|
1683
|
+
// Update the location
|
|
1684
|
+
router.location = dehydratedState.location;
|
|
1685
|
+
|
|
1686
|
+
// Update the context
|
|
1687
|
+
router.options.context = dehydratedState.context;
|
|
1688
|
+
|
|
1774
1689
|
// Match the routes
|
|
1775
1690
|
const matches = router.matchRoutes(router.location.pathname, {
|
|
1776
1691
|
strictParseParams: true
|
|
1777
1692
|
});
|
|
1778
1693
|
matches.forEach((match, index) => {
|
|
1779
|
-
const dehydratedMatch = dehydratedState.matches[index];
|
|
1694
|
+
const dehydratedMatch = dehydratedState.state.matches[index];
|
|
1780
1695
|
invariant(dehydratedMatch, 'Oh no! Dehydrated route matches did not match the active state of the router 😬');
|
|
1781
1696
|
Object.assign(match, dehydratedMatch);
|
|
1782
1697
|
});
|
|
@@ -1790,32 +1705,29 @@
|
|
|
1790
1705
|
to: '.',
|
|
1791
1706
|
search: true,
|
|
1792
1707
|
hash: true
|
|
1793
|
-
});
|
|
1794
|
-
// to the current location. Otherwise, load the current location.
|
|
1795
|
-
|
|
1708
|
+
});
|
|
1796
1709
|
|
|
1710
|
+
// If the current location isn't updated, trigger a navigation
|
|
1711
|
+
// to the current location. Otherwise, load the current location.
|
|
1797
1712
|
if (next.href !== router.location.href) {
|
|
1798
1713
|
router.__.commitLocation(next, true);
|
|
1799
1714
|
}
|
|
1800
|
-
|
|
1801
1715
|
if (!router.state.matches.length) {
|
|
1802
1716
|
router.load();
|
|
1803
1717
|
}
|
|
1804
|
-
|
|
1805
1718
|
const unsub = router.history.listen(event => {
|
|
1806
1719
|
router.load(router.__.parseLocation(event.location, router.location));
|
|
1807
|
-
});
|
|
1808
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1720
|
+
});
|
|
1809
1721
|
|
|
1722
|
+
// addEventListener does not exist in React Native, but window does
|
|
1723
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1810
1724
|
if (!isServer && window.addEventListener) {
|
|
1811
1725
|
// Listen to visibillitychange and focus
|
|
1812
1726
|
window.addEventListener('visibilitychange', router.onFocus, false);
|
|
1813
1727
|
window.addEventListener('focus', router.onFocus, false);
|
|
1814
1728
|
}
|
|
1815
|
-
|
|
1816
1729
|
return () => {
|
|
1817
1730
|
unsub();
|
|
1818
|
-
|
|
1819
1731
|
if (!isServer && window.removeEventListener) {
|
|
1820
1732
|
// Be sure to unsubscribe if a new handler is set
|
|
1821
1733
|
window.removeEventListener('visibilitychange', router.onFocus);
|
|
@@ -1828,28 +1740,23 @@
|
|
|
1828
1740
|
},
|
|
1829
1741
|
update: opts => {
|
|
1830
1742
|
const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
|
|
1831
|
-
|
|
1832
1743
|
if (!router.location || newHistory) {
|
|
1833
1744
|
if (opts != null && opts.history) {
|
|
1834
1745
|
router.history = opts.history;
|
|
1835
1746
|
}
|
|
1836
|
-
|
|
1837
1747
|
router.location = router.__.parseLocation(router.history.location);
|
|
1838
1748
|
router.state.location = router.location;
|
|
1839
1749
|
}
|
|
1840
|
-
|
|
1841
1750
|
Object.assign(router.options, opts);
|
|
1842
1751
|
const {
|
|
1843
1752
|
basepath,
|
|
1844
1753
|
routeConfig
|
|
1845
1754
|
} = router.options;
|
|
1846
1755
|
router.basepath = cleanPath("/" + (basepath != null ? basepath : ''));
|
|
1847
|
-
|
|
1848
1756
|
if (routeConfig) {
|
|
1849
1757
|
router.routesById = {};
|
|
1850
1758
|
router.routeTree = router.__.buildRouteTree(routeConfig);
|
|
1851
1759
|
}
|
|
1852
|
-
|
|
1853
1760
|
return router;
|
|
1854
1761
|
},
|
|
1855
1762
|
cancelMatches: () => {
|
|
@@ -1861,31 +1768,18 @@
|
|
|
1861
1768
|
load: async next => {
|
|
1862
1769
|
const id = Math.random();
|
|
1863
1770
|
router.startedLoadingAt = id;
|
|
1864
|
-
|
|
1865
1771
|
if (next) {
|
|
1866
1772
|
// Ingest the new location
|
|
1867
1773
|
router.location = next;
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1774
|
+
}
|
|
1870
1775
|
|
|
1871
|
-
|
|
1776
|
+
// Cancel any pending matches
|
|
1777
|
+
router.cancelMatches();
|
|
1872
1778
|
|
|
1779
|
+
// Match the routes
|
|
1873
1780
|
const matches = router.matchRoutes(router.location.pathname, {
|
|
1874
1781
|
strictParseParams: true
|
|
1875
|
-
});
|
|
1876
|
-
|
|
1877
|
-
try {
|
|
1878
|
-
await Promise.all(matches.map(match => match.options.beforeLoad == null ? void 0 : match.options.beforeLoad({
|
|
1879
|
-
context: router.context
|
|
1880
|
-
})));
|
|
1881
|
-
} catch (err) {
|
|
1882
|
-
if (err != null && err.then) {
|
|
1883
|
-
await new Promise(() => {});
|
|
1884
|
-
}
|
|
1885
|
-
|
|
1886
|
-
throw err;
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1782
|
+
});
|
|
1889
1783
|
if (typeof document !== 'undefined') {
|
|
1890
1784
|
router.state = _extends({}, router.state, {
|
|
1891
1785
|
pending: {
|
|
@@ -1902,18 +1796,29 @@
|
|
|
1902
1796
|
});
|
|
1903
1797
|
}
|
|
1904
1798
|
|
|
1905
|
-
|
|
1799
|
+
// Check if each match middleware to see if the route can be accessed
|
|
1800
|
+
try {
|
|
1801
|
+
await Promise.all(matches.map(match => match.options.beforeLoad == null ? void 0 : match.options.beforeLoad({
|
|
1802
|
+
router: router,
|
|
1803
|
+
match
|
|
1804
|
+
})));
|
|
1805
|
+
} catch (err) {
|
|
1806
|
+
if (err != null && err.then) {
|
|
1807
|
+
await new Promise(() => {});
|
|
1808
|
+
}
|
|
1809
|
+
throw err;
|
|
1810
|
+
}
|
|
1811
|
+
router.notify();
|
|
1906
1812
|
|
|
1813
|
+
// Load the matches
|
|
1907
1814
|
await router.loadMatches(matches);
|
|
1908
|
-
|
|
1909
1815
|
if (router.startedLoadingAt !== id) {
|
|
1910
1816
|
// Ignore side-effects of match loading
|
|
1911
1817
|
return router.navigationPromise;
|
|
1912
1818
|
}
|
|
1913
|
-
|
|
1914
1819
|
const previousMatches = router.state.matches;
|
|
1915
1820
|
const exiting = [],
|
|
1916
|
-
|
|
1821
|
+
staying = [];
|
|
1917
1822
|
previousMatches.forEach(d => {
|
|
1918
1823
|
if (matches.find(dd => dd.matchId === d.matchId)) {
|
|
1919
1824
|
staying.push(d);
|
|
@@ -1927,19 +1832,17 @@
|
|
|
1927
1832
|
const now = Date.now();
|
|
1928
1833
|
exiting.forEach(d => {
|
|
1929
1834
|
var _ref, _d$options$loaderGcMa, _ref2, _d$options$loaderMaxA;
|
|
1930
|
-
|
|
1931
1835
|
d.__.onExit == null ? void 0 : d.__.onExit({
|
|
1932
1836
|
params: d.params,
|
|
1933
1837
|
search: d.routeSearch
|
|
1934
|
-
});
|
|
1838
|
+
});
|
|
1935
1839
|
|
|
1840
|
+
// Clear idle error states when match leaves
|
|
1936
1841
|
if (d.status === 'error' && !d.isFetching) {
|
|
1937
1842
|
d.status = 'idle';
|
|
1938
1843
|
d.error = undefined;
|
|
1939
1844
|
}
|
|
1940
|
-
|
|
1941
1845
|
const gc = Math.max((_ref = (_d$options$loaderGcMa = d.options.loaderGcMaxAge) != null ? _d$options$loaderGcMa : router.options.defaultLoaderGcMaxAge) != null ? _ref : 0, (_ref2 = (_d$options$loaderMaxA = d.options.loaderMaxAge) != null ? _d$options$loaderMaxA : router.options.defaultLoaderMaxAge) != null ? _ref2 : 0);
|
|
1942
|
-
|
|
1943
1846
|
if (gc > 0) {
|
|
1944
1847
|
router.matchCache[d.matchId] = {
|
|
1945
1848
|
gc: gc == Infinity ? Number.MAX_SAFE_INTEGER : now + gc,
|
|
@@ -1960,12 +1863,10 @@
|
|
|
1960
1863
|
});
|
|
1961
1864
|
delete router.matchCache[d.matchId];
|
|
1962
1865
|
});
|
|
1963
|
-
|
|
1964
1866
|
if (router.startedLoadingAt !== id) {
|
|
1965
1867
|
// Ignore side-effects of match loading
|
|
1966
1868
|
return;
|
|
1967
1869
|
}
|
|
1968
|
-
|
|
1969
1870
|
matches.forEach(match => {
|
|
1970
1871
|
// Clear actions
|
|
1971
1872
|
if (match.action) {
|
|
@@ -1985,18 +1886,19 @@
|
|
|
1985
1886
|
cleanMatchCache: () => {
|
|
1986
1887
|
const now = Date.now();
|
|
1987
1888
|
Object.keys(router.matchCache).forEach(matchId => {
|
|
1988
|
-
const entry = router.matchCache[matchId];
|
|
1889
|
+
const entry = router.matchCache[matchId];
|
|
1989
1890
|
|
|
1891
|
+
// Don't remove loading matches
|
|
1990
1892
|
if (entry.match.status === 'loading') {
|
|
1991
1893
|
return;
|
|
1992
|
-
}
|
|
1993
|
-
|
|
1894
|
+
}
|
|
1994
1895
|
|
|
1896
|
+
// Do not remove successful matches that are still valid
|
|
1995
1897
|
if (entry.gc > 0 && entry.gc > now) {
|
|
1996
1898
|
return;
|
|
1997
|
-
}
|
|
1998
|
-
|
|
1899
|
+
}
|
|
1999
1900
|
|
|
1901
|
+
// Everything else gets removed
|
|
2000
1902
|
delete router.matchCache[matchId];
|
|
2001
1903
|
});
|
|
2002
1904
|
},
|
|
@@ -2004,7 +1906,6 @@
|
|
|
2004
1906
|
if (navigateOpts === void 0) {
|
|
2005
1907
|
navigateOpts = router.location;
|
|
2006
1908
|
}
|
|
2007
|
-
|
|
2008
1909
|
const next = router.buildNext(navigateOpts);
|
|
2009
1910
|
const matches = router.matchRoutes(next.pathname, {
|
|
2010
1911
|
strictParseParams: true
|
|
@@ -2014,11 +1915,9 @@
|
|
|
2014
1915
|
},
|
|
2015
1916
|
preloadRoute: async function preloadRoute(navigateOpts, loaderOpts) {
|
|
2016
1917
|
var _ref3, _ref4, _loaderOpts$maxAge, _ref5, _ref6, _loaderOpts$gcMaxAge;
|
|
2017
|
-
|
|
2018
1918
|
if (navigateOpts === void 0) {
|
|
2019
1919
|
navigateOpts = router.location;
|
|
2020
1920
|
}
|
|
2021
|
-
|
|
2022
1921
|
const next = router.buildNext(navigateOpts);
|
|
2023
1922
|
const matches = router.matchRoutes(next.pathname, {
|
|
2024
1923
|
strictParseParams: true
|
|
@@ -2032,90 +1931,70 @@
|
|
|
2032
1931
|
},
|
|
2033
1932
|
matchRoutes: (pathname, opts) => {
|
|
2034
1933
|
var _router$state$pending3, _router$state$pending4;
|
|
2035
|
-
|
|
2036
1934
|
router.cleanMatchCache();
|
|
2037
1935
|
const matches = [];
|
|
2038
|
-
|
|
2039
1936
|
if (!router.routeTree) {
|
|
2040
1937
|
return matches;
|
|
2041
1938
|
}
|
|
2042
|
-
|
|
2043
1939
|
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 : [])];
|
|
2044
|
-
|
|
2045
1940
|
const recurse = async routes => {
|
|
2046
1941
|
var _parentMatch$params, _router$options$filte, _foundRoute$childRout;
|
|
2047
|
-
|
|
2048
1942
|
const parentMatch = last(matches);
|
|
2049
1943
|
let params = (_parentMatch$params = parentMatch == null ? void 0 : parentMatch.params) != null ? _parentMatch$params : {};
|
|
2050
1944
|
const filteredRoutes = (_router$options$filte = router.options.filterRoutes == null ? void 0 : router.options.filterRoutes(routes)) != null ? _router$options$filte : routes;
|
|
2051
1945
|
let foundRoutes = [];
|
|
2052
|
-
|
|
2053
1946
|
const findMatchInRoutes = (parentRoutes, routes) => {
|
|
2054
1947
|
routes.some(route => {
|
|
2055
1948
|
var _route$childRoutes, _route$childRoutes2, _route$options$caseSe;
|
|
2056
|
-
|
|
2057
1949
|
if (!route.routePath && (_route$childRoutes = route.childRoutes) != null && _route$childRoutes.length) {
|
|
2058
1950
|
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
|
|
2059
1951
|
}
|
|
2060
|
-
|
|
2061
1952
|
const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
|
|
2062
1953
|
const matchParams = matchPathname(pathname, {
|
|
2063
1954
|
to: route.fullPath,
|
|
2064
1955
|
fuzzy,
|
|
2065
1956
|
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
2066
1957
|
});
|
|
2067
|
-
|
|
2068
1958
|
if (matchParams) {
|
|
2069
1959
|
let parsedParams;
|
|
2070
|
-
|
|
2071
1960
|
try {
|
|
2072
1961
|
var _route$options$parseP;
|
|
2073
|
-
|
|
2074
1962
|
parsedParams = (_route$options$parseP = route.options.parseParams == null ? void 0 : route.options.parseParams(matchParams)) != null ? _route$options$parseP : matchParams;
|
|
2075
1963
|
} catch (err) {
|
|
2076
1964
|
if (opts != null && opts.strictParseParams) {
|
|
2077
1965
|
throw err;
|
|
2078
1966
|
}
|
|
2079
1967
|
}
|
|
2080
|
-
|
|
2081
1968
|
params = _extends({}, params, parsedParams);
|
|
2082
1969
|
}
|
|
2083
|
-
|
|
2084
1970
|
if (!!matchParams) {
|
|
2085
1971
|
foundRoutes = [...parentRoutes, route];
|
|
2086
1972
|
}
|
|
2087
|
-
|
|
2088
1973
|
return !!foundRoutes.length;
|
|
2089
1974
|
});
|
|
2090
1975
|
return !!foundRoutes.length;
|
|
2091
1976
|
};
|
|
2092
|
-
|
|
2093
1977
|
findMatchInRoutes([], filteredRoutes);
|
|
2094
|
-
|
|
2095
1978
|
if (!foundRoutes.length) {
|
|
2096
1979
|
return;
|
|
2097
1980
|
}
|
|
2098
|
-
|
|
2099
1981
|
foundRoutes.forEach(foundRoute => {
|
|
2100
1982
|
var _router$matchCache$ma;
|
|
2101
|
-
|
|
2102
1983
|
const interpolatedPath = interpolatePath(foundRoute.routePath, params);
|
|
2103
1984
|
const matchId = interpolatePath(foundRoute.routeId, params, true);
|
|
2104
1985
|
const match = existingMatches.find(d => d.matchId === matchId) || ((_router$matchCache$ma = router.matchCache[matchId]) == null ? void 0 : _router$matchCache$ma.match) || createRouteMatch(router, foundRoute, {
|
|
2105
1986
|
parentMatch,
|
|
2106
1987
|
matchId,
|
|
2107
1988
|
params,
|
|
2108
|
-
pathname: joinPaths([
|
|
1989
|
+
pathname: joinPaths([router.basepath, interpolatedPath])
|
|
2109
1990
|
});
|
|
2110
1991
|
matches.push(match);
|
|
2111
1992
|
});
|
|
2112
1993
|
const foundRoute = last(foundRoutes);
|
|
2113
|
-
|
|
2114
1994
|
if ((_foundRoute$childRout = foundRoute.childRoutes) != null && _foundRoute$childRout.length) {
|
|
2115
1995
|
recurse(foundRoute.childRoutes);
|
|
2116
1996
|
}
|
|
2117
1997
|
};
|
|
2118
|
-
|
|
2119
1998
|
recurse([router.routeTree]);
|
|
2120
1999
|
cascadeLoaderData(matches);
|
|
2121
2000
|
return matches;
|
|
@@ -2124,14 +2003,11 @@
|
|
|
2124
2003
|
const matchPromises = resolvedMatches.map(async match => {
|
|
2125
2004
|
// Validate the match (loads search params etc)
|
|
2126
2005
|
match.__.validate();
|
|
2127
|
-
|
|
2128
2006
|
match.load(loaderOpts);
|
|
2129
2007
|
const search = match.search;
|
|
2130
|
-
|
|
2131
2008
|
if (search.__data && search.__data.matchId !== match.matchId) {
|
|
2132
2009
|
return;
|
|
2133
2010
|
}
|
|
2134
|
-
|
|
2135
2011
|
if (match.__.loadPromise) {
|
|
2136
2012
|
// Wait for the first sign of activity from the match
|
|
2137
2013
|
await match.__.loadPromise;
|
|
@@ -2143,7 +2019,6 @@
|
|
|
2143
2019
|
loadMatchData: async routeMatch => {
|
|
2144
2020
|
if (isServer || !router.options.useServerData) {
|
|
2145
2021
|
var _await$routeMatch$opt;
|
|
2146
|
-
|
|
2147
2022
|
return (_await$routeMatch$opt = await (routeMatch.options.loader == null ? void 0 : routeMatch.options.loader({
|
|
2148
2023
|
// parentLoaderPromise: routeMatch.parentMatch?.__.dataPromise,
|
|
2149
2024
|
params: routeMatch.params,
|
|
@@ -2159,21 +2034,30 @@
|
|
|
2159
2034
|
}
|
|
2160
2035
|
})
|
|
2161
2036
|
});
|
|
2162
|
-
const res = await fetch(next.href, {
|
|
2163
|
-
method: 'GET' // signal: routeMatch.__.abortController.signal,
|
|
2164
2037
|
|
|
2038
|
+
// Refresh:
|
|
2039
|
+
// '/dashboard'
|
|
2040
|
+
// '/dashboard/invoices/'
|
|
2041
|
+
// '/dashboard/invoices/123'
|
|
2042
|
+
|
|
2043
|
+
// New:
|
|
2044
|
+
// '/dashboard/invoices/456'
|
|
2045
|
+
|
|
2046
|
+
// TODO: batch requests when possible
|
|
2047
|
+
|
|
2048
|
+
const res = await fetch(next.href, {
|
|
2049
|
+
method: 'GET'
|
|
2050
|
+
// signal: routeMatch.__.abortController.signal,
|
|
2165
2051
|
});
|
|
2166
2052
|
|
|
2167
2053
|
if (res.ok) {
|
|
2168
2054
|
return res.json();
|
|
2169
2055
|
}
|
|
2170
|
-
|
|
2171
2056
|
throw new Error('Failed to fetch match data');
|
|
2172
2057
|
}
|
|
2173
2058
|
},
|
|
2174
2059
|
invalidateRoute: opts => {
|
|
2175
2060
|
var _router$state$pending5, _router$state$pending6;
|
|
2176
|
-
|
|
2177
2061
|
const next = router.buildNext(opts);
|
|
2178
2062
|
const unloadedMatchIds = router.matchRoutes(next.pathname).map(d => d.matchId);
|
|
2179
2063
|
[...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 => {
|
|
@@ -2192,25 +2076,21 @@
|
|
|
2192
2076
|
},
|
|
2193
2077
|
matchRoute: (location, opts) => {
|
|
2194
2078
|
var _location$from;
|
|
2195
|
-
|
|
2196
2079
|
// const location = router.buildNext(opts)
|
|
2080
|
+
|
|
2197
2081
|
location = _extends({}, location, {
|
|
2198
2082
|
to: location.to ? router.resolvePath((_location$from = location.from) != null ? _location$from : '', location.to) : undefined
|
|
2199
2083
|
});
|
|
2200
2084
|
const next = router.buildNext(location);
|
|
2201
|
-
|
|
2202
2085
|
if (opts != null && opts.pending) {
|
|
2203
2086
|
var _router$state$pending7;
|
|
2204
|
-
|
|
2205
2087
|
if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
|
|
2206
2088
|
return false;
|
|
2207
2089
|
}
|
|
2208
|
-
|
|
2209
2090
|
return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
|
|
2210
2091
|
to: next.pathname
|
|
2211
2092
|
}));
|
|
2212
2093
|
}
|
|
2213
|
-
|
|
2214
2094
|
return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
|
|
2215
2095
|
to: next.pathname
|
|
2216
2096
|
}));
|
|
@@ -2226,17 +2106,16 @@
|
|
|
2226
2106
|
} = _ref7;
|
|
2227
2107
|
// If this link simply reloads the current route,
|
|
2228
2108
|
// make sure it has a new key so it will trigger a data refresh
|
|
2109
|
+
|
|
2229
2110
|
// If this `to` is a valid external URL, return
|
|
2230
2111
|
// null for LinkUtils
|
|
2231
2112
|
const toString = String(to);
|
|
2232
2113
|
const fromString = String(from);
|
|
2233
2114
|
let isExternal;
|
|
2234
|
-
|
|
2235
2115
|
try {
|
|
2236
2116
|
new URL("" + toString);
|
|
2237
2117
|
isExternal = true;
|
|
2238
2118
|
} catch (e) {}
|
|
2239
|
-
|
|
2240
2119
|
invariant(!isExternal, 'Attempting to navigate to external url with router.navigate!');
|
|
2241
2120
|
return router.__.navigate({
|
|
2242
2121
|
from: fromString,
|
|
@@ -2249,7 +2128,6 @@
|
|
|
2249
2128
|
},
|
|
2250
2129
|
buildLink: _ref8 => {
|
|
2251
2130
|
var _preload, _ref9;
|
|
2252
|
-
|
|
2253
2131
|
let {
|
|
2254
2132
|
from,
|
|
2255
2133
|
to = '.',
|
|
@@ -2265,11 +2143,12 @@
|
|
|
2265
2143
|
preloadDelay: userPreloadDelay,
|
|
2266
2144
|
disabled
|
|
2267
2145
|
} = _ref8;
|
|
2268
|
-
|
|
2269
2146
|
// If this link simply reloads the current route,
|
|
2270
2147
|
// make sure it has a new key so it will trigger a data refresh
|
|
2148
|
+
|
|
2271
2149
|
// If this `to` is a valid external URL, return
|
|
2272
2150
|
// null for LinkUtils
|
|
2151
|
+
|
|
2273
2152
|
try {
|
|
2274
2153
|
new URL("" + to);
|
|
2275
2154
|
return {
|
|
@@ -2277,7 +2156,6 @@
|
|
|
2277
2156
|
href: to
|
|
2278
2157
|
};
|
|
2279
2158
|
} catch (e) {}
|
|
2280
|
-
|
|
2281
2159
|
const nextOpts = {
|
|
2282
2160
|
from,
|
|
2283
2161
|
to,
|
|
@@ -2288,33 +2166,35 @@
|
|
|
2288
2166
|
};
|
|
2289
2167
|
const next = router.buildNext(nextOpts);
|
|
2290
2168
|
preload = (_preload = preload) != null ? _preload : router.options.defaultPreload;
|
|
2291
|
-
const preloadDelay = (_ref9 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultPreloadDelay) != null ? _ref9 : 0;
|
|
2169
|
+
const preloadDelay = (_ref9 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultPreloadDelay) != null ? _ref9 : 0;
|
|
2292
2170
|
|
|
2171
|
+
// Compare path/hash for matches
|
|
2293
2172
|
const pathIsEqual = router.state.location.pathname === next.pathname;
|
|
2294
2173
|
const currentPathSplit = router.state.location.pathname.split('/');
|
|
2295
2174
|
const nextPathSplit = next.pathname.split('/');
|
|
2296
2175
|
const pathIsFuzzyEqual = nextPathSplit.every((d, i) => d === currentPathSplit[i]);
|
|
2297
|
-
const hashIsEqual = router.state.location.hash === next.hash;
|
|
2298
|
-
|
|
2176
|
+
const hashIsEqual = router.state.location.hash === next.hash;
|
|
2177
|
+
// Combine the matches based on user options
|
|
2299
2178
|
const pathTest = activeOptions != null && activeOptions.exact ? pathIsEqual : pathIsFuzzyEqual;
|
|
2300
|
-
const hashTest = activeOptions != null && activeOptions.includeHash ? hashIsEqual : true;
|
|
2179
|
+
const hashTest = activeOptions != null && activeOptions.includeHash ? hashIsEqual : true;
|
|
2301
2180
|
|
|
2302
|
-
|
|
2181
|
+
// The final "active" test
|
|
2182
|
+
const isActive = pathTest && hashTest;
|
|
2303
2183
|
|
|
2184
|
+
// The click handler
|
|
2304
2185
|
const handleClick = e => {
|
|
2305
2186
|
if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!target || target === '_self') && e.button === 0) {
|
|
2306
2187
|
e.preventDefault();
|
|
2307
|
-
|
|
2308
2188
|
if (pathIsEqual && !search && !hash) {
|
|
2309
2189
|
router.invalidateRoute(nextOpts);
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2190
|
+
}
|
|
2312
2191
|
|
|
2192
|
+
// All is well? Navigate!)
|
|
2313
2193
|
router.__.navigate(nextOpts);
|
|
2314
2194
|
}
|
|
2315
|
-
};
|
|
2316
|
-
|
|
2195
|
+
};
|
|
2317
2196
|
|
|
2197
|
+
// The click handler
|
|
2318
2198
|
const handleFocus = e => {
|
|
2319
2199
|
if (preload) {
|
|
2320
2200
|
router.preloadRoute(nextOpts, {
|
|
@@ -2323,15 +2203,12 @@
|
|
|
2323
2203
|
});
|
|
2324
2204
|
}
|
|
2325
2205
|
};
|
|
2326
|
-
|
|
2327
2206
|
const handleEnter = e => {
|
|
2328
2207
|
const target = e.target || {};
|
|
2329
|
-
|
|
2330
2208
|
if (preload) {
|
|
2331
2209
|
if (target.preloadTimeout) {
|
|
2332
2210
|
return;
|
|
2333
2211
|
}
|
|
2334
|
-
|
|
2335
2212
|
target.preloadTimeout = setTimeout(() => {
|
|
2336
2213
|
target.preloadTimeout = null;
|
|
2337
2214
|
router.preloadRoute(nextOpts, {
|
|
@@ -2341,16 +2218,13 @@
|
|
|
2341
2218
|
}, preloadDelay);
|
|
2342
2219
|
}
|
|
2343
2220
|
};
|
|
2344
|
-
|
|
2345
2221
|
const handleLeave = e => {
|
|
2346
2222
|
const target = e.target || {};
|
|
2347
|
-
|
|
2348
2223
|
if (target.preloadTimeout) {
|
|
2349
2224
|
clearTimeout(target.preloadTimeout);
|
|
2350
2225
|
target.preloadTimeout = null;
|
|
2351
2226
|
}
|
|
2352
2227
|
};
|
|
2353
|
-
|
|
2354
2228
|
return {
|
|
2355
2229
|
type: 'internal',
|
|
2356
2230
|
next,
|
|
@@ -2364,21 +2238,15 @@
|
|
|
2364
2238
|
},
|
|
2365
2239
|
buildNext: opts => {
|
|
2366
2240
|
const next = router.__.buildLocation(opts);
|
|
2367
|
-
|
|
2368
2241
|
const matches = router.matchRoutes(next.pathname);
|
|
2369
|
-
|
|
2370
2242
|
const __preSearchFilters = matches.map(match => {
|
|
2371
2243
|
var _match$options$preSea;
|
|
2372
|
-
|
|
2373
2244
|
return (_match$options$preSea = match.options.preSearchFilters) != null ? _match$options$preSea : [];
|
|
2374
2245
|
}).flat().filter(Boolean);
|
|
2375
|
-
|
|
2376
2246
|
const __postSearchFilters = matches.map(match => {
|
|
2377
2247
|
var _match$options$postSe;
|
|
2378
|
-
|
|
2379
2248
|
return (_match$options$postSe = match.options.postSearchFilters) != null ? _match$options$postSe : [];
|
|
2380
2249
|
}).flat().filter(Boolean);
|
|
2381
|
-
|
|
2382
2250
|
return router.__.buildLocation(_extends({}, opts, {
|
|
2383
2251
|
__preSearchFilters,
|
|
2384
2252
|
__postSearchFilters
|
|
@@ -2391,12 +2259,10 @@
|
|
|
2391
2259
|
const routeOptions = routeConfig.options;
|
|
2392
2260
|
const route = createRoute(routeConfig, routeOptions, parent, router);
|
|
2393
2261
|
const existingRoute = router.routesById[route.routeId];
|
|
2394
|
-
|
|
2395
2262
|
if (existingRoute) {
|
|
2396
2263
|
{
|
|
2397
2264
|
console.warn("Duplicate routes found with id: " + String(route.routeId), router.routesById, route);
|
|
2398
2265
|
}
|
|
2399
|
-
|
|
2400
2266
|
throw new Error();
|
|
2401
2267
|
}
|
|
2402
2268
|
router.routesById[route.routeId] = route;
|
|
@@ -2405,13 +2271,11 @@
|
|
|
2405
2271
|
return route;
|
|
2406
2272
|
});
|
|
2407
2273
|
};
|
|
2408
|
-
|
|
2409
2274
|
const routes = recurseRoutes([rootRouteConfig]);
|
|
2410
2275
|
return routes[0];
|
|
2411
2276
|
},
|
|
2412
2277
|
parseLocation: (location, previousLocation) => {
|
|
2413
2278
|
var _location$hash$split$;
|
|
2414
|
-
|
|
2415
2279
|
const parsedSearch = router.options.parseSearch(location.search);
|
|
2416
2280
|
return {
|
|
2417
2281
|
pathname: location.pathname,
|
|
@@ -2429,41 +2293,36 @@
|
|
|
2429
2293
|
},
|
|
2430
2294
|
buildLocation: function buildLocation(dest) {
|
|
2431
2295
|
var _dest$from, _router$basepath, _dest$to, _last, _dest$params, _dest$__preSearchFilt, _functionalUpdate, _dest$__preSearchFilt2, _dest$__postSearchFil;
|
|
2432
|
-
|
|
2433
2296
|
if (dest === void 0) {
|
|
2434
2297
|
dest = {};
|
|
2435
2298
|
}
|
|
2436
|
-
|
|
2437
2299
|
// const resolvedFrom: Location = {
|
|
2438
2300
|
// ...router.location,
|
|
2439
2301
|
const fromPathname = dest.fromCurrent ? router.location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.location.pathname;
|
|
2440
|
-
|
|
2441
2302
|
let pathname = resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
|
|
2442
|
-
|
|
2443
2303
|
const fromMatches = router.matchRoutes(router.location.pathname, {
|
|
2444
2304
|
strictParseParams: true
|
|
2445
2305
|
});
|
|
2446
2306
|
const toMatches = router.matchRoutes(pathname);
|
|
2447
|
-
|
|
2448
2307
|
const prevParams = _extends({}, (_last = last(fromMatches)) == null ? void 0 : _last.params);
|
|
2449
|
-
|
|
2450
2308
|
let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
|
|
2451
|
-
|
|
2452
2309
|
if (nextParams) {
|
|
2453
2310
|
toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
|
|
2454
2311
|
Object.assign({}, nextParams, fn(nextParams));
|
|
2455
2312
|
});
|
|
2456
2313
|
}
|
|
2314
|
+
pathname = interpolatePath(pathname, nextParams != null ? nextParams : {});
|
|
2457
2315
|
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
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
|
|
2316
|
+
// Pre filters first
|
|
2317
|
+
const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.location.search) : router.location.search;
|
|
2461
2318
|
|
|
2319
|
+
// Then the link/navigate function
|
|
2462
2320
|
const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
|
|
2463
2321
|
: dest.search ? (_functionalUpdate = functionalUpdate(dest.search, preFilteredSearch)) != null ? _functionalUpdate : {} // Updater
|
|
2464
2322
|
: (_dest$__preSearchFilt2 = dest.__preSearchFilters) != null && _dest$__preSearchFilt2.length ? preFilteredSearch // Preserve resolvedFrom filters
|
|
2465
|
-
: {};
|
|
2323
|
+
: {};
|
|
2466
2324
|
|
|
2325
|
+
// Then post filters
|
|
2467
2326
|
const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
|
|
2468
2327
|
const search = replaceEqualDeep(router.location.search, postFilteredSearch);
|
|
2469
2328
|
const searchStr = router.options.stringifySearch(search);
|
|
@@ -2483,17 +2342,13 @@
|
|
|
2483
2342
|
const id = '' + Date.now() + Math.random();
|
|
2484
2343
|
if (router.navigateTimeout) clearTimeout(router.navigateTimeout);
|
|
2485
2344
|
let nextAction = 'replace';
|
|
2486
|
-
|
|
2487
2345
|
if (!replace) {
|
|
2488
2346
|
nextAction = 'push';
|
|
2489
2347
|
}
|
|
2490
|
-
|
|
2491
2348
|
const isSameUrl = router.__.parseLocation(history.location).href === next.href;
|
|
2492
|
-
|
|
2493
2349
|
if (isSameUrl && !next.key) {
|
|
2494
2350
|
nextAction = 'replace';
|
|
2495
2351
|
}
|
|
2496
|
-
|
|
2497
2352
|
if (nextAction === 'replace') {
|
|
2498
2353
|
history.replace({
|
|
2499
2354
|
pathname: next.pathname,
|
|
@@ -2511,33 +2366,30 @@
|
|
|
2511
2366
|
id
|
|
2512
2367
|
});
|
|
2513
2368
|
}
|
|
2514
|
-
|
|
2515
2369
|
router.navigationPromise = new Promise(resolve => {
|
|
2516
2370
|
const previousNavigationResolve = router.resolveNavigation;
|
|
2517
|
-
|
|
2518
2371
|
router.resolveNavigation = () => {
|
|
2519
2372
|
previousNavigationResolve();
|
|
2520
2373
|
resolve();
|
|
2374
|
+
delete router.navigationPromise;
|
|
2521
2375
|
};
|
|
2522
2376
|
});
|
|
2523
2377
|
return router.navigationPromise;
|
|
2524
2378
|
}
|
|
2525
2379
|
}
|
|
2526
2380
|
};
|
|
2527
|
-
router.update(userOptions);
|
|
2381
|
+
router.update(userOptions);
|
|
2528
2382
|
|
|
2383
|
+
// Allow frameworks to hook into the router creation
|
|
2529
2384
|
router.options.createRouter == null ? void 0 : router.options.createRouter(router);
|
|
2530
2385
|
return router;
|
|
2531
2386
|
}
|
|
2532
|
-
|
|
2533
2387
|
function isCtrlEvent(e) {
|
|
2534
2388
|
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
2535
2389
|
}
|
|
2536
|
-
|
|
2537
2390
|
function cascadeLoaderData(matches) {
|
|
2538
2391
|
matches.forEach((match, index) => {
|
|
2539
2392
|
const parent = matches[index - 1];
|
|
2540
|
-
|
|
2541
2393
|
if (parent) {
|
|
2542
2394
|
match.loaderData = replaceEqualDeep(match.loaderData, _extends({}, parent.loaderData, match.routeLoaderData));
|
|
2543
2395
|
}
|
|
@@ -2545,8 +2397,8 @@
|
|
|
2545
2397
|
}
|
|
2546
2398
|
|
|
2547
2399
|
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"],
|
|
2548
|
-
|
|
2549
|
-
|
|
2400
|
+
_excluded2 = ["pending", "caseSensitive", "children"],
|
|
2401
|
+
_excluded3 = ["router"];
|
|
2550
2402
|
function lazy(importer) {
|
|
2551
2403
|
const lazyComp = /*#__PURE__*/React__namespace.lazy(importer);
|
|
2552
2404
|
let promise;
|
|
@@ -2558,7 +2410,6 @@
|
|
|
2558
2410
|
} : {}, props));
|
|
2559
2411
|
});
|
|
2560
2412
|
const finalComp = forwardedComp;
|
|
2561
|
-
|
|
2562
2413
|
finalComp.preload = () => {
|
|
2563
2414
|
if (!promise) {
|
|
2564
2415
|
promise = importer().then(module => {
|
|
@@ -2566,13 +2417,12 @@
|
|
|
2566
2417
|
return resolvedComp;
|
|
2567
2418
|
});
|
|
2568
2419
|
}
|
|
2569
|
-
|
|
2570
2420
|
return promise;
|
|
2571
2421
|
};
|
|
2572
|
-
|
|
2573
2422
|
return finalComp;
|
|
2574
2423
|
}
|
|
2575
2424
|
//
|
|
2425
|
+
|
|
2576
2426
|
function Link(props) {
|
|
2577
2427
|
const router = useRouter();
|
|
2578
2428
|
return /*#__PURE__*/React__namespace.createElement(router.Link, props);
|
|
@@ -2582,11 +2432,9 @@
|
|
|
2582
2432
|
function MatchesProvider(props) {
|
|
2583
2433
|
return /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, props);
|
|
2584
2434
|
}
|
|
2585
|
-
|
|
2586
2435
|
const useRouterSubscription = router => {
|
|
2587
2436
|
shim.useSyncExternalStore(cb => router.subscribe(() => cb()), () => router.state, () => router.state);
|
|
2588
2437
|
};
|
|
2589
|
-
|
|
2590
2438
|
function createReactRouter(opts) {
|
|
2591
2439
|
const makeRouteExt = (route, router) => {
|
|
2592
2440
|
return {
|
|
@@ -2594,7 +2442,6 @@
|
|
|
2594
2442
|
if (subRouteId === void 0) {
|
|
2595
2443
|
subRouteId = '.';
|
|
2596
2444
|
}
|
|
2597
|
-
|
|
2598
2445
|
const resolvedRouteId = router.resolvePath(route.routeId, subRouteId);
|
|
2599
2446
|
const resolvedRoute = router.getRoute(resolvedRouteId);
|
|
2600
2447
|
useRouterSubscription(router);
|
|
@@ -2603,27 +2450,25 @@
|
|
|
2603
2450
|
},
|
|
2604
2451
|
linkProps: options => {
|
|
2605
2452
|
var _functionalUpdate, _functionalUpdate2;
|
|
2606
|
-
|
|
2607
2453
|
const {
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2454
|
+
// custom props
|
|
2455
|
+
|
|
2456
|
+
target,
|
|
2457
|
+
activeProps = () => ({
|
|
2458
|
+
className: 'active'
|
|
2459
|
+
}),
|
|
2460
|
+
inactiveProps = () => ({}),
|
|
2461
|
+
disabled,
|
|
2462
|
+
// element props
|
|
2463
|
+
style,
|
|
2464
|
+
className,
|
|
2465
|
+
onClick,
|
|
2466
|
+
onFocus,
|
|
2467
|
+
onMouseEnter,
|
|
2468
|
+
onMouseLeave
|
|
2469
|
+
} = options,
|
|
2470
|
+
rest = _objectWithoutPropertiesLoose(options, _excluded);
|
|
2625
2471
|
const linkInfo = route.buildLink(options);
|
|
2626
|
-
|
|
2627
2472
|
if (linkInfo.type === 'external') {
|
|
2628
2473
|
const {
|
|
2629
2474
|
href
|
|
@@ -2632,7 +2477,6 @@
|
|
|
2632
2477
|
href
|
|
2633
2478
|
};
|
|
2634
2479
|
}
|
|
2635
|
-
|
|
2636
2480
|
const {
|
|
2637
2481
|
handleClick,
|
|
2638
2482
|
handleFocus,
|
|
@@ -2641,24 +2485,24 @@
|
|
|
2641
2485
|
isActive,
|
|
2642
2486
|
next
|
|
2643
2487
|
} = linkInfo;
|
|
2644
|
-
|
|
2645
2488
|
const reactHandleClick = e => {
|
|
2646
|
-
if (React__namespace.startTransition)
|
|
2489
|
+
if (React__namespace.startTransition)
|
|
2490
|
+
// This is a hack for react < 18
|
|
2647
2491
|
React__namespace.startTransition(() => {
|
|
2648
2492
|
handleClick(e);
|
|
2649
2493
|
});else handleClick(e);
|
|
2650
2494
|
};
|
|
2651
|
-
|
|
2652
2495
|
const composeHandlers = handlers => e => {
|
|
2653
2496
|
e.persist();
|
|
2654
2497
|
handlers.forEach(handler => {
|
|
2655
2498
|
if (handler) handler(e);
|
|
2656
2499
|
});
|
|
2657
|
-
};
|
|
2658
|
-
|
|
2500
|
+
};
|
|
2659
2501
|
|
|
2660
|
-
|
|
2502
|
+
// Get the active props
|
|
2503
|
+
const resolvedActiveProps = isActive ? (_functionalUpdate = functionalUpdate(activeProps, {})) != null ? _functionalUpdate : {} : {};
|
|
2661
2504
|
|
|
2505
|
+
// Get the inactive props
|
|
2662
2506
|
const resolvedInactiveProps = isActive ? {} : (_functionalUpdate2 = functionalUpdate(inactiveProps, {})) != null ? _functionalUpdate2 : {};
|
|
2663
2507
|
return _extends$2({}, resolvedActiveProps, resolvedInactiveProps, rest, {
|
|
2664
2508
|
href: disabled ? undefined : next.href,
|
|
@@ -2689,25 +2533,21 @@
|
|
|
2689
2533
|
}),
|
|
2690
2534
|
MatchRoute: opts => {
|
|
2691
2535
|
const {
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2536
|
+
pending,
|
|
2537
|
+
caseSensitive
|
|
2538
|
+
} = opts,
|
|
2539
|
+
rest = _objectWithoutPropertiesLoose(opts, _excluded2);
|
|
2697
2540
|
const params = route.matchRoute(rest, {
|
|
2698
2541
|
pending,
|
|
2699
2542
|
caseSensitive
|
|
2700
2543
|
});
|
|
2701
|
-
|
|
2702
2544
|
if (!params) {
|
|
2703
2545
|
return null;
|
|
2704
2546
|
}
|
|
2705
|
-
|
|
2706
2547
|
return typeof opts.children === 'function' ? opts.children(params) : opts.children;
|
|
2707
2548
|
}
|
|
2708
2549
|
};
|
|
2709
2550
|
};
|
|
2710
|
-
|
|
2711
2551
|
const coreRouter = createRouter(_extends$2({}, opts, {
|
|
2712
2552
|
createRouter: router => {
|
|
2713
2553
|
const routerExt = {
|
|
@@ -2716,18 +2556,15 @@
|
|
|
2716
2556
|
return router.state;
|
|
2717
2557
|
},
|
|
2718
2558
|
useMatch: (routeId, opts) => {
|
|
2719
|
-
var
|
|
2720
|
-
|
|
2559
|
+
var _opts$strict;
|
|
2721
2560
|
useRouterSubscription(router);
|
|
2722
2561
|
invariant(routeId !== rootRouteId, "\"" + rootRouteId + "\" cannot be used with useMatch! Did you mean to useRoute(\"" + rootRouteId + "\")?");
|
|
2723
|
-
const
|
|
2562
|
+
const nearestMatch = useNearestMatch();
|
|
2724
2563
|
const match = router.state.matches.find(d => d.routeId === routeId);
|
|
2725
|
-
|
|
2726
2564
|
if ((_opts$strict = opts == null ? void 0 : opts.strict) != null ? _opts$strict : true) {
|
|
2727
2565
|
invariant(match, "Could not find an active match for \"" + routeId + "\"!");
|
|
2728
|
-
invariant(
|
|
2566
|
+
invariant(nearestMatch.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 '" + nearestMatch.routeId + "' route. Did you mean to 'useMatch(\"" + (match == null ? void 0 : match.routeId) + "\", { strict: false })' or 'useRoute(\"" + (match == null ? void 0 : match.routeId) + "\")' instead?");
|
|
2729
2567
|
}
|
|
2730
|
-
|
|
2731
2568
|
return match;
|
|
2732
2569
|
}
|
|
2733
2570
|
};
|
|
@@ -2744,7 +2581,8 @@
|
|
|
2744
2581
|
},
|
|
2745
2582
|
loadComponent: async component => {
|
|
2746
2583
|
if (component.preload && typeof document !== 'undefined') {
|
|
2747
|
-
component.preload();
|
|
2584
|
+
component.preload();
|
|
2585
|
+
// return await component.preload()
|
|
2748
2586
|
}
|
|
2749
2587
|
|
|
2750
2588
|
return component;
|
|
@@ -2753,29 +2591,22 @@
|
|
|
2753
2591
|
return coreRouter;
|
|
2754
2592
|
}
|
|
2755
2593
|
function RouterProvider(_ref2) {
|
|
2756
|
-
var _router$options$useCo;
|
|
2757
|
-
|
|
2758
2594
|
let {
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
rest = _objectWithoutPropertiesLoose(_ref2, _excluded3);
|
|
2763
|
-
|
|
2595
|
+
router
|
|
2596
|
+
} = _ref2,
|
|
2597
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded3);
|
|
2764
2598
|
router.update(rest);
|
|
2765
|
-
const defaultRouterContext = React__namespace.useRef({});
|
|
2766
|
-
const userContext = (_router$options$useCo = router.options.useContext == null ? void 0 : router.options.useContext()) != null ? _router$options$useCo : defaultRouterContext.current;
|
|
2767
|
-
router.context = userContext;
|
|
2768
2599
|
useRouterSubscription(router);
|
|
2769
2600
|
React__namespace.useEffect(() => {
|
|
2770
2601
|
return router.mount();
|
|
2771
2602
|
}, [router]);
|
|
2772
|
-
return /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
|
|
2603
|
+
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
|
|
2773
2604
|
value: {
|
|
2774
2605
|
router: router
|
|
2775
2606
|
}
|
|
2776
2607
|
}, /*#__PURE__*/React__namespace.createElement(MatchesProvider, {
|
|
2777
|
-
value: router.state.matches
|
|
2778
|
-
},
|
|
2608
|
+
value: [undefined, ...router.state.matches]
|
|
2609
|
+
}, /*#__PURE__*/React__namespace.createElement(Outlet, null))));
|
|
2779
2610
|
}
|
|
2780
2611
|
function useRouter() {
|
|
2781
2612
|
const value = React__namespace.useContext(routerContext);
|
|
@@ -2791,9 +2622,7 @@
|
|
|
2791
2622
|
return router.useMatch(routeId, opts);
|
|
2792
2623
|
}
|
|
2793
2624
|
function useNearestMatch() {
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
const runtimeMatch = (_useMatches2 = useMatches()) == null ? void 0 : _useMatches2[0];
|
|
2625
|
+
const runtimeMatch = useMatches()[0];
|
|
2797
2626
|
invariant(runtimeMatch, "Could not find a nearest match!");
|
|
2798
2627
|
return runtimeMatch;
|
|
2799
2628
|
}
|
|
@@ -2814,16 +2643,13 @@
|
|
|
2814
2643
|
}
|
|
2815
2644
|
function Outlet() {
|
|
2816
2645
|
var _ref3, _match$__$pendingComp, _match$__$errorCompon;
|
|
2817
|
-
|
|
2818
2646
|
const router = useRouter();
|
|
2819
2647
|
const matches = useMatches().slice(1);
|
|
2820
2648
|
const match = matches[0];
|
|
2821
2649
|
const defaultPending = React__namespace.useCallback(() => null, []);
|
|
2822
|
-
|
|
2823
2650
|
if (!match) {
|
|
2824
2651
|
return null;
|
|
2825
2652
|
}
|
|
2826
|
-
|
|
2827
2653
|
const PendingComponent = (_ref3 = (_match$__$pendingComp = match.__.pendingComponent) != null ? _match$__$pendingComp : router.options.defaultPendingComponent) != null ? _ref3 : defaultPending;
|
|
2828
2654
|
const errorComponent = (_match$__$errorCompon = match.__.errorComponent) != null ? _match$__$errorCompon : router.options.defaultErrorComponent;
|
|
2829
2655
|
return /*#__PURE__*/React__namespace.createElement(MatchesProvider, {
|
|
@@ -2831,23 +2657,20 @@
|
|
|
2831
2657
|
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
2832
2658
|
fallback: /*#__PURE__*/React__namespace.createElement(PendingComponent, null)
|
|
2833
2659
|
}, /*#__PURE__*/React__namespace.createElement(CatchBoundary, {
|
|
2660
|
+
key: match.routeId,
|
|
2834
2661
|
errorComponent: errorComponent,
|
|
2835
|
-
|
|
2662
|
+
match: match
|
|
2836
2663
|
}, (() => {
|
|
2837
2664
|
if (match.status === 'error') {
|
|
2838
2665
|
throw match.error;
|
|
2839
2666
|
}
|
|
2840
|
-
|
|
2841
2667
|
if (match.status === 'success') {
|
|
2842
2668
|
var _ref4, _ref5;
|
|
2843
|
-
|
|
2844
2669
|
return /*#__PURE__*/React__namespace.createElement((_ref4 = (_ref5 = match.__.component) != null ? _ref5 : router.options.defaultComponent) != null ? _ref4 : Outlet);
|
|
2845
2670
|
}
|
|
2846
|
-
|
|
2847
2671
|
throw match.__.loadPromise;
|
|
2848
2672
|
})())));
|
|
2849
2673
|
}
|
|
2850
|
-
|
|
2851
2674
|
class CatchBoundary extends React__namespace.Component {
|
|
2852
2675
|
constructor() {
|
|
2853
2676
|
super(...arguments);
|
|
@@ -2856,30 +2679,27 @@
|
|
|
2856
2679
|
info: undefined
|
|
2857
2680
|
};
|
|
2858
2681
|
}
|
|
2859
|
-
|
|
2860
2682
|
componentDidCatch(error, info) {
|
|
2683
|
+
console.error("Error in route match: " + this.props.match.matchId);
|
|
2861
2684
|
console.error(error);
|
|
2862
2685
|
this.setState({
|
|
2863
2686
|
error,
|
|
2864
2687
|
info
|
|
2865
2688
|
});
|
|
2866
2689
|
}
|
|
2867
|
-
|
|
2868
2690
|
render() {
|
|
2869
2691
|
return /*#__PURE__*/React__namespace.createElement(CatchBoundaryInner, _extends$2({}, this.props, {
|
|
2870
2692
|
errorState: this.state,
|
|
2871
2693
|
reset: () => this.setState({})
|
|
2872
2694
|
}));
|
|
2873
2695
|
}
|
|
2696
|
+
}
|
|
2874
2697
|
|
|
2875
|
-
|
|
2698
|
+
// This is the messiest thing ever... I'm either seriously tired (likely) or
|
|
2876
2699
|
// there has to be a better way to reset error boundaries when the
|
|
2877
2700
|
// router's location key changes.
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
2701
|
function CatchBoundaryInner(props) {
|
|
2881
2702
|
var _props$errorComponent;
|
|
2882
|
-
|
|
2883
2703
|
const [activeErrorState, setActiveErrorState] = React__namespace.useState(props.errorState);
|
|
2884
2704
|
const router = useRouter();
|
|
2885
2705
|
const errorComponent = (_props$errorComponent = props.errorComponent) != null ? _props$errorComponent : DefaultErrorBoundary;
|
|
@@ -2893,24 +2713,19 @@
|
|
|
2893
2713
|
}
|
|
2894
2714
|
});
|
|
2895
2715
|
}
|
|
2896
|
-
|
|
2897
2716
|
return;
|
|
2898
2717
|
}, [activeErrorState]);
|
|
2899
2718
|
React__namespace.useEffect(() => {
|
|
2900
2719
|
if (props.errorState.error) {
|
|
2901
2720
|
setActiveErrorState(props.errorState);
|
|
2902
2721
|
}
|
|
2903
|
-
|
|
2904
2722
|
props.reset();
|
|
2905
2723
|
}, [props.errorState.error]);
|
|
2906
|
-
|
|
2907
2724
|
if (activeErrorState.error) {
|
|
2908
2725
|
return /*#__PURE__*/React__namespace.createElement(errorComponent, activeErrorState);
|
|
2909
2726
|
}
|
|
2910
|
-
|
|
2911
2727
|
return props.children;
|
|
2912
2728
|
}
|
|
2913
|
-
|
|
2914
2729
|
function DefaultErrorBoundary(_ref6) {
|
|
2915
2730
|
let {
|
|
2916
2731
|
error
|