@tanstack/router-core 1.131.7 → 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 +168 -196
  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 +168 -196
  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 +112 -110
  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,24 +212,27 @@ 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
237
233
  });
238
234
  const lastMatch = utils.last(allCurrentLocationMatches);
239
- let fromPath = this.resolvePathWithBase(lastMatch.fullPath, ".");
235
+ let fromPath = lastMatch.fullPath;
240
236
  const toPath = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
241
237
  const routeIsChanging = !!dest.to && !comparePaths(dest.to.toString(), fromPath) && !comparePaths(toPath, fromPath);
242
238
  if (dest.unsafeRelative === "path") {
@@ -259,7 +255,6 @@ class RouterCore {
259
255
  }
260
256
  }
261
257
  }
262
- fromPath = this.resolvePathWithBase(fromPath, ".");
263
258
  const fromSearch = lastMatch.search;
264
259
  const fromParams = { ...lastMatch.params };
265
260
  const nextTo = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
@@ -272,13 +267,16 @@ class RouterCore {
272
267
  params: nextParams ?? {},
273
268
  parseCache: this.parsePathnameCache
274
269
  }).interpolatedPath;
275
- const destRoutes = this.matchRoutes(interpolatedNextTo, void 0, {
276
- _buildLocation: true
277
- }).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]);
278
277
  if (Object.keys(nextParams).length > 0) {
279
278
  destRoutes.map((route) => {
280
- var _a2;
281
- return ((_a2 = route.options.params) == null ? void 0 : _a2.stringify) ?? route.options.stringifyParams;
279
+ return route.options.params?.stringify ?? route.options.stringifyParams;
282
280
  }).filter(Boolean).forEach((fn) => {
283
281
  nextParams = { ...nextParams, ...fn(nextParams) };
284
282
  });
@@ -294,7 +292,7 @@ class RouterCore {
294
292
  parseCache: this.parsePathnameCache
295
293
  }).interpolatedPath;
296
294
  let nextSearch = fromSearch;
297
- if (opts._includeValidateSearch && ((_a = this.options.search) == null ? void 0 : _a.strict)) {
295
+ if (opts._includeValidateSearch && this.options.search?.strict) {
298
296
  let validatedSearch = {};
299
297
  destRoutes.forEach((route) => {
300
298
  try {
@@ -335,12 +333,11 @@ class RouterCore {
335
333
  };
336
334
  };
337
335
  const buildWithMatches = (dest = {}, maskedDest) => {
338
- var _a;
339
336
  const next = build(dest);
340
337
  let maskedNext = maskedDest ? build(maskedDest) : void 0;
341
338
  if (!maskedNext) {
342
339
  let params = {};
343
- const foundMask = (_a = this.options.routeMasks) == null ? void 0 : _a.find((d) => {
340
+ const foundMask = this.options.routeMasks?.find((d) => {
344
341
  const match = path.matchPathname(
345
342
  this.basepath,
346
343
  next.pathname,
@@ -406,7 +403,7 @@ class RouterCore {
406
403
  const isSameUrl = this.latestLocation.href === next.href;
407
404
  const previousCommitPromise = this.commitLocationPromise;
408
405
  this.commitLocationPromise = utils.createControlledPromise(() => {
409
- previousCommitPromise == null ? void 0 : previousCommitPromise.resolve();
406
+ previousCommitPromise?.resolve();
410
407
  });
411
408
  if (isSameUrl && isSameState()) {
412
409
  this.load();
@@ -510,7 +507,7 @@ class RouterCore {
510
507
  };
511
508
  this.beforeLoad = () => {
512
509
  this.cancelMatches();
513
- this.updateLatestLocation();
510
+ this.latestLocation = this.parseLocation(this.latestLocation);
514
511
  if (this.isServer) {
515
512
  const nextLocation = this.buildLocation({
516
513
  to: this.latestLocation.pathname,
@@ -551,7 +548,6 @@ class RouterCore {
551
548
  let loadPromise;
552
549
  loadPromise = new Promise((resolve) => {
553
550
  this.startTransition(async () => {
554
- var _a;
555
551
  try {
556
552
  this.beforeLoad();
557
553
  const next = this.latestLocation;
@@ -573,7 +569,7 @@ class RouterCore {
573
569
  })
574
570
  });
575
571
  await this.loadMatches({
576
- sync: opts == null ? void 0 : opts.sync,
572
+ sync: opts?.sync,
577
573
  matches: this.state.pendingMatches,
578
574
  location: next,
579
575
  // eslint-disable-next-line @typescript-eslint/require-await
@@ -615,8 +611,7 @@ class RouterCore {
615
611
  [stayingMatches, "onStay"]
616
612
  ].forEach(([matches, hook]) => {
617
613
  matches.forEach((match) => {
618
- var _a2, _b;
619
- (_b = (_a2 = this.looseRoutesById[match.routeId].options)[hook]) == null ? void 0 : _b.call(_a2, match);
614
+ this.looseRoutesById[match.routeId].options[hook]?.(match);
620
615
  });
621
616
  });
622
617
  });
@@ -642,7 +637,7 @@ class RouterCore {
642
637
  }));
643
638
  }
644
639
  if (this.latestLoadPromise === loadPromise) {
645
- (_a = this.commitLocationPromise) == null ? void 0 : _a.resolve();
640
+ this.commitLocationPromise?.resolve();
646
641
  this.latestLoadPromise = void 0;
647
642
  this.commitLocationPromise = void 0;
648
643
  }
@@ -688,22 +683,17 @@ class RouterCore {
688
683
  }
689
684
  };
690
685
  this.updateMatch = (id, updater) => {
691
- var _a;
692
- 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" : "";
693
687
  if (matchesKey) {
694
- this.__store.setState((s) => {
695
- var _a2;
696
- return {
697
- ...s,
698
- [matchesKey]: (_a2 = s[matchesKey]) == null ? void 0 : _a2.map((d) => d.id === id ? updater(d) : d)
699
- };
700
- });
688
+ this.__store.setState((s) => ({
689
+ ...s,
690
+ [matchesKey]: s[matchesKey]?.map((d) => d.id === id ? updater(d) : d)
691
+ }));
701
692
  }
702
693
  };
703
694
  this.getMatch = (matchId) => {
704
- var _a;
705
695
  const findFn = (d) => d.id === matchId;
706
- 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);
707
697
  };
708
698
  this.loadMatches = async ({
709
699
  location,
@@ -718,7 +708,7 @@ class RouterCore {
718
708
  const triggerOnReady = async () => {
719
709
  if (!rendered) {
720
710
  rendered = true;
721
- await (onReady == null ? void 0 : onReady());
711
+ await onReady?.();
722
712
  }
723
713
  };
724
714
  const resolvePreload = (matchId) => {
@@ -728,7 +718,6 @@ class RouterCore {
728
718
  triggerOnReady();
729
719
  }
730
720
  const handleRedirectAndNotFound = (match, err) => {
731
- var _a, _b, _c;
732
721
  if (redirect.isRedirect(err) || notFound.isNotFound(err)) {
733
722
  if (redirect.isRedirect(err)) {
734
723
  if (err.redirectHandled) {
@@ -737,20 +726,20 @@ class RouterCore {
737
726
  }
738
727
  }
739
728
  }
740
- (_a = match._nonReactive.beforeLoadPromise) == null ? void 0 : _a.resolve();
741
- (_b = match._nonReactive.loaderPromise) == null ? void 0 : _b.resolve();
742
- match._nonReactive.beforeLoadPromise = void 0;
743
- match._nonReactive.loaderPromise = void 0;
729
+ match.beforeLoadPromise?.resolve();
730
+ match.loaderPromise?.resolve();
744
731
  updateMatch(match.id, (prev) => ({
745
732
  ...prev,
746
733
  status: redirect.isRedirect(err) ? "redirected" : notFound.isNotFound(err) ? "notFound" : "error",
747
734
  isFetching: false,
748
- error: err
735
+ error: err,
736
+ beforeLoadPromise: void 0,
737
+ loaderPromise: void 0
749
738
  }));
750
739
  if (!err.routeId) {
751
740
  err.routeId = match.routeId;
752
741
  }
753
- (_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
742
+ match.loadPromise?.resolve();
754
743
  if (redirect.isRedirect(err)) {
755
744
  rendered = true;
756
745
  err.options._fromLocation = location;
@@ -767,7 +756,7 @@ class RouterCore {
767
756
  };
768
757
  const shouldSkipLoader = (matchId) => {
769
758
  const match = this.getMatch(matchId);
770
- if (!this.isServer && match._nonReactive.dehydrated) {
759
+ if (!this.isServer && match._dehydrated) {
771
760
  return true;
772
761
  }
773
762
  if (this.isServer) {
@@ -781,10 +770,8 @@ class RouterCore {
781
770
  await new Promise((resolveAll, rejectAll) => {
782
771
  ;
783
772
  (async () => {
784
- var _a, _b, _c, _d;
785
773
  try {
786
774
  const handleSerialError = (index, err, routerCode) => {
787
- var _a2, _b2;
788
775
  const { id: matchId, routeId } = matches[index];
789
776
  const route = this.looseRoutesById[routeId];
790
777
  if (err instanceof Promise) {
@@ -794,29 +781,28 @@ class RouterCore {
794
781
  firstBadMatchIndex = firstBadMatchIndex ?? index;
795
782
  handleRedirectAndNotFound(this.getMatch(matchId), err);
796
783
  try {
797
- (_b2 = (_a2 = route.options).onError) == null ? void 0 : _b2.call(_a2, err);
784
+ route.options.onError?.(err);
798
785
  } catch (errorHandlerErr) {
799
786
  err = errorHandlerErr;
800
787
  handleRedirectAndNotFound(this.getMatch(matchId), err);
801
788
  }
802
789
  updateMatch(matchId, (prev) => {
803
- var _a3, _b3;
804
- (_a3 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a3.resolve();
805
- prev._nonReactive.beforeLoadPromise = void 0;
806
- (_b3 = prev._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
790
+ prev.beforeLoadPromise?.resolve();
791
+ prev.loadPromise?.resolve();
807
792
  return {
808
793
  ...prev,
809
794
  error: err,
810
795
  status: "error",
811
796
  isFetching: false,
812
797
  updatedAt: Date.now(),
813
- abortController: new AbortController()
798
+ abortController: new AbortController(),
799
+ beforeLoadPromise: void 0
814
800
  };
815
801
  });
816
802
  };
817
803
  for (const [index, { id: matchId, routeId }] of matches.entries()) {
818
804
  const existingMatch = this.getMatch(matchId);
819
- const parentMatchId = (_a = matches[index - 1]) == null ? void 0 : _a.id;
805
+ const parentMatchId = matches[index - 1]?.id;
820
806
  const parentMatch = parentMatchId ? this.getMatch(parentMatchId) : void 0;
821
807
  const route = this.looseRoutesById[routeId];
822
808
  const pendingMs = route.options.pendingMs ?? this.options.defaultPendingMs;
@@ -826,7 +812,7 @@ class RouterCore {
826
812
  ssr = matchId === root.rootRouteId;
827
813
  } else {
828
814
  const defaultSsr = this.options.defaultSsr ?? true;
829
- if ((parentMatch == null ? void 0 : parentMatch.ssr) === false) {
815
+ if (parentMatch?.ssr === false) {
830
816
  ssr = false;
831
817
  } else {
832
818
  let tempSsr;
@@ -860,39 +846,44 @@ class RouterCore {
860
846
  } else {
861
847
  tempSsr = route.options.ssr;
862
848
  }
863
- if (tempSsr === true && (parentMatch == null ? void 0 : parentMatch.ssr) === "data-only") {
849
+ if (tempSsr === true && parentMatch?.ssr === "data-only") {
864
850
  ssr = "data-only";
865
851
  } else {
866
852
  ssr = tempSsr;
867
853
  }
868
854
  }
869
855
  }
870
- existingMatch.ssr = ssr;
856
+ updateMatch(matchId, (prev) => ({
857
+ ...prev,
858
+ ssr
859
+ }));
871
860
  }
872
861
  if (shouldSkipLoader(matchId)) {
873
862
  continue;
874
863
  }
875
- 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));
876
865
  let executeBeforeLoad = true;
877
866
  const setupPendingTimeout = () => {
878
- const match = this.getMatch(matchId);
879
- if (shouldPending && match._nonReactive.pendingTimeout === void 0) {
867
+ if (shouldPending && this.getMatch(matchId).pendingTimeout === void 0) {
880
868
  const pendingTimeout = setTimeout(() => {
881
869
  try {
882
870
  triggerOnReady();
883
871
  } catch {
884
872
  }
885
873
  }, pendingMs);
886
- match._nonReactive.pendingTimeout = pendingTimeout;
874
+ updateMatch(matchId, (prev) => ({
875
+ ...prev,
876
+ pendingTimeout
877
+ }));
887
878
  }
888
879
  };
889
880
  if (
890
881
  // If we are in the middle of a load, either of these will be present
891
882
  // (not to be confused with `loadPromise`, which is always defined)
892
- existingMatch._nonReactive.beforeLoadPromise || existingMatch._nonReactive.loaderPromise
883
+ existingMatch.beforeLoadPromise || existingMatch.loaderPromise
893
884
  ) {
894
885
  setupPendingTimeout();
895
- await existingMatch._nonReactive.beforeLoadPromise;
886
+ await existingMatch.beforeLoadPromise;
896
887
  const match = this.getMatch(matchId);
897
888
  if (match.status === "error") {
898
889
  executeBeforeLoad = true;
@@ -902,11 +893,15 @@ class RouterCore {
902
893
  }
903
894
  if (executeBeforeLoad) {
904
895
  try {
905
- const match = this.getMatch(matchId);
906
- match._nonReactive.beforeLoadPromise = utils.createControlledPromise();
907
- const prevLoadPromise = match._nonReactive.loadPromise;
908
- match._nonReactive.loadPromise = utils.createControlledPromise(() => {
909
- 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
+ };
910
905
  });
911
906
  const { paramsError, searchError } = this.getMatch(matchId);
912
907
  if (paramsError) {
@@ -917,7 +912,7 @@ class RouterCore {
917
912
  }
918
913
  setupPendingTimeout();
919
914
  const abortController = new AbortController();
920
- const parentMatchContext = (parentMatch == null ? void 0 : parentMatch.context) ?? this.options.context ?? void 0;
915
+ const parentMatchContext = parentMatch?.context ?? this.options.context ?? {};
921
916
  updateMatch(matchId, (prev) => ({
922
917
  ...prev,
923
918
  isFetching: "beforeLoad",
@@ -942,7 +937,7 @@ class RouterCore {
942
937
  cause: preload ? "preload" : cause,
943
938
  matches
944
939
  };
945
- const beforeLoadContext = await ((_d = (_c = route.options).beforeLoad) == null ? void 0 : _d.call(_c, beforeLoadFnContext));
940
+ const beforeLoadContext = await route.options.beforeLoad?.(beforeLoadFnContext);
946
941
  if (redirect.isRedirect(beforeLoadContext) || notFound.isNotFound(beforeLoadContext)) {
947
942
  handleSerialError(index, beforeLoadContext, "BEFORE_LOAD");
948
943
  }
@@ -962,11 +957,10 @@ class RouterCore {
962
957
  handleSerialError(index, err, "BEFORE_LOAD");
963
958
  }
964
959
  updateMatch(matchId, (prev) => {
965
- var _a2;
966
- (_a2 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a2.resolve();
967
- prev._nonReactive.beforeLoadPromise = void 0;
960
+ prev.beforeLoadPromise?.resolve();
968
961
  return {
969
962
  ...prev,
963
+ beforeLoadPromise: void 0,
970
964
  isFetching: false
971
965
  };
972
966
  });
@@ -977,12 +971,10 @@ class RouterCore {
977
971
  validResolvedMatches.forEach(({ id: matchId, routeId }, index) => {
978
972
  matchPromises.push(
979
973
  (async () => {
980
- var _a2, _b2;
981
974
  let loaderShouldRunAsync = false;
982
975
  let loaderIsRunningAsync = false;
983
976
  const route = this.looseRoutesById[routeId];
984
977
  const executeHead = async () => {
985
- var _a3, _b3, _c2, _d2, _e, _f;
986
978
  const match = this.getMatch(matchId);
987
979
  if (!match) {
988
980
  return;
@@ -993,13 +985,13 @@ class RouterCore {
993
985
  params: match.params,
994
986
  loaderData: match.loaderData
995
987
  };
996
- const headFnContent = await ((_b3 = (_a3 = route.options).head) == null ? void 0 : _b3.call(_a3, assetContext));
997
- const meta = headFnContent == null ? void 0 : headFnContent.meta;
998
- const links = headFnContent == null ? void 0 : headFnContent.links;
999
- const headScripts = headFnContent == null ? void 0 : headFnContent.scripts;
1000
- const styles = headFnContent == null ? void 0 : headFnContent.styles;
1001
- const scripts = await ((_d2 = (_c2 = route.options).scripts) == null ? void 0 : _d2.call(_c2, assetContext));
1002
- 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);
1003
995
  return {
1004
996
  meta,
1005
997
  links,
@@ -1011,8 +1003,8 @@ class RouterCore {
1011
1003
  };
1012
1004
  const potentialPendingMinPromise = async () => {
1013
1005
  const latestMatch = this.getMatch(matchId);
1014
- if (latestMatch._nonReactive.minPendingPromise) {
1015
- await latestMatch._nonReactive.minPendingPromise;
1006
+ if (latestMatch.minPendingPromise) {
1007
+ await latestMatch.minPendingPromise;
1016
1008
  }
1017
1009
  };
1018
1010
  const prevMatch = this.getMatch(matchId);
@@ -1025,11 +1017,11 @@ class RouterCore {
1025
1017
  }));
1026
1018
  return this.getMatch(matchId);
1027
1019
  }
1028
- } else if (prevMatch._nonReactive.loaderPromise) {
1020
+ } else if (prevMatch.loaderPromise) {
1029
1021
  if (prevMatch.status === "success" && !sync && !prevMatch.preload) {
1030
1022
  return this.getMatch(matchId);
1031
1023
  }
1032
- await prevMatch._nonReactive.loaderPromise;
1024
+ await prevMatch.loaderPromise;
1033
1025
  const match = this.getMatch(matchId);
1034
1026
  if (match.error) {
1035
1027
  handleRedirectAndNotFound(match, match.error);
@@ -1063,15 +1055,12 @@ class RouterCore {
1063
1055
  const staleAge = preload ? route.options.preloadStaleTime ?? this.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? this.options.defaultStaleTime ?? 0;
1064
1056
  const shouldReloadOption = route.options.shouldReload;
1065
1057
  const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(getLoaderContext()) : shouldReloadOption;
1066
- updateMatch(matchId, (prev) => {
1067
- prev._nonReactive.loaderPromise = utils.createControlledPromise();
1068
- return {
1069
- ...prev,
1070
- preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
1071
- };
1072
- });
1058
+ updateMatch(matchId, (prev) => ({
1059
+ ...prev,
1060
+ loaderPromise: utils.createControlledPromise(),
1061
+ preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
1062
+ }));
1073
1063
  const runLoader = async () => {
1074
- var _a3, _b3, _c2, _d2;
1075
1064
  try {
1076
1065
  try {
1077
1066
  if (!this.isServer || this.isServer && this.getMatch(matchId).ssr === true) {
@@ -1081,7 +1070,7 @@ class RouterCore {
1081
1070
  ...prev,
1082
1071
  isFetching: "loader"
1083
1072
  }));
1084
- const loaderData = await ((_b3 = (_a3 = route.options).loader) == null ? void 0 : _b3.call(_a3, getLoaderContext()));
1073
+ const loaderData = await route.options.loader?.(getLoaderContext());
1085
1074
  handleRedirectAndNotFound(
1086
1075
  this.getMatch(matchId),
1087
1076
  loaderData
@@ -1107,7 +1096,7 @@ class RouterCore {
1107
1096
  await potentialPendingMinPromise();
1108
1097
  handleRedirectAndNotFound(this.getMatch(matchId), e);
1109
1098
  try {
1110
- (_d2 = (_c2 = route.options).onError) == null ? void 0 : _d2.call(_c2, e);
1099
+ route.options.onError?.(e);
1111
1100
  } catch (onErrorError) {
1112
1101
  error = onErrorError;
1113
1102
  handleRedirectAndNotFound(
@@ -1126,13 +1115,11 @@ class RouterCore {
1126
1115
  }
1127
1116
  } catch (err) {
1128
1117
  const head = await executeHead();
1129
- updateMatch(matchId, (prev) => {
1130
- prev._nonReactive.loaderPromise = void 0;
1131
- return {
1132
- ...prev,
1133
- ...head
1134
- };
1135
- });
1118
+ updateMatch(matchId, (prev) => ({
1119
+ ...prev,
1120
+ loaderPromise: void 0,
1121
+ ...head
1122
+ }));
1136
1123
  handleRedirectAndNotFound(this.getMatch(matchId), err);
1137
1124
  }
1138
1125
  };
@@ -1142,13 +1129,15 @@ class RouterCore {
1142
1129
  } else if (loaderShouldRunAsync && !sync) {
1143
1130
  loaderIsRunningAsync = true;
1144
1131
  (async () => {
1145
- var _a3, _b3;
1146
1132
  try {
1147
1133
  await runLoader();
1148
- const match = this.getMatch(matchId);
1149
- (_a3 = match._nonReactive.loaderPromise) == null ? void 0 : _a3.resolve();
1150
- (_b3 = match._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
1151
- 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
+ }));
1152
1141
  } catch (err) {
1153
1142
  if (redirect.isRedirect(err)) {
1154
1143
  await this.navigate(err.options);
@@ -1166,20 +1155,19 @@ class RouterCore {
1166
1155
  }
1167
1156
  }
1168
1157
  if (!loaderIsRunningAsync) {
1169
- const match = this.getMatch(matchId);
1170
- (_a2 = match._nonReactive.loaderPromise) == null ? void 0 : _a2.resolve();
1171
- (_b2 = match._nonReactive.loadPromise) == null ? void 0 : _b2.resolve();
1158
+ const { loaderPromise, loadPromise } = this.getMatch(matchId);
1159
+ loaderPromise?.resolve();
1160
+ loadPromise?.resolve();
1172
1161
  }
1173
1162
  updateMatch(matchId, (prev) => {
1174
- clearTimeout(prev._nonReactive.pendingTimeout);
1175
- prev._nonReactive.pendingTimeout = void 0;
1176
- if (!loaderIsRunningAsync)
1177
- prev._nonReactive.loaderPromise = void 0;
1178
- prev._nonReactive.dehydrated = void 0;
1163
+ clearTimeout(prev.pendingTimeout);
1179
1164
  return {
1180
1165
  ...prev,
1181
1166
  isFetching: loaderIsRunningAsync ? prev.isFetching : false,
1182
- invalid: false
1167
+ loaderPromise: loaderIsRunningAsync ? prev.loaderPromise : void 0,
1168
+ invalid: false,
1169
+ pendingTimeout: void 0,
1170
+ _dehydrated: void 0
1183
1171
  };
1184
1172
  });
1185
1173
  return this.getMatch(matchId);
@@ -1206,27 +1194,23 @@ class RouterCore {
1206
1194
  };
1207
1195
  this.invalidate = (opts) => {
1208
1196
  const invalidate = (d) => {
1209
- var _a;
1210
- if (((_a = opts == null ? void 0 : opts.filter) == null ? void 0 : _a.call(opts, d)) ?? true) {
1197
+ if (opts?.filter?.(d) ?? true) {
1211
1198
  return {
1212
1199
  ...d,
1213
1200
  invalid: true,
1214
- ...(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 } : {}
1215
1202
  };
1216
1203
  }
1217
1204
  return d;
1218
1205
  };
1219
- this.__store.setState((s) => {
1220
- var _a;
1221
- return {
1222
- ...s,
1223
- matches: s.matches.map(invalidate),
1224
- cachedMatches: s.cachedMatches.map(invalidate),
1225
- pendingMatches: (_a = s.pendingMatches) == null ? void 0 : _a.map(invalidate)
1226
- };
1227
- });
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
+ }));
1228
1212
  this.shouldViewTransition = false;
1229
- return this.load({ sync: opts == null ? void 0 : opts.sync });
1213
+ return this.load({ sync: opts?.sync });
1230
1214
  };
1231
1215
  this.resolveRedirect = (redirect2) => {
1232
1216
  if (!redirect2.options.href) {
@@ -1239,7 +1223,7 @@ class RouterCore {
1239
1223
  return redirect2;
1240
1224
  };
1241
1225
  this.clearCache = (opts) => {
1242
- const filter = opts == null ? void 0 : opts.filter;
1226
+ const filter = opts?.filter;
1243
1227
  if (filter !== void 0) {
1244
1228
  this.__store.setState((s) => {
1245
1229
  return {
@@ -1288,7 +1272,7 @@ class RouterCore {
1288
1272
  () => Promise.all(
1289
1273
  componentTypes.map(async (type) => {
1290
1274
  const component = route.options[type];
1291
- if (component == null ? void 0 : component.preload) {
1275
+ if (component?.preload) {
1292
1276
  await component.preload();
1293
1277
  }
1294
1278
  })
@@ -1364,10 +1348,10 @@ class RouterCore {
1364
1348
  leaveParams: true
1365
1349
  };
1366
1350
  const next = this.buildLocation(matchLocation);
1367
- if ((opts == null ? void 0 : opts.pending) && this.state.status !== "pending") {
1351
+ if (opts?.pending && this.state.status !== "pending") {
1368
1352
  return false;
1369
1353
  }
1370
- 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;
1371
1355
  const baseLocation = pending ? this.latestLocation : this.state.resolvedLocation || this.state.location;
1372
1356
  const match = path.matchPathname(
1373
1357
  this.basepath,
@@ -1386,7 +1370,7 @@ class RouterCore {
1386
1370
  return false;
1387
1371
  }
1388
1372
  }
1389
- if (match && ((opts == null ? void 0 : opts.includeSearch) ?? true)) {
1373
+ if (match && (opts?.includeSearch ?? true)) {
1390
1374
  return utils.deepEqual(baseLocation.search, next.search, { partial: true }) ? match : false;
1391
1375
  }
1392
1376
  return match;
@@ -1394,13 +1378,12 @@ class RouterCore {
1394
1378
  this._handleNotFound = (matches, err, {
1395
1379
  updateMatch = this.updateMatch
1396
1380
  } = {}) => {
1397
- var _a;
1398
1381
  const routeCursor = this.routesById[err.routeId ?? ""] ?? this.routeTree;
1399
1382
  const matchesByRouteId = {};
1400
1383
  for (const match of matches) {
1401
1384
  matchesByRouteId[match.routeId] = match;
1402
1385
  }
1403
- if (!routeCursor.options.notFoundComponent && ((_a = this.options) == null ? void 0 : _a.defaultNotFoundComponent)) {
1386
+ if (!routeCursor.options.notFoundComponent && this.options?.defaultNotFoundComponent) {
1404
1387
  routeCursor.options.notFoundComponent = this.options.defaultNotFoundComponent;
1405
1388
  }
1406
1389
  invariant(
@@ -1458,10 +1441,9 @@ class RouterCore {
1458
1441
  return this.routesById;
1459
1442
  }
1460
1443
  matchRoutesInternal(next, opts) {
1461
- var _a;
1462
1444
  const { foundRoute, matchedRoutes, routeParams } = this.getMatchedRoutes(
1463
1445
  next.pathname,
1464
- (_a = opts == null ? void 0 : opts.dest) == null ? void 0 : _a.to
1446
+ opts?.dest?.to
1465
1447
  );
1466
1448
  let isGlobalNotFound = false;
1467
1449
  if (
@@ -1492,9 +1474,8 @@ class RouterCore {
1492
1474
  return root.rootRouteId;
1493
1475
  })();
1494
1476
  const parseErrors = matchedRoutes.map((route) => {
1495
- var _a2;
1496
1477
  let parsedParamsError;
1497
- const parseParams = ((_a2 = route.options.params) == null ? void 0 : _a2.parse) ?? route.options.parseParams;
1478
+ const parseParams = route.options.params?.parse ?? route.options.parseParams;
1498
1479
  if (parseParams) {
1499
1480
  try {
1500
1481
  const parsedParams = parseParams(routeParams);
@@ -1503,7 +1484,7 @@ class RouterCore {
1503
1484
  parsedParamsError = new PathParamError(err.message, {
1504
1485
  cause: err
1505
1486
  });
1506
- if (opts == null ? void 0 : opts.throwOnError) {
1487
+ if (opts?.throwOnError) {
1507
1488
  throw parsedParamsError;
1508
1489
  }
1509
1490
  return parsedParamsError;
@@ -1513,18 +1494,17 @@ class RouterCore {
1513
1494
  });
1514
1495
  const matches = [];
1515
1496
  const getParentContext = (parentMatch) => {
1516
- const parentMatchId = parentMatch == null ? void 0 : parentMatch.id;
1517
- 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 ?? {};
1518
1499
  return parentContext;
1519
1500
  };
1520
1501
  matchedRoutes.forEach((route, index) => {
1521
- var _a2, _b;
1522
1502
  const parentMatch = matches[index - 1];
1523
1503
  const [preMatchSearch, strictMatchSearch, searchError] = (() => {
1524
- const parentSearch = (parentMatch == null ? void 0 : parentMatch.search) ?? next.search;
1525
- const parentStrictSearch = (parentMatch == null ? void 0 : parentMatch._strictSearch) ?? void 0;
1504
+ const parentSearch = parentMatch?.search ?? next.search;
1505
+ const parentStrictSearch = parentMatch?._strictSearch ?? {};
1526
1506
  try {
1527
- const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
1507
+ const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? {};
1528
1508
  return [
1529
1509
  {
1530
1510
  ...parentSearch,
@@ -1540,15 +1520,15 @@ class RouterCore {
1540
1520
  cause: err
1541
1521
  });
1542
1522
  }
1543
- if (opts == null ? void 0 : opts.throwOnError) {
1523
+ if (opts?.throwOnError) {
1544
1524
  throw searchParamError;
1545
1525
  }
1546
1526
  return [parentSearch, {}, searchParamError];
1547
1527
  }
1548
1528
  })();
1549
- const loaderDeps = ((_b = (_a2 = route.options).loaderDeps) == null ? void 0 : _b.call(_a2, {
1529
+ const loaderDeps = route.options.loaderDeps?.({
1550
1530
  search: preMatchSearch
1551
- })) ?? "";
1531
+ }) ?? "";
1552
1532
  const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : "";
1553
1533
  const { usedParams, interpolatedPath } = path.interpolatePath({
1554
1534
  path: route.fullPath,
@@ -1594,10 +1574,7 @@ class RouterCore {
1594
1574
  isFetching: false,
1595
1575
  error: void 0,
1596
1576
  paramsError: parseErrors[index],
1597
- __routeContext: void 0,
1598
- _nonReactive: {
1599
- loadPromise: utils.createControlledPromise()
1600
- },
1577
+ __routeContext: {},
1601
1578
  __beforeLoadContext: void 0,
1602
1579
  context: {},
1603
1580
  abortController: new AbortController(),
@@ -1611,10 +1588,11 @@ class RouterCore {
1611
1588
  headScripts: void 0,
1612
1589
  meta: void 0,
1613
1590
  staticData: route.options.staticData || {},
1591
+ loadPromise: utils.createControlledPromise(),
1614
1592
  fullPath: route.fullPath
1615
1593
  };
1616
1594
  }
1617
- if (!(opts == null ? void 0 : opts.preload)) {
1595
+ if (!opts?.preload) {
1618
1596
  match.globalNotFound = globalNotFoundRouteId === route.id;
1619
1597
  }
1620
1598
  match.searchError = searchError;
@@ -1629,24 +1607,22 @@ class RouterCore {
1629
1607
  matches.forEach((match, index) => {
1630
1608
  const route = this.looseRoutesById[match.routeId];
1631
1609
  const existingMatch = this.getMatch(match.id);
1632
- if (!existingMatch && (opts == null ? void 0 : opts._buildLocation) !== true) {
1610
+ if (!existingMatch && opts?._buildLocation !== true) {
1633
1611
  const parentMatch = matches[index - 1];
1634
1612
  const parentContext = getParentContext(parentMatch);
1635
- if (route.options.context) {
1636
- const contextFnContext = {
1637
- deps: match.loaderDeps,
1638
- params: match.params,
1639
- context: parentContext ?? {},
1640
- location: next,
1641
- navigate: (opts2) => this.navigate({ ...opts2, _fromLocation: next }),
1642
- buildLocation: this.buildLocation,
1643
- cause: match.cause,
1644
- abortController: match.abortController,
1645
- preload: !!match.preload,
1646
- matches
1647
- };
1648
- match.__routeContext = route.options.context(contextFnContext) ?? void 0;
1649
- }
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) ?? {};
1650
1626
  match.context = {
1651
1627
  ...parentContext,
1652
1628
  ...match.__routeContext,
@@ -1712,9 +1688,8 @@ const componentTypes = [
1712
1688
  "notFoundComponent"
1713
1689
  ];
1714
1690
  function routeNeedsPreload(route) {
1715
- var _a;
1716
1691
  for (const componentType of componentTypes) {
1717
- if ((_a = route.options[componentType]) == null ? void 0 : _a.preload) {
1692
+ if (route.options[componentType]?.preload) {
1718
1693
  return true;
1719
1694
  }
1720
1695
  }
@@ -1748,7 +1723,7 @@ function processRouteTree({
1748
1723
  const routesByPath = {};
1749
1724
  const recurseRoutes = (childRoutes) => {
1750
1725
  childRoutes.forEach((childRoute, i) => {
1751
- initRoute == null ? void 0 : initRoute(childRoute, i);
1726
+ initRoute?.(childRoute, i);
1752
1727
  const existingRoute = routesById[childRoute.id];
1753
1728
  invariant(
1754
1729
  !existingRoute,
@@ -1762,7 +1737,7 @@ function processRouteTree({
1762
1737
  }
1763
1738
  }
1764
1739
  const children = childRoute.children;
1765
- if (children == null ? void 0 : children.length) {
1740
+ if (children?.length) {
1766
1741
  recurseRoutes(children);
1767
1742
  }
1768
1743
  });
@@ -1771,14 +1746,13 @@ function processRouteTree({
1771
1746
  const scoredRoutes = [];
1772
1747
  const routes = Object.values(routesById);
1773
1748
  routes.forEach((d, i) => {
1774
- var _a;
1775
1749
  if (d.isRoot || !d.path) {
1776
1750
  return;
1777
1751
  }
1778
1752
  const trimmed = path.trimPathLeft(d.fullPath);
1779
1753
  let parsed = path.parsePathname(trimmed);
1780
1754
  let skip = 0;
1781
- while (parsed.length > skip + 1 && ((_a = parsed[skip]) == null ? void 0 : _a.value) === "/") {
1755
+ while (parsed.length > skip + 1 && parsed[skip]?.value === "/") {
1782
1756
  skip++;
1783
1757
  }
1784
1758
  if (skip > 0) parsed = parsed.slice(skip);
@@ -1863,13 +1837,12 @@ function getMatchedRoutes({
1863
1837
  let routeParams = {};
1864
1838
  const trimmedPath = path.trimPathRight(pathname);
1865
1839
  const getMatchedParams = (route) => {
1866
- var _a;
1867
1840
  const result = path.matchPathname(
1868
1841
  basepath,
1869
1842
  trimmedPath,
1870
1843
  {
1871
1844
  to: route.fullPath,
1872
- caseSensitive: ((_a = route.options) == null ? void 0 : _a.caseSensitive) ?? caseSensitive,
1845
+ caseSensitive: route.options?.caseSensitive ?? caseSensitive,
1873
1846
  // we need fuzzy matching for `notFoundMode: 'fuzzy'`
1874
1847
  fuzzy: true
1875
1848
  },
@@ -1918,10 +1891,9 @@ function applySearchMiddleware({
1918
1891
  }) {
1919
1892
  const allMiddlewares = destRoutes.reduce(
1920
1893
  (acc, route) => {
1921
- var _a;
1922
1894
  const middlewares = [];
1923
1895
  if ("search" in route.options) {
1924
- if ((_a = route.options.search) == null ? void 0 : _a.middlewares) {
1896
+ if (route.options.search?.middlewares) {
1925
1897
  middlewares.push(...route.options.search.middlewares);
1926
1898
  }
1927
1899
  } else if (route.options.preSearchFilters || route.options.postSearchFilters) {
@@ -1953,7 +1925,7 @@ function applySearchMiddleware({
1953
1925
  try {
1954
1926
  const validatedSearch = {
1955
1927
  ...result,
1956
- ...validateSearch(route.options.validateSearch, result) ?? void 0
1928
+ ...validateSearch(route.options.validateSearch, result) ?? {}
1957
1929
  };
1958
1930
  return validatedSearch;
1959
1931
  } catch {