@tanstack/router-core 1.131.12 → 1.131.13
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 +31 -41
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -3
- package/dist/esm/router.d.ts +1 -3
- package/dist/esm/router.js +31 -41
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +43 -53
package/dist/cjs/router.cjs
CHANGED
|
@@ -729,42 +729,36 @@ class RouterCore {
|
|
|
729
729
|
}
|
|
730
730
|
const handleRedirectAndNotFound = (match, err) => {
|
|
731
731
|
var _a, _b, _c;
|
|
732
|
-
if (redirect.isRedirect(err)
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
}));
|
|
751
|
-
if (!err.routeId) {
|
|
752
|
-
err.routeId = match.routeId;
|
|
753
|
-
}
|
|
754
|
-
(_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
|
|
755
|
-
}
|
|
756
|
-
if (redirect.isRedirect(err)) {
|
|
757
|
-
rendered = true;
|
|
758
|
-
err.options._fromLocation = location;
|
|
759
|
-
err.redirectHandled = true;
|
|
760
|
-
err = this.resolveRedirect(err);
|
|
761
|
-
throw err;
|
|
762
|
-
} else if (notFound.isNotFound(err)) {
|
|
763
|
-
this._handleNotFound(matches, err, {
|
|
764
|
-
updateMatch
|
|
765
|
-
});
|
|
766
|
-
throw err;
|
|
732
|
+
if (!redirect.isRedirect(err) && !notFound.isNotFound(err)) return;
|
|
733
|
+
if (redirect.isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) {
|
|
734
|
+
throw err;
|
|
735
|
+
}
|
|
736
|
+
if (match) {
|
|
737
|
+
(_a = match._nonReactive.beforeLoadPromise) == null ? void 0 : _a.resolve();
|
|
738
|
+
(_b = match._nonReactive.loaderPromise) == null ? void 0 : _b.resolve();
|
|
739
|
+
match._nonReactive.beforeLoadPromise = void 0;
|
|
740
|
+
match._nonReactive.loaderPromise = void 0;
|
|
741
|
+
const status = redirect.isRedirect(err) ? "redirected" : "notFound";
|
|
742
|
+
updateMatch(match.id, (prev) => ({
|
|
743
|
+
...prev,
|
|
744
|
+
status,
|
|
745
|
+
isFetching: false,
|
|
746
|
+
error: err
|
|
747
|
+
}));
|
|
748
|
+
if (notFound.isNotFound(err) && !err.routeId) {
|
|
749
|
+
err.routeId = match.routeId;
|
|
767
750
|
}
|
|
751
|
+
(_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
|
|
752
|
+
}
|
|
753
|
+
if (redirect.isRedirect(err)) {
|
|
754
|
+
rendered = true;
|
|
755
|
+
err.options._fromLocation = location;
|
|
756
|
+
err.redirectHandled = true;
|
|
757
|
+
err = this.resolveRedirect(err);
|
|
758
|
+
throw err;
|
|
759
|
+
} else {
|
|
760
|
+
this._handleNotFound(matches, err, updateMatch);
|
|
761
|
+
throw err;
|
|
768
762
|
}
|
|
769
763
|
};
|
|
770
764
|
const shouldSkipLoader = (matchId) => {
|
|
@@ -1411,9 +1405,7 @@ class RouterCore {
|
|
|
1411
1405
|
}
|
|
1412
1406
|
return match;
|
|
1413
1407
|
};
|
|
1414
|
-
this._handleNotFound = (matches, err, {
|
|
1415
|
-
updateMatch = this.updateMatch
|
|
1416
|
-
} = {}) => {
|
|
1408
|
+
this._handleNotFound = (matches, err, updateMatch = this.updateMatch) => {
|
|
1417
1409
|
var _a;
|
|
1418
1410
|
const routeCursor = this.routesById[err.routeId ?? ""] ?? this.routeTree;
|
|
1419
1411
|
const matchesByRouteId = {};
|
|
@@ -1440,9 +1432,7 @@ class RouterCore {
|
|
|
1440
1432
|
}));
|
|
1441
1433
|
if (err.routerCode === "BEFORE_LOAD" && routeCursor.parentRoute) {
|
|
1442
1434
|
err.routeId = routeCursor.parentRoute.id;
|
|
1443
|
-
this._handleNotFound(matches, err,
|
|
1444
|
-
updateMatch
|
|
1445
|
-
});
|
|
1435
|
+
this._handleNotFound(matches, err, updateMatch);
|
|
1446
1436
|
}
|
|
1447
1437
|
};
|
|
1448
1438
|
this.hasNotFoundMatch = () => {
|