mphttpx 1.0.6 → 1.0.7

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
@@ -35,98 +35,6 @@ declare const TextDecoderE: {
35
35
  prototype: TextDecoder;
36
36
  };
37
37
 
38
- declare class EventP implements Event {
39
- static readonly NONE: 0;
40
- static readonly CAPTURING_PHASE: 1;
41
- static readonly AT_TARGET: 2;
42
- static readonly BUBBLING_PHASE: 3;
43
- constructor(type: string, eventInitDict?: EventInit);
44
- get type(): string;
45
- get bubbles(): boolean;
46
- get cancelable(): boolean;
47
- get composed(): boolean;
48
- get target(): EventTarget | null;
49
- get currentTarget(): EventTarget | null;
50
- get eventPhase(): number;
51
- readonly NONE: 0;
52
- readonly CAPTURING_PHASE: 1;
53
- readonly AT_TARGET: 2;
54
- readonly BUBBLING_PHASE: 3;
55
- get srcElement(): EventTarget | null;
56
- get cancelBubble(): boolean;
57
- set cancelBubble(value: boolean);
58
- get defaultPrevented(): boolean;
59
- get returnValue(): boolean;
60
- set returnValue(value: boolean);
61
- readonly isTrusted: boolean;
62
- get timeStamp(): number;
63
- composedPath(): EventTarget[];
64
- initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
65
- preventDefault(): void;
66
- stopImmediatePropagation(): void;
67
- stopPropagation(): void;
68
- toString(): string;
69
- get isPolyfill(): {
70
- symbol: symbol;
71
- hierarchy: string[];
72
- };
73
- }
74
- declare const EventE: {
75
- new (type: string, eventInitDict?: EventInit): Event;
76
- prototype: Event;
77
- readonly NONE: 0;
78
- readonly CAPTURING_PHASE: 1;
79
- readonly AT_TARGET: 2;
80
- readonly BUBBLING_PHASE: 3;
81
- };
82
-
83
- declare class EventTargetP implements EventTarget {
84
- constructor();
85
- addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
86
- dispatchEvent(event: Event): boolean;
87
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
88
- toString(): string;
89
- get isPolyfill(): {
90
- symbol: symbol;
91
- hierarchy: string[];
92
- };
93
- }
94
- declare const EventTargetE: {
95
- new (): EventTarget;
96
- prototype: EventTarget;
97
- };
98
-
99
- declare class CustomEventP<T> extends EventP implements CustomEvent {
100
- constructor(type: string, eventInitDict?: CustomEventInit<T>);
101
- get detail(): T;
102
- initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void;
103
- toString(): string;
104
- get isPolyfill(): {
105
- symbol: symbol;
106
- hierarchy: string[];
107
- };
108
- }
109
- declare const CustomEventE: {
110
- new <T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
111
- prototype: CustomEvent;
112
- };
113
-
114
- declare class ProgressEventP extends EventP implements ProgressEvent {
115
- constructor(type: string, eventInitDict?: ProgressEventInit);
116
- get lengthComputable(): boolean;
117
- get loaded(): number;
118
- get total(): number;
119
- toString(): string;
120
- get isPolyfill(): {
121
- symbol: symbol;
122
- hierarchy: string[];
123
- };
124
- }
125
- declare const ProgressEventE: {
126
- new (type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
127
- prototype: ProgressEvent;
128
- };
129
-
130
38
  declare class BlobP implements Blob {
131
39
  constructor(blobParts?: BlobPart[], options?: BlobPropertyBag);
132
40
  get size(): number;
@@ -163,6 +71,22 @@ declare const FileE: {
163
71
  prototype: File;
164
72
  };
165
73
 
74
+ declare class EventTargetP implements EventTarget {
75
+ 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
+ };
84
+ }
85
+ declare const EventTargetE: {
86
+ new (): EventTarget;
87
+ prototype: EventTarget;
88
+ };
89
+
166
90
  declare class FileReaderP extends EventTargetP implements FileReader {
167
91
  static readonly EMPTY: 0;
168
92
  static readonly LOADING: 1;
@@ -255,6 +179,120 @@ declare const URLSearchParamsE: {
255
179
  prototype: URLSearchParams;
256
180
  };
257
181
 
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;
185
+
186
+ declare class HeadersP implements Headers {
187
+ constructor(init?: HeadersInit);
188
+ append(name: string, value: string): void;
189
+ delete(name: string): void;
190
+ get(name: string): string | null;
191
+ 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;
195
+ entries(): ArrayIterator<[string, string]>;
196
+ keys(): ArrayIterator<string>;
197
+ values(): ArrayIterator<string>;
198
+ [Symbol.iterator](): ArrayIterator<[string, string]>;
199
+ toString(): string;
200
+ get isPolyfill(): {
201
+ symbol: symbol;
202
+ hierarchy: string[];
203
+ };
204
+ }
205
+ declare const HeadersE: {
206
+ new (init?: HeadersInit): Headers;
207
+ prototype: Headers;
208
+ };
209
+
210
+ declare class BodyImpl implements Body {
211
+ constructor();
212
+ get body(): Body["body"];
213
+ get bodyUsed(): boolean;
214
+ arrayBuffer(): Promise<ArrayBuffer>;
215
+ blob(): Promise<Blob>;
216
+ bytes(): Promise<Uint8Array<ArrayBuffer>>;
217
+ formData(): Promise<FormData>;
218
+ json(): Promise<any>;
219
+ text(): Promise<string>;
220
+ toString(): string;
221
+ get isPolyfill(): {
222
+ symbol: symbol;
223
+ hierarchy: string[];
224
+ };
225
+ }
226
+
227
+ declare class RequestP extends BodyImpl implements Request {
228
+ constructor(input: RequestInfo | URL, init?: RequestInit);
229
+ get cache(): RequestCache;
230
+ get credentials(): RequestCredentials;
231
+ get destination(): RequestDestination;
232
+ get headers(): Headers;
233
+ get integrity(): string;
234
+ get keepalive(): boolean;
235
+ get method(): string;
236
+ get mode(): RequestMode;
237
+ get redirect(): RequestRedirect;
238
+ get referrer(): string;
239
+ get referrerPolicy(): ReferrerPolicy;
240
+ get signal(): AbortSignal;
241
+ get url(): string;
242
+ clone(): Request;
243
+ toString(): string;
244
+ get isPolyfill(): {
245
+ symbol: symbol;
246
+ hierarchy: string[];
247
+ };
248
+ }
249
+ declare const RequestE: {
250
+ new (input: RequestInfo | URL, init?: RequestInit): Request;
251
+ prototype: Request;
252
+ };
253
+
254
+ declare class ResponseP extends BodyImpl implements Response {
255
+ constructor(body?: BodyInit | null, init?: ResponseInit);
256
+ get headers(): Headers;
257
+ get ok(): boolean;
258
+ get redirected(): boolean;
259
+ get status(): number;
260
+ get statusText(): string;
261
+ get type(): ResponseType;
262
+ get url(): string;
263
+ clone(): Response;
264
+ static json(data: any, init?: ResponseInit): Response;
265
+ 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
+ };
272
+ }
273
+ declare const ResponseE: {
274
+ new (body?: BodyInit | null, init?: ResponseInit): Response;
275
+ prototype: Response;
276
+ error(): Response;
277
+ json(data: any, init?: ResponseInit): Response;
278
+ redirect(url: string | URL, status?: number): Response;
279
+ };
280
+
281
+ declare class AbortControllerP implements AbortController {
282
+ constructor();
283
+ get signal(): AbortSignal;
284
+ abort(reason?: any): void;
285
+ toString(): string;
286
+ get isPolyfill(): {
287
+ symbol: symbol;
288
+ hierarchy: string[];
289
+ };
290
+ }
291
+ declare const AbortControllerE: {
292
+ new (): AbortController;
293
+ prototype: AbortController;
294
+ };
295
+
258
296
  declare class AbortSignalP extends EventTargetP implements AbortSignal {
259
297
  static abort(reason?: any): AbortSignal;
260
298
  static any(signals: AbortSignal[]): AbortSignal;
@@ -279,19 +317,80 @@ declare const AbortSignalE: {
279
317
  timeout(milliseconds: number): AbortSignal;
280
318
  };
281
319
 
282
- declare class AbortControllerP implements AbortController {
283
- constructor();
284
- get signal(): AbortSignal;
285
- abort(reason?: any): void;
320
+ declare class EventP implements Event {
321
+ static readonly NONE: 0;
322
+ static readonly CAPTURING_PHASE: 1;
323
+ static readonly AT_TARGET: 2;
324
+ static readonly BUBBLING_PHASE: 3;
325
+ constructor(type: string, eventInitDict?: EventInit);
326
+ get type(): string;
327
+ get bubbles(): boolean;
328
+ get cancelable(): boolean;
329
+ get composed(): boolean;
330
+ get target(): EventTarget | null;
331
+ get currentTarget(): EventTarget | null;
332
+ get eventPhase(): number;
333
+ readonly NONE: 0;
334
+ readonly CAPTURING_PHASE: 1;
335
+ readonly AT_TARGET: 2;
336
+ readonly BUBBLING_PHASE: 3;
337
+ get srcElement(): EventTarget | null;
338
+ get cancelBubble(): boolean;
339
+ set cancelBubble(value: boolean);
340
+ get defaultPrevented(): boolean;
341
+ get returnValue(): boolean;
342
+ set returnValue(value: boolean);
343
+ readonly isTrusted: boolean;
344
+ get timeStamp(): number;
345
+ composedPath(): EventTarget[];
346
+ initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
347
+ preventDefault(): void;
348
+ stopImmediatePropagation(): void;
349
+ stopPropagation(): void;
286
350
  toString(): string;
287
351
  get isPolyfill(): {
288
352
  symbol: symbol;
289
353
  hierarchy: string[];
290
354
  };
291
355
  }
292
- declare const AbortControllerE: {
293
- new (): AbortController;
294
- prototype: AbortController;
356
+ declare const EventE: {
357
+ new (type: string, eventInitDict?: EventInit): Event;
358
+ prototype: Event;
359
+ readonly NONE: 0;
360
+ readonly CAPTURING_PHASE: 1;
361
+ readonly AT_TARGET: 2;
362
+ readonly BUBBLING_PHASE: 3;
363
+ };
364
+
365
+ declare class CustomEventP<T> extends EventP implements CustomEvent {
366
+ constructor(type: string, eventInitDict?: CustomEventInit<T>);
367
+ 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
+ };
374
+ }
375
+ declare const CustomEventE: {
376
+ new <T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
377
+ prototype: CustomEvent;
378
+ };
379
+
380
+ declare class ProgressEventP extends EventP implements ProgressEvent {
381
+ constructor(type: string, eventInitDict?: ProgressEventInit);
382
+ get lengthComputable(): boolean;
383
+ get loaded(): number;
384
+ get total(): number;
385
+ toString(): string;
386
+ get isPolyfill(): {
387
+ symbol: symbol;
388
+ hierarchy: string[];
389
+ };
390
+ }
391
+ declare const ProgressEventE: {
392
+ new (type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
393
+ prototype: ProgressEvent;
295
394
  };
296
395
 
297
396
  declare class XMLHttpRequestEventTargetP extends EventTargetP implements XMLHttpRequestEventTarget {
@@ -317,6 +416,352 @@ declare class XMLHttpRequestEventTargetP extends EventTargetP implements XMLHttp
317
416
  };
318
417
  }
319
418
 
419
+ /**
420
+ * 发起 HTTPS 网络请求。
421
+ */
422
+ type TRequestFunc = (options: IRequestOptions) => IRequestTask;
423
+ interface IRequestOptions {
424
+ /**
425
+ * 开发者服务器接口地址
426
+ */
427
+ url: string;
428
+ /**
429
+ * 请求的参数
430
+ */
431
+ data?: string | object | ArrayBuffer;
432
+ /**
433
+ * 设置请求的 header,header 中不能设置 Referer。content-type 默认为 application/json
434
+ */
435
+ header?: object;
436
+ /**
437
+ * 超时时间,单位为毫秒。默认值为 60000
438
+ */
439
+ timeout?: number;
440
+ /**
441
+ * HTTP 请求方法
442
+ * 默认值:GET
443
+ */
444
+ method?: "OPTIONS" | "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "TRACE" | "CONNECT";
445
+ /**
446
+ * 返回的数据格式
447
+ * 合法值:
448
+ * - json(默认值): 返回的数据为 JSON,返回后会对返回的数据进行一次 JSON.parse
449
+ * - 其他: 不对返回的内容进行 JSON.parse
450
+ * - 支付宝(额外类型):"json_or_text" | "base64" | "arraybuffer"
451
+ */
452
+ dataType?: "json" | "text" | "json_or_text" | "base64" | "arraybuffer";
453
+ /**
454
+ * 响应的数据类型
455
+ * 合法值:
456
+ * - text(默认值): 响应的数据为文本
457
+ * - arraybuffer: 响应的数据为 ArrayBuffer
458
+ */
459
+ responseType?: "text" | "arraybuffer";
460
+ /**
461
+ * 使用高性能模式。从基础库 v3.5.0 开始在 Android 端默认开启,其他端暂不生效。该模式下有更优的网络性能表现,更多信息请查看下方说明。
462
+ * 默认值:true
463
+ */
464
+ useHighPerformanceMode?: boolean;
465
+ withCredentials?: boolean;
466
+ /**
467
+ * 支付宝
468
+ * 是否手工设置 cookie。如果为 true,请求将使用 headers 中设置的 cookie;如果为 false,则 headers 中的 cookie 字段将被忽略,请求头中将包含服务端上一次返回的 cookie(如果有且未过期)
469
+ * 默认值:false
470
+ */
471
+ enableCookie?: boolean;
472
+ /**
473
+ * 开启 http2
474
+ * 默认值:false
475
+ */
476
+ enableHttp2?: boolean;
477
+ /**
478
+ * 是否开启 profile。iOS 和 Android 端默认开启,其他端暂不支持。开启后可在接口回调的 res.profile 中查看性能调试信息。
479
+ * 默认值:true
480
+ */
481
+ enableProfile?: boolean;
482
+ /**
483
+ * 是否开启 Quic/h3 协议(iOS 微信目前使用 gQUIC-Q43;Android 微信在 v8.0.54 前使用 gQUIC-Q43,v8.0.54 开始使用 IETF QUIC,即 h3 协议;PC微信使用 IETF QUIC,即 h3 协议)
484
+ * 默认值:false
485
+ */
486
+ enableQuic?: boolean;
487
+ /**
488
+ * 开启 Http 缓存
489
+ * 默认值:false
490
+ */
491
+ enableCache?: boolean;
492
+ /**
493
+ * 是否开启 HttpDNS 服务。如开启,需要同时填入 httpDNSServiceId 。
494
+ * 默认值:false
495
+ */
496
+ enableHttpDNS?: boolean;
497
+ /**
498
+ * HttpDNS 服务商 Id。
499
+ */
500
+ httpDNSServiceId?: string;
501
+ /**
502
+ * HttpDNS 超时时间。HttpDNS解析时间超过该值时不再走HttpDNS,本次请求将回退到localDNS。默认为 60000 毫秒。
503
+ * 默认值:60000
504
+ */
505
+ httpDNSTimeout?: number;
506
+ /**
507
+ * 开启 transfer-encoding chunked。
508
+ * 默认值:false
509
+ */
510
+ enableChunked?: boolean;
511
+ /**
512
+ * 强制使用蜂窝网络发送请求
513
+ * 默认值:false
514
+ */
515
+ forceCellularNetwork?: boolean;
516
+ /**
517
+ * 重定向拦截策略。(目前安卓、iOS、开发者工具已支持,PC端将在后续支持)
518
+ * 合法值:
519
+ * - follow(默认值): 不拦截重定向,即客户端自动处理重定向
520
+ * - manual: 拦截重定向。开启后,当 http 状态码为 3xx 时客户端不再自动重定向,而是触发 onHeadersReceived 回调,并结束本次 request 请求。可通过 onHeadersReceived 回调中的 header.Location 获取重定向的 url
521
+ */
522
+ redirect?: "follow" | "manual";
523
+ /**
524
+ * 接口调用成功的回调函数
525
+ */
526
+ success?: (res: IRequestSuccessCallbackResult) => void;
527
+ /**
528
+ * 接口调用失败的回调函数
529
+ */
530
+ fail?: (err: IRequestFailCallbackResult) => void;
531
+ /**
532
+ * 接口调用结束的回调函数(调用成功、失败都会执行)
533
+ */
534
+ complete?: Function;
535
+ }
536
+ interface IGeneralCallbackResult {
537
+ /**
538
+ * 网络请求过程中的一些异常信息,例如httpdns超时等
539
+ */
540
+ exception: {
541
+ /**
542
+ * 本次请求底层重试次数
543
+ */
544
+ retryCount: number;
545
+ /**
546
+ * 本次请求底层失败信息,所有失败信息均符合Errno错误码
547
+ */
548
+ reasons: Array<{
549
+ /**
550
+ * 错误原因
551
+ */
552
+ errMsg: string;
553
+ /**
554
+ * 错误码
555
+ */
556
+ errno: number;
557
+ }>;
558
+ };
559
+ /**
560
+ * 最终请求是否使用了HttpDNS解析的IP。仅当enableHttpDNS传true时返回此字段。如果开启enableHttpDNS但最终请求未使用HttpDNS解析的IP,可在exception查看原因。
561
+ */
562
+ useHttpDNS: boolean;
563
+ }
564
+ interface IRequestSuccessCallbackBaseResult {
565
+ /**
566
+ * 开发者服务器返回的数据
567
+ */
568
+ data: string | object | ArrayBuffer;
569
+ /**
570
+ * 开发者服务器返回的 HTTP 状态码
571
+ */
572
+ statusCode: number;
573
+ /**
574
+ * 开发者服务器返回的 HTTP Response Header
575
+ */
576
+ header: object;
577
+ }
578
+ interface IRequestSuccessCallbackResult extends IGeneralCallbackResult, IRequestSuccessCallbackBaseResult {
579
+ /**
580
+ * 开发者服务器返回的 cookies,格式为字符串数组
581
+ */
582
+ cookies: string[];
583
+ /**
584
+ * 网络请求过程中一些调试信息。目前仅 iOS 和 Android 端支持,其他端暂不支持。
585
+ */
586
+ profile: {
587
+ /**
588
+ * 调用接口的时间。
589
+ */
590
+ invokeStart: number;
591
+ /**
592
+ * httpDNS 开始查询的时间。仅当开启 httpDNS 功能时返回该字段。目前仅wx.request接口支持
593
+ */
594
+ httpDNSDomainLookUpStart: number;
595
+ /**
596
+ * httpDNS 完成查询的时间。仅当开启 httpDNS 功能时返回该字段。目前仅wx.request接口支持
597
+ */
598
+ httpDNSDomainLookUpEnd: number;
599
+ /**
600
+ * 开始排队的时间。达到并行上限时才需要排队。
601
+ */
602
+ queueStart: number;
603
+ /**
604
+ * 结束排队的时间。达到并行上限时才需要排队。如果未发生排队,则该字段和 queueStart 字段值相同
605
+ */
606
+ queueEnd: number;
607
+ /**
608
+ * 第一个 HTTP 重定向发生时的时间。有跳转且是同域名内的重定向才算,否则值为 0
609
+ */
610
+ redirectStart: number;
611
+ /**
612
+ * 最后一个 HTTP 重定向完成时的时间。有跳转且是同域名内部的重定向才算,否则值为 0
613
+ */
614
+ redirectEnd: number;
615
+ /**
616
+ * 组件准备好使用 HTTP 请求抓取资源的时间,这发生在检查本地缓存之前
617
+ */
618
+ fetchStart: number;
619
+ /**
620
+ * Local DNS 域名查询开始的时间,如果使用了本地缓存(即无 DNS 查询)或持久连接,则与 fetchStart 值相等
621
+ */
622
+ domainLookUpStart: number;
623
+ /**
624
+ * Local DNS 域名查询完成的时间,如果使用了本地缓存(即无 DNS 查询)或持久连接,则与 fetchStart 值相等
625
+ */
626
+ domainLookUpEnd: number;
627
+ /**
628
+ * HTTP(TCP) 开始建立连接的时间,如果是持久连接,则与 fetchStart 值相等。注意如果在传输层发生了错误且重新建立连接,则这里显示的是新建立的连接开始的时间
629
+ */
630
+ connectStart: number;
631
+ /**
632
+ * HTTP(TCP) 完成建立连接的时间(完成握手),如果是持久连接,则与 fetchStart 值相等。注意如果在传输层发生了错误且重新建立连接,则这里显示的是新建立的连接完成的时间。注意这里握手结束,包括安全连接建立完成、SOCKS 授权通过
633
+ */
634
+ connectEnd: number;
635
+ /**
636
+ * SSL建立连接的时间,如果不是安全连接,则值为 0
637
+ */
638
+ SSLconnectionStart: number;
639
+ /**
640
+ * SSL建立完成的时间,如果不是安全连接,则值为 0
641
+ */
642
+ SSLconnectionEnd: number;
643
+ /**
644
+ * HTTP请求读取真实文档开始的时间(完成建立连接),包括从本地读取缓存。连接错误重连时,这里显示的也是新建立连接的时间
645
+ */
646
+ requestStart: number;
647
+ /**
648
+ * HTTP请求读取真实文档结束的时间
649
+ */
650
+ requestEnd: number;
651
+ /**
652
+ * HTTP 开始接收响应的时间(获取到第一个字节),包括从本地读取缓存
653
+ */
654
+ responseStart: number;
655
+ /**
656
+ * HTTP 响应全部接收完成的时间(获取到最后一个字节),包括从本地读取缓存
657
+ */
658
+ responseEnd: number;
659
+ /**
660
+ * 当次请求连接过程中实时 rtt
661
+ */
662
+ rtt: number;
663
+ /**
664
+ * 评估的网络状态 unknown, offline, slow 2g, 2g, 3g, 4g, last/0, 1, 2, 3, 4, 5, 6
665
+ */
666
+ estimate_nettype: number;
667
+ /**
668
+ * 协议层根据多个请求评估当前网络的 rtt(仅供参考)
669
+ */
670
+ httpRttEstimate: number;
671
+ /**
672
+ * 传输层根据多个请求评估的当前网络的 rtt(仅供参考)
673
+ */
674
+ transportRttEstimate: number;
675
+ /**
676
+ * 评估当前网络下载的kbps
677
+ */
678
+ downstreamThroughputKbpsEstimate: number;
679
+ /**
680
+ * 当前网络的实际下载kbps
681
+ */
682
+ throughputKbps: number;
683
+ /**
684
+ * 当前请求的IP
685
+ */
686
+ peerIP: string;
687
+ /**
688
+ * 当前请求的端口
689
+ */
690
+ port: number;
691
+ /**
692
+ * 是否复用连接
693
+ */
694
+ socketReused: boolean;
695
+ /**
696
+ * 发送的字节数
697
+ */
698
+ sendBytesCount: number;
699
+ /**
700
+ * 收到字节数
701
+ */
702
+ receivedBytedCount: number;
703
+ /**
704
+ * 使用协议类型,有效值:http1.1, h2, quic, unknown
705
+ */
706
+ protocol: string;
707
+ /**
708
+ * 是否走到了高性能模式。基础库 v3.3.4 起支持。
709
+ */
710
+ usingHighPerformanceMode: boolean;
711
+ };
712
+ }
713
+ interface IRequestFailCallbackResult extends IGeneralCallbackResult {
714
+ /**
715
+ * 错误信息
716
+ */
717
+ errMsg: string;
718
+ /**
719
+ * errno 错误码
720
+ */
721
+ errno: number;
722
+ }
723
+ interface IRequestTask {
724
+ /**
725
+ * 中断请求任务
726
+ */
727
+ abort: () => void;
728
+ /**
729
+ * 监听 HTTP Response Header 事件。会比请求完成事件更早
730
+ */
731
+ onHeadersReceived: (listener: (res: {
732
+ /**
733
+ * 开发者服务器返回的 HTTP Response Header
734
+ */
735
+ header: object;
736
+ /**
737
+ * 开发者服务器返回的 HTTP 状态码 (目前开发者工具上不会返回 statusCode 字段,可用真机查看该字段,后续将会支持)
738
+ */
739
+ statusCode: number;
740
+ /**
741
+ * 开发者服务器返回的 cookies,格式为字符串数组
742
+ */
743
+ cookies: string[];
744
+ }) => void) => void;
745
+ /**
746
+ * 移除 HTTP Response Header 事件的监听函数
747
+ */
748
+ offHeadersReceived: (listener: Function) => void;
749
+ /**
750
+ * 监听 Transfer-Encoding Chunk Received 事件。当接收到新的chunk时触发。
751
+ */
752
+ onChunkReceived: (listener: (res: {
753
+ /**
754
+ * 返回的chunk buffer
755
+ */
756
+ data: ArrayBuffer;
757
+ }) => void) => void;
758
+ /**
759
+ * 移除 Transfer-Encoding Chunk Received 事件的监听函数
760
+ */
761
+ offChunkReceived: (listener: Function) => void;
762
+ }
763
+
764
+ declare const setRequest: (request: TRequestFunc) => void;
320
765
  declare class XMLHttpRequestP extends XMLHttpRequestEventTargetP implements XMLHttpRequest {
321
766
  static readonly UNSENT: 0;
322
767
  static readonly OPENED: 1;
@@ -368,102 +813,4 @@ declare const XMLHttpRequestE: {
368
813
  readonly DONE: 4;
369
814
  } | typeof XMLHttpRequestP;
370
815
 
371
- declare function fetchP(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
372
- declare const fetchE: typeof fetch;
373
-
374
- declare class HeadersP implements Headers {
375
- constructor(init?: HeadersInit);
376
- append(name: string, value: string): void;
377
- delete(name: string): void;
378
- get(name: string): string | null;
379
- getSetCookie(): string[];
380
- has(name: string): boolean;
381
- set(name: string, value: string): void;
382
- forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void;
383
- entries(): MapIterator<[string, string]>;
384
- keys(): ArrayIterator<string>;
385
- values(): ArrayIterator<string>;
386
- [Symbol.iterator](): MapIterator<[string, string]>;
387
- toString(): string;
388
- get isPolyfill(): {
389
- symbol: symbol;
390
- hierarchy: string[];
391
- };
392
- }
393
- declare const HeadersE: {
394
- new (init?: HeadersInit): Headers;
395
- prototype: Headers;
396
- };
397
-
398
- declare class BodyP implements Body {
399
- constructor();
400
- get body(): Body["body"];
401
- get bodyUsed(): boolean;
402
- arrayBuffer(): Promise<ArrayBuffer>;
403
- blob(): Promise<Blob>;
404
- bytes(): Promise<Uint8Array<ArrayBuffer>>;
405
- formData(): Promise<FormData>;
406
- json(): Promise<any>;
407
- text(): Promise<string>;
408
- toString(): string;
409
- get isPolyfill(): {
410
- symbol: symbol;
411
- hierarchy: string[];
412
- };
413
- }
414
-
415
- declare class RequestP extends BodyP implements Request {
416
- constructor(input: RequestInfo | URL, init?: RequestInit);
417
- get cache(): RequestCache;
418
- get credentials(): RequestCredentials;
419
- get destination(): RequestDestination;
420
- get headers(): Headers;
421
- get integrity(): string;
422
- get keepalive(): boolean;
423
- get method(): string;
424
- get mode(): RequestMode;
425
- get redirect(): RequestRedirect;
426
- get referrer(): string;
427
- get referrerPolicy(): ReferrerPolicy;
428
- get signal(): AbortSignal;
429
- get url(): string;
430
- clone(): Request;
431
- toString(): string;
432
- get isPolyfill(): {
433
- symbol: symbol;
434
- hierarchy: string[];
435
- };
436
- }
437
- declare const RequestE: {
438
- new (input: RequestInfo | URL, init?: RequestInit): Request;
439
- prototype: Request;
440
- };
441
-
442
- declare class ResponseP extends BodyP implements Response {
443
- constructor(body?: BodyInit | null, init?: ResponseInit);
444
- get headers(): Headers;
445
- get ok(): boolean;
446
- get redirected(): boolean;
447
- get status(): number;
448
- get statusText(): string;
449
- get type(): ResponseType;
450
- get url(): string;
451
- clone(): Response;
452
- static json(data: any, init?: ResponseInit): Response;
453
- static error(): ResponseP;
454
- static redirect(url: string | URL, status?: number): Response;
455
- toString(): string;
456
- get isPolyfill(): {
457
- symbol: symbol;
458
- hierarchy: string[];
459
- };
460
- }
461
- declare const ResponseE: {
462
- new (body?: BodyInit | null, init?: ResponseInit): Response;
463
- prototype: Response;
464
- error(): Response;
465
- json(data: any, init?: ResponseInit): Response;
466
- redirect(url: string | URL, status?: number): Response;
467
- };
468
-
469
- 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 };
816
+ 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 };