@tanstack/router-core 1.136.11 → 1.136.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.
@@ -634,6 +634,14 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
634
634
  startViewTransition: (fn: () => Promise<void>) => void;
635
635
  updateMatch: UpdateMatchFn;
636
636
  getMatch: GetMatchFn;
637
+ /**
638
+ * Invalidate the current matches and optionally force them back into a pending state.
639
+ *
640
+ * - Marks all matches that pass the optional `filter` as `invalid: true`.
641
+ * - If `forcePending` is true, or a match is currently in `'error'` or `'notFound'` status,
642
+ * its status is reset to `'pending'` and its `error` cleared so that the loader is re-run
643
+ * on the next `load()` call (eg. after HMR or a manual invalidation).
644
+ */
637
645
  invalidate: InvalidateFn<RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>>;
638
646
  resolveRedirect: (redirect: AnyRedirect) => AnyRedirect;
639
647
  clearCache: ClearCacheFn<this>;
@@ -652,9 +652,17 @@ class RouterCore {
652
652
  loadedAt: Date.now(),
653
653
  matches: newMatches,
654
654
  pendingMatches: void 0,
655
+ /**
656
+ * When committing new matches, cache any exiting matches that are still usable.
657
+ * Routes that resolved with `status: 'error'` or `status: 'notFound'` are
658
+ * deliberately excluded from `cachedMatches` so that subsequent invalidations
659
+ * or reloads re-run their loaders instead of reusing the failed/not-found data.
660
+ */
655
661
  cachedMatches: [
656
662
  ...s.cachedMatches,
657
- ...exitingMatches.filter((d) => d.status !== "error")
663
+ ...exitingMatches.filter(
664
+ (d) => d.status !== "error" && d.status !== "notFound"
665
+ )
658
666
  ]
659
667
  };
660
668
  });
@@ -773,7 +781,7 @@ class RouterCore {
773
781
  return {
774
782
  ...d,
775
783
  invalid: true,
776
- ...opts?.forcePending || d.status === "error" ? { status: "pending", error: void 0 } : void 0
784
+ ...opts?.forcePending || d.status === "error" || d.status === "notFound" ? { status: "pending", error: void 0 } : void 0
777
785
  };
778
786
  }
779
787
  return d;
@@ -1058,9 +1066,13 @@ class RouterCore {
1058
1066
  strictParseParams(strictParams)
1059
1067
  );
1060
1068
  } catch (err) {
1061
- paramsError = new PathParamError(err.message, {
1062
- cause: err
1063
- });
1069
+ if (isNotFound(err) || isRedirect(err)) {
1070
+ paramsError = err;
1071
+ } else {
1072
+ paramsError = new PathParamError(err.message, {
1073
+ cause: err
1074
+ });
1075
+ }
1064
1076
  if (opts?.throwOnError) {
1065
1077
  throw paramsError;
1066
1078
  }