@tanstack/router-core 1.131.3 → 1.131.5

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 /** @internal */\n beforeLoadPromise?: ControlledPromise<void>\n /** @internal */\n loaderPromise?: ControlledPromise<void>\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 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,7 +52,12 @@ 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>;
55
+ _nonReactive: {
56
+ loadPromise?: ControlledPromise<void>;
57
+ displayPendingPromise?: Promise<void>;
58
+ minPendingPromise?: ControlledPromise<void>;
59
+ dehydrated?: boolean;
60
+ };
56
61
  loaderData?: TLoaderData;
57
62
  context: TAllContext;
58
63
  search: TFullSearchSchema;
@@ -66,12 +71,9 @@ export interface RouteMatch<out TRouteId, out TFullPath, out TAllParams, out TFu
66
71
  headers?: Record<string, string>;
67
72
  globalNotFound?: boolean;
68
73
  staticData: StaticDataRouteOption;
69
- minPendingPromise?: ControlledPromise<void>;
70
- pendingTimeout?: ReturnType<typeof setTimeout>;
74
+ /** This attribute is not reactive */
71
75
  ssr?: boolean | 'data-only';
72
- _dehydrated?: boolean;
73
76
  _forcePending?: boolean;
74
- displayPendingPromise?: Promise<void>;
75
77
  _displayPending?: boolean;
76
78
  }
77
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;
@@ -276,13 +271,9 @@ class RouterCore {
276
271
  params: nextParams ?? {},
277
272
  parseCache: this.parsePathnameCache
278
273
  }).interpolatedPath;
279
- const destRoutes = this.matchRoutes(
280
- interpolatedNextTo,
281
- {},
282
- {
283
- _buildLocation: true
284
- }
285
- ).map((d) => this.looseRoutesById[d.routeId]);
274
+ const destRoutes = this.matchRoutes(interpolatedNextTo, void 0, {
275
+ _buildLocation: true
276
+ }).map((d) => this.looseRoutesById[d.routeId]);
286
277
  if (Object.keys(nextParams).length > 0) {
287
278
  destRoutes.map((route) => {
288
279
  var _a2;
@@ -745,20 +736,20 @@ class RouterCore {
745
736
  }
746
737
  }
747
738
  }
748
- (_a = match.beforeLoadPromise) == null ? void 0 : _a.resolve();
749
- (_b = match.loaderPromise) == null ? void 0 : _b.resolve();
739
+ (_a = match._nonReactive.beforeLoadPromise) == null ? void 0 : _a.resolve();
740
+ (_b = match._nonReactive.loaderPromise) == null ? void 0 : _b.resolve();
741
+ match._nonReactive.beforeLoadPromise = void 0;
742
+ match._nonReactive.loaderPromise = void 0;
750
743
  updateMatch(match.id, (prev) => ({
751
744
  ...prev,
752
745
  status: redirect.isRedirect(err) ? "redirected" : notFound.isNotFound(err) ? "notFound" : "error",
753
746
  isFetching: false,
754
- error: err,
755
- beforeLoadPromise: void 0,
756
- loaderPromise: void 0
747
+ error: err
757
748
  }));
758
749
  if (!err.routeId) {
759
750
  err.routeId = match.routeId;
760
751
  }
761
- (_c = match.loadPromise) == null ? void 0 : _c.resolve();
752
+ (_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
762
753
  if (redirect.isRedirect(err)) {
763
754
  rendered = true;
764
755
  err.options._fromLocation = location;
@@ -775,7 +766,7 @@ class RouterCore {
775
766
  };
776
767
  const shouldSkipLoader = (matchId) => {
777
768
  const match = this.getMatch(matchId);
778
- if (!this.isServer && match._dehydrated) {
769
+ if (!this.isServer && match._nonReactive.dehydrated) {
779
770
  return true;
780
771
  }
781
772
  if (this.isServer) {
@@ -809,16 +800,16 @@ class RouterCore {
809
800
  }
810
801
  updateMatch(matchId, (prev) => {
811
802
  var _a3, _b3;
812
- (_a3 = prev.beforeLoadPromise) == null ? void 0 : _a3.resolve();
813
- (_b3 = prev.loadPromise) == null ? void 0 : _b3.resolve();
803
+ (_a3 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a3.resolve();
804
+ prev._nonReactive.beforeLoadPromise = void 0;
805
+ (_b3 = prev._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
814
806
  return {
815
807
  ...prev,
816
808
  error: err,
817
809
  status: "error",
818
810
  isFetching: false,
819
811
  updatedAt: Date.now(),
820
- abortController: new AbortController(),
821
- beforeLoadPromise: void 0
812
+ abortController: new AbortController()
822
813
  };
823
814
  });
824
815
  };
@@ -875,10 +866,7 @@ class RouterCore {
875
866
  }
876
867
  }
877
868
  }
878
- updateMatch(matchId, (prev) => ({
879
- ...prev,
880
- ssr
881
- }));
869
+ existingMatch.ssr = ssr;
882
870
  }
883
871
  if (shouldSkipLoader(matchId)) {
884
872
  continue;
@@ -886,26 +874,24 @@ class RouterCore {
886
874
  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
875
  let executeBeforeLoad = true;
888
876
  const setupPendingTimeout = () => {
889
- if (shouldPending && this.getMatch(matchId).pendingTimeout === void 0) {
877
+ const match = this.getMatch(matchId);
878
+ if (shouldPending && match._nonReactive.pendingTimeout === void 0) {
890
879
  const pendingTimeout = setTimeout(() => {
891
880
  try {
892
881
  triggerOnReady();
893
882
  } catch {
894
883
  }
895
884
  }, pendingMs);
896
- updateMatch(matchId, (prev) => ({
897
- ...prev,
898
- pendingTimeout
899
- }));
885
+ match._nonReactive.pendingTimeout = pendingTimeout;
900
886
  }
901
887
  };
902
888
  if (
903
889
  // If we are in the middle of a load, either of these will be present
904
890
  // (not to be confused with `loadPromise`, which is always defined)
905
- existingMatch.beforeLoadPromise || existingMatch.loaderPromise
891
+ existingMatch._nonReactive.beforeLoadPromise || existingMatch._nonReactive.loaderPromise
906
892
  ) {
907
893
  setupPendingTimeout();
908
- await existingMatch.beforeLoadPromise;
894
+ await existingMatch._nonReactive.beforeLoadPromise;
909
895
  const match = this.getMatch(matchId);
910
896
  if (match.status === "error") {
911
897
  executeBeforeLoad = true;
@@ -915,15 +901,11 @@ class RouterCore {
915
901
  }
916
902
  if (executeBeforeLoad) {
917
903
  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
- };
904
+ const match = this.getMatch(matchId);
905
+ match._nonReactive.beforeLoadPromise = utils.createControlledPromise();
906
+ const prevLoadPromise = match._nonReactive.loadPromise;
907
+ match._nonReactive.loadPromise = utils.createControlledPromise(() => {
908
+ prevLoadPromise == null ? void 0 : prevLoadPromise.resolve();
927
909
  });
928
910
  const { paramsError, searchError } = this.getMatch(matchId);
929
911
  if (paramsError) {
@@ -934,7 +916,7 @@ class RouterCore {
934
916
  }
935
917
  setupPendingTimeout();
936
918
  const abortController = new AbortController();
937
- const parentMatchContext = (parentMatch == null ? void 0 : parentMatch.context) ?? this.options.context ?? {};
919
+ const parentMatchContext = (parentMatch == null ? void 0 : parentMatch.context) ?? this.options.context ?? void 0;
938
920
  updateMatch(matchId, (prev) => ({
939
921
  ...prev,
940
922
  isFetching: "beforeLoad",
@@ -980,10 +962,10 @@ class RouterCore {
980
962
  }
981
963
  updateMatch(matchId, (prev) => {
982
964
  var _a2;
983
- (_a2 = prev.beforeLoadPromise) == null ? void 0 : _a2.resolve();
965
+ (_a2 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a2.resolve();
966
+ prev._nonReactive.beforeLoadPromise = void 0;
984
967
  return {
985
968
  ...prev,
986
- beforeLoadPromise: void 0,
987
969
  isFetching: false
988
970
  };
989
971
  });
@@ -994,11 +976,12 @@ class RouterCore {
994
976
  validResolvedMatches.forEach(({ id: matchId, routeId }, index) => {
995
977
  matchPromises.push(
996
978
  (async () => {
979
+ var _a2, _b2;
997
980
  let loaderShouldRunAsync = false;
998
981
  let loaderIsRunningAsync = false;
999
982
  const route = this.looseRoutesById[routeId];
1000
983
  const executeHead = async () => {
1001
- var _a2, _b2, _c2, _d2, _e, _f;
984
+ var _a3, _b3, _c2, _d2, _e, _f;
1002
985
  const match = this.getMatch(matchId);
1003
986
  if (!match) {
1004
987
  return;
@@ -1009,7 +992,7 @@ class RouterCore {
1009
992
  params: match.params,
1010
993
  loaderData: match.loaderData
1011
994
  };
1012
- const headFnContent = await ((_b2 = (_a2 = route.options).head) == null ? void 0 : _b2.call(_a2, assetContext));
995
+ const headFnContent = await ((_b3 = (_a3 = route.options).head) == null ? void 0 : _b3.call(_a3, assetContext));
1013
996
  const meta = headFnContent == null ? void 0 : headFnContent.meta;
1014
997
  const links = headFnContent == null ? void 0 : headFnContent.links;
1015
998
  const headScripts = headFnContent == null ? void 0 : headFnContent.scripts;
@@ -1027,8 +1010,8 @@ class RouterCore {
1027
1010
  };
1028
1011
  const potentialPendingMinPromise = async () => {
1029
1012
  const latestMatch = this.getMatch(matchId);
1030
- if (latestMatch.minPendingPromise) {
1031
- await latestMatch.minPendingPromise;
1013
+ if (latestMatch._nonReactive.minPendingPromise) {
1014
+ await latestMatch._nonReactive.minPendingPromise;
1032
1015
  }
1033
1016
  };
1034
1017
  const prevMatch = this.getMatch(matchId);
@@ -1041,11 +1024,11 @@ class RouterCore {
1041
1024
  }));
1042
1025
  return this.getMatch(matchId);
1043
1026
  }
1044
- } else if (prevMatch.loaderPromise) {
1027
+ } else if (prevMatch._nonReactive.loaderPromise) {
1045
1028
  if (prevMatch.status === "success" && !sync && !prevMatch.preload) {
1046
1029
  return this.getMatch(matchId);
1047
1030
  }
1048
- await prevMatch.loaderPromise;
1031
+ await prevMatch._nonReactive.loaderPromise;
1049
1032
  const match = this.getMatch(matchId);
1050
1033
  if (match.error) {
1051
1034
  handleRedirectAndNotFound(match, match.error);
@@ -1079,13 +1062,15 @@ class RouterCore {
1079
1062
  const staleAge = preload ? route.options.preloadStaleTime ?? this.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? this.options.defaultStaleTime ?? 0;
1080
1063
  const shouldReloadOption = route.options.shouldReload;
1081
1064
  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
- }));
1065
+ updateMatch(matchId, (prev) => {
1066
+ prev._nonReactive.loaderPromise = utils.createControlledPromise();
1067
+ return {
1068
+ ...prev,
1069
+ preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
1070
+ };
1071
+ });
1087
1072
  const runLoader = async () => {
1088
- var _a2, _b2, _c2, _d2;
1073
+ var _a3, _b3, _c2, _d2;
1089
1074
  try {
1090
1075
  try {
1091
1076
  if (!this.isServer || this.isServer && this.getMatch(matchId).ssr === true) {
@@ -1095,7 +1080,7 @@ class RouterCore {
1095
1080
  ...prev,
1096
1081
  isFetching: "loader"
1097
1082
  }));
1098
- const loaderData = await ((_b2 = (_a2 = route.options).loader) == null ? void 0 : _b2.call(_a2, getLoaderContext()));
1083
+ const loaderData = await ((_b3 = (_a3 = route.options).loader) == null ? void 0 : _b3.call(_a3, getLoaderContext()));
1099
1084
  handleRedirectAndNotFound(
1100
1085
  this.getMatch(matchId),
1101
1086
  loaderData
@@ -1140,11 +1125,13 @@ class RouterCore {
1140
1125
  }
1141
1126
  } catch (err) {
1142
1127
  const head = await executeHead();
1143
- updateMatch(matchId, (prev) => ({
1144
- ...prev,
1145
- loaderPromise: void 0,
1146
- ...head
1147
- }));
1128
+ updateMatch(matchId, (prev) => {
1129
+ prev._nonReactive.loaderPromise = void 0;
1130
+ return {
1131
+ ...prev,
1132
+ ...head
1133
+ };
1134
+ });
1148
1135
  handleRedirectAndNotFound(this.getMatch(matchId), err);
1149
1136
  }
1150
1137
  };
@@ -1154,15 +1141,13 @@ class RouterCore {
1154
1141
  } else if (loaderShouldRunAsync && !sync) {
1155
1142
  loaderIsRunningAsync = true;
1156
1143
  (async () => {
1144
+ var _a3, _b3;
1157
1145
  try {
1158
1146
  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
- }));
1147
+ const match = this.getMatch(matchId);
1148
+ (_a3 = match._nonReactive.loaderPromise) == null ? void 0 : _a3.resolve();
1149
+ (_b3 = match._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
1150
+ match._nonReactive.loaderPromise = void 0;
1166
1151
  } catch (err) {
1167
1152
  if (redirect.isRedirect(err)) {
1168
1153
  await this.navigate(err.options);
@@ -1180,19 +1165,20 @@ class RouterCore {
1180
1165
  }
1181
1166
  }
1182
1167
  if (!loaderIsRunningAsync) {
1183
- const { loaderPromise, loadPromise } = this.getMatch(matchId);
1184
- loaderPromise == null ? void 0 : loaderPromise.resolve();
1185
- loadPromise == null ? void 0 : loadPromise.resolve();
1168
+ const match = this.getMatch(matchId);
1169
+ (_a2 = match._nonReactive.loaderPromise) == null ? void 0 : _a2.resolve();
1170
+ (_b2 = match._nonReactive.loadPromise) == null ? void 0 : _b2.resolve();
1186
1171
  }
1187
1172
  updateMatch(matchId, (prev) => {
1188
- clearTimeout(prev.pendingTimeout);
1173
+ clearTimeout(prev._nonReactive.pendingTimeout);
1174
+ prev._nonReactive.pendingTimeout = void 0;
1175
+ if (!loaderIsRunningAsync)
1176
+ prev._nonReactive.loaderPromise = void 0;
1177
+ prev._nonReactive.dehydrated = void 0;
1189
1178
  return {
1190
1179
  ...prev,
1191
1180
  isFetching: loaderIsRunningAsync ? prev.isFetching : false,
1192
- loaderPromise: loaderIsRunningAsync ? prev.loaderPromise : void 0,
1193
- invalid: false,
1194
- pendingTimeout: void 0,
1195
- _dehydrated: void 0
1181
+ invalid: false
1196
1182
  };
1197
1183
  });
1198
1184
  return this.getMatch(matchId);
@@ -1224,7 +1210,7 @@ class RouterCore {
1224
1210
  return {
1225
1211
  ...d,
1226
1212
  invalid: true,
1227
- ...(opts == null ? void 0 : opts.forcePending) || d.status === "error" ? { status: "pending", error: void 0 } : {}
1213
+ ...(opts == null ? void 0 : opts.forcePending) || d.status === "error" ? { status: "pending", error: void 0 } : void 0
1228
1214
  };
1229
1215
  }
1230
1216
  return d;
@@ -1527,7 +1513,7 @@ class RouterCore {
1527
1513
  const matches = [];
1528
1514
  const getParentContext = (parentMatch) => {
1529
1515
  const parentMatchId = parentMatch == null ? void 0 : parentMatch.id;
1530
- const parentContext = !parentMatchId ? this.options.context ?? {} : parentMatch.context ?? this.options.context ?? {};
1516
+ const parentContext = !parentMatchId ? this.options.context ?? void 0 : parentMatch.context ?? this.options.context ?? void 0;
1531
1517
  return parentContext;
1532
1518
  };
1533
1519
  matchedRoutes.forEach((route, index) => {
@@ -1535,9 +1521,9 @@ class RouterCore {
1535
1521
  const parentMatch = matches[index - 1];
1536
1522
  const [preMatchSearch, strictMatchSearch, searchError] = (() => {
1537
1523
  const parentSearch = (parentMatch == null ? void 0 : parentMatch.search) ?? next.search;
1538
- const parentStrictSearch = (parentMatch == null ? void 0 : parentMatch._strictSearch) ?? {};
1524
+ const parentStrictSearch = (parentMatch == null ? void 0 : parentMatch._strictSearch) ?? void 0;
1539
1525
  try {
1540
- const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? {};
1526
+ const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
1541
1527
  return [
1542
1528
  {
1543
1529
  ...parentSearch,
@@ -1607,7 +1593,10 @@ class RouterCore {
1607
1593
  isFetching: false,
1608
1594
  error: void 0,
1609
1595
  paramsError: parseErrors[index],
1610
- __routeContext: {},
1596
+ __routeContext: void 0,
1597
+ _nonReactive: {
1598
+ loadPromise: utils.createControlledPromise()
1599
+ },
1611
1600
  __beforeLoadContext: void 0,
1612
1601
  context: {},
1613
1602
  abortController: new AbortController(),
@@ -1621,7 +1610,6 @@ class RouterCore {
1621
1610
  headScripts: void 0,
1622
1611
  meta: void 0,
1623
1612
  staticData: route.options.staticData || {},
1624
- loadPromise: utils.createControlledPromise(),
1625
1613
  fullPath: route.fullPath
1626
1614
  };
1627
1615
  }
@@ -1638,25 +1626,26 @@ class RouterCore {
1638
1626
  matches.push(match);
1639
1627
  });
1640
1628
  matches.forEach((match, index) => {
1641
- var _a2, _b;
1642
1629
  const route = this.looseRoutesById[match.routeId];
1643
1630
  const existingMatch = this.getMatch(match.id);
1644
1631
  if (!existingMatch && (opts == null ? void 0 : opts._buildLocation) !== true) {
1645
1632
  const parentMatch = matches[index - 1];
1646
1633
  const parentContext = getParentContext(parentMatch);
1647
- const contextFnContext = {
1648
- deps: match.loaderDeps,
1649
- params: match.params,
1650
- context: parentContext,
1651
- location: next,
1652
- navigate: (opts2) => this.navigate({ ...opts2, _fromLocation: next }),
1653
- buildLocation: this.buildLocation,
1654
- cause: match.cause,
1655
- abortController: match.abortController,
1656
- preload: !!match.preload,
1657
- matches
1658
- };
1659
- match.__routeContext = ((_b = (_a2 = route.options).context) == null ? void 0 : _b.call(_a2, contextFnContext)) ?? {};
1634
+ if (route.options.context) {
1635
+ const contextFnContext = {
1636
+ deps: match.loaderDeps,
1637
+ params: match.params,
1638
+ context: parentContext ?? {},
1639
+ location: next,
1640
+ navigate: (opts2) => this.navigate({ ...opts2, _fromLocation: next }),
1641
+ buildLocation: this.buildLocation,
1642
+ cause: match.cause,
1643
+ abortController: match.abortController,
1644
+ preload: !!match.preload,
1645
+ matches
1646
+ };
1647
+ match.__routeContext = route.options.context(contextFnContext) ?? void 0;
1648
+ }
1660
1649
  match.context = {
1661
1650
  ...parentContext,
1662
1651
  ...match.__routeContext,
@@ -1963,7 +1952,7 @@ function applySearchMiddleware({
1963
1952
  try {
1964
1953
  const validatedSearch = {
1965
1954
  ...result,
1966
- ...validateSearch(route.options.validateSearch, result) ?? {}
1955
+ ...validateSearch(route.options.validateSearch, result) ?? void 0
1967
1956
  };
1968
1957
  return validatedSearch;
1969
1958
  } catch {