@wevu/web-apis
Version:
Web API polyfills and global installers for mini-program runtimes
37 lines (36 loc) • 1.16 kB
text/typescript
import { RequestGlobalsMiniProgramOptions } from "./networkDefaults.mjs";
import { URLPolyfill } from "./url.mjs";
//#region src/fetch.d.ts
interface RequestLikeInput {
url: string;
method?: string;
headers?: unknown;
signal?: AbortSignal | null;
bodyUsed?: boolean;
clone?: () => {
arrayBuffer?: () => Promise<ArrayBuffer>;
text?: () => Promise<string>;
};
}
interface RequestGlobalsFetchInit {
method?: string;
headers?: unknown;
body?: unknown;
signal?: AbortSignal | null;
miniProgram?: RequestGlobalsMiniProgramOptions;
miniprogram?: RequestGlobalsMiniProgramOptions;
[key: string]: unknown;
}
declare global {
interface RequestInit {
miniProgram?: RequestGlobalsMiniProgramOptions;
miniprogram?: RequestGlobalsMiniProgramOptions;
}
}
type RequestGlobalsFetchInput = string | URL | URLPolyfill | RequestLikeInput;
/**
* @description 使用 @wevu/api 的 request 能力实现 fetch 语义对齐。
*/
declare function fetch(input: RequestGlobalsFetchInput, init?: RequestGlobalsFetchInit): Promise<Response>;
//#endregion
export { RequestGlobalsFetchInit, type RequestGlobalsMiniProgramOptions, fetch };