mphttpx 1.0.3 → 1.0.5

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.esm.js CHANGED
@@ -46,7 +46,7 @@ class TextEncoderP {
46
46
  return encodeText(input).encoded;
47
47
  }
48
48
  encodeInto(source, destination) {
49
- const result = encodeText(source, destination);
49
+ let result = encodeText(source, destination);
50
50
  return { read: result.read, written: result.written };
51
51
  }
52
52
  toString() { return "[object TextEncoder]"; }
@@ -140,6 +140,7 @@ function encodeText(input, destination) {
140
140
  const TextEncoderE = g["TextEncoder"] || TextEncoderP;
141
141
 
142
142
  var _a$a, _b$3;
143
+ /** @internal */
143
144
  const state$h = Symbol( /* "TextDecoderState" */);
144
145
  class TextDecoderP {
145
146
  constructor(utfLabel = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
@@ -283,8 +284,9 @@ class TextDecoderP {
283
284
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
284
285
  }
285
286
  defineStringTag(TextDecoderP, "TextDecoder");
286
- const _bomSeen = Symbol();
287
- const _partial = Symbol();
287
+ /** @internal */ const _bomSeen = Symbol();
288
+ /** @internal */ const _partial = Symbol();
289
+ /** @internal */
288
290
  class TextDecoderState {
289
291
  constructor() {
290
292
  this.fatal = false;
@@ -301,19 +303,20 @@ function getBytesPerSequence(byte) {
301
303
  const TextDecoderE = g["TextDecoder"] || TextDecoderP;
302
304
 
303
305
  var _a$9, _b$2, _c$1, _d$1, _e$1, _f$1;
306
+ /** @internal */
304
307
  const state$g = Symbol( /* "EventState" */);
305
308
  class EventP {
306
309
  constructor(type, eventInitDict) {
307
- this.NONE = EventP.NONE;
308
- this.CAPTURING_PHASE = EventP.CAPTURING_PHASE;
309
- this.AT_TARGET = EventP.AT_TARGET;
310
- this.BUBBLING_PHASE = EventP.BUBBLING_PHASE;
311
310
  this[state$g] = new EventState();
312
311
  const that = this[state$g];
313
312
  that.type = String(type);
314
313
  that.bubbles = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.bubbles);
315
314
  that.cancelable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.cancelable);
316
315
  that.composed = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.composed);
316
+ Object.defineProperty(this, "isTrusted", {
317
+ enumerable: true,
318
+ get: (function isTrusted() { return this[state$g][_isTrusted]; }).bind(this),
319
+ });
317
320
  }
318
321
  get type() { return this[state$g].type; }
319
322
  get bubbles() { return this[state$g].bubbles; }
@@ -330,10 +333,9 @@ class EventP {
330
333
  set returnValue(value) { if (!value) {
331
334
  this.preventDefault();
332
335
  } }
333
- get isTrusted() { return this[state$g][_isTrusted]; }
334
336
  get timeStamp() { return this[state$g].timeStamp; }
335
337
  composedPath() {
336
- const path = !!this.target ? [this.target] : [];
338
+ let path = !!this.target ? [this.target] : [];
337
339
  if (!!this.currentTarget && this.currentTarget !== this.target)
338
340
  path.push(this.currentTarget);
339
341
  return path;
@@ -368,17 +370,22 @@ class EventP {
368
370
  toString() { return "[object Event]"; }
369
371
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
370
372
  }
371
- EventP.NONE = 0;
372
- EventP.CAPTURING_PHASE = 1;
373
- EventP.AT_TARGET = 2;
374
- EventP.BUBBLING_PHASE = 3;
373
+ const properties$2 = {
374
+ NONE: { value: 0, enumerable: true },
375
+ CAPTURING_PHASE: { value: 1, enumerable: true },
376
+ AT_TARGET: { value: 2, enumerable: true },
377
+ BUBBLING_PHASE: { value: 3, enumerable: true },
378
+ };
379
+ Object.defineProperties(EventP, properties$2);
380
+ Object.defineProperties(EventP.prototype, properties$2);
375
381
  defineStringTag(EventP, "Event");
376
- const _TimeStamp = Symbol();
382
+ /** @internal */ const _TimeStamp = Symbol();
377
383
  const _isTrusted = Symbol();
378
384
  const _passive = Symbol();
379
385
  const _dispatched = Symbol();
380
386
  const _preventDefaultCalled = Symbol();
381
387
  const _stopImmediatePropagationCalled = Symbol();
388
+ /** @internal */
382
389
  class EventState {
383
390
  constructor() {
384
391
  this.type = "";
@@ -402,7 +409,7 @@ class EventState {
402
409
  _a$9 = _TimeStamp, _b$2 = _isTrusted, _c$1 = _passive, _d$1 = _dispatched, _e$1 = _preventDefaultCalled, _f$1 = _stopImmediatePropagationCalled;
403
410
  EventState[_a$9] = (new Date()).getTime();
404
411
  function createInnerEvent(target, type, eventInitDict, isTrusted = true) {
405
- const event = new EventP(type, eventInitDict);
412
+ let event = new EventP(type, eventInitDict);
406
413
  event[state$g].target = target;
407
414
  event[state$g][_isTrusted] = isTrusted;
408
415
  return event;
@@ -410,6 +417,7 @@ function createInnerEvent(target, type, eventInitDict, isTrusted = true) {
410
417
  const EventE = g["EventTarget"] ? g["Event"] : EventP;
411
418
 
412
419
  var _a$8;
420
+ /** @internal */
413
421
  const state$f = Symbol( /* "EventTargetState" */);
414
422
  class EventTargetP {
415
423
  constructor() {
@@ -441,9 +449,8 @@ class EventTargetP {
441
449
  if (!(event instanceof EventP)) {
442
450
  throw new TypeError("EventTarget.dispatchEvent: Argument 1 does not implement interface Event.");
443
451
  }
444
- const s = event[state$g];
445
- s.target = this;
446
- s[_isTrusted] = false;
452
+ event[state$g].target = this;
453
+ Object.defineProperty(event[state$g], _isTrusted, { value: false, configurable: true, enumerable: true, writable: true });
447
454
  return fire.call(this[state$f], event);
448
455
  }
449
456
  removeEventListener(type, callback, options) {
@@ -458,7 +465,9 @@ class EventTargetP {
458
465
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
459
466
  }
460
467
  defineStringTag(EventTargetP, "EventTarget");
468
+ /** @internal */
461
469
  const _executors = Symbol();
470
+ /** @internal */
462
471
  class EventTargetState {
463
472
  constructor(target) {
464
473
  this[_a$8] = [];
@@ -473,15 +482,15 @@ function fire(event) {
473
482
  s.currentTarget = this.target;
474
483
  s.eventPhase = EventP.AT_TARGET;
475
484
  s[_dispatched] = true;
476
- const onceIndexes = [];
485
+ let onceIndexes = [];
477
486
  for (let i = 0; i < this[_executors].length; ++i) {
478
- const executor = this[_executors][i];
487
+ let executor = this[_executors][i];
479
488
  if (executor.type !== event.type)
480
489
  continue;
481
490
  s[_passive] = !!executor.options.passive;
482
491
  if (executor.options.once)
483
492
  onceIndexes.push(i);
484
- const { callback: cb } = executor;
493
+ let { callback: cb } = executor;
485
494
  try {
486
495
  if (typeof cb === "function")
487
496
  cb.call(this.target, event);
@@ -517,6 +526,7 @@ function reply(signal, executor) {
517
526
  console.error(e);
518
527
  }
519
528
  }
529
+ /** @internal */
520
530
  class Executor {
521
531
  constructor(type, callback) {
522
532
  this.options = {};
@@ -556,6 +566,7 @@ function executeFn(cb, ev) {
556
566
  }
557
567
  const EventTargetE = g["EventTarget"] || EventTargetP;
558
568
 
569
+ /** @internal */
559
570
  const state$e = Symbol( /* "CustomEventState" */);
560
571
  class CustomEventP extends EventP {
561
572
  constructor(type, eventInitDict) {
@@ -575,10 +586,12 @@ class CustomEventP extends EventP {
575
586
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
576
587
  }
577
588
  defineStringTag(CustomEventP, "CustomEvent");
589
+ /** @internal */
578
590
  class CustomEventState {
579
591
  }
580
592
  const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
581
593
 
594
+ /** @internal */
582
595
  const state$d = Symbol( /* "ProgressEventState" */);
583
596
  class ProgressEventP extends EventP {
584
597
  constructor(type, eventInitDict) {
@@ -597,6 +610,7 @@ class ProgressEventP extends EventP {
597
610
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
598
611
  }
599
612
  defineStringTag(ProgressEventP, "ProgressEvent");
613
+ /** @internal */
600
614
  class ProgressEventState {
601
615
  constructor() {
602
616
  this.lengthComputable = false;
@@ -608,7 +622,7 @@ function getValue(val) {
608
622
  return typeof val === "function" ? val() : val;
609
623
  }
610
624
  function createInnerProgressEvent(target, type, { lengthComputable = false, loaded = 0, total = 0, } = {}) {
611
- const event = new ProgressEventP(type);
625
+ let event = new ProgressEventP(type);
612
626
  event[state$d].lengthComputable = lengthComputable;
613
627
  event[state$d].loaded = loaded;
614
628
  event[state$d].total = total;
@@ -617,7 +631,7 @@ function createInnerProgressEvent(target, type, { lengthComputable = false, load
617
631
  return event;
618
632
  }
619
633
  function emitProcessEvent(target, type, loaded = 0, total = 0) {
620
- const event = createInnerProgressEvent(target, type, {
634
+ let event = createInnerProgressEvent(target, type, {
621
635
  lengthComputable: () => { return getValue(total) > 0; },
622
636
  loaded,
623
637
  total,
@@ -626,6 +640,7 @@ function emitProcessEvent(target, type, loaded = 0, total = 0) {
626
640
  }
627
641
  const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
628
642
 
643
+ /** @internal */
629
644
  const state$c = Symbol( /* "BlobState" */);
630
645
  class BlobP {
631
646
  constructor(blobParts = [], options) {
@@ -651,7 +666,7 @@ class BlobP {
651
666
  this[state$c] = new BlobState(concat(chunks));
652
667
  const that = this[state$c];
653
668
  that.size = that[_u8array].length;
654
- const rawType = (options === null || options === void 0 ? void 0 : options.type) || "";
669
+ let rawType = (options === null || options === void 0 ? void 0 : options.type) || "";
655
670
  that.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
656
671
  }
657
672
  get size() { return this[state$c].size; }
@@ -663,27 +678,35 @@ class BlobP {
663
678
  return Promise.resolve(clone(this[state$c][_u8array].buffer));
664
679
  }
665
680
  slice(start, end, contentType) {
666
- const sliced = this[state$c][_u8array].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$c][_u8array].length);
681
+ let sliced = this[state$c][_u8array].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$c][_u8array].length);
667
682
  return new BlobP([sliced], { type: contentType !== null && contentType !== void 0 ? contentType : "" });
668
683
  }
669
684
  stream() {
670
685
  throw new ReferenceError("ReadableStream is not defined");
671
686
  }
672
687
  text() {
673
- const decoder = new TextDecoderP();
688
+ let decoder = new TextDecoderP();
674
689
  return Promise.resolve(decoder.decode(this[state$c][_u8array]));
675
690
  }
676
691
  toString() { return "[object Blob]"; }
677
692
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
678
693
  }
679
694
  defineStringTag(BlobP, "Blob");
695
+ /** @internal */
680
696
  const _u8array = Symbol();
697
+ /** @internal */
681
698
  class BlobState {
682
699
  constructor(buffer) {
683
700
  this.size = 0;
684
701
  this.type = "";
685
702
  this[_u8array] = buffer;
686
703
  }
704
+ toUint8Array() {
705
+ return this[_u8array];
706
+ }
707
+ toArrayBuffer() {
708
+ return this[_u8array].buffer;
709
+ }
687
710
  }
688
711
  function u8array2base64(input) {
689
712
  let byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@@ -714,14 +737,14 @@ function convert$1(buf) {
714
737
  : new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
715
738
  }
716
739
  function clone(buf) {
717
- const sourceArray = convert$1(buf);
718
- const cloneArray = new Uint8Array(new ArrayBuffer(sourceArray.byteLength));
740
+ let sourceArray = convert$1(buf);
741
+ let cloneArray = new Uint8Array(new ArrayBuffer(sourceArray.byteLength));
719
742
  cloneArray.set(sourceArray);
720
743
  return cloneArray;
721
744
  }
722
745
  function concat(chunks) {
723
- const totalByteLength = chunks.reduce((acc, cur) => acc + cur.byteLength, 0);
724
- const result = new Uint8Array(totalByteLength);
746
+ let totalByteLength = chunks.reduce((acc, cur) => acc + cur.byteLength, 0);
747
+ let result = new Uint8Array(totalByteLength);
725
748
  chunks.reduce((offset, chunk) => {
726
749
  result.set(chunk, offset);
727
750
  return offset + chunk.byteLength;
@@ -730,6 +753,7 @@ function concat(chunks) {
730
753
  }
731
754
  const BlobE = g["Blob"] || BlobP;
732
755
 
756
+ /** @internal */
733
757
  const state$b = Symbol( /* "FileState" */);
734
758
  class FileP extends BlobP {
735
759
  constructor(fileBits, fileName, options) {
@@ -745,6 +769,7 @@ class FileP extends BlobP {
745
769
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
746
770
  }
747
771
  defineStringTag(FileP, "File");
772
+ /** @internal */
748
773
  class FileState {
749
774
  constructor() {
750
775
  this.lastModified = 0;
@@ -754,36 +779,11 @@ class FileState {
754
779
  const FileE = g["Blob"] ? g["File"] : FileP;
755
780
 
756
781
  var _a$7;
782
+ /** @internal */
757
783
  const state$a = Symbol( /* "FileReaderState" */);
758
784
  class FileReaderP extends EventTargetP {
759
785
  constructor() {
760
786
  super();
761
- this.EMPTY = 0;
762
- this.LOADING = 1;
763
- this.DONE = 2;
764
- this.readAsArrayBuffer = (blob) => {
765
- read$1.call(this[state$a], "readAsArrayBuffer", blob, () => {
766
- this[state$a].result = blob[state$c][_u8array].buffer.slice(0);
767
- });
768
- };
769
- this.readAsBinaryString = (blob) => {
770
- read$1.call(this[state$a], "readAsBinaryString", blob, () => {
771
- this[state$a].result = blob[state$c][_u8array].reduce((acc, cur) => {
772
- acc += String.fromCharCode(cur);
773
- return acc;
774
- }, "");
775
- });
776
- };
777
- this.readAsDataURL = (blob) => {
778
- read$1.call(this[state$a], "readAsDataURL", blob, () => {
779
- this[state$a].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$c][_u8array]);
780
- });
781
- };
782
- this.readAsText = (blob, encoding) => {
783
- read$1.call(this[state$a], "readAsText", blob, () => {
784
- this[state$a].result = (new TextDecoderP(encoding)).decode(blob[state$c][_u8array]);
785
- });
786
- };
787
787
  this[state$a] = new FileReaderState(this);
788
788
  }
789
789
  get readyState() { return this[state$a].readyState; }
@@ -796,6 +796,29 @@ class FileReaderP extends EventTargetP {
796
796
  emitProcessEvent(this, "abort");
797
797
  }
798
798
  }
799
+ readAsArrayBuffer(blob) {
800
+ read$1.call(this[state$a], "readAsArrayBuffer", blob, () => {
801
+ this[state$a].result = blob[state$c].toArrayBuffer().slice(0);
802
+ });
803
+ }
804
+ readAsBinaryString(blob) {
805
+ read$1.call(this[state$a], "readAsBinaryString", blob, () => {
806
+ this[state$a].result = blob[state$c].toUint8Array().reduce((acc, cur) => {
807
+ acc += String.fromCharCode(cur);
808
+ return acc;
809
+ }, "");
810
+ });
811
+ }
812
+ readAsDataURL(blob) {
813
+ read$1.call(this[state$a], "readAsDataURL", blob, () => {
814
+ this[state$a].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$c].toUint8Array());
815
+ });
816
+ }
817
+ readAsText(blob, encoding) {
818
+ read$1.call(this[state$a], "readAsText", blob, () => {
819
+ this[state$a].result = (new TextDecoderP(encoding)).decode(blob[state$c].toUint8Array());
820
+ });
821
+ }
799
822
  get onabort() { return this[state$a].onabort; }
800
823
  set onabort(value) { this[state$a].onabort = value; attach$1.call(this[state$a], "abort"); }
801
824
  get onerror() { return this[state$a].onerror; }
@@ -811,11 +834,17 @@ class FileReaderP extends EventTargetP {
811
834
  toString() { return "[object FileReader]"; }
812
835
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
813
836
  }
814
- FileReaderP.EMPTY = 0;
815
- FileReaderP.LOADING = 1;
816
- FileReaderP.DONE = 2;
837
+ const properties$1 = {
838
+ EMPTY: { value: 0, enumerable: true },
839
+ LOADING: { value: 1, enumerable: true },
840
+ DONE: { value: 2, enumerable: true },
841
+ };
842
+ Object.defineProperties(FileReaderP, properties$1);
843
+ Object.defineProperties(FileReaderP.prototype, properties$1);
817
844
  defineStringTag(FileReaderP, "FileReader");
845
+ /** @internal */
818
846
  const _handlers$3 = Symbol();
847
+ /** @internal */
819
848
  class FileReaderState {
820
849
  constructor(target) {
821
850
  this.readyState = FileReaderP.EMPTY;
@@ -874,6 +903,7 @@ function getHandlers$3() {
874
903
  const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
875
904
 
876
905
  var _a$6;
906
+ /** @internal */
877
907
  const state$9 = Symbol( /* "FormDataState" */);
878
908
  class FormDataP {
879
909
  constructor(form, submitter) {
@@ -889,7 +919,7 @@ class FormDataP {
889
919
  this[state$9][_formData].push(normalizeArgs(name, value, filename));
890
920
  }
891
921
  delete(name) {
892
- const result = [];
922
+ let result = [];
893
923
  name = String(name);
894
924
  each(this[state$9][_formData], entry => {
895
925
  entry[0] !== name && result.push(entry);
@@ -897,7 +927,7 @@ class FormDataP {
897
927
  this[state$9][_formData] = result;
898
928
  }
899
929
  get(name) {
900
- const entries = this[state$9][_formData];
930
+ let entries = this[state$9][_formData];
901
931
  name = String(name);
902
932
  for (let i = 0; i < entries.length; ++i) {
903
933
  if (entries[i][0] === name) {
@@ -907,7 +937,7 @@ class FormDataP {
907
937
  return null;
908
938
  }
909
939
  getAll(name) {
910
- const result = [];
940
+ let result = [];
911
941
  name = String(name);
912
942
  each(this[state$9][_formData], data => {
913
943
  data[0] === name && result.push(data[1]);
@@ -925,8 +955,8 @@ class FormDataP {
925
955
  }
926
956
  set(name, value, filename) {
927
957
  name = String(name);
928
- const result = [];
929
- const args = normalizeArgs(name, value, filename);
958
+ let result = [];
959
+ let args = normalizeArgs(name, value, filename);
930
960
  let replace = true;
931
961
  each(this[state$9][_formData], data => {
932
962
  data[0] === name
@@ -937,7 +967,7 @@ class FormDataP {
937
967
  this[state$9][_formData] = result;
938
968
  }
939
969
  forEach(callbackfn, thisArg) {
940
- for (const [name, value] of this) {
970
+ for (let [name, value] of this) {
941
971
  callbackfn.call(thisArg, value, name, thisArg);
942
972
  }
943
973
  }
@@ -957,7 +987,9 @@ class FormDataP {
957
987
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
958
988
  }
959
989
  defineStringTag(FormDataP, "FormData");
990
+ /** @internal */
960
991
  const _formData = Symbol();
992
+ /** @internal */
961
993
  class FormDataState {
962
994
  constructor() {
963
995
  this[_a$6] = [];
@@ -1088,6 +1120,7 @@ function createFormDataFromBody(body, errMsg = "Failed to fetch") {
1088
1120
  const FormDataE = g["FormData"] || FormDataP;
1089
1121
 
1090
1122
  var _a$5;
1123
+ /** @internal */
1091
1124
  const state$8 = Symbol( /* "URLSearchParamsState" */);
1092
1125
  class URLSearchParamsP {
1093
1126
  constructor(init) {
@@ -1187,7 +1220,9 @@ class URLSearchParamsP {
1187
1220
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
1188
1221
  }
1189
1222
  defineStringTag(URLSearchParamsP, "URLSearchParams");
1223
+ /** @internal */
1190
1224
  const _urlspDict = Symbol();
1225
+ /** @internal */
1191
1226
  class URLSearchParamsState {
1192
1227
  constructor() {
1193
1228
  this[_a$5] = {};
@@ -1210,7 +1245,7 @@ function parseToDict(search) {
1210
1245
  }
1211
1246
  }
1212
1247
  else {
1213
- for (const key in search) {
1248
+ for (let key in search) {
1214
1249
  if (search.hasOwnProperty(key)) {
1215
1250
  appendTo(dict, key, search[key]);
1216
1251
  }
@@ -1268,7 +1303,7 @@ function hasOwnProperty(obj, prop) {
1268
1303
  return Object.prototype.hasOwnProperty.call(obj, prop);
1269
1304
  }
1270
1305
  function flatCb(acc, cur) {
1271
- for (const item of cur) {
1306
+ for (let item of cur) {
1272
1307
  acc.push(item);
1273
1308
  }
1274
1309
  return acc;
@@ -1276,34 +1311,35 @@ function flatCb(acc, cur) {
1276
1311
  const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
1277
1312
 
1278
1313
  var _a$4;
1314
+ /** @internal */
1279
1315
  const state$7 = Symbol( /* "AbortSignalState" */);
1280
1316
  class AbortSignalP extends EventTargetP {
1281
1317
  static abort(reason) {
1282
- const signal = createAbortSignalP();
1318
+ let signal = createAbortSignalP();
1283
1319
  abort.call(signal[state$7], reason, false);
1284
1320
  return signal;
1285
1321
  }
1286
1322
  static any(signals) {
1287
- const signal = createAbortSignalP();
1288
- const abortedSignal = signals.find(x => x.aborted);
1323
+ let signal = createAbortSignalP();
1324
+ let abortedSignal = signals.find(x => x.aborted);
1289
1325
  if (abortedSignal) {
1290
1326
  abort.call(signal[state$7], abortedSignal.reason, false);
1291
1327
  }
1292
1328
  else {
1293
1329
  function abortFn(ev) {
1294
- for (const sig of signals) {
1330
+ for (let sig of signals) {
1295
1331
  sig.removeEventListener("abort", abortFn);
1296
1332
  }
1297
1333
  abort.call(signal[state$7], this.reason, true, ev.isTrusted);
1298
1334
  }
1299
- for (const sig of signals) {
1335
+ for (let sig of signals) {
1300
1336
  sig.addEventListener("abort", abortFn);
1301
1337
  }
1302
1338
  }
1303
1339
  return signal;
1304
1340
  }
1305
1341
  static timeout(milliseconds) {
1306
- const signal = createAbortSignalP();
1342
+ let signal = createAbortSignalP();
1307
1343
  setTimeout(() => {
1308
1344
  abort.call(signal[state$7], new MPException("signal timed out", "TimeoutError"));
1309
1345
  }, milliseconds);
@@ -1332,7 +1368,9 @@ class AbortSignalP extends EventTargetP {
1332
1368
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
1333
1369
  }
1334
1370
  defineStringTag(AbortSignalP, "AbortSignal");
1371
+ /** @internal */
1335
1372
  const _handlers$2 = Symbol();
1373
+ /** @internal */
1336
1374
  class AbortSignalState {
1337
1375
  constructor(target) {
1338
1376
  this.aborted = false;
@@ -1348,7 +1386,7 @@ function abort(reason, notify = true, isTrusted = true) {
1348
1386
  this.aborted = true;
1349
1387
  this.reason = reason !== null && reason !== void 0 ? reason : (new MPException("signal is aborted without reason", "AbortError"));
1350
1388
  if (notify) {
1351
- const evt = createInnerEvent(this.target, "abort", undefined, isTrusted);
1389
+ let evt = createInnerEvent(this.target, "abort", undefined, isTrusted);
1352
1390
  fire.call(this.target[state$f], evt);
1353
1391
  }
1354
1392
  }
@@ -1359,13 +1397,14 @@ function getHandlers$2() {
1359
1397
  };
1360
1398
  }
1361
1399
  function createAbortSignalP() {
1362
- const instance = Object.create(AbortSignalP.prototype);
1400
+ let instance = Object.create(AbortSignalP.prototype);
1363
1401
  instance[state$f] = new EventTargetState(instance);
1364
1402
  instance[state$7] = new AbortSignalState(instance);
1365
1403
  return instance;
1366
1404
  }
1367
1405
  const AbortSignalE = g["AbortSignal"] || AbortSignalP;
1368
1406
 
1407
+ /** @internal */
1369
1408
  const state$6 = Symbol( /* "AbortControllerState" */);
1370
1409
  class AbortControllerP {
1371
1410
  constructor() {
@@ -1379,6 +1418,7 @@ class AbortControllerP {
1379
1418
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
1380
1419
  }
1381
1420
  defineStringTag(AbortControllerP, "AbortController");
1421
+ /** @internal */
1382
1422
  class AbortControllerState {
1383
1423
  constructor() {
1384
1424
  this.signal = createAbortSignalP();
@@ -1387,6 +1427,7 @@ class AbortControllerState {
1387
1427
  const AbortControllerE = g["AbortController"] || AbortControllerP;
1388
1428
 
1389
1429
  var _a$3;
1430
+ /** @internal */
1390
1431
  const state$5 = Symbol( /* "XMLHttpRequestEventTargetState" */);
1391
1432
  class XMLHttpRequestEventTargetP extends EventTargetP {
1392
1433
  constructor() {
@@ -1414,7 +1455,9 @@ class XMLHttpRequestEventTargetP extends EventTargetP {
1414
1455
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
1415
1456
  }
1416
1457
  defineStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
1458
+ /** @internal */
1417
1459
  const _handlers$1 = Symbol();
1460
+ /** @internal */
1418
1461
  class XMLHttpRequestEventTargetState {
1419
1462
  /**
1420
1463
  * @param _target XMLHttpRequestEventTargetP
@@ -1462,7 +1505,7 @@ class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
1462
1505
  }
1463
1506
  defineStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
1464
1507
  function createXMLHttpRequestUploadP() {
1465
- const instance = Object.create(XMLHttpRequestUploadP.prototype);
1508
+ let instance = Object.create(XMLHttpRequestUploadP.prototype);
1466
1509
  instance[state$f] = new EventTargetState(instance);
1467
1510
  instance[state$5] = new XMLHttpRequestEventTargetState(instance);
1468
1511
  return instance;
@@ -1481,6 +1524,7 @@ const mp = (() => {
1481
1524
  (typeof tt !== u && typeof (tt === null || tt === void 0 ? void 0 : tt[r]) === f && tt) || // 抖音 | 飞书
1482
1525
  (typeof ks !== u && typeof (ks === null || ks === void 0 ? void 0 : ks[r]) === f && ks) || // 快手
1483
1526
  (typeof qh !== u && typeof (qh === null || qh === void 0 ? void 0 : qh[r]) === f && qh) || // 360
1527
+ (typeof xhs !== u && typeof (xhs === null || xhs === void 0 ? void 0 : xhs[r]) === f && xhs) || // 小红书
1484
1528
  undefined;
1485
1529
  if (typeof g["XMLHttpRequest"] === f) {
1486
1530
  return;
@@ -1521,15 +1565,11 @@ const request = mp ? mp.request : function errorRequest(options) {
1521
1565
  };
1522
1566
 
1523
1567
  var _a$2, _b$1, _c, _d, _e, _f, _g, _h, _j, _k;
1568
+ /** @internal */
1524
1569
  const state$4 = Symbol( /* "XMLHttpRequestState" */);
1525
1570
  class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1526
1571
  constructor() {
1527
1572
  super();
1528
- this.UNSENT = 0;
1529
- this.OPENED = 1;
1530
- this.HEADERS_RECEIVED = 2;
1531
- this.LOADING = 3;
1532
- this.DONE = 4;
1533
1573
  this[state$4] = new XMLHttpRequestState(this);
1534
1574
  }
1535
1575
  get readyState() { return this[state$4].readyState; }
@@ -1547,7 +1587,13 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1547
1587
  }
1548
1588
  get timeout() { return this[state$4].timeout; }
1549
1589
  set timeout(value) { this[state$4].timeout = value; }
1550
- get upload() { return this[state$4].upload; }
1590
+ get upload() {
1591
+ const that = this[state$4];
1592
+ if (!that.upload) {
1593
+ that.upload = createXMLHttpRequestUploadP();
1594
+ }
1595
+ return that.upload;
1596
+ }
1551
1597
  get withCredentials() { return this[state$4].withCredentials; }
1552
1598
  set withCredentials(value) { this[state$4].withCredentials = value; }
1553
1599
  abort() {
@@ -1562,7 +1608,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1562
1608
  var _l, _m;
1563
1609
  if (!this[state$4][_responseHeaders])
1564
1610
  return null;
1565
- const nameKey = name.toLowerCase();
1611
+ let nameKey = name.toLowerCase();
1566
1612
  return (_m = (_l = objectEntries(this[state$4][_responseHeaders] || {}).find(x => x[0].toLowerCase() === nameKey)) === null || _l === void 0 ? void 0 : _l[1]) !== null && _m !== void 0 ? _m : null;
1567
1613
  }
1568
1614
  open(...args) {
@@ -1578,10 +1624,10 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1578
1624
  that[_method] = normalizeMethod(method);
1579
1625
  that[_requestURL] = String(url);
1580
1626
  if (username !== null || password !== null) {
1581
- const _username = String(username !== null && username !== void 0 ? username : "");
1582
- const _password = String(password !== null && password !== void 0 ? password : "");
1627
+ let _username = String(username !== null && username !== void 0 ? username : "");
1628
+ let _password = String(password !== null && password !== void 0 ? password : "");
1583
1629
  if (_username.length > 0 || _password.length > 0) {
1584
- const auth = `Basic ${u8array2base64((new TextEncoderP()).encode(_username + ":" + _password))}`;
1630
+ let auth = `Basic ${u8array2base64((new TextEncoderP()).encode(_username + ":" + _password))}`;
1585
1631
  this.setRequestHeader("Authorization", auth);
1586
1632
  }
1587
1633
  }
@@ -1590,7 +1636,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1590
1636
  }
1591
1637
  overrideMimeType(mime) {
1592
1638
  if (this[state$4][_inAfterOpenBeforeSend]) {
1593
- console.warn(`XMLHttpRequest.overrideMimeType(${mime}) is not implemented: The method will have no effect on response parsing.`);
1639
+ console.warn(`XMLHttpRequest.overrideMimeType('${mime}') is not implemented: The method will have no effect on response parsing.`);
1594
1640
  }
1595
1641
  }
1596
1642
  send(body) {
@@ -1599,13 +1645,14 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1599
1645
  throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
1600
1646
  }
1601
1647
  that[_inAfterOpenBeforeSend] = false;
1602
- const allowsRequestBody = ["GET", "HEAD"].indexOf(that[_method]) === -1;
1648
+ const allowsRequestBody = that[_method] !== "GET" && that[_method] !== "HEAD";
1603
1649
  const processHeaders = allowsRequestBody && Object.keys(that[_requestHeaders]).map(x => x.toLowerCase()).indexOf("content-type") === -1;
1604
- const processContentLength = that.upload[state$f][_executors].length > 0;
1605
- let headers = Object.assign({}, that[_requestHeaders]);
1606
- let contentLength = 0;
1650
+ const upload = that.upload;
1651
+ const processContentLength = upload && upload[state$f][_executors].length > 0;
1652
+ let headers = processHeaders ? Object.assign({}, that[_requestHeaders]) : that[_requestHeaders];
1653
+ let contentLength = zero;
1607
1654
  let data = convert(body, processHeaders ? v => { assignRequestHeader(headers, "Content-Type", v); } : void 0, processContentLength ? v => { contentLength = v; } : void 0);
1608
- that[_requestTask] = request({
1655
+ let options = {
1609
1656
  url: that[_requestURL],
1610
1657
  method: that[_method],
1611
1658
  header: headers,
@@ -1615,26 +1662,31 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1615
1662
  success: requestSuccess.bind(that),
1616
1663
  fail: requestFail.bind(that),
1617
1664
  complete: requestComplete.bind(that),
1618
- });
1665
+ };
1666
+ if (that.withCredentials) {
1667
+ options.withCredentials = true;
1668
+ options.enableCookie = true;
1669
+ }
1670
+ that[_requestTask] = request(options);
1619
1671
  emitProcessEvent(this, "loadstart");
1620
1672
  if (processContentLength) {
1621
1673
  const hasRequestBody = allowsRequestBody && (typeof data === "string" ? data.length > 0 : data.byteLength > 0);
1622
1674
  if (hasRequestBody) {
1623
- emitProcessEvent(that.upload, "loadstart", 0, contentLength);
1675
+ emitProcessEvent(upload, "loadstart", 0, contentLength);
1624
1676
  }
1625
1677
  setTimeout(() => {
1626
1678
  const _aborted = that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED;
1627
1679
  const _contentLength = _aborted ? 0 : contentLength;
1628
1680
  if (_aborted) {
1629
- emitProcessEvent(that.upload, "abort");
1681
+ emitProcessEvent(upload, "abort");
1630
1682
  }
1631
1683
  else {
1632
1684
  if (hasRequestBody) {
1633
- emitProcessEvent(that.upload, "load", _contentLength, _contentLength);
1685
+ emitProcessEvent(upload, "load", _contentLength, _contentLength);
1634
1686
  }
1635
1687
  }
1636
1688
  if (_aborted || hasRequestBody) {
1637
- emitProcessEvent(that.upload, "loadend", _contentLength, _contentLength);
1689
+ emitProcessEvent(upload, "loadend", _contentLength, _contentLength);
1638
1690
  }
1639
1691
  });
1640
1692
  }
@@ -1651,22 +1703,27 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1651
1703
  toString() { return "[object XMLHttpRequest]"; }
1652
1704
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
1653
1705
  }
1654
- XMLHttpRequestP.UNSENT = 0;
1655
- XMLHttpRequestP.OPENED = 1;
1656
- XMLHttpRequestP.HEADERS_RECEIVED = 2;
1657
- XMLHttpRequestP.LOADING = 3;
1658
- XMLHttpRequestP.DONE = 4;
1706
+ const properties = {
1707
+ UNSENT: { value: 0, enumerable: true },
1708
+ OPENED: { value: 1, enumerable: true },
1709
+ HEADERS_RECEIVED: { value: 2, enumerable: true },
1710
+ LOADING: { value: 3, enumerable: true },
1711
+ DONE: { value: 4, enumerable: true },
1712
+ };
1713
+ Object.defineProperties(XMLHttpRequestP, properties);
1714
+ Object.defineProperties(XMLHttpRequestP.prototype, properties);
1659
1715
  defineStringTag(XMLHttpRequestP, "XMLHttpRequest");
1660
- const _handlers = Symbol();
1661
- const _inAfterOpenBeforeSend = Symbol();
1662
- const _resetPending = Symbol();
1663
- const _timeoutId = Symbol();
1664
- const _requestURL = Symbol();
1665
- const _method = Symbol();
1666
- const _requestHeaders = Symbol();
1716
+ /** @internal */ const _handlers = Symbol();
1717
+ /** @internal */ const _inAfterOpenBeforeSend = Symbol();
1718
+ /** @internal */ const _resetPending = Symbol();
1719
+ /** @internal */ const _timeoutId = Symbol();
1720
+ /** @internal */ const _requestURL = Symbol();
1721
+ /** @internal */ const _method = Symbol();
1722
+ /** @internal */ const _requestHeaders = Symbol();
1667
1723
  const _responseHeaders = Symbol();
1668
- const _responseContentLength = Symbol();
1669
- const _requestTask = Symbol();
1724
+ /** @internal */ const _responseContentLength = Symbol();
1725
+ /** @internal */ const _requestTask = Symbol();
1726
+ /** @internal */
1670
1727
  class XMLHttpRequestState {
1671
1728
  constructor(target) {
1672
1729
  this.readyState = XMLHttpRequestP.UNSENT;
@@ -1686,10 +1743,9 @@ class XMLHttpRequestState {
1686
1743
  this[_f] = "GET";
1687
1744
  this[_g] = { Accept: "*/*" };
1688
1745
  this[_h] = null;
1689
- this[_j] = 0;
1746
+ this[_j] = zero;
1690
1747
  this[_k] = null;
1691
1748
  this.target = target;
1692
- this.upload = createXMLHttpRequestUploadP();
1693
1749
  }
1694
1750
  }
1695
1751
  _a$2 = _handlers, _b$1 = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
@@ -1697,7 +1753,7 @@ function requestSuccess({ statusCode, header, data }) {
1697
1753
  this.responseURL = this[_requestURL];
1698
1754
  this.status = statusCode;
1699
1755
  this[_responseHeaders] = header;
1700
- const lengthStr = this.target.getResponseHeader("Content-Length");
1756
+ let lengthStr = this.target.getResponseHeader("Content-Length");
1701
1757
  this[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
1702
1758
  if (this.readyState === XMLHttpRequestP.OPENED) {
1703
1759
  setReadyStateAndNotify.call(this, XMLHttpRequestP.HEADERS_RECEIVED);
@@ -1799,7 +1855,7 @@ function resetXHR() {
1799
1855
  this.statusText = "";
1800
1856
  this[_requestHeaders] = {};
1801
1857
  this[_responseHeaders] = null;
1802
- this[_responseContentLength] = 0;
1858
+ this[_responseContentLength] = zero;
1803
1859
  }
1804
1860
  function resetRequestTimeout() {
1805
1861
  if (this[_timeoutId]) {
@@ -1808,10 +1864,10 @@ function resetRequestTimeout() {
1808
1864
  }
1809
1865
  }
1810
1866
  function setReadyStateAndNotify(value) {
1811
- const hasChanged = value !== this.readyState;
1867
+ let hasChanged = value !== this.readyState;
1812
1868
  this.readyState = value;
1813
1869
  if (hasChanged) {
1814
- const evt = createInnerEvent(this.target, "readystatechange");
1870
+ let evt = createInnerEvent(this.target, "readystatechange");
1815
1871
  fire.call(this.target[state$f], evt);
1816
1872
  }
1817
1873
  }
@@ -1830,8 +1886,8 @@ function normalizeDataType(responseType) {
1830
1886
  return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
1831
1887
  }
1832
1888
  function assignRequestHeader(headers, name, value) {
1833
- const nameKey = name.toLowerCase();
1834
- for (const key of Object.keys(headers)) {
1889
+ let nameKey = name.toLowerCase();
1890
+ for (let key of Object.keys(headers)) {
1835
1891
  if (key.toLowerCase() === nameKey) {
1836
1892
  headers[key] = value;
1837
1893
  return;
@@ -1869,14 +1925,14 @@ function convert(body, setContentType, setContentLength) {
1869
1925
  result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
1870
1926
  }
1871
1927
  else if (isPolyfillType("Blob", body)) {
1872
- result = body[state$c][_u8array].buffer.slice(0);
1928
+ result = body[state$c].toArrayBuffer().slice(0);
1873
1929
  if (setContentType && body.type) {
1874
1930
  setContentType(body.type);
1875
1931
  }
1876
1932
  }
1877
1933
  else if (isPolyfillType("FormData", body)) {
1878
- const blob = body[state$9].toBlob();
1879
- result = blob[state$c][_u8array].buffer;
1934
+ let blob = body[state$9].toBlob();
1935
+ result = blob[state$c].toArrayBuffer();
1880
1936
  if (setContentType) {
1881
1937
  setContentType(blob.type);
1882
1938
  }
@@ -1888,12 +1944,9 @@ function convert(body, setContentType, setContentLength) {
1888
1944
  result = String(body);
1889
1945
  }
1890
1946
  if (setContentLength) {
1891
- if (typeof result === "string") {
1892
- setContentLength(() => { return encode(result).byteLength; });
1893
- }
1894
- else {
1895
- setContentLength(result.byteLength);
1896
- }
1947
+ setContentLength(() => {
1948
+ return (typeof result === "string" ? encode(result) : result).byteLength;
1949
+ });
1897
1950
  }
1898
1951
  return result;
1899
1952
  }
@@ -1915,6 +1968,7 @@ function convertBack(type, data) {
1915
1968
  return temp;
1916
1969
  }
1917
1970
  }
1971
+ const zero = () => 0;
1918
1972
  const statusMessages = {
1919
1973
  100: "Continue",
1920
1974
  101: "Switching Protocols",
@@ -1984,6 +2038,7 @@ function statusTextMap(val) {
1984
2038
  const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
1985
2039
 
1986
2040
  var _a$1, _b;
2041
+ /** @internal */
1987
2042
  const state$3 = Symbol( /* "BodyState" */);
1988
2043
  class BodyP {
1989
2044
  constructor() {
@@ -2030,6 +2085,7 @@ class BodyP {
2030
2085
  defineStringTag(BodyP, "Body");
2031
2086
  const _name = Symbol();
2032
2087
  const _body = Symbol();
2088
+ /** @internal */
2033
2089
  class BodyState {
2034
2090
  constructor() {
2035
2091
  this.bodyUsed = false;
@@ -2090,6 +2146,7 @@ function consumed(kind) {
2090
2146
  }
2091
2147
 
2092
2148
  var _a;
2149
+ /** @internal */
2093
2150
  const state$2 = Symbol( /* "HeadersState" */);
2094
2151
  class HeadersP {
2095
2152
  constructor(init) {
@@ -2165,7 +2222,9 @@ class HeadersP {
2165
2222
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
2166
2223
  }
2167
2224
  defineStringTag(HeadersP, "Headers");
2225
+ /** @internal */
2168
2226
  const _headersMap = Symbol();
2227
+ /** @internal */
2169
2228
  class HeadersState {
2170
2229
  constructor() {
2171
2230
  this[_a] = new Map();
@@ -2214,6 +2273,7 @@ function parseHeaders(rawHeaders) {
2214
2273
  }
2215
2274
  const HeadersE = g["Headers"] || HeadersP;
2216
2275
 
2276
+ /** @internal */
2217
2277
  const state$1 = Symbol( /* "RequestState" */);
2218
2278
  class RequestP extends BodyP {
2219
2279
  constructor(input, init) {
@@ -2233,7 +2293,10 @@ class RequestP extends BodyP {
2233
2293
  }
2234
2294
  that.method = input.method;
2235
2295
  that.mode = input.mode;
2236
- that.signal = input.signal;
2296
+ let inputSignal = input[state$1].signal;
2297
+ if (inputSignal) {
2298
+ that.signal = inputSignal;
2299
+ }
2237
2300
  that.url = input.url;
2238
2301
  let _input = input;
2239
2302
  if (!body && _input[state$3][_body] !== null) {
@@ -2309,9 +2372,10 @@ class RequestP extends BodyP {
2309
2372
  return new RequestP(this, { body: (_a = this[state$3][_body]) !== null && _a !== void 0 ? _a : null });
2310
2373
  }
2311
2374
  toString() { return "[object Request]"; }
2312
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
2375
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request", "Body"] }; }
2313
2376
  }
2314
2377
  defineStringTag(RequestP, "Request");
2378
+ /** @internal */
2315
2379
  class RequestState {
2316
2380
  constructor() {
2317
2381
  this.cache = "default";
@@ -2329,6 +2393,7 @@ class RequestState {
2329
2393
  }
2330
2394
  const RequestE = g["Request"] || RequestP;
2331
2395
 
2396
+ /** @internal */
2332
2397
  const state = Symbol( /* "ResponseState" */);
2333
2398
  class ResponseP extends BodyP {
2334
2399
  constructor(body, init) {
@@ -2363,7 +2428,7 @@ class ResponseP extends BodyP {
2363
2428
  get type() { return this[state].type; }
2364
2429
  get url() { return this[state].url; }
2365
2430
  clone() {
2366
- const response = new ResponseP(this[state$3][_body], {
2431
+ let response = new ResponseP(this[state$3][_body], {
2367
2432
  headers: new HeadersP(this.headers),
2368
2433
  status: this.status,
2369
2434
  statusText: this.statusText,
@@ -2375,7 +2440,7 @@ class ResponseP extends BodyP {
2375
2440
  return new Response(JSON.stringify(data), init);
2376
2441
  }
2377
2442
  static error() {
2378
- const response = new ResponseP(null, { status: 200, statusText: "" });
2443
+ let response = new ResponseP(null, { status: 200, statusText: "" });
2379
2444
  response[state].ok = false;
2380
2445
  response[state].status = 0;
2381
2446
  response[state].type = "error";
@@ -2388,9 +2453,10 @@ class ResponseP extends BodyP {
2388
2453
  return new Response(null, { status, headers: { location: String(url) } });
2389
2454
  }
2390
2455
  toString() { return "[object Response]"; }
2391
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
2456
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response", "Body"] }; }
2392
2457
  }
2393
2458
  defineStringTag(ResponseP, "Response");
2459
+ /** @internal */
2394
2460
  class ResponseState {
2395
2461
  constructor() {
2396
2462
  this.ok = true;
@@ -2408,9 +2474,10 @@ function fetchP(input, init) {
2408
2474
  throw new TypeError("fetch is not a constructor");
2409
2475
  }
2410
2476
  return new Promise(function (resolve, reject) {
2411
- let request = new RequestP(input, init);
2412
- if (request.signal && request.signal.aborted) {
2413
- return reject(request.signal.reason);
2477
+ const request = new RequestP(input, init);
2478
+ const signal = request[state$1].signal;
2479
+ if (signal && signal.aborted) {
2480
+ return reject(signal.reason);
2414
2481
  }
2415
2482
  let xhr = new XMLHttpRequestE();
2416
2483
  xhr.onload = function () {
@@ -2420,7 +2487,7 @@ function fetchP(input, init) {
2420
2487
  statusText: xhr.statusText,
2421
2488
  };
2422
2489
  setTimeout(() => {
2423
- const response = new ResponseP(xhr.response, options);
2490
+ let response = new ResponseP(xhr.response, options);
2424
2491
  response[state].url = xhr.responseURL;
2425
2492
  resolve(response);
2426
2493
  });
@@ -2447,7 +2514,7 @@ function fetchP(input, init) {
2447
2514
  else if (request.credentials === "omit") {
2448
2515
  xhr.withCredentials = false;
2449
2516
  }
2450
- if (init && isObjectHeaders(init.headers)) {
2517
+ if (init && typeof init === "object" && isObjectHeaders(init.headers)) {
2451
2518
  let headers = init.headers;
2452
2519
  let names = [];
2453
2520
  objectEntries(headers).forEach(([name, value]) => {
@@ -2465,13 +2532,13 @@ function fetchP(input, init) {
2465
2532
  xhr.setRequestHeader(name, value);
2466
2533
  });
2467
2534
  }
2468
- if (request.signal) {
2535
+ if (signal) {
2469
2536
  const abortXHR = () => { xhr.abort(); };
2470
- request.signal.addEventListener("abort", abortXHR);
2537
+ signal.addEventListener("abort", abortXHR);
2471
2538
  xhr.onreadystatechange = function () {
2472
2539
  // DONE (success or failure)
2473
2540
  if (xhr.readyState === 4) {
2474
- request.signal.removeEventListener("abort", abortXHR);
2541
+ signal.removeEventListener("abort", abortXHR);
2475
2542
  }
2476
2543
  };
2477
2544
  }