mphttpx 1.1.0 → 1.2.0-beta.1
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/README.zh-CN.md +982 -0
- package/dist/index.cjs.js +173 -212
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.d.ts +32 -32
- package/dist/index.esm.js +173 -212
- package/dist/index.esm.min.js +1 -1
- package/package.json +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -7,13 +7,6 @@
|
|
|
7
7
|
/** @internal */
|
|
8
8
|
const polyfill = "MPHTTPX";
|
|
9
9
|
/** @internal */
|
|
10
|
-
function Class_setStringTag(targetFunc, stringTag) {
|
|
11
|
-
Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
|
|
12
|
-
configurable: true,
|
|
13
|
-
value: stringTag,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
/** @internal */
|
|
17
10
|
function checkArgsLength(args, required, className, funcName) {
|
|
18
11
|
if (args.length < required) {
|
|
19
12
|
throw new TypeError(`Failed to ${funcName ? ("execute '" + funcName + "' on") : "construct"} '${className}': ${required} argument${required > 1 ? "s" : ""} required, but only ${args.length} present.`);
|
|
@@ -34,7 +27,7 @@ function isObjectType(name, value) {
|
|
|
34
27
|
return Object.prototype.toString.call(value) === `[object ${name}]`;
|
|
35
28
|
}
|
|
36
29
|
/** @internal */
|
|
37
|
-
function isPolyfillType(name, value) {
|
|
30
|
+
function isPolyfillType(name, value, strict = false) {
|
|
38
31
|
return !!value
|
|
39
32
|
&& typeof value === "object"
|
|
40
33
|
&& "isPolyfill" in value
|
|
@@ -44,7 +37,12 @@ function isPolyfillType(name, value) {
|
|
|
44
37
|
&& value.isPolyfill.symbol === polyfill
|
|
45
38
|
&& "hierarchy" in value.isPolyfill
|
|
46
39
|
&& Array.isArray(value.isPolyfill.hierarchy)
|
|
47
|
-
&& value.isPolyfill.hierarchy.indexOf(name)
|
|
40
|
+
&& ((index) => strict ? index === 0 : index > -1)(value.isPolyfill.hierarchy.indexOf(name));
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
function isArrayBuffer(value) {
|
|
44
|
+
// Mini Program
|
|
45
|
+
return isObjectType("ArrayBuffer", value) || (!!value && typeof value === "object" && ArrayBuffer.prototype.isPrototypeOf(value));
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
class TextEncoderP {
|
|
@@ -57,16 +55,16 @@ class TextEncoderP {
|
|
|
57
55
|
const [source, destination] = args;
|
|
58
56
|
checkArgsLength(args, 2, "TextEncoder", "encodeInto");
|
|
59
57
|
let _source = "" + source;
|
|
60
|
-
if (!(destination instanceof Uint8Array)) {
|
|
58
|
+
if (!(destination instanceof Uint8Array || isObjectType("Uint8Array", destination))) {
|
|
61
59
|
throw new TypeError("Failed to execute 'encodeInto' on 'TextEncoder': parameter 2 is not of type 'Uint8Array'.");
|
|
62
60
|
}
|
|
63
61
|
let result = encodeText(_source, destination);
|
|
64
62
|
return { read: result.read, written: result.written };
|
|
65
63
|
}
|
|
66
64
|
/** @internal */ toString() { return "[object TextEncoder]"; }
|
|
65
|
+
/** @internal */ get [Symbol.toStringTag]() { return "TextEncoder"; }
|
|
67
66
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
|
|
68
67
|
}
|
|
69
|
-
Class_setStringTag(TextEncoderP, "TextEncoder");
|
|
70
68
|
function encodeText(input, destination) {
|
|
71
69
|
const HAS_DESTINATION = typeof destination !== "undefined";
|
|
72
70
|
let pos = 0;
|
|
@@ -183,10 +181,10 @@ class TextDecoderP {
|
|
|
183
181
|
const s = this[state$k];
|
|
184
182
|
let bytes;
|
|
185
183
|
if (input !== undefined) {
|
|
186
|
-
if (input
|
|
184
|
+
if (isArrayBuffer(input)) {
|
|
187
185
|
bytes = new Uint8Array(input);
|
|
188
186
|
}
|
|
189
|
-
else if (input instanceof Uint8Array) {
|
|
187
|
+
else if (input instanceof Uint8Array || isObjectType("Uint8Array", input)) {
|
|
190
188
|
bytes = input;
|
|
191
189
|
}
|
|
192
190
|
else if (ArrayBuffer.isView(input)) {
|
|
@@ -309,9 +307,9 @@ class TextDecoderP {
|
|
|
309
307
|
return res.length > 0x4000 ? buildString(res) : concatString(res);
|
|
310
308
|
}
|
|
311
309
|
/** @internal */ toString() { return "[object TextDecoder]"; }
|
|
310
|
+
/** @internal */ get [Symbol.toStringTag]() { return "TextDecoder"; }
|
|
312
311
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
|
|
313
312
|
}
|
|
314
|
-
Class_setStringTag(TextDecoderP, "TextDecoder");
|
|
315
313
|
/** @internal */ const _bomDone = Symbol();
|
|
316
314
|
/** @internal */ const _partial = Symbol();
|
|
317
315
|
/** @internal */
|
|
@@ -357,7 +355,7 @@ class BlobP {
|
|
|
357
355
|
if (isPolyfillType("Blob", chunk)) {
|
|
358
356
|
chunks.push(chunk[state$j][_buffer]);
|
|
359
357
|
}
|
|
360
|
-
else if (chunk
|
|
358
|
+
else if (isArrayBuffer(chunk) || ArrayBuffer.isView(chunk)) {
|
|
361
359
|
chunks.push(BufferSource_toUint8Array(chunk));
|
|
362
360
|
}
|
|
363
361
|
else {
|
|
@@ -389,9 +387,9 @@ class BlobP {
|
|
|
389
387
|
return Promise.resolve(decode$1(this[state$j][_buffer]));
|
|
390
388
|
}
|
|
391
389
|
/** @internal */ toString() { return "[object Blob]"; }
|
|
390
|
+
/** @internal */ get [Symbol.toStringTag]() { return "Blob"; }
|
|
392
391
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
|
|
393
392
|
}
|
|
394
|
-
Class_setStringTag(BlobP, "Blob");
|
|
395
393
|
/** @internal */
|
|
396
394
|
const _buffer = Symbol();
|
|
397
395
|
/** @internal */
|
|
@@ -407,7 +405,7 @@ function Blob_toUint8Array(blob) {
|
|
|
407
405
|
return blob[state$j][_buffer];
|
|
408
406
|
}
|
|
409
407
|
function BufferSource_toUint8Array(buf) {
|
|
410
|
-
return buf
|
|
408
|
+
return isArrayBuffer(buf)
|
|
411
409
|
? new Uint8Array(buf)
|
|
412
410
|
: new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
413
411
|
}
|
|
@@ -477,9 +475,9 @@ class FileP extends BlobP {
|
|
|
477
475
|
get name() { return this[state$i].name; }
|
|
478
476
|
get webkitRelativePath() { return ""; }
|
|
479
477
|
/** @internal */ toString() { return "[object File]"; }
|
|
478
|
+
/** @internal */ get [Symbol.toStringTag]() { return "File"; }
|
|
480
479
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
|
|
481
480
|
}
|
|
482
|
-
Class_setStringTag(FileP, "File");
|
|
483
481
|
/** @internal */
|
|
484
482
|
class FileState {
|
|
485
483
|
constructor() {
|
|
@@ -492,6 +490,10 @@ const FileE = g["Blob"] ? g["File"] : FileP;
|
|
|
492
490
|
var _a$a, _b$3, _c$1, _d$1, _e$1;
|
|
493
491
|
/** @internal */ const state$h = Symbol( /* "EventState" */);
|
|
494
492
|
class EventP {
|
|
493
|
+
static get NONE() { return 0; }
|
|
494
|
+
static get CAPTURING_PHASE() { return 1; }
|
|
495
|
+
static get AT_TARGET() { return 2; }
|
|
496
|
+
static get BUBBLING_PHASE() { return 3; }
|
|
495
497
|
constructor(...args) {
|
|
496
498
|
const [type, eventInitDict] = args;
|
|
497
499
|
checkArgsLength(args, 1, new.target.name);
|
|
@@ -513,6 +515,10 @@ class EventP {
|
|
|
513
515
|
get target() { return this[state$h].target; }
|
|
514
516
|
get currentTarget() { return this[state$h].currentTarget; }
|
|
515
517
|
get eventPhase() { return this[state$h].eventPhase; }
|
|
518
|
+
get NONE() { return 0; }
|
|
519
|
+
get CAPTURING_PHASE() { return 1; }
|
|
520
|
+
get AT_TARGET() { return 2; }
|
|
521
|
+
get BUBBLING_PHASE() { return 3; }
|
|
516
522
|
get srcElement() { return this[state$h].target; }
|
|
517
523
|
get cancelBubble() { return this[state$h].cancelBubble; }
|
|
518
524
|
set cancelBubble(value) { this[state$h].cancelBubble = !!value; }
|
|
@@ -558,17 +564,9 @@ class EventP {
|
|
|
558
564
|
this.cancelBubble = true;
|
|
559
565
|
}
|
|
560
566
|
/** @internal */ toString() { return "[object Event]"; }
|
|
567
|
+
/** @internal */ get [Symbol.toStringTag]() { return "Event"; }
|
|
561
568
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
|
|
562
569
|
}
|
|
563
|
-
const properties$2 = {
|
|
564
|
-
NONE: { value: 0, enumerable: true },
|
|
565
|
-
CAPTURING_PHASE: { value: 1, enumerable: true },
|
|
566
|
-
AT_TARGET: { value: 2, enumerable: true },
|
|
567
|
-
BUBBLING_PHASE: { value: 3, enumerable: true },
|
|
568
|
-
};
|
|
569
|
-
Object.defineProperties(EventP, properties$2);
|
|
570
|
-
Object.defineProperties(EventP.prototype, properties$2);
|
|
571
|
-
Class_setStringTag(EventP, "Event");
|
|
572
570
|
/** @internal */ const _timeStamp = (new Date()).getTime();
|
|
573
571
|
/** @internal */ const _isTrusted = Symbol();
|
|
574
572
|
/** @internal */ const _passive = Symbol();
|
|
@@ -584,7 +582,7 @@ class EventState {
|
|
|
584
582
|
this.composed = false;
|
|
585
583
|
this.target = null;
|
|
586
584
|
this.currentTarget = null;
|
|
587
|
-
this.eventPhase =
|
|
585
|
+
this.eventPhase = 0 /* NONE */;
|
|
588
586
|
this.cancelBubble = false;
|
|
589
587
|
this.defaultPrevented = false;
|
|
590
588
|
this.returnValue = true;
|
|
@@ -710,9 +708,9 @@ class EventTargetP {
|
|
|
710
708
|
}
|
|
711
709
|
}
|
|
712
710
|
/** @internal */ toString() { return "[object EventTarget]"; }
|
|
711
|
+
/** @internal */ get [Symbol.toStringTag]() { return "EventTarget"; }
|
|
713
712
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
|
|
714
713
|
}
|
|
715
|
-
Class_setStringTag(EventTargetP, "EventTarget");
|
|
716
714
|
/** @internal */
|
|
717
715
|
const _executors = Symbol();
|
|
718
716
|
/** @internal */
|
|
@@ -731,7 +729,7 @@ function EventTarget_fire(target, event) {
|
|
|
731
729
|
if (!event.target)
|
|
732
730
|
evs.target = target;
|
|
733
731
|
evs.currentTarget = target;
|
|
734
|
-
evs.eventPhase =
|
|
732
|
+
evs.eventPhase = 2 /* AT_TARGET */;
|
|
735
733
|
Event_setEtField(event, dispatched$2, true);
|
|
736
734
|
let onceIndexes = [];
|
|
737
735
|
for (let i = 0; i < s[_executors].length; ++i) {
|
|
@@ -761,7 +759,7 @@ function EventTarget_fire(target, event) {
|
|
|
761
759
|
}, []);
|
|
762
760
|
}
|
|
763
761
|
evs.currentTarget = null;
|
|
764
|
-
evs.eventPhase =
|
|
762
|
+
evs.eventPhase = 0 /* NONE */;
|
|
765
763
|
Event_setEtField(event, dispatched$2, false);
|
|
766
764
|
return !(event.cancelable && Event_getEtField(event, preventDefaultCalled));
|
|
767
765
|
}
|
|
@@ -841,9 +839,9 @@ class ProgressEventP extends EventP {
|
|
|
841
839
|
get loaded() { return getValue(this[state$f].loaded); }
|
|
842
840
|
get total() { return getValue(this[state$f].total); }
|
|
843
841
|
/** @internal */ toString() { return "[object ProgressEvent]"; }
|
|
842
|
+
/** @internal */ get [Symbol.toStringTag]() { return "ProgressEvent"; }
|
|
844
843
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
|
|
845
844
|
}
|
|
846
|
-
Class_setStringTag(ProgressEventP, "ProgressEvent");
|
|
847
845
|
/** @internal */
|
|
848
846
|
class ProgressEventState {
|
|
849
847
|
constructor() {
|
|
@@ -879,17 +877,23 @@ var _a$8;
|
|
|
879
877
|
/** @internal */
|
|
880
878
|
const state$e = Symbol( /* "FileReaderState" */);
|
|
881
879
|
class FileReaderP extends EventTargetP {
|
|
880
|
+
static get EMPTY() { return 0; }
|
|
881
|
+
static get LOADING() { return 1; }
|
|
882
|
+
static get DONE() { return 2; }
|
|
882
883
|
constructor() {
|
|
883
884
|
super();
|
|
884
885
|
this[state$e] = new FileReaderState(this);
|
|
885
886
|
}
|
|
886
887
|
get readyState() { return this[state$e].readyState; }
|
|
887
888
|
get result() { return this[state$e].result; }
|
|
889
|
+
get EMPTY() { return 0; }
|
|
890
|
+
get LOADING() { return 1; }
|
|
891
|
+
get DONE() { return 2; }
|
|
888
892
|
get error() { return this[state$e].error; }
|
|
889
893
|
abort() {
|
|
890
|
-
if (this.readyState ===
|
|
894
|
+
if (this.readyState === 1 /* LOADING */) {
|
|
891
895
|
const s = this[state$e];
|
|
892
|
-
s.readyState =
|
|
896
|
+
s.readyState = 2 /* DONE */;
|
|
893
897
|
s.result = null;
|
|
894
898
|
s.error = new MPException("An ongoing operation was aborted, typically with a call to abort().", "AbortError");
|
|
895
899
|
emitProcessEvent(this, "abort");
|
|
@@ -941,22 +945,15 @@ class FileReaderP extends EventTargetP {
|
|
|
941
945
|
get onprogress() { return this[state$e].onprogress; }
|
|
942
946
|
set onprogress(value) { this[state$e].onprogress = value; attach$2(this, "progress"); }
|
|
943
947
|
/** @internal */ toString() { return "[object FileReader]"; }
|
|
948
|
+
/** @internal */ get [Symbol.toStringTag]() { return "FileReader"; }
|
|
944
949
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
|
|
945
950
|
}
|
|
946
|
-
const properties$1 = {
|
|
947
|
-
EMPTY: { value: 0, enumerable: true },
|
|
948
|
-
LOADING: { value: 1, enumerable: true },
|
|
949
|
-
DONE: { value: 2, enumerable: true },
|
|
950
|
-
};
|
|
951
|
-
Object.defineProperties(FileReaderP, properties$1);
|
|
952
|
-
Object.defineProperties(FileReaderP.prototype, properties$1);
|
|
953
|
-
Class_setStringTag(FileReaderP, "FileReader");
|
|
954
951
|
/** @internal */
|
|
955
952
|
const _handlers$4 = Symbol();
|
|
956
953
|
/** @internal */
|
|
957
954
|
class FileReaderState {
|
|
958
955
|
constructor(target) {
|
|
959
|
-
this.readyState =
|
|
956
|
+
this.readyState = 0 /* EMPTY */;
|
|
960
957
|
this.result = null;
|
|
961
958
|
this.error = null;
|
|
962
959
|
this[_a$8] = getHandlers$4(this);
|
|
@@ -978,11 +975,11 @@ function read$1(reader, kind, args, setResult) {
|
|
|
978
975
|
}
|
|
979
976
|
const s = reader[state$e];
|
|
980
977
|
s.error = null;
|
|
981
|
-
s.readyState =
|
|
978
|
+
s.readyState = 1 /* LOADING */;
|
|
982
979
|
emitProcessEvent(s.target, "loadstart", 0, blob.size);
|
|
983
980
|
setTimeout(() => {
|
|
984
|
-
if (s.readyState ===
|
|
985
|
-
s.readyState =
|
|
981
|
+
if (s.readyState === 1 /* LOADING */) {
|
|
982
|
+
s.readyState = 2 /* DONE */;
|
|
986
983
|
try {
|
|
987
984
|
setResult(blob);
|
|
988
985
|
emitProcessEvent(s.target, "load", blob.size, blob.size);
|
|
@@ -1022,7 +1019,7 @@ class URLSearchParamsP {
|
|
|
1022
1019
|
constructor(init) {
|
|
1023
1020
|
this[state$d] = new URLSearchParamsState();
|
|
1024
1021
|
if (init !== undefined) {
|
|
1025
|
-
if (isObjectType("URLSearchParams", init)) {
|
|
1022
|
+
if (isObjectType("URLSearchParams", init) || isPolyfillType("URLSearchParams", init)) {
|
|
1026
1023
|
init.forEach((value, name) => { this.append(name, value); }, this);
|
|
1027
1024
|
}
|
|
1028
1025
|
else if (init && typeof init === "object") {
|
|
@@ -1203,10 +1200,9 @@ class URLSearchParamsP {
|
|
|
1203
1200
|
}
|
|
1204
1201
|
return result.join("&");
|
|
1205
1202
|
}
|
|
1206
|
-
/** @internal */
|
|
1207
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
|
|
1203
|
+
/** @internal */ get [Symbol.toStringTag]() { return "URLSearchParams"; }
|
|
1204
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
|
|
1208
1205
|
}
|
|
1209
|
-
Class_setStringTag(URLSearchParamsP, "URLSearchParams");
|
|
1210
1206
|
/** @internal */
|
|
1211
1207
|
const _urlspArray = Symbol();
|
|
1212
1208
|
/** @internal */
|
|
@@ -1370,9 +1366,9 @@ class FormDataP {
|
|
|
1370
1366
|
return this.entries();
|
|
1371
1367
|
}
|
|
1372
1368
|
/** @internal */ toString() { return "[object FormData]"; }
|
|
1369
|
+
/** @internal */ get [Symbol.toStringTag]() { return "FormData"; }
|
|
1373
1370
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
|
|
1374
1371
|
}
|
|
1375
|
-
Class_setStringTag(FormDataP, "FormData");
|
|
1376
1372
|
/** @internal */
|
|
1377
1373
|
const _formData = Symbol();
|
|
1378
1374
|
/** @internal */
|
|
@@ -1408,7 +1404,7 @@ function normalizeArgs(name, value, filename) {
|
|
|
1408
1404
|
: typeof value.name === "string"
|
|
1409
1405
|
? value.name
|
|
1410
1406
|
: "blob";
|
|
1411
|
-
if (value.name !== filename || isObjectType("Blob", value)) {
|
|
1407
|
+
if (value.name !== filename || isObjectType("Blob", value) || isPolyfillType("Blob", value, true)) {
|
|
1412
1408
|
value = new FileP([value], filename);
|
|
1413
1409
|
}
|
|
1414
1410
|
return ["" + name, value];
|
|
@@ -1485,8 +1481,8 @@ class HeadersP {
|
|
|
1485
1481
|
constructor(init) {
|
|
1486
1482
|
this[state$b] = new HeadersState();
|
|
1487
1483
|
if (init !== undefined) {
|
|
1488
|
-
if (isObjectType("Headers", init)) {
|
|
1489
|
-
init.forEach((value, name) => { this
|
|
1484
|
+
if (isObjectType("Headers", init) || isPolyfillType("Headers", init)) {
|
|
1485
|
+
init.forEach((value, name) => { Headers_append(this, name, value); }, this);
|
|
1490
1486
|
}
|
|
1491
1487
|
else if (Array.isArray(init) || (init && typeof init === "object" && Symbol.iterator in init)) {
|
|
1492
1488
|
let _init = Array.isArray(init) ? init : Array.from(init);
|
|
@@ -1521,51 +1517,20 @@ class HeadersP {
|
|
|
1521
1517
|
checkArgsFn(args, 2, "append");
|
|
1522
1518
|
let _name = normalizeName(name, throwsFn(this[state$b][_initialized] ? "append" : ""));
|
|
1523
1519
|
let _value = normalizeValue(value);
|
|
1524
|
-
|
|
1525
|
-
let array = this[state$b][_headersArray];
|
|
1526
|
-
for (let i = 0; i < array.length; ++i) {
|
|
1527
|
-
let item = array[i];
|
|
1528
|
-
if (item[0] === _name) {
|
|
1529
|
-
item[1] = `${item[1]}, ${_value}`;
|
|
1530
|
-
index = i;
|
|
1531
|
-
break;
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
if (index === -1) {
|
|
1535
|
-
array.push([_name, _value]);
|
|
1536
|
-
}
|
|
1520
|
+
Headers_append(this, _name, _value);
|
|
1537
1521
|
}
|
|
1538
1522
|
delete(...args) {
|
|
1539
1523
|
const [name] = args;
|
|
1540
1524
|
checkArgsFn(args, 1, "delete");
|
|
1541
1525
|
let _name = normalizeName(name, throwsFn("delete"));
|
|
1542
|
-
|
|
1543
|
-
let array = this[state$b][_headersArray];
|
|
1544
|
-
let result = [];
|
|
1545
|
-
for (let i = 0; i < array.length; ++i) {
|
|
1546
|
-
let item = array[i];
|
|
1547
|
-
if (item[0] === _name) {
|
|
1548
|
-
index = i;
|
|
1549
|
-
continue;
|
|
1550
|
-
}
|
|
1551
|
-
result.push(item);
|
|
1552
|
-
}
|
|
1553
|
-
if (index > -1) {
|
|
1554
|
-
this[state$b][_headersArray] = result;
|
|
1555
|
-
}
|
|
1526
|
+
delete this[state$b][_headersDict][_name];
|
|
1556
1527
|
}
|
|
1557
1528
|
get(...args) {
|
|
1529
|
+
var _c;
|
|
1558
1530
|
const [name] = args;
|
|
1559
1531
|
checkArgsFn(args, 1, "get");
|
|
1560
1532
|
let _name = normalizeName(name, throwsFn("get"));
|
|
1561
|
-
|
|
1562
|
-
for (let i = 0; i < array.length; ++i) {
|
|
1563
|
-
let item = array[i];
|
|
1564
|
-
if (item[0] === _name) {
|
|
1565
|
-
return item[1];
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
return null;
|
|
1533
|
+
return (_c = this[state$b][_headersDict][_name]) !== null && _c !== void 0 ? _c : null;
|
|
1569
1534
|
}
|
|
1570
1535
|
getSetCookie() {
|
|
1571
1536
|
let value = this.get("Set-Cookie");
|
|
@@ -1575,33 +1540,14 @@ class HeadersP {
|
|
|
1575
1540
|
const [name] = args;
|
|
1576
1541
|
checkArgsFn(args, 1, "has");
|
|
1577
1542
|
let _name = normalizeName(name, throwsFn("has"));
|
|
1578
|
-
|
|
1579
|
-
for (let i = 0; i < array.length; ++i) {
|
|
1580
|
-
let item = array[i];
|
|
1581
|
-
if (item[0] === _name) {
|
|
1582
|
-
return true;
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
return false;
|
|
1543
|
+
return this[state$b][_headersDict].hasOwnProperty(_name);
|
|
1586
1544
|
}
|
|
1587
1545
|
set(...args) {
|
|
1588
1546
|
const [name, value] = args;
|
|
1589
1547
|
checkArgsFn(args, 2, "set");
|
|
1590
1548
|
let _name = normalizeName(name, throwsFn("set"));
|
|
1591
1549
|
let _value = normalizeValue(value);
|
|
1592
|
-
|
|
1593
|
-
let array = this[state$b][_headersArray];
|
|
1594
|
-
for (let i = 0; i < array.length; ++i) {
|
|
1595
|
-
let item = array[i];
|
|
1596
|
-
if (item[0] === _name) {
|
|
1597
|
-
item[1] = _value;
|
|
1598
|
-
index = i;
|
|
1599
|
-
break;
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
if (index === -1) {
|
|
1603
|
-
array.push([_name, _value]);
|
|
1604
|
-
}
|
|
1550
|
+
this[state$b][_headersDict][_name] = _value;
|
|
1605
1551
|
}
|
|
1606
1552
|
forEach(...args) {
|
|
1607
1553
|
const [callbackfn, thisArg] = args;
|
|
@@ -1609,38 +1555,49 @@ class HeadersP {
|
|
|
1609
1555
|
if (typeof callbackfn !== "function") {
|
|
1610
1556
|
throw new TypeError("Failed to execute 'forEach' on 'Headers': parameter 1 is not of type 'Function'.");
|
|
1611
1557
|
}
|
|
1612
|
-
let
|
|
1613
|
-
for (let i = 0; i <
|
|
1614
|
-
let
|
|
1615
|
-
callbackfn.call(thisArg,
|
|
1558
|
+
let names = Object.getOwnPropertyNames(this[state$b][_headersDict]);
|
|
1559
|
+
for (let i = 0; i < names.length; ++i) {
|
|
1560
|
+
let name = names[i];
|
|
1561
|
+
callbackfn.call(thisArg, this[state$b][_headersDict][name], name, this);
|
|
1616
1562
|
}
|
|
1617
1563
|
}
|
|
1618
1564
|
entries() {
|
|
1619
|
-
|
|
1565
|
+
let array = [];
|
|
1566
|
+
this.forEach((value, name) => { array.push([name, value]); });
|
|
1567
|
+
return array.values();
|
|
1620
1568
|
}
|
|
1621
1569
|
keys() {
|
|
1622
|
-
|
|
1570
|
+
let array = [];
|
|
1571
|
+
this.forEach((value, name) => { array.push(name); });
|
|
1572
|
+
return array.values();
|
|
1623
1573
|
}
|
|
1624
1574
|
values() {
|
|
1625
|
-
|
|
1575
|
+
let array = [];
|
|
1576
|
+
this.forEach((value, name) => { array.push(value); });
|
|
1577
|
+
return array.values();
|
|
1626
1578
|
}
|
|
1627
1579
|
[Symbol.iterator]() {
|
|
1628
1580
|
return this.entries();
|
|
1629
1581
|
}
|
|
1630
1582
|
/** @internal */ toString() { return "[object Headers]"; }
|
|
1583
|
+
/** @internal */ get [Symbol.toStringTag]() { return "Headers"; }
|
|
1631
1584
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
|
|
1632
1585
|
}
|
|
1633
|
-
Class_setStringTag(HeadersP, "Headers");
|
|
1634
1586
|
/** @internal */ const _initialized = Symbol();
|
|
1635
|
-
/** @internal */ const
|
|
1587
|
+
/** @internal */ const _headersDict = Symbol();
|
|
1636
1588
|
/** @internal */
|
|
1637
1589
|
class HeadersState {
|
|
1638
1590
|
constructor() {
|
|
1639
1591
|
this[_a$5] = false;
|
|
1640
|
-
this[_b$2] =
|
|
1592
|
+
this[_b$2] = {};
|
|
1641
1593
|
}
|
|
1642
1594
|
}
|
|
1643
|
-
_a$5 = _initialized, _b$2 =
|
|
1595
|
+
_a$5 = _initialized, _b$2 = _headersDict;
|
|
1596
|
+
function Headers_append(headers, name, value) {
|
|
1597
|
+
let dict = headers[state$b][_headersDict];
|
|
1598
|
+
let oldValue = dict[name];
|
|
1599
|
+
dict[name] = oldValue !== undefined ? `${oldValue}, ${value}` : value;
|
|
1600
|
+
}
|
|
1644
1601
|
function throwsFn(kind) {
|
|
1645
1602
|
return () => {
|
|
1646
1603
|
throw new TypeError(`Failed to ${kind ? ("execute '" + kind + "' on") : "construct"} 'Headers': Invalid name`);
|
|
@@ -1727,9 +1684,9 @@ class BodyImpl {
|
|
|
1727
1684
|
return consumed(this, kind) || read(this, kind);
|
|
1728
1685
|
}
|
|
1729
1686
|
/** @internal */ toString() { return "[object Body]"; }
|
|
1687
|
+
/** @internal */ get [Symbol.toStringTag]() { return "Body"; }
|
|
1730
1688
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
|
|
1731
1689
|
}
|
|
1732
|
-
Class_setStringTag(BodyImpl, "Body");
|
|
1733
1690
|
/** @internal */
|
|
1734
1691
|
const _body = Symbol();
|
|
1735
1692
|
/** @internal */
|
|
@@ -1820,13 +1777,13 @@ function convert(body, cloneArrayBuffer = true, setContentType, setContentLength
|
|
|
1820
1777
|
setContentType("text/plain;charset=UTF-8");
|
|
1821
1778
|
}
|
|
1822
1779
|
}
|
|
1823
|
-
else if (isObjectType("URLSearchParams", body)) {
|
|
1780
|
+
else if (isObjectType("URLSearchParams", body) || isPolyfillType("URLSearchParams", body)) {
|
|
1824
1781
|
result = body.toString();
|
|
1825
1782
|
if (setContentType) {
|
|
1826
1783
|
setContentType("application/x-www-form-urlencoded;charset=UTF-8");
|
|
1827
1784
|
}
|
|
1828
1785
|
}
|
|
1829
|
-
else if (body
|
|
1786
|
+
else if (isArrayBuffer(body)) {
|
|
1830
1787
|
result = cloneArrayBuffer ? body.slice(0) : body;
|
|
1831
1788
|
}
|
|
1832
1789
|
else if (ArrayBuffer.isView(body)) {
|
|
@@ -1865,7 +1822,7 @@ function convert(body, cloneArrayBuffer = true, setContentType, setContentLength
|
|
|
1865
1822
|
}
|
|
1866
1823
|
/** @internal */
|
|
1867
1824
|
function convertBack(type, data) {
|
|
1868
|
-
let temp = !!data ? (typeof data !== "string" && !(data
|
|
1825
|
+
let temp = !!data ? (typeof data !== "string" && !isArrayBuffer(data) ? JSON.stringify(data) : data) : "";
|
|
1869
1826
|
if (!type || type === "text") {
|
|
1870
1827
|
return typeof temp === "string" ? temp : decode$1(temp);
|
|
1871
1828
|
}
|
|
@@ -1873,7 +1830,7 @@ function convertBack(type, data) {
|
|
|
1873
1830
|
return JSON.parse(typeof temp === "string" ? temp : decode$1(temp));
|
|
1874
1831
|
}
|
|
1875
1832
|
else if (type === "arraybuffer") {
|
|
1876
|
-
return temp
|
|
1833
|
+
return isArrayBuffer(temp) ? temp.slice(0) : encode$1(temp).buffer;
|
|
1877
1834
|
}
|
|
1878
1835
|
else if (type === "blob") {
|
|
1879
1836
|
return new BlobP([temp]);
|
|
@@ -1957,9 +1914,9 @@ class AbortSignalP extends EventTargetP {
|
|
|
1957
1914
|
attachFn(this, "abort", value, this[state$9][_handlers$3].onabort);
|
|
1958
1915
|
}
|
|
1959
1916
|
/** @internal */ toString() { return "[object AbortSignal]"; }
|
|
1917
|
+
/** @internal */ get [Symbol.toStringTag]() { return "AbortSignal"; }
|
|
1960
1918
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
|
|
1961
1919
|
}
|
|
1962
|
-
Class_setStringTag(AbortSignalP, "AbortSignal");
|
|
1963
1920
|
/** @internal */
|
|
1964
1921
|
const _handlers$3 = Symbol();
|
|
1965
1922
|
/** @internal */
|
|
@@ -2010,9 +1967,9 @@ class AbortControllerP {
|
|
|
2010
1967
|
AbortSignal_abort(this[state$8].signal, reason);
|
|
2011
1968
|
}
|
|
2012
1969
|
/** @internal */ toString() { return "[object AbortController]"; }
|
|
1970
|
+
/** @internal */ get [Symbol.toStringTag]() { return "AbortController"; }
|
|
2013
1971
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
|
|
2014
1972
|
}
|
|
2015
|
-
Class_setStringTag(AbortControllerP, "AbortController");
|
|
2016
1973
|
/** @internal */
|
|
2017
1974
|
class AbortControllerState {
|
|
2018
1975
|
constructor() {
|
|
@@ -2131,9 +2088,9 @@ class RequestP extends BodyImpl {
|
|
|
2131
2088
|
return new RequestP(this, { body: (_a = Body_toPayload(this)) !== null && _a !== void 0 ? _a : null });
|
|
2132
2089
|
}
|
|
2133
2090
|
/** @internal */ toString() { return "[object Request]"; }
|
|
2091
|
+
/** @internal */ get [Symbol.toStringTag]() { return "Request"; }
|
|
2134
2092
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
|
|
2135
2093
|
}
|
|
2136
|
-
Class_setStringTag(RequestP, "Request");
|
|
2137
2094
|
/** @internal */
|
|
2138
2095
|
class RequestState {
|
|
2139
2096
|
constructor() {
|
|
@@ -2160,8 +2117,7 @@ function normalizeMethod(method) {
|
|
|
2160
2117
|
const RequestE = g["Request"] || RequestP;
|
|
2161
2118
|
|
|
2162
2119
|
// @ts-nocheck
|
|
2163
|
-
|
|
2164
|
-
const mp$3 = (() => {
|
|
2120
|
+
function getPlatform() {
|
|
2165
2121
|
let u = "undefined", r = "request", f = "function";
|
|
2166
2122
|
let mp;
|
|
2167
2123
|
mp =
|
|
@@ -2184,7 +2140,9 @@ const mp$3 = (() => {
|
|
|
2184
2140
|
(typeof Taro !== u && typeof (Taro === null || Taro === void 0 ? void 0 : Taro[r]) === f && Taro) || // Taro
|
|
2185
2141
|
undefined;
|
|
2186
2142
|
return mp;
|
|
2187
|
-
}
|
|
2143
|
+
}
|
|
2144
|
+
/** @internal */
|
|
2145
|
+
const mp$3 = getPlatform();
|
|
2188
2146
|
|
|
2189
2147
|
const request = mp$3 ? mp$3.request : function errorRequest(options) {
|
|
2190
2148
|
const errMsg = "NOT_SUPPORTED_ERR";
|
|
@@ -2239,9 +2197,9 @@ class XMLHttpRequestEventTargetP extends EventTargetP {
|
|
|
2239
2197
|
get ontimeout() { return this[state$6].ontimeout; }
|
|
2240
2198
|
set ontimeout(value) { this[state$6].ontimeout = value; attach$1(this, "timeout"); }
|
|
2241
2199
|
/** @internal */ toString() { return "[object XMLHttpRequestEventTarget]"; }
|
|
2200
|
+
/** @internal */ get [Symbol.toStringTag]() { return "XMLHttpRequestEventTarget"; }
|
|
2242
2201
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2243
2202
|
}
|
|
2244
|
-
Class_setStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
|
|
2245
2203
|
/** @internal */
|
|
2246
2204
|
const _handlers$2 = Symbol();
|
|
2247
2205
|
/** @internal */
|
|
@@ -2280,14 +2238,6 @@ function getHandlers$2(s) {
|
|
|
2280
2238
|
ontimeout: (ev) => { executeFn(s.target, s.ontimeout, ev); },
|
|
2281
2239
|
};
|
|
2282
2240
|
}
|
|
2283
|
-
/** @internal */
|
|
2284
|
-
const XHR_properties = {
|
|
2285
|
-
UNSENT: { value: 0, enumerable: true },
|
|
2286
|
-
OPENED: { value: 1, enumerable: true },
|
|
2287
|
-
HEADERS_RECEIVED: { value: 2, enumerable: true },
|
|
2288
|
-
LOADING: { value: 3, enumerable: true },
|
|
2289
|
-
DONE: { value: 4, enumerable: true },
|
|
2290
|
-
};
|
|
2291
2241
|
const responseTypes = ["", "text", "json", "arraybuffer", "blob", "document"];
|
|
2292
2242
|
/** @internal */
|
|
2293
2243
|
function normalizeResponseType(responseType) {
|
|
@@ -2370,9 +2320,9 @@ class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
|
|
|
2370
2320
|
super();
|
|
2371
2321
|
}
|
|
2372
2322
|
/** @internal */ toString() { return "[object XMLHttpRequestUpload]"; }
|
|
2323
|
+
/** @internal */ get [Symbol.toStringTag]() { return "XMLHttpRequestUpload"; }
|
|
2373
2324
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2374
2325
|
}
|
|
2375
|
-
Class_setStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
|
|
2376
2326
|
/** @internal */
|
|
2377
2327
|
function createXMLHttpRequestUpload() {
|
|
2378
2328
|
let upload = Object.create(XMLHttpRequestUploadP.prototype);
|
|
@@ -2384,13 +2334,22 @@ function createXMLHttpRequestUpload() {
|
|
|
2384
2334
|
var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2385
2335
|
const mp$2 = { request: request };
|
|
2386
2336
|
const setRequest = (request) => { mp$2.request = request; };
|
|
2387
|
-
/** @internal */
|
|
2388
|
-
const state$5 = Symbol( /* "XMLHttpRequestState" */);
|
|
2337
|
+
/** @internal */ const state$5 = Symbol( /* "XMLHttpRequestState" */);
|
|
2389
2338
|
class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
|
|
2339
|
+
static get UNSENT() { return 0; }
|
|
2340
|
+
static get OPENED() { return 1; }
|
|
2341
|
+
static get HEADERS_RECEIVED() { return 2; }
|
|
2342
|
+
static get LOADING() { return 3; }
|
|
2343
|
+
static get DONE() { return 4; }
|
|
2390
2344
|
constructor() {
|
|
2391
2345
|
super();
|
|
2392
2346
|
this[state$5] = new XMLHttpRequestState(this);
|
|
2393
2347
|
}
|
|
2348
|
+
get UNSENT() { return 0; }
|
|
2349
|
+
get OPENED() { return 1; }
|
|
2350
|
+
get HEADERS_RECEIVED() { return 2; }
|
|
2351
|
+
get LOADING() { return 3; }
|
|
2352
|
+
get DONE() { return 4; }
|
|
2394
2353
|
get readyState() { return this[state$5].readyState; }
|
|
2395
2354
|
get response() { return this[state$5].response; }
|
|
2396
2355
|
get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
|
|
@@ -2400,7 +2359,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
|
|
|
2400
2359
|
get responseXML() { return null; }
|
|
2401
2360
|
get status() { return this[state$5].status; }
|
|
2402
2361
|
get statusText() {
|
|
2403
|
-
if (this.readyState ===
|
|
2362
|
+
if (this.readyState === 0 /* UNSENT */ || this.readyState === 1 /* OPENED */)
|
|
2404
2363
|
return "";
|
|
2405
2364
|
return this[state$5].statusText || statusTextMap(this.status);
|
|
2406
2365
|
}
|
|
@@ -2452,7 +2411,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
|
|
|
2452
2411
|
}
|
|
2453
2412
|
}
|
|
2454
2413
|
s[_inAfterOpenBeforeSend] = true;
|
|
2455
|
-
setReadyStateAndNotify(this,
|
|
2414
|
+
setReadyStateAndNotify(this, 1 /* OPENED */);
|
|
2456
2415
|
}
|
|
2457
2416
|
overrideMimeType(...args) {
|
|
2458
2417
|
const [mime] = args;
|
|
@@ -2463,7 +2422,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
|
|
|
2463
2422
|
}
|
|
2464
2423
|
send(body) {
|
|
2465
2424
|
const s = this[state$5];
|
|
2466
|
-
if (!s[_inAfterOpenBeforeSend] || s.readyState !==
|
|
2425
|
+
if (!s[_inAfterOpenBeforeSend] || s.readyState !== 1 /* OPENED */) {
|
|
2467
2426
|
throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
2468
2427
|
}
|
|
2469
2428
|
s[_inAfterOpenBeforeSend] = false;
|
|
@@ -2502,7 +2461,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
|
|
|
2502
2461
|
}
|
|
2503
2462
|
setTimeout(() => {
|
|
2504
2463
|
if (s.upload) {
|
|
2505
|
-
const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !==
|
|
2464
|
+
const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !== 1 /* OPENED */;
|
|
2506
2465
|
const _contentLength = _aborted ? 0 : contentLength;
|
|
2507
2466
|
if (_aborted) {
|
|
2508
2467
|
emitProcessEvent(this.upload, "abort");
|
|
@@ -2523,13 +2482,17 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
|
|
|
2523
2482
|
const [name, value] = args;
|
|
2524
2483
|
checkArgsLength(args, 2, "XMLHttpRequest", "setRequestHeader");
|
|
2525
2484
|
const s = this[state$5];
|
|
2526
|
-
if (!s[_inAfterOpenBeforeSend] || s.readyState !==
|
|
2485
|
+
if (!s[_inAfterOpenBeforeSend] || s.readyState !== 1 /* OPENED */) {
|
|
2527
2486
|
throw new MPException("Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
2528
2487
|
}
|
|
2529
|
-
let _name =
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2488
|
+
let _name = "" + name;
|
|
2489
|
+
let _value = "" + value;
|
|
2490
|
+
try {
|
|
2491
|
+
s[_requestHeaders].append(_name, _value);
|
|
2492
|
+
}
|
|
2493
|
+
catch (e) {
|
|
2494
|
+
throw new SyntaxError(`Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '${_name}' is not a valid HTTP header field name.`);
|
|
2495
|
+
}
|
|
2533
2496
|
}
|
|
2534
2497
|
get onreadystatechange() { return this[state$5].onreadystatechange; }
|
|
2535
2498
|
set onreadystatechange(value) {
|
|
@@ -2537,11 +2500,9 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
|
|
|
2537
2500
|
attachFn(this, "readystatechange", value, this[state$5][_handlers$1].onreadystatechange);
|
|
2538
2501
|
}
|
|
2539
2502
|
/** @internal */ toString() { return "[object XMLHttpRequest]"; }
|
|
2503
|
+
/** @internal */ get [Symbol.toStringTag]() { return "XMLHttpRequest"; }
|
|
2540
2504
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2541
2505
|
}
|
|
2542
|
-
Object.defineProperties(XMLHttpRequestImpl, XHR_properties);
|
|
2543
|
-
Object.defineProperties(XMLHttpRequestImpl.prototype, XHR_properties);
|
|
2544
|
-
Class_setStringTag(XMLHttpRequestImpl, "XMLHttpRequest");
|
|
2545
2506
|
/** @internal */ const _handlers$1 = Symbol();
|
|
2546
2507
|
/** @internal */ const _inAfterOpenBeforeSend = Symbol();
|
|
2547
2508
|
/** @internal */ const _resetPending = Symbol();
|
|
@@ -2555,7 +2516,7 @@ Class_setStringTag(XMLHttpRequestImpl, "XMLHttpRequest");
|
|
|
2555
2516
|
/** @internal */
|
|
2556
2517
|
class XMLHttpRequestState {
|
|
2557
2518
|
constructor(target) {
|
|
2558
|
-
this.readyState =
|
|
2519
|
+
this.readyState = 0 /* UNSENT */;
|
|
2559
2520
|
this.response = "";
|
|
2560
2521
|
this.responseType = "";
|
|
2561
2522
|
this.responseURL = "";
|
|
@@ -2590,12 +2551,12 @@ function requestSuccess(res) {
|
|
|
2590
2551
|
const s = this[state$5];
|
|
2591
2552
|
s.responseURL = s[_requestURL];
|
|
2592
2553
|
s.status = "statusCode" in res ? res.statusCode : "status" in res ? res.status : 200;
|
|
2593
|
-
s[_responseHeaders] = new HeadersP(("header" in res ? res.header : "headers" in res ? res.headers :
|
|
2554
|
+
s[_responseHeaders] = new HeadersP(("header" in res ? res.header : "headers" in res ? res.headers : {}));
|
|
2594
2555
|
let lengthStr = s[_responseHeaders].get("Content-Length");
|
|
2595
2556
|
s[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
|
|
2596
|
-
if (s.readyState ===
|
|
2597
|
-
setReadyStateAndNotify(this,
|
|
2598
|
-
setReadyStateAndNotify(this,
|
|
2557
|
+
if (s.readyState === 1 /* OPENED */) {
|
|
2558
|
+
setReadyStateAndNotify(this, 2 /* HEADERS_RECEIVED */);
|
|
2559
|
+
setReadyStateAndNotify(this, 3 /* LOADING */);
|
|
2599
2560
|
setTimeout(() => {
|
|
2600
2561
|
if (!s[_inAfterOpenBeforeSend]) {
|
|
2601
2562
|
let l = s[_responseContentLength];
|
|
@@ -2624,14 +2585,14 @@ function requestFail(err) {
|
|
|
2624
2585
|
requestSuccess.call(this, {
|
|
2625
2586
|
statusCode: "statusCode" in err ? err.statusCode : err.status || 0,
|
|
2626
2587
|
header: "header" in err ? err.header : err.headers || {},
|
|
2627
|
-
data: "data" in err ? err.data : "",
|
|
2588
|
+
data: "data" in err ? err.data || "" : "",
|
|
2628
2589
|
});
|
|
2629
2590
|
return;
|
|
2630
2591
|
}
|
|
2631
2592
|
const s = this[state$5];
|
|
2632
2593
|
s.status = 0;
|
|
2633
2594
|
s.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
|
|
2634
|
-
if (!s[_inAfterOpenBeforeSend] && s.readyState !==
|
|
2595
|
+
if (!s[_inAfterOpenBeforeSend] && s.readyState !== 0 /* UNSENT */ && s.readyState !== 4 /* DONE */) {
|
|
2635
2596
|
emitProcessEvent(this, "error");
|
|
2636
2597
|
resetRequestTimeout(this);
|
|
2637
2598
|
}
|
|
@@ -2639,8 +2600,8 @@ function requestFail(err) {
|
|
|
2639
2600
|
function requestComplete() {
|
|
2640
2601
|
const s = this[state$5];
|
|
2641
2602
|
s[_requestTask] = null;
|
|
2642
|
-
if (!s[_inAfterOpenBeforeSend] && (s.readyState ===
|
|
2643
|
-
setReadyStateAndNotify(this,
|
|
2603
|
+
if (!s[_inAfterOpenBeforeSend] && (s.readyState === 1 /* OPENED */ || s.readyState === 3 /* LOADING */)) {
|
|
2604
|
+
setReadyStateAndNotify(this, 4 /* DONE */);
|
|
2644
2605
|
}
|
|
2645
2606
|
setTimeout(() => {
|
|
2646
2607
|
if (!s[_inAfterOpenBeforeSend]) {
|
|
@@ -2659,9 +2620,9 @@ function clearRequest(xhr, delay = true) {
|
|
|
2659
2620
|
const s = xhr[state$5];
|
|
2660
2621
|
const timerFn = delay ? setTimeout : (f) => { f(); };
|
|
2661
2622
|
s[_resetPending] = true;
|
|
2662
|
-
if (s[_requestTask] && s.readyState !==
|
|
2623
|
+
if (s[_requestTask] && s.readyState !== 4 /* DONE */) {
|
|
2663
2624
|
if (delay) {
|
|
2664
|
-
setReadyStateAndNotify(xhr,
|
|
2625
|
+
setReadyStateAndNotify(xhr, 4 /* DONE */);
|
|
2665
2626
|
}
|
|
2666
2627
|
timerFn(() => {
|
|
2667
2628
|
const requestTask = s[_requestTask];
|
|
@@ -2679,7 +2640,7 @@ function clearRequest(xhr, delay = true) {
|
|
|
2679
2640
|
timerFn(() => {
|
|
2680
2641
|
if (s[_resetPending]) {
|
|
2681
2642
|
if (delay) {
|
|
2682
|
-
s.readyState =
|
|
2643
|
+
s.readyState = 0 /* UNSENT */;
|
|
2683
2644
|
}
|
|
2684
2645
|
resetXHR(xhr);
|
|
2685
2646
|
}
|
|
@@ -2689,10 +2650,10 @@ function checkRequestTimeout(xhr) {
|
|
|
2689
2650
|
const s = xhr[state$5];
|
|
2690
2651
|
if (s.timeout) {
|
|
2691
2652
|
s[_timeoutId] = setTimeout(() => {
|
|
2692
|
-
if (!s.status && s.readyState !==
|
|
2653
|
+
if (!s.status && s.readyState !== 4 /* DONE */) {
|
|
2693
2654
|
if (s[_requestTask])
|
|
2694
2655
|
safeAbort(s[_requestTask]);
|
|
2695
|
-
setReadyStateAndNotify(xhr,
|
|
2656
|
+
setReadyStateAndNotify(xhr, 4 /* DONE */);
|
|
2696
2657
|
emitProcessEvent(xhr, "timeout");
|
|
2697
2658
|
}
|
|
2698
2659
|
}, s.timeout);
|
|
@@ -2801,9 +2762,9 @@ class ResponseP extends BodyImpl {
|
|
|
2801
2762
|
return new ResponseP(null, { status, headers: { location: "" + url } });
|
|
2802
2763
|
}
|
|
2803
2764
|
/** @internal */ toString() { return "[object Response]"; }
|
|
2765
|
+
/** @internal */ get [Symbol.toStringTag]() { return "Response"; }
|
|
2804
2766
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
|
|
2805
2767
|
}
|
|
2806
|
-
Class_setStringTag(ResponseP, "Response");
|
|
2807
2768
|
/** @internal */
|
|
2808
2769
|
class ResponseState {
|
|
2809
2770
|
constructor() {
|
|
@@ -2874,7 +2835,7 @@ function fetchP(...args) {
|
|
|
2874
2835
|
if ("responseType" in xhr) {
|
|
2875
2836
|
xhr.responseType = "arraybuffer";
|
|
2876
2837
|
}
|
|
2877
|
-
if (init && typeof init === "object" && typeof init.headers === "object" && !isObjectType("Headers", init.headers)) {
|
|
2838
|
+
if (init && typeof init === "object" && typeof init.headers === "object" && !(isObjectType("Headers", init.headers) || isPolyfillType("Headers", init.headers))) {
|
|
2878
2839
|
let headers = init.headers;
|
|
2879
2840
|
let names = [];
|
|
2880
2841
|
Object.getOwnPropertyNames(headers).forEach(name => {
|
|
@@ -2896,8 +2857,8 @@ function fetchP(...args) {
|
|
|
2896
2857
|
const abortXHR = () => { xhr.abort(); };
|
|
2897
2858
|
signal.addEventListener("abort", abortXHR);
|
|
2898
2859
|
xhr.onreadystatechange = function () {
|
|
2899
|
-
//
|
|
2900
|
-
if (xhr.readyState === 4) {
|
|
2860
|
+
// success or failure
|
|
2861
|
+
if (xhr.readyState === 4 /* DONE */) {
|
|
2901
2862
|
signal.removeEventListener("abort", abortXHR);
|
|
2902
2863
|
}
|
|
2903
2864
|
};
|
|
@@ -2928,9 +2889,9 @@ class CustomEventP extends EventP {
|
|
|
2928
2889
|
this[state$3].detail = detail !== null && detail !== void 0 ? detail : null;
|
|
2929
2890
|
}
|
|
2930
2891
|
/** @internal */ toString() { return "[object CustomEvent]"; }
|
|
2892
|
+
/** @internal */ get [Symbol.toStringTag]() { return "CustomEvent"; }
|
|
2931
2893
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
|
|
2932
2894
|
}
|
|
2933
|
-
Class_setStringTag(CustomEventP, "CustomEvent");
|
|
2934
2895
|
/** @internal */
|
|
2935
2896
|
class CustomEventState {
|
|
2936
2897
|
}
|
|
@@ -2954,9 +2915,9 @@ class CloseEventP extends EventP {
|
|
|
2954
2915
|
get reason() { return this[state$2].reason; }
|
|
2955
2916
|
get wasClean() { return this[state$2].wasClean; }
|
|
2956
2917
|
/** @internal */ toString() { return "[object CloseEvent]"; }
|
|
2918
|
+
/** @internal */ get [Symbol.toStringTag]() { return "CloseEvent"; }
|
|
2957
2919
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CloseEvent", "Event"] }; }
|
|
2958
2920
|
}
|
|
2959
|
-
Class_setStringTag(CloseEventP, "CloseEvent");
|
|
2960
2921
|
/** @internal */
|
|
2961
2922
|
class CloseEventState {
|
|
2962
2923
|
constructor() {
|
|
@@ -3009,9 +2970,9 @@ class MessageEventP extends EventP {
|
|
|
3009
2970
|
s.ports = ports;
|
|
3010
2971
|
}
|
|
3011
2972
|
/** @internal */ toString() { return "[object MessageEvent]"; }
|
|
2973
|
+
/** @internal */ get [Symbol.toStringTag]() { return "MessageEvent"; }
|
|
3012
2974
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["MessageEvent", "Event"] }; }
|
|
3013
2975
|
}
|
|
3014
|
-
Class_setStringTag(MessageEventP, "MessageEvent");
|
|
3015
2976
|
/** @internal */
|
|
3016
2977
|
class MessageEventState {
|
|
3017
2978
|
constructor() {
|
|
@@ -3049,6 +3010,10 @@ const setConnectSocket = (connectSocket) => { mp.connectSocket = connectSocket;
|
|
|
3049
3010
|
/** @internal */
|
|
3050
3011
|
const state = Symbol( /* "WebSocketState" */);
|
|
3051
3012
|
class WebSocketImpl extends EventTargetP {
|
|
3013
|
+
static get CONNECTING() { return 0; }
|
|
3014
|
+
static get OPEN() { return 1; }
|
|
3015
|
+
static get CLOSING() { return 2; }
|
|
3016
|
+
static get CLOSED() { return 3; }
|
|
3052
3017
|
constructor(...args) {
|
|
3053
3018
|
const [url, protocols] = args;
|
|
3054
3019
|
checkArgsLength(args, 1, "WebSocket");
|
|
@@ -3074,6 +3039,10 @@ class WebSocketImpl extends EventTargetP {
|
|
|
3074
3039
|
throw new Error(`connectSocket can't establish a connection to the server at ${"" + url}.`);
|
|
3075
3040
|
}
|
|
3076
3041
|
}
|
|
3042
|
+
get CONNECTING() { return 0; }
|
|
3043
|
+
get OPEN() { return 1; }
|
|
3044
|
+
get CLOSING() { return 2; }
|
|
3045
|
+
get CLOSED() { return 3; }
|
|
3077
3046
|
get binaryType() { return this[state].binaryType; }
|
|
3078
3047
|
set binaryType(value) { if (value === "blob" || value === "arraybuffer") {
|
|
3079
3048
|
this[state].binaryType = value;
|
|
@@ -3084,29 +3053,29 @@ class WebSocketImpl extends EventTargetP {
|
|
|
3084
3053
|
get readyState() { return this[state].readyState; }
|
|
3085
3054
|
get url() { return this[state].url; }
|
|
3086
3055
|
close(code, reason) {
|
|
3087
|
-
if (this.readyState ===
|
|
3056
|
+
if (this.readyState === 2 /* CLOSING */ || this.readyState === 3 /* CLOSED */)
|
|
3088
3057
|
return;
|
|
3089
|
-
this[state].readyState =
|
|
3058
|
+
this[state].readyState = 2 /* CLOSING */;
|
|
3090
3059
|
this[state][_socketTask].close({
|
|
3091
3060
|
code: code,
|
|
3092
3061
|
reason: reason,
|
|
3093
3062
|
fail(err) { console.error(err); },
|
|
3094
3063
|
complete: (function () {
|
|
3095
|
-
this[state].readyState =
|
|
3064
|
+
this[state].readyState = 3 /* CLOSED */;
|
|
3096
3065
|
}).bind(this),
|
|
3097
3066
|
});
|
|
3098
3067
|
}
|
|
3099
3068
|
send(...args) {
|
|
3100
3069
|
const [data] = args;
|
|
3101
3070
|
checkArgsLength(args, 1, "WebSocket", "send");
|
|
3102
|
-
if (this.readyState ===
|
|
3071
|
+
if (this.readyState === 0 /* CONNECTING */) {
|
|
3103
3072
|
throw new MPException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.", "InvalidStateError");
|
|
3104
3073
|
}
|
|
3105
|
-
if (this.readyState ===
|
|
3074
|
+
if (this.readyState === 2 /* CLOSING */ || this.readyState === 3 /* CLOSED */) {
|
|
3106
3075
|
return console.error("WebSocket is already in CLOSING or CLOSED state.");
|
|
3107
3076
|
}
|
|
3108
3077
|
let _data;
|
|
3109
|
-
if (data
|
|
3078
|
+
if (isArrayBuffer(data)) {
|
|
3110
3079
|
_data = data;
|
|
3111
3080
|
}
|
|
3112
3081
|
else if (ArrayBuffer.isView(data)) {
|
|
@@ -3132,17 +3101,9 @@ class WebSocketImpl extends EventTargetP {
|
|
|
3132
3101
|
get onopen() { return this[state].onopen; }
|
|
3133
3102
|
set onopen(value) { this[state].onopen = value; attach(this, "open"); }
|
|
3134
3103
|
/** @internal */ toString() { return "[object WebSocket]"; }
|
|
3104
|
+
/** @internal */ get [Symbol.toStringTag]() { return "WebSocket"; }
|
|
3135
3105
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["WebSocket", "EventTarget"] }; }
|
|
3136
3106
|
}
|
|
3137
|
-
const properties = {
|
|
3138
|
-
CONNECTING: { value: 0, enumerable: true },
|
|
3139
|
-
OPEN: { value: 1, enumerable: true },
|
|
3140
|
-
CLOSING: { value: 2, enumerable: true },
|
|
3141
|
-
CLOSED: { value: 3, enumerable: true },
|
|
3142
|
-
};
|
|
3143
|
-
Object.defineProperties(WebSocketImpl, properties);
|
|
3144
|
-
Object.defineProperties(WebSocketImpl.prototype, properties);
|
|
3145
|
-
Class_setStringTag(WebSocketImpl, "WebSocket");
|
|
3146
3107
|
/** @internal */ const _socketTask = Symbol();
|
|
3147
3108
|
/** @internal */ const _error = Symbol();
|
|
3148
3109
|
/** @internal */ const _handlers = Symbol();
|
|
@@ -3182,41 +3143,41 @@ function getHandlers(s) {
|
|
|
3182
3143
|
};
|
|
3183
3144
|
}
|
|
3184
3145
|
function onOpen(ws) {
|
|
3185
|
-
let
|
|
3186
|
-
|
|
3146
|
+
let socket = ws;
|
|
3147
|
+
socket[state][_socketTask].onOpen(res => {
|
|
3187
3148
|
if ("header" in res && res.header && typeof res.header === "object") {
|
|
3188
3149
|
let headers = new HeadersP(res.header);
|
|
3189
|
-
|
|
3150
|
+
socket[state].protocol = headers.get("Sec-WebSocket-Protocol") || "";
|
|
3190
3151
|
}
|
|
3191
|
-
|
|
3192
|
-
EventTarget_fire(
|
|
3152
|
+
socket[state].readyState = 1 /* OPEN */;
|
|
3153
|
+
EventTarget_fire(socket, createInnerEvent(socket, "open"));
|
|
3193
3154
|
});
|
|
3194
3155
|
}
|
|
3195
3156
|
function onClose(ws) {
|
|
3196
|
-
let
|
|
3197
|
-
|
|
3198
|
-
|
|
3157
|
+
let socket = ws;
|
|
3158
|
+
socket[state][_socketTask].onClose(res => {
|
|
3159
|
+
socket[state].readyState = 3 /* CLOSED */;
|
|
3199
3160
|
let event = new CloseEventP("close", {
|
|
3200
|
-
wasClean: !
|
|
3161
|
+
wasClean: !socket[state][_error],
|
|
3201
3162
|
code: res.code,
|
|
3202
3163
|
reason: res.reason,
|
|
3203
3164
|
});
|
|
3204
3165
|
Event_setTrusted(event, true);
|
|
3205
|
-
EventTarget_fire(
|
|
3166
|
+
EventTarget_fire(socket, event);
|
|
3206
3167
|
});
|
|
3207
3168
|
}
|
|
3208
3169
|
function onError(ws) {
|
|
3209
|
-
let
|
|
3210
|
-
|
|
3170
|
+
let socket = ws;
|
|
3171
|
+
socket[state][_socketTask].onError(res => {
|
|
3211
3172
|
console.error(res);
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
EventTarget_fire(
|
|
3173
|
+
socket[state][_error] = res;
|
|
3174
|
+
socket[state].readyState = 3 /* CLOSED */;
|
|
3175
|
+
EventTarget_fire(socket, createInnerEvent(socket, "error"));
|
|
3215
3176
|
});
|
|
3216
3177
|
}
|
|
3217
3178
|
function onMessage(ws) {
|
|
3218
|
-
let
|
|
3219
|
-
|
|
3179
|
+
let socket = ws;
|
|
3180
|
+
socket[state][_socketTask].onMessage(res => {
|
|
3220
3181
|
let data = res.data;
|
|
3221
3182
|
let _data;
|
|
3222
3183
|
// Alipay Mini Program
|
|
@@ -3233,15 +3194,15 @@ function onMessage(ws) {
|
|
|
3233
3194
|
else {
|
|
3234
3195
|
_data = data;
|
|
3235
3196
|
}
|
|
3236
|
-
if (_data
|
|
3197
|
+
if (isArrayBuffer(_data) && socket.binaryType === "blob") {
|
|
3237
3198
|
_data = new BlobP([_data]);
|
|
3238
3199
|
}
|
|
3239
3200
|
let event = new MessageEventP("message", {
|
|
3240
3201
|
data: _data,
|
|
3241
|
-
origin:
|
|
3202
|
+
origin: socket.url,
|
|
3242
3203
|
});
|
|
3243
3204
|
Event_setTrusted(event, true);
|
|
3244
|
-
EventTarget_fire(
|
|
3205
|
+
EventTarget_fire(socket, event);
|
|
3245
3206
|
});
|
|
3246
3207
|
}
|
|
3247
3208
|
|