@tanstack/router-core 1.134.13 → 1.134.18
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 +21 -3
- 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 +21 -3
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +30 -3
package/dist/esm/router.d.ts
CHANGED
|
@@ -561,6 +561,7 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
|
|
|
561
561
|
rewrite?: LocationRewrite;
|
|
562
562
|
origin?: string;
|
|
563
563
|
latestLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
564
|
+
pendingBuiltLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
564
565
|
basepath: string;
|
|
565
566
|
routeTree: TRouteTree;
|
|
566
567
|
routesById: RoutesById<TRouteTree>;
|
package/dist/esm/router.js
CHANGED
|
@@ -269,13 +269,24 @@ class RouterCore {
|
|
|
269
269
|
match._nonReactive.pendingTimeout = void 0;
|
|
270
270
|
};
|
|
271
271
|
this.cancelMatches = () => {
|
|
272
|
-
this.state.
|
|
272
|
+
const currentPendingMatches = this.state.matches.filter(
|
|
273
|
+
(match) => match.status === "pending"
|
|
274
|
+
);
|
|
275
|
+
const currentLoadingMatches = this.state.matches.filter(
|
|
276
|
+
(match) => match.isFetching === "loader"
|
|
277
|
+
);
|
|
278
|
+
const matchesToCancelArray = /* @__PURE__ */ new Set([
|
|
279
|
+
...this.state.pendingMatches ?? [],
|
|
280
|
+
...currentPendingMatches,
|
|
281
|
+
...currentLoadingMatches
|
|
282
|
+
]);
|
|
283
|
+
matchesToCancelArray.forEach((match) => {
|
|
273
284
|
this.cancelMatch(match.id);
|
|
274
285
|
});
|
|
275
286
|
};
|
|
276
287
|
this.buildLocation = (opts) => {
|
|
277
288
|
const build = (dest = {}) => {
|
|
278
|
-
const currentLocation = dest._fromLocation || this.latestLocation;
|
|
289
|
+
const currentLocation = dest._fromLocation || this.pendingBuiltLocation || this.latestLocation;
|
|
279
290
|
const allCurrentLocationMatches = this.matchRoutes(currentLocation, {
|
|
280
291
|
_buildLocation: true
|
|
281
292
|
});
|
|
@@ -513,7 +524,8 @@ class RouterCore {
|
|
|
513
524
|
...rest,
|
|
514
525
|
_includeValidateSearch: true
|
|
515
526
|
});
|
|
516
|
-
|
|
527
|
+
this.pendingBuiltLocation = location;
|
|
528
|
+
const commitPromise = this.commitLocation({
|
|
517
529
|
...location,
|
|
518
530
|
viewTransition,
|
|
519
531
|
replace,
|
|
@@ -521,6 +533,12 @@ class RouterCore {
|
|
|
521
533
|
hashScrollIntoView,
|
|
522
534
|
ignoreBlocker
|
|
523
535
|
});
|
|
536
|
+
Promise.resolve().then(() => {
|
|
537
|
+
if (this.pendingBuiltLocation === location) {
|
|
538
|
+
this.pendingBuiltLocation = void 0;
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
return commitPromise;
|
|
524
542
|
};
|
|
525
543
|
this.navigate = ({ to, reloadDocument, href, ...rest }) => {
|
|
526
544
|
if (!reloadDocument && href) {
|