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