import type { ReactNode } from 'react'; export type TransitionName = 'fade' | 'slide' | 'scale' | 'none'; export type TransitionStage = 'idle' | 'entering' | 'exiting'; export type QueryValue = string | number | string[] | number[]; export type Query = Record; export type LoaderContext

= { params: P; path: string; query?: Query; hash?: string; }; export type LoaderFn = (context: LoaderContext

) => Promise | R; export type OnEnterFn

= (context: LoaderContext

) => void | Promise; export type OnLeaveFn

= (context: LoaderContext

) => void | Promise; export type OnErrorFn

= (error: unknown, context: LoaderContext

) => void | boolean | Promise; export type PolicyFn

= (context: LoaderContext

) => boolean | Promise; export type PrefetchFn

= (context: LoaderContext

) => Promise; export type RouteOptions

= { loader?: LoaderFn; ttl?: number; shouldReload?: (context: { prev?: LoaderContext

; next: LoaderContext

; }) => boolean; fallback?: ReactNode | ((context: LoaderContext

) => ReactNode); errorBoundary?: React.ComponentType<{ error: any; params?: P; }>; preload?: boolean; keepPreviousData?: boolean; revalidateOnFocus?: boolean; meta?: Record; priority?: number; transition?: TransitionName; duration?: number; }; type GuardResult = boolean | { redirect: string; }; export type GuardFn

= (context: LoaderContext

) => GuardResult | Promise; export type MiddlewareFn

= (context: LoaderContext

) => void | Promise; export type RouteComponent

= React.ComponentType

| (() => Promise<{ default: React.ComponentType

; }>); export type RouteNode

= { path: string; component?: RouteComponent; children: RouteNode[]; parent?: RouteNode; options: RouteOptions; guardFns?: GuardFn

[]; middlewares?: MiddlewareFn

[]; meta?: Record; onEnter?: OnEnterFn

[]; onLeave?: OnLeaveFn

[]; onError?: OnErrorFn

[]; policies?: PolicyFn

[]; prefetch?: PrefetchFn

; errorBoundary?: RouteComponent; }; export type InternalRouteMatch

= { node: RouteNode

; params: P; query?: Query; hash?: string; }; export type ExtractParams = Path extends `${string}:${infer Param}/${infer Rest}` ? { [K in Param | keyof ExtractParams<`/${Rest}`>]: string; } : Path extends `${string}:${infer Param}` ? { [K in Param]: string; } : object; export type BuilderRouteAPI = { guard: (fn: GuardFn) => BuilderRouteAPI; middleware: (fn: MiddlewareFn) => BuilderRouteAPI; meta: (obj: Record) => BuilderRouteAPI; onEnter: (fn: OnEnterFn) => BuilderRouteAPI; onLeave: (fn: OnLeaveFn) => BuilderRouteAPI; onError: (fn: OnErrorFn) => BuilderRouteAPI; policy: (fn: PolicyFn) => BuilderRouteAPI; prefetch: (fn: PrefetchFn) => BuilderRouteAPI; errorBoundary: (component: RouteComponent<{ error: any; params?: Params; }>) => BuilderRouteAPI; route: (path: Path, component?: RouteComponent, options?: ((api: BuilderRouteAPI>) => void) | RouteOptions, R>) => BuilderRouteAPI>; }; export type InferParams = T extends InternalRouteMatch ? P : never; export type InferLoaderData = T extends RouteNode ? R : never; export {};