/** * Types for React Router's instrumentation API. * * Derived from React Router's `instrumentations` API. * If React Router changes these types, this file must be updated. * * @see https://reactrouter.com/how-to/instrumentation */ export type InstrumentationResult = { status: 'success'; error: undefined; } | { status: 'error'; error: unknown; }; export interface ReadonlyRequest { method: string; url: string; headers: Pick; } export interface RouteHandlerInstrumentationInfo { readonly request: ReadonlyRequest; readonly params: Record; readonly pattern?: string; readonly unstable_pattern?: string; readonly context?: unknown; } export interface RouterNavigationInstrumentationInfo { readonly to: string | number; readonly currentUrl: string; readonly formMethod?: string; readonly formEncType?: string; readonly formData?: FormData; readonly body?: unknown; } export interface RouterFetchInstrumentationInfo { readonly href: string; readonly currentUrl: string; readonly fetcherKey: string; readonly formMethod?: string; readonly formEncType?: string; readonly formData?: FormData; readonly body?: unknown; } export interface RequestHandlerInstrumentationInfo { readonly request: Request; readonly context: unknown; } export type InstrumentFunction = (handler: () => Promise, info: T) => Promise; export interface RouteInstrumentations { lazy?: InstrumentFunction; 'lazy.loader'?: InstrumentFunction; 'lazy.action'?: InstrumentFunction; 'lazy.middleware'?: InstrumentFunction; middleware?: InstrumentFunction; loader?: InstrumentFunction; action?: InstrumentFunction; } export interface RouterInstrumentations { navigate?: InstrumentFunction; fetch?: InstrumentFunction; } export interface RequestHandlerInstrumentations { request?: InstrumentFunction; } export interface InstrumentableRoute { id: string; index: boolean | undefined; path: string | undefined; instrument(instrumentations: RouteInstrumentations): void; } export interface InstrumentableRouter { instrument(instrumentations: RouterInstrumentations): void; } export interface InstrumentableRequestHandler { instrument(instrumentations: RequestHandlerInstrumentations): void; } export interface ClientInstrumentation { router?(router: InstrumentableRouter): void; route?(route: InstrumentableRoute): void; } export interface ServerInstrumentation { handler?(handler: InstrumentableRequestHandler): void; route?(route: InstrumentableRoute): void; } //# sourceMappingURL=types.d.ts.map