@tanstack/router-core 1.131.2 → 1.131.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Matches.cjs","sources":["../../src/Matches.ts"],"sourcesContent":["import type { AnyRoute, StaticDataRouteOption } from './route'\nimport type {\n AllContext,\n AllLoaderData,\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteIds,\n} from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { Constrain, ControlledPromise } from './utils'\n\nexport type AnyMatchAndValue = { match: any; value: any }\n\nexport type FindValueByIndex<\n TKey,\n TValue extends ReadonlyArray<any>,\n> = TKey extends `${infer TIndex extends number}` ? TValue[TIndex] : never\n\nexport type FindValueByKey<TKey, TValue> =\n TValue extends ReadonlyArray<any>\n ? FindValueByIndex<TKey, TValue>\n : TValue[TKey & keyof TValue]\n\nexport type CreateMatchAndValue<TMatch, TValue> = TValue extends any\n ? {\n match: TMatch\n value: TValue\n }\n : never\n\nexport type NextMatchAndValue<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? CreateMatchAndValue<\n TMatchAndValue['match'],\n FindValueByKey<TKey, TMatchAndValue['value']>\n >\n : never\n\nexport type IsMatchKeyOf<TValue> =\n TValue extends ReadonlyArray<any>\n ? number extends TValue['length']\n ? `${number}`\n : keyof TValue & `${number}`\n : TValue extends object\n ? keyof TValue & string\n : never\n\nexport type IsMatchPath<\n TParentPath extends string,\n TMatchAndValue extends AnyMatchAndValue,\n> = `${TParentPath}${IsMatchKeyOf<TMatchAndValue['value']>}`\n\nexport type IsMatchResult<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? TKey extends keyof TMatchAndValue['value']\n ? TMatchAndValue['match']\n : never\n : never\n\nexport type IsMatchParse<\n TPath,\n TMatchAndValue extends AnyMatchAndValue,\n TParentPath extends string = '',\n> = TPath extends `${string}.${string}`\n ? TPath extends `${infer TFirst}.${infer TRest}`\n ? IsMatchParse<\n TRest,\n NextMatchAndValue<TFirst, TMatchAndValue>,\n `${TParentPath}${TFirst}.`\n >\n : never\n : {\n path: IsMatchPath<TParentPath, TMatchAndValue>\n result: IsMatchResult<TPath, TMatchAndValue>\n }\n\nexport type IsMatch<TMatch, TPath> = IsMatchParse<\n TPath,\n TMatch extends any ? { match: TMatch; value: TMatch } : never\n>\n\n/**\n * Narrows matches based on a path\n * @experimental\n */\nexport const isMatch = <TMatch, TPath extends string>(\n match: TMatch,\n path: Constrain<TPath, IsMatch<TMatch, TPath>['path']>,\n): match is IsMatch<TMatch, TPath>['result'] => {\n const parts = (path as string).split('.')\n let part\n let value: any = match\n\n while ((part = parts.shift()) != null && value != null) {\n value = value[part]\n }\n\n return value != null\n}\n\nexport interface DefaultRouteMatchExtensions {\n scripts?: unknown\n links?: unknown\n headScripts?: unknown\n meta?: unknown\n styles?: unknown\n}\n\nexport interface RouteMatchExtensions extends DefaultRouteMatchExtensions {}\n\nexport interface RouteMatch<\n out TRouteId,\n out TFullPath,\n out TAllParams,\n out TFullSearchSchema,\n out TLoaderData,\n out TAllContext,\n out TLoaderDeps,\n> extends RouteMatchExtensions {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n params: TAllParams\n _strictParams: TAllParams\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: false | 'beforeLoad' | 'loader'\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: ControlledPromise<void>\n beforeLoadPromise?: ControlledPromise<void>\n loaderPromise?: ControlledPromise<void>\n loaderData?: TLoaderData\n __routeContext: Record<string, unknown>\n __beforeLoadContext?: Record<string, unknown>\n context: TAllContext\n search: TFullSearchSchema\n _strictSearch: TFullSearchSchema\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: TLoaderDeps\n preload: boolean\n invalid: boolean\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n minPendingPromise?: ControlledPromise<void>\n pendingTimeout?: ReturnType<typeof setTimeout>\n ssr?: boolean | 'data-only'\n _dehydrated?: boolean\n _forcePending?: boolean\n displayPendingPromise?: Promise<void>\n _displayPending?: boolean\n}\n\nexport interface PreValidationErrorHandlingRouteMatch<\n TRouteId,\n TFullPath,\n TAllParams,\n TFullSearchSchema,\n> {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n search:\n | { status: 'success'; value: TFullSearchSchema }\n | { status: 'error'; error: unknown }\n params:\n | { status: 'success'; value: TAllParams }\n | { status: 'error'; error: unknown }\n staticData: StaticDataRouteOption\n ssr?: boolean | 'data-only'\n}\n\nexport type MakePreValidationErrorHandlingRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? PreValidationErrorHandlingRouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema']\n >\n : never\n\nexport type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<\n TRoute['types']['id'],\n TRoute['types']['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n>\n\nexport type MakeRouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n> = RouteMatch<\n TRouteId,\n RouteById<TRouteTree, TRouteId>['types']['fullPath'],\n TStrict extends false\n ? AllParams<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allParams'],\n TStrict extends false\n ? FullSearchSchema<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n TStrict extends false\n ? AllLoaderData<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['loaderData'],\n TStrict extends false\n ? AllContext<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allContext'],\n RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n>\n\nexport type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>\n\nexport type MakeRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? RouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n >\n : never\n\n/**\n * The `MatchRouteOptions` type is used to describe the options that can be used when matching a route.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#matchrouteoptions-type)\n */\nexport interface MatchRouteOptions {\n /**\n * If `true`, will match against pending location instead of the current location.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#pending-property)\n */\n pending?: boolean\n /**\n * If `true`, will match against the current location with case sensitivity.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)\n */\n caseSensitive?: boolean\n /**\n * If `true`, will match against the current location's search params using a deep inclusive check. e.g. `{ a: 1 }` will match for a current location of `{ a: 1, b: 2 }`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#includesearch-property)\n */\n includeSearch?: boolean\n /**\n * If `true`, will match against the current location using a fuzzy match. e.g. `/posts` will match for a current location of `/posts/123`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#fuzzy-property)\n */\n fuzzy?: boolean\n}\n"],"names":[],"mappings":";;AA2Fa,MAAA,UAAU,CACrB,OACA,SAC8C;AACxC,QAAA,QAAS,KAAgB,MAAM,GAAG;AACpC,MAAA;AACJ,MAAI,QAAa;AAEjB,UAAQ,OAAO,MAAM,MAAY,MAAA,QAAQ,SAAS,MAAM;AACtD,YAAQ,MAAM,IAAI;AAAA,EAAA;AAGpB,SAAO,SAAS;AAClB;;"}
1
+ {"version":3,"file":"Matches.cjs","sources":["../../src/Matches.ts"],"sourcesContent":["import type { AnyRoute, StaticDataRouteOption } from './route'\nimport type {\n AllContext,\n AllLoaderData,\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteIds,\n} from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { Constrain, ControlledPromise } from './utils'\n\nexport type AnyMatchAndValue = { match: any; value: any }\n\nexport type FindValueByIndex<\n TKey,\n TValue extends ReadonlyArray<any>,\n> = TKey extends `${infer TIndex extends number}` ? TValue[TIndex] : never\n\nexport type FindValueByKey<TKey, TValue> =\n TValue extends ReadonlyArray<any>\n ? FindValueByIndex<TKey, TValue>\n : TValue[TKey & keyof TValue]\n\nexport type CreateMatchAndValue<TMatch, TValue> = TValue extends any\n ? {\n match: TMatch\n value: TValue\n }\n : never\n\nexport type NextMatchAndValue<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? CreateMatchAndValue<\n TMatchAndValue['match'],\n FindValueByKey<TKey, TMatchAndValue['value']>\n >\n : never\n\nexport type IsMatchKeyOf<TValue> =\n TValue extends ReadonlyArray<any>\n ? number extends TValue['length']\n ? `${number}`\n : keyof TValue & `${number}`\n : TValue extends object\n ? keyof TValue & string\n : never\n\nexport type IsMatchPath<\n TParentPath extends string,\n TMatchAndValue extends AnyMatchAndValue,\n> = `${TParentPath}${IsMatchKeyOf<TMatchAndValue['value']>}`\n\nexport type IsMatchResult<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? TKey extends keyof TMatchAndValue['value']\n ? TMatchAndValue['match']\n : never\n : never\n\nexport type IsMatchParse<\n TPath,\n TMatchAndValue extends AnyMatchAndValue,\n TParentPath extends string = '',\n> = TPath extends `${string}.${string}`\n ? TPath extends `${infer TFirst}.${infer TRest}`\n ? IsMatchParse<\n TRest,\n NextMatchAndValue<TFirst, TMatchAndValue>,\n `${TParentPath}${TFirst}.`\n >\n : never\n : {\n path: IsMatchPath<TParentPath, TMatchAndValue>\n result: IsMatchResult<TPath, TMatchAndValue>\n }\n\nexport type IsMatch<TMatch, TPath> = IsMatchParse<\n TPath,\n TMatch extends any ? { match: TMatch; value: TMatch } : never\n>\n\n/**\n * Narrows matches based on a path\n * @experimental\n */\nexport const isMatch = <TMatch, TPath extends string>(\n match: TMatch,\n path: Constrain<TPath, IsMatch<TMatch, TPath>['path']>,\n): match is IsMatch<TMatch, TPath>['result'] => {\n const parts = (path as string).split('.')\n let part\n let value: any = match\n\n while ((part = parts.shift()) != null && value != null) {\n value = value[part]\n }\n\n return value != null\n}\n\nexport interface DefaultRouteMatchExtensions {\n scripts?: unknown\n links?: unknown\n headScripts?: unknown\n meta?: unknown\n styles?: unknown\n}\n\nexport interface RouteMatchExtensions extends DefaultRouteMatchExtensions {}\n\nexport interface RouteMatch<\n out TRouteId,\n out TFullPath,\n out TAllParams,\n out TFullSearchSchema,\n out TLoaderData,\n out TAllContext,\n out TLoaderDeps,\n> extends RouteMatchExtensions {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n params: TAllParams\n _strictParams: TAllParams\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: false | 'beforeLoad' | 'loader'\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n _nonReactive: {\n /** @internal */\n beforeLoadPromise?: ControlledPromise<void>\n /** @internal */\n loaderPromise?: ControlledPromise<void>\n /** @internal */\n pendingTimeout?: ReturnType<typeof setTimeout>\n loadPromise?: ControlledPromise<void>\n displayPendingPromise?: Promise<void>\n minPendingPromise?: ControlledPromise<void>\n dehydrated?: boolean\n }\n loaderData?: TLoaderData\n /** @internal */\n __routeContext: Record<string, unknown>\n /** @internal */\n __beforeLoadContext?: Record<string, unknown>\n context: TAllContext\n search: TFullSearchSchema\n _strictSearch: TFullSearchSchema\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: TLoaderDeps\n preload: boolean\n invalid: boolean\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n /** This attribute is not reactive */\n ssr?: boolean | 'data-only'\n _forcePending?: boolean\n _displayPending?: boolean\n}\n\nexport interface PreValidationErrorHandlingRouteMatch<\n TRouteId,\n TFullPath,\n TAllParams,\n TFullSearchSchema,\n> {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n search:\n | { status: 'success'; value: TFullSearchSchema }\n | { status: 'error'; error: unknown }\n params:\n | { status: 'success'; value: TAllParams }\n | { status: 'error'; error: unknown }\n staticData: StaticDataRouteOption\n ssr?: boolean | 'data-only'\n}\n\nexport type MakePreValidationErrorHandlingRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? PreValidationErrorHandlingRouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema']\n >\n : never\n\nexport type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<\n TRoute['types']['id'],\n TRoute['types']['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n>\n\nexport type MakeRouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n> = RouteMatch<\n TRouteId,\n RouteById<TRouteTree, TRouteId>['types']['fullPath'],\n TStrict extends false\n ? AllParams<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allParams'],\n TStrict extends false\n ? FullSearchSchema<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n TStrict extends false\n ? AllLoaderData<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['loaderData'],\n TStrict extends false\n ? AllContext<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allContext'],\n RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n>\n\nexport type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>\n\nexport type MakeRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? RouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n >\n : never\n\n/**\n * The `MatchRouteOptions` type is used to describe the options that can be used when matching a route.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#matchrouteoptions-type)\n */\nexport interface MatchRouteOptions {\n /**\n * If `true`, will match against pending location instead of the current location.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#pending-property)\n */\n pending?: boolean\n /**\n * If `true`, will match against the current location with case sensitivity.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)\n */\n caseSensitive?: boolean\n /**\n * If `true`, will match against the current location's search params using a deep inclusive check. e.g. `{ a: 1 }` will match for a current location of `{ a: 1, b: 2 }`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#includesearch-property)\n */\n includeSearch?: boolean\n /**\n * If `true`, will match against the current location using a fuzzy match. e.g. `/posts` will match for a current location of `/posts/123`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#fuzzy-property)\n */\n fuzzy?: boolean\n}\n"],"names":[],"mappings":";;AA2Fa,MAAA,UAAU,CACrB,OACA,SAC8C;AACxC,QAAA,QAAS,KAAgB,MAAM,GAAG;AACpC,MAAA;AACJ,MAAI,QAAa;AAEjB,UAAQ,OAAO,MAAM,MAAY,MAAA,QAAQ,SAAS,MAAM;AACtD,YAAQ,MAAM,IAAI;AAAA,EAAA;AAGpB,SAAO,SAAS;AAClB;;"}
@@ -52,12 +52,13 @@ export interface RouteMatch<out TRouteId, out TFullPath, out TAllParams, out TFu
52
52
  paramsError: unknown;
53
53
  searchError: unknown;
54
54
  updatedAt: number;
55
- loadPromise?: ControlledPromise<void>;
56
- beforeLoadPromise?: ControlledPromise<void>;
57
- loaderPromise?: ControlledPromise<void>;
55
+ _nonReactive: {
56
+ loadPromise?: ControlledPromise<void>;
57
+ displayPendingPromise?: Promise<void>;
58
+ minPendingPromise?: ControlledPromise<void>;
59
+ dehydrated?: boolean;
60
+ };
58
61
  loaderData?: TLoaderData;
59
- __routeContext: Record<string, unknown>;
60
- __beforeLoadContext?: Record<string, unknown>;
61
62
  context: TAllContext;
62
63
  search: TFullSearchSchema;
63
64
  _strictSearch: TFullSearchSchema;
@@ -70,12 +71,9 @@ export interface RouteMatch<out TRouteId, out TFullPath, out TAllParams, out TFu
70
71
  headers?: Record<string, string>;
71
72
  globalNotFound?: boolean;
72
73
  staticData: StaticDataRouteOption;
73
- minPendingPromise?: ControlledPromise<void>;
74
- pendingTimeout?: ReturnType<typeof setTimeout>;
74
+ /** This attribute is not reactive */
75
75
  ssr?: boolean | 'data-only';
76
- _dehydrated?: boolean;
77
76
  _forcePending?: boolean;
78
- displayPendingPromise?: Promise<void>;
79
77
  _displayPending?: boolean;
80
78
  }
81
79
  export interface PreValidationErrorHandlingRouteMatch<TRouteId, TFullPath, TAllParams, TFullSearchSchema> {
@@ -219,13 +219,8 @@ class RouterCore {
219
219
  const match = this.getMatch(id);
220
220
  if (!match) return;
221
221
  match.abortController.abort();
222
- this.updateMatch(id, (prev) => {
223
- clearTimeout(prev.pendingTimeout);
224
- return {
225
- ...prev,
226
- pendingTimeout: void 0
227
- };
228
- });
222
+ match._nonReactive.pendingTimeout = void 0;
223
+ clearTimeout(match._nonReactive.pendingTimeout);
229
224
  };
230
225
  this.cancelMatches = () => {
231
226
  var _a;
@@ -745,20 +740,20 @@ class RouterCore {
745
740
  }
746
741
  }
747
742
  }
748
- (_a = match.beforeLoadPromise) == null ? void 0 : _a.resolve();
749
- (_b = match.loaderPromise) == null ? void 0 : _b.resolve();
743
+ (_a = match._nonReactive.beforeLoadPromise) == null ? void 0 : _a.resolve();
744
+ (_b = match._nonReactive.loaderPromise) == null ? void 0 : _b.resolve();
745
+ match._nonReactive.beforeLoadPromise = void 0;
746
+ match._nonReactive.loaderPromise = void 0;
750
747
  updateMatch(match.id, (prev) => ({
751
748
  ...prev,
752
749
  status: redirect.isRedirect(err) ? "redirected" : notFound.isNotFound(err) ? "notFound" : "error",
753
750
  isFetching: false,
754
- error: err,
755
- beforeLoadPromise: void 0,
756
- loaderPromise: void 0
751
+ error: err
757
752
  }));
758
753
  if (!err.routeId) {
759
754
  err.routeId = match.routeId;
760
755
  }
761
- (_c = match.loadPromise) == null ? void 0 : _c.resolve();
756
+ (_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
762
757
  if (redirect.isRedirect(err)) {
763
758
  rendered = true;
764
759
  err.options._fromLocation = location;
@@ -775,7 +770,7 @@ class RouterCore {
775
770
  };
776
771
  const shouldSkipLoader = (matchId) => {
777
772
  const match = this.getMatch(matchId);
778
- if (!this.isServer && match._dehydrated) {
773
+ if (!this.isServer && match._nonReactive.dehydrated) {
779
774
  return true;
780
775
  }
781
776
  if (this.isServer) {
@@ -809,16 +804,16 @@ class RouterCore {
809
804
  }
810
805
  updateMatch(matchId, (prev) => {
811
806
  var _a3, _b3;
812
- (_a3 = prev.beforeLoadPromise) == null ? void 0 : _a3.resolve();
813
- (_b3 = prev.loadPromise) == null ? void 0 : _b3.resolve();
807
+ (_a3 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a3.resolve();
808
+ prev._nonReactive.beforeLoadPromise = void 0;
809
+ (_b3 = prev._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
814
810
  return {
815
811
  ...prev,
816
812
  error: err,
817
813
  status: "error",
818
814
  isFetching: false,
819
815
  updatedAt: Date.now(),
820
- abortController: new AbortController(),
821
- beforeLoadPromise: void 0
816
+ abortController: new AbortController()
822
817
  };
823
818
  });
824
819
  };
@@ -875,10 +870,7 @@ class RouterCore {
875
870
  }
876
871
  }
877
872
  }
878
- updateMatch(matchId, (prev) => ({
879
- ...prev,
880
- ssr
881
- }));
873
+ existingMatch.ssr = ssr;
882
874
  }
883
875
  if (shouldSkipLoader(matchId)) {
884
876
  continue;
@@ -886,26 +878,24 @@ class RouterCore {
886
878
  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)));
887
879
  let executeBeforeLoad = true;
888
880
  const setupPendingTimeout = () => {
889
- if (shouldPending && this.getMatch(matchId).pendingTimeout === void 0) {
881
+ const match = this.getMatch(matchId);
882
+ if (shouldPending && match._nonReactive.pendingTimeout === void 0) {
890
883
  const pendingTimeout = setTimeout(() => {
891
884
  try {
892
885
  triggerOnReady();
893
886
  } catch {
894
887
  }
895
888
  }, pendingMs);
896
- updateMatch(matchId, (prev) => ({
897
- ...prev,
898
- pendingTimeout
899
- }));
889
+ match._nonReactive.pendingTimeout = pendingTimeout;
900
890
  }
901
891
  };
902
892
  if (
903
893
  // If we are in the middle of a load, either of these will be present
904
894
  // (not to be confused with `loadPromise`, which is always defined)
905
- existingMatch.beforeLoadPromise || existingMatch.loaderPromise
895
+ existingMatch._nonReactive.beforeLoadPromise || existingMatch._nonReactive.loaderPromise
906
896
  ) {
907
897
  setupPendingTimeout();
908
- await existingMatch.beforeLoadPromise;
898
+ await existingMatch._nonReactive.beforeLoadPromise;
909
899
  const match = this.getMatch(matchId);
910
900
  if (match.status === "error") {
911
901
  executeBeforeLoad = true;
@@ -915,15 +905,11 @@ class RouterCore {
915
905
  }
916
906
  if (executeBeforeLoad) {
917
907
  try {
918
- updateMatch(matchId, (prev) => {
919
- const prevLoadPromise = prev.loadPromise;
920
- return {
921
- ...prev,
922
- loadPromise: utils.createControlledPromise(() => {
923
- prevLoadPromise == null ? void 0 : prevLoadPromise.resolve();
924
- }),
925
- beforeLoadPromise: utils.createControlledPromise()
926
- };
908
+ const match = this.getMatch(matchId);
909
+ match._nonReactive.beforeLoadPromise = utils.createControlledPromise();
910
+ const prevLoadPromise = match._nonReactive.loadPromise;
911
+ match._nonReactive.loadPromise = utils.createControlledPromise(() => {
912
+ prevLoadPromise == null ? void 0 : prevLoadPromise.resolve();
927
913
  });
928
914
  const { paramsError, searchError } = this.getMatch(matchId);
929
915
  if (paramsError) {
@@ -980,10 +966,10 @@ class RouterCore {
980
966
  }
981
967
  updateMatch(matchId, (prev) => {
982
968
  var _a2;
983
- (_a2 = prev.beforeLoadPromise) == null ? void 0 : _a2.resolve();
969
+ (_a2 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a2.resolve();
970
+ prev._nonReactive.beforeLoadPromise = void 0;
984
971
  return {
985
972
  ...prev,
986
- beforeLoadPromise: void 0,
987
973
  isFetching: false
988
974
  };
989
975
  });
@@ -994,11 +980,12 @@ class RouterCore {
994
980
  validResolvedMatches.forEach(({ id: matchId, routeId }, index) => {
995
981
  matchPromises.push(
996
982
  (async () => {
983
+ var _a2, _b2;
997
984
  let loaderShouldRunAsync = false;
998
985
  let loaderIsRunningAsync = false;
999
986
  const route = this.looseRoutesById[routeId];
1000
987
  const executeHead = async () => {
1001
- var _a2, _b2, _c2, _d2, _e, _f;
988
+ var _a3, _b3, _c2, _d2, _e, _f;
1002
989
  const match = this.getMatch(matchId);
1003
990
  if (!match) {
1004
991
  return;
@@ -1009,7 +996,7 @@ class RouterCore {
1009
996
  params: match.params,
1010
997
  loaderData: match.loaderData
1011
998
  };
1012
- const headFnContent = await ((_b2 = (_a2 = route.options).head) == null ? void 0 : _b2.call(_a2, assetContext));
999
+ const headFnContent = await ((_b3 = (_a3 = route.options).head) == null ? void 0 : _b3.call(_a3, assetContext));
1013
1000
  const meta = headFnContent == null ? void 0 : headFnContent.meta;
1014
1001
  const links = headFnContent == null ? void 0 : headFnContent.links;
1015
1002
  const headScripts = headFnContent == null ? void 0 : headFnContent.scripts;
@@ -1027,8 +1014,8 @@ class RouterCore {
1027
1014
  };
1028
1015
  const potentialPendingMinPromise = async () => {
1029
1016
  const latestMatch = this.getMatch(matchId);
1030
- if (latestMatch.minPendingPromise) {
1031
- await latestMatch.minPendingPromise;
1017
+ if (latestMatch._nonReactive.minPendingPromise) {
1018
+ await latestMatch._nonReactive.minPendingPromise;
1032
1019
  }
1033
1020
  };
1034
1021
  const prevMatch = this.getMatch(matchId);
@@ -1041,11 +1028,11 @@ class RouterCore {
1041
1028
  }));
1042
1029
  return this.getMatch(matchId);
1043
1030
  }
1044
- } else if (prevMatch.loaderPromise) {
1031
+ } else if (prevMatch._nonReactive.loaderPromise) {
1045
1032
  if (prevMatch.status === "success" && !sync && !prevMatch.preload) {
1046
1033
  return this.getMatch(matchId);
1047
1034
  }
1048
- await prevMatch.loaderPromise;
1035
+ await prevMatch._nonReactive.loaderPromise;
1049
1036
  const match = this.getMatch(matchId);
1050
1037
  if (match.error) {
1051
1038
  handleRedirectAndNotFound(match, match.error);
@@ -1079,13 +1066,15 @@ class RouterCore {
1079
1066
  const staleAge = preload ? route.options.preloadStaleTime ?? this.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? this.options.defaultStaleTime ?? 0;
1080
1067
  const shouldReloadOption = route.options.shouldReload;
1081
1068
  const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(getLoaderContext()) : shouldReloadOption;
1082
- updateMatch(matchId, (prev) => ({
1083
- ...prev,
1084
- loaderPromise: utils.createControlledPromise(),
1085
- preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
1086
- }));
1069
+ updateMatch(matchId, (prev) => {
1070
+ prev._nonReactive.loaderPromise = utils.createControlledPromise();
1071
+ return {
1072
+ ...prev,
1073
+ preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
1074
+ };
1075
+ });
1087
1076
  const runLoader = async () => {
1088
- var _a2, _b2, _c2, _d2;
1077
+ var _a3, _b3, _c2, _d2;
1089
1078
  try {
1090
1079
  try {
1091
1080
  if (!this.isServer || this.isServer && this.getMatch(matchId).ssr === true) {
@@ -1095,7 +1084,7 @@ class RouterCore {
1095
1084
  ...prev,
1096
1085
  isFetching: "loader"
1097
1086
  }));
1098
- const loaderData = await ((_b2 = (_a2 = route.options).loader) == null ? void 0 : _b2.call(_a2, getLoaderContext()));
1087
+ const loaderData = await ((_b3 = (_a3 = route.options).loader) == null ? void 0 : _b3.call(_a3, getLoaderContext()));
1099
1088
  handleRedirectAndNotFound(
1100
1089
  this.getMatch(matchId),
1101
1090
  loaderData
@@ -1140,11 +1129,13 @@ class RouterCore {
1140
1129
  }
1141
1130
  } catch (err) {
1142
1131
  const head = await executeHead();
1143
- updateMatch(matchId, (prev) => ({
1144
- ...prev,
1145
- loaderPromise: void 0,
1146
- ...head
1147
- }));
1132
+ updateMatch(matchId, (prev) => {
1133
+ prev._nonReactive.loaderPromise = void 0;
1134
+ return {
1135
+ ...prev,
1136
+ ...head
1137
+ };
1138
+ });
1148
1139
  handleRedirectAndNotFound(this.getMatch(matchId), err);
1149
1140
  }
1150
1141
  };
@@ -1154,15 +1145,13 @@ class RouterCore {
1154
1145
  } else if (loaderShouldRunAsync && !sync) {
1155
1146
  loaderIsRunningAsync = true;
1156
1147
  (async () => {
1148
+ var _a3, _b3;
1157
1149
  try {
1158
1150
  await runLoader();
1159
- const { loaderPromise, loadPromise } = this.getMatch(matchId);
1160
- loaderPromise == null ? void 0 : loaderPromise.resolve();
1161
- loadPromise == null ? void 0 : loadPromise.resolve();
1162
- updateMatch(matchId, (prev) => ({
1163
- ...prev,
1164
- loaderPromise: void 0
1165
- }));
1151
+ const match = this.getMatch(matchId);
1152
+ (_a3 = match._nonReactive.loaderPromise) == null ? void 0 : _a3.resolve();
1153
+ (_b3 = match._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
1154
+ match._nonReactive.loaderPromise = void 0;
1166
1155
  } catch (err) {
1167
1156
  if (redirect.isRedirect(err)) {
1168
1157
  await this.navigate(err.options);
@@ -1180,19 +1169,20 @@ class RouterCore {
1180
1169
  }
1181
1170
  }
1182
1171
  if (!loaderIsRunningAsync) {
1183
- const { loaderPromise, loadPromise } = this.getMatch(matchId);
1184
- loaderPromise == null ? void 0 : loaderPromise.resolve();
1185
- loadPromise == null ? void 0 : loadPromise.resolve();
1172
+ const match = this.getMatch(matchId);
1173
+ (_a2 = match._nonReactive.loaderPromise) == null ? void 0 : _a2.resolve();
1174
+ (_b2 = match._nonReactive.loadPromise) == null ? void 0 : _b2.resolve();
1186
1175
  }
1187
1176
  updateMatch(matchId, (prev) => {
1188
- clearTimeout(prev.pendingTimeout);
1177
+ clearTimeout(prev._nonReactive.pendingTimeout);
1178
+ prev._nonReactive.pendingTimeout = void 0;
1179
+ if (!loaderIsRunningAsync)
1180
+ prev._nonReactive.loaderPromise = void 0;
1181
+ prev._nonReactive.dehydrated = void 0;
1189
1182
  return {
1190
1183
  ...prev,
1191
1184
  isFetching: loaderIsRunningAsync ? prev.isFetching : false,
1192
- loaderPromise: loaderIsRunningAsync ? prev.loaderPromise : void 0,
1193
- invalid: false,
1194
- pendingTimeout: void 0,
1195
- _dehydrated: void 0
1185
+ invalid: false
1196
1186
  };
1197
1187
  });
1198
1188
  return this.getMatch(matchId);
@@ -1608,6 +1598,9 @@ class RouterCore {
1608
1598
  error: void 0,
1609
1599
  paramsError: parseErrors[index],
1610
1600
  __routeContext: {},
1601
+ _nonReactive: {
1602
+ loadPromise: utils.createControlledPromise()
1603
+ },
1611
1604
  __beforeLoadContext: void 0,
1612
1605
  context: {},
1613
1606
  abortController: new AbortController(),
@@ -1621,7 +1614,6 @@ class RouterCore {
1621
1614
  headScripts: void 0,
1622
1615
  meta: void 0,
1623
1616
  staticData: route.options.staticData || {},
1624
- loadPromise: utils.createControlledPromise(),
1625
1617
  fullPath: route.fullPath
1626
1618
  };
1627
1619
  }