@tanstack/router-core 1.127.2 → 1.127.8

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.
@@ -23,7 +23,7 @@ export { defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifyS
23
23
  export type { SearchSerializer, SearchParser } from './searchParams.cjs';
24
24
  export type { OptionalStructuralSharing } from './structuralSharing.cjs';
25
25
  export { last, functionalUpdate, pick, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, escapeJSON, shallow, createControlledPromise, isModuleNotFoundError, } from './utils.cjs';
26
- export type { NoInfer, IsAny, PickAsRequired, PickRequired, PickOptional, WithoutEmpty, Expand, DeepPartial, MakeDifferenceOptional, IsUnion, IsNonEmptyObject, Assign, IntersectAssign, Timeout, Updater, NonNullableUpdater, StringLiteral, ThrowOrOptional, ThrowConstraint, ControlledPromise, ExtractObjects, PartialMergeAllObject, MergeAllPrimitive, ExtractPrimitives, PartialMergeAll, Constrain, ConstrainLiteral, UnionToIntersection, MergeAllObjects, MergeAll, ValidateJSON, StrictOrFrom, LooseReturnType, LooseAsyncReturnType, } from './utils.cjs';
26
+ export type { NoInfer, IsAny, PickAsRequired, PickRequired, PickOptional, WithoutEmpty, Expand, DeepPartial, MakeDifferenceOptional, IsUnion, IsNonEmptyObject, Assign, IntersectAssign, Timeout, Updater, NonNullableUpdater, StringLiteral, ThrowOrOptional, ThrowConstraint, ControlledPromise, ExtractObjects, PartialMergeAllObject, MergeAllPrimitive, ExtractPrimitives, PartialMergeAll, Constrain, ConstrainLiteral, UnionToIntersection, MergeAllObjects, MergeAll, ValidateJSON, StrictOrFrom, LooseReturnType, LooseAsyncReturnType, Awaitable, } from './utils.cjs';
27
27
  export type { StandardSchemaValidatorProps, StandardSchemaValidator, AnyStandardSchemaValidator, StandardSchemaValidatorTypes, AnyStandardSchemaValidateSuccess, AnyStandardSchemaValidateFailure, AnyStandardSchemaValidateIssue, AnyStandardSchemaValidateInput, AnyStandardSchemaValidate, ValidatorObj, AnyValidatorObj, ValidatorAdapter, AnyValidatorAdapter, AnyValidatorFn, ValidatorFn, Validator, AnyValidator, AnySchema, DefaultValidator, ResolveSearchValidatorInputFn, ResolveSearchValidatorInput, ResolveValidatorInputFn, ResolveValidatorInput, ResolveValidatorOutputFn, ResolveValidatorOutput, } from './validators.cjs';
28
28
  export type { UseRouteContextBaseOptions, UseRouteContextOptions, UseRouteContextResult, } from './useRouteContext.cjs';
29
29
  export type { UseSearchResult, ResolveUseSearch } from './useSearch.cjs';
@@ -48,7 +48,6 @@ class RouterCore {
48
48
  this.isScrollRestoring = false;
49
49
  this.isScrollRestorationSetup = false;
50
50
  this.startTransition = (fn) => fn();
51
- this.isShell = false;
52
51
  this.update = (newOptions) => {
53
52
  var _a;
54
53
  if (newOptions.notFoundRoute) {
@@ -103,9 +102,6 @@ class RouterCore {
103
102
  "selector(:active-view-transition-type(a)"
104
103
  );
105
104
  }
106
- if (this.latestLocation.search.__TSS_SHELL) {
107
- this.isShell = true;
108
- }
109
105
  };
110
106
  this.buildRouteTree = () => {
111
107
  const { routesById, routesByPath, flatRoutes } = processRouteTree({
@@ -513,10 +509,7 @@ class RouterCore {
513
509
  throw redirect.redirect({ href: nextLocation.href });
514
510
  }
515
511
  }
516
- let pendingMatches = this.matchRoutes(this.latestLocation);
517
- if (this.isShell) {
518
- pendingMatches = pendingMatches.slice(0, 1);
519
- }
512
+ const pendingMatches = this.matchRoutes(this.latestLocation);
520
513
  this.__store.setState((s) => ({
521
514
  ...s,
522
515
  status: "pending",
@@ -711,32 +704,6 @@ class RouterCore {
711
704
  const triggerOnReady = async () => {
712
705
  if (!rendered) {
713
706
  rendered = true;
714
- if (!allPreload && !this.isServer) {
715
- matches.forEach((match) => {
716
- const {
717
- id: matchId,
718
- routeId,
719
- _forcePending,
720
- minPendingPromise
721
- } = match;
722
- const route = this.looseRoutesById[routeId];
723
- const pendingMinMs = route.options.pendingMinMs ?? this.options.defaultPendingMinMs;
724
- if (_forcePending && pendingMinMs && !minPendingPromise) {
725
- const minPendingPromise2 = utils.createControlledPromise();
726
- updateMatch(matchId, (prev) => ({
727
- ...prev,
728
- minPendingPromise: minPendingPromise2
729
- }));
730
- setTimeout(() => {
731
- minPendingPromise2.resolve();
732
- updateMatch(matchId, (prev) => ({
733
- ...prev,
734
- minPendingPromise: void 0
735
- }));
736
- }, pendingMinMs);
737
- }
738
- });
739
- }
740
707
  await (onReady == null ? void 0 : onReady());
741
708
  }
742
709
  };
@@ -840,46 +807,50 @@ class RouterCore {
840
807
  const route = this.looseRoutesById[routeId];
841
808
  const pendingMs = route.options.pendingMs ?? this.options.defaultPendingMs;
842
809
  if (this.isServer) {
843
- const defaultSsr = this.options.defaultSsr ?? true;
844
810
  let ssr;
845
- if ((parentMatch == null ? void 0 : parentMatch.ssr) === false) {
846
- ssr = false;
811
+ if (this.isShell()) {
812
+ ssr = matchId === root.rootRouteId;
847
813
  } else {
848
- let tempSsr;
849
- if (route.options.ssr === void 0) {
850
- tempSsr = defaultSsr;
851
- } else if (typeof route.options.ssr === "function") {
852
- let makeMaybe = function(value, error) {
853
- if (error) {
854
- return { status: "error", error };
855
- }
856
- return { status: "success", value };
857
- };
858
- const { search, params } = this.getMatch(matchId);
859
- const ssrFnContext = {
860
- search: makeMaybe(search, existingMatch.searchError),
861
- params: makeMaybe(params, existingMatch.paramsError),
862
- location,
863
- matches: matches.map((match) => ({
864
- index: match.index,
865
- pathname: match.pathname,
866
- fullPath: match.fullPath,
867
- staticData: match.staticData,
868
- id: match.id,
869
- routeId: match.routeId,
870
- search: makeMaybe(match.search, match.searchError),
871
- params: makeMaybe(match.params, match.paramsError),
872
- ssr: match.ssr
873
- }))
874
- };
875
- tempSsr = await route.options.ssr(ssrFnContext) ?? defaultSsr;
876
- } else {
877
- tempSsr = route.options.ssr;
878
- }
879
- if (tempSsr === true && (parentMatch == null ? void 0 : parentMatch.ssr) === "data-only") {
880
- ssr = "data-only";
814
+ const defaultSsr = this.options.defaultSsr ?? true;
815
+ if ((parentMatch == null ? void 0 : parentMatch.ssr) === false) {
816
+ ssr = false;
881
817
  } else {
882
- ssr = tempSsr;
818
+ let tempSsr;
819
+ if (route.options.ssr === void 0) {
820
+ tempSsr = defaultSsr;
821
+ } else if (typeof route.options.ssr === "function") {
822
+ let makeMaybe = function(value, error) {
823
+ if (error) {
824
+ return { status: "error", error };
825
+ }
826
+ return { status: "success", value };
827
+ };
828
+ const { search, params } = this.getMatch(matchId);
829
+ const ssrFnContext = {
830
+ search: makeMaybe(search, existingMatch.searchError),
831
+ params: makeMaybe(params, existingMatch.paramsError),
832
+ location,
833
+ matches: matches.map((match) => ({
834
+ index: match.index,
835
+ pathname: match.pathname,
836
+ fullPath: match.fullPath,
837
+ staticData: match.staticData,
838
+ id: match.id,
839
+ routeId: match.routeId,
840
+ search: makeMaybe(match.search, match.searchError),
841
+ params: makeMaybe(match.params, match.paramsError),
842
+ ssr: match.ssr
843
+ }))
844
+ };
845
+ tempSsr = await route.options.ssr(ssrFnContext) ?? defaultSsr;
846
+ } else {
847
+ tempSsr = route.options.ssr;
848
+ }
849
+ if (tempSsr === true && (parentMatch == null ? void 0 : parentMatch.ssr) === "data-only") {
850
+ ssr = "data-only";
851
+ } else {
852
+ ssr = tempSsr;
853
+ }
883
854
  }
884
855
  }
885
856
  updateMatch(matchId, (prev) => ({
@@ -1047,8 +1018,6 @@ class RouterCore {
1047
1018
  ...head
1048
1019
  }));
1049
1020
  return this.getMatch(matchId);
1050
- } else {
1051
- await potentialPendingMinPromise();
1052
1021
  }
1053
1022
  } else if (prevMatch.loaderPromise) {
1054
1023
  if (prevMatch.status === "success" && !sync && !prevMatch.preload) {
@@ -1157,10 +1126,10 @@ class RouterCore {
1157
1126
  handleRedirectAndNotFound(this.getMatch(matchId), err);
1158
1127
  }
1159
1128
  };
1160
- const { status, invalid, _forcePending } = this.getMatch(matchId);
1129
+ const { status, invalid } = this.getMatch(matchId);
1161
1130
  loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? age > staleAge));
1162
1131
  if (preload && route.options.preload === false) {
1163
- } else if (loaderShouldRunAsync && !sync && !_forcePending) {
1132
+ } else if (loaderShouldRunAsync && !sync) {
1164
1133
  loaderIsRunningAsync = true;
1165
1134
  (async () => {
1166
1135
  try {
@@ -1181,9 +1150,6 @@ class RouterCore {
1181
1150
  } else if (status !== "success" || loaderShouldRunAsync && sync) {
1182
1151
  await runLoader();
1183
1152
  } else {
1184
- if (_forcePending) {
1185
- await potentialPendingMinPromise();
1186
- }
1187
1153
  const head = await executeHead();
1188
1154
  updateMatch(matchId, (prev) => ({
1189
1155
  ...prev,
@@ -1204,8 +1170,7 @@ class RouterCore {
1204
1170
  loaderPromise: loaderIsRunningAsync ? prev.loaderPromise : void 0,
1205
1171
  invalid: false,
1206
1172
  pendingTimeout: void 0,
1207
- _dehydrated: void 0,
1208
- _forcePending: void 0
1173
+ _dehydrated: void 0
1209
1174
  };
1210
1175
  });
1211
1176
  return this.getMatch(matchId);
@@ -1463,6 +1428,9 @@ class RouterCore {
1463
1428
  self.__TSR_ROUTER__ = this;
1464
1429
  }
1465
1430
  }
1431
+ isShell() {
1432
+ return this.options.isShell;
1433
+ }
1466
1434
  get state() {
1467
1435
  return this.__store.state;
1468
1436
  }