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.esm.js
CHANGED
|
@@ -46,7 +46,7 @@ class TextEncoderP {
|
|
|
46
46
|
return encodeText(input).encoded;
|
|
47
47
|
}
|
|
48
48
|
encodeInto(source, destination) {
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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
|
-
|
|
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
|
-
|
|
445
|
-
|
|
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
|
-
|
|
485
|
+
let onceIndexes = [];
|
|
477
486
|
for (let i = 0; i < this[_executors].length; ++i) {
|
|
478
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
718
|
-
|
|
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
|
-
|
|
724
|
-
|
|
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,13 +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
787
|
this[state$a] = new FileReaderState(this);
|
|
765
788
|
}
|
|
766
789
|
get readyState() { return this[state$a].readyState; }
|
|
@@ -775,12 +798,12 @@ class FileReaderP extends EventTargetP {
|
|
|
775
798
|
}
|
|
776
799
|
readAsArrayBuffer(blob) {
|
|
777
800
|
read$1.call(this[state$a], "readAsArrayBuffer", blob, () => {
|
|
778
|
-
this[state$a].result = blob[state$c]
|
|
801
|
+
this[state$a].result = blob[state$c].toArrayBuffer().slice(0);
|
|
779
802
|
});
|
|
780
803
|
}
|
|
781
804
|
readAsBinaryString(blob) {
|
|
782
805
|
read$1.call(this[state$a], "readAsBinaryString", blob, () => {
|
|
783
|
-
this[state$a].result = blob[state$c]
|
|
806
|
+
this[state$a].result = blob[state$c].toUint8Array().reduce((acc, cur) => {
|
|
784
807
|
acc += String.fromCharCode(cur);
|
|
785
808
|
return acc;
|
|
786
809
|
}, "");
|
|
@@ -788,12 +811,12 @@ class FileReaderP extends EventTargetP {
|
|
|
788
811
|
}
|
|
789
812
|
readAsDataURL(blob) {
|
|
790
813
|
read$1.call(this[state$a], "readAsDataURL", blob, () => {
|
|
791
|
-
this[state$a].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$c]
|
|
814
|
+
this[state$a].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$c].toUint8Array());
|
|
792
815
|
});
|
|
793
816
|
}
|
|
794
817
|
readAsText(blob, encoding) {
|
|
795
818
|
read$1.call(this[state$a], "readAsText", blob, () => {
|
|
796
|
-
this[state$a].result = (new TextDecoderP(encoding)).decode(blob[state$c]
|
|
819
|
+
this[state$a].result = (new TextDecoderP(encoding)).decode(blob[state$c].toUint8Array());
|
|
797
820
|
});
|
|
798
821
|
}
|
|
799
822
|
get onabort() { return this[state$a].onabort; }
|
|
@@ -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
|
-
|
|
815
|
-
|
|
816
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
929
|
-
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
1288
|
-
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -1522,15 +1565,11 @@ const request = mp ? mp.request : function errorRequest(options) {
|
|
|
1522
1565
|
};
|
|
1523
1566
|
|
|
1524
1567
|
var _a$2, _b$1, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1568
|
+
/** @internal */
|
|
1525
1569
|
const state$4 = Symbol( /* "XMLHttpRequestState" */);
|
|
1526
1570
|
class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
1527
1571
|
constructor() {
|
|
1528
1572
|
super();
|
|
1529
|
-
this.UNSENT = 0;
|
|
1530
|
-
this.OPENED = 1;
|
|
1531
|
-
this.HEADERS_RECEIVED = 2;
|
|
1532
|
-
this.LOADING = 3;
|
|
1533
|
-
this.DONE = 4;
|
|
1534
1573
|
this[state$4] = new XMLHttpRequestState(this);
|
|
1535
1574
|
}
|
|
1536
1575
|
get readyState() { return this[state$4].readyState; }
|
|
@@ -1548,7 +1587,13 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1548
1587
|
}
|
|
1549
1588
|
get timeout() { return this[state$4].timeout; }
|
|
1550
1589
|
set timeout(value) { this[state$4].timeout = value; }
|
|
1551
|
-
get upload() {
|
|
1590
|
+
get upload() {
|
|
1591
|
+
const that = this[state$4];
|
|
1592
|
+
if (!that.upload) {
|
|
1593
|
+
that.upload = createXMLHttpRequestUploadP();
|
|
1594
|
+
}
|
|
1595
|
+
return that.upload;
|
|
1596
|
+
}
|
|
1552
1597
|
get withCredentials() { return this[state$4].withCredentials; }
|
|
1553
1598
|
set withCredentials(value) { this[state$4].withCredentials = value; }
|
|
1554
1599
|
abort() {
|
|
@@ -1563,7 +1608,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1563
1608
|
var _l, _m;
|
|
1564
1609
|
if (!this[state$4][_responseHeaders])
|
|
1565
1610
|
return null;
|
|
1566
|
-
|
|
1611
|
+
let nameKey = name.toLowerCase();
|
|
1567
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;
|
|
1568
1613
|
}
|
|
1569
1614
|
open(...args) {
|
|
@@ -1579,10 +1624,10 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1579
1624
|
that[_method] = normalizeMethod(method);
|
|
1580
1625
|
that[_requestURL] = String(url);
|
|
1581
1626
|
if (username !== null || password !== null) {
|
|
1582
|
-
|
|
1583
|
-
|
|
1627
|
+
let _username = String(username !== null && username !== void 0 ? username : "");
|
|
1628
|
+
let _password = String(password !== null && password !== void 0 ? password : "");
|
|
1584
1629
|
if (_username.length > 0 || _password.length > 0) {
|
|
1585
|
-
|
|
1630
|
+
let auth = `Basic ${u8array2base64((new TextEncoderP()).encode(_username + ":" + _password))}`;
|
|
1586
1631
|
this.setRequestHeader("Authorization", auth);
|
|
1587
1632
|
}
|
|
1588
1633
|
}
|
|
@@ -1591,7 +1636,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1591
1636
|
}
|
|
1592
1637
|
overrideMimeType(mime) {
|
|
1593
1638
|
if (this[state$4][_inAfterOpenBeforeSend]) {
|
|
1594
|
-
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.`);
|
|
1595
1640
|
}
|
|
1596
1641
|
}
|
|
1597
1642
|
send(body) {
|
|
@@ -1600,13 +1645,14 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1600
1645
|
throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
1601
1646
|
}
|
|
1602
1647
|
that[_inAfterOpenBeforeSend] = false;
|
|
1603
|
-
const allowsRequestBody = ["GET"
|
|
1648
|
+
const allowsRequestBody = that[_method] !== "GET" && that[_method] !== "HEAD";
|
|
1604
1649
|
const processHeaders = allowsRequestBody && Object.keys(that[_requestHeaders]).map(x => x.toLowerCase()).indexOf("content-type") === -1;
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1607
|
-
let
|
|
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;
|
|
1608
1654
|
let data = convert(body, processHeaders ? v => { assignRequestHeader(headers, "Content-Type", v); } : void 0, processContentLength ? v => { contentLength = v; } : void 0);
|
|
1609
|
-
|
|
1655
|
+
let options = {
|
|
1610
1656
|
url: that[_requestURL],
|
|
1611
1657
|
method: that[_method],
|
|
1612
1658
|
header: headers,
|
|
@@ -1616,26 +1662,31 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1616
1662
|
success: requestSuccess.bind(that),
|
|
1617
1663
|
fail: requestFail.bind(that),
|
|
1618
1664
|
complete: requestComplete.bind(that),
|
|
1619
|
-
}
|
|
1665
|
+
};
|
|
1666
|
+
if (that.withCredentials) {
|
|
1667
|
+
options.withCredentials = true;
|
|
1668
|
+
options.enableCookie = true;
|
|
1669
|
+
}
|
|
1670
|
+
that[_requestTask] = request(options);
|
|
1620
1671
|
emitProcessEvent(this, "loadstart");
|
|
1621
1672
|
if (processContentLength) {
|
|
1622
1673
|
const hasRequestBody = allowsRequestBody && (typeof data === "string" ? data.length > 0 : data.byteLength > 0);
|
|
1623
1674
|
if (hasRequestBody) {
|
|
1624
|
-
emitProcessEvent(
|
|
1675
|
+
emitProcessEvent(upload, "loadstart", 0, contentLength);
|
|
1625
1676
|
}
|
|
1626
1677
|
setTimeout(() => {
|
|
1627
1678
|
const _aborted = that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED;
|
|
1628
1679
|
const _contentLength = _aborted ? 0 : contentLength;
|
|
1629
1680
|
if (_aborted) {
|
|
1630
|
-
emitProcessEvent(
|
|
1681
|
+
emitProcessEvent(upload, "abort");
|
|
1631
1682
|
}
|
|
1632
1683
|
else {
|
|
1633
1684
|
if (hasRequestBody) {
|
|
1634
|
-
emitProcessEvent(
|
|
1685
|
+
emitProcessEvent(upload, "load", _contentLength, _contentLength);
|
|
1635
1686
|
}
|
|
1636
1687
|
}
|
|
1637
1688
|
if (_aborted || hasRequestBody) {
|
|
1638
|
-
emitProcessEvent(
|
|
1689
|
+
emitProcessEvent(upload, "loadend", _contentLength, _contentLength);
|
|
1639
1690
|
}
|
|
1640
1691
|
});
|
|
1641
1692
|
}
|
|
@@ -1652,22 +1703,27 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
1652
1703
|
toString() { return "[object XMLHttpRequest]"; }
|
|
1653
1704
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1654
1705
|
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
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);
|
|
1660
1715
|
defineStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
1661
|
-
const _handlers = Symbol();
|
|
1662
|
-
const _inAfterOpenBeforeSend = Symbol();
|
|
1663
|
-
const _resetPending = Symbol();
|
|
1664
|
-
const _timeoutId = Symbol();
|
|
1665
|
-
const _requestURL = Symbol();
|
|
1666
|
-
const _method = Symbol();
|
|
1667
|
-
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();
|
|
1668
1723
|
const _responseHeaders = Symbol();
|
|
1669
|
-
const _responseContentLength = Symbol();
|
|
1670
|
-
const _requestTask = Symbol();
|
|
1724
|
+
/** @internal */ const _responseContentLength = Symbol();
|
|
1725
|
+
/** @internal */ const _requestTask = Symbol();
|
|
1726
|
+
/** @internal */
|
|
1671
1727
|
class XMLHttpRequestState {
|
|
1672
1728
|
constructor(target) {
|
|
1673
1729
|
this.readyState = XMLHttpRequestP.UNSENT;
|
|
@@ -1687,10 +1743,9 @@ class XMLHttpRequestState {
|
|
|
1687
1743
|
this[_f] = "GET";
|
|
1688
1744
|
this[_g] = { Accept: "*/*" };
|
|
1689
1745
|
this[_h] = null;
|
|
1690
|
-
this[_j] =
|
|
1746
|
+
this[_j] = zero;
|
|
1691
1747
|
this[_k] = null;
|
|
1692
1748
|
this.target = target;
|
|
1693
|
-
this.upload = createXMLHttpRequestUploadP();
|
|
1694
1749
|
}
|
|
1695
1750
|
}
|
|
1696
1751
|
_a$2 = _handlers, _b$1 = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
|
|
@@ -1698,7 +1753,7 @@ function requestSuccess({ statusCode, header, data }) {
|
|
|
1698
1753
|
this.responseURL = this[_requestURL];
|
|
1699
1754
|
this.status = statusCode;
|
|
1700
1755
|
this[_responseHeaders] = header;
|
|
1701
|
-
|
|
1756
|
+
let lengthStr = this.target.getResponseHeader("Content-Length");
|
|
1702
1757
|
this[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
|
|
1703
1758
|
if (this.readyState === XMLHttpRequestP.OPENED) {
|
|
1704
1759
|
setReadyStateAndNotify.call(this, XMLHttpRequestP.HEADERS_RECEIVED);
|
|
@@ -1800,7 +1855,7 @@ function resetXHR() {
|
|
|
1800
1855
|
this.statusText = "";
|
|
1801
1856
|
this[_requestHeaders] = {};
|
|
1802
1857
|
this[_responseHeaders] = null;
|
|
1803
|
-
this[_responseContentLength] =
|
|
1858
|
+
this[_responseContentLength] = zero;
|
|
1804
1859
|
}
|
|
1805
1860
|
function resetRequestTimeout() {
|
|
1806
1861
|
if (this[_timeoutId]) {
|
|
@@ -1809,10 +1864,10 @@ function resetRequestTimeout() {
|
|
|
1809
1864
|
}
|
|
1810
1865
|
}
|
|
1811
1866
|
function setReadyStateAndNotify(value) {
|
|
1812
|
-
|
|
1867
|
+
let hasChanged = value !== this.readyState;
|
|
1813
1868
|
this.readyState = value;
|
|
1814
1869
|
if (hasChanged) {
|
|
1815
|
-
|
|
1870
|
+
let evt = createInnerEvent(this.target, "readystatechange");
|
|
1816
1871
|
fire.call(this.target[state$f], evt);
|
|
1817
1872
|
}
|
|
1818
1873
|
}
|
|
@@ -1831,8 +1886,8 @@ function normalizeDataType(responseType) {
|
|
|
1831
1886
|
return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
|
|
1832
1887
|
}
|
|
1833
1888
|
function assignRequestHeader(headers, name, value) {
|
|
1834
|
-
|
|
1835
|
-
for (
|
|
1889
|
+
let nameKey = name.toLowerCase();
|
|
1890
|
+
for (let key of Object.keys(headers)) {
|
|
1836
1891
|
if (key.toLowerCase() === nameKey) {
|
|
1837
1892
|
headers[key] = value;
|
|
1838
1893
|
return;
|
|
@@ -1870,14 +1925,14 @@ function convert(body, setContentType, setContentLength) {
|
|
|
1870
1925
|
result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
1871
1926
|
}
|
|
1872
1927
|
else if (isPolyfillType("Blob", body)) {
|
|
1873
|
-
result = body[state$c]
|
|
1928
|
+
result = body[state$c].toArrayBuffer().slice(0);
|
|
1874
1929
|
if (setContentType && body.type) {
|
|
1875
1930
|
setContentType(body.type);
|
|
1876
1931
|
}
|
|
1877
1932
|
}
|
|
1878
1933
|
else if (isPolyfillType("FormData", body)) {
|
|
1879
|
-
|
|
1880
|
-
result = blob[state$c]
|
|
1934
|
+
let blob = body[state$9].toBlob();
|
|
1935
|
+
result = blob[state$c].toArrayBuffer();
|
|
1881
1936
|
if (setContentType) {
|
|
1882
1937
|
setContentType(blob.type);
|
|
1883
1938
|
}
|
|
@@ -1889,12 +1944,9 @@ function convert(body, setContentType, setContentLength) {
|
|
|
1889
1944
|
result = String(body);
|
|
1890
1945
|
}
|
|
1891
1946
|
if (setContentLength) {
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
}
|
|
1895
|
-
else {
|
|
1896
|
-
setContentLength(result.byteLength);
|
|
1897
|
-
}
|
|
1947
|
+
setContentLength(() => {
|
|
1948
|
+
return (typeof result === "string" ? encode(result) : result).byteLength;
|
|
1949
|
+
});
|
|
1898
1950
|
}
|
|
1899
1951
|
return result;
|
|
1900
1952
|
}
|
|
@@ -1916,6 +1968,7 @@ function convertBack(type, data) {
|
|
|
1916
1968
|
return temp;
|
|
1917
1969
|
}
|
|
1918
1970
|
}
|
|
1971
|
+
const zero = () => 0;
|
|
1919
1972
|
const statusMessages = {
|
|
1920
1973
|
100: "Continue",
|
|
1921
1974
|
101: "Switching Protocols",
|
|
@@ -1985,6 +2038,7 @@ function statusTextMap(val) {
|
|
|
1985
2038
|
const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
|
|
1986
2039
|
|
|
1987
2040
|
var _a$1, _b;
|
|
2041
|
+
/** @internal */
|
|
1988
2042
|
const state$3 = Symbol( /* "BodyState" */);
|
|
1989
2043
|
class BodyP {
|
|
1990
2044
|
constructor() {
|
|
@@ -2031,6 +2085,7 @@ class BodyP {
|
|
|
2031
2085
|
defineStringTag(BodyP, "Body");
|
|
2032
2086
|
const _name = Symbol();
|
|
2033
2087
|
const _body = Symbol();
|
|
2088
|
+
/** @internal */
|
|
2034
2089
|
class BodyState {
|
|
2035
2090
|
constructor() {
|
|
2036
2091
|
this.bodyUsed = false;
|
|
@@ -2091,6 +2146,7 @@ function consumed(kind) {
|
|
|
2091
2146
|
}
|
|
2092
2147
|
|
|
2093
2148
|
var _a;
|
|
2149
|
+
/** @internal */
|
|
2094
2150
|
const state$2 = Symbol( /* "HeadersState" */);
|
|
2095
2151
|
class HeadersP {
|
|
2096
2152
|
constructor(init) {
|
|
@@ -2166,7 +2222,9 @@ class HeadersP {
|
|
|
2166
2222
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
|
|
2167
2223
|
}
|
|
2168
2224
|
defineStringTag(HeadersP, "Headers");
|
|
2225
|
+
/** @internal */
|
|
2169
2226
|
const _headersMap = Symbol();
|
|
2227
|
+
/** @internal */
|
|
2170
2228
|
class HeadersState {
|
|
2171
2229
|
constructor() {
|
|
2172
2230
|
this[_a] = new Map();
|
|
@@ -2215,6 +2273,7 @@ function parseHeaders(rawHeaders) {
|
|
|
2215
2273
|
}
|
|
2216
2274
|
const HeadersE = g["Headers"] || HeadersP;
|
|
2217
2275
|
|
|
2276
|
+
/** @internal */
|
|
2218
2277
|
const state$1 = Symbol( /* "RequestState" */);
|
|
2219
2278
|
class RequestP extends BodyP {
|
|
2220
2279
|
constructor(input, init) {
|
|
@@ -2234,7 +2293,10 @@ class RequestP extends BodyP {
|
|
|
2234
2293
|
}
|
|
2235
2294
|
that.method = input.method;
|
|
2236
2295
|
that.mode = input.mode;
|
|
2237
|
-
|
|
2296
|
+
let inputSignal = input[state$1].signal;
|
|
2297
|
+
if (inputSignal) {
|
|
2298
|
+
that.signal = inputSignal;
|
|
2299
|
+
}
|
|
2238
2300
|
that.url = input.url;
|
|
2239
2301
|
let _input = input;
|
|
2240
2302
|
if (!body && _input[state$3][_body] !== null) {
|
|
@@ -2310,9 +2372,10 @@ class RequestP extends BodyP {
|
|
|
2310
2372
|
return new RequestP(this, { body: (_a = this[state$3][_body]) !== null && _a !== void 0 ? _a : null });
|
|
2311
2373
|
}
|
|
2312
2374
|
toString() { return "[object Request]"; }
|
|
2313
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
|
|
2375
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request", "Body"] }; }
|
|
2314
2376
|
}
|
|
2315
2377
|
defineStringTag(RequestP, "Request");
|
|
2378
|
+
/** @internal */
|
|
2316
2379
|
class RequestState {
|
|
2317
2380
|
constructor() {
|
|
2318
2381
|
this.cache = "default";
|
|
@@ -2330,6 +2393,7 @@ class RequestState {
|
|
|
2330
2393
|
}
|
|
2331
2394
|
const RequestE = g["Request"] || RequestP;
|
|
2332
2395
|
|
|
2396
|
+
/** @internal */
|
|
2333
2397
|
const state = Symbol( /* "ResponseState" */);
|
|
2334
2398
|
class ResponseP extends BodyP {
|
|
2335
2399
|
constructor(body, init) {
|
|
@@ -2364,7 +2428,7 @@ class ResponseP extends BodyP {
|
|
|
2364
2428
|
get type() { return this[state].type; }
|
|
2365
2429
|
get url() { return this[state].url; }
|
|
2366
2430
|
clone() {
|
|
2367
|
-
|
|
2431
|
+
let response = new ResponseP(this[state$3][_body], {
|
|
2368
2432
|
headers: new HeadersP(this.headers),
|
|
2369
2433
|
status: this.status,
|
|
2370
2434
|
statusText: this.statusText,
|
|
@@ -2376,7 +2440,7 @@ class ResponseP extends BodyP {
|
|
|
2376
2440
|
return new Response(JSON.stringify(data), init);
|
|
2377
2441
|
}
|
|
2378
2442
|
static error() {
|
|
2379
|
-
|
|
2443
|
+
let response = new ResponseP(null, { status: 200, statusText: "" });
|
|
2380
2444
|
response[state].ok = false;
|
|
2381
2445
|
response[state].status = 0;
|
|
2382
2446
|
response[state].type = "error";
|
|
@@ -2389,9 +2453,10 @@ class ResponseP extends BodyP {
|
|
|
2389
2453
|
return new Response(null, { status, headers: { location: String(url) } });
|
|
2390
2454
|
}
|
|
2391
2455
|
toString() { return "[object Response]"; }
|
|
2392
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
|
|
2456
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response", "Body"] }; }
|
|
2393
2457
|
}
|
|
2394
2458
|
defineStringTag(ResponseP, "Response");
|
|
2459
|
+
/** @internal */
|
|
2395
2460
|
class ResponseState {
|
|
2396
2461
|
constructor() {
|
|
2397
2462
|
this.ok = true;
|
|
@@ -2409,9 +2474,10 @@ function fetchP(input, init) {
|
|
|
2409
2474
|
throw new TypeError("fetch is not a constructor");
|
|
2410
2475
|
}
|
|
2411
2476
|
return new Promise(function (resolve, reject) {
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2477
|
+
const request = new RequestP(input, init);
|
|
2478
|
+
const signal = request[state$1].signal;
|
|
2479
|
+
if (signal && signal.aborted) {
|
|
2480
|
+
return reject(signal.reason);
|
|
2415
2481
|
}
|
|
2416
2482
|
let xhr = new XMLHttpRequestE();
|
|
2417
2483
|
xhr.onload = function () {
|
|
@@ -2421,7 +2487,7 @@ function fetchP(input, init) {
|
|
|
2421
2487
|
statusText: xhr.statusText,
|
|
2422
2488
|
};
|
|
2423
2489
|
setTimeout(() => {
|
|
2424
|
-
|
|
2490
|
+
let response = new ResponseP(xhr.response, options);
|
|
2425
2491
|
response[state].url = xhr.responseURL;
|
|
2426
2492
|
resolve(response);
|
|
2427
2493
|
});
|
|
@@ -2448,7 +2514,7 @@ function fetchP(input, init) {
|
|
|
2448
2514
|
else if (request.credentials === "omit") {
|
|
2449
2515
|
xhr.withCredentials = false;
|
|
2450
2516
|
}
|
|
2451
|
-
if (init && isObjectHeaders(init.headers)) {
|
|
2517
|
+
if (init && typeof init === "object" && isObjectHeaders(init.headers)) {
|
|
2452
2518
|
let headers = init.headers;
|
|
2453
2519
|
let names = [];
|
|
2454
2520
|
objectEntries(headers).forEach(([name, value]) => {
|
|
@@ -2466,13 +2532,13 @@ function fetchP(input, init) {
|
|
|
2466
2532
|
xhr.setRequestHeader(name, value);
|
|
2467
2533
|
});
|
|
2468
2534
|
}
|
|
2469
|
-
if (
|
|
2535
|
+
if (signal) {
|
|
2470
2536
|
const abortXHR = () => { xhr.abort(); };
|
|
2471
|
-
|
|
2537
|
+
signal.addEventListener("abort", abortXHR);
|
|
2472
2538
|
xhr.onreadystatechange = function () {
|
|
2473
2539
|
// DONE (success or failure)
|
|
2474
2540
|
if (xhr.readyState === 4) {
|
|
2475
|
-
|
|
2541
|
+
signal.removeEventListener("abort", abortXHR);
|
|
2476
2542
|
}
|
|
2477
2543
|
};
|
|
2478
2544
|
}
|