@tanstack/router-core 1.131.5 → 1.132.0-alpha.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.
Files changed (88) hide show
  1. package/dist/cjs/Matches.cjs.map +1 -1
  2. package/dist/cjs/Matches.d.cts +9 -7
  3. package/dist/cjs/defer.cjs +1 -1
  4. package/dist/cjs/defer.cjs.map +1 -1
  5. package/dist/cjs/index.cjs +0 -2
  6. package/dist/cjs/index.cjs.map +1 -1
  7. package/dist/cjs/index.d.cts +1 -1
  8. package/dist/cjs/lru-cache.cjs.map +1 -1
  9. package/dist/cjs/not-found.cjs +1 -1
  10. package/dist/cjs/not-found.cjs.map +1 -1
  11. package/dist/cjs/path.cjs +10 -12
  12. package/dist/cjs/path.cjs.map +1 -1
  13. package/dist/cjs/qss.cjs.map +1 -1
  14. package/dist/cjs/redirect.cjs.map +1 -1
  15. package/dist/cjs/route.cjs +6 -7
  16. package/dist/cjs/route.cjs.map +1 -1
  17. package/dist/cjs/router.cjs +167 -194
  18. package/dist/cjs/router.cjs.map +1 -1
  19. package/dist/cjs/router.d.cts +1 -2
  20. package/dist/cjs/scroll-restoration.cjs +2 -3
  21. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  22. package/dist/cjs/scroll-restoration.d.cts +9 -0
  23. package/dist/cjs/searchMiddleware.cjs.map +1 -1
  24. package/dist/cjs/searchParams.cjs.map +1 -1
  25. package/dist/cjs/ssr/createRequestHandler.cjs +2 -3
  26. package/dist/cjs/ssr/createRequestHandler.cjs.map +1 -1
  27. package/dist/cjs/ssr/handlerCallback.cjs.map +1 -1
  28. package/dist/cjs/ssr/headers.cjs.map +1 -1
  29. package/dist/cjs/ssr/json.cjs +1 -1
  30. package/dist/cjs/ssr/json.cjs.map +1 -1
  31. package/dist/cjs/ssr/seroval-plugins.cjs.map +1 -1
  32. package/dist/cjs/ssr/ssr-client.cjs +47 -48
  33. package/dist/cjs/ssr/ssr-client.cjs.map +1 -1
  34. package/dist/cjs/ssr/ssr-server.cjs +2 -3
  35. package/dist/cjs/ssr/ssr-server.cjs.map +1 -1
  36. package/dist/cjs/ssr/transformStreamWithRouter.cjs +3 -4
  37. package/dist/cjs/ssr/transformStreamWithRouter.cjs.map +1 -1
  38. package/dist/cjs/typePrimitives.d.cts +6 -6
  39. package/dist/cjs/utils.cjs +4 -27
  40. package/dist/cjs/utils.cjs.map +1 -1
  41. package/dist/cjs/utils.d.cts +0 -6
  42. package/dist/esm/Matches.d.ts +9 -7
  43. package/dist/esm/Matches.js.map +1 -1
  44. package/dist/esm/defer.js +1 -1
  45. package/dist/esm/defer.js.map +1 -1
  46. package/dist/esm/index.d.ts +1 -1
  47. package/dist/esm/index.js +1 -3
  48. package/dist/esm/lru-cache.js.map +1 -1
  49. package/dist/esm/not-found.js +1 -1
  50. package/dist/esm/not-found.js.map +1 -1
  51. package/dist/esm/path.js +10 -12
  52. package/dist/esm/path.js.map +1 -1
  53. package/dist/esm/qss.js.map +1 -1
  54. package/dist/esm/redirect.js.map +1 -1
  55. package/dist/esm/route.js +6 -7
  56. package/dist/esm/route.js.map +1 -1
  57. package/dist/esm/router.d.ts +1 -2
  58. package/dist/esm/router.js +167 -194
  59. package/dist/esm/router.js.map +1 -1
  60. package/dist/esm/scroll-restoration.d.ts +9 -0
  61. package/dist/esm/scroll-restoration.js +2 -3
  62. package/dist/esm/scroll-restoration.js.map +1 -1
  63. package/dist/esm/searchMiddleware.js.map +1 -1
  64. package/dist/esm/searchParams.js.map +1 -1
  65. package/dist/esm/ssr/createRequestHandler.js +2 -3
  66. package/dist/esm/ssr/createRequestHandler.js.map +1 -1
  67. package/dist/esm/ssr/handlerCallback.js.map +1 -1
  68. package/dist/esm/ssr/headers.js.map +1 -1
  69. package/dist/esm/ssr/json.js +1 -1
  70. package/dist/esm/ssr/json.js.map +1 -1
  71. package/dist/esm/ssr/seroval-plugins.js.map +1 -1
  72. package/dist/esm/ssr/ssr-client.js +47 -48
  73. package/dist/esm/ssr/ssr-client.js.map +1 -1
  74. package/dist/esm/ssr/ssr-server.js +2 -3
  75. package/dist/esm/ssr/ssr-server.js.map +1 -1
  76. package/dist/esm/ssr/transformStreamWithRouter.js +3 -4
  77. package/dist/esm/ssr/transformStreamWithRouter.js.map +1 -1
  78. package/dist/esm/typePrimitives.d.ts +6 -6
  79. package/dist/esm/utils.d.ts +0 -6
  80. package/dist/esm/utils.js +5 -28
  81. package/dist/esm/utils.js.map +1 -1
  82. package/package.json +2 -2
  83. package/src/Matches.ts +8 -16
  84. package/src/index.ts +0 -2
  85. package/src/router.ts +111 -107
  86. package/src/ssr/ssr-client.ts +41 -42
  87. package/src/typePrimitives.ts +6 -6
  88. package/src/utils.ts +0 -41
@@ -29,9 +29,9 @@ function defaultSerializeError(err) {
29
29
  function getLocationChangeInfo(routerState) {
30
30
  const fromLocation = routerState.resolvedLocation;
31
31
  const toLocation = routerState.location;
32
- const pathChanged = (fromLocation == null ? void 0 : fromLocation.pathname) !== toLocation.pathname;
33
- const hrefChanged = (fromLocation == null ? void 0 : fromLocation.href) !== toLocation.href;
34
- const hashChanged = (fromLocation == null ? void 0 : fromLocation.hash) !== toLocation.hash;
32
+ const pathChanged = fromLocation?.pathname !== toLocation.pathname;
33
+ const hrefChanged = fromLocation?.href !== toLocation.href;
34
+ const hashChanged = fromLocation?.hash !== toLocation.hash;
35
35
  return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged };
36
36
  }
37
37
  class RouterCore {
@@ -50,7 +50,6 @@ class RouterCore {
50
50
  this.isScrollRestorationSetup = false;
51
51
  this.startTransition = (fn) => fn();
52
52
  this.update = (newOptions) => {
53
- var _a;
54
53
  if (newOptions.notFoundRoute) {
55
54
  console.warn(
56
55
  "The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info."
@@ -79,7 +78,7 @@ class RouterCore {
79
78
  this.history = this.options.history ?? (this.isServer ? history.createMemoryHistory({
80
79
  initialEntries: [this.basepath || "/"]
81
80
  }) : history.createBrowserHistory());
82
- this.updateLatestLocation();
81
+ this.latestLocation = this.parseLocation();
83
82
  }
84
83
  if (this.options.routeTree !== this.routeTree) {
85
84
  this.routeTree = this.options.routeTree;
@@ -98,18 +97,12 @@ class RouterCore {
98
97
  });
99
98
  scrollRestoration.setupScrollRestoration(this);
100
99
  }
101
- if (typeof window !== "undefined" && "CSS" in window && typeof ((_a = window.CSS) == null ? void 0 : _a.supports) === "function") {
100
+ if (typeof window !== "undefined" && "CSS" in window && typeof window.CSS?.supports === "function") {
102
101
  this.isViewTransitionTypesSupported = window.CSS.supports(
103
102
  "selector(:active-view-transition-type(a)"
104
103
  );
105
104
  }
106
105
  };
107
- this.updateLatestLocation = () => {
108
- this.latestLocation = this.parseLocation(
109
- this.history.location,
110
- this.latestLocation
111
- );
112
- };
113
106
  this.buildRouteTree = () => {
114
107
  const { routesById, routesByPath, flatRoutes } = processRouteTree({
115
108
  routeTree: this.routeTree,
@@ -147,7 +140,7 @@ class RouterCore {
147
140
  }
148
141
  });
149
142
  };
150
- this.parseLocation = (locationToParse, previousLocation) => {
143
+ this.parseLocation = (previousLocation, locationToParse) => {
151
144
  const parse = ({
152
145
  pathname,
153
146
  search,
@@ -159,13 +152,13 @@ class RouterCore {
159
152
  return {
160
153
  pathname,
161
154
  searchStr,
162
- search: utils.replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
155
+ search: utils.replaceEqualDeep(previousLocation?.search, parsedSearch),
163
156
  hash: hash.split("#").reverse()[0] ?? "",
164
157
  href: `${pathname}${searchStr}${hash}`,
165
- state: utils.replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.state, state)
158
+ state: utils.replaceEqualDeep(previousLocation?.state, state)
166
159
  };
167
160
  };
168
- const location = parse(locationToParse);
161
+ const location = parse(locationToParse ?? this.history.location);
169
162
  const { __tempLocation, __tempKey } = location.state;
170
163
  if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
171
164
  const parsedTempLocation = parse(__tempLocation);
@@ -219,18 +212,21 @@ class RouterCore {
219
212
  const match = this.getMatch(id);
220
213
  if (!match) return;
221
214
  match.abortController.abort();
222
- match._nonReactive.pendingTimeout = void 0;
223
- clearTimeout(match._nonReactive.pendingTimeout);
215
+ this.updateMatch(id, (prev) => {
216
+ clearTimeout(prev.pendingTimeout);
217
+ return {
218
+ ...prev,
219
+ pendingTimeout: void 0
220
+ };
221
+ });
224
222
  };
225
223
  this.cancelMatches = () => {
226
- var _a;
227
- (_a = this.state.pendingMatches) == null ? void 0 : _a.forEach((match) => {
224
+ this.state.pendingMatches?.forEach((match) => {
228
225
  this.cancelMatch(match.id);
229
226
  });
230
227
  };
231
228
  this.buildLocation = (opts) => {
232
229
  const build = (dest = {}) => {
233
- var _a;
234
230
  const currentLocation = dest._fromLocation || this.latestLocation;
235
231
  const allCurrentLocationMatches = this.matchRoutes(currentLocation, {
236
232
  _buildLocation: true
@@ -271,13 +267,16 @@ class RouterCore {
271
267
  params: nextParams ?? {},
272
268
  parseCache: this.parsePathnameCache
273
269
  }).interpolatedPath;
274
- const destRoutes = this.matchRoutes(interpolatedNextTo, void 0, {
275
- _buildLocation: true
276
- }).map((d) => this.looseRoutesById[d.routeId]);
270
+ const destRoutes = this.matchRoutes(
271
+ interpolatedNextTo,
272
+ {},
273
+ {
274
+ _buildLocation: true
275
+ }
276
+ ).map((d) => this.looseRoutesById[d.routeId]);
277
277
  if (Object.keys(nextParams).length > 0) {
278
278
  destRoutes.map((route) => {
279
- var _a2;
280
- return ((_a2 = route.options.params) == null ? void 0 : _a2.stringify) ?? route.options.stringifyParams;
279
+ return route.options.params?.stringify ?? route.options.stringifyParams;
281
280
  }).filter(Boolean).forEach((fn) => {
282
281
  nextParams = { ...nextParams, ...fn(nextParams) };
283
282
  });
@@ -293,7 +292,7 @@ class RouterCore {
293
292
  parseCache: this.parsePathnameCache
294
293
  }).interpolatedPath;
295
294
  let nextSearch = fromSearch;
296
- if (opts._includeValidateSearch && ((_a = this.options.search) == null ? void 0 : _a.strict)) {
295
+ if (opts._includeValidateSearch && this.options.search?.strict) {
297
296
  let validatedSearch = {};
298
297
  destRoutes.forEach((route) => {
299
298
  try {
@@ -334,12 +333,11 @@ class RouterCore {
334
333
  };
335
334
  };
336
335
  const buildWithMatches = (dest = {}, maskedDest) => {
337
- var _a;
338
336
  const next = build(dest);
339
337
  let maskedNext = maskedDest ? build(maskedDest) : void 0;
340
338
  if (!maskedNext) {
341
339
  let params = {};
342
- const foundMask = (_a = this.options.routeMasks) == null ? void 0 : _a.find((d) => {
340
+ const foundMask = this.options.routeMasks?.find((d) => {
343
341
  const match = path.matchPathname(
344
342
  this.basepath,
345
343
  next.pathname,
@@ -405,7 +403,7 @@ class RouterCore {
405
403
  const isSameUrl = this.latestLocation.href === next.href;
406
404
  const previousCommitPromise = this.commitLocationPromise;
407
405
  this.commitLocationPromise = utils.createControlledPromise(() => {
408
- previousCommitPromise == null ? void 0 : previousCommitPromise.resolve();
406
+ previousCommitPromise?.resolve();
409
407
  });
410
408
  if (isSameUrl && isSameState()) {
411
409
  this.load();
@@ -509,7 +507,7 @@ class RouterCore {
509
507
  };
510
508
  this.beforeLoad = () => {
511
509
  this.cancelMatches();
512
- this.updateLatestLocation();
510
+ this.latestLocation = this.parseLocation(this.latestLocation);
513
511
  if (this.isServer) {
514
512
  const nextLocation = this.buildLocation({
515
513
  to: this.latestLocation.pathname,
@@ -550,7 +548,6 @@ class RouterCore {
550
548
  let loadPromise;
551
549
  loadPromise = new Promise((resolve) => {
552
550
  this.startTransition(async () => {
553
- var _a;
554
551
  try {
555
552
  this.beforeLoad();
556
553
  const next = this.latestLocation;
@@ -572,7 +569,7 @@ class RouterCore {
572
569
  })
573
570
  });
574
571
  await this.loadMatches({
575
- sync: opts == null ? void 0 : opts.sync,
572
+ sync: opts?.sync,
576
573
  matches: this.state.pendingMatches,
577
574
  location: next,
578
575
  // eslint-disable-next-line @typescript-eslint/require-await
@@ -614,8 +611,7 @@ class RouterCore {
614
611
  [stayingMatches, "onStay"]
615
612
  ].forEach(([matches, hook]) => {
616
613
  matches.forEach((match) => {
617
- var _a2, _b;
618
- (_b = (_a2 = this.looseRoutesById[match.routeId].options)[hook]) == null ? void 0 : _b.call(_a2, match);
614
+ this.looseRoutesById[match.routeId].options[hook]?.(match);
619
615
  });
620
616
  });
621
617
  });
@@ -641,7 +637,7 @@ class RouterCore {
641
637
  }));
642
638
  }
643
639
  if (this.latestLoadPromise === loadPromise) {
644
- (_a = this.commitLocationPromise) == null ? void 0 : _a.resolve();
640
+ this.commitLocationPromise?.resolve();
645
641
  this.latestLoadPromise = void 0;
646
642
  this.commitLocationPromise = void 0;
647
643
  }
@@ -687,22 +683,17 @@ class RouterCore {
687
683
  }
688
684
  };
689
685
  this.updateMatch = (id, updater) => {
690
- var _a;
691
- const matchesKey = ((_a = this.state.pendingMatches) == null ? void 0 : _a.some((d) => d.id === id)) ? "pendingMatches" : this.state.matches.some((d) => d.id === id) ? "matches" : this.state.cachedMatches.some((d) => d.id === id) ? "cachedMatches" : "";
686
+ const matchesKey = this.state.pendingMatches?.some((d) => d.id === id) ? "pendingMatches" : this.state.matches.some((d) => d.id === id) ? "matches" : this.state.cachedMatches.some((d) => d.id === id) ? "cachedMatches" : "";
692
687
  if (matchesKey) {
693
- this.__store.setState((s) => {
694
- var _a2;
695
- return {
696
- ...s,
697
- [matchesKey]: (_a2 = s[matchesKey]) == null ? void 0 : _a2.map((d) => d.id === id ? updater(d) : d)
698
- };
699
- });
688
+ this.__store.setState((s) => ({
689
+ ...s,
690
+ [matchesKey]: s[matchesKey]?.map((d) => d.id === id ? updater(d) : d)
691
+ }));
700
692
  }
701
693
  };
702
694
  this.getMatch = (matchId) => {
703
- var _a;
704
695
  const findFn = (d) => d.id === matchId;
705
- return this.state.cachedMatches.find(findFn) ?? ((_a = this.state.pendingMatches) == null ? void 0 : _a.find(findFn)) ?? this.state.matches.find(findFn);
696
+ return this.state.cachedMatches.find(findFn) ?? this.state.pendingMatches?.find(findFn) ?? this.state.matches.find(findFn);
706
697
  };
707
698
  this.loadMatches = async ({
708
699
  location,
@@ -717,7 +708,7 @@ class RouterCore {
717
708
  const triggerOnReady = async () => {
718
709
  if (!rendered) {
719
710
  rendered = true;
720
- await (onReady == null ? void 0 : onReady());
711
+ await onReady?.();
721
712
  }
722
713
  };
723
714
  const resolvePreload = (matchId) => {
@@ -727,7 +718,6 @@ class RouterCore {
727
718
  triggerOnReady();
728
719
  }
729
720
  const handleRedirectAndNotFound = (match, err) => {
730
- var _a, _b, _c;
731
721
  if (redirect.isRedirect(err) || notFound.isNotFound(err)) {
732
722
  if (redirect.isRedirect(err)) {
733
723
  if (err.redirectHandled) {
@@ -736,20 +726,20 @@ class RouterCore {
736
726
  }
737
727
  }
738
728
  }
739
- (_a = match._nonReactive.beforeLoadPromise) == null ? void 0 : _a.resolve();
740
- (_b = match._nonReactive.loaderPromise) == null ? void 0 : _b.resolve();
741
- match._nonReactive.beforeLoadPromise = void 0;
742
- match._nonReactive.loaderPromise = void 0;
729
+ match.beforeLoadPromise?.resolve();
730
+ match.loaderPromise?.resolve();
743
731
  updateMatch(match.id, (prev) => ({
744
732
  ...prev,
745
733
  status: redirect.isRedirect(err) ? "redirected" : notFound.isNotFound(err) ? "notFound" : "error",
746
734
  isFetching: false,
747
- error: err
735
+ error: err,
736
+ beforeLoadPromise: void 0,
737
+ loaderPromise: void 0
748
738
  }));
749
739
  if (!err.routeId) {
750
740
  err.routeId = match.routeId;
751
741
  }
752
- (_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
742
+ match.loadPromise?.resolve();
753
743
  if (redirect.isRedirect(err)) {
754
744
  rendered = true;
755
745
  err.options._fromLocation = location;
@@ -766,7 +756,7 @@ class RouterCore {
766
756
  };
767
757
  const shouldSkipLoader = (matchId) => {
768
758
  const match = this.getMatch(matchId);
769
- if (!this.isServer && match._nonReactive.dehydrated) {
759
+ if (!this.isServer && match._dehydrated) {
770
760
  return true;
771
761
  }
772
762
  if (this.isServer) {
@@ -780,10 +770,8 @@ class RouterCore {
780
770
  await new Promise((resolveAll, rejectAll) => {
781
771
  ;
782
772
  (async () => {
783
- var _a, _b, _c, _d;
784
773
  try {
785
774
  const handleSerialError = (index, err, routerCode) => {
786
- var _a2, _b2;
787
775
  const { id: matchId, routeId } = matches[index];
788
776
  const route = this.looseRoutesById[routeId];
789
777
  if (err instanceof Promise) {
@@ -793,29 +781,28 @@ class RouterCore {
793
781
  firstBadMatchIndex = firstBadMatchIndex ?? index;
794
782
  handleRedirectAndNotFound(this.getMatch(matchId), err);
795
783
  try {
796
- (_b2 = (_a2 = route.options).onError) == null ? void 0 : _b2.call(_a2, err);
784
+ route.options.onError?.(err);
797
785
  } catch (errorHandlerErr) {
798
786
  err = errorHandlerErr;
799
787
  handleRedirectAndNotFound(this.getMatch(matchId), err);
800
788
  }
801
789
  updateMatch(matchId, (prev) => {
802
- var _a3, _b3;
803
- (_a3 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a3.resolve();
804
- prev._nonReactive.beforeLoadPromise = void 0;
805
- (_b3 = prev._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
790
+ prev.beforeLoadPromise?.resolve();
791
+ prev.loadPromise?.resolve();
806
792
  return {
807
793
  ...prev,
808
794
  error: err,
809
795
  status: "error",
810
796
  isFetching: false,
811
797
  updatedAt: Date.now(),
812
- abortController: new AbortController()
798
+ abortController: new AbortController(),
799
+ beforeLoadPromise: void 0
813
800
  };
814
801
  });
815
802
  };
816
803
  for (const [index, { id: matchId, routeId }] of matches.entries()) {
817
804
  const existingMatch = this.getMatch(matchId);
818
- const parentMatchId = (_a = matches[index - 1]) == null ? void 0 : _a.id;
805
+ const parentMatchId = matches[index - 1]?.id;
819
806
  const parentMatch = parentMatchId ? this.getMatch(parentMatchId) : void 0;
820
807
  const route = this.looseRoutesById[routeId];
821
808
  const pendingMs = route.options.pendingMs ?? this.options.defaultPendingMs;
@@ -825,7 +812,7 @@ class RouterCore {
825
812
  ssr = matchId === root.rootRouteId;
826
813
  } else {
827
814
  const defaultSsr = this.options.defaultSsr ?? true;
828
- if ((parentMatch == null ? void 0 : parentMatch.ssr) === false) {
815
+ if (parentMatch?.ssr === false) {
829
816
  ssr = false;
830
817
  } else {
831
818
  let tempSsr;
@@ -859,39 +846,44 @@ class RouterCore {
859
846
  } else {
860
847
  tempSsr = route.options.ssr;
861
848
  }
862
- if (tempSsr === true && (parentMatch == null ? void 0 : parentMatch.ssr) === "data-only") {
849
+ if (tempSsr === true && parentMatch?.ssr === "data-only") {
863
850
  ssr = "data-only";
864
851
  } else {
865
852
  ssr = tempSsr;
866
853
  }
867
854
  }
868
855
  }
869
- existingMatch.ssr = ssr;
856
+ updateMatch(matchId, (prev) => ({
857
+ ...prev,
858
+ ssr
859
+ }));
870
860
  }
871
861
  if (shouldSkipLoader(matchId)) {
872
862
  continue;
873
863
  }
874
- const shouldPending = !!(onReady && !this.isServer && !resolvePreload(matchId) && (route.options.loader || route.options.beforeLoad || routeNeedsPreload(route)) && typeof pendingMs === "number" && pendingMs !== Infinity && (route.options.pendingComponent ?? ((_b = this.options) == null ? void 0 : _b.defaultPendingComponent)));
864
+ const shouldPending = !!(onReady && !this.isServer && !resolvePreload(matchId) && (route.options.loader || route.options.beforeLoad || routeNeedsPreload(route)) && typeof pendingMs === "number" && pendingMs !== Infinity && (route.options.pendingComponent ?? this.options?.defaultPendingComponent));
875
865
  let executeBeforeLoad = true;
876
866
  const setupPendingTimeout = () => {
877
- const match = this.getMatch(matchId);
878
- if (shouldPending && match._nonReactive.pendingTimeout === void 0) {
867
+ if (shouldPending && this.getMatch(matchId).pendingTimeout === void 0) {
879
868
  const pendingTimeout = setTimeout(() => {
880
869
  try {
881
870
  triggerOnReady();
882
871
  } catch {
883
872
  }
884
873
  }, pendingMs);
885
- match._nonReactive.pendingTimeout = pendingTimeout;
874
+ updateMatch(matchId, (prev) => ({
875
+ ...prev,
876
+ pendingTimeout
877
+ }));
886
878
  }
887
879
  };
888
880
  if (
889
881
  // If we are in the middle of a load, either of these will be present
890
882
  // (not to be confused with `loadPromise`, which is always defined)
891
- existingMatch._nonReactive.beforeLoadPromise || existingMatch._nonReactive.loaderPromise
883
+ existingMatch.beforeLoadPromise || existingMatch.loaderPromise
892
884
  ) {
893
885
  setupPendingTimeout();
894
- await existingMatch._nonReactive.beforeLoadPromise;
886
+ await existingMatch.beforeLoadPromise;
895
887
  const match = this.getMatch(matchId);
896
888
  if (match.status === "error") {
897
889
  executeBeforeLoad = true;
@@ -901,11 +893,15 @@ class RouterCore {
901
893
  }
902
894
  if (executeBeforeLoad) {
903
895
  try {
904
- const match = this.getMatch(matchId);
905
- match._nonReactive.beforeLoadPromise = utils.createControlledPromise();
906
- const prevLoadPromise = match._nonReactive.loadPromise;
907
- match._nonReactive.loadPromise = utils.createControlledPromise(() => {
908
- prevLoadPromise == null ? void 0 : prevLoadPromise.resolve();
896
+ updateMatch(matchId, (prev) => {
897
+ const prevLoadPromise = prev.loadPromise;
898
+ return {
899
+ ...prev,
900
+ loadPromise: utils.createControlledPromise(() => {
901
+ prevLoadPromise?.resolve();
902
+ }),
903
+ beforeLoadPromise: utils.createControlledPromise()
904
+ };
909
905
  });
910
906
  const { paramsError, searchError } = this.getMatch(matchId);
911
907
  if (paramsError) {
@@ -916,7 +912,7 @@ class RouterCore {
916
912
  }
917
913
  setupPendingTimeout();
918
914
  const abortController = new AbortController();
919
- const parentMatchContext = (parentMatch == null ? void 0 : parentMatch.context) ?? this.options.context ?? void 0;
915
+ const parentMatchContext = parentMatch?.context ?? this.options.context ?? {};
920
916
  updateMatch(matchId, (prev) => ({
921
917
  ...prev,
922
918
  isFetching: "beforeLoad",
@@ -941,7 +937,7 @@ class RouterCore {
941
937
  cause: preload ? "preload" : cause,
942
938
  matches
943
939
  };
944
- const beforeLoadContext = await ((_d = (_c = route.options).beforeLoad) == null ? void 0 : _d.call(_c, beforeLoadFnContext));
940
+ const beforeLoadContext = await route.options.beforeLoad?.(beforeLoadFnContext);
945
941
  if (redirect.isRedirect(beforeLoadContext) || notFound.isNotFound(beforeLoadContext)) {
946
942
  handleSerialError(index, beforeLoadContext, "BEFORE_LOAD");
947
943
  }
@@ -961,11 +957,10 @@ class RouterCore {
961
957
  handleSerialError(index, err, "BEFORE_LOAD");
962
958
  }
963
959
  updateMatch(matchId, (prev) => {
964
- var _a2;
965
- (_a2 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a2.resolve();
966
- prev._nonReactive.beforeLoadPromise = void 0;
960
+ prev.beforeLoadPromise?.resolve();
967
961
  return {
968
962
  ...prev,
963
+ beforeLoadPromise: void 0,
969
964
  isFetching: false
970
965
  };
971
966
  });
@@ -976,12 +971,10 @@ class RouterCore {
976
971
  validResolvedMatches.forEach(({ id: matchId, routeId }, index) => {
977
972
  matchPromises.push(
978
973
  (async () => {
979
- var _a2, _b2;
980
974
  let loaderShouldRunAsync = false;
981
975
  let loaderIsRunningAsync = false;
982
976
  const route = this.looseRoutesById[routeId];
983
977
  const executeHead = async () => {
984
- var _a3, _b3, _c2, _d2, _e, _f;
985
978
  const match = this.getMatch(matchId);
986
979
  if (!match) {
987
980
  return;
@@ -992,13 +985,13 @@ class RouterCore {
992
985
  params: match.params,
993
986
  loaderData: match.loaderData
994
987
  };
995
- const headFnContent = await ((_b3 = (_a3 = route.options).head) == null ? void 0 : _b3.call(_a3, assetContext));
996
- const meta = headFnContent == null ? void 0 : headFnContent.meta;
997
- const links = headFnContent == null ? void 0 : headFnContent.links;
998
- const headScripts = headFnContent == null ? void 0 : headFnContent.scripts;
999
- const styles = headFnContent == null ? void 0 : headFnContent.styles;
1000
- const scripts = await ((_d2 = (_c2 = route.options).scripts) == null ? void 0 : _d2.call(_c2, assetContext));
1001
- const headers = await ((_f = (_e = route.options).headers) == null ? void 0 : _f.call(_e, assetContext));
988
+ const headFnContent = await route.options.head?.(assetContext);
989
+ const meta = headFnContent?.meta;
990
+ const links = headFnContent?.links;
991
+ const headScripts = headFnContent?.scripts;
992
+ const styles = headFnContent?.styles;
993
+ const scripts = await route.options.scripts?.(assetContext);
994
+ const headers = await route.options.headers?.(assetContext);
1002
995
  return {
1003
996
  meta,
1004
997
  links,
@@ -1010,8 +1003,8 @@ class RouterCore {
1010
1003
  };
1011
1004
  const potentialPendingMinPromise = async () => {
1012
1005
  const latestMatch = this.getMatch(matchId);
1013
- if (latestMatch._nonReactive.minPendingPromise) {
1014
- await latestMatch._nonReactive.minPendingPromise;
1006
+ if (latestMatch.minPendingPromise) {
1007
+ await latestMatch.minPendingPromise;
1015
1008
  }
1016
1009
  };
1017
1010
  const prevMatch = this.getMatch(matchId);
@@ -1024,11 +1017,11 @@ class RouterCore {
1024
1017
  }));
1025
1018
  return this.getMatch(matchId);
1026
1019
  }
1027
- } else if (prevMatch._nonReactive.loaderPromise) {
1020
+ } else if (prevMatch.loaderPromise) {
1028
1021
  if (prevMatch.status === "success" && !sync && !prevMatch.preload) {
1029
1022
  return this.getMatch(matchId);
1030
1023
  }
1031
- await prevMatch._nonReactive.loaderPromise;
1024
+ await prevMatch.loaderPromise;
1032
1025
  const match = this.getMatch(matchId);
1033
1026
  if (match.error) {
1034
1027
  handleRedirectAndNotFound(match, match.error);
@@ -1062,15 +1055,12 @@ class RouterCore {
1062
1055
  const staleAge = preload ? route.options.preloadStaleTime ?? this.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? this.options.defaultStaleTime ?? 0;
1063
1056
  const shouldReloadOption = route.options.shouldReload;
1064
1057
  const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(getLoaderContext()) : shouldReloadOption;
1065
- updateMatch(matchId, (prev) => {
1066
- prev._nonReactive.loaderPromise = utils.createControlledPromise();
1067
- return {
1068
- ...prev,
1069
- preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
1070
- };
1071
- });
1058
+ updateMatch(matchId, (prev) => ({
1059
+ ...prev,
1060
+ loaderPromise: utils.createControlledPromise(),
1061
+ preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
1062
+ }));
1072
1063
  const runLoader = async () => {
1073
- var _a3, _b3, _c2, _d2;
1074
1064
  try {
1075
1065
  try {
1076
1066
  if (!this.isServer || this.isServer && this.getMatch(matchId).ssr === true) {
@@ -1080,7 +1070,7 @@ class RouterCore {
1080
1070
  ...prev,
1081
1071
  isFetching: "loader"
1082
1072
  }));
1083
- const loaderData = await ((_b3 = (_a3 = route.options).loader) == null ? void 0 : _b3.call(_a3, getLoaderContext()));
1073
+ const loaderData = await route.options.loader?.(getLoaderContext());
1084
1074
  handleRedirectAndNotFound(
1085
1075
  this.getMatch(matchId),
1086
1076
  loaderData
@@ -1106,7 +1096,7 @@ class RouterCore {
1106
1096
  await potentialPendingMinPromise();
1107
1097
  handleRedirectAndNotFound(this.getMatch(matchId), e);
1108
1098
  try {
1109
- (_d2 = (_c2 = route.options).onError) == null ? void 0 : _d2.call(_c2, e);
1099
+ route.options.onError?.(e);
1110
1100
  } catch (onErrorError) {
1111
1101
  error = onErrorError;
1112
1102
  handleRedirectAndNotFound(
@@ -1125,13 +1115,11 @@ class RouterCore {
1125
1115
  }
1126
1116
  } catch (err) {
1127
1117
  const head = await executeHead();
1128
- updateMatch(matchId, (prev) => {
1129
- prev._nonReactive.loaderPromise = void 0;
1130
- return {
1131
- ...prev,
1132
- ...head
1133
- };
1134
- });
1118
+ updateMatch(matchId, (prev) => ({
1119
+ ...prev,
1120
+ loaderPromise: void 0,
1121
+ ...head
1122
+ }));
1135
1123
  handleRedirectAndNotFound(this.getMatch(matchId), err);
1136
1124
  }
1137
1125
  };
@@ -1141,13 +1129,15 @@ class RouterCore {
1141
1129
  } else if (loaderShouldRunAsync && !sync) {
1142
1130
  loaderIsRunningAsync = true;
1143
1131
  (async () => {
1144
- var _a3, _b3;
1145
1132
  try {
1146
1133
  await runLoader();
1147
- const match = this.getMatch(matchId);
1148
- (_a3 = match._nonReactive.loaderPromise) == null ? void 0 : _a3.resolve();
1149
- (_b3 = match._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
1150
- match._nonReactive.loaderPromise = void 0;
1134
+ const { loaderPromise, loadPromise } = this.getMatch(matchId);
1135
+ loaderPromise?.resolve();
1136
+ loadPromise?.resolve();
1137
+ updateMatch(matchId, (prev) => ({
1138
+ ...prev,
1139
+ loaderPromise: void 0
1140
+ }));
1151
1141
  } catch (err) {
1152
1142
  if (redirect.isRedirect(err)) {
1153
1143
  await this.navigate(err.options);
@@ -1165,20 +1155,19 @@ class RouterCore {
1165
1155
  }
1166
1156
  }
1167
1157
  if (!loaderIsRunningAsync) {
1168
- const match = this.getMatch(matchId);
1169
- (_a2 = match._nonReactive.loaderPromise) == null ? void 0 : _a2.resolve();
1170
- (_b2 = match._nonReactive.loadPromise) == null ? void 0 : _b2.resolve();
1158
+ const { loaderPromise, loadPromise } = this.getMatch(matchId);
1159
+ loaderPromise?.resolve();
1160
+ loadPromise?.resolve();
1171
1161
  }
1172
1162
  updateMatch(matchId, (prev) => {
1173
- clearTimeout(prev._nonReactive.pendingTimeout);
1174
- prev._nonReactive.pendingTimeout = void 0;
1175
- if (!loaderIsRunningAsync)
1176
- prev._nonReactive.loaderPromise = void 0;
1177
- prev._nonReactive.dehydrated = void 0;
1163
+ clearTimeout(prev.pendingTimeout);
1178
1164
  return {
1179
1165
  ...prev,
1180
1166
  isFetching: loaderIsRunningAsync ? prev.isFetching : false,
1181
- invalid: false
1167
+ loaderPromise: loaderIsRunningAsync ? prev.loaderPromise : void 0,
1168
+ invalid: false,
1169
+ pendingTimeout: void 0,
1170
+ _dehydrated: void 0
1182
1171
  };
1183
1172
  });
1184
1173
  return this.getMatch(matchId);
@@ -1205,27 +1194,23 @@ class RouterCore {
1205
1194
  };
1206
1195
  this.invalidate = (opts) => {
1207
1196
  const invalidate = (d) => {
1208
- var _a;
1209
- if (((_a = opts == null ? void 0 : opts.filter) == null ? void 0 : _a.call(opts, d)) ?? true) {
1197
+ if (opts?.filter?.(d) ?? true) {
1210
1198
  return {
1211
1199
  ...d,
1212
1200
  invalid: true,
1213
- ...(opts == null ? void 0 : opts.forcePending) || d.status === "error" ? { status: "pending", error: void 0 } : void 0
1201
+ ...opts?.forcePending || d.status === "error" ? { status: "pending", error: void 0 } : {}
1214
1202
  };
1215
1203
  }
1216
1204
  return d;
1217
1205
  };
1218
- this.__store.setState((s) => {
1219
- var _a;
1220
- return {
1221
- ...s,
1222
- matches: s.matches.map(invalidate),
1223
- cachedMatches: s.cachedMatches.map(invalidate),
1224
- pendingMatches: (_a = s.pendingMatches) == null ? void 0 : _a.map(invalidate)
1225
- };
1226
- });
1206
+ this.__store.setState((s) => ({
1207
+ ...s,
1208
+ matches: s.matches.map(invalidate),
1209
+ cachedMatches: s.cachedMatches.map(invalidate),
1210
+ pendingMatches: s.pendingMatches?.map(invalidate)
1211
+ }));
1227
1212
  this.shouldViewTransition = false;
1228
- return this.load({ sync: opts == null ? void 0 : opts.sync });
1213
+ return this.load({ sync: opts?.sync });
1229
1214
  };
1230
1215
  this.resolveRedirect = (redirect2) => {
1231
1216
  if (!redirect2.options.href) {
@@ -1238,7 +1223,7 @@ class RouterCore {
1238
1223
  return redirect2;
1239
1224
  };
1240
1225
  this.clearCache = (opts) => {
1241
- const filter = opts == null ? void 0 : opts.filter;
1226
+ const filter = opts?.filter;
1242
1227
  if (filter !== void 0) {
1243
1228
  this.__store.setState((s) => {
1244
1229
  return {
@@ -1287,7 +1272,7 @@ class RouterCore {
1287
1272
  () => Promise.all(
1288
1273
  componentTypes.map(async (type) => {
1289
1274
  const component = route.options[type];
1290
- if (component == null ? void 0 : component.preload) {
1275
+ if (component?.preload) {
1291
1276
  await component.preload();
1292
1277
  }
1293
1278
  })
@@ -1363,10 +1348,10 @@ class RouterCore {
1363
1348
  leaveParams: true
1364
1349
  };
1365
1350
  const next = this.buildLocation(matchLocation);
1366
- if ((opts == null ? void 0 : opts.pending) && this.state.status !== "pending") {
1351
+ if (opts?.pending && this.state.status !== "pending") {
1367
1352
  return false;
1368
1353
  }
1369
- const pending = (opts == null ? void 0 : opts.pending) === void 0 ? !this.state.isLoading : opts.pending;
1354
+ const pending = opts?.pending === void 0 ? !this.state.isLoading : opts.pending;
1370
1355
  const baseLocation = pending ? this.latestLocation : this.state.resolvedLocation || this.state.location;
1371
1356
  const match = path.matchPathname(
1372
1357
  this.basepath,
@@ -1385,7 +1370,7 @@ class RouterCore {
1385
1370
  return false;
1386
1371
  }
1387
1372
  }
1388
- if (match && ((opts == null ? void 0 : opts.includeSearch) ?? true)) {
1373
+ if (match && (opts?.includeSearch ?? true)) {
1389
1374
  return utils.deepEqual(baseLocation.search, next.search, { partial: true }) ? match : false;
1390
1375
  }
1391
1376
  return match;
@@ -1393,13 +1378,12 @@ class RouterCore {
1393
1378
  this._handleNotFound = (matches, err, {
1394
1379
  updateMatch = this.updateMatch
1395
1380
  } = {}) => {
1396
- var _a;
1397
1381
  const routeCursor = this.routesById[err.routeId ?? ""] ?? this.routeTree;
1398
1382
  const matchesByRouteId = {};
1399
1383
  for (const match of matches) {
1400
1384
  matchesByRouteId[match.routeId] = match;
1401
1385
  }
1402
- if (!routeCursor.options.notFoundComponent && ((_a = this.options) == null ? void 0 : _a.defaultNotFoundComponent)) {
1386
+ if (!routeCursor.options.notFoundComponent && this.options?.defaultNotFoundComponent) {
1403
1387
  routeCursor.options.notFoundComponent = this.options.defaultNotFoundComponent;
1404
1388
  }
1405
1389
  invariant(
@@ -1457,10 +1441,9 @@ class RouterCore {
1457
1441
  return this.routesById;
1458
1442
  }
1459
1443
  matchRoutesInternal(next, opts) {
1460
- var _a;
1461
1444
  const { foundRoute, matchedRoutes, routeParams } = this.getMatchedRoutes(
1462
1445
  next.pathname,
1463
- (_a = opts == null ? void 0 : opts.dest) == null ? void 0 : _a.to
1446
+ opts?.dest?.to
1464
1447
  );
1465
1448
  let isGlobalNotFound = false;
1466
1449
  if (
@@ -1491,9 +1474,8 @@ class RouterCore {
1491
1474
  return root.rootRouteId;
1492
1475
  })();
1493
1476
  const parseErrors = matchedRoutes.map((route) => {
1494
- var _a2;
1495
1477
  let parsedParamsError;
1496
- const parseParams = ((_a2 = route.options.params) == null ? void 0 : _a2.parse) ?? route.options.parseParams;
1478
+ const parseParams = route.options.params?.parse ?? route.options.parseParams;
1497
1479
  if (parseParams) {
1498
1480
  try {
1499
1481
  const parsedParams = parseParams(routeParams);
@@ -1502,7 +1484,7 @@ class RouterCore {
1502
1484
  parsedParamsError = new PathParamError(err.message, {
1503
1485
  cause: err
1504
1486
  });
1505
- if (opts == null ? void 0 : opts.throwOnError) {
1487
+ if (opts?.throwOnError) {
1506
1488
  throw parsedParamsError;
1507
1489
  }
1508
1490
  return parsedParamsError;
@@ -1512,18 +1494,17 @@ class RouterCore {
1512
1494
  });
1513
1495
  const matches = [];
1514
1496
  const getParentContext = (parentMatch) => {
1515
- const parentMatchId = parentMatch == null ? void 0 : parentMatch.id;
1516
- const parentContext = !parentMatchId ? this.options.context ?? void 0 : parentMatch.context ?? this.options.context ?? void 0;
1497
+ const parentMatchId = parentMatch?.id;
1498
+ const parentContext = !parentMatchId ? this.options.context ?? {} : parentMatch.context ?? this.options.context ?? {};
1517
1499
  return parentContext;
1518
1500
  };
1519
1501
  matchedRoutes.forEach((route, index) => {
1520
- var _a2, _b;
1521
1502
  const parentMatch = matches[index - 1];
1522
1503
  const [preMatchSearch, strictMatchSearch, searchError] = (() => {
1523
- const parentSearch = (parentMatch == null ? void 0 : parentMatch.search) ?? next.search;
1524
- const parentStrictSearch = (parentMatch == null ? void 0 : parentMatch._strictSearch) ?? void 0;
1504
+ const parentSearch = parentMatch?.search ?? next.search;
1505
+ const parentStrictSearch = parentMatch?._strictSearch ?? {};
1525
1506
  try {
1526
- const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
1507
+ const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? {};
1527
1508
  return [
1528
1509
  {
1529
1510
  ...parentSearch,
@@ -1539,15 +1520,15 @@ class RouterCore {
1539
1520
  cause: err
1540
1521
  });
1541
1522
  }
1542
- if (opts == null ? void 0 : opts.throwOnError) {
1523
+ if (opts?.throwOnError) {
1543
1524
  throw searchParamError;
1544
1525
  }
1545
1526
  return [parentSearch, {}, searchParamError];
1546
1527
  }
1547
1528
  })();
1548
- const loaderDeps = ((_b = (_a2 = route.options).loaderDeps) == null ? void 0 : _b.call(_a2, {
1529
+ const loaderDeps = route.options.loaderDeps?.({
1549
1530
  search: preMatchSearch
1550
- })) ?? "";
1531
+ }) ?? "";
1551
1532
  const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : "";
1552
1533
  const { usedParams, interpolatedPath } = path.interpolatePath({
1553
1534
  path: route.fullPath,
@@ -1593,10 +1574,7 @@ class RouterCore {
1593
1574
  isFetching: false,
1594
1575
  error: void 0,
1595
1576
  paramsError: parseErrors[index],
1596
- __routeContext: void 0,
1597
- _nonReactive: {
1598
- loadPromise: utils.createControlledPromise()
1599
- },
1577
+ __routeContext: {},
1600
1578
  __beforeLoadContext: void 0,
1601
1579
  context: {},
1602
1580
  abortController: new AbortController(),
@@ -1610,10 +1588,11 @@ class RouterCore {
1610
1588
  headScripts: void 0,
1611
1589
  meta: void 0,
1612
1590
  staticData: route.options.staticData || {},
1591
+ loadPromise: utils.createControlledPromise(),
1613
1592
  fullPath: route.fullPath
1614
1593
  };
1615
1594
  }
1616
- if (!(opts == null ? void 0 : opts.preload)) {
1595
+ if (!opts?.preload) {
1617
1596
  match.globalNotFound = globalNotFoundRouteId === route.id;
1618
1597
  }
1619
1598
  match.searchError = searchError;
@@ -1628,24 +1607,22 @@ class RouterCore {
1628
1607
  matches.forEach((match, index) => {
1629
1608
  const route = this.looseRoutesById[match.routeId];
1630
1609
  const existingMatch = this.getMatch(match.id);
1631
- if (!existingMatch && (opts == null ? void 0 : opts._buildLocation) !== true) {
1610
+ if (!existingMatch && opts?._buildLocation !== true) {
1632
1611
  const parentMatch = matches[index - 1];
1633
1612
  const parentContext = getParentContext(parentMatch);
1634
- if (route.options.context) {
1635
- const contextFnContext = {
1636
- deps: match.loaderDeps,
1637
- params: match.params,
1638
- context: parentContext ?? {},
1639
- location: next,
1640
- navigate: (opts2) => this.navigate({ ...opts2, _fromLocation: next }),
1641
- buildLocation: this.buildLocation,
1642
- cause: match.cause,
1643
- abortController: match.abortController,
1644
- preload: !!match.preload,
1645
- matches
1646
- };
1647
- match.__routeContext = route.options.context(contextFnContext) ?? void 0;
1648
- }
1613
+ const contextFnContext = {
1614
+ deps: match.loaderDeps,
1615
+ params: match.params,
1616
+ context: parentContext,
1617
+ location: next,
1618
+ navigate: (opts2) => this.navigate({ ...opts2, _fromLocation: next }),
1619
+ buildLocation: this.buildLocation,
1620
+ cause: match.cause,
1621
+ abortController: match.abortController,
1622
+ preload: !!match.preload,
1623
+ matches
1624
+ };
1625
+ match.__routeContext = route.options.context?.(contextFnContext) ?? {};
1649
1626
  match.context = {
1650
1627
  ...parentContext,
1651
1628
  ...match.__routeContext,
@@ -1711,9 +1688,8 @@ const componentTypes = [
1711
1688
  "notFoundComponent"
1712
1689
  ];
1713
1690
  function routeNeedsPreload(route) {
1714
- var _a;
1715
1691
  for (const componentType of componentTypes) {
1716
- if ((_a = route.options[componentType]) == null ? void 0 : _a.preload) {
1692
+ if (route.options[componentType]?.preload) {
1717
1693
  return true;
1718
1694
  }
1719
1695
  }
@@ -1747,7 +1723,7 @@ function processRouteTree({
1747
1723
  const routesByPath = {};
1748
1724
  const recurseRoutes = (childRoutes) => {
1749
1725
  childRoutes.forEach((childRoute, i) => {
1750
- initRoute == null ? void 0 : initRoute(childRoute, i);
1726
+ initRoute?.(childRoute, i);
1751
1727
  const existingRoute = routesById[childRoute.id];
1752
1728
  invariant(
1753
1729
  !existingRoute,
@@ -1761,7 +1737,7 @@ function processRouteTree({
1761
1737
  }
1762
1738
  }
1763
1739
  const children = childRoute.children;
1764
- if (children == null ? void 0 : children.length) {
1740
+ if (children?.length) {
1765
1741
  recurseRoutes(children);
1766
1742
  }
1767
1743
  });
@@ -1770,14 +1746,13 @@ function processRouteTree({
1770
1746
  const scoredRoutes = [];
1771
1747
  const routes = Object.values(routesById);
1772
1748
  routes.forEach((d, i) => {
1773
- var _a;
1774
1749
  if (d.isRoot || !d.path) {
1775
1750
  return;
1776
1751
  }
1777
1752
  const trimmed = path.trimPathLeft(d.fullPath);
1778
1753
  let parsed = path.parsePathname(trimmed);
1779
1754
  let skip = 0;
1780
- while (parsed.length > skip + 1 && ((_a = parsed[skip]) == null ? void 0 : _a.value) === "/") {
1755
+ while (parsed.length > skip + 1 && parsed[skip]?.value === "/") {
1781
1756
  skip++;
1782
1757
  }
1783
1758
  if (skip > 0) parsed = parsed.slice(skip);
@@ -1862,13 +1837,12 @@ function getMatchedRoutes({
1862
1837
  let routeParams = {};
1863
1838
  const trimmedPath = path.trimPathRight(pathname);
1864
1839
  const getMatchedParams = (route) => {
1865
- var _a;
1866
1840
  const result = path.matchPathname(
1867
1841
  basepath,
1868
1842
  trimmedPath,
1869
1843
  {
1870
1844
  to: route.fullPath,
1871
- caseSensitive: ((_a = route.options) == null ? void 0 : _a.caseSensitive) ?? caseSensitive,
1845
+ caseSensitive: route.options?.caseSensitive ?? caseSensitive,
1872
1846
  // we need fuzzy matching for `notFoundMode: 'fuzzy'`
1873
1847
  fuzzy: true
1874
1848
  },
@@ -1917,10 +1891,9 @@ function applySearchMiddleware({
1917
1891
  }) {
1918
1892
  const allMiddlewares = destRoutes.reduce(
1919
1893
  (acc, route) => {
1920
- var _a;
1921
1894
  const middlewares = [];
1922
1895
  if ("search" in route.options) {
1923
- if ((_a = route.options.search) == null ? void 0 : _a.middlewares) {
1896
+ if (route.options.search?.middlewares) {
1924
1897
  middlewares.push(...route.options.search.middlewares);
1925
1898
  }
1926
1899
  } else if (route.options.preSearchFilters || route.options.postSearchFilters) {
@@ -1952,7 +1925,7 @@ function applySearchMiddleware({
1952
1925
  try {
1953
1926
  const validatedSearch = {
1954
1927
  ...result,
1955
- ...validateSearch(route.options.validateSearch, result) ?? void 0
1928
+ ...validateSearch(route.options.validateSearch, result) ?? {}
1956
1929
  };
1957
1930
  return validatedSearch;
1958
1931
  } catch {