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