@tanstack/react-router 1.71.0 → 1.72.0

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.
@@ -321,7 +321,24 @@ class Router {
321
321
  leaveWildcards: false,
322
322
  leaveParams: opts.leaveParams
323
323
  });
324
- const applyMiddlewares = () => {
324
+ let search = fromSearch;
325
+ if (opts._includeValidateSearch) {
326
+ let validatedSearch = ((_f = this.options.search) == null ? void 0 : _f.strict) ? {} : search;
327
+ matchedRoutesResult == null ? void 0 : matchedRoutesResult.matchedRoutes.forEach((route) => {
328
+ try {
329
+ if (route.options.validateSearch) {
330
+ const validator = typeof route.options.validateSearch === "object" ? route.options.validateSearch.parse : route.options.validateSearch;
331
+ validatedSearch = {
332
+ ...validatedSearch,
333
+ ...validator({ ...validatedSearch, ...search })
334
+ };
335
+ }
336
+ } catch (e) {
337
+ }
338
+ });
339
+ search = validatedSearch;
340
+ }
341
+ const applyMiddlewares = (search2) => {
325
342
  const allMiddlewares = (stayingMatches == null ? void 0 : stayingMatches.reduce(
326
343
  (acc, route) => {
327
344
  var _a2;
@@ -332,14 +349,14 @@ class Router {
332
349
  }
333
350
  } else if (route.options.preSearchFilters || route.options.postSearchFilters) {
334
351
  const legacyMiddleware = ({
335
- search: search2,
352
+ search: search3,
336
353
  next
337
354
  }) => {
338
- let nextSearch = search2;
355
+ let nextSearch = search3;
339
356
  if ("preSearchFilters" in route.options && route.options.preSearchFilters) {
340
357
  nextSearch = route.options.preSearchFilters.reduce(
341
358
  (prev, next2) => next2(prev),
342
- search2
359
+ search3
343
360
  );
344
361
  }
345
362
  const result = next(nextSearch);
@@ -357,14 +374,14 @@ class Router {
357
374
  },
358
375
  []
359
376
  )) ?? [];
360
- const final = ({ search: search2 }) => {
377
+ const final = ({ search: search3 }) => {
361
378
  if (!dest.search) {
362
379
  return {};
363
380
  }
364
381
  if (dest.search === true) {
365
- return search2;
382
+ return search3;
366
383
  }
367
- return functionalUpdate(dest.search, search2);
384
+ return functionalUpdate(dest.search, search3);
368
385
  };
369
386
  allMiddlewares.push(final);
370
387
  const applyNext = (index, currentSearch) => {
@@ -377,25 +394,9 @@ class Router {
377
394
  };
378
395
  return middleware({ search: currentSearch, next });
379
396
  };
380
- return applyNext(0, fromSearch);
397
+ return applyNext(0, search2);
381
398
  };
382
- let search = applyMiddlewares();
383
- if (opts._includeValidateSearch) {
384
- let validatedSearch = ((_f = this.options.search) == null ? void 0 : _f.strict) ? {} : search;
385
- matchedRoutesResult == null ? void 0 : matchedRoutesResult.matchedRoutes.forEach((route) => {
386
- try {
387
- if (route.options.validateSearch) {
388
- const validator = typeof route.options.validateSearch === "object" ? route.options.validateSearch.parse : route.options.validateSearch;
389
- validatedSearch = {
390
- ...validatedSearch,
391
- ...validator({ ...validatedSearch, ...search })
392
- };
393
- }
394
- } catch (e) {
395
- }
396
- });
397
- search = validatedSearch;
398
- }
399
+ search = applyMiddlewares(search);
399
400
  search = replaceEqualDeep(fromSearch, search);
400
401
  const searchStr = this.options.stringifySearch(search);
401
402
  const hash = dest.hash === true ? this.latestLocation.hash : dest.hash ? functionalUpdate(dest.hash, this.latestLocation.hash) : void 0;