@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/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;
|
|
@@ -737,20 +737,22 @@ class RouterCore {
|
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
|
-
(
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
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();
|
|
752
755
|
}
|
|
753
|
-
(_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
|
|
754
756
|
if (redirect.isRedirect(err)) {
|
|
755
757
|
rendered = true;
|
|
756
758
|
err.options._fromLocation = location;
|
|
@@ -981,33 +983,39 @@ class RouterCore {
|
|
|
981
983
|
let loaderShouldRunAsync = false;
|
|
982
984
|
let loaderIsRunningAsync = false;
|
|
983
985
|
const route = this.looseRoutesById[routeId];
|
|
984
|
-
const executeHead =
|
|
986
|
+
const executeHead = () => {
|
|
985
987
|
var _a3, _b3, _c2, _d2, _e, _f;
|
|
986
988
|
const match = this.getMatch(matchId);
|
|
987
989
|
if (!match) {
|
|
988
990
|
return;
|
|
989
991
|
}
|
|
992
|
+
if (!route.options.head && !route.options.scripts && !route.options.headers) {
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
990
995
|
const assetContext = {
|
|
991
996
|
matches,
|
|
992
997
|
match,
|
|
993
998
|
params: match.params,
|
|
994
999
|
loaderData: match.loaderData
|
|
995
1000
|
};
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
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
|
+
});
|
|
1011
1019
|
};
|
|
1012
1020
|
const potentialPendingMinPromise = async () => {
|
|
1013
1021
|
const latestMatch = this.getMatch(matchId);
|
|
@@ -1018,11 +1026,14 @@ class RouterCore {
|
|
|
1018
1026
|
const prevMatch = this.getMatch(matchId);
|
|
1019
1027
|
if (shouldSkipLoader(matchId)) {
|
|
1020
1028
|
if (this.isServer) {
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1029
|
+
const headResult = executeHead();
|
|
1030
|
+
if (headResult) {
|
|
1031
|
+
const head = await headResult;
|
|
1032
|
+
updateMatch(matchId, (prev) => ({
|
|
1033
|
+
...prev,
|
|
1034
|
+
...head
|
|
1035
|
+
}));
|
|
1036
|
+
}
|
|
1026
1037
|
return this.getMatch(matchId);
|
|
1027
1038
|
}
|
|
1028
1039
|
} else if (prevMatch._nonReactive.loaderPromise) {
|
|
@@ -1091,7 +1102,8 @@ class RouterCore {
|
|
|
1091
1102
|
loaderData
|
|
1092
1103
|
}));
|
|
1093
1104
|
await route._lazyPromise;
|
|
1094
|
-
const
|
|
1105
|
+
const headResult = executeHead();
|
|
1106
|
+
const head = headResult ? await headResult : void 0;
|
|
1095
1107
|
await potentialPendingMinPromise();
|
|
1096
1108
|
await route._componentsPromise;
|
|
1097
1109
|
updateMatch(matchId, (prev) => ({
|
|
@@ -1115,7 +1127,8 @@ class RouterCore {
|
|
|
1115
1127
|
onErrorError
|
|
1116
1128
|
);
|
|
1117
1129
|
}
|
|
1118
|
-
const
|
|
1130
|
+
const headResult = executeHead();
|
|
1131
|
+
const head = headResult ? await headResult : void 0;
|
|
1119
1132
|
updateMatch(matchId, (prev) => ({
|
|
1120
1133
|
...prev,
|
|
1121
1134
|
error,
|
|
@@ -1125,15 +1138,19 @@ class RouterCore {
|
|
|
1125
1138
|
}));
|
|
1126
1139
|
}
|
|
1127
1140
|
} catch (err) {
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
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);
|
|
1137
1154
|
}
|
|
1138
1155
|
};
|
|
1139
1156
|
const { status, invalid } = this.getMatch(matchId);
|
|
@@ -1158,11 +1175,14 @@ class RouterCore {
|
|
|
1158
1175
|
} else if (status !== "success" || loaderShouldRunAsync && sync) {
|
|
1159
1176
|
await runLoader();
|
|
1160
1177
|
} else {
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1178
|
+
const headResult = executeHead();
|
|
1179
|
+
if (headResult) {
|
|
1180
|
+
const head = await headResult;
|
|
1181
|
+
updateMatch(matchId, (prev) => ({
|
|
1182
|
+
...prev,
|
|
1183
|
+
...head
|
|
1184
|
+
}));
|
|
1185
|
+
}
|
|
1166
1186
|
}
|
|
1167
1187
|
}
|
|
1168
1188
|
if (!loaderIsRunningAsync) {
|