@tanstack/router-core 1.130.5 → 1.130.7

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.
@@ -430,7 +430,7 @@ export interface MatchRoutesFn {
430
430
  (pathnameOrNext: string | ParsedLocation, locationSearchOrOpts?: AnySchema | MatchRoutesOpts, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
431
431
  }
432
432
  export type GetMatchFn = (matchId: string) => AnyRouteMatch | undefined;
433
- export type UpdateMatchFn = (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => AnyRouteMatch;
433
+ export type UpdateMatchFn = (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => void;
434
434
  export type LoadRouteChunkFn = (route: AnyRoute) => Promise<Array<void>>;
435
435
  export type ResolveRedirect = (err: AnyRedirect) => ResolvedRedirect;
436
436
  export type ClearCacheFn<TRouter extends AnyRouter> = (opts?: {
@@ -430,7 +430,7 @@ export interface MatchRoutesFn {
430
430
  (pathnameOrNext: string | ParsedLocation, locationSearchOrOpts?: AnySchema | MatchRoutesOpts, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
431
431
  }
432
432
  export type GetMatchFn = (matchId: string) => AnyRouteMatch | undefined;
433
- export type UpdateMatchFn = (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => AnyRouteMatch;
433
+ export type UpdateMatchFn = (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => void;
434
434
  export type LoadRouteChunkFn = (route: AnyRoute) => Promise<Array<void>>;
435
435
  export type ResolveRedirect = (err: AnyRedirect) => ResolvedRedirect;
436
436
  export type ClearCacheFn<TRouter extends AnyRouter> = (opts?: {
@@ -541,7 +541,7 @@ class RouterCore {
541
541
  pendingMatches,
542
542
  // If a cached moved to pendingMatches, remove it from cachedMatches
543
543
  cachedMatches: s.cachedMatches.filter(
544
- (d) => !pendingMatches.find((e) => e.id === d.id)
544
+ (d) => !pendingMatches.some((e) => e.id === d.id)
545
545
  )
546
546
  }));
547
547
  };
@@ -587,13 +587,13 @@ class RouterCore {
587
587
  const previousMatches = s.matches;
588
588
  const newMatches = s.pendingMatches || s.matches;
589
589
  exitingMatches = previousMatches.filter(
590
- (match) => !newMatches.find((d) => d.id === match.id)
590
+ (match) => !newMatches.some((d) => d.id === match.id)
591
591
  );
592
592
  enteringMatches = newMatches.filter(
593
- (match) => !previousMatches.find((d) => d.id === match.id)
593
+ (match) => !previousMatches.some((d) => d.id === match.id)
594
594
  );
595
595
  stayingMatches = previousMatches.filter(
596
- (match) => newMatches.find((d) => d.id === match.id)
596
+ (match) => newMatches.some((d) => d.id === match.id)
597
597
  );
598
598
  return {
599
599
  ...s,
@@ -689,23 +689,16 @@ class RouterCore {
689
689
  };
690
690
  this.updateMatch = (id, updater) => {
691
691
  var _a;
692
- let updated;
693
- const isPending = (_a = this.state.pendingMatches) == null ? void 0 : _a.find((d) => d.id === id);
694
- const isMatched = this.state.matches.find((d) => d.id === id);
695
- const isCached = this.state.cachedMatches.find((d) => d.id === id);
696
- const matchesKey = isPending ? "pendingMatches" : isMatched ? "matches" : isCached ? "cachedMatches" : "";
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" : "";
697
693
  if (matchesKey) {
698
694
  this.__store.setState((s) => {
699
695
  var _a2;
700
696
  return {
701
697
  ...s,
702
- [matchesKey]: (_a2 = s[matchesKey]) == null ? void 0 : _a2.map(
703
- (d) => d.id === id ? updated = updater(d) : d
704
- )
698
+ [matchesKey]: (_a2 = s[matchesKey]) == null ? void 0 : _a2.map((d) => d.id === id ? updater(d) : d)
705
699
  };
706
700
  });
707
701
  }
708
- return updated;
709
702
  };
710
703
  this.getMatch = (matchId) => {
711
704
  var _a;
@@ -729,9 +722,9 @@ class RouterCore {
729
722
  }
730
723
  };
731
724
  const resolvePreload = (matchId) => {
732
- return !!(allPreload && !this.state.matches.find((d) => d.id === matchId));
725
+ return !!(allPreload && !this.state.matches.some((d) => d.id === matchId));
733
726
  };
734
- if (!this.isServer && this.state.matches.find((d) => d._forcePending)) {
727
+ if (!this.isServer && this.state.matches.some((d) => d._forcePending)) {
735
728
  triggerOnReady();
736
729
  }
737
730
  const handleRedirectAndNotFound = (match, err) => {
@@ -1081,7 +1074,7 @@ class RouterCore {
1081
1074
  updateMatch(matchId, (prev) => ({
1082
1075
  ...prev,
1083
1076
  loaderPromise: createControlledPromise(),
1084
- preload: !!preload && !this.state.matches.find((d) => d.id === matchId)
1077
+ preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
1085
1078
  }));
1086
1079
  const runLoader = async () => {
1087
1080
  var _a2, _b2, _c2, _d2;