@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.
@@ -340,6 +340,7 @@ export interface BuildNextOptions {
340
340
  href?: string;
341
341
  _fromLocation?: ParsedLocation;
342
342
  unsafeRelative?: 'path';
343
+ _isNavigate?: boolean;
343
344
  }
344
345
  type NavigationEventInfo = {
345
346
  fromLocation?: ParsedLocation;
@@ -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;
@@ -340,6 +340,7 @@ export interface BuildNextOptions {
340
340
  href?: string;
341
341
  _fromLocation?: ParsedLocation;
342
342
  unsafeRelative?: 'path';
343
+ _isNavigate?: boolean;
343
344
  }
344
345
  type NavigationEventInfo = {
345
346
  fromLocation?: ParsedLocation;
@@ -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 allFromMatches = this.matchRoutes(currentLocation, {
232
+ const allCurrentLocationMatches = this.matchRoutes(currentLocation, {
233
233
  _buildLocation: true
234
234
  });
235
- const lastMatch = last(allFromMatches);
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
- const existingFrom = [...allFromMatches].reverse().find((d) => {
244
- return this.comparePaths(d.fullPath, fromPath);
245
- });
246
- if (!existingFrom) {
247
- console.warn(`Could not find match for from: ${fromPath}`);
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 = () => {