import { GetFrameworkGeneric } from './frameworks'; import { ParsePathParams } from './link'; import { RouteInfo } from './routeInfo'; import { RouteMatch } from './routeMatch'; import { AnyRouter } from './router'; import { Expand, IsAny, NoInfer, PickUnsafe } from './utils'; export declare const rootRouteId: "__root__"; export type RootRouteId = typeof rootRouteId; export type AnyLoaderData = {}; export type AnyPathParams = {}; export type AnySearchSchema = {}; export interface RouteMeta { } export type SearchSchemaValidator = SearchSchemaValidatorObj | SearchSchemaValidatorFn; export type SearchSchemaValidatorObj = { parse?: SearchSchemaValidatorFn; }; export type SearchSchemaValidatorFn = (searchObj: Record) => {} extends TParentSchema ? TReturn : keyof TReturn extends keyof TParentSchema ? { error: 'Top level search params cannot be redefined by child routes!'; keys: keyof TReturn & keyof TParentSchema; } : TReturn; export type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!'; export type ParentParams = AnyPathParams extends TParentParams ? {} : { [Key in keyof TParentParams]?: DefinedPathParamWarning; }; export type OnLoadFn = (loaderContext: LoaderContext) => Promise | void; export interface LoaderContext { params: TAllParams; search: TFullSearchSchema; signal?: AbortSignal; } export type UnloaderFn = (routeMatch: RouteMatch>) => void; export type RouteOptions, unknown> = Record, string>, TAllParams extends AnyPathParams = {}> = ({ path: TPath; } | { id: TRouteId; }) & { caseSensitive?: boolean; validateSearch?: SearchSchemaValidator; preSearchFilters?: SearchFilter[]; postSearchFilters?: SearchFilter[]; component?: GetFrameworkGeneric<'Component'>; errorComponent?: GetFrameworkGeneric<'ErrorComponent'>; pendingComponent?: GetFrameworkGeneric<'Component'>; beforeLoad?: (opts: { router: AnyRouter; match: RouteMatch; }) => Promise | void; onLoad?: OnLoadFn; onLoadError?: (err: any) => void; onLoaded?: (matchContext: { params: TAllParams; search: TFullSearchSchema; }) => void | undefined | ((match: { params: TAllParams; search: TFullSearchSchema; }) => void); onTransition?: (match: { params: TAllParams; search: TFullSearchSchema; }) => void; meta?: RouteMeta; } & ({ parseParams?: never; stringifyParams?: never; } | { parseParams: (rawParams: IsAny, string>>) => TParams; stringifyParams: (params: TParams) => Record, string>; }) & (PickUnsafe> extends never ? {} : 'Cannot redefined path params in child routes!'); export type SearchFilter = (prev: T) => U; export interface RouteConfig { id: TId; routeId: TRouteId; path: NoInfer; fullPath: TFullPath; options: RouteOptions; children?: TKnownChildren; addChildren: IsAny(children: TNewChildren extends AnyRouteConfig[] ? TNewChildren : { error: 'Invalid route detected'; route: TNewChildren; }) => RouteConfig>; createRoute: CreateRouteConfigFn; generate: GenerateFn; } type GenerateFn = , unknown> = Record, string>, TAllParams extends AnyPathParams extends TParams ? Record, string> : NoInfer = AnyPathParams extends TParams ? Record, string> : NoInfer>(options: Omit, TParentParams, TParams, Expand>, 'path'>) => void; type CreateRouteConfigFn = , unknown> = Record, string>, TAllParams extends AnyPathParams extends TParams ? Record, string> : NoInfer = AnyPathParams extends TParams ? Record, string> : NoInfer, TKnownChildren extends RouteConfig[] = RouteConfig[], TResolvedId extends string = string extends TRouteId ? string extends TPath ? string : TPath : TRouteId>(options?: TIsRoot extends true ? Omit, TParentParams, TParams, Expand>, 'path'> & { path?: never; } : RouteOptions, TParentParams, TParams, Expand>, children?: TKnownChildren, isRoot?: boolean, parentId?: string, parentPath?: string) => RouteConfig, TResolvedId, TPath, string extends TPath ? '' : RoutePath>, TParentSearchSchema, TSearchSchema, Expand, TParentParams, TParams, Expand, TKnownChildren>; type RoutePath = T extends RootRouteId ? '/' : TrimPathRight<`${T}`>; type RoutePrefix = string extends TId ? RootRouteId : TId extends string ? `${TPrefix}/${TId}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight}/${TrimPath}`>}` : never; export interface AnyRouteConfig extends RouteConfig { } export interface AnyRouteConfigWithChildren extends RouteConfig { } type TrimPath = '' extends T ? '' : TrimPathRight>; type TrimPathLeft = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft : T extends `/${infer U}` ? TrimPathLeft : T; type TrimPathRight = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight : T; export declare const createRouteConfig: CreateRouteConfigFn; export {};