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