Sign In

@tanstack/router-core

Package Overview
Dependencies
Maintainers
3
Versions
489
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/router-core - npm Package Compare versions

Comparing version
1.171.16-pre.0
to
1.171.16
+1
-1
dist/cjs/link.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"file":"link.cjs","names":[],"sources":["../../src/link.ts"],"sourcesContent":["import type { HistoryState, ParsedHistoryState } from '@tanstack/history'\nimport type {\n AllParams,\n CatchAllPaths,\n CurrentPath,\n FullSearchSchema,\n FullSearchSchemaInput,\n ParentPath,\n RouteByPath,\n RouteByToPath,\n RoutePaths,\n RouteToPath,\n ToPath,\n} from './routeInfo'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ViewTransitionOptions,\n} from './router'\nimport type {\n ConstrainLiteral,\n Expand,\n MakeDifferenceOptional,\n NoInfer,\n NonNullableUpdater,\n Updater,\n} from './utils'\nimport type { ParsedLocation } from './location'\n\nexport type IsRequiredParams<TParams> =\n Record<never, never> extends TParams ? never : true\n\nexport interface ParsePathParamsResult<\n in out TRequired,\n in out TOptional,\n in out TRest,\n> {\n required: TRequired\n optional: TOptional\n rest: TRest\n}\n\nexport type AnyParsePathParamsResult = ParsePathParamsResult<\n string,\n string,\n string\n>\n\nexport type ParsePathParamsBoundaryStart<T extends string> =\n T extends `${infer TLeft}{-${infer TRight}`\n ? ParsePathParamsResult<\n ParsePathParams<TLeft>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['required']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : T extends `${infer TLeft}{${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsSymbol<T extends string> =\n T extends `${string}$${infer TRight}`\n ? TRight extends `${string}/${string}`\n ? TRight extends `${infer TParam}/${infer TRest}`\n ? TParam extends ''\n ? ParsePathParamsResult<\n ParsePathParams<TRest>['required'],\n '_splat' | ParsePathParams<TRest>['optional'],\n ParsePathParams<TRest>['rest']\n >\n : ParsePathParamsResult<\n TParam | ParsePathParams<TRest>['required'],\n ParsePathParams<TRest>['optional'],\n ParsePathParams<TRest>['rest']\n >\n : never\n : TRight extends ''\n ? ParsePathParamsResult<never, '_splat', never>\n : ParsePathParamsResult<TRight, never, never>\n : never\n\nexport type ParsePathParamsBoundaryEnd<T extends string> =\n T extends `${infer TLeft}}${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsEscapeStart<T extends string> =\n T extends `${infer TLeft}[${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsEscapeEnd<T extends string> =\n T extends `${string}]${infer TRight}` ? ParsePathParams<TRight> : never\n\nexport type ParsePathParams<T extends string> = T extends `${string}[${string}`\n ? ParsePathParamsEscapeStart<T>\n : T extends `${string}]${string}`\n ? ParsePathParamsEscapeEnd<T>\n : T extends `${string}}${string}`\n ? ParsePathParamsBoundaryEnd<T>\n : T extends `${string}{${string}`\n ? ParsePathParamsBoundaryStart<T>\n : T extends `${string}$${string}`\n ? ParsePathParamsSymbol<T>\n : never\n\nexport type AddTrailingSlash<T> = T extends `${string}/` ? T : `${T & string}/`\n\nexport type RemoveTrailingSlashes<T> = T & `${string}/` extends never\n ? T\n : T extends `${infer R}/`\n ? R\n : T\n\nexport type AddLeadingSlash<T> = T & `/${string}` extends never\n ? `/${T & string}`\n : T\n\nexport type RemoveLeadingSlashes<T> = T & `/${string}` extends never\n ? T\n : T extends `/${infer R}`\n ? R\n : T\n\ntype JoinPath<TLeft extends string, TRight extends string> = TRight extends ''\n ? TLeft\n : TLeft extends ''\n ? TRight\n : `${RemoveTrailingSlashes<TLeft>}/${RemoveLeadingSlashes<TRight>}`\n\ntype RemoveLastSegment<\n T extends string,\n TAcc extends string = '',\n> = T extends `${infer TSegment}/${infer TRest}`\n ? TRest & `${string}/${string}` extends never\n ? TRest extends ''\n ? TAcc\n : `${TAcc}${TSegment}`\n : RemoveLastSegment<TRest, `${TAcc}${TSegment}/`>\n : TAcc\n\nexport type ResolveCurrentPath<\n TFrom extends string,\n TTo extends string,\n> = TTo extends '.'\n ? TFrom\n : TTo extends './'\n ? AddTrailingSlash<TFrom>\n : TTo & `./${string}` extends never\n ? never\n : TTo extends `./${infer TRest}`\n ? AddLeadingSlash<JoinPath<TFrom, TRest>>\n : never\n\nexport type ResolveParentPath<\n TFrom extends string,\n TTo extends string,\n> = TTo extends '../' | '..'\n ? TFrom extends '' | '/'\n ? never\n : AddLeadingSlash<RemoveLastSegment<TFrom>>\n : TTo & `../${string}` extends never\n ? AddLeadingSlash<JoinPath<TFrom, TTo>>\n : TFrom extends '' | '/'\n ? never\n : TTo extends `../${infer ToRest}`\n ? ResolveParentPath<RemoveLastSegment<TFrom>, ToRest>\n : AddLeadingSlash<JoinPath<TFrom, TTo>>\n\nexport type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom\n ? TTo\n : string extends TTo\n ? TFrom\n : undefined extends TTo\n ? TFrom\n : TTo extends string\n ? TFrom extends string\n ? TTo extends `/${string}`\n ? TTo\n : TTo extends `..${string}`\n ? ResolveParentPath<TFrom, TTo>\n : TTo extends `.${string}`\n ? ResolveCurrentPath<TFrom, TTo>\n : AddLeadingSlash<JoinPath<TFrom, TTo>>\n : never\n : never\n\nexport type FindDescendantToPaths<\n TRouter extends AnyRouter,\n TPrefix extends string,\n> = `${TPrefix}/${string}` & RouteToPath<TRouter>\n\nexport type InferDescendantToPaths<\n TRouter extends AnyRouter,\n TPrefix extends string,\n TPaths = FindDescendantToPaths<TRouter, TPrefix>,\n> = TPaths extends `${TPrefix}/`\n ? never\n : TPaths extends `${TPrefix}/${infer TRest}`\n ? TRest\n : never\n\nexport type RelativeToPath<\n TRouter extends AnyRouter,\n TTo extends string,\n TResolvedPath extends string,\n> =\n | (TResolvedPath & RouteToPath<TRouter> extends never\n ? never\n : ToPath<TRouter, TTo>)\n | `${RemoveTrailingSlashes<TTo>}/${InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TResolvedPath>>}`\n\nexport type RelativeToParentPath<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,\n> =\n | RelativeToPath<TRouter, TTo, TResolvedPath>\n | (TTo extends `${string}..` | `${string}../`\n ? TResolvedPath extends '/' | ''\n ? never\n : FindDescendantToPaths<\n TRouter,\n RemoveTrailingSlashes<TResolvedPath>\n > extends never\n ? never\n : `${RemoveTrailingSlashes<TTo>}/${ParentPath<TRouter>}`\n : never)\n\nexport type RelativeToCurrentPath<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,\n> = RelativeToPath<TRouter, TTo, TResolvedPath> | CurrentPath<TRouter>\n\nexport type AbsoluteToPath<TRouter extends AnyRouter, TFrom extends string> =\n | (string extends TFrom\n ? CurrentPath<TRouter>\n : TFrom extends `/`\n ? never\n : CurrentPath<TRouter>)\n | (string extends TFrom\n ? ParentPath<TRouter>\n : TFrom extends `/`\n ? never\n : ParentPath<TRouter>)\n | RouteToPath<TRouter>\n | (TFrom extends '/'\n ? never\n : string extends TFrom\n ? never\n : InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TFrom>>)\n\nexport type RelativeToPathAutoComplete<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n> = string extends TTo\n ? string\n : string extends TFrom\n ? AbsoluteToPath<TRouter, TFrom>\n : TTo & `..${string}` extends never\n ? TTo & `.${string}` extends never\n ? AbsoluteToPath<TRouter, TFrom>\n : RelativeToCurrentPath<TRouter, TFrom, TTo>\n : RelativeToParentPath<TRouter, TFrom, TTo>\n\nexport type NavigateOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & NavigateOptionProps\n\n/**\n * The NavigateOptions type is used to describe the options that can be used when describing a navigation action in TanStack Router.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType)\n */\nexport interface NavigateOptionProps {\n /**\n * If set to `true`, the router will scroll the element with an id matching the hash into view with default `ScrollIntoViewOptions`.\n * If set to `false`, the router will not scroll the element with an id matching the hash into view.\n * If set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options.\n * @default true\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#hashscrollintoview)\n * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)\n */\n hashScrollIntoView?: boolean | ScrollIntoViewOptions\n /**\n * `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#replace)\n */\n replace?: boolean\n /**\n * Defaults to `true` so that the scroll position will be reset to 0,0 after the location is committed to the browser history.\n * If `false`, the scroll position will not be reset to 0,0 after the location is committed to history.\n * @default true\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#resetscroll)\n */\n resetScroll?: boolean\n /** @deprecated All navigations now use startTransition under the hood */\n startTransition?: boolean\n /**\n * If set to `true`, the router will wrap the resulting navigation in a `document.startViewTransition()` call.\n * If `ViewTransitionOptions`, route navigations will be called using `document.startViewTransition({update, types})`\n * where `types` will be the strings array passed with `ViewTransitionOptions[\"types\"]`.\n * If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed.\n *\n * If the browser does not support this api, this option will be ignored.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#viewtransition)\n * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)\n * @see [Google](https://developer.chrome.com/docs/web-platform/view-transitions/same-document#view-transition-types)\n */\n viewTransition?: boolean | ViewTransitionOptions\n /**\n * If `true`, navigation will ignore any blockers that might prevent it.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#ignoreblocker)\n */\n ignoreBlocker?: boolean\n /**\n * If `true`, navigation to a route inside of router will trigger a full page load instead of the traditional SPA navigation.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#reloaddocument)\n */\n reloadDocument?: boolean\n /**\n * This can be used instead of `to` to navigate to a fully built href, e.g. pointing to an external target.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n href?: string\n /** @internal */\n publicHref?: string\n}\n\nexport type ToOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ToSubOptions<TRouter, TFrom, TTo> & MaskOptions<TRouter, TMaskFrom, TMaskTo>\n\nexport interface MaskOptions<\n in out TRouter extends AnyRouter,\n in out TMaskFrom extends string,\n in out TMaskTo extends string,\n> {\n _fromLocation?: ParsedLocation\n mask?: ToMaskOptions<TRouter, TMaskFrom, TMaskTo>\n}\n\nexport type ToMaskOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TMaskFrom extends string = string,\n TMaskTo extends string = '.',\n> = ToSubOptions<TRouter, TMaskFrom, TMaskTo> & {\n unmaskOnReload?: boolean\n}\n\nexport type ToSubOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n SearchParamOptions<TRouter, TFrom, TTo> &\n PathParamOptions<TRouter, TFrom, TTo>\n\nexport interface RequiredToOptions<\n in out TRouter extends AnyRouter,\n in out TFrom extends string,\n in out TTo extends string | undefined,\n> {\n /**\n * The internal route path to navigate to. This should be a relative or absolute path within your application.\n * For external URLs, use the `href` property instead.\n * @example \"/dashboard\" or \"../profile\"\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n to: ToPathOption<TRouter, TFrom, TTo> & {}\n}\n\nexport interface OptionalToOptions<\n in out TRouter extends AnyRouter,\n in out TFrom extends string,\n in out TTo extends string | undefined,\n> {\n /**\n * The internal route path to navigate to. This should be a relative or absolute path within your application.\n * For external URLs, use the `href` property instead.\n * @example \"/dashboard\" or \"../profile\"\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n to?: ToPathOption<TRouter, TFrom, TTo> & {}\n}\n\nexport type MakeToRequired<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string | undefined,\n> = string extends TFrom\n ? string extends TTo\n ? OptionalToOptions<TRouter, TFrom, TTo>\n : TTo & CatchAllPaths<TRouter> extends never\n ? RequiredToOptions<TRouter, TFrom, TTo>\n : OptionalToOptions<TRouter, TFrom, TTo>\n : OptionalToOptions<TRouter, TFrom, TTo>\n\nexport type ToSubOptionsProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n> = MakeToRequired<TRouter, TFrom, TTo> & {\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>\n from?: FromPathOption<TRouter, TFrom> & {}\n unsafeRelative?: 'path'\n}\n\nexport type ParamsReducerFn<\n in out TRouter extends AnyRouter,\n in out TParamVariant extends ParamVariant,\n in out TFrom,\n in out TTo,\n> = (\n current: Expand<ResolveFromParams<TRouter, TParamVariant, TFrom>>,\n) => Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>\n\ntype ParamsReducer<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n | Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>\n | (ParamsReducerFn<TRouter, TParamVariant, TFrom, TTo> & {})\n\ntype ParamVariant = 'PATH' | 'SEARCH'\n\nexport type ResolveRoute<\n TRouter extends AnyRouter,\n TFrom,\n TTo,\n TPath = ResolveRelativePath<TFrom, TTo>,\n> = TPath extends string\n ? TFrom extends TPath\n ? RouteByPath<TRouter['routeTree'], TPath>\n : RouteByToPath<TRouter, TPath>\n : never\n\ntype ResolveFromParamType<TParamVariant extends ParamVariant> =\n TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema'\n\ntype ResolveFromAllParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n> = TParamVariant extends 'PATH'\n ? AllParams<TRouter['routeTree']>\n : FullSearchSchema<TRouter['routeTree']>\n\ntype ResolveFromParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n> = string extends TFrom\n ? ResolveFromAllParams<TRouter, TParamVariant>\n : RouteByPath<\n TRouter['routeTree'],\n TFrom\n >['types'][ResolveFromParamType<TParamVariant>]\n\ntype ResolveToParamType<TParamVariant extends ParamVariant> =\n TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput'\n\ntype ResolveAllToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n> = TParamVariant extends 'PATH'\n ? AllParams<TRouter['routeTree']>\n : FullSearchSchemaInput<TRouter['routeTree']>\n\nexport type ResolveToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n ResolveRelativePath<TFrom, TTo> extends infer TPath\n ? undefined extends TPath\n ? never\n : string extends TPath\n ? ResolveAllToParams<TRouter, TParamVariant>\n : TPath extends CatchAllPaths<TRouter>\n ? ResolveAllToParams<TRouter, TParamVariant>\n : ResolveRoute<\n TRouter,\n TFrom,\n TTo\n >['types'][ResolveToParamType<TParamVariant>]\n : never\n\ntype ResolveRelativeToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n TToParams = ResolveToParams<TRouter, TParamVariant, TFrom, TTo>,\n> = TParamVariant extends 'SEARCH'\n ? TToParams\n : string extends TFrom\n ? TToParams\n : MakeDifferenceOptional<\n ResolveFromParams<TRouter, TParamVariant, TFrom>,\n TToParams\n >\n\nexport interface MakeOptionalSearchParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n search?: true | (ParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {})\n}\n\nexport interface MakeOptionalPathParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n params?: true | (ParamsReducer<TRouter, 'PATH', TFrom, TTo> & {})\n}\n\ntype MakeRequiredParamsReducer<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n | (string extends TFrom\n ? never\n : ResolveFromParams<\n TRouter,\n TParamVariant,\n TFrom\n > extends ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>\n ? true\n : never)\n | (ParamsReducer<TRouter, TParamVariant, TFrom, TTo> & {})\n\nexport interface MakeRequiredPathParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n params: MakeRequiredParamsReducer<TRouter, 'PATH', TFrom, TTo> & {}\n}\n\nexport interface MakeRequiredSearchParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n search: MakeRequiredParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {}\n}\n\nexport type IsRequired<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n ResolveRelativePath<TFrom, TTo> extends infer TPath\n ? undefined extends TPath\n ? never\n : TPath extends CatchAllPaths<TRouter>\n ? never\n : IsRequiredParams<\n ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>\n >\n : never\n\nexport type SearchParamOptions<TRouter extends AnyRouter, TFrom, TTo> =\n IsRequired<TRouter, 'SEARCH', TFrom, TTo> extends never\n ? MakeOptionalSearchParams<TRouter, TFrom, TTo>\n : MakeRequiredSearchParams<TRouter, TFrom, TTo>\n\nexport type PathParamOptions<TRouter extends AnyRouter, TFrom, TTo> =\n IsRequired<TRouter, 'PATH', TFrom, TTo> extends never\n ? MakeOptionalPathParams<TRouter, TFrom, TTo>\n : MakeRequiredPathParams<TRouter, TFrom, TTo>\n\nexport type ToPathOption<\n TRouter extends AnyRouter = AnyRouter,\n TFrom extends string = string,\n TTo extends string | undefined = string,\n> = ConstrainLiteral<\n TTo,\n RelativeToPathAutoComplete<\n TRouter,\n NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',\n NoInfer<TTo> & string\n >\n>\n\nexport type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<\n TFrom,\n RoutePaths<TRouter['routeTree']>\n>\n\n/**\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options)\n */\nexport interface ActiveOptions {\n /**\n * If true, the link will be active if the current route matches the `to` route path exactly (no children routes)\n * @default false\n */\n exact?: boolean\n /**\n * If true, the link will only be active if the current URL hash matches the `hash` prop\n * @default false\n */\n includeHash?: boolean\n /**\n * If true, the link will only be active if the current URL search params inclusively match the `search` prop\n * @default true\n */\n includeSearch?: boolean\n /**\n * This modifies the `includeSearch` behavior.\n * If true, properties in `search` that are explicitly `undefined` must NOT be present in the current URL search params for the link to be active.\n * @default false\n */\n explicitUndefined?: boolean\n}\n\nexport interface LinkOptionsProps {\n /**\n * The standard anchor tag target attribute\n */\n target?: HTMLAnchorElement['target']\n /**\n * Configurable options to determine if the link should be considered active or not\n * @default {exact:true,includeHash:true}\n */\n activeOptions?: ActiveOptions\n /**\n * The preloading strategy for this link\n * - `false` - No preloading\n * - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.\n * - `'viewport'` - Preload the linked route when it enters the viewport\n */\n preload?: false | 'intent' | 'viewport' | 'render'\n /**\n * When a preload strategy is set, this delays the preload by this many milliseconds.\n * If the user exits the link before this delay, the preload will be cancelled.\n */\n preloadDelay?: number\n /**\n * Control whether the link should be disabled or not\n * If set to `true`, the link will be rendered without an `href` attribute\n * @default false\n */\n disabled?: boolean\n /**\n * When the preload strategy is set to `intent`, this controls the proximity of the link to the cursor before it is preloaded.\n * If the user exits this proximity before this delay, the preload will be cancelled.\n */\n preloadIntentProximity?: number\n}\n\nexport type LinkOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkOptionsProps\n\nexport const preloadWarning = 'Error preloading route! ☝️'\n"],"mappings":";AA+rBA,MAAa,iBAAiB"}
{"version":3,"file":"link.cjs","names":[],"sources":["../../src/link.ts"],"sourcesContent":["import type { HistoryState, ParsedHistoryState } from '@tanstack/history'\nimport type {\n AllParams,\n CatchAllPaths,\n CurrentPath,\n FullSearchSchema,\n FullSearchSchemaInput,\n ParentPath,\n RouteByPath,\n RouteByToPath,\n RoutePaths,\n RouteToPath,\n ToPath,\n} from './routeInfo'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ViewTransitionOptions,\n} from './router'\nimport type {\n ConstrainLiteral,\n Expand,\n MakeDifferenceOptional,\n NoInfer,\n NonNullableUpdater,\n Updater,\n} from './utils'\nimport type { ParsedLocation } from './location'\n\nexport type IsRequiredParams<TParams> =\n Record<never, never> extends TParams ? never : true\n\nexport interface ParsePathParamsResult<\n in out TRequired,\n in out TOptional,\n in out TRest,\n> {\n required: TRequired\n optional: TOptional\n rest: TRest\n}\n\nexport type AnyParsePathParamsResult = ParsePathParamsResult<\n string,\n string,\n string\n>\n\nexport type ParsePathParamsBoundaryStart<T extends string> =\n T extends `${infer TLeft}{-${infer TRight}`\n ? ParsePathParamsResult<\n ParsePathParams<TLeft>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['required']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : T extends `${infer TLeft}{${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsSymbol<T extends string> =\n T extends `${string}$${infer TRight}`\n ? TRight extends `${string}/${string}`\n ? TRight extends `${infer TParam}/${infer TRest}`\n ? TParam extends ''\n ? ParsePathParamsResult<\n ParsePathParams<TRest>['required'],\n '_splat' | ParsePathParams<TRest>['optional'],\n ParsePathParams<TRest>['rest']\n >\n : ParsePathParamsResult<\n TParam | ParsePathParams<TRest>['required'],\n ParsePathParams<TRest>['optional'],\n ParsePathParams<TRest>['rest']\n >\n : never\n : TRight extends ''\n ? ParsePathParamsResult<never, '_splat', never>\n : ParsePathParamsResult<TRight, never, never>\n : never\n\nexport type ParsePathParamsBoundaryEnd<T extends string> =\n T extends `${infer TLeft}}${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsEscapeStart<T extends string> =\n T extends `${infer TLeft}[${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsEscapeEnd<T extends string> =\n T extends `${string}]${infer TRight}` ? ParsePathParams<TRight> : never\n\nexport type ParsePathParams<T extends string> = T extends `${string}[${string}`\n ? ParsePathParamsEscapeStart<T>\n : T extends `${string}]${string}`\n ? ParsePathParamsEscapeEnd<T>\n : T extends `${string}}${string}`\n ? ParsePathParamsBoundaryEnd<T>\n : T extends `${string}{${string}`\n ? ParsePathParamsBoundaryStart<T>\n : T extends `${string}$${string}`\n ? ParsePathParamsSymbol<T>\n : never\n\nexport type AddTrailingSlash<T> = T extends `${string}/` ? T : `${T & string}/`\n\nexport type RemoveTrailingSlashes<T> = T & `${string}/` extends never\n ? T\n : T extends `${infer R}/`\n ? R\n : T\n\nexport type AddLeadingSlash<T> = T & `/${string}` extends never\n ? `/${T & string}`\n : T\n\nexport type RemoveLeadingSlashes<T> = T & `/${string}` extends never\n ? T\n : T extends `/${infer R}`\n ? R\n : T\n\ntype JoinPath<TLeft extends string, TRight extends string> = TRight extends ''\n ? TLeft\n : TLeft extends ''\n ? TRight\n : `${RemoveTrailingSlashes<TLeft>}/${RemoveLeadingSlashes<TRight>}`\n\ntype RemoveLastSegment<\n T extends string,\n TAcc extends string = '',\n> = T extends `${infer TSegment}/${infer TRest}`\n ? TRest & `${string}/${string}` extends never\n ? TRest extends ''\n ? TAcc\n : `${TAcc}${TSegment}`\n : RemoveLastSegment<TRest, `${TAcc}${TSegment}/`>\n : TAcc\n\nexport type ResolveCurrentPath<\n TFrom extends string,\n TTo extends string,\n> = TTo extends '.'\n ? TFrom\n : TTo extends './'\n ? AddTrailingSlash<TFrom>\n : TTo & `./${string}` extends never\n ? never\n : TTo extends `./${infer TRest}`\n ? AddLeadingSlash<JoinPath<TFrom, TRest>>\n : never\n\nexport type ResolveParentPath<\n TFrom extends string,\n TTo extends string,\n> = TTo extends '../' | '..'\n ? TFrom extends '' | '/'\n ? never\n : AddLeadingSlash<RemoveLastSegment<TFrom>>\n : TTo & `../${string}` extends never\n ? AddLeadingSlash<JoinPath<TFrom, TTo>>\n : TFrom extends '' | '/'\n ? never\n : TTo extends `../${infer ToRest}`\n ? ResolveParentPath<RemoveLastSegment<TFrom>, ToRest>\n : AddLeadingSlash<JoinPath<TFrom, TTo>>\n\nexport type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom\n ? TTo\n : string extends TTo\n ? TFrom\n : undefined extends TTo\n ? TFrom\n : TTo extends string\n ? TFrom extends string\n ? TTo extends `/${string}`\n ? TTo\n : TTo extends `..${string}`\n ? ResolveParentPath<TFrom, TTo>\n : TTo extends `.${string}`\n ? ResolveCurrentPath<TFrom, TTo>\n : AddLeadingSlash<JoinPath<TFrom, TTo>>\n : never\n : never\n\nexport type FindDescendantToPaths<\n TRouter extends AnyRouter,\n TPrefix extends string,\n> = `${TPrefix}/${string}` & RouteToPath<TRouter>\n\nexport type InferDescendantToPaths<\n TRouter extends AnyRouter,\n TPrefix extends string,\n TPaths = FindDescendantToPaths<TRouter, TPrefix>,\n> = TPaths extends `${TPrefix}/`\n ? never\n : TPaths extends `${TPrefix}/${infer TRest}`\n ? TRest\n : never\n\nexport type RelativeToPath<\n TRouter extends AnyRouter,\n TTo extends string,\n TResolvedPath extends string,\n> =\n | (TResolvedPath & RouteToPath<TRouter> extends never\n ? never\n : ToPath<TRouter, TTo>)\n | `${RemoveTrailingSlashes<TTo>}/${InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TResolvedPath>>}`\n\nexport type RelativeToParentPath<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,\n> =\n | RelativeToPath<TRouter, TTo, TResolvedPath>\n | (TTo extends `${string}..` | `${string}../`\n ? TResolvedPath extends '/' | ''\n ? never\n : FindDescendantToPaths<\n TRouter,\n RemoveTrailingSlashes<TResolvedPath>\n > extends never\n ? never\n : `${RemoveTrailingSlashes<TTo>}/${ParentPath<TRouter>}`\n : never)\n\nexport type RelativeToCurrentPath<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,\n> = RelativeToPath<TRouter, TTo, TResolvedPath> | CurrentPath<TRouter>\n\nexport type AbsoluteToPath<TRouter extends AnyRouter, TFrom extends string> =\n | (string extends TFrom\n ? CurrentPath<TRouter>\n : TFrom extends `/`\n ? never\n : CurrentPath<TRouter>)\n | (string extends TFrom\n ? ParentPath<TRouter>\n : TFrom extends `/`\n ? never\n : ParentPath<TRouter>)\n | RouteToPath<TRouter>\n | (TFrom extends '/'\n ? never\n : string extends TFrom\n ? never\n : InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TFrom>>)\n\nexport type RelativeToPathAutoComplete<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n> = string extends TTo\n ? string\n : string extends TFrom\n ? AbsoluteToPath<TRouter, TFrom>\n : TTo & `..${string}` extends never\n ? TTo & `.${string}` extends never\n ? AbsoluteToPath<TRouter, TFrom>\n : RelativeToCurrentPath<TRouter, TFrom, TTo>\n : RelativeToParentPath<TRouter, TFrom, TTo>\n\nexport type NavigateOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & NavigateOptionProps\n\n/**\n * The NavigateOptions type is used to describe the options that can be used when describing a navigation action in TanStack Router.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType)\n */\nexport interface NavigateOptionProps {\n /**\n * If set to `true`, the router will scroll the element with an id matching the hash into view with default `ScrollIntoViewOptions`.\n * If set to `false`, the router will not scroll the element with an id matching the hash into view.\n * If set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options.\n * @default true\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#hashscrollintoview)\n * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)\n */\n hashScrollIntoView?: boolean | ScrollIntoViewOptions\n /**\n * `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#replace)\n */\n replace?: boolean\n /**\n * Defaults to `true` so that the scroll position will be reset to 0,0 after the location is committed to the browser history.\n * If `false`, the scroll position will not be reset to 0,0 after the location is committed to history.\n * @default true\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#resetscroll)\n */\n resetScroll?: boolean\n /** @deprecated All navigations now use startTransition under the hood */\n startTransition?: boolean\n /**\n * If set to `true`, the router will wrap the resulting navigation in a `document.startViewTransition()` call.\n * If `ViewTransitionOptions`, route navigations will be called using `document.startViewTransition({update, types})`\n * where `types` will be the strings array passed with `ViewTransitionOptions[\"types\"]`.\n * If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed.\n *\n * If the browser does not support this api, this option will be ignored.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#viewtransition)\n * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)\n * @see [Google](https://developer.chrome.com/docs/web-platform/view-transitions/same-document#view-transition-types)\n */\n viewTransition?: boolean | ViewTransitionOptions\n /**\n * If `true`, navigation will ignore any blockers that might prevent it.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#ignoreblocker)\n */\n ignoreBlocker?: boolean\n /**\n * If `true`, navigation to a route inside of router will trigger a full page load instead of the traditional SPA navigation.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#reloaddocument)\n */\n reloadDocument?: boolean\n /**\n * This can be used instead of `to` to navigate to a fully built href, e.g. pointing to an external target.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n href?: string\n /** @internal */\n publicHref?: string\n}\n\nexport type ToOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ToSubOptions<TRouter, TFrom, TTo> & MaskOptions<TRouter, TMaskFrom, TMaskTo>\n\nexport interface MaskOptions<\n in out TRouter extends AnyRouter,\n in out TMaskFrom extends string,\n in out TMaskTo extends string,\n> {\n _fromLocation?: ParsedLocation\n mask?: ToMaskOptions<TRouter, TMaskFrom, TMaskTo>\n}\n\nexport type ToMaskOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TMaskFrom extends string = string,\n TMaskTo extends string = '.',\n> = ToSubOptions<TRouter, TMaskFrom, TMaskTo> & {\n unmaskOnReload?: boolean\n}\n\nexport type ToSubOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n SearchParamOptions<TRouter, TFrom, TTo> &\n PathParamOptions<TRouter, TFrom, TTo>\n\nexport interface RequiredToOptions<\n in out TRouter extends AnyRouter,\n in out TFrom extends string,\n in out TTo extends string | undefined,\n> {\n /**\n * The internal route path to navigate to. This should be a relative or absolute path within your application.\n * For external URLs, use the `href` property instead.\n * @example \"/dashboard\" or \"../profile\"\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n to: ToPathOption<TRouter, TFrom, TTo> & {}\n}\n\nexport interface OptionalToOptions<\n in out TRouter extends AnyRouter,\n in out TFrom extends string,\n in out TTo extends string | undefined,\n> {\n /**\n * The internal route path to navigate to. This should be a relative or absolute path within your application.\n * For external URLs, use the `href` property instead.\n * @example \"/dashboard\" or \"../profile\"\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n to?: ToPathOption<TRouter, TFrom, TTo> & {}\n}\n\nexport type MakeToRequired<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string | undefined,\n> = string extends TFrom\n ? string extends TTo\n ? OptionalToOptions<TRouter, TFrom, TTo>\n : TTo & CatchAllPaths<TRouter> extends never\n ? RequiredToOptions<TRouter, TFrom, TTo>\n : OptionalToOptions<TRouter, TFrom, TTo>\n : OptionalToOptions<TRouter, TFrom, TTo>\n\nexport type ToSubOptionsProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n> = MakeToRequired<TRouter, TFrom, TTo> & {\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>\n from?: FromPathOption<TRouter, TFrom> & {}\n unsafeRelative?: 'path'\n}\n\nexport type ParamsReducerFn<\n in out TRouter extends AnyRouter,\n in out TParamVariant extends ParamVariant,\n in out TFrom,\n in out TTo,\n> = (\n current: Expand<ResolveFromParams<TRouter, TParamVariant, TFrom>>,\n) => Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>\n\ntype ParamsReducer<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n | Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>\n | (ParamsReducerFn<TRouter, TParamVariant, TFrom, TTo> & {})\n\ntype ParamVariant = 'PATH' | 'SEARCH'\n\nexport type ResolveRoute<\n TRouter extends AnyRouter,\n TFrom,\n TTo,\n TPath = ResolveRelativePath<TFrom, TTo>,\n> = TPath extends string\n ? TFrom extends TPath\n ? RouteByPath<TRouter['routeTree'], TPath>\n : RouteByToPath<TRouter, TPath>\n : never\n\ntype ResolveFromParamType<TParamVariant extends ParamVariant> =\n TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema'\n\ntype ResolveFromAllParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n> = TParamVariant extends 'PATH'\n ? AllParams<TRouter['routeTree']>\n : FullSearchSchema<TRouter['routeTree']>\n\ntype ResolveFromParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n> = string extends TFrom\n ? ResolveFromAllParams<TRouter, TParamVariant>\n : RouteByPath<\n TRouter['routeTree'],\n TFrom\n >['types'][ResolveFromParamType<TParamVariant>]\n\ntype ResolveToParamType<TParamVariant extends ParamVariant> =\n TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput'\n\ntype ResolveAllToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n> = TParamVariant extends 'PATH'\n ? AllParams<TRouter['routeTree']>\n : FullSearchSchemaInput<TRouter['routeTree']>\n\nexport type ResolveToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n ResolveRelativePath<TFrom, TTo> extends infer TPath\n ? undefined extends TPath\n ? never\n : string extends TPath\n ? ResolveAllToParams<TRouter, TParamVariant>\n : TPath extends CatchAllPaths<TRouter>\n ? ResolveAllToParams<TRouter, TParamVariant>\n : ResolveRoute<\n TRouter,\n TFrom,\n TTo\n >['types'][ResolveToParamType<TParamVariant>]\n : never\n\ntype ResolveRelativeToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n TToParams = ResolveToParams<TRouter, TParamVariant, TFrom, TTo>,\n> = TParamVariant extends 'SEARCH'\n ? TToParams\n : string extends TFrom\n ? TToParams\n : MakeDifferenceOptional<\n ResolveFromParams<TRouter, TParamVariant, TFrom>,\n TToParams\n >\n\nexport interface MakeOptionalSearchParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n search?: true | (ParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {})\n}\n\nexport interface MakeOptionalPathParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n params?: true | (ParamsReducer<TRouter, 'PATH', TFrom, TTo> & {})\n}\n\ntype MakeRequiredParamsReducer<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n | (string extends TFrom\n ? never\n : ResolveFromParams<\n TRouter,\n TParamVariant,\n TFrom\n > extends ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>\n ? true\n : never)\n | (ParamsReducer<TRouter, TParamVariant, TFrom, TTo> & {})\n\nexport interface MakeRequiredPathParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n params: MakeRequiredParamsReducer<TRouter, 'PATH', TFrom, TTo> & {}\n}\n\nexport interface MakeRequiredSearchParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n search: MakeRequiredParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {}\n}\n\nexport type IsRequired<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n ResolveRelativePath<TFrom, TTo> extends infer TPath\n ? undefined extends TPath\n ? never\n : TPath extends CatchAllPaths<TRouter>\n ? never\n : IsRequiredParams<\n ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>\n >\n : never\n\nexport type SearchParamOptions<TRouter extends AnyRouter, TFrom, TTo> =\n IsRequired<TRouter, 'SEARCH', TFrom, TTo> extends never\n ? MakeOptionalSearchParams<TRouter, TFrom, TTo>\n : MakeRequiredSearchParams<TRouter, TFrom, TTo>\n\nexport type PathParamOptions<TRouter extends AnyRouter, TFrom, TTo> =\n IsRequired<TRouter, 'PATH', TFrom, TTo> extends never\n ? MakeOptionalPathParams<TRouter, TFrom, TTo>\n : MakeRequiredPathParams<TRouter, TFrom, TTo>\n\nexport type ToPathOption<\n TRouter extends AnyRouter = AnyRouter,\n TFrom extends string = string,\n TTo extends string | undefined = string,\n> = ConstrainLiteral<\n TTo,\n RelativeToPathAutoComplete<\n TRouter,\n NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',\n NoInfer<TTo> & string\n >\n>\n\nexport type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<\n TFrom,\n RoutePaths<TRouter['routeTree']>\n>\n\n/**\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options)\n */\nexport interface ActiveOptions {\n /**\n * If true, the link will be active if the current route matches the `to` route path exactly (no children routes)\n * @default false\n */\n exact?: boolean\n /**\n * If true, the link will only be active if the current URL hash matches the `hash` prop\n * @default false\n */\n includeHash?: boolean\n /**\n * If true, the link will only be active if the current URL search params inclusively match the `search` prop\n * @default true\n */\n includeSearch?: boolean\n /**\n * This modifies the `includeSearch` behavior.\n * If true, properties in `search` that are explicitly `undefined` must NOT be present in the current URL search params for the link to be active.\n * @default false\n */\n explicitUndefined?: boolean\n}\n\nexport interface LinkOptionsProps {\n /**\n * The standard anchor tag target attribute\n */\n target?: HTMLAnchorElement['target']\n /**\n * Configurable options to determine if the link should be considered active or not\n * @default {exact:true,includeHash:true}\n */\n activeOptions?: ActiveOptions\n /**\n * The preloading strategy for this link\n * - `false` - No preloading\n * - `'intent'` - Preload the linked route when the user focuses, hovers over, or touches the link\n * - `'viewport'` - Preload the linked route when it enters the viewport\n * - `'render'` - Preload the linked route as soon as it renders\n */\n preload?: false | 'intent' | 'viewport' | 'render'\n /**\n * When the intent preload strategy is set, this delays focus and hover\n * preloading by this many milliseconds. Touch intent preloads immediately.\n * If focus or hover exits before this delay, the preload will be cancelled.\n */\n preloadDelay?: number\n /**\n * Control whether the link should be disabled or not\n * If set to `true`, the link will be rendered without an `href` attribute\n * @default false\n */\n disabled?: boolean\n /**\n * When the preload strategy is set to `intent`, this controls the proximity of the link to the cursor before it is preloaded.\n * If the user exits this proximity before this delay, the preload will be cancelled.\n */\n preloadIntentProximity?: number\n}\n\nexport type LinkOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkOptionsProps\n\nexport const preloadWarning = 'Error preloading route! ☝️'\n"],"mappings":";AAisBA,MAAa,iBAAiB"}

@@ -198,9 +198,11 @@ import { HistoryState, ParsedHistoryState } from '@tanstack/history';

* - `false` - No preloading
* - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
* - `'intent'` - Preload the linked route when the user focuses, hovers over, or touches the link
* - `'viewport'` - Preload the linked route when it enters the viewport
* - `'render'` - Preload the linked route as soon as it renders
*/
preload?: false | 'intent' | 'viewport' | 'render';
/**
* When a preload strategy is set, this delays the preload by this many milliseconds.
* If the user exits the link before this delay, the preload will be cancelled.
* When the intent preload strategy is set, this delays focus and hover
* preloading by this many milliseconds. Touch intent preloads immediately.
* If focus or hover exits before this delay, the preload will be cancelled.
*/

@@ -207,0 +209,0 @@ preloadDelay?: number;

@@ -1,2 +0,1 @@

const require_utils = require("./utils.cjs");
const require_not_found = require("./not-found.cjs");

@@ -14,10 +13,12 @@ const require_redirect = require("./redirect.cjs");

}
function loadComponents(route) {
function loadComponents(route, onPendingReady) {
const component = preloadComponent(route, "component");
const pending = preloadComponent(route, "pendingComponent");
if (component && pending) return Promise.all([component, pending]).then(() => {});
return component ?? pending;
const pendingReady = onPendingReady && pending ? pending.then(onPendingReady) : pending;
if (onPendingReady && !pending) onPendingReady();
if (component && pendingReady) return Promise.all([component, pendingReady]).then(() => {});
return component ?? pendingReady;
}
function loadRouteChunk(route, componentType) {
const afterLazy = () => componentType === false ? void 0 : componentType ? preloadComponent(route, componentType) : loadComponents(route);
function loadRouteChunk(route, componentType, onPendingReady) {
const afterLazy = () => componentType === false ? void 0 : componentType ? preloadComponent(route, componentType) : loadComponents(route, onPendingReady);
const current = route._lazy;

@@ -111,3 +112,3 @@ if (current) return current === true ? afterLazy() : current.then(afterLazy);

}
async function contextualize(router, lane, options, end) {
async function contextualize(router, lane, options, end, planSuccessfulLane) {
const [location, matches] = lane;

@@ -193,6 +194,11 @@ const signal = options[0].signal;

}
planSuccessfulLane();
}
function releaseOwnedFlight(router, id, flight) {
function releaseOwnedFlight(router, match, flight) {
if (!flight || --flight[2]) return;
if (router._flights?.get(id) === flight) router._flights.delete(id);
if (router._flights?.get(match.id) === flight) {
const current = router._tx;
if (current && !current[0].signal.aborted && !(process.env.NODE_ENV !== "production" && current[6]) && !current[3].includes(match) && current[3].some((candidate) => candidate.id === match.id) && current[3].some((candidate) => candidate.isFetching === "beforeLoad")) return;
router._flights.delete(match.id);
}
return flight[1];

@@ -203,23 +209,4 @@ }

match._flight = void 0;
releaseOwnedFlight(router, match.id, flight)?.abort();
releaseOwnedFlight(router, match, flight)?.abort();
}
function laneInputs(router, location) {
const masked = location.maskedLocation;
return [
router.routeTree,
router.options.context ?? {},
router.options.additionalContext,
require_router._getUserHistoryState(location.state),
location.search,
masked && [
masked.href,
require_router._getUserHistoryState(masked.state),
masked.search,
masked.unmaskOnReload
]
];
}
function samePreloadLane(preload, router, location, redirects) {
return preload[3] === router._committed && preload[5] === redirects && require_utils.deepEqual(preload[4], laneInputs(router, location)) && !preload[0].some((match) => getRoute(router, match).options.preload === false);
}
/**

@@ -234,3 +221,3 @@ * Not passing in a `next` ownership recipient

match._flight = void 0;
const controller = releaseOwnedFlight(router, match.id, flight);
const controller = releaseOwnedFlight(router, match, flight);
if (controller) abort.push(controller);

@@ -240,6 +227,23 @@ }

}
function discardPreload(router, preload) {
preload[1].abort();
transferMatchResources(router, preload[0]);
function transferPredecessorResources(router, previous, next) {
const abort = [];
for (const match of previous) if (!next.includes(match)) {
const flight = match._flight;
match._flight = void 0;
if (flight?.[2] === 1 && router._flights?.get(match.id) === flight && !(process.env.NODE_ENV !== "production" && router._tx?.[6]) && next.some((candidate) => candidate.id === match.id)) flight[2] = 0;
else {
const controller = releaseOwnedFlight(router, match, flight);
if (controller) abort.push(controller);
}
}
for (const controller of abort) controller.abort();
}
function releaseUnownedFlights(router) {
const abort = [];
for (const [id, flight] of router._flights ?? []) if (!flight[2]) {
router._flights.delete(id);
abort.push(flight[1]);
}
for (const controller of abort) controller.abort();
}
function acquireMatchResources(matches) {

@@ -282,34 +286,26 @@ for (const match of matches) {

let flight = match._flight;
let joined = !!flight;
setFetching(router, match, "loader", owner);
try {
for (;;) {
if (!flight) {
const controller = new AbortController();
flight = [
Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, controller, parentMatchPromise, preload))).then((value) => normalize(value, false, route.id), (cause) => normalize(cause, true, route.id)).then((result) => {
return result[0] === ERROR && match._flight === flight ? normalizeError(route, result[1]) : result;
}),
controller,
1
];
(router._flights ??= /* @__PURE__ */ new Map()).set(match.id, flight);
}
match._flight = flight;
match.abortController = flight[1];
try {
const outcome = await waitFor(flight[0], signal);
if (!joined || outcome[0] === SUCCESS || outcome[0] === REDIRECTED) return outcome;
} catch (cause) {
if (cause === signal) {
releaseFlight(router, match);
return [CANCELED];
}
throw cause;
}
releaseFlight(router, match);
if (signal.aborted) return [CANCELED];
flight = void 0;
joined = false;
if (!flight) {
const controller = new AbortController();
flight = [
Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, controller, parentMatchPromise, preload))).then((value) => normalize(value, false, route.id), (cause) => normalize(cause, true, route.id)).then((result) => {
if (result[0] !== SUCCESS && router._flights?.get(match.id) === flight) {
router._flights.delete(match.id);
if (!flight[2]) controller.abort();
}
return result[0] === ERROR && flight[2] ? normalizeError(route, result[1]) : result;
}),
controller,
1
];
(router._flights ??= /* @__PURE__ */ new Map()).set(match.id, flight);
}
match._flight = flight;
match.abortController = flight[1];
return await waitFor(flight[0], signal);
} catch (cause) {
if (cause !== signal) throw cause;
releaseFlight(router, match);
return [CANCELED];
} finally {

@@ -359,6 +355,6 @@ setFetching(router, match, false, owner);

const plannedCacheMatch = preload ? router._cache.get(match.id) : void 0;
let configured;
let reload = false;
let reloadFailure;
try {
let configured;
if (match.status === "success") {

@@ -384,5 +380,10 @@ configured = route.options.shouldReload;

const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
let donor = (!preload || route.options.preload !== false) && routeLoader && !(process.env.NODE_ENV !== "production" && router._tx?.[6]) ? router._flights?.get(match.id) : void 0;
if (donor === match._flight || reloadFailure) donor = void 0;
else if (donor && !reload && !preload && configured === void 0) reload = true;
else if (!reload) donor = void 0;
const background = !!(routeLoader && reload && match.status === "success" && !preload && !options[5] && ((typeof routeLoader === "function" ? void 0 : routeLoader?.staleReloadMode) ?? router.options.defaultStaleReloadMode) !== "blocking");
const loaded = reload && (!preload || route.options.preload !== false);
const blocking = loaded && !background && (match.status !== "success" || !!routeLoader);
const onLazyReady = route.lazyFn && route._lazy !== true ? options[8] : void 0;
if (loaded && !routeLoader) {

@@ -392,9 +393,7 @@ match.invalid = false;

}
let donor = loaded && routeLoader ? router._flights?.get(match.id) : void 0;
if (donor === match._flight) donor = void 0;
else if (donor) donor[2]++;
if (donor) donor[2]++;
if (blocking) {
const acceptedFlight = match._flight;
match._flight = donor;
releaseOwnedFlight(router, match.id, acceptedFlight)?.abort();
releaseOwnedFlight(router, match, acceptedFlight)?.abort();
if (match.status === "success") match.status = "pending";

@@ -408,3 +407,3 @@ options[8]?.();

if (result[0] === SUCCESS) {
if (preload && routeLoader) cacheLoaderMatch(router, match, plannedCacheMatch);
if (preload && routeLoader && !options[0].signal.aborted) cacheLoaderMatch(router, match, plannedCacheMatch);
match.status = "pending";

@@ -415,5 +414,3 @@ }

});
const chunkFailure = waitFor(Promise.resolve().then(() => loadRouteChunk(route)), options[0].signal).then(() => {
options[8]?.();
}, (cause) => [index, normalizeLaneError(route, cause, options)]).then((failure) => outcome.then((result) => {
const chunkFailure = waitFor(Promise.resolve().then(() => loadRouteChunk(route, void 0, onLazyReady)), options[0].signal).then(() => void 0, (cause) => [index, normalizeLaneError(route, cause, options)]).then((failure) => outcome.then((result) => {
if (blocking && !failure && result[0] === SUCCESS && match.status === "pending" && options[2]()) {

@@ -618,16 +615,22 @@ match.status = "success";

let end = plannedBoundary < 0 ? matches.length : plannedBoundary + 1;
const failure = await contextualize(router, matched, options, end);
if (failure) options[5] = true;
const tasks = [];
const start = options[7] ?? 0;
let semanticParent = start ? Promise.resolve(matched[1][start - 1]) : void 0;
end = failure?.[0] ?? end;
if (failure?.[1][0] === NOT_FOUND) {
failure[2] = await getNotFoundBoundary(router, matched[1], failure, options[0].signal);
end = Math.min(end, failure[2] + 1);
} else if ((failure?.[1][0] ?? 0) >= REDIRECTED) end = 0;
for (let index = start; index < end; index++) {
if (options[0].signal.aborted) break;
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options);
const planSuccessfulLane = () => {
for (let index = start; index < end; index++) {
if (options[0].signal.aborted) break;
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options);
}
};
const failure = await contextualize(router, matched, options, end, planSuccessfulLane);
if (failure) {
options[5] = true;
end = failure[0];
if (failure[1][0] === NOT_FOUND) {
failure[2] = await getNotFoundBoundary(router, matched[1], failure, options[0].signal);
end = Math.min(end, failure[2] + 1);
} else if (failure[1][0] >= REDIRECTED) end = 0;
planSuccessfulLane();
}
if (options[2]() && !options[4]) releaseUnownedFlights(router);
let reduced;

@@ -722,3 +725,3 @@ try {

offered[boundary].status = "pending";
const ack = router.startTransition(() => router.stores.setMatches(offered), offered, true).then((rendered) => {
const ack = router.startTransition(() => router.stores.setMatches(offered), offered).then((rendered) => {
if (rendered && router._pending === session && session[4] === ack && !session[2]) session[2] = Date.now() + min;

@@ -820,5 +823,6 @@ return rendered;

async function transitionRefresh(router, tx, lane, changeInfo) {
const refresh = tx[6];
const checkpoint = {
previousMatches: router._committed,
previousPresentation: tx[6]?.[0] ?? router.stores.matches.get(),
previousPresentation: refresh[0],
previousCache: router._cache,

@@ -830,3 +834,3 @@ commitPromise: router._commitPromise,

finishPending(router, tx);
router._rollbackRefresh = rollback;
refresh[2] = rollback;
commitRefreshMatches(router, tx, lane[1], checkpoint);

@@ -844,3 +848,3 @@ if (!checkpoint.published || router._tx !== tx) return;

const rollback = () => {
if (router._rollbackRefresh === rollback) router._rollbackRefresh = void 0;
if (refresh[2] === rollback) refresh[2] = void 0;
const restored = rollbackPublication(router, tx, lane, checkpoint);

@@ -852,5 +856,5 @@ router._cancelTransition?.();

const rendered = await router.startTransition(commit, lane[1]);
if (router._rollbackRefresh === rollback) router._rollbackRefresh = void 0;
if (refresh[2] === rollback) refresh[2] = void 0;
if (checkpoint.published) {
const handoff = tx[6]?.[1];
const handoff = refresh[1];
if (handoff && router._handoff === handoff) handoff[1]();

@@ -932,3 +936,3 @@ if (router._tx === tx) tx[6] = void 0;

}
async function runClientTransaction(router, tx, forceStaleReload, onReady, sync, resolvedPrefix, adopted, retained) {
async function runClientTransaction(router, tx, forceStaleReload, onReady, sync, resolvedPrefix) {
const options = [

@@ -945,20 +949,3 @@ tx[0],

];
let result;
try {
result = adopted ? await adopted[2] : await executeClientLane(router, tx[2], tx[3], options);
} finally {
if (retained) discardPreload(router, retained);
}
if (adopted && router._tx === tx && (isControl(result) && result[0] === CANCELED || !isControl(result) && result[1].some((match) => match.status !== "success" || match._notFound))) {
const donors = tx[3];
tx[3] = [];
transferMatchResources(router, donors);
tx[0].abort();
if (router._tx !== tx) return;
const controller = new AbortController();
tx[0] = options[0] = controller;
tx[3] = router.matchRoutes(tx[2], { _controller: controller });
acquireMatchResources(tx[3]);
result = await executeClientLane(router, tx[2], tx[3], options);
}
const result = await executeClientLane(router, tx[2], tx[3], options);
if (isControl(result)) {

@@ -1059,3 +1046,3 @@ if (result[0] === REDIRECTED && router._tx === tx) {

if (process.env.NODE_ENV !== "production") {
router._rollbackRefresh?.();
router._tx?.[6]?.[2]?.();
rematerialize = !!router._refreshNextLoad || !!router._tx?.[6];

@@ -1070,6 +1057,2 @@ }

const redirects = pendingLocation?.href === location.href ? pendingLocation._redirects ?? 0 : 0;
if (opts?._dedupe && !redirects && previousOwner && !rematerialize && previousOwner[2].href === location.href && router.stores.status.get() === "pending") {
await awaitCurrent(router);
return;
}
const handoff = router._handoff;

@@ -1082,3 +1065,3 @@ const hydrationController = rematerialize ? void 0 : handoff?.[0]();

previousPreflight?.abort();
if (preflight.signal.aborted || router._tx !== previousOwner) {
if (preflight.signal.aborted) {
await awaitCurrent(router, previousOwner);

@@ -1092,8 +1075,7 @@ return;

});
if (!preflight.signal.aborted && router._tx === previousOwner) router.emit({
if (!preflight.signal.aborted) router.emit({
type: "onBeforeLoad",
...changeInfo
});
if (preflight.signal.aborted || router._tx !== previousOwner) {
preflight.abort();
if (preflight.signal.aborted) {
await awaitCurrent(router, previousOwner);

@@ -1103,57 +1085,31 @@ return;

const sameHref = previousLocation.href === location.href;
let adopted = router._preloads?.get(location.href);
let retained;
if (rematerialize && adopted) {
router._preloads.delete(location.href);
discardPreload(router, adopted);
adopted = void 0;
if (preflight.signal.aborted || router._tx !== previousOwner) {
preflight.abort();
await awaitCurrent(router, previousOwner);
return;
}
}
if (adopted && (hydrationController || !samePreloadLane(adopted, router, pendingLocation?.href === location.href ? pendingLocation : location, redirects))) {
router._preloads.delete(location.href);
retained = adopted;
adopted = void 0;
}
let matches;
let controller = preflight;
let resolvedPrefix;
if (adopted) {
controller = adopted[1];
matches = adopted[0];
router._preloads.delete(location.href);
} else {
try {
matches = process.env.NODE_ENV !== "production" && rematerialize ? router.matchRoutes(location, {
_controller: preflight,
_rematerialize: true
}) : router.matchRoutes(location, { _controller: preflight });
acquireMatchResources(matches);
} catch (cause) {
preflight.abort();
if (retained) discardPreload(router, retained);
if (!require_redirect.isRedirect(cause)) {
if (process.env.NODE_ENV !== "production" && rematerialize) router._refreshNextLoad = void 0;
await awaitCurrent(router);
router._commitPromise?.resolve();
router._commitPromise = void 0;
return;
}
await router.navigate({
...cause.options,
replace: true,
ignoreBlocker: true
});
await awaitCurrent(router, previousOwner);
try {
matches = process.env.NODE_ENV !== "production" && rematerialize ? router.matchRoutes(location, {
_controller: preflight,
_rematerialize: true
}) : router.matchRoutes(location, { _controller: preflight });
acquireMatchResources(matches);
} catch (cause) {
preflight.abort();
if (!require_redirect.isRedirect(cause)) {
if (process.env.NODE_ENV !== "production" && rematerialize) router._refreshNextLoad = void 0;
await awaitCurrent(router);
router._commitPromise?.resolve();
router._commitPromise = void 0;
return;
}
resolvedPrefix = hydrationController ? handoff[1](matches) : void 0;
if (resolvedPrefix) controller = hydrationController;
else hydrationController?.abort();
await router.navigate({
...cause.options,
replace: true,
ignoreBlocker: true
});
await awaitCurrent(router, previousOwner);
return;
}
if (router._preflight !== preflight || router._tx !== previousOwner) {
preflight.abort();
const resolvedPrefix = hydrationController ? handoff[1](matches) : void 0;
if (resolvedPrefix) controller = hydrationController;
else hydrationController?.abort();
if (preflight.signal.aborted) {
transferMatchResources(router, matches);

@@ -1170,3 +1126,3 @@ await awaitCurrent(router, previousOwner);

Date.now(),
Promise.resolve().then(() => runClientTransaction(router, tx, sameHref, () => offerPending(router, tx), opts?.sync, resolvedPrefix, adopted, retained)).catch(() => {
Promise.resolve().then(() => runClientTransaction(router, tx, sameHref, () => offerPending(router, tx), opts?.sync, resolvedPrefix)).catch(() => {
if (router._tx === tx) restoreCommitted(router, tx);

@@ -1180,3 +1136,2 @@ })

router._tx = tx;
if (!rematerialize && router._handoff === handoff) router._handoff = void 0;
if (previousOwner) {

@@ -1188,3 +1143,3 @@ for (const match of router.stores.matches.get()) {

previousOwner[0].abort();
transferMatchResources(router, previousOwner[3]);
transferPredecessorResources(router, previousOwner[3], tx[3]);
}

@@ -1209,3 +1164,3 @@ if (router._tx !== tx) {

async function refreshClientRoute(router) {
router._rollbackRefresh?.();
router._tx?.[6]?.[2]?.();
const pending = router._tx;

@@ -1221,12 +1176,5 @@ if (pending && !pending[6] && router.stores.status.get() === "pending") {

}
function followPreloadRedirect(router, result, location, owner, redirects) {
if (result[0] === REDIRECTED && !result[1].options.reloadDocument && router._tx === owner) return preloadClientRoute(router, {
...result[1].options,
_fromLocation: location
}, redirects + 1);
}
async function preloadClientRoute(router, opts, redirects = 0) {
if (redirects > 20) return;
const owner = router._tx;
if (process.env.NODE_ENV !== "production" && (router._refreshNextLoad || owner?.[6])) return;
if (process.env.NODE_ENV !== "production" && (router._refreshNextLoad || router._tx?.[6])) return;
const location = opts._builtLocation ?? router.buildLocation(opts);

@@ -1236,54 +1184,34 @@ const base = router._committed;

let matches;
let preload;
let replaced;
try {
const pending = router._preloads?.get(location.href);
if (pending) {
if (samePreloadLane(pending, router, location, redirects)) {
const result = await pending[2];
return isControl(result) ? followPreloadRedirect(router, result, location, owner, redirects) : result[1];
}
router._preloads.delete(location.href);
replaced = pending;
}
matches = router.matchRoutes(location, { _controller: controller });
acquireMatchResources(matches);
const promise = Promise.resolve().then(() => executeClientLane(router, location, matches, [
controller,
redirects,
() => true,
base,
true
])).finally(() => {
if (replaced) discardPreload(router, replaced);
});
preload = [
matches,
controller,
promise,
base,
laneInputs(router, location),
redirects
];
(router._preloads ??= /* @__PURE__ */ new Map()).set(location.href, preload);
const result = await promise;
if (router._preloads?.get(location.href) !== preload) return isControl(result) ? void 0 : result[1];
router._preloads.delete(location.href);
if (isControl(result)) {
} catch (cause) {
controller.abort();
if (!require_not_found.isNotFound(cause)) console.error(cause);
return;
}
(router._preloads ??= /* @__PURE__ */ new Map()).set(controller, matches);
let active;
try {
let result;
try {
result = await executeClientLane(router, location, matches, [
controller,
redirects,
() => true,
base,
true
]);
} finally {
active = router._preloads.delete(controller);
transferMatchResources(router, matches);
controller.abort();
transferMatchResources(router, matches);
return followPreloadRedirect(router, result, location, owner, redirects);
}
transferMatchResources(router, result[1]);
controller.abort();
return result[1];
if (!isControl(result)) return result[1];
if (active && result[0] === REDIRECTED && !result[1].options.reloadDocument) return preloadClientRoute(router, {
...result[1].options,
_fromLocation: location
}, redirects + 1);
} catch (cause) {
if (!preload || router._preloads?.get(location.href) === preload) {
if (preload) router._preloads.delete(location.href);
controller.abort();
if (matches) transferMatchResources(router, matches);
}
if (router._tx !== owner) return;
if (!require_not_found.isNotFound(cause)) console.error(cause);
return;
}

@@ -1303,4 +1231,3 @@ }

router.ssr = { manifest: dehydratedRouter.manifest };
const nonce = document.querySelector("meta[property=\"csp-nonce\"]")?.content;
router.options.ssr = { nonce };
router.options.ssr = { nonce: document.querySelector("meta[property=\"csp-nonce\"]")?.content };
const dehydratedMatches = dehydratedRouter.matches;

@@ -1311,21 +1238,20 @@ const controller = new AbortController();

previousPreflight?.abort();
const retire = (cause) => {
if (router._preflight === controller) router._preflight = void 0;
controller.abort(cause);
return false;
};
const isCurrent = () => !router._tx && router._preflight === controller && !controller.signal.aborted || retire();
const isCurrent = () => router._preflight === controller;
let location;
let candidates;
let handoffInputs;
let handoffHistoryHref;
let handoffHistoryState;
try {
await waitFor(router.options.hydrate?.(dehydratedRouter.dehydratedData), controller.signal);
if (!isCurrent()) return;
const historyLocation = router.history.location;
handoffHistoryHref = historyLocation.href;
handoffHistoryState = historyLocation.state;
router.updateLatestLocation();
location = router.latestLocation;
router.stores.location.set(location);
handoffInputs = laneInputs(router, location);
candidates = router.matchRoutes(location, { _controller: controller });
} catch (cause) {
retire(cause);
if (isCurrent()) router._preflight = void 0;
controller.abort(cause);
if (cause !== controller.signal) throw cause;

@@ -1379,3 +1305,2 @@ }

}
let verifiedContextEnd = verifiedAssetEnd;
if (!isTerminal && committed.length === shared && shared < candidates.length) pendingBoundary = shared;

@@ -1396,11 +1321,7 @@ const chunks = committed.map(async (match) => {

} catch {
isCurrent();
return;
}
if (!isCurrent()) return;
if (chunkFailure < committed.length) {
verifiedContextEnd = Math.min(verifiedContextEnd, chunkFailure);
retryFrom(chunkFailure);
}
const contextEnd = Math.max(pendingBoundary === committed.length ? committed.length + 1 : committed.length, verifiedContextEnd);
if (chunkFailure < committed.length) retryFrom(chunkFailure);
const contextEnd = Math.max(pendingBoundary === committed.length ? committed.length + 1 : committed.length, chunkFailure < chunks.length ? chunkFailure : verifiedAssetEnd);
for (let index = 0; index < contextEnd; index++) {

@@ -1449,3 +1370,3 @@ const match = candidates[index];

const boundary = presented[pendingBoundary];
dataOnlyAssetEnd = boundary.status === "success" && boundary.ssr === "data-only" && boundary.error === void 0 && !boundary._notFound && verifiedAssetEnd > pendingBoundary + 1 ? verifiedAssetEnd : void 0;
dataOnlyAssetEnd = boundary.ssr === "data-only" && verifiedAssetEnd > pendingBoundary + 1 ? verifiedAssetEnd : void 0;
presented = presented.slice();

@@ -1459,8 +1380,11 @@ presented[pendingBoundary] = {

}
const claim = () => needsClientLoad && !router._tx && router.latestLocation.state === location.state && require_utils.deepEqual(handoffInputs, laneInputs(router, router.latestLocation)) && router._committed === committedMatches && committedMatches.length && !controller.signal.aborted ? controller : void 0;
const claim = () => {
const historyLocation = router.history.location;
return needsClientLoad && !router._tx && historyLocation.href === handoffHistoryHref && historyLocation.state === handoffHistoryState && router._committed === committedMatches && committedMatches.length && !controller.signal.aborted ? controller : void 0;
};
const handoff = [claim, (matches) => {
if (router._handoff !== handoff) return;
router._handoff = void 0;
const prefix = committedMatches.length;
if (!matches || !claim() || committedMatches.some((match, index) => match.id !== matches[index]?.id)) {
router._handoff = void 0;
controller.abort();

@@ -1472,3 +1396,3 @@ return;

for (let index = prefix; index < handoffAssetEnd; index++) if (candidates[index]?.id !== matches[index]?.id) {
handoffAssetEnd = index > (pendingBoundary ?? -1) + 1 ? index : void 0;
handoffAssetEnd = index > pendingBoundary + 1 ? index : void 0;
break;

@@ -1506,4 +1430,3 @@ }

exports.replaceRouteChunk = replaceRouteChunk;
exports.transferMatchResources = transferMatchResources;
//# sourceMappingURL=load-client.cjs.map

@@ -10,3 +10,3 @@ import { GLOBAL_SEROVAL, GLOBAL_TSR } from './ssr/constants.cjs';

export declare function replaceRouteChunk(route: AnyRoute, lazyFn: AnyRoute['lazyFn']): void;
export declare function loadRouteChunk(route: AnyRoute, componentType?: 'errorComponent' | 'notFoundComponent' | false): Promise<void> | undefined;
export declare function loadRouteChunk(route: AnyRoute, componentType?: 'errorComponent' | 'notFoundComponent' | false, onPendingReady?: () => void): Promise<void> | undefined;
/** Return the structural lane through the first terminal render boundary. */

@@ -41,3 +41,3 @@ export declare function _getRenderedMatches(matches: Array<AnyRouteMatch>): Array<AnyRouteMatch>;

declare const CANCELED = 4;
type LoaderOutcome = [typeof SUCCESS, data: unknown] | [typeof ERROR, error: unknown] | [typeof NOT_FOUND, error: NotFoundError] | [typeof REDIRECTED, redirect: AnyRedirect] | [typeof CANCELED];
type LoaderOutcome = [kind: typeof SUCCESS, data: unknown] | [kind: typeof ERROR, error: unknown] | [kind: typeof NOT_FOUND, error: NotFoundError] | [kind: typeof REDIRECTED, redirect: AnyRedirect] | [kind: typeof CANCELED];
type IndexedOutcome = [index: number, outcome: LoaderOutcome, boundary?: number];

@@ -63,23 +63,2 @@ export type LoaderFlight = [

};
export type LaneInputs = [
routeTree: AnyRoute,
context: unknown,
additionalContext: unknown,
state: object,
search: object,
maskedLocation: [
href: string,
state: object,
search: object,
unmaskOnReload: boolean | undefined
] | undefined
];
export type ActivePreload = [
matches: Array<AnyRouteMatch>,
controller: AbortController,
result: Promise<LaneResult>,
semanticOwner: Array<AnyRouteMatch>,
inputs: LaneInputs,
redirects: number
];
export type LoadTransaction = [

@@ -94,8 +73,10 @@ controller: AbortController,

* Dev-only HMR refresh mode. Presence is the mode flag; a refresh always
* carries the presentation it started from, while the hydration handoff is
* genuinely optional — the tuple makes a half-armed refresh unrepresentable.
* carries the presentation it started from and its optional hydration
* handoff. While a publication awaits acknowledgement, its rollback lives
* with the transaction that owns the publication.
*/
refresh?: [
presentation: Array<AnyRouteMatch>,
handoff: NonNullable<AnyRouter['_handoff']> | undefined
handoff: NonNullable<AnyRouter['_handoff']> | undefined,
rollback?: () => boolean
]

@@ -113,6 +94,5 @@ ];

type CoordinatorRouter = AnyRouter & {
/** Whole speculative lanes that a matching navigation may adopt. */
_preloads?: Map<string, ActivePreload>;
/** Active speculative lanes retained for cancellation, invalidation, and cache clearing. */
_preloads?: Map<AbortController, Array<AnyRouteMatch>>;
_refreshNextLoad?: boolean;
_rollbackRefresh?: () => void;
_cancelTransition?: () => void;

@@ -123,16 +103,8 @@ };

outcome: Promise<LoaderOutcome>,
ready: Promise<IndexedOutcome | undefined>,
chunkFailure: Promise<IndexedOutcome | undefined>,
candidate: WorkMatch
];
type ControlOutcome = [typeof REDIRECTED, redirect: AnyRedirect] | [typeof CANCELED];
type LaneResult = ProjectedLane | ControlOutcome;
export declare function waitFor<T>(value: T | PromiseLike<T>, signal: AbortSignal): Promise<T>;
export declare function getRoute(router: AnyRouter, match: WorkMatch): AnyRoute;
export declare function navigateFrom(router: AnyRouter, location: ParsedLocation): (opts: any) => Promise<void>;
export declare function laneInputs(router: AnyRouter, location: ParsedLocation): LaneInputs;
/**
* Not passing in a `next` ownership recipient
* is equivalent to discarding the match resources
*/
export declare function transferMatchResources(router: AnyRouter, previous: Array<AnyRouteMatch>, next?: Array<AnyRouteMatch>): void;
export declare function cacheLoaderMatch(router: CoordinatorRouter, match: SettledMatch, planned: AnyRouteMatch | undefined): void;

@@ -142,3 +114,2 @@ export declare function projectLane(router: AnyRouter, lane: ReducedLane, signal: AbortSignal, start?: number, end?: number): Promise<ProjectedLane>;

sync?: boolean;
_dedupe?: boolean;
}): Promise<void>;

@@ -145,0 +116,0 @@ export declare function refreshClientRoute(router: CoordinatorRouter): Promise<void>;

@@ -390,3 +390,3 @@ const require_utils = require("./utils.cjs");

this._commitPromise = commitPromise;
if (isSameLocation) this.load({ _dedupe: true });
if (isSameLocation) this.load();
else {

@@ -522,5 +522,16 @@ let { maskedLocation, hashScrollIntoView, ...nextHistory } = next;

const filter = opts?.filter;
const invalidIds = filter ? new Set([...committedMatches, ...this._cache.values()].filter((match) => filter(match)).map((match) => match.id)) : void 0;
const preloads = this._preloads;
const invalidIds = new Set([
...committedMatches,
...this._cache.values(),
...[...preloads?.values() ?? []].flat(),
...this._tx?.[3] ?? []
].filter((match) => !filter || filter(match)).map((match) => match.id));
const discardedPreloads = [];
for (const [controller, matches] of preloads ?? []) if (matches.some((match) => invalidIds.has(match.id))) {
preloads.delete(controller);
discardedPreloads.push(controller);
}
const invalidate = (d) => {
if (!invalidIds || invalidIds.has(d.id)) {
if (invalidIds.has(d.id)) {
const route = this.routesById[d.routeId];

@@ -540,7 +551,9 @@ const next = {

};
const committed = committedMatches.map(invalidate);
this._committed = committed;
const cache = /* @__PURE__ */ new Map();
for (const [id, match] of this._cache) cache.set(id, invalidate(match));
this._cache = cache;
this._committed = committedMatches.map(invalidate);
for (const [id, match] of this._cache) if (invalidIds.has(id)) {
match.invalid = true;
if (opts?.forcePending) match.status = "pending";
}
for (const id of invalidIds) this._flights?.delete(id);
for (const controller of discardedPreloads) controller.abort();
this.shouldViewTransition = false;

@@ -571,16 +584,24 @@ return this.load({ sync: opts?.sync });

const filter = opts?.filter;
const retained = /* @__PURE__ */ new Map();
const discarded = [];
for (const [id, match] of cached) if (filter && !filter(match)) retained.set(id, match);
else discarded.push(match);
const retainedPreloads = /* @__PURE__ */ new Map();
const discardedPreloads = [];
for (const [href, preload] of preloads ?? []) if (!filter || preload[0].some(filter)) {
discardedPreloads.push(preload);
discarded.push(...preload[0]);
} else retainedPreloads.set(href, preload);
this._cache = retained;
this._preloads = retainedPreloads;
require_load_client.transferMatchResources(this, discarded);
for (const preload of discardedPreloads) preload[1].abort();
const discardedIds = [];
for (const [id, match] of cached) if (!filter || filter(match)) {
discardedIds.push(id);
discarded.push(match);
}
const abort = [];
for (const [controller, matches] of preloads ?? []) if (!filter || matches.some(filter)) {
abort.push(controller);
discarded.push(...matches);
}
for (const id of discardedIds) cached.delete(id);
for (const controller of abort) preloads.delete(controller);
for (const match of discarded) {
const flight = match._flight;
match._flight = void 0;
if (flight && !--flight[2]) {
if (this._flights?.get(match.id) === flight) this._flights.delete(match.id);
abort.push(flight[1]);
}
}
for (const controller of abort) controller.abort();
};

@@ -938,3 +959,2 @@ this.loadRouteChunk = require_load_client.loadRouteChunk;

exports.SearchParamError = SearchParamError;
exports._getUserHistoryState = _getUserHistoryState;
exports.defaultSerializeError = defaultSerializeError;

@@ -941,0 +961,0 @@ exports.getInitialRouterState = getInitialRouterState;

@@ -1,2 +0,1 @@

import { loadRouteChunk, ActivePreload, LoadTransaction, LoaderFlight, PendingSession } from './load-client.cjs';
import { LRUCache } from './lru-cache.cjs';

@@ -6,2 +5,3 @@ import { ProcessRouteTreeResult, ProcessedTree } from './new-process-route-tree.cjs';

import { AnyRedirect, ResolvedRedirect } from './redirect.cjs';
import { LoadTransaction, LoaderFlight, PendingSession } from './load-client.cjs';
import { ServerLoadResult } from './load-server.cjs';

@@ -486,6 +486,5 @@ import { HistoryAction, HistoryLocation, HistoryState, ParsedHistoryState, RouterHistory } from '@tanstack/history';

_signal?: AbortSignal;
_dedupe?: boolean;
}) => Promise<void>;
export type CommitLocationFn = ({ viewTransition, ignoreBlocker, ...next }: ParsedLocation & CommitLocationOptions) => Promise<void>;
export type StartTransitionFn = (fn: () => void, expected: Array<AnyRouteMatch>, urgent?: boolean) => Promise<boolean>;
export type StartTransitionFn = (fn: () => void, expected: Array<AnyRouteMatch>) => Promise<boolean>;
export interface MatchRoutesFn {

@@ -607,4 +606,4 @@ (pathname: string, locationSearch?: AnySchema, opts?: MatchRoutesOpts): Array<MakeRouteMatchUnion>;

_flights?: Map<string, LoaderFlight>;
/** Whole speculative lanes that an identical navigation may adopt. */
_preloads?: Map<string, ActivePreload>;
/** Active speculative lanes retained for cancellation, invalidation, and cache clearing. */
_preloads?: Map<AbortController, Array<AnyRouteMatch>>;
/** Owns cancellable work before a client transaction publishes. */

@@ -618,4 +617,7 @@ _preflight?: AbortController;

_serverResult?: ServerLoadResult;
/** Framework callback that acknowledges an exact matches publication. */
_rendered?: (matches: Array<AnyRouteMatch>) => void;
/** Framework publication waiting for an exact render acknowledgement. */
_rendered?: [
offered?: Array<AnyRouteMatch>,
settle?: (rendered: boolean) => void
];
/** Development-only HMR reload for a route and its descendants. */

@@ -740,5 +742,7 @@ _refreshRoute: (() => Promise<void>) | undefined;

/**
* Invalidate the current matches and optionally force them back into a pending state.
* Invalidate selected match generations and optionally force current matches
* back into a pending state.
*
* - Marks all matches that pass the optional `filter` as `invalid: true`.
* - Marks committed and cached matches whose IDs are selected as invalid.
* - Retires selected active preloads so older work cannot publish fresh data.
*

@@ -751,3 +755,3 @@ * The next load decides when to publish pending UI, so invalidation does not

clearCache: ClearCacheFn<this>;
loadRouteChunk: typeof loadRouteChunk;
loadRouteChunk: (route: AnyRoute, componentType?: 'errorComponent' | 'notFoundComponent' | false) => Promise<void> | undefined;
preloadRoute: PreloadRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;

@@ -754,0 +758,0 @@ matchRoute: MatchRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;

@@ -198,9 +198,11 @@ import { HistoryState, ParsedHistoryState } from '@tanstack/history';

* - `false` - No preloading
* - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
* - `'intent'` - Preload the linked route when the user focuses, hovers over, or touches the link
* - `'viewport'` - Preload the linked route when it enters the viewport
* - `'render'` - Preload the linked route as soon as it renders
*/
preload?: false | 'intent' | 'viewport' | 'render';
/**
* When a preload strategy is set, this delays the preload by this many milliseconds.
* If the user exits the link before this delay, the preload will be cancelled.
* When the intent preload strategy is set, this delays focus and hover
* preloading by this many milliseconds. Touch intent preloads immediately.
* If focus or hover exits before this delay, the preload will be cancelled.
*/

@@ -207,0 +209,0 @@ preloadDelay?: number;

@@ -1,1 +0,1 @@

{"version":3,"file":"link.js","names":[],"sources":["../../src/link.ts"],"sourcesContent":["import type { HistoryState, ParsedHistoryState } from '@tanstack/history'\nimport type {\n AllParams,\n CatchAllPaths,\n CurrentPath,\n FullSearchSchema,\n FullSearchSchemaInput,\n ParentPath,\n RouteByPath,\n RouteByToPath,\n RoutePaths,\n RouteToPath,\n ToPath,\n} from './routeInfo'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ViewTransitionOptions,\n} from './router'\nimport type {\n ConstrainLiteral,\n Expand,\n MakeDifferenceOptional,\n NoInfer,\n NonNullableUpdater,\n Updater,\n} from './utils'\nimport type { ParsedLocation } from './location'\n\nexport type IsRequiredParams<TParams> =\n Record<never, never> extends TParams ? never : true\n\nexport interface ParsePathParamsResult<\n in out TRequired,\n in out TOptional,\n in out TRest,\n> {\n required: TRequired\n optional: TOptional\n rest: TRest\n}\n\nexport type AnyParsePathParamsResult = ParsePathParamsResult<\n string,\n string,\n string\n>\n\nexport type ParsePathParamsBoundaryStart<T extends string> =\n T extends `${infer TLeft}{-${infer TRight}`\n ? ParsePathParamsResult<\n ParsePathParams<TLeft>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['required']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : T extends `${infer TLeft}{${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsSymbol<T extends string> =\n T extends `${string}$${infer TRight}`\n ? TRight extends `${string}/${string}`\n ? TRight extends `${infer TParam}/${infer TRest}`\n ? TParam extends ''\n ? ParsePathParamsResult<\n ParsePathParams<TRest>['required'],\n '_splat' | ParsePathParams<TRest>['optional'],\n ParsePathParams<TRest>['rest']\n >\n : ParsePathParamsResult<\n TParam | ParsePathParams<TRest>['required'],\n ParsePathParams<TRest>['optional'],\n ParsePathParams<TRest>['rest']\n >\n : never\n : TRight extends ''\n ? ParsePathParamsResult<never, '_splat', never>\n : ParsePathParamsResult<TRight, never, never>\n : never\n\nexport type ParsePathParamsBoundaryEnd<T extends string> =\n T extends `${infer TLeft}}${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsEscapeStart<T extends string> =\n T extends `${infer TLeft}[${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsEscapeEnd<T extends string> =\n T extends `${string}]${infer TRight}` ? ParsePathParams<TRight> : never\n\nexport type ParsePathParams<T extends string> = T extends `${string}[${string}`\n ? ParsePathParamsEscapeStart<T>\n : T extends `${string}]${string}`\n ? ParsePathParamsEscapeEnd<T>\n : T extends `${string}}${string}`\n ? ParsePathParamsBoundaryEnd<T>\n : T extends `${string}{${string}`\n ? ParsePathParamsBoundaryStart<T>\n : T extends `${string}$${string}`\n ? ParsePathParamsSymbol<T>\n : never\n\nexport type AddTrailingSlash<T> = T extends `${string}/` ? T : `${T & string}/`\n\nexport type RemoveTrailingSlashes<T> = T & `${string}/` extends never\n ? T\n : T extends `${infer R}/`\n ? R\n : T\n\nexport type AddLeadingSlash<T> = T & `/${string}` extends never\n ? `/${T & string}`\n : T\n\nexport type RemoveLeadingSlashes<T> = T & `/${string}` extends never\n ? T\n : T extends `/${infer R}`\n ? R\n : T\n\ntype JoinPath<TLeft extends string, TRight extends string> = TRight extends ''\n ? TLeft\n : TLeft extends ''\n ? TRight\n : `${RemoveTrailingSlashes<TLeft>}/${RemoveLeadingSlashes<TRight>}`\n\ntype RemoveLastSegment<\n T extends string,\n TAcc extends string = '',\n> = T extends `${infer TSegment}/${infer TRest}`\n ? TRest & `${string}/${string}` extends never\n ? TRest extends ''\n ? TAcc\n : `${TAcc}${TSegment}`\n : RemoveLastSegment<TRest, `${TAcc}${TSegment}/`>\n : TAcc\n\nexport type ResolveCurrentPath<\n TFrom extends string,\n TTo extends string,\n> = TTo extends '.'\n ? TFrom\n : TTo extends './'\n ? AddTrailingSlash<TFrom>\n : TTo & `./${string}` extends never\n ? never\n : TTo extends `./${infer TRest}`\n ? AddLeadingSlash<JoinPath<TFrom, TRest>>\n : never\n\nexport type ResolveParentPath<\n TFrom extends string,\n TTo extends string,\n> = TTo extends '../' | '..'\n ? TFrom extends '' | '/'\n ? never\n : AddLeadingSlash<RemoveLastSegment<TFrom>>\n : TTo & `../${string}` extends never\n ? AddLeadingSlash<JoinPath<TFrom, TTo>>\n : TFrom extends '' | '/'\n ? never\n : TTo extends `../${infer ToRest}`\n ? ResolveParentPath<RemoveLastSegment<TFrom>, ToRest>\n : AddLeadingSlash<JoinPath<TFrom, TTo>>\n\nexport type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom\n ? TTo\n : string extends TTo\n ? TFrom\n : undefined extends TTo\n ? TFrom\n : TTo extends string\n ? TFrom extends string\n ? TTo extends `/${string}`\n ? TTo\n : TTo extends `..${string}`\n ? ResolveParentPath<TFrom, TTo>\n : TTo extends `.${string}`\n ? ResolveCurrentPath<TFrom, TTo>\n : AddLeadingSlash<JoinPath<TFrom, TTo>>\n : never\n : never\n\nexport type FindDescendantToPaths<\n TRouter extends AnyRouter,\n TPrefix extends string,\n> = `${TPrefix}/${string}` & RouteToPath<TRouter>\n\nexport type InferDescendantToPaths<\n TRouter extends AnyRouter,\n TPrefix extends string,\n TPaths = FindDescendantToPaths<TRouter, TPrefix>,\n> = TPaths extends `${TPrefix}/`\n ? never\n : TPaths extends `${TPrefix}/${infer TRest}`\n ? TRest\n : never\n\nexport type RelativeToPath<\n TRouter extends AnyRouter,\n TTo extends string,\n TResolvedPath extends string,\n> =\n | (TResolvedPath & RouteToPath<TRouter> extends never\n ? never\n : ToPath<TRouter, TTo>)\n | `${RemoveTrailingSlashes<TTo>}/${InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TResolvedPath>>}`\n\nexport type RelativeToParentPath<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,\n> =\n | RelativeToPath<TRouter, TTo, TResolvedPath>\n | (TTo extends `${string}..` | `${string}../`\n ? TResolvedPath extends '/' | ''\n ? never\n : FindDescendantToPaths<\n TRouter,\n RemoveTrailingSlashes<TResolvedPath>\n > extends never\n ? never\n : `${RemoveTrailingSlashes<TTo>}/${ParentPath<TRouter>}`\n : never)\n\nexport type RelativeToCurrentPath<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,\n> = RelativeToPath<TRouter, TTo, TResolvedPath> | CurrentPath<TRouter>\n\nexport type AbsoluteToPath<TRouter extends AnyRouter, TFrom extends string> =\n | (string extends TFrom\n ? CurrentPath<TRouter>\n : TFrom extends `/`\n ? never\n : CurrentPath<TRouter>)\n | (string extends TFrom\n ? ParentPath<TRouter>\n : TFrom extends `/`\n ? never\n : ParentPath<TRouter>)\n | RouteToPath<TRouter>\n | (TFrom extends '/'\n ? never\n : string extends TFrom\n ? never\n : InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TFrom>>)\n\nexport type RelativeToPathAutoComplete<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n> = string extends TTo\n ? string\n : string extends TFrom\n ? AbsoluteToPath<TRouter, TFrom>\n : TTo & `..${string}` extends never\n ? TTo & `.${string}` extends never\n ? AbsoluteToPath<TRouter, TFrom>\n : RelativeToCurrentPath<TRouter, TFrom, TTo>\n : RelativeToParentPath<TRouter, TFrom, TTo>\n\nexport type NavigateOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & NavigateOptionProps\n\n/**\n * The NavigateOptions type is used to describe the options that can be used when describing a navigation action in TanStack Router.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType)\n */\nexport interface NavigateOptionProps {\n /**\n * If set to `true`, the router will scroll the element with an id matching the hash into view with default `ScrollIntoViewOptions`.\n * If set to `false`, the router will not scroll the element with an id matching the hash into view.\n * If set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options.\n * @default true\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#hashscrollintoview)\n * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)\n */\n hashScrollIntoView?: boolean | ScrollIntoViewOptions\n /**\n * `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#replace)\n */\n replace?: boolean\n /**\n * Defaults to `true` so that the scroll position will be reset to 0,0 after the location is committed to the browser history.\n * If `false`, the scroll position will not be reset to 0,0 after the location is committed to history.\n * @default true\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#resetscroll)\n */\n resetScroll?: boolean\n /** @deprecated All navigations now use startTransition under the hood */\n startTransition?: boolean\n /**\n * If set to `true`, the router will wrap the resulting navigation in a `document.startViewTransition()` call.\n * If `ViewTransitionOptions`, route navigations will be called using `document.startViewTransition({update, types})`\n * where `types` will be the strings array passed with `ViewTransitionOptions[\"types\"]`.\n * If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed.\n *\n * If the browser does not support this api, this option will be ignored.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#viewtransition)\n * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)\n * @see [Google](https://developer.chrome.com/docs/web-platform/view-transitions/same-document#view-transition-types)\n */\n viewTransition?: boolean | ViewTransitionOptions\n /**\n * If `true`, navigation will ignore any blockers that might prevent it.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#ignoreblocker)\n */\n ignoreBlocker?: boolean\n /**\n * If `true`, navigation to a route inside of router will trigger a full page load instead of the traditional SPA navigation.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#reloaddocument)\n */\n reloadDocument?: boolean\n /**\n * This can be used instead of `to` to navigate to a fully built href, e.g. pointing to an external target.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n href?: string\n /** @internal */\n publicHref?: string\n}\n\nexport type ToOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ToSubOptions<TRouter, TFrom, TTo> & MaskOptions<TRouter, TMaskFrom, TMaskTo>\n\nexport interface MaskOptions<\n in out TRouter extends AnyRouter,\n in out TMaskFrom extends string,\n in out TMaskTo extends string,\n> {\n _fromLocation?: ParsedLocation\n mask?: ToMaskOptions<TRouter, TMaskFrom, TMaskTo>\n}\n\nexport type ToMaskOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TMaskFrom extends string = string,\n TMaskTo extends string = '.',\n> = ToSubOptions<TRouter, TMaskFrom, TMaskTo> & {\n unmaskOnReload?: boolean\n}\n\nexport type ToSubOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n SearchParamOptions<TRouter, TFrom, TTo> &\n PathParamOptions<TRouter, TFrom, TTo>\n\nexport interface RequiredToOptions<\n in out TRouter extends AnyRouter,\n in out TFrom extends string,\n in out TTo extends string | undefined,\n> {\n /**\n * The internal route path to navigate to. This should be a relative or absolute path within your application.\n * For external URLs, use the `href` property instead.\n * @example \"/dashboard\" or \"../profile\"\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n to: ToPathOption<TRouter, TFrom, TTo> & {}\n}\n\nexport interface OptionalToOptions<\n in out TRouter extends AnyRouter,\n in out TFrom extends string,\n in out TTo extends string | undefined,\n> {\n /**\n * The internal route path to navigate to. This should be a relative or absolute path within your application.\n * For external URLs, use the `href` property instead.\n * @example \"/dashboard\" or \"../profile\"\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n to?: ToPathOption<TRouter, TFrom, TTo> & {}\n}\n\nexport type MakeToRequired<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string | undefined,\n> = string extends TFrom\n ? string extends TTo\n ? OptionalToOptions<TRouter, TFrom, TTo>\n : TTo & CatchAllPaths<TRouter> extends never\n ? RequiredToOptions<TRouter, TFrom, TTo>\n : OptionalToOptions<TRouter, TFrom, TTo>\n : OptionalToOptions<TRouter, TFrom, TTo>\n\nexport type ToSubOptionsProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n> = MakeToRequired<TRouter, TFrom, TTo> & {\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>\n from?: FromPathOption<TRouter, TFrom> & {}\n unsafeRelative?: 'path'\n}\n\nexport type ParamsReducerFn<\n in out TRouter extends AnyRouter,\n in out TParamVariant extends ParamVariant,\n in out TFrom,\n in out TTo,\n> = (\n current: Expand<ResolveFromParams<TRouter, TParamVariant, TFrom>>,\n) => Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>\n\ntype ParamsReducer<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n | Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>\n | (ParamsReducerFn<TRouter, TParamVariant, TFrom, TTo> & {})\n\ntype ParamVariant = 'PATH' | 'SEARCH'\n\nexport type ResolveRoute<\n TRouter extends AnyRouter,\n TFrom,\n TTo,\n TPath = ResolveRelativePath<TFrom, TTo>,\n> = TPath extends string\n ? TFrom extends TPath\n ? RouteByPath<TRouter['routeTree'], TPath>\n : RouteByToPath<TRouter, TPath>\n : never\n\ntype ResolveFromParamType<TParamVariant extends ParamVariant> =\n TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema'\n\ntype ResolveFromAllParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n> = TParamVariant extends 'PATH'\n ? AllParams<TRouter['routeTree']>\n : FullSearchSchema<TRouter['routeTree']>\n\ntype ResolveFromParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n> = string extends TFrom\n ? ResolveFromAllParams<TRouter, TParamVariant>\n : RouteByPath<\n TRouter['routeTree'],\n TFrom\n >['types'][ResolveFromParamType<TParamVariant>]\n\ntype ResolveToParamType<TParamVariant extends ParamVariant> =\n TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput'\n\ntype ResolveAllToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n> = TParamVariant extends 'PATH'\n ? AllParams<TRouter['routeTree']>\n : FullSearchSchemaInput<TRouter['routeTree']>\n\nexport type ResolveToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n ResolveRelativePath<TFrom, TTo> extends infer TPath\n ? undefined extends TPath\n ? never\n : string extends TPath\n ? ResolveAllToParams<TRouter, TParamVariant>\n : TPath extends CatchAllPaths<TRouter>\n ? ResolveAllToParams<TRouter, TParamVariant>\n : ResolveRoute<\n TRouter,\n TFrom,\n TTo\n >['types'][ResolveToParamType<TParamVariant>]\n : never\n\ntype ResolveRelativeToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n TToParams = ResolveToParams<TRouter, TParamVariant, TFrom, TTo>,\n> = TParamVariant extends 'SEARCH'\n ? TToParams\n : string extends TFrom\n ? TToParams\n : MakeDifferenceOptional<\n ResolveFromParams<TRouter, TParamVariant, TFrom>,\n TToParams\n >\n\nexport interface MakeOptionalSearchParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n search?: true | (ParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {})\n}\n\nexport interface MakeOptionalPathParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n params?: true | (ParamsReducer<TRouter, 'PATH', TFrom, TTo> & {})\n}\n\ntype MakeRequiredParamsReducer<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n | (string extends TFrom\n ? never\n : ResolveFromParams<\n TRouter,\n TParamVariant,\n TFrom\n > extends ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>\n ? true\n : never)\n | (ParamsReducer<TRouter, TParamVariant, TFrom, TTo> & {})\n\nexport interface MakeRequiredPathParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n params: MakeRequiredParamsReducer<TRouter, 'PATH', TFrom, TTo> & {}\n}\n\nexport interface MakeRequiredSearchParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n search: MakeRequiredParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {}\n}\n\nexport type IsRequired<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n ResolveRelativePath<TFrom, TTo> extends infer TPath\n ? undefined extends TPath\n ? never\n : TPath extends CatchAllPaths<TRouter>\n ? never\n : IsRequiredParams<\n ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>\n >\n : never\n\nexport type SearchParamOptions<TRouter extends AnyRouter, TFrom, TTo> =\n IsRequired<TRouter, 'SEARCH', TFrom, TTo> extends never\n ? MakeOptionalSearchParams<TRouter, TFrom, TTo>\n : MakeRequiredSearchParams<TRouter, TFrom, TTo>\n\nexport type PathParamOptions<TRouter extends AnyRouter, TFrom, TTo> =\n IsRequired<TRouter, 'PATH', TFrom, TTo> extends never\n ? MakeOptionalPathParams<TRouter, TFrom, TTo>\n : MakeRequiredPathParams<TRouter, TFrom, TTo>\n\nexport type ToPathOption<\n TRouter extends AnyRouter = AnyRouter,\n TFrom extends string = string,\n TTo extends string | undefined = string,\n> = ConstrainLiteral<\n TTo,\n RelativeToPathAutoComplete<\n TRouter,\n NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',\n NoInfer<TTo> & string\n >\n>\n\nexport type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<\n TFrom,\n RoutePaths<TRouter['routeTree']>\n>\n\n/**\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options)\n */\nexport interface ActiveOptions {\n /**\n * If true, the link will be active if the current route matches the `to` route path exactly (no children routes)\n * @default false\n */\n exact?: boolean\n /**\n * If true, the link will only be active if the current URL hash matches the `hash` prop\n * @default false\n */\n includeHash?: boolean\n /**\n * If true, the link will only be active if the current URL search params inclusively match the `search` prop\n * @default true\n */\n includeSearch?: boolean\n /**\n * This modifies the `includeSearch` behavior.\n * If true, properties in `search` that are explicitly `undefined` must NOT be present in the current URL search params for the link to be active.\n * @default false\n */\n explicitUndefined?: boolean\n}\n\nexport interface LinkOptionsProps {\n /**\n * The standard anchor tag target attribute\n */\n target?: HTMLAnchorElement['target']\n /**\n * Configurable options to determine if the link should be considered active or not\n * @default {exact:true,includeHash:true}\n */\n activeOptions?: ActiveOptions\n /**\n * The preloading strategy for this link\n * - `false` - No preloading\n * - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.\n * - `'viewport'` - Preload the linked route when it enters the viewport\n */\n preload?: false | 'intent' | 'viewport' | 'render'\n /**\n * When a preload strategy is set, this delays the preload by this many milliseconds.\n * If the user exits the link before this delay, the preload will be cancelled.\n */\n preloadDelay?: number\n /**\n * Control whether the link should be disabled or not\n * If set to `true`, the link will be rendered without an `href` attribute\n * @default false\n */\n disabled?: boolean\n /**\n * When the preload strategy is set to `intent`, this controls the proximity of the link to the cursor before it is preloaded.\n * If the user exits this proximity before this delay, the preload will be cancelled.\n */\n preloadIntentProximity?: number\n}\n\nexport type LinkOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkOptionsProps\n\nexport const preloadWarning = 'Error preloading route! ☝️'\n"],"mappings":";AA+rBA,MAAa,iBAAiB"}
{"version":3,"file":"link.js","names":[],"sources":["../../src/link.ts"],"sourcesContent":["import type { HistoryState, ParsedHistoryState } from '@tanstack/history'\nimport type {\n AllParams,\n CatchAllPaths,\n CurrentPath,\n FullSearchSchema,\n FullSearchSchemaInput,\n ParentPath,\n RouteByPath,\n RouteByToPath,\n RoutePaths,\n RouteToPath,\n ToPath,\n} from './routeInfo'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ViewTransitionOptions,\n} from './router'\nimport type {\n ConstrainLiteral,\n Expand,\n MakeDifferenceOptional,\n NoInfer,\n NonNullableUpdater,\n Updater,\n} from './utils'\nimport type { ParsedLocation } from './location'\n\nexport type IsRequiredParams<TParams> =\n Record<never, never> extends TParams ? never : true\n\nexport interface ParsePathParamsResult<\n in out TRequired,\n in out TOptional,\n in out TRest,\n> {\n required: TRequired\n optional: TOptional\n rest: TRest\n}\n\nexport type AnyParsePathParamsResult = ParsePathParamsResult<\n string,\n string,\n string\n>\n\nexport type ParsePathParamsBoundaryStart<T extends string> =\n T extends `${infer TLeft}{-${infer TRight}`\n ? ParsePathParamsResult<\n ParsePathParams<TLeft>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['required']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : T extends `${infer TLeft}{${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsSymbol<T extends string> =\n T extends `${string}$${infer TRight}`\n ? TRight extends `${string}/${string}`\n ? TRight extends `${infer TParam}/${infer TRest}`\n ? TParam extends ''\n ? ParsePathParamsResult<\n ParsePathParams<TRest>['required'],\n '_splat' | ParsePathParams<TRest>['optional'],\n ParsePathParams<TRest>['rest']\n >\n : ParsePathParamsResult<\n TParam | ParsePathParams<TRest>['required'],\n ParsePathParams<TRest>['optional'],\n ParsePathParams<TRest>['rest']\n >\n : never\n : TRight extends ''\n ? ParsePathParamsResult<never, '_splat', never>\n : ParsePathParamsResult<TRight, never, never>\n : never\n\nexport type ParsePathParamsBoundaryEnd<T extends string> =\n T extends `${infer TLeft}}${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsEscapeStart<T extends string> =\n T extends `${infer TLeft}[${infer TRight}`\n ? ParsePathParamsResult<\n | ParsePathParams<TLeft>['required']\n | ParsePathParams<TRight>['required'],\n | ParsePathParams<TLeft>['optional']\n | ParsePathParams<TRight>['optional'],\n ParsePathParams<TRight>['rest']\n >\n : never\n\nexport type ParsePathParamsEscapeEnd<T extends string> =\n T extends `${string}]${infer TRight}` ? ParsePathParams<TRight> : never\n\nexport type ParsePathParams<T extends string> = T extends `${string}[${string}`\n ? ParsePathParamsEscapeStart<T>\n : T extends `${string}]${string}`\n ? ParsePathParamsEscapeEnd<T>\n : T extends `${string}}${string}`\n ? ParsePathParamsBoundaryEnd<T>\n : T extends `${string}{${string}`\n ? ParsePathParamsBoundaryStart<T>\n : T extends `${string}$${string}`\n ? ParsePathParamsSymbol<T>\n : never\n\nexport type AddTrailingSlash<T> = T extends `${string}/` ? T : `${T & string}/`\n\nexport type RemoveTrailingSlashes<T> = T & `${string}/` extends never\n ? T\n : T extends `${infer R}/`\n ? R\n : T\n\nexport type AddLeadingSlash<T> = T & `/${string}` extends never\n ? `/${T & string}`\n : T\n\nexport type RemoveLeadingSlashes<T> = T & `/${string}` extends never\n ? T\n : T extends `/${infer R}`\n ? R\n : T\n\ntype JoinPath<TLeft extends string, TRight extends string> = TRight extends ''\n ? TLeft\n : TLeft extends ''\n ? TRight\n : `${RemoveTrailingSlashes<TLeft>}/${RemoveLeadingSlashes<TRight>}`\n\ntype RemoveLastSegment<\n T extends string,\n TAcc extends string = '',\n> = T extends `${infer TSegment}/${infer TRest}`\n ? TRest & `${string}/${string}` extends never\n ? TRest extends ''\n ? TAcc\n : `${TAcc}${TSegment}`\n : RemoveLastSegment<TRest, `${TAcc}${TSegment}/`>\n : TAcc\n\nexport type ResolveCurrentPath<\n TFrom extends string,\n TTo extends string,\n> = TTo extends '.'\n ? TFrom\n : TTo extends './'\n ? AddTrailingSlash<TFrom>\n : TTo & `./${string}` extends never\n ? never\n : TTo extends `./${infer TRest}`\n ? AddLeadingSlash<JoinPath<TFrom, TRest>>\n : never\n\nexport type ResolveParentPath<\n TFrom extends string,\n TTo extends string,\n> = TTo extends '../' | '..'\n ? TFrom extends '' | '/'\n ? never\n : AddLeadingSlash<RemoveLastSegment<TFrom>>\n : TTo & `../${string}` extends never\n ? AddLeadingSlash<JoinPath<TFrom, TTo>>\n : TFrom extends '' | '/'\n ? never\n : TTo extends `../${infer ToRest}`\n ? ResolveParentPath<RemoveLastSegment<TFrom>, ToRest>\n : AddLeadingSlash<JoinPath<TFrom, TTo>>\n\nexport type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom\n ? TTo\n : string extends TTo\n ? TFrom\n : undefined extends TTo\n ? TFrom\n : TTo extends string\n ? TFrom extends string\n ? TTo extends `/${string}`\n ? TTo\n : TTo extends `..${string}`\n ? ResolveParentPath<TFrom, TTo>\n : TTo extends `.${string}`\n ? ResolveCurrentPath<TFrom, TTo>\n : AddLeadingSlash<JoinPath<TFrom, TTo>>\n : never\n : never\n\nexport type FindDescendantToPaths<\n TRouter extends AnyRouter,\n TPrefix extends string,\n> = `${TPrefix}/${string}` & RouteToPath<TRouter>\n\nexport type InferDescendantToPaths<\n TRouter extends AnyRouter,\n TPrefix extends string,\n TPaths = FindDescendantToPaths<TRouter, TPrefix>,\n> = TPaths extends `${TPrefix}/`\n ? never\n : TPaths extends `${TPrefix}/${infer TRest}`\n ? TRest\n : never\n\nexport type RelativeToPath<\n TRouter extends AnyRouter,\n TTo extends string,\n TResolvedPath extends string,\n> =\n | (TResolvedPath & RouteToPath<TRouter> extends never\n ? never\n : ToPath<TRouter, TTo>)\n | `${RemoveTrailingSlashes<TTo>}/${InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TResolvedPath>>}`\n\nexport type RelativeToParentPath<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,\n> =\n | RelativeToPath<TRouter, TTo, TResolvedPath>\n | (TTo extends `${string}..` | `${string}../`\n ? TResolvedPath extends '/' | ''\n ? never\n : FindDescendantToPaths<\n TRouter,\n RemoveTrailingSlashes<TResolvedPath>\n > extends never\n ? never\n : `${RemoveTrailingSlashes<TTo>}/${ParentPath<TRouter>}`\n : never)\n\nexport type RelativeToCurrentPath<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,\n> = RelativeToPath<TRouter, TTo, TResolvedPath> | CurrentPath<TRouter>\n\nexport type AbsoluteToPath<TRouter extends AnyRouter, TFrom extends string> =\n | (string extends TFrom\n ? CurrentPath<TRouter>\n : TFrom extends `/`\n ? never\n : CurrentPath<TRouter>)\n | (string extends TFrom\n ? ParentPath<TRouter>\n : TFrom extends `/`\n ? never\n : ParentPath<TRouter>)\n | RouteToPath<TRouter>\n | (TFrom extends '/'\n ? never\n : string extends TFrom\n ? never\n : InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TFrom>>)\n\nexport type RelativeToPathAutoComplete<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string,\n> = string extends TTo\n ? string\n : string extends TFrom\n ? AbsoluteToPath<TRouter, TFrom>\n : TTo & `..${string}` extends never\n ? TTo & `.${string}` extends never\n ? AbsoluteToPath<TRouter, TFrom>\n : RelativeToCurrentPath<TRouter, TFrom, TTo>\n : RelativeToParentPath<TRouter, TFrom, TTo>\n\nexport type NavigateOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & NavigateOptionProps\n\n/**\n * The NavigateOptions type is used to describe the options that can be used when describing a navigation action in TanStack Router.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType)\n */\nexport interface NavigateOptionProps {\n /**\n * If set to `true`, the router will scroll the element with an id matching the hash into view with default `ScrollIntoViewOptions`.\n * If set to `false`, the router will not scroll the element with an id matching the hash into view.\n * If set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options.\n * @default true\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#hashscrollintoview)\n * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)\n */\n hashScrollIntoView?: boolean | ScrollIntoViewOptions\n /**\n * `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#replace)\n */\n replace?: boolean\n /**\n * Defaults to `true` so that the scroll position will be reset to 0,0 after the location is committed to the browser history.\n * If `false`, the scroll position will not be reset to 0,0 after the location is committed to history.\n * @default true\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#resetscroll)\n */\n resetScroll?: boolean\n /** @deprecated All navigations now use startTransition under the hood */\n startTransition?: boolean\n /**\n * If set to `true`, the router will wrap the resulting navigation in a `document.startViewTransition()` call.\n * If `ViewTransitionOptions`, route navigations will be called using `document.startViewTransition({update, types})`\n * where `types` will be the strings array passed with `ViewTransitionOptions[\"types\"]`.\n * If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed.\n *\n * If the browser does not support this api, this option will be ignored.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#viewtransition)\n * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)\n * @see [Google](https://developer.chrome.com/docs/web-platform/view-transitions/same-document#view-transition-types)\n */\n viewTransition?: boolean | ViewTransitionOptions\n /**\n * If `true`, navigation will ignore any blockers that might prevent it.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#ignoreblocker)\n */\n ignoreBlocker?: boolean\n /**\n * If `true`, navigation to a route inside of router will trigger a full page load instead of the traditional SPA navigation.\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#reloaddocument)\n */\n reloadDocument?: boolean\n /**\n * This can be used instead of `to` to navigate to a fully built href, e.g. pointing to an external target.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n href?: string\n /** @internal */\n publicHref?: string\n}\n\nexport type ToOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ToSubOptions<TRouter, TFrom, TTo> & MaskOptions<TRouter, TMaskFrom, TMaskTo>\n\nexport interface MaskOptions<\n in out TRouter extends AnyRouter,\n in out TMaskFrom extends string,\n in out TMaskTo extends string,\n> {\n _fromLocation?: ParsedLocation\n mask?: ToMaskOptions<TRouter, TMaskFrom, TMaskTo>\n}\n\nexport type ToMaskOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TMaskFrom extends string = string,\n TMaskTo extends string = '.',\n> = ToSubOptions<TRouter, TMaskFrom, TMaskTo> & {\n unmaskOnReload?: boolean\n}\n\nexport type ToSubOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n SearchParamOptions<TRouter, TFrom, TTo> &\n PathParamOptions<TRouter, TFrom, TTo>\n\nexport interface RequiredToOptions<\n in out TRouter extends AnyRouter,\n in out TFrom extends string,\n in out TTo extends string | undefined,\n> {\n /**\n * The internal route path to navigate to. This should be a relative or absolute path within your application.\n * For external URLs, use the `href` property instead.\n * @example \"/dashboard\" or \"../profile\"\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n to: ToPathOption<TRouter, TFrom, TTo> & {}\n}\n\nexport interface OptionalToOptions<\n in out TRouter extends AnyRouter,\n in out TFrom extends string,\n in out TTo extends string | undefined,\n> {\n /**\n * The internal route path to navigate to. This should be a relative or absolute path within your application.\n * For external URLs, use the `href` property instead.\n * @example \"/dashboard\" or \"../profile\"\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)\n */\n to?: ToPathOption<TRouter, TFrom, TTo> & {}\n}\n\nexport type MakeToRequired<\n TRouter extends AnyRouter,\n TFrom extends string,\n TTo extends string | undefined,\n> = string extends TFrom\n ? string extends TTo\n ? OptionalToOptions<TRouter, TFrom, TTo>\n : TTo & CatchAllPaths<TRouter> extends never\n ? RequiredToOptions<TRouter, TFrom, TTo>\n : OptionalToOptions<TRouter, TFrom, TTo>\n : OptionalToOptions<TRouter, TFrom, TTo>\n\nexport type ToSubOptionsProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n> = MakeToRequired<TRouter, TFrom, TTo> & {\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>\n from?: FromPathOption<TRouter, TFrom> & {}\n unsafeRelative?: 'path'\n}\n\nexport type ParamsReducerFn<\n in out TRouter extends AnyRouter,\n in out TParamVariant extends ParamVariant,\n in out TFrom,\n in out TTo,\n> = (\n current: Expand<ResolveFromParams<TRouter, TParamVariant, TFrom>>,\n) => Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>\n\ntype ParamsReducer<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n | Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>\n | (ParamsReducerFn<TRouter, TParamVariant, TFrom, TTo> & {})\n\ntype ParamVariant = 'PATH' | 'SEARCH'\n\nexport type ResolveRoute<\n TRouter extends AnyRouter,\n TFrom,\n TTo,\n TPath = ResolveRelativePath<TFrom, TTo>,\n> = TPath extends string\n ? TFrom extends TPath\n ? RouteByPath<TRouter['routeTree'], TPath>\n : RouteByToPath<TRouter, TPath>\n : never\n\ntype ResolveFromParamType<TParamVariant extends ParamVariant> =\n TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema'\n\ntype ResolveFromAllParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n> = TParamVariant extends 'PATH'\n ? AllParams<TRouter['routeTree']>\n : FullSearchSchema<TRouter['routeTree']>\n\ntype ResolveFromParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n> = string extends TFrom\n ? ResolveFromAllParams<TRouter, TParamVariant>\n : RouteByPath<\n TRouter['routeTree'],\n TFrom\n >['types'][ResolveFromParamType<TParamVariant>]\n\ntype ResolveToParamType<TParamVariant extends ParamVariant> =\n TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput'\n\ntype ResolveAllToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n> = TParamVariant extends 'PATH'\n ? AllParams<TRouter['routeTree']>\n : FullSearchSchemaInput<TRouter['routeTree']>\n\nexport type ResolveToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n ResolveRelativePath<TFrom, TTo> extends infer TPath\n ? undefined extends TPath\n ? never\n : string extends TPath\n ? ResolveAllToParams<TRouter, TParamVariant>\n : TPath extends CatchAllPaths<TRouter>\n ? ResolveAllToParams<TRouter, TParamVariant>\n : ResolveRoute<\n TRouter,\n TFrom,\n TTo\n >['types'][ResolveToParamType<TParamVariant>]\n : never\n\ntype ResolveRelativeToParams<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n TToParams = ResolveToParams<TRouter, TParamVariant, TFrom, TTo>,\n> = TParamVariant extends 'SEARCH'\n ? TToParams\n : string extends TFrom\n ? TToParams\n : MakeDifferenceOptional<\n ResolveFromParams<TRouter, TParamVariant, TFrom>,\n TToParams\n >\n\nexport interface MakeOptionalSearchParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n search?: true | (ParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {})\n}\n\nexport interface MakeOptionalPathParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n params?: true | (ParamsReducer<TRouter, 'PATH', TFrom, TTo> & {})\n}\n\ntype MakeRequiredParamsReducer<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n | (string extends TFrom\n ? never\n : ResolveFromParams<\n TRouter,\n TParamVariant,\n TFrom\n > extends ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>\n ? true\n : never)\n | (ParamsReducer<TRouter, TParamVariant, TFrom, TTo> & {})\n\nexport interface MakeRequiredPathParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n params: MakeRequiredParamsReducer<TRouter, 'PATH', TFrom, TTo> & {}\n}\n\nexport interface MakeRequiredSearchParams<\n in out TRouter extends AnyRouter,\n in out TFrom,\n in out TTo,\n> {\n search: MakeRequiredParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {}\n}\n\nexport type IsRequired<\n TRouter extends AnyRouter,\n TParamVariant extends ParamVariant,\n TFrom,\n TTo,\n> =\n ResolveRelativePath<TFrom, TTo> extends infer TPath\n ? undefined extends TPath\n ? never\n : TPath extends CatchAllPaths<TRouter>\n ? never\n : IsRequiredParams<\n ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>\n >\n : never\n\nexport type SearchParamOptions<TRouter extends AnyRouter, TFrom, TTo> =\n IsRequired<TRouter, 'SEARCH', TFrom, TTo> extends never\n ? MakeOptionalSearchParams<TRouter, TFrom, TTo>\n : MakeRequiredSearchParams<TRouter, TFrom, TTo>\n\nexport type PathParamOptions<TRouter extends AnyRouter, TFrom, TTo> =\n IsRequired<TRouter, 'PATH', TFrom, TTo> extends never\n ? MakeOptionalPathParams<TRouter, TFrom, TTo>\n : MakeRequiredPathParams<TRouter, TFrom, TTo>\n\nexport type ToPathOption<\n TRouter extends AnyRouter = AnyRouter,\n TFrom extends string = string,\n TTo extends string | undefined = string,\n> = ConstrainLiteral<\n TTo,\n RelativeToPathAutoComplete<\n TRouter,\n NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',\n NoInfer<TTo> & string\n >\n>\n\nexport type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<\n TFrom,\n RoutePaths<TRouter['routeTree']>\n>\n\n/**\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options)\n */\nexport interface ActiveOptions {\n /**\n * If true, the link will be active if the current route matches the `to` route path exactly (no children routes)\n * @default false\n */\n exact?: boolean\n /**\n * If true, the link will only be active if the current URL hash matches the `hash` prop\n * @default false\n */\n includeHash?: boolean\n /**\n * If true, the link will only be active if the current URL search params inclusively match the `search` prop\n * @default true\n */\n includeSearch?: boolean\n /**\n * This modifies the `includeSearch` behavior.\n * If true, properties in `search` that are explicitly `undefined` must NOT be present in the current URL search params for the link to be active.\n * @default false\n */\n explicitUndefined?: boolean\n}\n\nexport interface LinkOptionsProps {\n /**\n * The standard anchor tag target attribute\n */\n target?: HTMLAnchorElement['target']\n /**\n * Configurable options to determine if the link should be considered active or not\n * @default {exact:true,includeHash:true}\n */\n activeOptions?: ActiveOptions\n /**\n * The preloading strategy for this link\n * - `false` - No preloading\n * - `'intent'` - Preload the linked route when the user focuses, hovers over, or touches the link\n * - `'viewport'` - Preload the linked route when it enters the viewport\n * - `'render'` - Preload the linked route as soon as it renders\n */\n preload?: false | 'intent' | 'viewport' | 'render'\n /**\n * When the intent preload strategy is set, this delays focus and hover\n * preloading by this many milliseconds. Touch intent preloads immediately.\n * If focus or hover exits before this delay, the preload will be cancelled.\n */\n preloadDelay?: number\n /**\n * Control whether the link should be disabled or not\n * If set to `true`, the link will be rendered without an `href` attribute\n * @default false\n */\n disabled?: boolean\n /**\n * When the preload strategy is set to `intent`, this controls the proximity of the link to the cursor before it is preloaded.\n * If the user exits this proximity before this delay, the preload will be cancelled.\n */\n preloadIntentProximity?: number\n}\n\nexport type LinkOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkOptionsProps\n\nexport const preloadWarning = 'Error preloading route! ☝️'\n"],"mappings":";AAisBA,MAAa,iBAAiB"}

@@ -10,3 +10,3 @@ import { GLOBAL_SEROVAL, GLOBAL_TSR } from './ssr/constants.js';

export declare function replaceRouteChunk(route: AnyRoute, lazyFn: AnyRoute['lazyFn']): void;
export declare function loadRouteChunk(route: AnyRoute, componentType?: 'errorComponent' | 'notFoundComponent' | false): Promise<void> | undefined;
export declare function loadRouteChunk(route: AnyRoute, componentType?: 'errorComponent' | 'notFoundComponent' | false, onPendingReady?: () => void): Promise<void> | undefined;
/** Return the structural lane through the first terminal render boundary. */

@@ -41,3 +41,3 @@ export declare function _getRenderedMatches(matches: Array<AnyRouteMatch>): Array<AnyRouteMatch>;

declare const CANCELED = 4;
type LoaderOutcome = [typeof SUCCESS, data: unknown] | [typeof ERROR, error: unknown] | [typeof NOT_FOUND, error: NotFoundError] | [typeof REDIRECTED, redirect: AnyRedirect] | [typeof CANCELED];
type LoaderOutcome = [kind: typeof SUCCESS, data: unknown] | [kind: typeof ERROR, error: unknown] | [kind: typeof NOT_FOUND, error: NotFoundError] | [kind: typeof REDIRECTED, redirect: AnyRedirect] | [kind: typeof CANCELED];
type IndexedOutcome = [index: number, outcome: LoaderOutcome, boundary?: number];

@@ -63,23 +63,2 @@ export type LoaderFlight = [

};
export type LaneInputs = [
routeTree: AnyRoute,
context: unknown,
additionalContext: unknown,
state: object,
search: object,
maskedLocation: [
href: string,
state: object,
search: object,
unmaskOnReload: boolean | undefined
] | undefined
];
export type ActivePreload = [
matches: Array<AnyRouteMatch>,
controller: AbortController,
result: Promise<LaneResult>,
semanticOwner: Array<AnyRouteMatch>,
inputs: LaneInputs,
redirects: number
];
export type LoadTransaction = [

@@ -94,8 +73,10 @@ controller: AbortController,

* Dev-only HMR refresh mode. Presence is the mode flag; a refresh always
* carries the presentation it started from, while the hydration handoff is
* genuinely optional — the tuple makes a half-armed refresh unrepresentable.
* carries the presentation it started from and its optional hydration
* handoff. While a publication awaits acknowledgement, its rollback lives
* with the transaction that owns the publication.
*/
refresh?: [
presentation: Array<AnyRouteMatch>,
handoff: NonNullable<AnyRouter['_handoff']> | undefined
handoff: NonNullable<AnyRouter['_handoff']> | undefined,
rollback?: () => boolean
]

@@ -113,6 +94,5 @@ ];

type CoordinatorRouter = AnyRouter & {
/** Whole speculative lanes that a matching navigation may adopt. */
_preloads?: Map<string, ActivePreload>;
/** Active speculative lanes retained for cancellation, invalidation, and cache clearing. */
_preloads?: Map<AbortController, Array<AnyRouteMatch>>;
_refreshNextLoad?: boolean;
_rollbackRefresh?: () => void;
_cancelTransition?: () => void;

@@ -123,16 +103,8 @@ };

outcome: Promise<LoaderOutcome>,
ready: Promise<IndexedOutcome | undefined>,
chunkFailure: Promise<IndexedOutcome | undefined>,
candidate: WorkMatch
];
type ControlOutcome = [typeof REDIRECTED, redirect: AnyRedirect] | [typeof CANCELED];
type LaneResult = ProjectedLane | ControlOutcome;
export declare function waitFor<T>(value: T | PromiseLike<T>, signal: AbortSignal): Promise<T>;
export declare function getRoute(router: AnyRouter, match: WorkMatch): AnyRoute;
export declare function navigateFrom(router: AnyRouter, location: ParsedLocation): (opts: any) => Promise<void>;
export declare function laneInputs(router: AnyRouter, location: ParsedLocation): LaneInputs;
/**
* Not passing in a `next` ownership recipient
* is equivalent to discarding the match resources
*/
export declare function transferMatchResources(router: AnyRouter, previous: Array<AnyRouteMatch>, next?: Array<AnyRouteMatch>): void;
export declare function cacheLoaderMatch(router: CoordinatorRouter, match: SettledMatch, planned: AnyRouteMatch | undefined): void;

@@ -142,3 +114,2 @@ export declare function projectLane(router: AnyRouter, lane: ReducedLane, signal: AbortSignal, start?: number, end?: number): Promise<ProjectedLane>;

sync?: boolean;
_dedupe?: boolean;
}): Promise<void>;

@@ -145,0 +116,0 @@ export declare function refreshClientRoute(router: CoordinatorRouter): Promise<void>;

@@ -1,6 +0,5 @@

import { deepEqual } from "./utils.js";
import { isNotFound } from "./not-found.js";
import { isRedirect } from "./redirect.js";
import { hydrateSsrMatchId } from "./ssr/ssr-match-id.js";
import { _getUserHistoryState, getLocationChangeInfo, runRouteLifecycle } from "./router.js";
import { getLocationChangeInfo, runRouteLifecycle } from "./router.js";
//#region src/load-client.ts

@@ -14,10 +13,12 @@ function replaceRouteChunk(route, lazyFn) {

}
function loadComponents(route) {
function loadComponents(route, onPendingReady) {
const component = preloadComponent(route, "component");
const pending = preloadComponent(route, "pendingComponent");
if (component && pending) return Promise.all([component, pending]).then(() => {});
return component ?? pending;
const pendingReady = onPendingReady && pending ? pending.then(onPendingReady) : pending;
if (onPendingReady && !pending) onPendingReady();
if (component && pendingReady) return Promise.all([component, pendingReady]).then(() => {});
return component ?? pendingReady;
}
function loadRouteChunk(route, componentType) {
const afterLazy = () => componentType === false ? void 0 : componentType ? preloadComponent(route, componentType) : loadComponents(route);
function loadRouteChunk(route, componentType, onPendingReady) {
const afterLazy = () => componentType === false ? void 0 : componentType ? preloadComponent(route, componentType) : loadComponents(route, onPendingReady);
const current = route._lazy;

@@ -111,3 +112,3 @@ if (current) return current === true ? afterLazy() : current.then(afterLazy);

}
async function contextualize(router, lane, options, end) {
async function contextualize(router, lane, options, end, planSuccessfulLane) {
const [location, matches] = lane;

@@ -193,6 +194,11 @@ const signal = options[0].signal;

}
planSuccessfulLane();
}
function releaseOwnedFlight(router, id, flight) {
function releaseOwnedFlight(router, match, flight) {
if (!flight || --flight[2]) return;
if (router._flights?.get(id) === flight) router._flights.delete(id);
if (router._flights?.get(match.id) === flight) {
const current = router._tx;
if (current && !current[0].signal.aborted && !(process.env.NODE_ENV !== "production" && current[6]) && !current[3].includes(match) && current[3].some((candidate) => candidate.id === match.id) && current[3].some((candidate) => candidate.isFetching === "beforeLoad")) return;
router._flights.delete(match.id);
}
return flight[1];

@@ -203,23 +209,4 @@ }

match._flight = void 0;
releaseOwnedFlight(router, match.id, flight)?.abort();
releaseOwnedFlight(router, match, flight)?.abort();
}
function laneInputs(router, location) {
const masked = location.maskedLocation;
return [
router.routeTree,
router.options.context ?? {},
router.options.additionalContext,
_getUserHistoryState(location.state),
location.search,
masked && [
masked.href,
_getUserHistoryState(masked.state),
masked.search,
masked.unmaskOnReload
]
];
}
function samePreloadLane(preload, router, location, redirects) {
return preload[3] === router._committed && preload[5] === redirects && deepEqual(preload[4], laneInputs(router, location)) && !preload[0].some((match) => getRoute(router, match).options.preload === false);
}
/**

@@ -234,3 +221,3 @@ * Not passing in a `next` ownership recipient

match._flight = void 0;
const controller = releaseOwnedFlight(router, match.id, flight);
const controller = releaseOwnedFlight(router, match, flight);
if (controller) abort.push(controller);

@@ -240,6 +227,23 @@ }

}
function discardPreload(router, preload) {
preload[1].abort();
transferMatchResources(router, preload[0]);
function transferPredecessorResources(router, previous, next) {
const abort = [];
for (const match of previous) if (!next.includes(match)) {
const flight = match._flight;
match._flight = void 0;
if (flight?.[2] === 1 && router._flights?.get(match.id) === flight && !(process.env.NODE_ENV !== "production" && router._tx?.[6]) && next.some((candidate) => candidate.id === match.id)) flight[2] = 0;
else {
const controller = releaseOwnedFlight(router, match, flight);
if (controller) abort.push(controller);
}
}
for (const controller of abort) controller.abort();
}
function releaseUnownedFlights(router) {
const abort = [];
for (const [id, flight] of router._flights ?? []) if (!flight[2]) {
router._flights.delete(id);
abort.push(flight[1]);
}
for (const controller of abort) controller.abort();
}
function acquireMatchResources(matches) {

@@ -282,34 +286,26 @@ for (const match of matches) {

let flight = match._flight;
let joined = !!flight;
setFetching(router, match, "loader", owner);
try {
for (;;) {
if (!flight) {
const controller = new AbortController();
flight = [
Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, controller, parentMatchPromise, preload))).then((value) => normalize(value, false, route.id), (cause) => normalize(cause, true, route.id)).then((result) => {
return result[0] === ERROR && match._flight === flight ? normalizeError(route, result[1]) : result;
}),
controller,
1
];
(router._flights ??= /* @__PURE__ */ new Map()).set(match.id, flight);
}
match._flight = flight;
match.abortController = flight[1];
try {
const outcome = await waitFor(flight[0], signal);
if (!joined || outcome[0] === SUCCESS || outcome[0] === REDIRECTED) return outcome;
} catch (cause) {
if (cause === signal) {
releaseFlight(router, match);
return [CANCELED];
}
throw cause;
}
releaseFlight(router, match);
if (signal.aborted) return [CANCELED];
flight = void 0;
joined = false;
if (!flight) {
const controller = new AbortController();
flight = [
Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, controller, parentMatchPromise, preload))).then((value) => normalize(value, false, route.id), (cause) => normalize(cause, true, route.id)).then((result) => {
if (result[0] !== SUCCESS && router._flights?.get(match.id) === flight) {
router._flights.delete(match.id);
if (!flight[2]) controller.abort();
}
return result[0] === ERROR && flight[2] ? normalizeError(route, result[1]) : result;
}),
controller,
1
];
(router._flights ??= /* @__PURE__ */ new Map()).set(match.id, flight);
}
match._flight = flight;
match.abortController = flight[1];
return await waitFor(flight[0], signal);
} catch (cause) {
if (cause !== signal) throw cause;
releaseFlight(router, match);
return [CANCELED];
} finally {

@@ -359,6 +355,6 @@ setFetching(router, match, false, owner);

const plannedCacheMatch = preload ? router._cache.get(match.id) : void 0;
let configured;
let reload = false;
let reloadFailure;
try {
let configured;
if (match.status === "success") {

@@ -384,5 +380,10 @@ configured = route.options.shouldReload;

const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
let donor = (!preload || route.options.preload !== false) && routeLoader && !(process.env.NODE_ENV !== "production" && router._tx?.[6]) ? router._flights?.get(match.id) : void 0;
if (donor === match._flight || reloadFailure) donor = void 0;
else if (donor && !reload && !preload && configured === void 0) reload = true;
else if (!reload) donor = void 0;
const background = !!(routeLoader && reload && match.status === "success" && !preload && !options[5] && ((typeof routeLoader === "function" ? void 0 : routeLoader?.staleReloadMode) ?? router.options.defaultStaleReloadMode) !== "blocking");
const loaded = reload && (!preload || route.options.preload !== false);
const blocking = loaded && !background && (match.status !== "success" || !!routeLoader);
const onLazyReady = route.lazyFn && route._lazy !== true ? options[8] : void 0;
if (loaded && !routeLoader) {

@@ -392,9 +393,7 @@ match.invalid = false;

}
let donor = loaded && routeLoader ? router._flights?.get(match.id) : void 0;
if (donor === match._flight) donor = void 0;
else if (donor) donor[2]++;
if (donor) donor[2]++;
if (blocking) {
const acceptedFlight = match._flight;
match._flight = donor;
releaseOwnedFlight(router, match.id, acceptedFlight)?.abort();
releaseOwnedFlight(router, match, acceptedFlight)?.abort();
if (match.status === "success") match.status = "pending";

@@ -408,3 +407,3 @@ options[8]?.();

if (result[0] === SUCCESS) {
if (preload && routeLoader) cacheLoaderMatch(router, match, plannedCacheMatch);
if (preload && routeLoader && !options[0].signal.aborted) cacheLoaderMatch(router, match, plannedCacheMatch);
match.status = "pending";

@@ -415,5 +414,3 @@ }

});
const chunkFailure = waitFor(Promise.resolve().then(() => loadRouteChunk(route)), options[0].signal).then(() => {
options[8]?.();
}, (cause) => [index, normalizeLaneError(route, cause, options)]).then((failure) => outcome.then((result) => {
const chunkFailure = waitFor(Promise.resolve().then(() => loadRouteChunk(route, void 0, onLazyReady)), options[0].signal).then(() => void 0, (cause) => [index, normalizeLaneError(route, cause, options)]).then((failure) => outcome.then((result) => {
if (blocking && !failure && result[0] === SUCCESS && match.status === "pending" && options[2]()) {

@@ -618,16 +615,22 @@ match.status = "success";

let end = plannedBoundary < 0 ? matches.length : plannedBoundary + 1;
const failure = await contextualize(router, matched, options, end);
if (failure) options[5] = true;
const tasks = [];
const start = options[7] ?? 0;
let semanticParent = start ? Promise.resolve(matched[1][start - 1]) : void 0;
end = failure?.[0] ?? end;
if (failure?.[1][0] === NOT_FOUND) {
failure[2] = await getNotFoundBoundary(router, matched[1], failure, options[0].signal);
end = Math.min(end, failure[2] + 1);
} else if ((failure?.[1][0] ?? 0) >= REDIRECTED) end = 0;
for (let index = start; index < end; index++) {
if (options[0].signal.aborted) break;
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options);
const planSuccessfulLane = () => {
for (let index = start; index < end; index++) {
if (options[0].signal.aborted) break;
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options);
}
};
const failure = await contextualize(router, matched, options, end, planSuccessfulLane);
if (failure) {
options[5] = true;
end = failure[0];
if (failure[1][0] === NOT_FOUND) {
failure[2] = await getNotFoundBoundary(router, matched[1], failure, options[0].signal);
end = Math.min(end, failure[2] + 1);
} else if (failure[1][0] >= REDIRECTED) end = 0;
planSuccessfulLane();
}
if (options[2]() && !options[4]) releaseUnownedFlights(router);
let reduced;

@@ -722,3 +725,3 @@ try {

offered[boundary].status = "pending";
const ack = router.startTransition(() => router.stores.setMatches(offered), offered, true).then((rendered) => {
const ack = router.startTransition(() => router.stores.setMatches(offered), offered).then((rendered) => {
if (rendered && router._pending === session && session[4] === ack && !session[2]) session[2] = Date.now() + min;

@@ -820,5 +823,6 @@ return rendered;

async function transitionRefresh(router, tx, lane, changeInfo) {
const refresh = tx[6];
const checkpoint = {
previousMatches: router._committed,
previousPresentation: tx[6]?.[0] ?? router.stores.matches.get(),
previousPresentation: refresh[0],
previousCache: router._cache,

@@ -830,3 +834,3 @@ commitPromise: router._commitPromise,

finishPending(router, tx);
router._rollbackRefresh = rollback;
refresh[2] = rollback;
commitRefreshMatches(router, tx, lane[1], checkpoint);

@@ -844,3 +848,3 @@ if (!checkpoint.published || router._tx !== tx) return;

const rollback = () => {
if (router._rollbackRefresh === rollback) router._rollbackRefresh = void 0;
if (refresh[2] === rollback) refresh[2] = void 0;
const restored = rollbackPublication(router, tx, lane, checkpoint);

@@ -852,5 +856,5 @@ router._cancelTransition?.();

const rendered = await router.startTransition(commit, lane[1]);
if (router._rollbackRefresh === rollback) router._rollbackRefresh = void 0;
if (refresh[2] === rollback) refresh[2] = void 0;
if (checkpoint.published) {
const handoff = tx[6]?.[1];
const handoff = refresh[1];
if (handoff && router._handoff === handoff) handoff[1]();

@@ -932,3 +936,3 @@ if (router._tx === tx) tx[6] = void 0;

}
async function runClientTransaction(router, tx, forceStaleReload, onReady, sync, resolvedPrefix, adopted, retained) {
async function runClientTransaction(router, tx, forceStaleReload, onReady, sync, resolvedPrefix) {
const options = [

@@ -945,20 +949,3 @@ tx[0],

];
let result;
try {
result = adopted ? await adopted[2] : await executeClientLane(router, tx[2], tx[3], options);
} finally {
if (retained) discardPreload(router, retained);
}
if (adopted && router._tx === tx && (isControl(result) && result[0] === CANCELED || !isControl(result) && result[1].some((match) => match.status !== "success" || match._notFound))) {
const donors = tx[3];
tx[3] = [];
transferMatchResources(router, donors);
tx[0].abort();
if (router._tx !== tx) return;
const controller = new AbortController();
tx[0] = options[0] = controller;
tx[3] = router.matchRoutes(tx[2], { _controller: controller });
acquireMatchResources(tx[3]);
result = await executeClientLane(router, tx[2], tx[3], options);
}
const result = await executeClientLane(router, tx[2], tx[3], options);
if (isControl(result)) {

@@ -1059,3 +1046,3 @@ if (result[0] === REDIRECTED && router._tx === tx) {

if (process.env.NODE_ENV !== "production") {
router._rollbackRefresh?.();
router._tx?.[6]?.[2]?.();
rematerialize = !!router._refreshNextLoad || !!router._tx?.[6];

@@ -1070,6 +1057,2 @@ }

const redirects = pendingLocation?.href === location.href ? pendingLocation._redirects ?? 0 : 0;
if (opts?._dedupe && !redirects && previousOwner && !rematerialize && previousOwner[2].href === location.href && router.stores.status.get() === "pending") {
await awaitCurrent(router);
return;
}
const handoff = router._handoff;

@@ -1082,3 +1065,3 @@ const hydrationController = rematerialize ? void 0 : handoff?.[0]();

previousPreflight?.abort();
if (preflight.signal.aborted || router._tx !== previousOwner) {
if (preflight.signal.aborted) {
await awaitCurrent(router, previousOwner);

@@ -1092,8 +1075,7 @@ return;

});
if (!preflight.signal.aborted && router._tx === previousOwner) router.emit({
if (!preflight.signal.aborted) router.emit({
type: "onBeforeLoad",
...changeInfo
});
if (preflight.signal.aborted || router._tx !== previousOwner) {
preflight.abort();
if (preflight.signal.aborted) {
await awaitCurrent(router, previousOwner);

@@ -1103,57 +1085,31 @@ return;

const sameHref = previousLocation.href === location.href;
let adopted = router._preloads?.get(location.href);
let retained;
if (rematerialize && adopted) {
router._preloads.delete(location.href);
discardPreload(router, adopted);
adopted = void 0;
if (preflight.signal.aborted || router._tx !== previousOwner) {
preflight.abort();
await awaitCurrent(router, previousOwner);
return;
}
}
if (adopted && (hydrationController || !samePreloadLane(adopted, router, pendingLocation?.href === location.href ? pendingLocation : location, redirects))) {
router._preloads.delete(location.href);
retained = adopted;
adopted = void 0;
}
let matches;
let controller = preflight;
let resolvedPrefix;
if (adopted) {
controller = adopted[1];
matches = adopted[0];
router._preloads.delete(location.href);
} else {
try {
matches = process.env.NODE_ENV !== "production" && rematerialize ? router.matchRoutes(location, {
_controller: preflight,
_rematerialize: true
}) : router.matchRoutes(location, { _controller: preflight });
acquireMatchResources(matches);
} catch (cause) {
preflight.abort();
if (retained) discardPreload(router, retained);
if (!isRedirect(cause)) {
if (process.env.NODE_ENV !== "production" && rematerialize) router._refreshNextLoad = void 0;
await awaitCurrent(router);
router._commitPromise?.resolve();
router._commitPromise = void 0;
return;
}
await router.navigate({
...cause.options,
replace: true,
ignoreBlocker: true
});
await awaitCurrent(router, previousOwner);
try {
matches = process.env.NODE_ENV !== "production" && rematerialize ? router.matchRoutes(location, {
_controller: preflight,
_rematerialize: true
}) : router.matchRoutes(location, { _controller: preflight });
acquireMatchResources(matches);
} catch (cause) {
preflight.abort();
if (!isRedirect(cause)) {
if (process.env.NODE_ENV !== "production" && rematerialize) router._refreshNextLoad = void 0;
await awaitCurrent(router);
router._commitPromise?.resolve();
router._commitPromise = void 0;
return;
}
resolvedPrefix = hydrationController ? handoff[1](matches) : void 0;
if (resolvedPrefix) controller = hydrationController;
else hydrationController?.abort();
await router.navigate({
...cause.options,
replace: true,
ignoreBlocker: true
});
await awaitCurrent(router, previousOwner);
return;
}
if (router._preflight !== preflight || router._tx !== previousOwner) {
preflight.abort();
const resolvedPrefix = hydrationController ? handoff[1](matches) : void 0;
if (resolvedPrefix) controller = hydrationController;
else hydrationController?.abort();
if (preflight.signal.aborted) {
transferMatchResources(router, matches);

@@ -1170,3 +1126,3 @@ await awaitCurrent(router, previousOwner);

Date.now(),
Promise.resolve().then(() => runClientTransaction(router, tx, sameHref, () => offerPending(router, tx), opts?.sync, resolvedPrefix, adopted, retained)).catch(() => {
Promise.resolve().then(() => runClientTransaction(router, tx, sameHref, () => offerPending(router, tx), opts?.sync, resolvedPrefix)).catch(() => {
if (router._tx === tx) restoreCommitted(router, tx);

@@ -1180,3 +1136,2 @@ })

router._tx = tx;
if (!rematerialize && router._handoff === handoff) router._handoff = void 0;
if (previousOwner) {

@@ -1188,3 +1143,3 @@ for (const match of router.stores.matches.get()) {

previousOwner[0].abort();
transferMatchResources(router, previousOwner[3]);
transferPredecessorResources(router, previousOwner[3], tx[3]);
}

@@ -1209,3 +1164,3 @@ if (router._tx !== tx) {

async function refreshClientRoute(router) {
router._rollbackRefresh?.();
router._tx?.[6]?.[2]?.();
const pending = router._tx;

@@ -1221,12 +1176,5 @@ if (pending && !pending[6] && router.stores.status.get() === "pending") {

}
function followPreloadRedirect(router, result, location, owner, redirects) {
if (result[0] === REDIRECTED && !result[1].options.reloadDocument && router._tx === owner) return preloadClientRoute(router, {
...result[1].options,
_fromLocation: location
}, redirects + 1);
}
async function preloadClientRoute(router, opts, redirects = 0) {
if (redirects > 20) return;
const owner = router._tx;
if (process.env.NODE_ENV !== "production" && (router._refreshNextLoad || owner?.[6])) return;
if (process.env.NODE_ENV !== "production" && (router._refreshNextLoad || router._tx?.[6])) return;
const location = opts._builtLocation ?? router.buildLocation(opts);

@@ -1236,54 +1184,34 @@ const base = router._committed;

let matches;
let preload;
let replaced;
try {
const pending = router._preloads?.get(location.href);
if (pending) {
if (samePreloadLane(pending, router, location, redirects)) {
const result = await pending[2];
return isControl(result) ? followPreloadRedirect(router, result, location, owner, redirects) : result[1];
}
router._preloads.delete(location.href);
replaced = pending;
}
matches = router.matchRoutes(location, { _controller: controller });
acquireMatchResources(matches);
const promise = Promise.resolve().then(() => executeClientLane(router, location, matches, [
controller,
redirects,
() => true,
base,
true
])).finally(() => {
if (replaced) discardPreload(router, replaced);
});
preload = [
matches,
controller,
promise,
base,
laneInputs(router, location),
redirects
];
(router._preloads ??= /* @__PURE__ */ new Map()).set(location.href, preload);
const result = await promise;
if (router._preloads?.get(location.href) !== preload) return isControl(result) ? void 0 : result[1];
router._preloads.delete(location.href);
if (isControl(result)) {
} catch (cause) {
controller.abort();
if (!isNotFound(cause)) console.error(cause);
return;
}
(router._preloads ??= /* @__PURE__ */ new Map()).set(controller, matches);
let active;
try {
let result;
try {
result = await executeClientLane(router, location, matches, [
controller,
redirects,
() => true,
base,
true
]);
} finally {
active = router._preloads.delete(controller);
transferMatchResources(router, matches);
controller.abort();
transferMatchResources(router, matches);
return followPreloadRedirect(router, result, location, owner, redirects);
}
transferMatchResources(router, result[1]);
controller.abort();
return result[1];
if (!isControl(result)) return result[1];
if (active && result[0] === REDIRECTED && !result[1].options.reloadDocument) return preloadClientRoute(router, {
...result[1].options,
_fromLocation: location
}, redirects + 1);
} catch (cause) {
if (!preload || router._preloads?.get(location.href) === preload) {
if (preload) router._preloads.delete(location.href);
controller.abort();
if (matches) transferMatchResources(router, matches);
}
if (router._tx !== owner) return;
if (!isNotFound(cause)) console.error(cause);
return;
}

@@ -1303,4 +1231,3 @@ }

router.ssr = { manifest: dehydratedRouter.manifest };
const nonce = document.querySelector("meta[property=\"csp-nonce\"]")?.content;
router.options.ssr = { nonce };
router.options.ssr = { nonce: document.querySelector("meta[property=\"csp-nonce\"]")?.content };
const dehydratedMatches = dehydratedRouter.matches;

@@ -1311,21 +1238,20 @@ const controller = new AbortController();

previousPreflight?.abort();
const retire = (cause) => {
if (router._preflight === controller) router._preflight = void 0;
controller.abort(cause);
return false;
};
const isCurrent = () => !router._tx && router._preflight === controller && !controller.signal.aborted || retire();
const isCurrent = () => router._preflight === controller;
let location;
let candidates;
let handoffInputs;
let handoffHistoryHref;
let handoffHistoryState;
try {
await waitFor(router.options.hydrate?.(dehydratedRouter.dehydratedData), controller.signal);
if (!isCurrent()) return;
const historyLocation = router.history.location;
handoffHistoryHref = historyLocation.href;
handoffHistoryState = historyLocation.state;
router.updateLatestLocation();
location = router.latestLocation;
router.stores.location.set(location);
handoffInputs = laneInputs(router, location);
candidates = router.matchRoutes(location, { _controller: controller });
} catch (cause) {
retire(cause);
if (isCurrent()) router._preflight = void 0;
controller.abort(cause);
if (cause !== controller.signal) throw cause;

@@ -1379,3 +1305,2 @@ }

}
let verifiedContextEnd = verifiedAssetEnd;
if (!isTerminal && committed.length === shared && shared < candidates.length) pendingBoundary = shared;

@@ -1396,11 +1321,7 @@ const chunks = committed.map(async (match) => {

} catch {
isCurrent();
return;
}
if (!isCurrent()) return;
if (chunkFailure < committed.length) {
verifiedContextEnd = Math.min(verifiedContextEnd, chunkFailure);
retryFrom(chunkFailure);
}
const contextEnd = Math.max(pendingBoundary === committed.length ? committed.length + 1 : committed.length, verifiedContextEnd);
if (chunkFailure < committed.length) retryFrom(chunkFailure);
const contextEnd = Math.max(pendingBoundary === committed.length ? committed.length + 1 : committed.length, chunkFailure < chunks.length ? chunkFailure : verifiedAssetEnd);
for (let index = 0; index < contextEnd; index++) {

@@ -1449,3 +1370,3 @@ const match = candidates[index];

const boundary = presented[pendingBoundary];
dataOnlyAssetEnd = boundary.status === "success" && boundary.ssr === "data-only" && boundary.error === void 0 && !boundary._notFound && verifiedAssetEnd > pendingBoundary + 1 ? verifiedAssetEnd : void 0;
dataOnlyAssetEnd = boundary.ssr === "data-only" && verifiedAssetEnd > pendingBoundary + 1 ? verifiedAssetEnd : void 0;
presented = presented.slice();

@@ -1459,8 +1380,11 @@ presented[pendingBoundary] = {

}
const claim = () => needsClientLoad && !router._tx && router.latestLocation.state === location.state && deepEqual(handoffInputs, laneInputs(router, router.latestLocation)) && router._committed === committedMatches && committedMatches.length && !controller.signal.aborted ? controller : void 0;
const claim = () => {
const historyLocation = router.history.location;
return needsClientLoad && !router._tx && historyLocation.href === handoffHistoryHref && historyLocation.state === handoffHistoryState && router._committed === committedMatches && committedMatches.length && !controller.signal.aborted ? controller : void 0;
};
const handoff = [claim, (matches) => {
if (router._handoff !== handoff) return;
router._handoff = void 0;
const prefix = committedMatches.length;
if (!matches || !claim() || committedMatches.some((match, index) => match.id !== matches[index]?.id)) {
router._handoff = void 0;
controller.abort();

@@ -1472,3 +1396,3 @@ return;

for (let index = prefix; index < handoffAssetEnd; index++) if (candidates[index]?.id !== matches[index]?.id) {
handoffAssetEnd = index > (pendingBoundary ?? -1) + 1 ? index : void 0;
handoffAssetEnd = index > pendingBoundary + 1 ? index : void 0;
break;

@@ -1498,4 +1422,4 @@ }

//#endregion
export { _getAssetMatches, _getRenderedMatches, hydrate, loadClientRoute, loadRouteChunk, preloadClientRoute, refreshClientRoute, replaceRouteChunk, transferMatchResources };
export { _getAssetMatches, _getRenderedMatches, hydrate, loadClientRoute, loadRouteChunk, preloadClientRoute, refreshClientRoute, replaceRouteChunk };
//# sourceMappingURL=load-client.js.map

@@ -1,2 +0,1 @@

import { loadRouteChunk, ActivePreload, LoadTransaction, LoaderFlight, PendingSession } from './load-client.js';
import { LRUCache } from './lru-cache.js';

@@ -6,2 +5,3 @@ import { ProcessRouteTreeResult, ProcessedTree } from './new-process-route-tree.js';

import { AnyRedirect, ResolvedRedirect } from './redirect.js';
import { LoadTransaction, LoaderFlight, PendingSession } from './load-client.js';
import { ServerLoadResult } from './load-server.js';

@@ -486,6 +486,5 @@ import { HistoryAction, HistoryLocation, HistoryState, ParsedHistoryState, RouterHistory } from '@tanstack/history';

_signal?: AbortSignal;
_dedupe?: boolean;
}) => Promise<void>;
export type CommitLocationFn = ({ viewTransition, ignoreBlocker, ...next }: ParsedLocation & CommitLocationOptions) => Promise<void>;
export type StartTransitionFn = (fn: () => void, expected: Array<AnyRouteMatch>, urgent?: boolean) => Promise<boolean>;
export type StartTransitionFn = (fn: () => void, expected: Array<AnyRouteMatch>) => Promise<boolean>;
export interface MatchRoutesFn {

@@ -607,4 +606,4 @@ (pathname: string, locationSearch?: AnySchema, opts?: MatchRoutesOpts): Array<MakeRouteMatchUnion>;

_flights?: Map<string, LoaderFlight>;
/** Whole speculative lanes that an identical navigation may adopt. */
_preloads?: Map<string, ActivePreload>;
/** Active speculative lanes retained for cancellation, invalidation, and cache clearing. */
_preloads?: Map<AbortController, Array<AnyRouteMatch>>;
/** Owns cancellable work before a client transaction publishes. */

@@ -618,4 +617,7 @@ _preflight?: AbortController;

_serverResult?: ServerLoadResult;
/** Framework callback that acknowledges an exact matches publication. */
_rendered?: (matches: Array<AnyRouteMatch>) => void;
/** Framework publication waiting for an exact render acknowledgement. */
_rendered?: [
offered?: Array<AnyRouteMatch>,
settle?: (rendered: boolean) => void
];
/** Development-only HMR reload for a route and its descendants. */

@@ -740,5 +742,7 @@ _refreshRoute: (() => Promise<void>) | undefined;

/**
* Invalidate the current matches and optionally force them back into a pending state.
* Invalidate selected match generations and optionally force current matches
* back into a pending state.
*
* - Marks all matches that pass the optional `filter` as `invalid: true`.
* - Marks committed and cached matches whose IDs are selected as invalid.
* - Retires selected active preloads so older work cannot publish fresh data.
*

@@ -751,3 +755,3 @@ * The next load decides when to publish pending UI, so invalidation does not

clearCache: ClearCacheFn<this>;
loadRouteChunk: typeof loadRouteChunk;
loadRouteChunk: (route: AnyRoute, componentType?: 'errorComponent' | 'notFoundComponent' | false) => Promise<void> | undefined;
preloadRoute: PreloadRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;

@@ -754,0 +758,0 @@ matchRoute: MatchRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;

@@ -10,3 +10,3 @@ import { DEFAULT_PROTOCOL_ALLOWLIST, decodePath, deepEqual, encodePathLikeUrl, findLast, functionalUpdate, hasKeys, isDangerousProtocol, last, nullReplaceEqualDeep, replaceEqualDeep } from "./utils.js";

import { isRedirect } from "./redirect.js";
import { loadClientRoute, loadRouteChunk, preloadClientRoute, refreshClientRoute, replaceRouteChunk, transferMatchResources } from "./load-client.js";
import { loadClientRoute, loadRouteChunk, preloadClientRoute, refreshClientRoute, replaceRouteChunk } from "./load-client.js";
import { composeRewrites, executeRewriteInput, executeRewriteOutput, rewriteBasepath } from "./rewrite.js";

@@ -391,3 +391,3 @@ import { createRouterStores } from "./stores.js";

this._commitPromise = commitPromise;
if (isSameLocation) this.load({ _dedupe: true });
if (isSameLocation) this.load();
else {

@@ -523,5 +523,16 @@ let { maskedLocation, hashScrollIntoView, ...nextHistory } = next;

const filter = opts?.filter;
const invalidIds = filter ? new Set([...committedMatches, ...this._cache.values()].filter((match) => filter(match)).map((match) => match.id)) : void 0;
const preloads = this._preloads;
const invalidIds = new Set([
...committedMatches,
...this._cache.values(),
...[...preloads?.values() ?? []].flat(),
...this._tx?.[3] ?? []
].filter((match) => !filter || filter(match)).map((match) => match.id));
const discardedPreloads = [];
for (const [controller, matches] of preloads ?? []) if (matches.some((match) => invalidIds.has(match.id))) {
preloads.delete(controller);
discardedPreloads.push(controller);
}
const invalidate = (d) => {
if (!invalidIds || invalidIds.has(d.id)) {
if (invalidIds.has(d.id)) {
const route = this.routesById[d.routeId];

@@ -541,7 +552,9 @@ const next = {

};
const committed = committedMatches.map(invalidate);
this._committed = committed;
const cache = /* @__PURE__ */ new Map();
for (const [id, match] of this._cache) cache.set(id, invalidate(match));
this._cache = cache;
this._committed = committedMatches.map(invalidate);
for (const [id, match] of this._cache) if (invalidIds.has(id)) {
match.invalid = true;
if (opts?.forcePending) match.status = "pending";
}
for (const id of invalidIds) this._flights?.delete(id);
for (const controller of discardedPreloads) controller.abort();
this.shouldViewTransition = false;

@@ -572,16 +585,24 @@ return this.load({ sync: opts?.sync });

const filter = opts?.filter;
const retained = /* @__PURE__ */ new Map();
const discarded = [];
for (const [id, match] of cached) if (filter && !filter(match)) retained.set(id, match);
else discarded.push(match);
const retainedPreloads = /* @__PURE__ */ new Map();
const discardedPreloads = [];
for (const [href, preload] of preloads ?? []) if (!filter || preload[0].some(filter)) {
discardedPreloads.push(preload);
discarded.push(...preload[0]);
} else retainedPreloads.set(href, preload);
this._cache = retained;
this._preloads = retainedPreloads;
transferMatchResources(this, discarded);
for (const preload of discardedPreloads) preload[1].abort();
const discardedIds = [];
for (const [id, match] of cached) if (!filter || filter(match)) {
discardedIds.push(id);
discarded.push(match);
}
const abort = [];
for (const [controller, matches] of preloads ?? []) if (!filter || matches.some(filter)) {
abort.push(controller);
discarded.push(...matches);
}
for (const id of discardedIds) cached.delete(id);
for (const controller of abort) preloads.delete(controller);
for (const match of discarded) {
const flight = match._flight;
match._flight = void 0;
if (flight && !--flight[2]) {
if (this._flights?.get(match.id) === flight) this._flights.delete(match.id);
abort.push(flight[1]);
}
}
for (const controller of abort) controller.abort();
};

@@ -936,4 +957,4 @@ this.loadRouteChunk = loadRouteChunk;

//#endregion
export { PathParamError, RouterCore, SearchParamError, _getUserHistoryState, defaultSerializeError, getInitialRouterState, getLocationChangeInfo, lazyFn, runRouteLifecycle, trailingSlashOptions };
export { PathParamError, RouterCore, SearchParamError, defaultSerializeError, getInitialRouterState, getLocationChangeInfo, lazyFn, runRouteLifecycle, trailingSlashOptions };
//# sourceMappingURL=router.js.map
{
"name": "@tanstack/router-core",
"version": "1.171.16-pre.0",
"version": "1.171.16",
"description": "Modern and scalable routing for React applications",

@@ -5,0 +5,0 @@ "author": "Tanner Linsley",

---
name: router-core/auth-and-guards
name: auth-and-guards
description: >-

@@ -9,8 +9,8 @@ Route protection with beforeLoad, redirect()/throw redirect(),

for auth state.
type: sub-skill
library: tanstack-router
library_version: '1.166.2'
metadata:
type: sub-skill
library: tanstack-router
library_version: '1.171.15'
requires:
- router-core
- router-core/data-loading
sources:

@@ -381,3 +381,3 @@ - TanStack/router:docs/router/guide/authenticated-routes.md

A `beforeLoad` redirect protects the **route's UI**, not the **server functions** declared on it. `createServerFn` produces an RPC endpoint reachable by direct POST regardless of which route renders the calling UI. An attacker doesn't have to load `/_authenticated/orders` — they can curl the RPC endpoint directly.
A `beforeLoad` redirect protects the **route's UI**, not the **server functions** declared on it. `createServerFn` produces an RPC endpoint reachable directly with its declared HTTP method regardless of which route renders the calling UI. An attacker doesn't have to load `/_authenticated/orders` — they can call this GET RPC endpoint directly.

@@ -415,2 +415,6 @@ ```tsx

### CRITICAL: The anonymous destination can still disclose protected data
Protect the entire anonymous response, not only the API call. A public login or unauthorized page still leaks data if its title, copy, search params, or serialized loader state names the protected user, tenant, record, or resource. Test a direct anonymous request and follow redirects. Assert that the handler rejects before reading private data, no protected loader runs, the final HTML and serialized state contain no protected identity, and the redirect contains only a sanitized relative return URL.
### HIGH: Auth check in component instead of beforeLoad

@@ -441,4 +445,2 @@

`beforeLoad` runs before any component rendering and before the loader. It completely prevents the flash.
### HIGH: Not re-throwing redirects in try/catch

@@ -497,4 +499,2 @@

---
## Cross-References

@@ -501,0 +501,0 @@

---
name: router-core/code-splitting
name: code-splitting
description: >-

@@ -8,5 +8,6 @@ Automatic code splitting (autoCodeSplitting), .lazy.tsx convention,

splitBehavior programmatic config, critical vs non-critical properties.
type: sub-skill
library: tanstack-router
library_version: '1.166.2'
metadata:
type: sub-skill
library: tanstack-router
library_version: '1.171.15'
requires:

@@ -13,0 +14,0 @@ - router-core

---
name: router-core/data-loading
name: data-loading
description: >-

@@ -9,5 +9,6 @@ Route loader option, loaderDeps for cache keys, staleTime/gcTime/

Await component, deferred data loading with unawaited promises.
type: sub-skill
library: tanstack-router
library_version: '1.166.2'
metadata:
type: sub-skill
library: tanstack-router
library_version: '1.171.15'
requires:

@@ -220,4 +221,4 @@ - router-core

export const Route = createFileRoute('/posts')({
beforeLoad: () => ({
fetchPosts: () => fetch('/api/posts').then((r) => r.json()),
beforeLoad: ({ context }) => ({
fetchPosts: context.fetchPosts,
}),

@@ -228,2 +229,18 @@ loader: ({ context: { fetchPosts } }) => fetchPosts(),

Keep the implementation SSR-safe when the router is used by TanStack Start. A relative `fetch('/api/posts')` works in a browser event handler, but Node and many server runtimes require an absolute URL during SSR. For app-internal data in Start, call a server function from the loader:
```tsx
import { createServerFn } from '@tanstack/react-start'
const getPosts = createServerFn({ method: 'GET' }).handler(() => {
return db.posts.findMany()
})
export const Route = createFileRoute('/posts')({
loader: () => getPosts(),
})
```
Use a server route plus an origin-derived absolute URL only when the HTTP boundary itself is required. Do not hard-code the production origin.
### Deferred Data Loading

@@ -282,4 +299,4 @@

const handleAdd = async () => {
await fetch('/api/posts', { method: 'POST', body: '...' })
router.invalidate()
await createPost({ title: 'New post' })
await router.invalidate({ sync: true })
}

@@ -291,7 +308,5 @@

For synchronous invalidation (wait until loaders finish):
Use `await router.invalidate({ sync: true })` when the next step requires refreshed loader data.
```tsx
await router.invalidate({ sync: true })
```
Treat the mutation and invalidation as one workflow. The mutation must persist before invalidation starts, and the loader must read from the same authoritative store. Verify create, update, and delete through the rendered route, including a fresh reload; local component state can hide a stale loader or non-persistent write.

@@ -369,12 +384,9 @@ ### Error Handling

// CORRECT — loaders run in the browser, use fetch or API calls
// CORRECT for an SPA — use a client-safe API helper
export const Route = createFileRoute('/posts')({
loader: async () => {
const res = await fetch('/api/posts')
return res.json()
},
loader: () => fetchPosts(),
})
```
Do NOT put database queries, filesystem access, or server-only code in loaders unless you are using TanStack Start server functions.
Do NOT put database queries, filesystem access, or server-only code directly in loaders. In TanStack Start, put that work in a server function and call the function from the loader. Do not use a relative `fetch('/api/...')` in an SSR loader.

@@ -381,0 +393,0 @@ ### MEDIUM: Not understanding staleTime default is 0

---
name: router-core/navigation
name: navigation
description: >-

@@ -9,5 +9,6 @@ Link component, useNavigate, Navigate component, router.navigate,

linkOptions helper, scroll restoration, MatchRoute.
type: sub-skill
library: tanstack-router
library_version: '1.166.2'
metadata:
type: sub-skill
library: tanstack-router
library_version: '1.171.15'
requires:

@@ -14,0 +15,0 @@ - router-core

---
name: router-core/not-found-and-errors
name: not-found-and-errors
description: >-

@@ -8,5 +8,6 @@ notFound() function, notFoundComponent, defaultNotFoundComponent,

masking (mask option, createRouteMask, unmaskOnReload).
type: sub-skill
library: tanstack-router
library_version: '1.166.2'
metadata:
type: sub-skill
library: tanstack-router
library_version: '1.171.15'
requires:

@@ -13,0 +14,0 @@ - router-core

---
name: router-core/path-params
name: path-params
description: >-

@@ -8,5 +8,6 @@ Dynamic path segments ($paramName), splat routes ($ / _splat),

i18n locale patterns.
type: sub-skill
library: tanstack-router
library_version: '1.166.2'
metadata:
type: sub-skill
library: tanstack-router
library_version: '1.171.15'
requires:

@@ -13,0 +14,0 @@ - router-core

---
name: router-core/search-params
name: search-params
description: >-

@@ -8,5 +8,6 @@ validateSearch, search param validation with Zod/Valibot/ArkType adapters,

inheritance, loaderDeps for cache keys, reading and writing search params.
type: sub-skill
library: tanstack-router
library_version: '1.166.2'
metadata:
type: sub-skill
library: tanstack-router
library_version: '1.171.15'
requires:

@@ -13,0 +14,0 @@ - router-core

@@ -8,5 +8,6 @@ ---

file naming conventions. Entry point for all router skills.
type: core
library: tanstack-router
library_version: '1.166.2'
metadata:
type: core
library: tanstack-router
library_version: '1.171.15'
---

@@ -22,2 +23,4 @@

Use this entry skill to choose one primary sub-skill. Do not load the full catalog. Load a second sub-skill only when the task crosses a real boundary, such as an authenticated loader that needs both `auth-and-guards` and `data-loading`.
## Sub-Skills

@@ -71,2 +74,18 @@

## Cross-Cutting Completion Checks
For route refactors:
1. Rename or move the route file; do not hand-edit the generated `createFileRoute` path.
2. Regenerate `routeTree.gen.ts` with the configured Router plugin or CLI.
3. Update links, redirects, `from` narrowing, params, and tests that reference the old route.
4. Run type tests and a production build. A typecheck alone does not prove route generation or bundling works.
For response schema changes:
1. Update the source model and shared validation schema.
2. Update the server function or API serializer so the field exists at runtime.
3. Update loader and component consumers without casts.
4. Assert the actual response payload in a unit or integration test. Typechecking cannot catch a serializer that omits the new field.
## Minimal Working Example

@@ -142,2 +161,2 @@

This skill targets `@tanstack/router-core` v1.166.2 and `@tanstack/react-router` v1.166.2. APIs are stable. Splat routes use `$` (not `*`); the `*` compat alias will be removed in v2.
This skill targets `@tanstack/router-core` v1.171.15. Splat routes use `$` (not `*`); the `*` compat alias will be removed in v2.
---
name: router-core/ssr
name: ssr
description: >-

@@ -10,5 +10,6 @@ Non-streaming and streaming SSR, RouterClient/RouterServer,

history on server, data serialization, document head management.
type: sub-skill
library: tanstack-router
library_version: '1.166.2'
metadata:
type: sub-skill
library: tanstack-router
library_version: '1.171.15'
requires:

@@ -15,0 +16,0 @@ - router-core

---
name: router-core/type-safety
name: type-safety
description: >-

@@ -9,5 +9,6 @@ Full type inference philosophy (never cast, never annotate inferred

and ValidateLinkOptions type utilities, as const satisfies pattern.
type: sub-skill
library: tanstack-router
library_version: '1.166.2'
metadata:
type: sub-skill
library: tanstack-router
library_version: '1.171.15'
requires:

@@ -493,2 +494,8 @@ - router-core

### 6. CRITICAL: Treating typecheck as proof of runtime schema propagation
Types can say a field exists while a database projection, API serializer, or server function omits it. When adding or renaming a field, trace the value through storage, validation, handler output, loader data, and rendered UI. Do not cast the response to the desired type.
Add a runtime assertion against the real handler or serialized response, such as `expect(await getOrder({ data: { id } })).toMatchObject({ totalCents: 2599 })`.
Then run the route-level test and production build. The type test remains necessary, but it is not the runtime contract test.
See also: router-core (Register setup), router-core/navigation (from narrowing), router-core/code-splitting (getRouteApi).

@@ -674,9 +674,11 @@ import type { HistoryState, ParsedHistoryState } from '@tanstack/history'

* - `false` - No preloading
* - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
* - `'intent'` - Preload the linked route when the user focuses, hovers over, or touches the link
* - `'viewport'` - Preload the linked route when it enters the viewport
* - `'render'` - Preload the linked route as soon as it renders
*/
preload?: false | 'intent' | 'viewport' | 'render'
/**
* When a preload strategy is set, this delays the preload by this many milliseconds.
* If the user exits the link before this delay, the preload will be cancelled.
* When the intent preload strategy is set, this delays focus and hover
* preloading by this many milliseconds. Touch intent preloads immediately.
* If focus or hover exits before this delay, the preload will be cancelled.
*/

@@ -683,0 +685,0 @@ preloadDelay?: number

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display