@tanstack/router-core 1.112.0 → 1.112.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
1
+ import { LazyRoute } from './fileRoute.js';
1
2
  import { NavigateOptions, ParsePathParams } from './link.js';
2
3
  import { ParsedLocation } from './location.js';
3
4
  import { AnyRouteMatch, MakeRouteMatchFromRoute, MakeRouteMatchUnion, RouteMatch } from './Matches.js';
4
5
  import { RootRouteId } from './root.js';
5
- import { ParseRoute } from './routeInfo.js';
6
+ import { ParseRoute, RouteById, RoutePaths } from './routeInfo.js';
6
7
  import { AnyRouter, RegisteredRouter } from './router.js';
7
8
  import { BuildLocationFn, NavigateFn } from './RouterProvider.js';
8
9
  import { Assign, Constrain, Expand, IntersectAssign, NoInfer } from './utils.js';
@@ -145,7 +146,7 @@ export interface RemountDepsOptions<in out TRouteId, in out TFullSearchSchema, i
145
146
  params: TAllParams;
146
147
  loaderDeps: TLoaderDeps;
147
148
  }
148
- export type MakeRemountDepsOptionsUnion<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TRoute extends AnyRoute = ParseRoute<TRouteTree>> = TRoute extends any ? RemountDepsOptions<TRoute['id'], TRoute['types']['fullSearchSchema'], TRoute['types']['allParams'], TRoute['types']['loaderDeps']> : never;
149
+ export type MakeRemountDepsOptionsUnion<TRouteTree extends AnyRoute = RegisteredRouter['routeTree']> = ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute ? TRoute extends any ? RemountDepsOptions<TRoute['id'], TRoute['types']['fullSearchSchema'], TRoute['types']['allParams'], TRoute['types']['loaderDeps']> : never : never;
149
150
  export interface RouteTypes<in out TParentRoute extends AnyRoute, in out TPath extends string, in out TFullPath extends string, in out TCustomId extends string, in out TId extends string, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps, in out TLoaderFn, in out TChildren, in out TFileRouteTypes> {
150
151
  parentRoute: TParentRoute;
151
152
  path: TPath;
@@ -171,23 +172,37 @@ export interface RouteTypes<in out TParentRoute extends AnyRoute, in out TPath e
171
172
  fileRouteTypes: TFileRouteTypes;
172
173
  }
173
174
  export type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
174
- export interface Route<in out TParentRoute extends AnyRoute, in out TPath extends string, in out TFullPath extends string, in out TCustomId extends string, in out TId extends string, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps, in out TLoaderFn, in out TChildren, in out TFileRouteTypes> {
175
+ export interface RouteExtensions<TId, TFullPath> {
176
+ }
177
+ export type RouteLazyFn<TRoute extends AnyRoute> = (lazyFn: () => Promise<LazyRoute>) => TRoute;
178
+ export type RouteAddChildrenFn<in out TParentRoute extends AnyRoute, in out TPath extends string, in out TFullPath extends string, in out TCustomId extends string, in out TId extends string, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps extends Record<string, any>, in out TLoaderFn, in out TFileRouteTypes> = <const TNewChildren>(children: Constrain<TNewChildren, ReadonlyArray<AnyRoute> | Record<string, AnyRoute>>) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
179
+ export type RouteAddFileChildrenFn<in out TParentRoute extends AnyRoute, in out TPath extends string, in out TFullPath extends string, in out TCustomId extends string, in out TId extends string, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps extends Record<string, any>, in out TLoaderFn, in out TFileRouteTypes> = <const TNewChildren>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
180
+ export type RouteAddFileTypesFn<TParentRoute extends AnyRoute, TPath extends string, TFullPath extends string, TCustomId extends string, TId extends string, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps extends Record<string, any>, TLoaderFn, TChildren> = <TNewFileRouteTypes>() => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TNewFileRouteTypes>;
181
+ export interface Route<in out TParentRoute extends AnyRoute, in out TPath extends string, in out TFullPath extends string, in out TCustomId extends string, in out TId extends string, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps extends Record<string, any>, in out TLoaderFn, in out TChildren, in out TFileRouteTypes> extends RouteExtensions<TId, TFullPath> {
175
182
  fullPath: TFullPath;
176
183
  path: TPath;
177
184
  id: TId;
185
+ parentRoute: TParentRoute;
186
+ children?: TChildren;
178
187
  types: RouteTypes<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>;
188
+ options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>;
189
+ isRoot: TParentRoute extends AnyRoute ? true : false;
190
+ _componentsPromise?: Promise<Array<void>>;
191
+ lazyFn?: () => Promise<LazyRoute>;
192
+ _lazyPromise?: Promise<void>;
193
+ rank: number;
194
+ to: TrimPathRight<TFullPath>;
195
+ init: (opts: {
196
+ originalIndex: number;
197
+ defaultSsr?: boolean;
198
+ }) => void;
199
+ update: (options: UpdatableRouteOptions<TParentRoute, TCustomId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => this;
200
+ lazy: RouteLazyFn<this>;
201
+ addChildren: RouteAddChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
202
+ _addFileChildren: RouteAddFileChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
203
+ _addFileTypes: RouteAddFileTypesFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren>;
179
204
  }
180
205
  export type AnyRoute = Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any>;
181
- export interface RootRoute<in out TSearchValidator, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps extends Record<string, any>, in out TLoaderFn, in out TChildren, in out TFileRouteTypes> extends Route<any, // TParentRoute
182
- '/', // TPath
183
- '/', // TFullPath
184
- string, // TCustomId
185
- RootRouteId, // TId
186
- TSearchValidator, // TSearchValidator
187
- {}, // TParams
188
- TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, // TChildren
189
- TFileRouteTypes> {
190
- }
191
206
  export type AnyRouteWithContext<TContext> = AnyRoute & {
192
207
  types: {
193
208
  allContext: TContext;
@@ -240,7 +255,7 @@ export interface DefaultUpdatableRouteOptionsExtensions {
240
255
  notFoundComponent?: unknown;
241
256
  pendingComponent?: unknown;
242
257
  }
243
- export interface UpdatableRouteOptionsExtensions {
258
+ export interface UpdatableRouteOptionsExtensions extends DefaultUpdatableRouteOptionsExtensions {
244
259
  }
245
260
  export interface UpdatableRouteOptions<in out TParentRoute extends AnyRoute, in out TRouteId, in out TFullPath, in out TParams, in out TSearchValidator, in out TLoaderFn, in out TLoaderDeps, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn> extends UpdatableStaticRouteOption, UpdatableRouteOptionsExtensions {
246
261
  caseSensitive?: boolean;
@@ -303,6 +318,34 @@ RootRouteId, // TCustomId
303
318
  '', // TPath
304
319
  TSearchValidator, {}, // TParams
305
320
  TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'params'>;
321
+ export type RouteConstraints = {
322
+ TParentRoute: AnyRoute;
323
+ TPath: string;
324
+ TFullPath: string;
325
+ TCustomId: string;
326
+ TId: string;
327
+ TSearchSchema: AnySchema;
328
+ TFullSearchSchema: AnySchema;
329
+ TParams: Record<string, any>;
330
+ TAllParams: Record<string, any>;
331
+ TParentContext: AnyContext;
332
+ TRouteContext: RouteContext;
333
+ TAllContext: AnyContext;
334
+ TRouterContext: AnyContext;
335
+ TChildren: unknown;
336
+ TRouteTree: AnyRoute;
337
+ };
338
+ export type RouteTypesById<TRouter extends AnyRouter, TId> = RouteById<TRouter['routeTree'], TId>['types'];
339
+ export type RouteMask<TRouteTree extends AnyRoute> = {
340
+ routeTree: TRouteTree;
341
+ from: RoutePaths<TRouteTree>;
342
+ to?: any;
343
+ params?: any;
344
+ search?: any;
345
+ hash?: any;
346
+ state?: any;
347
+ unmaskOnReload?: boolean;
348
+ };
306
349
  /**
307
350
  * @deprecated Use `ErrorComponentProps` instead.
308
351
  */
@@ -1,21 +1,482 @@
1
1
  import { ParsedLocation } from './location.js';
2
2
  import { DeferredPromiseState } from './defer.js';
3
- import { ControlledPromise } from './utils.js';
4
- import { AnyRoute, AnyRouteWithContext } from './route.js';
3
+ import { ControlledPromise, NoInfer, NonNullableUpdater, Updater } from './utils.js';
4
+ import { AnyContext, AnyRoute, AnyRouteWithContext, MakeRemountDepsOptionsUnion, RouteMask } from './route.js';
5
+ import { Store } from '@tanstack/store';
6
+ import { FullSearchSchema, RouteById, RoutePaths, RoutesById, RoutesByPath } from './routeInfo.js';
7
+ import { AnyRouteMatch, MakeRouteMatchUnion, MatchRouteOptions } from './Matches.js';
8
+ import { AnyRedirect, ResolvedRedirect } from './redirect.js';
9
+ import { BuildLocationFn, CommitLocationOptions, NavigateFn } from './RouterProvider.js';
10
+ import { HistoryLocation, HistoryState, ParsedHistoryState, RouterHistory } from '@tanstack/history';
11
+ import { Manifest } from './manifest.js';
12
+ import { StartSerializer } from './serializer.js';
13
+ import { AnySchema } from './validators.js';
14
+ import { NavigateOptions, ResolveRelativePath, ToOptions } from './link.js';
15
+ import { SearchParser, SearchSerializer } from './searchParams.js';
16
+ declare global {
17
+ interface Window {
18
+ __TSR_ROUTER__?: AnyRouter;
19
+ }
20
+ }
21
+ export type ControllablePromise<T = any> = Promise<T> & {
22
+ resolve: (value: T) => void;
23
+ reject: (value?: any) => void;
24
+ };
25
+ export type InjectedHtmlEntry = Promise<string>;
5
26
  export interface Register {
6
27
  }
7
28
  export type RegisteredRouter = Register extends {
8
29
  router: infer TRouter extends AnyRouter;
9
30
  } ? TRouter : AnyRouter;
10
- export interface RouterOptions<in out TTrailingSlashOption extends TrailingSlashOption> {
31
+ export type DefaultRemountDepsFn<TRouteTree extends AnyRoute> = (opts: MakeRemountDepsOptionsUnion<TRouteTree>) => any;
32
+ export interface DefaultRouterOptionsExtensions {
33
+ }
34
+ export interface RouterOptionsExtensions extends DefaultRouterOptionsExtensions {
35
+ }
36
+ export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean = false, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>> extends RouterOptionsExtensions {
37
+ /**
38
+ * The history object that will be used to manage the browser history.
39
+ *
40
+ * If not provided, a new createBrowserHistory instance will be created and used.
41
+ *
42
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
43
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
44
+ */
45
+ history?: TRouterHistory;
46
+ /**
47
+ * A function that will be used to stringify search params when generating links.
48
+ *
49
+ * @default defaultStringifySearch
50
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)
51
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
52
+ */
53
+ stringifySearch?: SearchSerializer;
54
+ /**
55
+ * A function that will be used to parse search params when parsing the current location.
56
+ *
57
+ * @default defaultParseSearch
58
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)
59
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
60
+ */
61
+ parseSearch?: SearchParser;
62
+ /**
63
+ * If `false`, routes will not be preloaded by default in any way.
64
+ *
65
+ * If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.
66
+ *
67
+ * If `'viewport'`, routes will be preloaded by default when they are within the viewport.
68
+ *
69
+ * @default false
70
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)
71
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
72
+ */
73
+ defaultPreload?: false | 'intent' | 'viewport' | 'render';
74
+ /**
75
+ * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.
76
+ *
77
+ * @default 50
78
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)
79
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)
80
+ */
81
+ defaultPreloadDelay?: number;
82
+ /**
83
+ * The default `pendingMs` a route should use if no pendingMs is provided.
84
+ *
85
+ * @default 1000
86
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)
87
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
88
+ */
89
+ defaultPendingMs?: number;
90
+ /**
91
+ * The default `pendingMinMs` a route should use if no pendingMinMs is provided.
92
+ *
93
+ * @default 500
94
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)
95
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
96
+ */
97
+ defaultPendingMinMs?: number;
98
+ /**
99
+ * The default `staleTime` a route should use if no staleTime is provided. This is the time in milliseconds that a route will be considered fresh.
100
+ *
101
+ * @default 0
102
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)
103
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
104
+ */
105
+ defaultStaleTime?: number;
106
+ /**
107
+ * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.
108
+ *
109
+ * @default 30_000 `(30 seconds)`
110
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)
111
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
112
+ */
113
+ defaultPreloadStaleTime?: number;
114
+ /**
115
+ * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.
116
+ *
117
+ * @default 1_800_000 `(30 minutes)`
118
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)
119
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
120
+ */
121
+ defaultPreloadGcTime?: number;
122
+ /**
123
+ * If `true`, route navigations will called using `document.startViewTransition()`.
124
+ *
125
+ * If the browser does not support this api, this option will be ignored.
126
+ *
127
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.
128
+ *
129
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)
130
+ */
131
+ defaultViewTransition?: boolean | ViewTransitionOptions;
132
+ /**
133
+ * The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating
134
+ *
135
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.
136
+ *
137
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)
138
+ */
139
+ defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions;
140
+ /**
141
+ * @default 'fuzzy'
142
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)
143
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)
144
+ */
145
+ notFoundMode?: 'root' | 'fuzzy';
146
+ /**
147
+ * The default `gcTime` a route should use if no gcTime is provided.
148
+ *
149
+ * @default 1_800_000 `(30 minutes)`
150
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)
151
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
152
+ */
153
+ defaultGcTime?: number;
154
+ /**
155
+ * If `true`, all routes will be matched as case-sensitive.
156
+ *
157
+ * @default false
158
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)
159
+ */
160
+ caseSensitive?: boolean;
161
+ /**
162
+ *
163
+ * The route tree that will be used to configure the router instance.
164
+ *
165
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)
166
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/routing/route-trees)
167
+ */
168
+ routeTree?: TRouteTree;
169
+ /**
170
+ * The basepath for then entire router. This is useful for mounting a router instance at a subpath.
171
+ *
172
+ * @default '/'
173
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)
174
+ */
175
+ basepath?: string;
176
+ /**
177
+ * The root context that will be provided to all routes in the route tree.
178
+ *
179
+ * This can be used to provide a context to all routes in the tree without having to provide it to each route individually.
180
+ *
181
+ * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).
182
+ *
183
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)
184
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)
185
+ */
186
+ context?: InferRouterContext<TRouteTree>;
187
+ /**
188
+ * A function that will be called when the router is dehydrated.
189
+ *
190
+ * The return value of this function will be serialized and stored in the router's dehydrated state.
191
+ *
192
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
193
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
194
+ */
195
+ dehydrate?: () => TDehydrated;
196
+ /**
197
+ * A function that will be called when the router is hydrated.
198
+ *
199
+ * The return value of this function will be serialized and stored in the router's dehydrated state.
200
+ *
201
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)
202
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
203
+ */
204
+ hydrate?: (dehydrated: TDehydrated) => void;
205
+ /**
206
+ * An array of route masks that will be used to mask routes in the route tree.
207
+ *
208
+ * Route masking is when you display a route at a different path than the one it is configured to match, like a modal popup that when shared will unmask to the modal's content instead of the modal's context.
209
+ *
210
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)
211
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)
212
+ */
213
+ routeMasks?: Array<RouteMask<TRouteTree>>;
214
+ /**
215
+ * If `true`, route masks will, by default, be removed when the page is reloaded.
216
+ *
217
+ * This can be overridden on a per-mask basis by setting the `unmaskOnReload` option on the mask, or on a per-navigation basis by setting the `unmaskOnReload` option in the `Navigate` options.
218
+ *
219
+ * @default false
220
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)
221
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)
222
+ */
223
+ unmaskOnReload?: boolean;
224
+ /**
225
+ * Use `notFoundComponent` instead.
226
+ *
227
+ * @deprecated
228
+ * See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.
229
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)
230
+ */
231
+ notFoundRoute?: AnyRoute;
232
+ /**
233
+ * Configures how trailing slashes are treated.
234
+ *
235
+ * - `'always'` will add a trailing slash if not present
236
+ * - `'never'` will remove the trailing slash if present
237
+ * - `'preserve'` will not modify the trailing slash.
238
+ *
239
+ * @default 'never'
240
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)
241
+ */
11
242
  trailingSlash?: TTrailingSlashOption;
243
+ /**
244
+ * While usually automatic, sometimes it can be useful to force the router into a server-side state, e.g. when using the router in a non-browser environment that has access to a global.document object.
245
+ *
246
+ * @default typeof document !== 'undefined'
247
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)
248
+ */
249
+ isServer?: boolean;
250
+ defaultSsr?: boolean;
251
+ search?: {
252
+ /**
253
+ * Configures how unknown search params (= not returned by any `validateSearch`) are treated.
254
+ *
255
+ * @default false
256
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#search.strict-property)
257
+ */
258
+ strict?: boolean;
259
+ };
260
+ /**
261
+ * Configures whether structural sharing is enabled by default for fine-grained selectors.
262
+ *
263
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstructuralsharing-property)
264
+ */
265
+ defaultStructuralSharing?: TDefaultStructuralSharingOption;
266
+ /**
267
+ * Configures which URI characters are allowed in path params that would ordinarily be escaped by encodeURIComponent.
268
+ *
269
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#pathparamsallowedcharacters-property)
270
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/path-params#allowed-characters)
271
+ */
272
+ pathParamsAllowedCharacters?: Array<';' | ':' | '@' | '&' | '=' | '+' | '$' | ','>;
273
+ defaultRemountDeps?: DefaultRemountDepsFn<TRouteTree>;
274
+ /**
275
+ * If `true`, scroll restoration will be enabled
276
+ *
277
+ * @default false
278
+ */
279
+ scrollRestoration?: boolean;
280
+ /**
281
+ * A function that will be called to get the key for the scroll restoration cache.
282
+ *
283
+ * @default (location) => location.href
284
+ */
285
+ getScrollRestorationKey?: (location: ParsedLocation) => string;
286
+ /**
287
+ * The default behavior for scroll restoration.
288
+ *
289
+ * @default 'auto'
290
+ */
291
+ scrollRestorationBehavior?: ScrollBehavior;
292
+ /**
293
+ * An array of selectors that will be used to scroll to the top of the page in addition to `window`
294
+ *
295
+ * @default ['window']
296
+ */
297
+ scrollToTopSelectors?: Array<string>;
298
+ }
299
+ export interface RouterState<in out TRouteTree extends AnyRoute = AnyRoute, in out TRouteMatch = MakeRouteMatchUnion> {
300
+ status: 'pending' | 'idle';
301
+ loadedAt: number;
302
+ isLoading: boolean;
303
+ isTransitioning: boolean;
304
+ matches: Array<TRouteMatch>;
305
+ pendingMatches?: Array<TRouteMatch>;
306
+ cachedMatches: Array<TRouteMatch>;
307
+ location: ParsedLocation<FullSearchSchema<TRouteTree>>;
308
+ resolvedLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>;
309
+ statusCode: number;
310
+ redirect?: ResolvedRedirect;
311
+ }
312
+ export interface BuildNextOptions {
313
+ to?: string | number | null;
314
+ params?: true | Updater<unknown>;
315
+ search?: true | Updater<unknown>;
316
+ hash?: true | Updater<string>;
317
+ state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>;
318
+ mask?: {
319
+ to?: string | number | null;
320
+ params?: true | Updater<unknown>;
321
+ search?: true | Updater<unknown>;
322
+ hash?: true | Updater<string>;
323
+ state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>;
324
+ unmaskOnReload?: boolean;
325
+ };
326
+ from?: string;
327
+ _fromLocation?: ParsedLocation;
328
+ href?: string;
329
+ }
330
+ type NavigationEventInfo = {
331
+ fromLocation?: ParsedLocation;
332
+ toLocation: ParsedLocation;
333
+ pathChanged: boolean;
334
+ hrefChanged: boolean;
335
+ hashChanged: boolean;
336
+ };
337
+ export type RouterEvents = {
338
+ onBeforeNavigate: {
339
+ type: 'onBeforeNavigate';
340
+ } & NavigationEventInfo;
341
+ onBeforeLoad: {
342
+ type: 'onBeforeLoad';
343
+ } & NavigationEventInfo;
344
+ onLoad: {
345
+ type: 'onLoad';
346
+ } & NavigationEventInfo;
347
+ onResolved: {
348
+ type: 'onResolved';
349
+ } & NavigationEventInfo;
350
+ onBeforeRouteMount: {
351
+ type: 'onBeforeRouteMount';
352
+ } & NavigationEventInfo;
353
+ onInjectedHtml: {
354
+ type: 'onInjectedHtml';
355
+ promise: Promise<string>;
356
+ };
357
+ onRendered: {
358
+ type: 'onRendered';
359
+ } & NavigationEventInfo;
360
+ };
361
+ export type RouterEvent = RouterEvents[keyof RouterEvents];
362
+ export type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void;
363
+ export type RouterListener<TRouterEvent extends RouterEvent> = {
364
+ eventType: TRouterEvent['type'];
365
+ fn: ListenerFn<TRouterEvent>;
366
+ };
367
+ export interface MatchRoutesOpts {
368
+ preload?: boolean;
369
+ throwOnError?: boolean;
370
+ _buildLocation?: boolean;
371
+ dest?: BuildNextOptions;
372
+ }
373
+ export type InferRouterContext<TRouteTree extends AnyRoute> = TRouteTree['types']['routerContext'];
374
+ export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends InferRouterContext<TRouteTree> ? {
375
+ context?: InferRouterContext<TRouteTree>;
376
+ } : {
377
+ context: InferRouterContext<TRouteTree>;
378
+ };
379
+ export type RouterConstructorOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory, TDehydrated extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>, 'context'> & RouterContextOptions<TRouteTree>;
380
+ export interface RouterErrorSerializer<TSerializedError> {
381
+ serialize: (err: unknown) => TSerializedError;
382
+ deserialize: (err: TSerializedError) => unknown;
383
+ }
384
+ export interface MatchedRoutesResult {
385
+ matchedRoutes: Array<AnyRoute>;
386
+ routeParams: Record<string, string>;
387
+ }
388
+ export type PreloadRouteFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory> = <TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string | undefined = undefined, TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''>(opts: NavigateOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<Array<AnyRouteMatch> | undefined>;
389
+ export type MatchRouteFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory> = <TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string | undefined = undefined, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>['types']['allParams'];
390
+ export type UpdateFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory, TDehydrated extends Record<string, any>> = (newOptions: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>) => void;
391
+ export type InvalidateFn<TRouter extends AnyRouter> = (opts?: {
392
+ filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
393
+ sync?: boolean;
394
+ }) => Promise<void>;
395
+ export type ParseLocationFn<TRouteTree extends AnyRoute> = (previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>, locationToParse?: HistoryLocation) => ParsedLocation<FullSearchSchema<TRouteTree>>;
396
+ export type GetMatchRoutesFn = (next: ParsedLocation, dest?: BuildNextOptions) => {
397
+ matchedRoutes: Array<AnyRoute>;
398
+ routeParams: Record<string, string>;
399
+ foundRoute: AnyRoute | undefined;
400
+ };
401
+ export type EmitFn = (routerEvent: RouterEvent) => void;
402
+ export type LoadFn = (opts?: {
403
+ sync?: boolean;
404
+ }) => Promise<void>;
405
+ export type CommitLocationFn = ({ viewTransition, ignoreBlocker, ...next }: ParsedLocation & CommitLocationOptions) => Promise<void>;
406
+ export type StartTransitionFn = (fn: () => void) => void;
407
+ export type SubscribeFn = <TType extends keyof RouterEvents>(eventType: TType, fn: ListenerFn<RouterEvents[TType]>) => () => void;
408
+ export interface MatchRoutesFn {
409
+ (pathname: string, locationSearch: AnySchema, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
410
+ (next: ParsedLocation, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
411
+ (pathnameOrNext: string | ParsedLocation, locationSearchOrOpts?: AnySchema | MatchRoutesOpts, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
412
+ }
413
+ export type GetMatchFn = (matchId: string) => AnyRouteMatch | undefined;
414
+ export type UpdateMatchFn = (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => AnyRouteMatch;
415
+ export type LoadRouteChunkFn = (route: AnyRoute) => Promise<Array<void>>;
416
+ export type ResolveRedirect = (err: AnyRedirect) => ResolvedRedirect;
417
+ export type ClearCacheFn<TRouter extends AnyRouter> = (opts?: {
418
+ filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
419
+ }) => void;
420
+ export interface ServerSrr {
421
+ injectedHtml: Array<InjectedHtmlEntry>;
422
+ injectHtml: (getHtml: () => string | Promise<string>) => Promise<void>;
423
+ injectScript: (getScript: () => string | Promise<string>, opts?: {
424
+ logScript?: boolean;
425
+ }) => Promise<void>;
426
+ streamValue: (key: string, value: any) => void;
427
+ streamedKeys: Set<string>;
428
+ onMatchSettled: (opts: {
429
+ router: AnyRouter;
430
+ match: AnyRouteMatch;
431
+ }) => any;
12
432
  }
13
- export interface Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption> {
433
+ export interface Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption, in out TDefaultStructuralSharingOption extends boolean, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>> {
14
434
  routeTree: TRouteTree;
15
- options: RouterOptions<TTrailingSlashOption>;
435
+ options: RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>;
436
+ __store: Store<RouterState<TRouteTree>>;
437
+ navigate: NavigateFn;
438
+ history: TRouterHistory;
439
+ state: RouterState<TRouteTree>;
440
+ isServer: boolean;
441
+ clientSsr?: {
442
+ getStreamedValue: <T>(key: string) => T | undefined;
443
+ };
444
+ looseRoutesById: Record<string, AnyRoute>;
445
+ latestLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
446
+ isScrollRestoring: boolean;
447
+ resetNextScroll: boolean;
448
+ isScrollRestorationSetup: boolean;
449
+ ssr?: {
450
+ manifest: Manifest | undefined;
451
+ serializer: StartSerializer;
452
+ };
453
+ serverSsr?: ServerSrr;
454
+ basepath: string;
455
+ routesById: RoutesById<TRouteTree>;
456
+ routesByPath: RoutesByPath<TRouteTree>;
457
+ flatRoutes: Array<AnyRoute>;
458
+ parseLocation: ParseLocationFn<TRouteTree>;
459
+ getMatchedRoutes: GetMatchRoutesFn;
460
+ emit: EmitFn;
461
+ load: LoadFn;
462
+ commitLocation: CommitLocationFn;
463
+ buildLocation: BuildLocationFn;
464
+ startTransition: StartTransitionFn;
465
+ subscribe: SubscribeFn;
466
+ matchRoutes: MatchRoutesFn;
467
+ preloadRoute: PreloadRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;
468
+ getMatch: GetMatchFn;
469
+ updateMatch: UpdateMatchFn;
470
+ matchRoute: MatchRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;
471
+ update: UpdateFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>;
472
+ invalidate: InvalidateFn<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>>;
473
+ loadRouteChunk: LoadRouteChunkFn;
474
+ resolveRedirect: ResolveRedirect;
475
+ buildRouteTree: () => void;
476
+ clearCache: ClearCacheFn<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>>;
16
477
  }
17
- export type AnyRouterWithContext<TContext> = Router<AnyRouteWithContext<TContext>, any>;
18
- export type AnyRouter = Router<any, any>;
478
+ export type AnyRouterWithContext<TContext> = Router<AnyRouteWithContext<TContext>, any, any, any, any>;
479
+ export type AnyRouter = Router<any, any, any, any, any>;
19
480
  export interface ViewTransitionOptions {
20
481
  types: Array<string>;
21
482
  }
@@ -55,3 +516,4 @@ export declare function getLocationChangeInfo(routerState: {
55
516
  hrefChanged: boolean;
56
517
  hashChanged: boolean;
57
518
  };
519
+ export {};