@tanstack/router-core 0.0.1-beta.151 → 0.0.1-beta.153

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.
@@ -96,6 +96,27 @@ declare function replaceEqualDeep<T>(prev: any, _next: T): T;
96
96
  declare function isPlainObject(o: any): boolean;
97
97
  declare function partialDeepEqual(a: any, b: any): boolean;
98
98
 
99
+ type ParseRoute<TRouteTree extends AnyRoute> = TRouteTree | ParseRouteChildren<TRouteTree>;
100
+ type ParseRouteChildren<TRouteTree extends AnyRoute> = TRouteTree extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, infer TChildren, any> ? unknown extends TChildren ? never : TChildren extends AnyRoute[] ? {
101
+ [TId in TChildren[number]['id'] as string]: ParseRoute<TChildren[number]>;
102
+ }[string] : never : never;
103
+ type RoutesById<TRouteTree extends AnyRoute> = {
104
+ [K in ParseRoute<TRouteTree>['id'] as K['id']]: K;
105
+ };
106
+ type RouteById<TRouteTree extends AnyRoute, TId> = Extract<ParseRoute<TRouteTree>, {
107
+ id: TId;
108
+ }>;
109
+ type RouteIds<TRouteTree extends AnyRoute> = AnyRoute extends TRouteTree ? string : ParseRoute<TRouteTree>['id'];
110
+ type RoutesByPath<TRouteTree extends AnyRoute> = {
111
+ [K in ParseRoute<TRouteTree>['fullPath'] as K['fullPath']]: K;
112
+ };
113
+ type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<ParseRoute<TRouteTree>, {
114
+ fullPath: TPath;
115
+ }>;
116
+ type RoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['fullPath'] | '/';
117
+ type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['__types']['fullSearchSchema']> & {};
118
+ type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['__types']['allParams']>;
119
+
99
120
  declare global {
100
121
  interface Window {
101
122
  __TSR_DEHYDRATED__?: HydrationCtx;
@@ -103,20 +124,18 @@ declare global {
103
124
  }
104
125
  interface Register {
105
126
  }
106
- type AnyRouter = Router<any, any, any>;
107
- type RegisteredRouterPair = Register extends {
127
+ type AnyRouter = Router<any, any>;
128
+ type RegisteredRouter = Register extends {
108
129
  router: infer TRouter extends AnyRouter;
109
- } ? [TRouter, TRouter['types']['RoutesInfo']] : [Router, AnyRoutesInfo];
110
- type RegisteredRouter = RegisteredRouterPair[0];
111
- type RegisteredRoutesInfo = RegisteredRouterPair[1];
130
+ } ? TRouter : Router;
112
131
  interface LocationState {
113
132
  }
114
- interface ParsedLocation<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
133
+ interface ParsedLocation<TSearchObj extends AnySearchSchema = {}> {
115
134
  href: string;
116
135
  pathname: string;
117
136
  search: TSearchObj;
118
137
  searchStr: string;
119
- state: TState;
138
+ state: LocationState;
120
139
  hash: string;
121
140
  key?: string;
122
141
  }
@@ -132,7 +151,7 @@ type HydrationCtx = {
132
151
  router: DehydratedRouter;
133
152
  payload: Record<string, any>;
134
153
  };
135
- interface RouteMatch<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TRoute extends AnyRoute = Route> {
154
+ interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRoute extends AnyRoute = Route> {
136
155
  id: string;
137
156
  key?: string;
138
157
  routeId: string;
@@ -153,11 +172,11 @@ interface RouteMatch<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TRou
153
172
  routeContext: TRoute['__types']['routeContext'];
154
173
  context: TRoute['__types']['context'];
155
174
  routeSearch: TRoute['__types']['searchSchema'];
156
- search: TRoutesInfo['fullSearchSchema'] & TRoute['__types']['fullSearchSchema'];
175
+ search: FullSearchSchema<TRouteTree> & TRoute['__types']['fullSearchSchema'];
157
176
  fetchedAt: number;
158
177
  abortController: AbortController;
159
178
  }
160
- type AnyRouteMatch = RouteMatch<AnyRoutesInfo, AnyRoute>;
179
+ type AnyRouteMatch = RouteMatch<AnyRoute, AnyRoute>;
161
180
  type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends TRouteTree['__types']['routerContext'] ? {
162
181
  context?: TRouteTree['__types']['routerContext'];
163
182
  } : {
@@ -191,16 +210,16 @@ interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<
191
210
  dehydrate?: () => TDehydrated;
192
211
  hydrate?: (dehydrated: TDehydrated) => void;
193
212
  }
194
- interface RouterState<TRoutesInfo extends AnyRoutesInfo = AnyRoutesInfo, TState extends LocationState = LocationState> {
213
+ interface RouterState<TRouteTree extends AnyRoute = AnyRoute> {
195
214
  status: 'idle' | 'pending';
196
215
  isFetching: boolean;
197
- matchesById: Record<string, RouteMatch<TRoutesInfo, TRoutesInfo['routeIntersection']>>;
216
+ matchesById: Record<string, RouteMatch<any, any>>;
198
217
  matchIds: string[];
199
218
  pendingMatchIds: string[];
200
- matches: RouteMatch<TRoutesInfo, TRoutesInfo['routeIntersection']>[];
201
- pendingMatches: RouteMatch<TRoutesInfo, TRoutesInfo['routeIntersection']>[];
202
- location: ParsedLocation<TRoutesInfo['fullSearchSchema'], TState>;
203
- resolvedLocation: ParsedLocation<TRoutesInfo['fullSearchSchema'], TState>;
219
+ matches: RouteMatch<any, any>[];
220
+ pendingMatches: RouteMatch<any, any>[];
221
+ location: ParsedLocation<FullSearchSchema<TRouteTree>>;
222
+ resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
204
223
  lastUpdated: number;
205
224
  }
206
225
  type ListenerFn = () => void;
@@ -235,24 +254,23 @@ interface DehydratedRouter {
235
254
  }
236
255
  type RouterConstructorOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & RouterContextOptions<TRouteTree>;
237
256
  declare const componentTypes: readonly ["component", "errorComponent", "pendingComponent"];
238
- declare class Router<TRouteTree extends AnyRoute = AnyRoute, TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteTree>, TDehydrated extends Record<string, any> = Record<string, any>> {
257
+ declare class Router<TRouteTree extends AnyRoute = AnyRoute, TDehydrated extends Record<string, any> = Record<string, any>> {
239
258
  #private;
240
259
  types: {
241
260
  RootRoute: TRouteTree;
242
- RoutesInfo: TRoutesInfo;
243
261
  };
244
262
  options: PickAsRequired<RouterOptions<TRouteTree, TDehydrated>, 'stringifySearch' | 'parseSearch' | 'context'>;
245
263
  history: RouterHistory;
246
264
  basepath: string;
247
- routeTree: RootRoute;
248
- routesById: RoutesById<TRoutesInfo>;
249
- routesByPath: RoutesByPath<TRoutesInfo>;
250
- flatRoutes: TRoutesInfo['routesByFullPath'][keyof TRoutesInfo['routesByFullPath']][];
265
+ routeTree: TRouteTree;
266
+ routesById: RoutesById<TRouteTree>;
267
+ routesByPath: RoutesByPath<TRouteTree>;
268
+ flatRoutes: ParseRoute<TRouteTree>[];
251
269
  navigateTimeout: undefined | Timeout;
252
270
  nextAction: undefined | 'push' | 'replace';
253
271
  navigationPromise: undefined | Promise<void>;
254
- __store: Store<RouterState<TRoutesInfo>>;
255
- state: RouterState<TRoutesInfo>;
272
+ __store: Store<RouterState<TRouteTree>>;
273
+ state: RouterState<TRouteTree>;
256
274
  dehydratedData?: TDehydrated;
257
275
  constructor(options: RouterConstructorOptions<TRouteTree, TDehydrated>);
258
276
  reset: () => void;
@@ -269,32 +287,32 @@ declare class Router<TRouteTree extends AnyRoute = AnyRoute, TRoutesInfo extends
269
287
  next?: ParsedLocation;
270
288
  throwOnError?: boolean;
271
289
  }) => Promise<void>;
272
- getRoute: <TId extends keyof TRoutesInfo["routesById"]>(id: TId) => TRoutesInfo["routesById"][TId];
290
+ getRoute: (id: string) => Route;
273
291
  preloadRoute: (navigateOpts?: BuildNextOptions & {
274
292
  maxAge?: number;
275
- }) => Promise<RouteMatch<TRoutesInfo, TRoutesInfo["routeIntersection"]>[]>;
293
+ }) => Promise<RouteMatch<TRouteTree, ParseRoute<TRouteTree>>[]>;
276
294
  cleanMatches: () => void;
277
295
  matchRoutes: (pathname: string, locationSearch: AnySearchSchema, opts?: {
278
296
  throwOnError?: boolean;
279
297
  debug?: boolean;
280
- }) => RouteMatch<TRoutesInfo, TRoutesInfo['routeIntersection']>[];
298
+ }) => RouteMatch<TRouteTree, ParseRoute<TRouteTree>>[];
281
299
  loadMatches: (resolvedMatches: AnyRouteMatch[], opts?: {
282
300
  preload?: boolean;
283
301
  maxAge?: number;
284
302
  }) => Promise<void>;
285
303
  reload: () => Promise<void>;
286
304
  resolvePath: (from: string, path: string) => string;
287
- navigate: <TFrom extends string = "/", TTo extends string = "">({ from, to, search, hash, replace, params, }: NavigateOptions<TRoutesInfo, TFrom, TTo>) => Promise<void>;
288
- matchRoute: <TFrom extends string = "/", TTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRoutesInfo, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | TRoutesInfo["routesById"][TResolved]["__types"]["allParams"];
289
- buildLink: <TFrom extends string = "/", TTo extends string = "">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadDelay: userPreloadDelay, disabled, }: LinkOptions<TRoutesInfo, TFrom, TTo>) => LinkInfo;
305
+ navigate: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, hash, replace, params, }: NavigateOptions<TRouteTree, TFrom, TTo>) => Promise<void>;
306
+ matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRouteTree, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["__types"]["allParams"];
307
+ buildLink: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadDelay: userPreloadDelay, disabled, }: LinkOptions<TRouteTree, TFrom, TTo>) => LinkInfo;
290
308
  dehydrate: () => DehydratedRouter;
291
309
  hydrate: (__do_not_use_server_ctx?: HydrationCtx) => Promise<void>;
292
310
  injectedHtml: (string | (() => Promise<string> | string))[];
293
311
  injectHtml: (html: string | (() => Promise<string> | string)) => Promise<void>;
294
312
  dehydrateData: <T>(key: any, getData: T | (() => T | Promise<T>)) => () => T | undefined;
295
313
  hydrateData: <T = unknown>(key: any) => T | undefined;
296
- getRouteMatch: (id: string) => undefined | RouteMatch<TRoutesInfo, AnyRoute>;
297
- setRouteMatch: (id: string, updater: (prev: RouteMatch<TRoutesInfo, AnyRoute>) => RouteMatch<TRoutesInfo, AnyRoute>) => void;
314
+ getRouteMatch: (id: string) => undefined | RouteMatch<TRouteTree, AnyRoute>;
315
+ setRouteMatch: (id: string, updater: (prev: RouteMatch<TRouteTree, AnyRoute>) => RouteMatch<TRouteTree, AnyRoute>) => void;
298
316
  setRouteMatchData: (id: string, updater: (prev: any) => any, opts?: {
299
317
  updatedAt?: number;
300
318
  maxAge?: number;
@@ -309,10 +327,10 @@ declare class Router<TRouteTree extends AnyRoute = AnyRoute, TRoutesInfo extends
309
327
  }) => boolean;
310
328
  }
311
329
  type AnyRedirect = Redirect<any, any, any>;
312
- type Redirect<TRoutesInfo extends AnyRoutesInfo = RegisteredRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = ''> = NavigateOptions<TRoutesInfo, TFrom, TTo> & {
330
+ type Redirect<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = NavigateOptions<TRouteTree, TFrom, TTo> & {
313
331
  code?: number;
314
332
  };
315
- declare function redirect<TRoutesInfo extends AnyRoutesInfo = RegisteredRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = ''>(opts: Redirect<TRoutesInfo, TFrom, TTo>): Redirect<TRoutesInfo, TFrom, TTo>;
333
+ declare function redirect<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''>(opts: Redirect<TRouteTree, TFrom, TTo>): Redirect<TRouteTree, TFrom, TTo>;
316
334
  declare function isRedirect(obj: any): obj is AnyRedirect;
317
335
  declare class SearchParamError extends Error {
318
336
  }
@@ -354,11 +372,11 @@ type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {
354
372
  meta: RouteMeta;
355
373
  };
356
374
  type AnyRouteProps = RouteProps<any, any, any, any, any>;
357
- type ComponentPropsFromRoute<TRoute> = TRoute extends Route<infer TParentRoute, infer TPath, infer TFullPath, infer TCustomId, infer TId, infer TLoader, infer TSearchSchema, infer TFullSearchSchema, infer TParams, infer TAllParams, infer TParentContext, infer TAllParentContext, infer TRouteContext, infer TContext, infer TRouterContext, infer TChildren, infer TRoutesInfo> ? RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext> : never;
375
+ type ComponentPropsFromRoute<TRoute> = TRoute extends Route<infer TParentRoute, infer TPath, infer TFullPath, infer TCustomId, infer TId, infer TLoader, infer TSearchSchema, infer TFullSearchSchema, infer TParams, infer TAllParams, infer TParentContext, infer TAllParentContext, infer TRouteContext, infer TContext, infer TRouterContext, infer TChildren, infer TRouteTree> ? RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext> : never;
358
376
  type ComponentFromRoute<TRoute> = RegisteredRouteComponent<ComponentPropsFromRoute<TRoute>>;
359
377
  type RouteLoaderFromRoute<TRoute extends AnyRoute> = LoaderFn<TRoute['__types']['loader'], TRoute['__types']['searchSchema'], TRoute['__types']['fullSearchSchema'], TRoute['__types']['allParams'], TRoute['__types']['routeContext'], TRoute['__types']['context']>;
360
- type RouteProps<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams = AnyPathParams, TRouteContext = AnyContext, TContext = AnyContext> = {
361
- useMatch: () => RouteMatch<AnyRoutesInfo, AnyRoute>;
378
+ type RouteProps<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TContext extends AnyContext = AnyContext> = {
379
+ useMatch: () => RouteMatch<any, any>;
362
380
  useLoader: () => UseLoaderResult<TLoader>;
363
381
  useSearch: <TStrict extends boolean = true, TSearch = TFullSearchSchema, TSelected = TSearch>(opts?: {
364
382
  strict?: TStrict;
@@ -374,9 +392,10 @@ type RouteProps<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = A
374
392
  select?: (context: TDefaultSelected) => TSelected;
375
393
  }) => TSelected;
376
394
  };
377
- type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TLoader = unknown, TParentSearchSchema extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = AnyPathParams, TParams extends AnyPathParams = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = TParams, TParentContext extends AnyContext = AnyContext, TAllParentContext extends IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext> = IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext>, TRouteContext extends RouteContext = RouteContext, TContext extends MergeParamsFromParent<TAllParentContext, TRouteContext> = MergeParamsFromParent<TAllParentContext, TRouteContext>> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TLoader, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>;
395
+ type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TLoader = unknown, TParentSearchSchema extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParams extends AnyPathParams = AnyPathParams, TAllParams extends AnyPathParams = TParams, TParentContext extends AnyContext = AnyContext, TAllParentContext extends AnyContext = AnyContext, TRouteContext extends RouteContext = RouteContext, TContext extends AnyContext = AnyContext> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TLoader, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>;
378
396
  type ParamsFallback<TPath extends string, TParams> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams;
379
- type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TLoader = unknown, TParentSearchSchema extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = AnyPathParams, TParams = unknown, TAllParams = ParamsFallback<TPath, TParams>, TParentContext extends AnyContext = AnyContext, TAllParentContext extends IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext> = IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext>, TRouteContext extends RouteContext = RouteContext, TContext extends MergeParamsFromParent<TAllParentContext, TRouteContext> = MergeParamsFromParent<TAllParentContext, TRouteContext>> = RoutePathOptions<TCustomId, TPath> & {
397
+ type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TLoader = unknown, TParentSearchSchema extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParams = unknown, TAllParams = ParamsFallback<TPath, TParams>, TParentContext extends AnyContext = AnyContext, TAllParentContext extends AnyContext = AnyContext, TRouteContext extends RouteContext = RouteContext, TContext extends AnyContext = AnyContext> = RoutePathOptions<TCustomId, TPath> & {
398
+ layoutLimit?: string;
380
399
  getParentRoute: () => TParentRoute;
381
400
  validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
382
401
  loader?: LoaderFn<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>;
@@ -484,7 +503,6 @@ type InferFullSearchSchema<TRoute> = TRoute extends {
484
503
  type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = InferFullSearchSchema<TParentRoute> & TSearchSchema;
485
504
  interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
486
505
  }
487
- type AnyRouteWithRouterContext<TRouterContext extends AnyContext> = Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, TRouterContext, any, any>;
488
506
  type MergeParamsFromParent<T, U> = IsAny<T, U, T & U>;
489
507
  type UseLoaderResult<T> = T extends Record<PropertyKey, infer U> ? {
490
508
  [K in keyof T]: UseLoaderResultPromise<T[K]>;
@@ -496,7 +514,25 @@ type StreamedPromise<T> = {
496
514
  data: T;
497
515
  resolve: (value: T) => void;
498
516
  };
499
- declare class Route<TParentRoute extends AnyRoute = AnyRoute, TPath extends string = '/', TFullPath extends ResolveFullPath<TParentRoute, TPath> = ResolveFullPath<TParentRoute, TPath>, TCustomId extends string = string, TId extends ResolveId<TParentRoute, TCustomId, TPath> = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<ParsePathParams<TPath>, any> = Record<ParsePathParams<TPath>, string>, TAllParams extends MergeParamsFromParent<TParentRoute['__types']['allParams'], TParams> = MergeParamsFromParent<TParentRoute['__types']['allParams'], TParams>, TParentContext extends TParentRoute['__types']['routeContext'] = TParentRoute['__types']['routeContext'], TAllParentContext extends TParentRoute['__types']['context'] = TParentRoute['__types']['context'], TRouteContext extends RouteContext = RouteContext, TContext extends MergeParamsFromParent<TParentRoute['__types']['context'], TRouteContext> = MergeParamsFromParent<TParentRoute['__types']['context'], TRouteContext>, TRouterContext extends AnyContext = AnyContext, TChildren extends unknown = unknown, TRoutesInfo extends DefaultRoutesInfo = DefaultRoutesInfo> {
517
+ type RouteConstraints = {
518
+ TParentRoute: AnyRoute;
519
+ TPath: string;
520
+ TFullPath: string;
521
+ TCustomId: string;
522
+ TId: string;
523
+ TSearchSchema: AnySearchSchema;
524
+ TFullSearchSchema: AnySearchSchema;
525
+ TParams: Record<string, any>;
526
+ TAllParams: Record<string, any>;
527
+ TParentContext: AnyContext;
528
+ TAllParentContext: AnyContext;
529
+ TRouteContext: RouteContext;
530
+ TContext: AnyContext;
531
+ TRouterContext: AnyContext;
532
+ TChildren: unknown;
533
+ TRouteTree: AnyRoute;
534
+ };
535
+ declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends RouteConstraints['TParams'] = Record<ParsePathParams<TPath>, string>, TAllParams extends RouteConstraints['TAllParams'] = MergeParamsFromParent<TParentRoute['__types']['allParams'], TParams>, TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['__types']['routeContext'], TAllParentContext extends RouteConstraints['TAllParentContext'] = TParentRoute['__types']['context'], TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TContext extends RouteConstraints['TContext'] = MergeParamsFromParent<TParentRoute['__types']['context'], TRouteContext>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> {
500
536
  __types: {
501
537
  parentRoute: TParentRoute;
502
538
  path: TPath;
@@ -514,11 +550,11 @@ declare class Route<TParentRoute extends AnyRoute = AnyRoute, TPath extends stri
514
550
  routeContext: TRouteContext;
515
551
  context: TContext;
516
552
  children: TChildren;
517
- routesInfo: TRoutesInfo;
553
+ routeTree: TRouteTree;
518
554
  routerContext: TRouterContext;
519
555
  };
520
556
  isRoot: TParentRoute extends Route<any> ? true : false;
521
- options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParentRoute['__types']['allParams'], TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>;
557
+ options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>;
522
558
  parentRoute: TParentRoute;
523
559
  id: TId;
524
560
  path: TPath;
@@ -526,108 +562,78 @@ declare class Route<TParentRoute extends AnyRoute = AnyRoute, TPath extends stri
526
562
  to: TrimPathRight<TFullPath>;
527
563
  children?: TChildren;
528
564
  originalIndex?: number;
529
- router?: Router<TRoutesInfo['routeTree'], TRoutesInfo>;
565
+ router?: AnyRouter;
530
566
  rank: number;
531
- constructor(options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParentRoute['__types']['allParams'], TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>);
567
+ constructor(options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>);
532
568
  init: (opts: {
533
569
  originalIndex: number;
534
570
  router: AnyRouter;
535
571
  }) => void;
536
- addChildren: <TNewChildren extends AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, TRouterContext, TNewChildren, TRoutesInfo>;
572
+ addChildren: <TNewChildren extends AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, TRouterContext, TNewChildren, TRouteTree>;
537
573
  update: (options: UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => this;
538
574
  static __onInit: (route: typeof this$1) => void;
539
575
  }
540
576
  type AnyRootRoute = RootRoute<any, any, any, any>;
541
577
  declare class RouterContext<TRouterContext extends {}> {
542
578
  constructor();
543
- createRootRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TContext extends RouteContext = RouteContext>(options?: Omit<RouteOptions<AnyRoute, "__root__", "", {}, TSearchSchema, {}, {}, AnyPathParams, Record<never, string>, Record<never, string>, AnyContext, AnyContext, RouteContext, RouteContext>, "caseSensitive" | "path" | "getParentRoute" | "stringifyParams" | "parseParams" | "id"> | undefined) => RootRoute<TLoader, TSearchSchema, TContext, TRouterContext>;
579
+ createRootRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TContext extends RouteContext = RouteContext>(options?: Omit<RouteOptions<AnyRoute, "__root__", "", {}, TSearchSchema, {}, {}, AnyPathParams, AnyPathParams, AnyContext, AnyContext, RouteContext, AnyContext>, "caseSensitive" | "id" | "path" | "getParentRoute" | "stringifyParams" | "parseParams"> | undefined) => RootRoute<TLoader, TSearchSchema, TContext, TRouterContext>;
544
580
  }
545
581
  declare class RootRoute<TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TContext extends RouteContext = RouteContext, TRouterContext extends {} = {}> extends Route<any, '/', '/', string, RootRouteId, TLoader, TSearchSchema, TSearchSchema, {}, {}, TRouterContext, TRouterContext, MergeParamsFromParent<TRouterContext, TContext>, MergeParamsFromParent<TRouterContext, TContext>, TRouterContext, any, any> {
546
- constructor(options?: Omit<RouteOptions<AnyRoute, RootRouteId, '', TLoader, TSearchSchema, {}, {}>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
582
+ constructor(options?: Omit<RouteOptions<AnyRoute, RootRouteId, '', TLoader, TSearchSchema, {}>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
547
583
  }
548
- type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed extends RoutePrefix<TParentRoute['fullPath'], TPath> = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
584
+ type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
549
585
  type RoutePrefix<TPrefix extends string, TPath extends string> = string extends TPath ? RootRouteId : TPath extends string ? TPrefix extends RootRouteId ? TPath extends '/' ? '/' : `/${TrimPath<TPath>}` : `${TPrefix}/${TPath}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}` : never;
550
586
  type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
551
587
  type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
552
588
  type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
553
589
 
554
- interface AnyRoutesInfo {
555
- routeTree: AnyRoute;
556
- routeUnion: AnyRoute;
557
- routesById: Record<string, AnyRoute>;
558
- routesByFullPath: Record<string, AnyRoute>;
559
- routeIds: any;
560
- routePaths: any;
561
- routeIntersection: AnyRoute;
562
- fullSearchSchema: Record<string, any>;
563
- allParams: Record<string, any>;
564
- }
565
- interface DefaultRoutesInfo {
566
- routeTree: AnyRoute;
567
- routeUnion: AnyRoute;
568
- routesById: Record<string, Route>;
569
- routesByFullPath: Record<string, Route>;
570
- routeIds: string;
571
- routePaths: string;
572
- routeIntersection: AnyRoute;
573
- fullSearchSchema: AnySearchSchema;
574
- allParams: AnyPathParams;
575
- }
576
- interface RoutesInfo<TRouteTree extends AnyRoute = Route> extends RoutesInfoInner<TRouteTree, ParseRoute<TRouteTree>> {
577
- }
578
- interface RoutesInfoInner<TRouteTree extends AnyRoute, TRouteUnion extends AnyRoute = Route, TRoutesById = {
579
- '/': TRouteUnion;
580
- } & {
581
- [TRoute in TRouteUnion as TRoute['id']]: TRoute;
582
- }, TRoutesByFullPath = {
583
- '/': TRouteUnion;
584
- } & {
585
- [TRoute in TRouteUnion as TRoute['fullPath'] extends RootRouteId ? never : string extends TRoute['fullPath'] ? never : `${TRoute['fullPath']}/` extends keyof TRoutesById ? never : TRoute['fullPath'] extends `${infer Trimmed}/` ? Trimmed : TRoute['fullPath']]: TRoute;
586
- }> {
587
- routeTree: TRouteTree;
588
- routeUnion: TRouteUnion;
589
- routesById: TRoutesById;
590
- routesByFullPath: TRoutesByFullPath;
591
- routeIds: keyof TRoutesById;
592
- routePaths: keyof TRoutesByFullPath;
593
- routeIntersection: Route<TRouteUnion['__types']['parentRoute'], // TParentRoute,
594
- TRouteUnion['__types']['path'], // TPath,
595
- TRouteUnion['__types']['fullPath'], // TFullPath,
596
- TRouteUnion['__types']['customId'], // TCustomId,
597
- TRouteUnion['__types']['id'], // TId,
598
- TRouteUnion['__types']['loader'], // TId,
599
- // TId,
600
- MergeUnion<TRouteUnion['__types']['searchSchema']> & {}, // TSearchSchema,
601
- // TSearchSchema,
602
- MergeUnion<TRouteUnion['__types']['fullSearchSchema']> & {}, // TFullSearchSchema,
603
- MergeUnion<TRouteUnion['__types']['params']>, // TParams,
604
- MergeUnion<TRouteUnion['__types']['allParams']>, // TAllParams,
605
- MergeUnion<TRouteUnion['__types']['parentContext']>, // TParentContext,
606
- MergeUnion<TRouteUnion['__types']['allParentContext']>, // TAllParentContext,
607
- // TAllParentContext,
608
- MergeUnion<TRouteUnion['__types']['routeContext']> & {}, // TRouteContext,
609
- // TRouteContext,
610
- MergeUnion<TRouteUnion['__types']['context']> & {}, // TContext,
611
- // TContext,
612
- MergeUnion<TRouteUnion['__types']['routerContext']> & {}, // TRouterContext,
613
- TRouteUnion['__types']['children'], // TChildren,
614
- TRouteUnion['__types']['routesInfo']>;
615
- fullSearchSchema: Partial<MergeUnion<TRouteUnion['__types']['fullSearchSchema']>>;
616
- allParams: Partial<MergeUnion<TRouteUnion['__types']['allParams']>>;
617
- }
618
- type ParseRoute<TRouteTree> = TRouteTree extends AnyRoute ? TRouteTree | ParseRouteChildren<TRouteTree> : never;
619
- type ParseRouteChildren<TRouteTree> = TRouteTree extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, infer TChildren, any> ? unknown extends TChildren ? never : TChildren extends AnyRoute[] ? Values<{
620
- [TId in TChildren[number]['id']]: ParseRouteChild<TChildren[number], TId>;
621
- }> : never : never;
622
- type ParseRouteChild<TRoute, TId> = TRoute extends AnyRoute ? ParseRoute<TRoute> : never;
623
- type RoutesById<TRoutesInfo extends AnyRoutesInfo> = {
624
- [K in keyof TRoutesInfo['routesById']]: TRoutesInfo['routesById'][K];
625
- };
626
- type RouteById<TRoutesInfo extends AnyRoutesInfo, TId> = TId extends keyof TRoutesInfo['routesById'] ? IsAny<TRoutesInfo['routesById'][TId]['id'], Route, TRoutesInfo['routesById'][TId]> : never;
627
- type RoutesByPath<TRoutesInfo extends AnyRoutesInfo> = {
628
- [K in keyof TRoutesInfo['routesByFullPath']]: TRoutesInfo['routesByFullPath'][K];
629
- };
630
- type RouteByPath<TRoutesInfo extends AnyRoutesInfo, TPath> = TPath extends keyof TRoutesInfo['routesByFullPath'] ? IsAny<TRoutesInfo['routesByFullPath'][TPath]['id'], Route, TRoutesInfo['routesByFullPath'][TPath]> : never;
590
+ interface FileRoutesByPath {
591
+ }
592
+ type Replace<S extends string, From extends string, To extends string> = S extends `${infer Start}${From}${infer Rest}` ? `${Start}${To}${Replace<Rest, From, To>}` : S;
593
+ type TrimLeft<T extends string, S extends string> = T extends `${S}${infer U}` ? U : T;
594
+ type TrimRight<T extends string, S extends string> = T extends `${infer U}${S}` ? U : T;
595
+ type Trim<T extends string, S extends string> = TrimLeft<TrimRight<T, S>, S>;
596
+ type RemoveUnderScores<T extends string> = Replace<Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>, '/_', '/'>;
597
+ type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : Replace<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['__types']['customId']>, ''>;
598
+ type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}` ? string : ResolveFilePath<TParentRoute, TFilePath>;
599
+ declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, RemoveUnderScores<TPath>>> {
600
+ path: TFilePath;
601
+ constructor(path: TFilePath);
602
+ createRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = (TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never) extends never ? AnyPathParams : Record<TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never, string>, TAllParams extends Record<string, any> = IsAny<TParentRoute["__types"]["allParams"], TParams, TParentRoute["__types"]["allParams"] & TParams>, TParentContext extends AnyContext = TParentRoute["__types"]["routeContext"], TAllParentContext extends string = TParentRoute["__types"]["context"], TRouteContext extends RouteContext = RouteContext, TContext extends AnyContext = IsAny<TParentRoute["__types"]["context"], TRouteContext, TParentRoute["__types"]["context"] & TRouteContext>, TRouterContext extends AnyContext = AnyContext, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options: Omit<RouteOptions<TParentRoute, string, string, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext>, "id" | "path" | "getParentRoute"> & {
603
+ meta?: RouteMeta | undefined;
604
+ } & {
605
+ key?: false | GetKeyFn<TFullSearchSchema, TAllParams> | null | undefined;
606
+ caseSensitive?: boolean | undefined;
607
+ wrapInSuspense?: boolean | undefined;
608
+ component?: ((props: RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => unknown) | undefined;
609
+ errorComponent?: ((props: {
610
+ error: unknown;
611
+ } & Partial<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>) => unknown) | undefined;
612
+ pendingComponent?: ((props: RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => unknown) | undefined;
613
+ preSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
614
+ postSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
615
+ preloadMaxAge?: number | undefined;
616
+ maxAge?: number | undefined;
617
+ gcMaxAge?: number | undefined;
618
+ beforeLoad?: ((opts: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>) => void | Promise<void>) | undefined;
619
+ onBeforeLoadError?: ((err: any) => void) | undefined;
620
+ onValidateSearchError?: ((err: any) => void) | undefined;
621
+ onParseParamsError?: ((err: any) => void) | undefined;
622
+ onLoadError?: ((err: any) => void) | undefined;
623
+ onError?: ((err: any) => void) | undefined;
624
+ onLoaded?: ((matchContext: {
625
+ params: TAllParams;
626
+ search: TFullSearchSchema;
627
+ }) => void | ((match: {
628
+ params: TAllParams;
629
+ search: TFullSearchSchema;
630
+ }) => void) | undefined) | undefined;
631
+ onTransition?: ((match: {
632
+ params: TAllParams;
633
+ search: TFullSearchSchema;
634
+ }) => void) | undefined;
635
+ }) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, TRouterContext, TChildren, TRouteTree>;
636
+ }
631
637
 
632
638
  type LinkInfo = {
633
639
  type: 'external';
@@ -645,7 +651,9 @@ type LinkInfo = {
645
651
  };
646
652
  type CleanPath<T extends string> = T extends `${infer L}//${infer R}` ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`> : T extends `${infer L}//` ? `${CleanPath<L>}/` : T extends `//${infer L}` ? `/${CleanPath<L>}` : T;
647
653
  type Split<S, TIncludeTrailingSlash = true> = S extends unknown ? string extends S ? string[] : S extends string ? CleanPath<S> extends '' ? [] : TIncludeTrailingSlash extends true ? CleanPath<S> extends `${infer T}/` ? [...Split<T>, '/'] : CleanPath<S> extends `/${infer U}` ? Split<U> : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : [S] : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : S extends string ? [S] : never : never : never;
648
- type ParsePathParams<T extends string> = Split<T>[number] extends infer U ? U extends `$${infer V}` ? V : never : never;
654
+ type ParsePathParams<T extends string> = keyof {
655
+ [K in Trim<Split<T>[number], '_'> as K extends `$${infer L}` ? L : never]: K;
656
+ };
649
657
  type Join<T, Delimiter extends string = '/'> = T extends [] ? '' : T extends [infer L extends string] ? L : T extends [infer L extends string, ...infer Tail extends [...string[]]] ? CleanPath<`${L}${Delimiter}${Join<Tail>}`> : never;
650
658
  type Last<T extends any[]> = T extends [...infer _, infer L] ? L : never;
651
659
  type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
@@ -661,16 +669,16 @@ type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, T
661
669
  ] ? `${TTo}${Join<RestPath>}` : never : (TFrom extends `/` ? never : SplitPaths extends [...Split<TFrom, false>, ...infer RestPath] ? Join<RestPath> extends {
662
670
  length: 0;
663
671
  } ? never : './' : never) | (TFrom extends `/` ? never : '../') | AllPaths;
664
- type NavigateOptions<TRoutesInfo extends AnyRoutesInfo = RegisteredRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = ''> = ToOptions<TRoutesInfo, TFrom, TTo> & {
672
+ type NavigateOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = ToOptions<TRouteTree, TFrom, TTo> & {
665
673
  replace?: boolean;
666
674
  };
667
- type ToOptions<TRoutesInfo extends AnyRoutesInfo = RegisteredRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = '', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
668
- to?: ToPathOption<TRoutesInfo, TFrom, TTo>;
675
+ type ToOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
676
+ to?: ToPathOption<TRouteTree, TFrom, TTo>;
669
677
  hash?: Updater<string>;
670
678
  state?: LocationState;
671
679
  from?: TFrom;
672
- } & CheckPath<TRoutesInfo, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TRoutesInfo, TFrom, TResolvedTo> & PathParamOptions<TRoutesInfo, TFrom, TResolvedTo>;
673
- type SearchParamOptions<TRoutesInfo extends AnyRoutesInfo, TFrom, TTo, TFromSchema = UnionToIntersection<TRoutesInfo['fullSearchSchema'] & RouteByPath<TRoutesInfo, TFrom> extends never ? {} : RouteByPath<TRoutesInfo, TFrom>['__types']['fullSearchSchema']>, TToSchema = Partial<RouteByPath<TRoutesInfo, TFrom>['__types']['fullSearchSchema']> & Omit<RouteByPath<TRoutesInfo, TTo>['__types']['fullSearchSchema'], keyof PickRequired<RouteByPath<TRoutesInfo, TFrom>['__types']['fullSearchSchema']>>, TFromFullSchema = UnionToIntersection<TRoutesInfo['fullSearchSchema'] & TFromSchema>, TToFullSchema = UnionToIntersection<TRoutesInfo['fullSearchSchema'] & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
680
+ } & CheckPath<TRouteTree, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TRouteTree, TFrom, TResolvedTo> & PathParamOptions<TRouteTree, TFrom, TResolvedTo>;
681
+ type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['__types']['fullSearchSchema']>, TToSchema = Partial<RouteByPath<TRouteTree, TFrom>['__types']['fullSearchSchema']> & Omit<RouteByPath<TRouteTree, TTo>['__types']['fullSearchSchema'], keyof PickRequired<RouteByPath<TRouteTree, TFrom>['__types']['fullSearchSchema']>>, TFromFullSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & TFromSchema>, TToFullSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
674
682
  search?: true | SearchReducer<TFromFullSchema, TToFullSchema>;
675
683
  } : {
676
684
  search: SearchReducer<TFromFullSchema, TToFullSchema>;
@@ -678,38 +686,38 @@ type SearchParamOptions<TRoutesInfo extends AnyRoutesInfo, TFrom, TTo, TFromSche
678
686
  type SearchReducer<TFrom, TTo> = {
679
687
  [TKey in keyof TTo]: TTo[TKey];
680
688
  } | ((current: TFrom) => TTo);
681
- type PathParamOptions<TRoutesInfo extends AnyRoutesInfo, TFrom, TTo, TFromSchema = UnionToIntersection<RouteByPath<TRoutesInfo, TFrom> extends never ? {} : RouteByPath<TRoutesInfo, TFrom>['__types']['allParams']>, TToSchema = Partial<RouteByPath<TRoutesInfo, TFrom>['__types']['allParams']> & Omit<RouteByPath<TRoutesInfo, TTo>['__types']['allParams'], keyof PickRequired<RouteByPath<TRoutesInfo, TFrom>['__types']['allParams']>>, TFromFullParams = UnionToIntersection<TRoutesInfo['allParams'] & TFromSchema>, TToFullParams = UnionToIntersection<TRoutesInfo['allParams'] & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
689
+ type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['__types']['allParams']>, TToSchema = Partial<RouteByPath<TRouteTree, TFrom>['__types']['allParams']> & Omit<RouteByPath<TRouteTree, TTo>['__types']['allParams'], keyof PickRequired<RouteByPath<TRouteTree, TFrom>['__types']['allParams']>>, TFromFullParams = UnionToIntersection<AllParams<TRouteTree> & TFromSchema>, TToFullParams = UnionToIntersection<AllParams<TRouteTree> & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
682
690
  params?: ParamsReducer<TFromFullParams, TToFullParams>;
683
691
  } : {
684
692
  params: ParamsReducer<TFromFullParams, TToFullParams>;
685
693
  };
686
694
  type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
687
- type ToPathOption<TRoutesInfo extends AnyRoutesInfo = RegisteredRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = ''> = TTo | RelativeToPathAutoComplete<TRoutesInfo['routePaths'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
688
- type ToIdOption<TRoutesInfo extends AnyRoutesInfo = RegisteredRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = ''> = TTo | RelativeToPathAutoComplete<TRoutesInfo['routeIds'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
695
+ type ToPathOption<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = TTo | RelativeToPathAutoComplete<RoutePaths<TRouteTree>, NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
696
+ type ToIdOption<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = TTo | RelativeToPathAutoComplete<RouteIds<TRouteTree>, NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
689
697
  interface ActiveOptions {
690
698
  exact?: boolean;
691
699
  includeHash?: boolean;
692
700
  includeSearch?: boolean;
693
701
  }
694
- type LinkOptions<TRoutesInfo extends AnyRoutesInfo = RegisteredRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = ''> = NavigateOptions<TRoutesInfo, TFrom, TTo> & {
702
+ type LinkOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = NavigateOptions<TRouteTree, TFrom, TTo> & {
695
703
  target?: HTMLAnchorElement['target'];
696
704
  activeOptions?: ActiveOptions;
697
705
  preload?: false | 'intent';
698
706
  preloadDelay?: number;
699
707
  disabled?: boolean;
700
708
  };
701
- type CheckRelativePath<TRoutesInfo extends AnyRoutesInfo, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends TRoutesInfo['routePaths'] ? {} : {
709
+ type CheckRelativePath<TRouteTree extends AnyRoute, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends RoutePaths<TRouteTree> ? {} : {
702
710
  Error: `${TFrom} + ${TTo} resolves to ${ResolveRelativePath<TFrom, TTo>}, which is not a valid route path.`;
703
- 'Valid Route Paths': TRoutesInfo['routePaths'];
711
+ 'Valid Route Paths': RoutePaths<TRouteTree>;
704
712
  } : {} : {};
705
- type CheckPath<TRoutesInfo extends AnyRoutesInfo, TPath, TPass> = Exclude<TPath, TRoutesInfo['routePaths']> extends never ? TPass : CheckPathError<TRoutesInfo, Exclude<TPath, TRoutesInfo['routePaths']>>;
706
- type CheckPathError<TRoutesInfo extends AnyRoutesInfo, TInvalids> = {
707
- to: TRoutesInfo['routePaths'];
713
+ type CheckPath<TRouteTree extends AnyRoute, TPath, TPass> = Exclude<TPath, RoutePaths<TRouteTree>> extends never ? TPass : CheckPathError<TRouteTree, Exclude<TPath, RoutePaths<TRouteTree>>>;
714
+ type CheckPathError<TRouteTree extends AnyRoute, TInvalids> = {
715
+ to: RoutePaths<TRouteTree>;
708
716
  };
709
- type CheckId<TRoutesInfo extends AnyRoutesInfo, TPath, TPass> = Exclude<TPath, TRoutesInfo['routeIds']> extends never ? TPass : CheckIdError<TRoutesInfo, Exclude<TPath, TRoutesInfo['routeIds']>>;
710
- type CheckIdError<TRoutesInfo extends AnyRoutesInfo, TInvalids> = {
717
+ type CheckId<TRouteTree extends AnyRoute, TPath, TPass> = Exclude<TPath, RouteIds<TRouteTree>> extends never ? TPass : CheckIdError<TRouteTree, Exclude<TPath, RouteIds<TRouteTree>>>;
718
+ type CheckIdError<TRouteTree extends AnyRoute, TInvalids> = {
711
719
  Error: `${TInvalids extends string ? TInvalids : never} is not a valid route ID.`;
712
- 'Valid Route IDs': TRoutesInfo['routeIds'];
720
+ 'Valid Route IDs': RouteIds<TRouteTree>;
713
721
  };
714
722
  type ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string ? TTo extends string ? TTo extends '.' ? TFrom : TTo extends `./` ? Join<[TFrom, '/']> : TTo extends `./${infer TRest}` ? ResolveRelativePath<TFrom, TRest> : TTo extends `/${infer TRest}` ? TTo : Split<TTo> extends ['..', ...infer ToRest] ? Split<TFrom> extends [...infer FromRest, infer FromTail] ? ToRest extends ['/'] ? Join<[...FromRest, '/']> : ResolveRelativePath<Join<FromRest>, Join<ToRest>> : never : Split<TTo> extends ['.', ...infer ToRest] ? ToRest extends ['/'] ? Join<[TFrom, '/']> : ResolveRelativePath<TFrom, Join<ToRest>> : CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>> : never : never;
715
723
 
@@ -731,50 +739,9 @@ declare function matchByPath(basepath: string, from: string, matchLocation: Pick
731
739
  declare function encode(obj: any, pfx?: string): string;
732
740
  declare function decode(str: any): {};
733
741
 
734
- interface FileRoutesByPath {
735
- }
736
- declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TPath extends string = Last<Split<TFilePath>>, TCustomId extends string = TPath extends `_${infer T}` ? T : string> {
737
- path: TFilePath;
738
- constructor(path: TFilePath);
739
- createRoute: <TFullPath extends ResolveFullPath<TParentRoute, TPath, string extends TPath ? "__root__" : TPath extends string ? TParentRoute["fullPath"] extends infer T ? T extends TParentRoute["fullPath"] ? T extends "__root__" ? TPath extends "/" ? "/" : `/${TrimPath<TPath>}` : `${T}/${TPath}` extends "/" ? "/" : `/${TrimPathLeft<`${TrimPathRight<T>}/${TrimPath<TPath>}`>}` : never : never : never> = ResolveFullPath<TParentRoute, TPath, string extends TPath ? "__root__" : TPath extends string ? TParentRoute["fullPath"] extends infer T ? T extends TParentRoute["fullPath"] ? T extends "__root__" ? TPath extends "/" ? "/" : `/${TrimPath<TPath>}` : `${T}/${TPath}` extends "/" ? "/" : `/${TrimPathLeft<`${TrimPathRight<T>}/${TrimPath<TPath>}`>}` : never : never : never>, TId extends ResolveId<TParentRoute, TCustomId, TPath> = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<ParsePathParams<TPath>, any> = Record<ParsePathParams<TPath>, string>, TAllParams extends IsAny<TParentRoute["__types"]["allParams"], TParams, TParentRoute["__types"]["allParams"] & TParams> = IsAny<TParentRoute["__types"]["allParams"], TParams, TParentRoute["__types"]["allParams"] & TParams>, TParentContext extends TParentRoute["__types"]["routeContext"] = TParentRoute["__types"]["routeContext"], TAllParentContext extends TParentRoute["__types"]["context"] = TParentRoute["__types"]["context"], TRouteContext extends RouteContext = RouteContext, TContext extends IsAny<TParentRoute["__types"]["context"], TRouteContext, TParentRoute["__types"]["context"] & TRouteContext> = IsAny<TParentRoute["__types"]["context"], TRouteContext, TParentRoute["__types"]["context"] & TRouteContext>, TRouterContext extends AnyContext = AnyContext, TChildren extends unknown = unknown, TRoutesInfo extends DefaultRoutesInfo = DefaultRoutesInfo>(options: Omit<RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParentRoute["__types"]["allParams"], TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext>, "path" | "getParentRoute" | "id"> & {
740
- meta?: RouteMeta | undefined;
741
- } & {
742
- key?: false | GetKeyFn<TFullSearchSchema, TAllParams> | null | undefined;
743
- caseSensitive?: boolean | undefined;
744
- wrapInSuspense?: boolean | undefined;
745
- component?: ((props: RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => unknown) | undefined;
746
- errorComponent?: ((props: {
747
- error: unknown;
748
- } & Partial<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>) => unknown) | undefined;
749
- pendingComponent?: ((props: RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => unknown) | undefined;
750
- preSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
751
- postSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
752
- preloadMaxAge?: number | undefined;
753
- maxAge?: number | undefined;
754
- gcMaxAge?: number | undefined;
755
- beforeLoad?: ((opts: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>) => void | Promise<void>) | undefined;
756
- onBeforeLoadError?: ((err: any) => void) | undefined;
757
- onValidateSearchError?: ((err: any) => void) | undefined;
758
- onParseParamsError?: ((err: any) => void) | undefined;
759
- onLoadError?: ((err: any) => void) | undefined;
760
- onError?: ((err: any) => void) | undefined;
761
- onLoaded?: ((matchContext: {
762
- params: TAllParams;
763
- search: TFullSearchSchema;
764
- }) => void | ((match: {
765
- params: TAllParams;
766
- search: TFullSearchSchema;
767
- }) => void) | undefined) | undefined;
768
- onTransition?: ((match: {
769
- params: TAllParams;
770
- search: TFullSearchSchema;
771
- }) => void) | undefined;
772
- }) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, TRouterContext, TChildren, TRoutesInfo>;
773
- }
774
-
775
742
  declare const defaultParseSearch: (searchStr: string) => AnySearchSchema;
776
743
  declare const defaultStringifySearch: (search: Record<string, any>) => string;
777
744
  declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySearchSchema;
778
745
  declare function stringifySearchWith(stringify: (search: any) => string): (search: Record<string, any>) => string;
779
746
 
780
- export { ActiveOptions, AnyContext, AnyPathParams, AnyRedirect, AnyRootRoute, AnyRoute, AnyRouteMatch, AnyRouteProps, AnyRouteWithRouterContext, AnyRouter, AnyRoutesInfo, AnySearchSchema, BaseRouteOptions, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, ComponentFromRoute, ComponentPropsFromRoute, DeepAwaited, DefaultRoutesInfo, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FileRoute, FileRoutesByPath, FromLocation, GetKeyFn, HydrationCtx, InferFullSearchSchema, IsAny, IsAnyBoolean, IsKnown, Join, Last, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LoaderFn, LocationState, MatchLocation, MatchRouteOptions, MergeParamsFromParent, MergeUnion, MetaOptions, NavigateOptions, NoInfer, ParamsFallback, ParentParams, ParseParamsFn, ParseParamsObj, ParseParamsOption, ParsePathParams, ParseRoute, ParseRouteChild, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamError, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, PreloadableObj, Redirect, Register, RegisterRouteComponent, RegisterRouteErrorComponent, RegisteredRouteComponent, RegisteredRouteErrorComponent, RegisteredRouter, RegisteredRouterPair, RegisteredRoutesInfo, RelativeToPathAutoComplete, ResolveFullPath, ResolveFullSearchSchema, ResolveId, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteContext, RouteLoaderFromRoute, RouteMatch, RouteMeta, RouteOptions, RoutePathOptions, RoutePathOptionsIntersection, RouteProps, Router, RouterConstructorOptions, RouterContext, RouterContextOptions, RouterHistory, RouterLocation, RouterOptions, RouterState, RoutesById, RoutesByPath, RoutesInfo, RoutesInfoInner, SearchFilter, SearchParamError, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, StreamedPromise, Timeout, ToIdOption, ToOptions, ToPathOption, TrimPath, TrimPathLeft, TrimPathRight, UnionToIntersection, UnloaderFn, UpdatableRouteOptions, Updater, UseLoaderResult, UseLoaderResultPromise, ValueKeys, Values, cleanPath, componentTypes, createBrowserHistory, createHashHistory, createMemoryHistory, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, isPlainObject, isRedirect, joinPaths, last, lazyFn, matchByPath, matchPathname, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight };
747
+ export { ActiveOptions, AllParams, AnyContext, AnyPathParams, AnyRedirect, AnyRootRoute, AnyRoute, AnyRouteMatch, AnyRouteProps, AnyRouter, AnySearchSchema, BaseRouteOptions, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, CleanPath, ComponentFromRoute, ComponentPropsFromRoute, DeepAwaited, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FileRoute, FileRoutePath, FileRoutesByPath, FromLocation, FullSearchSchema, GetKeyFn, HydrationCtx, InferFullSearchSchema, IsAny, IsAnyBoolean, IsKnown, Join, Last, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LoaderFn, LocationState, MatchLocation, MatchRouteOptions, MergeParamsFromParent, MergeUnion, MetaOptions, NavigateOptions, NoInfer, ParamsFallback, ParentParams, ParseParamsFn, ParseParamsObj, ParseParamsOption, ParsePathParams, ParseRoute, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamError, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, PreloadableObj, Redirect, Register, RegisterRouteComponent, RegisterRouteErrorComponent, RegisteredRouteComponent, RegisteredRouteErrorComponent, RegisteredRouter, RelativeToPathAutoComplete, RemoveUnderScores, ResolveFilePath, ResolveFullPath, ResolveFullSearchSchema, ResolveId, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteConstraints, RouteContext, RouteIds, RouteLoaderFromRoute, RouteMatch, RouteMeta, RouteOptions, RoutePathOptions, RoutePathOptionsIntersection, RoutePaths, RouteProps, Router, RouterConstructorOptions, RouterContext, RouterContextOptions, RouterHistory, RouterLocation, RouterOptions, RouterState, RoutesById, RoutesByPath, SearchFilter, SearchParamError, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, StreamedPromise, Timeout, ToIdOption, ToOptions, ToPathOption, Trim, TrimLeft, TrimPath, TrimPathLeft, TrimPathRight, TrimRight, UnionToIntersection, UnloaderFn, UpdatableRouteOptions, Updater, UseLoaderResult, UseLoaderResultPromise, ValueKeys, Values, cleanPath, componentTypes, createBrowserHistory, createHashHistory, createMemoryHistory, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, isPlainObject, isRedirect, joinPaths, last, lazyFn, matchByPath, matchPathname, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight };