mphttpx 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md.bak +107 -0
- package/dist/index.cjs.js +188 -122
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.d.ts +30 -332
- package/dist/index.esm.js +188 -122
- package/dist/index.esm.min.js +1 -1
- package/package.json +7 -3
- package/dist/types/AbortControllerP.d.ts +0 -20
- package/dist/types/AbortSignalP.d.ts +0 -41
- package/dist/types/BlobP.d.ts +0 -32
- package/dist/types/BodyP.d.ts +0 -28
- package/dist/types/CustomEventP.d.ts +0 -21
- package/dist/types/EventP.d.ts +0 -74
- package/dist/types/EventTargetP.d.ts +0 -36
- package/dist/types/FileP.d.ts +0 -23
- package/dist/types/FileReaderP.d.ts +0 -67
- package/dist/types/FormDataP.d.ts +0 -39
- package/dist/types/HeadersP.d.ts +0 -33
- package/dist/types/ProgressEventP.d.ts +0 -26
- package/dist/types/RequestP.d.ts +0 -45
- package/dist/types/ResponseP.d.ts +0 -40
- package/dist/types/TextDecoderP.d.ts +0 -33
- package/dist/types/TextEncoderP.d.ts +0 -15
- package/dist/types/URLSearchParamsP.d.ts +0 -32
- package/dist/types/XMLHttpRequestEventTargetP.d.ts +0 -50
- package/dist/types/XMLHttpRequestP.d.ts +0 -96
- package/dist/types/XMLHttpRequestUploadP.d.ts +0 -10
- package/dist/types/fetchP.d.ts +0 -3
- package/dist/types/index.d.ts +0 -18
- package/dist/types/isPolyfill.d.ts +0 -10
- package/dist/types/platform.d.ts +0 -4
- package/dist/types/request.d.ts +0 -363
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
-
|
|
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
|
-
|
|
447
|
-
|
|
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
|
-
|
|
487
|
+
let onceIndexes = [];
|
|
479
488
|
for (let i = 0; i < this[_executors].length; ++i) {
|
|
480
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
720
|
-
|
|
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
|
-
|
|
726
|
-
|
|
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,13 +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
789
|
this[state$a] = new FileReaderState(this);
|
|
767
790
|
}
|
|
768
791
|
get readyState() { return this[state$a].readyState; }
|
|
@@ -777,12 +800,12 @@ class FileReaderP extends EventTargetP {
|
|
|
777
800
|
}
|
|
778
801
|
readAsArrayBuffer(blob) {
|
|
779
802
|
read$1.call(this[state$a], "readAsArrayBuffer", blob, () => {
|
|
780
|
-
this[state$a].result = blob[state$c]
|
|
803
|
+
this[state$a].result = blob[state$c].toArrayBuffer().slice(0);
|
|
781
804
|
});
|
|
782
805
|
}
|
|
783
806
|
readAsBinaryString(blob) {
|
|
784
807
|
read$1.call(this[state$a], "readAsBinaryString", blob, () => {
|
|
785
|
-
this[state$a].result = blob[state$c]
|
|
808
|
+
this[state$a].result = blob[state$c].toUint8Array().reduce((acc, cur) => {
|
|
786
809
|
acc += String.fromCharCode(cur);
|
|
787
810
|
return acc;
|
|
788
811
|
}, "");
|
|
@@ -790,12 +813,12 @@ class FileReaderP extends EventTargetP {
|
|
|
790
813
|
}
|
|
791
814
|
readAsDataURL(blob) {
|
|
792
815
|
read$1.call(this[state$a], "readAsDataURL", blob, () => {
|
|
793
|
-
this[state$a].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$c]
|
|
816
|
+
this[state$a].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$c].toUint8Array());
|
|
794
817
|
});
|
|
795
818
|
}
|
|
796
819
|
readAsText(blob, encoding) {
|
|
797
820
|
read$1.call(this[state$a], "readAsText", blob, () => {
|
|
798
|
-
this[state$a].result = (new TextDecoderP(encoding)).decode(blob[state$c]
|
|
821
|
+
this[state$a].result = (new TextDecoderP(encoding)).decode(blob[state$c].toUint8Array());
|
|
799
822
|
});
|
|
800
823
|
}
|
|
801
824
|
get onabort() { return this[state$a].onabort; }
|
|
@@ -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
|
-
|
|
817
|
-
|
|
818
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
931
|
-
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
1290
|
-
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -1524,15 +1567,11 @@ const request = mp ? mp.request : function errorRequest(options) {
|
|
|
1524
1567
|
};
|
|
1525
1568
|
|
|
1526
1569
|
var _a$2, _b$1, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1570
|
+
/** @internal */
|
|
1527
1571
|
const state$4 = Symbol( /* "XMLHttpRequestState" */);
|
|
1528
1572
|
class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
1529
1573
|
constructor() {
|
|
1530
1574
|
super();
|
|
1531
|
-
this.UNSENT = 0;
|
|
1532
|
-
this.OPENED = 1;
|
|
1533
|
-
this.HEADERS_RECEIVED = 2;
|
|
1534
|
-
this.LOADING = 3;
|
|
1535
|
-
this.DONE = 4;
|
|
1536
1575
|
this[state$4] = new XMLHttpRequestState(this);
|
|
1537
1576
|
}
|
|
1538
1577
|
get readyState() { return this[state$4].readyState; }
|
|
@@ -1550,7 +1589,13 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1550
1589
|
}
|
|
1551
1590
|
get timeout() { return this[state$4].timeout; }
|
|
1552
1591
|
set timeout(value) { this[state$4].timeout = value; }
|
|
1553
|
-
get upload() {
|
|
1592
|
+
get upload() {
|
|
1593
|
+
const that = this[state$4];
|
|
1594
|
+
if (!that.upload) {
|
|
1595
|
+
that.upload = createXMLHttpRequestUploadP();
|
|
1596
|
+
}
|
|
1597
|
+
return that.upload;
|
|
1598
|
+
}
|
|
1554
1599
|
get withCredentials() { return this[state$4].withCredentials; }
|
|
1555
1600
|
set withCredentials(value) { this[state$4].withCredentials = value; }
|
|
1556
1601
|
abort() {
|
|
@@ -1565,7 +1610,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1565
1610
|
var _l, _m;
|
|
1566
1611
|
if (!this[state$4][_responseHeaders])
|
|
1567
1612
|
return null;
|
|
1568
|
-
|
|
1613
|
+
let nameKey = name.toLowerCase();
|
|
1569
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;
|
|
1570
1615
|
}
|
|
1571
1616
|
open(...args) {
|
|
@@ -1581,10 +1626,10 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1581
1626
|
that[_method] = normalizeMethod(method);
|
|
1582
1627
|
that[_requestURL] = String(url);
|
|
1583
1628
|
if (username !== null || password !== null) {
|
|
1584
|
-
|
|
1585
|
-
|
|
1629
|
+
let _username = String(username !== null && username !== void 0 ? username : "");
|
|
1630
|
+
let _password = String(password !== null && password !== void 0 ? password : "");
|
|
1586
1631
|
if (_username.length > 0 || _password.length > 0) {
|
|
1587
|
-
|
|
1632
|
+
let auth = `Basic ${u8array2base64((new TextEncoderP()).encode(_username + ":" + _password))}`;
|
|
1588
1633
|
this.setRequestHeader("Authorization", auth);
|
|
1589
1634
|
}
|
|
1590
1635
|
}
|
|
@@ -1593,7 +1638,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1593
1638
|
}
|
|
1594
1639
|
overrideMimeType(mime) {
|
|
1595
1640
|
if (this[state$4][_inAfterOpenBeforeSend]) {
|
|
1596
|
-
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.`);
|
|
1597
1642
|
}
|
|
1598
1643
|
}
|
|
1599
1644
|
send(body) {
|
|
@@ -1602,13 +1647,14 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1602
1647
|
throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
1603
1648
|
}
|
|
1604
1649
|
that[_inAfterOpenBeforeSend] = false;
|
|
1605
|
-
const allowsRequestBody = ["GET"
|
|
1650
|
+
const allowsRequestBody = that[_method] !== "GET" && that[_method] !== "HEAD";
|
|
1606
1651
|
const processHeaders = allowsRequestBody && Object.keys(that[_requestHeaders]).map(x => x.toLowerCase()).indexOf("content-type") === -1;
|
|
1607
|
-
const
|
|
1608
|
-
|
|
1609
|
-
let
|
|
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;
|
|
1610
1656
|
let data = convert(body, processHeaders ? v => { assignRequestHeader(headers, "Content-Type", v); } : void 0, processContentLength ? v => { contentLength = v; } : void 0);
|
|
1611
|
-
|
|
1657
|
+
let options = {
|
|
1612
1658
|
url: that[_requestURL],
|
|
1613
1659
|
method: that[_method],
|
|
1614
1660
|
header: headers,
|
|
@@ -1618,26 +1664,31 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1618
1664
|
success: requestSuccess.bind(that),
|
|
1619
1665
|
fail: requestFail.bind(that),
|
|
1620
1666
|
complete: requestComplete.bind(that),
|
|
1621
|
-
}
|
|
1667
|
+
};
|
|
1668
|
+
if (that.withCredentials) {
|
|
1669
|
+
options.withCredentials = true;
|
|
1670
|
+
options.enableCookie = true;
|
|
1671
|
+
}
|
|
1672
|
+
that[_requestTask] = request(options);
|
|
1622
1673
|
emitProcessEvent(this, "loadstart");
|
|
1623
1674
|
if (processContentLength) {
|
|
1624
1675
|
const hasRequestBody = allowsRequestBody && (typeof data === "string" ? data.length > 0 : data.byteLength > 0);
|
|
1625
1676
|
if (hasRequestBody) {
|
|
1626
|
-
emitProcessEvent(
|
|
1677
|
+
emitProcessEvent(upload, "loadstart", 0, contentLength);
|
|
1627
1678
|
}
|
|
1628
1679
|
setTimeout(() => {
|
|
1629
1680
|
const _aborted = that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED;
|
|
1630
1681
|
const _contentLength = _aborted ? 0 : contentLength;
|
|
1631
1682
|
if (_aborted) {
|
|
1632
|
-
emitProcessEvent(
|
|
1683
|
+
emitProcessEvent(upload, "abort");
|
|
1633
1684
|
}
|
|
1634
1685
|
else {
|
|
1635
1686
|
if (hasRequestBody) {
|
|
1636
|
-
emitProcessEvent(
|
|
1687
|
+
emitProcessEvent(upload, "load", _contentLength, _contentLength);
|
|
1637
1688
|
}
|
|
1638
1689
|
}
|
|
1639
1690
|
if (_aborted || hasRequestBody) {
|
|
1640
|
-
emitProcessEvent(
|
|
1691
|
+
emitProcessEvent(upload, "loadend", _contentLength, _contentLength);
|
|
1641
1692
|
}
|
|
1642
1693
|
});
|
|
1643
1694
|
}
|
|
@@ -1654,22 +1705,27 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1654
1705
|
toString() { return "[object XMLHttpRequest]"; }
|
|
1655
1706
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1656
1707
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
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);
|
|
1662
1717
|
defineStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
1663
|
-
const _handlers = Symbol();
|
|
1664
|
-
const _inAfterOpenBeforeSend = Symbol();
|
|
1665
|
-
const _resetPending = Symbol();
|
|
1666
|
-
const _timeoutId = Symbol();
|
|
1667
|
-
const _requestURL = Symbol();
|
|
1668
|
-
const _method = Symbol();
|
|
1669
|
-
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();
|
|
1670
1725
|
const _responseHeaders = Symbol();
|
|
1671
|
-
const _responseContentLength = Symbol();
|
|
1672
|
-
const _requestTask = Symbol();
|
|
1726
|
+
/** @internal */ const _responseContentLength = Symbol();
|
|
1727
|
+
/** @internal */ const _requestTask = Symbol();
|
|
1728
|
+
/** @internal */
|
|
1673
1729
|
class XMLHttpRequestState {
|
|
1674
1730
|
constructor(target) {
|
|
1675
1731
|
this.readyState = XMLHttpRequestP.UNSENT;
|
|
@@ -1689,10 +1745,9 @@ class XMLHttpRequestState {
|
|
|
1689
1745
|
this[_f] = "GET";
|
|
1690
1746
|
this[_g] = { Accept: "*/*" };
|
|
1691
1747
|
this[_h] = null;
|
|
1692
|
-
this[_j] =
|
|
1748
|
+
this[_j] = zero;
|
|
1693
1749
|
this[_k] = null;
|
|
1694
1750
|
this.target = target;
|
|
1695
|
-
this.upload = createXMLHttpRequestUploadP();
|
|
1696
1751
|
}
|
|
1697
1752
|
}
|
|
1698
1753
|
_a$2 = _handlers, _b$1 = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
|
|
@@ -1700,7 +1755,7 @@ function requestSuccess({ statusCode, header, data }) {
|
|
|
1700
1755
|
this.responseURL = this[_requestURL];
|
|
1701
1756
|
this.status = statusCode;
|
|
1702
1757
|
this[_responseHeaders] = header;
|
|
1703
|
-
|
|
1758
|
+
let lengthStr = this.target.getResponseHeader("Content-Length");
|
|
1704
1759
|
this[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
|
|
1705
1760
|
if (this.readyState === XMLHttpRequestP.OPENED) {
|
|
1706
1761
|
setReadyStateAndNotify.call(this, XMLHttpRequestP.HEADERS_RECEIVED);
|
|
@@ -1802,7 +1857,7 @@ function resetXHR() {
|
|
|
1802
1857
|
this.statusText = "";
|
|
1803
1858
|
this[_requestHeaders] = {};
|
|
1804
1859
|
this[_responseHeaders] = null;
|
|
1805
|
-
this[_responseContentLength] =
|
|
1860
|
+
this[_responseContentLength] = zero;
|
|
1806
1861
|
}
|
|
1807
1862
|
function resetRequestTimeout() {
|
|
1808
1863
|
if (this[_timeoutId]) {
|
|
@@ -1811,10 +1866,10 @@ function resetRequestTimeout() {
|
|
|
1811
1866
|
}
|
|
1812
1867
|
}
|
|
1813
1868
|
function setReadyStateAndNotify(value) {
|
|
1814
|
-
|
|
1869
|
+
let hasChanged = value !== this.readyState;
|
|
1815
1870
|
this.readyState = value;
|
|
1816
1871
|
if (hasChanged) {
|
|
1817
|
-
|
|
1872
|
+
let evt = createInnerEvent(this.target, "readystatechange");
|
|
1818
1873
|
fire.call(this.target[state$f], evt);
|
|
1819
1874
|
}
|
|
1820
1875
|
}
|
|
@@ -1833,8 +1888,8 @@ function normalizeDataType(responseType) {
|
|
|
1833
1888
|
return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
|
|
1834
1889
|
}
|
|
1835
1890
|
function assignRequestHeader(headers, name, value) {
|
|
1836
|
-
|
|
1837
|
-
for (
|
|
1891
|
+
let nameKey = name.toLowerCase();
|
|
1892
|
+
for (let key of Object.keys(headers)) {
|
|
1838
1893
|
if (key.toLowerCase() === nameKey) {
|
|
1839
1894
|
headers[key] = value;
|
|
1840
1895
|
return;
|
|
@@ -1872,14 +1927,14 @@ function convert(body, setContentType, setContentLength) {
|
|
|
1872
1927
|
result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
1873
1928
|
}
|
|
1874
1929
|
else if (isPolyfillType("Blob", body)) {
|
|
1875
|
-
result = body[state$c]
|
|
1930
|
+
result = body[state$c].toArrayBuffer().slice(0);
|
|
1876
1931
|
if (setContentType && body.type) {
|
|
1877
1932
|
setContentType(body.type);
|
|
1878
1933
|
}
|
|
1879
1934
|
}
|
|
1880
1935
|
else if (isPolyfillType("FormData", body)) {
|
|
1881
|
-
|
|
1882
|
-
result = blob[state$c]
|
|
1936
|
+
let blob = body[state$9].toBlob();
|
|
1937
|
+
result = blob[state$c].toArrayBuffer();
|
|
1883
1938
|
if (setContentType) {
|
|
1884
1939
|
setContentType(blob.type);
|
|
1885
1940
|
}
|
|
@@ -1891,12 +1946,9 @@ function convert(body, setContentType, setContentLength) {
|
|
|
1891
1946
|
result = String(body);
|
|
1892
1947
|
}
|
|
1893
1948
|
if (setContentLength) {
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
}
|
|
1897
|
-
else {
|
|
1898
|
-
setContentLength(result.byteLength);
|
|
1899
|
-
}
|
|
1949
|
+
setContentLength(() => {
|
|
1950
|
+
return (typeof result === "string" ? encode(result) : result).byteLength;
|
|
1951
|
+
});
|
|
1900
1952
|
}
|
|
1901
1953
|
return result;
|
|
1902
1954
|
}
|
|
@@ -1918,6 +1970,7 @@ function convertBack(type, data) {
|
|
|
1918
1970
|
return temp;
|
|
1919
1971
|
}
|
|
1920
1972
|
}
|
|
1973
|
+
const zero = () => 0;
|
|
1921
1974
|
const statusMessages = {
|
|
1922
1975
|
100: "Continue",
|
|
1923
1976
|
101: "Switching Protocols",
|
|
@@ -1987,6 +2040,7 @@ function statusTextMap(val) {
|
|
|
1987
2040
|
const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
|
|
1988
2041
|
|
|
1989
2042
|
var _a$1, _b;
|
|
2043
|
+
/** @internal */
|
|
1990
2044
|
const state$3 = Symbol( /* "BodyState" */);
|
|
1991
2045
|
class BodyP {
|
|
1992
2046
|
constructor() {
|
|
@@ -2033,6 +2087,7 @@ class BodyP {
|
|
|
2033
2087
|
defineStringTag(BodyP, "Body");
|
|
2034
2088
|
const _name = Symbol();
|
|
2035
2089
|
const _body = Symbol();
|
|
2090
|
+
/** @internal */
|
|
2036
2091
|
class BodyState {
|
|
2037
2092
|
constructor() {
|
|
2038
2093
|
this.bodyUsed = false;
|
|
@@ -2093,6 +2148,7 @@ function consumed(kind) {
|
|
|
2093
2148
|
}
|
|
2094
2149
|
|
|
2095
2150
|
var _a;
|
|
2151
|
+
/** @internal */
|
|
2096
2152
|
const state$2 = Symbol( /* "HeadersState" */);
|
|
2097
2153
|
class HeadersP {
|
|
2098
2154
|
constructor(init) {
|
|
@@ -2168,7 +2224,9 @@ class HeadersP {
|
|
|
2168
2224
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
|
|
2169
2225
|
}
|
|
2170
2226
|
defineStringTag(HeadersP, "Headers");
|
|
2227
|
+
/** @internal */
|
|
2171
2228
|
const _headersMap = Symbol();
|
|
2229
|
+
/** @internal */
|
|
2172
2230
|
class HeadersState {
|
|
2173
2231
|
constructor() {
|
|
2174
2232
|
this[_a] = new Map();
|
|
@@ -2217,6 +2275,7 @@ function parseHeaders(rawHeaders) {
|
|
|
2217
2275
|
}
|
|
2218
2276
|
const HeadersE = g["Headers"] || HeadersP;
|
|
2219
2277
|
|
|
2278
|
+
/** @internal */
|
|
2220
2279
|
const state$1 = Symbol( /* "RequestState" */);
|
|
2221
2280
|
class RequestP extends BodyP {
|
|
2222
2281
|
constructor(input, init) {
|
|
@@ -2236,7 +2295,10 @@ class RequestP extends BodyP {
|
|
|
2236
2295
|
}
|
|
2237
2296
|
that.method = input.method;
|
|
2238
2297
|
that.mode = input.mode;
|
|
2239
|
-
|
|
2298
|
+
let inputSignal = input[state$1].signal;
|
|
2299
|
+
if (inputSignal) {
|
|
2300
|
+
that.signal = inputSignal;
|
|
2301
|
+
}
|
|
2240
2302
|
that.url = input.url;
|
|
2241
2303
|
let _input = input;
|
|
2242
2304
|
if (!body && _input[state$3][_body] !== null) {
|
|
@@ -2312,9 +2374,10 @@ class RequestP extends BodyP {
|
|
|
2312
2374
|
return new RequestP(this, { body: (_a = this[state$3][_body]) !== null && _a !== void 0 ? _a : null });
|
|
2313
2375
|
}
|
|
2314
2376
|
toString() { return "[object Request]"; }
|
|
2315
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
|
|
2377
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request", "Body"] }; }
|
|
2316
2378
|
}
|
|
2317
2379
|
defineStringTag(RequestP, "Request");
|
|
2380
|
+
/** @internal */
|
|
2318
2381
|
class RequestState {
|
|
2319
2382
|
constructor() {
|
|
2320
2383
|
this.cache = "default";
|
|
@@ -2332,6 +2395,7 @@ class RequestState {
|
|
|
2332
2395
|
}
|
|
2333
2396
|
const RequestE = g["Request"] || RequestP;
|
|
2334
2397
|
|
|
2398
|
+
/** @internal */
|
|
2335
2399
|
const state = Symbol( /* "ResponseState" */);
|
|
2336
2400
|
class ResponseP extends BodyP {
|
|
2337
2401
|
constructor(body, init) {
|
|
@@ -2366,7 +2430,7 @@ class ResponseP extends BodyP {
|
|
|
2366
2430
|
get type() { return this[state].type; }
|
|
2367
2431
|
get url() { return this[state].url; }
|
|
2368
2432
|
clone() {
|
|
2369
|
-
|
|
2433
|
+
let response = new ResponseP(this[state$3][_body], {
|
|
2370
2434
|
headers: new HeadersP(this.headers),
|
|
2371
2435
|
status: this.status,
|
|
2372
2436
|
statusText: this.statusText,
|
|
@@ -2378,7 +2442,7 @@ class ResponseP extends BodyP {
|
|
|
2378
2442
|
return new Response(JSON.stringify(data), init);
|
|
2379
2443
|
}
|
|
2380
2444
|
static error() {
|
|
2381
|
-
|
|
2445
|
+
let response = new ResponseP(null, { status: 200, statusText: "" });
|
|
2382
2446
|
response[state].ok = false;
|
|
2383
2447
|
response[state].status = 0;
|
|
2384
2448
|
response[state].type = "error";
|
|
@@ -2391,9 +2455,10 @@ class ResponseP extends BodyP {
|
|
|
2391
2455
|
return new Response(null, { status, headers: { location: String(url) } });
|
|
2392
2456
|
}
|
|
2393
2457
|
toString() { return "[object Response]"; }
|
|
2394
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
|
|
2458
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response", "Body"] }; }
|
|
2395
2459
|
}
|
|
2396
2460
|
defineStringTag(ResponseP, "Response");
|
|
2461
|
+
/** @internal */
|
|
2397
2462
|
class ResponseState {
|
|
2398
2463
|
constructor() {
|
|
2399
2464
|
this.ok = true;
|
|
@@ -2411,9 +2476,10 @@ function fetchP(input, init) {
|
|
|
2411
2476
|
throw new TypeError("fetch is not a constructor");
|
|
2412
2477
|
}
|
|
2413
2478
|
return new Promise(function (resolve, reject) {
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2479
|
+
const request = new RequestP(input, init);
|
|
2480
|
+
const signal = request[state$1].signal;
|
|
2481
|
+
if (signal && signal.aborted) {
|
|
2482
|
+
return reject(signal.reason);
|
|
2417
2483
|
}
|
|
2418
2484
|
let xhr = new XMLHttpRequestE();
|
|
2419
2485
|
xhr.onload = function () {
|
|
@@ -2423,7 +2489,7 @@ function fetchP(input, init) {
|
|
|
2423
2489
|
statusText: xhr.statusText,
|
|
2424
2490
|
};
|
|
2425
2491
|
setTimeout(() => {
|
|
2426
|
-
|
|
2492
|
+
let response = new ResponseP(xhr.response, options);
|
|
2427
2493
|
response[state].url = xhr.responseURL;
|
|
2428
2494
|
resolve(response);
|
|
2429
2495
|
});
|
|
@@ -2450,7 +2516,7 @@ function fetchP(input, init) {
|
|
|
2450
2516
|
else if (request.credentials === "omit") {
|
|
2451
2517
|
xhr.withCredentials = false;
|
|
2452
2518
|
}
|
|
2453
|
-
if (init && isObjectHeaders(init.headers)) {
|
|
2519
|
+
if (init && typeof init === "object" && isObjectHeaders(init.headers)) {
|
|
2454
2520
|
let headers = init.headers;
|
|
2455
2521
|
let names = [];
|
|
2456
2522
|
objectEntries(headers).forEach(([name, value]) => {
|
|
@@ -2468,13 +2534,13 @@ function fetchP(input, init) {
|
|
|
2468
2534
|
xhr.setRequestHeader(name, value);
|
|
2469
2535
|
});
|
|
2470
2536
|
}
|
|
2471
|
-
if (
|
|
2537
|
+
if (signal) {
|
|
2472
2538
|
const abortXHR = () => { xhr.abort(); };
|
|
2473
|
-
|
|
2539
|
+
signal.addEventListener("abort", abortXHR);
|
|
2474
2540
|
xhr.onreadystatechange = function () {
|
|
2475
2541
|
// DONE (success or failure)
|
|
2476
2542
|
if (xhr.readyState === 4) {
|
|
2477
|
-
|
|
2543
|
+
signal.removeEventListener("abort", abortXHR);
|
|
2478
2544
|
}
|
|
2479
2545
|
};
|
|
2480
2546
|
}
|