@tanstack/router-core 1.125.4 → 1.126.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/RouterProvider.d.cts +1 -0
- package/dist/cjs/router.cjs +18 -8
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -0
- package/dist/esm/RouterProvider.d.ts +1 -0
- package/dist/esm/router.d.ts +1 -0
- package/dist/esm/router.js +18 -8
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/RouterProvider.ts +1 -0
- package/src/router.ts +26 -7
package/dist/cjs/router.d.cts
CHANGED
|
@@ -23,4 +23,5 @@ export type NavigateFn = <TRouter extends RegisteredRouter, TTo extends string |
|
|
|
23
23
|
export type BuildLocationFn = <TRouter extends RegisteredRouter, TTo extends string | undefined, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>(opts: ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
24
24
|
leaveParams?: boolean;
|
|
25
25
|
_includeValidateSearch?: boolean;
|
|
26
|
+
_isNavigate?: boolean;
|
|
26
27
|
}) => ParsedLocation;
|
package/dist/esm/router.d.ts
CHANGED
package/dist/esm/router.js
CHANGED
|
@@ -229,10 +229,10 @@ class RouterCore {
|
|
|
229
229
|
const build = (dest = {}) => {
|
|
230
230
|
var _a;
|
|
231
231
|
const currentLocation = dest._fromLocation || this.latestLocation;
|
|
232
|
-
const
|
|
232
|
+
const allCurrentLocationMatches = this.matchRoutes(currentLocation, {
|
|
233
233
|
_buildLocation: true
|
|
234
234
|
});
|
|
235
|
-
const lastMatch = last(
|
|
235
|
+
const lastMatch = last(allCurrentLocationMatches);
|
|
236
236
|
let fromPath = lastMatch.fullPath;
|
|
237
237
|
const toPath = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
238
238
|
const routeIsChanging = !!dest.to && !this.comparePaths(dest.to.toString(), fromPath) && !this.comparePaths(toPath, fromPath);
|
|
@@ -240,11 +240,20 @@ class RouterCore {
|
|
|
240
240
|
fromPath = currentLocation.pathname;
|
|
241
241
|
} else if (routeIsChanging && dest.from) {
|
|
242
242
|
fromPath = dest.from;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
243
|
+
if (process.env.NODE_ENV !== "production" && dest._isNavigate) {
|
|
244
|
+
const allFromMatches = this.getMatchedRoutes(
|
|
245
|
+
dest.from,
|
|
246
|
+
void 0
|
|
247
|
+
).matchedRoutes;
|
|
248
|
+
const matchedFrom = [...allCurrentLocationMatches].reverse().find((d) => {
|
|
249
|
+
return this.comparePaths(d.fullPath, fromPath);
|
|
250
|
+
});
|
|
251
|
+
const matchedCurrent = [...allFromMatches].reverse().find((d) => {
|
|
252
|
+
return this.comparePaths(d.fullPath, currentLocation.pathname);
|
|
253
|
+
});
|
|
254
|
+
if (!matchedFrom && !matchedCurrent) {
|
|
255
|
+
console.warn(`Could not find match for from: ${fromPath}`);
|
|
256
|
+
}
|
|
248
257
|
}
|
|
249
258
|
}
|
|
250
259
|
const fromSearch = lastMatch.search;
|
|
@@ -482,7 +491,8 @@ class RouterCore {
|
|
|
482
491
|
return this.buildAndCommitLocation({
|
|
483
492
|
...rest,
|
|
484
493
|
href,
|
|
485
|
-
to
|
|
494
|
+
to,
|
|
495
|
+
_isNavigate: true
|
|
486
496
|
});
|
|
487
497
|
};
|
|
488
498
|
this.beforeLoad = () => {
|