mphttpx 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +705 -24
- package/dist/index.cjs.js +1962 -1569
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.d.ts +558 -289
- package/dist/index.esm.js +1961 -1570
- package/dist/index.esm.min.js +1 -1
- package/package.json +2 -1
- package/README.md.bak +0 -107
package/dist/index.cjs.js
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const polyfill = Symbol("isPolyfill");
|
|
4
3
|
/* eslint-disable no-prototype-builtins */
|
|
5
|
-
const g = (typeof globalThis !== "undefined" && globalThis) ||
|
|
4
|
+
/** @internal */ const g = (typeof globalThis !== "undefined" && globalThis) ||
|
|
6
5
|
(typeof self !== "undefined" && self) ||
|
|
7
6
|
// @ts-ignore eslint-disable-next-line no-undef
|
|
8
7
|
(typeof global !== "undefined" && global) ||
|
|
9
8
|
{};
|
|
9
|
+
/** @internal */
|
|
10
|
+
const polyfill = "MPHTTPX";
|
|
11
|
+
/** @internal */
|
|
12
|
+
function Class_setStringTag(targetFunc, stringTag) {
|
|
13
|
+
Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
|
|
14
|
+
configurable: true,
|
|
15
|
+
value: stringTag,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** @internal */
|
|
19
|
+
function checkArgsLength(args, required, className, funcName) {
|
|
20
|
+
if (args.length < required) {
|
|
21
|
+
throw new TypeError(`Failed to ${funcName ? ("execute '" + funcName + "' on") : "construct"} '${className}': ${required} argument${required > 1 ? "s" : ""} required, but only ${args.length} present.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** @internal */
|
|
25
|
+
class MPException extends Error {
|
|
26
|
+
constructor(message, name) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = "Error";
|
|
29
|
+
if (name) {
|
|
30
|
+
this.name = name;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** @internal */
|
|
10
35
|
function isObjectType(name, value) {
|
|
11
36
|
return Object.prototype.toString.call(value) === `[object ${name}]`;
|
|
12
37
|
}
|
|
38
|
+
/** @internal */
|
|
13
39
|
function isPolyfillType(name, value) {
|
|
14
40
|
return !!value
|
|
15
41
|
&& typeof value === "object"
|
|
@@ -22,39 +48,28 @@ function isPolyfillType(name, value) {
|
|
|
22
48
|
&& Array.isArray(value.isPolyfill.hierarchy)
|
|
23
49
|
&& value.isPolyfill.hierarchy.indexOf(name) > -1;
|
|
24
50
|
}
|
|
25
|
-
class MPException extends Error {
|
|
26
|
-
constructor(message, name) {
|
|
27
|
-
super();
|
|
28
|
-
this.message = message !== null && message !== void 0 ? message : this.message;
|
|
29
|
-
this.name = name !== null && name !== void 0 ? name : this.name;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function defineStringTag(targetFunc, stringTag) {
|
|
33
|
-
Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
|
|
34
|
-
configurable: true,
|
|
35
|
-
value: stringTag,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
function objectValues(obj) {
|
|
39
|
-
return Object.keys(obj).map(key => obj[key]);
|
|
40
|
-
}
|
|
41
|
-
function objectEntries(obj) {
|
|
42
|
-
return Object.keys(obj).map(key => [key, obj[key]]);
|
|
43
|
-
}
|
|
44
51
|
|
|
52
|
+
/** @type {typeof globalThis.TextEncoder} */
|
|
45
53
|
class TextEncoderP {
|
|
46
54
|
get encoding() { return "utf-8"; }
|
|
47
55
|
encode(input = "") {
|
|
48
|
-
|
|
56
|
+
let _input = "" + input;
|
|
57
|
+
return encodeText(_input).encoded;
|
|
49
58
|
}
|
|
50
|
-
encodeInto(
|
|
51
|
-
|
|
59
|
+
encodeInto(...args) {
|
|
60
|
+
const [source, destination] = args;
|
|
61
|
+
checkArgsLength(args, 2, "TextEncoder", "encodeInto");
|
|
62
|
+
let _source = "" + source;
|
|
63
|
+
if (!(destination instanceof Uint8Array)) {
|
|
64
|
+
throw new TypeError("Failed to execute 'encodeInto' on 'TextEncoder': parameter 2 is not of type 'Uint8Array'.");
|
|
65
|
+
}
|
|
66
|
+
let result = encodeText(_source, destination);
|
|
52
67
|
return { read: result.read, written: result.written };
|
|
53
68
|
}
|
|
54
|
-
toString() { return "[object TextEncoder]"; }
|
|
55
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
|
|
69
|
+
/** @internal */ toString() { return "[object TextEncoder]"; }
|
|
70
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
|
|
56
71
|
}
|
|
57
|
-
|
|
72
|
+
Class_setStringTag(TextEncoderP, "TextEncoder");
|
|
58
73
|
function encodeText(input, destination) {
|
|
59
74
|
const HAS_DESTINATION = typeof destination !== "undefined";
|
|
60
75
|
let pos = 0;
|
|
@@ -64,26 +79,34 @@ function encodeText(input, destination) {
|
|
|
64
79
|
let tlen = Math.max(32, len + (len >> 1) + 7); // 1.5x size
|
|
65
80
|
let target = HAS_DESTINATION ? destination : new Uint8Array((tlen >> 3) << 3); // ... but at 8 byte offset
|
|
66
81
|
while (pos < len) {
|
|
67
|
-
let value = input.charCodeAt(pos
|
|
82
|
+
let value = input.charCodeAt(pos);
|
|
83
|
+
let codeUnitCount = 1;
|
|
68
84
|
if (value >= 0xd800 && value <= 0xdbff) {
|
|
69
85
|
// high surrogate
|
|
70
|
-
if (pos < len) {
|
|
71
|
-
let extra = input.charCodeAt(pos);
|
|
86
|
+
if (pos + 1 < len) {
|
|
87
|
+
let extra = input.charCodeAt(pos + 1);
|
|
72
88
|
if ((extra & 0xfc00) === 0xdc00) {
|
|
73
|
-
|
|
89
|
+
codeUnitCount = 2;
|
|
90
|
+
pos += 2;
|
|
74
91
|
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
|
75
92
|
}
|
|
76
93
|
else {
|
|
94
|
+
pos += 1;
|
|
77
95
|
value = 0xfffd;
|
|
78
96
|
}
|
|
79
97
|
}
|
|
80
98
|
else {
|
|
99
|
+
pos += 1;
|
|
81
100
|
value = 0xfffd;
|
|
82
101
|
}
|
|
83
102
|
}
|
|
84
103
|
else if (value >= 0xdc00 && value <= 0xdfff) {
|
|
104
|
+
pos += 1;
|
|
85
105
|
value = 0xfffd;
|
|
86
106
|
}
|
|
107
|
+
else {
|
|
108
|
+
pos += 1;
|
|
109
|
+
}
|
|
87
110
|
// expand the buffer if we couldn't write 4 bytes
|
|
88
111
|
if (!HAS_DESTINATION && at + 4 > target.length) {
|
|
89
112
|
tlen += 8; // minimum extra
|
|
@@ -113,28 +136,30 @@ function encodeText(input, destination) {
|
|
|
113
136
|
if (HAS_DESTINATION && at + byteCount > target.length) {
|
|
114
137
|
break;
|
|
115
138
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
switch (byteCount) {
|
|
140
|
+
case 1: // 1-byte
|
|
141
|
+
target[at++] = value; // ASCII
|
|
142
|
+
break;
|
|
143
|
+
case 2: // 2-byte
|
|
144
|
+
target[at++] = ((value >> 6) & 0x1f) | 0xc0;
|
|
145
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
146
|
+
break;
|
|
147
|
+
case 3: // 3-byte
|
|
148
|
+
target[at++] = ((value >> 12) & 0x0f) | 0xe0;
|
|
149
|
+
target[at++] = ((value >> 6) & 0x3f) | 0x80;
|
|
150
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
151
|
+
break;
|
|
152
|
+
case 4: // 4-byte
|
|
153
|
+
target[at++] = ((value >> 18) & 0x07) | 0xf0;
|
|
154
|
+
target[at++] = ((value >> 12) & 0x3f) | 0x80;
|
|
155
|
+
target[at++] = ((value >> 6) & 0x3f) | 0x80;
|
|
156
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
read += codeUnitCount;
|
|
135
160
|
}
|
|
136
161
|
return {
|
|
137
|
-
encoded: !HAS_DESTINATION ? target.slice(0, at) : destination
|
|
162
|
+
encoded: !HAS_DESTINATION ? target.slice(0, at) : destination,
|
|
138
163
|
read: read,
|
|
139
164
|
written: at,
|
|
140
165
|
};
|
|
@@ -144,78 +169,83 @@ const TextEncoderE = g["TextEncoder"] || TextEncoderP;
|
|
|
144
169
|
var _a$a, _b$3;
|
|
145
170
|
/** @internal */
|
|
146
171
|
const state$h = Symbol( /* "TextDecoderState" */);
|
|
172
|
+
/** @type {typeof globalThis.TextDecoder} */
|
|
147
173
|
class TextDecoderP {
|
|
148
|
-
constructor(
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
constructor(label = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
|
|
175
|
+
let _label = "" + label;
|
|
176
|
+
if (["utf-8", "utf8", "unicode-1-1-utf-8"].indexOf(_label.toLowerCase()) === -1) {
|
|
177
|
+
throw new RangeError(`Failed to construct 'TextDecoder': encoding ('${_label}') not implemented.`);
|
|
151
178
|
}
|
|
152
179
|
this[state$h] = new TextDecoderState();
|
|
153
|
-
this[state$h].fatal = fatal;
|
|
154
|
-
this[state$h].ignoreBOM = ignoreBOM;
|
|
180
|
+
this[state$h].fatal = !!fatal;
|
|
181
|
+
this[state$h].ignoreBOM = !!ignoreBOM;
|
|
155
182
|
}
|
|
156
183
|
get encoding() { return "utf-8"; }
|
|
157
184
|
get fatal() { return this[state$h].fatal; }
|
|
158
185
|
get ignoreBOM() { return this[state$h].ignoreBOM; }
|
|
159
|
-
decode(
|
|
160
|
-
const
|
|
161
|
-
let
|
|
162
|
-
if (
|
|
163
|
-
if (
|
|
164
|
-
|
|
186
|
+
decode(input, { stream = false } = {}) {
|
|
187
|
+
const s = this[state$h];
|
|
188
|
+
let bytes;
|
|
189
|
+
if (input !== undefined) {
|
|
190
|
+
if (input instanceof ArrayBuffer) {
|
|
191
|
+
bytes = new Uint8Array(input);
|
|
192
|
+
}
|
|
193
|
+
else if (input instanceof Uint8Array) {
|
|
194
|
+
bytes = input;
|
|
165
195
|
}
|
|
166
|
-
else if (ArrayBuffer.isView(
|
|
167
|
-
|
|
196
|
+
else if (ArrayBuffer.isView(input)) {
|
|
197
|
+
bytes = new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
168
198
|
}
|
|
169
199
|
else {
|
|
170
|
-
|
|
200
|
+
throw new TypeError("Failed to execute 'decode' on 'TextDecoder': parameter 1 is not of type 'ArrayBuffer'.");
|
|
171
201
|
}
|
|
172
202
|
}
|
|
173
203
|
else {
|
|
174
|
-
if (
|
|
204
|
+
if (s[_partial].length > 0) {
|
|
175
205
|
if (this.fatal) {
|
|
206
|
+
s[_partial] = [];
|
|
176
207
|
throw new TypeError("TextDecoder: Incomplete UTF-8 sequence.");
|
|
177
208
|
}
|
|
178
|
-
else {
|
|
179
|
-
that[_partial] = [];
|
|
180
|
-
}
|
|
181
209
|
}
|
|
182
210
|
return "";
|
|
183
211
|
}
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
212
|
+
if (s[_bomDone] < 3) {
|
|
213
|
+
s[_bomDone] += bytes.length;
|
|
214
|
+
if (bytes.length >= 3) {
|
|
215
|
+
if (bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf) {
|
|
216
|
+
bytes = bytes.subarray(3); // × WeChat 2.5.0
|
|
217
|
+
}
|
|
188
218
|
}
|
|
189
219
|
}
|
|
190
|
-
if (
|
|
191
|
-
let merged = new Uint8Array(
|
|
192
|
-
merged.set(
|
|
193
|
-
merged.set(
|
|
194
|
-
|
|
195
|
-
|
|
220
|
+
if (s[_partial].length > 0) {
|
|
221
|
+
let merged = new Uint8Array(s[_partial].length + bytes.length);
|
|
222
|
+
merged.set(s[_partial], 0);
|
|
223
|
+
merged.set(bytes, s[_partial].length);
|
|
224
|
+
bytes = merged;
|
|
225
|
+
s[_partial] = [];
|
|
196
226
|
}
|
|
197
|
-
let end =
|
|
227
|
+
let end = bytes.length;
|
|
198
228
|
let res = [];
|
|
199
|
-
if (stream &&
|
|
200
|
-
let i =
|
|
201
|
-
while (i > 0 && i >
|
|
202
|
-
let byte =
|
|
229
|
+
if (stream && bytes.length > 0) {
|
|
230
|
+
let i = bytes.length;
|
|
231
|
+
while (i > 0 && i > bytes.length - 4) {
|
|
232
|
+
let byte = bytes[i - 1];
|
|
203
233
|
if ((byte & 0b11000000) !== 0b10000000) {
|
|
204
234
|
let len = getBytesPerSequence(byte);
|
|
205
|
-
if (len >
|
|
235
|
+
if (len > bytes.length - (i - 1)) {
|
|
206
236
|
end = i - 1;
|
|
207
237
|
}
|
|
208
238
|
break;
|
|
209
239
|
}
|
|
210
240
|
i--;
|
|
211
241
|
}
|
|
212
|
-
|
|
213
|
-
|
|
242
|
+
s[_partial] = Array.from(bytes.slice(end)); // save tail // × WeChat 2.5.0
|
|
243
|
+
bytes = bytes.slice(0, end); // × WeChat 2.5.0
|
|
214
244
|
}
|
|
215
245
|
let i = 0;
|
|
216
246
|
while (i < end) {
|
|
217
|
-
let firstByte = buf[i];
|
|
218
247
|
let codePoint = null;
|
|
248
|
+
let firstByte = bytes[i];
|
|
219
249
|
let bytesPerSequence = getBytesPerSequence(firstByte);
|
|
220
250
|
if (i + bytesPerSequence <= end) {
|
|
221
251
|
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
@@ -226,7 +256,7 @@ class TextDecoderP {
|
|
|
226
256
|
}
|
|
227
257
|
break;
|
|
228
258
|
case 2:
|
|
229
|
-
secondByte =
|
|
259
|
+
secondByte = bytes[i + 1];
|
|
230
260
|
if ((secondByte & 0xC0) === 0x80) {
|
|
231
261
|
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
232
262
|
if (tempCodePoint > 0x7F) {
|
|
@@ -235,8 +265,8 @@ class TextDecoderP {
|
|
|
235
265
|
}
|
|
236
266
|
break;
|
|
237
267
|
case 3:
|
|
238
|
-
secondByte =
|
|
239
|
-
thirdByte =
|
|
268
|
+
secondByte = bytes[i + 1];
|
|
269
|
+
thirdByte = bytes[i + 2];
|
|
240
270
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
241
271
|
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
242
272
|
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
@@ -245,27 +275,31 @@ class TextDecoderP {
|
|
|
245
275
|
}
|
|
246
276
|
break;
|
|
247
277
|
case 4:
|
|
248
|
-
secondByte =
|
|
249
|
-
thirdByte =
|
|
250
|
-
fourthByte =
|
|
278
|
+
secondByte = bytes[i + 1];
|
|
279
|
+
thirdByte = bytes[i + 2];
|
|
280
|
+
fourthByte = bytes[i + 3];
|
|
251
281
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
252
282
|
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
253
283
|
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
254
284
|
codePoint = tempCodePoint;
|
|
255
285
|
}
|
|
256
286
|
}
|
|
287
|
+
break;
|
|
257
288
|
}
|
|
258
289
|
}
|
|
259
290
|
if (codePoint === null) {
|
|
260
291
|
if (this.fatal) {
|
|
292
|
+
s[_partial] = [];
|
|
261
293
|
throw new TypeError("TextDecoder.decode: Decoding failed.");
|
|
262
294
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
codePoint = 0xFFFD;
|
|
267
|
-
bytesPerSequence = 1;
|
|
295
|
+
let skip = 1;
|
|
296
|
+
while (i + skip < end && (bytes[i + skip] & 0b11000000) === 0b10000000) {
|
|
297
|
+
skip += 1;
|
|
268
298
|
}
|
|
299
|
+
// we did not generate a valid codePoint so insert a replacement char (U+FFFD)
|
|
300
|
+
res.push(0xFFFD);
|
|
301
|
+
i += skip;
|
|
302
|
+
continue;
|
|
269
303
|
}
|
|
270
304
|
else if (codePoint > 0xFFFF) {
|
|
271
305
|
// encode to utf16 (surrogate pair dance)
|
|
@@ -276,101 +310,262 @@ class TextDecoderP {
|
|
|
276
310
|
res.push(codePoint);
|
|
277
311
|
i += bytesPerSequence;
|
|
278
312
|
}
|
|
279
|
-
|
|
280
|
-
for (let j = 0, len = res.length; j < len; j += 0x1000) {
|
|
281
|
-
str += String.fromCharCode.apply(String, res.slice(j, j + 0x1000));
|
|
282
|
-
}
|
|
283
|
-
return str;
|
|
313
|
+
return res.length > 0x4000 ? buildString(res) : concatString(res);
|
|
284
314
|
}
|
|
285
|
-
toString() { return "[object TextDecoder]"; }
|
|
286
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
|
|
315
|
+
/** @internal */ toString() { return "[object TextDecoder]"; }
|
|
316
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
|
|
287
317
|
}
|
|
288
|
-
|
|
289
|
-
/** @internal */ const
|
|
318
|
+
Class_setStringTag(TextDecoderP, "TextDecoder");
|
|
319
|
+
/** @internal */ const _bomDone = Symbol();
|
|
290
320
|
/** @internal */ const _partial = Symbol();
|
|
291
321
|
/** @internal */
|
|
292
322
|
class TextDecoderState {
|
|
293
323
|
constructor() {
|
|
294
324
|
this.fatal = false;
|
|
295
325
|
this.ignoreBOM = false;
|
|
296
|
-
this[_a$a] =
|
|
326
|
+
this[_a$a] = 0;
|
|
297
327
|
this[_b$3] = [];
|
|
298
328
|
}
|
|
299
329
|
}
|
|
300
|
-
_a$a =
|
|
301
|
-
const UTF8Labels = ["utf-8", "utf8", "unicode-1-1-utf-8"];
|
|
330
|
+
_a$a = _bomDone, _b$3 = _partial;
|
|
302
331
|
function getBytesPerSequence(byte) {
|
|
303
332
|
return (byte > 0xEF) ? 4 : (byte > 0xDF) ? 3 : (byte > 0xBF) ? 2 : 1;
|
|
304
333
|
}
|
|
334
|
+
const buildString = (res) => {
|
|
335
|
+
let arr = [];
|
|
336
|
+
for (let i = 0, len = res.length; i < len; i += 0x1000) {
|
|
337
|
+
arr.push(String.fromCharCode.apply(String, res.slice(i, i + 0x1000)));
|
|
338
|
+
}
|
|
339
|
+
return arr.join("");
|
|
340
|
+
};
|
|
341
|
+
const concatString = (res) => {
|
|
342
|
+
let str = "";
|
|
343
|
+
for (let i = 0, len = res.length; i < len; i += 0x1000) {
|
|
344
|
+
str += String.fromCharCode.apply(String, res.slice(i, i + 0x1000));
|
|
345
|
+
}
|
|
346
|
+
return str;
|
|
347
|
+
};
|
|
305
348
|
const TextDecoderE = g["TextDecoder"] || TextDecoderP;
|
|
306
349
|
|
|
307
|
-
var _a$9, _b$2, _c$1, _d$1, _e$1, _f$1;
|
|
308
350
|
/** @internal */
|
|
309
|
-
const state$g = Symbol( /* "
|
|
351
|
+
const state$g = Symbol( /* "BlobState" */);
|
|
352
|
+
/** @type {typeof globalThis.Blob} */
|
|
353
|
+
class BlobP {
|
|
354
|
+
constructor(blobParts = [], options) {
|
|
355
|
+
if (!(Array.isArray(blobParts) || (blobParts && typeof blobParts === "object" && Symbol.iterator in blobParts))) {
|
|
356
|
+
throw new TypeError("Failed to construct 'Blob/File': The provided value cannot be converted to a sequence.");
|
|
357
|
+
}
|
|
358
|
+
let _blobParts = Array.isArray(blobParts) ? blobParts : Array.from(blobParts);
|
|
359
|
+
let chunks = [];
|
|
360
|
+
for (let i = 0; i < _blobParts.length; ++i) {
|
|
361
|
+
let chunk = _blobParts[i];
|
|
362
|
+
if (isPolyfillType("Blob", chunk)) {
|
|
363
|
+
chunks.push(chunk[state$g][_buffer]);
|
|
364
|
+
}
|
|
365
|
+
else if (chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk)) {
|
|
366
|
+
chunks.push(BufferSource_toUint8Array(chunk));
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
chunks.push(encode$1("" + chunk));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
this[state$g] = new BlobState(concat(chunks));
|
|
373
|
+
const s = this[state$g];
|
|
374
|
+
s.size = s[_buffer].length;
|
|
375
|
+
let rawType = "" + ((options === null || options === void 0 ? void 0 : options.type) || "");
|
|
376
|
+
s.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
|
|
377
|
+
}
|
|
378
|
+
get size() { return this[state$g].size; }
|
|
379
|
+
get type() { return this[state$g].type; }
|
|
380
|
+
arrayBuffer() {
|
|
381
|
+
return Promise.resolve(clone(this[state$g][_buffer].buffer).buffer);
|
|
382
|
+
}
|
|
383
|
+
bytes() {
|
|
384
|
+
return Promise.resolve(clone(this[state$g][_buffer].buffer));
|
|
385
|
+
}
|
|
386
|
+
slice(start, end, contentType) {
|
|
387
|
+
let sliced = this[state$g][_buffer].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$g][_buffer].length); // × WeChat 2.5.0
|
|
388
|
+
return new BlobP([sliced], { type: "" + (contentType !== null && contentType !== void 0 ? contentType : "") });
|
|
389
|
+
}
|
|
390
|
+
stream() {
|
|
391
|
+
throw new TypeError("Failed to execute 'stream' on 'Blob': method not implemented.");
|
|
392
|
+
}
|
|
393
|
+
text() {
|
|
394
|
+
return Promise.resolve(decode$1(this[state$g][_buffer]));
|
|
395
|
+
}
|
|
396
|
+
/** @internal */ toString() { return "[object Blob]"; }
|
|
397
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
|
|
398
|
+
}
|
|
399
|
+
Class_setStringTag(BlobP, "Blob");
|
|
400
|
+
/** @internal */
|
|
401
|
+
const _buffer = Symbol();
|
|
402
|
+
/** @internal */
|
|
403
|
+
class BlobState {
|
|
404
|
+
constructor(buffer) {
|
|
405
|
+
this.size = 0;
|
|
406
|
+
this.type = "";
|
|
407
|
+
this[_buffer] = buffer;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/** @internal */
|
|
411
|
+
function Blob_toUint8Array(blob) {
|
|
412
|
+
return blob[state$g][_buffer];
|
|
413
|
+
}
|
|
414
|
+
function BufferSource_toUint8Array(buf) {
|
|
415
|
+
return buf instanceof ArrayBuffer
|
|
416
|
+
? new Uint8Array(buf)
|
|
417
|
+
: new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
418
|
+
}
|
|
419
|
+
function clone(buf) {
|
|
420
|
+
let sourceArray = BufferSource_toUint8Array(buf);
|
|
421
|
+
let cloneArray = new Uint8Array(new ArrayBuffer(sourceArray.byteLength));
|
|
422
|
+
cloneArray.set(sourceArray);
|
|
423
|
+
return cloneArray;
|
|
424
|
+
}
|
|
425
|
+
function concat(chunks) {
|
|
426
|
+
let totalByteLength = chunks.reduce((acc, cur) => acc + cur.byteLength, 0);
|
|
427
|
+
let result = new Uint8Array(totalByteLength);
|
|
428
|
+
chunks.reduce((offset, chunk) => {
|
|
429
|
+
result.set(chunk, offset);
|
|
430
|
+
return offset + chunk.byteLength;
|
|
431
|
+
}, 0);
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
/** @internal */
|
|
435
|
+
function encode$1(str) {
|
|
436
|
+
let encoder = new TextEncoderP();
|
|
437
|
+
return encoder.encode(str);
|
|
438
|
+
}
|
|
439
|
+
/** @internal */
|
|
440
|
+
function decode$1(buf) {
|
|
441
|
+
let decoder = new TextDecoderP();
|
|
442
|
+
return decoder.decode(buf);
|
|
443
|
+
}
|
|
444
|
+
/** @internal */
|
|
445
|
+
function Uint8Array_toBase64(input) {
|
|
446
|
+
let byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
447
|
+
let output = [];
|
|
448
|
+
for (var i = 0; i < input.length; i += 3) {
|
|
449
|
+
let byte1 = input[i];
|
|
450
|
+
let haveByte2 = i + 1 < input.length;
|
|
451
|
+
let byte2 = haveByte2 ? input[i + 1] : 0;
|
|
452
|
+
let haveByte3 = i + 2 < input.length;
|
|
453
|
+
let byte3 = haveByte3 ? input[i + 2] : 0;
|
|
454
|
+
let outByte1 = byte1 >> 2;
|
|
455
|
+
let outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
|
|
456
|
+
let outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6);
|
|
457
|
+
let outByte4 = byte3 & 0x3F;
|
|
458
|
+
if (!haveByte3) {
|
|
459
|
+
outByte4 = 64;
|
|
460
|
+
if (!haveByte2) {
|
|
461
|
+
outByte3 = 64;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
|
|
465
|
+
}
|
|
466
|
+
return output.join("");
|
|
467
|
+
}
|
|
468
|
+
const BlobE = g["Blob"] || BlobP;
|
|
469
|
+
|
|
470
|
+
/** @internal */
|
|
471
|
+
const state$f = Symbol( /* "FileState" */);
|
|
472
|
+
/** @type {typeof globalThis.File} */
|
|
473
|
+
class FileP extends BlobP {
|
|
474
|
+
constructor(...args) {
|
|
475
|
+
const [fileBits, fileName, options] = args;
|
|
476
|
+
checkArgsLength(args, 2, "File");
|
|
477
|
+
super(fileBits, options);
|
|
478
|
+
this[state$f] = new FileState();
|
|
479
|
+
this[state$f].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date()) || 0;
|
|
480
|
+
this[state$f].name = "" + fileName;
|
|
481
|
+
}
|
|
482
|
+
get lastModified() { return this[state$f].lastModified; }
|
|
483
|
+
get name() { return this[state$f].name; }
|
|
484
|
+
get webkitRelativePath() { return ""; }
|
|
485
|
+
/** @internal */ toString() { return "[object File]"; }
|
|
486
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
|
|
487
|
+
}
|
|
488
|
+
Class_setStringTag(FileP, "File");
|
|
489
|
+
/** @internal */
|
|
490
|
+
class FileState {
|
|
491
|
+
constructor() {
|
|
492
|
+
this.lastModified = 0;
|
|
493
|
+
this.name = "";
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const FileE = g["Blob"] ? g["File"] : FileP;
|
|
497
|
+
|
|
498
|
+
var _a$9, _b$2, _c$1, _d$1, _e$1;
|
|
499
|
+
/** @internal */ const state$e = Symbol( /* "EventState" */);
|
|
500
|
+
/** @type {typeof globalThis.Event} */
|
|
310
501
|
class EventP {
|
|
311
|
-
constructor(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
502
|
+
constructor(...args) {
|
|
503
|
+
const [type, eventInitDict] = args;
|
|
504
|
+
checkArgsLength(args, 1, new.target.name);
|
|
505
|
+
this[state$e] = new EventState();
|
|
506
|
+
const s = this[state$e];
|
|
507
|
+
s.type = "" + type;
|
|
508
|
+
s.bubbles = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.bubbles);
|
|
509
|
+
s.cancelable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.cancelable);
|
|
510
|
+
s.composed = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.composed);
|
|
318
511
|
Object.defineProperty(this, "isTrusted", {
|
|
319
512
|
enumerable: true,
|
|
320
|
-
get: (function isTrusted() { return this[state$
|
|
513
|
+
get: (function isTrusted() { return this[state$e][_isTrusted]; }).bind(this),
|
|
321
514
|
});
|
|
322
515
|
}
|
|
323
|
-
get type() { return this[state$
|
|
324
|
-
get bubbles() { return this[state$
|
|
325
|
-
get cancelable() { return this[state$
|
|
326
|
-
get composed() { return this[state$
|
|
327
|
-
get target() { return this[state$
|
|
328
|
-
get currentTarget() { return this[state$
|
|
329
|
-
get eventPhase() { return this[state$
|
|
330
|
-
get srcElement() { return this[state$
|
|
331
|
-
get cancelBubble() { return this[state$
|
|
332
|
-
set cancelBubble(value) { this[state$
|
|
333
|
-
get defaultPrevented() { return this[state$
|
|
334
|
-
get returnValue() { return this[state$
|
|
516
|
+
get type() { return this[state$e].type; }
|
|
517
|
+
get bubbles() { return this[state$e].bubbles; }
|
|
518
|
+
get cancelable() { return this[state$e].cancelable; }
|
|
519
|
+
get composed() { return this[state$e].composed; }
|
|
520
|
+
get target() { return this[state$e].target; }
|
|
521
|
+
get currentTarget() { return this[state$e].currentTarget; }
|
|
522
|
+
get eventPhase() { return this[state$e].eventPhase; }
|
|
523
|
+
get srcElement() { return this[state$e].target; }
|
|
524
|
+
get cancelBubble() { return this[state$e].cancelBubble; }
|
|
525
|
+
set cancelBubble(value) { this[state$e].cancelBubble = !!value; }
|
|
526
|
+
get defaultPrevented() { return this[state$e].defaultPrevented; }
|
|
527
|
+
get returnValue() { return this[state$e].returnValue; }
|
|
335
528
|
set returnValue(value) { if (!value) {
|
|
336
529
|
this.preventDefault();
|
|
337
530
|
} }
|
|
338
|
-
get timeStamp() { return this[state$
|
|
531
|
+
get timeStamp() { return this[state$e].timeStamp; }
|
|
339
532
|
composedPath() {
|
|
340
533
|
let path = !!this.target ? [this.target] : [];
|
|
341
534
|
if (!!this.currentTarget && this.currentTarget !== this.target)
|
|
342
535
|
path.push(this.currentTarget);
|
|
343
536
|
return path;
|
|
344
537
|
}
|
|
345
|
-
initEvent(
|
|
346
|
-
const
|
|
347
|
-
|
|
538
|
+
initEvent(...args) {
|
|
539
|
+
const [type, bubbles, cancelable] = args;
|
|
540
|
+
checkArgsLength(args, 1, "Event", "initEvent");
|
|
541
|
+
const s = this[state$e];
|
|
542
|
+
if (s[_dispatched])
|
|
348
543
|
return;
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
544
|
+
s.type = "" + type;
|
|
545
|
+
s.bubbles = !!bubbles;
|
|
546
|
+
s.cancelable = !!cancelable;
|
|
352
547
|
}
|
|
353
548
|
preventDefault() {
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
549
|
+
const s = this[state$e];
|
|
550
|
+
if (s[_passive]) {
|
|
356
551
|
console.warn(`Ignoring 'preventDefault()' call on event of type '${this.type}' from a listener registered as 'passive'.`);
|
|
357
552
|
return;
|
|
358
553
|
}
|
|
359
554
|
if (this.cancelable) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
555
|
+
s[_preventDefaultCalled] = true;
|
|
556
|
+
s.defaultPrevented = true;
|
|
557
|
+
s.returnValue = false;
|
|
363
558
|
}
|
|
364
559
|
}
|
|
365
560
|
stopImmediatePropagation() {
|
|
366
|
-
this[state$
|
|
561
|
+
this[state$e][_stopImmediatePropagationCalled] = true;
|
|
367
562
|
this.cancelBubble = true;
|
|
368
563
|
}
|
|
369
564
|
stopPropagation() {
|
|
370
565
|
this.cancelBubble = true;
|
|
371
566
|
}
|
|
372
|
-
toString() { return "[object Event]"; }
|
|
373
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
|
|
567
|
+
/** @internal */ toString() { return "[object Event]"; }
|
|
568
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
|
|
374
569
|
}
|
|
375
570
|
const properties$2 = {
|
|
376
571
|
NONE: { value: 0, enumerable: true },
|
|
@@ -380,13 +575,13 @@ const properties$2 = {
|
|
|
380
575
|
};
|
|
381
576
|
Object.defineProperties(EventP, properties$2);
|
|
382
577
|
Object.defineProperties(EventP.prototype, properties$2);
|
|
383
|
-
|
|
384
|
-
/** @internal */ const
|
|
385
|
-
const _isTrusted = Symbol();
|
|
386
|
-
const _passive = Symbol();
|
|
387
|
-
const _dispatched = Symbol();
|
|
388
|
-
const _preventDefaultCalled = Symbol();
|
|
389
|
-
const _stopImmediatePropagationCalled = Symbol();
|
|
578
|
+
Class_setStringTag(EventP, "Event");
|
|
579
|
+
/** @internal */ const _timeStamp = (new Date()).getTime();
|
|
580
|
+
/** @internal */ const _isTrusted = Symbol();
|
|
581
|
+
/** @internal */ const _passive = Symbol();
|
|
582
|
+
/** @internal */ const _dispatched = Symbol();
|
|
583
|
+
/** @internal */ const _preventDefaultCalled = Symbol();
|
|
584
|
+
/** @internal */ const _stopImmediatePropagationCalled = Symbol();
|
|
390
585
|
/** @internal */
|
|
391
586
|
class EventState {
|
|
392
587
|
constructor() {
|
|
@@ -400,139 +595,202 @@ class EventState {
|
|
|
400
595
|
this.cancelBubble = false;
|
|
401
596
|
this.defaultPrevented = false;
|
|
402
597
|
this.returnValue = true;
|
|
403
|
-
this.timeStamp = (new Date()).getTime() -
|
|
598
|
+
this.timeStamp = (new Date()).getTime() - _timeStamp;
|
|
599
|
+
this[_a$9] = false;
|
|
404
600
|
this[_b$2] = false;
|
|
405
601
|
this[_c$1] = false;
|
|
406
602
|
this[_d$1] = false;
|
|
407
603
|
this[_e$1] = false;
|
|
408
|
-
this[_f$1] = false;
|
|
409
604
|
}
|
|
410
605
|
}
|
|
411
|
-
_a$9 =
|
|
412
|
-
|
|
606
|
+
_a$9 = _isTrusted, _b$2 = _passive, _c$1 = _dispatched, _d$1 = _preventDefaultCalled, _e$1 = _stopImmediatePropagationCalled;
|
|
607
|
+
/** @internal */
|
|
608
|
+
function Event_setTrusted(event, isTrusted) {
|
|
609
|
+
Object.defineProperty(event[state$e], _isTrusted, {
|
|
610
|
+
value: isTrusted,
|
|
611
|
+
writable: true,
|
|
612
|
+
enumerable: true,
|
|
613
|
+
configurable: true,
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
const passive$1 = 0;
|
|
617
|
+
const dispatched$2 = 1;
|
|
618
|
+
const preventDefaultCalled$1 = 2;
|
|
619
|
+
const stopImmediatePropagationCalled$1 = 3;
|
|
620
|
+
/** @internal */
|
|
621
|
+
function Event_getEtField(event, field) {
|
|
622
|
+
const s = event[state$e];
|
|
623
|
+
switch (field) {
|
|
624
|
+
case passive$1:
|
|
625
|
+
return s[_passive];
|
|
626
|
+
case dispatched$2:
|
|
627
|
+
return s[_dispatched];
|
|
628
|
+
case preventDefaultCalled$1:
|
|
629
|
+
return s[_preventDefaultCalled];
|
|
630
|
+
case stopImmediatePropagationCalled$1:
|
|
631
|
+
return s[_stopImmediatePropagationCalled];
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
/** @internal */
|
|
635
|
+
function Event_setEtField(event, field, value) {
|
|
636
|
+
const s = event[state$e];
|
|
637
|
+
switch (field) {
|
|
638
|
+
case passive$1:
|
|
639
|
+
s[_passive] = value;
|
|
640
|
+
break;
|
|
641
|
+
case dispatched$2:
|
|
642
|
+
s[_dispatched] = value;
|
|
643
|
+
break;
|
|
644
|
+
case preventDefaultCalled$1:
|
|
645
|
+
s[_preventDefaultCalled] = value;
|
|
646
|
+
break;
|
|
647
|
+
case stopImmediatePropagationCalled$1:
|
|
648
|
+
s[_stopImmediatePropagationCalled] = value;
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
/** @internal */
|
|
413
653
|
function createInnerEvent(target, type, eventInitDict, isTrusted = true) {
|
|
414
654
|
let event = new EventP(type, eventInitDict);
|
|
415
|
-
event[state$
|
|
416
|
-
event[state$
|
|
655
|
+
event[state$e].target = target;
|
|
656
|
+
event[state$e][_isTrusted] = isTrusted;
|
|
417
657
|
return event;
|
|
418
658
|
}
|
|
419
659
|
const EventE = g["EventTarget"] ? g["Event"] : EventP;
|
|
420
660
|
|
|
421
661
|
var _a$8;
|
|
422
|
-
|
|
423
|
-
const
|
|
662
|
+
const passive = 0;
|
|
663
|
+
const dispatched$1 = 1;
|
|
664
|
+
const preventDefaultCalled = 2;
|
|
665
|
+
const stopImmediatePropagationCalled = 3;
|
|
666
|
+
/** @internal */ const state$d = Symbol( /* "EventTargetState" */);
|
|
667
|
+
/** @type {typeof globalThis.EventTarget} */
|
|
424
668
|
class EventTargetP {
|
|
425
669
|
constructor() {
|
|
426
|
-
this[state$
|
|
670
|
+
this[state$d] = new EventTargetState(this);
|
|
671
|
+
this[state$d].name = new.target.name;
|
|
427
672
|
}
|
|
428
|
-
addEventListener(
|
|
429
|
-
const
|
|
673
|
+
addEventListener(...args) {
|
|
674
|
+
const [type, callback, options] = args;
|
|
675
|
+
checkArgsLength(args, 2, this[state$d].name, "addEventListener");
|
|
676
|
+
if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
|
|
677
|
+
throw new TypeError(`Failed to execute 'addEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
|
|
678
|
+
}
|
|
679
|
+
const s = this[state$d];
|
|
430
680
|
const executor = new Executor(type, callback);
|
|
431
681
|
executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
|
|
432
|
-
if (!
|
|
433
|
-
if (typeof options === "object") {
|
|
682
|
+
if (!s[_executors].some(x => x.equals(executor))) {
|
|
683
|
+
if (options && typeof options === "object") {
|
|
434
684
|
const { once, passive, signal } = options;
|
|
435
685
|
executor.options.once = !!once;
|
|
436
686
|
executor.options.passive = !!passive;
|
|
437
687
|
if (signal) {
|
|
438
688
|
executor.options.signal = signal;
|
|
439
|
-
reply
|
|
689
|
+
reply(this, signal, executor);
|
|
440
690
|
}
|
|
441
691
|
}
|
|
442
|
-
|
|
692
|
+
s[_executors].push(executor);
|
|
443
693
|
const f = (v) => !!v.options.capture ? 0 : 1;
|
|
444
|
-
|
|
694
|
+
s[_executors] = s[_executors].sort((a, b) => f(a) - f(b));
|
|
445
695
|
}
|
|
446
696
|
}
|
|
447
|
-
dispatchEvent(
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
697
|
+
dispatchEvent(...args) {
|
|
698
|
+
const [event] = args;
|
|
699
|
+
checkArgsLength(args, 1, this[state$d].name, "dispatchEvent");
|
|
451
700
|
if (!(event instanceof EventP)) {
|
|
452
|
-
throw new TypeError(
|
|
701
|
+
throw new TypeError(`Failed to execute 'dispatchEvent' on '${this[state$d].name}': parameter 1 is not of type 'Event'.`);
|
|
453
702
|
}
|
|
454
|
-
event
|
|
455
|
-
|
|
456
|
-
return
|
|
703
|
+
Event_setTrusted(event, false);
|
|
704
|
+
event[state$e].target = this;
|
|
705
|
+
return EventTarget_fire(this, event);
|
|
457
706
|
}
|
|
458
|
-
removeEventListener(
|
|
459
|
-
const
|
|
707
|
+
removeEventListener(...args) {
|
|
708
|
+
const [type, callback, options] = args;
|
|
709
|
+
checkArgsLength(args, 2, this[state$d].name, "removeEventListener");
|
|
710
|
+
if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
|
|
711
|
+
throw new TypeError(`Failed to execute 'removeEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
|
|
712
|
+
}
|
|
713
|
+
const s = this[state$d];
|
|
460
714
|
const executor = new Executor(type, callback);
|
|
461
715
|
executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
|
|
462
|
-
if (
|
|
463
|
-
|
|
716
|
+
if (s[_executors].some(x => x.equals(executor))) {
|
|
717
|
+
s[_executors] = s[_executors].filter(x => !x.equals(executor));
|
|
464
718
|
}
|
|
465
719
|
}
|
|
466
|
-
toString() { return "[object EventTarget]"; }
|
|
467
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
|
|
720
|
+
/** @internal */ toString() { return "[object EventTarget]"; }
|
|
721
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
|
|
468
722
|
}
|
|
469
|
-
|
|
723
|
+
Class_setStringTag(EventTargetP, "EventTarget");
|
|
470
724
|
/** @internal */
|
|
471
725
|
const _executors = Symbol();
|
|
472
726
|
/** @internal */
|
|
473
727
|
class EventTargetState {
|
|
474
728
|
constructor(target) {
|
|
729
|
+
this.name = "EventTarget";
|
|
475
730
|
this[_a$8] = [];
|
|
476
731
|
this.target = target;
|
|
477
732
|
}
|
|
478
733
|
}
|
|
479
734
|
_a$8 = _executors;
|
|
480
|
-
|
|
481
|
-
|
|
735
|
+
/** @internal */
|
|
736
|
+
function EventTarget_fire(target, event) {
|
|
737
|
+
const s = target[state$d];
|
|
738
|
+
const evs = event[state$e];
|
|
482
739
|
if (!event.target)
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
740
|
+
evs.target = target;
|
|
741
|
+
evs.currentTarget = target;
|
|
742
|
+
evs.eventPhase = EventP.AT_TARGET;
|
|
743
|
+
Event_setEtField(event, dispatched$1, true);
|
|
487
744
|
let onceIndexes = [];
|
|
488
|
-
for (let i = 0; i <
|
|
489
|
-
|
|
745
|
+
for (let i = 0; i < s[_executors].length; ++i) {
|
|
746
|
+
if (Event_getEtField(event, stopImmediatePropagationCalled))
|
|
747
|
+
break;
|
|
748
|
+
let executor = s[_executors][i];
|
|
490
749
|
if (executor.type !== event.type)
|
|
491
750
|
continue;
|
|
492
|
-
s[_passive] = !!executor.options.passive;
|
|
493
751
|
if (executor.options.once)
|
|
494
752
|
onceIndexes.push(i);
|
|
495
|
-
|
|
753
|
+
Event_setEtField(event, passive, !!executor.options.passive);
|
|
496
754
|
try {
|
|
755
|
+
let cb = executor.callback;
|
|
497
756
|
if (typeof cb === "function")
|
|
498
|
-
cb.call(
|
|
757
|
+
cb.call(target, event);
|
|
499
758
|
}
|
|
500
759
|
catch (e) {
|
|
501
760
|
console.error(e);
|
|
502
761
|
}
|
|
503
|
-
|
|
504
|
-
if (s[_stopImmediatePropagationCalled])
|
|
505
|
-
break;
|
|
762
|
+
Event_setEtField(event, passive, false);
|
|
506
763
|
}
|
|
507
764
|
if (onceIndexes.length > 0) {
|
|
508
|
-
|
|
765
|
+
s[_executors] = s[_executors].reduce((acc, cur, index) => {
|
|
509
766
|
if (onceIndexes.indexOf(index) === -1)
|
|
510
767
|
acc.push(cur);
|
|
511
768
|
return acc;
|
|
512
769
|
}, []);
|
|
513
770
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
return !(event.cancelable &&
|
|
771
|
+
evs.currentTarget = null;
|
|
772
|
+
evs.eventPhase = EventP.NONE;
|
|
773
|
+
Event_setEtField(event, dispatched$1, false);
|
|
774
|
+
return !(event.cancelable && Event_getEtField(event, preventDefaultCalled));
|
|
518
775
|
}
|
|
519
|
-
function reply(signal, executor) {
|
|
776
|
+
function reply(target, signal, executor) {
|
|
777
|
+
const s = target[state$d];
|
|
520
778
|
const onAbort = () => {
|
|
521
|
-
|
|
779
|
+
s[_executors] = s[_executors].filter(x => !x.equals(executor));
|
|
522
780
|
signal.removeEventListener("abort", onAbort);
|
|
523
781
|
};
|
|
524
782
|
try {
|
|
525
783
|
signal.addEventListener("abort", onAbort);
|
|
526
784
|
}
|
|
527
785
|
catch (e) {
|
|
528
|
-
console.
|
|
786
|
+
console.warn(e);
|
|
529
787
|
}
|
|
530
788
|
}
|
|
531
789
|
/** @internal */
|
|
532
790
|
class Executor {
|
|
533
791
|
constructor(type, callback) {
|
|
534
792
|
this.options = {};
|
|
535
|
-
this.type =
|
|
793
|
+
this.type = "" + type;
|
|
536
794
|
this.callback = extract(callback);
|
|
537
795
|
}
|
|
538
796
|
equals(executor) {
|
|
@@ -554,64 +812,52 @@ function extract(cb) {
|
|
|
554
812
|
function isEventListenerObject(cb) {
|
|
555
813
|
return !!cb && "handleEvent" in cb && typeof cb.handleEvent === "function";
|
|
556
814
|
}
|
|
557
|
-
|
|
815
|
+
/** @internal */
|
|
816
|
+
function attachFn(target, type, cb, listener) {
|
|
558
817
|
if (typeof cb === "function") {
|
|
559
|
-
|
|
818
|
+
target.addEventListener(type, listener);
|
|
560
819
|
}
|
|
561
820
|
else {
|
|
562
|
-
|
|
821
|
+
target.removeEventListener(type, listener);
|
|
563
822
|
}
|
|
564
823
|
}
|
|
565
|
-
|
|
824
|
+
/** @internal */
|
|
825
|
+
function executeFn(target, cb, ev) {
|
|
566
826
|
if (typeof cb === "function")
|
|
567
|
-
cb.call(
|
|
827
|
+
cb.call(target, ev);
|
|
568
828
|
}
|
|
569
829
|
const EventTargetE = g["EventTarget"] || EventTargetP;
|
|
570
830
|
|
|
571
831
|
/** @internal */
|
|
572
|
-
const state$
|
|
573
|
-
|
|
574
|
-
constructor(type, eventInitDict) {
|
|
575
|
-
var _a;
|
|
576
|
-
super(type, eventInitDict);
|
|
577
|
-
this[state$e] = new CustomEventState();
|
|
578
|
-
this[state$e].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
|
|
579
|
-
}
|
|
580
|
-
get detail() { return this[state$e].detail; }
|
|
581
|
-
initCustomEvent(type, bubbles, cancelable, detail) {
|
|
582
|
-
if (this[state$g][_dispatched])
|
|
583
|
-
return;
|
|
584
|
-
this.initEvent(type, bubbles, cancelable);
|
|
585
|
-
this[state$e].detail = detail !== null && detail !== void 0 ? detail : null;
|
|
586
|
-
}
|
|
587
|
-
toString() { return "[object CustomEvent]"; }
|
|
588
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
|
|
589
|
-
}
|
|
590
|
-
defineStringTag(CustomEventP, "CustomEvent");
|
|
591
|
-
/** @internal */
|
|
592
|
-
class CustomEventState {
|
|
593
|
-
}
|
|
594
|
-
const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
|
|
595
|
-
|
|
596
|
-
/** @internal */
|
|
597
|
-
const state$d = Symbol( /* "ProgressEventState" */);
|
|
832
|
+
const state$c = Symbol( /* "ProgressEventState" */);
|
|
833
|
+
/** @type {typeof globalThis.ProgressEvent} */
|
|
598
834
|
class ProgressEventP extends EventP {
|
|
599
835
|
constructor(type, eventInitDict) {
|
|
600
836
|
var _a, _b;
|
|
601
837
|
super(type, eventInitDict);
|
|
602
|
-
this[state$
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
838
|
+
this[state$c] = new ProgressEventState();
|
|
839
|
+
const s = this[state$c];
|
|
840
|
+
s.lengthComputable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lengthComputable);
|
|
841
|
+
s.loaded = Number((_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.loaded) !== null && _a !== void 0 ? _a : 0);
|
|
842
|
+
s.total = Number((_b = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.total) !== null && _b !== void 0 ? _b : 0);
|
|
843
|
+
let errField = "";
|
|
844
|
+
if (isNaN(s.loaded)) {
|
|
845
|
+
errField = "loaded";
|
|
846
|
+
}
|
|
847
|
+
if (isNaN(s.total)) {
|
|
848
|
+
errField = "total";
|
|
849
|
+
}
|
|
850
|
+
if (errField) {
|
|
851
|
+
throw new TypeError(`Failed to construct 'ProgressEvent': Failed to read the '${errField}' property from 'ProgressEventInit': The provided double value is non-finite.`);
|
|
852
|
+
}
|
|
607
853
|
}
|
|
608
|
-
get lengthComputable() { return getValue(this[state$
|
|
609
|
-
get loaded() { return getValue(this[state$
|
|
610
|
-
get total() { return getValue(this[state$
|
|
611
|
-
toString() { return "[object ProgressEvent]"; }
|
|
612
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
|
|
854
|
+
get lengthComputable() { return getValue(this[state$c].lengthComputable); }
|
|
855
|
+
get loaded() { return getValue(this[state$c].loaded); }
|
|
856
|
+
get total() { return getValue(this[state$c].total); }
|
|
857
|
+
/** @internal */ toString() { return "[object ProgressEvent]"; }
|
|
858
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
|
|
613
859
|
}
|
|
614
|
-
|
|
860
|
+
Class_setStringTag(ProgressEventP, "ProgressEvent");
|
|
615
861
|
/** @internal */
|
|
616
862
|
class ProgressEventState {
|
|
617
863
|
constructor() {
|
|
@@ -625,356 +871,511 @@ function getValue(val) {
|
|
|
625
871
|
}
|
|
626
872
|
function createInnerProgressEvent(target, type, { lengthComputable = false, loaded = 0, total = 0, } = {}) {
|
|
627
873
|
let event = new ProgressEventP(type);
|
|
628
|
-
event[state$
|
|
629
|
-
event[state$
|
|
630
|
-
event[state$
|
|
631
|
-
event[state$
|
|
632
|
-
event
|
|
874
|
+
event[state$c].lengthComputable = lengthComputable;
|
|
875
|
+
event[state$c].loaded = loaded;
|
|
876
|
+
event[state$c].total = total;
|
|
877
|
+
event[state$e].target = target;
|
|
878
|
+
Event_setTrusted(event, true);
|
|
633
879
|
return event;
|
|
634
880
|
}
|
|
881
|
+
/** @internal */
|
|
635
882
|
function emitProcessEvent(target, type, loaded = 0, total = 0) {
|
|
636
883
|
let event = createInnerProgressEvent(target, type, {
|
|
637
884
|
lengthComputable: () => { return getValue(total) > 0; },
|
|
638
885
|
loaded,
|
|
639
886
|
total,
|
|
640
887
|
});
|
|
641
|
-
|
|
888
|
+
EventTarget_fire(target, event);
|
|
642
889
|
}
|
|
643
890
|
const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
|
|
644
891
|
|
|
892
|
+
var _a$7;
|
|
645
893
|
/** @internal */
|
|
646
|
-
const state$
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
894
|
+
const state$b = Symbol( /* "FileReaderState" */);
|
|
895
|
+
/** @type {typeof globalThis.FileReader} */
|
|
896
|
+
class FileReaderP extends EventTargetP {
|
|
897
|
+
constructor() {
|
|
898
|
+
super();
|
|
899
|
+
this[state$b] = new FileReaderState(this);
|
|
900
|
+
}
|
|
901
|
+
get readyState() { return this[state$b].readyState; }
|
|
902
|
+
get result() { return this[state$b].result; }
|
|
903
|
+
get error() { return this[state$b].error; }
|
|
904
|
+
abort() {
|
|
905
|
+
if (this.readyState === FileReaderP.LOADING) {
|
|
906
|
+
const s = this[state$b];
|
|
907
|
+
s.readyState = FileReaderP.DONE;
|
|
908
|
+
s.result = null;
|
|
909
|
+
s.error = new MPException("An ongoing operation was aborted, typically with a call to abort().", "AbortError");
|
|
910
|
+
emitProcessEvent(this, "abort");
|
|
651
911
|
}
|
|
652
|
-
let encoder = null;
|
|
653
|
-
let chunks = blobParts.reduce((chunks, part) => {
|
|
654
|
-
if (isPolyfillType("Blob", part)) {
|
|
655
|
-
chunks.push(part[state$c][_u8array]);
|
|
656
|
-
}
|
|
657
|
-
else if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
658
|
-
chunks.push(convert$1(part));
|
|
659
|
-
}
|
|
660
|
-
else {
|
|
661
|
-
if (!encoder) {
|
|
662
|
-
encoder = new TextEncoderP();
|
|
663
|
-
}
|
|
664
|
-
chunks.push(encoder.encode(String(part)));
|
|
665
|
-
}
|
|
666
|
-
return chunks;
|
|
667
|
-
}, []);
|
|
668
|
-
this[state$c] = new BlobState(concat(chunks));
|
|
669
|
-
const that = this[state$c];
|
|
670
|
-
that.size = that[_u8array].length;
|
|
671
|
-
let rawType = (options === null || options === void 0 ? void 0 : options.type) || "";
|
|
672
|
-
that.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
|
|
673
|
-
}
|
|
674
|
-
get size() { return this[state$c].size; }
|
|
675
|
-
get type() { return this[state$c].type; }
|
|
676
|
-
arrayBuffer() {
|
|
677
|
-
return Promise.resolve(clone(this[state$c][_u8array].buffer).buffer);
|
|
678
912
|
}
|
|
679
|
-
|
|
680
|
-
|
|
913
|
+
readAsArrayBuffer(...args) {
|
|
914
|
+
read$1(this, "readAsArrayBuffer", args, blob => {
|
|
915
|
+
this[state$b].result = Blob_toUint8Array(blob).buffer.slice(0);
|
|
916
|
+
});
|
|
681
917
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
918
|
+
readAsBinaryString(...args) {
|
|
919
|
+
read$1(this, "readAsBinaryString", args, blob => {
|
|
920
|
+
let str = [];
|
|
921
|
+
let buf = Blob_toUint8Array(blob);
|
|
922
|
+
for (let i = 0; i < buf.length; ++i) {
|
|
923
|
+
let char = buf[i];
|
|
924
|
+
str.push(String.fromCharCode(char));
|
|
925
|
+
}
|
|
926
|
+
this[state$b].result = str.join("");
|
|
927
|
+
});
|
|
685
928
|
}
|
|
686
|
-
|
|
687
|
-
|
|
929
|
+
readAsDataURL(...args) {
|
|
930
|
+
read$1(this, "readAsDataURL", args, blob => {
|
|
931
|
+
this[state$b].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
|
|
932
|
+
});
|
|
688
933
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
934
|
+
readAsText(...args) {
|
|
935
|
+
const encoding = args.length > 1 ? args[1] : undefined;
|
|
936
|
+
read$1(this, "readAsText", args, blob => {
|
|
937
|
+
if (encoding !== undefined) {
|
|
938
|
+
let _encoding = "" + encoding;
|
|
939
|
+
if (["utf-8", "utf8", "unicode-1-1-utf-8"].indexOf(_encoding.toLowerCase()) === -1) {
|
|
940
|
+
console.error(`TypeError: Failed to execute 'readAsText' on 'FileReader': encoding ('${_encoding}') not implemented.`);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
this[state$b].result = decode$1(Blob_toUint8Array(blob));
|
|
944
|
+
});
|
|
692
945
|
}
|
|
693
|
-
|
|
694
|
-
|
|
946
|
+
get onabort() { return this[state$b].onabort; }
|
|
947
|
+
set onabort(value) { this[state$b].onabort = value; attach$1(this, "abort"); }
|
|
948
|
+
get onerror() { return this[state$b].onerror; }
|
|
949
|
+
set onerror(value) { this[state$b].onerror = value; attach$1(this, "error"); }
|
|
950
|
+
get onload() { return this[state$b].onload; }
|
|
951
|
+
set onload(value) { this[state$b].onload = value; attach$1(this, "load"); }
|
|
952
|
+
get onloadend() { return this[state$b].onloadend; }
|
|
953
|
+
set onloadend(value) { this[state$b].onloadend = value; attach$1(this, "loadend"); }
|
|
954
|
+
get onloadstart() { return this[state$b].onloadstart; }
|
|
955
|
+
set onloadstart(value) { this[state$b].onloadstart = value; attach$1(this, "loadstart"); }
|
|
956
|
+
get onprogress() { return this[state$b].onprogress; }
|
|
957
|
+
set onprogress(value) { this[state$b].onprogress = value; attach$1(this, "progress"); }
|
|
958
|
+
/** @internal */ toString() { return "[object FileReader]"; }
|
|
959
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
|
|
695
960
|
}
|
|
696
|
-
|
|
961
|
+
const properties$1 = {
|
|
962
|
+
EMPTY: { value: 0, enumerable: true },
|
|
963
|
+
LOADING: { value: 1, enumerable: true },
|
|
964
|
+
DONE: { value: 2, enumerable: true },
|
|
965
|
+
};
|
|
966
|
+
Object.defineProperties(FileReaderP, properties$1);
|
|
967
|
+
Object.defineProperties(FileReaderP.prototype, properties$1);
|
|
968
|
+
Class_setStringTag(FileReaderP, "FileReader");
|
|
697
969
|
/** @internal */
|
|
698
|
-
const
|
|
970
|
+
const _handlers$3 = Symbol();
|
|
699
971
|
/** @internal */
|
|
700
|
-
class
|
|
701
|
-
constructor(
|
|
702
|
-
this.
|
|
703
|
-
this.
|
|
704
|
-
this
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
972
|
+
class FileReaderState {
|
|
973
|
+
constructor(target) {
|
|
974
|
+
this.readyState = FileReaderP.EMPTY;
|
|
975
|
+
this.result = null;
|
|
976
|
+
this.error = null;
|
|
977
|
+
this[_a$7] = getHandlers$3(this);
|
|
978
|
+
this.onabort = null;
|
|
979
|
+
this.onerror = null;
|
|
980
|
+
this.onload = null;
|
|
981
|
+
this.onloadend = null;
|
|
982
|
+
this.onloadstart = null;
|
|
983
|
+
this.onprogress = null;
|
|
984
|
+
this.target = target;
|
|
711
985
|
}
|
|
712
986
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
987
|
+
_a$7 = _handlers$3;
|
|
988
|
+
function read$1(reader, kind, args, setResult) {
|
|
989
|
+
const [blob] = args;
|
|
990
|
+
checkArgsLength(args, 1, "FileReader", kind);
|
|
991
|
+
if (!isPolyfillType("Blob", blob)) {
|
|
992
|
+
throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
|
|
993
|
+
}
|
|
994
|
+
const s = reader[state$b];
|
|
995
|
+
s.error = null;
|
|
996
|
+
s.readyState = FileReaderP.LOADING;
|
|
997
|
+
emitProcessEvent(s.target, "loadstart", 0, blob.size);
|
|
998
|
+
setTimeout(() => {
|
|
999
|
+
if (s.readyState === FileReaderP.LOADING) {
|
|
1000
|
+
s.readyState = FileReaderP.DONE;
|
|
1001
|
+
try {
|
|
1002
|
+
setResult(blob);
|
|
1003
|
+
emitProcessEvent(s.target, "load", blob.size, blob.size);
|
|
1004
|
+
}
|
|
1005
|
+
catch (e) {
|
|
1006
|
+
s.result = null;
|
|
1007
|
+
s.error = e;
|
|
1008
|
+
emitProcessEvent(s.target, "error", 0, blob.size);
|
|
730
1009
|
}
|
|
731
1010
|
}
|
|
732
|
-
|
|
733
|
-
}
|
|
734
|
-
return output.join("");
|
|
735
|
-
}
|
|
736
|
-
function convert$1(buf) {
|
|
737
|
-
return buf instanceof ArrayBuffer
|
|
738
|
-
? new Uint8Array(buf)
|
|
739
|
-
: new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
1011
|
+
emitProcessEvent(s.target, "loadend", !!s.result ? blob.size : 0, blob.size);
|
|
1012
|
+
});
|
|
740
1013
|
}
|
|
741
|
-
function
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1014
|
+
function attach$1(reader, type) {
|
|
1015
|
+
const s = reader[state$b];
|
|
1016
|
+
const fnName = ("on" + type);
|
|
1017
|
+
const cb = s[fnName];
|
|
1018
|
+
const listener = s[_handlers$3][fnName];
|
|
1019
|
+
attachFn(reader, type, cb, listener);
|
|
746
1020
|
}
|
|
747
|
-
function
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
1021
|
+
function getHandlers$3(s) {
|
|
1022
|
+
return {
|
|
1023
|
+
onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
|
|
1024
|
+
onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
|
|
1025
|
+
onload: (ev) => { executeFn(s.target, s.onload, ev); },
|
|
1026
|
+
onloadend: (ev) => { executeFn(s.target, s.onloadend, ev); },
|
|
1027
|
+
onloadstart: (ev) => { executeFn(s.target, s.onloadstart, ev); },
|
|
1028
|
+
onprogress: (ev) => { executeFn(s.target, s.onprogress, ev); },
|
|
1029
|
+
};
|
|
755
1030
|
}
|
|
756
|
-
const
|
|
1031
|
+
const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
|
|
757
1032
|
|
|
758
|
-
|
|
759
|
-
const state$
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
this[state$
|
|
765
|
-
|
|
1033
|
+
var _a$6;
|
|
1034
|
+
/** @internal */ const state$a = Symbol( /* "URLSearchParamsState" */);
|
|
1035
|
+
const checkArgsFn$2 = (args, required, funcName) => { checkArgsLength(args, required, "URLSearchParams", funcName); };
|
|
1036
|
+
/** @type {typeof globalThis.URLSearchParams} */
|
|
1037
|
+
class URLSearchParamsP {
|
|
1038
|
+
constructor(init) {
|
|
1039
|
+
this[state$a] = new URLSearchParamsState();
|
|
1040
|
+
if (init !== undefined) {
|
|
1041
|
+
if (isObjectType("URLSearchParams", init)) {
|
|
1042
|
+
init.forEach((value, name) => { this.append(name, value); }, this);
|
|
1043
|
+
}
|
|
1044
|
+
else if (init && typeof init === "object") {
|
|
1045
|
+
if (Array.isArray(init) || Symbol.iterator in init) {
|
|
1046
|
+
let _init = Array.isArray(init) ? init : Array.from(init);
|
|
1047
|
+
for (let i = 0; i < _init.length; ++i) {
|
|
1048
|
+
let item = _init[i];
|
|
1049
|
+
if (Array.isArray(item) || (item && typeof item === "object" && Symbol.iterator in item)) {
|
|
1050
|
+
let pair = Array.isArray(item) ? item : Array.from(item);
|
|
1051
|
+
if (pair.length === 2) {
|
|
1052
|
+
this.append(pair[0], pair[1]);
|
|
1053
|
+
}
|
|
1054
|
+
else {
|
|
1055
|
+
throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
else {
|
|
1059
|
+
throw new TypeError("Failed to construct 'URLSearchParams': The provided value cannot be converted to a sequence.");
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
else {
|
|
1064
|
+
Object.getOwnPropertyNames(init).forEach(name => { this.append(name, init[name]); }, this);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
else {
|
|
1068
|
+
let _init = "" + init;
|
|
1069
|
+
if (_init.indexOf("?") === 0) {
|
|
1070
|
+
_init = _init.slice(1);
|
|
1071
|
+
}
|
|
1072
|
+
let pairs = _init.split("&");
|
|
1073
|
+
for (let i = 0; i < pairs.length; ++i) {
|
|
1074
|
+
let pair = pairs[i], separatorIndex = pair.indexOf("=");
|
|
1075
|
+
if (separatorIndex > -1) {
|
|
1076
|
+
this.append(decode(pair.slice(0, separatorIndex)), decode(pair.slice(separatorIndex + 1)));
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
if (pair) {
|
|
1080
|
+
this.append(decode(pair), "");
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
766
1086
|
}
|
|
767
|
-
get
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
defineStringTag(FileP, "File");
|
|
774
|
-
/** @internal */
|
|
775
|
-
class FileState {
|
|
776
|
-
constructor() {
|
|
777
|
-
this.lastModified = 0;
|
|
778
|
-
this.name = "";
|
|
1087
|
+
get size() { return this[state$a][_urlspArray].length; }
|
|
1088
|
+
append(...args) {
|
|
1089
|
+
const [name, value] = args;
|
|
1090
|
+
checkArgsFn$2(args, 2, "append");
|
|
1091
|
+
this[state$a][_urlspArray].push(["" + name, normalizeValue$1(value)]);
|
|
779
1092
|
}
|
|
780
|
-
|
|
781
|
-
const
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
1093
|
+
delete(...args) {
|
|
1094
|
+
const [name, value] = args;
|
|
1095
|
+
checkArgsFn$2(args, 1, "delete");
|
|
1096
|
+
let _name = "" + name;
|
|
1097
|
+
let index = -1;
|
|
1098
|
+
let array = this[state$a][_urlspArray];
|
|
1099
|
+
let result = [];
|
|
1100
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1101
|
+
let item = array[i];
|
|
1102
|
+
if (item[0] === _name) {
|
|
1103
|
+
if (args.length !== 1 && item[1] !== normalizeValue$1(value)) {
|
|
1104
|
+
result.push(item);
|
|
1105
|
+
}
|
|
1106
|
+
index = i;
|
|
1107
|
+
continue;
|
|
1108
|
+
}
|
|
1109
|
+
result.push(item);
|
|
1110
|
+
}
|
|
1111
|
+
if (index > -1) {
|
|
1112
|
+
this[state$a][_urlspArray] = result;
|
|
1113
|
+
}
|
|
790
1114
|
}
|
|
791
|
-
get
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
1115
|
+
get(...args) {
|
|
1116
|
+
const [name] = args;
|
|
1117
|
+
checkArgsFn$2(args, 1, "get");
|
|
1118
|
+
let _name = "" + name;
|
|
1119
|
+
let array = this[state$a][_urlspArray];
|
|
1120
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1121
|
+
let item = array[i];
|
|
1122
|
+
if (item[0] === _name) {
|
|
1123
|
+
return item[1];
|
|
1124
|
+
}
|
|
799
1125
|
}
|
|
1126
|
+
return null;
|
|
800
1127
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
1128
|
+
getAll(...args) {
|
|
1129
|
+
const [name] = args;
|
|
1130
|
+
checkArgsFn$2(args, 1, "getAll");
|
|
1131
|
+
let _name = "" + name;
|
|
1132
|
+
let array = this[state$a][_urlspArray];
|
|
1133
|
+
let result = [];
|
|
1134
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1135
|
+
let item = array[i];
|
|
1136
|
+
if (item[0] === _name) {
|
|
1137
|
+
result.push(item[1]);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
return result;
|
|
805
1141
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
1142
|
+
has(...args) {
|
|
1143
|
+
const [name, value] = args;
|
|
1144
|
+
checkArgsFn$2(args, 1, "has");
|
|
1145
|
+
let _name = "" + name;
|
|
1146
|
+
let array = this[state$a][_urlspArray];
|
|
1147
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1148
|
+
let item = array[i];
|
|
1149
|
+
if (item[0] === _name) {
|
|
1150
|
+
if (args.length === 1) {
|
|
1151
|
+
return true;
|
|
1152
|
+
}
|
|
1153
|
+
else {
|
|
1154
|
+
if (item[1] === normalizeValue$1(value)) {
|
|
1155
|
+
return true;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
return false;
|
|
813
1161
|
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
1162
|
+
set(...args) {
|
|
1163
|
+
const [name, value] = args;
|
|
1164
|
+
checkArgsFn$2(args, 2, "set");
|
|
1165
|
+
let _name = "" + name;
|
|
1166
|
+
let _value = normalizeValue$1(value);
|
|
1167
|
+
let index = -1;
|
|
1168
|
+
let array = this[state$a][_urlspArray];
|
|
1169
|
+
let result = [];
|
|
1170
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1171
|
+
let item = array[i];
|
|
1172
|
+
if (item[0] === _name) {
|
|
1173
|
+
if (index === -1) {
|
|
1174
|
+
index = i;
|
|
1175
|
+
result.push([_name, _value]);
|
|
1176
|
+
}
|
|
1177
|
+
continue;
|
|
1178
|
+
}
|
|
1179
|
+
result.push(item);
|
|
1180
|
+
}
|
|
1181
|
+
if (index === -1) {
|
|
1182
|
+
result.push([_name, _value]);
|
|
1183
|
+
}
|
|
1184
|
+
this[state$a][_urlspArray] = result;
|
|
818
1185
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
1186
|
+
sort() {
|
|
1187
|
+
this[state$a][_urlspArray].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
1188
|
+
}
|
|
1189
|
+
forEach(...args) {
|
|
1190
|
+
const [callbackfn, thisArg] = args;
|
|
1191
|
+
checkArgsFn$2(args, 1, "forEach");
|
|
1192
|
+
if (typeof callbackfn !== "function") {
|
|
1193
|
+
throw new TypeError("Failed to execute 'forEach' on 'URLSearchParams': parameter 1 is not of type 'Function'.");
|
|
1194
|
+
}
|
|
1195
|
+
let array = this[state$a][_urlspArray];
|
|
1196
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1197
|
+
let item = array[i];
|
|
1198
|
+
callbackfn.call(thisArg, item[1], item[0], this);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
entries() {
|
|
1202
|
+
return this[state$a][_urlspArray].map(x => [x[0], x[1]]).values();
|
|
1203
|
+
}
|
|
1204
|
+
keys() {
|
|
1205
|
+
return this[state$a][_urlspArray].map(x => x[0]).values();
|
|
1206
|
+
}
|
|
1207
|
+
values() {
|
|
1208
|
+
return this[state$a][_urlspArray].map(x => x[1]).values();
|
|
1209
|
+
}
|
|
1210
|
+
[Symbol.iterator]() {
|
|
1211
|
+
return this.entries();
|
|
1212
|
+
}
|
|
1213
|
+
toString() {
|
|
1214
|
+
let array = this[state$a][_urlspArray];
|
|
1215
|
+
let result = [];
|
|
1216
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1217
|
+
let item = array[i];
|
|
1218
|
+
result.push(encode(item[0]) + "=" + encode(item[1]));
|
|
1219
|
+
}
|
|
1220
|
+
return result.join("&");
|
|
823
1221
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
get onerror() { return this[state$a].onerror; }
|
|
827
|
-
set onerror(value) { this[state$a].onerror = value; attach$1.call(this[state$a], "error"); }
|
|
828
|
-
get onload() { return this[state$a].onload; }
|
|
829
|
-
set onload(value) { this[state$a].onload = value; attach$1.call(this[state$a], "load"); }
|
|
830
|
-
get onloadend() { return this[state$a].onloadend; }
|
|
831
|
-
set onloadend(value) { this[state$a].onloadend = value; attach$1.call(this[state$a], "loadend"); }
|
|
832
|
-
get onloadstart() { return this[state$a].onloadstart; }
|
|
833
|
-
set onloadstart(value) { this[state$a].onloadstart = value; attach$1.call(this[state$a], "loadstart"); }
|
|
834
|
-
get onprogress() { return this[state$a].onprogress; }
|
|
835
|
-
set onprogress(value) { this[state$a].onprogress = value; attach$1.call(this[state$a], "progress"); }
|
|
836
|
-
toString() { return "[object FileReader]"; }
|
|
837
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
|
|
1222
|
+
/** @internal */
|
|
1223
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
|
|
838
1224
|
}
|
|
839
|
-
|
|
840
|
-
EMPTY: { value: 0, enumerable: true },
|
|
841
|
-
LOADING: { value: 1, enumerable: true },
|
|
842
|
-
DONE: { value: 2, enumerable: true },
|
|
843
|
-
};
|
|
844
|
-
Object.defineProperties(FileReaderP, properties$1);
|
|
845
|
-
Object.defineProperties(FileReaderP.prototype, properties$1);
|
|
846
|
-
defineStringTag(FileReaderP, "FileReader");
|
|
1225
|
+
Class_setStringTag(URLSearchParamsP, "URLSearchParams");
|
|
847
1226
|
/** @internal */
|
|
848
|
-
const
|
|
1227
|
+
const _urlspArray = Symbol();
|
|
849
1228
|
/** @internal */
|
|
850
|
-
class
|
|
851
|
-
constructor(
|
|
852
|
-
this
|
|
853
|
-
this.result = null;
|
|
854
|
-
this.error = null;
|
|
855
|
-
this[_a$7] = getHandlers$3.call(this);
|
|
856
|
-
this.onabort = null;
|
|
857
|
-
this.onerror = null;
|
|
858
|
-
this.onload = null;
|
|
859
|
-
this.onloadend = null;
|
|
860
|
-
this.onloadstart = null;
|
|
861
|
-
this.onprogress = null;
|
|
862
|
-
this.target = target;
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
_a$7 = _handlers$3;
|
|
866
|
-
function read$1(kind, blob, setResult) {
|
|
867
|
-
if (!isPolyfillType("Blob", blob)) {
|
|
868
|
-
throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
|
|
1229
|
+
class URLSearchParamsState {
|
|
1230
|
+
constructor() {
|
|
1231
|
+
this[_a$6] = [];
|
|
869
1232
|
}
|
|
870
|
-
this.error = null;
|
|
871
|
-
this.readyState = FileReaderP.LOADING;
|
|
872
|
-
emitProcessEvent(this.target, "loadstart", 0, blob.size);
|
|
873
|
-
setTimeout(() => {
|
|
874
|
-
if (this.readyState === FileReaderP.LOADING) {
|
|
875
|
-
this.readyState = FileReaderP.DONE;
|
|
876
|
-
try {
|
|
877
|
-
setResult();
|
|
878
|
-
emitProcessEvent(this.target, "load", blob.size, blob.size);
|
|
879
|
-
}
|
|
880
|
-
catch (e) {
|
|
881
|
-
this.result = null;
|
|
882
|
-
this.error = e;
|
|
883
|
-
emitProcessEvent(this.target, "error", 0, blob.size);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
emitProcessEvent(this.target, "loadend", !!this.result ? blob.size : 0, blob.size);
|
|
887
|
-
});
|
|
888
1233
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1234
|
+
_a$6 = _urlspArray;
|
|
1235
|
+
function normalizeValue$1(value) {
|
|
1236
|
+
return typeof value === "string" ? value : (value !== null && value !== undefined && typeof value.toString === "function"
|
|
1237
|
+
? value.toString()
|
|
1238
|
+
: JSON.stringify(value));
|
|
894
1239
|
}
|
|
895
|
-
function
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1240
|
+
function encode(str) {
|
|
1241
|
+
const replace = {
|
|
1242
|
+
"!": "%21",
|
|
1243
|
+
"'": "%27",
|
|
1244
|
+
"(": "%28",
|
|
1245
|
+
")": "%29",
|
|
1246
|
+
"~": "%7E",
|
|
1247
|
+
"%20": "+",
|
|
1248
|
+
"%00": "\x00",
|
|
903
1249
|
};
|
|
1250
|
+
return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, match => replace[match]);
|
|
904
1251
|
}
|
|
905
|
-
|
|
1252
|
+
function decode(str) {
|
|
1253
|
+
return str
|
|
1254
|
+
.replace(/[ +]/g, "%20")
|
|
1255
|
+
.replace(/(%[a-f0-9]{2})+/ig, match => decodeURIComponent(match));
|
|
1256
|
+
}
|
|
1257
|
+
const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
|
|
906
1258
|
|
|
907
|
-
var _a$
|
|
908
|
-
/** @internal */
|
|
909
|
-
const
|
|
1259
|
+
var _a$5;
|
|
1260
|
+
/** @internal */ const state$9 = Symbol( /* "FormDataState" */);
|
|
1261
|
+
const checkArgsFn$1 = (args, required, funcName) => { checkArgsLength(args, required, "FormData", funcName); };
|
|
1262
|
+
/** @type {typeof globalThis.FormData} */
|
|
910
1263
|
class FormDataP {
|
|
911
1264
|
constructor(form, submitter) {
|
|
912
|
-
if (
|
|
913
|
-
|
|
1265
|
+
if (submitter === undefined) {
|
|
1266
|
+
if (form !== undefined) {
|
|
1267
|
+
console.error("TypeError: Failed to construct 'FormData': parameter 1 not implemented.");
|
|
1268
|
+
}
|
|
914
1269
|
}
|
|
915
|
-
|
|
916
|
-
|
|
1270
|
+
else {
|
|
1271
|
+
if (submitter !== null) {
|
|
1272
|
+
console.error("TypeError: Failed to construct 'FormData': parameter 1 and parameter 2 not implemented.");
|
|
1273
|
+
}
|
|
917
1274
|
}
|
|
918
1275
|
this[state$9] = new FormDataState();
|
|
919
1276
|
}
|
|
920
|
-
append(
|
|
1277
|
+
append(...args) {
|
|
1278
|
+
const [name, value, filename] = args;
|
|
1279
|
+
checkArgsFn$1(args, 2, "append");
|
|
921
1280
|
this[state$9][_formData].push(normalizeArgs(name, value, filename));
|
|
922
1281
|
}
|
|
923
|
-
delete(
|
|
1282
|
+
delete(...args) {
|
|
1283
|
+
const [name] = args;
|
|
1284
|
+
checkArgsFn$1(args, 1, "delete");
|
|
1285
|
+
let _name = "" + name;
|
|
1286
|
+
let index = -1;
|
|
1287
|
+
let array = this[state$9][_formData];
|
|
924
1288
|
let result = [];
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1289
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1290
|
+
let item = array[i];
|
|
1291
|
+
if (item[0] === _name) {
|
|
1292
|
+
index = i;
|
|
1293
|
+
continue;
|
|
1294
|
+
}
|
|
1295
|
+
result.push(item);
|
|
1296
|
+
}
|
|
1297
|
+
if (index > -1) {
|
|
1298
|
+
this[state$9][_formData] = result;
|
|
1299
|
+
}
|
|
930
1300
|
}
|
|
931
|
-
get(
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1301
|
+
get(...args) {
|
|
1302
|
+
const [name] = args;
|
|
1303
|
+
checkArgsFn$1(args, 1, "get");
|
|
1304
|
+
let _name = "" + name;
|
|
1305
|
+
let array = this[state$9][_formData];
|
|
1306
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1307
|
+
let item = array[i];
|
|
1308
|
+
if (item[0] === _name) {
|
|
1309
|
+
return item[1];
|
|
937
1310
|
}
|
|
938
1311
|
}
|
|
939
1312
|
return null;
|
|
940
1313
|
}
|
|
941
|
-
getAll(
|
|
1314
|
+
getAll(...args) {
|
|
1315
|
+
const [name] = args;
|
|
1316
|
+
checkArgsFn$1(args, 1, "getAll");
|
|
1317
|
+
let _name = "" + name;
|
|
1318
|
+
let array = this[state$9][_formData];
|
|
942
1319
|
let result = [];
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1320
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1321
|
+
let item = array[i];
|
|
1322
|
+
if (item[0] === _name) {
|
|
1323
|
+
result.push(item[1]);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
947
1326
|
return result;
|
|
948
1327
|
}
|
|
949
|
-
has(
|
|
950
|
-
name =
|
|
951
|
-
|
|
952
|
-
|
|
1328
|
+
has(...args) {
|
|
1329
|
+
const [name] = args;
|
|
1330
|
+
checkArgsFn$1(args, 1, "has");
|
|
1331
|
+
let _name = "" + name;
|
|
1332
|
+
let array = this[state$9][_formData];
|
|
1333
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1334
|
+
let item = array[i];
|
|
1335
|
+
if (item[0] === _name) {
|
|
953
1336
|
return true;
|
|
954
1337
|
}
|
|
955
1338
|
}
|
|
956
1339
|
return false;
|
|
957
1340
|
}
|
|
958
|
-
set(
|
|
959
|
-
name =
|
|
1341
|
+
set(...args) {
|
|
1342
|
+
const [name, value, filename] = args;
|
|
1343
|
+
checkArgsFn$1(args, 2, "set");
|
|
1344
|
+
let _name = "" + name;
|
|
1345
|
+
let _args = normalizeArgs(name, value, filename);
|
|
1346
|
+
let index = -1;
|
|
1347
|
+
let array = this[state$9][_formData];
|
|
960
1348
|
let result = [];
|
|
961
|
-
let
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1349
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1350
|
+
let item = array[i];
|
|
1351
|
+
if (item[0] === _name) {
|
|
1352
|
+
if (index === -1) {
|
|
1353
|
+
index = i;
|
|
1354
|
+
result.push(_args);
|
|
1355
|
+
}
|
|
1356
|
+
continue;
|
|
1357
|
+
}
|
|
1358
|
+
result.push(item);
|
|
1359
|
+
}
|
|
1360
|
+
if (index === -1) {
|
|
1361
|
+
result.push(_args);
|
|
1362
|
+
}
|
|
969
1363
|
this[state$9][_formData] = result;
|
|
970
1364
|
}
|
|
971
|
-
forEach(
|
|
972
|
-
|
|
973
|
-
|
|
1365
|
+
forEach(...args) {
|
|
1366
|
+
const [callbackfn, thisArg] = args;
|
|
1367
|
+
checkArgsFn$1(args, 1, "forEach");
|
|
1368
|
+
if (typeof callbackfn !== "function") {
|
|
1369
|
+
throw new TypeError("Failed to execute 'forEach' on 'FormData': parameter 1 is not of type 'Function'.");
|
|
1370
|
+
}
|
|
1371
|
+
let array = this[state$9][_formData];
|
|
1372
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1373
|
+
let item = array[i];
|
|
1374
|
+
callbackfn.call(thisArg, item[1], item[0], thisArg);
|
|
974
1375
|
}
|
|
975
1376
|
}
|
|
976
1377
|
entries() {
|
|
977
|
-
return this[state$9][_formData].values();
|
|
1378
|
+
return this[state$9][_formData].map(x => [x[0], x[1]]).values();
|
|
978
1379
|
}
|
|
979
1380
|
keys() {
|
|
980
1381
|
return this[state$9][_formData].map(x => x[0]).values();
|
|
@@ -985,391 +1386,599 @@ class FormDataP {
|
|
|
985
1386
|
[Symbol.iterator]() {
|
|
986
1387
|
return this.entries();
|
|
987
1388
|
}
|
|
988
|
-
toString() { return "[object FormData]"; }
|
|
989
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
|
|
1389
|
+
/** @internal */ toString() { return "[object FormData]"; }
|
|
1390
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
|
|
990
1391
|
}
|
|
991
|
-
|
|
1392
|
+
Class_setStringTag(FormDataP, "FormData");
|
|
992
1393
|
/** @internal */
|
|
993
1394
|
const _formData = Symbol();
|
|
994
1395
|
/** @internal */
|
|
995
1396
|
class FormDataState {
|
|
996
1397
|
constructor() {
|
|
997
|
-
this[_a$
|
|
1398
|
+
this[_a$5] = [];
|
|
998
1399
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1400
|
+
}
|
|
1401
|
+
_a$5 = _formData;
|
|
1402
|
+
/** @internal */
|
|
1403
|
+
function FormData_toBlob(formData) {
|
|
1404
|
+
const boundary = "----formdata-mphttpx-" + Math.random();
|
|
1405
|
+
const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
|
|
1406
|
+
let chunks = [];
|
|
1407
|
+
for (let i = 0; i < formData[state$9][_formData].length; ++i) {
|
|
1408
|
+
let pair = formData[state$9][_formData][i];
|
|
1409
|
+
let name = pair[0];
|
|
1410
|
+
let value = pair[1];
|
|
1411
|
+
if (typeof value === "string") {
|
|
1412
|
+
chunks.push(p + escape(normalizeLinefeeds(name)) + `"\r\n\r\n${normalizeLinefeeds(value)}\r\n`);
|
|
1413
|
+
}
|
|
1414
|
+
else {
|
|
1415
|
+
chunks.push(p + escape(normalizeLinefeeds(name)) + `"; filename="${escape(value.name)}"\r\nContent-Type: ${value.type || "application/octet-stream"}\r\n\r\n`, value, `\r\n`);
|
|
1010
1416
|
}
|
|
1011
|
-
chunks.push(`--${boundary}--`);
|
|
1012
|
-
return new BlobP(chunks, {
|
|
1013
|
-
type: "multipart/form-data; boundary=" + boundary,
|
|
1014
|
-
});
|
|
1015
1417
|
}
|
|
1418
|
+
chunks.push(`--${boundary}--`);
|
|
1419
|
+
return new BlobP(chunks, { type: "multipart/form-data; boundary=" + boundary });
|
|
1016
1420
|
}
|
|
1017
|
-
_a$6 = _formData;
|
|
1018
1421
|
function normalizeArgs(name, value, filename) {
|
|
1019
1422
|
if (isPolyfillType("Blob", value)) {
|
|
1020
1423
|
filename = filename !== undefined
|
|
1021
|
-
?
|
|
1424
|
+
? ("" + filename)
|
|
1022
1425
|
: typeof value.name === "string"
|
|
1023
1426
|
? value.name
|
|
1024
1427
|
: "blob";
|
|
1025
|
-
if (value.name !== filename ||
|
|
1428
|
+
if (value.name !== filename || isObjectType("Blob", value)) {
|
|
1026
1429
|
value = new FileP([value], filename);
|
|
1027
1430
|
}
|
|
1028
|
-
return [
|
|
1431
|
+
return ["" + name, value];
|
|
1029
1432
|
}
|
|
1030
|
-
return [
|
|
1433
|
+
return ["" + name, "" + value];
|
|
1031
1434
|
}
|
|
1435
|
+
// normalize line feeds for textarea
|
|
1436
|
+
// https://html.spec.whatwg.org/multipage/form-elements.html#textarea-line-break-normalisation-transformation
|
|
1032
1437
|
function normalizeLinefeeds(value) {
|
|
1033
1438
|
return value.replace(/\r?\n|\r/g, "\r\n");
|
|
1034
1439
|
}
|
|
1035
|
-
function each(arr, cb) {
|
|
1036
|
-
for (let i = 0; i < arr.length; ++i) {
|
|
1037
|
-
cb(arr[i]);
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
1440
|
function escape(str) {
|
|
1041
1441
|
return str.replace(/\n/g, '%0A').replace(/\r/g, '%0D').replace(/"/g, '%22');
|
|
1042
1442
|
}
|
|
1043
|
-
/**
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
}
|
|
1053
|
-
// 1. Extract boundary string (from the first line, removing leading "--")
|
|
1054
|
-
const firstLineEnd = body.indexOf("\r\n");
|
|
1443
|
+
/** @internal */
|
|
1444
|
+
function createFormDataFromBinaryText(text, boundary) {
|
|
1445
|
+
const throwParseError = () => {
|
|
1446
|
+
throw new TypeError("Could not parse content as FormData.");
|
|
1447
|
+
};
|
|
1448
|
+
if (typeof text !== "string" || text.trim() === "") {
|
|
1449
|
+
throwParseError();
|
|
1450
|
+
}
|
|
1451
|
+
let firstLineEnd = text.indexOf("\r\n");
|
|
1055
1452
|
if (firstLineEnd === -1) {
|
|
1056
|
-
|
|
1057
|
-
|
|
1453
|
+
throwParseError();
|
|
1454
|
+
}
|
|
1455
|
+
let _boundary = text.substring(2, firstLineEnd).trim();
|
|
1456
|
+
if (!_boundary) {
|
|
1457
|
+
throwParseError();
|
|
1058
1458
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
// Invalid multipart format: Empty boundary
|
|
1062
|
-
throw new TypeError("Invalid MIME type");
|
|
1459
|
+
if (boundary !== undefined && boundary !== _boundary) {
|
|
1460
|
+
throwParseError();
|
|
1063
1461
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
const trimmed = part.trim();
|
|
1462
|
+
let parts = text.split(`--${_boundary}`).filter(part => {
|
|
1463
|
+
let trimmed = part.trim();
|
|
1067
1464
|
return trimmed !== "" && trimmed !== "--";
|
|
1068
1465
|
});
|
|
1069
1466
|
if (parts.length === 0) {
|
|
1070
|
-
|
|
1071
|
-
throw new TypeError(errMsg);
|
|
1467
|
+
throwParseError();
|
|
1072
1468
|
}
|
|
1073
|
-
|
|
1469
|
+
let formData = new FormDataP();
|
|
1074
1470
|
parts.forEach(part => {
|
|
1075
|
-
|
|
1076
|
-
const separatorIndex = part.indexOf("\r\n\r\n");
|
|
1471
|
+
let separatorIndex = part.indexOf("\r\n\r\n");
|
|
1077
1472
|
if (separatorIndex === -1) {
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
if (!
|
|
1089
|
-
|
|
1090
|
-
throw new TypeError(errMsg);
|
|
1091
|
-
}
|
|
1092
|
-
const fieldName = nameMatch[1];
|
|
1093
|
-
const isFile = !!filenameMatch; // Whether it's a file field
|
|
1094
|
-
const mimeType = contentTypeMatch ? (contentTypeMatch[1] || "").trim() : "application/octet-stream";
|
|
1095
|
-
// 4. Process content (text or binary)
|
|
1096
|
-
if (isFile) {
|
|
1097
|
-
// File field: Use TextEncoder to handle raw binary data
|
|
1098
|
-
try {
|
|
1099
|
-
// Remove line breaks from content (simulating browser behavior)
|
|
1100
|
-
const content = contentRaw.replace(/\r\n/g, "");
|
|
1101
|
-
// Convert string to Uint8Array using TextEncoder
|
|
1102
|
-
const encoder = new TextEncoderP();
|
|
1103
|
-
const uint8Array = encoder.encode(content);
|
|
1104
|
-
// Create File object (default filename is unknown-file)
|
|
1105
|
-
const filename = filenameMatch[1] || "unknown-file";
|
|
1106
|
-
const file = new FileP([uint8Array], filename, { type: mimeType });
|
|
1107
|
-
formData.append(fieldName, file, filename);
|
|
1108
|
-
}
|
|
1109
|
-
catch (e) {
|
|
1110
|
-
// `Failed to process file field "${fieldName}": ${(e as Error).message}`
|
|
1111
|
-
throw new TypeError(errMsg);
|
|
1112
|
-
}
|
|
1473
|
+
throwParseError();
|
|
1474
|
+
}
|
|
1475
|
+
let headerRaw = part.substring(0, separatorIndex).trim();
|
|
1476
|
+
let nameMatch = headerRaw.match(/name="([^"]*)"/);
|
|
1477
|
+
if (!nameMatch || nameMatch.length < 2) {
|
|
1478
|
+
throwParseError();
|
|
1479
|
+
}
|
|
1480
|
+
let fieldName = nameMatch[1];
|
|
1481
|
+
let filenameMatch = headerRaw.match(/filename="([^"]*)"/);
|
|
1482
|
+
let contentRaw = part.substring(separatorIndex + 4);
|
|
1483
|
+
if (!filenameMatch) {
|
|
1484
|
+
formData.append(fieldName, contentRaw.replace(/^[\r\n]+|[\r\n]+$/g, ""));
|
|
1113
1485
|
}
|
|
1114
1486
|
else {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1487
|
+
let filename = filenameMatch[1] || "";
|
|
1488
|
+
let contentTypeMatch = headerRaw.match(/Content-Type: ([^\r\n]+)/);
|
|
1489
|
+
let mimeType = contentTypeMatch ? (contentTypeMatch[1] || "").trim() : "text/plain";
|
|
1490
|
+
let content = contentRaw.replace(/\r\n/g, "");
|
|
1491
|
+
formData.append(fieldName, new FileP([content], filename, { type: mimeType }));
|
|
1118
1492
|
}
|
|
1119
1493
|
});
|
|
1120
1494
|
return formData;
|
|
1121
1495
|
}
|
|
1122
1496
|
const FormDataE = g["FormData"] || FormDataP;
|
|
1123
1497
|
|
|
1124
|
-
var _a$
|
|
1125
|
-
/** @internal */
|
|
1126
|
-
const
|
|
1127
|
-
|
|
1498
|
+
var _a$4, _b$1;
|
|
1499
|
+
/** @internal */ const state$8 = Symbol( /* "HeadersState" */);
|
|
1500
|
+
const checkArgsFn = (args, required, funcName) => { checkArgsLength(args, required, "Headers", funcName); };
|
|
1501
|
+
/** @type {typeof globalThis.Headers} */
|
|
1502
|
+
class HeadersP {
|
|
1128
1503
|
constructor(init) {
|
|
1129
|
-
|
|
1130
|
-
if (
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1504
|
+
this[state$8] = new HeadersState();
|
|
1505
|
+
if (init !== undefined) {
|
|
1506
|
+
if (isObjectType("Headers", init)) {
|
|
1507
|
+
init.forEach((value, name) => { this.append(name, value); }, this);
|
|
1508
|
+
}
|
|
1509
|
+
else if (Array.isArray(init) || (init && typeof init === "object" && Symbol.iterator in init)) {
|
|
1510
|
+
let _init = Array.isArray(init) ? init : Array.from(init);
|
|
1511
|
+
_init.forEach(item => {
|
|
1512
|
+
if (Array.isArray(item) || (item && typeof item === "object" && Symbol.iterator in item)) {
|
|
1513
|
+
let pair = Array.isArray(item) ? item : Array.from(item);
|
|
1514
|
+
if (pair.length === 2) {
|
|
1515
|
+
this.append(pair[0], pair[1]);
|
|
1516
|
+
}
|
|
1517
|
+
else {
|
|
1518
|
+
throw new TypeError("Failed to construct 'Headers': Invalid value");
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
else {
|
|
1522
|
+
throw new TypeError("Failed to construct 'Headers': The provided value cannot be converted to a sequence.");
|
|
1523
|
+
}
|
|
1524
|
+
}, this);
|
|
1525
|
+
}
|
|
1526
|
+
else {
|
|
1527
|
+
if (init && typeof init === "object") {
|
|
1528
|
+
Object.getOwnPropertyNames(init).forEach(name => { this.append(name, init[name]); }, this);
|
|
1529
|
+
}
|
|
1530
|
+
else {
|
|
1531
|
+
throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(record<ByteString, ByteString> or sequence<sequence<ByteString>>)'.");
|
|
1150
1532
|
}
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
this[state$8][_initialized] = true;
|
|
1536
|
+
}
|
|
1537
|
+
append(...args) {
|
|
1538
|
+
const [name, value] = args;
|
|
1539
|
+
checkArgsFn(args, 2, "append");
|
|
1540
|
+
let _name = normalizeName(name, throwsFn(this[state$8][_initialized] ? "append" : ""));
|
|
1541
|
+
let _value = normalizeValue(value);
|
|
1542
|
+
let index = -1;
|
|
1543
|
+
let array = this[state$8][_headersArray];
|
|
1544
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1545
|
+
let item = array[i];
|
|
1546
|
+
if (item[0] === _name) {
|
|
1547
|
+
item[1] = `${item[1]}, ${_value}`;
|
|
1548
|
+
index = i;
|
|
1549
|
+
break;
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
if (index === -1) {
|
|
1553
|
+
array.push([_name, _value]);
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
delete(...args) {
|
|
1557
|
+
const [name] = args;
|
|
1558
|
+
checkArgsFn(args, 1, "delete");
|
|
1559
|
+
let _name = normalizeName(name, throwsFn("delete"));
|
|
1560
|
+
let index = -1;
|
|
1561
|
+
let array = this[state$8][_headersArray];
|
|
1562
|
+
let result = [];
|
|
1563
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1564
|
+
let item = array[i];
|
|
1565
|
+
if (item[0] === _name) {
|
|
1566
|
+
index = i;
|
|
1151
1567
|
continue;
|
|
1152
1568
|
}
|
|
1153
|
-
|
|
1569
|
+
result.push(item);
|
|
1570
|
+
}
|
|
1571
|
+
if (index > -1) {
|
|
1572
|
+
this[state$8][_headersArray] = result;
|
|
1154
1573
|
}
|
|
1155
|
-
this[state$8][_urlspDict] = dict;
|
|
1156
1574
|
}
|
|
1157
|
-
get(
|
|
1158
|
-
|
|
1159
|
-
|
|
1575
|
+
get(...args) {
|
|
1576
|
+
const [name] = args;
|
|
1577
|
+
checkArgsFn(args, 1, "get");
|
|
1578
|
+
let _name = normalizeName(name, throwsFn("get"));
|
|
1579
|
+
let array = this[state$8][_headersArray];
|
|
1580
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1581
|
+
let item = array[i];
|
|
1582
|
+
if (item[0] === _name) {
|
|
1583
|
+
return item[1];
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
return null;
|
|
1160
1587
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1588
|
+
getSetCookie() {
|
|
1589
|
+
let value = this.get("Set-Cookie");
|
|
1590
|
+
return value ? value.split(", ") : [];
|
|
1163
1591
|
}
|
|
1164
|
-
has(
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1592
|
+
has(...args) {
|
|
1593
|
+
const [name] = args;
|
|
1594
|
+
checkArgsFn(args, 1, "has");
|
|
1595
|
+
let _name = normalizeName(name, throwsFn("has"));
|
|
1596
|
+
let array = this[state$8][_headersArray];
|
|
1597
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1598
|
+
let item = array[i];
|
|
1599
|
+
if (item[0] === _name) {
|
|
1600
|
+
return true;
|
|
1168
1601
|
}
|
|
1169
|
-
return true;
|
|
1170
1602
|
}
|
|
1171
1603
|
return false;
|
|
1172
1604
|
}
|
|
1173
|
-
set(
|
|
1174
|
-
|
|
1605
|
+
set(...args) {
|
|
1606
|
+
const [name, value] = args;
|
|
1607
|
+
checkArgsFn(args, 2, "set");
|
|
1608
|
+
let _name = normalizeName(name, throwsFn("set"));
|
|
1609
|
+
let _value = normalizeValue(value);
|
|
1610
|
+
let index = -1;
|
|
1611
|
+
let array = this[state$8][_headersArray];
|
|
1612
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1613
|
+
let item = array[i];
|
|
1614
|
+
if (item[0] === _name) {
|
|
1615
|
+
item[1] = _value;
|
|
1616
|
+
index = i;
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
if (index === -1) {
|
|
1621
|
+
array.push([_name, _value]);
|
|
1622
|
+
}
|
|
1175
1623
|
}
|
|
1176
|
-
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
objectEntries(this[state$8][_urlspDict]).forEach(([key, values]) => {
|
|
1188
|
-
values.forEach(value => {
|
|
1189
|
-
callbackfn.call(thisArg, value, key, this);
|
|
1190
|
-
});
|
|
1191
|
-
});
|
|
1624
|
+
forEach(...args) {
|
|
1625
|
+
const [callbackfn, thisArg] = args;
|
|
1626
|
+
checkArgsFn(args, 1, "forEach");
|
|
1627
|
+
if (typeof callbackfn !== "function") {
|
|
1628
|
+
throw new TypeError("Failed to execute 'forEach' on 'Headers': parameter 1 is not of type 'Function'.");
|
|
1629
|
+
}
|
|
1630
|
+
let array = this[state$8][_headersArray];
|
|
1631
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1632
|
+
let item = array[i];
|
|
1633
|
+
callbackfn.call(thisArg, item[1], item[0], this);
|
|
1634
|
+
}
|
|
1192
1635
|
}
|
|
1193
1636
|
entries() {
|
|
1194
|
-
return
|
|
1195
|
-
.map(([key, values]) => {
|
|
1196
|
-
return values.map(value => {
|
|
1197
|
-
return [key, value];
|
|
1198
|
-
});
|
|
1199
|
-
})
|
|
1200
|
-
.reduce(flatCb, [])
|
|
1201
|
-
.values();
|
|
1637
|
+
return this[state$8][_headersArray].map(x => [x[0], x[1]]).values();
|
|
1202
1638
|
}
|
|
1203
1639
|
keys() {
|
|
1204
|
-
return
|
|
1640
|
+
return this[state$8][_headersArray].map(x => x[0]).values();
|
|
1641
|
+
}
|
|
1642
|
+
values() {
|
|
1643
|
+
return this[state$8][_headersArray].map(x => x[1]).values();
|
|
1644
|
+
}
|
|
1645
|
+
[Symbol.iterator]() {
|
|
1646
|
+
return this.entries();
|
|
1647
|
+
}
|
|
1648
|
+
/** @internal */ toString() { return "[object Headers]"; }
|
|
1649
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
|
|
1650
|
+
}
|
|
1651
|
+
Class_setStringTag(HeadersP, "Headers");
|
|
1652
|
+
/** @internal */ const _initialized = Symbol();
|
|
1653
|
+
/** @internal */ const _headersArray = Symbol();
|
|
1654
|
+
/** @internal */
|
|
1655
|
+
class HeadersState {
|
|
1656
|
+
constructor() {
|
|
1657
|
+
this[_a$4] = false;
|
|
1658
|
+
this[_b$1] = [];
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
_a$4 = _initialized, _b$1 = _headersArray;
|
|
1662
|
+
function throwsFn(kind) {
|
|
1663
|
+
return () => {
|
|
1664
|
+
throw new TypeError(`Failed to ${kind ? ("execute '" + kind + "' on") : "construct"} 'Headers': Invalid name`);
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1667
|
+
/** @internal */
|
|
1668
|
+
function normalizeName(name, throwError) {
|
|
1669
|
+
if (typeof name !== "string") {
|
|
1670
|
+
name = "" + name;
|
|
1671
|
+
}
|
|
1672
|
+
if (throwError && (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "")) {
|
|
1673
|
+
throwError();
|
|
1674
|
+
}
|
|
1675
|
+
return name.toLowerCase();
|
|
1676
|
+
}
|
|
1677
|
+
/** @internal */
|
|
1678
|
+
function normalizeValue(value) {
|
|
1679
|
+
return typeof value === "string" ? value : ("" + value);
|
|
1680
|
+
}
|
|
1681
|
+
/** @internal */
|
|
1682
|
+
function parseHeaders(rawHeaders) {
|
|
1683
|
+
let headers = new HeadersP();
|
|
1684
|
+
let preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
|
|
1685
|
+
preProcessedHeaders
|
|
1686
|
+
.split("\r")
|
|
1687
|
+
.map(header => header.indexOf("\n") === 0 ? header.substring(1, header.length) : header)
|
|
1688
|
+
.forEach(line => {
|
|
1689
|
+
let parts = line.split(":");
|
|
1690
|
+
let name = parts.shift().trim();
|
|
1691
|
+
if (name) {
|
|
1692
|
+
let value = parts.join(":").trim();
|
|
1693
|
+
try {
|
|
1694
|
+
headers.append(name, value);
|
|
1695
|
+
}
|
|
1696
|
+
catch (e) {
|
|
1697
|
+
console.warn(`SyntaxError: Response.headers: '${name}' is not a valid HTTP header field name.`);
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
});
|
|
1701
|
+
return headers;
|
|
1702
|
+
}
|
|
1703
|
+
const HeadersE = g["Headers"] || HeadersP;
|
|
1704
|
+
|
|
1705
|
+
var _a$3;
|
|
1706
|
+
/** @internal */ const state$7 = Symbol( /* "BodyState" */);
|
|
1707
|
+
class BodyImpl {
|
|
1708
|
+
/** @internal */
|
|
1709
|
+
constructor() {
|
|
1710
|
+
if (new.target === BodyImpl) {
|
|
1711
|
+
throw new TypeError("Failed to construct 'Body': Illegal constructor");
|
|
1712
|
+
}
|
|
1713
|
+
this[state$7] = new BodyState();
|
|
1714
|
+
}
|
|
1715
|
+
get body() {
|
|
1716
|
+
if (!this[state$7][_body]) {
|
|
1717
|
+
return null;
|
|
1718
|
+
}
|
|
1719
|
+
throw new TypeError(`Failed to access 'body' on '${this[state$7].name}': property not implemented.`);
|
|
1720
|
+
}
|
|
1721
|
+
get bodyUsed() { return this[state$7].bodyUsed; }
|
|
1722
|
+
;
|
|
1723
|
+
arrayBuffer() {
|
|
1724
|
+
const kind = "arrayBuffer";
|
|
1725
|
+
return consumed(this, kind) || read(this, kind);
|
|
1726
|
+
}
|
|
1727
|
+
blob() {
|
|
1728
|
+
const kind = "blob";
|
|
1729
|
+
return consumed(this, kind) || read(this, kind);
|
|
1730
|
+
}
|
|
1731
|
+
bytes() {
|
|
1732
|
+
const kind = "bytes";
|
|
1733
|
+
return consumed(this, kind) || read(this, kind);
|
|
1734
|
+
}
|
|
1735
|
+
formData() {
|
|
1736
|
+
const kind = "formData";
|
|
1737
|
+
return consumed(this, kind) || read(this, kind);
|
|
1738
|
+
}
|
|
1739
|
+
json() {
|
|
1740
|
+
const kind = "json";
|
|
1741
|
+
return consumed(this, kind) || read(this, kind);
|
|
1742
|
+
}
|
|
1743
|
+
text() {
|
|
1744
|
+
const kind = "text";
|
|
1745
|
+
return consumed(this, kind) || read(this, kind);
|
|
1746
|
+
}
|
|
1747
|
+
/** @internal */ toString() { return "[object Body]"; }
|
|
1748
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
|
|
1749
|
+
}
|
|
1750
|
+
Class_setStringTag(BodyImpl, "Body");
|
|
1751
|
+
/** @internal */
|
|
1752
|
+
const _body = Symbol();
|
|
1753
|
+
/** @internal */
|
|
1754
|
+
class BodyState {
|
|
1755
|
+
constructor() {
|
|
1756
|
+
this.name = "Body";
|
|
1757
|
+
this.bodyUsed = false;
|
|
1758
|
+
this[_a$3] = "";
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
_a$3 = _body;
|
|
1762
|
+
/** @internal */
|
|
1763
|
+
function Body_init(body, payload) {
|
|
1764
|
+
const b = body;
|
|
1765
|
+
if (isObjectType("ReadableStream", payload)) {
|
|
1766
|
+
throw new TypeError(`Failed to construct '${b[state$7].name}': ReadableStream not implemented.`);
|
|
1767
|
+
}
|
|
1768
|
+
b[state$7][_body] = convert(payload, true, type => { if (!b.headers.has("Content-Type")) {
|
|
1769
|
+
b.headers.set("Content-Type", type);
|
|
1770
|
+
} });
|
|
1771
|
+
}
|
|
1772
|
+
/** @internal */
|
|
1773
|
+
function Body_toPayload(body) {
|
|
1774
|
+
return body[state$7][_body];
|
|
1775
|
+
}
|
|
1776
|
+
function read(body, kind) {
|
|
1777
|
+
return new Promise((resolve, reject) => {
|
|
1778
|
+
try {
|
|
1779
|
+
resolve(readSync(body, kind));
|
|
1780
|
+
}
|
|
1781
|
+
catch (e) {
|
|
1782
|
+
reject(e);
|
|
1783
|
+
}
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
function readSync(body, kind) {
|
|
1787
|
+
const payload = body[state$7][_body];
|
|
1788
|
+
if (kind === "arrayBuffer") {
|
|
1789
|
+
return convertBack("arraybuffer", payload);
|
|
1790
|
+
}
|
|
1791
|
+
else if (kind === "blob") {
|
|
1792
|
+
return convertBack("blob", payload);
|
|
1793
|
+
}
|
|
1794
|
+
else if (kind === "bytes") {
|
|
1795
|
+
let arrayBuffer = convertBack("arraybuffer", payload);
|
|
1796
|
+
return new Uint8Array(arrayBuffer);
|
|
1797
|
+
}
|
|
1798
|
+
else if (kind === "formData") {
|
|
1799
|
+
const extractBoundary = (contentType) => {
|
|
1800
|
+
if (!contentType) {
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
if (!/multipart\/form-data/i.test(contentType)) {
|
|
1804
|
+
return;
|
|
1805
|
+
}
|
|
1806
|
+
let boundaryMatch = contentType.match(/boundary\s*=\s*([^;]+)/i);
|
|
1807
|
+
if (boundaryMatch && boundaryMatch[1]) {
|
|
1808
|
+
let boundary = boundaryMatch[1].trim();
|
|
1809
|
+
return boundary.replace(/^["']|["']$/g, "");
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
let text = convertBack("text", payload);
|
|
1813
|
+
let boundary = extractBoundary(body.headers.get("Content-Type")) || "";
|
|
1814
|
+
return createFormDataFromBinaryText(text, boundary);
|
|
1815
|
+
}
|
|
1816
|
+
else if (kind === "json") {
|
|
1817
|
+
return convertBack("json", payload);
|
|
1818
|
+
}
|
|
1819
|
+
else {
|
|
1820
|
+
return convertBack("text", payload);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
function consumed(body, kind) {
|
|
1824
|
+
const s = body[state$7];
|
|
1825
|
+
if (!s[_body])
|
|
1826
|
+
return;
|
|
1827
|
+
if (s.bodyUsed) {
|
|
1828
|
+
return Promise.reject(new TypeError(`Failed to execute '${kind}' on '${s.name}': body stream already read`));
|
|
1829
|
+
}
|
|
1830
|
+
s.bodyUsed = true;
|
|
1831
|
+
}
|
|
1832
|
+
/** @internal */
|
|
1833
|
+
function convert(body, cloneArrayBuffer = true, setContentType, setContentLength) {
|
|
1834
|
+
let result;
|
|
1835
|
+
if (typeof body === "string") {
|
|
1836
|
+
result = body;
|
|
1837
|
+
if (setContentType) {
|
|
1838
|
+
setContentType("text/plain;charset=UTF-8");
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
else if (isObjectType("URLSearchParams", body)) {
|
|
1842
|
+
result = body.toString();
|
|
1843
|
+
if (setContentType) {
|
|
1844
|
+
setContentType("application/x-www-form-urlencoded;charset=UTF-8");
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
else if (body instanceof ArrayBuffer) {
|
|
1848
|
+
result = cloneArrayBuffer ? body.slice(0) : body;
|
|
1849
|
+
}
|
|
1850
|
+
else if (ArrayBuffer.isView(body)) {
|
|
1851
|
+
result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
1852
|
+
}
|
|
1853
|
+
else if (isPolyfillType("Blob", body)) {
|
|
1854
|
+
result = Blob_toUint8Array(body).buffer.slice(0);
|
|
1855
|
+
if (setContentType && body.type) {
|
|
1856
|
+
setContentType(body.type);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
else if (isPolyfillType("FormData", body)) {
|
|
1860
|
+
let blob = FormData_toBlob(body);
|
|
1861
|
+
result = Blob_toUint8Array(blob).buffer;
|
|
1862
|
+
if (setContentType) {
|
|
1863
|
+
setContentType(blob.type);
|
|
1864
|
+
}
|
|
1205
1865
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1866
|
+
else if (!body) {
|
|
1867
|
+
result = "";
|
|
1208
1868
|
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1869
|
+
else {
|
|
1870
|
+
result = "" + body;
|
|
1211
1871
|
}
|
|
1212
|
-
|
|
1213
|
-
let
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1872
|
+
if (setContentLength) {
|
|
1873
|
+
let calculated = false, contentLength = 0;
|
|
1874
|
+
setContentLength(() => {
|
|
1875
|
+
if (!calculated) {
|
|
1876
|
+
calculated = true;
|
|
1877
|
+
contentLength = (typeof result === "string" ? encode$1(result).buffer : result).byteLength;
|
|
1218
1878
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1879
|
+
return contentLength;
|
|
1880
|
+
});
|
|
1221
1881
|
}
|
|
1222
|
-
|
|
1882
|
+
return result;
|
|
1223
1883
|
}
|
|
1224
|
-
defineStringTag(URLSearchParamsP, "URLSearchParams");
|
|
1225
1884
|
/** @internal */
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
this[_a$5] = {};
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
_a$5 = _urlspDict;
|
|
1234
|
-
function parseToDict(search) {
|
|
1235
|
-
let dict = {};
|
|
1236
|
-
if (typeof search === "object") {
|
|
1237
|
-
// if `search` is an array, treat it as a sequence
|
|
1238
|
-
if (Array.isArray(search)) {
|
|
1239
|
-
for (let i = 0; i < search.length; ++i) {
|
|
1240
|
-
let item = search[i];
|
|
1241
|
-
if (Array.isArray(item) && item.length === 2) {
|
|
1242
|
-
appendTo(dict, item[0], item[1]);
|
|
1243
|
-
}
|
|
1244
|
-
else {
|
|
1245
|
-
throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
else {
|
|
1250
|
-
for (let key in search) {
|
|
1251
|
-
if (search.hasOwnProperty(key)) {
|
|
1252
|
-
appendTo(dict, key, search[key]);
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1885
|
+
function convertBack(type, data) {
|
|
1886
|
+
let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
|
|
1887
|
+
if (!type || type === "text") {
|
|
1888
|
+
return typeof temp === "string" ? temp : decode$1(temp);
|
|
1256
1889
|
}
|
|
1257
|
-
else {
|
|
1258
|
-
|
|
1259
|
-
if (search.indexOf("?") === 0) {
|
|
1260
|
-
search = search.slice(1);
|
|
1261
|
-
}
|
|
1262
|
-
let pairs = search.split("&");
|
|
1263
|
-
for (let j = 0; j < pairs.length; ++j) {
|
|
1264
|
-
let value = pairs[j], index = value.indexOf("=");
|
|
1265
|
-
if (-1 < index) {
|
|
1266
|
-
appendTo(dict, decode$1(value.slice(0, index)), decode$1(value.slice(index + 1)));
|
|
1267
|
-
}
|
|
1268
|
-
else {
|
|
1269
|
-
if (value) {
|
|
1270
|
-
appendTo(dict, decode$1(value), "");
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1890
|
+
else if (type === "json") {
|
|
1891
|
+
return JSON.parse(typeof temp === "string" ? temp : decode$1(temp));
|
|
1274
1892
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
function appendTo(dict, name, value) {
|
|
1278
|
-
let val = typeof value === "string" ? value : (value !== null && value !== undefined && typeof value.toString === "function" ? value.toString() : JSON.stringify(value));
|
|
1279
|
-
// Prevent using `hasOwnProperty` as a property name
|
|
1280
|
-
if (hasOwnProperty(dict, name)) {
|
|
1281
|
-
dict[name].push(val);
|
|
1893
|
+
else if (type === "arraybuffer") {
|
|
1894
|
+
return temp instanceof ArrayBuffer ? temp.slice(0) : encode$1(temp).buffer;
|
|
1282
1895
|
}
|
|
1283
|
-
else {
|
|
1284
|
-
|
|
1896
|
+
else if (type === "blob") {
|
|
1897
|
+
return new BlobP([temp]);
|
|
1285
1898
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
const replace = {
|
|
1289
|
-
"!": "%21",
|
|
1290
|
-
"'": "%27",
|
|
1291
|
-
"(": "%28",
|
|
1292
|
-
")": "%29",
|
|
1293
|
-
"~": "%7E",
|
|
1294
|
-
"%20": "+",
|
|
1295
|
-
"%00": "\x00",
|
|
1296
|
-
};
|
|
1297
|
-
return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, match => replace[match]);
|
|
1298
|
-
}
|
|
1299
|
-
function decode$1(str) {
|
|
1300
|
-
return str
|
|
1301
|
-
.replace(/[ +]/g, "%20")
|
|
1302
|
-
.replace(/(%[a-f0-9]{2})+/ig, match => decodeURIComponent(match));
|
|
1303
|
-
}
|
|
1304
|
-
function hasOwnProperty(obj, prop) {
|
|
1305
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1306
|
-
}
|
|
1307
|
-
function flatCb(acc, cur) {
|
|
1308
|
-
for (let item of cur) {
|
|
1309
|
-
acc.push(item);
|
|
1899
|
+
else {
|
|
1900
|
+
return temp;
|
|
1310
1901
|
}
|
|
1311
|
-
return acc;
|
|
1312
1902
|
}
|
|
1313
|
-
const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
|
|
1314
1903
|
|
|
1315
|
-
var _a$
|
|
1904
|
+
var _a$2;
|
|
1316
1905
|
/** @internal */
|
|
1317
|
-
const state$
|
|
1906
|
+
const state$6 = Symbol( /* "AbortSignalState" */);
|
|
1907
|
+
/** @type {typeof globalThis.AbortSignal} */
|
|
1318
1908
|
class AbortSignalP extends EventTargetP {
|
|
1319
1909
|
static abort(reason) {
|
|
1320
|
-
let signal =
|
|
1321
|
-
|
|
1910
|
+
let signal = createAbortSignal();
|
|
1911
|
+
AbortSignal_abort(signal, reason, false);
|
|
1322
1912
|
return signal;
|
|
1323
1913
|
}
|
|
1324
|
-
static any(
|
|
1325
|
-
|
|
1326
|
-
|
|
1914
|
+
static any(...args) {
|
|
1915
|
+
const [signals] = args;
|
|
1916
|
+
checkArgsLength(args, 1, "AbortSignal", "any");
|
|
1917
|
+
if (!(Array.isArray(signals) || (signals && typeof signals === "object" && Symbol.iterator in signals))) {
|
|
1918
|
+
throw new TypeError("Failed to execute 'any' on 'AbortSignal': The provided value cannot be converted to a sequence.");
|
|
1919
|
+
}
|
|
1920
|
+
let _signals = Array.isArray(signals) ? signals : Array.from(signals);
|
|
1921
|
+
_signals.forEach(sig => {
|
|
1922
|
+
if (!isPolyfillType("EventTarget", sig)) {
|
|
1923
|
+
throw new TypeError("Failed to execute 'any' on 'AbortSignal': Failed to convert value to 'AbortSignal'.");
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
let signal = createAbortSignal();
|
|
1927
|
+
let abortedSignal = _signals.find(x => x.aborted);
|
|
1327
1928
|
if (abortedSignal) {
|
|
1328
|
-
|
|
1929
|
+
AbortSignal_abort(signal, abortedSignal.reason, false);
|
|
1329
1930
|
}
|
|
1330
1931
|
else {
|
|
1331
1932
|
function abortFn(ev) {
|
|
1332
|
-
for (let
|
|
1933
|
+
for (let i = 0; i < _signals.length; ++i) {
|
|
1934
|
+
let sig = _signals[i];
|
|
1333
1935
|
sig.removeEventListener("abort", abortFn);
|
|
1334
1936
|
}
|
|
1335
|
-
|
|
1937
|
+
AbortSignal_abort(signal, this.reason, true, ev.isTrusted);
|
|
1336
1938
|
}
|
|
1337
|
-
for (let
|
|
1939
|
+
for (let i = 0; i < _signals.length; ++i) {
|
|
1940
|
+
let sig = _signals[i];
|
|
1338
1941
|
sig.addEventListener("abort", abortFn);
|
|
1339
1942
|
}
|
|
1340
1943
|
}
|
|
1341
1944
|
return signal;
|
|
1342
1945
|
}
|
|
1343
|
-
static timeout(
|
|
1344
|
-
|
|
1946
|
+
static timeout(...args) {
|
|
1947
|
+
const [milliseconds] = args;
|
|
1948
|
+
checkArgsLength(args, 1, "AbortSignal", "timeout");
|
|
1949
|
+
if (!(milliseconds >= 0)) {
|
|
1950
|
+
throw new TypeError("Failed to execute 'timeout' on 'AbortSignal': Value is outside the 'unsigned long long' value range.");
|
|
1951
|
+
}
|
|
1952
|
+
let signal = createAbortSignal();
|
|
1345
1953
|
setTimeout(() => {
|
|
1346
|
-
|
|
1954
|
+
AbortSignal_abort(signal, new MPException("signal timed out", "TimeoutError"));
|
|
1347
1955
|
}, milliseconds);
|
|
1348
1956
|
return signal;
|
|
1349
1957
|
}
|
|
1958
|
+
/** @internal */
|
|
1350
1959
|
constructor() {
|
|
1351
1960
|
if (new.target === AbortSignalP) {
|
|
1352
1961
|
throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
|
|
1353
1962
|
}
|
|
1354
1963
|
super();
|
|
1355
|
-
this[state$
|
|
1964
|
+
this[state$6] = new AbortSignalState(this);
|
|
1356
1965
|
}
|
|
1357
|
-
get aborted() { return this[state$
|
|
1358
|
-
get reason() { return this[state$
|
|
1966
|
+
get aborted() { return this[state$6].aborted; }
|
|
1967
|
+
get reason() { return this[state$6].reason; }
|
|
1359
1968
|
throwIfAborted() {
|
|
1360
1969
|
if (this.aborted) {
|
|
1361
1970
|
throw this.reason;
|
|
1362
1971
|
}
|
|
1363
1972
|
}
|
|
1364
|
-
get onabort() { return this[state$
|
|
1973
|
+
get onabort() { return this[state$6].onabort; }
|
|
1365
1974
|
set onabort(value) {
|
|
1366
|
-
this[state$
|
|
1367
|
-
attachFn
|
|
1975
|
+
this[state$6].onabort = value;
|
|
1976
|
+
attachFn(this, "abort", value, this[state$6][_handlers$2].onabort);
|
|
1368
1977
|
}
|
|
1369
|
-
toString() { return "[object AbortSignal]"; }
|
|
1370
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
|
|
1978
|
+
/** @internal */ toString() { return "[object AbortSignal]"; }
|
|
1979
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
|
|
1371
1980
|
}
|
|
1372
|
-
|
|
1981
|
+
Class_setStringTag(AbortSignalP, "AbortSignal");
|
|
1373
1982
|
/** @internal */
|
|
1374
1983
|
const _handlers$2 = Symbol();
|
|
1375
1984
|
/** @internal */
|
|
@@ -1377,95 +1986,239 @@ class AbortSignalState {
|
|
|
1377
1986
|
constructor(target) {
|
|
1378
1987
|
this.aborted = false;
|
|
1379
1988
|
this.reason = undefined;
|
|
1380
|
-
this[_a$
|
|
1989
|
+
this[_a$2] = getHandlers$2(this);
|
|
1381
1990
|
this.onabort = null;
|
|
1382
1991
|
this.target = target;
|
|
1383
1992
|
}
|
|
1384
1993
|
}
|
|
1385
|
-
_a$
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1994
|
+
_a$2 = _handlers$2;
|
|
1995
|
+
/** @internal */
|
|
1996
|
+
function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
|
|
1997
|
+
const s = signal[state$6];
|
|
1998
|
+
if (!s.aborted) {
|
|
1999
|
+
s.aborted = true;
|
|
2000
|
+
s.reason = reason !== null && reason !== void 0 ? reason : (new MPException("signal is aborted without reason", "AbortError"));
|
|
1390
2001
|
if (notify) {
|
|
1391
|
-
let evt = createInnerEvent(
|
|
1392
|
-
|
|
2002
|
+
let evt = createInnerEvent(signal, "abort", undefined, isTrusted);
|
|
2003
|
+
EventTarget_fire(signal, evt);
|
|
1393
2004
|
}
|
|
1394
2005
|
}
|
|
1395
2006
|
}
|
|
1396
|
-
function getHandlers$2() {
|
|
2007
|
+
function getHandlers$2(s) {
|
|
1397
2008
|
return {
|
|
1398
|
-
onabort: (ev) => { executeFn
|
|
2009
|
+
onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
|
|
1399
2010
|
};
|
|
1400
2011
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
2012
|
+
/** @internal */
|
|
2013
|
+
function createAbortSignal() {
|
|
2014
|
+
let signal = Object.create(AbortSignalP.prototype);
|
|
2015
|
+
signal[state$d] = new EventTargetState(signal);
|
|
2016
|
+
signal[state$6] = new AbortSignalState(signal);
|
|
2017
|
+
return signal;
|
|
1406
2018
|
}
|
|
1407
2019
|
const AbortSignalE = g["AbortSignal"] || AbortSignalP;
|
|
1408
2020
|
|
|
1409
2021
|
/** @internal */
|
|
1410
|
-
const state$
|
|
2022
|
+
const state$5 = Symbol( /* "AbortControllerState" */);
|
|
2023
|
+
/** @type {typeof globalThis.AbortController} */
|
|
1411
2024
|
class AbortControllerP {
|
|
1412
2025
|
constructor() {
|
|
1413
|
-
this[state$
|
|
2026
|
+
this[state$5] = new AbortControllerState();
|
|
1414
2027
|
}
|
|
1415
|
-
get signal() { return this[state$
|
|
2028
|
+
get signal() { return this[state$5].signal; }
|
|
1416
2029
|
abort(reason) {
|
|
1417
|
-
|
|
2030
|
+
AbortSignal_abort(this[state$5].signal, reason);
|
|
1418
2031
|
}
|
|
1419
|
-
toString() { return "[object AbortController]"; }
|
|
1420
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
|
|
2032
|
+
/** @internal */ toString() { return "[object AbortController]"; }
|
|
2033
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
|
|
1421
2034
|
}
|
|
1422
|
-
|
|
2035
|
+
Class_setStringTag(AbortControllerP, "AbortController");
|
|
1423
2036
|
/** @internal */
|
|
1424
2037
|
class AbortControllerState {
|
|
1425
2038
|
constructor() {
|
|
1426
|
-
this.signal =
|
|
2039
|
+
this.signal = createAbortSignal();
|
|
1427
2040
|
}
|
|
1428
2041
|
}
|
|
1429
2042
|
const AbortControllerE = g["AbortController"] || AbortControllerP;
|
|
1430
2043
|
|
|
1431
|
-
|
|
2044
|
+
/** @internal */ const state$4 = Symbol( /* "RequestState" */);
|
|
2045
|
+
/** @type {typeof globalThis.Request} */
|
|
2046
|
+
class RequestP extends BodyImpl {
|
|
2047
|
+
constructor(...args) {
|
|
2048
|
+
const [input, init] = args;
|
|
2049
|
+
checkArgsLength(args, 1, "Request");
|
|
2050
|
+
super();
|
|
2051
|
+
this[state$7].name = "Request";
|
|
2052
|
+
this[state$4] = new RequestState();
|
|
2053
|
+
const s = this[state$4];
|
|
2054
|
+
let _init = init !== null && init !== void 0 ? init : {};
|
|
2055
|
+
if (typeof _init !== "object") {
|
|
2056
|
+
throw new TypeError("Failed to construct 'Request': The provided value is not of type 'RequestInit'.");
|
|
2057
|
+
}
|
|
2058
|
+
let body = _init.body;
|
|
2059
|
+
if (isPolyfillType("Request", input)) {
|
|
2060
|
+
if (input.bodyUsed) {
|
|
2061
|
+
throw new TypeError("Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used.");
|
|
2062
|
+
}
|
|
2063
|
+
s.cache = input.cache;
|
|
2064
|
+
s.credentials = input.credentials;
|
|
2065
|
+
if (!_init.headers) {
|
|
2066
|
+
s.headers = new HeadersP(input.headers);
|
|
2067
|
+
}
|
|
2068
|
+
s.method = input.method;
|
|
2069
|
+
s.mode = input.mode;
|
|
2070
|
+
let inputSignal = input[state$4].signal;
|
|
2071
|
+
if (inputSignal) {
|
|
2072
|
+
s.signal = inputSignal;
|
|
2073
|
+
}
|
|
2074
|
+
s.url = input.url;
|
|
2075
|
+
let payload = Body_toPayload(input);
|
|
2076
|
+
if (!body && payload !== "") {
|
|
2077
|
+
body = payload;
|
|
2078
|
+
input[state$7].bodyUsed = true;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
else {
|
|
2082
|
+
s.url = "" + input;
|
|
2083
|
+
}
|
|
2084
|
+
if (_init.cache) {
|
|
2085
|
+
s.cache = _init.cache;
|
|
2086
|
+
}
|
|
2087
|
+
if (_init.credentials) {
|
|
2088
|
+
s.credentials = _init.credentials;
|
|
2089
|
+
}
|
|
2090
|
+
if (_init.headers) {
|
|
2091
|
+
s.headers = new HeadersP(_init.headers);
|
|
2092
|
+
}
|
|
2093
|
+
if (_init.method) {
|
|
2094
|
+
s.method = normalizeMethod(_init.method);
|
|
2095
|
+
}
|
|
2096
|
+
if (_init.mode) {
|
|
2097
|
+
s.mode = _init.mode;
|
|
2098
|
+
}
|
|
2099
|
+
if (_init.signal) {
|
|
2100
|
+
s.signal = _init.signal;
|
|
2101
|
+
}
|
|
2102
|
+
if ((this.method === "GET" || this.method === "HEAD") && body) {
|
|
2103
|
+
throw new TypeError("Failed to construct 'Request': Request with GET/HEAD method cannot have body.");
|
|
2104
|
+
}
|
|
2105
|
+
Body_init(this, body);
|
|
2106
|
+
if (this.method === "GET" || this.method === "HEAD") {
|
|
2107
|
+
if (_init.cache === "no-store" || _init.cache === "no-cache") {
|
|
2108
|
+
// Search for a '_' parameter in the query string
|
|
2109
|
+
let reParamSearch = /([?&])_=[^&]*/;
|
|
2110
|
+
if (reParamSearch.test(this.url)) {
|
|
2111
|
+
// If it already exists then set the value with the current time
|
|
2112
|
+
s.url = this.url.replace(reParamSearch, "$1_=" + (new Date()).getTime());
|
|
2113
|
+
}
|
|
2114
|
+
else {
|
|
2115
|
+
// Otherwise add a new '_' parameter to the end with the current time
|
|
2116
|
+
let reQueryString = /\?/;
|
|
2117
|
+
s.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (new Date()).getTime();
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
get cache() { return this[state$4].cache; }
|
|
2123
|
+
get credentials() { return this[state$4].credentials; }
|
|
2124
|
+
get destination() { return this[state$4].destination; }
|
|
2125
|
+
get headers() {
|
|
2126
|
+
const s = this[state$4];
|
|
2127
|
+
if (!s.headers) {
|
|
2128
|
+
s.headers = new HeadersP();
|
|
2129
|
+
}
|
|
2130
|
+
return s.headers;
|
|
2131
|
+
}
|
|
2132
|
+
get integrity() { return this[state$4].integrity; }
|
|
2133
|
+
get keepalive() { return this[state$4].keepalive; }
|
|
2134
|
+
get method() { return this[state$4].method; }
|
|
2135
|
+
get mode() { return this[state$4].mode; }
|
|
2136
|
+
get redirect() { return this[state$4].redirect; }
|
|
2137
|
+
get referrer() { return this[state$4].referrer; }
|
|
2138
|
+
get referrerPolicy() { return this[state$4].referrerPolicy; }
|
|
2139
|
+
get signal() {
|
|
2140
|
+
const s = this[state$4];
|
|
2141
|
+
if (!s.signal) {
|
|
2142
|
+
s.signal = (new AbortControllerP()).signal;
|
|
2143
|
+
}
|
|
2144
|
+
return s.signal;
|
|
2145
|
+
}
|
|
2146
|
+
get url() { return this[state$4].url; }
|
|
2147
|
+
clone() {
|
|
2148
|
+
var _a;
|
|
2149
|
+
if (this.bodyUsed) {
|
|
2150
|
+
throw new TypeError("Failed to execute 'clone' on 'Request': Request body is already used");
|
|
2151
|
+
}
|
|
2152
|
+
return new RequestP(this, { body: (_a = Body_toPayload(this)) !== null && _a !== void 0 ? _a : null });
|
|
2153
|
+
}
|
|
2154
|
+
/** @internal */ toString() { return "[object Request]"; }
|
|
2155
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
|
|
2156
|
+
}
|
|
2157
|
+
Class_setStringTag(RequestP, "Request");
|
|
2158
|
+
/** @internal */
|
|
2159
|
+
class RequestState {
|
|
2160
|
+
constructor() {
|
|
2161
|
+
this.cache = "default";
|
|
2162
|
+
this.credentials = "same-origin";
|
|
2163
|
+
this.destination = "";
|
|
2164
|
+
this.integrity = "";
|
|
2165
|
+
this.keepalive = false;
|
|
2166
|
+
this.method = "GET";
|
|
2167
|
+
this.mode = "cors";
|
|
2168
|
+
this.redirect = "follow";
|
|
2169
|
+
this.referrer = "about:client";
|
|
2170
|
+
this.referrerPolicy = "";
|
|
2171
|
+
this.url = "";
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
// HTTP methods whose capitalization should be normalized
|
|
2175
|
+
const methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
|
|
1432
2176
|
/** @internal */
|
|
1433
|
-
|
|
2177
|
+
function normalizeMethod(method) {
|
|
2178
|
+
let upcased = method.toUpperCase();
|
|
2179
|
+
return methods.indexOf(upcased) > -1 ? upcased : method;
|
|
2180
|
+
}
|
|
2181
|
+
const RequestE = g["Request"] || RequestP;
|
|
2182
|
+
|
|
2183
|
+
var _a$1;
|
|
2184
|
+
/** @internal */ const state$3 = Symbol( /* "XMLHttpRequestEventTargetState" */);
|
|
2185
|
+
/** @type {typeof globalThis.XMLHttpRequestEventTarget} */
|
|
1434
2186
|
class XMLHttpRequestEventTargetP extends EventTargetP {
|
|
2187
|
+
/** @internal */
|
|
1435
2188
|
constructor() {
|
|
1436
2189
|
if (new.target === XMLHttpRequestEventTargetP) {
|
|
1437
2190
|
throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
|
|
1438
2191
|
}
|
|
1439
2192
|
super();
|
|
1440
|
-
this[state$
|
|
1441
|
-
}
|
|
1442
|
-
get onabort() { return this[state$
|
|
1443
|
-
set onabort(value) { this[state$
|
|
1444
|
-
get onerror() { return this[state$
|
|
1445
|
-
set onerror(value) { this[state$
|
|
1446
|
-
get onload() { return this[state$
|
|
1447
|
-
set onload(value) { this[state$
|
|
1448
|
-
get onloadend() { return this[state$
|
|
1449
|
-
set onloadend(value) { this[state$
|
|
1450
|
-
get onloadstart() { return this[state$
|
|
1451
|
-
set onloadstart(value) { this[state$
|
|
1452
|
-
get onprogress() { return this[state$
|
|
1453
|
-
set onprogress(value) { this[state$
|
|
1454
|
-
get ontimeout() { return this[state$
|
|
1455
|
-
set ontimeout(value) { this[state$
|
|
1456
|
-
toString() { return "[object XMLHttpRequestEventTarget]"; }
|
|
1457
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1458
|
-
}
|
|
1459
|
-
|
|
2193
|
+
this[state$3] = new XMLHttpRequestEventTargetState(this);
|
|
2194
|
+
}
|
|
2195
|
+
get onabort() { return this[state$3].onabort; }
|
|
2196
|
+
set onabort(value) { this[state$3].onabort = value; attach(this, "abort"); }
|
|
2197
|
+
get onerror() { return this[state$3].onerror; }
|
|
2198
|
+
set onerror(value) { this[state$3].onerror = value; attach(this, "error"); }
|
|
2199
|
+
get onload() { return this[state$3].onload; }
|
|
2200
|
+
set onload(value) { this[state$3].onload = value; attach(this, "load"); }
|
|
2201
|
+
get onloadend() { return this[state$3].onloadend; }
|
|
2202
|
+
set onloadend(value) { this[state$3].onloadend = value; attach(this, "loadend"); }
|
|
2203
|
+
get onloadstart() { return this[state$3].onloadstart; }
|
|
2204
|
+
set onloadstart(value) { this[state$3].onloadstart = value; attach(this, "loadstart"); }
|
|
2205
|
+
get onprogress() { return this[state$3].onprogress; }
|
|
2206
|
+
set onprogress(value) { this[state$3].onprogress = value; attach(this, "progress"); }
|
|
2207
|
+
get ontimeout() { return this[state$3].ontimeout; }
|
|
2208
|
+
set ontimeout(value) { this[state$3].ontimeout = value; attach(this, "timeout"); }
|
|
2209
|
+
/** @internal */ toString() { return "[object XMLHttpRequestEventTarget]"; }
|
|
2210
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2211
|
+
}
|
|
2212
|
+
Class_setStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
|
|
1460
2213
|
/** @internal */
|
|
1461
2214
|
const _handlers$1 = Symbol();
|
|
1462
2215
|
/** @internal */
|
|
1463
2216
|
class XMLHttpRequestEventTargetState {
|
|
1464
2217
|
/**
|
|
1465
|
-
* @param _target
|
|
2218
|
+
* @param _target XMLHttpRequestEventTarget
|
|
1466
2219
|
*/
|
|
1467
2220
|
constructor(_target) {
|
|
1468
|
-
this[_a$
|
|
2221
|
+
this[_a$1] = getHandlers$1(this);
|
|
1469
2222
|
this.onabort = null;
|
|
1470
2223
|
this.onerror = null;
|
|
1471
2224
|
this.onload = null;
|
|
@@ -1476,45 +2229,50 @@ class XMLHttpRequestEventTargetState {
|
|
|
1476
2229
|
this.target = _target;
|
|
1477
2230
|
}
|
|
1478
2231
|
}
|
|
1479
|
-
_a$
|
|
1480
|
-
function attach(type) {
|
|
2232
|
+
_a$1 = _handlers$1;
|
|
2233
|
+
function attach(target, type) {
|
|
2234
|
+
const s = target[state$3];
|
|
1481
2235
|
const fnName = ("on" + type);
|
|
1482
|
-
const cb =
|
|
1483
|
-
const listener =
|
|
1484
|
-
attachFn
|
|
2236
|
+
const cb = s[fnName];
|
|
2237
|
+
const listener = s[_handlers$1][fnName];
|
|
2238
|
+
attachFn(target, type, cb, listener);
|
|
1485
2239
|
}
|
|
1486
|
-
function getHandlers$1() {
|
|
2240
|
+
function getHandlers$1(s) {
|
|
1487
2241
|
return {
|
|
1488
|
-
onabort: (ev) => { executeFn
|
|
1489
|
-
onerror: (ev) => { executeFn
|
|
1490
|
-
onload: (ev) => { executeFn
|
|
1491
|
-
onloadend: (ev) => { executeFn
|
|
1492
|
-
onloadstart: (ev) => { executeFn
|
|
1493
|
-
onprogress: (ev) => { executeFn
|
|
1494
|
-
ontimeout: (ev) => { executeFn
|
|
2242
|
+
onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
|
|
2243
|
+
onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
|
|
2244
|
+
onload: (ev) => { executeFn(s.target, s.onload, ev); },
|
|
2245
|
+
onloadend: (ev) => { executeFn(s.target, s.onloadend, ev); },
|
|
2246
|
+
onloadstart: (ev) => { executeFn(s.target, s.onloadstart, ev); },
|
|
2247
|
+
onprogress: (ev) => { executeFn(s.target, s.onprogress, ev); },
|
|
2248
|
+
ontimeout: (ev) => { executeFn(s.target, s.ontimeout, ev); },
|
|
1495
2249
|
};
|
|
1496
2250
|
}
|
|
1497
2251
|
|
|
2252
|
+
/** @type {typeof globalThis.XMLHttpRequestUpload} */
|
|
1498
2253
|
class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
|
|
2254
|
+
/** @internal */
|
|
1499
2255
|
constructor() {
|
|
1500
2256
|
if (new.target === XMLHttpRequestUploadP) {
|
|
1501
2257
|
throw new TypeError("Failed to construct 'XMLHttpRequestUpload': Illegal constructor");
|
|
1502
2258
|
}
|
|
1503
2259
|
super();
|
|
1504
2260
|
}
|
|
1505
|
-
toString() { return "[object XMLHttpRequestUpload]"; }
|
|
1506
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2261
|
+
/** @internal */ toString() { return "[object XMLHttpRequestUpload]"; }
|
|
2262
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1507
2263
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
2264
|
+
Class_setStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
|
|
2265
|
+
/** @internal */
|
|
2266
|
+
function createXMLHttpRequestUpload() {
|
|
2267
|
+
let upload = Object.create(XMLHttpRequestUploadP.prototype);
|
|
2268
|
+
upload[state$d] = new EventTargetState(upload);
|
|
2269
|
+
upload[state$3] = new XMLHttpRequestEventTargetState(upload);
|
|
2270
|
+
return upload;
|
|
1514
2271
|
}
|
|
1515
2272
|
|
|
1516
2273
|
// @ts-nocheck
|
|
1517
|
-
|
|
2274
|
+
/** @internal */
|
|
2275
|
+
const mp$2 = (() => {
|
|
1518
2276
|
let u = "undefined", r = "request", f = "function";
|
|
1519
2277
|
let mp;
|
|
1520
2278
|
mp =
|
|
@@ -1539,7 +2297,7 @@ const mp = (() => {
|
|
|
1539
2297
|
return mp;
|
|
1540
2298
|
})();
|
|
1541
2299
|
|
|
1542
|
-
const request = mp ? mp.request : function errorRequest(options) {
|
|
2300
|
+
const request = mp$2 ? mp$2.request : function errorRequest(options) {
|
|
1543
2301
|
const errMsg = "NOT_SUPPORTED_ERR";
|
|
1544
2302
|
const errno = 9;
|
|
1545
2303
|
const err = {
|
|
@@ -1558,7 +2316,7 @@ const request = mp ? mp.request : function errorRequest(options) {
|
|
|
1558
2316
|
}
|
|
1559
2317
|
}
|
|
1560
2318
|
catch (e) {
|
|
1561
|
-
console.
|
|
2319
|
+
console.error(e);
|
|
1562
2320
|
} })
|
|
1563
2321
|
.then(() => { if (options.complete) {
|
|
1564
2322
|
options.complete(err);
|
|
@@ -1566,144 +2324,159 @@ const request = mp ? mp.request : function errorRequest(options) {
|
|
|
1566
2324
|
throw new ReferenceError("request is not defined");
|
|
1567
2325
|
};
|
|
1568
2326
|
|
|
1569
|
-
var _a
|
|
2327
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2328
|
+
const mp$1 = { request: request };
|
|
2329
|
+
const setRequest = (request) => { mp$1.request = request; };
|
|
1570
2330
|
/** @internal */
|
|
1571
|
-
const state$
|
|
2331
|
+
const state$2 = Symbol( /* "XMLHttpRequestState" */);
|
|
2332
|
+
/** @type {typeof globalThis.XMLHttpRequest} */
|
|
1572
2333
|
class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
1573
2334
|
constructor() {
|
|
1574
2335
|
super();
|
|
1575
|
-
this[state$
|
|
2336
|
+
this[state$2] = new XMLHttpRequestState(this);
|
|
1576
2337
|
}
|
|
1577
|
-
get readyState() { return this[state$
|
|
1578
|
-
get response() { return this[state$
|
|
2338
|
+
get readyState() { return this[state$2].readyState; }
|
|
2339
|
+
get response() { return this[state$2].response; }
|
|
1579
2340
|
get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
|
|
1580
|
-
get responseType() { return this[state$
|
|
1581
|
-
set responseType(value) { this[state$
|
|
1582
|
-
get responseURL() { return this[state$
|
|
2341
|
+
get responseType() { return this[state$2].responseType; }
|
|
2342
|
+
set responseType(value) { this[state$2].responseType = normalizeResponseType(value); }
|
|
2343
|
+
get responseURL() { return this[state$2].responseURL; }
|
|
1583
2344
|
get responseXML() { return null; }
|
|
1584
|
-
get status() { return this[state$
|
|
2345
|
+
get status() { return this[state$2].status; }
|
|
1585
2346
|
get statusText() {
|
|
1586
2347
|
if (this.readyState === XMLHttpRequestP.UNSENT || this.readyState === XMLHttpRequestP.OPENED)
|
|
1587
2348
|
return "";
|
|
1588
|
-
return this[state$
|
|
2349
|
+
return this[state$2].statusText || statusTextMap(this.status);
|
|
1589
2350
|
}
|
|
1590
|
-
get timeout() { return this[state$
|
|
1591
|
-
set timeout(value) { this[state$
|
|
2351
|
+
get timeout() { return this[state$2].timeout; }
|
|
2352
|
+
set timeout(value) { this[state$2].timeout = value > 0 ? value : 0; }
|
|
1592
2353
|
get upload() {
|
|
1593
|
-
const
|
|
1594
|
-
if (!
|
|
1595
|
-
|
|
2354
|
+
const s = this[state$2];
|
|
2355
|
+
if (!s.upload) {
|
|
2356
|
+
s.upload = createXMLHttpRequestUpload();
|
|
1596
2357
|
}
|
|
1597
|
-
return
|
|
2358
|
+
return s.upload;
|
|
1598
2359
|
}
|
|
1599
|
-
get withCredentials() { return this[state$
|
|
1600
|
-
set withCredentials(value) { this[state$
|
|
2360
|
+
get withCredentials() { return this[state$2].withCredentials; }
|
|
2361
|
+
set withCredentials(value) { this[state$2].withCredentials = !!value; }
|
|
1601
2362
|
abort() {
|
|
1602
|
-
clearRequest
|
|
2363
|
+
clearRequest(this);
|
|
1603
2364
|
}
|
|
1604
2365
|
getAllResponseHeaders() {
|
|
1605
|
-
if (!this[state$
|
|
2366
|
+
if (!this[state$2][_responseHeaders])
|
|
1606
2367
|
return "";
|
|
1607
|
-
return
|
|
2368
|
+
return Array.from(this[state$2][_responseHeaders].entries()).map(([k, v]) => `${k}: ${v}\r\n`).join("");
|
|
1608
2369
|
}
|
|
1609
|
-
getResponseHeader(
|
|
1610
|
-
|
|
1611
|
-
|
|
2370
|
+
getResponseHeader(...args) {
|
|
2371
|
+
const [name] = args;
|
|
2372
|
+
checkArgsLength(args, 1, "XMLHttpRequest", "getResponseHeader");
|
|
2373
|
+
if (!this[state$2][_responseHeaders])
|
|
1612
2374
|
return null;
|
|
1613
|
-
|
|
1614
|
-
return (_m = (_l = objectEntries(this[state$4][_responseHeaders] || {}).find(x => x[0].toLowerCase() === nameKey)) === null || _l === void 0 ? void 0 : _l[1]) !== null && _m !== void 0 ? _m : null;
|
|
2375
|
+
return this[state$2][_responseHeaders].get(name);
|
|
1615
2376
|
}
|
|
1616
2377
|
open(...args) {
|
|
1617
2378
|
const [method, url, async = true, username = null, password = null] = args;
|
|
1618
|
-
|
|
1619
|
-
if (args.length < 2) {
|
|
1620
|
-
throw new TypeError(`Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${args.length} present.`);
|
|
1621
|
-
}
|
|
2379
|
+
checkArgsLength(args, 2, "XMLHttpRequest", "open");
|
|
1622
2380
|
if (!async) {
|
|
1623
2381
|
console.warn("Synchronous XMLHttpRequest is not supported because of its detrimental effects to the end user's experience.");
|
|
1624
2382
|
}
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
2383
|
+
const s = this[state$2];
|
|
2384
|
+
clearRequest(this, false);
|
|
2385
|
+
s[_method] = normalizeMethod(method);
|
|
2386
|
+
s[_requestURL] = "" + url;
|
|
1628
2387
|
if (username !== null || password !== null) {
|
|
1629
|
-
let _username =
|
|
1630
|
-
let _password =
|
|
2388
|
+
let _username = "" + (username !== null && username !== void 0 ? username : "");
|
|
2389
|
+
let _password = "" + (password !== null && password !== void 0 ? password : "");
|
|
1631
2390
|
if (_username.length > 0 || _password.length > 0) {
|
|
1632
|
-
let auth = `Basic ${
|
|
2391
|
+
let auth = `Basic ${Uint8Array_toBase64(encode$1(_username + ":" + _password))}`;
|
|
1633
2392
|
this.setRequestHeader("Authorization", auth);
|
|
1634
2393
|
}
|
|
1635
2394
|
}
|
|
1636
|
-
|
|
1637
|
-
setReadyStateAndNotify
|
|
2395
|
+
s[_inAfterOpenBeforeSend] = true;
|
|
2396
|
+
setReadyStateAndNotify(this, XMLHttpRequestP.OPENED);
|
|
1638
2397
|
}
|
|
1639
|
-
overrideMimeType(
|
|
1640
|
-
|
|
1641
|
-
|
|
2398
|
+
overrideMimeType(...args) {
|
|
2399
|
+
const [mime] = args;
|
|
2400
|
+
checkArgsLength(args, 1, "XMLHttpRequest", "overrideMimeType");
|
|
2401
|
+
if (this[state$2][_inAfterOpenBeforeSend]) {
|
|
2402
|
+
console.error(`TypeError: Failed to execute 'overrideMimeType' on 'XMLHttpRequest': mimeType ('${mime}') not implemented.`);
|
|
1642
2403
|
}
|
|
1643
2404
|
}
|
|
1644
2405
|
send(body) {
|
|
1645
|
-
const
|
|
1646
|
-
if (!
|
|
2406
|
+
const s = this[state$2];
|
|
2407
|
+
if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestP.OPENED) {
|
|
1647
2408
|
throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
1648
2409
|
}
|
|
1649
|
-
|
|
1650
|
-
const allowsRequestBody =
|
|
1651
|
-
const processHeaders = allowsRequestBody &&
|
|
1652
|
-
const
|
|
1653
|
-
|
|
1654
|
-
let headers = processHeaders ? Object.assign({}, that[_requestHeaders]) : that[_requestHeaders];
|
|
2410
|
+
s[_inAfterOpenBeforeSend] = false;
|
|
2411
|
+
const allowsRequestBody = s[_method] !== "GET" && s[_method] !== "HEAD";
|
|
2412
|
+
const processHeaders = allowsRequestBody && !s[_requestHeaders].has("Content-Type");
|
|
2413
|
+
const processContentLength = allowsRequestBody && !!body;
|
|
2414
|
+
let headers = () => { let dict = {}; s[_requestHeaders].forEach((value, name) => { dict[name] = value; }); return dict; };
|
|
1655
2415
|
let contentLength = zero;
|
|
1656
|
-
|
|
2416
|
+
const processHeadersFn = processHeaders ? (v) => { s[_requestHeaders].set("Content-Type", v); } : void 0;
|
|
2417
|
+
const processContentLengthFn = processContentLength ? (v) => { contentLength = v; } : void 0;
|
|
2418
|
+
let data = body;
|
|
2419
|
+
try {
|
|
2420
|
+
data = convert(body, false, processHeadersFn, processContentLengthFn);
|
|
2421
|
+
}
|
|
2422
|
+
catch (e) {
|
|
2423
|
+
console.warn(e);
|
|
2424
|
+
}
|
|
1657
2425
|
let options = {
|
|
1658
|
-
url:
|
|
1659
|
-
method:
|
|
1660
|
-
header: headers,
|
|
2426
|
+
url: s[_requestURL],
|
|
2427
|
+
method: s[_method],
|
|
2428
|
+
header: headers(),
|
|
1661
2429
|
data,
|
|
1662
|
-
dataType:
|
|
1663
|
-
responseType: normalizeDataType(
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
2430
|
+
dataType: s.responseType === "json" ? "json" : normalizeDataType(s.responseType),
|
|
2431
|
+
responseType: normalizeDataType(s.responseType),
|
|
2432
|
+
withCredentials: s.withCredentials,
|
|
2433
|
+
success: requestSuccess.bind(this),
|
|
2434
|
+
fail: requestFail.bind(this),
|
|
2435
|
+
complete: requestComplete.bind(this),
|
|
1667
2436
|
};
|
|
1668
|
-
|
|
1669
|
-
options.withCredentials = true;
|
|
1670
|
-
options.enableCookie = true;
|
|
1671
|
-
}
|
|
1672
|
-
that[_requestTask] = request(options);
|
|
2437
|
+
s[_requestTask] = mp$1.request(options);
|
|
1673
2438
|
emitProcessEvent(this, "loadstart");
|
|
1674
|
-
if (processContentLength) {
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
const _aborted = that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED;
|
|
2439
|
+
if (processContentLength && s.upload) {
|
|
2440
|
+
emitProcessEvent(this.upload, "loadstart", 0, contentLength);
|
|
2441
|
+
}
|
|
2442
|
+
setTimeout(() => {
|
|
2443
|
+
if (s.upload) {
|
|
2444
|
+
const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestP.OPENED;
|
|
1681
2445
|
const _contentLength = _aborted ? 0 : contentLength;
|
|
1682
2446
|
if (_aborted) {
|
|
1683
|
-
emitProcessEvent(upload, "abort");
|
|
2447
|
+
emitProcessEvent(this.upload, "abort");
|
|
1684
2448
|
}
|
|
1685
2449
|
else {
|
|
1686
|
-
if (
|
|
1687
|
-
emitProcessEvent(upload, "load", _contentLength, _contentLength);
|
|
2450
|
+
if (processContentLength) {
|
|
2451
|
+
emitProcessEvent(this.upload, "load", _contentLength, _contentLength);
|
|
1688
2452
|
}
|
|
1689
2453
|
}
|
|
1690
|
-
if (_aborted ||
|
|
1691
|
-
emitProcessEvent(upload, "loadend", _contentLength, _contentLength);
|
|
2454
|
+
if (_aborted || processContentLength) {
|
|
2455
|
+
emitProcessEvent(this.upload, "loadend", _contentLength, _contentLength);
|
|
1692
2456
|
}
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
checkRequestTimeout
|
|
2457
|
+
}
|
|
2458
|
+
});
|
|
2459
|
+
checkRequestTimeout(this);
|
|
1696
2460
|
}
|
|
1697
|
-
setRequestHeader(
|
|
1698
|
-
|
|
2461
|
+
setRequestHeader(...args) {
|
|
2462
|
+
const [name, value] = args;
|
|
2463
|
+
checkArgsLength(args, 2, "XMLHttpRequest", "setRequestHeader");
|
|
2464
|
+
const s = this[state$2];
|
|
2465
|
+
if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestP.OPENED) {
|
|
2466
|
+
throw new MPException("Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
2467
|
+
}
|
|
2468
|
+
let _name = normalizeName(name, () => {
|
|
2469
|
+
throw new SyntaxError(`Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '${name}' is not a valid HTTP header field name.`);
|
|
2470
|
+
});
|
|
2471
|
+
s[_requestHeaders].append(_name, value);
|
|
1699
2472
|
}
|
|
1700
|
-
get onreadystatechange() { return this[state$
|
|
2473
|
+
get onreadystatechange() { return this[state$2].onreadystatechange; }
|
|
1701
2474
|
set onreadystatechange(value) {
|
|
1702
|
-
this[state$
|
|
1703
|
-
attachFn
|
|
2475
|
+
this[state$2].onreadystatechange = value;
|
|
2476
|
+
attachFn(this, "readystatechange", value, this[state$2][_handlers].onreadystatechange);
|
|
1704
2477
|
}
|
|
1705
|
-
toString() { return "[object XMLHttpRequest]"; }
|
|
1706
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2478
|
+
/** @internal */ toString() { return "[object XMLHttpRequest]"; }
|
|
2479
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
1707
2480
|
}
|
|
1708
2481
|
const properties = {
|
|
1709
2482
|
UNSENT: { value: 0, enumerable: true },
|
|
@@ -1714,7 +2487,7 @@ const properties = {
|
|
|
1714
2487
|
};
|
|
1715
2488
|
Object.defineProperties(XMLHttpRequestP, properties);
|
|
1716
2489
|
Object.defineProperties(XMLHttpRequestP.prototype, properties);
|
|
1717
|
-
|
|
2490
|
+
Class_setStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
1718
2491
|
/** @internal */ const _handlers = Symbol();
|
|
1719
2492
|
/** @internal */ const _inAfterOpenBeforeSend = Symbol();
|
|
1720
2493
|
/** @internal */ const _resetPending = Symbol();
|
|
@@ -1722,7 +2495,7 @@ defineStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
|
1722
2495
|
/** @internal */ const _requestURL = Symbol();
|
|
1723
2496
|
/** @internal */ const _method = Symbol();
|
|
1724
2497
|
/** @internal */ const _requestHeaders = Symbol();
|
|
1725
|
-
const _responseHeaders = Symbol();
|
|
2498
|
+
/** @internal */ const _responseHeaders = Symbol();
|
|
1726
2499
|
/** @internal */ const _responseContentLength = Symbol();
|
|
1727
2500
|
/** @internal */ const _requestTask = Symbol();
|
|
1728
2501
|
/** @internal */
|
|
@@ -1736,40 +2509,41 @@ class XMLHttpRequestState {
|
|
|
1736
2509
|
this.statusText = "";
|
|
1737
2510
|
this.timeout = 0;
|
|
1738
2511
|
this.withCredentials = false;
|
|
1739
|
-
this[_a
|
|
2512
|
+
this[_a] = getHandlers(this);
|
|
1740
2513
|
this.onreadystatechange = null;
|
|
1741
|
-
this[_b
|
|
2514
|
+
this[_b] = false;
|
|
1742
2515
|
this[_c] = false;
|
|
1743
2516
|
this[_d] = 0;
|
|
1744
2517
|
this[_e] = "";
|
|
1745
2518
|
this[_f] = "GET";
|
|
1746
|
-
this[_g] =
|
|
2519
|
+
this[_g] = new HeadersP();
|
|
1747
2520
|
this[_h] = null;
|
|
1748
2521
|
this[_j] = zero;
|
|
1749
2522
|
this[_k] = null;
|
|
1750
2523
|
this.target = target;
|
|
1751
2524
|
}
|
|
1752
2525
|
}
|
|
1753
|
-
_a
|
|
2526
|
+
_a = _handlers, _b = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
|
|
1754
2527
|
function requestSuccess({ statusCode, header, data }) {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
setReadyStateAndNotify
|
|
2528
|
+
const s = this[state$2];
|
|
2529
|
+
s.responseURL = s[_requestURL];
|
|
2530
|
+
s.status = statusCode;
|
|
2531
|
+
s[_responseHeaders] = new HeadersP(header);
|
|
2532
|
+
let lengthStr = s[_responseHeaders].get("Content-Length");
|
|
2533
|
+
s[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
|
|
2534
|
+
if (s.readyState === XMLHttpRequestP.OPENED) {
|
|
2535
|
+
setReadyStateAndNotify(this, XMLHttpRequestP.HEADERS_RECEIVED);
|
|
2536
|
+
setReadyStateAndNotify(this, XMLHttpRequestP.LOADING);
|
|
1763
2537
|
setTimeout(() => {
|
|
1764
|
-
if (!
|
|
1765
|
-
let l =
|
|
2538
|
+
if (!s[_inAfterOpenBeforeSend]) {
|
|
2539
|
+
let l = s[_responseContentLength];
|
|
1766
2540
|
try {
|
|
1767
|
-
|
|
1768
|
-
emitProcessEvent(this
|
|
2541
|
+
s.response = convertBack(s.responseType, data);
|
|
2542
|
+
emitProcessEvent(this, "load", l, l);
|
|
1769
2543
|
}
|
|
1770
2544
|
catch (e) {
|
|
1771
2545
|
console.error(e);
|
|
1772
|
-
emitProcessEvent(this
|
|
2546
|
+
emitProcessEvent(this, "error");
|
|
1773
2547
|
}
|
|
1774
2548
|
}
|
|
1775
2549
|
});
|
|
@@ -1783,193 +2557,115 @@ function requestFail(err) {
|
|
|
1783
2557
|
// returned from the server: status, headers, and data.
|
|
1784
2558
|
// In the browser's XMLHttpRequest, these two errors (Error 14 and Error 19)
|
|
1785
2559
|
// differ from those in Alipay Mini Programs and should instead return normally.
|
|
1786
|
-
// Therefore, this scenario is also handled here as a successful request response.
|
|
1787
|
-
if ("status" in err) {
|
|
1788
|
-
requestSuccess.call(this, { statusCode: err.status, header: err.headers, data: err.data });
|
|
1789
|
-
return;
|
|
1790
|
-
}
|
|
1791
|
-
this.status = 0;
|
|
1792
|
-
this.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
|
|
1793
|
-
if (!this[_inAfterOpenBeforeSend] && this.readyState !== XMLHttpRequestP.UNSENT && this.readyState !== XMLHttpRequestP.DONE) {
|
|
1794
|
-
emitProcessEvent(this.target, "error");
|
|
1795
|
-
resetRequestTimeout.call(this);
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
function requestComplete() {
|
|
1799
|
-
this[_requestTask] = null;
|
|
1800
|
-
if (!this[_inAfterOpenBeforeSend] && (this.readyState === XMLHttpRequestP.OPENED || this.readyState === XMLHttpRequestP.LOADING)) {
|
|
1801
|
-
setReadyStateAndNotify.call(this, XMLHttpRequestP.DONE);
|
|
1802
|
-
}
|
|
1803
|
-
setTimeout(() => {
|
|
1804
|
-
if (!this[_inAfterOpenBeforeSend]) {
|
|
1805
|
-
let l = this[_responseContentLength];
|
|
1806
|
-
emitProcessEvent(this.target, "loadend", l, l);
|
|
1807
|
-
}
|
|
1808
|
-
});
|
|
1809
|
-
}
|
|
1810
|
-
function clearRequest(delay = true) {
|
|
1811
|
-
const timerFn = delay ? setTimeout : (f) => { f(); };
|
|
1812
|
-
this[_resetPending] = true;
|
|
1813
|
-
if (this[_requestTask] && this.readyState !== XMLHttpRequestP.DONE) {
|
|
1814
|
-
if (delay) {
|
|
1815
|
-
setReadyStateAndNotify.call(this, XMLHttpRequestP.DONE);
|
|
1816
|
-
}
|
|
1817
|
-
timerFn(() => {
|
|
1818
|
-
const requestTask = this[_requestTask];
|
|
1819
|
-
if (requestTask) {
|
|
1820
|
-
requestTask.abort();
|
|
1821
|
-
}
|
|
1822
|
-
if (delay) {
|
|
1823
|
-
emitProcessEvent(this.target, "abort");
|
|
1824
|
-
}
|
|
1825
|
-
if (delay && !requestTask) {
|
|
1826
|
-
emitProcessEvent(this.target, "loadend");
|
|
1827
|
-
}
|
|
1828
|
-
});
|
|
1829
|
-
}
|
|
1830
|
-
timerFn(() => {
|
|
1831
|
-
if (this[_resetPending]) {
|
|
1832
|
-
if (delay) {
|
|
1833
|
-
this.readyState = XMLHttpRequestP.UNSENT;
|
|
1834
|
-
}
|
|
1835
|
-
resetXHR.call(this);
|
|
1836
|
-
}
|
|
1837
|
-
});
|
|
1838
|
-
}
|
|
1839
|
-
function checkRequestTimeout() {
|
|
1840
|
-
if (this.timeout) {
|
|
1841
|
-
this[_timeoutId] = setTimeout(() => {
|
|
1842
|
-
if (!this.status && this.readyState !== XMLHttpRequestP.DONE) {
|
|
1843
|
-
if (this[_requestTask])
|
|
1844
|
-
this[_requestTask].abort();
|
|
1845
|
-
setReadyStateAndNotify.call(this, XMLHttpRequestP.DONE);
|
|
1846
|
-
emitProcessEvent(this.target, "timeout");
|
|
1847
|
-
}
|
|
1848
|
-
}, this.timeout);
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
function resetXHR() {
|
|
1852
|
-
this[_resetPending] = false;
|
|
1853
|
-
resetRequestTimeout.call(this);
|
|
1854
|
-
this.response = "";
|
|
1855
|
-
this.responseURL = "";
|
|
1856
|
-
this.status = 0;
|
|
1857
|
-
this.statusText = "";
|
|
1858
|
-
this[_requestHeaders] = {};
|
|
1859
|
-
this[_responseHeaders] = null;
|
|
1860
|
-
this[_responseContentLength] = zero;
|
|
1861
|
-
}
|
|
1862
|
-
function resetRequestTimeout() {
|
|
1863
|
-
if (this[_timeoutId]) {
|
|
1864
|
-
clearTimeout(this[_timeoutId]);
|
|
1865
|
-
this[_timeoutId] = 0;
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
function setReadyStateAndNotify(value) {
|
|
1869
|
-
let hasChanged = value !== this.readyState;
|
|
1870
|
-
this.readyState = value;
|
|
1871
|
-
if (hasChanged) {
|
|
1872
|
-
let evt = createInnerEvent(this.target, "readystatechange");
|
|
1873
|
-
fire.call(this.target[state$f], evt);
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
function getHandlers() {
|
|
1877
|
-
return {
|
|
1878
|
-
onreadystatechange: (ev) => { executeFn.call(this.target, this.onreadystatechange, ev); },
|
|
1879
|
-
};
|
|
1880
|
-
}
|
|
1881
|
-
// HTTP methods whose capitalization should be normalized
|
|
1882
|
-
const methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
|
|
1883
|
-
function normalizeMethod(method) {
|
|
1884
|
-
let upcased = method.toUpperCase();
|
|
1885
|
-
return methods.indexOf(upcased) > -1 ? upcased : method;
|
|
1886
|
-
}
|
|
1887
|
-
function normalizeDataType(responseType) {
|
|
1888
|
-
return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
|
|
1889
|
-
}
|
|
1890
|
-
function assignRequestHeader(headers, name, value) {
|
|
1891
|
-
let nameKey = name.toLowerCase();
|
|
1892
|
-
for (let key of Object.keys(headers)) {
|
|
1893
|
-
if (key.toLowerCase() === nameKey) {
|
|
1894
|
-
headers[key] = value;
|
|
1895
|
-
return;
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
Object.assign(headers, { [name]: value });
|
|
1899
|
-
return;
|
|
1900
|
-
}
|
|
1901
|
-
const encode = (str) => {
|
|
1902
|
-
const encoder = new TextEncoderP();
|
|
1903
|
-
return encoder.encode(str).buffer;
|
|
1904
|
-
};
|
|
1905
|
-
const decode = (buf) => {
|
|
1906
|
-
let decoder = new TextDecoderP();
|
|
1907
|
-
return decoder.decode(buf);
|
|
1908
|
-
};
|
|
1909
|
-
function convert(body, setContentType, setContentLength) {
|
|
1910
|
-
let result;
|
|
1911
|
-
if (typeof body === "string") {
|
|
1912
|
-
result = body;
|
|
1913
|
-
if (setContentType) {
|
|
1914
|
-
setContentType("text/plain;charset=UTF-8");
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
else if (isObjectType("URLSearchParams", body)) {
|
|
1918
|
-
result = body.toString();
|
|
1919
|
-
if (setContentType) {
|
|
1920
|
-
setContentType("application/x-www-form-urlencoded;charset=UTF-8");
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
else if (body instanceof ArrayBuffer) {
|
|
1924
|
-
result = body.slice(0);
|
|
1925
|
-
}
|
|
1926
|
-
else if (ArrayBuffer.isView(body)) {
|
|
1927
|
-
result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
1928
|
-
}
|
|
1929
|
-
else if (isPolyfillType("Blob", body)) {
|
|
1930
|
-
result = body[state$c].toArrayBuffer().slice(0);
|
|
1931
|
-
if (setContentType && body.type) {
|
|
1932
|
-
setContentType(body.type);
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
else if (isPolyfillType("FormData", body)) {
|
|
1936
|
-
let blob = body[state$9].toBlob();
|
|
1937
|
-
result = blob[state$c].toArrayBuffer();
|
|
1938
|
-
if (setContentType) {
|
|
1939
|
-
setContentType(blob.type);
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
else if (!body) {
|
|
1943
|
-
result = "";
|
|
1944
|
-
}
|
|
1945
|
-
else {
|
|
1946
|
-
result = String(body);
|
|
1947
|
-
}
|
|
1948
|
-
if (setContentLength) {
|
|
1949
|
-
setContentLength(() => {
|
|
1950
|
-
return (typeof result === "string" ? encode(result) : result).byteLength;
|
|
1951
|
-
});
|
|
1952
|
-
}
|
|
1953
|
-
return result;
|
|
1954
|
-
}
|
|
1955
|
-
function convertBack(type, data) {
|
|
1956
|
-
let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
|
|
1957
|
-
if (!type || type === "text") {
|
|
1958
|
-
return typeof temp === "string" ? temp : decode(temp);
|
|
2560
|
+
// Therefore, this scenario is also handled here as a successful request response.
|
|
2561
|
+
if ("status" in err) {
|
|
2562
|
+
requestSuccess.call(this, { statusCode: err.status, header: err.headers, data: err.data });
|
|
2563
|
+
return;
|
|
1959
2564
|
}
|
|
1960
|
-
|
|
1961
|
-
|
|
2565
|
+
const s = this[state$2];
|
|
2566
|
+
s.status = 0;
|
|
2567
|
+
s.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
|
|
2568
|
+
if (!s[_inAfterOpenBeforeSend] && s.readyState !== XMLHttpRequestP.UNSENT && s.readyState !== XMLHttpRequestP.DONE) {
|
|
2569
|
+
emitProcessEvent(this, "error");
|
|
2570
|
+
resetRequestTimeout(this);
|
|
1962
2571
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
2572
|
+
}
|
|
2573
|
+
function requestComplete() {
|
|
2574
|
+
const s = this[state$2];
|
|
2575
|
+
s[_requestTask] = null;
|
|
2576
|
+
if (!s[_inAfterOpenBeforeSend] && (s.readyState === XMLHttpRequestP.OPENED || s.readyState === XMLHttpRequestP.LOADING)) {
|
|
2577
|
+
setReadyStateAndNotify(this, XMLHttpRequestP.DONE);
|
|
1965
2578
|
}
|
|
1966
|
-
|
|
1967
|
-
|
|
2579
|
+
setTimeout(() => {
|
|
2580
|
+
if (!s[_inAfterOpenBeforeSend]) {
|
|
2581
|
+
let l = s[_responseContentLength];
|
|
2582
|
+
emitProcessEvent(this, "loadend", l, l);
|
|
2583
|
+
}
|
|
2584
|
+
});
|
|
2585
|
+
}
|
|
2586
|
+
function clearRequest(xhr, delay = true) {
|
|
2587
|
+
const s = xhr[state$2];
|
|
2588
|
+
const timerFn = delay ? setTimeout : (f) => { f(); };
|
|
2589
|
+
s[_resetPending] = true;
|
|
2590
|
+
if (s[_requestTask] && s.readyState !== XMLHttpRequestP.DONE) {
|
|
2591
|
+
if (delay) {
|
|
2592
|
+
setReadyStateAndNotify(xhr, XMLHttpRequestP.DONE);
|
|
2593
|
+
}
|
|
2594
|
+
timerFn(() => {
|
|
2595
|
+
const requestTask = s[_requestTask];
|
|
2596
|
+
if (requestTask) {
|
|
2597
|
+
requestTask.abort();
|
|
2598
|
+
}
|
|
2599
|
+
if (delay) {
|
|
2600
|
+
emitProcessEvent(xhr, "abort");
|
|
2601
|
+
}
|
|
2602
|
+
if (delay && !requestTask) {
|
|
2603
|
+
emitProcessEvent(xhr, "loadend");
|
|
2604
|
+
}
|
|
2605
|
+
});
|
|
1968
2606
|
}
|
|
1969
|
-
|
|
1970
|
-
|
|
2607
|
+
timerFn(() => {
|
|
2608
|
+
if (s[_resetPending]) {
|
|
2609
|
+
if (delay) {
|
|
2610
|
+
s.readyState = XMLHttpRequestP.UNSENT;
|
|
2611
|
+
}
|
|
2612
|
+
resetXHR(xhr);
|
|
2613
|
+
}
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
function checkRequestTimeout(xhr) {
|
|
2617
|
+
const s = xhr[state$2];
|
|
2618
|
+
if (s.timeout) {
|
|
2619
|
+
s[_timeoutId] = setTimeout(() => {
|
|
2620
|
+
if (!s.status && s.readyState !== XMLHttpRequestP.DONE) {
|
|
2621
|
+
if (s[_requestTask])
|
|
2622
|
+
s[_requestTask].abort();
|
|
2623
|
+
setReadyStateAndNotify(xhr, XMLHttpRequestP.DONE);
|
|
2624
|
+
emitProcessEvent(xhr, "timeout");
|
|
2625
|
+
}
|
|
2626
|
+
}, s.timeout);
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
function resetXHR(xhr) {
|
|
2630
|
+
const s = xhr[state$2];
|
|
2631
|
+
s[_resetPending] = false;
|
|
2632
|
+
resetRequestTimeout(xhr);
|
|
2633
|
+
s.response = "";
|
|
2634
|
+
s.responseURL = "";
|
|
2635
|
+
s.status = 0;
|
|
2636
|
+
s.statusText = "";
|
|
2637
|
+
s[_requestHeaders] = new HeadersP();
|
|
2638
|
+
s[_responseHeaders] = null;
|
|
2639
|
+
s[_responseContentLength] = zero;
|
|
2640
|
+
}
|
|
2641
|
+
function resetRequestTimeout(xhr) {
|
|
2642
|
+
const s = xhr[state$2];
|
|
2643
|
+
if (s[_timeoutId]) {
|
|
2644
|
+
clearTimeout(s[_timeoutId]);
|
|
2645
|
+
s[_timeoutId] = 0;
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
function setReadyStateAndNotify(xhr, value) {
|
|
2649
|
+
const s = xhr[state$2];
|
|
2650
|
+
let hasChanged = value !== s.readyState;
|
|
2651
|
+
s.readyState = value;
|
|
2652
|
+
if (hasChanged) {
|
|
2653
|
+
let evt = createInnerEvent(xhr, "readystatechange");
|
|
2654
|
+
EventTarget_fire(xhr, evt);
|
|
1971
2655
|
}
|
|
1972
2656
|
}
|
|
2657
|
+
function getHandlers(s) {
|
|
2658
|
+
return {
|
|
2659
|
+
onreadystatechange: (ev) => { executeFn(s.target, s.onreadystatechange, ev); },
|
|
2660
|
+
};
|
|
2661
|
+
}
|
|
2662
|
+
const responseTypes = ["", "text", "json", "arraybuffer", "blob", "document"];
|
|
2663
|
+
function normalizeResponseType(responseType) {
|
|
2664
|
+
return responseTypes.indexOf(responseType) > -1 ? responseType : "";
|
|
2665
|
+
}
|
|
2666
|
+
function normalizeDataType(responseType) {
|
|
2667
|
+
return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
|
|
2668
|
+
}
|
|
1973
2669
|
const zero = () => 0;
|
|
1974
2670
|
const statusMessages = {
|
|
1975
2671
|
100: "Continue",
|
|
@@ -2039,425 +2735,81 @@ function statusTextMap(val) {
|
|
|
2039
2735
|
}
|
|
2040
2736
|
const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
|
|
2041
2737
|
|
|
2042
|
-
|
|
2043
|
-
/** @
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
constructor() {
|
|
2047
|
-
if (new.target === BodyP) {
|
|
2048
|
-
throw new TypeError("Failed to construct 'Body': Illegal constructor");
|
|
2049
|
-
}
|
|
2050
|
-
this[state$3] = new BodyState();
|
|
2051
|
-
}
|
|
2052
|
-
get body() {
|
|
2053
|
-
if (!this[state$3][_body]) {
|
|
2054
|
-
return null;
|
|
2055
|
-
}
|
|
2056
|
-
throw new ReferenceError("ReadableStream is not defined");
|
|
2057
|
-
}
|
|
2058
|
-
get bodyUsed() { return this[state$3].bodyUsed; }
|
|
2059
|
-
;
|
|
2060
|
-
arrayBuffer() {
|
|
2061
|
-
const kind = "arrayBuffer";
|
|
2062
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2063
|
-
}
|
|
2064
|
-
blob() {
|
|
2065
|
-
const kind = "blob";
|
|
2066
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2067
|
-
}
|
|
2068
|
-
bytes() {
|
|
2069
|
-
const kind = "bytes";
|
|
2070
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2071
|
-
}
|
|
2072
|
-
formData() {
|
|
2073
|
-
const kind = "formData";
|
|
2074
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2075
|
-
}
|
|
2076
|
-
json() {
|
|
2077
|
-
const kind = "json";
|
|
2078
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2079
|
-
}
|
|
2080
|
-
text() {
|
|
2081
|
-
const kind = "text";
|
|
2082
|
-
return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
|
|
2083
|
-
}
|
|
2084
|
-
toString() { return "[object Body]"; }
|
|
2085
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
|
|
2086
|
-
}
|
|
2087
|
-
defineStringTag(BodyP, "Body");
|
|
2088
|
-
const _name = Symbol();
|
|
2089
|
-
const _body = Symbol();
|
|
2090
|
-
/** @internal */
|
|
2091
|
-
class BodyState {
|
|
2092
|
-
constructor() {
|
|
2093
|
-
this.bodyUsed = false;
|
|
2094
|
-
this[_a$1] = "Body";
|
|
2095
|
-
this[_b] = "";
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
_a$1 = _name, _b = _body;
|
|
2099
|
-
function initFn(body, headers) {
|
|
2100
|
-
if (isObjectType("ReadableStream", body)) {
|
|
2101
|
-
throw new ReferenceError("ReadableStream is not defined");
|
|
2102
|
-
}
|
|
2103
|
-
this[_body] = convert(body, type => {
|
|
2104
|
-
if (headers && !headers.get("Content-Type")) {
|
|
2105
|
-
headers.set("Content-Type", type);
|
|
2106
|
-
}
|
|
2107
|
-
});
|
|
2108
|
-
}
|
|
2109
|
-
function read(kind) {
|
|
2110
|
-
return new Promise((resolve, reject) => {
|
|
2111
|
-
try {
|
|
2112
|
-
resolve(readSync.call(this, kind));
|
|
2113
|
-
}
|
|
2114
|
-
catch (e) {
|
|
2115
|
-
reject(e);
|
|
2116
|
-
}
|
|
2117
|
-
});
|
|
2118
|
-
}
|
|
2119
|
-
function readSync(kind) {
|
|
2120
|
-
if (kind === "arrayBuffer") {
|
|
2121
|
-
return convertBack("arraybuffer", this[_body]);
|
|
2122
|
-
}
|
|
2123
|
-
else if (kind === "blob") {
|
|
2124
|
-
return convertBack("blob", this[_body]);
|
|
2125
|
-
}
|
|
2126
|
-
else if (kind === "bytes") {
|
|
2127
|
-
let arrayBuffer = convertBack("arraybuffer", this[_body]);
|
|
2128
|
-
return new Uint8Array(arrayBuffer);
|
|
2129
|
-
}
|
|
2130
|
-
else if (kind === "formData") {
|
|
2131
|
-
let text = convertBack("text", this[_body]);
|
|
2132
|
-
return createFormDataFromBody(text);
|
|
2133
|
-
}
|
|
2134
|
-
else if (kind === "json") {
|
|
2135
|
-
return convertBack("json", this[_body]);
|
|
2136
|
-
}
|
|
2137
|
-
else {
|
|
2138
|
-
return convertBack("text", this[_body]);
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
|
-
function consumed(kind) {
|
|
2142
|
-
if (!this[_body])
|
|
2143
|
-
return;
|
|
2144
|
-
if (this.bodyUsed) {
|
|
2145
|
-
return Promise.reject(new TypeError(`TypeError: Failed to execute '${kind}' on '${this[_name]}': body stream already read`));
|
|
2146
|
-
}
|
|
2147
|
-
this.bodyUsed = true;
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
var _a;
|
|
2151
|
-
/** @internal */
|
|
2152
|
-
const state$2 = Symbol( /* "HeadersState" */);
|
|
2153
|
-
class HeadersP {
|
|
2154
|
-
constructor(init) {
|
|
2155
|
-
this[state$2] = new HeadersState();
|
|
2156
|
-
if (isObjectType("Headers", init)) {
|
|
2157
|
-
init.forEach((value, name) => {
|
|
2158
|
-
this.append(name, value);
|
|
2159
|
-
});
|
|
2160
|
-
}
|
|
2161
|
-
else if (Array.isArray(init)) {
|
|
2162
|
-
init.forEach(header => {
|
|
2163
|
-
if (!Array.isArray(header)) {
|
|
2164
|
-
throw new TypeError("Failed to construct 'Headers': The provided value cannot be converted to a sequence.");
|
|
2165
|
-
}
|
|
2166
|
-
if (header.length !== 2) {
|
|
2167
|
-
throw new TypeError("Failed to construct 'Headers': Invalid value");
|
|
2168
|
-
}
|
|
2169
|
-
this.append(header[0], header[1]);
|
|
2170
|
-
});
|
|
2171
|
-
}
|
|
2172
|
-
else if (init) {
|
|
2173
|
-
objectEntries(init).forEach(([name, value]) => {
|
|
2174
|
-
this.append(name, value);
|
|
2175
|
-
});
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
|
-
append(name, value) {
|
|
2179
|
-
var _b;
|
|
2180
|
-
let key = normalizeName(name, "append");
|
|
2181
|
-
value = normalizeValue(value);
|
|
2182
|
-
let oldValue = (_b = this[state$2][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1];
|
|
2183
|
-
this[state$2][_headersMap].set(key, ["" + name, oldValue ? `${oldValue}, ${value}` : value]);
|
|
2184
|
-
}
|
|
2185
|
-
delete(name) {
|
|
2186
|
-
let key = normalizeName(name, "delete");
|
|
2187
|
-
this[state$2][_headersMap].delete(key);
|
|
2188
|
-
}
|
|
2189
|
-
get(name) {
|
|
2190
|
-
var _b, _c;
|
|
2191
|
-
let key = normalizeName(name, "get");
|
|
2192
|
-
return (_c = (_b = this[state$2][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : null;
|
|
2193
|
-
}
|
|
2194
|
-
getSetCookie() {
|
|
2195
|
-
let value = this.get("Set-Cookie");
|
|
2196
|
-
return value ? value.split(", ") : [];
|
|
2197
|
-
}
|
|
2198
|
-
has(name) {
|
|
2199
|
-
let key = normalizeName(name, "has");
|
|
2200
|
-
return this[state$2][_headersMap].has(key);
|
|
2201
|
-
}
|
|
2202
|
-
set(name, value) {
|
|
2203
|
-
let key = normalizeName(name, "set");
|
|
2204
|
-
this[state$2][_headersMap].set(key, ["" + name, normalizeValue(value)]);
|
|
2205
|
-
}
|
|
2206
|
-
forEach(callbackfn, thisArg) {
|
|
2207
|
-
Array.from(this.entries()).forEach(([name, value]) => {
|
|
2208
|
-
callbackfn.call(thisArg, value, name, this);
|
|
2209
|
-
});
|
|
2210
|
-
}
|
|
2211
|
-
entries() {
|
|
2212
|
-
return this[state$2][_headersMap].values();
|
|
2213
|
-
}
|
|
2214
|
-
keys() {
|
|
2215
|
-
return Array.from(this.entries()).map(pair => pair[0]).values();
|
|
2216
|
-
}
|
|
2217
|
-
values() {
|
|
2218
|
-
return Array.from(this.entries()).map(pair => pair[1]).values();
|
|
2219
|
-
}
|
|
2220
|
-
[Symbol.iterator]() {
|
|
2221
|
-
return this.entries();
|
|
2222
|
-
}
|
|
2223
|
-
toString() { return "[object Headers]"; }
|
|
2224
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
|
|
2225
|
-
}
|
|
2226
|
-
defineStringTag(HeadersP, "Headers");
|
|
2227
|
-
/** @internal */
|
|
2228
|
-
const _headersMap = Symbol();
|
|
2229
|
-
/** @internal */
|
|
2230
|
-
class HeadersState {
|
|
2231
|
-
constructor() {
|
|
2232
|
-
this[_a] = new Map();
|
|
2233
|
-
}
|
|
2234
|
-
}
|
|
2235
|
-
_a = _headersMap;
|
|
2236
|
-
function normalizeName(name, kind = "") {
|
|
2237
|
-
if (typeof name !== "string") {
|
|
2238
|
-
name = String(name);
|
|
2239
|
-
}
|
|
2240
|
-
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
|
|
2241
|
-
if (kind) {
|
|
2242
|
-
throw new TypeError(`Failed to execute '${kind}' on 'Headers': Invalid name`);
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
return name.toLowerCase();
|
|
2246
|
-
}
|
|
2247
|
-
function normalizeValue(value) {
|
|
2248
|
-
if (typeof value !== "string") {
|
|
2249
|
-
value = String(value);
|
|
2250
|
-
}
|
|
2251
|
-
return value;
|
|
2252
|
-
}
|
|
2253
|
-
function parseHeaders(rawHeaders) {
|
|
2254
|
-
let headers = new HeadersP();
|
|
2255
|
-
let preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
|
|
2256
|
-
preProcessedHeaders
|
|
2257
|
-
.split("\r")
|
|
2258
|
-
.map(function (header) {
|
|
2259
|
-
return header.indexOf("\n") === 0 ? header.substring(1, header.length) : header;
|
|
2260
|
-
})
|
|
2261
|
-
.forEach(function (line) {
|
|
2262
|
-
let parts = line.split(":");
|
|
2263
|
-
let key = parts.shift().trim();
|
|
2264
|
-
if (key) {
|
|
2265
|
-
let value = parts.join(":").trim();
|
|
2266
|
-
try {
|
|
2267
|
-
headers.append(key, value);
|
|
2268
|
-
}
|
|
2269
|
-
catch (error) {
|
|
2270
|
-
console.warn("Response " + error.message);
|
|
2271
|
-
}
|
|
2272
|
-
}
|
|
2273
|
-
});
|
|
2274
|
-
return headers;
|
|
2275
|
-
}
|
|
2276
|
-
const HeadersE = g["Headers"] || HeadersP;
|
|
2277
|
-
|
|
2278
|
-
/** @internal */
|
|
2279
|
-
const state$1 = Symbol( /* "RequestState" */);
|
|
2280
|
-
class RequestP extends BodyP {
|
|
2281
|
-
constructor(input, init) {
|
|
2738
|
+
/** @internal */ const state$1 = Symbol( /* "ResponseState" */);
|
|
2739
|
+
/** @type {typeof globalThis.Response} */
|
|
2740
|
+
class ResponseP extends BodyImpl {
|
|
2741
|
+
constructor(body, init) {
|
|
2282
2742
|
super();
|
|
2283
|
-
this[state$
|
|
2284
|
-
|
|
2285
|
-
this[state$
|
|
2286
|
-
let
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
if (!options.headers) {
|
|
2294
|
-
that.headers = new HeadersP(input.headers);
|
|
2295
|
-
}
|
|
2296
|
-
that.method = input.method;
|
|
2297
|
-
that.mode = input.mode;
|
|
2298
|
-
let inputSignal = input[state$1].signal;
|
|
2299
|
-
if (inputSignal) {
|
|
2300
|
-
that.signal = inputSignal;
|
|
2301
|
-
}
|
|
2302
|
-
that.url = input.url;
|
|
2303
|
-
let _input = input;
|
|
2304
|
-
if (!body && _input[state$3][_body] !== null) {
|
|
2305
|
-
body = _input[state$3][_body];
|
|
2306
|
-
_input[state$3].bodyUsed = true;
|
|
2307
|
-
}
|
|
2308
|
-
}
|
|
2309
|
-
else {
|
|
2310
|
-
that.url = String(input);
|
|
2311
|
-
}
|
|
2312
|
-
if (options.credentials) {
|
|
2313
|
-
that.credentials = options.credentials;
|
|
2314
|
-
}
|
|
2315
|
-
if (options.headers) {
|
|
2316
|
-
that.headers = new HeadersP(options.headers);
|
|
2317
|
-
}
|
|
2318
|
-
if (options.method) {
|
|
2319
|
-
that.method = normalizeMethod(options.method);
|
|
2320
|
-
}
|
|
2321
|
-
if (options.mode) {
|
|
2322
|
-
that.mode = options.mode;
|
|
2323
|
-
}
|
|
2324
|
-
if (options.signal) {
|
|
2325
|
-
that.signal = options.signal;
|
|
2326
|
-
}
|
|
2327
|
-
if ((this.method === "GET" || this.method === "HEAD") && body) {
|
|
2328
|
-
throw new TypeError("Failed to construct 'Request': Request with GET/HEAD method cannot have body.");
|
|
2743
|
+
this[state$7].name = "Response";
|
|
2744
|
+
this[state$1] = new ResponseState();
|
|
2745
|
+
const s = this[state$1];
|
|
2746
|
+
let _init = init !== null && init !== void 0 ? init : {};
|
|
2747
|
+
if (typeof _init !== "object") {
|
|
2748
|
+
throw new TypeError("Failed to construct 'Response': The provided value is not of type 'ResponseInit'.");
|
|
2749
|
+
}
|
|
2750
|
+
let status = _init.status === undefined ? 200 : _init.status;
|
|
2751
|
+
if (status < 200 || status > 500) {
|
|
2752
|
+
throw new RangeError(`Failed to construct 'Response': The status provided (${+status}) is outside the range [200, 599].`);
|
|
2329
2753
|
}
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
if (options.cache === "no-store" || options.cache === "no-cache") {
|
|
2333
|
-
// Search for a '_' parameter in the query string
|
|
2334
|
-
let reParamSearch = /([?&])_=[^&]*/;
|
|
2335
|
-
if (reParamSearch.test(this.url)) {
|
|
2336
|
-
// If it already exists then set the value with the current time
|
|
2337
|
-
that.url = this.url.replace(reParamSearch, "$1_=" + (new Date()).getTime());
|
|
2338
|
-
}
|
|
2339
|
-
else {
|
|
2340
|
-
// Otherwise add a new '_' parameter to the end with the current time
|
|
2341
|
-
let reQueryString = /\?/;
|
|
2342
|
-
that.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (new Date()).getTime();
|
|
2343
|
-
}
|
|
2344
|
-
}
|
|
2754
|
+
if (_init.headers) {
|
|
2755
|
+
s.headers = new HeadersP(_init.headers);
|
|
2345
2756
|
}
|
|
2757
|
+
s.ok = status >= 200 && status < 300;
|
|
2758
|
+
s.status = status;
|
|
2759
|
+
s.statusText = _init.statusText === undefined ? "" : "" + _init.statusText;
|
|
2760
|
+
Body_init(this, body);
|
|
2346
2761
|
}
|
|
2347
|
-
get cache() { return this[state$1].cache; }
|
|
2348
|
-
get credentials() { return this[state$1].credentials; }
|
|
2349
|
-
get destination() { return this[state$1].destination; }
|
|
2350
2762
|
get headers() {
|
|
2351
|
-
const
|
|
2352
|
-
if (!
|
|
2353
|
-
|
|
2354
|
-
}
|
|
2355
|
-
return that.headers;
|
|
2356
|
-
}
|
|
2357
|
-
get integrity() { return this[state$1].integrity; }
|
|
2358
|
-
get keepalive() { return this[state$1].keepalive; }
|
|
2359
|
-
get method() { return this[state$1].method; }
|
|
2360
|
-
get mode() { return this[state$1].mode; }
|
|
2361
|
-
get redirect() { return this[state$1].redirect; }
|
|
2362
|
-
get referrer() { return this[state$1].referrer; }
|
|
2363
|
-
get referrerPolicy() { return this[state$1].referrerPolicy; }
|
|
2364
|
-
get signal() {
|
|
2365
|
-
const that = this[state$1];
|
|
2366
|
-
if (!that.signal) {
|
|
2367
|
-
that.signal = (new AbortControllerP()).signal;
|
|
2763
|
+
const s = this[state$1];
|
|
2764
|
+
if (!s.headers) {
|
|
2765
|
+
s.headers = new HeadersP();
|
|
2368
2766
|
}
|
|
2369
|
-
return
|
|
2767
|
+
return s.headers;
|
|
2370
2768
|
}
|
|
2769
|
+
get ok() { return this[state$1].ok; }
|
|
2770
|
+
get redirected() { return this[state$1].redirected; }
|
|
2771
|
+
get status() { return this[state$1].status; }
|
|
2772
|
+
get statusText() { return this[state$1].statusText; }
|
|
2773
|
+
get type() { return this[state$1].type; }
|
|
2371
2774
|
get url() { return this[state$1].url; }
|
|
2372
2775
|
clone() {
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
}
|
|
2376
|
-
toString() { return "[object Request]"; }
|
|
2377
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request", "Body"] }; }
|
|
2378
|
-
}
|
|
2379
|
-
defineStringTag(RequestP, "Request");
|
|
2380
|
-
/** @internal */
|
|
2381
|
-
class RequestState {
|
|
2382
|
-
constructor() {
|
|
2383
|
-
this.cache = "default";
|
|
2384
|
-
this.credentials = "same-origin";
|
|
2385
|
-
this.destination = "";
|
|
2386
|
-
this.integrity = "";
|
|
2387
|
-
this.keepalive = false;
|
|
2388
|
-
this.method = "GET";
|
|
2389
|
-
this.mode = "cors";
|
|
2390
|
-
this.redirect = "follow";
|
|
2391
|
-
this.referrer = "about:client";
|
|
2392
|
-
this.referrerPolicy = "";
|
|
2393
|
-
this.url = "";
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
const RequestE = g["Request"] || RequestP;
|
|
2397
|
-
|
|
2398
|
-
/** @internal */
|
|
2399
|
-
const state = Symbol( /* "ResponseState" */);
|
|
2400
|
-
class ResponseP extends BodyP {
|
|
2401
|
-
constructor(body, init) {
|
|
2402
|
-
super();
|
|
2403
|
-
this[state] = new ResponseState();
|
|
2404
|
-
const that = this[state];
|
|
2405
|
-
this[state$3][_name] = "Response";
|
|
2406
|
-
let options = init !== null && init !== void 0 ? init : {};
|
|
2407
|
-
let status = options.status === undefined ? 200 : options.status;
|
|
2408
|
-
if (status < 200 || status > 500) {
|
|
2409
|
-
throw new RangeError(`Failed to construct 'Response': The status provided (${+status}) is outside the range [200, 599].`);
|
|
2410
|
-
}
|
|
2411
|
-
if (options.headers) {
|
|
2412
|
-
that.headers = new HeadersP(options.headers);
|
|
2776
|
+
if (this.bodyUsed) {
|
|
2777
|
+
throw new TypeError("Failed to execute 'clone' on 'Response': Response body is already used");
|
|
2413
2778
|
}
|
|
2414
|
-
|
|
2415
|
-
that.status = status;
|
|
2416
|
-
that.statusText = options.statusText === undefined ? "" : "" + options.statusText;
|
|
2417
|
-
initFn.call(this[state$3], body, this.headers);
|
|
2418
|
-
}
|
|
2419
|
-
get headers() {
|
|
2420
|
-
const that = this[state];
|
|
2421
|
-
if (!that.headers) {
|
|
2422
|
-
that.headers = new HeadersP();
|
|
2423
|
-
}
|
|
2424
|
-
return that.headers;
|
|
2425
|
-
}
|
|
2426
|
-
get ok() { return this[state].ok; }
|
|
2427
|
-
get redirected() { return this[state].redirected; }
|
|
2428
|
-
get status() { return this[state].status; }
|
|
2429
|
-
get statusText() { return this[state].statusText; }
|
|
2430
|
-
get type() { return this[state].type; }
|
|
2431
|
-
get url() { return this[state].url; }
|
|
2432
|
-
clone() {
|
|
2433
|
-
let response = new ResponseP(this[state$3][_body], {
|
|
2779
|
+
let response = new ResponseP(Body_toPayload(this), {
|
|
2434
2780
|
headers: new HeadersP(this.headers),
|
|
2435
2781
|
status: this.status,
|
|
2436
2782
|
statusText: this.statusText,
|
|
2437
2783
|
});
|
|
2438
|
-
response[state].url = this.url;
|
|
2784
|
+
response[state$1].url = this.url;
|
|
2439
2785
|
return response;
|
|
2440
2786
|
}
|
|
2441
|
-
static json(
|
|
2442
|
-
|
|
2787
|
+
static json(...args) {
|
|
2788
|
+
const [data, init] = args;
|
|
2789
|
+
checkArgsLength(args, 1, "Response", "json");
|
|
2790
|
+
let response = new ResponseP(typeof data === "string" ? data : JSON.stringify(data), init);
|
|
2791
|
+
response.headers.set("Content-Type", "application/json");
|
|
2792
|
+
return response;
|
|
2443
2793
|
}
|
|
2444
2794
|
static error() {
|
|
2445
2795
|
let response = new ResponseP(null, { status: 200, statusText: "" });
|
|
2446
|
-
response[state].ok = false;
|
|
2447
|
-
response[state].status = 0;
|
|
2448
|
-
response[state].type = "error";
|
|
2796
|
+
response[state$1].ok = false;
|
|
2797
|
+
response[state$1].status = 0;
|
|
2798
|
+
response[state$1].type = "error";
|
|
2449
2799
|
return response;
|
|
2450
2800
|
}
|
|
2451
|
-
static redirect(
|
|
2801
|
+
static redirect(...args) {
|
|
2802
|
+
const [url, status = 301] = args;
|
|
2803
|
+
checkArgsLength(args, 1, "Response", "redirect");
|
|
2452
2804
|
if ([301, 302, 303, 307, 308].indexOf(status) === -1) {
|
|
2453
2805
|
throw new RangeError("Failed to execute 'redirect' on 'Response': Invalid status code");
|
|
2454
2806
|
}
|
|
2455
|
-
return new
|
|
2807
|
+
return new ResponseP(null, { status, headers: { location: "" + url } });
|
|
2456
2808
|
}
|
|
2457
|
-
toString() { return "[object Response]"; }
|
|
2458
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"
|
|
2809
|
+
/** @internal */ toString() { return "[object Response]"; }
|
|
2810
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
|
|
2459
2811
|
}
|
|
2460
|
-
|
|
2812
|
+
Class_setStringTag(ResponseP, "Response");
|
|
2461
2813
|
/** @internal */
|
|
2462
2814
|
class ResponseState {
|
|
2463
2815
|
constructor() {
|
|
@@ -2471,26 +2823,36 @@ class ResponseState {
|
|
|
2471
2823
|
}
|
|
2472
2824
|
const ResponseE = g["Response"] || ResponseP;
|
|
2473
2825
|
|
|
2474
|
-
|
|
2826
|
+
const mp = { XMLHttpRequest: XMLHttpRequestE };
|
|
2827
|
+
const setXMLHttpRequest = (XHR) => { mp.XMLHttpRequest = XHR; };
|
|
2828
|
+
/** @type {typeof globalThis["fetch"]} */
|
|
2829
|
+
function fetchP(...args) {
|
|
2475
2830
|
if (new.target === fetchP) {
|
|
2476
2831
|
throw new TypeError("fetch is not a constructor");
|
|
2477
2832
|
}
|
|
2478
|
-
|
|
2833
|
+
const [input, init] = args;
|
|
2834
|
+
checkArgsLength(args, 1, "Window", "fetch");
|
|
2835
|
+
return new Promise((resolve, reject) => {
|
|
2479
2836
|
const request = new RequestP(input, init);
|
|
2480
|
-
const signal = request[state$
|
|
2837
|
+
const signal = request[state$4].signal;
|
|
2481
2838
|
if (signal && signal.aborted) {
|
|
2482
2839
|
return reject(signal.reason);
|
|
2483
2840
|
}
|
|
2484
|
-
let xhr = new
|
|
2841
|
+
let xhr = new mp.XMLHttpRequest();
|
|
2485
2842
|
xhr.onload = function () {
|
|
2486
2843
|
let options = {
|
|
2487
|
-
headers:
|
|
2844
|
+
headers: parseHeaders(xhr.getAllResponseHeaders() || ""),
|
|
2488
2845
|
status: xhr.status,
|
|
2489
2846
|
statusText: xhr.statusText,
|
|
2490
2847
|
};
|
|
2848
|
+
// This check if specifically for when a user fetches a file locally from the file system
|
|
2849
|
+
// Only if the status is out of a normal range
|
|
2850
|
+
if (request.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
|
|
2851
|
+
options.status = 200;
|
|
2852
|
+
}
|
|
2491
2853
|
setTimeout(() => {
|
|
2492
|
-
let response = new ResponseP(xhr.response, options);
|
|
2493
|
-
response[state].url = xhr.responseURL;
|
|
2854
|
+
let response = new ResponseP("response" in xhr ? xhr.response : xhr.responseText, options);
|
|
2855
|
+
response[state$1].url = "responseURL" in xhr ? xhr.responseURL : (options.headers.get("X-Request-URL") || "");
|
|
2494
2856
|
resolve(response);
|
|
2495
2857
|
});
|
|
2496
2858
|
};
|
|
@@ -2509,28 +2871,31 @@ function fetchP(input, init) {
|
|
|
2509
2871
|
reject(new MPException("request:fail abort", "AbortError"));
|
|
2510
2872
|
});
|
|
2511
2873
|
};
|
|
2512
|
-
xhr.open(request.method, request.url);
|
|
2874
|
+
xhr.open(request.method, request.url, true);
|
|
2513
2875
|
if (request.credentials === "include") {
|
|
2514
2876
|
xhr.withCredentials = true;
|
|
2515
2877
|
}
|
|
2516
2878
|
else if (request.credentials === "omit") {
|
|
2517
2879
|
xhr.withCredentials = false;
|
|
2518
2880
|
}
|
|
2519
|
-
if (
|
|
2881
|
+
if ("responseType" in xhr) {
|
|
2882
|
+
xhr.responseType = "arraybuffer";
|
|
2883
|
+
}
|
|
2884
|
+
if (init && typeof init === "object" && typeof init.headers === "object" && !isObjectType("Headers", init.headers)) {
|
|
2520
2885
|
let headers = init.headers;
|
|
2521
2886
|
let names = [];
|
|
2522
|
-
|
|
2887
|
+
Object.getOwnPropertyNames(headers).forEach(name => {
|
|
2523
2888
|
names.push(normalizeName(name));
|
|
2524
|
-
xhr.setRequestHeader(name, normalizeValue(
|
|
2889
|
+
xhr.setRequestHeader(name, normalizeValue(headers[name]));
|
|
2525
2890
|
});
|
|
2526
|
-
request.headers.forEach(
|
|
2527
|
-
if (names.indexOf(
|
|
2891
|
+
request.headers.forEach((value, name) => {
|
|
2892
|
+
if (names.indexOf(name) === -1) {
|
|
2528
2893
|
xhr.setRequestHeader(name, value);
|
|
2529
2894
|
}
|
|
2530
2895
|
});
|
|
2531
2896
|
}
|
|
2532
2897
|
else {
|
|
2533
|
-
request.headers.forEach(
|
|
2898
|
+
request.headers.forEach((value, name) => {
|
|
2534
2899
|
xhr.setRequestHeader(name, value);
|
|
2535
2900
|
});
|
|
2536
2901
|
}
|
|
@@ -2544,14 +2909,40 @@ function fetchP(input, init) {
|
|
|
2544
2909
|
}
|
|
2545
2910
|
};
|
|
2546
2911
|
}
|
|
2547
|
-
xhr.send(request
|
|
2912
|
+
xhr.send(Body_toPayload(request));
|
|
2548
2913
|
});
|
|
2549
2914
|
}
|
|
2550
|
-
function isObjectHeaders(val) {
|
|
2551
|
-
return typeof val === "object" && !isObjectType("Headers", val);
|
|
2552
|
-
}
|
|
2553
2915
|
const fetchE = g["fetch"] || fetchP;
|
|
2554
2916
|
|
|
2917
|
+
const dispatched = 1;
|
|
2918
|
+
/** @internal */
|
|
2919
|
+
const state = Symbol( /* "CustomEventState" */);
|
|
2920
|
+
/** @type {typeof globalThis.CustomEvent} */
|
|
2921
|
+
class CustomEventP extends EventP {
|
|
2922
|
+
constructor(type, eventInitDict) {
|
|
2923
|
+
var _a;
|
|
2924
|
+
super(type, eventInitDict);
|
|
2925
|
+
this[state] = new CustomEventState();
|
|
2926
|
+
this[state].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
|
|
2927
|
+
}
|
|
2928
|
+
get detail() { return this[state].detail; }
|
|
2929
|
+
initCustomEvent(...args) {
|
|
2930
|
+
const [type, bubbles, cancelable, detail] = args;
|
|
2931
|
+
checkArgsLength(args, 1, "CustomEvent", "initCustomEvent");
|
|
2932
|
+
if (Event_getEtField(this, dispatched))
|
|
2933
|
+
return;
|
|
2934
|
+
this.initEvent(type, bubbles, cancelable);
|
|
2935
|
+
this[state].detail = detail !== null && detail !== void 0 ? detail : null;
|
|
2936
|
+
}
|
|
2937
|
+
/** @internal */ toString() { return "[object CustomEvent]"; }
|
|
2938
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
|
|
2939
|
+
}
|
|
2940
|
+
Class_setStringTag(CustomEventP, "CustomEvent");
|
|
2941
|
+
/** @internal */
|
|
2942
|
+
class CustomEventState {
|
|
2943
|
+
}
|
|
2944
|
+
const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
|
|
2945
|
+
|
|
2555
2946
|
exports.AbortController = AbortControllerE;
|
|
2556
2947
|
exports.AbortControllerP = AbortControllerP;
|
|
2557
2948
|
exports.AbortSignal = AbortSignalE;
|
|
@@ -2588,3 +2979,5 @@ exports.XMLHttpRequest = XMLHttpRequestE;
|
|
|
2588
2979
|
exports.XMLHttpRequestP = XMLHttpRequestP;
|
|
2589
2980
|
exports.fetch = fetchE;
|
|
2590
2981
|
exports.fetchP = fetchP;
|
|
2982
|
+
exports.setRequest = setRequest;
|
|
2983
|
+
exports.setXMLHttpRequest = setXMLHttpRequest;
|