mphttpx 1.0.12 → 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/dist/index.cjs.js CHANGED
@@ -9,13 +9,6 @@
9
9
  /** @internal */
10
10
  const polyfill = "MPHTTPX";
11
11
  /** @internal */
12
- function Class_setStringTag(targetFunc, stringTag) {
13
- Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
14
- configurable: true,
15
- value: stringTag,
16
- });
17
- }
18
- /** @internal */
19
12
  function checkArgsLength(args, required, className, funcName) {
20
13
  if (args.length < required) {
21
14
  throw new TypeError(`Failed to ${funcName ? ("execute '" + funcName + "' on") : "construct"} '${className}': ${required} argument${required > 1 ? "s" : ""} required, but only ${args.length} present.`);
@@ -36,7 +29,7 @@ function isObjectType(name, value) {
36
29
  return Object.prototype.toString.call(value) === `[object ${name}]`;
37
30
  }
38
31
  /** @internal */
39
- function isPolyfillType(name, value) {
32
+ function isPolyfillType(name, value, strict = false) {
40
33
  return !!value
41
34
  && typeof value === "object"
42
35
  && "isPolyfill" in value
@@ -46,7 +39,12 @@ function isPolyfillType(name, value) {
46
39
  && value.isPolyfill.symbol === polyfill
47
40
  && "hierarchy" in value.isPolyfill
48
41
  && Array.isArray(value.isPolyfill.hierarchy)
49
- && value.isPolyfill.hierarchy.indexOf(name) > -1;
42
+ && ((index) => strict ? index === 0 : index > -1)(value.isPolyfill.hierarchy.indexOf(name));
43
+ }
44
+ /** @internal */
45
+ function isArrayBuffer(value) {
46
+ // Mini Program
47
+ return isObjectType("ArrayBuffer", value) || (!!value && typeof value === "object" && ArrayBuffer.prototype.isPrototypeOf(value));
50
48
  }
51
49
 
52
50
  class TextEncoderP {
@@ -59,16 +57,16 @@ class TextEncoderP {
59
57
  const [source, destination] = args;
60
58
  checkArgsLength(args, 2, "TextEncoder", "encodeInto");
61
59
  let _source = "" + source;
62
- if (!(destination instanceof Uint8Array)) {
60
+ if (!(destination instanceof Uint8Array || isObjectType("Uint8Array", destination))) {
63
61
  throw new TypeError("Failed to execute 'encodeInto' on 'TextEncoder': parameter 2 is not of type 'Uint8Array'.");
64
62
  }
65
63
  let result = encodeText(_source, destination);
66
64
  return { read: result.read, written: result.written };
67
65
  }
68
66
  /** @internal */ toString() { return "[object TextEncoder]"; }
67
+ /** @internal */ get [Symbol.toStringTag]() { return "TextEncoder"; }
69
68
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
70
69
  }
71
- Class_setStringTag(TextEncoderP, "TextEncoder");
72
70
  function encodeText(input, destination) {
73
71
  const HAS_DESTINATION = typeof destination !== "undefined";
74
72
  let pos = 0;
@@ -165,30 +163,30 @@ function encodeText(input, destination) {
165
163
  }
166
164
  const TextEncoderE = g["TextEncoder"] || TextEncoderP;
167
165
 
168
- var _a$a, _b$3;
166
+ var _a$b, _b$4;
169
167
  /** @internal */
170
- const state$h = Symbol( /* "TextDecoderState" */);
168
+ const state$k = Symbol( /* "TextDecoderState" */);
171
169
  class TextDecoderP {
172
170
  constructor(label = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
173
171
  let _label = "" + label;
174
172
  if (["utf-8", "utf8", "unicode-1-1-utf-8"].indexOf(_label.toLowerCase()) === -1) {
175
173
  throw new RangeError(`Failed to construct 'TextDecoder': encoding ('${_label}') not implemented.`);
176
174
  }
177
- this[state$h] = new TextDecoderState();
178
- this[state$h].fatal = !!fatal;
179
- this[state$h].ignoreBOM = !!ignoreBOM;
175
+ this[state$k] = new TextDecoderState();
176
+ this[state$k].fatal = !!fatal;
177
+ this[state$k].ignoreBOM = !!ignoreBOM;
180
178
  }
181
179
  get encoding() { return "utf-8"; }
182
- get fatal() { return this[state$h].fatal; }
183
- get ignoreBOM() { return this[state$h].ignoreBOM; }
180
+ get fatal() { return this[state$k].fatal; }
181
+ get ignoreBOM() { return this[state$k].ignoreBOM; }
184
182
  decode(input, { stream = false } = {}) {
185
- const s = this[state$h];
183
+ const s = this[state$k];
186
184
  let bytes;
187
185
  if (input !== undefined) {
188
- if (input instanceof ArrayBuffer) {
186
+ if (isArrayBuffer(input)) {
189
187
  bytes = new Uint8Array(input);
190
188
  }
191
- else if (input instanceof Uint8Array) {
189
+ else if (input instanceof Uint8Array || isObjectType("Uint8Array", input)) {
192
190
  bytes = input;
193
191
  }
194
192
  else if (ArrayBuffer.isView(input)) {
@@ -311,9 +309,9 @@ class TextDecoderP {
311
309
  return res.length > 0x4000 ? buildString(res) : concatString(res);
312
310
  }
313
311
  /** @internal */ toString() { return "[object TextDecoder]"; }
312
+ /** @internal */ get [Symbol.toStringTag]() { return "TextDecoder"; }
314
313
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
315
314
  }
316
- Class_setStringTag(TextDecoderP, "TextDecoder");
317
315
  /** @internal */ const _bomDone = Symbol();
318
316
  /** @internal */ const _partial = Symbol();
319
317
  /** @internal */
@@ -321,11 +319,11 @@ class TextDecoderState {
321
319
  constructor() {
322
320
  this.fatal = false;
323
321
  this.ignoreBOM = false;
324
- this[_a$a] = 0;
325
- this[_b$3] = [];
322
+ this[_a$b] = 0;
323
+ this[_b$4] = [];
326
324
  }
327
325
  }
328
- _a$a = _bomDone, _b$3 = _partial;
326
+ _a$b = _bomDone, _b$4 = _partial;
329
327
  function getBytesPerSequence(byte) {
330
328
  return (byte > 0xEF) ? 4 : (byte > 0xDF) ? 3 : (byte > 0xBF) ? 2 : 1;
331
329
  }
@@ -346,7 +344,7 @@ const concatString = (res) => {
346
344
  const TextDecoderE = g["TextDecoder"] || TextDecoderP;
347
345
 
348
346
  /** @internal */
349
- const state$g = Symbol( /* "BlobState" */);
347
+ const state$j = Symbol( /* "BlobState" */);
350
348
  class BlobP {
351
349
  constructor(blobParts = [], options) {
352
350
  if (!(Array.isArray(blobParts) || (blobParts && typeof blobParts === "object" && Symbol.iterator in blobParts))) {
@@ -357,43 +355,43 @@ class BlobP {
357
355
  for (let i = 0; i < _blobParts.length; ++i) {
358
356
  let chunk = _blobParts[i];
359
357
  if (isPolyfillType("Blob", chunk)) {
360
- chunks.push(chunk[state$g][_buffer]);
358
+ chunks.push(chunk[state$j][_buffer]);
361
359
  }
362
- else if (chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk)) {
360
+ else if (isArrayBuffer(chunk) || ArrayBuffer.isView(chunk)) {
363
361
  chunks.push(BufferSource_toUint8Array(chunk));
364
362
  }
365
363
  else {
366
364
  chunks.push(encode$1("" + chunk));
367
365
  }
368
366
  }
369
- this[state$g] = new BlobState(concat(chunks));
370
- const s = this[state$g];
367
+ this[state$j] = new BlobState(concat(chunks));
368
+ const s = this[state$j];
371
369
  s.size = s[_buffer].length;
372
370
  let rawType = "" + ((options === null || options === void 0 ? void 0 : options.type) || "");
373
371
  s.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
374
372
  }
375
- get size() { return this[state$g].size; }
376
- get type() { return this[state$g].type; }
373
+ get size() { return this[state$j].size; }
374
+ get type() { return this[state$j].type; }
377
375
  arrayBuffer() {
378
- return Promise.resolve(clone(this[state$g][_buffer].buffer).buffer);
376
+ return Promise.resolve(clone(this[state$j][_buffer].buffer).buffer);
379
377
  }
380
378
  bytes() {
381
- return Promise.resolve(clone(this[state$g][_buffer].buffer));
379
+ return Promise.resolve(clone(this[state$j][_buffer].buffer));
382
380
  }
383
381
  slice(start, end, contentType) {
384
- let sliced = this[state$g][_buffer].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$g][_buffer].length); // × WeChat 2.5.0
382
+ let sliced = this[state$j][_buffer].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$j][_buffer].length); // × WeChat 2.5.0
385
383
  return new BlobP([sliced], { type: "" + (contentType !== null && contentType !== void 0 ? contentType : "") });
386
384
  }
387
385
  stream() {
388
386
  throw new TypeError("Failed to execute 'stream' on 'Blob': method not implemented.");
389
387
  }
390
388
  text() {
391
- return Promise.resolve(decode$1(this[state$g][_buffer]));
389
+ return Promise.resolve(decode$1(this[state$j][_buffer]));
392
390
  }
393
391
  /** @internal */ toString() { return "[object Blob]"; }
392
+ /** @internal */ get [Symbol.toStringTag]() { return "Blob"; }
394
393
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
395
394
  }
396
- Class_setStringTag(BlobP, "Blob");
397
395
  /** @internal */
398
396
  const _buffer = Symbol();
399
397
  /** @internal */
@@ -406,10 +404,10 @@ class BlobState {
406
404
  }
407
405
  /** @internal */
408
406
  function Blob_toUint8Array(blob) {
409
- return blob[state$g][_buffer];
407
+ return blob[state$j][_buffer];
410
408
  }
411
409
  function BufferSource_toUint8Array(buf) {
412
- return buf instanceof ArrayBuffer
410
+ return isArrayBuffer(buf)
413
411
  ? new Uint8Array(buf)
414
412
  : new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
415
413
  }
@@ -465,23 +463,23 @@ function Uint8Array_toBase64(input) {
465
463
  const BlobE = g["Blob"] || BlobP;
466
464
 
467
465
  /** @internal */
468
- const state$f = Symbol( /* "FileState" */);
466
+ const state$i = Symbol( /* "FileState" */);
469
467
  class FileP extends BlobP {
470
468
  constructor(...args) {
471
469
  const [fileBits, fileName, options] = args;
472
470
  checkArgsLength(args, 2, "File");
473
471
  super(fileBits, options);
474
- this[state$f] = new FileState();
475
- this[state$f].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date()) || 0;
476
- this[state$f].name = "" + fileName;
472
+ this[state$i] = new FileState();
473
+ this[state$i].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date()) || 0;
474
+ this[state$i].name = "" + fileName;
477
475
  }
478
- get lastModified() { return this[state$f].lastModified; }
479
- get name() { return this[state$f].name; }
476
+ get lastModified() { return this[state$i].lastModified; }
477
+ get name() { return this[state$i].name; }
480
478
  get webkitRelativePath() { return ""; }
481
479
  /** @internal */ toString() { return "[object File]"; }
480
+ /** @internal */ get [Symbol.toStringTag]() { return "File"; }
482
481
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
483
482
  }
484
- Class_setStringTag(FileP, "File");
485
483
  /** @internal */
486
484
  class FileState {
487
485
  constructor() {
@@ -491,39 +489,47 @@ class FileState {
491
489
  }
492
490
  const FileE = g["Blob"] ? g["File"] : FileP;
493
491
 
494
- var _a$9, _b$2, _c$1, _d$1, _e$1;
495
- /** @internal */ const state$e = Symbol( /* "EventState" */);
492
+ var _a$a, _b$3, _c$1, _d$1, _e$1;
493
+ /** @internal */ const state$h = Symbol( /* "EventState" */);
496
494
  class EventP {
495
+ static get NONE() { return 0; }
496
+ static get CAPTURING_PHASE() { return 1; }
497
+ static get AT_TARGET() { return 2; }
498
+ static get BUBBLING_PHASE() { return 3; }
497
499
  constructor(...args) {
498
500
  const [type, eventInitDict] = args;
499
501
  checkArgsLength(args, 1, new.target.name);
500
- this[state$e] = new EventState();
501
- const s = this[state$e];
502
+ this[state$h] = new EventState();
503
+ const s = this[state$h];
502
504
  s.type = "" + type;
503
505
  s.bubbles = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.bubbles);
504
506
  s.cancelable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.cancelable);
505
507
  s.composed = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.composed);
506
508
  Object.defineProperty(this, "isTrusted", {
507
509
  enumerable: true,
508
- get: (function isTrusted() { return this[state$e][_isTrusted]; }).bind(this),
510
+ get: (function isTrusted() { return this[state$h][_isTrusted]; }).bind(this),
509
511
  });
510
512
  }
511
- get type() { return this[state$e].type; }
512
- get bubbles() { return this[state$e].bubbles; }
513
- get cancelable() { return this[state$e].cancelable; }
514
- get composed() { return this[state$e].composed; }
515
- get target() { return this[state$e].target; }
516
- get currentTarget() { return this[state$e].currentTarget; }
517
- get eventPhase() { return this[state$e].eventPhase; }
518
- get srcElement() { return this[state$e].target; }
519
- get cancelBubble() { return this[state$e].cancelBubble; }
520
- set cancelBubble(value) { this[state$e].cancelBubble = !!value; }
521
- get defaultPrevented() { return this[state$e].defaultPrevented; }
522
- get returnValue() { return this[state$e].returnValue; }
513
+ get type() { return this[state$h].type; }
514
+ get bubbles() { return this[state$h].bubbles; }
515
+ get cancelable() { return this[state$h].cancelable; }
516
+ get composed() { return this[state$h].composed; }
517
+ get target() { return this[state$h].target; }
518
+ get currentTarget() { return this[state$h].currentTarget; }
519
+ get eventPhase() { return this[state$h].eventPhase; }
520
+ get NONE() { return 0; }
521
+ get CAPTURING_PHASE() { return 1; }
522
+ get AT_TARGET() { return 2; }
523
+ get BUBBLING_PHASE() { return 3; }
524
+ get srcElement() { return this[state$h].target; }
525
+ get cancelBubble() { return this[state$h].cancelBubble; }
526
+ set cancelBubble(value) { this[state$h].cancelBubble = !!value; }
527
+ get defaultPrevented() { return this[state$h].defaultPrevented; }
528
+ get returnValue() { return this[state$h].returnValue; }
523
529
  set returnValue(value) { if (!value) {
524
530
  this.preventDefault();
525
531
  } }
526
- get timeStamp() { return this[state$e].timeStamp; }
532
+ get timeStamp() { return this[state$h].timeStamp; }
527
533
  composedPath() {
528
534
  let path = !!this.target ? [this.target] : [];
529
535
  if (!!this.currentTarget && this.currentTarget !== this.target)
@@ -533,7 +539,7 @@ class EventP {
533
539
  initEvent(...args) {
534
540
  const [type, bubbles, cancelable] = args;
535
541
  checkArgsLength(args, 1, "Event", "initEvent");
536
- const s = this[state$e];
542
+ const s = this[state$h];
537
543
  if (s[_dispatched])
538
544
  return;
539
545
  s.type = "" + type;
@@ -541,7 +547,7 @@ class EventP {
541
547
  s.cancelable = !!cancelable;
542
548
  }
543
549
  preventDefault() {
544
- const s = this[state$e];
550
+ const s = this[state$h];
545
551
  if (s[_passive]) {
546
552
  console.warn(`Ignoring 'preventDefault()' call on event of type '${this.type}' from a listener registered as 'passive'.`);
547
553
  return;
@@ -553,24 +559,16 @@ class EventP {
553
559
  }
554
560
  }
555
561
  stopImmediatePropagation() {
556
- this[state$e][_stopImmediatePropagationCalled] = true;
562
+ this[state$h][_stopImmediatePropagationCalled] = true;
557
563
  this.cancelBubble = true;
558
564
  }
559
565
  stopPropagation() {
560
566
  this.cancelBubble = true;
561
567
  }
562
568
  /** @internal */ toString() { return "[object Event]"; }
569
+ /** @internal */ get [Symbol.toStringTag]() { return "Event"; }
563
570
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
564
571
  }
565
- const properties$1 = {
566
- NONE: { value: 0, enumerable: true },
567
- CAPTURING_PHASE: { value: 1, enumerable: true },
568
- AT_TARGET: { value: 2, enumerable: true },
569
- BUBBLING_PHASE: { value: 3, enumerable: true },
570
- };
571
- Object.defineProperties(EventP, properties$1);
572
- Object.defineProperties(EventP.prototype, properties$1);
573
- Class_setStringTag(EventP, "Event");
574
572
  /** @internal */ const _timeStamp = (new Date()).getTime();
575
573
  /** @internal */ const _isTrusted = Symbol();
576
574
  /** @internal */ const _passive = Symbol();
@@ -586,22 +584,22 @@ class EventState {
586
584
  this.composed = false;
587
585
  this.target = null;
588
586
  this.currentTarget = null;
589
- this.eventPhase = EventP.NONE;
587
+ this.eventPhase = 0 /* NONE */;
590
588
  this.cancelBubble = false;
591
589
  this.defaultPrevented = false;
592
590
  this.returnValue = true;
593
591
  this.timeStamp = (new Date()).getTime() - _timeStamp;
594
- this[_a$9] = false;
595
- this[_b$2] = false;
592
+ this[_a$a] = false;
593
+ this[_b$3] = false;
596
594
  this[_c$1] = false;
597
595
  this[_d$1] = false;
598
596
  this[_e$1] = false;
599
597
  }
600
598
  }
601
- _a$9 = _isTrusted, _b$2 = _passive, _c$1 = _dispatched, _d$1 = _preventDefaultCalled, _e$1 = _stopImmediatePropagationCalled;
599
+ _a$a = _isTrusted, _b$3 = _passive, _c$1 = _dispatched, _d$1 = _preventDefaultCalled, _e$1 = _stopImmediatePropagationCalled;
602
600
  /** @internal */
603
601
  function Event_setTrusted(event, isTrusted) {
604
- Object.defineProperty(event[state$e], _isTrusted, {
602
+ Object.defineProperty(event[state$h], _isTrusted, {
605
603
  value: isTrusted,
606
604
  writable: true,
607
605
  enumerable: true,
@@ -609,16 +607,16 @@ function Event_setTrusted(event, isTrusted) {
609
607
  });
610
608
  }
611
609
  const passive$1 = 0;
612
- const dispatched$2 = 1;
610
+ const dispatched$3 = 1;
613
611
  const preventDefaultCalled$1 = 2;
614
612
  const stopImmediatePropagationCalled$1 = 3;
615
613
  /** @internal */
616
614
  function Event_getEtField(event, field) {
617
- const s = event[state$e];
615
+ const s = event[state$h];
618
616
  switch (field) {
619
617
  case passive$1:
620
618
  return s[_passive];
621
- case dispatched$2:
619
+ case dispatched$3:
622
620
  return s[_dispatched];
623
621
  case preventDefaultCalled$1:
624
622
  return s[_preventDefaultCalled];
@@ -628,12 +626,12 @@ function Event_getEtField(event, field) {
628
626
  }
629
627
  /** @internal */
630
628
  function Event_setEtField(event, field, value) {
631
- const s = event[state$e];
629
+ const s = event[state$h];
632
630
  switch (field) {
633
631
  case passive$1:
634
632
  s[_passive] = value;
635
633
  break;
636
- case dispatched$2:
634
+ case dispatched$3:
637
635
  s[_dispatched] = value;
638
636
  break;
639
637
  case preventDefaultCalled$1:
@@ -647,30 +645,30 @@ function Event_setEtField(event, field, value) {
647
645
  /** @internal */
648
646
  function createInnerEvent(target, type, eventInitDict, isTrusted = true) {
649
647
  let event = new EventP(type, eventInitDict);
650
- event[state$e].target = target;
651
- event[state$e][_isTrusted] = isTrusted;
648
+ event[state$h].target = target;
649
+ event[state$h][_isTrusted] = isTrusted;
652
650
  return event;
653
651
  }
654
652
  const EventE = g["EventTarget"] ? g["Event"] : EventP;
655
653
 
656
- var _a$8;
654
+ var _a$9;
657
655
  const passive = 0;
658
- const dispatched$1 = 1;
656
+ const dispatched$2 = 1;
659
657
  const preventDefaultCalled = 2;
660
658
  const stopImmediatePropagationCalled = 3;
661
- /** @internal */ const state$d = Symbol( /* "EventTargetState" */);
659
+ /** @internal */ const state$g = Symbol( /* "EventTargetState" */);
662
660
  class EventTargetP {
663
661
  constructor() {
664
- this[state$d] = new EventTargetState(this);
665
- this[state$d].name = new.target.name;
662
+ this[state$g] = new EventTargetState(this);
663
+ this[state$g].name = new.target.name;
666
664
  }
667
665
  addEventListener(...args) {
668
666
  const [type, callback, options] = args;
669
- checkArgsLength(args, 2, this[state$d].name, "addEventListener");
667
+ checkArgsLength(args, 2, this[state$g].name, "addEventListener");
670
668
  if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
671
- throw new TypeError(`Failed to execute 'addEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
669
+ throw new TypeError(`Failed to execute 'addEventListener' on '${this[state$g].name}': parameter 2 is not of type 'Object'.`);
672
670
  }
673
- const s = this[state$d];
671
+ const s = this[state$g];
674
672
  const executor = new Executor(type, callback);
675
673
  executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
676
674
  if (!s[_executors].some(x => x.equals(executor))) {
@@ -690,21 +688,21 @@ class EventTargetP {
690
688
  }
691
689
  dispatchEvent(...args) {
692
690
  const [event] = args;
693
- checkArgsLength(args, 1, this[state$d].name, "dispatchEvent");
691
+ checkArgsLength(args, 1, this[state$g].name, "dispatchEvent");
694
692
  if (!(event instanceof EventP)) {
695
- throw new TypeError(`Failed to execute 'dispatchEvent' on '${this[state$d].name}': parameter 1 is not of type 'Event'.`);
693
+ throw new TypeError(`Failed to execute 'dispatchEvent' on '${this[state$g].name}': parameter 1 is not of type 'Event'.`);
696
694
  }
697
695
  Event_setTrusted(event, false);
698
- event[state$e].target = this;
696
+ event[state$h].target = this;
699
697
  return EventTarget_fire(this, event);
700
698
  }
701
699
  removeEventListener(...args) {
702
700
  const [type, callback, options] = args;
703
- checkArgsLength(args, 2, this[state$d].name, "removeEventListener");
701
+ checkArgsLength(args, 2, this[state$g].name, "removeEventListener");
704
702
  if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
705
- throw new TypeError(`Failed to execute 'removeEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
703
+ throw new TypeError(`Failed to execute 'removeEventListener' on '${this[state$g].name}': parameter 2 is not of type 'Object'.`);
706
704
  }
707
- const s = this[state$d];
705
+ const s = this[state$g];
708
706
  const executor = new Executor(type, callback);
709
707
  executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
710
708
  if (s[_executors].some(x => x.equals(executor))) {
@@ -712,29 +710,29 @@ class EventTargetP {
712
710
  }
713
711
  }
714
712
  /** @internal */ toString() { return "[object EventTarget]"; }
713
+ /** @internal */ get [Symbol.toStringTag]() { return "EventTarget"; }
715
714
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
716
715
  }
717
- Class_setStringTag(EventTargetP, "EventTarget");
718
716
  /** @internal */
719
717
  const _executors = Symbol();
720
718
  /** @internal */
721
719
  class EventTargetState {
722
720
  constructor(target) {
723
721
  this.name = "EventTarget";
724
- this[_a$8] = [];
722
+ this[_a$9] = [];
725
723
  this.target = target;
726
724
  }
727
725
  }
728
- _a$8 = _executors;
726
+ _a$9 = _executors;
729
727
  /** @internal */
730
728
  function EventTarget_fire(target, event) {
731
- const s = target[state$d];
732
- const evs = event[state$e];
729
+ const s = target[state$g];
730
+ const evs = event[state$h];
733
731
  if (!event.target)
734
732
  evs.target = target;
735
733
  evs.currentTarget = target;
736
- evs.eventPhase = EventP.AT_TARGET;
737
- Event_setEtField(event, dispatched$1, true);
734
+ evs.eventPhase = 2 /* AT_TARGET */;
735
+ Event_setEtField(event, dispatched$2, true);
738
736
  let onceIndexes = [];
739
737
  for (let i = 0; i < s[_executors].length; ++i) {
740
738
  if (Event_getEtField(event, stopImmediatePropagationCalled))
@@ -763,12 +761,12 @@ function EventTarget_fire(target, event) {
763
761
  }, []);
764
762
  }
765
763
  evs.currentTarget = null;
766
- evs.eventPhase = EventP.NONE;
767
- Event_setEtField(event, dispatched$1, false);
764
+ evs.eventPhase = 0 /* NONE */;
765
+ Event_setEtField(event, dispatched$2, false);
768
766
  return !(event.cancelable && Event_getEtField(event, preventDefaultCalled));
769
767
  }
770
768
  function reply(target, signal, executor) {
771
- const s = target[state$d];
769
+ const s = target[state$g];
772
770
  const onAbort = () => {
773
771
  s[_executors] = s[_executors].filter(x => !x.equals(executor));
774
772
  signal.removeEventListener("abort", onAbort);
@@ -818,13 +816,13 @@ function executeFn(target, cb, ev) {
818
816
  const EventTargetE = g["EventTarget"] || EventTargetP;
819
817
 
820
818
  /** @internal */
821
- const state$c = Symbol( /* "ProgressEventState" */);
819
+ const state$f = Symbol( /* "ProgressEventState" */);
822
820
  class ProgressEventP extends EventP {
823
821
  constructor(type, eventInitDict) {
824
822
  var _a, _b;
825
823
  super(type, eventInitDict);
826
- this[state$c] = new ProgressEventState();
827
- const s = this[state$c];
824
+ this[state$f] = new ProgressEventState();
825
+ const s = this[state$f];
828
826
  s.lengthComputable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lengthComputable);
829
827
  s.loaded = Number((_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.loaded) !== null && _a !== void 0 ? _a : 0);
830
828
  s.total = Number((_b = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.total) !== null && _b !== void 0 ? _b : 0);
@@ -839,13 +837,13 @@ class ProgressEventP extends EventP {
839
837
  throw new TypeError(`Failed to construct 'ProgressEvent': Failed to read the '${errField}' property from 'ProgressEventInit': The provided double value is non-finite.`);
840
838
  }
841
839
  }
842
- get lengthComputable() { return getValue(this[state$c].lengthComputable); }
843
- get loaded() { return getValue(this[state$c].loaded); }
844
- get total() { return getValue(this[state$c].total); }
840
+ get lengthComputable() { return getValue(this[state$f].lengthComputable); }
841
+ get loaded() { return getValue(this[state$f].loaded); }
842
+ get total() { return getValue(this[state$f].total); }
845
843
  /** @internal */ toString() { return "[object ProgressEvent]"; }
844
+ /** @internal */ get [Symbol.toStringTag]() { return "ProgressEvent"; }
846
845
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
847
846
  }
848
- Class_setStringTag(ProgressEventP, "ProgressEvent");
849
847
  /** @internal */
850
848
  class ProgressEventState {
851
849
  constructor() {
@@ -859,10 +857,10 @@ function getValue(val) {
859
857
  }
860
858
  function createInnerProgressEvent(target, type, { lengthComputable = false, loaded = 0, total = 0, } = {}) {
861
859
  let event = new ProgressEventP(type);
862
- event[state$c].lengthComputable = lengthComputable;
863
- event[state$c].loaded = loaded;
864
- event[state$c].total = total;
865
- event[state$e].target = target;
860
+ event[state$f].lengthComputable = lengthComputable;
861
+ event[state$f].loaded = loaded;
862
+ event[state$f].total = total;
863
+ event[state$h].target = target;
866
864
  Event_setTrusted(event, true);
867
865
  return event;
868
866
  }
@@ -875,23 +873,29 @@ function emitProcessEvent(target, type, loaded = 0, total = 0) {
875
873
  });
876
874
  EventTarget_fire(target, event);
877
875
  }
878
- const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
876
+ g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
879
877
 
880
- var _a$7;
878
+ var _a$8;
881
879
  /** @internal */
882
- const state$b = Symbol( /* "FileReaderState" */);
880
+ const state$e = Symbol( /* "FileReaderState" */);
883
881
  class FileReaderP extends EventTargetP {
882
+ static get EMPTY() { return 0; }
883
+ static get LOADING() { return 1; }
884
+ static get DONE() { return 2; }
884
885
  constructor() {
885
886
  super();
886
- this[state$b] = new FileReaderState(this);
887
- }
888
- get readyState() { return this[state$b].readyState; }
889
- get result() { return this[state$b].result; }
890
- get error() { return this[state$b].error; }
887
+ this[state$e] = new FileReaderState(this);
888
+ }
889
+ get readyState() { return this[state$e].readyState; }
890
+ get result() { return this[state$e].result; }
891
+ get EMPTY() { return 0; }
892
+ get LOADING() { return 1; }
893
+ get DONE() { return 2; }
894
+ get error() { return this[state$e].error; }
891
895
  abort() {
892
- if (this.readyState === FileReaderP.LOADING) {
893
- const s = this[state$b];
894
- s.readyState = FileReaderP.DONE;
896
+ if (this.readyState === 1 /* LOADING */) {
897
+ const s = this[state$e];
898
+ s.readyState = 2 /* DONE */;
895
899
  s.result = null;
896
900
  s.error = new MPException("An ongoing operation was aborted, typically with a call to abort().", "AbortError");
897
901
  emitProcessEvent(this, "abort");
@@ -899,7 +903,7 @@ class FileReaderP extends EventTargetP {
899
903
  }
900
904
  readAsArrayBuffer(...args) {
901
905
  read$1(this, "readAsArrayBuffer", args, blob => {
902
- this[state$b].result = Blob_toUint8Array(blob).buffer.slice(0);
906
+ this[state$e].result = Blob_toUint8Array(blob).buffer.slice(0);
903
907
  });
904
908
  }
905
909
  readAsBinaryString(...args) {
@@ -910,12 +914,12 @@ class FileReaderP extends EventTargetP {
910
914
  let char = buf[i];
911
915
  str.push(String.fromCharCode(char));
912
916
  }
913
- this[state$b].result = str.join("");
917
+ this[state$e].result = str.join("");
914
918
  });
915
919
  }
916
920
  readAsDataURL(...args) {
917
921
  read$1(this, "readAsDataURL", args, blob => {
918
- this[state$b].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
922
+ this[state$e].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
919
923
  });
920
924
  }
921
925
  readAsText(...args) {
@@ -927,41 +931,34 @@ class FileReaderP extends EventTargetP {
927
931
  console.error(`TypeError: Failed to execute 'readAsText' on 'FileReader': encoding ('${_encoding}') not implemented.`);
928
932
  }
929
933
  }
930
- this[state$b].result = decode$1(Blob_toUint8Array(blob));
934
+ this[state$e].result = decode$1(Blob_toUint8Array(blob));
931
935
  });
932
936
  }
933
- get onabort() { return this[state$b].onabort; }
934
- set onabort(value) { this[state$b].onabort = value; attach$1(this, "abort"); }
935
- get onerror() { return this[state$b].onerror; }
936
- set onerror(value) { this[state$b].onerror = value; attach$1(this, "error"); }
937
- get onload() { return this[state$b].onload; }
938
- set onload(value) { this[state$b].onload = value; attach$1(this, "load"); }
939
- get onloadend() { return this[state$b].onloadend; }
940
- set onloadend(value) { this[state$b].onloadend = value; attach$1(this, "loadend"); }
941
- get onloadstart() { return this[state$b].onloadstart; }
942
- set onloadstart(value) { this[state$b].onloadstart = value; attach$1(this, "loadstart"); }
943
- get onprogress() { return this[state$b].onprogress; }
944
- set onprogress(value) { this[state$b].onprogress = value; attach$1(this, "progress"); }
937
+ get onabort() { return this[state$e].onabort; }
938
+ set onabort(value) { this[state$e].onabort = value; attach$2(this, "abort"); }
939
+ get onerror() { return this[state$e].onerror; }
940
+ set onerror(value) { this[state$e].onerror = value; attach$2(this, "error"); }
941
+ get onload() { return this[state$e].onload; }
942
+ set onload(value) { this[state$e].onload = value; attach$2(this, "load"); }
943
+ get onloadend() { return this[state$e].onloadend; }
944
+ set onloadend(value) { this[state$e].onloadend = value; attach$2(this, "loadend"); }
945
+ get onloadstart() { return this[state$e].onloadstart; }
946
+ set onloadstart(value) { this[state$e].onloadstart = value; attach$2(this, "loadstart"); }
947
+ get onprogress() { return this[state$e].onprogress; }
948
+ set onprogress(value) { this[state$e].onprogress = value; attach$2(this, "progress"); }
945
949
  /** @internal */ toString() { return "[object FileReader]"; }
950
+ /** @internal */ get [Symbol.toStringTag]() { return "FileReader"; }
946
951
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
947
952
  }
948
- const properties = {
949
- EMPTY: { value: 0, enumerable: true },
950
- LOADING: { value: 1, enumerable: true },
951
- DONE: { value: 2, enumerable: true },
952
- };
953
- Object.defineProperties(FileReaderP, properties);
954
- Object.defineProperties(FileReaderP.prototype, properties);
955
- Class_setStringTag(FileReaderP, "FileReader");
956
953
  /** @internal */
957
- const _handlers$3 = Symbol();
954
+ const _handlers$4 = Symbol();
958
955
  /** @internal */
959
956
  class FileReaderState {
960
957
  constructor(target) {
961
- this.readyState = FileReaderP.EMPTY;
958
+ this.readyState = 0 /* EMPTY */;
962
959
  this.result = null;
963
960
  this.error = null;
964
- this[_a$7] = getHandlers$3(this);
961
+ this[_a$8] = getHandlers$4(this);
965
962
  this.onabort = null;
966
963
  this.onerror = null;
967
964
  this.onload = null;
@@ -971,20 +968,20 @@ class FileReaderState {
971
968
  this.target = target;
972
969
  }
973
970
  }
974
- _a$7 = _handlers$3;
971
+ _a$8 = _handlers$4;
975
972
  function read$1(reader, kind, args, setResult) {
976
973
  const [blob] = args;
977
974
  checkArgsLength(args, 1, "FileReader", kind);
978
975
  if (!isPolyfillType("Blob", blob)) {
979
976
  throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
980
977
  }
981
- const s = reader[state$b];
978
+ const s = reader[state$e];
982
979
  s.error = null;
983
- s.readyState = FileReaderP.LOADING;
980
+ s.readyState = 1 /* LOADING */;
984
981
  emitProcessEvent(s.target, "loadstart", 0, blob.size);
985
982
  setTimeout(() => {
986
- if (s.readyState === FileReaderP.LOADING) {
987
- s.readyState = FileReaderP.DONE;
983
+ if (s.readyState === 1 /* LOADING */) {
984
+ s.readyState = 2 /* DONE */;
988
985
  try {
989
986
  setResult(blob);
990
987
  emitProcessEvent(s.target, "load", blob.size, blob.size);
@@ -998,14 +995,14 @@ function read$1(reader, kind, args, setResult) {
998
995
  emitProcessEvent(s.target, "loadend", !!s.result ? blob.size : 0, blob.size);
999
996
  });
1000
997
  }
1001
- function attach$1(reader, type) {
1002
- const s = reader[state$b];
998
+ function attach$2(reader, type) {
999
+ const s = reader[state$e];
1003
1000
  const fnName = ("on" + type);
1004
1001
  const cb = s[fnName];
1005
- const listener = s[_handlers$3][fnName];
1002
+ const listener = s[_handlers$4][fnName];
1006
1003
  attachFn(reader, type, cb, listener);
1007
1004
  }
1008
- function getHandlers$3(s) {
1005
+ function getHandlers$4(s) {
1009
1006
  return {
1010
1007
  onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
1011
1008
  onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
@@ -1017,14 +1014,14 @@ function getHandlers$3(s) {
1017
1014
  }
1018
1015
  const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
1019
1016
 
1020
- var _a$6;
1021
- /** @internal */ const state$a = Symbol( /* "URLSearchParamsState" */);
1017
+ var _a$7;
1018
+ /** @internal */ const state$d = Symbol( /* "URLSearchParamsState" */);
1022
1019
  const checkArgsFn$2 = (args, required, funcName) => { checkArgsLength(args, required, "URLSearchParams", funcName); };
1023
1020
  class URLSearchParamsP {
1024
1021
  constructor(init) {
1025
- this[state$a] = new URLSearchParamsState();
1022
+ this[state$d] = new URLSearchParamsState();
1026
1023
  if (init !== undefined) {
1027
- if (isObjectType("URLSearchParams", init)) {
1024
+ if (isObjectType("URLSearchParams", init) || isPolyfillType("URLSearchParams", init)) {
1028
1025
  init.forEach((value, name) => { this.append(name, value); }, this);
1029
1026
  }
1030
1027
  else if (init && typeof init === "object") {
@@ -1070,18 +1067,18 @@ class URLSearchParamsP {
1070
1067
  }
1071
1068
  }
1072
1069
  }
1073
- get size() { return this[state$a][_urlspArray].length; }
1070
+ get size() { return this[state$d][_urlspArray].length; }
1074
1071
  append(...args) {
1075
1072
  const [name, value] = args;
1076
1073
  checkArgsFn$2(args, 2, "append");
1077
- this[state$a][_urlspArray].push(["" + name, normalizeValue$1(value)]);
1074
+ this[state$d][_urlspArray].push(["" + name, normalizeValue$1(value)]);
1078
1075
  }
1079
1076
  delete(...args) {
1080
1077
  const [name, value] = args;
1081
1078
  checkArgsFn$2(args, 1, "delete");
1082
1079
  let _name = "" + name;
1083
1080
  let index = -1;
1084
- let array = this[state$a][_urlspArray];
1081
+ let array = this[state$d][_urlspArray];
1085
1082
  let result = [];
1086
1083
  for (let i = 0; i < array.length; ++i) {
1087
1084
  let item = array[i];
@@ -1095,14 +1092,14 @@ class URLSearchParamsP {
1095
1092
  result.push(item);
1096
1093
  }
1097
1094
  if (index > -1) {
1098
- this[state$a][_urlspArray] = result;
1095
+ this[state$d][_urlspArray] = result;
1099
1096
  }
1100
1097
  }
1101
1098
  get(...args) {
1102
1099
  const [name] = args;
1103
1100
  checkArgsFn$2(args, 1, "get");
1104
1101
  let _name = "" + name;
1105
- let array = this[state$a][_urlspArray];
1102
+ let array = this[state$d][_urlspArray];
1106
1103
  for (let i = 0; i < array.length; ++i) {
1107
1104
  let item = array[i];
1108
1105
  if (item[0] === _name) {
@@ -1115,7 +1112,7 @@ class URLSearchParamsP {
1115
1112
  const [name] = args;
1116
1113
  checkArgsFn$2(args, 1, "getAll");
1117
1114
  let _name = "" + name;
1118
- let array = this[state$a][_urlspArray];
1115
+ let array = this[state$d][_urlspArray];
1119
1116
  let result = [];
1120
1117
  for (let i = 0; i < array.length; ++i) {
1121
1118
  let item = array[i];
@@ -1129,7 +1126,7 @@ class URLSearchParamsP {
1129
1126
  const [name, value] = args;
1130
1127
  checkArgsFn$2(args, 1, "has");
1131
1128
  let _name = "" + name;
1132
- let array = this[state$a][_urlspArray];
1129
+ let array = this[state$d][_urlspArray];
1133
1130
  for (let i = 0; i < array.length; ++i) {
1134
1131
  let item = array[i];
1135
1132
  if (item[0] === _name) {
@@ -1151,7 +1148,7 @@ class URLSearchParamsP {
1151
1148
  let _name = "" + name;
1152
1149
  let _value = normalizeValue$1(value);
1153
1150
  let index = -1;
1154
- let array = this[state$a][_urlspArray];
1151
+ let array = this[state$d][_urlspArray];
1155
1152
  let result = [];
1156
1153
  for (let i = 0; i < array.length; ++i) {
1157
1154
  let item = array[i];
@@ -1167,10 +1164,10 @@ class URLSearchParamsP {
1167
1164
  if (index === -1) {
1168
1165
  result.push([_name, _value]);
1169
1166
  }
1170
- this[state$a][_urlspArray] = result;
1167
+ this[state$d][_urlspArray] = result;
1171
1168
  }
1172
1169
  sort() {
1173
- this[state$a][_urlspArray].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
1170
+ this[state$d][_urlspArray].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
1174
1171
  }
1175
1172
  forEach(...args) {
1176
1173
  const [callbackfn, thisArg] = args;
@@ -1178,26 +1175,26 @@ class URLSearchParamsP {
1178
1175
  if (typeof callbackfn !== "function") {
1179
1176
  throw new TypeError("Failed to execute 'forEach' on 'URLSearchParams': parameter 1 is not of type 'Function'.");
1180
1177
  }
1181
- let array = this[state$a][_urlspArray];
1178
+ let array = this[state$d][_urlspArray];
1182
1179
  for (let i = 0; i < array.length; ++i) {
1183
1180
  let item = array[i];
1184
1181
  callbackfn.call(thisArg, item[1], item[0], this);
1185
1182
  }
1186
1183
  }
1187
1184
  entries() {
1188
- return this[state$a][_urlspArray].map(x => [x[0], x[1]]).values();
1185
+ return this[state$d][_urlspArray].map(x => [x[0], x[1]]).values();
1189
1186
  }
1190
1187
  keys() {
1191
- return this[state$a][_urlspArray].map(x => x[0]).values();
1188
+ return this[state$d][_urlspArray].map(x => x[0]).values();
1192
1189
  }
1193
1190
  values() {
1194
- return this[state$a][_urlspArray].map(x => x[1]).values();
1191
+ return this[state$d][_urlspArray].map(x => x[1]).values();
1195
1192
  }
1196
1193
  [Symbol.iterator]() {
1197
1194
  return this.entries();
1198
1195
  }
1199
1196
  toString() {
1200
- let array = this[state$a][_urlspArray];
1197
+ let array = this[state$d][_urlspArray];
1201
1198
  let result = [];
1202
1199
  for (let i = 0; i < array.length; ++i) {
1203
1200
  let item = array[i];
@@ -1205,19 +1202,18 @@ class URLSearchParamsP {
1205
1202
  }
1206
1203
  return result.join("&");
1207
1204
  }
1208
- /** @internal */
1209
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
1205
+ /** @internal */ get [Symbol.toStringTag]() { return "URLSearchParams"; }
1206
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
1210
1207
  }
1211
- Class_setStringTag(URLSearchParamsP, "URLSearchParams");
1212
1208
  /** @internal */
1213
1209
  const _urlspArray = Symbol();
1214
1210
  /** @internal */
1215
1211
  class URLSearchParamsState {
1216
1212
  constructor() {
1217
- this[_a$6] = [];
1213
+ this[_a$7] = [];
1218
1214
  }
1219
1215
  }
1220
- _a$6 = _urlspArray;
1216
+ _a$7 = _urlspArray;
1221
1217
  function normalizeValue$1(value) {
1222
1218
  return typeof value === "string" ? value : (value !== null && value !== undefined && typeof value.toString === "function"
1223
1219
  ? value.toString()
@@ -1242,8 +1238,8 @@ function decode(str) {
1242
1238
  }
1243
1239
  const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
1244
1240
 
1245
- var _a$5;
1246
- /** @internal */ const state$9 = Symbol( /* "FormDataState" */);
1241
+ var _a$6;
1242
+ /** @internal */ const state$c = Symbol( /* "FormDataState" */);
1247
1243
  const checkArgsFn$1 = (args, required, funcName) => { checkArgsLength(args, required, "FormData", funcName); };
1248
1244
  class FormDataP {
1249
1245
  constructor(form, submitter) {
@@ -1257,19 +1253,19 @@ class FormDataP {
1257
1253
  console.error("TypeError: Failed to construct 'FormData': parameter 1 and parameter 2 not implemented.");
1258
1254
  }
1259
1255
  }
1260
- this[state$9] = new FormDataState();
1256
+ this[state$c] = new FormDataState();
1261
1257
  }
1262
1258
  append(...args) {
1263
1259
  const [name, value, filename] = args;
1264
1260
  checkArgsFn$1(args, 2, "append");
1265
- this[state$9][_formData].push(normalizeArgs(name, value, filename));
1261
+ this[state$c][_formData].push(normalizeArgs(name, value, filename));
1266
1262
  }
1267
1263
  delete(...args) {
1268
1264
  const [name] = args;
1269
1265
  checkArgsFn$1(args, 1, "delete");
1270
1266
  let _name = "" + name;
1271
1267
  let index = -1;
1272
- let array = this[state$9][_formData];
1268
+ let array = this[state$c][_formData];
1273
1269
  let result = [];
1274
1270
  for (let i = 0; i < array.length; ++i) {
1275
1271
  let item = array[i];
@@ -1280,14 +1276,14 @@ class FormDataP {
1280
1276
  result.push(item);
1281
1277
  }
1282
1278
  if (index > -1) {
1283
- this[state$9][_formData] = result;
1279
+ this[state$c][_formData] = result;
1284
1280
  }
1285
1281
  }
1286
1282
  get(...args) {
1287
1283
  const [name] = args;
1288
1284
  checkArgsFn$1(args, 1, "get");
1289
1285
  let _name = "" + name;
1290
- let array = this[state$9][_formData];
1286
+ let array = this[state$c][_formData];
1291
1287
  for (let i = 0; i < array.length; ++i) {
1292
1288
  let item = array[i];
1293
1289
  if (item[0] === _name) {
@@ -1300,7 +1296,7 @@ class FormDataP {
1300
1296
  const [name] = args;
1301
1297
  checkArgsFn$1(args, 1, "getAll");
1302
1298
  let _name = "" + name;
1303
- let array = this[state$9][_formData];
1299
+ let array = this[state$c][_formData];
1304
1300
  let result = [];
1305
1301
  for (let i = 0; i < array.length; ++i) {
1306
1302
  let item = array[i];
@@ -1314,7 +1310,7 @@ class FormDataP {
1314
1310
  const [name] = args;
1315
1311
  checkArgsFn$1(args, 1, "has");
1316
1312
  let _name = "" + name;
1317
- let array = this[state$9][_formData];
1313
+ let array = this[state$c][_formData];
1318
1314
  for (let i = 0; i < array.length; ++i) {
1319
1315
  let item = array[i];
1320
1316
  if (item[0] === _name) {
@@ -1329,7 +1325,7 @@ class FormDataP {
1329
1325
  let _name = "" + name;
1330
1326
  let _args = normalizeArgs(name, value, filename);
1331
1327
  let index = -1;
1332
- let array = this[state$9][_formData];
1328
+ let array = this[state$c][_formData];
1333
1329
  let result = [];
1334
1330
  for (let i = 0; i < array.length; ++i) {
1335
1331
  let item = array[i];
@@ -1345,7 +1341,7 @@ class FormDataP {
1345
1341
  if (index === -1) {
1346
1342
  result.push(_args);
1347
1343
  }
1348
- this[state$9][_formData] = result;
1344
+ this[state$c][_formData] = result;
1349
1345
  }
1350
1346
  forEach(...args) {
1351
1347
  const [callbackfn, thisArg] = args;
@@ -1353,44 +1349,44 @@ class FormDataP {
1353
1349
  if (typeof callbackfn !== "function") {
1354
1350
  throw new TypeError("Failed to execute 'forEach' on 'FormData': parameter 1 is not of type 'Function'.");
1355
1351
  }
1356
- let array = this[state$9][_formData];
1352
+ let array = this[state$c][_formData];
1357
1353
  for (let i = 0; i < array.length; ++i) {
1358
1354
  let item = array[i];
1359
1355
  callbackfn.call(thisArg, item[1], item[0], thisArg);
1360
1356
  }
1361
1357
  }
1362
1358
  entries() {
1363
- return this[state$9][_formData].map(x => [x[0], x[1]]).values();
1359
+ return this[state$c][_formData].map(x => [x[0], x[1]]).values();
1364
1360
  }
1365
1361
  keys() {
1366
- return this[state$9][_formData].map(x => x[0]).values();
1362
+ return this[state$c][_formData].map(x => x[0]).values();
1367
1363
  }
1368
1364
  values() {
1369
- return this[state$9][_formData].map(x => x[1]).values();
1365
+ return this[state$c][_formData].map(x => x[1]).values();
1370
1366
  }
1371
1367
  [Symbol.iterator]() {
1372
1368
  return this.entries();
1373
1369
  }
1374
1370
  /** @internal */ toString() { return "[object FormData]"; }
1371
+ /** @internal */ get [Symbol.toStringTag]() { return "FormData"; }
1375
1372
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
1376
1373
  }
1377
- Class_setStringTag(FormDataP, "FormData");
1378
1374
  /** @internal */
1379
1375
  const _formData = Symbol();
1380
1376
  /** @internal */
1381
1377
  class FormDataState {
1382
1378
  constructor() {
1383
- this[_a$5] = [];
1379
+ this[_a$6] = [];
1384
1380
  }
1385
1381
  }
1386
- _a$5 = _formData;
1382
+ _a$6 = _formData;
1387
1383
  /** @internal */
1388
1384
  function FormData_toBlob(formData) {
1389
1385
  const boundary = "----formdata-mphttpx-" + Math.random();
1390
1386
  const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
1391
1387
  let chunks = [];
1392
- for (let i = 0; i < formData[state$9][_formData].length; ++i) {
1393
- let pair = formData[state$9][_formData][i];
1388
+ for (let i = 0; i < formData[state$c][_formData].length; ++i) {
1389
+ let pair = formData[state$c][_formData][i];
1394
1390
  let name = pair[0];
1395
1391
  let value = pair[1];
1396
1392
  if (typeof value === "string") {
@@ -1410,7 +1406,7 @@ function normalizeArgs(name, value, filename) {
1410
1406
  : typeof value.name === "string"
1411
1407
  ? value.name
1412
1408
  : "blob";
1413
- if (value.name !== filename || isObjectType("Blob", value)) {
1409
+ if (value.name !== filename || isObjectType("Blob", value) || isPolyfillType("Blob", value, true)) {
1414
1410
  value = new FileP([value], filename);
1415
1411
  }
1416
1412
  return ["" + name, value];
@@ -1480,15 +1476,15 @@ function createFormDataFromBinaryText(text, boundary) {
1480
1476
  }
1481
1477
  const FormDataE = g["FormData"] || FormDataP;
1482
1478
 
1483
- var _a$4, _b$1;
1484
- /** @internal */ const state$8 = Symbol( /* "HeadersState" */);
1479
+ var _a$5, _b$2;
1480
+ /** @internal */ const state$b = Symbol( /* "HeadersState" */);
1485
1481
  const checkArgsFn = (args, required, funcName) => { checkArgsLength(args, required, "Headers", funcName); };
1486
1482
  class HeadersP {
1487
1483
  constructor(init) {
1488
- this[state$8] = new HeadersState();
1484
+ this[state$b] = new HeadersState();
1489
1485
  if (init !== undefined) {
1490
- if (isObjectType("Headers", init)) {
1491
- init.forEach((value, name) => { this.append(name, value); }, this);
1486
+ if (isObjectType("Headers", init) || isPolyfillType("Headers", init)) {
1487
+ init.forEach((value, name) => { Headers_append(this, name, value); }, this);
1492
1488
  }
1493
1489
  else if (Array.isArray(init) || (init && typeof init === "object" && Symbol.iterator in init)) {
1494
1490
  let _init = Array.isArray(init) ? init : Array.from(init);
@@ -1516,58 +1512,27 @@ class HeadersP {
1516
1512
  }
1517
1513
  }
1518
1514
  }
1519
- this[state$8][_initialized] = true;
1515
+ this[state$b][_initialized] = true;
1520
1516
  }
1521
1517
  append(...args) {
1522
1518
  const [name, value] = args;
1523
1519
  checkArgsFn(args, 2, "append");
1524
- let _name = normalizeName(name, throwsFn(this[state$8][_initialized] ? "append" : ""));
1520
+ let _name = normalizeName(name, throwsFn(this[state$b][_initialized] ? "append" : ""));
1525
1521
  let _value = normalizeValue(value);
1526
- let index = -1;
1527
- let array = this[state$8][_headersArray];
1528
- for (let i = 0; i < array.length; ++i) {
1529
- let item = array[i];
1530
- if (item[0] === _name) {
1531
- item[1] = `${item[1]}, ${_value}`;
1532
- index = i;
1533
- break;
1534
- }
1535
- }
1536
- if (index === -1) {
1537
- array.push([_name, _value]);
1538
- }
1522
+ Headers_append(this, _name, _value);
1539
1523
  }
1540
1524
  delete(...args) {
1541
1525
  const [name] = args;
1542
1526
  checkArgsFn(args, 1, "delete");
1543
1527
  let _name = normalizeName(name, throwsFn("delete"));
1544
- let index = -1;
1545
- let array = this[state$8][_headersArray];
1546
- let result = [];
1547
- for (let i = 0; i < array.length; ++i) {
1548
- let item = array[i];
1549
- if (item[0] === _name) {
1550
- index = i;
1551
- continue;
1552
- }
1553
- result.push(item);
1554
- }
1555
- if (index > -1) {
1556
- this[state$8][_headersArray] = result;
1557
- }
1528
+ delete this[state$b][_headersDict][_name];
1558
1529
  }
1559
1530
  get(...args) {
1531
+ var _c;
1560
1532
  const [name] = args;
1561
1533
  checkArgsFn(args, 1, "get");
1562
1534
  let _name = normalizeName(name, throwsFn("get"));
1563
- let array = this[state$8][_headersArray];
1564
- for (let i = 0; i < array.length; ++i) {
1565
- let item = array[i];
1566
- if (item[0] === _name) {
1567
- return item[1];
1568
- }
1569
- }
1570
- return null;
1535
+ return (_c = this[state$b][_headersDict][_name]) !== null && _c !== void 0 ? _c : null;
1571
1536
  }
1572
1537
  getSetCookie() {
1573
1538
  let value = this.get("Set-Cookie");
@@ -1577,33 +1542,14 @@ class HeadersP {
1577
1542
  const [name] = args;
1578
1543
  checkArgsFn(args, 1, "has");
1579
1544
  let _name = normalizeName(name, throwsFn("has"));
1580
- let array = this[state$8][_headersArray];
1581
- for (let i = 0; i < array.length; ++i) {
1582
- let item = array[i];
1583
- if (item[0] === _name) {
1584
- return true;
1585
- }
1586
- }
1587
- return false;
1545
+ return this[state$b][_headersDict].hasOwnProperty(_name);
1588
1546
  }
1589
1547
  set(...args) {
1590
1548
  const [name, value] = args;
1591
1549
  checkArgsFn(args, 2, "set");
1592
1550
  let _name = normalizeName(name, throwsFn("set"));
1593
1551
  let _value = normalizeValue(value);
1594
- let index = -1;
1595
- let array = this[state$8][_headersArray];
1596
- for (let i = 0; i < array.length; ++i) {
1597
- let item = array[i];
1598
- if (item[0] === _name) {
1599
- item[1] = _value;
1600
- index = i;
1601
- break;
1602
- }
1603
- }
1604
- if (index === -1) {
1605
- array.push([_name, _value]);
1606
- }
1552
+ this[state$b][_headersDict][_name] = _value;
1607
1553
  }
1608
1554
  forEach(...args) {
1609
1555
  const [callbackfn, thisArg] = args;
@@ -1611,38 +1557,49 @@ class HeadersP {
1611
1557
  if (typeof callbackfn !== "function") {
1612
1558
  throw new TypeError("Failed to execute 'forEach' on 'Headers': parameter 1 is not of type 'Function'.");
1613
1559
  }
1614
- let array = this[state$8][_headersArray];
1615
- for (let i = 0; i < array.length; ++i) {
1616
- let item = array[i];
1617
- callbackfn.call(thisArg, item[1], item[0], this);
1560
+ let names = Object.getOwnPropertyNames(this[state$b][_headersDict]);
1561
+ for (let i = 0; i < names.length; ++i) {
1562
+ let name = names[i];
1563
+ callbackfn.call(thisArg, this[state$b][_headersDict][name], name, this);
1618
1564
  }
1619
1565
  }
1620
1566
  entries() {
1621
- return this[state$8][_headersArray].map(x => [x[0], x[1]]).values();
1567
+ let array = [];
1568
+ this.forEach((value, name) => { array.push([name, value]); });
1569
+ return array.values();
1622
1570
  }
1623
1571
  keys() {
1624
- return this[state$8][_headersArray].map(x => x[0]).values();
1572
+ let array = [];
1573
+ this.forEach((value, name) => { array.push(name); });
1574
+ return array.values();
1625
1575
  }
1626
1576
  values() {
1627
- return this[state$8][_headersArray].map(x => x[1]).values();
1577
+ let array = [];
1578
+ this.forEach((value, name) => { array.push(value); });
1579
+ return array.values();
1628
1580
  }
1629
1581
  [Symbol.iterator]() {
1630
1582
  return this.entries();
1631
1583
  }
1632
1584
  /** @internal */ toString() { return "[object Headers]"; }
1585
+ /** @internal */ get [Symbol.toStringTag]() { return "Headers"; }
1633
1586
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
1634
1587
  }
1635
- Class_setStringTag(HeadersP, "Headers");
1636
1588
  /** @internal */ const _initialized = Symbol();
1637
- /** @internal */ const _headersArray = Symbol();
1589
+ /** @internal */ const _headersDict = Symbol();
1638
1590
  /** @internal */
1639
1591
  class HeadersState {
1640
1592
  constructor() {
1641
- this[_a$4] = false;
1642
- this[_b$1] = [];
1593
+ this[_a$5] = false;
1594
+ this[_b$2] = {};
1643
1595
  }
1644
1596
  }
1645
- _a$4 = _initialized, _b$1 = _headersArray;
1597
+ _a$5 = _initialized, _b$2 = _headersDict;
1598
+ function Headers_append(headers, name, value) {
1599
+ let dict = headers[state$b][_headersDict];
1600
+ let oldValue = dict[name];
1601
+ dict[name] = oldValue !== undefined ? `${oldValue}, ${value}` : value;
1602
+ }
1646
1603
  function throwsFn(kind) {
1647
1604
  return () => {
1648
1605
  throw new TypeError(`Failed to ${kind ? ("execute '" + kind + "' on") : "construct"} 'Headers': Invalid name`);
@@ -1686,23 +1643,23 @@ function parseHeaders(rawHeaders) {
1686
1643
  }
1687
1644
  const HeadersE = g["Headers"] || HeadersP;
1688
1645
 
1689
- var _a$3;
1690
- /** @internal */ const state$7 = Symbol( /* "BodyState" */);
1646
+ var _a$4;
1647
+ /** @internal */ const state$a = Symbol( /* "BodyState" */);
1691
1648
  class BodyImpl {
1692
1649
  /** @internal */
1693
1650
  constructor() {
1694
1651
  if (new.target === BodyImpl) {
1695
1652
  throw new TypeError("Failed to construct 'Body': Illegal constructor");
1696
1653
  }
1697
- this[state$7] = new BodyState();
1654
+ this[state$a] = new BodyState();
1698
1655
  }
1699
1656
  get body() {
1700
- if (!this[state$7][_body]) {
1657
+ if (!this[state$a][_body]) {
1701
1658
  return null;
1702
1659
  }
1703
- throw new TypeError(`Failed to access 'body' on '${this[state$7].name}': property not implemented.`);
1660
+ throw new TypeError(`Failed to access 'body' on '${this[state$a].name}': property not implemented.`);
1704
1661
  }
1705
- get bodyUsed() { return this[state$7].bodyUsed; }
1662
+ get bodyUsed() { return this[state$a].bodyUsed; }
1706
1663
  ;
1707
1664
  arrayBuffer() {
1708
1665
  const kind = "arrayBuffer";
@@ -1729,9 +1686,9 @@ class BodyImpl {
1729
1686
  return consumed(this, kind) || read(this, kind);
1730
1687
  }
1731
1688
  /** @internal */ toString() { return "[object Body]"; }
1689
+ /** @internal */ get [Symbol.toStringTag]() { return "Body"; }
1732
1690
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
1733
1691
  }
1734
- Class_setStringTag(BodyImpl, "Body");
1735
1692
  /** @internal */
1736
1693
  const _body = Symbol();
1737
1694
  /** @internal */
@@ -1739,23 +1696,23 @@ class BodyState {
1739
1696
  constructor() {
1740
1697
  this.name = "Body";
1741
1698
  this.bodyUsed = false;
1742
- this[_a$3] = "";
1699
+ this[_a$4] = "";
1743
1700
  }
1744
1701
  }
1745
- _a$3 = _body;
1702
+ _a$4 = _body;
1746
1703
  /** @internal */
1747
1704
  function Body_init(body, payload) {
1748
1705
  const b = body;
1749
1706
  if (isObjectType("ReadableStream", payload)) {
1750
- throw new TypeError(`Failed to construct '${b[state$7].name}': ReadableStream not implemented.`);
1707
+ throw new TypeError(`Failed to construct '${b[state$a].name}': ReadableStream not implemented.`);
1751
1708
  }
1752
- b[state$7][_body] = convert(payload, true, type => { if (!b.headers.has("Content-Type")) {
1709
+ b[state$a][_body] = convert(payload, true, type => { if (!b.headers.has("Content-Type")) {
1753
1710
  b.headers.set("Content-Type", type);
1754
1711
  } });
1755
1712
  }
1756
1713
  /** @internal */
1757
1714
  function Body_toPayload(body) {
1758
- return body[state$7][_body];
1715
+ return body[state$a][_body];
1759
1716
  }
1760
1717
  function read(body, kind) {
1761
1718
  return new Promise((resolve, reject) => {
@@ -1768,7 +1725,7 @@ function read(body, kind) {
1768
1725
  });
1769
1726
  }
1770
1727
  function readSync(body, kind) {
1771
- const payload = body[state$7][_body];
1728
+ const payload = body[state$a][_body];
1772
1729
  if (kind === "arrayBuffer") {
1773
1730
  return convertBack("arraybuffer", payload);
1774
1731
  }
@@ -1805,7 +1762,7 @@ function readSync(body, kind) {
1805
1762
  }
1806
1763
  }
1807
1764
  function consumed(body, kind) {
1808
- const s = body[state$7];
1765
+ const s = body[state$a];
1809
1766
  if (!s[_body])
1810
1767
  return;
1811
1768
  if (s.bodyUsed) {
@@ -1822,13 +1779,13 @@ function convert(body, cloneArrayBuffer = true, setContentType, setContentLength
1822
1779
  setContentType("text/plain;charset=UTF-8");
1823
1780
  }
1824
1781
  }
1825
- else if (isObjectType("URLSearchParams", body)) {
1782
+ else if (isObjectType("URLSearchParams", body) || isPolyfillType("URLSearchParams", body)) {
1826
1783
  result = body.toString();
1827
1784
  if (setContentType) {
1828
1785
  setContentType("application/x-www-form-urlencoded;charset=UTF-8");
1829
1786
  }
1830
1787
  }
1831
- else if (body instanceof ArrayBuffer) {
1788
+ else if (isArrayBuffer(body)) {
1832
1789
  result = cloneArrayBuffer ? body.slice(0) : body;
1833
1790
  }
1834
1791
  else if (ArrayBuffer.isView(body)) {
@@ -1867,7 +1824,7 @@ function convert(body, cloneArrayBuffer = true, setContentType, setContentLength
1867
1824
  }
1868
1825
  /** @internal */
1869
1826
  function convertBack(type, data) {
1870
- let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
1827
+ let temp = !!data ? (typeof data !== "string" && !isArrayBuffer(data) ? JSON.stringify(data) : data) : "";
1871
1828
  if (!type || type === "text") {
1872
1829
  return typeof temp === "string" ? temp : decode$1(temp);
1873
1830
  }
@@ -1875,7 +1832,7 @@ function convertBack(type, data) {
1875
1832
  return JSON.parse(typeof temp === "string" ? temp : decode$1(temp));
1876
1833
  }
1877
1834
  else if (type === "arraybuffer") {
1878
- return temp instanceof ArrayBuffer ? temp.slice(0) : encode$1(temp).buffer;
1835
+ return isArrayBuffer(temp) ? temp.slice(0) : encode$1(temp).buffer;
1879
1836
  }
1880
1837
  else if (type === "blob") {
1881
1838
  return new BlobP([temp]);
@@ -1885,9 +1842,9 @@ function convertBack(type, data) {
1885
1842
  }
1886
1843
  }
1887
1844
 
1888
- var _a$2;
1845
+ var _a$3;
1889
1846
  /** @internal */
1890
- const state$6 = Symbol( /* "AbortSignalState" */);
1847
+ const state$9 = Symbol( /* "AbortSignalState" */);
1891
1848
  class AbortSignalP extends EventTargetP {
1892
1849
  static abort(reason) {
1893
1850
  let signal = createAbortSignal();
@@ -1944,40 +1901,40 @@ class AbortSignalP extends EventTargetP {
1944
1901
  throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
1945
1902
  }
1946
1903
  super();
1947
- this[state$6] = new AbortSignalState(this);
1904
+ this[state$9] = new AbortSignalState(this);
1948
1905
  }
1949
- get aborted() { return this[state$6].aborted; }
1950
- get reason() { return this[state$6].reason; }
1906
+ get aborted() { return this[state$9].aborted; }
1907
+ get reason() { return this[state$9].reason; }
1951
1908
  throwIfAborted() {
1952
1909
  if (this.aborted) {
1953
1910
  throw this.reason;
1954
1911
  }
1955
1912
  }
1956
- get onabort() { return this[state$6].onabort; }
1913
+ get onabort() { return this[state$9].onabort; }
1957
1914
  set onabort(value) {
1958
- this[state$6].onabort = value;
1959
- attachFn(this, "abort", value, this[state$6][_handlers$2].onabort);
1915
+ this[state$9].onabort = value;
1916
+ attachFn(this, "abort", value, this[state$9][_handlers$3].onabort);
1960
1917
  }
1961
1918
  /** @internal */ toString() { return "[object AbortSignal]"; }
1919
+ /** @internal */ get [Symbol.toStringTag]() { return "AbortSignal"; }
1962
1920
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
1963
1921
  }
1964
- Class_setStringTag(AbortSignalP, "AbortSignal");
1965
1922
  /** @internal */
1966
- const _handlers$2 = Symbol();
1923
+ const _handlers$3 = Symbol();
1967
1924
  /** @internal */
1968
1925
  class AbortSignalState {
1969
1926
  constructor(target) {
1970
1927
  this.aborted = false;
1971
1928
  this.reason = undefined;
1972
- this[_a$2] = getHandlers$2(this);
1929
+ this[_a$3] = getHandlers$3(this);
1973
1930
  this.onabort = null;
1974
1931
  this.target = target;
1975
1932
  }
1976
1933
  }
1977
- _a$2 = _handlers$2;
1934
+ _a$3 = _handlers$3;
1978
1935
  /** @internal */
1979
1936
  function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
1980
- const s = signal[state$6];
1937
+ const s = signal[state$9];
1981
1938
  if (!s.aborted) {
1982
1939
  s.aborted = true;
1983
1940
  s.reason = reason !== null && reason !== void 0 ? reason : (new MPException("signal is aborted without reason", "AbortError"));
@@ -1987,7 +1944,7 @@ function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
1987
1944
  }
1988
1945
  }
1989
1946
  }
1990
- function getHandlers$2(s) {
1947
+ function getHandlers$3(s) {
1991
1948
  return {
1992
1949
  onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
1993
1950
  };
@@ -1995,26 +1952,26 @@ function getHandlers$2(s) {
1995
1952
  /** @internal */
1996
1953
  function createAbortSignal() {
1997
1954
  let signal = Object.create(AbortSignalP.prototype);
1998
- signal[state$d] = new EventTargetState(signal);
1999
- signal[state$6] = new AbortSignalState(signal);
1955
+ signal[state$g] = new EventTargetState(signal);
1956
+ signal[state$9] = new AbortSignalState(signal);
2000
1957
  return signal;
2001
1958
  }
2002
1959
  const AbortSignalE = g["AbortSignal"] || AbortSignalP;
2003
1960
 
2004
1961
  /** @internal */
2005
- const state$5 = Symbol( /* "AbortControllerState" */);
1962
+ const state$8 = Symbol( /* "AbortControllerState" */);
2006
1963
  class AbortControllerP {
2007
1964
  constructor() {
2008
- this[state$5] = new AbortControllerState();
1965
+ this[state$8] = new AbortControllerState();
2009
1966
  }
2010
- get signal() { return this[state$5].signal; }
1967
+ get signal() { return this[state$8].signal; }
2011
1968
  abort(reason) {
2012
- AbortSignal_abort(this[state$5].signal, reason);
1969
+ AbortSignal_abort(this[state$8].signal, reason);
2013
1970
  }
2014
1971
  /** @internal */ toString() { return "[object AbortController]"; }
1972
+ /** @internal */ get [Symbol.toStringTag]() { return "AbortController"; }
2015
1973
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
2016
1974
  }
2017
- Class_setStringTag(AbortControllerP, "AbortController");
2018
1975
  /** @internal */
2019
1976
  class AbortControllerState {
2020
1977
  constructor() {
@@ -2023,15 +1980,15 @@ class AbortControllerState {
2023
1980
  }
2024
1981
  const AbortControllerE = g["AbortController"] || AbortControllerP;
2025
1982
 
2026
- /** @internal */ const state$4 = Symbol( /* "RequestState" */);
1983
+ /** @internal */ const state$7 = Symbol( /* "RequestState" */);
2027
1984
  class RequestP extends BodyImpl {
2028
1985
  constructor(...args) {
2029
1986
  const [input, init] = args;
2030
1987
  checkArgsLength(args, 1, "Request");
2031
1988
  super();
2032
- this[state$7].name = "Request";
2033
- this[state$4] = new RequestState();
2034
- const s = this[state$4];
1989
+ this[state$a].name = "Request";
1990
+ this[state$7] = new RequestState();
1991
+ const s = this[state$7];
2035
1992
  let _init = init !== null && init !== void 0 ? init : {};
2036
1993
  if (typeof _init !== "object") {
2037
1994
  throw new TypeError("Failed to construct 'Request': The provided value is not of type 'RequestInit'.");
@@ -2048,7 +2005,7 @@ class RequestP extends BodyImpl {
2048
2005
  }
2049
2006
  s.method = input.method;
2050
2007
  s.mode = input.mode;
2051
- let inputSignal = input[state$4].signal;
2008
+ let inputSignal = input[state$7].signal;
2052
2009
  if (inputSignal) {
2053
2010
  s.signal = inputSignal;
2054
2011
  }
@@ -2056,7 +2013,7 @@ class RequestP extends BodyImpl {
2056
2013
  let payload = Body_toPayload(input);
2057
2014
  if (!body && payload !== "") {
2058
2015
  body = payload;
2059
- input[state$7].bodyUsed = true;
2016
+ input[state$a].bodyUsed = true;
2060
2017
  }
2061
2018
  }
2062
2019
  else {
@@ -2100,31 +2057,31 @@ class RequestP extends BodyImpl {
2100
2057
  }
2101
2058
  }
2102
2059
  }
2103
- get cache() { return this[state$4].cache; }
2104
- get credentials() { return this[state$4].credentials; }
2105
- get destination() { return this[state$4].destination; }
2060
+ get cache() { return this[state$7].cache; }
2061
+ get credentials() { return this[state$7].credentials; }
2062
+ get destination() { return this[state$7].destination; }
2106
2063
  get headers() {
2107
- const s = this[state$4];
2064
+ const s = this[state$7];
2108
2065
  if (!s.headers) {
2109
2066
  s.headers = new HeadersP();
2110
2067
  }
2111
2068
  return s.headers;
2112
2069
  }
2113
- get integrity() { return this[state$4].integrity; }
2114
- get keepalive() { return this[state$4].keepalive; }
2115
- get method() { return this[state$4].method; }
2116
- get mode() { return this[state$4].mode; }
2117
- get redirect() { return this[state$4].redirect; }
2118
- get referrer() { return this[state$4].referrer; }
2119
- get referrerPolicy() { return this[state$4].referrerPolicy; }
2070
+ get integrity() { return this[state$7].integrity; }
2071
+ get keepalive() { return this[state$7].keepalive; }
2072
+ get method() { return this[state$7].method; }
2073
+ get mode() { return this[state$7].mode; }
2074
+ get redirect() { return this[state$7].redirect; }
2075
+ get referrer() { return this[state$7].referrer; }
2076
+ get referrerPolicy() { return this[state$7].referrerPolicy; }
2120
2077
  get signal() {
2121
- const s = this[state$4];
2078
+ const s = this[state$7];
2122
2079
  if (!s.signal) {
2123
2080
  s.signal = (new AbortControllerP()).signal;
2124
2081
  }
2125
2082
  return s.signal;
2126
2083
  }
2127
- get url() { return this[state$4].url; }
2084
+ get url() { return this[state$7].url; }
2128
2085
  clone() {
2129
2086
  var _a;
2130
2087
  if (this.bodyUsed) {
@@ -2133,9 +2090,9 @@ class RequestP extends BodyImpl {
2133
2090
  return new RequestP(this, { body: (_a = Body_toPayload(this)) !== null && _a !== void 0 ? _a : null });
2134
2091
  }
2135
2092
  /** @internal */ toString() { return "[object Request]"; }
2093
+ /** @internal */ get [Symbol.toStringTag]() { return "Request"; }
2136
2094
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
2137
2095
  }
2138
- Class_setStringTag(RequestP, "Request");
2139
2096
  /** @internal */
2140
2097
  class RequestState {
2141
2098
  constructor() {
@@ -2162,8 +2119,7 @@ function normalizeMethod(method) {
2162
2119
  const RequestE = g["Request"] || RequestP;
2163
2120
 
2164
2121
  // @ts-nocheck
2165
- /** @internal */
2166
- const mp$2 = (() => {
2122
+ function getPlatform() {
2167
2123
  let u = "undefined", r = "request", f = "function";
2168
2124
  let mp;
2169
2125
  mp =
@@ -2186,9 +2142,11 @@ const mp$2 = (() => {
2186
2142
  (typeof Taro !== u && typeof (Taro === null || Taro === void 0 ? void 0 : Taro[r]) === f && Taro) || // Taro
2187
2143
  undefined;
2188
2144
  return mp;
2189
- })();
2145
+ }
2146
+ /** @internal */
2147
+ const mp$3 = getPlatform();
2190
2148
 
2191
- const request = mp$2 ? mp$2.request : function errorRequest(options) {
2149
+ const request = mp$3 ? mp$3.request : function errorRequest(options) {
2192
2150
  const errMsg = "NOT_SUPPORTED_ERR";
2193
2151
  const errno = 9;
2194
2152
  const err = {
@@ -2215,8 +2173,8 @@ const request = mp$2 ? mp$2.request : function errorRequest(options) {
2215
2173
  throw new ReferenceError("request is not defined");
2216
2174
  };
2217
2175
 
2218
- var _a$1;
2219
- /** @internal */ const state$3 = Symbol( /* "XMLHttpRequestEventTargetState" */);
2176
+ var _a$2;
2177
+ /** @internal */ const state$6 = Symbol( /* "XMLHttpRequestEventTargetState" */);
2220
2178
  class XMLHttpRequestEventTargetP extends EventTargetP {
2221
2179
  /** @internal */
2222
2180
  constructor() {
@@ -2224,35 +2182,35 @@ class XMLHttpRequestEventTargetP extends EventTargetP {
2224
2182
  throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
2225
2183
  }
2226
2184
  super();
2227
- this[state$3] = new XMLHttpRequestEventTargetState(this);
2228
- }
2229
- get onabort() { return this[state$3].onabort; }
2230
- set onabort(value) { this[state$3].onabort = value; attach(this, "abort"); }
2231
- get onerror() { return this[state$3].onerror; }
2232
- set onerror(value) { this[state$3].onerror = value; attach(this, "error"); }
2233
- get onload() { return this[state$3].onload; }
2234
- set onload(value) { this[state$3].onload = value; attach(this, "load"); }
2235
- get onloadend() { return this[state$3].onloadend; }
2236
- set onloadend(value) { this[state$3].onloadend = value; attach(this, "loadend"); }
2237
- get onloadstart() { return this[state$3].onloadstart; }
2238
- set onloadstart(value) { this[state$3].onloadstart = value; attach(this, "loadstart"); }
2239
- get onprogress() { return this[state$3].onprogress; }
2240
- set onprogress(value) { this[state$3].onprogress = value; attach(this, "progress"); }
2241
- get ontimeout() { return this[state$3].ontimeout; }
2242
- set ontimeout(value) { this[state$3].ontimeout = value; attach(this, "timeout"); }
2185
+ this[state$6] = new XMLHttpRequestEventTargetState(this);
2186
+ }
2187
+ get onabort() { return this[state$6].onabort; }
2188
+ set onabort(value) { this[state$6].onabort = value; attach$1(this, "abort"); }
2189
+ get onerror() { return this[state$6].onerror; }
2190
+ set onerror(value) { this[state$6].onerror = value; attach$1(this, "error"); }
2191
+ get onload() { return this[state$6].onload; }
2192
+ set onload(value) { this[state$6].onload = value; attach$1(this, "load"); }
2193
+ get onloadend() { return this[state$6].onloadend; }
2194
+ set onloadend(value) { this[state$6].onloadend = value; attach$1(this, "loadend"); }
2195
+ get onloadstart() { return this[state$6].onloadstart; }
2196
+ set onloadstart(value) { this[state$6].onloadstart = value; attach$1(this, "loadstart"); }
2197
+ get onprogress() { return this[state$6].onprogress; }
2198
+ set onprogress(value) { this[state$6].onprogress = value; attach$1(this, "progress"); }
2199
+ get ontimeout() { return this[state$6].ontimeout; }
2200
+ set ontimeout(value) { this[state$6].ontimeout = value; attach$1(this, "timeout"); }
2243
2201
  /** @internal */ toString() { return "[object XMLHttpRequestEventTarget]"; }
2202
+ /** @internal */ get [Symbol.toStringTag]() { return "XMLHttpRequestEventTarget"; }
2244
2203
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
2245
2204
  }
2246
- Class_setStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
2247
2205
  /** @internal */
2248
- const _handlers$1 = Symbol();
2206
+ const _handlers$2 = Symbol();
2249
2207
  /** @internal */
2250
2208
  class XMLHttpRequestEventTargetState {
2251
2209
  /**
2252
2210
  * @param _target XMLHttpRequestEventTarget
2253
2211
  */
2254
2212
  constructor(_target) {
2255
- this[_a$1] = getHandlers$1(this);
2213
+ this[_a$2] = getHandlers$2(this);
2256
2214
  this.onabort = null;
2257
2215
  this.onerror = null;
2258
2216
  this.onload = null;
@@ -2263,15 +2221,15 @@ class XMLHttpRequestEventTargetState {
2263
2221
  this.target = _target;
2264
2222
  }
2265
2223
  }
2266
- _a$1 = _handlers$1;
2267
- function attach(target, type) {
2268
- const s = target[state$3];
2224
+ _a$2 = _handlers$2;
2225
+ function attach$1(target, type) {
2226
+ const s = target[state$6];
2269
2227
  const fnName = ("on" + type);
2270
2228
  const cb = s[fnName];
2271
- const listener = s[_handlers$1][fnName];
2229
+ const listener = s[_handlers$2][fnName];
2272
2230
  attachFn(target, type, cb, listener);
2273
2231
  }
2274
- function getHandlers$1(s) {
2232
+ function getHandlers$2(s) {
2275
2233
  return {
2276
2234
  onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
2277
2235
  onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
@@ -2282,14 +2240,6 @@ function getHandlers$1(s) {
2282
2240
  ontimeout: (ev) => { executeFn(s.target, s.ontimeout, ev); },
2283
2241
  };
2284
2242
  }
2285
- /** @internal */
2286
- const XHR_properties = {
2287
- UNSENT: { value: 0, enumerable: true },
2288
- OPENED: { value: 1, enumerable: true },
2289
- HEADERS_RECEIVED: { value: 2, enumerable: true },
2290
- LOADING: { value: 3, enumerable: true },
2291
- DONE: { value: 4, enumerable: true },
2292
- };
2293
2243
  const responseTypes = ["", "text", "json", "arraybuffer", "blob", "document"];
2294
2244
  /** @internal */
2295
2245
  function normalizeResponseType(responseType) {
@@ -2372,56 +2322,65 @@ class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
2372
2322
  super();
2373
2323
  }
2374
2324
  /** @internal */ toString() { return "[object XMLHttpRequestUpload]"; }
2325
+ /** @internal */ get [Symbol.toStringTag]() { return "XMLHttpRequestUpload"; }
2375
2326
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
2376
2327
  }
2377
- Class_setStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
2378
2328
  /** @internal */
2379
2329
  function createXMLHttpRequestUpload() {
2380
2330
  let upload = Object.create(XMLHttpRequestUploadP.prototype);
2381
- upload[state$d] = new EventTargetState(upload);
2382
- upload[state$3] = new XMLHttpRequestEventTargetState(upload);
2331
+ upload[state$g] = new EventTargetState(upload);
2332
+ upload[state$6] = new XMLHttpRequestEventTargetState(upload);
2383
2333
  return upload;
2384
2334
  }
2385
2335
 
2386
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2387
- const mp$1 = { request: request };
2388
- const setRequest = (request) => { mp$1.request = request; };
2389
- /** @internal */
2390
- const state$2 = Symbol( /* "XMLHttpRequestState" */);
2336
+ var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k;
2337
+ const mp$2 = { request: request };
2338
+ const setRequest = (request) => { mp$2.request = request; };
2339
+ /** @internal */ const state$5 = Symbol( /* "XMLHttpRequestState" */);
2391
2340
  class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2341
+ static get UNSENT() { return 0; }
2342
+ static get OPENED() { return 1; }
2343
+ static get HEADERS_RECEIVED() { return 2; }
2344
+ static get LOADING() { return 3; }
2345
+ static get DONE() { return 4; }
2392
2346
  constructor() {
2393
2347
  super();
2394
- this[state$2] = new XMLHttpRequestState(this);
2395
- }
2396
- get readyState() { return this[state$2].readyState; }
2397
- get response() { return this[state$2].response; }
2348
+ this[state$5] = new XMLHttpRequestState(this);
2349
+ }
2350
+ get UNSENT() { return 0; }
2351
+ get OPENED() { return 1; }
2352
+ get HEADERS_RECEIVED() { return 2; }
2353
+ get LOADING() { return 3; }
2354
+ get DONE() { return 4; }
2355
+ get readyState() { return this[state$5].readyState; }
2356
+ get response() { return this[state$5].response; }
2398
2357
  get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
2399
- get responseType() { return this[state$2].responseType; }
2400
- set responseType(value) { this[state$2].responseType = normalizeResponseType(value); }
2401
- get responseURL() { return this[state$2].responseURL; }
2358
+ get responseType() { return this[state$5].responseType; }
2359
+ set responseType(value) { this[state$5].responseType = normalizeResponseType(value); }
2360
+ get responseURL() { return this[state$5].responseURL; }
2402
2361
  get responseXML() { return null; }
2403
- get status() { return this[state$2].status; }
2362
+ get status() { return this[state$5].status; }
2404
2363
  get statusText() {
2405
- if (this.readyState === XMLHttpRequestImpl.UNSENT || this.readyState === XMLHttpRequestImpl.OPENED)
2364
+ if (this.readyState === 0 /* UNSENT */ || this.readyState === 1 /* OPENED */)
2406
2365
  return "";
2407
- return this[state$2].statusText || statusTextMap(this.status);
2366
+ return this[state$5].statusText || statusTextMap(this.status);
2408
2367
  }
2409
- get timeout() { return this[state$2].timeout; }
2410
- set timeout(value) { this[state$2].timeout = value > 0 ? value : 0; }
2368
+ get timeout() { return this[state$5].timeout; }
2369
+ set timeout(value) { this[state$5].timeout = value > 0 ? value : 0; }
2411
2370
  get upload() {
2412
- const s = this[state$2];
2371
+ const s = this[state$5];
2413
2372
  if (!s.upload) {
2414
2373
  s.upload = createXMLHttpRequestUpload();
2415
2374
  }
2416
2375
  return s.upload;
2417
2376
  }
2418
- get withCredentials() { return this[state$2].withCredentials; }
2419
- set withCredentials(value) { this[state$2].withCredentials = !!value; }
2377
+ get withCredentials() { return this[state$5].withCredentials; }
2378
+ set withCredentials(value) { this[state$5].withCredentials = !!value; }
2420
2379
  abort() {
2421
2380
  clearRequest(this);
2422
2381
  }
2423
2382
  getAllResponseHeaders() {
2424
- const headers = this[state$2][_responseHeaders];
2383
+ const headers = this[state$5][_responseHeaders];
2425
2384
  if (!headers)
2426
2385
  return "";
2427
2386
  let result = [];
@@ -2431,9 +2390,9 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2431
2390
  getResponseHeader(...args) {
2432
2391
  const [name] = args;
2433
2392
  checkArgsLength(args, 1, "XMLHttpRequest", "getResponseHeader");
2434
- if (!this[state$2][_responseHeaders])
2393
+ if (!this[state$5][_responseHeaders])
2435
2394
  return null;
2436
- return this[state$2][_responseHeaders].get(name);
2395
+ return this[state$5][_responseHeaders].get(name);
2437
2396
  }
2438
2397
  open(...args) {
2439
2398
  const [method, url, async = true, username = null, password = null] = args;
@@ -2441,7 +2400,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2441
2400
  if (!async) {
2442
2401
  console.warn("Synchronous XMLHttpRequest is not supported because of its detrimental effects to the end user's experience.");
2443
2402
  }
2444
- const s = this[state$2];
2403
+ const s = this[state$5];
2445
2404
  clearRequest(this, false);
2446
2405
  s[_method] = normalizeMethod(method);
2447
2406
  s[_requestURL] = "" + url;
@@ -2454,18 +2413,18 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2454
2413
  }
2455
2414
  }
2456
2415
  s[_inAfterOpenBeforeSend] = true;
2457
- setReadyStateAndNotify(this, XMLHttpRequestImpl.OPENED);
2416
+ setReadyStateAndNotify(this, 1 /* OPENED */);
2458
2417
  }
2459
2418
  overrideMimeType(...args) {
2460
2419
  const [mime] = args;
2461
2420
  checkArgsLength(args, 1, "XMLHttpRequest", "overrideMimeType");
2462
- if (this[state$2][_inAfterOpenBeforeSend]) {
2421
+ if (this[state$5][_inAfterOpenBeforeSend]) {
2463
2422
  console.error(`TypeError: Failed to execute 'overrideMimeType' on 'XMLHttpRequest': mimeType ('${mime}') not implemented.`);
2464
2423
  }
2465
2424
  }
2466
2425
  send(body) {
2467
- const s = this[state$2];
2468
- if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED) {
2426
+ const s = this[state$5];
2427
+ if (!s[_inAfterOpenBeforeSend] || s.readyState !== 1 /* OPENED */) {
2469
2428
  throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
2470
2429
  }
2471
2430
  s[_inAfterOpenBeforeSend] = false;
@@ -2497,14 +2456,14 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2497
2456
  };
2498
2457
  // Alipay Mini Program
2499
2458
  options.headers = options.header;
2500
- s[_requestTask] = mp$1.request(options);
2459
+ s[_requestTask] = mp$2.request(options);
2501
2460
  emitProcessEvent(this, "loadstart");
2502
2461
  if (processContentLength && s.upload) {
2503
2462
  emitProcessEvent(this.upload, "loadstart", 0, contentLength);
2504
2463
  }
2505
2464
  setTimeout(() => {
2506
2465
  if (s.upload) {
2507
- const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED;
2466
+ const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !== 1 /* OPENED */;
2508
2467
  const _contentLength = _aborted ? 0 : contentLength;
2509
2468
  if (_aborted) {
2510
2469
  emitProcessEvent(this.upload, "abort");
@@ -2524,27 +2483,29 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2524
2483
  setRequestHeader(...args) {
2525
2484
  const [name, value] = args;
2526
2485
  checkArgsLength(args, 2, "XMLHttpRequest", "setRequestHeader");
2527
- const s = this[state$2];
2528
- if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED) {
2486
+ const s = this[state$5];
2487
+ if (!s[_inAfterOpenBeforeSend] || s.readyState !== 1 /* OPENED */) {
2529
2488
  throw new MPException("Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
2530
2489
  }
2531
- let _name = normalizeName(name, () => {
2532
- throw new SyntaxError(`Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '${name}' is not a valid HTTP header field name.`);
2533
- });
2534
- s[_requestHeaders].append(_name, value);
2490
+ let _name = "" + name;
2491
+ let _value = "" + value;
2492
+ try {
2493
+ s[_requestHeaders].append(_name, _value);
2494
+ }
2495
+ catch (e) {
2496
+ throw new SyntaxError(`Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '${_name}' is not a valid HTTP header field name.`);
2497
+ }
2535
2498
  }
2536
- get onreadystatechange() { return this[state$2].onreadystatechange; }
2499
+ get onreadystatechange() { return this[state$5].onreadystatechange; }
2537
2500
  set onreadystatechange(value) {
2538
- this[state$2].onreadystatechange = value;
2539
- attachFn(this, "readystatechange", value, this[state$2][_handlers].onreadystatechange);
2501
+ this[state$5].onreadystatechange = value;
2502
+ attachFn(this, "readystatechange", value, this[state$5][_handlers$1].onreadystatechange);
2540
2503
  }
2541
2504
  /** @internal */ toString() { return "[object XMLHttpRequest]"; }
2505
+ /** @internal */ get [Symbol.toStringTag]() { return "XMLHttpRequest"; }
2542
2506
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
2543
2507
  }
2544
- Object.defineProperties(XMLHttpRequestImpl, XHR_properties);
2545
- Object.defineProperties(XMLHttpRequestImpl.prototype, XHR_properties);
2546
- Class_setStringTag(XMLHttpRequestImpl, "XMLHttpRequest");
2547
- /** @internal */ const _handlers = Symbol();
2508
+ /** @internal */ const _handlers$1 = Symbol();
2548
2509
  /** @internal */ const _inAfterOpenBeforeSend = Symbol();
2549
2510
  /** @internal */ const _resetPending = Symbol();
2550
2511
  /** @internal */ const _timeoutId = Symbol();
@@ -2557,7 +2518,7 @@ Class_setStringTag(XMLHttpRequestImpl, "XMLHttpRequest");
2557
2518
  /** @internal */
2558
2519
  class XMLHttpRequestState {
2559
2520
  constructor(target) {
2560
- this.readyState = XMLHttpRequestImpl.UNSENT;
2521
+ this.readyState = 0 /* UNSENT */;
2561
2522
  this.response = "";
2562
2523
  this.responseType = "";
2563
2524
  this.responseURL = "";
@@ -2565,9 +2526,9 @@ class XMLHttpRequestState {
2565
2526
  this.statusText = "";
2566
2527
  this.timeout = 0;
2567
2528
  this.withCredentials = false;
2568
- this[_a] = getHandlers(this);
2529
+ this[_a$1] = getHandlers$1(this);
2569
2530
  this.onreadystatechange = null;
2570
- this[_b] = false;
2531
+ this[_b$1] = false;
2571
2532
  this[_c] = false;
2572
2533
  this[_d] = 0;
2573
2534
  this[_e] = "";
@@ -2579,8 +2540,8 @@ class XMLHttpRequestState {
2579
2540
  this.target = target;
2580
2541
  }
2581
2542
  }
2582
- _a = _handlers, _b = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
2583
- function getHandlers(s) {
2543
+ _a$1 = _handlers$1, _b$1 = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
2544
+ function getHandlers$1(s) {
2584
2545
  return {
2585
2546
  onreadystatechange: (ev) => { executeFn(s.target, s.onreadystatechange, ev); },
2586
2547
  };
@@ -2589,15 +2550,15 @@ function normalizeDataType(responseType) {
2589
2550
  return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
2590
2551
  }
2591
2552
  function requestSuccess(res) {
2592
- const s = this[state$2];
2553
+ const s = this[state$5];
2593
2554
  s.responseURL = s[_requestURL];
2594
2555
  s.status = "statusCode" in res ? res.statusCode : "status" in res ? res.status : 200;
2595
- s[_responseHeaders] = new HeadersP(("header" in res ? res.header : "headers" in res ? res.headers : undefined));
2556
+ s[_responseHeaders] = new HeadersP(("header" in res ? res.header : "headers" in res ? res.headers : {}));
2596
2557
  let lengthStr = s[_responseHeaders].get("Content-Length");
2597
2558
  s[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
2598
- if (s.readyState === XMLHttpRequestImpl.OPENED) {
2599
- setReadyStateAndNotify(this, XMLHttpRequestImpl.HEADERS_RECEIVED);
2600
- setReadyStateAndNotify(this, XMLHttpRequestImpl.LOADING);
2559
+ if (s.readyState === 1 /* OPENED */) {
2560
+ setReadyStateAndNotify(this, 2 /* HEADERS_RECEIVED */);
2561
+ setReadyStateAndNotify(this, 3 /* LOADING */);
2601
2562
  setTimeout(() => {
2602
2563
  if (!s[_inAfterOpenBeforeSend]) {
2603
2564
  let l = s[_responseContentLength];
@@ -2626,23 +2587,23 @@ function requestFail(err) {
2626
2587
  requestSuccess.call(this, {
2627
2588
  statusCode: "statusCode" in err ? err.statusCode : err.status || 0,
2628
2589
  header: "header" in err ? err.header : err.headers || {},
2629
- data: "data" in err ? err.data : "",
2590
+ data: "data" in err ? err.data || "" : "",
2630
2591
  });
2631
2592
  return;
2632
2593
  }
2633
- const s = this[state$2];
2594
+ const s = this[state$5];
2634
2595
  s.status = 0;
2635
2596
  s.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
2636
- if (!s[_inAfterOpenBeforeSend] && s.readyState !== XMLHttpRequestImpl.UNSENT && s.readyState !== XMLHttpRequestImpl.DONE) {
2597
+ if (!s[_inAfterOpenBeforeSend] && s.readyState !== 0 /* UNSENT */ && s.readyState !== 4 /* DONE */) {
2637
2598
  emitProcessEvent(this, "error");
2638
2599
  resetRequestTimeout(this);
2639
2600
  }
2640
2601
  }
2641
2602
  function requestComplete() {
2642
- const s = this[state$2];
2603
+ const s = this[state$5];
2643
2604
  s[_requestTask] = null;
2644
- if (!s[_inAfterOpenBeforeSend] && (s.readyState === XMLHttpRequestImpl.OPENED || s.readyState === XMLHttpRequestImpl.LOADING)) {
2645
- setReadyStateAndNotify(this, XMLHttpRequestImpl.DONE);
2605
+ if (!s[_inAfterOpenBeforeSend] && (s.readyState === 1 /* OPENED */ || s.readyState === 3 /* LOADING */)) {
2606
+ setReadyStateAndNotify(this, 4 /* DONE */);
2646
2607
  }
2647
2608
  setTimeout(() => {
2648
2609
  if (!s[_inAfterOpenBeforeSend]) {
@@ -2658,12 +2619,12 @@ function safeAbort(task) {
2658
2619
  }
2659
2620
  }
2660
2621
  function clearRequest(xhr, delay = true) {
2661
- const s = xhr[state$2];
2622
+ const s = xhr[state$5];
2662
2623
  const timerFn = delay ? setTimeout : (f) => { f(); };
2663
2624
  s[_resetPending] = true;
2664
- if (s[_requestTask] && s.readyState !== XMLHttpRequestImpl.DONE) {
2625
+ if (s[_requestTask] && s.readyState !== 4 /* DONE */) {
2665
2626
  if (delay) {
2666
- setReadyStateAndNotify(xhr, XMLHttpRequestImpl.DONE);
2627
+ setReadyStateAndNotify(xhr, 4 /* DONE */);
2667
2628
  }
2668
2629
  timerFn(() => {
2669
2630
  const requestTask = s[_requestTask];
@@ -2681,27 +2642,27 @@ function clearRequest(xhr, delay = true) {
2681
2642
  timerFn(() => {
2682
2643
  if (s[_resetPending]) {
2683
2644
  if (delay) {
2684
- s.readyState = XMLHttpRequestImpl.UNSENT;
2645
+ s.readyState = 0 /* UNSENT */;
2685
2646
  }
2686
2647
  resetXHR(xhr);
2687
2648
  }
2688
2649
  });
2689
2650
  }
2690
2651
  function checkRequestTimeout(xhr) {
2691
- const s = xhr[state$2];
2652
+ const s = xhr[state$5];
2692
2653
  if (s.timeout) {
2693
2654
  s[_timeoutId] = setTimeout(() => {
2694
- if (!s.status && s.readyState !== XMLHttpRequestImpl.DONE) {
2655
+ if (!s.status && s.readyState !== 4 /* DONE */) {
2695
2656
  if (s[_requestTask])
2696
2657
  safeAbort(s[_requestTask]);
2697
- setReadyStateAndNotify(xhr, XMLHttpRequestImpl.DONE);
2658
+ setReadyStateAndNotify(xhr, 4 /* DONE */);
2698
2659
  emitProcessEvent(xhr, "timeout");
2699
2660
  }
2700
2661
  }, s.timeout);
2701
2662
  }
2702
2663
  }
2703
2664
  function resetXHR(xhr) {
2704
- const s = xhr[state$2];
2665
+ const s = xhr[state$5];
2705
2666
  s[_resetPending] = false;
2706
2667
  resetRequestTimeout(xhr);
2707
2668
  s.response = "";
@@ -2713,14 +2674,14 @@ function resetXHR(xhr) {
2713
2674
  s[_responseContentLength] = () => 0;
2714
2675
  }
2715
2676
  function resetRequestTimeout(xhr) {
2716
- const s = xhr[state$2];
2677
+ const s = xhr[state$5];
2717
2678
  if (s[_timeoutId]) {
2718
2679
  clearTimeout(s[_timeoutId]);
2719
2680
  s[_timeoutId] = 0;
2720
2681
  }
2721
2682
  }
2722
2683
  function setReadyStateAndNotify(xhr, value) {
2723
- const s = xhr[state$2];
2684
+ const s = xhr[state$5];
2724
2685
  let hasChanged = value !== s.readyState;
2725
2686
  s.readyState = value;
2726
2687
  if (hasChanged) {
@@ -2732,13 +2693,13 @@ function setReadyStateAndNotify(xhr, value) {
2732
2693
  const XMLHttpRequestP = XMLHttpRequestImpl;
2733
2694
  const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
2734
2695
 
2735
- /** @internal */ const state$1 = Symbol( /* "ResponseState" */);
2696
+ /** @internal */ const state$4 = Symbol( /* "ResponseState" */);
2736
2697
  class ResponseP extends BodyImpl {
2737
2698
  constructor(body, init) {
2738
2699
  super();
2739
- this[state$7].name = "Response";
2740
- this[state$1] = new ResponseState();
2741
- const s = this[state$1];
2700
+ this[state$a].name = "Response";
2701
+ this[state$4] = new ResponseState();
2702
+ const s = this[state$4];
2742
2703
  let _init = init !== null && init !== void 0 ? init : {};
2743
2704
  if (typeof _init !== "object") {
2744
2705
  throw new TypeError("Failed to construct 'Response': The provided value is not of type 'ResponseInit'.");
@@ -2756,18 +2717,18 @@ class ResponseP extends BodyImpl {
2756
2717
  Body_init(this, body);
2757
2718
  }
2758
2719
  get headers() {
2759
- const s = this[state$1];
2720
+ const s = this[state$4];
2760
2721
  if (!s.headers) {
2761
2722
  s.headers = new HeadersP();
2762
2723
  }
2763
2724
  return s.headers;
2764
2725
  }
2765
- get ok() { return this[state$1].ok; }
2766
- get redirected() { return this[state$1].redirected; }
2767
- get status() { return this[state$1].status; }
2768
- get statusText() { return this[state$1].statusText; }
2769
- get type() { return this[state$1].type; }
2770
- get url() { return this[state$1].url; }
2726
+ get ok() { return this[state$4].ok; }
2727
+ get redirected() { return this[state$4].redirected; }
2728
+ get status() { return this[state$4].status; }
2729
+ get statusText() { return this[state$4].statusText; }
2730
+ get type() { return this[state$4].type; }
2731
+ get url() { return this[state$4].url; }
2771
2732
  clone() {
2772
2733
  if (this.bodyUsed) {
2773
2734
  throw new TypeError("Failed to execute 'clone' on 'Response': Response body is already used");
@@ -2777,7 +2738,7 @@ class ResponseP extends BodyImpl {
2777
2738
  status: this.status,
2778
2739
  statusText: this.statusText,
2779
2740
  });
2780
- response[state$1].url = this.url;
2741
+ response[state$4].url = this.url;
2781
2742
  return response;
2782
2743
  }
2783
2744
  static json(...args) {
@@ -2789,9 +2750,9 @@ class ResponseP extends BodyImpl {
2789
2750
  }
2790
2751
  static error() {
2791
2752
  let response = new ResponseP(null, { status: 200, statusText: "" });
2792
- response[state$1].ok = false;
2793
- response[state$1].status = 0;
2794
- response[state$1].type = "error";
2753
+ response[state$4].ok = false;
2754
+ response[state$4].status = 0;
2755
+ response[state$4].type = "error";
2795
2756
  return response;
2796
2757
  }
2797
2758
  static redirect(...args) {
@@ -2803,9 +2764,9 @@ class ResponseP extends BodyImpl {
2803
2764
  return new ResponseP(null, { status, headers: { location: "" + url } });
2804
2765
  }
2805
2766
  /** @internal */ toString() { return "[object Response]"; }
2767
+ /** @internal */ get [Symbol.toStringTag]() { return "Response"; }
2806
2768
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
2807
2769
  }
2808
- Class_setStringTag(ResponseP, "Response");
2809
2770
  /** @internal */
2810
2771
  class ResponseState {
2811
2772
  constructor() {
@@ -2819,8 +2780,8 @@ class ResponseState {
2819
2780
  }
2820
2781
  const ResponseE = g["Response"] || ResponseP;
2821
2782
 
2822
- const mp = { XMLHttpRequest: XMLHttpRequestE };
2823
- const setXMLHttpRequest = (XHR) => { mp.XMLHttpRequest = XHR; };
2783
+ const mp$1 = { XMLHttpRequest: XMLHttpRequestE };
2784
+ const setXMLHttpRequest = (XHR) => { mp$1.XMLHttpRequest = XHR; };
2824
2785
  function fetchP(...args) {
2825
2786
  if (new.target === fetchP) {
2826
2787
  throw new TypeError("fetch is not a constructor");
@@ -2829,11 +2790,11 @@ function fetchP(...args) {
2829
2790
  checkArgsLength(args, 1, "Window", "fetch");
2830
2791
  return new Promise((resolve, reject) => {
2831
2792
  const request = new RequestP(input, init);
2832
- const signal = request[state$4].signal;
2793
+ const signal = request[state$7].signal;
2833
2794
  if (signal && signal.aborted) {
2834
2795
  return reject(signal.reason);
2835
2796
  }
2836
- let xhr = new mp.XMLHttpRequest();
2797
+ let xhr = new mp$1.XMLHttpRequest();
2837
2798
  xhr.onload = function () {
2838
2799
  let options = {
2839
2800
  headers: parseHeaders(xhr.getAllResponseHeaders() || ""),
@@ -2847,7 +2808,7 @@ function fetchP(...args) {
2847
2808
  }
2848
2809
  setTimeout(() => {
2849
2810
  let response = new ResponseP("response" in xhr ? xhr.response : xhr.responseText, options);
2850
- response[state$1].url = "responseURL" in xhr ? xhr.responseURL : (options.headers.get("X-Request-URL") || "");
2811
+ response[state$4].url = "responseURL" in xhr ? xhr.responseURL : (options.headers.get("X-Request-URL") || "");
2851
2812
  resolve(response);
2852
2813
  });
2853
2814
  };
@@ -2876,7 +2837,7 @@ function fetchP(...args) {
2876
2837
  if ("responseType" in xhr) {
2877
2838
  xhr.responseType = "arraybuffer";
2878
2839
  }
2879
- if (init && typeof init === "object" && typeof init.headers === "object" && !isObjectType("Headers", init.headers)) {
2840
+ if (init && typeof init === "object" && typeof init.headers === "object" && !(isObjectType("Headers", init.headers) || isPolyfillType("Headers", init.headers))) {
2880
2841
  let headers = init.headers;
2881
2842
  let names = [];
2882
2843
  Object.getOwnPropertyNames(headers).forEach(name => {
@@ -2898,8 +2859,8 @@ function fetchP(...args) {
2898
2859
  const abortXHR = () => { xhr.abort(); };
2899
2860
  signal.addEventListener("abort", abortXHR);
2900
2861
  xhr.onreadystatechange = function () {
2901
- // DONE (success or failure)
2902
- if (xhr.readyState === 4) {
2862
+ // success or failure
2863
+ if (xhr.readyState === 4 /* DONE */) {
2903
2864
  signal.removeEventListener("abort", abortXHR);
2904
2865
  }
2905
2866
  };
@@ -2910,34 +2871,346 @@ function fetchP(...args) {
2910
2871
  }
2911
2872
  const fetchE = g["fetch"] || fetchP;
2912
2873
 
2913
- const dispatched = 1;
2874
+ const dispatched$1 = 1;
2914
2875
  /** @internal */
2915
- const state = Symbol( /* "CustomEventState" */);
2876
+ const state$3 = Symbol( /* "CustomEventState" */);
2916
2877
  class CustomEventP extends EventP {
2917
2878
  constructor(type, eventInitDict) {
2918
2879
  var _a;
2919
2880
  super(type, eventInitDict);
2920
- this[state] = new CustomEventState();
2921
- this[state].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
2881
+ this[state$3] = new CustomEventState();
2882
+ this[state$3].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
2922
2883
  }
2923
- get detail() { return this[state].detail; }
2884
+ get detail() { return this[state$3].detail; }
2924
2885
  initCustomEvent(...args) {
2925
2886
  const [type, bubbles, cancelable, detail] = args;
2926
2887
  checkArgsLength(args, 1, "CustomEvent", "initCustomEvent");
2927
- if (Event_getEtField(this, dispatched))
2888
+ if (Event_getEtField(this, dispatched$1))
2928
2889
  return;
2929
2890
  this.initEvent(type, bubbles, cancelable);
2930
- this[state].detail = detail !== null && detail !== void 0 ? detail : null;
2891
+ this[state$3].detail = detail !== null && detail !== void 0 ? detail : null;
2931
2892
  }
2932
2893
  /** @internal */ toString() { return "[object CustomEvent]"; }
2894
+ /** @internal */ get [Symbol.toStringTag]() { return "CustomEvent"; }
2933
2895
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
2934
2896
  }
2935
- Class_setStringTag(CustomEventP, "CustomEvent");
2936
2897
  /** @internal */
2937
2898
  class CustomEventState {
2938
2899
  }
2939
2900
  const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
2940
2901
 
2902
+ /** @internal */
2903
+ const state$2 = Symbol( /* "CloseEventState" */);
2904
+ class CloseEventP extends EventP {
2905
+ constructor(type, eventInitDict) {
2906
+ var _a;
2907
+ super(type, eventInitDict);
2908
+ this[state$2] = new CloseEventState();
2909
+ const s = this[state$2];
2910
+ let _code = Number((_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.code) !== null && _a !== void 0 ? _a : 0);
2911
+ s.code = isNaN(_code) ? 0 : _code;
2912
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.reason) !== undefined)
2913
+ s.reason = "" + eventInitDict.reason;
2914
+ s.wasClean = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.wasClean);
2915
+ }
2916
+ get code() { return this[state$2].code; }
2917
+ get reason() { return this[state$2].reason; }
2918
+ get wasClean() { return this[state$2].wasClean; }
2919
+ /** @internal */ toString() { return "[object CloseEvent]"; }
2920
+ /** @internal */ get [Symbol.toStringTag]() { return "CloseEvent"; }
2921
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CloseEvent", "Event"] }; }
2922
+ }
2923
+ /** @internal */
2924
+ class CloseEventState {
2925
+ constructor() {
2926
+ this.code = 0;
2927
+ this.reason = "";
2928
+ this.wasClean = false;
2929
+ }
2930
+ }
2931
+ g["EventTarget"] ? g["CloseEvent"] : CloseEventP;
2932
+
2933
+ const dispatched = 1;
2934
+ /** @internal */
2935
+ const state$1 = Symbol( /* "MessageEventState" */);
2936
+ class MessageEventP extends EventP {
2937
+ constructor(type, eventInitDict) {
2938
+ var _a;
2939
+ super(type, eventInitDict);
2940
+ this[state$1] = new MessageEventState();
2941
+ const s = this[state$1];
2942
+ s.data = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.data) !== null && _a !== void 0 ? _a : null;
2943
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.origin) !== undefined)
2944
+ s.origin = "" + eventInitDict.origin;
2945
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lastEventId) !== undefined)
2946
+ s.lastEventId = "" + eventInitDict.lastEventId;
2947
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.source) !== undefined)
2948
+ s.source = eventInitDict.source;
2949
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.ports) !== undefined)
2950
+ s.ports = eventInitDict.ports;
2951
+ }
2952
+ get data() { return this[state$1].data; }
2953
+ get lastEventId() { return this[state$1].lastEventId; }
2954
+ get origin() { return this[state$1].origin; }
2955
+ get ports() { return this[state$1].ports; }
2956
+ get source() { return this[state$1].source; }
2957
+ initMessageEvent(...args) {
2958
+ const [type, bubbles, cancelable, data, origin, lastEventId, source, ports] = args;
2959
+ checkArgsLength(args, 1, "MessageEvent", "initMessageEvent");
2960
+ if (Event_getEtField(this, dispatched))
2961
+ return;
2962
+ this.initEvent(type, bubbles, cancelable);
2963
+ const s = this[state$1];
2964
+ s.data = data !== null && data !== void 0 ? data : null;
2965
+ if (origin !== undefined)
2966
+ s.origin = "" + origin;
2967
+ if (lastEventId !== undefined)
2968
+ s.lastEventId = "" + lastEventId;
2969
+ if (source !== undefined)
2970
+ s.source = source;
2971
+ if (ports !== undefined)
2972
+ s.ports = ports;
2973
+ }
2974
+ /** @internal */ toString() { return "[object MessageEvent]"; }
2975
+ /** @internal */ get [Symbol.toStringTag]() { return "MessageEvent"; }
2976
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["MessageEvent", "Event"] }; }
2977
+ }
2978
+ /** @internal */
2979
+ class MessageEventState {
2980
+ constructor() {
2981
+ this.data = null;
2982
+ this.lastEventId = "";
2983
+ this.origin = "";
2984
+ this.ports = [];
2985
+ this.source = null;
2986
+ }
2987
+ }
2988
+ g["EventTarget"] ? g["MessageEvent"] : MessageEventP;
2989
+
2990
+ const connectSocket = mp$3 ? mp$3.connectSocket : function errorConnectSocket(options) {
2991
+ return {
2992
+ send(obj) { },
2993
+ close(obj) { },
2994
+ onOpen(listener) { },
2995
+ onMessage(listener) { },
2996
+ onError(listener) {
2997
+ if (typeof listener === "function") {
2998
+ listener({ errMsg: "NOT_SUPPORTED_ERR" });
2999
+ }
3000
+ },
3001
+ onClose(listener) {
3002
+ if (typeof listener === "function") {
3003
+ setTimeout(() => { listener({ code: 3009, reason: "NOT_SUPPORTED_ERR" }); });
3004
+ }
3005
+ },
3006
+ };
3007
+ };
3008
+
3009
+ var _a, _b;
3010
+ const mp = { connectSocket: connectSocket };
3011
+ const setConnectSocket = (connectSocket) => { mp.connectSocket = connectSocket; };
3012
+ /** @internal */
3013
+ const state = Symbol( /* "WebSocketState" */);
3014
+ class WebSocketImpl extends EventTargetP {
3015
+ static get CONNECTING() { return 0; }
3016
+ static get OPEN() { return 1; }
3017
+ static get CLOSING() { return 2; }
3018
+ static get CLOSED() { return 3; }
3019
+ constructor(...args) {
3020
+ const [url, protocols] = args;
3021
+ checkArgsLength(args, 1, "WebSocket");
3022
+ super();
3023
+ this[state] = new WebSocketState(this, {
3024
+ url: "" + url,
3025
+ protocols: protocols !== undefined
3026
+ ? (Array.isArray(protocols) || (protocols && typeof protocols === "object" && Symbol.iterator in protocols))
3027
+ ? Array.isArray(protocols) ? protocols : Array.from(protocols)
3028
+ : ["" + protocols]
3029
+ : [],
3030
+ multiple: true, // Alipay Mini Program
3031
+ fail(err) { console.error(err); },
3032
+ });
3033
+ let socketTask = this[state][_socketTask];
3034
+ if (socketTask && typeof socketTask === "object") {
3035
+ onOpen(this);
3036
+ onClose(this);
3037
+ onError(this);
3038
+ onMessage(this);
3039
+ }
3040
+ else {
3041
+ throw new Error(`connectSocket can't establish a connection to the server at ${"" + url}.`);
3042
+ }
3043
+ }
3044
+ get CONNECTING() { return 0; }
3045
+ get OPEN() { return 1; }
3046
+ get CLOSING() { return 2; }
3047
+ get CLOSED() { return 3; }
3048
+ get binaryType() { return this[state].binaryType; }
3049
+ set binaryType(value) { if (value === "blob" || value === "arraybuffer") {
3050
+ this[state].binaryType = value;
3051
+ } }
3052
+ get bufferedAmount() { return this[state].bufferedAmount; }
3053
+ get extensions() { return this[state].extensions; }
3054
+ get protocol() { return this[state].protocol; }
3055
+ get readyState() { return this[state].readyState; }
3056
+ get url() { return this[state].url; }
3057
+ close(code, reason) {
3058
+ if (this.readyState === 2 /* CLOSING */ || this.readyState === 3 /* CLOSED */)
3059
+ return;
3060
+ this[state].readyState = 2 /* CLOSING */;
3061
+ this[state][_socketTask].close({
3062
+ code: code,
3063
+ reason: reason,
3064
+ fail(err) { console.error(err); },
3065
+ complete: (function () {
3066
+ this[state].readyState = 3 /* CLOSED */;
3067
+ }).bind(this),
3068
+ });
3069
+ }
3070
+ send(...args) {
3071
+ const [data] = args;
3072
+ checkArgsLength(args, 1, "WebSocket", "send");
3073
+ if (this.readyState === 0 /* CONNECTING */) {
3074
+ throw new MPException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.", "InvalidStateError");
3075
+ }
3076
+ if (this.readyState === 2 /* CLOSING */ || this.readyState === 3 /* CLOSED */) {
3077
+ return console.error("WebSocket is already in CLOSING or CLOSED state.");
3078
+ }
3079
+ let _data;
3080
+ if (isArrayBuffer(data)) {
3081
+ _data = data;
3082
+ }
3083
+ else if (ArrayBuffer.isView(data)) {
3084
+ _data = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
3085
+ }
3086
+ else if (isPolyfillType("Blob", data)) {
3087
+ _data = Blob_toUint8Array(data).buffer.slice(0);
3088
+ }
3089
+ else {
3090
+ _data = "" + data;
3091
+ }
3092
+ this[state][_socketTask].send({
3093
+ data: _data,
3094
+ fail(err) { console.error(err); },
3095
+ });
3096
+ }
3097
+ get onclose() { return this[state].onclose; }
3098
+ set onclose(value) { this[state].onclose = value; attach(this, "close"); }
3099
+ get onerror() { return this[state].onerror; }
3100
+ set onerror(value) { this[state].onerror = value; attach(this, "error"); }
3101
+ get onmessage() { return this[state].onmessage; }
3102
+ set onmessage(value) { this[state].onmessage = value; attach(this, "message"); }
3103
+ get onopen() { return this[state].onopen; }
3104
+ set onopen(value) { this[state].onopen = value; attach(this, "open"); }
3105
+ /** @internal */ toString() { return "[object WebSocket]"; }
3106
+ /** @internal */ get [Symbol.toStringTag]() { return "WebSocket"; }
3107
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["WebSocket", "EventTarget"] }; }
3108
+ }
3109
+ /** @internal */ const _socketTask = Symbol();
3110
+ /** @internal */ const _error = Symbol();
3111
+ /** @internal */ const _handlers = Symbol();
3112
+ /** @internal */
3113
+ class WebSocketState {
3114
+ constructor(target, opts) {
3115
+ this.binaryType = "blob";
3116
+ this.bufferedAmount = 0;
3117
+ this.extensions = "";
3118
+ this.protocol = "";
3119
+ this.readyState = 0;
3120
+ this[_a] = null;
3121
+ this[_b] = getHandlers(this);
3122
+ this.onclose = null;
3123
+ this.onerror = null;
3124
+ this.onmessage = null;
3125
+ this.onopen = null;
3126
+ this.target = target;
3127
+ this.url = opts.url;
3128
+ this[_socketTask] = mp.connectSocket(opts);
3129
+ }
3130
+ }
3131
+ _a = _error, _b = _handlers;
3132
+ function attach(target, type) {
3133
+ const s = target[state];
3134
+ const fnName = ("on" + type);
3135
+ const cb = s[fnName];
3136
+ const listener = s[_handlers][fnName];
3137
+ attachFn(target, type, cb, listener);
3138
+ }
3139
+ function getHandlers(s) {
3140
+ return {
3141
+ onclose: (ev) => { executeFn(s.target, s.onclose, ev); },
3142
+ onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
3143
+ onmessage: (ev) => { executeFn(s.target, s.onmessage, ev); },
3144
+ onopen: (ev) => { executeFn(s.target, s.onopen, ev); },
3145
+ };
3146
+ }
3147
+ function onOpen(ws) {
3148
+ let socket = ws;
3149
+ socket[state][_socketTask].onOpen(res => {
3150
+ if ("header" in res && res.header && typeof res.header === "object") {
3151
+ let headers = new HeadersP(res.header);
3152
+ socket[state].protocol = headers.get("Sec-WebSocket-Protocol") || "";
3153
+ }
3154
+ socket[state].readyState = 1 /* OPEN */;
3155
+ EventTarget_fire(socket, createInnerEvent(socket, "open"));
3156
+ });
3157
+ }
3158
+ function onClose(ws) {
3159
+ let socket = ws;
3160
+ socket[state][_socketTask].onClose(res => {
3161
+ socket[state].readyState = 3 /* CLOSED */;
3162
+ let event = new CloseEventP("close", {
3163
+ wasClean: !socket[state][_error],
3164
+ code: res.code,
3165
+ reason: res.reason,
3166
+ });
3167
+ Event_setTrusted(event, true);
3168
+ EventTarget_fire(socket, event);
3169
+ });
3170
+ }
3171
+ function onError(ws) {
3172
+ let socket = ws;
3173
+ socket[state][_socketTask].onError(res => {
3174
+ console.error(res);
3175
+ socket[state][_error] = res;
3176
+ socket[state].readyState = 3 /* CLOSED */;
3177
+ EventTarget_fire(socket, createInnerEvent(socket, "error"));
3178
+ });
3179
+ }
3180
+ function onMessage(ws) {
3181
+ let socket = ws;
3182
+ socket[state][_socketTask].onMessage(res => {
3183
+ let data = res.data;
3184
+ let _data;
3185
+ // Alipay Mini Program
3186
+ if (data && typeof data === "object" && "data" in data) {
3187
+ _data = data.data;
3188
+ if ("isBuffer" in data && data.isBuffer && typeof _data === "string") {
3189
+ // @ts-ignore
3190
+ try {
3191
+ _data = my.base64ToArrayBuffer(_data);
3192
+ }
3193
+ catch (e) { }
3194
+ }
3195
+ }
3196
+ else {
3197
+ _data = data;
3198
+ }
3199
+ if (isArrayBuffer(_data) && socket.binaryType === "blob") {
3200
+ _data = new BlobP([_data]);
3201
+ }
3202
+ let event = new MessageEventP("message", {
3203
+ data: _data,
3204
+ origin: socket.url,
3205
+ });
3206
+ Event_setTrusted(event, true);
3207
+ EventTarget_fire(socket, event);
3208
+ });
3209
+ }
3210
+
3211
+ const WebSocketP = WebSocketImpl;
3212
+ const WebSocketE = (typeof WebSocket !== "undefined" && WebSocket) || WebSocketP;
3213
+
2941
3214
  exports.AbortController = AbortControllerE;
2942
3215
  exports.AbortControllerP = AbortControllerP;
2943
3216
  exports.AbortSignal = AbortSignalE;
@@ -2958,8 +3231,6 @@ exports.FormData = FormDataE;
2958
3231
  exports.FormDataP = FormDataP;
2959
3232
  exports.Headers = HeadersE;
2960
3233
  exports.HeadersP = HeadersP;
2961
- exports.ProgressEvent = ProgressEventE;
2962
- exports.ProgressEventP = ProgressEventP;
2963
3234
  exports.Request = RequestE;
2964
3235
  exports.RequestP = RequestP;
2965
3236
  exports.Response = ResponseE;
@@ -2970,9 +3241,12 @@ exports.TextEncoder = TextEncoderE;
2970
3241
  exports.TextEncoderP = TextEncoderP;
2971
3242
  exports.URLSearchParams = URLSearchParamsE;
2972
3243
  exports.URLSearchParamsP = URLSearchParamsP;
3244
+ exports.WebSocket = WebSocketE;
3245
+ exports.WebSocketP = WebSocketP;
2973
3246
  exports.XMLHttpRequest = XMLHttpRequestE;
2974
3247
  exports.XMLHttpRequestP = XMLHttpRequestP;
2975
3248
  exports.fetch = fetchE;
2976
3249
  exports.fetchP = fetchP;
3250
+ exports.setConnectSocket = setConnectSocket;
2977
3251
  exports.setRequest = setRequest;
2978
3252
  exports.setXMLHttpRequest = setXMLHttpRequest;