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