mphttpx 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,7 @@
1
1
  declare class TextEncoderP implements TextEncoder {
2
2
  get encoding(): string;
3
3
  encode(input?: string): Uint8Array<ArrayBuffer>;
4
- encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
5
- toString(): string;
6
- get isPolyfill(): {
7
- symbol: symbol;
8
- hierarchy: string[];
9
- };
4
+ encodeInto(...args: Parameters<TextEncoder["encodeInto"]>): TextEncoderEncodeIntoResult;
10
5
  }
11
6
  declare const TextEncoderE: {
12
7
  new (): TextEncoder;
@@ -14,21 +9,16 @@ declare const TextEncoderE: {
14
9
  };
15
10
 
16
11
  declare class TextDecoderP implements TextDecoder {
17
- constructor(utfLabel?: string, { fatal, ignoreBOM }?: {
12
+ constructor(label?: string, { fatal, ignoreBOM }?: {
18
13
  fatal?: boolean | undefined;
19
14
  ignoreBOM?: boolean | undefined;
20
15
  });
21
16
  get encoding(): string;
22
17
  get fatal(): boolean;
23
18
  get ignoreBOM(): boolean;
24
- decode(buffer?: Parameters<TextDecoder["decode"]>[0], { stream }?: {
19
+ decode(input?: Parameters<TextDecoder["decode"]>[0], { stream }?: {
25
20
  stream?: boolean | undefined;
26
21
  }): string;
27
- toString(): string;
28
- get isPolyfill(): {
29
- symbol: symbol;
30
- hierarchy: string[];
31
- };
32
22
  }
33
23
  declare const TextDecoderE: {
34
24
  new (label?: string, options?: TextDecoderOptions): TextDecoder;
@@ -44,11 +34,6 @@ declare class BlobP implements Blob {
44
34
  slice(start?: number, end?: number, contentType?: string): Blob;
45
35
  stream(): ReturnType<Blob["stream"]>;
46
36
  text(): Promise<string>;
47
- toString(): string;
48
- get isPolyfill(): {
49
- symbol: symbol;
50
- hierarchy: string[];
51
- };
52
37
  }
53
38
  declare const BlobE: {
54
39
  new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
@@ -56,15 +41,10 @@ declare const BlobE: {
56
41
  };
57
42
 
58
43
  declare class FileP extends BlobP implements File {
59
- constructor(fileBits: BlobPart[], fileName: string, options?: FilePropertyBag);
44
+ constructor(...args: [BlobPart[], string, FilePropertyBag?]);
60
45
  get lastModified(): number;
61
46
  get name(): string;
62
47
  get webkitRelativePath(): string;
63
- toString(): string;
64
- get isPolyfill(): {
65
- symbol: symbol;
66
- hierarchy: string[];
67
- };
68
48
  }
69
49
  declare const FileE: {
70
50
  new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
@@ -73,14 +53,9 @@ declare const FileE: {
73
53
 
74
54
  declare class EventTargetP implements EventTarget {
75
55
  constructor();
76
- addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
77
- dispatchEvent(event: Event): boolean;
78
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
79
- toString(): string;
80
- get isPolyfill(): {
81
- symbol: symbol;
82
- hierarchy: string[];
83
- };
56
+ addEventListener(...args: [string, EventListenerOrEventListenerObject | null, (AddEventListenerOptions | boolean)?]): void;
57
+ dispatchEvent(...args: [Event]): boolean;
58
+ removeEventListener(...args: [string, EventListenerOrEventListenerObject | null, (EventListenerOptions | boolean)?]): void;
84
59
  }
85
60
  declare const EventTargetE: {
86
61
  new (): EventTarget;
@@ -97,12 +72,12 @@ declare class FileReaderP extends EventTargetP implements FileReader {
97
72
  readonly EMPTY: 0;
98
73
  readonly LOADING: 1;
99
74
  readonly DONE: 2;
100
- get error(): DOMException | null;
75
+ get error(): (DOMException | null);
101
76
  abort(): void;
102
- readAsArrayBuffer(blob: Blob): void;
103
- readAsBinaryString(blob: Blob): void;
104
- readAsDataURL(blob: Blob): void;
105
- readAsText(blob: Blob, encoding?: string): void;
77
+ readAsArrayBuffer(...args: [Blob]): void;
78
+ readAsBinaryString(...args: [Blob]): void;
79
+ readAsDataURL(...args: [Blob]): void;
80
+ readAsText(...args: [Blob, string?]): void;
106
81
  get onabort(): ((this: FileReader, ev: ProgressEvent<FileReader>) => any) | null;
107
82
  set onabort(value: ((this: FileReader, ev: ProgressEvent<FileReader>) => any) | null);
108
83
  get onerror(): ((this: FileReader, ev: ProgressEvent<FileReader>) => any) | null;
@@ -115,11 +90,6 @@ declare class FileReaderP extends EventTargetP implements FileReader {
115
90
  set onloadstart(value: ((this: FileReader, ev: ProgressEvent<FileReader>) => any) | null);
116
91
  get onprogress(): ((this: FileReader, ev: ProgressEvent<FileReader>) => any) | null;
117
92
  set onprogress(value: ((this: FileReader, ev: ProgressEvent<FileReader>) => any) | null);
118
- toString(): string;
119
- get isPolyfill(): {
120
- symbol: symbol;
121
- hierarchy: string[];
122
- };
123
93
  }
124
94
  declare const FileReaderE: {
125
95
  new (): FileReader;
@@ -129,86 +99,71 @@ declare const FileReaderE: {
129
99
  readonly DONE: 2;
130
100
  };
131
101
 
132
- declare class FormDataP implements FormData {
133
- constructor(form?: HTMLFormElement, submitter?: HTMLElement | null);
134
- append(name: string, value: string | Blob, filename?: string): void;
135
- delete(name: string): void;
136
- get(name: string): FormDataEntryValue | null;
137
- getAll(name: string): FormDataEntryValue[];
138
- has(name: string): boolean;
139
- set(name: string, value: string | Blob, filename?: string): void;
140
- forEach(callbackfn: (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg?: any): void;
141
- entries(): ArrayIterator<[string, FormDataEntryValue]>;
142
- keys(): ArrayIterator<string>;
143
- values(): ArrayIterator<FormDataEntryValue>;
144
- [Symbol.iterator](): ArrayIterator<[string, FormDataEntryValue]>;
145
- toString(): string;
146
- get isPolyfill(): {
147
- symbol: symbol;
148
- hierarchy: string[];
149
- };
150
- }
151
- declare const FormDataE: {
152
- new (form?: HTMLFormElement, submitter?: HTMLElement | null): FormData;
153
- prototype: FormData;
154
- };
155
-
156
102
  declare class URLSearchParamsP implements URLSearchParams {
157
103
  constructor(init?: string[][] | Record<string, string> | string | URLSearchParams);
158
104
  get size(): number;
159
- append(name: string, value: string): void;
160
- delete(name: string, value?: string): void;
161
- get(name: string): string | null;
162
- getAll(name: string): string[];
163
- has(name: string, value?: string): boolean;
164
- set(name: string, value: string): void;
105
+ append(...args: [string, string]): void;
106
+ delete(...args: [string, string?]): void;
107
+ get(...args: [string]): string | null;
108
+ getAll(...args: [string]): string[];
109
+ has(...args: [string, string?]): boolean;
110
+ set(...args: [string, string]): void;
165
111
  sort(): void;
166
- forEach(callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any): void;
112
+ forEach(...args: [(value: string, key: string, parent: URLSearchParams) => void, any?]): void;
167
113
  entries(): ArrayIterator<[string, string]>;
168
114
  keys(): ArrayIterator<string>;
169
115
  values(): ArrayIterator<string>;
170
116
  [Symbol.iterator](): ArrayIterator<[string, string]>;
171
117
  toString(): string;
172
- get isPolyfill(): {
173
- symbol: symbol;
174
- hierarchy: string[];
175
- };
176
118
  }
177
119
  declare const URLSearchParamsE: {
178
120
  new (init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
179
121
  prototype: URLSearchParams;
180
122
  };
181
123
 
182
- declare const setXMLHttpRequest: (XHR: (typeof globalThis)["XMLHttpRequest"]) => void;
183
- declare function fetchP(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
184
- declare const fetchE: typeof fetch;
124
+ declare class FormDataP implements FormData {
125
+ constructor(form?: HTMLFormElement, submitter?: HTMLElement | null);
126
+ append(...args: [string, string | Blob, string?]): void;
127
+ delete(...args: [string]): void;
128
+ get(...args: [string]): FormDataEntryValue | null;
129
+ getAll(...args: [string]): FormDataEntryValue[];
130
+ has(...args: [string]): boolean;
131
+ set(...args: [string, string | Blob, string?]): void;
132
+ forEach(...args: [(value: FormDataEntryValue, key: string, parent: FormData) => void, any?]): void;
133
+ entries(): ArrayIterator<[string, FormDataEntryValue]>;
134
+ keys(): ArrayIterator<string>;
135
+ values(): ArrayIterator<FormDataEntryValue>;
136
+ [Symbol.iterator](): ArrayIterator<[string, FormDataEntryValue]>;
137
+ }
138
+ declare const FormDataE: {
139
+ new (form?: HTMLFormElement, submitter?: HTMLElement | null): FormData;
140
+ prototype: FormData;
141
+ };
185
142
 
186
143
  declare class HeadersP implements Headers {
187
144
  constructor(init?: HeadersInit);
188
- append(name: string, value: string): void;
189
- delete(name: string): void;
190
- get(name: string): string | null;
145
+ append(...args: [string, string]): void;
146
+ delete(...args: [string]): void;
147
+ get(...args: [string]): string | null;
191
148
  getSetCookie(): string[];
192
- has(name: string): boolean;
193
- set(name: string, value: string): void;
194
- forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void;
149
+ has(...args: [string]): boolean;
150
+ set(...args: [string, string]): void;
151
+ forEach(...args: [(value: string, key: string, parent: Headers) => void, any?]): void;
195
152
  entries(): ArrayIterator<[string, string]>;
196
153
  keys(): ArrayIterator<string>;
197
154
  values(): ArrayIterator<string>;
198
155
  [Symbol.iterator](): ArrayIterator<[string, string]>;
199
- toString(): string;
200
- get isPolyfill(): {
201
- symbol: symbol;
202
- hierarchy: string[];
203
- };
204
156
  }
205
157
  declare const HeadersE: {
206
158
  new (init?: HeadersInit): Headers;
207
159
  prototype: Headers;
208
160
  };
209
161
 
210
- declare class BodyImpl implements Body {
211
- constructor();
162
+ declare const setXMLHttpRequest: (XHR: (typeof globalThis)["XMLHttpRequest"]) => void;
163
+ declare function fetchP(...args: [RequestInfo | URL, RequestInit?]): Promise<Response>;
164
+ declare const fetchE: typeof fetch;
165
+
166
+ declare abstract class BodyImpl implements Body {
212
167
  get body(): Body["body"];
213
168
  get bodyUsed(): boolean;
214
169
  arrayBuffer(): Promise<ArrayBuffer>;
@@ -217,15 +172,10 @@ declare class BodyImpl implements Body {
217
172
  formData(): Promise<FormData>;
218
173
  json(): Promise<any>;
219
174
  text(): Promise<string>;
220
- toString(): string;
221
- get isPolyfill(): {
222
- symbol: symbol;
223
- hierarchy: string[];
224
- };
225
175
  }
226
176
 
227
177
  declare class RequestP extends BodyImpl implements Request {
228
- constructor(input: RequestInfo | URL, init?: RequestInit);
178
+ constructor(...args: [RequestInfo | URL, RequestInit?]);
229
179
  get cache(): RequestCache;
230
180
  get credentials(): RequestCredentials;
231
181
  get destination(): RequestDestination;
@@ -240,11 +190,6 @@ declare class RequestP extends BodyImpl implements Request {
240
190
  get signal(): AbortSignal;
241
191
  get url(): string;
242
192
  clone(): Request;
243
- toString(): string;
244
- get isPolyfill(): {
245
- symbol: symbol;
246
- hierarchy: string[];
247
- };
248
193
  }
249
194
  declare const RequestE: {
250
195
  new (input: RequestInfo | URL, init?: RequestInit): Request;
@@ -261,14 +206,9 @@ declare class ResponseP extends BodyImpl implements Response {
261
206
  get type(): ResponseType;
262
207
  get url(): string;
263
208
  clone(): Response;
264
- static json(data: any, init?: ResponseInit): Response;
209
+ static json(...args: [any, ResponseInit?]): Response;
265
210
  static error(): Response;
266
- static redirect(url: string | URL, status?: number): Response;
267
- toString(): string;
268
- get isPolyfill(): {
269
- symbol: symbol;
270
- hierarchy: string[];
271
- };
211
+ static redirect(...args: [string | URL, number?]): Response;
272
212
  }
273
213
  declare const ResponseE: {
274
214
  new (body?: BodyInit | null, init?: ResponseInit): Response;
@@ -282,11 +222,6 @@ declare class AbortControllerP implements AbortController {
282
222
  constructor();
283
223
  get signal(): AbortSignal;
284
224
  abort(reason?: any): void;
285
- toString(): string;
286
- get isPolyfill(): {
287
- symbol: symbol;
288
- hierarchy: string[];
289
- };
290
225
  }
291
226
  declare const AbortControllerE: {
292
227
  new (): AbortController;
@@ -295,19 +230,13 @@ declare const AbortControllerE: {
295
230
 
296
231
  declare class AbortSignalP extends EventTargetP implements AbortSignal {
297
232
  static abort(reason?: any): AbortSignal;
298
- static any(signals: AbortSignal[]): AbortSignal;
299
- static timeout(milliseconds: number): AbortSignal;
300
- constructor();
233
+ static any(...args: [AbortSignal[]]): AbortSignal;
234
+ static timeout(...args: [number]): AbortSignal;
301
235
  get aborted(): boolean;
302
236
  get reason(): any;
303
237
  throwIfAborted(): void;
304
238
  get onabort(): ((this: AbortSignal, ev: Event) => any) | null;
305
239
  set onabort(value: ((this: AbortSignal, ev: Event) => any) | null);
306
- toString(): string;
307
- get isPolyfill(): {
308
- symbol: symbol;
309
- hierarchy: string[];
310
- };
311
240
  }
312
241
  declare const AbortSignalE: {
313
242
  new (): AbortSignal;
@@ -322,7 +251,7 @@ declare class EventP implements Event {
322
251
  static readonly CAPTURING_PHASE: 1;
323
252
  static readonly AT_TARGET: 2;
324
253
  static readonly BUBBLING_PHASE: 3;
325
- constructor(type: string, eventInitDict?: EventInit);
254
+ constructor(...args: [string, EventInit?]);
326
255
  get type(): string;
327
256
  get bubbles(): boolean;
328
257
  get cancelable(): boolean;
@@ -343,15 +272,10 @@ declare class EventP implements Event {
343
272
  readonly isTrusted: boolean;
344
273
  get timeStamp(): number;
345
274
  composedPath(): EventTarget[];
346
- initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
275
+ initEvent(...args: [string, boolean?, boolean?]): void;
347
276
  preventDefault(): void;
348
277
  stopImmediatePropagation(): void;
349
278
  stopPropagation(): void;
350
- toString(): string;
351
- get isPolyfill(): {
352
- symbol: symbol;
353
- hierarchy: string[];
354
- };
355
279
  }
356
280
  declare const EventE: {
357
281
  new (type: string, eventInitDict?: EventInit): Event;
@@ -365,12 +289,7 @@ declare const EventE: {
365
289
  declare class CustomEventP<T> extends EventP implements CustomEvent {
366
290
  constructor(type: string, eventInitDict?: CustomEventInit<T>);
367
291
  get detail(): T;
368
- initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void;
369
- toString(): string;
370
- get isPolyfill(): {
371
- symbol: symbol;
372
- hierarchy: string[];
373
- };
292
+ initCustomEvent(...args: [string, boolean?, boolean?, T?]): void;
374
293
  }
375
294
  declare const CustomEventE: {
376
295
  new <T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
@@ -382,40 +301,12 @@ declare class ProgressEventP extends EventP implements ProgressEvent {
382
301
  get lengthComputable(): boolean;
383
302
  get loaded(): number;
384
303
  get total(): number;
385
- toString(): string;
386
- get isPolyfill(): {
387
- symbol: symbol;
388
- hierarchy: string[];
389
- };
390
304
  }
391
305
  declare const ProgressEventE: {
392
306
  new (type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
393
307
  prototype: ProgressEvent;
394
308
  };
395
309
 
396
- declare class XMLHttpRequestEventTargetP extends EventTargetP implements XMLHttpRequestEventTarget {
397
- constructor();
398
- get onabort(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
399
- set onabort(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
400
- get onerror(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
401
- set onerror(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
402
- get onload(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
403
- set onload(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
404
- get onloadend(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
405
- set onloadend(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
406
- get onloadstart(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
407
- set onloadstart(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
408
- get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
409
- set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
410
- get ontimeout(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
411
- set ontimeout(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
412
- toString(): string;
413
- get isPolyfill(): {
414
- symbol: symbol;
415
- hierarchy: string[];
416
- };
417
- }
418
-
419
310
  /**
420
311
  * 发起 HTTPS 网络请求。
421
312
  */
@@ -428,7 +319,7 @@ interface IRequestOptions {
428
319
  /**
429
320
  * 请求的参数
430
321
  */
431
- data?: string | object | ArrayBuffer;
322
+ data: string | object | ArrayBuffer | undefined;
432
323
  /**
433
324
  * 设置请求的 header,header 中不能设置 Referer。content-type 默认为 application/json
434
325
  */
@@ -761,8 +652,25 @@ interface IRequestTask {
761
652
  offChunkReceived: (listener: Function) => void;
762
653
  }
763
654
 
655
+ declare class XMLHttpRequestEventTargetP extends EventTargetP implements XMLHttpRequestEventTarget {
656
+ get onabort(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
657
+ set onabort(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
658
+ get onerror(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
659
+ set onerror(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
660
+ get onload(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
661
+ set onload(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
662
+ get onloadend(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
663
+ set onloadend(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
664
+ get onloadstart(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
665
+ set onloadstart(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
666
+ get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
667
+ set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
668
+ get ontimeout(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
669
+ set ontimeout(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
670
+ }
671
+
764
672
  declare const setRequest: (request: TRequestFunc) => void;
765
- declare class XMLHttpRequestP extends XMLHttpRequestEventTargetP implements XMLHttpRequest {
673
+ declare class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP implements XMLHttpRequest {
766
674
  static readonly UNSENT: 0;
767
675
  static readonly OPENED: 1;
768
676
  static readonly HEADERS_RECEIVED: 2;
@@ -790,19 +698,16 @@ declare class XMLHttpRequestP extends XMLHttpRequestEventTargetP implements XMLH
790
698
  set withCredentials(value: boolean);
791
699
  abort(): void;
792
700
  getAllResponseHeaders(): string;
793
- getResponseHeader(name: string): string | null;
701
+ getResponseHeader(...args: [string]): string | null;
794
702
  open(...args: [method: string, url: string | URL, async?: boolean, username?: string | null, password?: string | null]): void;
795
- overrideMimeType(mime: string): void;
703
+ overrideMimeType(...args: [string]): void;
796
704
  send(body?: Document | XMLHttpRequestBodyInit | null): void;
797
- setRequestHeader(name: string, value: string): void;
705
+ setRequestHeader(...args: [string, string]): void;
798
706
  get onreadystatechange(): ((this: XMLHttpRequest, ev: Event) => any) | null;
799
707
  set onreadystatechange(value: ((this: XMLHttpRequest, ev: Event) => any) | null);
800
- toString(): string;
801
- get isPolyfill(): {
802
- symbol: symbol;
803
- hierarchy: string[];
804
- };
805
708
  }
709
+
710
+ declare const XMLHttpRequestP: typeof XMLHttpRequestImpl;
806
711
  declare const XMLHttpRequestE: {
807
712
  new (): XMLHttpRequest;
808
713
  prototype: XMLHttpRequest;
@@ -811,6 +716,6 @@ declare const XMLHttpRequestE: {
811
716
  readonly HEADERS_RECEIVED: 2;
812
717
  readonly LOADING: 3;
813
718
  readonly DONE: 4;
814
- } | typeof XMLHttpRequestP;
719
+ } | typeof XMLHttpRequestImpl;
815
720
 
816
721
  export { AbortControllerE as AbortController, AbortControllerP, AbortSignalE as AbortSignal, AbortSignalP, BlobE as Blob, BlobP, CustomEventE as CustomEvent, CustomEventP, EventE as Event, EventP, EventTargetE as EventTarget, EventTargetP, FileE as File, FileP, FileReaderE as FileReader, FileReaderP, FormDataE as FormData, FormDataP, HeadersE as Headers, HeadersP, ProgressEventE as ProgressEvent, ProgressEventP, RequestE as Request, RequestP, ResponseE as Response, ResponseP, TextDecoderE as TextDecoder, TextDecoderP, TextEncoderE as TextEncoder, TextEncoderP, URLSearchParamsE as URLSearchParams, URLSearchParamsP, XMLHttpRequestE as XMLHttpRequest, XMLHttpRequestP, fetchE as fetch, fetchP, setRequest, setXMLHttpRequest };