import type { HttpxHookErrorData, HttpxInitOption, HttpxPromise, HttpxRequestOption, HttpxResponse, HttpxResponseData } from "./types/Httpx"; export declare class Httpx { #private; private GM_Api; private HttpxRequestHook; private HttpxResponseHook; private HttpxRequestOption; private HttpxResponseCallBack; private HttpxRequest; /** * 实例化 * @param option 初始化配置 */ constructor(option?: Partial); /** * 覆盖当前配置 * @param option */ config(option?: Partial): void; /** * 拦截器 */ interceptors: { /** * 请求拦截器 */ request: { context: Httpx; /** * 添加拦截器 * @param fn 设置的请求前回调函数,如果返回配置,则使用返回的配置,如果返回null|undefined,则阻止请求 */ use(fn: >(details: T) => void | T | Promise): string | undefined; /** * 移除拦截器 * @param id 通过use返回的id */ eject(id: string): boolean; /** * 移除所有拦截器 */ ejectAll(): void; }; /** * 响应拦截器 */ response: { context: Httpx; /** * 添加拦截器 * @param successFn 设置的响应后回调函数,如果返回响应,则使用返回的响应,如果返回null|undefined,则阻止响应 * + 2xx 范围内的状态码都会触发该函数 * @param errorFn 设置的响应后回调函数,如果返回响应,则使用返回的响应,如果返回null|undefined,则阻止响应 * + 超出 2xx 范围的状态码都会触发该函数 */ use(successFn?: >(response: T, details: HttpxRequestOption) => void | T, errorFn?: (data: T) => void | T | Promise): string | undefined; /** * 移除拦截器 * @param id 通过use返回的id */ eject(id: string): boolean; /** * 移除所有拦截器 */ ejectAll(): void; }; }; /** * 修改xmlHttpRequest * @param httpRequest 网络请求函数 */ setXMLHttpRequest(httpRequest: (...args: any[]) => any): void; /** * GET 请求 * @param details 配置 */ get(details: T): HttpxPromise>; /** * GET 请求 * @param url 请求的url * @param details 配置 */ get>(url: string, details?: T): HttpxPromise>; /** * POST 请求 * @param details 配置 */ post(details?: T): HttpxPromise>; /** * POST 请求 * @param url 请求的url * @param details 配置 */ post>(url: string, details?: T): HttpxPromise>; /** * HEAD 请求 * @param details 配置 */ head(details: T): HttpxPromise>; /** * HEAD 请求 * @param url 请求的url * @param details 配置 */ head>(url: string, details?: T): HttpxPromise>; /** * OPTIONS 请求 * @param details 配置 */ options(details: T): HttpxPromise>; /** * OPTIONS 请求 * @param url 请求的url * @param details 配置 */ options>(url: string, details?: T): HttpxPromise>; /** * DELETE 请求 * @param details 配置 */ delete(details: T): HttpxPromise>; /** * DELETE 请求 * @param url 请求的url * @param details 配置 */ delete>(url: string, details?: T): HttpxPromise>; /** * PUT 请求 * @param details 配置 */ put(details: T): HttpxPromise>; /** * PUT 请求 * @param url 请求的url * @param details 配置 */ put>(url: string, details?: T): HttpxPromise>; /** * 发送请求 * @param details 配置 * @param beforeRequestOption 处理请求前的配置 */ request(details: T, beforeRequestOption?: (option: Required) => void): HttpxPromise>; }