mphttpx 1.0.0
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 +1 -0
- package/dist/global.js +1 -0
- package/dist/index.cjs.js +2349 -0
- package/dist/index.cjs.min.js +1 -0
- package/dist/index.d.ts +823 -0
- package/dist/index.esm.js +2312 -0
- package/dist/index.esm.min.js +1 -0
- package/dist/types/AbortControllerP.d.ts +20 -0
- package/dist/types/AbortSignalP.d.ts +37 -0
- package/dist/types/BlobP.d.ts +30 -0
- package/dist/types/BodyP.d.ts +33 -0
- package/dist/types/CustomEventP.d.ts +21 -0
- package/dist/types/EventP.d.ts +64 -0
- package/dist/types/EventTargetP.d.ts +37 -0
- package/dist/types/FileP.d.ts +23 -0
- package/dist/types/FileReaderP.d.ts +67 -0
- package/dist/types/FormDataP.d.ts +37 -0
- package/dist/types/HeadersP.d.ts +31 -0
- package/dist/types/ProgressEventP.d.ts +24 -0
- package/dist/types/RequestP.d.ts +45 -0
- package/dist/types/ResponseP.d.ts +39 -0
- package/dist/types/TextDecoderP.d.ts +31 -0
- package/dist/types/TextEncoderP.d.ts +15 -0
- package/dist/types/URLSearchParamsP.d.ts +31 -0
- package/dist/types/XMLHttpRequestEventTargetP.d.ts +47 -0
- package/dist/types/XMLHttpRequestP.d.ts +94 -0
- package/dist/types/XMLHttpRequestUploadP.d.ts +10 -0
- package/dist/types/fetchP.d.ts +3 -0
- package/dist/types/global.d.ts +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/isPolyfill.d.ts +9 -0
- package/dist/types/platform.d.ts +4 -0
- package/dist/types/request.d.ts +362 -0
- package/package.json +30 -0
|
@@ -0,0 +1,2349 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const polyfill = Symbol("isPolyfill");
|
|
4
|
+
const state$9 = Symbol("INTERNAL_STATE");
|
|
5
|
+
/* eslint-disable no-prototype-builtins */
|
|
6
|
+
const g = (typeof globalThis !== "undefined" && globalThis) ||
|
|
7
|
+
(typeof self !== "undefined" && self) ||
|
|
8
|
+
// @ts-ignore eslint-disable-next-line no-undef
|
|
9
|
+
(typeof global !== "undefined" && global) ||
|
|
10
|
+
{};
|
|
11
|
+
function isObjectType(name, value) {
|
|
12
|
+
return Object.prototype.toString.call(value) === `[object ${name}]`;
|
|
13
|
+
}
|
|
14
|
+
function isPolyfillType(name, value) {
|
|
15
|
+
return !!value
|
|
16
|
+
&& typeof value === "object"
|
|
17
|
+
&& "isPolyfill" in value
|
|
18
|
+
&& !!value.isPolyfill
|
|
19
|
+
&& typeof value.isPolyfill === "object"
|
|
20
|
+
&& "symbol" in value.isPolyfill
|
|
21
|
+
&& value.isPolyfill.symbol === polyfill
|
|
22
|
+
&& "hierarchy" in value.isPolyfill
|
|
23
|
+
&& Array.isArray(value.isPolyfill.hierarchy)
|
|
24
|
+
&& value.isPolyfill.hierarchy.includes(name);
|
|
25
|
+
}
|
|
26
|
+
class MPException extends Error {
|
|
27
|
+
constructor(message, name) {
|
|
28
|
+
super();
|
|
29
|
+
this.message = message ?? this.message;
|
|
30
|
+
this.name = name ?? this.name;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function defineStringTag(targetFunc, stringTag) {
|
|
34
|
+
Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
|
|
35
|
+
configurable: true,
|
|
36
|
+
value: stringTag,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class TextEncoderP {
|
|
41
|
+
get encoding() { return "utf-8"; }
|
|
42
|
+
encode(input = "") {
|
|
43
|
+
return encodeText(input).encoded;
|
|
44
|
+
}
|
|
45
|
+
encodeInto(source, destination) {
|
|
46
|
+
const result = encodeText(source, destination);
|
|
47
|
+
return { read: result.read, written: result.written };
|
|
48
|
+
}
|
|
49
|
+
toString() { return "[object TextEncoder]"; }
|
|
50
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
|
|
51
|
+
}
|
|
52
|
+
defineStringTag(TextEncoderP, "TextEncoder");
|
|
53
|
+
function encodeText(input, destination) {
|
|
54
|
+
const HAS_DESTINATION = typeof destination !== "undefined";
|
|
55
|
+
let pos = 0;
|
|
56
|
+
let read = 0;
|
|
57
|
+
let len = input.length;
|
|
58
|
+
let at = 0; // output position
|
|
59
|
+
let tlen = Math.max(32, len + (len >> 1) + 7); // 1.5x size
|
|
60
|
+
let target = HAS_DESTINATION ? destination : new Uint8Array((tlen >> 3) << 3); // ... but at 8 byte offset
|
|
61
|
+
while (pos < len) {
|
|
62
|
+
let value = input.charCodeAt(pos++);
|
|
63
|
+
if (value >= 0xd800 && value <= 0xdbff) {
|
|
64
|
+
// high surrogate
|
|
65
|
+
if (pos < len) {
|
|
66
|
+
let extra = input.charCodeAt(pos);
|
|
67
|
+
if ((extra & 0xfc00) === 0xdc00) {
|
|
68
|
+
++pos;
|
|
69
|
+
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
value = 0xfffd;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
value = 0xfffd;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (value >= 0xdc00 && value <= 0xdfff) {
|
|
80
|
+
value = 0xfffd;
|
|
81
|
+
}
|
|
82
|
+
// expand the buffer if we couldn't write 4 bytes
|
|
83
|
+
if (!HAS_DESTINATION && at + 4 > target.length) {
|
|
84
|
+
tlen += 8; // minimum extra
|
|
85
|
+
tlen *= (1.0 + (pos / input.length) * 2); // take 2x the remaining
|
|
86
|
+
tlen = (tlen >> 3) << 3; // 8 byte offset
|
|
87
|
+
let update = new Uint8Array(tlen);
|
|
88
|
+
update.set(target);
|
|
89
|
+
target = update;
|
|
90
|
+
}
|
|
91
|
+
let byteCount;
|
|
92
|
+
if ((value & 0xffffff80) === 0) { // 1-byte
|
|
93
|
+
byteCount = 1;
|
|
94
|
+
}
|
|
95
|
+
else if ((value & 0xfffff800) === 0) { // 2-byte
|
|
96
|
+
byteCount = 2;
|
|
97
|
+
}
|
|
98
|
+
else if ((value & 0xffff0000) === 0) { // 3-byte
|
|
99
|
+
byteCount = 3;
|
|
100
|
+
}
|
|
101
|
+
else if ((value & 0xffe00000) === 0) { // 4-byte
|
|
102
|
+
byteCount = 4;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
value = 0xfffd;
|
|
106
|
+
byteCount = 3;
|
|
107
|
+
}
|
|
108
|
+
if (HAS_DESTINATION && at + byteCount > target.length) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
if (byteCount === 1) { // 1-byte
|
|
112
|
+
target[at++] = value; // ASCII
|
|
113
|
+
}
|
|
114
|
+
else if (byteCount === 2) { // 2-byte
|
|
115
|
+
target[at++] = ((value >> 6) & 0x1f) | 0xc0;
|
|
116
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
117
|
+
}
|
|
118
|
+
else if (byteCount === 3) { // 3-byte
|
|
119
|
+
target[at++] = ((value >> 12) & 0x0f) | 0xe0;
|
|
120
|
+
target[at++] = ((value >> 6) & 0x3f) | 0x80;
|
|
121
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
122
|
+
}
|
|
123
|
+
else if (byteCount === 4) { // 4-byte
|
|
124
|
+
target[at++] = ((value >> 18) & 0x07) | 0xf0;
|
|
125
|
+
target[at++] = ((value >> 12) & 0x3f) | 0x80;
|
|
126
|
+
target[at++] = ((value >> 6) & 0x3f) | 0x80;
|
|
127
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
128
|
+
}
|
|
129
|
+
read++;
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
encoded: !HAS_DESTINATION ? target.slice(0, at) : destination.slice(),
|
|
133
|
+
read: read,
|
|
134
|
+
written: at,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const TextEncoderE = g["TextEncoder"] || TextEncoderP;
|
|
138
|
+
|
|
139
|
+
const state$8 = Symbol("TextDecoderState");
|
|
140
|
+
class TextDecoderP {
|
|
141
|
+
constructor(utfLabel = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
|
|
142
|
+
if (!UTF8Labels.includes(utfLabel.toLowerCase())) {
|
|
143
|
+
throw new RangeError("TextDecoder: The encoding label provided ('" + utfLabel + "') is invalid.");
|
|
144
|
+
}
|
|
145
|
+
this[state$8] = new TextDecoderState();
|
|
146
|
+
this[state$8].fatal = fatal;
|
|
147
|
+
this[state$8].ignoreBOM = ignoreBOM;
|
|
148
|
+
}
|
|
149
|
+
[state$8];
|
|
150
|
+
get encoding() { return "utf-8"; }
|
|
151
|
+
get fatal() { return this[state$8].fatal; }
|
|
152
|
+
get ignoreBOM() { return this[state$8].ignoreBOM; }
|
|
153
|
+
decode(buffer, { stream = false } = {}) {
|
|
154
|
+
let buf;
|
|
155
|
+
if (typeof buffer !== "undefined") {
|
|
156
|
+
if (buffer instanceof Uint8Array) {
|
|
157
|
+
buf = buffer;
|
|
158
|
+
}
|
|
159
|
+
else if (ArrayBuffer.isView(buffer)) {
|
|
160
|
+
buf = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
buf = new Uint8Array(buffer);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
if (this[state$8]._partial.length > 0) {
|
|
168
|
+
if (this.fatal) {
|
|
169
|
+
throw new TypeError("TextDecoder: Incomplete UTF-8 sequence.");
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this[state$8]._partial = [];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return "";
|
|
176
|
+
}
|
|
177
|
+
if (!this[state$8]._bomSeen && this.ignoreBOM && buf.length >= 3) {
|
|
178
|
+
if (buf[0] === 0xef && buf[1] === 0xbb && buf[2] === 0xbf) {
|
|
179
|
+
buf = buf.subarray(3);
|
|
180
|
+
this[state$8]._bomSeen = true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (this[state$8]._partial.length > 0) {
|
|
184
|
+
let merged = new Uint8Array(this[state$8]._partial.length + buf.length);
|
|
185
|
+
merged.set(this[state$8]._partial, 0);
|
|
186
|
+
merged.set(buf, this[state$8]._partial.length);
|
|
187
|
+
buf = merged;
|
|
188
|
+
this[state$8]._partial = [];
|
|
189
|
+
}
|
|
190
|
+
let end = buf.length;
|
|
191
|
+
let res = [];
|
|
192
|
+
if (stream && buf.length > 0) {
|
|
193
|
+
let i = buf.length;
|
|
194
|
+
while (i > 0 && i > buf.length - 4) {
|
|
195
|
+
let byte = buf[i - 1];
|
|
196
|
+
if ((byte & 0b11000000) !== 0b10000000) {
|
|
197
|
+
let len = getBytesPerSequence(byte);
|
|
198
|
+
if (len > buf.length - (i - 1)) {
|
|
199
|
+
end = i - 1;
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
i--;
|
|
204
|
+
}
|
|
205
|
+
this[state$8]._partial = Array.from(buf.slice(end)); // save tail
|
|
206
|
+
buf = buf.slice(0, end);
|
|
207
|
+
}
|
|
208
|
+
let i = 0;
|
|
209
|
+
while (i < end) {
|
|
210
|
+
let firstByte = buf[i];
|
|
211
|
+
let codePoint = null;
|
|
212
|
+
let bytesPerSequence = getBytesPerSequence(firstByte);
|
|
213
|
+
if (i + bytesPerSequence <= end) {
|
|
214
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
215
|
+
switch (bytesPerSequence) {
|
|
216
|
+
case 1:
|
|
217
|
+
if (firstByte < 0x80) {
|
|
218
|
+
codePoint = firstByte;
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
case 2:
|
|
222
|
+
secondByte = buf[i + 1];
|
|
223
|
+
if ((secondByte & 0xC0) === 0x80) {
|
|
224
|
+
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
225
|
+
if (tempCodePoint > 0x7F) {
|
|
226
|
+
codePoint = tempCodePoint;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
case 3:
|
|
231
|
+
secondByte = buf[i + 1];
|
|
232
|
+
thirdByte = buf[i + 2];
|
|
233
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
234
|
+
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
235
|
+
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
236
|
+
codePoint = tempCodePoint;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
break;
|
|
240
|
+
case 4:
|
|
241
|
+
secondByte = buf[i + 1];
|
|
242
|
+
thirdByte = buf[i + 2];
|
|
243
|
+
fourthByte = buf[i + 3];
|
|
244
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
245
|
+
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
246
|
+
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
247
|
+
codePoint = tempCodePoint;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (codePoint === null) {
|
|
253
|
+
if (this.fatal) {
|
|
254
|
+
throw new TypeError("TextDecoder.decode: Decoding failed.");
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
// we did not generate a valid codePoint so insert a
|
|
258
|
+
// replacement char (U+FFFD) and advance only 1 byte
|
|
259
|
+
codePoint = 0xFFFD;
|
|
260
|
+
bytesPerSequence = 1;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else if (codePoint > 0xFFFF) {
|
|
264
|
+
// encode to utf16 (surrogate pair dance)
|
|
265
|
+
codePoint -= 0x10000;
|
|
266
|
+
res.push(codePoint >>> 10 & 0x3FF | 0xD800);
|
|
267
|
+
codePoint = 0xDC00 | codePoint & 0x3FF;
|
|
268
|
+
}
|
|
269
|
+
res.push(codePoint);
|
|
270
|
+
i += bytesPerSequence;
|
|
271
|
+
}
|
|
272
|
+
let str = "";
|
|
273
|
+
for (let j = 0, len = res.length; j < len; j += 0x1000) {
|
|
274
|
+
str += String.fromCharCode.apply(String, res.slice(j, j + 0x1000));
|
|
275
|
+
}
|
|
276
|
+
return str;
|
|
277
|
+
}
|
|
278
|
+
toString() { return "[object TextDecoder]"; }
|
|
279
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
|
|
280
|
+
}
|
|
281
|
+
defineStringTag(TextDecoderP, "TextDecoder");
|
|
282
|
+
class TextDecoderState {
|
|
283
|
+
fatal = false;
|
|
284
|
+
ignoreBOM = false;
|
|
285
|
+
_bomSeen = false;
|
|
286
|
+
_partial = [];
|
|
287
|
+
}
|
|
288
|
+
const UTF8Labels = ["utf-8", "utf8", "unicode-1-1-utf-8"];
|
|
289
|
+
function getBytesPerSequence(byte) {
|
|
290
|
+
return (byte > 0xEF) ? 4 : (byte > 0xDF) ? 3 : (byte > 0xBF) ? 2 : 1;
|
|
291
|
+
}
|
|
292
|
+
const TextDecoderE = g["TextDecoder"] || TextDecoderP;
|
|
293
|
+
|
|
294
|
+
class EventP {
|
|
295
|
+
static NONE = 0;
|
|
296
|
+
static CAPTURING_PHASE = 1;
|
|
297
|
+
static AT_TARGET = 2;
|
|
298
|
+
static BUBBLING_PHASE = 3;
|
|
299
|
+
constructor(type, eventInitDict) {
|
|
300
|
+
this[state$9] = new EventState();
|
|
301
|
+
this[state$9].type = String(type);
|
|
302
|
+
this[state$9].bubbles = !!eventInitDict?.bubbles;
|
|
303
|
+
this[state$9].cancelable = !!eventInitDict?.cancelable;
|
|
304
|
+
this[state$9].composed = !!eventInitDict?.composed;
|
|
305
|
+
}
|
|
306
|
+
[state$9];
|
|
307
|
+
get type() { return this[state$9].type; }
|
|
308
|
+
get bubbles() { return this[state$9].bubbles; }
|
|
309
|
+
get cancelable() { return this[state$9].cancelable; }
|
|
310
|
+
get composed() { return this[state$9].composed; }
|
|
311
|
+
get target() { return this[state$9].target; }
|
|
312
|
+
get currentTarget() { return this[state$9].currentTarget; }
|
|
313
|
+
get eventPhase() { return this[state$9].eventPhase; }
|
|
314
|
+
NONE = EventP.NONE;
|
|
315
|
+
CAPTURING_PHASE = EventP.CAPTURING_PHASE;
|
|
316
|
+
AT_TARGET = EventP.AT_TARGET;
|
|
317
|
+
BUBBLING_PHASE = EventP.BUBBLING_PHASE;
|
|
318
|
+
get srcElement() { return this[state$9].target; }
|
|
319
|
+
cancelBubble = false;
|
|
320
|
+
get defaultPrevented() { return this[state$9].defaultPrevented; }
|
|
321
|
+
get returnValue() { return this[state$9].returnValue; }
|
|
322
|
+
set returnValue(value) { if (!value) {
|
|
323
|
+
this.preventDefault();
|
|
324
|
+
} }
|
|
325
|
+
get isTrusted() { return this[state$9].isTrusted; }
|
|
326
|
+
get timeStamp() { return this[state$9].timeStamp; }
|
|
327
|
+
composedPath() {
|
|
328
|
+
const path = !!this.target ? [this.target] : [];
|
|
329
|
+
if (!!this.currentTarget && this.currentTarget !== this.target)
|
|
330
|
+
path.push(this.currentTarget);
|
|
331
|
+
return path;
|
|
332
|
+
}
|
|
333
|
+
initEvent = (type, bubbles, cancelable) => {
|
|
334
|
+
if (this[state$9]._dispatched)
|
|
335
|
+
return;
|
|
336
|
+
this[state$9].type = String(type);
|
|
337
|
+
this[state$9].bubbles = !!bubbles;
|
|
338
|
+
this[state$9].cancelable = !!cancelable;
|
|
339
|
+
};
|
|
340
|
+
preventDefault = () => {
|
|
341
|
+
if (this[state$9]._passive) {
|
|
342
|
+
console.warn(`Ignoring 'preventDefault()' call on event of type '${this.type}' from a listener registered as 'passive'.`);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (this.cancelable) {
|
|
346
|
+
this[state$9]._preventDefaultCalled = true;
|
|
347
|
+
this[state$9].defaultPrevented = true;
|
|
348
|
+
this[state$9].returnValue = false;
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
stopImmediatePropagation = () => {
|
|
352
|
+
this[state$9]._stopImmediatePropagationCalled = true;
|
|
353
|
+
this.cancelBubble = true;
|
|
354
|
+
};
|
|
355
|
+
stopPropagation() {
|
|
356
|
+
this.cancelBubble = true;
|
|
357
|
+
}
|
|
358
|
+
toString() { return "[object Event]"; }
|
|
359
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
|
|
360
|
+
}
|
|
361
|
+
defineStringTag(EventP, "Event");
|
|
362
|
+
class EventState {
|
|
363
|
+
static TimeStamp = (new Date()).getTime();
|
|
364
|
+
type = "";
|
|
365
|
+
bubbles = false;
|
|
366
|
+
cancelable = false;
|
|
367
|
+
composed = false;
|
|
368
|
+
target = null;
|
|
369
|
+
currentTarget = null;
|
|
370
|
+
eventPhase = EventP.NONE;
|
|
371
|
+
defaultPrevented = false;
|
|
372
|
+
returnValue = true;
|
|
373
|
+
isTrusted = false;
|
|
374
|
+
timeStamp = (new Date()).getTime() - EventState.TimeStamp;
|
|
375
|
+
_passive = false;
|
|
376
|
+
_dispatched = false;
|
|
377
|
+
_preventDefaultCalled = false;
|
|
378
|
+
_stopImmediatePropagationCalled = false;
|
|
379
|
+
}
|
|
380
|
+
const EventE = g["EventTarget"] ? g["Event"] : EventP;
|
|
381
|
+
|
|
382
|
+
const state$7 = Symbol("EventTargetState");
|
|
383
|
+
class EventTargetP {
|
|
384
|
+
constructor() {
|
|
385
|
+
this[state$7] = new EventTargetState(this);
|
|
386
|
+
}
|
|
387
|
+
[state$7];
|
|
388
|
+
addEventListener(type, callback, options) {
|
|
389
|
+
const executor = new Executor(type, callback);
|
|
390
|
+
executor.options.capture = typeof options === "boolean" ? options : !!options?.capture;
|
|
391
|
+
if (!this[state$7].executors.some(x => x.equals(executor))) {
|
|
392
|
+
if (typeof options === "object") {
|
|
393
|
+
const { once, passive, signal } = options;
|
|
394
|
+
executor.options.once = !!once;
|
|
395
|
+
executor.options.passive = !!passive;
|
|
396
|
+
if (signal) {
|
|
397
|
+
executor.options.signal = signal;
|
|
398
|
+
this[state$7].reply(signal, executor);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
this[state$7].executors.push(executor);
|
|
402
|
+
const f = (v) => !!v.options.capture ? 0 : 1;
|
|
403
|
+
this[state$7].executors = this[state$7].executors.sort((a, b) => f(a) - f(b));
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
dispatchEvent(event) {
|
|
407
|
+
if (typeof event !== "object") {
|
|
408
|
+
throw new TypeError("EventTarget.dispatchEvent: Argument 1 is not an object.");
|
|
409
|
+
}
|
|
410
|
+
if (!(event instanceof EventP)) {
|
|
411
|
+
throw new TypeError("EventTarget.dispatchEvent: Argument 1 does not implement interface Event.");
|
|
412
|
+
}
|
|
413
|
+
const s = event[state$9];
|
|
414
|
+
s.target = this;
|
|
415
|
+
s.isTrusted = false;
|
|
416
|
+
return this[state$7].fire(event);
|
|
417
|
+
}
|
|
418
|
+
removeEventListener(type, callback, options) {
|
|
419
|
+
const executor = new Executor(type, callback);
|
|
420
|
+
executor.options.capture = typeof options === "boolean" ? options : !!options?.capture;
|
|
421
|
+
if (this[state$7].executors.some(x => x.equals(executor))) {
|
|
422
|
+
this[state$7].executors = this[state$7].executors.filter(x => !x.equals(executor));
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
toString() { return "[object EventTarget]"; }
|
|
426
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
|
|
427
|
+
}
|
|
428
|
+
defineStringTag(EventTargetP, "EventTarget");
|
|
429
|
+
class EventTargetState {
|
|
430
|
+
constructor(target) {
|
|
431
|
+
this.target = target;
|
|
432
|
+
}
|
|
433
|
+
target;
|
|
434
|
+
executors = [];
|
|
435
|
+
fire(event) {
|
|
436
|
+
const s = event[state$9];
|
|
437
|
+
if (!event.target)
|
|
438
|
+
s.target = this.target;
|
|
439
|
+
s.currentTarget = this.target;
|
|
440
|
+
s.eventPhase = EventP.AT_TARGET;
|
|
441
|
+
s._dispatched = true;
|
|
442
|
+
const onceIndexes = [];
|
|
443
|
+
for (let i = 0; i < this.executors.length; ++i) {
|
|
444
|
+
const executor = this.executors[i];
|
|
445
|
+
if (executor.type !== event.type)
|
|
446
|
+
continue;
|
|
447
|
+
s._passive = !!executor.options.passive;
|
|
448
|
+
if (executor.options.once)
|
|
449
|
+
onceIndexes.push(i);
|
|
450
|
+
try {
|
|
451
|
+
const { callback: cb } = executor;
|
|
452
|
+
if (typeof cb === "function")
|
|
453
|
+
cb.call(this.target, event);
|
|
454
|
+
}
|
|
455
|
+
catch (e) {
|
|
456
|
+
console.error(e);
|
|
457
|
+
}
|
|
458
|
+
s._passive = false;
|
|
459
|
+
if (s._stopImmediatePropagationCalled)
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
if (onceIndexes.length > 0) {
|
|
463
|
+
this.executors = this.executors.reduce((acc, cur, index) => {
|
|
464
|
+
if (!onceIndexes.includes(index))
|
|
465
|
+
acc.push(cur);
|
|
466
|
+
return acc;
|
|
467
|
+
}, []);
|
|
468
|
+
}
|
|
469
|
+
s.currentTarget = null;
|
|
470
|
+
s.eventPhase = EventP.NONE;
|
|
471
|
+
s._dispatched = false;
|
|
472
|
+
return !(event.cancelable && s._preventDefaultCalled);
|
|
473
|
+
}
|
|
474
|
+
reply(signal, executor) {
|
|
475
|
+
try {
|
|
476
|
+
const onAbort = () => {
|
|
477
|
+
this.executors = this.executors.filter(x => !x.equals(executor));
|
|
478
|
+
signal.removeEventListener("abort", onAbort);
|
|
479
|
+
};
|
|
480
|
+
signal.addEventListener("abort", onAbort);
|
|
481
|
+
}
|
|
482
|
+
catch (e) {
|
|
483
|
+
console.error(e);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
class Executor {
|
|
488
|
+
static extract(cb) {
|
|
489
|
+
if (typeof cb === "function") {
|
|
490
|
+
return cb;
|
|
491
|
+
}
|
|
492
|
+
else if (isEventListenerObject(cb)) {
|
|
493
|
+
return cb.handleEvent;
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
return cb;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
constructor(type, callback) {
|
|
500
|
+
this.type = String(type);
|
|
501
|
+
this.callback = Executor.extract(callback);
|
|
502
|
+
}
|
|
503
|
+
type;
|
|
504
|
+
callback;
|
|
505
|
+
options = {};
|
|
506
|
+
equals(executor) {
|
|
507
|
+
return Object.is(this.type, executor.type) && Object.is(this.callback, executor.callback)
|
|
508
|
+
&& Object.is(this.options.capture, executor.options.capture);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function isEventListenerObject(cb) {
|
|
512
|
+
return !!cb && "handleEvent" in cb && typeof cb.handleEvent === "function";
|
|
513
|
+
}
|
|
514
|
+
function attachFn(type, cb, listener) {
|
|
515
|
+
if (typeof cb === "function") {
|
|
516
|
+
this.addEventListener(type, listener);
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
this.removeEventListener(type, listener);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function executeFn(cb, ev) {
|
|
523
|
+
if (typeof cb === "function")
|
|
524
|
+
cb.call(this, ev);
|
|
525
|
+
}
|
|
526
|
+
const EventTargetE = g["EventTarget"] || EventTargetP;
|
|
527
|
+
|
|
528
|
+
const state$6 = Symbol("CustomEventState");
|
|
529
|
+
class CustomEventP extends EventP {
|
|
530
|
+
constructor(type, eventInitDict) {
|
|
531
|
+
super(type, eventInitDict);
|
|
532
|
+
this[state$6] = new CustomEventState();
|
|
533
|
+
this[state$6].detail = eventInitDict?.detail ?? null;
|
|
534
|
+
}
|
|
535
|
+
[state$6];
|
|
536
|
+
get detail() { return this[state$6].detail; }
|
|
537
|
+
initCustomEvent(type, bubbles, cancelable, detail) {
|
|
538
|
+
if (this[state$9]._dispatched)
|
|
539
|
+
return;
|
|
540
|
+
this.initEvent(type, bubbles, cancelable);
|
|
541
|
+
this[state$6].detail = detail ?? null;
|
|
542
|
+
}
|
|
543
|
+
toString() { return "[object CustomEvent]"; }
|
|
544
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
|
|
545
|
+
}
|
|
546
|
+
defineStringTag(CustomEventP, "CustomEvent");
|
|
547
|
+
class CustomEventState {
|
|
548
|
+
detail;
|
|
549
|
+
}
|
|
550
|
+
const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
|
|
551
|
+
|
|
552
|
+
const state$5 = Symbol("ProgressEventState");
|
|
553
|
+
class ProgressEventP extends EventP {
|
|
554
|
+
constructor(type, eventInitDict) {
|
|
555
|
+
super(type, eventInitDict);
|
|
556
|
+
this[state$5] = new ProgressEventState();
|
|
557
|
+
this[state$5].lengthComputable = !!eventInitDict?.lengthComputable;
|
|
558
|
+
this[state$5].loaded = eventInitDict?.loaded ?? 0;
|
|
559
|
+
this[state$5].total = eventInitDict?.total ?? 0;
|
|
560
|
+
}
|
|
561
|
+
[state$5];
|
|
562
|
+
get lengthComputable() { return this[state$5].lengthComputable; }
|
|
563
|
+
get loaded() { return this[state$5].loaded; }
|
|
564
|
+
get total() { return this[state$5].total; }
|
|
565
|
+
toString() { return "[object ProgressEvent]"; }
|
|
566
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
|
|
567
|
+
}
|
|
568
|
+
defineStringTag(ProgressEventP, "ProgressEvent");
|
|
569
|
+
class ProgressEventState {
|
|
570
|
+
lengthComputable = false;
|
|
571
|
+
loaded = 0;
|
|
572
|
+
total = 0;
|
|
573
|
+
}
|
|
574
|
+
const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
|
|
575
|
+
|
|
576
|
+
class BlobP {
|
|
577
|
+
constructor(blobParts = [], options) {
|
|
578
|
+
if (!Array.isArray(blobParts)) {
|
|
579
|
+
throw new TypeError("First argument to Blob constructor must be an Array.");
|
|
580
|
+
}
|
|
581
|
+
let encoder = null;
|
|
582
|
+
let chunks = blobParts.reduce((chunks, part) => {
|
|
583
|
+
if (isPolyfillType("Blob", part)) {
|
|
584
|
+
chunks.push(part[state$9]._u8array);
|
|
585
|
+
}
|
|
586
|
+
else if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
587
|
+
chunks.push(convert$1(part));
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
if (!encoder) {
|
|
591
|
+
encoder = new TextEncoderP();
|
|
592
|
+
}
|
|
593
|
+
chunks.push(encoder.encode(String(part)));
|
|
594
|
+
}
|
|
595
|
+
return chunks;
|
|
596
|
+
}, []);
|
|
597
|
+
this[state$9] = new BlobState(concat(chunks));
|
|
598
|
+
this[state$9].size = this[state$9]._u8array.length;
|
|
599
|
+
const rawType = options?.type || "";
|
|
600
|
+
this[state$9].type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
|
|
601
|
+
}
|
|
602
|
+
[state$9];
|
|
603
|
+
get size() { return this[state$9].size; }
|
|
604
|
+
get type() { return this[state$9].type; }
|
|
605
|
+
arrayBuffer() {
|
|
606
|
+
return Promise.resolve(clone(this[state$9]._u8array.buffer).buffer);
|
|
607
|
+
}
|
|
608
|
+
bytes() {
|
|
609
|
+
return Promise.resolve(clone(this[state$9]._u8array.buffer));
|
|
610
|
+
}
|
|
611
|
+
slice(start, end, contentType) {
|
|
612
|
+
const sliced = this[state$9]._u8array.slice(start ?? 0, end ?? this[state$9]._u8array.length);
|
|
613
|
+
return new BlobP([sliced], { type: contentType ?? "" });
|
|
614
|
+
}
|
|
615
|
+
stream() {
|
|
616
|
+
throw new ReferenceError("ReadableStream is not defined");
|
|
617
|
+
}
|
|
618
|
+
text() {
|
|
619
|
+
const decoder = new TextDecoderP();
|
|
620
|
+
return Promise.resolve(decoder.decode(this[state$9]._u8array));
|
|
621
|
+
}
|
|
622
|
+
toString() { return "[object Blob]"; }
|
|
623
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
|
|
624
|
+
}
|
|
625
|
+
defineStringTag(BlobP, "Blob");
|
|
626
|
+
class BlobState {
|
|
627
|
+
constructor(buffer) {
|
|
628
|
+
this._u8array = buffer;
|
|
629
|
+
}
|
|
630
|
+
size = 0;
|
|
631
|
+
type = "";
|
|
632
|
+
_u8array;
|
|
633
|
+
}
|
|
634
|
+
function u8array2base64(input) {
|
|
635
|
+
let byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
636
|
+
let output = [];
|
|
637
|
+
for (var i = 0; i < input.length; i += 3) {
|
|
638
|
+
let byte1 = input[i];
|
|
639
|
+
let haveByte2 = i + 1 < input.length;
|
|
640
|
+
let byte2 = haveByte2 ? input[i + 1] : 0;
|
|
641
|
+
let haveByte3 = i + 2 < input.length;
|
|
642
|
+
let byte3 = haveByte3 ? input[i + 2] : 0;
|
|
643
|
+
let outByte1 = byte1 >> 2;
|
|
644
|
+
let outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
|
|
645
|
+
let outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6);
|
|
646
|
+
let outByte4 = byte3 & 0x3F;
|
|
647
|
+
if (!haveByte3) {
|
|
648
|
+
outByte4 = 64;
|
|
649
|
+
if (!haveByte2) {
|
|
650
|
+
outByte3 = 64;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
|
|
654
|
+
}
|
|
655
|
+
return output.join("");
|
|
656
|
+
}
|
|
657
|
+
function convert$1(buf) {
|
|
658
|
+
return buf instanceof ArrayBuffer
|
|
659
|
+
? new Uint8Array(buf)
|
|
660
|
+
: new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
661
|
+
}
|
|
662
|
+
function clone(buf) {
|
|
663
|
+
const sourceArray = convert$1(buf);
|
|
664
|
+
const cloneArray = new Uint8Array(new ArrayBuffer(sourceArray.byteLength));
|
|
665
|
+
cloneArray.set(sourceArray);
|
|
666
|
+
return cloneArray;
|
|
667
|
+
}
|
|
668
|
+
function concat(chunks) {
|
|
669
|
+
const totalByteLength = chunks.reduce((acc, cur) => acc + cur.byteLength, 0);
|
|
670
|
+
const result = new Uint8Array(totalByteLength);
|
|
671
|
+
chunks.reduce((offset, chunk) => {
|
|
672
|
+
result.set(chunk, offset);
|
|
673
|
+
return offset + chunk.byteLength;
|
|
674
|
+
}, 0);
|
|
675
|
+
return result;
|
|
676
|
+
}
|
|
677
|
+
const BlobE = g["Blob"] || BlobP;
|
|
678
|
+
|
|
679
|
+
const state$4 = Symbol("FileState");
|
|
680
|
+
class FileP extends BlobP {
|
|
681
|
+
constructor(fileBits, fileName, options) {
|
|
682
|
+
super(fileBits, options);
|
|
683
|
+
this[state$4] = new FileState();
|
|
684
|
+
this[state$4].lastModified = +(options?.lastModified ? new Date(options.lastModified) : new Date());
|
|
685
|
+
this[state$4].name = fileName.replace(/\//g, ":");
|
|
686
|
+
}
|
|
687
|
+
[state$4];
|
|
688
|
+
get lastModified() { return this[state$4].lastModified; }
|
|
689
|
+
get name() { return this[state$4].name; }
|
|
690
|
+
get webkitRelativePath() { return ""; }
|
|
691
|
+
toString() { return "[object File]"; }
|
|
692
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
|
|
693
|
+
}
|
|
694
|
+
defineStringTag(FileP, "File");
|
|
695
|
+
class FileState {
|
|
696
|
+
lastModified = 0;
|
|
697
|
+
name = "";
|
|
698
|
+
}
|
|
699
|
+
const FileE = g["Blob"] ? g["File"] : FileP;
|
|
700
|
+
|
|
701
|
+
const state$3 = Symbol("FileReaderState");
|
|
702
|
+
class FileReaderP extends EventTargetP {
|
|
703
|
+
static EMPTY = 0;
|
|
704
|
+
static LOADING = 1;
|
|
705
|
+
static DONE = 2;
|
|
706
|
+
constructor() {
|
|
707
|
+
super();
|
|
708
|
+
this[state$3] = new FileReaderState(this);
|
|
709
|
+
}
|
|
710
|
+
[state$3];
|
|
711
|
+
get readyState() { return this[state$3].readyState; }
|
|
712
|
+
get result() { return this[state$3].result; }
|
|
713
|
+
EMPTY = 0;
|
|
714
|
+
LOADING = 1;
|
|
715
|
+
DONE = 2;
|
|
716
|
+
get error() { return this[state$3].error; }
|
|
717
|
+
abort() {
|
|
718
|
+
if (this.readyState === FileReaderP.LOADING) {
|
|
719
|
+
this[state$3].readyState = FileReaderP.DONE;
|
|
720
|
+
this[state$3].result = null;
|
|
721
|
+
this[state$3].emitProcessEvent("abort");
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
readAsArrayBuffer = (blob) => {
|
|
725
|
+
this[state$3].read("readAsArrayBuffer", blob, () => {
|
|
726
|
+
this[state$3].result = blob[state$9]._u8array.buffer.slice(0);
|
|
727
|
+
});
|
|
728
|
+
};
|
|
729
|
+
readAsBinaryString = (blob) => {
|
|
730
|
+
this[state$3].read("readAsBinaryString", blob, () => {
|
|
731
|
+
this[state$3].result = blob[state$9]._u8array.reduce((acc, cur) => {
|
|
732
|
+
acc += String.fromCharCode(cur);
|
|
733
|
+
return acc;
|
|
734
|
+
}, "");
|
|
735
|
+
});
|
|
736
|
+
};
|
|
737
|
+
readAsDataURL = (blob) => {
|
|
738
|
+
this[state$3].read("readAsDataURL", blob, () => {
|
|
739
|
+
this[state$3].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$9]._u8array);
|
|
740
|
+
});
|
|
741
|
+
};
|
|
742
|
+
readAsText = (blob, encoding) => {
|
|
743
|
+
this[state$3].read("readAsText", blob, () => {
|
|
744
|
+
this[state$3].result = (new TextDecoderP(encoding)).decode(blob[state$9]._u8array);
|
|
745
|
+
});
|
|
746
|
+
};
|
|
747
|
+
get onabort() { return this[state$3].onabort; }
|
|
748
|
+
set onabort(value) { this[state$3].onabort = value; this[state$3].attach("abort"); }
|
|
749
|
+
get onerror() { return this[state$3].onerror; }
|
|
750
|
+
set onerror(value) { this[state$3].onerror = value; this[state$3].attach("error"); }
|
|
751
|
+
get onload() { return this[state$3].onload; }
|
|
752
|
+
set onload(value) { this[state$3].onload = value; this[state$3].attach("load"); }
|
|
753
|
+
get onloadend() { return this[state$3].onloadend; }
|
|
754
|
+
set onloadend(value) { this[state$3].onloadend = value; this[state$3].attach("loadend"); }
|
|
755
|
+
get onloadstart() { return this[state$3].onloadstart; }
|
|
756
|
+
set onloadstart(value) { this[state$3].onloadstart = value; this[state$3].attach("loadstart"); }
|
|
757
|
+
get onprogress() { return this[state$3].onprogress; }
|
|
758
|
+
set onprogress(value) { this[state$3].onprogress = value; this[state$3].attach("progress"); }
|
|
759
|
+
toString() { return "[object FileReader]"; }
|
|
760
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
|
|
761
|
+
}
|
|
762
|
+
defineStringTag(FileReaderP, "FileReader");
|
|
763
|
+
class FileReaderState {
|
|
764
|
+
constructor(target) {
|
|
765
|
+
this.target = target;
|
|
766
|
+
}
|
|
767
|
+
target;
|
|
768
|
+
readyState = FileReaderP.EMPTY;
|
|
769
|
+
result = null;
|
|
770
|
+
error = null;
|
|
771
|
+
read(kind, blob, setResult) {
|
|
772
|
+
if (!isPolyfillType("Blob", blob)) {
|
|
773
|
+
throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
|
|
774
|
+
}
|
|
775
|
+
this.error = null;
|
|
776
|
+
this.readyState = FileReaderP.LOADING;
|
|
777
|
+
this.emitProcessEvent("loadstart", 0, blob.size);
|
|
778
|
+
setTimeout(() => {
|
|
779
|
+
if (this.readyState === FileReaderP.LOADING) {
|
|
780
|
+
this.readyState = FileReaderP.DONE;
|
|
781
|
+
try {
|
|
782
|
+
setResult();
|
|
783
|
+
this.emitProcessEvent("load", blob.size, blob.size);
|
|
784
|
+
}
|
|
785
|
+
catch (e) {
|
|
786
|
+
this.result = null;
|
|
787
|
+
this.error = e;
|
|
788
|
+
this.emitProcessEvent("error", 0, blob.size);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
this.emitProcessEvent("loadend", !!this.result ? blob.size : 0, blob.size);
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
emitProcessEvent(type, loaded = 0, total = 0) {
|
|
795
|
+
const event = new ProgressEventP(type, {
|
|
796
|
+
lengthComputable: total > 0,
|
|
797
|
+
loaded,
|
|
798
|
+
total,
|
|
799
|
+
});
|
|
800
|
+
event[state$9].target = this.target;
|
|
801
|
+
event[state$9].isTrusted = true;
|
|
802
|
+
this.target[state$7].fire(event);
|
|
803
|
+
}
|
|
804
|
+
attach(type) {
|
|
805
|
+
const cb = this[("on" + type)];
|
|
806
|
+
const listener = this[("_on" + type)];
|
|
807
|
+
attachFn.call(this.target, type, cb, listener);
|
|
808
|
+
}
|
|
809
|
+
onabort = null;
|
|
810
|
+
_onabort = (ev) => { executeFn.call(this.target, this.onabort, ev); };
|
|
811
|
+
onerror = null;
|
|
812
|
+
_onerror = (ev) => { executeFn.call(this.target, this.onerror, ev); };
|
|
813
|
+
onload = null;
|
|
814
|
+
_onload = (ev) => { executeFn.call(this.target, this.onload, ev); };
|
|
815
|
+
onloadend = null;
|
|
816
|
+
_onloadend = (ev) => { executeFn.call(this.target, this.onloadend, ev); };
|
|
817
|
+
onloadstart = null;
|
|
818
|
+
_onloadstart = (ev) => { executeFn.call(this.target, this.onloadstart, ev); };
|
|
819
|
+
onprogress = null;
|
|
820
|
+
_onprogress = (ev) => { executeFn.call(this.target, this.onprogress, ev); };
|
|
821
|
+
}
|
|
822
|
+
const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
|
|
823
|
+
|
|
824
|
+
class FormDataP {
|
|
825
|
+
constructor(form, submitter) {
|
|
826
|
+
if (form !== void 0) {
|
|
827
|
+
throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.");
|
|
828
|
+
}
|
|
829
|
+
if (!!submitter) {
|
|
830
|
+
throw new TypeError("Failed to construct 'FormData': parameter 2 is not of type 'HTMLElement'.");
|
|
831
|
+
}
|
|
832
|
+
this[state$9] = new FormDataState();
|
|
833
|
+
}
|
|
834
|
+
[state$9];
|
|
835
|
+
append(name, value, filename) {
|
|
836
|
+
this[state$9]._data.push(normalizeArgs(name, value, filename));
|
|
837
|
+
}
|
|
838
|
+
delete(name) {
|
|
839
|
+
const result = [];
|
|
840
|
+
name = String(name);
|
|
841
|
+
each(this[state$9]._data, entry => {
|
|
842
|
+
entry[0] !== name && result.push(entry);
|
|
843
|
+
});
|
|
844
|
+
this[state$9]._data = result;
|
|
845
|
+
}
|
|
846
|
+
get(name) {
|
|
847
|
+
const entries = this[state$9]._data;
|
|
848
|
+
name = String(name);
|
|
849
|
+
for (let i = 0; i < entries.length; ++i) {
|
|
850
|
+
if (entries[i][0] === name) {
|
|
851
|
+
return entries[i][1];
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return null;
|
|
855
|
+
}
|
|
856
|
+
getAll(name) {
|
|
857
|
+
const result = [];
|
|
858
|
+
name = String(name);
|
|
859
|
+
each(this[state$9]._data, data => {
|
|
860
|
+
data[0] === name && result.push(data[1]);
|
|
861
|
+
});
|
|
862
|
+
return result;
|
|
863
|
+
}
|
|
864
|
+
has(name) {
|
|
865
|
+
name = String(name);
|
|
866
|
+
for (let i = 0; i < this[state$9]._data.length; ++i) {
|
|
867
|
+
if (this[state$9]._data[i][0] === name) {
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
set(name, value, filename) {
|
|
874
|
+
name = String(name);
|
|
875
|
+
const result = [];
|
|
876
|
+
const args = normalizeArgs(name, value, filename);
|
|
877
|
+
let replace = true;
|
|
878
|
+
each(this[state$9]._data, data => {
|
|
879
|
+
data[0] === name
|
|
880
|
+
? replace && (replace = !result.push(args))
|
|
881
|
+
: result.push(data);
|
|
882
|
+
});
|
|
883
|
+
replace && result.push(args);
|
|
884
|
+
this[state$9]._data = result;
|
|
885
|
+
}
|
|
886
|
+
forEach(callbackfn, thisArg) {
|
|
887
|
+
for (const [name, value] of this) {
|
|
888
|
+
callbackfn.call(thisArg, value, name, thisArg);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
entries() {
|
|
892
|
+
return this[state$9]._data.values();
|
|
893
|
+
}
|
|
894
|
+
keys() {
|
|
895
|
+
return this[state$9]._data.map(x => x[0]).values();
|
|
896
|
+
}
|
|
897
|
+
values() {
|
|
898
|
+
return this[state$9]._data.map(x => x[1]).values();
|
|
899
|
+
}
|
|
900
|
+
[Symbol.iterator]() {
|
|
901
|
+
return this.entries();
|
|
902
|
+
}
|
|
903
|
+
toString() { return "[object FormData]"; }
|
|
904
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
|
|
905
|
+
}
|
|
906
|
+
defineStringTag(FormDataP, "FormData");
|
|
907
|
+
class FormDataState {
|
|
908
|
+
_data = [];
|
|
909
|
+
toBlob() {
|
|
910
|
+
const boundary = "----formdata-polyfill-" + Math.random();
|
|
911
|
+
const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
|
|
912
|
+
let chunks = [];
|
|
913
|
+
for (const [name, value] of this._data.values()) {
|
|
914
|
+
if (typeof value === "string") {
|
|
915
|
+
chunks.push(p + escape(normalizeLinefeeds(name)) + `"\r\n\r\n${normalizeLinefeeds(value)}\r\n`);
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
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`);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
chunks.push(`--${boundary}--`);
|
|
922
|
+
return new BlobP(chunks, {
|
|
923
|
+
type: "multipart/form-data; boundary=" + boundary,
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
function normalizeArgs(name, value, filename) {
|
|
928
|
+
if (isPolyfillType("Blob", value)) {
|
|
929
|
+
filename = filename !== undefined
|
|
930
|
+
? String(filename + "")
|
|
931
|
+
: typeof value.name === "string"
|
|
932
|
+
? value.name
|
|
933
|
+
: "blob";
|
|
934
|
+
if (value.name !== filename || Object.prototype.toString.call(value) === "[object Blob]") {
|
|
935
|
+
value = new FileP([value], filename);
|
|
936
|
+
}
|
|
937
|
+
return [String(name), value];
|
|
938
|
+
}
|
|
939
|
+
return [String(name), String(value)];
|
|
940
|
+
}
|
|
941
|
+
function normalizeLinefeeds(value) {
|
|
942
|
+
return value.replace(/\r?\n|\r/g, "\r\n");
|
|
943
|
+
}
|
|
944
|
+
function each(arr, cb) {
|
|
945
|
+
for (let i = 0; i < arr.length; ++i) {
|
|
946
|
+
cb(arr[i]);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
function escape(str) {
|
|
950
|
+
return str.replace(/\n/g, '%0A').replace(/\r/g, '%0D').replace(/"/g, '%22');
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Parses multipart/form-data binary data, supporting restoration of text fields and files
|
|
954
|
+
* @param body - Text in multipart/form-data format (including boundaries and data)
|
|
955
|
+
* @returns Parsed FormData object (text fields as strings, files as File objects)
|
|
956
|
+
*/
|
|
957
|
+
function createFormData(body) {
|
|
958
|
+
const formData = new FormDataP();
|
|
959
|
+
if (typeof body !== "string" || body.trim() === "") {
|
|
960
|
+
return formData;
|
|
961
|
+
}
|
|
962
|
+
// 1. Extract boundary string (from the first line, removing leading "--")
|
|
963
|
+
const firstLineEnd = body.indexOf("\r\n");
|
|
964
|
+
if (firstLineEnd === -1) {
|
|
965
|
+
// Invalid multipart format: Missing line break in header
|
|
966
|
+
throw new TypeError("Failed to fetch");
|
|
967
|
+
}
|
|
968
|
+
const boundary = body.substring(2, firstLineEnd).trim();
|
|
969
|
+
if (!boundary) {
|
|
970
|
+
// Invalid multipart format: Empty boundary
|
|
971
|
+
throw new TypeError("Invalid MIME type");
|
|
972
|
+
}
|
|
973
|
+
// 2. Split data into individual parts (excluding empty content and trailing "--")
|
|
974
|
+
const parts = body.split(`--${boundary}`).filter(part => {
|
|
975
|
+
const trimmed = part.trim();
|
|
976
|
+
return trimmed !== "" && trimmed !== "--";
|
|
977
|
+
});
|
|
978
|
+
if (parts.length === 0) {
|
|
979
|
+
// Invalid multipart format: No parts found
|
|
980
|
+
throw new TypeError("Failed to fetch");
|
|
981
|
+
}
|
|
982
|
+
// 3. Parse each part
|
|
983
|
+
parts.forEach(part => {
|
|
984
|
+
// Split header and content (separator between header and content is "\r\n\r\n")
|
|
985
|
+
const separatorIndex = part.indexOf("\r\n\r\n");
|
|
986
|
+
if (separatorIndex === -1) {
|
|
987
|
+
// Invalid part format: Missing header-content separator
|
|
988
|
+
throw new TypeError("Failed to fetch");
|
|
989
|
+
}
|
|
990
|
+
// Extract header (Content-Disposition and Content-Type)
|
|
991
|
+
const headerRaw = part.substring(0, separatorIndex).trim();
|
|
992
|
+
const contentRaw = part.substring(separatorIndex + 4); // Skip "\r\n\r\n"
|
|
993
|
+
// Parse header information
|
|
994
|
+
const nameMatch = headerRaw.match(/name="([^"]+)"/); // Field name
|
|
995
|
+
const filenameMatch = headerRaw.match(/filename="([^"]*)"/); // Filename (optional, only for file fields)
|
|
996
|
+
const contentTypeMatch = headerRaw.match(/Content-Type: ([^\r\n]+)/); // MIME type (optional)
|
|
997
|
+
if (!nameMatch || !nameMatch[1]) {
|
|
998
|
+
// Invalid part format: Missing field name
|
|
999
|
+
throw new TypeError("Failed to fetch");
|
|
1000
|
+
}
|
|
1001
|
+
const fieldName = nameMatch[1];
|
|
1002
|
+
const isFile = !!filenameMatch; // Whether it's a file field
|
|
1003
|
+
const mimeType = contentTypeMatch ? (contentTypeMatch[1] || "").trim() : "application/octet-stream";
|
|
1004
|
+
// 4. Process content (text or binary)
|
|
1005
|
+
if (isFile) {
|
|
1006
|
+
// File field: Use TextEncoder to handle raw binary data
|
|
1007
|
+
try {
|
|
1008
|
+
// Remove line breaks from content (simulating browser behavior)
|
|
1009
|
+
const content = contentRaw.replace(/\r\n/g, "");
|
|
1010
|
+
// Convert string to Uint8Array using TextEncoder
|
|
1011
|
+
const encoder = new TextEncoderP();
|
|
1012
|
+
const uint8Array = encoder.encode(content);
|
|
1013
|
+
// Create File object (default filename is unknown-file)
|
|
1014
|
+
const filename = filenameMatch[1] || "unknown-file";
|
|
1015
|
+
const file = new FileP([uint8Array], filename, { type: mimeType });
|
|
1016
|
+
formData.append(fieldName, file, filename);
|
|
1017
|
+
}
|
|
1018
|
+
catch (e) {
|
|
1019
|
+
// `Failed to process file field "${fieldName}": ${(e as Error).message}`
|
|
1020
|
+
throw new TypeError("Failed to fetch");
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
else {
|
|
1024
|
+
// Text field: Directly take content (remove leading/trailing line breaks to match browser behavior)
|
|
1025
|
+
const value = contentRaw.replace(/^[\r\n]+|[\r\n]+$/g, "");
|
|
1026
|
+
formData.append(fieldName, value);
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
return formData;
|
|
1030
|
+
}
|
|
1031
|
+
const FormDataE = g["FormData"] || FormDataP;
|
|
1032
|
+
|
|
1033
|
+
class URLSearchParamsP {
|
|
1034
|
+
constructor(init) {
|
|
1035
|
+
let search = init || "";
|
|
1036
|
+
if (isObjectType("URLSearchParams", search)) {
|
|
1037
|
+
search = search.toString();
|
|
1038
|
+
}
|
|
1039
|
+
this[state$9] = new URLSearchParamsState();
|
|
1040
|
+
this[state$9]._dict = parseToDict(search);
|
|
1041
|
+
}
|
|
1042
|
+
[state$9];
|
|
1043
|
+
get size() {
|
|
1044
|
+
return Object.values(this[state$9]._dict).reduce((acc, cur) => acc + cur.length, 0);
|
|
1045
|
+
}
|
|
1046
|
+
append(name, value) {
|
|
1047
|
+
appendTo(this[state$9]._dict, name, value);
|
|
1048
|
+
}
|
|
1049
|
+
delete(name, value) {
|
|
1050
|
+
let dict = {};
|
|
1051
|
+
for (let [key, values] of Object.entries(this[state$9]._dict)) {
|
|
1052
|
+
if (key === name) {
|
|
1053
|
+
if (value !== undefined) {
|
|
1054
|
+
let vals = values.filter(x => x !== ("" + value));
|
|
1055
|
+
if (vals.length > 0)
|
|
1056
|
+
Object.assign(dict, { [key]: vals });
|
|
1057
|
+
}
|
|
1058
|
+
continue;
|
|
1059
|
+
}
|
|
1060
|
+
Object.assign(dict, { [key]: values });
|
|
1061
|
+
}
|
|
1062
|
+
this[state$9]._dict = dict;
|
|
1063
|
+
}
|
|
1064
|
+
get(name) {
|
|
1065
|
+
return this.has(name) ? this[state$9]._dict[name][0] ?? null : null;
|
|
1066
|
+
}
|
|
1067
|
+
getAll(name) {
|
|
1068
|
+
return this.has(name) ? this[state$9]._dict[name].slice(0) : [];
|
|
1069
|
+
}
|
|
1070
|
+
has(name, value) {
|
|
1071
|
+
if (hasOwnProperty(this[state$9]._dict, name)) {
|
|
1072
|
+
if (value !== undefined) {
|
|
1073
|
+
return this[state$9]._dict[name].includes(("" + value));
|
|
1074
|
+
}
|
|
1075
|
+
return true;
|
|
1076
|
+
}
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1079
|
+
set(name, value) {
|
|
1080
|
+
this[state$9]._dict[name] = ["" + value];
|
|
1081
|
+
}
|
|
1082
|
+
sort() {
|
|
1083
|
+
let keys = Object.keys(this[state$9]._dict);
|
|
1084
|
+
keys.sort();
|
|
1085
|
+
let dict = {};
|
|
1086
|
+
for (let key of keys) {
|
|
1087
|
+
Object.assign(dict, { [key]: this[state$9]._dict[key] });
|
|
1088
|
+
}
|
|
1089
|
+
this[state$9]._dict = dict;
|
|
1090
|
+
}
|
|
1091
|
+
forEach(callbackfn, thisArg) {
|
|
1092
|
+
Object.entries(this[state$9]._dict).forEach(([key, values]) => {
|
|
1093
|
+
values.forEach(value => {
|
|
1094
|
+
callbackfn.call(thisArg, value, key, this);
|
|
1095
|
+
});
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
entries() {
|
|
1099
|
+
return Object.entries(this[state$9]._dict)
|
|
1100
|
+
.map(([key, values]) => {
|
|
1101
|
+
return values.map(value => {
|
|
1102
|
+
return [key, value];
|
|
1103
|
+
});
|
|
1104
|
+
})
|
|
1105
|
+
.flat()
|
|
1106
|
+
.values();
|
|
1107
|
+
}
|
|
1108
|
+
keys() {
|
|
1109
|
+
return Object.keys(this[state$9]._dict).values();
|
|
1110
|
+
}
|
|
1111
|
+
values() {
|
|
1112
|
+
return Object.values(this[state$9]._dict).flat().values();
|
|
1113
|
+
}
|
|
1114
|
+
[Symbol.iterator]() {
|
|
1115
|
+
return this.entries();
|
|
1116
|
+
}
|
|
1117
|
+
toString() {
|
|
1118
|
+
let query = [];
|
|
1119
|
+
for (let [key, values] of Object.entries(this[state$9]._dict)) {
|
|
1120
|
+
let name = encode$1(key);
|
|
1121
|
+
for (let val of values) {
|
|
1122
|
+
query.push(name + "=" + encode$1(val));
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return query.join("&");
|
|
1126
|
+
}
|
|
1127
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
|
|
1128
|
+
}
|
|
1129
|
+
defineStringTag(URLSearchParamsP, "URLSearchParams");
|
|
1130
|
+
class URLSearchParamsState {
|
|
1131
|
+
_dict = {};
|
|
1132
|
+
}
|
|
1133
|
+
function parseToDict(search) {
|
|
1134
|
+
let dict = {};
|
|
1135
|
+
if (typeof search === "object") {
|
|
1136
|
+
// if `search` is an array, treat it as a sequence
|
|
1137
|
+
if (Array.isArray(search)) {
|
|
1138
|
+
for (let i = 0; i < search.length; ++i) {
|
|
1139
|
+
let item = search[i];
|
|
1140
|
+
if (Array.isArray(item) && item.length === 2) {
|
|
1141
|
+
appendTo(dict, item[0], item[1]);
|
|
1142
|
+
}
|
|
1143
|
+
else {
|
|
1144
|
+
throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
for (const key in search) {
|
|
1150
|
+
if (search.hasOwnProperty(key)) {
|
|
1151
|
+
appendTo(dict, key, search[key]);
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
else {
|
|
1157
|
+
// remove first '?'
|
|
1158
|
+
if (search.indexOf("?") === 0) {
|
|
1159
|
+
search = search.slice(1);
|
|
1160
|
+
}
|
|
1161
|
+
let pairs = search.split("&");
|
|
1162
|
+
for (let j = 0; j < pairs.length; ++j) {
|
|
1163
|
+
let value = pairs[j], index = value.indexOf("=");
|
|
1164
|
+
if (-1 < index) {
|
|
1165
|
+
appendTo(dict, decode$1(value.slice(0, index)), decode$1(value.slice(index + 1)));
|
|
1166
|
+
}
|
|
1167
|
+
else {
|
|
1168
|
+
if (value) {
|
|
1169
|
+
appendTo(dict, decode$1(value), "");
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
return dict;
|
|
1175
|
+
}
|
|
1176
|
+
function appendTo(dict, name, value) {
|
|
1177
|
+
let val = typeof value === "string" ? value : (value !== null && value !== undefined && typeof value.toString === "function" ? value.toString() : JSON.stringify(value));
|
|
1178
|
+
// Prevent using `hasOwnProperty` as a property name
|
|
1179
|
+
if (hasOwnProperty(dict, name)) {
|
|
1180
|
+
dict[name].push(val);
|
|
1181
|
+
}
|
|
1182
|
+
else {
|
|
1183
|
+
dict[name] = [val];
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
function encode$1(str) {
|
|
1187
|
+
const replace = {
|
|
1188
|
+
"!": "%21",
|
|
1189
|
+
"'": "%27",
|
|
1190
|
+
"(": "%28",
|
|
1191
|
+
")": "%29",
|
|
1192
|
+
"~": "%7E",
|
|
1193
|
+
"%20": "+",
|
|
1194
|
+
"%00": "\x00",
|
|
1195
|
+
};
|
|
1196
|
+
return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, match => replace[match]);
|
|
1197
|
+
}
|
|
1198
|
+
function decode$1(str) {
|
|
1199
|
+
return str
|
|
1200
|
+
.replace(/[ +]/g, "%20")
|
|
1201
|
+
.replace(/(%[a-f0-9]{2})+/ig, match => decodeURIComponent(match));
|
|
1202
|
+
}
|
|
1203
|
+
function hasOwnProperty(obj, prop) {
|
|
1204
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1205
|
+
}
|
|
1206
|
+
const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
|
|
1207
|
+
|
|
1208
|
+
class AbortSignalP extends EventTargetP {
|
|
1209
|
+
static abort(reason) {
|
|
1210
|
+
const signal = createAbortSignalP();
|
|
1211
|
+
signal[state$9].abort(reason, false);
|
|
1212
|
+
return signal;
|
|
1213
|
+
}
|
|
1214
|
+
static any(signals) {
|
|
1215
|
+
const signal = createAbortSignalP();
|
|
1216
|
+
const abortedSignal = signals.find(x => x.aborted);
|
|
1217
|
+
if (abortedSignal) {
|
|
1218
|
+
signal[state$9].abort(abortedSignal.reason, false);
|
|
1219
|
+
}
|
|
1220
|
+
else {
|
|
1221
|
+
function abortFn(ev) {
|
|
1222
|
+
for (const sig of signals) {
|
|
1223
|
+
sig.removeEventListener("abort", abortFn);
|
|
1224
|
+
}
|
|
1225
|
+
signal[state$9].abort(this.reason, true, ev.isTrusted);
|
|
1226
|
+
}
|
|
1227
|
+
for (const sig of signals) {
|
|
1228
|
+
sig.addEventListener("abort", abortFn);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
return signal;
|
|
1232
|
+
}
|
|
1233
|
+
static timeout(milliseconds) {
|
|
1234
|
+
const signal = createAbortSignalP();
|
|
1235
|
+
setTimeout(() => {
|
|
1236
|
+
signal[state$9].abort(new MPException("signal timed out", "TimeoutError"));
|
|
1237
|
+
}, milliseconds);
|
|
1238
|
+
return signal;
|
|
1239
|
+
}
|
|
1240
|
+
constructor() {
|
|
1241
|
+
if (new.target === AbortSignalP) {
|
|
1242
|
+
throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
|
|
1243
|
+
}
|
|
1244
|
+
super();
|
|
1245
|
+
this[state$9] = new AbortSignalState(this);
|
|
1246
|
+
}
|
|
1247
|
+
[state$9];
|
|
1248
|
+
get aborted() { return this[state$9].aborted; }
|
|
1249
|
+
get reason() { return this[state$9].reason; }
|
|
1250
|
+
throwIfAborted() {
|
|
1251
|
+
if (this.aborted) {
|
|
1252
|
+
throw this.reason;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
get onabort() { return this[state$9].onabort; }
|
|
1256
|
+
set onabort(value) {
|
|
1257
|
+
this[state$9].onabort = value;
|
|
1258
|
+
attachFn.call(this, "abort", value, this[state$9]._onabort);
|
|
1259
|
+
}
|
|
1260
|
+
toString() { return "[object AbortSignal]"; }
|
|
1261
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
|
|
1262
|
+
}
|
|
1263
|
+
defineStringTag(AbortSignalP, "AbortSignal");
|
|
1264
|
+
class AbortSignalState {
|
|
1265
|
+
constructor(target) {
|
|
1266
|
+
this.target = target;
|
|
1267
|
+
}
|
|
1268
|
+
target;
|
|
1269
|
+
aborted = false;
|
|
1270
|
+
reason = undefined;
|
|
1271
|
+
abort(reason, notify = true, isTrusted = true) {
|
|
1272
|
+
if (!this.aborted) {
|
|
1273
|
+
this.aborted = true;
|
|
1274
|
+
this.reason = reason ?? (new MPException("signal is aborted without reason", "AbortError"));
|
|
1275
|
+
if (notify) {
|
|
1276
|
+
const evt = new EventP("abort");
|
|
1277
|
+
evt[state$9].target = this.target;
|
|
1278
|
+
evt[state$9].isTrusted = isTrusted;
|
|
1279
|
+
this.target[state$7].fire(evt);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
onabort = null;
|
|
1284
|
+
_onabort = (ev) => { executeFn.call(this.target, this.onabort, ev); };
|
|
1285
|
+
}
|
|
1286
|
+
function createAbortSignalP() {
|
|
1287
|
+
const instance = Object.create(AbortSignalP.prototype);
|
|
1288
|
+
instance[state$7] = new EventTargetState(instance);
|
|
1289
|
+
instance[state$9] = new AbortSignalState(instance);
|
|
1290
|
+
return instance;
|
|
1291
|
+
}
|
|
1292
|
+
const AbortSignalE = g["AbortSignal"] || AbortSignalP;
|
|
1293
|
+
|
|
1294
|
+
const state$2 = Symbol("AbortControllerState");
|
|
1295
|
+
class AbortControllerP {
|
|
1296
|
+
constructor() {
|
|
1297
|
+
this[state$2] = new AbortControllerState();
|
|
1298
|
+
}
|
|
1299
|
+
[state$2];
|
|
1300
|
+
get signal() { return this[state$2].signal; }
|
|
1301
|
+
abort(reason) {
|
|
1302
|
+
this[state$2].signal[state$9].abort(reason);
|
|
1303
|
+
}
|
|
1304
|
+
toString() { return "[object AbortController]"; }
|
|
1305
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
|
|
1306
|
+
}
|
|
1307
|
+
defineStringTag(AbortControllerP, "AbortController");
|
|
1308
|
+
class AbortControllerState {
|
|
1309
|
+
signal = createAbortSignalP();
|
|
1310
|
+
}
|
|
1311
|
+
const AbortControllerE = g["AbortController"] || AbortControllerP;
|
|
1312
|
+
|
|
1313
|
+
// @ts-nocheck
|
|
1314
|
+
const mp = (() => {
|
|
1315
|
+
let u = "undefined", r = "request", f = "function";
|
|
1316
|
+
let mp;
|
|
1317
|
+
mp =
|
|
1318
|
+
(typeof wx !== u && typeof wx?.[r] === f && wx) || // 微信
|
|
1319
|
+
(typeof my !== u && typeof my?.[r] === f && my) || // 支付宝
|
|
1320
|
+
(typeof qq !== u && typeof qq?.[r] === f && qq) || // QQ
|
|
1321
|
+
(typeof jd !== u && typeof jd?.[r] === f && jd) || // 京东
|
|
1322
|
+
(typeof swan !== u && typeof swan?.[r] === f && swan) || // 百度
|
|
1323
|
+
(typeof tt !== u && typeof tt?.[r] === f && tt) || // 抖音 | 飞书
|
|
1324
|
+
(typeof ks !== u && typeof ks?.[r] === f && ks) || // 快手
|
|
1325
|
+
(typeof qh !== u && typeof qh?.[r] === f && qh) || // 360
|
|
1326
|
+
undefined;
|
|
1327
|
+
if (typeof g["XMLHttpRequest"] === f && typeof g["fetch"] === f) {
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
if (mp === undefined)
|
|
1331
|
+
mp =
|
|
1332
|
+
(typeof uni !== u && typeof uni?.[r] === f && uni) || // UniApp
|
|
1333
|
+
(typeof Taro !== u && typeof Taro?.[r] === f && Taro) || // Taro
|
|
1334
|
+
undefined;
|
|
1335
|
+
return mp;
|
|
1336
|
+
})();
|
|
1337
|
+
|
|
1338
|
+
class XMLHttpRequestEventTargetP extends EventTargetP {
|
|
1339
|
+
constructor() {
|
|
1340
|
+
if (new.target === XMLHttpRequestEventTargetP) {
|
|
1341
|
+
throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
|
|
1342
|
+
}
|
|
1343
|
+
super();
|
|
1344
|
+
this[state$9] = new XMLHttpRequestEventTargetState(this);
|
|
1345
|
+
}
|
|
1346
|
+
[state$9];
|
|
1347
|
+
get onabort() { return this[state$9].onabort; }
|
|
1348
|
+
set onabort(value) { this[state$9].onabort = value; this[state$9].attach("abort"); }
|
|
1349
|
+
get onerror() { return this[state$9].onerror; }
|
|
1350
|
+
set onerror(value) { this[state$9].onerror = value; this[state$9].attach("error"); }
|
|
1351
|
+
get onload() { return this[state$9].onload; }
|
|
1352
|
+
set onload(value) { this[state$9].onload = value; this[state$9].attach("load"); }
|
|
1353
|
+
get onloadend() { return this[state$9].onloadend; }
|
|
1354
|
+
set onloadend(value) { this[state$9].onloadend = value; this[state$9].attach("loadend"); }
|
|
1355
|
+
get onloadstart() { return this[state$9].onloadstart; }
|
|
1356
|
+
set onloadstart(value) { this[state$9].onloadstart = value; this[state$9].attach("loadstart"); }
|
|
1357
|
+
get onprogress() { return this[state$9].onprogress; }
|
|
1358
|
+
set onprogress(value) { this[state$9].onprogress = value; this[state$9].attach("progress"); }
|
|
1359
|
+
get ontimeout() { return this[state$9].ontimeout; }
|
|
1360
|
+
set ontimeout(value) { this[state$9].ontimeout = value; this[state$9].attach("timeout"); }
|
|
1361
|
+
toString() { return "[object XMLHttpRequestEventTarget]"; }
|
|
1362
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1363
|
+
}
|
|
1364
|
+
defineStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
|
|
1365
|
+
class XMLHttpRequestEventTargetState {
|
|
1366
|
+
/**
|
|
1367
|
+
* @param _target XMLHttpRequestEventTargetP
|
|
1368
|
+
*/
|
|
1369
|
+
constructor(_target) {
|
|
1370
|
+
this.target = _target;
|
|
1371
|
+
}
|
|
1372
|
+
target;
|
|
1373
|
+
attach(type) {
|
|
1374
|
+
const cb = this[("on" + type)];
|
|
1375
|
+
const listener = this[("_on" + type)];
|
|
1376
|
+
attachFn.call(this.target, type, cb, listener);
|
|
1377
|
+
}
|
|
1378
|
+
onabort = null;
|
|
1379
|
+
_onabort = (ev) => { executeFn.call(this.target, this.onabort, ev); };
|
|
1380
|
+
onerror = null;
|
|
1381
|
+
_onerror = (ev) => { executeFn.call(this.target, this.onerror, ev); };
|
|
1382
|
+
onload = null;
|
|
1383
|
+
_onload = (ev) => { executeFn.call(this.target, this.onload, ev); };
|
|
1384
|
+
onloadend = null;
|
|
1385
|
+
_onloadend = (ev) => { executeFn.call(this.target, this.onloadend, ev); };
|
|
1386
|
+
onloadstart = null;
|
|
1387
|
+
_onloadstart = (ev) => { executeFn.call(this.target, this.onloadstart, ev); };
|
|
1388
|
+
onprogress = null;
|
|
1389
|
+
_onprogress = (ev) => { executeFn.call(this.target, this.onprogress, ev); };
|
|
1390
|
+
ontimeout = null;
|
|
1391
|
+
_ontimeout = (ev) => { executeFn.call(this.target, this.ontimeout, ev); };
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
|
|
1395
|
+
constructor() {
|
|
1396
|
+
if (new.target === XMLHttpRequestUploadP) {
|
|
1397
|
+
throw new TypeError("Failed to construct 'XMLHttpRequestUpload': Illegal constructor");
|
|
1398
|
+
}
|
|
1399
|
+
super();
|
|
1400
|
+
}
|
|
1401
|
+
toString() { return "[object XMLHttpRequestUpload]"; }
|
|
1402
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1403
|
+
}
|
|
1404
|
+
defineStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
|
|
1405
|
+
function createXMLHttpRequestUploadP() {
|
|
1406
|
+
const instance = Object.create(XMLHttpRequestUploadP.prototype);
|
|
1407
|
+
instance[state$7] = new EventTargetState(instance);
|
|
1408
|
+
instance[state$9] = new XMLHttpRequestEventTargetState(instance);
|
|
1409
|
+
return instance;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
const request = mp ? mp.request : function errorRequest(options) {
|
|
1413
|
+
const errMsg = "NOT_SUPPORTED_ERR";
|
|
1414
|
+
const errno = 9;
|
|
1415
|
+
const err = {
|
|
1416
|
+
errMsg,
|
|
1417
|
+
errno,
|
|
1418
|
+
exception: {
|
|
1419
|
+
retryCount: 0,
|
|
1420
|
+
reasons: [{ errMsg, errno }],
|
|
1421
|
+
},
|
|
1422
|
+
useHttpDNS: false,
|
|
1423
|
+
};
|
|
1424
|
+
Promise.resolve(err)
|
|
1425
|
+
.then(err => { if (options.fail) {
|
|
1426
|
+
options.fail(err);
|
|
1427
|
+
} })
|
|
1428
|
+
.finally(() => { if (options.complete) {
|
|
1429
|
+
options.complete(err);
|
|
1430
|
+
} });
|
|
1431
|
+
throw new ReferenceError("request is not defined");
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
const state$1 = Symbol("XMLHttpRequestState");
|
|
1435
|
+
class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
1436
|
+
static UNSENT = 0;
|
|
1437
|
+
static OPENED = 1;
|
|
1438
|
+
static HEADERS_RECEIVED = 2;
|
|
1439
|
+
static LOADING = 3;
|
|
1440
|
+
static DONE = 4;
|
|
1441
|
+
constructor() {
|
|
1442
|
+
super();
|
|
1443
|
+
this[state$1] = new XMLHttpRequestState(this);
|
|
1444
|
+
}
|
|
1445
|
+
[state$1];
|
|
1446
|
+
UNSENT = 0;
|
|
1447
|
+
OPENED = 1;
|
|
1448
|
+
HEADERS_RECEIVED = 2;
|
|
1449
|
+
LOADING = 3;
|
|
1450
|
+
DONE = 4;
|
|
1451
|
+
get readyState() { return this[state$1].readyState; }
|
|
1452
|
+
get response() { return this[state$1].response; }
|
|
1453
|
+
get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
|
|
1454
|
+
get responseType() { return this[state$1].responseType; }
|
|
1455
|
+
set responseType(value) { this[state$1].responseType = value; }
|
|
1456
|
+
get responseURL() { return this[state$1].responseURL; }
|
|
1457
|
+
get responseXML() { return null; }
|
|
1458
|
+
get status() { return this[state$1].status; }
|
|
1459
|
+
get statusText() {
|
|
1460
|
+
if (this.readyState === XMLHttpRequestP.UNSENT || this.readyState === XMLHttpRequestP.OPENED)
|
|
1461
|
+
return "";
|
|
1462
|
+
return this[state$1].statusText || statusTextMap(this.status);
|
|
1463
|
+
}
|
|
1464
|
+
get timeout() { return this[state$1].timeout; }
|
|
1465
|
+
set timeout(value) { this[state$1].timeout = value; }
|
|
1466
|
+
get upload() { return this[state$1].upload; }
|
|
1467
|
+
get withCredentials() { return this[state$1].withCredentials; }
|
|
1468
|
+
set withCredentials(value) { this[state$1].withCredentials = value; }
|
|
1469
|
+
abort() {
|
|
1470
|
+
this[state$1].clearRequest();
|
|
1471
|
+
}
|
|
1472
|
+
getAllResponseHeaders() {
|
|
1473
|
+
if (!this[state$1]._resHeaders)
|
|
1474
|
+
return "";
|
|
1475
|
+
return Object.entries(this[state$1]._resHeaders || {}).map(([k, v]) => `${k}: ${v}\r\n`).join("");
|
|
1476
|
+
}
|
|
1477
|
+
getResponseHeader(name) {
|
|
1478
|
+
if (!this[state$1]._resHeaders)
|
|
1479
|
+
return null;
|
|
1480
|
+
return Object.entries(this[state$1]._resHeaders || {}).find(x => x[0].toLowerCase() === name.toLowerCase())?.[1] ?? null;
|
|
1481
|
+
}
|
|
1482
|
+
open(...args) {
|
|
1483
|
+
const [method, url, async = true, username = null, password = null] = args;
|
|
1484
|
+
if (args.length < 2) {
|
|
1485
|
+
throw new TypeError(`Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${args.length} present.`);
|
|
1486
|
+
}
|
|
1487
|
+
if (!async) {
|
|
1488
|
+
console.warn("Synchronous XMLHttpRequest is deprecated because of its detrimental effects to the end user's experience.");
|
|
1489
|
+
}
|
|
1490
|
+
this[state$1].clearRequest(false);
|
|
1491
|
+
this[state$1]._method = normalizeMethod(method);
|
|
1492
|
+
this[state$1]._reqURL = String(url);
|
|
1493
|
+
this[state$1]._reqCanSend = true;
|
|
1494
|
+
this[state$1].setReadyStateAndNotify(XMLHttpRequestP.OPENED);
|
|
1495
|
+
}
|
|
1496
|
+
overrideMimeType(mime) { }
|
|
1497
|
+
send(body) {
|
|
1498
|
+
if (!this[state$1]._reqCanSend || this.readyState !== XMLHttpRequestP.OPENED) {
|
|
1499
|
+
throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
1500
|
+
}
|
|
1501
|
+
this[state$1]._reqCanSend = false;
|
|
1502
|
+
this[state$1].execRequest(body);
|
|
1503
|
+
this[state$1].checkRequestTimeout();
|
|
1504
|
+
}
|
|
1505
|
+
setRequestHeader(name, value) {
|
|
1506
|
+
assignRequestHeader(this[state$1]._reqHeaders, name, value);
|
|
1507
|
+
}
|
|
1508
|
+
get onreadystatechange() { return this[state$1].onreadystatechange; }
|
|
1509
|
+
set onreadystatechange(value) {
|
|
1510
|
+
this[state$1].onreadystatechange = value;
|
|
1511
|
+
attachFn.call(this, "readystatechange", value, this[state$1]._onreadystatechange);
|
|
1512
|
+
}
|
|
1513
|
+
toString() { return "[object XMLHttpRequest"; }
|
|
1514
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1515
|
+
}
|
|
1516
|
+
defineStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
1517
|
+
class XMLHttpRequestState {
|
|
1518
|
+
constructor(target) {
|
|
1519
|
+
this.target = target;
|
|
1520
|
+
this.upload = createXMLHttpRequestUploadP();
|
|
1521
|
+
}
|
|
1522
|
+
target;
|
|
1523
|
+
readyState = XMLHttpRequestP.UNSENT;
|
|
1524
|
+
response = "";
|
|
1525
|
+
responseType = "";
|
|
1526
|
+
responseURL = "";
|
|
1527
|
+
status = 0;
|
|
1528
|
+
statusText = "";
|
|
1529
|
+
timeout = 0;
|
|
1530
|
+
upload;
|
|
1531
|
+
withCredentials = false;
|
|
1532
|
+
_reqCanSend = false;
|
|
1533
|
+
_resetPending = false;
|
|
1534
|
+
_timeoutId = 0;
|
|
1535
|
+
_reqURL = "";
|
|
1536
|
+
_method = "GET";
|
|
1537
|
+
_reqHeaders = { Accept: "*/*" };
|
|
1538
|
+
_resHeaders = null;
|
|
1539
|
+
_resContLen = 0;
|
|
1540
|
+
_requestTask = null;
|
|
1541
|
+
execRequest(body) {
|
|
1542
|
+
const allowsRequestBody = !["GET", "HEAD"].includes(this._method);
|
|
1543
|
+
const contentTypeExists = Object.keys(this._reqHeaders).map(x => x.toLowerCase()).includes("Content-Type".toLowerCase());
|
|
1544
|
+
const processHeaders = allowsRequestBody && !contentTypeExists;
|
|
1545
|
+
const processContentLength = this.upload[state$7].executors.length > 0;
|
|
1546
|
+
let headers = { ...this._reqHeaders };
|
|
1547
|
+
let contentLength = 0;
|
|
1548
|
+
let data = convert(body, processHeaders ? v => { headers["Content-Type"] = v; } : void 0, processContentLength ? v => { contentLength = v; } : void 0);
|
|
1549
|
+
this._requestTask = request({
|
|
1550
|
+
url: this._reqURL,
|
|
1551
|
+
method: this._method,
|
|
1552
|
+
header: headers,
|
|
1553
|
+
data,
|
|
1554
|
+
dataType: this.responseType === "json" ? "json" : "text",
|
|
1555
|
+
responseType: this.responseType === "arraybuffer" ? "arraybuffer" : "text",
|
|
1556
|
+
success: this.requestSuccess.bind(this),
|
|
1557
|
+
fail: this.requestFail.bind(this),
|
|
1558
|
+
complete: this.requestComplete.bind(this),
|
|
1559
|
+
});
|
|
1560
|
+
this.emitProcessEvent("loadstart");
|
|
1561
|
+
if (processContentLength) {
|
|
1562
|
+
const hasRequestBody = allowsRequestBody && contentLength > 0;
|
|
1563
|
+
if (hasRequestBody) {
|
|
1564
|
+
this.emitProcessEvent("loadstart", 0, contentLength, this.upload);
|
|
1565
|
+
}
|
|
1566
|
+
setTimeout(() => {
|
|
1567
|
+
const _aborted = this._reqCanSend || this.readyState !== XMLHttpRequestP.OPENED;
|
|
1568
|
+
const _contentLength = _aborted ? 0 : contentLength;
|
|
1569
|
+
if (_aborted) {
|
|
1570
|
+
this.emitProcessEvent("abort", 0, 0, this.upload);
|
|
1571
|
+
}
|
|
1572
|
+
else {
|
|
1573
|
+
if (hasRequestBody) {
|
|
1574
|
+
this.emitProcessEvent("load", _contentLength, _contentLength, this.upload);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
if (_aborted || hasRequestBody) {
|
|
1578
|
+
this.emitProcessEvent("loadend", _contentLength, _contentLength, this.upload);
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
requestSuccess({ statusCode, header, data }) {
|
|
1584
|
+
this.responseURL = this._reqURL;
|
|
1585
|
+
this.status = statusCode;
|
|
1586
|
+
this._resHeaders = header;
|
|
1587
|
+
this._resContLen = parseInt(this.target.getResponseHeader("Content-Length") || "0");
|
|
1588
|
+
if (this.readyState === XMLHttpRequestP.OPENED) {
|
|
1589
|
+
this.setReadyStateAndNotify(XMLHttpRequestP.HEADERS_RECEIVED);
|
|
1590
|
+
this.setReadyStateAndNotify(XMLHttpRequestP.LOADING);
|
|
1591
|
+
setTimeout(() => {
|
|
1592
|
+
if (!this._reqCanSend) {
|
|
1593
|
+
let l = this._resContLen;
|
|
1594
|
+
try {
|
|
1595
|
+
this.response = convertBack(this.responseType, data);
|
|
1596
|
+
this.emitProcessEvent("load", l, l);
|
|
1597
|
+
}
|
|
1598
|
+
catch (e) {
|
|
1599
|
+
console.error(e);
|
|
1600
|
+
this.emitProcessEvent("error");
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
requestFail(err) {
|
|
1607
|
+
// Alipay Mini Programs
|
|
1608
|
+
// error: 14 --- JSON parse data error
|
|
1609
|
+
// error: 19 --- http status error
|
|
1610
|
+
// At this point, the error data object will contain three pieces of information
|
|
1611
|
+
// returned from the server: status, headers, and data.
|
|
1612
|
+
// In the browser's XMLHttpRequest, these two errors (Error 14 and Error 19)
|
|
1613
|
+
// differ from those in Alipay Mini Programs and should instead return normally.
|
|
1614
|
+
// Therefore, this scenario is also handled here as a successful request response.
|
|
1615
|
+
if ("status" in err) {
|
|
1616
|
+
this.requestSuccess({ statusCode: err.status, header: err.headers, data: err.data });
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
this.status = 0;
|
|
1620
|
+
this.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
|
|
1621
|
+
if (!this._reqCanSend && this.readyState !== XMLHttpRequestP.UNSENT && this.readyState !== XMLHttpRequestP.DONE) {
|
|
1622
|
+
this.emitProcessEvent("error");
|
|
1623
|
+
this.resetRequestTimeout();
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
requestComplete() {
|
|
1627
|
+
this._requestTask = null;
|
|
1628
|
+
if (!this._reqCanSend && (this.readyState === XMLHttpRequestP.OPENED || this.readyState === XMLHttpRequestP.LOADING)) {
|
|
1629
|
+
this.setReadyStateAndNotify(XMLHttpRequestP.DONE);
|
|
1630
|
+
}
|
|
1631
|
+
setTimeout(() => {
|
|
1632
|
+
if (!this._reqCanSend) {
|
|
1633
|
+
let l = this._resContLen;
|
|
1634
|
+
this.emitProcessEvent("loadend", l, l);
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
clearRequest(delay = true) {
|
|
1639
|
+
const timerFn = delay ? setTimeout : (f) => { f(); };
|
|
1640
|
+
this._resetPending = true;
|
|
1641
|
+
if (this._requestTask && this.readyState !== XMLHttpRequestP.DONE) {
|
|
1642
|
+
if (delay) {
|
|
1643
|
+
this.setReadyStateAndNotify(XMLHttpRequestP.DONE);
|
|
1644
|
+
}
|
|
1645
|
+
timerFn(() => {
|
|
1646
|
+
const requestTask = this._requestTask;
|
|
1647
|
+
if (requestTask) {
|
|
1648
|
+
requestTask.abort();
|
|
1649
|
+
}
|
|
1650
|
+
if (delay) {
|
|
1651
|
+
this.emitProcessEvent("abort");
|
|
1652
|
+
}
|
|
1653
|
+
if (delay && !requestTask) {
|
|
1654
|
+
this.emitProcessEvent("loadend");
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
timerFn(() => {
|
|
1659
|
+
if (this._resetPending) {
|
|
1660
|
+
if (delay) {
|
|
1661
|
+
this.readyState = XMLHttpRequestP.UNSENT;
|
|
1662
|
+
}
|
|
1663
|
+
this.resetXHR();
|
|
1664
|
+
}
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
checkRequestTimeout() {
|
|
1668
|
+
if (this.timeout) {
|
|
1669
|
+
this._timeoutId = setTimeout(() => {
|
|
1670
|
+
if (!this.status && this.readyState !== XMLHttpRequestP.DONE) {
|
|
1671
|
+
if (this._requestTask)
|
|
1672
|
+
this._requestTask.abort();
|
|
1673
|
+
this.setReadyStateAndNotify(XMLHttpRequestP.DONE);
|
|
1674
|
+
this.emitProcessEvent("timeout");
|
|
1675
|
+
}
|
|
1676
|
+
}, this.timeout);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
resetXHR() {
|
|
1680
|
+
this._resetPending = false;
|
|
1681
|
+
this.resetRequestTimeout();
|
|
1682
|
+
this.response = "";
|
|
1683
|
+
this.responseURL = "";
|
|
1684
|
+
this.status = 0;
|
|
1685
|
+
this.statusText = "";
|
|
1686
|
+
this._reqHeaders = {};
|
|
1687
|
+
this._resHeaders = null;
|
|
1688
|
+
this._resContLen = 0;
|
|
1689
|
+
}
|
|
1690
|
+
resetRequestTimeout() {
|
|
1691
|
+
if (this._timeoutId) {
|
|
1692
|
+
clearTimeout(this._timeoutId);
|
|
1693
|
+
this._timeoutId = 0;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
emitProcessEvent(type, loaded = 0, total = 0, target) {
|
|
1697
|
+
const _target = target ?? this.target;
|
|
1698
|
+
const _event = new ProgressEventP(type, {
|
|
1699
|
+
lengthComputable: total > 0,
|
|
1700
|
+
loaded,
|
|
1701
|
+
total,
|
|
1702
|
+
});
|
|
1703
|
+
_event[state$9].target = _target;
|
|
1704
|
+
_event[state$9].isTrusted = true;
|
|
1705
|
+
_target[state$7].fire(_event);
|
|
1706
|
+
}
|
|
1707
|
+
setReadyStateAndNotify(value) {
|
|
1708
|
+
const hasChanged = value !== this.readyState;
|
|
1709
|
+
this.readyState = value;
|
|
1710
|
+
if (hasChanged) {
|
|
1711
|
+
const evt = new EventP("readystatechange");
|
|
1712
|
+
evt[state$9].target = this.target;
|
|
1713
|
+
evt[state$9].isTrusted = true;
|
|
1714
|
+
this.target[state$7].fire(evt);
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
onreadystatechange = null;
|
|
1718
|
+
_onreadystatechange = (ev) => { executeFn.call(this.target, this.onreadystatechange, ev); };
|
|
1719
|
+
}
|
|
1720
|
+
// HTTP methods whose capitalization should be normalized
|
|
1721
|
+
const methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
|
|
1722
|
+
function normalizeMethod(method) {
|
|
1723
|
+
let upcased = method.toUpperCase();
|
|
1724
|
+
return methods.indexOf(upcased) > -1 ? upcased : method;
|
|
1725
|
+
}
|
|
1726
|
+
function assignRequestHeader(headers, name, value) {
|
|
1727
|
+
for (const key of Object.keys(headers)) {
|
|
1728
|
+
if (key.toLowerCase() === name.toLowerCase()) {
|
|
1729
|
+
headers[key] = value;
|
|
1730
|
+
return;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
Object.assign(headers, { [name]: value });
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
const encode = (str) => {
|
|
1737
|
+
const encoder = new TextEncoderP();
|
|
1738
|
+
return encoder.encode(str).buffer;
|
|
1739
|
+
};
|
|
1740
|
+
const decode = (buf) => {
|
|
1741
|
+
let decoder = new TextDecoderP();
|
|
1742
|
+
return decoder.decode(buf);
|
|
1743
|
+
};
|
|
1744
|
+
function convert(body, setContentType, setContentLength) {
|
|
1745
|
+
let result;
|
|
1746
|
+
if (typeof body === "string") {
|
|
1747
|
+
result = body;
|
|
1748
|
+
if (setContentType) {
|
|
1749
|
+
setContentType("text/plain;charset=UTF-8");
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
else if (isObjectType("URLSearchParams", body)) {
|
|
1753
|
+
result = body.toString();
|
|
1754
|
+
if (setContentType) {
|
|
1755
|
+
setContentType("application/x-www-form-urlencoded;charset=UTF-8");
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
else if (body instanceof ArrayBuffer) {
|
|
1759
|
+
result = body.slice(0);
|
|
1760
|
+
}
|
|
1761
|
+
else if (ArrayBuffer.isView(body)) {
|
|
1762
|
+
result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
1763
|
+
}
|
|
1764
|
+
else if (isPolyfillType("Blob", body)) {
|
|
1765
|
+
result = body[state$9]._u8array.buffer.slice(0);
|
|
1766
|
+
if (setContentType && body.type) {
|
|
1767
|
+
setContentType(body.type);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
else if (isPolyfillType("FormData", body)) {
|
|
1771
|
+
const blob = body[state$9].toBlob();
|
|
1772
|
+
result = blob[state$9]._u8array.buffer;
|
|
1773
|
+
if (setContentType) {
|
|
1774
|
+
setContentType(blob.type);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
else if (!body) {
|
|
1778
|
+
result = "";
|
|
1779
|
+
}
|
|
1780
|
+
else {
|
|
1781
|
+
result = String(body);
|
|
1782
|
+
}
|
|
1783
|
+
if (setContentLength) {
|
|
1784
|
+
setContentLength((typeof result === "string" ? encode(result) : result).byteLength);
|
|
1785
|
+
}
|
|
1786
|
+
return result;
|
|
1787
|
+
}
|
|
1788
|
+
function convertBack(type, data) {
|
|
1789
|
+
let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
|
|
1790
|
+
if (!type || type === "text") {
|
|
1791
|
+
return typeof temp === "string" ? temp : decode(temp);
|
|
1792
|
+
}
|
|
1793
|
+
else if (type === "json") {
|
|
1794
|
+
return JSON.parse(typeof temp === "string" ? temp : decode(temp));
|
|
1795
|
+
}
|
|
1796
|
+
else if (type === "arraybuffer") {
|
|
1797
|
+
return temp instanceof ArrayBuffer ? temp.slice(0) : encode(temp);
|
|
1798
|
+
}
|
|
1799
|
+
else if (type === "blob") {
|
|
1800
|
+
return new BlobP([temp]);
|
|
1801
|
+
}
|
|
1802
|
+
else {
|
|
1803
|
+
return temp;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
const statusMessages = {
|
|
1807
|
+
100: "Continue",
|
|
1808
|
+
101: "Switching Protocols",
|
|
1809
|
+
102: "Processing",
|
|
1810
|
+
103: "Early Hints",
|
|
1811
|
+
200: "OK",
|
|
1812
|
+
201: "Created",
|
|
1813
|
+
202: "Accepted",
|
|
1814
|
+
203: "Non-Authoritative Information",
|
|
1815
|
+
204: "No Content",
|
|
1816
|
+
205: "Reset Content",
|
|
1817
|
+
206: "Partial Content",
|
|
1818
|
+
207: "Multi-Status",
|
|
1819
|
+
208: "Already Reported",
|
|
1820
|
+
226: "IM Used",
|
|
1821
|
+
300: "Multiple Choices",
|
|
1822
|
+
301: "Moved Permanently",
|
|
1823
|
+
302: "Found",
|
|
1824
|
+
303: "See Other",
|
|
1825
|
+
304: "Not Modified",
|
|
1826
|
+
307: "Temporary Redirect",
|
|
1827
|
+
308: "Permanent Redirect",
|
|
1828
|
+
400: "Bad Request",
|
|
1829
|
+
401: "Unauthorized",
|
|
1830
|
+
402: "Payment Required",
|
|
1831
|
+
403: "Forbidden",
|
|
1832
|
+
404: "Not Found",
|
|
1833
|
+
405: "Method Not Allowed",
|
|
1834
|
+
406: "Not Acceptable",
|
|
1835
|
+
407: "Proxy Authentication Required",
|
|
1836
|
+
408: "Request Timeout",
|
|
1837
|
+
409: "Conflict",
|
|
1838
|
+
410: "Gone",
|
|
1839
|
+
411: "Length Required",
|
|
1840
|
+
412: "Precondition Failed",
|
|
1841
|
+
413: "Content Too Large",
|
|
1842
|
+
414: "URI Too Long",
|
|
1843
|
+
415: "Unsupported Media Type",
|
|
1844
|
+
416: "Range Not Satisfiable",
|
|
1845
|
+
417: "Expectation Failed",
|
|
1846
|
+
418: "I'm a teapot",
|
|
1847
|
+
421: "Misdirected Request",
|
|
1848
|
+
422: "Unprocessable Entity",
|
|
1849
|
+
423: "Locked",
|
|
1850
|
+
424: "Failed Dependency",
|
|
1851
|
+
425: "Too Early",
|
|
1852
|
+
426: "Upgrade Required",
|
|
1853
|
+
428: "Precondition Required",
|
|
1854
|
+
429: "Too Many Requests",
|
|
1855
|
+
431: "Request Header Fields Too Large",
|
|
1856
|
+
451: "Unavailable For Legal Reasons",
|
|
1857
|
+
500: "Internal Server Error",
|
|
1858
|
+
501: "Not Implemented",
|
|
1859
|
+
502: "Bad Gateway",
|
|
1860
|
+
503: "Service Unavailable",
|
|
1861
|
+
504: "Gateway Timeout",
|
|
1862
|
+
505: "HTTP Version Not Supported",
|
|
1863
|
+
506: "Variant Also Negotiates",
|
|
1864
|
+
507: "Insufficient Storage",
|
|
1865
|
+
508: "Loop Detected",
|
|
1866
|
+
510: "Not Extended",
|
|
1867
|
+
511: "Network Authentication Required"
|
|
1868
|
+
};
|
|
1869
|
+
function statusTextMap(val) {
|
|
1870
|
+
return statusMessages[val] || "unknown";
|
|
1871
|
+
}
|
|
1872
|
+
const XMLHttpRequestE = !mp ? g["XMLHttpRequest"] : XMLHttpRequestP;
|
|
1873
|
+
|
|
1874
|
+
const state = Symbol("BodyState");
|
|
1875
|
+
class BodyP {
|
|
1876
|
+
constructor() {
|
|
1877
|
+
if (new.target === BodyP) {
|
|
1878
|
+
throw new TypeError("Failed to construct 'Body': Illegal constructor");
|
|
1879
|
+
}
|
|
1880
|
+
this[state] = new BodyState();
|
|
1881
|
+
}
|
|
1882
|
+
[state];
|
|
1883
|
+
get body() {
|
|
1884
|
+
if (!this[state]._body) {
|
|
1885
|
+
return null;
|
|
1886
|
+
}
|
|
1887
|
+
throw new ReferenceError("ReadableStream is not defined");
|
|
1888
|
+
}
|
|
1889
|
+
get bodyUsed() { return this[state].bodyUsed; }
|
|
1890
|
+
;
|
|
1891
|
+
arrayBuffer() {
|
|
1892
|
+
const kind = "arrayBuffer";
|
|
1893
|
+
return this[state].consumed(kind) || this[state].read(kind);
|
|
1894
|
+
}
|
|
1895
|
+
blob() {
|
|
1896
|
+
const kind = "blob";
|
|
1897
|
+
return this[state].consumed(kind) || this[state].read(kind);
|
|
1898
|
+
}
|
|
1899
|
+
bytes() {
|
|
1900
|
+
const kind = "bytes";
|
|
1901
|
+
return this[state].consumed(kind) || this[state].read(kind);
|
|
1902
|
+
}
|
|
1903
|
+
formData() {
|
|
1904
|
+
const kind = "formData";
|
|
1905
|
+
return this[state].consumed(kind) || this[state].read(kind);
|
|
1906
|
+
}
|
|
1907
|
+
json() {
|
|
1908
|
+
const kind = "json";
|
|
1909
|
+
return this[state].consumed(kind) || this[state].read(kind);
|
|
1910
|
+
}
|
|
1911
|
+
text() {
|
|
1912
|
+
const kind = "text";
|
|
1913
|
+
return this[state].consumed(kind) || this[state].read(kind);
|
|
1914
|
+
}
|
|
1915
|
+
toString() { return "[object Body]"; }
|
|
1916
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
|
|
1917
|
+
}
|
|
1918
|
+
defineStringTag(BodyP, "Body");
|
|
1919
|
+
class BodyState {
|
|
1920
|
+
bodyUsed = false;
|
|
1921
|
+
_name = "Body";
|
|
1922
|
+
_body = "";
|
|
1923
|
+
init(body, headers) {
|
|
1924
|
+
if (isObjectType("ReadableStream", body)) {
|
|
1925
|
+
throw new ReferenceError("ReadableStream is not defined");
|
|
1926
|
+
}
|
|
1927
|
+
this._body = convert(body, type => {
|
|
1928
|
+
if (headers && !headers.get("Content-Type")) {
|
|
1929
|
+
headers.set("Content-Type", type);
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
read(kind) {
|
|
1934
|
+
return new Promise((resolve, reject) => {
|
|
1935
|
+
try {
|
|
1936
|
+
if (kind === "arrayBuffer") {
|
|
1937
|
+
resolve(convertBack("arraybuffer", this._body));
|
|
1938
|
+
}
|
|
1939
|
+
else if (kind === "blob") {
|
|
1940
|
+
resolve(convertBack("blob", this._body));
|
|
1941
|
+
}
|
|
1942
|
+
else if (kind === "bytes") {
|
|
1943
|
+
let arrayBuffer = convertBack("arraybuffer", this._body);
|
|
1944
|
+
resolve(new Uint8Array(arrayBuffer));
|
|
1945
|
+
}
|
|
1946
|
+
else if (kind === "formData") {
|
|
1947
|
+
let text = convertBack("text", this._body);
|
|
1948
|
+
resolve(createFormData(text));
|
|
1949
|
+
}
|
|
1950
|
+
else if (kind === "json") {
|
|
1951
|
+
resolve(convertBack("json", this._body));
|
|
1952
|
+
}
|
|
1953
|
+
else {
|
|
1954
|
+
resolve(convertBack("text", this._body));
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
catch (e) {
|
|
1958
|
+
reject(e);
|
|
1959
|
+
}
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
consumed(kind) {
|
|
1963
|
+
if (!this._body)
|
|
1964
|
+
return;
|
|
1965
|
+
if (this.bodyUsed) {
|
|
1966
|
+
return Promise.reject(new TypeError(`TypeError: Failed to execute '${kind}' on '${this._name}': body stream already read`));
|
|
1967
|
+
}
|
|
1968
|
+
this.bodyUsed = true;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
class HeadersP {
|
|
1973
|
+
constructor(init) {
|
|
1974
|
+
this[state$9] = new HeadersState();
|
|
1975
|
+
if (isObjectType("Headers", init)) {
|
|
1976
|
+
init.forEach((value, name) => {
|
|
1977
|
+
this.append(name, value);
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
else if (Array.isArray(init)) {
|
|
1981
|
+
init.forEach(header => {
|
|
1982
|
+
if (!Array.isArray(header)) {
|
|
1983
|
+
throw new TypeError("Failed to construct 'Headers': The provided value cannot be converted to a sequence.");
|
|
1984
|
+
}
|
|
1985
|
+
if (header.length !== 2) {
|
|
1986
|
+
throw new TypeError("Failed to construct 'Headers': Invalid value");
|
|
1987
|
+
}
|
|
1988
|
+
this.append(header[0], header[1]);
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
else if (init) {
|
|
1992
|
+
Object.entries(init).forEach(([name, value]) => {
|
|
1993
|
+
this.append(name, value);
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
[state$9];
|
|
1998
|
+
append(name, value) {
|
|
1999
|
+
let key = normalizeName(name, "append");
|
|
2000
|
+
value = normalizeValue(value);
|
|
2001
|
+
let oldValue = this[state$9]._map.get(key)?.[1];
|
|
2002
|
+
this[state$9]._map.set(key, ["" + name, oldValue ? `${oldValue}, ${value}` : value]);
|
|
2003
|
+
}
|
|
2004
|
+
delete(name) {
|
|
2005
|
+
let key = normalizeName(name, "delete");
|
|
2006
|
+
this[state$9]._map.delete(key);
|
|
2007
|
+
}
|
|
2008
|
+
get(name) {
|
|
2009
|
+
let key = normalizeName(name, "get");
|
|
2010
|
+
return this[state$9]._map.get(key)?.[1] ?? null;
|
|
2011
|
+
}
|
|
2012
|
+
getSetCookie() {
|
|
2013
|
+
let value = this.get("Set-Cookie");
|
|
2014
|
+
return value ? value.split(", ") : [];
|
|
2015
|
+
}
|
|
2016
|
+
has(name) {
|
|
2017
|
+
let key = normalizeName(name, "has");
|
|
2018
|
+
return this[state$9]._map.has(key);
|
|
2019
|
+
}
|
|
2020
|
+
set(name, value) {
|
|
2021
|
+
let key = normalizeName(name, "set");
|
|
2022
|
+
this[state$9]._map.set(key, ["" + name, normalizeValue(value)]);
|
|
2023
|
+
}
|
|
2024
|
+
forEach(callbackfn, thisArg) {
|
|
2025
|
+
Array.from(this.entries()).forEach(([name, value]) => {
|
|
2026
|
+
callbackfn.call(thisArg, value, name, this);
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
entries() {
|
|
2030
|
+
return this[state$9]._map.values();
|
|
2031
|
+
}
|
|
2032
|
+
keys() {
|
|
2033
|
+
return Array.from(this.entries()).map(pair => pair[0]).values();
|
|
2034
|
+
}
|
|
2035
|
+
values() {
|
|
2036
|
+
return Array.from(this.entries()).map(pair => pair[1]).values();
|
|
2037
|
+
}
|
|
2038
|
+
[Symbol.iterator]() {
|
|
2039
|
+
return this.entries();
|
|
2040
|
+
}
|
|
2041
|
+
toString() { return "[object Headers]"; }
|
|
2042
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
|
|
2043
|
+
}
|
|
2044
|
+
defineStringTag(HeadersP, "Headers");
|
|
2045
|
+
class HeadersState {
|
|
2046
|
+
_map = new Map();
|
|
2047
|
+
}
|
|
2048
|
+
function normalizeName(name, kind = "") {
|
|
2049
|
+
if (typeof name !== "string") {
|
|
2050
|
+
name = String(name);
|
|
2051
|
+
}
|
|
2052
|
+
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
|
|
2053
|
+
if (kind) {
|
|
2054
|
+
throw new TypeError(`Failed to execute '${kind}' on 'Headers': Invalid name`);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
return name.toLowerCase();
|
|
2058
|
+
}
|
|
2059
|
+
function normalizeValue(value) {
|
|
2060
|
+
if (typeof value !== "string") {
|
|
2061
|
+
value = String(value);
|
|
2062
|
+
}
|
|
2063
|
+
return value;
|
|
2064
|
+
}
|
|
2065
|
+
const HeadersE = g["Headers"] || HeadersP;
|
|
2066
|
+
|
|
2067
|
+
class RequestP extends BodyP {
|
|
2068
|
+
constructor(input, init) {
|
|
2069
|
+
super();
|
|
2070
|
+
this[state$9] = new RequestState();
|
|
2071
|
+
this[state]._name = "Request";
|
|
2072
|
+
let options = init ?? {};
|
|
2073
|
+
let body = options.body;
|
|
2074
|
+
if (isPolyfillType("Request", input)) {
|
|
2075
|
+
if (input.bodyUsed) {
|
|
2076
|
+
throw new TypeError("Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used.");
|
|
2077
|
+
}
|
|
2078
|
+
this[state$9].credentials = input.credentials;
|
|
2079
|
+
if (!options.headers) {
|
|
2080
|
+
this[state$9].headers = new HeadersP(input.headers);
|
|
2081
|
+
}
|
|
2082
|
+
this[state$9].method = input.method;
|
|
2083
|
+
this[state$9].mode = input.mode;
|
|
2084
|
+
this[state$9].signal = input.signal;
|
|
2085
|
+
this[state$9].url = input.url;
|
|
2086
|
+
let _input = input;
|
|
2087
|
+
if (!body && _input[state]._body !== null) {
|
|
2088
|
+
body = _input[state]._body;
|
|
2089
|
+
_input[state].bodyUsed = true;
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
else {
|
|
2093
|
+
this[state$9].url = String(input);
|
|
2094
|
+
}
|
|
2095
|
+
if (options.credentials) {
|
|
2096
|
+
this[state$9].credentials = options.credentials;
|
|
2097
|
+
}
|
|
2098
|
+
if (options.headers) {
|
|
2099
|
+
this[state$9].headers = new HeadersP(options.headers);
|
|
2100
|
+
}
|
|
2101
|
+
if (options.method) {
|
|
2102
|
+
this[state$9].method = normalizeMethod(options.method);
|
|
2103
|
+
}
|
|
2104
|
+
if (options.mode) {
|
|
2105
|
+
this[state$9].mode = options.mode;
|
|
2106
|
+
}
|
|
2107
|
+
if (options.signal) {
|
|
2108
|
+
this[state$9].signal = options.signal;
|
|
2109
|
+
}
|
|
2110
|
+
if ((this.method === "GET" || this.method === "HEAD") && body) {
|
|
2111
|
+
throw new TypeError("Failed to construct 'Request': Request with GET/HEAD method cannot have body.");
|
|
2112
|
+
}
|
|
2113
|
+
this[state].init(body, this.headers);
|
|
2114
|
+
if (this.method === "GET" || this.method === "HEAD") {
|
|
2115
|
+
if (options.cache === "no-store" || options.cache === "no-cache") {
|
|
2116
|
+
// Search for a '_' parameter in the query string
|
|
2117
|
+
let reParamSearch = /([?&])_=[^&]*/;
|
|
2118
|
+
if (reParamSearch.test(this.url)) {
|
|
2119
|
+
// If it already exists then set the value with the current time
|
|
2120
|
+
this[state$9].url = this.url.replace(reParamSearch, "$1_=" + (new Date()).getTime());
|
|
2121
|
+
}
|
|
2122
|
+
else {
|
|
2123
|
+
// Otherwise add a new '_' parameter to the end with the current time
|
|
2124
|
+
let reQueryString = /\?/;
|
|
2125
|
+
this[state$9].url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (new Date()).getTime();
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
[state$9];
|
|
2131
|
+
get cache() { return this[state$9].cache; }
|
|
2132
|
+
get credentials() { return this[state$9].credentials; }
|
|
2133
|
+
get destination() { return this[state$9].destination; }
|
|
2134
|
+
get headers() { return this[state$9].headers; }
|
|
2135
|
+
get integrity() { return this[state$9].integrity; }
|
|
2136
|
+
get keepalive() { return this[state$9].keepalive; }
|
|
2137
|
+
get method() { return this[state$9].method; }
|
|
2138
|
+
get mode() { return this[state$9].mode; }
|
|
2139
|
+
get redirect() { return this[state$9].redirect; }
|
|
2140
|
+
get referrer() { return this[state$9].referrer; }
|
|
2141
|
+
get referrerPolicy() { return this[state$9].referrerPolicy; }
|
|
2142
|
+
get signal() { return this[state$9].signal; }
|
|
2143
|
+
get url() { return this[state$9].url; }
|
|
2144
|
+
clone() {
|
|
2145
|
+
return new RequestP(this, { body: this[state]._body ?? null });
|
|
2146
|
+
}
|
|
2147
|
+
toString() { return "[object Request]"; }
|
|
2148
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
|
|
2149
|
+
}
|
|
2150
|
+
defineStringTag(RequestP, "Request");
|
|
2151
|
+
class RequestState {
|
|
2152
|
+
cache = "default";
|
|
2153
|
+
credentials = "same-origin";
|
|
2154
|
+
destination = "";
|
|
2155
|
+
headers = new HeadersP();
|
|
2156
|
+
integrity = "";
|
|
2157
|
+
keepalive = false;
|
|
2158
|
+
method = "GET";
|
|
2159
|
+
mode = "cors";
|
|
2160
|
+
redirect = "follow";
|
|
2161
|
+
referrer = "about:client";
|
|
2162
|
+
referrerPolicy = "";
|
|
2163
|
+
signal = (new AbortControllerP()).signal;
|
|
2164
|
+
url = "";
|
|
2165
|
+
}
|
|
2166
|
+
const RequestE = g["Request"] || RequestP;
|
|
2167
|
+
|
|
2168
|
+
class ResponseP extends BodyP {
|
|
2169
|
+
constructor(body, init) {
|
|
2170
|
+
super();
|
|
2171
|
+
this[state$9] = new ResponseState();
|
|
2172
|
+
this[state]._name = "Response";
|
|
2173
|
+
let options = init ?? {};
|
|
2174
|
+
let status = options.status === undefined ? 200 : options.status;
|
|
2175
|
+
if (status < 200 || status > 500) {
|
|
2176
|
+
throw new RangeError(`Failed to construct 'Response': The status provided (${+status}) is outside the range [200, 599].`);
|
|
2177
|
+
}
|
|
2178
|
+
if (options.headers) {
|
|
2179
|
+
this[state$9].headers = new HeadersP(options.headers);
|
|
2180
|
+
}
|
|
2181
|
+
this[state$9].ok = this.status >= 200 && this.status < 300;
|
|
2182
|
+
this[state$9].status = status;
|
|
2183
|
+
this[state$9].statusText = options.statusText === undefined ? "" : "" + options.statusText;
|
|
2184
|
+
this[state].init(body, this.headers);
|
|
2185
|
+
}
|
|
2186
|
+
[state$9];
|
|
2187
|
+
get headers() { return this[state$9].headers; }
|
|
2188
|
+
get ok() { return this[state$9].ok; }
|
|
2189
|
+
get redirected() { return this[state$9].redirected; }
|
|
2190
|
+
get status() { return this[state$9].status; }
|
|
2191
|
+
get statusText() { return this[state$9].statusText; }
|
|
2192
|
+
get type() { return this[state$9].type; }
|
|
2193
|
+
get url() { return this[state$9].url; }
|
|
2194
|
+
clone() {
|
|
2195
|
+
const response = new ResponseP(this[state]._body, {
|
|
2196
|
+
headers: new HeadersP(this.headers),
|
|
2197
|
+
status: this.status,
|
|
2198
|
+
statusText: this.statusText,
|
|
2199
|
+
});
|
|
2200
|
+
response[state$9].url = this.url;
|
|
2201
|
+
return response;
|
|
2202
|
+
}
|
|
2203
|
+
static json(data, init) {
|
|
2204
|
+
return new Response(JSON.stringify(data), init);
|
|
2205
|
+
}
|
|
2206
|
+
static error() {
|
|
2207
|
+
const response = new ResponseP(null, { status: 200, statusText: "" });
|
|
2208
|
+
response[state$9].ok = false;
|
|
2209
|
+
response[state$9].status = 0;
|
|
2210
|
+
response[state$9].type = "error";
|
|
2211
|
+
return response;
|
|
2212
|
+
}
|
|
2213
|
+
static redirect(url, status = 301) {
|
|
2214
|
+
if ([301, 302, 303, 307, 308].indexOf(status) === -1) {
|
|
2215
|
+
throw new RangeError("Failed to execute 'redirect' on 'Response': Invalid status code");
|
|
2216
|
+
}
|
|
2217
|
+
return new Response(null, { status, headers: { location: String(url) } });
|
|
2218
|
+
}
|
|
2219
|
+
toString() { return "[object Response]"; }
|
|
2220
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
|
|
2221
|
+
}
|
|
2222
|
+
defineStringTag(ResponseP, "Response");
|
|
2223
|
+
class ResponseState {
|
|
2224
|
+
headers = new HeadersP();
|
|
2225
|
+
ok = true;
|
|
2226
|
+
redirected = false;
|
|
2227
|
+
status = 200;
|
|
2228
|
+
statusText = "";
|
|
2229
|
+
type = "default";
|
|
2230
|
+
url = "";
|
|
2231
|
+
}
|
|
2232
|
+
const ResponseE = g["Response"] || ResponseP;
|
|
2233
|
+
|
|
2234
|
+
function fetchP(input, init) {
|
|
2235
|
+
if (new.target === fetchP) {
|
|
2236
|
+
throw new TypeError("fetch is not a constructor");
|
|
2237
|
+
}
|
|
2238
|
+
return new Promise(function (resolve, reject) {
|
|
2239
|
+
let request = new RequestP(input, init);
|
|
2240
|
+
if (request.signal && request.signal.aborted) {
|
|
2241
|
+
return reject(request.signal.reason);
|
|
2242
|
+
}
|
|
2243
|
+
let xhr = new XMLHttpRequestP();
|
|
2244
|
+
xhr.onload = function () {
|
|
2245
|
+
let options = {
|
|
2246
|
+
headers: new HeadersP(xhr[state$1]._resHeaders || undefined),
|
|
2247
|
+
status: xhr.status,
|
|
2248
|
+
statusText: xhr.statusText,
|
|
2249
|
+
};
|
|
2250
|
+
setTimeout(() => {
|
|
2251
|
+
const response = new ResponseP(xhr.response, options);
|
|
2252
|
+
response[state$9].url = xhr.responseURL;
|
|
2253
|
+
resolve(response);
|
|
2254
|
+
});
|
|
2255
|
+
};
|
|
2256
|
+
xhr.onerror = function () {
|
|
2257
|
+
setTimeout(function () {
|
|
2258
|
+
reject(new TypeError("Failed to fetch"));
|
|
2259
|
+
});
|
|
2260
|
+
};
|
|
2261
|
+
xhr.ontimeout = function () {
|
|
2262
|
+
setTimeout(function () {
|
|
2263
|
+
reject(new MPException("request:fail timeout", "TimeoutError"));
|
|
2264
|
+
});
|
|
2265
|
+
};
|
|
2266
|
+
xhr.onabort = function () {
|
|
2267
|
+
setTimeout(function () {
|
|
2268
|
+
reject(new MPException("request:fail abort", "AbortError"));
|
|
2269
|
+
});
|
|
2270
|
+
};
|
|
2271
|
+
xhr.open(request.method, request.url);
|
|
2272
|
+
if (request.credentials === "include") {
|
|
2273
|
+
xhr.withCredentials = true;
|
|
2274
|
+
}
|
|
2275
|
+
else if (request.credentials === "omit") {
|
|
2276
|
+
xhr.withCredentials = false;
|
|
2277
|
+
}
|
|
2278
|
+
if (init && isObjectHeaders(init.headers)) {
|
|
2279
|
+
let headers = init.headers;
|
|
2280
|
+
let names = [];
|
|
2281
|
+
Object.entries(headers).forEach(([name, value]) => {
|
|
2282
|
+
names.push(normalizeName(name));
|
|
2283
|
+
xhr.setRequestHeader(name, normalizeValue(value));
|
|
2284
|
+
});
|
|
2285
|
+
request.headers.forEach(function (value, name) {
|
|
2286
|
+
if (names.indexOf(normalizeName(name)) === -1) {
|
|
2287
|
+
xhr.setRequestHeader(name, value);
|
|
2288
|
+
}
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
else {
|
|
2292
|
+
request.headers.forEach(function (value, name) {
|
|
2293
|
+
xhr.setRequestHeader(name, value);
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
if (request.signal) {
|
|
2297
|
+
const abortXHR = () => { xhr.abort(); };
|
|
2298
|
+
request.signal.addEventListener("abort", abortXHR);
|
|
2299
|
+
xhr.onreadystatechange = function () {
|
|
2300
|
+
// DONE (success or failure)
|
|
2301
|
+
if (xhr.readyState === 4) {
|
|
2302
|
+
request.signal.removeEventListener("abort", abortXHR);
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
xhr.send(request[state]._body);
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
function isObjectHeaders(val) {
|
|
2310
|
+
return typeof val === "object" && !isObjectType("Headers", val);
|
|
2311
|
+
}
|
|
2312
|
+
const fetchE = !mp ? g["fetch"] : fetchP;
|
|
2313
|
+
|
|
2314
|
+
exports.AbortController = AbortControllerE;
|
|
2315
|
+
exports.AbortControllerP = AbortControllerP;
|
|
2316
|
+
exports.AbortSignal = AbortSignalE;
|
|
2317
|
+
exports.AbortSignalP = AbortSignalP;
|
|
2318
|
+
exports.Blob = BlobE;
|
|
2319
|
+
exports.BlobP = BlobP;
|
|
2320
|
+
exports.CustomEvent = CustomEventE;
|
|
2321
|
+
exports.CustomEventP = CustomEventP;
|
|
2322
|
+
exports.Event = EventE;
|
|
2323
|
+
exports.EventP = EventP;
|
|
2324
|
+
exports.EventTarget = EventTargetE;
|
|
2325
|
+
exports.EventTargetP = EventTargetP;
|
|
2326
|
+
exports.File = FileE;
|
|
2327
|
+
exports.FileP = FileP;
|
|
2328
|
+
exports.FileReader = FileReaderE;
|
|
2329
|
+
exports.FileReaderP = FileReaderP;
|
|
2330
|
+
exports.FormData = FormDataE;
|
|
2331
|
+
exports.FormDataP = FormDataP;
|
|
2332
|
+
exports.Headers = HeadersE;
|
|
2333
|
+
exports.HeadersP = HeadersP;
|
|
2334
|
+
exports.ProgressEvent = ProgressEventE;
|
|
2335
|
+
exports.ProgressEventP = ProgressEventP;
|
|
2336
|
+
exports.Request = RequestE;
|
|
2337
|
+
exports.RequestP = RequestP;
|
|
2338
|
+
exports.Response = ResponseE;
|
|
2339
|
+
exports.ResponseP = ResponseP;
|
|
2340
|
+
exports.TextDecoder = TextDecoderE;
|
|
2341
|
+
exports.TextDecoderP = TextDecoderP;
|
|
2342
|
+
exports.TextEncoder = TextEncoderE;
|
|
2343
|
+
exports.TextEncoderP = TextEncoderP;
|
|
2344
|
+
exports.URLSearchParams = URLSearchParamsE;
|
|
2345
|
+
exports.URLSearchParamsP = URLSearchParamsP;
|
|
2346
|
+
exports.XMLHttpRequest = XMLHttpRequestE;
|
|
2347
|
+
exports.XMLHttpRequestP = XMLHttpRequestP;
|
|
2348
|
+
exports.fetch = fetchE;
|
|
2349
|
+
exports.fetchP = fetchP;
|