@tanstack/router-core 1.122.0 → 1.123.2
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 +16 -10
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -0
- package/dist/esm/router.d.ts +1 -0
- package/dist/esm/router.js +16 -10
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +28 -17
package/dist/cjs/router.d.cts
CHANGED
|
@@ -396,6 +396,7 @@ export type UpdateFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends T
|
|
|
396
396
|
export type InvalidateFn<TRouter extends AnyRouter> = (opts?: {
|
|
397
397
|
filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
|
|
398
398
|
sync?: boolean;
|
|
399
|
+
forcePending?: boolean;
|
|
399
400
|
}) => Promise<void>;
|
|
400
401
|
export type ParseLocationFn<TRouteTree extends AnyRoute> = (previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>, locationToParse?: HistoryLocation) => ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
401
402
|
export type GetMatchRoutesFn = (pathname: string, routePathname: string | undefined) => {
|
package/dist/esm/router.d.ts
CHANGED
|
@@ -396,6 +396,7 @@ export type UpdateFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends T
|
|
|
396
396
|
export type InvalidateFn<TRouter extends AnyRouter> = (opts?: {
|
|
397
397
|
filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
|
|
398
398
|
sync?: boolean;
|
|
399
|
+
forcePending?: boolean;
|
|
399
400
|
}) => Promise<void>;
|
|
400
401
|
export type ParseLocationFn<TRouteTree extends AnyRoute> = (previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>, locationToParse?: HistoryLocation) => ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
401
402
|
export type GetMatchRoutesFn = (pathname: string, routePathname: string | undefined) => {
|
package/dist/esm/router.js
CHANGED
|
@@ -503,11 +503,9 @@ class RouterCore {
|
|
|
503
503
|
location: this.latestLocation,
|
|
504
504
|
pendingMatches,
|
|
505
505
|
// If a cached moved to pendingMatches, remove it from cachedMatches
|
|
506
|
-
cachedMatches: s.cachedMatches.filter(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
return cachedMatch.status === "success" && (cachedMatch.isFetching || cachedMatch.loaderData !== void 0);
|
|
510
|
-
})
|
|
506
|
+
cachedMatches: s.cachedMatches.filter(
|
|
507
|
+
(d) => !pendingMatches.find((e) => e.id === d.id)
|
|
508
|
+
)
|
|
511
509
|
}));
|
|
512
510
|
};
|
|
513
511
|
this.load = async (opts) => {
|
|
@@ -798,7 +796,12 @@ class RouterCore {
|
|
|
798
796
|
}, pendingMs);
|
|
799
797
|
}
|
|
800
798
|
await existingMatch.beforeLoadPromise;
|
|
801
|
-
|
|
799
|
+
const match = this.getMatch(matchId);
|
|
800
|
+
if (match.status === "error") {
|
|
801
|
+
executeBeforeLoad = true;
|
|
802
|
+
} else if (match.preload && (match.status === "redirected" || match.status === "notFound")) {
|
|
803
|
+
handleRedirectAndNotFound(match, match.error);
|
|
804
|
+
}
|
|
802
805
|
}
|
|
803
806
|
if (executeBeforeLoad) {
|
|
804
807
|
try {
|
|
@@ -890,11 +893,14 @@ class RouterCore {
|
|
|
890
893
|
validResolvedMatches.forEach(({ id: matchId, routeId }, index) => {
|
|
891
894
|
matchPromises.push(
|
|
892
895
|
(async () => {
|
|
893
|
-
const { loaderPromise: prevLoaderPromise } = this.getMatch(matchId);
|
|
894
896
|
let loaderShouldRunAsync = false;
|
|
895
897
|
let loaderIsRunningAsync = false;
|
|
896
|
-
|
|
897
|
-
|
|
898
|
+
const prevMatch = this.getMatch(matchId);
|
|
899
|
+
if (prevMatch.loaderPromise) {
|
|
900
|
+
if (prevMatch.status === "success" && !sync && !prevMatch.preload) {
|
|
901
|
+
return this.getMatch(matchId);
|
|
902
|
+
}
|
|
903
|
+
await prevMatch.loaderPromise;
|
|
898
904
|
const match = this.getMatch(matchId);
|
|
899
905
|
if (match.error) {
|
|
900
906
|
handleRedirectAndNotFound(match, match.error);
|
|
@@ -1097,7 +1103,7 @@ class RouterCore {
|
|
|
1097
1103
|
return {
|
|
1098
1104
|
...d,
|
|
1099
1105
|
invalid: true,
|
|
1100
|
-
...d.status === "error" ? { status: "pending", error: void 0 } : {}
|
|
1106
|
+
...(opts == null ? void 0 : opts.forcePending) || d.status === "error" ? { status: "pending", error: void 0 } : {}
|
|
1101
1107
|
};
|
|
1102
1108
|
}
|
|
1103
1109
|
return d;
|