mphttpx 1.0.6 → 1.0.7
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 +705 -24
- package/dist/index.cjs.js +1382 -1203
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.d.ts +545 -198
- package/dist/index.esm.js +1381 -1204
- package/dist/index.esm.min.js +1 -1
- package/package.json +2 -1
- package/README.md.bak +0 -107
package/dist/index.cjs.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/** @internal */
|
|
3
4
|
const polyfill = Symbol("isPolyfill");
|
|
4
5
|
/* eslint-disable no-prototype-builtins */
|
|
5
|
-
const g = (typeof globalThis !== "undefined" && globalThis) ||
|
|
6
|
+
/** @internal */ const g = (typeof globalThis !== "undefined" && globalThis) ||
|
|
6
7
|
(typeof self !== "undefined" && self) ||
|
|
7
8
|
// @ts-ignore eslint-disable-next-line no-undef
|
|
8
9
|
(typeof global !== "undefined" && global) ||
|
|
9
10
|
{};
|
|
11
|
+
/** @internal */
|
|
12
|
+
class MPException extends Error {
|
|
13
|
+
constructor(message, name) {
|
|
14
|
+
super();
|
|
15
|
+
this.message = message !== null && message !== void 0 ? message : this.message;
|
|
16
|
+
this.name = name !== null && name !== void 0 ? name : this.name;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** @internal */
|
|
10
20
|
function isObjectType(name, value) {
|
|
11
21
|
return Object.prototype.toString.call(value) === `[object ${name}]`;
|
|
12
22
|
}
|
|
23
|
+
/** @internal */
|
|
13
24
|
function isPolyfillType(name, value) {
|
|
14
25
|
return !!value
|
|
15
26
|
&& typeof value === "object"
|
|
@@ -22,22 +33,18 @@ function isPolyfillType(name, value) {
|
|
|
22
33
|
&& Array.isArray(value.isPolyfill.hierarchy)
|
|
23
34
|
&& value.isPolyfill.hierarchy.indexOf(name) > -1;
|
|
24
35
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
super();
|
|
28
|
-
this.message = message !== null && message !== void 0 ? message : this.message;
|
|
29
|
-
this.name = name !== null && name !== void 0 ? name : this.name;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function defineStringTag(targetFunc, stringTag) {
|
|
36
|
+
/** @internal */
|
|
37
|
+
function dfStringTag(targetFunc, stringTag) {
|
|
33
38
|
Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
|
|
34
39
|
configurable: true,
|
|
35
40
|
value: stringTag,
|
|
36
41
|
});
|
|
37
42
|
}
|
|
43
|
+
/** @internal */
|
|
38
44
|
function objectValues(obj) {
|
|
39
45
|
return Object.keys(obj).map(key => obj[key]);
|
|
40
46
|
}
|
|
47
|
+
/** @internal */
|
|
41
48
|
function objectEntries(obj) {
|
|
42
49
|
return Object.keys(obj).map(key => [key, obj[key]]);
|
|
43
50
|
}
|
|
@@ -54,7 +61,7 @@ class TextEncoderP {
|
|
|
54
61
|
toString() { return "[object TextEncoder]"; }
|
|
55
62
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
|
|
56
63
|
}
|
|
57
|
-
|
|
64
|
+
dfStringTag(TextEncoderP, "TextEncoder");
|
|
58
65
|
function encodeText(input, destination) {
|
|
59
66
|
const HAS_DESTINATION = typeof destination !== "undefined";
|
|
60
67
|
let pos = 0;
|
|
@@ -285,7 +292,7 @@ class TextDecoderP {
|
|
|
285
292
|
toString() { return "[object TextDecoder]"; }
|
|
286
293
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
|
|
287
294
|
}
|
|
288
|
-
|
|
295
|
+
dfStringTag(TextDecoderP, "TextDecoder");
|
|
289
296
|
/** @internal */ const _bomSeen = Symbol();
|
|
290
297
|
/** @internal */ const _partial = Symbol();
|
|
291
298
|
/** @internal */
|
|
@@ -304,38 +311,174 @@ function getBytesPerSequence(byte) {
|
|
|
304
311
|
}
|
|
305
312
|
const TextDecoderE = g["TextDecoder"] || TextDecoderP;
|
|
306
313
|
|
|
307
|
-
var _a$9, _b$2, _c$1, _d$1, _e$1, _f$1;
|
|
308
314
|
/** @internal */
|
|
309
|
-
const state$g = Symbol( /* "
|
|
315
|
+
const state$g = Symbol( /* "BlobState" */);
|
|
316
|
+
class BlobP {
|
|
317
|
+
constructor(blobParts = [], options) {
|
|
318
|
+
if (!Array.isArray(blobParts)) {
|
|
319
|
+
throw new TypeError("First argument to Blob constructor must be an Array.");
|
|
320
|
+
}
|
|
321
|
+
let encoder = null;
|
|
322
|
+
let chunks = blobParts.reduce((chunks, part) => {
|
|
323
|
+
if (isPolyfillType("Blob", part)) {
|
|
324
|
+
chunks.push(part[state$g][_buffer]);
|
|
325
|
+
}
|
|
326
|
+
else if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
327
|
+
chunks.push(BufferSource_toUint8Array(part));
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
if (!encoder) {
|
|
331
|
+
encoder = new TextEncoderP();
|
|
332
|
+
}
|
|
333
|
+
chunks.push(encoder.encode(String(part)));
|
|
334
|
+
}
|
|
335
|
+
return chunks;
|
|
336
|
+
}, []);
|
|
337
|
+
this[state$g] = new BlobState(concat(chunks));
|
|
338
|
+
const that = this[state$g];
|
|
339
|
+
that.size = that[_buffer].length;
|
|
340
|
+
let rawType = (options === null || options === void 0 ? void 0 : options.type) || "";
|
|
341
|
+
that.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
|
|
342
|
+
}
|
|
343
|
+
get size() { return this[state$g].size; }
|
|
344
|
+
get type() { return this[state$g].type; }
|
|
345
|
+
arrayBuffer() {
|
|
346
|
+
return Promise.resolve(clone(this[state$g][_buffer].buffer).buffer);
|
|
347
|
+
}
|
|
348
|
+
bytes() {
|
|
349
|
+
return Promise.resolve(clone(this[state$g][_buffer].buffer));
|
|
350
|
+
}
|
|
351
|
+
slice(start, end, contentType) {
|
|
352
|
+
let sliced = this[state$g][_buffer].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$g][_buffer].length);
|
|
353
|
+
return new BlobP([sliced], { type: contentType !== null && contentType !== void 0 ? contentType : "" });
|
|
354
|
+
}
|
|
355
|
+
stream() {
|
|
356
|
+
throw new ReferenceError("ReadableStream is not defined");
|
|
357
|
+
}
|
|
358
|
+
text() {
|
|
359
|
+
let decoder = new TextDecoderP();
|
|
360
|
+
return Promise.resolve(decoder.decode(this[state$g][_buffer]));
|
|
361
|
+
}
|
|
362
|
+
toString() { return "[object Blob]"; }
|
|
363
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
|
|
364
|
+
}
|
|
365
|
+
dfStringTag(BlobP, "Blob");
|
|
366
|
+
/** @internal */
|
|
367
|
+
const _buffer = Symbol();
|
|
368
|
+
/** @internal */
|
|
369
|
+
class BlobState {
|
|
370
|
+
constructor(buffer) {
|
|
371
|
+
this.size = 0;
|
|
372
|
+
this.type = "";
|
|
373
|
+
this[_buffer] = buffer;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/** @internal */
|
|
377
|
+
function Blob_toUint8Array(blob) {
|
|
378
|
+
return blob[state$g][_buffer];
|
|
379
|
+
}
|
|
380
|
+
function BufferSource_toUint8Array(buf) {
|
|
381
|
+
return buf instanceof ArrayBuffer
|
|
382
|
+
? new Uint8Array(buf)
|
|
383
|
+
: new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
384
|
+
}
|
|
385
|
+
function clone(buf) {
|
|
386
|
+
let sourceArray = BufferSource_toUint8Array(buf);
|
|
387
|
+
let cloneArray = new Uint8Array(new ArrayBuffer(sourceArray.byteLength));
|
|
388
|
+
cloneArray.set(sourceArray);
|
|
389
|
+
return cloneArray;
|
|
390
|
+
}
|
|
391
|
+
function concat(chunks) {
|
|
392
|
+
let totalByteLength = chunks.reduce((acc, cur) => acc + cur.byteLength, 0);
|
|
393
|
+
let result = new Uint8Array(totalByteLength);
|
|
394
|
+
chunks.reduce((offset, chunk) => {
|
|
395
|
+
result.set(chunk, offset);
|
|
396
|
+
return offset + chunk.byteLength;
|
|
397
|
+
}, 0);
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
/** @internal */
|
|
401
|
+
function Uint8Array_toBase64(input) {
|
|
402
|
+
let byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
403
|
+
let output = [];
|
|
404
|
+
for (var i = 0; i < input.length; i += 3) {
|
|
405
|
+
let byte1 = input[i];
|
|
406
|
+
let haveByte2 = i + 1 < input.length;
|
|
407
|
+
let byte2 = haveByte2 ? input[i + 1] : 0;
|
|
408
|
+
let haveByte3 = i + 2 < input.length;
|
|
409
|
+
let byte3 = haveByte3 ? input[i + 2] : 0;
|
|
410
|
+
let outByte1 = byte1 >> 2;
|
|
411
|
+
let outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
|
|
412
|
+
let outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6);
|
|
413
|
+
let outByte4 = byte3 & 0x3F;
|
|
414
|
+
if (!haveByte3) {
|
|
415
|
+
outByte4 = 64;
|
|
416
|
+
if (!haveByte2) {
|
|
417
|
+
outByte3 = 64;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
|
|
421
|
+
}
|
|
422
|
+
return output.join("");
|
|
423
|
+
}
|
|
424
|
+
const BlobE = g["Blob"] || BlobP;
|
|
425
|
+
|
|
426
|
+
/** @internal */
|
|
427
|
+
const state$f = Symbol( /* "FileState" */);
|
|
428
|
+
class FileP extends BlobP {
|
|
429
|
+
constructor(fileBits, fileName, options) {
|
|
430
|
+
super(fileBits, options);
|
|
431
|
+
this[state$f] = new FileState();
|
|
432
|
+
this[state$f].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date());
|
|
433
|
+
this[state$f].name = fileName.replace(/\//g, ":");
|
|
434
|
+
}
|
|
435
|
+
get lastModified() { return this[state$f].lastModified; }
|
|
436
|
+
get name() { return this[state$f].name; }
|
|
437
|
+
get webkitRelativePath() { return ""; }
|
|
438
|
+
toString() { return "[object File]"; }
|
|
439
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
|
|
440
|
+
}
|
|
441
|
+
dfStringTag(FileP, "File");
|
|
442
|
+
/** @internal */
|
|
443
|
+
class FileState {
|
|
444
|
+
constructor() {
|
|
445
|
+
this.lastModified = 0;
|
|
446
|
+
this.name = "";
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
const FileE = g["Blob"] ? g["File"] : FileP;
|
|
450
|
+
|
|
451
|
+
var _a$9, _b$2, _c$1, _d$1, _e$1;
|
|
452
|
+
/** @internal */ const state$e = Symbol( /* "EventState" */);
|
|
310
453
|
class EventP {
|
|
311
454
|
constructor(type, eventInitDict) {
|
|
312
|
-
this[state$
|
|
313
|
-
const that = this[state$
|
|
455
|
+
this[state$e] = new EventState();
|
|
456
|
+
const that = this[state$e];
|
|
314
457
|
that.type = String(type);
|
|
315
458
|
that.bubbles = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.bubbles);
|
|
316
459
|
that.cancelable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.cancelable);
|
|
317
460
|
that.composed = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.composed);
|
|
318
461
|
Object.defineProperty(this, "isTrusted", {
|
|
319
462
|
enumerable: true,
|
|
320
|
-
get: (function isTrusted() { return this[state$
|
|
463
|
+
get: (function isTrusted() { return this[state$e][_isTrusted]; }).bind(this),
|
|
321
464
|
});
|
|
322
465
|
}
|
|
323
|
-
get type() { return this[state$
|
|
324
|
-
get bubbles() { return this[state$
|
|
325
|
-
get cancelable() { return this[state$
|
|
326
|
-
get composed() { return this[state$
|
|
327
|
-
get target() { return this[state$
|
|
328
|
-
get currentTarget() { return this[state$
|
|
329
|
-
get eventPhase() { return this[state$
|
|
330
|
-
get srcElement() { return this[state$
|
|
331
|
-
get cancelBubble() { return this[state$
|
|
332
|
-
set cancelBubble(value) { this[state$
|
|
333
|
-
get defaultPrevented() { return this[state$
|
|
334
|
-
get returnValue() { return this[state$
|
|
466
|
+
get type() { return this[state$e].type; }
|
|
467
|
+
get bubbles() { return this[state$e].bubbles; }
|
|
468
|
+
get cancelable() { return this[state$e].cancelable; }
|
|
469
|
+
get composed() { return this[state$e].composed; }
|
|
470
|
+
get target() { return this[state$e].target; }
|
|
471
|
+
get currentTarget() { return this[state$e].currentTarget; }
|
|
472
|
+
get eventPhase() { return this[state$e].eventPhase; }
|
|
473
|
+
get srcElement() { return this[state$e].target; }
|
|
474
|
+
get cancelBubble() { return this[state$e].cancelBubble; }
|
|
475
|
+
set cancelBubble(value) { this[state$e].cancelBubble = value; }
|
|
476
|
+
get defaultPrevented() { return this[state$e].defaultPrevented; }
|
|
477
|
+
get returnValue() { return this[state$e].returnValue; }
|
|
335
478
|
set returnValue(value) { if (!value) {
|
|
336
479
|
this.preventDefault();
|
|
337
480
|
} }
|
|
338
|
-
get timeStamp() { return this[state$
|
|
481
|
+
get timeStamp() { return this[state$e].timeStamp; }
|
|
339
482
|
composedPath() {
|
|
340
483
|
let path = !!this.target ? [this.target] : [];
|
|
341
484
|
if (!!this.currentTarget && this.currentTarget !== this.target)
|
|
@@ -343,7 +486,7 @@ class EventP {
|
|
|
343
486
|
return path;
|
|
344
487
|
}
|
|
345
488
|
initEvent(type, bubbles, cancelable) {
|
|
346
|
-
const that = this[state$
|
|
489
|
+
const that = this[state$e];
|
|
347
490
|
if (that[_dispatched])
|
|
348
491
|
return;
|
|
349
492
|
that.type = String(type);
|
|
@@ -351,7 +494,7 @@ class EventP {
|
|
|
351
494
|
that.cancelable = !!cancelable;
|
|
352
495
|
}
|
|
353
496
|
preventDefault() {
|
|
354
|
-
const that = this[state$
|
|
497
|
+
const that = this[state$e];
|
|
355
498
|
if (that[_passive]) {
|
|
356
499
|
console.warn(`Ignoring 'preventDefault()' call on event of type '${this.type}' from a listener registered as 'passive'.`);
|
|
357
500
|
return;
|
|
@@ -363,7 +506,7 @@ class EventP {
|
|
|
363
506
|
}
|
|
364
507
|
}
|
|
365
508
|
stopImmediatePropagation() {
|
|
366
|
-
this[state$
|
|
509
|
+
this[state$e][_stopImmediatePropagationCalled] = true;
|
|
367
510
|
this.cancelBubble = true;
|
|
368
511
|
}
|
|
369
512
|
stopPropagation() {
|
|
@@ -380,13 +523,13 @@ const properties$2 = {
|
|
|
380
523
|
};
|
|
381
524
|
Object.defineProperties(EventP, properties$2);
|
|
382
525
|
Object.defineProperties(EventP.prototype, properties$2);
|
|
383
|
-
|
|
384
|
-
/** @internal */ const
|
|
385
|
-
const _isTrusted = Symbol();
|
|
386
|
-
const _passive = Symbol();
|
|
387
|
-
const _dispatched = Symbol();
|
|
388
|
-
const _preventDefaultCalled = Symbol();
|
|
389
|
-
const _stopImmediatePropagationCalled = Symbol();
|
|
526
|
+
dfStringTag(EventP, "Event");
|
|
527
|
+
/** @internal */ const _timeStamp = (new Date()).getTime();
|
|
528
|
+
/** @internal */ const _isTrusted = Symbol();
|
|
529
|
+
/** @internal */ const _passive = Symbol();
|
|
530
|
+
/** @internal */ const _dispatched = Symbol();
|
|
531
|
+
/** @internal */ const _preventDefaultCalled = Symbol();
|
|
532
|
+
/** @internal */ const _stopImmediatePropagationCalled = Symbol();
|
|
390
533
|
/** @internal */
|
|
391
534
|
class EventState {
|
|
392
535
|
constructor() {
|
|
@@ -400,33 +543,81 @@ class EventState {
|
|
|
400
543
|
this.cancelBubble = false;
|
|
401
544
|
this.defaultPrevented = false;
|
|
402
545
|
this.returnValue = true;
|
|
403
|
-
this.timeStamp = (new Date()).getTime() -
|
|
546
|
+
this.timeStamp = (new Date()).getTime() - _timeStamp;
|
|
547
|
+
this[_a$9] = false;
|
|
404
548
|
this[_b$2] = false;
|
|
405
549
|
this[_c$1] = false;
|
|
406
550
|
this[_d$1] = false;
|
|
407
551
|
this[_e$1] = false;
|
|
408
|
-
this[_f$1] = false;
|
|
409
552
|
}
|
|
410
553
|
}
|
|
411
|
-
_a$9 =
|
|
412
|
-
|
|
554
|
+
_a$9 = _isTrusted, _b$2 = _passive, _c$1 = _dispatched, _d$1 = _preventDefaultCalled, _e$1 = _stopImmediatePropagationCalled;
|
|
555
|
+
/** @internal */
|
|
556
|
+
function Event_setTrusted(event, isTrusted) {
|
|
557
|
+
Object.defineProperty(event[state$e], _isTrusted, {
|
|
558
|
+
value: isTrusted,
|
|
559
|
+
writable: true,
|
|
560
|
+
enumerable: true,
|
|
561
|
+
configurable: true,
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
const passive$1 = 0;
|
|
565
|
+
const dispatched$2 = 1;
|
|
566
|
+
const preventDefaultCalled$1 = 2;
|
|
567
|
+
const stopImmediatePropagationCalled$1 = 3;
|
|
568
|
+
/** @internal */
|
|
569
|
+
function Event_getEtField(event, field) {
|
|
570
|
+
const s = event[state$e];
|
|
571
|
+
switch (field) {
|
|
572
|
+
case passive$1:
|
|
573
|
+
return s[_passive];
|
|
574
|
+
case dispatched$2:
|
|
575
|
+
return s[_dispatched];
|
|
576
|
+
case preventDefaultCalled$1:
|
|
577
|
+
return s[_preventDefaultCalled];
|
|
578
|
+
case stopImmediatePropagationCalled$1:
|
|
579
|
+
return s[_stopImmediatePropagationCalled];
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
/** @internal */
|
|
583
|
+
function Event_setEtField(event, field, value) {
|
|
584
|
+
const s = event[state$e];
|
|
585
|
+
switch (field) {
|
|
586
|
+
case passive$1:
|
|
587
|
+
s[_passive] = value;
|
|
588
|
+
break;
|
|
589
|
+
case dispatched$2:
|
|
590
|
+
s[_dispatched] = value;
|
|
591
|
+
break;
|
|
592
|
+
case preventDefaultCalled$1:
|
|
593
|
+
s[_preventDefaultCalled] = value;
|
|
594
|
+
break;
|
|
595
|
+
case stopImmediatePropagationCalled$1:
|
|
596
|
+
s[_stopImmediatePropagationCalled] = value;
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
/** @internal */
|
|
413
601
|
function createInnerEvent(target, type, eventInitDict, isTrusted = true) {
|
|
414
602
|
let event = new EventP(type, eventInitDict);
|
|
415
|
-
event[state$
|
|
416
|
-
event[state$
|
|
603
|
+
event[state$e].target = target;
|
|
604
|
+
event[state$e][_isTrusted] = isTrusted;
|
|
417
605
|
return event;
|
|
418
606
|
}
|
|
419
607
|
const EventE = g["EventTarget"] ? g["Event"] : EventP;
|
|
420
608
|
|
|
421
609
|
var _a$8;
|
|
422
|
-
|
|
423
|
-
const
|
|
610
|
+
const passive = 0;
|
|
611
|
+
const dispatched$1 = 1;
|
|
612
|
+
const preventDefaultCalled = 2;
|
|
613
|
+
const stopImmediatePropagationCalled = 3;
|
|
614
|
+
/** @internal */ const state$d = Symbol( /* "EventTargetState" */);
|
|
424
615
|
class EventTargetP {
|
|
425
616
|
constructor() {
|
|
426
|
-
this[state$
|
|
617
|
+
this[state$d] = new EventTargetState(this);
|
|
427
618
|
}
|
|
428
619
|
addEventListener(type, callback, options) {
|
|
429
|
-
const that = this[state$
|
|
620
|
+
const that = this[state$d];
|
|
430
621
|
const executor = new Executor(type, callback);
|
|
431
622
|
executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
|
|
432
623
|
if (!that[_executors].some(x => x.equals(executor))) {
|
|
@@ -436,7 +627,7 @@ class EventTargetP {
|
|
|
436
627
|
executor.options.passive = !!passive;
|
|
437
628
|
if (signal) {
|
|
438
629
|
executor.options.signal = signal;
|
|
439
|
-
reply
|
|
630
|
+
reply(this, signal, executor);
|
|
440
631
|
}
|
|
441
632
|
}
|
|
442
633
|
that[_executors].push(executor);
|
|
@@ -451,12 +642,12 @@ class EventTargetP {
|
|
|
451
642
|
if (!(event instanceof EventP)) {
|
|
452
643
|
throw new TypeError("EventTarget.dispatchEvent: Argument 1 does not implement interface Event.");
|
|
453
644
|
}
|
|
454
|
-
event
|
|
455
|
-
|
|
456
|
-
return
|
|
645
|
+
Event_setTrusted(event, false);
|
|
646
|
+
event[state$e].target = this;
|
|
647
|
+
return EventTarget_fire(this, event);
|
|
457
648
|
}
|
|
458
649
|
removeEventListener(type, callback, options) {
|
|
459
|
-
const that = this[state$
|
|
650
|
+
const that = this[state$d];
|
|
460
651
|
const executor = new Executor(type, callback);
|
|
461
652
|
executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
|
|
462
653
|
if (that[_executors].some(x => x.equals(executor))) {
|
|
@@ -466,7 +657,7 @@ class EventTargetP {
|
|
|
466
657
|
toString() { return "[object EventTarget]"; }
|
|
467
658
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
|
|
468
659
|
}
|
|
469
|
-
|
|
660
|
+
dfStringTag(EventTargetP, "EventTarget");
|
|
470
661
|
/** @internal */
|
|
471
662
|
const _executors = Symbol();
|
|
472
663
|
/** @internal */
|
|
@@ -477,35 +668,37 @@ class EventTargetState {
|
|
|
477
668
|
}
|
|
478
669
|
}
|
|
479
670
|
_a$8 = _executors;
|
|
480
|
-
|
|
481
|
-
|
|
671
|
+
/** @internal */
|
|
672
|
+
function EventTarget_fire(target, event) {
|
|
673
|
+
const that = target[state$d];
|
|
674
|
+
const s = event[state$e];
|
|
482
675
|
if (!event.target)
|
|
483
|
-
s.target =
|
|
484
|
-
s.currentTarget =
|
|
676
|
+
s.target = target;
|
|
677
|
+
s.currentTarget = target;
|
|
485
678
|
s.eventPhase = EventP.AT_TARGET;
|
|
486
|
-
|
|
679
|
+
Event_setEtField(event, dispatched$1, true);
|
|
487
680
|
let onceIndexes = [];
|
|
488
|
-
for (let i = 0; i <
|
|
489
|
-
let executor =
|
|
681
|
+
for (let i = 0; i < that[_executors].length; ++i) {
|
|
682
|
+
let executor = that[_executors][i];
|
|
490
683
|
if (executor.type !== event.type)
|
|
491
684
|
continue;
|
|
492
|
-
|
|
685
|
+
Event_setEtField(event, passive, !!executor.options.passive);
|
|
493
686
|
if (executor.options.once)
|
|
494
687
|
onceIndexes.push(i);
|
|
495
688
|
let { callback: cb } = executor;
|
|
496
689
|
try {
|
|
497
690
|
if (typeof cb === "function")
|
|
498
|
-
cb.call(
|
|
691
|
+
cb.call(target, event);
|
|
499
692
|
}
|
|
500
693
|
catch (e) {
|
|
501
694
|
console.error(e);
|
|
502
695
|
}
|
|
503
|
-
|
|
504
|
-
if (
|
|
696
|
+
Event_setEtField(event, passive, false);
|
|
697
|
+
if (Event_getEtField(event, stopImmediatePropagationCalled))
|
|
505
698
|
break;
|
|
506
699
|
}
|
|
507
700
|
if (onceIndexes.length > 0) {
|
|
508
|
-
|
|
701
|
+
that[_executors] = that[_executors].reduce((acc, cur, index) => {
|
|
509
702
|
if (onceIndexes.indexOf(index) === -1)
|
|
510
703
|
acc.push(cur);
|
|
511
704
|
return acc;
|
|
@@ -513,19 +706,24 @@ function fire(event) {
|
|
|
513
706
|
}
|
|
514
707
|
s.currentTarget = null;
|
|
515
708
|
s.eventPhase = EventP.NONE;
|
|
516
|
-
|
|
517
|
-
return !(event.cancelable &&
|
|
709
|
+
Event_setEtField(event, dispatched$1, false);
|
|
710
|
+
return !(event.cancelable && Event_getEtField(event, preventDefaultCalled));
|
|
711
|
+
}
|
|
712
|
+
/** @internal */
|
|
713
|
+
function EventTarget_count(target) {
|
|
714
|
+
return target[state$d][_executors].length;
|
|
518
715
|
}
|
|
519
|
-
function reply(signal, executor) {
|
|
716
|
+
function reply(target, signal, executor) {
|
|
717
|
+
const s = target[state$d];
|
|
520
718
|
const onAbort = () => {
|
|
521
|
-
|
|
719
|
+
s[_executors] = s[_executors].filter(x => !x.equals(executor));
|
|
522
720
|
signal.removeEventListener("abort", onAbort);
|
|
523
721
|
};
|
|
524
722
|
try {
|
|
525
723
|
signal.addEventListener("abort", onAbort);
|
|
526
724
|
}
|
|
527
725
|
catch (e) {
|
|
528
|
-
console.
|
|
726
|
+
console.warn(e);
|
|
529
727
|
}
|
|
530
728
|
}
|
|
531
729
|
/** @internal */
|
|
@@ -554,64 +752,41 @@ function extract(cb) {
|
|
|
554
752
|
function isEventListenerObject(cb) {
|
|
555
753
|
return !!cb && "handleEvent" in cb && typeof cb.handleEvent === "function";
|
|
556
754
|
}
|
|
557
|
-
|
|
755
|
+
/** @internal */
|
|
756
|
+
function attachFn(target, type, cb, listener) {
|
|
558
757
|
if (typeof cb === "function") {
|
|
559
|
-
|
|
758
|
+
target.addEventListener(type, listener);
|
|
560
759
|
}
|
|
561
760
|
else {
|
|
562
|
-
|
|
761
|
+
target.removeEventListener(type, listener);
|
|
563
762
|
}
|
|
564
763
|
}
|
|
565
|
-
|
|
764
|
+
/** @internal */
|
|
765
|
+
function executeFn(target, cb, ev) {
|
|
566
766
|
if (typeof cb === "function")
|
|
567
|
-
cb.call(
|
|
767
|
+
cb.call(target, ev);
|
|
568
768
|
}
|
|
569
769
|
const EventTargetE = g["EventTarget"] || EventTargetP;
|
|
570
770
|
|
|
571
771
|
/** @internal */
|
|
572
|
-
const state$
|
|
573
|
-
class CustomEventP extends EventP {
|
|
574
|
-
constructor(type, eventInitDict) {
|
|
575
|
-
var _a;
|
|
576
|
-
super(type, eventInitDict);
|
|
577
|
-
this[state$e] = new CustomEventState();
|
|
578
|
-
this[state$e].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
|
|
579
|
-
}
|
|
580
|
-
get detail() { return this[state$e].detail; }
|
|
581
|
-
initCustomEvent(type, bubbles, cancelable, detail) {
|
|
582
|
-
if (this[state$g][_dispatched])
|
|
583
|
-
return;
|
|
584
|
-
this.initEvent(type, bubbles, cancelable);
|
|
585
|
-
this[state$e].detail = detail !== null && detail !== void 0 ? detail : null;
|
|
586
|
-
}
|
|
587
|
-
toString() { return "[object CustomEvent]"; }
|
|
588
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
|
|
589
|
-
}
|
|
590
|
-
defineStringTag(CustomEventP, "CustomEvent");
|
|
591
|
-
/** @internal */
|
|
592
|
-
class CustomEventState {
|
|
593
|
-
}
|
|
594
|
-
const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
|
|
595
|
-
|
|
596
|
-
/** @internal */
|
|
597
|
-
const state$d = Symbol( /* "ProgressEventState" */);
|
|
772
|
+
const state$c = Symbol( /* "ProgressEventState" */);
|
|
598
773
|
class ProgressEventP extends EventP {
|
|
599
774
|
constructor(type, eventInitDict) {
|
|
600
775
|
var _a, _b;
|
|
601
776
|
super(type, eventInitDict);
|
|
602
|
-
this[state$
|
|
603
|
-
const that = this[state$
|
|
777
|
+
this[state$c] = new ProgressEventState();
|
|
778
|
+
const that = this[state$c];
|
|
604
779
|
that.lengthComputable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lengthComputable);
|
|
605
780
|
that.loaded = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.loaded) !== null && _a !== void 0 ? _a : 0;
|
|
606
781
|
that.total = (_b = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.total) !== null && _b !== void 0 ? _b : 0;
|
|
607
782
|
}
|
|
608
|
-
get lengthComputable() { return getValue(this[state$
|
|
609
|
-
get loaded() { return getValue(this[state$
|
|
610
|
-
get total() { return getValue(this[state$
|
|
783
|
+
get lengthComputable() { return getValue(this[state$c].lengthComputable); }
|
|
784
|
+
get loaded() { return getValue(this[state$c].loaded); }
|
|
785
|
+
get total() { return getValue(this[state$c].total); }
|
|
611
786
|
toString() { return "[object ProgressEvent]"; }
|
|
612
787
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
|
|
613
788
|
}
|
|
614
|
-
|
|
789
|
+
dfStringTag(ProgressEventP, "ProgressEvent");
|
|
615
790
|
/** @internal */
|
|
616
791
|
class ProgressEventState {
|
|
617
792
|
constructor() {
|
|
@@ -625,234 +800,97 @@ function getValue(val) {
|
|
|
625
800
|
}
|
|
626
801
|
function createInnerProgressEvent(target, type, { lengthComputable = false, loaded = 0, total = 0, } = {}) {
|
|
627
802
|
let event = new ProgressEventP(type);
|
|
628
|
-
event[state$
|
|
629
|
-
event[state$
|
|
630
|
-
event[state$
|
|
631
|
-
event[state$
|
|
632
|
-
event
|
|
803
|
+
event[state$c].lengthComputable = lengthComputable;
|
|
804
|
+
event[state$c].loaded = loaded;
|
|
805
|
+
event[state$c].total = total;
|
|
806
|
+
event[state$e].target = target;
|
|
807
|
+
Event_setTrusted(event, true);
|
|
633
808
|
return event;
|
|
634
809
|
}
|
|
810
|
+
/** @internal */
|
|
635
811
|
function emitProcessEvent(target, type, loaded = 0, total = 0) {
|
|
636
812
|
let event = createInnerProgressEvent(target, type, {
|
|
637
813
|
lengthComputable: () => { return getValue(total) > 0; },
|
|
638
814
|
loaded,
|
|
639
815
|
total,
|
|
640
816
|
});
|
|
641
|
-
|
|
817
|
+
EventTarget_fire(target, event);
|
|
642
818
|
}
|
|
643
819
|
const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
|
|
644
820
|
|
|
821
|
+
var _a$7;
|
|
645
822
|
/** @internal */
|
|
646
|
-
const state$
|
|
647
|
-
class
|
|
648
|
-
constructor(
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
let encoder = null;
|
|
653
|
-
let chunks = blobParts.reduce((chunks, part) => {
|
|
654
|
-
if (isPolyfillType("Blob", part)) {
|
|
655
|
-
chunks.push(part[state$c][_u8array]);
|
|
656
|
-
}
|
|
657
|
-
else if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
658
|
-
chunks.push(convert$1(part));
|
|
659
|
-
}
|
|
660
|
-
else {
|
|
661
|
-
if (!encoder) {
|
|
662
|
-
encoder = new TextEncoderP();
|
|
663
|
-
}
|
|
664
|
-
chunks.push(encoder.encode(String(part)));
|
|
665
|
-
}
|
|
666
|
-
return chunks;
|
|
667
|
-
}, []);
|
|
668
|
-
this[state$c] = new BlobState(concat(chunks));
|
|
669
|
-
const that = this[state$c];
|
|
670
|
-
that.size = that[_u8array].length;
|
|
671
|
-
let rawType = (options === null || options === void 0 ? void 0 : options.type) || "";
|
|
672
|
-
that.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
|
|
823
|
+
const state$b = Symbol( /* "FileReaderState" */);
|
|
824
|
+
class FileReaderP extends EventTargetP {
|
|
825
|
+
constructor() {
|
|
826
|
+
super();
|
|
827
|
+
this[state$b] = new FileReaderState(this);
|
|
673
828
|
}
|
|
674
|
-
get
|
|
675
|
-
get
|
|
676
|
-
|
|
677
|
-
|
|
829
|
+
get readyState() { return this[state$b].readyState; }
|
|
830
|
+
get result() { return this[state$b].result; }
|
|
831
|
+
get error() { return this[state$b].error; }
|
|
832
|
+
abort() {
|
|
833
|
+
if (this.readyState === FileReaderP.LOADING) {
|
|
834
|
+
this[state$b].readyState = FileReaderP.DONE;
|
|
835
|
+
this[state$b].result = null;
|
|
836
|
+
emitProcessEvent(this, "abort");
|
|
837
|
+
}
|
|
678
838
|
}
|
|
679
|
-
|
|
680
|
-
|
|
839
|
+
readAsArrayBuffer(blob) {
|
|
840
|
+
read$1(this, "readAsArrayBuffer", blob, () => {
|
|
841
|
+
this[state$b].result = Blob_toUint8Array(blob).buffer.slice(0);
|
|
842
|
+
});
|
|
681
843
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
844
|
+
readAsBinaryString(blob) {
|
|
845
|
+
read$1(this, "readAsBinaryString", blob, () => {
|
|
846
|
+
this[state$b].result = Blob_toUint8Array(blob).reduce((acc, cur) => {
|
|
847
|
+
acc += String.fromCharCode(cur);
|
|
848
|
+
return acc;
|
|
849
|
+
}, "");
|
|
850
|
+
});
|
|
685
851
|
}
|
|
686
|
-
|
|
687
|
-
|
|
852
|
+
readAsDataURL(blob) {
|
|
853
|
+
read$1(this, "readAsDataURL", blob, () => {
|
|
854
|
+
this[state$b].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
|
|
855
|
+
});
|
|
688
856
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
857
|
+
readAsText(blob, encoding) {
|
|
858
|
+
read$1(this, "readAsText", blob, () => {
|
|
859
|
+
this[state$b].result = (new TextDecoderP(encoding)).decode(Blob_toUint8Array(blob));
|
|
860
|
+
});
|
|
692
861
|
}
|
|
693
|
-
|
|
694
|
-
|
|
862
|
+
get onabort() { return this[state$b].onabort; }
|
|
863
|
+
set onabort(value) { this[state$b].onabort = value; attach$1(this, "abort"); }
|
|
864
|
+
get onerror() { return this[state$b].onerror; }
|
|
865
|
+
set onerror(value) { this[state$b].onerror = value; attach$1(this, "error"); }
|
|
866
|
+
get onload() { return this[state$b].onload; }
|
|
867
|
+
set onload(value) { this[state$b].onload = value; attach$1(this, "load"); }
|
|
868
|
+
get onloadend() { return this[state$b].onloadend; }
|
|
869
|
+
set onloadend(value) { this[state$b].onloadend = value; attach$1(this, "loadend"); }
|
|
870
|
+
get onloadstart() { return this[state$b].onloadstart; }
|
|
871
|
+
set onloadstart(value) { this[state$b].onloadstart = value; attach$1(this, "loadstart"); }
|
|
872
|
+
get onprogress() { return this[state$b].onprogress; }
|
|
873
|
+
set onprogress(value) { this[state$b].onprogress = value; attach$1(this, "progress"); }
|
|
874
|
+
toString() { return "[object FileReader]"; }
|
|
875
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
|
|
695
876
|
}
|
|
696
|
-
|
|
877
|
+
const properties$1 = {
|
|
878
|
+
EMPTY: { value: 0, enumerable: true },
|
|
879
|
+
LOADING: { value: 1, enumerable: true },
|
|
880
|
+
DONE: { value: 2, enumerable: true },
|
|
881
|
+
};
|
|
882
|
+
Object.defineProperties(FileReaderP, properties$1);
|
|
883
|
+
Object.defineProperties(FileReaderP.prototype, properties$1);
|
|
884
|
+
dfStringTag(FileReaderP, "FileReader");
|
|
697
885
|
/** @internal */
|
|
698
|
-
const
|
|
699
|
-
/** @internal */
|
|
700
|
-
class BlobState {
|
|
701
|
-
constructor(buffer) {
|
|
702
|
-
this.size = 0;
|
|
703
|
-
this.type = "";
|
|
704
|
-
this[_u8array] = buffer;
|
|
705
|
-
}
|
|
706
|
-
toUint8Array() {
|
|
707
|
-
return this[_u8array];
|
|
708
|
-
}
|
|
709
|
-
toArrayBuffer() {
|
|
710
|
-
return this[_u8array].buffer;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
function u8array2base64(input) {
|
|
714
|
-
let byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
715
|
-
let output = [];
|
|
716
|
-
for (var i = 0; i < input.length; i += 3) {
|
|
717
|
-
let byte1 = input[i];
|
|
718
|
-
let haveByte2 = i + 1 < input.length;
|
|
719
|
-
let byte2 = haveByte2 ? input[i + 1] : 0;
|
|
720
|
-
let haveByte3 = i + 2 < input.length;
|
|
721
|
-
let byte3 = haveByte3 ? input[i + 2] : 0;
|
|
722
|
-
let outByte1 = byte1 >> 2;
|
|
723
|
-
let outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
|
|
724
|
-
let outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6);
|
|
725
|
-
let outByte4 = byte3 & 0x3F;
|
|
726
|
-
if (!haveByte3) {
|
|
727
|
-
outByte4 = 64;
|
|
728
|
-
if (!haveByte2) {
|
|
729
|
-
outByte3 = 64;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
|
|
733
|
-
}
|
|
734
|
-
return output.join("");
|
|
735
|
-
}
|
|
736
|
-
function convert$1(buf) {
|
|
737
|
-
return buf instanceof ArrayBuffer
|
|
738
|
-
? new Uint8Array(buf)
|
|
739
|
-
: new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
740
|
-
}
|
|
741
|
-
function clone(buf) {
|
|
742
|
-
let sourceArray = convert$1(buf);
|
|
743
|
-
let cloneArray = new Uint8Array(new ArrayBuffer(sourceArray.byteLength));
|
|
744
|
-
cloneArray.set(sourceArray);
|
|
745
|
-
return cloneArray;
|
|
746
|
-
}
|
|
747
|
-
function concat(chunks) {
|
|
748
|
-
let totalByteLength = chunks.reduce((acc, cur) => acc + cur.byteLength, 0);
|
|
749
|
-
let result = new Uint8Array(totalByteLength);
|
|
750
|
-
chunks.reduce((offset, chunk) => {
|
|
751
|
-
result.set(chunk, offset);
|
|
752
|
-
return offset + chunk.byteLength;
|
|
753
|
-
}, 0);
|
|
754
|
-
return result;
|
|
755
|
-
}
|
|
756
|
-
const BlobE = g["Blob"] || BlobP;
|
|
757
|
-
|
|
758
|
-
/** @internal */
|
|
759
|
-
const state$b = Symbol( /* "FileState" */);
|
|
760
|
-
class FileP extends BlobP {
|
|
761
|
-
constructor(fileBits, fileName, options) {
|
|
762
|
-
super(fileBits, options);
|
|
763
|
-
this[state$b] = new FileState();
|
|
764
|
-
this[state$b].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date());
|
|
765
|
-
this[state$b].name = fileName.replace(/\//g, ":");
|
|
766
|
-
}
|
|
767
|
-
get lastModified() { return this[state$b].lastModified; }
|
|
768
|
-
get name() { return this[state$b].name; }
|
|
769
|
-
get webkitRelativePath() { return ""; }
|
|
770
|
-
toString() { return "[object File]"; }
|
|
771
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
|
|
772
|
-
}
|
|
773
|
-
defineStringTag(FileP, "File");
|
|
774
|
-
/** @internal */
|
|
775
|
-
class FileState {
|
|
776
|
-
constructor() {
|
|
777
|
-
this.lastModified = 0;
|
|
778
|
-
this.name = "";
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
const FileE = g["Blob"] ? g["File"] : FileP;
|
|
782
|
-
|
|
783
|
-
var _a$7;
|
|
784
|
-
/** @internal */
|
|
785
|
-
const state$a = Symbol( /* "FileReaderState" */);
|
|
786
|
-
class FileReaderP extends EventTargetP {
|
|
787
|
-
constructor() {
|
|
788
|
-
super();
|
|
789
|
-
this[state$a] = new FileReaderState(this);
|
|
790
|
-
}
|
|
791
|
-
get readyState() { return this[state$a].readyState; }
|
|
792
|
-
get result() { return this[state$a].result; }
|
|
793
|
-
get error() { return this[state$a].error; }
|
|
794
|
-
abort() {
|
|
795
|
-
if (this.readyState === FileReaderP.LOADING) {
|
|
796
|
-
this[state$a].readyState = FileReaderP.DONE;
|
|
797
|
-
this[state$a].result = null;
|
|
798
|
-
emitProcessEvent(this, "abort");
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
readAsArrayBuffer(blob) {
|
|
802
|
-
read$1.call(this[state$a], "readAsArrayBuffer", blob, () => {
|
|
803
|
-
this[state$a].result = blob[state$c].toArrayBuffer().slice(0);
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
readAsBinaryString(blob) {
|
|
807
|
-
read$1.call(this[state$a], "readAsBinaryString", blob, () => {
|
|
808
|
-
this[state$a].result = blob[state$c].toUint8Array().reduce((acc, cur) => {
|
|
809
|
-
acc += String.fromCharCode(cur);
|
|
810
|
-
return acc;
|
|
811
|
-
}, "");
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
readAsDataURL(blob) {
|
|
815
|
-
read$1.call(this[state$a], "readAsDataURL", blob, () => {
|
|
816
|
-
this[state$a].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$c].toUint8Array());
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
readAsText(blob, encoding) {
|
|
820
|
-
read$1.call(this[state$a], "readAsText", blob, () => {
|
|
821
|
-
this[state$a].result = (new TextDecoderP(encoding)).decode(blob[state$c].toUint8Array());
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
get onabort() { return this[state$a].onabort; }
|
|
825
|
-
set onabort(value) { this[state$a].onabort = value; attach$1.call(this[state$a], "abort"); }
|
|
826
|
-
get onerror() { return this[state$a].onerror; }
|
|
827
|
-
set onerror(value) { this[state$a].onerror = value; attach$1.call(this[state$a], "error"); }
|
|
828
|
-
get onload() { return this[state$a].onload; }
|
|
829
|
-
set onload(value) { this[state$a].onload = value; attach$1.call(this[state$a], "load"); }
|
|
830
|
-
get onloadend() { return this[state$a].onloadend; }
|
|
831
|
-
set onloadend(value) { this[state$a].onloadend = value; attach$1.call(this[state$a], "loadend"); }
|
|
832
|
-
get onloadstart() { return this[state$a].onloadstart; }
|
|
833
|
-
set onloadstart(value) { this[state$a].onloadstart = value; attach$1.call(this[state$a], "loadstart"); }
|
|
834
|
-
get onprogress() { return this[state$a].onprogress; }
|
|
835
|
-
set onprogress(value) { this[state$a].onprogress = value; attach$1.call(this[state$a], "progress"); }
|
|
836
|
-
toString() { return "[object FileReader]"; }
|
|
837
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
|
|
838
|
-
}
|
|
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);
|
|
846
|
-
defineStringTag(FileReaderP, "FileReader");
|
|
847
|
-
/** @internal */
|
|
848
|
-
const _handlers$3 = Symbol();
|
|
886
|
+
const _handlers$3 = Symbol();
|
|
849
887
|
/** @internal */
|
|
850
888
|
class FileReaderState {
|
|
851
889
|
constructor(target) {
|
|
852
890
|
this.readyState = FileReaderP.EMPTY;
|
|
853
891
|
this.result = null;
|
|
854
892
|
this.error = null;
|
|
855
|
-
this[_a$7] = getHandlers$3
|
|
893
|
+
this[_a$7] = getHandlers$3(this);
|
|
856
894
|
this.onabort = null;
|
|
857
895
|
this.onerror = null;
|
|
858
896
|
this.onload = null;
|
|
@@ -863,50 +901,51 @@ class FileReaderState {
|
|
|
863
901
|
}
|
|
864
902
|
}
|
|
865
903
|
_a$7 = _handlers$3;
|
|
866
|
-
function read$1(kind, blob, setResult) {
|
|
904
|
+
function read$1(reader, kind, blob, setResult) {
|
|
867
905
|
if (!isPolyfillType("Blob", blob)) {
|
|
868
906
|
throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
|
|
869
907
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
908
|
+
const s = reader[state$b];
|
|
909
|
+
s.error = null;
|
|
910
|
+
s.readyState = FileReaderP.LOADING;
|
|
911
|
+
emitProcessEvent(s.target, "loadstart", 0, blob.size);
|
|
873
912
|
setTimeout(() => {
|
|
874
|
-
if (
|
|
875
|
-
|
|
913
|
+
if (s.readyState === FileReaderP.LOADING) {
|
|
914
|
+
s.readyState = FileReaderP.DONE;
|
|
876
915
|
try {
|
|
877
916
|
setResult();
|
|
878
|
-
emitProcessEvent(
|
|
917
|
+
emitProcessEvent(s.target, "load", blob.size, blob.size);
|
|
879
918
|
}
|
|
880
919
|
catch (e) {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
emitProcessEvent(
|
|
920
|
+
s.result = null;
|
|
921
|
+
s.error = e;
|
|
922
|
+
emitProcessEvent(s.target, "error", 0, blob.size);
|
|
884
923
|
}
|
|
885
924
|
}
|
|
886
|
-
emitProcessEvent(
|
|
925
|
+
emitProcessEvent(s.target, "loadend", !!s.result ? blob.size : 0, blob.size);
|
|
887
926
|
});
|
|
888
927
|
}
|
|
889
|
-
function attach$1(type) {
|
|
928
|
+
function attach$1(reader, type) {
|
|
929
|
+
const s = reader[state$b];
|
|
890
930
|
const fnName = ("on" + type);
|
|
891
|
-
const cb =
|
|
892
|
-
const listener =
|
|
893
|
-
attachFn
|
|
931
|
+
const cb = s[fnName];
|
|
932
|
+
const listener = s[_handlers$3][fnName];
|
|
933
|
+
attachFn(reader, type, cb, listener);
|
|
894
934
|
}
|
|
895
|
-
function getHandlers$3() {
|
|
935
|
+
function getHandlers$3(s) {
|
|
896
936
|
return {
|
|
897
|
-
onabort: (ev) => { executeFn
|
|
898
|
-
onerror: (ev) => { executeFn
|
|
899
|
-
onload: (ev) => { executeFn
|
|
900
|
-
onloadend: (ev) => { executeFn
|
|
901
|
-
onloadstart: (ev) => { executeFn
|
|
902
|
-
onprogress: (ev) => { executeFn
|
|
937
|
+
onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
|
|
938
|
+
onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
|
|
939
|
+
onload: (ev) => { executeFn(s.target, s.onload, ev); },
|
|
940
|
+
onloadend: (ev) => { executeFn(s.target, s.onloadend, ev); },
|
|
941
|
+
onloadstart: (ev) => { executeFn(s.target, s.onloadstart, ev); },
|
|
942
|
+
onprogress: (ev) => { executeFn(s.target, s.onprogress, ev); },
|
|
903
943
|
};
|
|
904
944
|
}
|
|
905
945
|
const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
|
|
906
946
|
|
|
907
947
|
var _a$6;
|
|
908
|
-
/** @internal */
|
|
909
|
-
const state$9 = Symbol( /* "FormDataState" */);
|
|
948
|
+
/** @internal */ const state$a = Symbol( /* "FormDataState" */);
|
|
910
949
|
class FormDataP {
|
|
911
950
|
constructor(form, submitter) {
|
|
912
951
|
if (form !== void 0) {
|
|
@@ -915,21 +954,21 @@ class FormDataP {
|
|
|
915
954
|
if (!!submitter) {
|
|
916
955
|
throw new TypeError("Failed to construct 'FormData': parameter 2 is not of type 'HTMLElement'.");
|
|
917
956
|
}
|
|
918
|
-
this[state$
|
|
957
|
+
this[state$a] = new FormDataState();
|
|
919
958
|
}
|
|
920
959
|
append(name, value, filename) {
|
|
921
|
-
this[state$
|
|
960
|
+
this[state$a][_formData].push(normalizeArgs(name, value, filename));
|
|
922
961
|
}
|
|
923
962
|
delete(name) {
|
|
924
963
|
let result = [];
|
|
925
964
|
name = String(name);
|
|
926
|
-
each(this[state$
|
|
965
|
+
each(this[state$a][_formData], entry => {
|
|
927
966
|
entry[0] !== name && result.push(entry);
|
|
928
967
|
});
|
|
929
|
-
this[state$
|
|
968
|
+
this[state$a][_formData] = result;
|
|
930
969
|
}
|
|
931
970
|
get(name) {
|
|
932
|
-
let entries = this[state$
|
|
971
|
+
let entries = this[state$a][_formData];
|
|
933
972
|
name = String(name);
|
|
934
973
|
for (let i = 0; i < entries.length; ++i) {
|
|
935
974
|
if (entries[i][0] === name) {
|
|
@@ -941,15 +980,15 @@ class FormDataP {
|
|
|
941
980
|
getAll(name) {
|
|
942
981
|
let result = [];
|
|
943
982
|
name = String(name);
|
|
944
|
-
each(this[state$
|
|
983
|
+
each(this[state$a][_formData], data => {
|
|
945
984
|
data[0] === name && result.push(data[1]);
|
|
946
985
|
});
|
|
947
986
|
return result;
|
|
948
987
|
}
|
|
949
988
|
has(name) {
|
|
950
989
|
name = String(name);
|
|
951
|
-
for (let i = 0; i < this[state$
|
|
952
|
-
if (this[state$
|
|
990
|
+
for (let i = 0; i < this[state$a][_formData].length; ++i) {
|
|
991
|
+
if (this[state$a][_formData][i][0] === name) {
|
|
953
992
|
return true;
|
|
954
993
|
}
|
|
955
994
|
}
|
|
@@ -960,27 +999,28 @@ class FormDataP {
|
|
|
960
999
|
let result = [];
|
|
961
1000
|
let args = normalizeArgs(name, value, filename);
|
|
962
1001
|
let replace = true;
|
|
963
|
-
each(this[state$
|
|
1002
|
+
each(this[state$a][_formData], data => {
|
|
964
1003
|
data[0] === name
|
|
965
1004
|
? replace && (replace = !result.push(args))
|
|
966
1005
|
: result.push(data);
|
|
967
1006
|
});
|
|
968
1007
|
replace && result.push(args);
|
|
969
|
-
this[state$
|
|
1008
|
+
this[state$a][_formData] = result;
|
|
970
1009
|
}
|
|
971
1010
|
forEach(callbackfn, thisArg) {
|
|
972
|
-
for (let
|
|
973
|
-
|
|
1011
|
+
for (let i = 0; i < this[state$a][_formData].length; ++i) {
|
|
1012
|
+
let pair = this[state$a][_formData][i];
|
|
1013
|
+
callbackfn.call(thisArg, pair[1], pair[0], thisArg);
|
|
974
1014
|
}
|
|
975
1015
|
}
|
|
976
1016
|
entries() {
|
|
977
|
-
return this[state$
|
|
1017
|
+
return this[state$a][_formData].values();
|
|
978
1018
|
}
|
|
979
1019
|
keys() {
|
|
980
|
-
return this[state$
|
|
1020
|
+
return this[state$a][_formData].map(x => x[0]).values();
|
|
981
1021
|
}
|
|
982
1022
|
values() {
|
|
983
|
-
return this[state$
|
|
1023
|
+
return this[state$a][_formData].map(x => x[1]).values();
|
|
984
1024
|
}
|
|
985
1025
|
[Symbol.iterator]() {
|
|
986
1026
|
return this.entries();
|
|
@@ -988,7 +1028,7 @@ class FormDataP {
|
|
|
988
1028
|
toString() { return "[object FormData]"; }
|
|
989
1029
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
|
|
990
1030
|
}
|
|
991
|
-
|
|
1031
|
+
dfStringTag(FormDataP, "FormData");
|
|
992
1032
|
/** @internal */
|
|
993
1033
|
const _formData = Symbol();
|
|
994
1034
|
/** @internal */
|
|
@@ -996,25 +1036,27 @@ class FormDataState {
|
|
|
996
1036
|
constructor() {
|
|
997
1037
|
this[_a$6] = [];
|
|
998
1038
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1039
|
+
}
|
|
1040
|
+
_a$6 = _formData;
|
|
1041
|
+
/** @internal */
|
|
1042
|
+
function FormData_toBlob(formData) {
|
|
1043
|
+
const boundary = "----formdata-polyfill-" + Math.random();
|
|
1044
|
+
const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
|
|
1045
|
+
let chunks = [];
|
|
1046
|
+
for (let i = 0; i < formData[state$a][_formData].length; ++i) {
|
|
1047
|
+
let pair = formData[state$a][_formData][i];
|
|
1048
|
+
let name = pair[0];
|
|
1049
|
+
let value = pair[1];
|
|
1050
|
+
if (typeof value === "string") {
|
|
1051
|
+
chunks.push(p + escape(normalizeLinefeeds(name)) + `"\r\n\r\n${normalizeLinefeeds(value)}\r\n`);
|
|
1052
|
+
}
|
|
1053
|
+
else {
|
|
1054
|
+
chunks.push(p + escape(normalizeLinefeeds(name)) + `"; filename="${escape(value.name)}"\r\nContent-Type: ${value.type || "application/octet-stream"}\r\n\r\n`, value, `\r\n`);
|
|
1010
1055
|
}
|
|
1011
|
-
chunks.push(`--${boundary}--`);
|
|
1012
|
-
return new BlobP(chunks, {
|
|
1013
|
-
type: "multipart/form-data; boundary=" + boundary,
|
|
1014
|
-
});
|
|
1015
1056
|
}
|
|
1057
|
+
chunks.push(`--${boundary}--`);
|
|
1058
|
+
return new BlobP(chunks, { type: "multipart/form-data; boundary=" + boundary });
|
|
1016
1059
|
}
|
|
1017
|
-
_a$6 = _formData;
|
|
1018
1060
|
function normalizeArgs(name, value, filename) {
|
|
1019
1061
|
if (isPolyfillType("Blob", value)) {
|
|
1020
1062
|
filename = filename !== undefined
|
|
@@ -1044,6 +1086,7 @@ function escape(str) {
|
|
|
1044
1086
|
* Parses multipart/form-data binary data, supporting restoration of text fields and files
|
|
1045
1087
|
* @param body - Text in multipart/form-data format (including boundaries and data)
|
|
1046
1088
|
* @returns Parsed FormData object (text fields as strings, files as File objects)
|
|
1089
|
+
* @internal
|
|
1047
1090
|
*/
|
|
1048
1091
|
function createFormDataFromBody(body, errMsg = "Failed to fetch") {
|
|
1049
1092
|
const formData = new FormDataP();
|
|
@@ -1123,25 +1166,29 @@ const FormDataE = g["FormData"] || FormDataP;
|
|
|
1123
1166
|
|
|
1124
1167
|
var _a$5;
|
|
1125
1168
|
/** @internal */
|
|
1126
|
-
const state$
|
|
1169
|
+
const state$9 = Symbol( /* "URLSearchParamsState" */);
|
|
1127
1170
|
class URLSearchParamsP {
|
|
1128
1171
|
constructor(init) {
|
|
1129
1172
|
let search = init || "";
|
|
1130
1173
|
if (isObjectType("URLSearchParams", search)) {
|
|
1131
1174
|
search = search.toString();
|
|
1132
1175
|
}
|
|
1133
|
-
this[state$
|
|
1134
|
-
this[state$
|
|
1176
|
+
this[state$9] = new URLSearchParamsState();
|
|
1177
|
+
this[state$9][_urlspDict] = parseToDict(search);
|
|
1135
1178
|
}
|
|
1136
1179
|
get size() {
|
|
1137
|
-
return objectValues(this[state$
|
|
1180
|
+
return objectValues(this[state$9][_urlspDict]).reduce((acc, cur) => acc + cur.length, 0);
|
|
1138
1181
|
}
|
|
1139
1182
|
append(name, value) {
|
|
1140
|
-
appendTo(this[state$
|
|
1183
|
+
appendTo(this[state$9][_urlspDict], name, value);
|
|
1141
1184
|
}
|
|
1142
1185
|
delete(name, value) {
|
|
1143
1186
|
let dict = {};
|
|
1144
|
-
|
|
1187
|
+
let pairs = objectEntries(this[state$9][_urlspDict]);
|
|
1188
|
+
for (let i = 0; i < pairs.length; ++i) {
|
|
1189
|
+
let pair = pairs[i];
|
|
1190
|
+
let key = pair[0];
|
|
1191
|
+
let values = pair[1];
|
|
1145
1192
|
if (key === name) {
|
|
1146
1193
|
if (value !== undefined) {
|
|
1147
1194
|
let vals = values.filter(x => x !== ("" + value));
|
|
@@ -1152,46 +1199,47 @@ class URLSearchParamsP {
|
|
|
1152
1199
|
}
|
|
1153
1200
|
Object.assign(dict, { [key]: values });
|
|
1154
1201
|
}
|
|
1155
|
-
this[state$
|
|
1202
|
+
this[state$9][_urlspDict] = dict;
|
|
1156
1203
|
}
|
|
1157
1204
|
get(name) {
|
|
1158
1205
|
var _b;
|
|
1159
|
-
return this.has(name) ? (_b = this[state$
|
|
1206
|
+
return this.has(name) ? (_b = this[state$9][_urlspDict][name][0]) !== null && _b !== void 0 ? _b : null : null;
|
|
1160
1207
|
}
|
|
1161
1208
|
getAll(name) {
|
|
1162
|
-
return this.has(name) ? this[state$
|
|
1209
|
+
return this.has(name) ? this[state$9][_urlspDict][name].slice(0) : [];
|
|
1163
1210
|
}
|
|
1164
1211
|
has(name, value) {
|
|
1165
|
-
if (hasOwnProperty(this[state$
|
|
1212
|
+
if (hasOwnProperty(this[state$9][_urlspDict], name)) {
|
|
1166
1213
|
if (value !== undefined) {
|
|
1167
|
-
return this[state$
|
|
1214
|
+
return this[state$9][_urlspDict][name].indexOf(("" + value)) > -1;
|
|
1168
1215
|
}
|
|
1169
1216
|
return true;
|
|
1170
1217
|
}
|
|
1171
1218
|
return false;
|
|
1172
1219
|
}
|
|
1173
1220
|
set(name, value) {
|
|
1174
|
-
this[state$
|
|
1221
|
+
this[state$9][_urlspDict][name] = ["" + value];
|
|
1175
1222
|
}
|
|
1176
1223
|
sort() {
|
|
1177
|
-
const that = this[state$
|
|
1224
|
+
const that = this[state$9];
|
|
1178
1225
|
let keys = Object.keys(that[_urlspDict]);
|
|
1179
1226
|
keys.sort();
|
|
1180
1227
|
let dict = {};
|
|
1181
|
-
for (let
|
|
1228
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
1229
|
+
let key = keys[i];
|
|
1182
1230
|
Object.assign(dict, { [key]: that[_urlspDict][key] });
|
|
1183
1231
|
}
|
|
1184
1232
|
that[_urlspDict] = dict;
|
|
1185
1233
|
}
|
|
1186
1234
|
forEach(callbackfn, thisArg) {
|
|
1187
|
-
objectEntries(this[state$
|
|
1235
|
+
objectEntries(this[state$9][_urlspDict]).forEach(([key, values]) => {
|
|
1188
1236
|
values.forEach(value => {
|
|
1189
1237
|
callbackfn.call(thisArg, value, key, this);
|
|
1190
1238
|
});
|
|
1191
1239
|
});
|
|
1192
1240
|
}
|
|
1193
1241
|
entries() {
|
|
1194
|
-
return objectEntries(this[state$
|
|
1242
|
+
return objectEntries(this[state$9][_urlspDict])
|
|
1195
1243
|
.map(([key, values]) => {
|
|
1196
1244
|
return values.map(value => {
|
|
1197
1245
|
return [key, value];
|
|
@@ -1201,19 +1249,24 @@ class URLSearchParamsP {
|
|
|
1201
1249
|
.values();
|
|
1202
1250
|
}
|
|
1203
1251
|
keys() {
|
|
1204
|
-
return Object.keys(this[state$
|
|
1252
|
+
return Object.keys(this[state$9][_urlspDict]).values();
|
|
1205
1253
|
}
|
|
1206
1254
|
values() {
|
|
1207
|
-
return objectValues(this[state$
|
|
1255
|
+
return objectValues(this[state$9][_urlspDict]).reduce(flatCb, []).values();
|
|
1208
1256
|
}
|
|
1209
1257
|
[Symbol.iterator]() {
|
|
1210
1258
|
return this.entries();
|
|
1211
1259
|
}
|
|
1212
1260
|
toString() {
|
|
1213
1261
|
let query = [];
|
|
1214
|
-
|
|
1262
|
+
let pairs = objectEntries(this[state$9][_urlspDict]);
|
|
1263
|
+
for (let i = 0; i < pairs.length; ++i) {
|
|
1264
|
+
let pair = pairs[i];
|
|
1265
|
+
let key = pair[0];
|
|
1266
|
+
let values = pair[1];
|
|
1215
1267
|
let name = encode$1(key);
|
|
1216
|
-
for (let
|
|
1268
|
+
for (let j = 0; j < values.length; ++j) {
|
|
1269
|
+
let val = values[j];
|
|
1217
1270
|
query.push(name + "=" + encode$1(val));
|
|
1218
1271
|
}
|
|
1219
1272
|
}
|
|
@@ -1221,7 +1274,7 @@ class URLSearchParamsP {
|
|
|
1221
1274
|
}
|
|
1222
1275
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
|
|
1223
1276
|
}
|
|
1224
|
-
|
|
1277
|
+
dfStringTag(URLSearchParamsP, "URLSearchParams");
|
|
1225
1278
|
/** @internal */
|
|
1226
1279
|
const _urlspDict = Symbol();
|
|
1227
1280
|
/** @internal */
|
|
@@ -1247,7 +1300,9 @@ function parseToDict(search) {
|
|
|
1247
1300
|
}
|
|
1248
1301
|
}
|
|
1249
1302
|
else {
|
|
1250
|
-
|
|
1303
|
+
let keys = Object.keys(search);
|
|
1304
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
1305
|
+
let key = keys[i];
|
|
1251
1306
|
if (search.hasOwnProperty(key)) {
|
|
1252
1307
|
appendTo(dict, key, search[key]);
|
|
1253
1308
|
}
|
|
@@ -1305,7 +1360,8 @@ function hasOwnProperty(obj, prop) {
|
|
|
1305
1360
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1306
1361
|
}
|
|
1307
1362
|
function flatCb(acc, cur) {
|
|
1308
|
-
for (let
|
|
1363
|
+
for (let i = 0; i < cur.length; ++i) {
|
|
1364
|
+
let item = cur[i];
|
|
1309
1365
|
acc.push(item);
|
|
1310
1366
|
}
|
|
1311
1367
|
return acc;
|
|
@@ -1314,36 +1370,39 @@ const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
|
|
|
1314
1370
|
|
|
1315
1371
|
var _a$4;
|
|
1316
1372
|
/** @internal */
|
|
1317
|
-
const state$
|
|
1373
|
+
const state$8 = Symbol( /* "AbortSignalState" */);
|
|
1318
1374
|
class AbortSignalP extends EventTargetP {
|
|
1319
1375
|
static abort(reason) {
|
|
1320
|
-
let signal =
|
|
1321
|
-
|
|
1376
|
+
let signal = createAbortSignal();
|
|
1377
|
+
AbortSignal_abort(signal, reason, false);
|
|
1322
1378
|
return signal;
|
|
1323
1379
|
}
|
|
1324
1380
|
static any(signals) {
|
|
1325
|
-
let signal =
|
|
1381
|
+
let signal = createAbortSignal();
|
|
1326
1382
|
let abortedSignal = signals.find(x => x.aborted);
|
|
1327
1383
|
if (abortedSignal) {
|
|
1328
|
-
|
|
1384
|
+
AbortSignal_abort(signal, abortedSignal.reason, false);
|
|
1329
1385
|
}
|
|
1330
1386
|
else {
|
|
1387
|
+
let _signals = Array.from(signals);
|
|
1331
1388
|
function abortFn(ev) {
|
|
1332
|
-
for (let
|
|
1389
|
+
for (let i = 0; i < _signals.length; ++i) {
|
|
1390
|
+
let sig = _signals[i];
|
|
1333
1391
|
sig.removeEventListener("abort", abortFn);
|
|
1334
1392
|
}
|
|
1335
|
-
|
|
1393
|
+
AbortSignal_abort(signal, this.reason, true, ev.isTrusted);
|
|
1336
1394
|
}
|
|
1337
|
-
for (let
|
|
1395
|
+
for (let i = 0; i < _signals.length; ++i) {
|
|
1396
|
+
let sig = _signals[1];
|
|
1338
1397
|
sig.addEventListener("abort", abortFn);
|
|
1339
1398
|
}
|
|
1340
1399
|
}
|
|
1341
1400
|
return signal;
|
|
1342
1401
|
}
|
|
1343
1402
|
static timeout(milliseconds) {
|
|
1344
|
-
let signal =
|
|
1403
|
+
let signal = createAbortSignal();
|
|
1345
1404
|
setTimeout(() => {
|
|
1346
|
-
|
|
1405
|
+
AbortSignal_abort(signal, new MPException("signal timed out", "TimeoutError"));
|
|
1347
1406
|
}, milliseconds);
|
|
1348
1407
|
return signal;
|
|
1349
1408
|
}
|
|
@@ -1352,24 +1411,24 @@ class AbortSignalP extends EventTargetP {
|
|
|
1352
1411
|
throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
|
|
1353
1412
|
}
|
|
1354
1413
|
super();
|
|
1355
|
-
this[state$
|
|
1414
|
+
this[state$8] = new AbortSignalState(this);
|
|
1356
1415
|
}
|
|
1357
|
-
get aborted() { return this[state$
|
|
1358
|
-
get reason() { return this[state$
|
|
1416
|
+
get aborted() { return this[state$8].aborted; }
|
|
1417
|
+
get reason() { return this[state$8].reason; }
|
|
1359
1418
|
throwIfAborted() {
|
|
1360
1419
|
if (this.aborted) {
|
|
1361
1420
|
throw this.reason;
|
|
1362
1421
|
}
|
|
1363
1422
|
}
|
|
1364
|
-
get onabort() { return this[state$
|
|
1423
|
+
get onabort() { return this[state$8].onabort; }
|
|
1365
1424
|
set onabort(value) {
|
|
1366
|
-
this[state$
|
|
1367
|
-
attachFn
|
|
1425
|
+
this[state$8].onabort = value;
|
|
1426
|
+
attachFn(this, "abort", value, this[state$8][_handlers$2].onabort);
|
|
1368
1427
|
}
|
|
1369
1428
|
toString() { return "[object AbortSignal]"; }
|
|
1370
1429
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
|
|
1371
1430
|
}
|
|
1372
|
-
|
|
1431
|
+
dfStringTag(AbortSignalP, "AbortSignal");
|
|
1373
1432
|
/** @internal */
|
|
1374
1433
|
const _handlers$2 = Symbol();
|
|
1375
1434
|
/** @internal */
|
|
@@ -1377,526 +1436,159 @@ class AbortSignalState {
|
|
|
1377
1436
|
constructor(target) {
|
|
1378
1437
|
this.aborted = false;
|
|
1379
1438
|
this.reason = undefined;
|
|
1380
|
-
this[_a$4] = getHandlers$2
|
|
1439
|
+
this[_a$4] = getHandlers$2(this);
|
|
1381
1440
|
this.onabort = null;
|
|
1382
1441
|
this.target = target;
|
|
1383
1442
|
}
|
|
1384
1443
|
}
|
|
1385
1444
|
_a$4 = _handlers$2;
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1445
|
+
/** @internal */
|
|
1446
|
+
function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
|
|
1447
|
+
const s = signal[state$8];
|
|
1448
|
+
if (!s.aborted) {
|
|
1449
|
+
s.aborted = true;
|
|
1450
|
+
s.reason = reason !== null && reason !== void 0 ? reason : (new MPException("signal is aborted without reason", "AbortError"));
|
|
1390
1451
|
if (notify) {
|
|
1391
|
-
let evt = createInnerEvent(
|
|
1392
|
-
|
|
1452
|
+
let evt = createInnerEvent(signal, "abort", undefined, isTrusted);
|
|
1453
|
+
EventTarget_fire(signal, evt);
|
|
1393
1454
|
}
|
|
1394
1455
|
}
|
|
1395
1456
|
}
|
|
1396
|
-
function getHandlers$2() {
|
|
1457
|
+
function getHandlers$2(s) {
|
|
1397
1458
|
return {
|
|
1398
|
-
onabort: (ev) => { executeFn
|
|
1459
|
+
onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
|
|
1399
1460
|
};
|
|
1400
1461
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1462
|
+
/** @internal */
|
|
1463
|
+
function createAbortSignal() {
|
|
1464
|
+
let signal = Object.create(AbortSignalP.prototype);
|
|
1465
|
+
signal[state$d] = new EventTargetState(signal);
|
|
1466
|
+
signal[state$8] = new AbortSignalState(signal);
|
|
1467
|
+
return signal;
|
|
1406
1468
|
}
|
|
1407
1469
|
const AbortSignalE = g["AbortSignal"] || AbortSignalP;
|
|
1408
1470
|
|
|
1471
|
+
var _a$3, _b$1;
|
|
1409
1472
|
/** @internal */
|
|
1410
|
-
const state$
|
|
1411
|
-
class
|
|
1473
|
+
const state$7 = Symbol( /* "BodyState" */);
|
|
1474
|
+
class BodyImpl {
|
|
1412
1475
|
constructor() {
|
|
1413
|
-
|
|
1476
|
+
if (new.target === BodyImpl) {
|
|
1477
|
+
throw new TypeError("Failed to construct 'Body': Illegal constructor");
|
|
1478
|
+
}
|
|
1479
|
+
this[state$7] = new BodyState();
|
|
1414
1480
|
}
|
|
1415
|
-
get
|
|
1416
|
-
|
|
1417
|
-
|
|
1481
|
+
get body() {
|
|
1482
|
+
if (!this[state$7][_body]) {
|
|
1483
|
+
return null;
|
|
1484
|
+
}
|
|
1485
|
+
throw new ReferenceError("ReadableStream is not defined");
|
|
1418
1486
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1487
|
+
get bodyUsed() { return this[state$7].bodyUsed; }
|
|
1488
|
+
;
|
|
1489
|
+
arrayBuffer() {
|
|
1490
|
+
const kind = "arrayBuffer";
|
|
1491
|
+
return consumed(this, kind) || read(this, kind);
|
|
1492
|
+
}
|
|
1493
|
+
blob() {
|
|
1494
|
+
const kind = "blob";
|
|
1495
|
+
return consumed(this, kind) || read(this, kind);
|
|
1496
|
+
}
|
|
1497
|
+
bytes() {
|
|
1498
|
+
const kind = "bytes";
|
|
1499
|
+
return consumed(this, kind) || read(this, kind);
|
|
1500
|
+
}
|
|
1501
|
+
formData() {
|
|
1502
|
+
const kind = "formData";
|
|
1503
|
+
return consumed(this, kind) || read(this, kind);
|
|
1504
|
+
}
|
|
1505
|
+
json() {
|
|
1506
|
+
const kind = "json";
|
|
1507
|
+
return consumed(this, kind) || read(this, kind);
|
|
1508
|
+
}
|
|
1509
|
+
text() {
|
|
1510
|
+
const kind = "text";
|
|
1511
|
+
return consumed(this, kind) || read(this, kind);
|
|
1512
|
+
}
|
|
1513
|
+
toString() { return "[object Body]"; }
|
|
1514
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
|
|
1421
1515
|
}
|
|
1422
|
-
|
|
1516
|
+
dfStringTag(BodyImpl, "Body");
|
|
1517
|
+
/** @internal */ const _name = Symbol();
|
|
1518
|
+
/** @internal */ const _body = Symbol();
|
|
1423
1519
|
/** @internal */
|
|
1424
|
-
class
|
|
1520
|
+
class BodyState {
|
|
1425
1521
|
constructor() {
|
|
1426
|
-
this.
|
|
1522
|
+
this.bodyUsed = false;
|
|
1523
|
+
this[_a$3] = "Body";
|
|
1524
|
+
this[_b$1] = "";
|
|
1427
1525
|
}
|
|
1428
1526
|
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
var _a$3;
|
|
1527
|
+
_a$3 = _name, _b$1 = _body;
|
|
1432
1528
|
/** @internal */
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1529
|
+
function Body_init(body, payload, headers) {
|
|
1530
|
+
if (isObjectType("ReadableStream", payload)) {
|
|
1531
|
+
throw new ReferenceError("ReadableStream is not defined");
|
|
1532
|
+
}
|
|
1533
|
+
body[state$7][_body] = convert(payload, type => {
|
|
1534
|
+
if (headers && !headers.get("Content-Type")) {
|
|
1535
|
+
headers.set("Content-Type", type);
|
|
1438
1536
|
}
|
|
1439
|
-
|
|
1440
|
-
this[state$5] = new XMLHttpRequestEventTargetState(this);
|
|
1441
|
-
}
|
|
1442
|
-
get onabort() { return this[state$5].onabort; }
|
|
1443
|
-
set onabort(value) { this[state$5].onabort = value; attach.call(this[state$5], "abort"); }
|
|
1444
|
-
get onerror() { return this[state$5].onerror; }
|
|
1445
|
-
set onerror(value) { this[state$5].onerror = value; attach.call(this[state$5], "error"); }
|
|
1446
|
-
get onload() { return this[state$5].onload; }
|
|
1447
|
-
set onload(value) { this[state$5].onload = value; attach.call(this[state$5], "load"); }
|
|
1448
|
-
get onloadend() { return this[state$5].onloadend; }
|
|
1449
|
-
set onloadend(value) { this[state$5].onloadend = value; attach.call(this[state$5], "loadend"); }
|
|
1450
|
-
get onloadstart() { return this[state$5].onloadstart; }
|
|
1451
|
-
set onloadstart(value) { this[state$5].onloadstart = value; attach.call(this[state$5], "loadstart"); }
|
|
1452
|
-
get onprogress() { return this[state$5].onprogress; }
|
|
1453
|
-
set onprogress(value) { this[state$5].onprogress = value; attach.call(this[state$5], "progress"); }
|
|
1454
|
-
get ontimeout() { return this[state$5].ontimeout; }
|
|
1455
|
-
set ontimeout(value) { this[state$5].ontimeout = value; attach.call(this[state$5], "timeout"); }
|
|
1456
|
-
toString() { return "[object XMLHttpRequestEventTarget]"; }
|
|
1457
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1537
|
+
});
|
|
1458
1538
|
}
|
|
1459
|
-
defineStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
|
|
1460
1539
|
/** @internal */
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
class XMLHttpRequestEventTargetState {
|
|
1464
|
-
/**
|
|
1465
|
-
* @param _target XMLHttpRequestEventTargetP
|
|
1466
|
-
*/
|
|
1467
|
-
constructor(_target) {
|
|
1468
|
-
this[_a$3] = getHandlers$1.call(this);
|
|
1469
|
-
this.onabort = null;
|
|
1470
|
-
this.onerror = null;
|
|
1471
|
-
this.onload = null;
|
|
1472
|
-
this.onloadend = null;
|
|
1473
|
-
this.onloadstart = null;
|
|
1474
|
-
this.onprogress = null;
|
|
1475
|
-
this.ontimeout = null;
|
|
1476
|
-
this.target = _target;
|
|
1477
|
-
}
|
|
1540
|
+
function Body_setName(body, name) {
|
|
1541
|
+
body[state$7][_name] = name;
|
|
1478
1542
|
}
|
|
1479
|
-
|
|
1480
|
-
function
|
|
1481
|
-
|
|
1482
|
-
const cb = this[fnName];
|
|
1483
|
-
const listener = this[_handlers$1][fnName];
|
|
1484
|
-
attachFn.call(this.target, type, cb, listener);
|
|
1543
|
+
/** @internal */
|
|
1544
|
+
function Body_setBodyUsed(body, bodyUsed) {
|
|
1545
|
+
body[state$7].bodyUsed = bodyUsed;
|
|
1485
1546
|
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
onerror: (ev) => { executeFn.call(this.target, this.onerror, ev); },
|
|
1490
|
-
onload: (ev) => { executeFn.call(this.target, this.onload, ev); },
|
|
1491
|
-
onloadend: (ev) => { executeFn.call(this.target, this.onloadend, ev); },
|
|
1492
|
-
onloadstart: (ev) => { executeFn.call(this.target, this.onloadstart, ev); },
|
|
1493
|
-
onprogress: (ev) => { executeFn.call(this.target, this.onprogress, ev); },
|
|
1494
|
-
ontimeout: (ev) => { executeFn.call(this.target, this.ontimeout, ev); },
|
|
1495
|
-
};
|
|
1547
|
+
/** @internal */
|
|
1548
|
+
function Body_toPayload(body) {
|
|
1549
|
+
return body[state$7][_body];
|
|
1496
1550
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
throw new TypeError("Failed to construct 'XMLHttpRequestUpload': Illegal constructor");
|
|
1551
|
+
function read(body, kind) {
|
|
1552
|
+
return new Promise((resolve, reject) => {
|
|
1553
|
+
try {
|
|
1554
|
+
resolve(readSync(body, kind));
|
|
1502
1555
|
}
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
toString() { return "[object XMLHttpRequestUpload]"; }
|
|
1506
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1507
|
-
}
|
|
1508
|
-
defineStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
|
|
1509
|
-
function createXMLHttpRequestUploadP() {
|
|
1510
|
-
let instance = Object.create(XMLHttpRequestUploadP.prototype);
|
|
1511
|
-
instance[state$f] = new EventTargetState(instance);
|
|
1512
|
-
instance[state$5] = new XMLHttpRequestEventTargetState(instance);
|
|
1513
|
-
return instance;
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
// @ts-nocheck
|
|
1517
|
-
const mp = (() => {
|
|
1518
|
-
let u = "undefined", r = "request", f = "function";
|
|
1519
|
-
let mp;
|
|
1520
|
-
mp =
|
|
1521
|
-
(typeof wx !== u && typeof (wx === null || wx === void 0 ? void 0 : wx[r]) === f && wx) || // 微信
|
|
1522
|
-
(typeof my !== u && typeof (my === null || my === void 0 ? void 0 : my[r]) === f && my) || // 支付宝
|
|
1523
|
-
(typeof qq !== u && typeof (qq === null || qq === void 0 ? void 0 : qq[r]) === f && qq) || // QQ
|
|
1524
|
-
(typeof jd !== u && typeof (jd === null || jd === void 0 ? void 0 : jd[r]) === f && jd) || // 京东
|
|
1525
|
-
(typeof swan !== u && typeof (swan === null || swan === void 0 ? void 0 : swan[r]) === f && swan) || // 百度
|
|
1526
|
-
(typeof tt !== u && typeof (tt === null || tt === void 0 ? void 0 : tt[r]) === f && tt) || // 抖音 | 飞书
|
|
1527
|
-
(typeof ks !== u && typeof (ks === null || ks === void 0 ? void 0 : ks[r]) === f && ks) || // 快手
|
|
1528
|
-
(typeof qh !== u && typeof (qh === null || qh === void 0 ? void 0 : qh[r]) === f && qh) || // 360
|
|
1529
|
-
(typeof xhs !== u && typeof (xhs === null || xhs === void 0 ? void 0 : xhs[r]) === f && xhs) || // 小红书
|
|
1530
|
-
undefined;
|
|
1531
|
-
if (typeof g["XMLHttpRequest"] === f) {
|
|
1532
|
-
return;
|
|
1533
|
-
}
|
|
1534
|
-
if (mp === undefined)
|
|
1535
|
-
mp =
|
|
1536
|
-
(typeof uni !== u && typeof (uni === null || uni === void 0 ? void 0 : uni[r]) === f && uni) || // UniApp
|
|
1537
|
-
(typeof Taro !== u && typeof (Taro === null || Taro === void 0 ? void 0 : Taro[r]) === f && Taro) || // Taro
|
|
1538
|
-
undefined;
|
|
1539
|
-
return mp;
|
|
1540
|
-
})();
|
|
1541
|
-
|
|
1542
|
-
const request = mp ? mp.request : function errorRequest(options) {
|
|
1543
|
-
const errMsg = "NOT_SUPPORTED_ERR";
|
|
1544
|
-
const errno = 9;
|
|
1545
|
-
const err = {
|
|
1546
|
-
errMsg,
|
|
1547
|
-
errno,
|
|
1548
|
-
exception: {
|
|
1549
|
-
retryCount: 0,
|
|
1550
|
-
reasons: [{ errMsg, errno }],
|
|
1551
|
-
},
|
|
1552
|
-
useHttpDNS: false,
|
|
1553
|
-
};
|
|
1554
|
-
Promise.resolve(err)
|
|
1555
|
-
.then(err => { try {
|
|
1556
|
-
if (options.fail) {
|
|
1557
|
-
options.fail(err);
|
|
1556
|
+
catch (e) {
|
|
1557
|
+
reject(e);
|
|
1558
1558
|
}
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
function readSync(body, kind) {
|
|
1562
|
+
const payload = body[state$7][_body];
|
|
1563
|
+
if (kind === "arrayBuffer") {
|
|
1564
|
+
return convertBack("arraybuffer", payload);
|
|
1559
1565
|
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
} })
|
|
1563
|
-
.then(() => { if (options.complete) {
|
|
1564
|
-
options.complete(err);
|
|
1565
|
-
} });
|
|
1566
|
-
throw new ReferenceError("request is not defined");
|
|
1567
|
-
};
|
|
1568
|
-
|
|
1569
|
-
var _a$2, _b$1, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1570
|
-
/** @internal */
|
|
1571
|
-
const state$4 = Symbol( /* "XMLHttpRequestState" */);
|
|
1572
|
-
class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
1573
|
-
constructor() {
|
|
1574
|
-
super();
|
|
1575
|
-
this[state$4] = new XMLHttpRequestState(this);
|
|
1566
|
+
else if (kind === "blob") {
|
|
1567
|
+
return convertBack("blob", payload);
|
|
1576
1568
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
get responseType() { return this[state$4].responseType; }
|
|
1581
|
-
set responseType(value) { this[state$4].responseType = value; }
|
|
1582
|
-
get responseURL() { return this[state$4].responseURL; }
|
|
1583
|
-
get responseXML() { return null; }
|
|
1584
|
-
get status() { return this[state$4].status; }
|
|
1585
|
-
get statusText() {
|
|
1586
|
-
if (this.readyState === XMLHttpRequestP.UNSENT || this.readyState === XMLHttpRequestP.OPENED)
|
|
1587
|
-
return "";
|
|
1588
|
-
return this[state$4].statusText || statusTextMap(this.status);
|
|
1569
|
+
else if (kind === "bytes") {
|
|
1570
|
+
let arrayBuffer = convertBack("arraybuffer", payload);
|
|
1571
|
+
return new Uint8Array(arrayBuffer);
|
|
1589
1572
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
const that = this[state$4];
|
|
1594
|
-
if (!that.upload) {
|
|
1595
|
-
that.upload = createXMLHttpRequestUploadP();
|
|
1596
|
-
}
|
|
1597
|
-
return that.upload;
|
|
1598
|
-
}
|
|
1599
|
-
get withCredentials() { return this[state$4].withCredentials; }
|
|
1600
|
-
set withCredentials(value) { this[state$4].withCredentials = value; }
|
|
1601
|
-
abort() {
|
|
1602
|
-
clearRequest.call(this[state$4]);
|
|
1603
|
-
}
|
|
1604
|
-
getAllResponseHeaders() {
|
|
1605
|
-
if (!this[state$4][_responseHeaders])
|
|
1606
|
-
return "";
|
|
1607
|
-
return objectEntries(this[state$4][_responseHeaders] || {}).map(([k, v]) => `${k}: ${v}\r\n`).join("");
|
|
1608
|
-
}
|
|
1609
|
-
getResponseHeader(name) {
|
|
1610
|
-
var _l, _m;
|
|
1611
|
-
if (!this[state$4][_responseHeaders])
|
|
1612
|
-
return null;
|
|
1613
|
-
let nameKey = name.toLowerCase();
|
|
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;
|
|
1615
|
-
}
|
|
1616
|
-
open(...args) {
|
|
1617
|
-
const [method, url, async = true, username = null, password = null] = args;
|
|
1618
|
-
const that = this[state$4];
|
|
1619
|
-
if (args.length < 2) {
|
|
1620
|
-
throw new TypeError(`Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${args.length} present.`);
|
|
1621
|
-
}
|
|
1622
|
-
if (!async) {
|
|
1623
|
-
console.warn("Synchronous XMLHttpRequest is not supported because of its detrimental effects to the end user's experience.");
|
|
1624
|
-
}
|
|
1625
|
-
clearRequest.call(that, false);
|
|
1626
|
-
that[_method] = normalizeMethod(method);
|
|
1627
|
-
that[_requestURL] = String(url);
|
|
1628
|
-
if (username !== null || password !== null) {
|
|
1629
|
-
let _username = String(username !== null && username !== void 0 ? username : "");
|
|
1630
|
-
let _password = String(password !== null && password !== void 0 ? password : "");
|
|
1631
|
-
if (_username.length > 0 || _password.length > 0) {
|
|
1632
|
-
let auth = `Basic ${u8array2base64((new TextEncoderP()).encode(_username + ":" + _password))}`;
|
|
1633
|
-
this.setRequestHeader("Authorization", auth);
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
that[_inAfterOpenBeforeSend] = true;
|
|
1637
|
-
setReadyStateAndNotify.call(that, XMLHttpRequestP.OPENED);
|
|
1638
|
-
}
|
|
1639
|
-
overrideMimeType(mime) {
|
|
1640
|
-
if (this[state$4][_inAfterOpenBeforeSend]) {
|
|
1641
|
-
console.warn(`XMLHttpRequest.overrideMimeType('${mime}') is not implemented: The method will have no effect on response parsing.`);
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
send(body) {
|
|
1645
|
-
const that = this[state$4];
|
|
1646
|
-
if (!that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED) {
|
|
1647
|
-
throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
1648
|
-
}
|
|
1649
|
-
that[_inAfterOpenBeforeSend] = false;
|
|
1650
|
-
const allowsRequestBody = that[_method] !== "GET" && that[_method] !== "HEAD";
|
|
1651
|
-
const processHeaders = allowsRequestBody && Object.keys(that[_requestHeaders]).map(x => x.toLowerCase()).indexOf("content-type") === -1;
|
|
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;
|
|
1656
|
-
let data = convert(body, processHeaders ? v => { assignRequestHeader(headers, "Content-Type", v); } : void 0, processContentLength ? v => { contentLength = v; } : void 0);
|
|
1657
|
-
let options = {
|
|
1658
|
-
url: that[_requestURL],
|
|
1659
|
-
method: that[_method],
|
|
1660
|
-
header: headers,
|
|
1661
|
-
data,
|
|
1662
|
-
dataType: that.responseType === "json" ? "json" : normalizeDataType(that.responseType),
|
|
1663
|
-
responseType: normalizeDataType(that.responseType),
|
|
1664
|
-
success: requestSuccess.bind(that),
|
|
1665
|
-
fail: requestFail.bind(that),
|
|
1666
|
-
complete: requestComplete.bind(that),
|
|
1667
|
-
};
|
|
1668
|
-
if (that.withCredentials) {
|
|
1669
|
-
options.withCredentials = true;
|
|
1670
|
-
options.enableCookie = true;
|
|
1671
|
-
}
|
|
1672
|
-
that[_requestTask] = request(options);
|
|
1673
|
-
emitProcessEvent(this, "loadstart");
|
|
1674
|
-
if (processContentLength) {
|
|
1675
|
-
const hasRequestBody = allowsRequestBody && (typeof data === "string" ? data.length > 0 : data.byteLength > 0);
|
|
1676
|
-
if (hasRequestBody) {
|
|
1677
|
-
emitProcessEvent(upload, "loadstart", 0, contentLength);
|
|
1678
|
-
}
|
|
1679
|
-
setTimeout(() => {
|
|
1680
|
-
const _aborted = that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED;
|
|
1681
|
-
const _contentLength = _aborted ? 0 : contentLength;
|
|
1682
|
-
if (_aborted) {
|
|
1683
|
-
emitProcessEvent(upload, "abort");
|
|
1684
|
-
}
|
|
1685
|
-
else {
|
|
1686
|
-
if (hasRequestBody) {
|
|
1687
|
-
emitProcessEvent(upload, "load", _contentLength, _contentLength);
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
if (_aborted || hasRequestBody) {
|
|
1691
|
-
emitProcessEvent(upload, "loadend", _contentLength, _contentLength);
|
|
1692
|
-
}
|
|
1693
|
-
});
|
|
1694
|
-
}
|
|
1695
|
-
checkRequestTimeout.call(that);
|
|
1696
|
-
}
|
|
1697
|
-
setRequestHeader(name, value) {
|
|
1698
|
-
assignRequestHeader(this[state$4][_requestHeaders], name, value);
|
|
1699
|
-
}
|
|
1700
|
-
get onreadystatechange() { return this[state$4].onreadystatechange; }
|
|
1701
|
-
set onreadystatechange(value) {
|
|
1702
|
-
this[state$4].onreadystatechange = value;
|
|
1703
|
-
attachFn.call(this, "readystatechange", value, this[state$4][_handlers].onreadystatechange);
|
|
1573
|
+
else if (kind === "formData") {
|
|
1574
|
+
let text = convertBack("text", payload);
|
|
1575
|
+
return createFormDataFromBody(text);
|
|
1704
1576
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
}
|
|
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);
|
|
1717
|
-
defineStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
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();
|
|
1725
|
-
const _responseHeaders = Symbol();
|
|
1726
|
-
/** @internal */ const _responseContentLength = Symbol();
|
|
1727
|
-
/** @internal */ const _requestTask = Symbol();
|
|
1728
|
-
/** @internal */
|
|
1729
|
-
class XMLHttpRequestState {
|
|
1730
|
-
constructor(target) {
|
|
1731
|
-
this.readyState = XMLHttpRequestP.UNSENT;
|
|
1732
|
-
this.response = "";
|
|
1733
|
-
this.responseType = "";
|
|
1734
|
-
this.responseURL = "";
|
|
1735
|
-
this.status = 0;
|
|
1736
|
-
this.statusText = "";
|
|
1737
|
-
this.timeout = 0;
|
|
1738
|
-
this.withCredentials = false;
|
|
1739
|
-
this[_a$2] = getHandlers.call(this);
|
|
1740
|
-
this.onreadystatechange = null;
|
|
1741
|
-
this[_b$1] = false;
|
|
1742
|
-
this[_c] = false;
|
|
1743
|
-
this[_d] = 0;
|
|
1744
|
-
this[_e] = "";
|
|
1745
|
-
this[_f] = "GET";
|
|
1746
|
-
this[_g] = { Accept: "*/*" };
|
|
1747
|
-
this[_h] = null;
|
|
1748
|
-
this[_j] = zero;
|
|
1749
|
-
this[_k] = null;
|
|
1750
|
-
this.target = target;
|
|
1577
|
+
else if (kind === "json") {
|
|
1578
|
+
return convertBack("json", payload);
|
|
1751
1579
|
}
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
function requestSuccess({ statusCode, header, data }) {
|
|
1755
|
-
this.responseURL = this[_requestURL];
|
|
1756
|
-
this.status = statusCode;
|
|
1757
|
-
this[_responseHeaders] = header;
|
|
1758
|
-
let lengthStr = this.target.getResponseHeader("Content-Length");
|
|
1759
|
-
this[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
|
|
1760
|
-
if (this.readyState === XMLHttpRequestP.OPENED) {
|
|
1761
|
-
setReadyStateAndNotify.call(this, XMLHttpRequestP.HEADERS_RECEIVED);
|
|
1762
|
-
setReadyStateAndNotify.call(this, XMLHttpRequestP.LOADING);
|
|
1763
|
-
setTimeout(() => {
|
|
1764
|
-
if (!this[_inAfterOpenBeforeSend]) {
|
|
1765
|
-
let l = this[_responseContentLength];
|
|
1766
|
-
try {
|
|
1767
|
-
this.response = convertBack(this.responseType, data);
|
|
1768
|
-
emitProcessEvent(this.target, "load", l, l);
|
|
1769
|
-
}
|
|
1770
|
-
catch (e) {
|
|
1771
|
-
console.error(e);
|
|
1772
|
-
emitProcessEvent(this.target, "error");
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
});
|
|
1580
|
+
else {
|
|
1581
|
+
return convertBack("text", payload);
|
|
1776
1582
|
}
|
|
1777
1583
|
}
|
|
1778
|
-
function
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
// error: 19 --- http status error
|
|
1782
|
-
// At this point, the error data object will contain three pieces of information
|
|
1783
|
-
// returned from the server: status, headers, and data.
|
|
1784
|
-
// In the browser's XMLHttpRequest, these two errors (Error 14 and Error 19)
|
|
1785
|
-
// differ from those in Alipay Mini Programs and should instead return normally.
|
|
1786
|
-
// Therefore, this scenario is also handled here as a successful request response.
|
|
1787
|
-
if ("status" in err) {
|
|
1788
|
-
requestSuccess.call(this, { statusCode: err.status, header: err.headers, data: err.data });
|
|
1584
|
+
function consumed(body, kind) {
|
|
1585
|
+
const s = body[state$7];
|
|
1586
|
+
if (!s[_body])
|
|
1789
1587
|
return;
|
|
1588
|
+
if (s.bodyUsed) {
|
|
1589
|
+
return Promise.reject(new TypeError(`TypeError: Failed to execute '${kind}' on '${s[_name]}': body stream already read`));
|
|
1790
1590
|
}
|
|
1791
|
-
|
|
1792
|
-
this.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
|
|
1793
|
-
if (!this[_inAfterOpenBeforeSend] && this.readyState !== XMLHttpRequestP.UNSENT && this.readyState !== XMLHttpRequestP.DONE) {
|
|
1794
|
-
emitProcessEvent(this.target, "error");
|
|
1795
|
-
resetRequestTimeout.call(this);
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
function requestComplete() {
|
|
1799
|
-
this[_requestTask] = null;
|
|
1800
|
-
if (!this[_inAfterOpenBeforeSend] && (this.readyState === XMLHttpRequestP.OPENED || this.readyState === XMLHttpRequestP.LOADING)) {
|
|
1801
|
-
setReadyStateAndNotify.call(this, XMLHttpRequestP.DONE);
|
|
1802
|
-
}
|
|
1803
|
-
setTimeout(() => {
|
|
1804
|
-
if (!this[_inAfterOpenBeforeSend]) {
|
|
1805
|
-
let l = this[_responseContentLength];
|
|
1806
|
-
emitProcessEvent(this.target, "loadend", l, l);
|
|
1807
|
-
}
|
|
1808
|
-
});
|
|
1809
|
-
}
|
|
1810
|
-
function clearRequest(delay = true) {
|
|
1811
|
-
const timerFn = delay ? setTimeout : (f) => { f(); };
|
|
1812
|
-
this[_resetPending] = true;
|
|
1813
|
-
if (this[_requestTask] && this.readyState !== XMLHttpRequestP.DONE) {
|
|
1814
|
-
if (delay) {
|
|
1815
|
-
setReadyStateAndNotify.call(this, XMLHttpRequestP.DONE);
|
|
1816
|
-
}
|
|
1817
|
-
timerFn(() => {
|
|
1818
|
-
const requestTask = this[_requestTask];
|
|
1819
|
-
if (requestTask) {
|
|
1820
|
-
requestTask.abort();
|
|
1821
|
-
}
|
|
1822
|
-
if (delay) {
|
|
1823
|
-
emitProcessEvent(this.target, "abort");
|
|
1824
|
-
}
|
|
1825
|
-
if (delay && !requestTask) {
|
|
1826
|
-
emitProcessEvent(this.target, "loadend");
|
|
1827
|
-
}
|
|
1828
|
-
});
|
|
1829
|
-
}
|
|
1830
|
-
timerFn(() => {
|
|
1831
|
-
if (this[_resetPending]) {
|
|
1832
|
-
if (delay) {
|
|
1833
|
-
this.readyState = XMLHttpRequestP.UNSENT;
|
|
1834
|
-
}
|
|
1835
|
-
resetXHR.call(this);
|
|
1836
|
-
}
|
|
1837
|
-
});
|
|
1838
|
-
}
|
|
1839
|
-
function checkRequestTimeout() {
|
|
1840
|
-
if (this.timeout) {
|
|
1841
|
-
this[_timeoutId] = setTimeout(() => {
|
|
1842
|
-
if (!this.status && this.readyState !== XMLHttpRequestP.DONE) {
|
|
1843
|
-
if (this[_requestTask])
|
|
1844
|
-
this[_requestTask].abort();
|
|
1845
|
-
setReadyStateAndNotify.call(this, XMLHttpRequestP.DONE);
|
|
1846
|
-
emitProcessEvent(this.target, "timeout");
|
|
1847
|
-
}
|
|
1848
|
-
}, this.timeout);
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
function resetXHR() {
|
|
1852
|
-
this[_resetPending] = false;
|
|
1853
|
-
resetRequestTimeout.call(this);
|
|
1854
|
-
this.response = "";
|
|
1855
|
-
this.responseURL = "";
|
|
1856
|
-
this.status = 0;
|
|
1857
|
-
this.statusText = "";
|
|
1858
|
-
this[_requestHeaders] = {};
|
|
1859
|
-
this[_responseHeaders] = null;
|
|
1860
|
-
this[_responseContentLength] = zero;
|
|
1861
|
-
}
|
|
1862
|
-
function resetRequestTimeout() {
|
|
1863
|
-
if (this[_timeoutId]) {
|
|
1864
|
-
clearTimeout(this[_timeoutId]);
|
|
1865
|
-
this[_timeoutId] = 0;
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
function setReadyStateAndNotify(value) {
|
|
1869
|
-
let hasChanged = value !== this.readyState;
|
|
1870
|
-
this.readyState = value;
|
|
1871
|
-
if (hasChanged) {
|
|
1872
|
-
let evt = createInnerEvent(this.target, "readystatechange");
|
|
1873
|
-
fire.call(this.target[state$f], evt);
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
function getHandlers() {
|
|
1877
|
-
return {
|
|
1878
|
-
onreadystatechange: (ev) => { executeFn.call(this.target, this.onreadystatechange, ev); },
|
|
1879
|
-
};
|
|
1880
|
-
}
|
|
1881
|
-
// HTTP methods whose capitalization should be normalized
|
|
1882
|
-
const methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
|
|
1883
|
-
function normalizeMethod(method) {
|
|
1884
|
-
let upcased = method.toUpperCase();
|
|
1885
|
-
return methods.indexOf(upcased) > -1 ? upcased : method;
|
|
1886
|
-
}
|
|
1887
|
-
function normalizeDataType(responseType) {
|
|
1888
|
-
return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
|
|
1889
|
-
}
|
|
1890
|
-
function assignRequestHeader(headers, name, value) {
|
|
1891
|
-
let nameKey = name.toLowerCase();
|
|
1892
|
-
for (let key of Object.keys(headers)) {
|
|
1893
|
-
if (key.toLowerCase() === nameKey) {
|
|
1894
|
-
headers[key] = value;
|
|
1895
|
-
return;
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
Object.assign(headers, { [name]: value });
|
|
1899
|
-
return;
|
|
1591
|
+
s.bodyUsed = true;
|
|
1900
1592
|
}
|
|
1901
1593
|
const encode = (str) => {
|
|
1902
1594
|
const encoder = new TextEncoderP();
|
|
@@ -1906,6 +1598,7 @@ const decode = (buf) => {
|
|
|
1906
1598
|
let decoder = new TextDecoderP();
|
|
1907
1599
|
return decoder.decode(buf);
|
|
1908
1600
|
};
|
|
1601
|
+
/** @internal */
|
|
1909
1602
|
function convert(body, setContentType, setContentLength) {
|
|
1910
1603
|
let result;
|
|
1911
1604
|
if (typeof body === "string") {
|
|
@@ -1927,14 +1620,14 @@ function convert(body, setContentType, setContentLength) {
|
|
|
1927
1620
|
result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
1928
1621
|
}
|
|
1929
1622
|
else if (isPolyfillType("Blob", body)) {
|
|
1930
|
-
result = body
|
|
1623
|
+
result = Blob_toUint8Array(body).buffer.slice(0);
|
|
1931
1624
|
if (setContentType && body.type) {
|
|
1932
1625
|
setContentType(body.type);
|
|
1933
1626
|
}
|
|
1934
1627
|
}
|
|
1935
1628
|
else if (isPolyfillType("FormData", body)) {
|
|
1936
|
-
let blob = body
|
|
1937
|
-
result = blob
|
|
1629
|
+
let blob = FormData_toBlob(body);
|
|
1630
|
+
result = Blob_toUint8Array(blob).buffer;
|
|
1938
1631
|
if (setContentType) {
|
|
1939
1632
|
setContentType(blob.type);
|
|
1940
1633
|
}
|
|
@@ -1946,12 +1639,11 @@ function convert(body, setContentType, setContentLength) {
|
|
|
1946
1639
|
result = String(body);
|
|
1947
1640
|
}
|
|
1948
1641
|
if (setContentLength) {
|
|
1949
|
-
setContentLength(() =>
|
|
1950
|
-
return (typeof result === "string" ? encode(result) : result).byteLength;
|
|
1951
|
-
});
|
|
1642
|
+
setContentLength(() => (typeof result === "string" ? encode(result) : result).byteLength);
|
|
1952
1643
|
}
|
|
1953
1644
|
return result;
|
|
1954
1645
|
}
|
|
1646
|
+
/** @internal */
|
|
1955
1647
|
function convertBack(type, data) {
|
|
1956
1648
|
let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
|
|
1957
1649
|
if (!type || type === "text") {
|
|
@@ -1970,189 +1662,13 @@ function convertBack(type, data) {
|
|
|
1970
1662
|
return temp;
|
|
1971
1663
|
}
|
|
1972
1664
|
}
|
|
1973
|
-
const zero = () => 0;
|
|
1974
|
-
const statusMessages = {
|
|
1975
|
-
100: "Continue",
|
|
1976
|
-
101: "Switching Protocols",
|
|
1977
|
-
102: "Processing",
|
|
1978
|
-
103: "Early Hints",
|
|
1979
|
-
200: "OK",
|
|
1980
|
-
201: "Created",
|
|
1981
|
-
202: "Accepted",
|
|
1982
|
-
203: "Non-Authoritative Information",
|
|
1983
|
-
204: "No Content",
|
|
1984
|
-
205: "Reset Content",
|
|
1985
|
-
206: "Partial Content",
|
|
1986
|
-
207: "Multi-Status",
|
|
1987
|
-
208: "Already Reported",
|
|
1988
|
-
226: "IM Used",
|
|
1989
|
-
300: "Multiple Choices",
|
|
1990
|
-
301: "Moved Permanently",
|
|
1991
|
-
302: "Found",
|
|
1992
|
-
303: "See Other",
|
|
1993
|
-
304: "Not Modified",
|
|
1994
|
-
307: "Temporary Redirect",
|
|
1995
|
-
308: "Permanent Redirect",
|
|
1996
|
-
400: "Bad Request",
|
|
1997
|
-
401: "Unauthorized",
|
|
1998
|
-
402: "Payment Required",
|
|
1999
|
-
403: "Forbidden",
|
|
2000
|
-
404: "Not Found",
|
|
2001
|
-
405: "Method Not Allowed",
|
|
2002
|
-
406: "Not Acceptable",
|
|
2003
|
-
407: "Proxy Authentication Required",
|
|
2004
|
-
408: "Request Timeout",
|
|
2005
|
-
409: "Conflict",
|
|
2006
|
-
410: "Gone",
|
|
2007
|
-
411: "Length Required",
|
|
2008
|
-
412: "Precondition Failed",
|
|
2009
|
-
413: "Content Too Large",
|
|
2010
|
-
414: "URI Too Long",
|
|
2011
|
-
415: "Unsupported Media Type",
|
|
2012
|
-
416: "Range Not Satisfiable",
|
|
2013
|
-
417: "Expectation Failed",
|
|
2014
|
-
418: "I'm a teapot",
|
|
2015
|
-
421: "Misdirected Request",
|
|
2016
|
-
422: "Unprocessable Entity",
|
|
2017
|
-
423: "Locked",
|
|
2018
|
-
424: "Failed Dependency",
|
|
2019
|
-
425: "Too Early",
|
|
2020
|
-
426: "Upgrade Required",
|
|
2021
|
-
428: "Precondition Required",
|
|
2022
|
-
429: "Too Many Requests",
|
|
2023
|
-
431: "Request Header Fields Too Large",
|
|
2024
|
-
451: "Unavailable For Legal Reasons",
|
|
2025
|
-
500: "Internal Server Error",
|
|
2026
|
-
501: "Not Implemented",
|
|
2027
|
-
502: "Bad Gateway",
|
|
2028
|
-
503: "Service Unavailable",
|
|
2029
|
-
504: "Gateway Timeout",
|
|
2030
|
-
505: "HTTP Version Not Supported",
|
|
2031
|
-
506: "Variant Also Negotiates",
|
|
2032
|
-
507: "Insufficient Storage",
|
|
2033
|
-
508: "Loop Detected",
|
|
2034
|
-
510: "Not Extended",
|
|
2035
|
-
511: "Network Authentication Required"
|
|
2036
|
-
};
|
|
2037
|
-
function statusTextMap(val) {
|
|
2038
|
-
return statusMessages[val] || "unknown";
|
|
2039
|
-
}
|
|
2040
|
-
const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
|
|
2041
|
-
|
|
2042
|
-
var _a$1, _b;
|
|
2043
|
-
/** @internal */
|
|
2044
|
-
const state$3 = Symbol( /* "BodyState" */);
|
|
2045
|
-
class BodyP {
|
|
2046
|
-
constructor() {
|
|
2047
|
-
if (new.target === BodyP) {
|
|
2048
|
-
throw new TypeError("Failed to construct 'Body': Illegal constructor");
|
|
2049
|
-
}
|
|
2050
|
-
this[state$3] = new BodyState();
|
|
2051
|
-
}
|
|
2052
|
-
get body() {
|
|
2053
|
-
if (!this[state$3][_body]) {
|
|
2054
|
-
return null;
|
|
2055
|
-
}
|
|
2056
|
-
throw new ReferenceError("ReadableStream is not defined");
|
|
2057
|
-
}
|
|
2058
|
-
get bodyUsed() { return this[state$3].bodyUsed; }
|
|
2059
|
-
;
|
|
2060
|
-
arrayBuffer() {
|
|
2061
|
-
const kind = "arrayBuffer";
|
|
2062
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2063
|
-
}
|
|
2064
|
-
blob() {
|
|
2065
|
-
const kind = "blob";
|
|
2066
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2067
|
-
}
|
|
2068
|
-
bytes() {
|
|
2069
|
-
const kind = "bytes";
|
|
2070
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2071
|
-
}
|
|
2072
|
-
formData() {
|
|
2073
|
-
const kind = "formData";
|
|
2074
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2075
|
-
}
|
|
2076
|
-
json() {
|
|
2077
|
-
const kind = "json";
|
|
2078
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2079
|
-
}
|
|
2080
|
-
text() {
|
|
2081
|
-
const kind = "text";
|
|
2082
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2083
|
-
}
|
|
2084
|
-
toString() { return "[object Body]"; }
|
|
2085
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
|
|
2086
|
-
}
|
|
2087
|
-
defineStringTag(BodyP, "Body");
|
|
2088
|
-
const _name = Symbol();
|
|
2089
|
-
const _body = Symbol();
|
|
2090
|
-
/** @internal */
|
|
2091
|
-
class BodyState {
|
|
2092
|
-
constructor() {
|
|
2093
|
-
this.bodyUsed = false;
|
|
2094
|
-
this[_a$1] = "Body";
|
|
2095
|
-
this[_b] = "";
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
_a$1 = _name, _b = _body;
|
|
2099
|
-
function initFn(body, headers) {
|
|
2100
|
-
if (isObjectType("ReadableStream", body)) {
|
|
2101
|
-
throw new ReferenceError("ReadableStream is not defined");
|
|
2102
|
-
}
|
|
2103
|
-
this[_body] = convert(body, type => {
|
|
2104
|
-
if (headers && !headers.get("Content-Type")) {
|
|
2105
|
-
headers.set("Content-Type", type);
|
|
2106
|
-
}
|
|
2107
|
-
});
|
|
2108
|
-
}
|
|
2109
|
-
function read(kind) {
|
|
2110
|
-
return new Promise((resolve, reject) => {
|
|
2111
|
-
try {
|
|
2112
|
-
resolve(readSync.call(this, kind));
|
|
2113
|
-
}
|
|
2114
|
-
catch (e) {
|
|
2115
|
-
reject(e);
|
|
2116
|
-
}
|
|
2117
|
-
});
|
|
2118
|
-
}
|
|
2119
|
-
function readSync(kind) {
|
|
2120
|
-
if (kind === "arrayBuffer") {
|
|
2121
|
-
return convertBack("arraybuffer", this[_body]);
|
|
2122
|
-
}
|
|
2123
|
-
else if (kind === "blob") {
|
|
2124
|
-
return convertBack("blob", this[_body]);
|
|
2125
|
-
}
|
|
2126
|
-
else if (kind === "bytes") {
|
|
2127
|
-
let arrayBuffer = convertBack("arraybuffer", this[_body]);
|
|
2128
|
-
return new Uint8Array(arrayBuffer);
|
|
2129
|
-
}
|
|
2130
|
-
else if (kind === "formData") {
|
|
2131
|
-
let text = convertBack("text", this[_body]);
|
|
2132
|
-
return createFormDataFromBody(text);
|
|
2133
|
-
}
|
|
2134
|
-
else if (kind === "json") {
|
|
2135
|
-
return convertBack("json", this[_body]);
|
|
2136
|
-
}
|
|
2137
|
-
else {
|
|
2138
|
-
return convertBack("text", this[_body]);
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
|
-
function consumed(kind) {
|
|
2142
|
-
if (!this[_body])
|
|
2143
|
-
return;
|
|
2144
|
-
if (this.bodyUsed) {
|
|
2145
|
-
return Promise.reject(new TypeError(`TypeError: Failed to execute '${kind}' on '${this[_name]}': body stream already read`));
|
|
2146
|
-
}
|
|
2147
|
-
this.bodyUsed = true;
|
|
2148
|
-
}
|
|
2149
1665
|
|
|
2150
|
-
var _a;
|
|
1666
|
+
var _a$2;
|
|
2151
1667
|
/** @internal */
|
|
2152
|
-
const state$
|
|
1668
|
+
const state$6 = Symbol( /* "HeadersState" */);
|
|
2153
1669
|
class HeadersP {
|
|
2154
1670
|
constructor(init) {
|
|
2155
|
-
this[state$
|
|
1671
|
+
this[state$6] = new HeadersState();
|
|
2156
1672
|
if (isObjectType("Headers", init)) {
|
|
2157
1673
|
init.forEach((value, name) => {
|
|
2158
1674
|
this.append(name, value);
|
|
@@ -2178,18 +1694,18 @@ class HeadersP {
|
|
|
2178
1694
|
append(name, value) {
|
|
2179
1695
|
var _b;
|
|
2180
1696
|
let key = normalizeName(name, "append");
|
|
2181
|
-
|
|
2182
|
-
let oldValue = (_b = this[state$
|
|
2183
|
-
this[state$
|
|
1697
|
+
let newValue = normalizeValue(value);
|
|
1698
|
+
let oldValue = (_b = this[state$6][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1];
|
|
1699
|
+
this[state$6][_headersMap].set(key, ["" + name, oldValue ? `${oldValue}, ${newValue}` : newValue]);
|
|
2184
1700
|
}
|
|
2185
1701
|
delete(name) {
|
|
2186
1702
|
let key = normalizeName(name, "delete");
|
|
2187
|
-
this[state$
|
|
1703
|
+
this[state$6][_headersMap].delete(key);
|
|
2188
1704
|
}
|
|
2189
1705
|
get(name) {
|
|
2190
1706
|
var _b, _c;
|
|
2191
1707
|
let key = normalizeName(name, "get");
|
|
2192
|
-
return (_c = (_b = this[state$
|
|
1708
|
+
return (_c = (_b = this[state$6][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : null;
|
|
2193
1709
|
}
|
|
2194
1710
|
getSetCookie() {
|
|
2195
1711
|
let value = this.get("Set-Cookie");
|
|
@@ -2197,11 +1713,11 @@ class HeadersP {
|
|
|
2197
1713
|
}
|
|
2198
1714
|
has(name) {
|
|
2199
1715
|
let key = normalizeName(name, "has");
|
|
2200
|
-
return this[state$
|
|
1716
|
+
return this[state$6][_headersMap].has(key);
|
|
2201
1717
|
}
|
|
2202
1718
|
set(name, value) {
|
|
2203
1719
|
let key = normalizeName(name, "set");
|
|
2204
|
-
this[state$
|
|
1720
|
+
this[state$6][_headersMap].set(key, ["" + name, normalizeValue(value)]);
|
|
2205
1721
|
}
|
|
2206
1722
|
forEach(callbackfn, thisArg) {
|
|
2207
1723
|
Array.from(this.entries()).forEach(([name, value]) => {
|
|
@@ -2209,7 +1725,7 @@ class HeadersP {
|
|
|
2209
1725
|
});
|
|
2210
1726
|
}
|
|
2211
1727
|
entries() {
|
|
2212
|
-
return this[state$
|
|
1728
|
+
return this[state$6][_headersMap].values();
|
|
2213
1729
|
}
|
|
2214
1730
|
keys() {
|
|
2215
1731
|
return Array.from(this.entries()).map(pair => pair[0]).values();
|
|
@@ -2223,16 +1739,74 @@ class HeadersP {
|
|
|
2223
1739
|
toString() { return "[object Headers]"; }
|
|
2224
1740
|
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
|
|
2225
1741
|
}
|
|
2226
|
-
|
|
1742
|
+
dfStringTag(HeadersP, "Headers");
|
|
2227
1743
|
/** @internal */
|
|
2228
1744
|
const _headersMap = Symbol();
|
|
2229
1745
|
/** @internal */
|
|
2230
1746
|
class HeadersState {
|
|
2231
1747
|
constructor() {
|
|
2232
|
-
this[_a] = new
|
|
1748
|
+
this[_a$2] = new SimpleMap();
|
|
2233
1749
|
}
|
|
2234
1750
|
}
|
|
2235
|
-
_a = _headersMap;
|
|
1751
|
+
_a$2 = _headersMap;
|
|
1752
|
+
/** @internal */
|
|
1753
|
+
class SimpleMap {
|
|
1754
|
+
constructor() {
|
|
1755
|
+
this.array = [];
|
|
1756
|
+
}
|
|
1757
|
+
get(key) {
|
|
1758
|
+
for (let i = 0; i < this.array.length; ++i) {
|
|
1759
|
+
let pair = this.array[i];
|
|
1760
|
+
if (pair[0] === key) {
|
|
1761
|
+
return pair[1];
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
set(key, value) {
|
|
1766
|
+
let index = -1;
|
|
1767
|
+
for (let i = 0; i < this.array.length; ++i) {
|
|
1768
|
+
let pair = this.array[i];
|
|
1769
|
+
if (pair[0] === key) {
|
|
1770
|
+
pair[1] = value;
|
|
1771
|
+
index = i;
|
|
1772
|
+
break;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
if (index === -1) {
|
|
1776
|
+
this.array.push([key, value]);
|
|
1777
|
+
}
|
|
1778
|
+
return this.array;
|
|
1779
|
+
}
|
|
1780
|
+
has(key) {
|
|
1781
|
+
for (let i = 0; i < this.array.length; ++i) {
|
|
1782
|
+
let pair = this.array[i];
|
|
1783
|
+
if (pair[0] === key) {
|
|
1784
|
+
return true;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
return false;
|
|
1788
|
+
}
|
|
1789
|
+
delete(key) {
|
|
1790
|
+
let index = -1;
|
|
1791
|
+
let array = [];
|
|
1792
|
+
for (let i = 0; i < this.array.length; ++i) {
|
|
1793
|
+
let pair = this.array[i];
|
|
1794
|
+
if (pair[0] === key) {
|
|
1795
|
+
index = i;
|
|
1796
|
+
continue;
|
|
1797
|
+
}
|
|
1798
|
+
array.push(pair);
|
|
1799
|
+
}
|
|
1800
|
+
if (index > -1) {
|
|
1801
|
+
this.array = array;
|
|
1802
|
+
}
|
|
1803
|
+
return index > -1;
|
|
1804
|
+
}
|
|
1805
|
+
values() {
|
|
1806
|
+
return this.array.map(x => x[1]).values();
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
/** @internal */
|
|
2236
1810
|
function normalizeName(name, kind = "") {
|
|
2237
1811
|
if (typeof name !== "string") {
|
|
2238
1812
|
name = String(name);
|
|
@@ -2244,12 +1818,14 @@ function normalizeName(name, kind = "") {
|
|
|
2244
1818
|
}
|
|
2245
1819
|
return name.toLowerCase();
|
|
2246
1820
|
}
|
|
1821
|
+
/** @internal */
|
|
2247
1822
|
function normalizeValue(value) {
|
|
2248
1823
|
if (typeof value !== "string") {
|
|
2249
1824
|
value = String(value);
|
|
2250
1825
|
}
|
|
2251
1826
|
return value;
|
|
2252
1827
|
}
|
|
1828
|
+
/** @internal */
|
|
2253
1829
|
function parseHeaders(rawHeaders) {
|
|
2254
1830
|
let headers = new HeadersP();
|
|
2255
1831
|
let preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
|
|
@@ -2276,13 +1852,34 @@ function parseHeaders(rawHeaders) {
|
|
|
2276
1852
|
const HeadersE = g["Headers"] || HeadersP;
|
|
2277
1853
|
|
|
2278
1854
|
/** @internal */
|
|
2279
|
-
const state$
|
|
2280
|
-
class
|
|
1855
|
+
const state$5 = Symbol( /* "AbortControllerState" */);
|
|
1856
|
+
class AbortControllerP {
|
|
1857
|
+
constructor() {
|
|
1858
|
+
this[state$5] = new AbortControllerState();
|
|
1859
|
+
}
|
|
1860
|
+
get signal() { return this[state$5].signal; }
|
|
1861
|
+
abort(reason) {
|
|
1862
|
+
AbortSignal_abort(this[state$5].signal, reason);
|
|
1863
|
+
}
|
|
1864
|
+
toString() { return "[object AbortController]"; }
|
|
1865
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
|
|
1866
|
+
}
|
|
1867
|
+
dfStringTag(AbortControllerP, "AbortController");
|
|
1868
|
+
/** @internal */
|
|
1869
|
+
class AbortControllerState {
|
|
1870
|
+
constructor() {
|
|
1871
|
+
this.signal = createAbortSignal();
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
const AbortControllerE = g["AbortController"] || AbortControllerP;
|
|
1875
|
+
|
|
1876
|
+
/** @internal */ const state$4 = Symbol( /* "RequestState" */);
|
|
1877
|
+
class RequestP extends BodyImpl {
|
|
2281
1878
|
constructor(input, init) {
|
|
2282
1879
|
super();
|
|
2283
|
-
this
|
|
2284
|
-
|
|
2285
|
-
this[state$
|
|
1880
|
+
Body_setName(this, "Request");
|
|
1881
|
+
this[state$4] = new RequestState();
|
|
1882
|
+
const that = this[state$4];
|
|
2286
1883
|
let options = init !== null && init !== void 0 ? init : {};
|
|
2287
1884
|
let body = options.body;
|
|
2288
1885
|
if (isPolyfillType("Request", input)) {
|
|
@@ -2295,15 +1892,15 @@ class RequestP extends BodyP {
|
|
|
2295
1892
|
}
|
|
2296
1893
|
that.method = input.method;
|
|
2297
1894
|
that.mode = input.mode;
|
|
2298
|
-
let inputSignal = input[state$
|
|
1895
|
+
let inputSignal = input[state$4].signal;
|
|
2299
1896
|
if (inputSignal) {
|
|
2300
1897
|
that.signal = inputSignal;
|
|
2301
1898
|
}
|
|
2302
1899
|
that.url = input.url;
|
|
2303
|
-
let
|
|
2304
|
-
if (!body &&
|
|
2305
|
-
body =
|
|
2306
|
-
|
|
1900
|
+
let payload = Body_toPayload(input);
|
|
1901
|
+
if (!body && payload !== null) {
|
|
1902
|
+
body = payload;
|
|
1903
|
+
Body_setBodyUsed(input, true);
|
|
2307
1904
|
}
|
|
2308
1905
|
}
|
|
2309
1906
|
else {
|
|
@@ -2327,7 +1924,7 @@ class RequestP extends BodyP {
|
|
|
2327
1924
|
if ((this.method === "GET" || this.method === "HEAD") && body) {
|
|
2328
1925
|
throw new TypeError("Failed to construct 'Request': Request with GET/HEAD method cannot have body.");
|
|
2329
1926
|
}
|
|
2330
|
-
|
|
1927
|
+
Body_init(this, body, this.headers);
|
|
2331
1928
|
if (this.method === "GET" || this.method === "HEAD") {
|
|
2332
1929
|
if (options.cache === "no-store" || options.cache === "no-cache") {
|
|
2333
1930
|
// Search for a '_' parameter in the query string
|
|
@@ -2344,153 +1941,707 @@ class RequestP extends BodyP {
|
|
|
2344
1941
|
}
|
|
2345
1942
|
}
|
|
2346
1943
|
}
|
|
2347
|
-
get cache() { return this[state$
|
|
2348
|
-
get credentials() { return this[state$
|
|
2349
|
-
get destination() { return this[state$
|
|
1944
|
+
get cache() { return this[state$4].cache; }
|
|
1945
|
+
get credentials() { return this[state$4].credentials; }
|
|
1946
|
+
get destination() { return this[state$4].destination; }
|
|
2350
1947
|
get headers() {
|
|
2351
|
-
const that = this[state$
|
|
1948
|
+
const that = this[state$4];
|
|
2352
1949
|
if (!that.headers) {
|
|
2353
1950
|
that.headers = new HeadersP();
|
|
2354
1951
|
}
|
|
2355
|
-
return that.headers;
|
|
1952
|
+
return that.headers;
|
|
1953
|
+
}
|
|
1954
|
+
get integrity() { return this[state$4].integrity; }
|
|
1955
|
+
get keepalive() { return this[state$4].keepalive; }
|
|
1956
|
+
get method() { return this[state$4].method; }
|
|
1957
|
+
get mode() { return this[state$4].mode; }
|
|
1958
|
+
get redirect() { return this[state$4].redirect; }
|
|
1959
|
+
get referrer() { return this[state$4].referrer; }
|
|
1960
|
+
get referrerPolicy() { return this[state$4].referrerPolicy; }
|
|
1961
|
+
get signal() {
|
|
1962
|
+
const that = this[state$4];
|
|
1963
|
+
if (!that.signal) {
|
|
1964
|
+
that.signal = (new AbortControllerP()).signal;
|
|
1965
|
+
}
|
|
1966
|
+
return that.signal;
|
|
1967
|
+
}
|
|
1968
|
+
get url() { return this[state$4].url; }
|
|
1969
|
+
clone() {
|
|
1970
|
+
var _a;
|
|
1971
|
+
return new RequestP(this, { body: (_a = Body_toPayload(this)) !== null && _a !== void 0 ? _a : null });
|
|
1972
|
+
}
|
|
1973
|
+
toString() { return "[object Request]"; }
|
|
1974
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request", "Body"] }; }
|
|
1975
|
+
}
|
|
1976
|
+
dfStringTag(RequestP, "Request");
|
|
1977
|
+
/** @internal */
|
|
1978
|
+
class RequestState {
|
|
1979
|
+
constructor() {
|
|
1980
|
+
this.cache = "default";
|
|
1981
|
+
this.credentials = "same-origin";
|
|
1982
|
+
this.destination = "";
|
|
1983
|
+
this.integrity = "";
|
|
1984
|
+
this.keepalive = false;
|
|
1985
|
+
this.method = "GET";
|
|
1986
|
+
this.mode = "cors";
|
|
1987
|
+
this.redirect = "follow";
|
|
1988
|
+
this.referrer = "about:client";
|
|
1989
|
+
this.referrerPolicy = "";
|
|
1990
|
+
this.url = "";
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
// HTTP methods whose capitalization should be normalized
|
|
1994
|
+
const methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
|
|
1995
|
+
/** @internal */
|
|
1996
|
+
function normalizeMethod(method) {
|
|
1997
|
+
let upcased = method.toUpperCase();
|
|
1998
|
+
return methods.indexOf(upcased) > -1 ? upcased : method;
|
|
1999
|
+
}
|
|
2000
|
+
const RequestE = g["Request"] || RequestP;
|
|
2001
|
+
|
|
2002
|
+
/** @internal */ const state$3 = Symbol( /* "ResponseState" */);
|
|
2003
|
+
class ResponseP extends BodyImpl {
|
|
2004
|
+
constructor(body, init) {
|
|
2005
|
+
super();
|
|
2006
|
+
Body_setName(this, "Response");
|
|
2007
|
+
this[state$3] = new ResponseState();
|
|
2008
|
+
const that = this[state$3];
|
|
2009
|
+
let options = init !== null && init !== void 0 ? init : {};
|
|
2010
|
+
let status = options.status === undefined ? 200 : options.status;
|
|
2011
|
+
if (status < 200 || status > 500) {
|
|
2012
|
+
throw new RangeError(`Failed to construct 'Response': The status provided (${+status}) is outside the range [200, 599].`);
|
|
2013
|
+
}
|
|
2014
|
+
if (options.headers) {
|
|
2015
|
+
that.headers = new HeadersP(options.headers);
|
|
2016
|
+
}
|
|
2017
|
+
that.ok = this.status >= 200 && this.status < 300;
|
|
2018
|
+
that.status = status;
|
|
2019
|
+
that.statusText = options.statusText === undefined ? "" : "" + options.statusText;
|
|
2020
|
+
Body_init(this, body, this.headers);
|
|
2021
|
+
}
|
|
2022
|
+
get headers() {
|
|
2023
|
+
const that = this[state$3];
|
|
2024
|
+
if (!that.headers) {
|
|
2025
|
+
that.headers = new HeadersP();
|
|
2026
|
+
}
|
|
2027
|
+
return that.headers;
|
|
2028
|
+
}
|
|
2029
|
+
get ok() { return this[state$3].ok; }
|
|
2030
|
+
get redirected() { return this[state$3].redirected; }
|
|
2031
|
+
get status() { return this[state$3].status; }
|
|
2032
|
+
get statusText() { return this[state$3].statusText; }
|
|
2033
|
+
get type() { return this[state$3].type; }
|
|
2034
|
+
get url() { return this[state$3].url; }
|
|
2035
|
+
clone() {
|
|
2036
|
+
let response = new ResponseP(Body_toPayload(this), {
|
|
2037
|
+
headers: new HeadersP(this.headers),
|
|
2038
|
+
status: this.status,
|
|
2039
|
+
statusText: this.statusText,
|
|
2040
|
+
});
|
|
2041
|
+
response[state$3].url = this.url;
|
|
2042
|
+
return response;
|
|
2043
|
+
}
|
|
2044
|
+
static json(data, init) {
|
|
2045
|
+
return new ResponseP(JSON.stringify(data), init);
|
|
2046
|
+
}
|
|
2047
|
+
static error() {
|
|
2048
|
+
let response = new ResponseP(null, { status: 200, statusText: "" });
|
|
2049
|
+
response[state$3].ok = false;
|
|
2050
|
+
response[state$3].status = 0;
|
|
2051
|
+
response[state$3].type = "error";
|
|
2052
|
+
return response;
|
|
2053
|
+
}
|
|
2054
|
+
static redirect(url, status = 301) {
|
|
2055
|
+
if ([301, 302, 303, 307, 308].indexOf(status) === -1) {
|
|
2056
|
+
throw new RangeError("Failed to execute 'redirect' on 'Response': Invalid status code");
|
|
2057
|
+
}
|
|
2058
|
+
return new ResponseP(null, { status, headers: { location: String(url) } });
|
|
2059
|
+
}
|
|
2060
|
+
toString() { return "[object Response]"; }
|
|
2061
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response", "Body"] }; }
|
|
2062
|
+
}
|
|
2063
|
+
dfStringTag(ResponseP, "Response");
|
|
2064
|
+
/** @internal */
|
|
2065
|
+
class ResponseState {
|
|
2066
|
+
constructor() {
|
|
2067
|
+
this.ok = true;
|
|
2068
|
+
this.redirected = false;
|
|
2069
|
+
this.status = 200;
|
|
2070
|
+
this.statusText = "";
|
|
2071
|
+
this.type = "default";
|
|
2072
|
+
this.url = "";
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
const ResponseE = g["Response"] || ResponseP;
|
|
2076
|
+
|
|
2077
|
+
var _a$1;
|
|
2078
|
+
/** @internal */ const state$2 = Symbol( /* "XMLHttpRequestEventTargetState" */);
|
|
2079
|
+
class XMLHttpRequestEventTargetP extends EventTargetP {
|
|
2080
|
+
constructor() {
|
|
2081
|
+
if (new.target === XMLHttpRequestEventTargetP) {
|
|
2082
|
+
throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
|
|
2083
|
+
}
|
|
2084
|
+
super();
|
|
2085
|
+
this[state$2] = new XMLHttpRequestEventTargetState(this);
|
|
2086
|
+
}
|
|
2087
|
+
get onabort() { return this[state$2].onabort; }
|
|
2088
|
+
set onabort(value) { this[state$2].onabort = value; attach(this, "abort"); }
|
|
2089
|
+
get onerror() { return this[state$2].onerror; }
|
|
2090
|
+
set onerror(value) { this[state$2].onerror = value; attach(this, "error"); }
|
|
2091
|
+
get onload() { return this[state$2].onload; }
|
|
2092
|
+
set onload(value) { this[state$2].onload = value; attach(this, "load"); }
|
|
2093
|
+
get onloadend() { return this[state$2].onloadend; }
|
|
2094
|
+
set onloadend(value) { this[state$2].onloadend = value; attach(this, "loadend"); }
|
|
2095
|
+
get onloadstart() { return this[state$2].onloadstart; }
|
|
2096
|
+
set onloadstart(value) { this[state$2].onloadstart = value; attach(this, "loadstart"); }
|
|
2097
|
+
get onprogress() { return this[state$2].onprogress; }
|
|
2098
|
+
set onprogress(value) { this[state$2].onprogress = value; attach(this, "progress"); }
|
|
2099
|
+
get ontimeout() { return this[state$2].ontimeout; }
|
|
2100
|
+
set ontimeout(value) { this[state$2].ontimeout = value; attach(this, "timeout"); }
|
|
2101
|
+
toString() { return "[object XMLHttpRequestEventTarget]"; }
|
|
2102
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2103
|
+
}
|
|
2104
|
+
dfStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
|
|
2105
|
+
/** @internal */
|
|
2106
|
+
const _handlers$1 = Symbol();
|
|
2107
|
+
/** @internal */
|
|
2108
|
+
class XMLHttpRequestEventTargetState {
|
|
2109
|
+
/**
|
|
2110
|
+
* @param _target XMLHttpRequestEventTarget
|
|
2111
|
+
*/
|
|
2112
|
+
constructor(_target) {
|
|
2113
|
+
this[_a$1] = getHandlers$1(this);
|
|
2114
|
+
this.onabort = null;
|
|
2115
|
+
this.onerror = null;
|
|
2116
|
+
this.onload = null;
|
|
2117
|
+
this.onloadend = null;
|
|
2118
|
+
this.onloadstart = null;
|
|
2119
|
+
this.onprogress = null;
|
|
2120
|
+
this.ontimeout = null;
|
|
2121
|
+
this.target = _target;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
_a$1 = _handlers$1;
|
|
2125
|
+
function attach(target, type) {
|
|
2126
|
+
const s = target[state$2];
|
|
2127
|
+
const fnName = ("on" + type);
|
|
2128
|
+
const cb = s[fnName];
|
|
2129
|
+
const listener = s[_handlers$1][fnName];
|
|
2130
|
+
attachFn(target, type, cb, listener);
|
|
2131
|
+
}
|
|
2132
|
+
function getHandlers$1(s) {
|
|
2133
|
+
return {
|
|
2134
|
+
onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
|
|
2135
|
+
onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
|
|
2136
|
+
onload: (ev) => { executeFn(s.target, s.onload, ev); },
|
|
2137
|
+
onloadend: (ev) => { executeFn(s.target, s.onloadend, ev); },
|
|
2138
|
+
onloadstart: (ev) => { executeFn(s.target, s.onloadstart, ev); },
|
|
2139
|
+
onprogress: (ev) => { executeFn(s.target, s.onprogress, ev); },
|
|
2140
|
+
ontimeout: (ev) => { executeFn(s.target, s.ontimeout, ev); },
|
|
2141
|
+
};
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
|
|
2145
|
+
constructor() {
|
|
2146
|
+
if (new.target === XMLHttpRequestUploadP) {
|
|
2147
|
+
throw new TypeError("Failed to construct 'XMLHttpRequestUpload': Illegal constructor");
|
|
2148
|
+
}
|
|
2149
|
+
super();
|
|
2150
|
+
}
|
|
2151
|
+
toString() { return "[object XMLHttpRequestUpload]"; }
|
|
2152
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2153
|
+
}
|
|
2154
|
+
dfStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
|
|
2155
|
+
/** @internal */
|
|
2156
|
+
function createXMLHttpRequestUpload() {
|
|
2157
|
+
let upload = Object.create(XMLHttpRequestUploadP.prototype);
|
|
2158
|
+
upload[state$d] = new EventTargetState(upload);
|
|
2159
|
+
upload[state$2] = new XMLHttpRequestEventTargetState(upload);
|
|
2160
|
+
return upload;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
// @ts-nocheck
|
|
2164
|
+
/** @internal */
|
|
2165
|
+
const mp$2 = (() => {
|
|
2166
|
+
let u = "undefined", r = "request", f = "function";
|
|
2167
|
+
let mp;
|
|
2168
|
+
mp =
|
|
2169
|
+
(typeof wx !== u && typeof (wx === null || wx === void 0 ? void 0 : wx[r]) === f && wx) || // 微信
|
|
2170
|
+
(typeof my !== u && typeof (my === null || my === void 0 ? void 0 : my[r]) === f && my) || // 支付宝
|
|
2171
|
+
(typeof qq !== u && typeof (qq === null || qq === void 0 ? void 0 : qq[r]) === f && qq) || // QQ
|
|
2172
|
+
(typeof jd !== u && typeof (jd === null || jd === void 0 ? void 0 : jd[r]) === f && jd) || // 京东
|
|
2173
|
+
(typeof swan !== u && typeof (swan === null || swan === void 0 ? void 0 : swan[r]) === f && swan) || // 百度
|
|
2174
|
+
(typeof tt !== u && typeof (tt === null || tt === void 0 ? void 0 : tt[r]) === f && tt) || // 抖音 | 飞书
|
|
2175
|
+
(typeof ks !== u && typeof (ks === null || ks === void 0 ? void 0 : ks[r]) === f && ks) || // 快手
|
|
2176
|
+
(typeof qh !== u && typeof (qh === null || qh === void 0 ? void 0 : qh[r]) === f && qh) || // 360
|
|
2177
|
+
(typeof xhs !== u && typeof (xhs === null || xhs === void 0 ? void 0 : xhs[r]) === f && xhs) || // 小红书
|
|
2178
|
+
undefined;
|
|
2179
|
+
if (typeof g["XMLHttpRequest"] === f) {
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
if (mp === undefined)
|
|
2183
|
+
mp =
|
|
2184
|
+
(typeof uni !== u && typeof (uni === null || uni === void 0 ? void 0 : uni[r]) === f && uni) || // UniApp
|
|
2185
|
+
(typeof Taro !== u && typeof (Taro === null || Taro === void 0 ? void 0 : Taro[r]) === f && Taro) || // Taro
|
|
2186
|
+
undefined;
|
|
2187
|
+
return mp;
|
|
2188
|
+
})();
|
|
2189
|
+
|
|
2190
|
+
const request = mp$2 ? mp$2.request : function errorRequest(options) {
|
|
2191
|
+
const errMsg = "NOT_SUPPORTED_ERR";
|
|
2192
|
+
const errno = 9;
|
|
2193
|
+
const err = {
|
|
2194
|
+
errMsg,
|
|
2195
|
+
errno,
|
|
2196
|
+
exception: {
|
|
2197
|
+
retryCount: 0,
|
|
2198
|
+
reasons: [{ errMsg, errno }],
|
|
2199
|
+
},
|
|
2200
|
+
useHttpDNS: false,
|
|
2201
|
+
};
|
|
2202
|
+
Promise.resolve(err)
|
|
2203
|
+
.then(err => { try {
|
|
2204
|
+
if (options.fail) {
|
|
2205
|
+
options.fail(err);
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
catch (e) {
|
|
2209
|
+
console.error(e);
|
|
2210
|
+
} })
|
|
2211
|
+
.then(() => { if (options.complete) {
|
|
2212
|
+
options.complete(err);
|
|
2213
|
+
} });
|
|
2214
|
+
throw new ReferenceError("request is not defined");
|
|
2215
|
+
};
|
|
2216
|
+
|
|
2217
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2218
|
+
const mp$1 = { request: request };
|
|
2219
|
+
const setRequest = (request) => { mp$1.request = request; };
|
|
2220
|
+
/** @internal */ const state$1 = Symbol( /* "XMLHttpRequestState" */);
|
|
2221
|
+
class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
2222
|
+
constructor() {
|
|
2223
|
+
super();
|
|
2224
|
+
this[state$1] = new XMLHttpRequestState(this);
|
|
2225
|
+
}
|
|
2226
|
+
get readyState() { return this[state$1].readyState; }
|
|
2227
|
+
get response() { return this[state$1].response; }
|
|
2228
|
+
get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
|
|
2229
|
+
get responseType() { return this[state$1].responseType; }
|
|
2230
|
+
set responseType(value) { this[state$1].responseType = normalizeResponseType(value); }
|
|
2231
|
+
get responseURL() { return this[state$1].responseURL; }
|
|
2232
|
+
get responseXML() { return null; }
|
|
2233
|
+
get status() { return this[state$1].status; }
|
|
2234
|
+
get statusText() {
|
|
2235
|
+
if (this.readyState === XMLHttpRequestP.UNSENT || this.readyState === XMLHttpRequestP.OPENED)
|
|
2236
|
+
return "";
|
|
2237
|
+
return this[state$1].statusText || statusTextMap(this.status);
|
|
2238
|
+
}
|
|
2239
|
+
get timeout() { return this[state$1].timeout; }
|
|
2240
|
+
set timeout(value) { this[state$1].timeout = value > 0 ? value : 0; }
|
|
2241
|
+
get upload() {
|
|
2242
|
+
const that = this[state$1];
|
|
2243
|
+
if (!that.upload) {
|
|
2244
|
+
that.upload = createXMLHttpRequestUpload();
|
|
2245
|
+
}
|
|
2246
|
+
return that.upload;
|
|
2247
|
+
}
|
|
2248
|
+
get withCredentials() { return this[state$1].withCredentials; }
|
|
2249
|
+
set withCredentials(value) { this[state$1].withCredentials = !!value; }
|
|
2250
|
+
abort() {
|
|
2251
|
+
clearRequest(this);
|
|
2252
|
+
}
|
|
2253
|
+
getAllResponseHeaders() {
|
|
2254
|
+
if (!this[state$1][_responseHeaders])
|
|
2255
|
+
return "";
|
|
2256
|
+
return Array.from(this[state$1][_responseHeaders].entries()).map(([k, v]) => `${k}: ${v}\r\n`).join("");
|
|
2257
|
+
}
|
|
2258
|
+
getResponseHeader(name) {
|
|
2259
|
+
if (!this[state$1][_responseHeaders])
|
|
2260
|
+
return null;
|
|
2261
|
+
return this[state$1][_responseHeaders].get(name);
|
|
2262
|
+
}
|
|
2263
|
+
open(...args) {
|
|
2264
|
+
const [method, url, async = true, username = null, password = null] = args;
|
|
2265
|
+
const that = this[state$1];
|
|
2266
|
+
if (args.length < 2) {
|
|
2267
|
+
throw new TypeError(`Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${args.length} present.`);
|
|
2268
|
+
}
|
|
2269
|
+
if (!async) {
|
|
2270
|
+
console.warn("Synchronous XMLHttpRequest is not supported because of its detrimental effects to the end user's experience.");
|
|
2271
|
+
}
|
|
2272
|
+
clearRequest(this, false);
|
|
2273
|
+
that[_method] = normalizeMethod(method);
|
|
2274
|
+
that[_requestURL] = String(url);
|
|
2275
|
+
if (username !== null || password !== null) {
|
|
2276
|
+
let _username = String(username !== null && username !== void 0 ? username : "");
|
|
2277
|
+
let _password = String(password !== null && password !== void 0 ? password : "");
|
|
2278
|
+
if (_username.length > 0 || _password.length > 0) {
|
|
2279
|
+
let auth = `Basic ${Uint8Array_toBase64((new TextEncoderP()).encode(_username + ":" + _password))}`;
|
|
2280
|
+
this.setRequestHeader("Authorization", auth);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
that[_inAfterOpenBeforeSend] = true;
|
|
2284
|
+
setReadyStateAndNotify(this, XMLHttpRequestP.OPENED);
|
|
2285
|
+
}
|
|
2286
|
+
overrideMimeType(mime) {
|
|
2287
|
+
if (this[state$1][_inAfterOpenBeforeSend]) {
|
|
2288
|
+
console.warn(`XMLHttpRequest.overrideMimeType('${mime}') is not implemented: The method will have no effect on response parsing.`);
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
send(body) {
|
|
2292
|
+
const that = this[state$1];
|
|
2293
|
+
if (!that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED) {
|
|
2294
|
+
throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
2295
|
+
}
|
|
2296
|
+
that[_inAfterOpenBeforeSend] = false;
|
|
2297
|
+
const allowsRequestBody = that[_method] !== "GET" && that[_method] !== "HEAD";
|
|
2298
|
+
const processHeaders = allowsRequestBody && !that[_requestHeaders].has("Content-Type");
|
|
2299
|
+
const upload = that.upload;
|
|
2300
|
+
const processContentLength = upload && EventTarget_count(upload) > 0;
|
|
2301
|
+
let headers = () => Array.from(that[_requestHeaders].entries())
|
|
2302
|
+
.reduce((acc, cur) => { acc[cur[0]] = cur[1]; return acc; }, {});
|
|
2303
|
+
let contentLength = zero;
|
|
2304
|
+
const processHeadersFn = processHeaders ? (v) => { that[_requestHeaders].set("Content-Type", v); } : void 0;
|
|
2305
|
+
const processContentLengthFn = processContentLength ? (v) => { contentLength = v; } : void 0;
|
|
2306
|
+
let data = body;
|
|
2307
|
+
try {
|
|
2308
|
+
data = convert(body, processHeadersFn, processContentLengthFn);
|
|
2309
|
+
}
|
|
2310
|
+
catch (e) {
|
|
2311
|
+
console.warn(e);
|
|
2312
|
+
}
|
|
2313
|
+
let options = {
|
|
2314
|
+
url: that[_requestURL],
|
|
2315
|
+
method: that[_method],
|
|
2316
|
+
header: headers(),
|
|
2317
|
+
data,
|
|
2318
|
+
dataType: that.responseType === "json" ? "json" : normalizeDataType(that.responseType),
|
|
2319
|
+
responseType: normalizeDataType(that.responseType),
|
|
2320
|
+
withCredentials: that.withCredentials,
|
|
2321
|
+
success: requestSuccess.bind(this),
|
|
2322
|
+
fail: requestFail.bind(this),
|
|
2323
|
+
complete: requestComplete.bind(this),
|
|
2324
|
+
};
|
|
2325
|
+
that[_requestTask] = mp$1.request(options);
|
|
2326
|
+
emitProcessEvent(this, "loadstart");
|
|
2327
|
+
if (processContentLength) {
|
|
2328
|
+
const hasRequestBody = allowsRequestBody && !!data;
|
|
2329
|
+
if (hasRequestBody) {
|
|
2330
|
+
emitProcessEvent(upload, "loadstart", 0, contentLength);
|
|
2331
|
+
}
|
|
2332
|
+
setTimeout(() => {
|
|
2333
|
+
const _aborted = that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED;
|
|
2334
|
+
const _contentLength = _aborted ? 0 : contentLength;
|
|
2335
|
+
if (_aborted) {
|
|
2336
|
+
emitProcessEvent(upload, "abort");
|
|
2337
|
+
}
|
|
2338
|
+
else {
|
|
2339
|
+
if (hasRequestBody) {
|
|
2340
|
+
emitProcessEvent(upload, "load", _contentLength, _contentLength);
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
if (_aborted || hasRequestBody) {
|
|
2344
|
+
emitProcessEvent(upload, "loadend", _contentLength, _contentLength);
|
|
2345
|
+
}
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2348
|
+
checkRequestTimeout(this);
|
|
2356
2349
|
}
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
get method() { return this[state$1].method; }
|
|
2360
|
-
get mode() { return this[state$1].mode; }
|
|
2361
|
-
get redirect() { return this[state$1].redirect; }
|
|
2362
|
-
get referrer() { return this[state$1].referrer; }
|
|
2363
|
-
get referrerPolicy() { return this[state$1].referrerPolicy; }
|
|
2364
|
-
get signal() {
|
|
2365
|
-
const that = this[state$1];
|
|
2366
|
-
if (!that.signal) {
|
|
2367
|
-
that.signal = (new AbortControllerP()).signal;
|
|
2368
|
-
}
|
|
2369
|
-
return that.signal;
|
|
2350
|
+
setRequestHeader(name, value) {
|
|
2351
|
+
this[state$1][_requestHeaders].append(name, value);
|
|
2370
2352
|
}
|
|
2371
|
-
get
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2353
|
+
get onreadystatechange() { return this[state$1].onreadystatechange; }
|
|
2354
|
+
set onreadystatechange(value) {
|
|
2355
|
+
this[state$1].onreadystatechange = value;
|
|
2356
|
+
attachFn(this, "readystatechange", value, this[state$1][_handlers].onreadystatechange);
|
|
2375
2357
|
}
|
|
2376
|
-
toString() { return "[object
|
|
2377
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["
|
|
2358
|
+
toString() { return "[object XMLHttpRequest]"; }
|
|
2359
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2378
2360
|
}
|
|
2379
|
-
|
|
2361
|
+
const properties = {
|
|
2362
|
+
UNSENT: { value: 0, enumerable: true },
|
|
2363
|
+
OPENED: { value: 1, enumerable: true },
|
|
2364
|
+
HEADERS_RECEIVED: { value: 2, enumerable: true },
|
|
2365
|
+
LOADING: { value: 3, enumerable: true },
|
|
2366
|
+
DONE: { value: 4, enumerable: true },
|
|
2367
|
+
};
|
|
2368
|
+
Object.defineProperties(XMLHttpRequestP, properties);
|
|
2369
|
+
Object.defineProperties(XMLHttpRequestP.prototype, properties);
|
|
2370
|
+
dfStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
2371
|
+
/** @internal */ const _handlers = Symbol();
|
|
2372
|
+
/** @internal */ const _inAfterOpenBeforeSend = Symbol();
|
|
2373
|
+
/** @internal */ const _resetPending = Symbol();
|
|
2374
|
+
/** @internal */ const _timeoutId = Symbol();
|
|
2375
|
+
/** @internal */ const _requestURL = Symbol();
|
|
2376
|
+
/** @internal */ const _method = Symbol();
|
|
2377
|
+
/** @internal */ const _requestHeaders = Symbol();
|
|
2378
|
+
/** @internal */ const _responseHeaders = Symbol();
|
|
2379
|
+
/** @internal */ const _responseContentLength = Symbol();
|
|
2380
|
+
/** @internal */ const _requestTask = Symbol();
|
|
2380
2381
|
/** @internal */
|
|
2381
|
-
class
|
|
2382
|
-
constructor() {
|
|
2383
|
-
this.
|
|
2384
|
-
this.
|
|
2385
|
-
this.
|
|
2386
|
-
this.
|
|
2387
|
-
this.
|
|
2388
|
-
this.
|
|
2389
|
-
this.
|
|
2390
|
-
this.
|
|
2391
|
-
this
|
|
2392
|
-
this.
|
|
2393
|
-
this
|
|
2382
|
+
class XMLHttpRequestState {
|
|
2383
|
+
constructor(target) {
|
|
2384
|
+
this.readyState = XMLHttpRequestP.UNSENT;
|
|
2385
|
+
this.response = "";
|
|
2386
|
+
this.responseType = "";
|
|
2387
|
+
this.responseURL = "";
|
|
2388
|
+
this.status = 0;
|
|
2389
|
+
this.statusText = "";
|
|
2390
|
+
this.timeout = 0;
|
|
2391
|
+
this.withCredentials = false;
|
|
2392
|
+
this[_a] = getHandlers(this);
|
|
2393
|
+
this.onreadystatechange = null;
|
|
2394
|
+
this[_b] = false;
|
|
2395
|
+
this[_c] = false;
|
|
2396
|
+
this[_d] = 0;
|
|
2397
|
+
this[_e] = "";
|
|
2398
|
+
this[_f] = "GET";
|
|
2399
|
+
this[_g] = new HeadersP();
|
|
2400
|
+
this[_h] = null;
|
|
2401
|
+
this[_j] = zero;
|
|
2402
|
+
this[_k] = null;
|
|
2403
|
+
this.target = target;
|
|
2394
2404
|
}
|
|
2395
2405
|
}
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
this
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
get headers() {
|
|
2420
|
-
const that = this[state];
|
|
2421
|
-
if (!that.headers) {
|
|
2422
|
-
that.headers = new HeadersP();
|
|
2423
|
-
}
|
|
2424
|
-
return that.headers;
|
|
2425
|
-
}
|
|
2426
|
-
get ok() { return this[state].ok; }
|
|
2427
|
-
get redirected() { return this[state].redirected; }
|
|
2428
|
-
get status() { return this[state].status; }
|
|
2429
|
-
get statusText() { return this[state].statusText; }
|
|
2430
|
-
get type() { return this[state].type; }
|
|
2431
|
-
get url() { return this[state].url; }
|
|
2432
|
-
clone() {
|
|
2433
|
-
let response = new ResponseP(this[state$3][_body], {
|
|
2434
|
-
headers: new HeadersP(this.headers),
|
|
2435
|
-
status: this.status,
|
|
2436
|
-
statusText: this.statusText,
|
|
2406
|
+
_a = _handlers, _b = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
|
|
2407
|
+
function requestSuccess({ statusCode, header, data }) {
|
|
2408
|
+
const s = this[state$1];
|
|
2409
|
+
s.responseURL = s[_requestURL];
|
|
2410
|
+
s.status = statusCode;
|
|
2411
|
+
s[_responseHeaders] = new HeadersP(header);
|
|
2412
|
+
let lengthStr = s[_responseHeaders].get("Content-Length");
|
|
2413
|
+
s[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
|
|
2414
|
+
if (s.readyState === XMLHttpRequestP.OPENED) {
|
|
2415
|
+
setReadyStateAndNotify(this, XMLHttpRequestP.HEADERS_RECEIVED);
|
|
2416
|
+
setReadyStateAndNotify(this, XMLHttpRequestP.LOADING);
|
|
2417
|
+
setTimeout(() => {
|
|
2418
|
+
if (!s[_inAfterOpenBeforeSend]) {
|
|
2419
|
+
let l = s[_responseContentLength];
|
|
2420
|
+
try {
|
|
2421
|
+
s.response = convertBack(s.responseType, data);
|
|
2422
|
+
emitProcessEvent(this, "load", l, l);
|
|
2423
|
+
}
|
|
2424
|
+
catch (e) {
|
|
2425
|
+
console.error(e);
|
|
2426
|
+
emitProcessEvent(this, "error");
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2437
2429
|
});
|
|
2438
|
-
response[state].url = this.url;
|
|
2439
|
-
return response;
|
|
2440
2430
|
}
|
|
2441
|
-
|
|
2442
|
-
|
|
2431
|
+
}
|
|
2432
|
+
function requestFail(err) {
|
|
2433
|
+
// Alipay Mini Programs
|
|
2434
|
+
// error: 14 --- JSON parse data error
|
|
2435
|
+
// error: 19 --- http status error
|
|
2436
|
+
// At this point, the error data object will contain three pieces of information
|
|
2437
|
+
// returned from the server: status, headers, and data.
|
|
2438
|
+
// In the browser's XMLHttpRequest, these two errors (Error 14 and Error 19)
|
|
2439
|
+
// differ from those in Alipay Mini Programs and should instead return normally.
|
|
2440
|
+
// Therefore, this scenario is also handled here as a successful request response.
|
|
2441
|
+
if ("status" in err) {
|
|
2442
|
+
requestSuccess.call(this, { statusCode: err.status, header: err.headers, data: err.data });
|
|
2443
|
+
return;
|
|
2443
2444
|
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2445
|
+
const s = this[state$1];
|
|
2446
|
+
s.status = 0;
|
|
2447
|
+
s.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
|
|
2448
|
+
if (!s[_inAfterOpenBeforeSend] && s.readyState !== XMLHttpRequestP.UNSENT && s.readyState !== XMLHttpRequestP.DONE) {
|
|
2449
|
+
emitProcessEvent(this, "error");
|
|
2450
|
+
resetRequestTimeout(this);
|
|
2450
2451
|
}
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2452
|
+
}
|
|
2453
|
+
function requestComplete() {
|
|
2454
|
+
const s = this[state$1];
|
|
2455
|
+
s[_requestTask] = null;
|
|
2456
|
+
if (!s[_inAfterOpenBeforeSend] && (s.readyState === XMLHttpRequestP.OPENED || s.readyState === XMLHttpRequestP.LOADING)) {
|
|
2457
|
+
setReadyStateAndNotify(this, XMLHttpRequestP.DONE);
|
|
2458
|
+
}
|
|
2459
|
+
setTimeout(() => {
|
|
2460
|
+
if (!s[_inAfterOpenBeforeSend]) {
|
|
2461
|
+
let l = s[_responseContentLength];
|
|
2462
|
+
emitProcessEvent(this, "loadend", l, l);
|
|
2463
|
+
}
|
|
2464
|
+
});
|
|
2465
|
+
}
|
|
2466
|
+
function clearRequest(xhr, delay = true) {
|
|
2467
|
+
const s = xhr[state$1];
|
|
2468
|
+
const timerFn = delay ? setTimeout : (f) => { f(); };
|
|
2469
|
+
s[_resetPending] = true;
|
|
2470
|
+
if (s[_requestTask] && s.readyState !== XMLHttpRequestP.DONE) {
|
|
2471
|
+
if (delay) {
|
|
2472
|
+
setReadyStateAndNotify(xhr, XMLHttpRequestP.DONE);
|
|
2454
2473
|
}
|
|
2455
|
-
|
|
2474
|
+
timerFn(() => {
|
|
2475
|
+
const requestTask = s[_requestTask];
|
|
2476
|
+
if (requestTask) {
|
|
2477
|
+
requestTask.abort();
|
|
2478
|
+
}
|
|
2479
|
+
if (delay) {
|
|
2480
|
+
emitProcessEvent(xhr, "abort");
|
|
2481
|
+
}
|
|
2482
|
+
if (delay && !requestTask) {
|
|
2483
|
+
emitProcessEvent(xhr, "loadend");
|
|
2484
|
+
}
|
|
2485
|
+
});
|
|
2456
2486
|
}
|
|
2457
|
-
|
|
2458
|
-
|
|
2487
|
+
timerFn(() => {
|
|
2488
|
+
if (s[_resetPending]) {
|
|
2489
|
+
if (delay) {
|
|
2490
|
+
s.readyState = XMLHttpRequestP.UNSENT;
|
|
2491
|
+
}
|
|
2492
|
+
resetXHR(xhr);
|
|
2493
|
+
}
|
|
2494
|
+
});
|
|
2459
2495
|
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2496
|
+
function checkRequestTimeout(xhr) {
|
|
2497
|
+
const s = xhr[state$1];
|
|
2498
|
+
if (s.timeout) {
|
|
2499
|
+
s[_timeoutId] = setTimeout(() => {
|
|
2500
|
+
if (!s.status && s.readyState !== XMLHttpRequestP.DONE) {
|
|
2501
|
+
if (s[_requestTask])
|
|
2502
|
+
s[_requestTask].abort();
|
|
2503
|
+
setReadyStateAndNotify(xhr, XMLHttpRequestP.DONE);
|
|
2504
|
+
emitProcessEvent(xhr, "timeout");
|
|
2505
|
+
}
|
|
2506
|
+
}, s.timeout);
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
function resetXHR(xhr) {
|
|
2510
|
+
const s = xhr[state$1];
|
|
2511
|
+
s[_resetPending] = false;
|
|
2512
|
+
resetRequestTimeout(xhr);
|
|
2513
|
+
s.response = "";
|
|
2514
|
+
s.responseURL = "";
|
|
2515
|
+
s.status = 0;
|
|
2516
|
+
s.statusText = "";
|
|
2517
|
+
s[_requestHeaders] = new HeadersP();
|
|
2518
|
+
s[_responseHeaders] = null;
|
|
2519
|
+
s[_responseContentLength] = zero;
|
|
2520
|
+
}
|
|
2521
|
+
function resetRequestTimeout(xhr) {
|
|
2522
|
+
const s = xhr[state$1];
|
|
2523
|
+
if (s[_timeoutId]) {
|
|
2524
|
+
clearTimeout(s[_timeoutId]);
|
|
2525
|
+
s[_timeoutId] = 0;
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
function setReadyStateAndNotify(xhr, value) {
|
|
2529
|
+
const s = xhr[state$1];
|
|
2530
|
+
let hasChanged = value !== s.readyState;
|
|
2531
|
+
s.readyState = value;
|
|
2532
|
+
if (hasChanged) {
|
|
2533
|
+
let evt = createInnerEvent(xhr, "readystatechange");
|
|
2534
|
+
EventTarget_fire(xhr, evt);
|
|
2470
2535
|
}
|
|
2471
2536
|
}
|
|
2472
|
-
|
|
2537
|
+
function getHandlers(s) {
|
|
2538
|
+
return {
|
|
2539
|
+
onreadystatechange: (ev) => { executeFn(s.target, s.onreadystatechange, ev); },
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
const responseTypes = ["", "text", "json", "arraybuffer", "blob", "document"];
|
|
2543
|
+
function normalizeResponseType(responseType) {
|
|
2544
|
+
return responseTypes.indexOf(responseType) > -1 ? responseType : "";
|
|
2545
|
+
}
|
|
2546
|
+
function normalizeDataType(responseType) {
|
|
2547
|
+
return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
|
|
2548
|
+
}
|
|
2549
|
+
function getAllResponseHeaders(xhr) {
|
|
2550
|
+
return xhr instanceof XMLHttpRequestP
|
|
2551
|
+
? xhr[state$1][_responseHeaders]
|
|
2552
|
+
: parseHeaders(xhr.getAllResponseHeaders() || "");
|
|
2553
|
+
}
|
|
2554
|
+
const zero = () => 0;
|
|
2555
|
+
const statusMessages = {
|
|
2556
|
+
100: "Continue",
|
|
2557
|
+
101: "Switching Protocols",
|
|
2558
|
+
102: "Processing",
|
|
2559
|
+
103: "Early Hints",
|
|
2560
|
+
200: "OK",
|
|
2561
|
+
201: "Created",
|
|
2562
|
+
202: "Accepted",
|
|
2563
|
+
203: "Non-Authoritative Information",
|
|
2564
|
+
204: "No Content",
|
|
2565
|
+
205: "Reset Content",
|
|
2566
|
+
206: "Partial Content",
|
|
2567
|
+
207: "Multi-Status",
|
|
2568
|
+
208: "Already Reported",
|
|
2569
|
+
226: "IM Used",
|
|
2570
|
+
300: "Multiple Choices",
|
|
2571
|
+
301: "Moved Permanently",
|
|
2572
|
+
302: "Found",
|
|
2573
|
+
303: "See Other",
|
|
2574
|
+
304: "Not Modified",
|
|
2575
|
+
307: "Temporary Redirect",
|
|
2576
|
+
308: "Permanent Redirect",
|
|
2577
|
+
400: "Bad Request",
|
|
2578
|
+
401: "Unauthorized",
|
|
2579
|
+
402: "Payment Required",
|
|
2580
|
+
403: "Forbidden",
|
|
2581
|
+
404: "Not Found",
|
|
2582
|
+
405: "Method Not Allowed",
|
|
2583
|
+
406: "Not Acceptable",
|
|
2584
|
+
407: "Proxy Authentication Required",
|
|
2585
|
+
408: "Request Timeout",
|
|
2586
|
+
409: "Conflict",
|
|
2587
|
+
410: "Gone",
|
|
2588
|
+
411: "Length Required",
|
|
2589
|
+
412: "Precondition Failed",
|
|
2590
|
+
413: "Content Too Large",
|
|
2591
|
+
414: "URI Too Long",
|
|
2592
|
+
415: "Unsupported Media Type",
|
|
2593
|
+
416: "Range Not Satisfiable",
|
|
2594
|
+
417: "Expectation Failed",
|
|
2595
|
+
418: "I'm a teapot",
|
|
2596
|
+
421: "Misdirected Request",
|
|
2597
|
+
422: "Unprocessable Entity",
|
|
2598
|
+
423: "Locked",
|
|
2599
|
+
424: "Failed Dependency",
|
|
2600
|
+
425: "Too Early",
|
|
2601
|
+
426: "Upgrade Required",
|
|
2602
|
+
428: "Precondition Required",
|
|
2603
|
+
429: "Too Many Requests",
|
|
2604
|
+
431: "Request Header Fields Too Large",
|
|
2605
|
+
451: "Unavailable For Legal Reasons",
|
|
2606
|
+
500: "Internal Server Error",
|
|
2607
|
+
501: "Not Implemented",
|
|
2608
|
+
502: "Bad Gateway",
|
|
2609
|
+
503: "Service Unavailable",
|
|
2610
|
+
504: "Gateway Timeout",
|
|
2611
|
+
505: "HTTP Version Not Supported",
|
|
2612
|
+
506: "Variant Also Negotiates",
|
|
2613
|
+
507: "Insufficient Storage",
|
|
2614
|
+
508: "Loop Detected",
|
|
2615
|
+
510: "Not Extended",
|
|
2616
|
+
511: "Network Authentication Required"
|
|
2617
|
+
};
|
|
2618
|
+
function statusTextMap(val) {
|
|
2619
|
+
return statusMessages[val] || "unknown";
|
|
2620
|
+
}
|
|
2621
|
+
const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
|
|
2473
2622
|
|
|
2623
|
+
const mp = { XMLHttpRequest: XMLHttpRequestE };
|
|
2624
|
+
const setXMLHttpRequest = (XHR) => { mp.XMLHttpRequest = XHR; };
|
|
2474
2625
|
function fetchP(input, init) {
|
|
2475
2626
|
if (new.target === fetchP) {
|
|
2476
2627
|
throw new TypeError("fetch is not a constructor");
|
|
2477
2628
|
}
|
|
2478
2629
|
return new Promise(function (resolve, reject) {
|
|
2479
2630
|
const request = new RequestP(input, init);
|
|
2480
|
-
const signal = request[state$
|
|
2631
|
+
const signal = request[state$4].signal;
|
|
2481
2632
|
if (signal && signal.aborted) {
|
|
2482
2633
|
return reject(signal.reason);
|
|
2483
2634
|
}
|
|
2484
|
-
let xhr = new
|
|
2635
|
+
let xhr = new mp.XMLHttpRequest();
|
|
2485
2636
|
xhr.onload = function () {
|
|
2486
2637
|
let options = {
|
|
2487
|
-
headers:
|
|
2638
|
+
headers: getAllResponseHeaders(xhr),
|
|
2488
2639
|
status: xhr.status,
|
|
2489
2640
|
statusText: xhr.statusText,
|
|
2490
2641
|
};
|
|
2491
2642
|
setTimeout(() => {
|
|
2492
2643
|
let response = new ResponseP(xhr.response, options);
|
|
2493
|
-
response[state].url = xhr.responseURL;
|
|
2644
|
+
response[state$3].url = xhr.responseURL;
|
|
2494
2645
|
resolve(response);
|
|
2495
2646
|
});
|
|
2496
2647
|
};
|
|
@@ -2544,7 +2695,7 @@ function fetchP(input, init) {
|
|
|
2544
2695
|
}
|
|
2545
2696
|
};
|
|
2546
2697
|
}
|
|
2547
|
-
xhr.send(request
|
|
2698
|
+
xhr.send(Body_toPayload(request));
|
|
2548
2699
|
});
|
|
2549
2700
|
}
|
|
2550
2701
|
function isObjectHeaders(val) {
|
|
@@ -2552,6 +2703,32 @@ function isObjectHeaders(val) {
|
|
|
2552
2703
|
}
|
|
2553
2704
|
const fetchE = g["fetch"] || fetchP;
|
|
2554
2705
|
|
|
2706
|
+
const dispatched = 1;
|
|
2707
|
+
/** @internal */
|
|
2708
|
+
const state = Symbol( /* "CustomEventState" */);
|
|
2709
|
+
class CustomEventP extends EventP {
|
|
2710
|
+
constructor(type, eventInitDict) {
|
|
2711
|
+
var _a;
|
|
2712
|
+
super(type, eventInitDict);
|
|
2713
|
+
this[state] = new CustomEventState();
|
|
2714
|
+
this[state].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
|
|
2715
|
+
}
|
|
2716
|
+
get detail() { return this[state].detail; }
|
|
2717
|
+
initCustomEvent(type, bubbles, cancelable, detail) {
|
|
2718
|
+
if (Event_getEtField(this, dispatched))
|
|
2719
|
+
return;
|
|
2720
|
+
this.initEvent(type, bubbles, cancelable);
|
|
2721
|
+
this[state].detail = detail !== null && detail !== void 0 ? detail : null;
|
|
2722
|
+
}
|
|
2723
|
+
toString() { return "[object CustomEvent]"; }
|
|
2724
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
|
|
2725
|
+
}
|
|
2726
|
+
dfStringTag(CustomEventP, "CustomEvent");
|
|
2727
|
+
/** @internal */
|
|
2728
|
+
class CustomEventState {
|
|
2729
|
+
}
|
|
2730
|
+
const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
|
|
2731
|
+
|
|
2555
2732
|
exports.AbortController = AbortControllerE;
|
|
2556
2733
|
exports.AbortControllerP = AbortControllerP;
|
|
2557
2734
|
exports.AbortSignal = AbortSignalE;
|
|
@@ -2588,3 +2765,5 @@ exports.XMLHttpRequest = XMLHttpRequestE;
|
|
|
2588
2765
|
exports.XMLHttpRequestP = XMLHttpRequestP;
|
|
2589
2766
|
exports.fetch = fetchE;
|
|
2590
2767
|
exports.fetchP = fetchP;
|
|
2768
|
+
exports.setRequest = setRequest;
|
|
2769
|
+
exports.setXMLHttpRequest = setXMLHttpRequest;
|