import { Engine, EngineAbortPromise } from "../engine"; import { Interceptor } from "../interceptor"; import { RequestContext } from "../context/request-context"; import { ResponseContext } from "../context/response-context"; export declare type RequestEnv = Record; export declare type RequestClient = "browser" | "wechatminiapp"; export declare function createRequestor(engine: Engine, requestContext?: RequestContext, requestEnv?: RequestEnv): Requestor; export declare function createFetchRequestor(requestContext?: RequestContext, requestEnv?: RequestEnv): Requestor; export declare function createWxmpRequestor(requestContext?: RequestContext, requestEnv?: RequestEnv): Requestor; export declare function createAutoAdaptRequestor(requestContext?: RequestContext, requestEnv?: RequestEnv): Requestor; export declare class Requestor { /** 所属客户端,目前仅识别浏览器端 */ static readonly client: RequestClient; /** 浏览器端相关工具属性,方法 */ static readonly browser: { PROTOCOL: string; HOSTNAME: string; PORT: string; ORIGIN: string; IS_LOCAL: boolean; IS_DOMAIN: boolean; HOSTNAME_HYPHEN_PREFIX: string; HOSTNAME_HYPHEN_SUFFIX: string; }; /** 获取环境变量 */ static processenv(name: string[]): T | undefined; /** 请求环境对象集合 */ readonly requestEnv?: RequestEnv; /** 当前请求环境 */ env?: Environment[number]; /** 请求引擎 */ readonly engine: Engine; /** 请求拦截器 */ readonly interceptors: Interceptor[]; /** 全局请求上下文 */ requestContext: RequestContext; /** 请求池 */ readonly requestPool: Map | EngineAbortPromise>; constructor(engine: Engine, requestContext?: RequestContext, requestEnv?: RequestEnv); /** 发起请求 */ request(requestContext: RequestContext): Promise>; /** 切换请求环境 */ switch(env: Environment): this; /** 使用拦截器 */ use(...interceptors: Interceptor[]): this; }