@tanstack/router-core 1.130.11 → 1.130.17

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.
@@ -409,7 +409,7 @@ export type InvalidateFn<TRouter extends AnyRouter> = (opts?: {
409
409
  sync?: boolean;
410
410
  forcePending?: boolean;
411
411
  }) => Promise<void>;
412
- export type ParseLocationFn<TRouteTree extends AnyRoute> = (previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>, locationToParse?: HistoryLocation) => ParsedLocation<FullSearchSchema<TRouteTree>>;
412
+ export type ParseLocationFn<TRouteTree extends AnyRoute> = (locationToParse: HistoryLocation, previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>) => ParsedLocation<FullSearchSchema<TRouteTree>>;
413
413
  export type GetMatchRoutesFn = (pathname: string, routePathname: string | undefined) => {
414
414
  matchedRoutes: Array<AnyRoute>;
415
415
  routeParams: Record<string, string>;
@@ -504,6 +504,7 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
504
504
  isPrerendering(): boolean;
505
505
  update: UpdateFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>;
506
506
  get state(): RouterState<TRouteTree, import('./Matches.cjs').RouteMatch<any, any, any, any, any, any, any>>;
507
+ updateLatestLocation: () => void;
507
508
  buildRouteTree: () => void;
508
509
  subscribe: SubscribeFn;
509
510
  emit: EmitFn;
@@ -409,7 +409,7 @@ export type InvalidateFn<TRouter extends AnyRouter> = (opts?: {
409
409
  sync?: boolean;
410
410
  forcePending?: boolean;
411
411
  }) => Promise<void>;
412
- export type ParseLocationFn<TRouteTree extends AnyRoute> = (previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>, locationToParse?: HistoryLocation) => ParsedLocation<FullSearchSchema<TRouteTree>>;
412
+ export type ParseLocationFn<TRouteTree extends AnyRoute> = (locationToParse: HistoryLocation, previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>) => ParsedLocation<FullSearchSchema<TRouteTree>>;
413
413
  export type GetMatchRoutesFn = (pathname: string, routePathname: string | undefined) => {
414
414
  matchedRoutes: Array<AnyRoute>;
415
415
  routeParams: Record<string, string>;
@@ -504,6 +504,7 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
504
504
  isPrerendering(): boolean;
505
505
  update: UpdateFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>;
506
506
  get state(): RouterState<TRouteTree, import('./Matches.js').RouteMatch<any, any, any, any, any, any, any>>;
507
+ updateLatestLocation: () => void;
507
508
  buildRouteTree: () => void;
508
509
  subscribe: SubscribeFn;
509
510
  emit: EmitFn;
@@ -77,7 +77,7 @@ class RouterCore {
77
77
  this.history = this.options.history ?? (this.isServer ? createMemoryHistory({
78
78
  initialEntries: [this.basepath || "/"]
79
79
  }) : createBrowserHistory());
80
- this.latestLocation = this.parseLocation();
80
+ this.updateLatestLocation();
81
81
  }
82
82
  if (this.options.routeTree !== this.routeTree) {
83
83
  this.routeTree = this.options.routeTree;
@@ -102,6 +102,12 @@ class RouterCore {
102
102
  );
103
103
  }
104
104
  };
105
+ this.updateLatestLocation = () => {
106
+ this.latestLocation = this.parseLocation(
107
+ this.history.location,
108
+ this.latestLocation
109
+ );
110
+ };
105
111
  this.buildRouteTree = () => {
106
112
  const { routesById, routesByPath, flatRoutes } = processRouteTree({
107
113
  routeTree: this.routeTree,
@@ -139,7 +145,7 @@ class RouterCore {
139
145
  }
140
146
  });
141
147
  };
142
- this.parseLocation = (previousLocation, locationToParse) => {
148
+ this.parseLocation = (locationToParse, previousLocation) => {
143
149
  const parse = ({
144
150
  pathname,
145
151
  search,
@@ -157,7 +163,7 @@ class RouterCore {
157
163
  state: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.state, state)
158
164
  };
159
165
  };
160
- const location = parse(locationToParse ?? this.history.location);
166
+ const location = parse(locationToParse);
161
167
  const { __tempLocation, __tempKey } = location.state;
162
168
  if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
163
169
  const parsedTempLocation = parse(__tempLocation);
@@ -510,7 +516,7 @@ class RouterCore {
510
516
  };
511
517
  this.beforeLoad = () => {
512
518
  this.cancelMatches();
513
- this.latestLocation = this.parseLocation(this.latestLocation);
519
+ this.updateLatestLocation();
514
520
  if (this.isServer) {
515
521
  const nextLocation = this.buildLocation({
516
522
  to: this.latestLocation.pathname,