@tanstack/router-core 1.121.19 → 1.121.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Matches.cjs +13 -0
- package/dist/cjs/Matches.cjs.map +1 -0
- package/dist/cjs/Matches.d.cts +109 -0
- package/dist/cjs/RouterProvider.d.cts +26 -0
- package/dist/cjs/defer.cjs +25 -0
- package/dist/cjs/defer.cjs.map +1 -0
- package/dist/cjs/defer.d.cts +20 -0
- package/dist/cjs/fileRoute.d.cts +23 -0
- package/dist/cjs/history.d.cts +8 -0
- package/dist/cjs/index.cjs +79 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +41 -0
- package/dist/cjs/link.cjs +5 -0
- package/dist/cjs/link.cjs.map +1 -0
- package/dist/cjs/link.d.cts +212 -0
- package/dist/cjs/location.d.cts +12 -0
- package/dist/cjs/manifest.d.cts +24 -0
- package/dist/cjs/not-found.cjs +13 -0
- package/dist/cjs/not-found.cjs.map +1 -0
- package/dist/cjs/not-found.d.cts +20 -0
- package/dist/cjs/path.cjs +412 -0
- package/dist/cjs/path.cjs.map +1 -0
- package/dist/cjs/path.d.cts +56 -0
- package/dist/cjs/qss.cjs +36 -0
- package/dist/cjs/qss.cjs.map +1 -0
- package/dist/cjs/qss.d.cts +31 -0
- package/dist/cjs/redirect.cjs +42 -0
- package/dist/cjs/redirect.cjs.map +1 -0
- package/dist/cjs/redirect.d.cts +41 -0
- package/dist/cjs/root.cjs +5 -0
- package/dist/cjs/root.cjs.map +1 -0
- package/dist/cjs/root.d.cts +2 -0
- package/dist/cjs/route.cjs +119 -0
- package/dist/cjs/route.cjs.map +1 -0
- package/dist/cjs/route.d.cts +432 -0
- package/dist/cjs/routeInfo.d.cts +54 -0
- package/dist/cjs/router.cjs +1805 -0
- package/dist/cjs/router.cjs.map +1 -0
- package/dist/cjs/router.d.cts +627 -0
- package/dist/cjs/scroll-restoration.cjs +207 -0
- package/dist/cjs/scroll-restoration.cjs.map +1 -0
- package/dist/cjs/scroll-restoration.d.cts +38 -0
- package/dist/cjs/searchMiddleware.cjs +42 -0
- package/dist/cjs/searchMiddleware.cjs.map +1 -0
- package/dist/cjs/searchMiddleware.d.cts +5 -0
- package/dist/cjs/searchParams.cjs +61 -0
- package/dist/cjs/searchParams.cjs.map +1 -0
- package/dist/cjs/searchParams.d.cts +7 -0
- package/dist/cjs/serializer.d.cts +22 -0
- package/dist/cjs/structuralSharing.d.cts +4 -0
- package/dist/cjs/typePrimitives.d.cts +65 -0
- package/dist/cjs/useLoaderData.d.cts +5 -0
- package/dist/cjs/useLoaderDeps.d.cts +5 -0
- package/dist/cjs/useNavigate.d.cts +3 -0
- package/dist/cjs/useParams.d.cts +5 -0
- package/dist/cjs/useRouteContext.d.cts +9 -0
- package/dist/cjs/useSearch.d.cts +5 -0
- package/dist/cjs/utils.cjs +165 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +94 -0
- package/dist/cjs/validators.d.cts +51 -0
- package/dist/esm/Matches.d.ts +109 -0
- package/dist/esm/Matches.js +13 -0
- package/dist/esm/Matches.js.map +1 -0
- package/dist/esm/RouterProvider.d.ts +26 -0
- package/dist/esm/defer.d.ts +20 -0
- package/dist/esm/defer.js +25 -0
- package/dist/esm/defer.js.map +1 -0
- package/dist/esm/fileRoute.d.ts +23 -0
- package/dist/esm/history.d.ts +8 -0
- package/dist/esm/index.d.ts +41 -0
- package/dist/esm/index.js +79 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/link.d.ts +212 -0
- package/dist/esm/link.js +5 -0
- package/dist/esm/link.js.map +1 -0
- package/dist/esm/location.d.ts +12 -0
- package/dist/esm/manifest.d.ts +24 -0
- package/dist/esm/not-found.d.ts +20 -0
- package/dist/esm/not-found.js +13 -0
- package/dist/esm/not-found.js.map +1 -0
- package/dist/esm/path.d.ts +56 -0
- package/dist/esm/path.js +412 -0
- package/dist/esm/path.js.map +1 -0
- package/dist/esm/qss.d.ts +31 -0
- package/dist/esm/qss.js +36 -0
- package/dist/esm/qss.js.map +1 -0
- package/dist/esm/redirect.d.ts +41 -0
- package/dist/esm/redirect.js +42 -0
- package/dist/esm/redirect.js.map +1 -0
- package/dist/esm/root.d.ts +2 -0
- package/dist/esm/root.js +5 -0
- package/dist/esm/root.js.map +1 -0
- package/dist/esm/route.d.ts +432 -0
- package/dist/esm/route.js +119 -0
- package/dist/esm/route.js.map +1 -0
- package/dist/esm/routeInfo.d.ts +54 -0
- package/dist/esm/router.d.ts +627 -0
- package/dist/esm/router.js +1805 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/scroll-restoration.d.ts +38 -0
- package/dist/esm/scroll-restoration.js +207 -0
- package/dist/esm/scroll-restoration.js.map +1 -0
- package/dist/esm/searchMiddleware.d.ts +5 -0
- package/dist/esm/searchMiddleware.js +42 -0
- package/dist/esm/searchMiddleware.js.map +1 -0
- package/dist/esm/searchParams.d.ts +7 -0
- package/dist/esm/searchParams.js +61 -0
- package/dist/esm/searchParams.js.map +1 -0
- package/dist/esm/serializer.d.ts +22 -0
- package/dist/esm/structuralSharing.d.ts +4 -0
- package/dist/esm/typePrimitives.d.ts +65 -0
- package/dist/esm/useLoaderData.d.ts +5 -0
- package/dist/esm/useLoaderDeps.d.ts +5 -0
- package/dist/esm/useNavigate.d.ts +3 -0
- package/dist/esm/useParams.d.ts +5 -0
- package/dist/esm/useRouteContext.d.ts +9 -0
- package/dist/esm/useSearch.d.ts +5 -0
- package/dist/esm/utils.d.ts +94 -0
- package/dist/esm/utils.js +165 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/validators.d.ts +51 -0
- package/package.json +2 -2
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { HistoryState, ParsedHistoryState } from '@tanstack/history';
|
|
2
|
+
import { AllParams, CatchAllPaths, CurrentPath, FullSearchSchema, FullSearchSchemaInput, ParentPath, RouteByPath, RouteByToPath, RoutePaths, RouteToPath, ToPath } from './routeInfo.cjs';
|
|
3
|
+
import { AnyRouter, RegisteredRouter, ViewTransitionOptions } from './router.cjs';
|
|
4
|
+
import { ConstrainLiteral, Expand, MakeDifferenceOptional, NoInfer, NonNullableUpdater, Updater } from './utils.cjs';
|
|
5
|
+
import { ParsedLocation } from './location.cjs';
|
|
6
|
+
export type IsRequiredParams<TParams> = Record<never, never> extends TParams ? never : true;
|
|
7
|
+
export interface ParsePathParamsResult<in out TRequired, in out TOptional, in out TRest> {
|
|
8
|
+
required: TRequired;
|
|
9
|
+
optional: TOptional;
|
|
10
|
+
rest: TRest;
|
|
11
|
+
}
|
|
12
|
+
export type AnyParsePathParamsResult = ParsePathParamsResult<string, string, string>;
|
|
13
|
+
export type ParsePathParamsBoundaryStart<T extends string> = T extends `${infer TLeft}{-${infer TRight}` ? ParsePathParamsResult<ParsePathParams<TLeft>['required'], ParsePathParams<TLeft>['optional'] | ParsePathParams<TRight>['required'] | ParsePathParams<TRight>['optional'], ParsePathParams<TRight>['rest']> : T extends `${infer TLeft}{${infer TRight}` ? ParsePathParamsResult<ParsePathParams<TLeft>['required'] | ParsePathParams<TRight>['required'], ParsePathParams<TLeft>['optional'] | ParsePathParams<TRight>['optional'], ParsePathParams<TRight>['rest']> : never;
|
|
14
|
+
export type ParsePathParamsSymbol<T extends string> = T extends `${string}$${infer TRight}` ? TRight extends `${string}/${string}` ? TRight extends `${infer TParam}/${infer TRest}` ? TParam extends '' ? ParsePathParamsResult<ParsePathParams<TRest>['required'], '_splat' | ParsePathParams<TRest>['optional'], ParsePathParams<TRest>['rest']> : ParsePathParamsResult<TParam | ParsePathParams<TRest>['required'], ParsePathParams<TRest>['optional'], ParsePathParams<TRest>['rest']> : never : TRight extends '' ? ParsePathParamsResult<never, '_splat', never> : ParsePathParamsResult<TRight, never, never> : never;
|
|
15
|
+
export type ParsePathParamsBoundaryEnd<T extends string> = T extends `${infer TLeft}}${infer TRight}` ? ParsePathParamsResult<ParsePathParams<TLeft>['required'] | ParsePathParams<TRight>['required'], ParsePathParams<TLeft>['optional'] | ParsePathParams<TRight>['optional'], ParsePathParams<TRight>['rest']> : never;
|
|
16
|
+
export type ParsePathParamsEscapeStart<T extends string> = T extends `${infer TLeft}[${infer TRight}` ? ParsePathParamsResult<ParsePathParams<TLeft>['required'] | ParsePathParams<TRight>['required'], ParsePathParams<TLeft>['optional'] | ParsePathParams<TRight>['optional'], ParsePathParams<TRight>['rest']> : never;
|
|
17
|
+
export type ParsePathParamsEscapeEnd<T extends string> = T extends `${string}]${infer TRight}` ? ParsePathParams<TRight> : never;
|
|
18
|
+
export type ParsePathParams<T extends string> = T extends `${string}[${string}` ? ParsePathParamsEscapeStart<T> : T extends `${string}]${string}` ? ParsePathParamsEscapeEnd<T> : T extends `${string}}${string}` ? ParsePathParamsBoundaryEnd<T> : T extends `${string}{${string}` ? ParsePathParamsBoundaryStart<T> : T extends `${string}$${string}` ? ParsePathParamsSymbol<T> : never;
|
|
19
|
+
export type AddTrailingSlash<T> = T extends `${string}/` ? T : `${T & string}/`;
|
|
20
|
+
export type RemoveTrailingSlashes<T> = T & `${string}/` extends never ? T : T extends `${infer R}/` ? R : T;
|
|
21
|
+
export type AddLeadingSlash<T> = T & `/${string}` extends never ? `/${T & string}` : T;
|
|
22
|
+
export type RemoveLeadingSlashes<T> = T & `/${string}` extends never ? T : T extends `/${infer R}` ? R : T;
|
|
23
|
+
type JoinPath<TLeft extends string, TRight extends string> = TRight extends '' ? TLeft : TLeft extends '' ? TRight : `${RemoveTrailingSlashes<TLeft>}/${RemoveLeadingSlashes<TRight>}`;
|
|
24
|
+
type RemoveLastSegment<T extends string, TAcc extends string = ''> = T extends `${infer TSegment}/${infer TRest}` ? TRest & `${string}/${string}` extends never ? TRest extends '' ? TAcc : `${TAcc}${TSegment}` : RemoveLastSegment<TRest, `${TAcc}${TSegment}/`> : TAcc;
|
|
25
|
+
export type ResolveCurrentPath<TFrom extends string, TTo extends string> = TTo extends '.' ? TFrom : TTo extends './' ? AddTrailingSlash<TFrom> : TTo & `./${string}` extends never ? never : TTo extends `./${infer TRest}` ? AddLeadingSlash<JoinPath<TFrom, TRest>> : never;
|
|
26
|
+
export type ResolveParentPath<TFrom extends string, TTo extends string> = TTo extends '../' | '..' ? TFrom extends '' | '/' ? never : AddLeadingSlash<RemoveLastSegment<TFrom>> : TTo & `../${string}` extends never ? AddLeadingSlash<JoinPath<TFrom, TTo>> : TFrom extends '' | '/' ? never : TTo extends `../${infer ToRest}` ? ResolveParentPath<RemoveLastSegment<TFrom>, ToRest> : AddLeadingSlash<JoinPath<TFrom, TTo>>;
|
|
27
|
+
export type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom ? TTo : string extends TTo ? TFrom : undefined extends TTo ? TFrom : TTo extends string ? TFrom extends string ? TTo extends `/${string}` ? TTo : TTo extends `..${string}` ? ResolveParentPath<TFrom, TTo> : TTo extends `.${string}` ? ResolveCurrentPath<TFrom, TTo> : AddLeadingSlash<JoinPath<TFrom, TTo>> : never : never;
|
|
28
|
+
export type FindDescendantToPaths<TRouter extends AnyRouter, TPrefix extends string> = `${TPrefix}/${string}` & RouteToPath<TRouter>;
|
|
29
|
+
export type InferDescendantToPaths<TRouter extends AnyRouter, TPrefix extends string, TPaths = FindDescendantToPaths<TRouter, TPrefix>> = TPaths extends `${TPrefix}/` ? never : TPaths extends `${TPrefix}/${infer TRest}` ? TRest : never;
|
|
30
|
+
export type RelativeToPath<TRouter extends AnyRouter, TTo extends string, TResolvedPath extends string> = (TResolvedPath & RouteToPath<TRouter> extends never ? never : ToPath<TRouter, TTo>) | `${RemoveTrailingSlashes<TTo>}/${InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TResolvedPath>>}`;
|
|
31
|
+
export type RelativeToParentPath<TRouter extends AnyRouter, TFrom extends string, TTo extends string, TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>> = RelativeToPath<TRouter, TTo, TResolvedPath> | (TTo extends `${string}..` | `${string}../` ? TResolvedPath extends '/' | '' ? never : FindDescendantToPaths<TRouter, RemoveTrailingSlashes<TResolvedPath>> extends never ? never : `${RemoveTrailingSlashes<TTo>}/${ParentPath<TRouter>}` : never);
|
|
32
|
+
export type RelativeToCurrentPath<TRouter extends AnyRouter, TFrom extends string, TTo extends string, TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>> = RelativeToPath<TRouter, TTo, TResolvedPath> | CurrentPath<TRouter>;
|
|
33
|
+
export type AbsoluteToPath<TRouter extends AnyRouter, TFrom extends string> = (string extends TFrom ? CurrentPath<TRouter> : TFrom extends `/` ? never : CurrentPath<TRouter>) | (string extends TFrom ? ParentPath<TRouter> : TFrom extends `/` ? never : ParentPath<TRouter>) | RouteToPath<TRouter> | (TFrom extends '/' ? never : string extends TFrom ? never : InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TFrom>>);
|
|
34
|
+
export type RelativeToPathAutoComplete<TRouter extends AnyRouter, TFrom extends string, TTo extends string> = string extends TTo ? string : string extends TFrom ? AbsoluteToPath<TRouter, TFrom> : TTo & `..${string}` extends never ? TTo & `.${string}` extends never ? AbsoluteToPath<TRouter, TFrom> : RelativeToCurrentPath<TRouter, TFrom, TTo> : RelativeToParentPath<TRouter, TFrom, TTo>;
|
|
35
|
+
export type NavigateOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & NavigateOptionProps;
|
|
36
|
+
/**
|
|
37
|
+
* The NavigateOptions type is used to describe the options that can be used when describing a navigation action in TanStack Router.
|
|
38
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType)
|
|
39
|
+
*/
|
|
40
|
+
export interface NavigateOptionProps {
|
|
41
|
+
/**
|
|
42
|
+
* If set to `true`, the router will scroll the element with an id matching the hash into view with default `ScrollIntoViewOptions`.
|
|
43
|
+
* If set to `false`, the router will not scroll the element with an id matching the hash into view.
|
|
44
|
+
* If set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options.
|
|
45
|
+
* @default true
|
|
46
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#hashscrollintoview)
|
|
47
|
+
* @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)
|
|
48
|
+
*/
|
|
49
|
+
hashScrollIntoView?: boolean | ScrollIntoViewOptions;
|
|
50
|
+
/**
|
|
51
|
+
* `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.
|
|
52
|
+
* @default false
|
|
53
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#replace)
|
|
54
|
+
*/
|
|
55
|
+
replace?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Defaults to `true` so that the scroll position will be reset to 0,0 after the location is committed to the browser history.
|
|
58
|
+
* If `false`, the scroll position will not be reset to 0,0 after the location is committed to history.
|
|
59
|
+
* @default true
|
|
60
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#resetscroll)
|
|
61
|
+
*/
|
|
62
|
+
resetScroll?: boolean;
|
|
63
|
+
/** @deprecated All navigations now use startTransition under the hood */
|
|
64
|
+
startTransition?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* If set to `true`, the router will wrap the resulting navigation in a `document.startViewTransition()` call.
|
|
67
|
+
* If `ViewTransitionOptions`, route navigations will be called using `document.startViewTransition({update, types})`
|
|
68
|
+
* where `types` will be the strings array passed with `ViewTransitionOptions["types"]`.
|
|
69
|
+
* If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed.
|
|
70
|
+
*
|
|
71
|
+
* If the browser does not support this api, this option will be ignored.
|
|
72
|
+
* @default false
|
|
73
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#viewtransition)
|
|
74
|
+
* @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)
|
|
75
|
+
* @see [Google](https://developer.chrome.com/docs/web-platform/view-transitions/same-document#view-transition-types)
|
|
76
|
+
*/
|
|
77
|
+
viewTransition?: boolean | ViewTransitionOptions;
|
|
78
|
+
/**
|
|
79
|
+
* If `true`, navigation will ignore any blockers that might prevent it.
|
|
80
|
+
* @default false
|
|
81
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#ignoreblocker)
|
|
82
|
+
*/
|
|
83
|
+
ignoreBlocker?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* If `true`, navigation to a route inside of router will trigger a full page load instead of the traditional SPA navigation.
|
|
86
|
+
* @default false
|
|
87
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#reloaddocument)
|
|
88
|
+
*/
|
|
89
|
+
reloadDocument?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* This can be used instead of `to` to navigate to a fully built href, e.g. pointing to an external target.
|
|
92
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)
|
|
93
|
+
*/
|
|
94
|
+
href?: string;
|
|
95
|
+
}
|
|
96
|
+
export type ToOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = ToSubOptions<TRouter, TFrom, TTo> & MaskOptions<TRouter, TMaskFrom, TMaskTo>;
|
|
97
|
+
export interface MaskOptions<in out TRouter extends AnyRouter, in out TMaskFrom extends string, in out TMaskTo extends string> {
|
|
98
|
+
_fromLocation?: ParsedLocation;
|
|
99
|
+
mask?: ToMaskOptions<TRouter, TMaskFrom, TMaskTo>;
|
|
100
|
+
}
|
|
101
|
+
export type ToMaskOptions<TRouter extends AnyRouter = RegisteredRouter, TMaskFrom extends string = string, TMaskTo extends string = '.'> = ToSubOptions<TRouter, TMaskFrom, TMaskTo> & {
|
|
102
|
+
unmaskOnReload?: boolean;
|
|
103
|
+
};
|
|
104
|
+
export type ToSubOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.'> = ToSubOptionsProps<TRouter, TFrom, TTo> & SearchParamOptions<TRouter, TFrom, TTo> & PathParamOptions<TRouter, TFrom, TTo>;
|
|
105
|
+
export interface RequiredToOptions<in out TRouter extends AnyRouter, in out TFrom extends string, in out TTo extends string | undefined> {
|
|
106
|
+
to: ToPathOption<TRouter, TFrom, TTo> & {};
|
|
107
|
+
}
|
|
108
|
+
export interface OptionalToOptions<in out TRouter extends AnyRouter, in out TFrom extends string, in out TTo extends string | undefined> {
|
|
109
|
+
to?: ToPathOption<TRouter, TFrom, TTo> & {};
|
|
110
|
+
}
|
|
111
|
+
export type MakeToRequired<TRouter extends AnyRouter, TFrom extends string, TTo extends string | undefined> = string extends TFrom ? string extends TTo ? OptionalToOptions<TRouter, TFrom, TTo> : TTo & CatchAllPaths<TRouter> extends never ? RequiredToOptions<TRouter, TFrom, TTo> : OptionalToOptions<TRouter, TFrom, TTo> : OptionalToOptions<TRouter, TFrom, TTo>;
|
|
112
|
+
export type ToSubOptionsProps<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TTo extends string | undefined = '.'> = MakeToRequired<TRouter, TFrom, TTo> & {
|
|
113
|
+
hash?: true | Updater<string>;
|
|
114
|
+
state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>;
|
|
115
|
+
from?: FromPathOption<TRouter, TFrom> & {};
|
|
116
|
+
unsafeRelative?: 'path';
|
|
117
|
+
};
|
|
118
|
+
export type ParamsReducerFn<in out TRouter extends AnyRouter, in out TParamVariant extends ParamVariant, in out TFrom, in out TTo> = (current: Expand<ResolveFromParams<TRouter, TParamVariant, TFrom>>) => Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>;
|
|
119
|
+
type ParamsReducer<TRouter extends AnyRouter, TParamVariant extends ParamVariant, TFrom, TTo> = Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>> | (ParamsReducerFn<TRouter, TParamVariant, TFrom, TTo> & {});
|
|
120
|
+
type ParamVariant = 'PATH' | 'SEARCH';
|
|
121
|
+
export type ResolveRoute<TRouter extends AnyRouter, TFrom, TTo, TPath = ResolveRelativePath<TFrom, TTo>> = TPath extends string ? TFrom extends TPath ? RouteByPath<TRouter['routeTree'], TPath> : RouteByToPath<TRouter, TPath> : never;
|
|
122
|
+
type ResolveFromParamType<TParamVariant extends ParamVariant> = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema';
|
|
123
|
+
type ResolveFromAllParams<TRouter extends AnyRouter, TParamVariant extends ParamVariant> = TParamVariant extends 'PATH' ? AllParams<TRouter['routeTree']> : FullSearchSchema<TRouter['routeTree']>;
|
|
124
|
+
type ResolveFromParams<TRouter extends AnyRouter, TParamVariant extends ParamVariant, TFrom> = string extends TFrom ? ResolveFromAllParams<TRouter, TParamVariant> : RouteByPath<TRouter['routeTree'], TFrom>['types'][ResolveFromParamType<TParamVariant>];
|
|
125
|
+
type ResolveToParamType<TParamVariant extends ParamVariant> = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput';
|
|
126
|
+
type ResolveAllToParams<TRouter extends AnyRouter, TParamVariant extends ParamVariant> = TParamVariant extends 'PATH' ? AllParams<TRouter['routeTree']> : FullSearchSchemaInput<TRouter['routeTree']>;
|
|
127
|
+
export type ResolveToParams<TRouter extends AnyRouter, TParamVariant extends ParamVariant, TFrom, TTo> = ResolveRelativePath<TFrom, TTo> extends infer TPath ? undefined extends TPath ? never : string extends TPath ? ResolveAllToParams<TRouter, TParamVariant> : TPath extends CatchAllPaths<TRouter> ? ResolveAllToParams<TRouter, TParamVariant> : ResolveRoute<TRouter, TFrom, TTo>['types'][ResolveToParamType<TParamVariant>] : never;
|
|
128
|
+
type ResolveRelativeToParams<TRouter extends AnyRouter, TParamVariant extends ParamVariant, TFrom, TTo, TToParams = ResolveToParams<TRouter, TParamVariant, TFrom, TTo>> = TParamVariant extends 'SEARCH' ? TToParams : string extends TFrom ? TToParams : MakeDifferenceOptional<ResolveFromParams<TRouter, TParamVariant, TFrom>, TToParams>;
|
|
129
|
+
export interface MakeOptionalSearchParams<in out TRouter extends AnyRouter, in out TFrom, in out TTo> {
|
|
130
|
+
search?: true | (ParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {});
|
|
131
|
+
}
|
|
132
|
+
export interface MakeOptionalPathParams<in out TRouter extends AnyRouter, in out TFrom, in out TTo> {
|
|
133
|
+
params?: true | (ParamsReducer<TRouter, 'PATH', TFrom, TTo> & {});
|
|
134
|
+
}
|
|
135
|
+
type MakeRequiredParamsReducer<TRouter extends AnyRouter, TParamVariant extends ParamVariant, TFrom, TTo> = (string extends TFrom ? never : ResolveFromParams<TRouter, TParamVariant, TFrom> extends ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo> ? true : never) | (ParamsReducer<TRouter, TParamVariant, TFrom, TTo> & {});
|
|
136
|
+
export interface MakeRequiredPathParams<in out TRouter extends AnyRouter, in out TFrom, in out TTo> {
|
|
137
|
+
params: MakeRequiredParamsReducer<TRouter, 'PATH', TFrom, TTo> & {};
|
|
138
|
+
}
|
|
139
|
+
export interface MakeRequiredSearchParams<in out TRouter extends AnyRouter, in out TFrom, in out TTo> {
|
|
140
|
+
search: MakeRequiredParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {};
|
|
141
|
+
}
|
|
142
|
+
export type IsRequired<TRouter extends AnyRouter, TParamVariant extends ParamVariant, TFrom, TTo> = ResolveRelativePath<TFrom, TTo> extends infer TPath ? undefined extends TPath ? never : TPath extends CatchAllPaths<TRouter> ? never : IsRequiredParams<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>> : never;
|
|
143
|
+
export type SearchParamOptions<TRouter extends AnyRouter, TFrom, TTo> = IsRequired<TRouter, 'SEARCH', TFrom, TTo> extends never ? MakeOptionalSearchParams<TRouter, TFrom, TTo> : MakeRequiredSearchParams<TRouter, TFrom, TTo>;
|
|
144
|
+
export type PathParamOptions<TRouter extends AnyRouter, TFrom, TTo> = IsRequired<TRouter, 'PATH', TFrom, TTo> extends never ? MakeOptionalPathParams<TRouter, TFrom, TTo> : MakeRequiredPathParams<TRouter, TFrom, TTo>;
|
|
145
|
+
export type ToPathOption<TRouter extends AnyRouter = AnyRouter, TFrom extends string = string, TTo extends string | undefined = string> = ConstrainLiteral<TTo, RelativeToPathAutoComplete<TRouter, NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>>;
|
|
146
|
+
export type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<TFrom, RoutePaths<TRouter['routeTree']>>;
|
|
147
|
+
/**
|
|
148
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options)
|
|
149
|
+
*/
|
|
150
|
+
export interface ActiveOptions {
|
|
151
|
+
/**
|
|
152
|
+
* If true, the link will be active if the current route matches the `to` route path exactly (no children routes)
|
|
153
|
+
* @default false
|
|
154
|
+
*/
|
|
155
|
+
exact?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* If true, the link will only be active if the current URL hash matches the `hash` prop
|
|
158
|
+
* @default false
|
|
159
|
+
*/
|
|
160
|
+
includeHash?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* If true, the link will only be active if the current URL search params inclusively match the `search` prop
|
|
163
|
+
* @default true
|
|
164
|
+
*/
|
|
165
|
+
includeSearch?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* This modifies the `includeSearch` behavior.
|
|
168
|
+
* 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.
|
|
169
|
+
* @default false
|
|
170
|
+
*/
|
|
171
|
+
explicitUndefined?: boolean;
|
|
172
|
+
}
|
|
173
|
+
export interface LinkOptionsProps {
|
|
174
|
+
/**
|
|
175
|
+
* The standard anchor tag target attribute
|
|
176
|
+
*/
|
|
177
|
+
target?: HTMLAnchorElement['target'];
|
|
178
|
+
/**
|
|
179
|
+
* Configurable options to determine if the link should be considered active or not
|
|
180
|
+
* @default {exact:true,includeHash:true}
|
|
181
|
+
*/
|
|
182
|
+
activeOptions?: ActiveOptions;
|
|
183
|
+
/**
|
|
184
|
+
* The preloading strategy for this link
|
|
185
|
+
* - `false` - No preloading
|
|
186
|
+
* - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
|
|
187
|
+
* - `'viewport'` - Preload the linked route when it enters the viewport
|
|
188
|
+
*/
|
|
189
|
+
preload?: false | 'intent' | 'viewport' | 'render';
|
|
190
|
+
/**
|
|
191
|
+
* When a preload strategy is set, this delays the preload by this many milliseconds.
|
|
192
|
+
* If the user exits the link before this delay, the preload will be cancelled.
|
|
193
|
+
*/
|
|
194
|
+
preloadDelay?: number;
|
|
195
|
+
/**
|
|
196
|
+
* Control whether the link should be disabled or not
|
|
197
|
+
* If set to `true`, the link will be rendered without an `href` attribute
|
|
198
|
+
* @default false
|
|
199
|
+
*/
|
|
200
|
+
disabled?: boolean;
|
|
201
|
+
/**
|
|
202
|
+
* When the preload strategy is set to `intent`, this controls the proximity of the link to the cursor before it is preloaded.
|
|
203
|
+
* If the user exits this proximity before this delay, the preload will be cancelled.
|
|
204
|
+
*/
|
|
205
|
+
preloadIntentProximity?: number;
|
|
206
|
+
}
|
|
207
|
+
export type LinkOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkOptionsProps;
|
|
208
|
+
export type LinkCurrentTargetElement = {
|
|
209
|
+
preloadTimeout?: null | ReturnType<typeof setTimeout>;
|
|
210
|
+
};
|
|
211
|
+
export declare const preloadWarning = "Error preloading route! \u261D\uFE0F";
|
|
212
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ParsedHistoryState } from '@tanstack/history';
|
|
2
|
+
import { AnySchema } from './validators.cjs';
|
|
3
|
+
export interface ParsedLocation<TSearchObj extends AnySchema = {}> {
|
|
4
|
+
href: string;
|
|
5
|
+
pathname: string;
|
|
6
|
+
search: TSearchObj;
|
|
7
|
+
searchStr: string;
|
|
8
|
+
state: ParsedHistoryState;
|
|
9
|
+
hash: string;
|
|
10
|
+
maskedLocation?: ParsedLocation<TSearchObj>;
|
|
11
|
+
unmaskOnReload?: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type Manifest = {
|
|
2
|
+
routes: Record<string, {
|
|
3
|
+
filePath?: string;
|
|
4
|
+
preloads?: Array<string>;
|
|
5
|
+
assets?: Array<RouterManagedTag>;
|
|
6
|
+
}>;
|
|
7
|
+
};
|
|
8
|
+
export type RouterManagedTag = {
|
|
9
|
+
tag: 'title';
|
|
10
|
+
attrs?: Record<string, any>;
|
|
11
|
+
children: string;
|
|
12
|
+
} | {
|
|
13
|
+
tag: 'meta' | 'link';
|
|
14
|
+
attrs?: Record<string, any>;
|
|
15
|
+
children?: never;
|
|
16
|
+
} | {
|
|
17
|
+
tag: 'script';
|
|
18
|
+
attrs?: Record<string, any>;
|
|
19
|
+
children?: string;
|
|
20
|
+
} | {
|
|
21
|
+
tag: 'style';
|
|
22
|
+
attrs?: Record<string, any>;
|
|
23
|
+
children?: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function notFound(options = {}) {
|
|
4
|
+
options.isNotFound = true;
|
|
5
|
+
if (options.throw) throw options;
|
|
6
|
+
return options;
|
|
7
|
+
}
|
|
8
|
+
function isNotFound(obj) {
|
|
9
|
+
return !!(obj == null ? void 0 : obj.isNotFound);
|
|
10
|
+
}
|
|
11
|
+
exports.isNotFound = isNotFound;
|
|
12
|
+
exports.notFound = notFound;
|
|
13
|
+
//# sourceMappingURL=not-found.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-found.cjs","sources":["../../src/not-found.ts"],"sourcesContent":["import type { RouteIds } from './routeInfo'\nimport type { RegisteredRouter } from './router'\n\nexport type NotFoundError = {\n /**\n @deprecated\n Use `routeId: rootRouteId` instead\n */\n global?: boolean\n /**\n @private\n Do not use this. It's used internally to indicate a path matching error\n */\n _global?: boolean\n data?: any\n throw?: boolean\n routeId?: RouteIds<RegisteredRouter['routeTree']>\n headers?: HeadersInit\n}\n\nexport function notFound(options: NotFoundError = {}) {\n ;(options as any).isNotFound = true\n if (options.throw) throw options\n return options\n}\n\nexport function isNotFound(obj: any): obj is NotFoundError {\n return !!obj?.isNotFound\n}\n"],"names":[],"mappings":";;AAoBgB,SAAA,SAAS,UAAyB,IAAI;AAClD,UAAgB,aAAa;AAC3B,MAAA,QAAQ,MAAa,OAAA;AAClB,SAAA;AACT;AAEO,SAAS,WAAW,KAAgC;AAClD,SAAA,CAAC,EAAC,2BAAK;AAChB;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RouteIds } from './routeInfo.cjs';
|
|
2
|
+
import { RegisteredRouter } from './router.cjs';
|
|
3
|
+
export type NotFoundError = {
|
|
4
|
+
/**
|
|
5
|
+
@deprecated
|
|
6
|
+
Use `routeId: rootRouteId` instead
|
|
7
|
+
*/
|
|
8
|
+
global?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
@private
|
|
11
|
+
Do not use this. It's used internally to indicate a path matching error
|
|
12
|
+
*/
|
|
13
|
+
_global?: boolean;
|
|
14
|
+
data?: any;
|
|
15
|
+
throw?: boolean;
|
|
16
|
+
routeId?: RouteIds<RegisteredRouter['routeTree']>;
|
|
17
|
+
headers?: HeadersInit;
|
|
18
|
+
};
|
|
19
|
+
export declare function notFound(options?: NotFoundError): NotFoundError;
|
|
20
|
+
export declare function isNotFound(obj: any): obj is NotFoundError;
|