@tanstack/react-router 1.35.2 → 1.35.5

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.
@@ -1,4 +1,4 @@
1
- import { AnyRoute, RootSearchSchema } from './route.cjs';
1
+ import { AnyRoute } from './route.cjs';
2
2
  import { AnyRouter, TrailingSlashOption } from './router.cjs';
3
3
  import { MergeUnion } from './utils.cjs';
4
4
 
@@ -34,8 +34,8 @@ export type RoutesByToPath<TRouter extends AnyRouter> = {
34
34
  [TRoute in ParseRouteWithoutBranches<TRouter['routeTree']> as RouteToByRouter<TRouter, TRoute>]: TRoute;
35
35
  };
36
36
  export type RouteByToPath<TRouter extends AnyRouter, TTo> = Extract<RoutesByToPath<TRouter>[TTo], AnyRoute>;
37
- export type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<Exclude<ParseRoute<TRouteTree>['types']['fullSearchSchema'], RootSearchSchema>>;
38
- export type FullSearchSchemaInput<TRouteTree extends AnyRoute> = MergeUnion<Exclude<ParseRoute<TRouteTree>['types']['fullSearchSchemaInput'], RootSearchSchema>>;
37
+ export type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['fullSearchSchema']>;
38
+ export type FullSearchSchemaInput<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['fullSearchSchemaInput']>;
39
39
  export type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['allParams']>;
40
40
  export type AllContext<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['allContext']>;
41
41
  export type AllLoaderData<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['loaderData']>;
@@ -398,31 +398,24 @@ class Router {
398
398
  };
399
399
  this.buildLocation = (opts) => {
400
400
  const build = (dest = {}, matches) => {
401
- var _a, _b, _c;
401
+ var _a, _b, _c, _d;
402
402
  let fromPath = this.latestLocation.pathname;
403
403
  let fromSearch = dest.fromSearch || this.latestLocation.search;
404
- const looseRoutesByPath = this.routesByPath;
405
- const fromRoute = dest.from !== void 0 ? looseRoutesByPath[path.trimPathRight(dest.from)] : void 0;
406
404
  const fromMatches = this.matchRoutes(
407
405
  this.latestLocation.pathname,
408
406
  fromSearch
409
407
  );
410
- const fromMatch = fromMatches.find((d) => d.routeId === (fromRoute == null ? void 0 : fromRoute.id));
411
- fromPath = (fromMatch == null ? void 0 : fromMatch.pathname) || fromPath;
412
- invariant(
413
- dest.from == null || fromMatch != null,
414
- "Could not find match for from: " + dest.from
415
- );
416
- fromSearch = ((_a = utils.last(fromMatches)) == null ? void 0 : _a.search) || this.latestLocation.search;
408
+ fromPath = ((_a = fromMatches.find((d) => d.id === dest.from)) == null ? void 0 : _a.pathname) || fromPath;
409
+ fromSearch = ((_b = utils.last(fromMatches)) == null ? void 0 : _b.search) || this.latestLocation.search;
417
410
  const stayingMatches = matches == null ? void 0 : matches.filter(
418
411
  (d) => fromMatches.find((e) => e.routeId === d.routeId)
419
412
  );
420
- const fromRouteByFromPathRouteId = this.routesById[(_b = stayingMatches == null ? void 0 : stayingMatches.find((d) => d.pathname === fromPath)) == null ? void 0 : _b.routeId];
413
+ const fromRouteByFromPathRouteId = this.routesById[(_c = stayingMatches == null ? void 0 : stayingMatches.find((d) => d.pathname === fromPath)) == null ? void 0 : _c.routeId];
421
414
  let pathname = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(
422
415
  fromPath,
423
416
  (fromRouteByFromPathRouteId == null ? void 0 : fromRouteByFromPathRouteId.to) ?? fromPath
424
417
  );
425
- const prevParams = { ...(_c = utils.last(fromMatches)) == null ? void 0 : _c.params };
418
+ const prevParams = { ...(_d = utils.last(fromMatches)) == null ? void 0 : _d.params };
426
419
  let nextParams = (dest.params ?? true) === true ? prevParams : { ...prevParams, ...utils.functionalUpdate(dest.params, prevParams) };
427
420
  if (Object.keys(nextParams).length > 0) {
428
421
  matches == null ? void 0 : matches.map((d) => this.looseRoutesById[d.routeId].options.stringifyParams).filter(Boolean).forEach((fn) => {
@@ -849,7 +842,7 @@ class Router {
849
842
  preload: !!preload,
850
843
  context: parentContext,
851
844
  location,
852
- navigate: (opts) => this.navigate({ ...opts }),
845
+ navigate: (opts) => this.navigate({ ...opts, from: match.pathname }),
853
846
  buildLocation: this.buildLocation,
854
847
  cause: preload ? "preload" : match.cause
855
848
  })) ?? {};
@@ -891,7 +884,7 @@ class Router {
891
884
  abortController: match.abortController,
892
885
  context: match.context,
893
886
  location,
894
- navigate: (opts) => this.navigate({ ...opts }),
887
+ navigate: (opts) => this.navigate({ ...opts, from: match.pathname }),
895
888
  cause: preload ? "preload" : match.cause,
896
889
  route
897
890
  };