export type Nullable = T | null | undefined; export type Readonlyable = Readonly | T; export type AnyArray = Readonlyable; export type Arrayable = [R] extends [never] ? T | T[] : R extends true ? Readonly | readonly T[] : R extends false ? AnyArray | Readonlyable : never; export type ValueOf = T[keyof T]; export type URLSearchParamsInit = NonNullable[0]>; export type URLSearchParamsOptions = Record>> | URLSearchParamsInit | object; /** RFC 9110 HTTP methods. */ export declare const HttpMethod: { readonly CONNECT: "CONNECT"; readonly DELETE: "DELETE"; readonly GET: "GET"; readonly HEAD: "HEAD"; readonly OPTIONS: "OPTIONS"; readonly PATCH: "PATCH"; readonly POST: "POST"; readonly PUT: "PUT"; readonly TRACE: "TRACE"; }; export type HttpMethod = ValueOf; /** Options passed to `xfetch()` and available on middleware context. */ export interface XFetchBaseOptions extends Omit { method?: HttpMethod; body?: BodyInit | object; query?: URLSearchParamsOptions; middlewares?: XFetchMiddleware[]; } /** Shape of the response `type` option — controls how the response body is parsed. */ export type ResponseType = Nullable<'arrayBuffer' | 'blob' | 'json' | 'text'>; export interface XFetchOptions extends XFetchBaseOptions { type?: ResponseType; } /** Mutable context passed through the middleware chain. */ export interface XFetchMiddlewareContext extends XFetchOptions { url: string; method: HttpMethod; headers: Headers; } /** The `next` callback — invokes the next middleware or the fetch leaf. */ export type XFetchMiddlewareNext = (context?: XFetchMiddlewareContext) => PromiseLike; /** A middleware function. Mutate `ctx`, call `next()`, and return a `Response`. */ export type XFetchMiddleware = (context: XFetchMiddlewareContext, next: XFetchMiddlewareNext) => PromiseLike | Response;