1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | interface Window {
|
9 | fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
10 | }
|
11 | declare let fetch: typeof window.fetch;
|
12 |
|
13 | declare type HeadersInit = Headers | string[][] | { [key: string]: string };
|
14 | declare class Headers {
|
15 | constructor(init?: HeadersInit);
|
16 |
|
17 | append(name: string, value: string): void;
|
18 | delete(name: string): void;
|
19 | get(name: string): string | null;
|
20 | has(name: string): boolean;
|
21 | set(name: string, value: string): void;
|
22 |
|
23 | // WebIDL pair iterator: iterable<ByteString, ByteString>
|
24 | entries(): IterableIterator<[string, string]>;
|
25 | forEach(callback: (value: string, index: number, headers: Headers) => void, thisArg?: any): void;
|
26 | keys(): IterableIterator<string>;
|
27 | values(): IterableIterator<string>;
|
28 | [Symbol.iterator](): IterableIterator<[string, string]>;
|
29 | }
|
30 |
|
31 | declare type BodyInit = Blob | ArrayBufferView | ArrayBuffer | FormData /* | URLSearchParams */ | string;
|
32 | declare type ResponseBodyInit = BodyInit | ReadableStream;
|
33 | interface Body {
|
34 | readonly bodyUsed: boolean;
|
35 | arrayBuffer(): Promise<ArrayBuffer>;
|
36 | blob(): Promise<Blob>;
|
37 | formData(): Promise<FormData>;
|
38 | json(): Promise<any>;
|
39 | json<T>(): Promise<T>;
|
40 | text(): Promise<string>;
|
41 | }
|
42 |
|
43 | declare type RequestInfo = Request | string;
|
44 | declare class Request {
|
45 | constructor(input: RequestInfo, init?: RequestInit);
|
46 |
|
47 | readonly method: string;
|
48 | readonly url: string;
|
49 | readonly headers: Headers;
|
50 |
|
51 | readonly type: RequestType
|
52 | readonly destination: RequestDestination;
|
53 | readonly referrer: string;
|
54 | readonly referrerPolicy: ReferrerPolicy;
|
55 | readonly mode: RequestMode;
|
56 | readonly credentials: RequestCredentials;
|
57 | readonly cache: RequestCache;
|
58 | readonly redirect: RequestRedirect;
|
59 | readonly integrity: string;
|
60 | readonly keepalive: boolean;
|
61 |
|
62 | clone(): Request;
|
63 | }
|
64 | interface Request extends Body {}
|
65 | interface RequestInit {
|
66 | method?: string;
|
67 | headers?: HeadersInit;
|
68 | body?: BodyInit;
|
69 | referrer?: string;
|
70 | referrerPolicy?: ReferrerPolicy;
|
71 | mode?: RequestMode;
|
72 | credentials?: RequestCredentials;
|
73 | cache?: RequestCache;
|
74 | redirect?: RequestRedirect;
|
75 | integrity?: string;
|
76 | window?: null;
|
77 | }
|
78 |
|
79 | type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video";
|
80 | type RequestDestination = "" | "document" | "embed" | "font" | "image" | "manifest" | "media" | "object" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "worker" | "xslt";
|
81 | type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors";
|
82 | type RequestCredentials = "omit" | "same-origin" | "include";
|
83 | type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache" | "only-if-cached";
|
84 | type RequestRedirect = "follow" | "error" | "manual";
|
85 |
|
86 | type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
87 |
|
88 | declare class Response {
|
89 | constructor(body?: ResponseBodyInit, init?: ResponseInit);
|
90 |
|
91 | static error(): Response;
|
92 | static redirect(url: string, status?: number): Response;
|
93 |
|
94 | readonly type: ResponseType;
|
95 |
|
96 | readonly url: string;
|
97 | readonly redirected: boolean;
|
98 | readonly status: number;
|
99 | readonly ok: boolean;
|
100 | readonly statusText: string;
|
101 | readonly headers: Headers;
|
102 | readonly body: ReadableStream | null;
|
103 | readonly trailer: Promise<Headers>;
|
104 |
|
105 | clone(): Response;
|
106 | }
|
107 | interface Response extends Body {}
|
108 |
|
109 | interface ResponseInit {
|
110 | status?: number;
|
111 | statusText?: string;
|
112 | headers?: HeadersInit;
|
113 | }
|
114 |
|
115 | type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
|