@tanstack/router-core 1.131.5 → 1.131.12
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/dist/cjs/router.cjs +73 -52
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +73 -52
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +96 -66
package/dist/cjs/router.cjs
CHANGED
|
@@ -219,8 +219,8 @@ class RouterCore {
|
|
|
219
219
|
const match = this.getMatch(id);
|
|
220
220
|
if (!match) return;
|
|
221
221
|
match.abortController.abort();
|
|
222
|
-
match._nonReactive.pendingTimeout = void 0;
|
|
223
222
|
clearTimeout(match._nonReactive.pendingTimeout);
|
|
223
|
+
match._nonReactive.pendingTimeout = void 0;
|
|
224
224
|
};
|
|
225
225
|
this.cancelMatches = () => {
|
|
226
226
|
var _a;
|
|
@@ -236,7 +236,7 @@ class RouterCore {
|
|
|
236
236
|
_buildLocation: true
|
|
237
237
|
});
|
|
238
238
|
const lastMatch = utils.last(allCurrentLocationMatches);
|
|
239
|
-
let fromPath = lastMatch.fullPath;
|
|
239
|
+
let fromPath = this.resolvePathWithBase(lastMatch.fullPath, ".");
|
|
240
240
|
const toPath = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
241
241
|
const routeIsChanging = !!dest.to && !comparePaths(dest.to.toString(), fromPath) && !comparePaths(toPath, fromPath);
|
|
242
242
|
if (dest.unsafeRelative === "path") {
|
|
@@ -259,6 +259,7 @@ class RouterCore {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
+
fromPath = this.resolvePathWithBase(fromPath, ".");
|
|
262
263
|
const fromSearch = lastMatch.search;
|
|
263
264
|
const fromParams = { ...lastMatch.params };
|
|
264
265
|
const nextTo = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
@@ -736,20 +737,22 @@ class RouterCore {
|
|
|
736
737
|
}
|
|
737
738
|
}
|
|
738
739
|
}
|
|
739
|
-
(
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
err.routeId
|
|
740
|
+
if (match) {
|
|
741
|
+
(_a = match._nonReactive.beforeLoadPromise) == null ? void 0 : _a.resolve();
|
|
742
|
+
(_b = match._nonReactive.loaderPromise) == null ? void 0 : _b.resolve();
|
|
743
|
+
match._nonReactive.beforeLoadPromise = void 0;
|
|
744
|
+
match._nonReactive.loaderPromise = void 0;
|
|
745
|
+
updateMatch(match.id, (prev) => ({
|
|
746
|
+
...prev,
|
|
747
|
+
status: redirect.isRedirect(err) ? "redirected" : notFound.isNotFound(err) ? "notFound" : "error",
|
|
748
|
+
isFetching: false,
|
|
749
|
+
error: err
|
|
750
|
+
}));
|
|
751
|
+
if (!err.routeId) {
|
|
752
|
+
err.routeId = match.routeId;
|
|
753
|
+
}
|
|
754
|
+
(_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
|
|
751
755
|
}
|
|
752
|
-
(_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
|
|
753
756
|
if (redirect.isRedirect(err)) {
|
|
754
757
|
rendered = true;
|
|
755
758
|
err.options._fromLocation = location;
|
|
@@ -980,33 +983,39 @@ class RouterCore {
|
|
|
980
983
|
let loaderShouldRunAsync = false;
|
|
981
984
|
let loaderIsRunningAsync = false;
|
|
982
985
|
const route = this.looseRoutesById[routeId];
|
|
983
|
-
const executeHead =
|
|
986
|
+
const executeHead = () => {
|
|
984
987
|
var _a3, _b3, _c2, _d2, _e, _f;
|
|
985
988
|
const match = this.getMatch(matchId);
|
|
986
989
|
if (!match) {
|
|
987
990
|
return;
|
|
988
991
|
}
|
|
992
|
+
if (!route.options.head && !route.options.scripts && !route.options.headers) {
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
989
995
|
const assetContext = {
|
|
990
996
|
matches,
|
|
991
997
|
match,
|
|
992
998
|
params: match.params,
|
|
993
999
|
loaderData: match.loaderData
|
|
994
1000
|
};
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1001
|
+
return Promise.all([
|
|
1002
|
+
(_b3 = (_a3 = route.options).head) == null ? void 0 : _b3.call(_a3, assetContext),
|
|
1003
|
+
(_d2 = (_c2 = route.options).scripts) == null ? void 0 : _d2.call(_c2, assetContext),
|
|
1004
|
+
(_f = (_e = route.options).headers) == null ? void 0 : _f.call(_e, assetContext)
|
|
1005
|
+
]).then(([headFnContent, scripts, headers]) => {
|
|
1006
|
+
const meta = headFnContent == null ? void 0 : headFnContent.meta;
|
|
1007
|
+
const links = headFnContent == null ? void 0 : headFnContent.links;
|
|
1008
|
+
const headScripts = headFnContent == null ? void 0 : headFnContent.scripts;
|
|
1009
|
+
const styles = headFnContent == null ? void 0 : headFnContent.styles;
|
|
1010
|
+
return {
|
|
1011
|
+
meta,
|
|
1012
|
+
links,
|
|
1013
|
+
headScripts,
|
|
1014
|
+
headers,
|
|
1015
|
+
scripts,
|
|
1016
|
+
styles
|
|
1017
|
+
};
|
|
1018
|
+
});
|
|
1010
1019
|
};
|
|
1011
1020
|
const potentialPendingMinPromise = async () => {
|
|
1012
1021
|
const latestMatch = this.getMatch(matchId);
|
|
@@ -1017,11 +1026,14 @@ class RouterCore {
|
|
|
1017
1026
|
const prevMatch = this.getMatch(matchId);
|
|
1018
1027
|
if (shouldSkipLoader(matchId)) {
|
|
1019
1028
|
if (this.isServer) {
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1029
|
+
const headResult = executeHead();
|
|
1030
|
+
if (headResult) {
|
|
1031
|
+
const head = await headResult;
|
|
1032
|
+
updateMatch(matchId, (prev) => ({
|
|
1033
|
+
...prev,
|
|
1034
|
+
...head
|
|
1035
|
+
}));
|
|
1036
|
+
}
|
|
1025
1037
|
return this.getMatch(matchId);
|
|
1026
1038
|
}
|
|
1027
1039
|
} else if (prevMatch._nonReactive.loaderPromise) {
|
|
@@ -1090,7 +1102,8 @@ class RouterCore {
|
|
|
1090
1102
|
loaderData
|
|
1091
1103
|
}));
|
|
1092
1104
|
await route._lazyPromise;
|
|
1093
|
-
const
|
|
1105
|
+
const headResult = executeHead();
|
|
1106
|
+
const head = headResult ? await headResult : void 0;
|
|
1094
1107
|
await potentialPendingMinPromise();
|
|
1095
1108
|
await route._componentsPromise;
|
|
1096
1109
|
updateMatch(matchId, (prev) => ({
|
|
@@ -1114,7 +1127,8 @@ class RouterCore {
|
|
|
1114
1127
|
onErrorError
|
|
1115
1128
|
);
|
|
1116
1129
|
}
|
|
1117
|
-
const
|
|
1130
|
+
const headResult = executeHead();
|
|
1131
|
+
const head = headResult ? await headResult : void 0;
|
|
1118
1132
|
updateMatch(matchId, (prev) => ({
|
|
1119
1133
|
...prev,
|
|
1120
1134
|
error,
|
|
@@ -1124,15 +1138,19 @@ class RouterCore {
|
|
|
1124
1138
|
}));
|
|
1125
1139
|
}
|
|
1126
1140
|
} catch (err) {
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1141
|
+
const match = this.getMatch(matchId);
|
|
1142
|
+
if (match) {
|
|
1143
|
+
const headResult = executeHead();
|
|
1144
|
+
if (headResult) {
|
|
1145
|
+
const head = await headResult;
|
|
1146
|
+
updateMatch(matchId, (prev) => ({
|
|
1147
|
+
...prev,
|
|
1148
|
+
...head
|
|
1149
|
+
}));
|
|
1150
|
+
}
|
|
1151
|
+
match._nonReactive.loaderPromise = void 0;
|
|
1152
|
+
}
|
|
1153
|
+
handleRedirectAndNotFound(match, err);
|
|
1136
1154
|
}
|
|
1137
1155
|
};
|
|
1138
1156
|
const { status, invalid } = this.getMatch(matchId);
|
|
@@ -1157,11 +1175,14 @@ class RouterCore {
|
|
|
1157
1175
|
} else if (status !== "success" || loaderShouldRunAsync && sync) {
|
|
1158
1176
|
await runLoader();
|
|
1159
1177
|
} else {
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1178
|
+
const headResult = executeHead();
|
|
1179
|
+
if (headResult) {
|
|
1180
|
+
const head = await headResult;
|
|
1181
|
+
updateMatch(matchId, (prev) => ({
|
|
1182
|
+
...prev,
|
|
1183
|
+
...head
|
|
1184
|
+
}));
|
|
1185
|
+
}
|
|
1165
1186
|
}
|
|
1166
1187
|
}
|
|
1167
1188
|
if (!loaderIsRunningAsync) {
|