@tanstack/router-core 1.171.13 → 1.171.14

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.
@@ -70,6 +70,7 @@ var RouterCore = class {
70
70
  this.isViewTransitionTypesSupported = void 0;
71
71
  this.subscribers = /* @__PURE__ */ new Set();
72
72
  this.routeBranchCache = /* @__PURE__ */ new WeakMap();
73
+ this.lightweightCache = /* @__PURE__ */ new WeakMap();
73
74
  this.startTransition = (fn) => fn();
74
75
  this.update = (newOptions) => {
75
76
  if (process.env.NODE_ENV !== "production") {
@@ -451,7 +452,7 @@ var RouterCore = class {
451
452
  hashScrollIntoView,
452
453
  ignoreBlocker
453
454
  });
454
- Promise.resolve().then(() => {
455
+ queueMicrotask(() => {
455
456
  if (this.pendingBuiltLocation === location) this.pendingBuiltLocation = void 0;
456
457
  });
457
458
  return commitPromise;
@@ -475,7 +476,7 @@ var RouterCore = class {
475
476
  const reloadHref = !hrefIsUrl && publicHref ? publicHref : href;
476
477
  if (require_utils.isDangerousProtocol(reloadHref, this.protocolAllowlist)) {
477
478
  if (process.env.NODE_ENV !== "production") console.warn(`Blocked navigation to dangerous protocol: ${reloadHref}`);
478
- return Promise.resolve();
479
+ return;
479
480
  }
480
481
  if (!rest.ignoreBlocker) {
481
482
  const blockers = this.history.getBlockers?.() ?? [];
@@ -484,12 +485,12 @@ var RouterCore = class {
484
485
  currentLocation: this.latestLocation,
485
486
  nextLocation: this.latestLocation,
486
487
  action: "PUSH"
487
- })) return Promise.resolve();
488
+ })) return;
488
489
  }
489
490
  }
490
491
  if (rest.replace) window.location.replace(reloadHref);
491
492
  else window.location.href = reloadHref;
492
- return Promise.resolve();
493
+ return;
493
494
  }
494
495
  return this.buildAndCommitLocation({
495
496
  ...rest,
@@ -1007,13 +1008,15 @@ var RouterCore = class {
1007
1008
  * operations like AbortController, ControlledPromise, loaderDeps, and full match objects.
1008
1009
  */
1009
1010
  matchRoutesLightweight(location) {
1011
+ const lastStateMatchId = require_utils.last(this.stores.matchesId.get());
1012
+ const cached = this.lightweightCache.get(location);
1013
+ if (cached && cached[0] === lastStateMatchId) return cached[1];
1010
1014
  const { matchedRoutes, routeParams } = this.getMatchedRoutes(location.pathname);
1011
1015
  const lastRoute = require_utils.last(matchedRoutes);
1012
1016
  const accumulatedSearch = { ...location.search };
1013
1017
  for (const route of matchedRoutes) try {
1014
1018
  Object.assign(accumulatedSearch, validateSearch(route.options.validateSearch, accumulatedSearch));
1015
1019
  } catch {}
1016
- const lastStateMatchId = require_utils.last(this.stores.matchesId.get());
1017
1020
  const lastStateMatch = lastStateMatchId && this.stores.matchStores.get(lastStateMatchId)?.get();
1018
1021
  const canReuseParams = lastStateMatch && lastStateMatch.routeId === lastRoute.id && lastStateMatch.pathname === location.pathname;
1019
1022
  let params;
@@ -1025,12 +1028,14 @@ var RouterCore = class {
1025
1028
  } catch {}
1026
1029
  params = strictParams;
1027
1030
  }
1028
- return {
1031
+ const result = {
1029
1032
  matchedRoutes,
1030
1033
  fullPath: lastRoute.fullPath,
1031
1034
  search: accumulatedSearch,
1032
1035
  params
1033
1036
  };
1037
+ this.lightweightCache.set(location, [lastStateMatchId, result]);
1038
+ return result;
1034
1039
  }
1035
1040
  };
1036
1041
  /** Error thrown when search parameter validation fails. */