import type { Component, JSX, Signal } from "solid-js"; declare module "solid-js/web" { interface RequestEvent { response: { status?: number; statusText?: string; headers: Headers; }; router?: { matches?: OutputMatch[]; cache?: Map; submission?: { input: any; result: any; url: string; }; dataOnly?: boolean | string[]; data?: Record; previousUrl?: string; }; serverOnly?: boolean; } } export type Params = Record; export type SearchParams = Record; export type SetParams = Record; export type SetSearchParams = Record; export interface Path { pathname: string; search: string; hash: string; } export interface Location extends Path { query: SearchParams; state: Readonly> | null; key: string; } export interface NavigateOptions { resolve: boolean; replace: boolean; scroll: boolean; state: S; } export interface Navigator { (to: string | number, options?: Partial): void; (delta: number): void; } export type NavigatorFactory = (route?: RouteContext) => Navigator; export interface LocationChange { value: string; replace?: boolean; scroll?: boolean; state?: S; rawPath?: string; } export interface RouterIntegration { signal: Signal; create?: (router: RouterContext) => void; utils?: Partial; } export type Intent = "initial" | "native" | "navigate" | "preload"; export interface RoutePreloadFuncArgs { params: Params; location: Location; intent: Intent; } export type RoutePreloadFunc = (args: RoutePreloadFuncArgs) => T; export interface RouteSectionProps { params: Params; location: Location; data: T; children?: JSX.Element; } export type RouteDefinition = { path?: S; matchFilters?: MatchFilters; preload?: RoutePreloadFunc; children?: RouteDefinition | RouteDefinition[]; component?: Component>; info?: Record; /** @deprecated use preload */ load?: RoutePreloadFunc; }; export type MatchFilter = readonly string[] | RegExp | ((s: string) => boolean); export type PathParams

= P extends `${infer Head}/${infer Tail}` ? [...PathParams, ...PathParams] : P extends `:${infer S}?` ? [S] : P extends `:${infer S}` ? [S] : P extends `*${infer S}` ? [S] : []; export type MatchFilters

= P extends string ? { [K in PathParams

[number]]?: MatchFilter; } : Record; export interface PathMatch { params: Params; path: string; } export interface RouteMatch extends PathMatch { route: RouteDescription; } export interface OutputMatch { path: string; pattern: string; match: string; params: Params; info?: Record; } export interface RouteDescription { key: unknown; originalPath: string; pattern: string; component?: Component; preload?: RoutePreloadFunc; matcher: (location: string) => PathMatch | null; matchFilters?: MatchFilters; info?: Record; } export interface Branch { routes: RouteDescription[]; score: number; matcher: (location: string) => RouteMatch[] | null; } export interface RouteContext { parent?: RouteContext; child?: RouteContext; pattern: string; path: () => string; outlet: () => JSX.Element; resolvePath(to: string): string | undefined; } export interface RouterUtils { renderPath(path: string): string; parsePath(str: string): string; go(delta: number): void; beforeLeave: BeforeLeaveLifecycle; paramsWrapper: (getParams: () => Params, branches: () => Branch[]) => Params; queryWrapper: (getQuery: () => SearchParams) => SearchParams; } export interface RouterContext { base: RouteContext; location: Location; params: Params; navigatorFactory: NavigatorFactory; isRouting: () => boolean; matches: () => RouteMatch[]; renderPath(path: string): string; parsePath(str: string): string; beforeLeave: BeforeLeaveLifecycle; preloadRoute: (url: URL, preloadData?: boolean) => void; singleFlight: boolean; submissions: Signal[]>; } export interface BeforeLeaveEventArgs { from: Location; to: string | number; options?: Partial; readonly defaultPrevented: boolean; preventDefault(): void; retry(force?: boolean): void; } export interface BeforeLeaveListener { listener(e: BeforeLeaveEventArgs): void; location: Location; navigate: Navigator; } export interface BeforeLeaveLifecycle { subscribe(listener: BeforeLeaveListener): () => void; confirm(to: string | number, options?: Partial): boolean; } export type Submission = { readonly input: T; readonly result?: U; readonly error: any; readonly pending: boolean; readonly url: string; clear: () => void; retry: () => void; }; export type SubmissionStub = { readonly input: undefined; readonly result: undefined; readonly error: undefined; readonly pending: undefined; readonly url: undefined; clear: () => void; retry: () => void; }; export interface MaybePreloadableComponent extends Component { preload?: () => void; } export type CacheEntry = [number, Promise, any, Intent | undefined, Signal & { count: number; }]; export type NarrowResponse = T extends CustomResponse ? U : Exclude; export type RouterResponseInit = Omit & { revalidate?: string | string[]; }; export type CustomResponse = Omit & { customBody: () => T; clone(...args: readonly unknown[]): CustomResponse; }; /** @deprecated */ export type RouteLoadFunc = RoutePreloadFunc; /** @deprecated */ export type RouteLoadFuncArgs = RoutePreloadFuncArgs;