seatable-html-page-sdk 0.0.11 → 0.0.13-beta.1
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/dist/index.js +1413 -877
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/comment-mode.js +123 -0
- package/es/comment-mode.js.map +1 -0
- package/es/constants.js +13 -0
- package/es/constants.js.map +1 -0
- package/es/iframe-adapter.js +124 -92
- package/es/iframe-adapter.js.map +1 -1
- package/lib/comment-mode.js +127 -0
- package/lib/comment-mode.js.map +1 -0
- package/lib/constants.js +17 -0
- package/lib/constants.js.map +1 -0
- package/lib/iframe-adapter.js +129 -97
- package/lib/iframe-adapter.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
*
|
|
52
52
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
53
53
|
*/
|
|
54
|
-
const isUndefined = typeOfTest(
|
|
54
|
+
const isUndefined = typeOfTest('undefined');
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Determine if a value is a Buffer
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
*
|
|
79
79
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
80
80
|
*/
|
|
81
|
-
const isArrayBuffer = kindOfTest(
|
|
81
|
+
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Determine if a value is a view on an ArrayBuffer
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
*/
|
|
90
90
|
function isArrayBufferView(val) {
|
|
91
91
|
let result;
|
|
92
|
-
if (typeof ArrayBuffer !==
|
|
92
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|
93
93
|
result = ArrayBuffer.isView(val);
|
|
94
94
|
} else {
|
|
95
95
|
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
*
|
|
105
105
|
* @returns {boolean} True if value is a String, otherwise false
|
|
106
106
|
*/
|
|
107
|
-
const isString = typeOfTest(
|
|
107
|
+
const isString = typeOfTest('string');
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Determine if a value is a Function
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
* @param {*} val The value to test
|
|
113
113
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
114
114
|
*/
|
|
115
|
-
const isFunction$1 = typeOfTest(
|
|
115
|
+
const isFunction$1 = typeOfTest('function');
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
* Determine if a value is a Number
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
*
|
|
122
122
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
123
123
|
*/
|
|
124
|
-
const isNumber = typeOfTest(
|
|
124
|
+
const isNumber = typeOfTest('number');
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
127
|
* Determine if a value is an Object
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
*
|
|
131
131
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
132
132
|
*/
|
|
133
|
-
const isObject = (thing) => thing !== null && typeof thing ===
|
|
133
|
+
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
* Determine if a value is a Boolean
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
149
149
|
*/
|
|
150
150
|
const isPlainObject = (val) => {
|
|
151
|
-
if (kindOf(val) !==
|
|
151
|
+
if (kindOf(val) !== 'object') {
|
|
152
152
|
return false;
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -176,10 +176,7 @@
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
try {
|
|
179
|
-
return (
|
|
180
|
-
Object.keys(val).length === 0 &&
|
|
181
|
-
Object.getPrototypeOf(val) === Object.prototype
|
|
182
|
-
);
|
|
179
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
183
180
|
} catch (e) {
|
|
184
181
|
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
185
182
|
return false;
|
|
@@ -193,7 +190,7 @@
|
|
|
193
190
|
*
|
|
194
191
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
195
192
|
*/
|
|
196
|
-
const isDate = kindOfTest(
|
|
193
|
+
const isDate = kindOfTest('Date');
|
|
197
194
|
|
|
198
195
|
/**
|
|
199
196
|
* Determine if a value is a File
|
|
@@ -202,7 +199,32 @@
|
|
|
202
199
|
*
|
|
203
200
|
* @returns {boolean} True if value is a File, otherwise false
|
|
204
201
|
*/
|
|
205
|
-
const isFile = kindOfTest(
|
|
202
|
+
const isFile = kindOfTest('File');
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Determine if a value is a React Native Blob
|
|
206
|
+
* React Native "blob": an object with a `uri` attribute. Optionally, it can
|
|
207
|
+
* also have a `name` and `type` attribute to specify filename and content type
|
|
208
|
+
*
|
|
209
|
+
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
210
|
+
*
|
|
211
|
+
* @param {*} value The value to test
|
|
212
|
+
*
|
|
213
|
+
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
214
|
+
*/
|
|
215
|
+
const isReactNativeBlob = (value) => {
|
|
216
|
+
return !!(value && typeof value.uri !== 'undefined');
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Determine if environment is React Native
|
|
221
|
+
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
222
|
+
*
|
|
223
|
+
* @param {*} formData The formData to test
|
|
224
|
+
*
|
|
225
|
+
* @returns {boolean} True if environment is React Native, otherwise false
|
|
226
|
+
*/
|
|
227
|
+
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
206
228
|
|
|
207
229
|
/**
|
|
208
230
|
* Determine if a value is a Blob
|
|
@@ -211,7 +233,7 @@
|
|
|
211
233
|
*
|
|
212
234
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
213
235
|
*/
|
|
214
|
-
const isBlob = kindOfTest(
|
|
236
|
+
const isBlob = kindOfTest('Blob');
|
|
215
237
|
|
|
216
238
|
/**
|
|
217
239
|
* Determine if a value is a FileList
|
|
@@ -220,7 +242,7 @@
|
|
|
220
242
|
*
|
|
221
243
|
* @returns {boolean} True if value is a File, otherwise false
|
|
222
244
|
*/
|
|
223
|
-
const isFileList = kindOfTest(
|
|
245
|
+
const isFileList = kindOfTest('FileList');
|
|
224
246
|
|
|
225
247
|
/**
|
|
226
248
|
* Determine if a value is a Stream
|
|
@@ -238,18 +260,28 @@
|
|
|
238
260
|
*
|
|
239
261
|
* @returns {boolean} True if value is an FormData, otherwise false
|
|
240
262
|
*/
|
|
263
|
+
function getGlobal() {
|
|
264
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
265
|
+
if (typeof self !== 'undefined') return self;
|
|
266
|
+
if (typeof window !== 'undefined') return window;
|
|
267
|
+
if (typeof global !== 'undefined') return global;
|
|
268
|
+
return {};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const G = getGlobal();
|
|
272
|
+
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
273
|
+
|
|
241
274
|
const isFormData = (thing) => {
|
|
242
|
-
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
);
|
|
275
|
+
if (!thing) return false;
|
|
276
|
+
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
277
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData (GHSA-6chq-wfr3-2hj9).
|
|
278
|
+
const proto = getPrototypeOf(thing);
|
|
279
|
+
if (!proto || proto === Object.prototype) return false;
|
|
280
|
+
if (!isFunction$1(thing.append)) return false;
|
|
281
|
+
const kind = kindOf(thing);
|
|
282
|
+
return kind === 'formdata' ||
|
|
283
|
+
// detect form-data instance
|
|
284
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]');
|
|
253
285
|
};
|
|
254
286
|
|
|
255
287
|
/**
|
|
@@ -259,13 +291,13 @@
|
|
|
259
291
|
*
|
|
260
292
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
261
293
|
*/
|
|
262
|
-
const isURLSearchParams = kindOfTest(
|
|
294
|
+
const isURLSearchParams = kindOfTest('URLSearchParams');
|
|
263
295
|
|
|
264
296
|
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
297
|
+
'ReadableStream',
|
|
298
|
+
'Request',
|
|
299
|
+
'Response',
|
|
300
|
+
'Headers',
|
|
269
301
|
].map(kindOfTest);
|
|
270
302
|
|
|
271
303
|
/**
|
|
@@ -275,9 +307,9 @@
|
|
|
275
307
|
*
|
|
276
308
|
* @returns {String} The String freed of excess whitespace
|
|
277
309
|
*/
|
|
278
|
-
const trim = (str) =>
|
|
279
|
-
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
280
|
-
|
|
310
|
+
const trim = (str) => {
|
|
311
|
+
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
312
|
+
};
|
|
281
313
|
/**
|
|
282
314
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
283
315
|
*
|
|
@@ -296,7 +328,7 @@
|
|
|
296
328
|
*/
|
|
297
329
|
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
298
330
|
// Don't bother if no value provided
|
|
299
|
-
if (obj === null || typeof obj ===
|
|
331
|
+
if (obj === null || typeof obj === 'undefined') {
|
|
300
332
|
return;
|
|
301
333
|
}
|
|
302
334
|
|
|
@@ -304,7 +336,7 @@
|
|
|
304
336
|
let l;
|
|
305
337
|
|
|
306
338
|
// Force an array if not already something iterable
|
|
307
|
-
if (typeof obj !==
|
|
339
|
+
if (typeof obj !== 'object') {
|
|
308
340
|
/*eslint no-param-reassign:0*/
|
|
309
341
|
obj = [obj];
|
|
310
342
|
}
|
|
@@ -321,9 +353,7 @@
|
|
|
321
353
|
}
|
|
322
354
|
|
|
323
355
|
// Iterate over object keys
|
|
324
|
-
const keys = allOwnKeys
|
|
325
|
-
? Object.getOwnPropertyNames(obj)
|
|
326
|
-
: Object.keys(obj);
|
|
356
|
+
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
327
357
|
const len = keys.length;
|
|
328
358
|
let key;
|
|
329
359
|
|
|
@@ -334,6 +364,14 @@
|
|
|
334
364
|
}
|
|
335
365
|
}
|
|
336
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Finds a key in an object, case-insensitive, returning the actual key name.
|
|
369
|
+
* Returns null if the object is a Buffer or if no match is found.
|
|
370
|
+
*
|
|
371
|
+
* @param {Object} obj - The object to search.
|
|
372
|
+
* @param {string} key - The key to find (case-insensitive).
|
|
373
|
+
* @returns {?string} The actual key name if found, otherwise null.
|
|
374
|
+
*/
|
|
337
375
|
function findKey(obj, key) {
|
|
338
376
|
if (isBuffer(obj)) {
|
|
339
377
|
return null;
|
|
@@ -354,16 +392,11 @@
|
|
|
354
392
|
|
|
355
393
|
const _global = (() => {
|
|
356
394
|
/*eslint no-undef:0*/
|
|
357
|
-
if (typeof globalThis !==
|
|
358
|
-
return typeof self !==
|
|
359
|
-
? self
|
|
360
|
-
: typeof window !== "undefined"
|
|
361
|
-
? window
|
|
362
|
-
: global;
|
|
395
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
396
|
+
return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
|
|
363
397
|
})();
|
|
364
398
|
|
|
365
|
-
const isContextDefined = (context) =>
|
|
366
|
-
!isUndefined(context) && context !== _global;
|
|
399
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
367
400
|
|
|
368
401
|
/**
|
|
369
402
|
* Accepts varargs expecting each argument to be an object, then
|
|
@@ -388,7 +421,7 @@
|
|
|
388
421
|
const result = {};
|
|
389
422
|
const assignValue = (val, key) => {
|
|
390
423
|
// Skip dangerous property names to prevent prototype pollution
|
|
391
|
-
if (key ===
|
|
424
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
392
425
|
return;
|
|
393
426
|
}
|
|
394
427
|
|
|
@@ -441,7 +474,7 @@
|
|
|
441
474
|
});
|
|
442
475
|
}
|
|
443
476
|
},
|
|
444
|
-
{ allOwnKeys }
|
|
477
|
+
{ allOwnKeys }
|
|
445
478
|
);
|
|
446
479
|
return a;
|
|
447
480
|
};
|
|
@@ -470,17 +503,14 @@
|
|
|
470
503
|
* @returns {void}
|
|
471
504
|
*/
|
|
472
505
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
473
|
-
constructor.prototype = Object.create(
|
|
474
|
-
|
|
475
|
-
descriptors,
|
|
476
|
-
);
|
|
477
|
-
Object.defineProperty(constructor.prototype, "constructor", {
|
|
506
|
+
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
507
|
+
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
478
508
|
value: constructor,
|
|
479
509
|
writable: true,
|
|
480
510
|
enumerable: false,
|
|
481
511
|
configurable: true,
|
|
482
512
|
});
|
|
483
|
-
Object.defineProperty(constructor,
|
|
513
|
+
Object.defineProperty(constructor, 'super', {
|
|
484
514
|
value: superConstructor.prototype,
|
|
485
515
|
});
|
|
486
516
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -510,20 +540,13 @@
|
|
|
510
540
|
i = props.length;
|
|
511
541
|
while (i-- > 0) {
|
|
512
542
|
prop = props[i];
|
|
513
|
-
if (
|
|
514
|
-
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
515
|
-
!merged[prop]
|
|
516
|
-
) {
|
|
543
|
+
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
517
544
|
destObj[prop] = sourceObj[prop];
|
|
518
545
|
merged[prop] = true;
|
|
519
546
|
}
|
|
520
547
|
}
|
|
521
548
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
522
|
-
} while (
|
|
523
|
-
sourceObj &&
|
|
524
|
-
(!filter || filter(sourceObj, destObj)) &&
|
|
525
|
-
sourceObj !== Object.prototype
|
|
526
|
-
);
|
|
549
|
+
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
527
550
|
|
|
528
551
|
return destObj;
|
|
529
552
|
};
|
|
@@ -580,7 +603,7 @@
|
|
|
580
603
|
return (thing) => {
|
|
581
604
|
return TypedArray && thing instanceof TypedArray;
|
|
582
605
|
};
|
|
583
|
-
})(typeof Uint8Array !==
|
|
606
|
+
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
|
584
607
|
|
|
585
608
|
/**
|
|
586
609
|
* For each entry in the object, call the function with the key and value.
|
|
@@ -623,14 +646,12 @@
|
|
|
623
646
|
};
|
|
624
647
|
|
|
625
648
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
626
|
-
const isHTMLForm = kindOfTest(
|
|
649
|
+
const isHTMLForm = kindOfTest('HTMLFormElement');
|
|
627
650
|
|
|
628
651
|
const toCamelCase = (str) => {
|
|
629
|
-
return str
|
|
630
|
-
.
|
|
631
|
-
|
|
632
|
-
return p1.toUpperCase() + p2;
|
|
633
|
-
});
|
|
652
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|
653
|
+
return p1.toUpperCase() + p2;
|
|
654
|
+
});
|
|
634
655
|
};
|
|
635
656
|
|
|
636
657
|
/* Creating a function that will check if an object has a property. */
|
|
@@ -647,7 +668,7 @@
|
|
|
647
668
|
*
|
|
648
669
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
649
670
|
*/
|
|
650
|
-
const isRegExp = kindOfTest(
|
|
671
|
+
const isRegExp = kindOfTest('RegExp');
|
|
651
672
|
|
|
652
673
|
const reduceDescriptors = (obj, reducer) => {
|
|
653
674
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -671,10 +692,7 @@
|
|
|
671
692
|
const freezeMethods = (obj) => {
|
|
672
693
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
673
694
|
// skip restricted props in strict mode
|
|
674
|
-
if (
|
|
675
|
-
isFunction$1(obj) &&
|
|
676
|
-
["arguments", "caller", "callee"].indexOf(name) !== -1
|
|
677
|
-
) {
|
|
695
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
678
696
|
return false;
|
|
679
697
|
}
|
|
680
698
|
|
|
@@ -684,7 +702,7 @@
|
|
|
684
702
|
|
|
685
703
|
descriptor.enumerable = false;
|
|
686
704
|
|
|
687
|
-
if (
|
|
705
|
+
if ('writable' in descriptor) {
|
|
688
706
|
descriptor.writable = false;
|
|
689
707
|
return;
|
|
690
708
|
}
|
|
@@ -697,6 +715,14 @@
|
|
|
697
715
|
});
|
|
698
716
|
};
|
|
699
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Converts an array or a delimited string into an object set with values as keys and true as values.
|
|
720
|
+
* Useful for fast membership checks.
|
|
721
|
+
*
|
|
722
|
+
* @param {Array|string} arrayOrString - The array or string to convert.
|
|
723
|
+
* @param {string} delimiter - The delimiter to use if input is a string.
|
|
724
|
+
* @returns {Object} An object with keys from the array or string, values set to true.
|
|
725
|
+
*/
|
|
700
726
|
const toObjectSet = (arrayOrString, delimiter) => {
|
|
701
727
|
const obj = {};
|
|
702
728
|
|
|
@@ -706,9 +732,7 @@
|
|
|
706
732
|
});
|
|
707
733
|
};
|
|
708
734
|
|
|
709
|
-
isArray(arrayOrString)
|
|
710
|
-
? define(arrayOrString)
|
|
711
|
-
: define(String(arrayOrString).split(delimiter));
|
|
735
|
+
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|
712
736
|
|
|
713
737
|
return obj;
|
|
714
738
|
};
|
|
@@ -716,9 +740,7 @@
|
|
|
716
740
|
const noop = () => {};
|
|
717
741
|
|
|
718
742
|
const toFiniteNumber = (value, defaultValue) => {
|
|
719
|
-
return value != null && Number.isFinite((value = +value))
|
|
720
|
-
? value
|
|
721
|
-
: defaultValue;
|
|
743
|
+
return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
|
|
722
744
|
};
|
|
723
745
|
|
|
724
746
|
/**
|
|
@@ -732,11 +754,17 @@
|
|
|
732
754
|
return !!(
|
|
733
755
|
thing &&
|
|
734
756
|
isFunction$1(thing.append) &&
|
|
735
|
-
thing[toStringTag] ===
|
|
757
|
+
thing[toStringTag] === 'FormData' &&
|
|
736
758
|
thing[iterator]
|
|
737
759
|
);
|
|
738
760
|
}
|
|
739
761
|
|
|
762
|
+
/**
|
|
763
|
+
* Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
|
|
764
|
+
*
|
|
765
|
+
* @param {Object} obj - The object to convert.
|
|
766
|
+
* @returns {Object} The JSON-compatible object.
|
|
767
|
+
*/
|
|
740
768
|
const toJSONObject = (obj) => {
|
|
741
769
|
const stack = new Array(10);
|
|
742
770
|
|
|
@@ -751,7 +779,7 @@
|
|
|
751
779
|
return source;
|
|
752
780
|
}
|
|
753
781
|
|
|
754
|
-
if (!(
|
|
782
|
+
if (!('toJSON' in source)) {
|
|
755
783
|
stack[i] = source;
|
|
756
784
|
const target = isArray(source) ? [] : {};
|
|
757
785
|
|
|
@@ -772,8 +800,20 @@
|
|
|
772
800
|
return visit(obj, 0);
|
|
773
801
|
};
|
|
774
802
|
|
|
775
|
-
|
|
803
|
+
/**
|
|
804
|
+
* Determines if a value is an async function.
|
|
805
|
+
*
|
|
806
|
+
* @param {*} thing - The value to test.
|
|
807
|
+
* @returns {boolean} True if value is an async function, otherwise false.
|
|
808
|
+
*/
|
|
809
|
+
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
776
810
|
|
|
811
|
+
/**
|
|
812
|
+
* Determines if a value is thenable (has then and catch methods).
|
|
813
|
+
*
|
|
814
|
+
* @param {*} thing - The value to test.
|
|
815
|
+
* @returns {boolean} True if value is thenable, otherwise false.
|
|
816
|
+
*/
|
|
777
817
|
const isThenable = (thing) =>
|
|
778
818
|
thing &&
|
|
779
819
|
(isObject(thing) || isFunction$1(thing)) &&
|
|
@@ -783,6 +823,14 @@
|
|
|
783
823
|
// original code
|
|
784
824
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
785
825
|
|
|
826
|
+
/**
|
|
827
|
+
* Provides a cross-platform setImmediate implementation.
|
|
828
|
+
* Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
|
|
829
|
+
*
|
|
830
|
+
* @param {boolean} setImmediateSupported - Whether setImmediate is supported.
|
|
831
|
+
* @param {boolean} postMessageSupported - Whether postMessage is supported.
|
|
832
|
+
* @returns {Function} A function to schedule a callback asynchronously.
|
|
833
|
+
*/
|
|
786
834
|
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
787
835
|
if (setImmediateSupported) {
|
|
788
836
|
return setImmediate;
|
|
@@ -791,27 +839,33 @@
|
|
|
791
839
|
return postMessageSupported
|
|
792
840
|
? ((token, callbacks) => {
|
|
793
841
|
_global.addEventListener(
|
|
794
|
-
|
|
842
|
+
'message',
|
|
795
843
|
({ source, data }) => {
|
|
796
844
|
if (source === _global && data === token) {
|
|
797
845
|
callbacks.length && callbacks.shift()();
|
|
798
846
|
}
|
|
799
847
|
},
|
|
800
|
-
false
|
|
848
|
+
false
|
|
801
849
|
);
|
|
802
850
|
|
|
803
851
|
return (cb) => {
|
|
804
852
|
callbacks.push(cb);
|
|
805
|
-
_global.postMessage(token,
|
|
853
|
+
_global.postMessage(token, '*');
|
|
806
854
|
};
|
|
807
855
|
})(`axios@${Math.random()}`, [])
|
|
808
856
|
: (cb) => setTimeout(cb);
|
|
809
|
-
})(typeof setImmediate ===
|
|
857
|
+
})(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
|
|
810
858
|
|
|
859
|
+
/**
|
|
860
|
+
* Schedules a microtask or asynchronous callback as soon as possible.
|
|
861
|
+
* Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
|
|
862
|
+
*
|
|
863
|
+
* @type {Function}
|
|
864
|
+
*/
|
|
811
865
|
const asap =
|
|
812
|
-
typeof queueMicrotask !==
|
|
866
|
+
typeof queueMicrotask !== 'undefined'
|
|
813
867
|
? queueMicrotask.bind(_global)
|
|
814
|
-
: (typeof process !==
|
|
868
|
+
: (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
|
|
815
869
|
|
|
816
870
|
// *********************
|
|
817
871
|
|
|
@@ -836,6 +890,8 @@
|
|
|
836
890
|
isUndefined,
|
|
837
891
|
isDate,
|
|
838
892
|
isFile,
|
|
893
|
+
isReactNativeBlob,
|
|
894
|
+
isReactNative,
|
|
839
895
|
isBlob,
|
|
840
896
|
isRegExp,
|
|
841
897
|
isFunction: isFunction$1,
|
|
@@ -878,57 +934,74 @@
|
|
|
878
934
|
};
|
|
879
935
|
|
|
880
936
|
class AxiosError extends Error {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
937
|
+
static from(error, code, config, request, response, customProps) {
|
|
938
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
939
|
+
axiosError.cause = error;
|
|
940
|
+
axiosError.name = error.name;
|
|
941
|
+
|
|
942
|
+
// Preserve status from the original error if not already set from response
|
|
943
|
+
if (error.status != null && axiosError.status == null) {
|
|
944
|
+
axiosError.status = error.status;
|
|
887
945
|
}
|
|
888
946
|
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
* @param {string} message The error message.
|
|
893
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
894
|
-
* @param {Object} [config] The config.
|
|
895
|
-
* @param {Object} [request] The request.
|
|
896
|
-
* @param {Object} [response] The response.
|
|
897
|
-
*
|
|
898
|
-
* @returns {Error} The created error.
|
|
899
|
-
*/
|
|
900
|
-
constructor(message, code, config, request, response) {
|
|
901
|
-
super(message);
|
|
902
|
-
this.name = 'AxiosError';
|
|
903
|
-
this.isAxiosError = true;
|
|
904
|
-
code && (this.code = code);
|
|
905
|
-
config && (this.config = config);
|
|
906
|
-
request && (this.request = request);
|
|
907
|
-
if (response) {
|
|
908
|
-
this.response = response;
|
|
909
|
-
this.status = response.status;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
947
|
+
customProps && Object.assign(axiosError, customProps);
|
|
948
|
+
return axiosError;
|
|
949
|
+
}
|
|
912
950
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
951
|
+
/**
|
|
952
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
953
|
+
*
|
|
954
|
+
* @param {string} message The error message.
|
|
955
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
956
|
+
* @param {Object} [config] The config.
|
|
957
|
+
* @param {Object} [request] The request.
|
|
958
|
+
* @param {Object} [response] The response.
|
|
959
|
+
*
|
|
960
|
+
* @returns {Error} The created error.
|
|
961
|
+
*/
|
|
962
|
+
constructor(message, code, config, request, response) {
|
|
963
|
+
super(message);
|
|
964
|
+
|
|
965
|
+
// Make message enumerable to maintain backward compatibility
|
|
966
|
+
// The native Error constructor sets message as non-enumerable,
|
|
967
|
+
// but axios < v1.13.3 had it as enumerable
|
|
968
|
+
Object.defineProperty(this, 'message', {
|
|
969
|
+
value: message,
|
|
970
|
+
enumerable: true,
|
|
971
|
+
writable: true,
|
|
972
|
+
configurable: true,
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
this.name = 'AxiosError';
|
|
976
|
+
this.isAxiosError = true;
|
|
977
|
+
code && (this.code = code);
|
|
978
|
+
config && (this.config = config);
|
|
979
|
+
request && (this.request = request);
|
|
980
|
+
if (response) {
|
|
981
|
+
this.response = response;
|
|
982
|
+
this.status = response.status;
|
|
931
983
|
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
toJSON() {
|
|
987
|
+
return {
|
|
988
|
+
// Standard
|
|
989
|
+
message: this.message,
|
|
990
|
+
name: this.name,
|
|
991
|
+
// Microsoft
|
|
992
|
+
description: this.description,
|
|
993
|
+
number: this.number,
|
|
994
|
+
// Mozilla
|
|
995
|
+
fileName: this.fileName,
|
|
996
|
+
lineNumber: this.lineNumber,
|
|
997
|
+
columnNumber: this.columnNumber,
|
|
998
|
+
stack: this.stack,
|
|
999
|
+
// Axios
|
|
1000
|
+
config: utils$1.toJSONObject(this.config),
|
|
1001
|
+
code: this.code,
|
|
1002
|
+
status: this.status,
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
932
1005
|
}
|
|
933
1006
|
|
|
934
1007
|
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
@@ -944,6 +1017,7 @@
|
|
|
944
1017
|
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
945
1018
|
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
946
1019
|
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1020
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
947
1021
|
|
|
948
1022
|
var AxiosError$1 = AxiosError;
|
|
949
1023
|
|
|
@@ -983,11 +1057,14 @@
|
|
|
983
1057
|
*/
|
|
984
1058
|
function renderKey(path, key, dots) {
|
|
985
1059
|
if (!path) return key;
|
|
986
|
-
return path
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1060
|
+
return path
|
|
1061
|
+
.concat(key)
|
|
1062
|
+
.map(function each(token, i) {
|
|
1063
|
+
// eslint-disable-next-line no-param-reassign
|
|
1064
|
+
token = removeBrackets(token);
|
|
1065
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
1066
|
+
})
|
|
1067
|
+
.join(dots ? '.' : '');
|
|
991
1068
|
}
|
|
992
1069
|
|
|
993
1070
|
/**
|
|
@@ -1037,21 +1114,27 @@
|
|
|
1037
1114
|
formData = formData || new (FormData)();
|
|
1038
1115
|
|
|
1039
1116
|
// eslint-disable-next-line no-param-reassign
|
|
1040
|
-
options = utils$1.toFlatObject(
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1117
|
+
options = utils$1.toFlatObject(
|
|
1118
|
+
options,
|
|
1119
|
+
{
|
|
1120
|
+
metaTokens: true,
|
|
1121
|
+
dots: false,
|
|
1122
|
+
indexes: false,
|
|
1123
|
+
},
|
|
1124
|
+
false,
|
|
1125
|
+
function defined(option, source) {
|
|
1126
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1127
|
+
return !utils$1.isUndefined(source[option]);
|
|
1128
|
+
}
|
|
1129
|
+
);
|
|
1048
1130
|
|
|
1049
1131
|
const metaTokens = options.metaTokens;
|
|
1050
1132
|
// eslint-disable-next-line no-use-before-define
|
|
1051
1133
|
const visitor = options.visitor || defaultVisitor;
|
|
1052
1134
|
const dots = options.dots;
|
|
1053
1135
|
const indexes = options.indexes;
|
|
1054
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1136
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1137
|
+
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1055
1138
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1056
1139
|
|
|
1057
1140
|
if (!utils$1.isFunction(visitor)) {
|
|
@@ -1093,6 +1176,11 @@
|
|
|
1093
1176
|
function defaultVisitor(value, key, path) {
|
|
1094
1177
|
let arr = value;
|
|
1095
1178
|
|
|
1179
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
1180
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1181
|
+
return false;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1096
1184
|
if (value && !path && typeof value === 'object') {
|
|
1097
1185
|
if (utils$1.endsWith(key, '{}')) {
|
|
1098
1186
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -1101,17 +1189,22 @@
|
|
|
1101
1189
|
value = JSON.stringify(value);
|
|
1102
1190
|
} else if (
|
|
1103
1191
|
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1104
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
1105
|
-
|
|
1192
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1193
|
+
) {
|
|
1106
1194
|
// eslint-disable-next-line no-param-reassign
|
|
1107
1195
|
key = removeBrackets(key);
|
|
1108
1196
|
|
|
1109
1197
|
arr.forEach(function each(el, index) {
|
|
1110
|
-
!(utils$1.isUndefined(el) || el === null) &&
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1198
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1199
|
+
formData.append(
|
|
1200
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1201
|
+
indexes === true
|
|
1202
|
+
? renderKey([key], index, dots)
|
|
1203
|
+
: indexes === null
|
|
1204
|
+
? key
|
|
1205
|
+
: key + '[]',
|
|
1206
|
+
convertValue(el)
|
|
1207
|
+
);
|
|
1115
1208
|
});
|
|
1116
1209
|
return false;
|
|
1117
1210
|
}
|
|
@@ -1131,12 +1224,19 @@
|
|
|
1131
1224
|
const exposedHelpers = Object.assign(predicates, {
|
|
1132
1225
|
defaultVisitor,
|
|
1133
1226
|
convertValue,
|
|
1134
|
-
isVisitable
|
|
1227
|
+
isVisitable,
|
|
1135
1228
|
});
|
|
1136
1229
|
|
|
1137
|
-
function build(value, path) {
|
|
1230
|
+
function build(value, path, depth = 0) {
|
|
1138
1231
|
if (utils$1.isUndefined(value)) return;
|
|
1139
1232
|
|
|
1233
|
+
if (depth > maxDepth) {
|
|
1234
|
+
throw new AxiosError$1(
|
|
1235
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1236
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1237
|
+
);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1140
1240
|
if (stack.indexOf(value) !== -1) {
|
|
1141
1241
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1142
1242
|
}
|
|
@@ -1144,12 +1244,12 @@
|
|
|
1144
1244
|
stack.push(value);
|
|
1145
1245
|
|
|
1146
1246
|
utils$1.forEach(value, function each(el, key) {
|
|
1147
|
-
const result =
|
|
1148
|
-
|
|
1149
|
-
|
|
1247
|
+
const result =
|
|
1248
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1249
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
1150
1250
|
|
|
1151
1251
|
if (result === true) {
|
|
1152
|
-
build(el, path ? path.concat(key) : [key]);
|
|
1252
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
1153
1253
|
}
|
|
1154
1254
|
});
|
|
1155
1255
|
|
|
@@ -1181,9 +1281,8 @@
|
|
|
1181
1281
|
')': '%29',
|
|
1182
1282
|
'~': '%7E',
|
|
1183
1283
|
'%20': '+',
|
|
1184
|
-
'%00': '\x00'
|
|
1185
1284
|
};
|
|
1186
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20
|
|
1285
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
1187
1286
|
return charMap[match];
|
|
1188
1287
|
});
|
|
1189
1288
|
}
|
|
@@ -1209,29 +1308,33 @@
|
|
|
1209
1308
|
};
|
|
1210
1309
|
|
|
1211
1310
|
prototype.toString = function toString(encoder) {
|
|
1212
|
-
const _encode = encoder
|
|
1213
|
-
|
|
1214
|
-
|
|
1311
|
+
const _encode = encoder
|
|
1312
|
+
? function (value) {
|
|
1313
|
+
return encoder.call(this, value, encode$1);
|
|
1314
|
+
}
|
|
1315
|
+
: encode$1;
|
|
1215
1316
|
|
|
1216
|
-
return this._pairs
|
|
1217
|
-
|
|
1218
|
-
|
|
1317
|
+
return this._pairs
|
|
1318
|
+
.map(function each(pair) {
|
|
1319
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1320
|
+
}, '')
|
|
1321
|
+
.join('&');
|
|
1219
1322
|
};
|
|
1220
1323
|
|
|
1221
1324
|
/**
|
|
1222
|
-
* It replaces
|
|
1223
|
-
*
|
|
1325
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
1326
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1224
1327
|
*
|
|
1225
1328
|
* @param {string} val The value to be encoded.
|
|
1226
1329
|
*
|
|
1227
1330
|
* @returns {string} The encoded value.
|
|
1228
1331
|
*/
|
|
1229
1332
|
function encode(val) {
|
|
1230
|
-
return encodeURIComponent(val)
|
|
1231
|
-
replace(/%3A/gi, ':')
|
|
1232
|
-
replace(/%24/g, '$')
|
|
1233
|
-
replace(/%2C/gi, ',')
|
|
1234
|
-
replace(/%20/g, '+');
|
|
1333
|
+
return encodeURIComponent(val)
|
|
1334
|
+
.replace(/%3A/gi, ':')
|
|
1335
|
+
.replace(/%24/g, '$')
|
|
1336
|
+
.replace(/%2C/gi, ',')
|
|
1337
|
+
.replace(/%20/g, '+');
|
|
1235
1338
|
}
|
|
1236
1339
|
|
|
1237
1340
|
/**
|
|
@@ -1248,11 +1351,13 @@
|
|
|
1248
1351
|
return url;
|
|
1249
1352
|
}
|
|
1250
1353
|
|
|
1251
|
-
const _encode = options && options.encode || encode;
|
|
1354
|
+
const _encode = (options && options.encode) || encode;
|
|
1252
1355
|
|
|
1253
|
-
const _options = utils$1.isFunction(options)
|
|
1254
|
-
|
|
1255
|
-
|
|
1356
|
+
const _options = utils$1.isFunction(options)
|
|
1357
|
+
? {
|
|
1358
|
+
serialize: options,
|
|
1359
|
+
}
|
|
1360
|
+
: options;
|
|
1256
1361
|
|
|
1257
1362
|
const serializeFn = _options && _options.serialize;
|
|
1258
1363
|
|
|
@@ -1261,13 +1366,13 @@
|
|
|
1261
1366
|
if (serializeFn) {
|
|
1262
1367
|
serializedParams = serializeFn(params, _options);
|
|
1263
1368
|
} else {
|
|
1264
|
-
serializedParams = utils$1.isURLSearchParams(params)
|
|
1265
|
-
params.toString()
|
|
1266
|
-
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1369
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
1370
|
+
? params.toString()
|
|
1371
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1267
1372
|
}
|
|
1268
1373
|
|
|
1269
1374
|
if (serializedParams) {
|
|
1270
|
-
const hashmarkIndex = url.indexOf(
|
|
1375
|
+
const hashmarkIndex = url.indexOf('#');
|
|
1271
1376
|
|
|
1272
1377
|
if (hashmarkIndex !== -1) {
|
|
1273
1378
|
url = url.slice(0, hashmarkIndex);
|
|
@@ -1297,7 +1402,7 @@
|
|
|
1297
1402
|
fulfilled,
|
|
1298
1403
|
rejected,
|
|
1299
1404
|
synchronous: options ? options.synchronous : false,
|
|
1300
|
-
runWhen: options ? options.runWhen : null
|
|
1405
|
+
runWhen: options ? options.runWhen : null,
|
|
1301
1406
|
});
|
|
1302
1407
|
return this.handlers.length - 1;
|
|
1303
1408
|
}
|
|
@@ -1351,7 +1456,7 @@
|
|
|
1351
1456
|
silentJSONParsing: true,
|
|
1352
1457
|
forcedJSONParsing: true,
|
|
1353
1458
|
clarifyTimeoutError: false,
|
|
1354
|
-
legacyInterceptorReqResOrdering: true
|
|
1459
|
+
legacyInterceptorReqResOrdering: true,
|
|
1355
1460
|
};
|
|
1356
1461
|
|
|
1357
1462
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -1365,14 +1470,14 @@
|
|
|
1365
1470
|
classes: {
|
|
1366
1471
|
URLSearchParams: URLSearchParams$1,
|
|
1367
1472
|
FormData: FormData$1,
|
|
1368
|
-
Blob: Blob$1
|
|
1473
|
+
Blob: Blob$1,
|
|
1369
1474
|
},
|
|
1370
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1475
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
1371
1476
|
};
|
|
1372
1477
|
|
|
1373
1478
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1374
1479
|
|
|
1375
|
-
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
1480
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
1376
1481
|
|
|
1377
1482
|
/**
|
|
1378
1483
|
* Determine if we're running in a standard browser environment
|
|
@@ -1391,7 +1496,8 @@
|
|
|
1391
1496
|
*
|
|
1392
1497
|
* @returns {boolean}
|
|
1393
1498
|
*/
|
|
1394
|
-
const hasStandardBrowserEnv =
|
|
1499
|
+
const hasStandardBrowserEnv =
|
|
1500
|
+
hasBrowserEnv &&
|
|
1395
1501
|
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1396
1502
|
|
|
1397
1503
|
/**
|
|
@@ -1412,7 +1518,7 @@
|
|
|
1412
1518
|
);
|
|
1413
1519
|
})();
|
|
1414
1520
|
|
|
1415
|
-
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1521
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
1416
1522
|
|
|
1417
1523
|
var utils = /*#__PURE__*/Object.freeze({
|
|
1418
1524
|
__proto__: null,
|
|
@@ -1425,12 +1531,12 @@
|
|
|
1425
1531
|
|
|
1426
1532
|
var platform = {
|
|
1427
1533
|
...utils,
|
|
1428
|
-
...platform$1
|
|
1534
|
+
...platform$1,
|
|
1429
1535
|
};
|
|
1430
1536
|
|
|
1431
1537
|
function toURLEncodedForm(data, options) {
|
|
1432
1538
|
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
1433
|
-
visitor: function(value, key, path, helpers) {
|
|
1539
|
+
visitor: function (value, key, path, helpers) {
|
|
1434
1540
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1435
1541
|
this.append(key, value.toString('base64'));
|
|
1436
1542
|
return false;
|
|
@@ -1438,7 +1544,7 @@
|
|
|
1438
1544
|
|
|
1439
1545
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
1440
1546
|
},
|
|
1441
|
-
...options
|
|
1547
|
+
...options,
|
|
1442
1548
|
});
|
|
1443
1549
|
}
|
|
1444
1550
|
|
|
@@ -1454,7 +1560,7 @@
|
|
|
1454
1560
|
// foo.x.y.z
|
|
1455
1561
|
// foo-x-y-z
|
|
1456
1562
|
// foo x y z
|
|
1457
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1563
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
1458
1564
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1459
1565
|
});
|
|
1460
1566
|
}
|
|
@@ -1498,7 +1604,9 @@
|
|
|
1498
1604
|
|
|
1499
1605
|
if (isLast) {
|
|
1500
1606
|
if (utils$1.hasOwnProp(target, name)) {
|
|
1501
|
-
target[name] =
|
|
1607
|
+
target[name] = utils$1.isArray(target[name])
|
|
1608
|
+
? target[name].concat(value)
|
|
1609
|
+
: [target[name], value];
|
|
1502
1610
|
} else {
|
|
1503
1611
|
target[name] = value;
|
|
1504
1612
|
}
|
|
@@ -1532,6 +1640,8 @@
|
|
|
1532
1640
|
return null;
|
|
1533
1641
|
}
|
|
1534
1642
|
|
|
1643
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
1644
|
+
|
|
1535
1645
|
/**
|
|
1536
1646
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
1537
1647
|
* of the input
|
|
@@ -1558,96 +1668,110 @@
|
|
|
1558
1668
|
}
|
|
1559
1669
|
|
|
1560
1670
|
const defaults = {
|
|
1561
|
-
|
|
1562
1671
|
transitional: transitionalDefaults,
|
|
1563
1672
|
|
|
1564
1673
|
adapter: ['xhr', 'http', 'fetch'],
|
|
1565
1674
|
|
|
1566
|
-
transformRequest: [
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1572
|
-
data = new FormData(data);
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
const isFormData = utils$1.isFormData(data);
|
|
1675
|
+
transformRequest: [
|
|
1676
|
+
function transformRequest(data, headers) {
|
|
1677
|
+
const contentType = headers.getContentType() || '';
|
|
1678
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1679
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
1576
1680
|
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1681
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1682
|
+
data = new FormData(data);
|
|
1683
|
+
}
|
|
1580
1684
|
|
|
1581
|
-
|
|
1582
|
-
utils$1.isBuffer(data) ||
|
|
1583
|
-
utils$1.isStream(data) ||
|
|
1584
|
-
utils$1.isFile(data) ||
|
|
1585
|
-
utils$1.isBlob(data) ||
|
|
1586
|
-
utils$1.isReadableStream(data)
|
|
1587
|
-
) {
|
|
1588
|
-
return data;
|
|
1589
|
-
}
|
|
1590
|
-
if (utils$1.isArrayBufferView(data)) {
|
|
1591
|
-
return data.buffer;
|
|
1592
|
-
}
|
|
1593
|
-
if (utils$1.isURLSearchParams(data)) {
|
|
1594
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1595
|
-
return data.toString();
|
|
1596
|
-
}
|
|
1685
|
+
const isFormData = utils$1.isFormData(data);
|
|
1597
1686
|
|
|
1598
|
-
|
|
1687
|
+
if (isFormData) {
|
|
1688
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1689
|
+
}
|
|
1599
1690
|
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1691
|
+
if (
|
|
1692
|
+
utils$1.isArrayBuffer(data) ||
|
|
1693
|
+
utils$1.isBuffer(data) ||
|
|
1694
|
+
utils$1.isStream(data) ||
|
|
1695
|
+
utils$1.isFile(data) ||
|
|
1696
|
+
utils$1.isBlob(data) ||
|
|
1697
|
+
utils$1.isReadableStream(data)
|
|
1698
|
+
) {
|
|
1699
|
+
return data;
|
|
1700
|
+
}
|
|
1701
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
1702
|
+
return data.buffer;
|
|
1703
|
+
}
|
|
1704
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
1705
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1706
|
+
return data.toString();
|
|
1603
1707
|
}
|
|
1604
1708
|
|
|
1605
|
-
|
|
1606
|
-
const _FormData = this.env && this.env.FormData;
|
|
1709
|
+
let isFileList;
|
|
1607
1710
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1711
|
+
if (isObjectPayload) {
|
|
1712
|
+
const formSerializer = own(this, 'formSerializer');
|
|
1713
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
1714
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
if (
|
|
1718
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
1719
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
1720
|
+
) {
|
|
1721
|
+
const env = own(this, 'env');
|
|
1722
|
+
const _FormData = env && env.FormData;
|
|
1723
|
+
|
|
1724
|
+
return toFormData(
|
|
1725
|
+
isFileList ? { 'files[]': data } : data,
|
|
1726
|
+
_FormData && new _FormData(),
|
|
1727
|
+
formSerializer
|
|
1728
|
+
);
|
|
1729
|
+
}
|
|
1613
1730
|
}
|
|
1614
|
-
}
|
|
1615
1731
|
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1732
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
1733
|
+
headers.setContentType('application/json', false);
|
|
1734
|
+
return stringifySafely(data);
|
|
1735
|
+
}
|
|
1620
1736
|
|
|
1621
|
-
|
|
1622
|
-
|
|
1737
|
+
return data;
|
|
1738
|
+
},
|
|
1739
|
+
],
|
|
1623
1740
|
|
|
1624
|
-
transformResponse: [
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1741
|
+
transformResponse: [
|
|
1742
|
+
function transformResponse(data) {
|
|
1743
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
1744
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1745
|
+
const responseType = own(this, 'responseType');
|
|
1746
|
+
const JSONRequested = responseType === 'json';
|
|
1628
1747
|
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1748
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
1749
|
+
return data;
|
|
1750
|
+
}
|
|
1632
1751
|
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1752
|
+
if (
|
|
1753
|
+
data &&
|
|
1754
|
+
utils$1.isString(data) &&
|
|
1755
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
1756
|
+
) {
|
|
1757
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1758
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1636
1759
|
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1760
|
+
try {
|
|
1761
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
1762
|
+
} catch (e) {
|
|
1763
|
+
if (strictJSONParsing) {
|
|
1764
|
+
if (e.name === 'SyntaxError') {
|
|
1765
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
1766
|
+
}
|
|
1767
|
+
throw e;
|
|
1643
1768
|
}
|
|
1644
|
-
throw e;
|
|
1645
1769
|
}
|
|
1646
1770
|
}
|
|
1647
|
-
}
|
|
1648
1771
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1772
|
+
return data;
|
|
1773
|
+
},
|
|
1774
|
+
],
|
|
1651
1775
|
|
|
1652
1776
|
/**
|
|
1653
1777
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
@@ -1663,7 +1787,7 @@
|
|
|
1663
1787
|
|
|
1664
1788
|
env: {
|
|
1665
1789
|
FormData: platform.classes.FormData,
|
|
1666
|
-
Blob: platform.classes.Blob
|
|
1790
|
+
Blob: platform.classes.Blob,
|
|
1667
1791
|
},
|
|
1668
1792
|
|
|
1669
1793
|
validateStatus: function validateStatus(status) {
|
|
@@ -1672,10 +1796,10 @@
|
|
|
1672
1796
|
|
|
1673
1797
|
headers: {
|
|
1674
1798
|
common: {
|
|
1675
|
-
|
|
1676
|
-
'Content-Type': undefined
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1799
|
+
Accept: 'application/json, text/plain, */*',
|
|
1800
|
+
'Content-Type': undefined,
|
|
1801
|
+
},
|
|
1802
|
+
},
|
|
1679
1803
|
};
|
|
1680
1804
|
|
|
1681
1805
|
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
@@ -1687,10 +1811,23 @@
|
|
|
1687
1811
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1688
1812
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1689
1813
|
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1690
|
-
'age',
|
|
1691
|
-
'
|
|
1692
|
-
'
|
|
1693
|
-
'
|
|
1814
|
+
'age',
|
|
1815
|
+
'authorization',
|
|
1816
|
+
'content-length',
|
|
1817
|
+
'content-type',
|
|
1818
|
+
'etag',
|
|
1819
|
+
'expires',
|
|
1820
|
+
'from',
|
|
1821
|
+
'host',
|
|
1822
|
+
'if-modified-since',
|
|
1823
|
+
'if-unmodified-since',
|
|
1824
|
+
'last-modified',
|
|
1825
|
+
'location',
|
|
1826
|
+
'max-forwards',
|
|
1827
|
+
'proxy-authorization',
|
|
1828
|
+
'referer',
|
|
1829
|
+
'retry-after',
|
|
1830
|
+
'user-agent',
|
|
1694
1831
|
]);
|
|
1695
1832
|
|
|
1696
1833
|
/**
|
|
@@ -1707,47 +1844,81 @@
|
|
|
1707
1844
|
*
|
|
1708
1845
|
* @returns {Object} Headers parsed into an object
|
|
1709
1846
|
*/
|
|
1710
|
-
var parseHeaders = rawHeaders => {
|
|
1847
|
+
var parseHeaders = (rawHeaders) => {
|
|
1711
1848
|
const parsed = {};
|
|
1712
1849
|
let key;
|
|
1713
1850
|
let val;
|
|
1714
1851
|
let i;
|
|
1715
1852
|
|
|
1716
|
-
rawHeaders &&
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1853
|
+
rawHeaders &&
|
|
1854
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
1855
|
+
i = line.indexOf(':');
|
|
1856
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1857
|
+
val = line.substring(i + 1).trim();
|
|
1720
1858
|
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1859
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1724
1862
|
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1863
|
+
if (key === 'set-cookie') {
|
|
1864
|
+
if (parsed[key]) {
|
|
1865
|
+
parsed[key].push(val);
|
|
1866
|
+
} else {
|
|
1867
|
+
parsed[key] = [val];
|
|
1868
|
+
}
|
|
1728
1869
|
} else {
|
|
1729
|
-
parsed[key] = [val
|
|
1870
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1730
1871
|
}
|
|
1731
|
-
}
|
|
1732
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1733
|
-
}
|
|
1734
|
-
});
|
|
1872
|
+
});
|
|
1735
1873
|
|
|
1736
1874
|
return parsed;
|
|
1737
1875
|
};
|
|
1738
1876
|
|
|
1739
1877
|
const $internals = Symbol('internals');
|
|
1740
1878
|
|
|
1879
|
+
const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
|
|
1880
|
+
|
|
1881
|
+
function trimSPorHTAB(str) {
|
|
1882
|
+
let start = 0;
|
|
1883
|
+
let end = str.length;
|
|
1884
|
+
|
|
1885
|
+
while (start < end) {
|
|
1886
|
+
const code = str.charCodeAt(start);
|
|
1887
|
+
|
|
1888
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1889
|
+
break;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
start += 1;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
while (end > start) {
|
|
1896
|
+
const code = str.charCodeAt(end - 1);
|
|
1897
|
+
|
|
1898
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1899
|
+
break;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
end -= 1;
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1741
1908
|
function normalizeHeader(header) {
|
|
1742
1909
|
return header && String(header).trim().toLowerCase();
|
|
1743
1910
|
}
|
|
1744
1911
|
|
|
1912
|
+
function sanitizeHeaderValue(str) {
|
|
1913
|
+
return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1745
1916
|
function normalizeValue(value) {
|
|
1746
1917
|
if (value === false || value == null) {
|
|
1747
1918
|
return value;
|
|
1748
1919
|
}
|
|
1749
1920
|
|
|
1750
|
-
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
1921
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
1751
1922
|
}
|
|
1752
1923
|
|
|
1753
1924
|
function parseTokens(str) {
|
|
@@ -1785,8 +1956,10 @@
|
|
|
1785
1956
|
}
|
|
1786
1957
|
|
|
1787
1958
|
function formatHeader(header) {
|
|
1788
|
-
return header
|
|
1789
|
-
.
|
|
1959
|
+
return header
|
|
1960
|
+
.trim()
|
|
1961
|
+
.toLowerCase()
|
|
1962
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1790
1963
|
return char.toUpperCase() + str;
|
|
1791
1964
|
});
|
|
1792
1965
|
}
|
|
@@ -1794,12 +1967,12 @@
|
|
|
1794
1967
|
function buildAccessors(obj, header) {
|
|
1795
1968
|
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1796
1969
|
|
|
1797
|
-
['get', 'set', 'has'].forEach(methodName => {
|
|
1970
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
1798
1971
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
1799
|
-
value: function(arg1, arg2, arg3) {
|
|
1972
|
+
value: function (arg1, arg2, arg3) {
|
|
1800
1973
|
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1801
1974
|
},
|
|
1802
|
-
configurable: true
|
|
1975
|
+
configurable: true,
|
|
1803
1976
|
});
|
|
1804
1977
|
});
|
|
1805
1978
|
}
|
|
@@ -1821,7 +1994,12 @@
|
|
|
1821
1994
|
|
|
1822
1995
|
const key = utils$1.findKey(self, lHeader);
|
|
1823
1996
|
|
|
1824
|
-
if
|
|
1997
|
+
if (
|
|
1998
|
+
!key ||
|
|
1999
|
+
self[key] === undefined ||
|
|
2000
|
+
_rewrite === true ||
|
|
2001
|
+
(_rewrite === undefined && self[key] !== false)
|
|
2002
|
+
) {
|
|
1825
2003
|
self[key || _header] = normalizeValue(_value);
|
|
1826
2004
|
}
|
|
1827
2005
|
}
|
|
@@ -1831,17 +2009,22 @@
|
|
|
1831
2009
|
|
|
1832
2010
|
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1833
2011
|
setHeaders(header, valueOrRewrite);
|
|
1834
|
-
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2012
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1835
2013
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1836
2014
|
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1837
|
-
let obj = {},
|
|
2015
|
+
let obj = {},
|
|
2016
|
+
dest,
|
|
2017
|
+
key;
|
|
1838
2018
|
for (const entry of header) {
|
|
1839
2019
|
if (!utils$1.isArray(entry)) {
|
|
1840
2020
|
throw TypeError('Object iterator must return a key-value pair');
|
|
1841
2021
|
}
|
|
1842
2022
|
|
|
1843
|
-
obj[key = entry[0]] = (dest = obj[key])
|
|
1844
|
-
|
|
2023
|
+
obj[(key = entry[0])] = (dest = obj[key])
|
|
2024
|
+
? utils$1.isArray(dest)
|
|
2025
|
+
? [...dest, entry[1]]
|
|
2026
|
+
: [dest, entry[1]]
|
|
2027
|
+
: entry[1];
|
|
1845
2028
|
}
|
|
1846
2029
|
|
|
1847
2030
|
setHeaders(obj, valueOrRewrite);
|
|
@@ -1888,7 +2071,11 @@
|
|
|
1888
2071
|
if (header) {
|
|
1889
2072
|
const key = utils$1.findKey(this, header);
|
|
1890
2073
|
|
|
1891
|
-
return !!(
|
|
2074
|
+
return !!(
|
|
2075
|
+
key &&
|
|
2076
|
+
this[key] !== undefined &&
|
|
2077
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2078
|
+
);
|
|
1892
2079
|
}
|
|
1893
2080
|
|
|
1894
2081
|
return false;
|
|
@@ -1928,7 +2115,7 @@
|
|
|
1928
2115
|
|
|
1929
2116
|
while (i--) {
|
|
1930
2117
|
const key = keys[i];
|
|
1931
|
-
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2118
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
1932
2119
|
delete this[key];
|
|
1933
2120
|
deleted = true;
|
|
1934
2121
|
}
|
|
@@ -1972,7 +2159,9 @@
|
|
|
1972
2159
|
const obj = Object.create(null);
|
|
1973
2160
|
|
|
1974
2161
|
utils$1.forEach(this, (value, header) => {
|
|
1975
|
-
value != null &&
|
|
2162
|
+
value != null &&
|
|
2163
|
+
value !== false &&
|
|
2164
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
1976
2165
|
});
|
|
1977
2166
|
|
|
1978
2167
|
return obj;
|
|
@@ -1983,11 +2172,13 @@
|
|
|
1983
2172
|
}
|
|
1984
2173
|
|
|
1985
2174
|
toString() {
|
|
1986
|
-
return Object.entries(this.toJSON())
|
|
2175
|
+
return Object.entries(this.toJSON())
|
|
2176
|
+
.map(([header, value]) => header + ': ' + value)
|
|
2177
|
+
.join('\n');
|
|
1987
2178
|
}
|
|
1988
2179
|
|
|
1989
2180
|
getSetCookie() {
|
|
1990
|
-
return this.get(
|
|
2181
|
+
return this.get('set-cookie') || [];
|
|
1991
2182
|
}
|
|
1992
2183
|
|
|
1993
2184
|
get [Symbol.toStringTag]() {
|
|
@@ -2007,9 +2198,12 @@
|
|
|
2007
2198
|
}
|
|
2008
2199
|
|
|
2009
2200
|
static accessor(header) {
|
|
2010
|
-
const internals =
|
|
2011
|
-
|
|
2012
|
-
|
|
2201
|
+
const internals =
|
|
2202
|
+
(this[$internals] =
|
|
2203
|
+
this[$internals] =
|
|
2204
|
+
{
|
|
2205
|
+
accessors: {},
|
|
2206
|
+
});
|
|
2013
2207
|
|
|
2014
2208
|
const accessors = internals.accessors;
|
|
2015
2209
|
const prototype = this.prototype;
|
|
@@ -2029,17 +2223,24 @@
|
|
|
2029
2223
|
}
|
|
2030
2224
|
}
|
|
2031
2225
|
|
|
2032
|
-
AxiosHeaders.accessor([
|
|
2226
|
+
AxiosHeaders.accessor([
|
|
2227
|
+
'Content-Type',
|
|
2228
|
+
'Content-Length',
|
|
2229
|
+
'Accept',
|
|
2230
|
+
'Accept-Encoding',
|
|
2231
|
+
'User-Agent',
|
|
2232
|
+
'Authorization',
|
|
2233
|
+
]);
|
|
2033
2234
|
|
|
2034
2235
|
// reserved names hotfix
|
|
2035
|
-
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
2236
|
+
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
|
2036
2237
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2037
2238
|
return {
|
|
2038
2239
|
get: () => value,
|
|
2039
2240
|
set(headerValue) {
|
|
2040
2241
|
this[mapped] = headerValue;
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2242
|
+
},
|
|
2243
|
+
};
|
|
2043
2244
|
});
|
|
2044
2245
|
|
|
2045
2246
|
utils$1.freezeMethods(AxiosHeaders);
|
|
@@ -2106,19 +2307,23 @@
|
|
|
2106
2307
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2107
2308
|
resolve(response);
|
|
2108
2309
|
} else {
|
|
2109
|
-
reject(
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2310
|
+
reject(
|
|
2311
|
+
new AxiosError$1(
|
|
2312
|
+
'Request failed with status code ' + response.status,
|
|
2313
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][
|
|
2314
|
+
Math.floor(response.status / 100) - 4
|
|
2315
|
+
],
|
|
2316
|
+
response.config,
|
|
2317
|
+
response.request,
|
|
2318
|
+
response
|
|
2319
|
+
)
|
|
2320
|
+
);
|
|
2116
2321
|
}
|
|
2117
2322
|
}
|
|
2118
2323
|
|
|
2119
2324
|
function parseProtocol(url) {
|
|
2120
2325
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
2121
|
-
return match && match[1] || '';
|
|
2326
|
+
return (match && match[1]) || '';
|
|
2122
2327
|
}
|
|
2123
2328
|
|
|
2124
2329
|
/**
|
|
@@ -2169,7 +2374,7 @@
|
|
|
2169
2374
|
|
|
2170
2375
|
const passed = startedAt && now - startedAt;
|
|
2171
2376
|
|
|
2172
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
2377
|
+
return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
|
|
2173
2378
|
};
|
|
2174
2379
|
}
|
|
2175
2380
|
|
|
@@ -2198,7 +2403,7 @@
|
|
|
2198
2403
|
const throttled = (...args) => {
|
|
2199
2404
|
const now = Date.now();
|
|
2200
2405
|
const passed = now - timestamp;
|
|
2201
|
-
if (
|
|
2406
|
+
if (passed >= threshold) {
|
|
2202
2407
|
invoke(args, now);
|
|
2203
2408
|
} else {
|
|
2204
2409
|
lastArgs = args;
|
|
@@ -2220,25 +2425,25 @@
|
|
|
2220
2425
|
let bytesNotified = 0;
|
|
2221
2426
|
const _speedometer = speedometer(50, 250);
|
|
2222
2427
|
|
|
2223
|
-
return throttle(e => {
|
|
2224
|
-
const
|
|
2428
|
+
return throttle((e) => {
|
|
2429
|
+
const rawLoaded = e.loaded;
|
|
2225
2430
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2226
|
-
const
|
|
2431
|
+
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
2432
|
+
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
2227
2433
|
const rate = _speedometer(progressBytes);
|
|
2228
|
-
const inRange = loaded <= total;
|
|
2229
2434
|
|
|
2230
|
-
bytesNotified = loaded;
|
|
2435
|
+
bytesNotified = Math.max(bytesNotified, loaded);
|
|
2231
2436
|
|
|
2232
2437
|
const data = {
|
|
2233
2438
|
loaded,
|
|
2234
2439
|
total,
|
|
2235
|
-
progress: total ?
|
|
2440
|
+
progress: total ? loaded / total : undefined,
|
|
2236
2441
|
bytes: progressBytes,
|
|
2237
2442
|
rate: rate ? rate : undefined,
|
|
2238
|
-
estimated: rate && total
|
|
2443
|
+
estimated: rate && total ? (total - loaded) / rate : undefined,
|
|
2239
2444
|
event: e,
|
|
2240
2445
|
lengthComputable: total != null,
|
|
2241
|
-
[isDownloadStream ? 'download' : 'upload']: true
|
|
2446
|
+
[isDownloadStream ? 'download' : 'upload']: true,
|
|
2242
2447
|
};
|
|
2243
2448
|
|
|
2244
2449
|
listener(data);
|
|
@@ -2248,77 +2453,82 @@
|
|
|
2248
2453
|
const progressEventDecorator = (total, throttled) => {
|
|
2249
2454
|
const lengthComputable = total != null;
|
|
2250
2455
|
|
|
2251
|
-
return [
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2456
|
+
return [
|
|
2457
|
+
(loaded) =>
|
|
2458
|
+
throttled[0]({
|
|
2459
|
+
lengthComputable,
|
|
2460
|
+
total,
|
|
2461
|
+
loaded,
|
|
2462
|
+
}),
|
|
2463
|
+
throttled[1],
|
|
2464
|
+
];
|
|
2256
2465
|
};
|
|
2257
2466
|
|
|
2258
|
-
const asyncDecorator =
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
return (
|
|
2264
|
-
origin.protocol === url.protocol &&
|
|
2265
|
-
origin.host === url.host &&
|
|
2266
|
-
(isMSIE || origin.port === url.port)
|
|
2267
|
-
);
|
|
2268
|
-
})(
|
|
2269
|
-
new URL(platform.origin),
|
|
2270
|
-
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
2271
|
-
) : () => true;
|
|
2272
|
-
|
|
2273
|
-
var cookies = platform.hasStandardBrowserEnv ?
|
|
2467
|
+
const asyncDecorator =
|
|
2468
|
+
(fn) =>
|
|
2469
|
+
(...args) =>
|
|
2470
|
+
utils$1.asap(() => fn(...args));
|
|
2274
2471
|
|
|
2275
|
-
|
|
2276
|
-
{
|
|
2277
|
-
|
|
2278
|
-
if (typeof document === 'undefined') return;
|
|
2472
|
+
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2473
|
+
? ((origin, isMSIE) => (url) => {
|
|
2474
|
+
url = new URL(url, platform.origin);
|
|
2279
2475
|
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2476
|
+
return (
|
|
2477
|
+
origin.protocol === url.protocol &&
|
|
2478
|
+
origin.host === url.host &&
|
|
2479
|
+
(isMSIE || origin.port === url.port)
|
|
2480
|
+
);
|
|
2481
|
+
})(
|
|
2482
|
+
new URL(platform.origin),
|
|
2483
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
2484
|
+
)
|
|
2485
|
+
: () => true;
|
|
2486
|
+
|
|
2487
|
+
var cookies = platform.hasStandardBrowserEnv
|
|
2488
|
+
? // Standard browser envs support document.cookie
|
|
2489
|
+
{
|
|
2490
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2491
|
+
if (typeof document === 'undefined') return;
|
|
2492
|
+
|
|
2493
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
2494
|
+
|
|
2495
|
+
if (utils$1.isNumber(expires)) {
|
|
2496
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
2497
|
+
}
|
|
2498
|
+
if (utils$1.isString(path)) {
|
|
2499
|
+
cookie.push(`path=${path}`);
|
|
2500
|
+
}
|
|
2501
|
+
if (utils$1.isString(domain)) {
|
|
2502
|
+
cookie.push(`domain=${domain}`);
|
|
2503
|
+
}
|
|
2504
|
+
if (secure === true) {
|
|
2505
|
+
cookie.push('secure');
|
|
2506
|
+
}
|
|
2507
|
+
if (utils$1.isString(sameSite)) {
|
|
2508
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
2509
|
+
}
|
|
2297
2510
|
|
|
2298
|
-
|
|
2299
|
-
|
|
2511
|
+
document.cookie = cookie.join('; ');
|
|
2512
|
+
},
|
|
2300
2513
|
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2514
|
+
read(name) {
|
|
2515
|
+
if (typeof document === 'undefined') return null;
|
|
2516
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
2517
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
2518
|
+
},
|
|
2306
2519
|
|
|
2307
|
-
|
|
2308
|
-
|
|
2520
|
+
remove(name) {
|
|
2521
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
2522
|
+
},
|
|
2309
2523
|
}
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
return null;
|
|
2319
|
-
},
|
|
2320
|
-
remove() {}
|
|
2321
|
-
};
|
|
2524
|
+
: // Non-standard browser env (web workers, react-native) lack needed support.
|
|
2525
|
+
{
|
|
2526
|
+
write() {},
|
|
2527
|
+
read() {
|
|
2528
|
+
return null;
|
|
2529
|
+
},
|
|
2530
|
+
remove() {},
|
|
2531
|
+
};
|
|
2322
2532
|
|
|
2323
2533
|
/**
|
|
2324
2534
|
* Determines whether the specified URL is absolute
|
|
@@ -2364,14 +2574,13 @@
|
|
|
2364
2574
|
*/
|
|
2365
2575
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
2366
2576
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
2367
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls
|
|
2577
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
2368
2578
|
return combineURLs(baseURL, requestedURL);
|
|
2369
2579
|
}
|
|
2370
2580
|
return requestedURL;
|
|
2371
2581
|
}
|
|
2372
2582
|
|
|
2373
|
-
const headersToObject = (thing) =>
|
|
2374
|
-
thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
2583
|
+
const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
|
|
2375
2584
|
|
|
2376
2585
|
/**
|
|
2377
2586
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2385,7 +2594,18 @@
|
|
|
2385
2594
|
function mergeConfig(config1, config2) {
|
|
2386
2595
|
// eslint-disable-next-line no-param-reassign
|
|
2387
2596
|
config2 = config2 || {};
|
|
2388
|
-
|
|
2597
|
+
|
|
2598
|
+
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
2599
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype
|
|
2600
|
+
// (see GHSA-q8qp-cvcw-x6jj). `hasOwnProperty` is restored as a non-enumerable
|
|
2601
|
+
// own slot to preserve ergonomics for user code that relies on it.
|
|
2602
|
+
const config = Object.create(null);
|
|
2603
|
+
Object.defineProperty(config, 'hasOwnProperty', {
|
|
2604
|
+
value: Object.prototype.hasOwnProperty,
|
|
2605
|
+
enumerable: false,
|
|
2606
|
+
writable: true,
|
|
2607
|
+
configurable: true,
|
|
2608
|
+
});
|
|
2389
2609
|
|
|
2390
2610
|
function getMergedValue(target, source, prop, caseless) {
|
|
2391
2611
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
@@ -2424,9 +2644,9 @@
|
|
|
2424
2644
|
|
|
2425
2645
|
// eslint-disable-next-line consistent-return
|
|
2426
2646
|
function mergeDirectKeys(a, b, prop) {
|
|
2427
|
-
if (prop
|
|
2647
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
2428
2648
|
return getMergedValue(a, b);
|
|
2429
|
-
} else if (prop
|
|
2649
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
2430
2650
|
return getMergedValue(undefined, a);
|
|
2431
2651
|
}
|
|
2432
2652
|
}
|
|
@@ -2458,29 +2678,21 @@
|
|
|
2458
2678
|
httpsAgent: defaultToConfig2,
|
|
2459
2679
|
cancelToken: defaultToConfig2,
|
|
2460
2680
|
socketPath: defaultToConfig2,
|
|
2681
|
+
allowedSocketPaths: defaultToConfig2,
|
|
2461
2682
|
responseEncoding: defaultToConfig2,
|
|
2462
2683
|
validateStatus: mergeDirectKeys,
|
|
2463
2684
|
headers: (a, b, prop) =>
|
|
2464
2685
|
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2465
2686
|
};
|
|
2466
2687
|
|
|
2467
|
-
utils$1.forEach(
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
return;
|
|
2476
|
-
const merge = utils$1.hasOwnProp(mergeMap, prop)
|
|
2477
|
-
? mergeMap[prop]
|
|
2478
|
-
: mergeDeepProperties;
|
|
2479
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2480
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
|
2481
|
-
(config[prop] = configValue);
|
|
2482
|
-
},
|
|
2483
|
-
);
|
|
2688
|
+
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
2689
|
+
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
2690
|
+
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
2691
|
+
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
2692
|
+
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
2693
|
+
const configValue = merge(a, b, prop);
|
|
2694
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2695
|
+
});
|
|
2484
2696
|
|
|
2485
2697
|
return config;
|
|
2486
2698
|
}
|
|
@@ -2488,16 +2700,38 @@
|
|
|
2488
2700
|
var resolveConfig = (config) => {
|
|
2489
2701
|
const newConfig = mergeConfig({}, config);
|
|
2490
2702
|
|
|
2491
|
-
|
|
2703
|
+
// Read only own properties to prevent prototype pollution gadgets
|
|
2704
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com'). See GHSA-q8qp-cvcw-x6jj.
|
|
2705
|
+
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
2706
|
+
|
|
2707
|
+
const data = own('data');
|
|
2708
|
+
let withXSRFToken = own('withXSRFToken');
|
|
2709
|
+
const xsrfHeaderName = own('xsrfHeaderName');
|
|
2710
|
+
const xsrfCookieName = own('xsrfCookieName');
|
|
2711
|
+
let headers = own('headers');
|
|
2712
|
+
const auth = own('auth');
|
|
2713
|
+
const baseURL = own('baseURL');
|
|
2714
|
+
const allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|
2715
|
+
const url = own('url');
|
|
2492
2716
|
|
|
2493
2717
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2494
2718
|
|
|
2495
|
-
newConfig.url = buildURL(
|
|
2719
|
+
newConfig.url = buildURL(
|
|
2720
|
+
buildFullPath(baseURL, url, allowAbsoluteUrls),
|
|
2721
|
+
config.params,
|
|
2722
|
+
config.paramsSerializer
|
|
2723
|
+
);
|
|
2496
2724
|
|
|
2497
2725
|
// HTTP basic authentication
|
|
2498
2726
|
if (auth) {
|
|
2499
|
-
headers.set(
|
|
2500
|
-
|
|
2727
|
+
headers.set(
|
|
2728
|
+
'Authorization',
|
|
2729
|
+
'Basic ' +
|
|
2730
|
+
btoa(
|
|
2731
|
+
(auth.username || '') +
|
|
2732
|
+
':' +
|
|
2733
|
+
(auth.password ? unescape(encodeURIComponent(auth.password)) : '')
|
|
2734
|
+
)
|
|
2501
2735
|
);
|
|
2502
2736
|
}
|
|
2503
2737
|
|
|
@@ -2515,17 +2749,25 @@
|
|
|
2515
2749
|
}
|
|
2516
2750
|
});
|
|
2517
2751
|
}
|
|
2518
|
-
}
|
|
2752
|
+
}
|
|
2519
2753
|
|
|
2520
2754
|
// Add xsrf header
|
|
2521
2755
|
// This is only done if running in a standard browser environment.
|
|
2522
2756
|
// Specifically not if we're in a web worker, or react-native.
|
|
2523
2757
|
|
|
2524
2758
|
if (platform.hasStandardBrowserEnv) {
|
|
2525
|
-
|
|
2759
|
+
if (utils$1.isFunction(withXSRFToken)) {
|
|
2760
|
+
withXSRFToken = withXSRFToken(newConfig);
|
|
2761
|
+
}
|
|
2526
2762
|
|
|
2527
|
-
|
|
2528
|
-
|
|
2763
|
+
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
2764
|
+
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
2765
|
+
// the XSRF token cross-origin. See GHSA-xx6v-rp6x-q39c.
|
|
2766
|
+
const shouldSendXSRF =
|
|
2767
|
+
withXSRFToken === true ||
|
|
2768
|
+
(withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
2769
|
+
|
|
2770
|
+
if (shouldSendXSRF) {
|
|
2529
2771
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
2530
2772
|
|
|
2531
2773
|
if (xsrfValue) {
|
|
@@ -2539,196 +2781,218 @@
|
|
|
2539
2781
|
|
|
2540
2782
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
2541
2783
|
|
|
2542
|
-
var xhrAdapter = isXHRAdapterSupported &&
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2784
|
+
var xhrAdapter = isXHRAdapterSupported &&
|
|
2785
|
+
function (config) {
|
|
2786
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2787
|
+
const _config = resolveConfig(config);
|
|
2788
|
+
let requestData = _config.data;
|
|
2789
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
2790
|
+
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
2791
|
+
let onCanceled;
|
|
2792
|
+
let uploadThrottled, downloadThrottled;
|
|
2793
|
+
let flushUpload, flushDownload;
|
|
2551
2794
|
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2795
|
+
function done() {
|
|
2796
|
+
flushUpload && flushUpload(); // flush events
|
|
2797
|
+
flushDownload && flushDownload(); // flush events
|
|
2555
2798
|
|
|
2556
|
-
|
|
2799
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
2557
2800
|
|
|
2558
|
-
|
|
2559
|
-
|
|
2801
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
2802
|
+
}
|
|
2560
2803
|
|
|
2561
|
-
|
|
2804
|
+
let request = new XMLHttpRequest();
|
|
2562
2805
|
|
|
2563
|
-
|
|
2806
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
2564
2807
|
|
|
2565
|
-
|
|
2566
|
-
|
|
2808
|
+
// Set the request timeout in MS
|
|
2809
|
+
request.timeout = _config.timeout;
|
|
2567
2810
|
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2811
|
+
function onloadend() {
|
|
2812
|
+
if (!request) {
|
|
2813
|
+
return;
|
|
2814
|
+
}
|
|
2815
|
+
// Prepare the response
|
|
2816
|
+
const responseHeaders = AxiosHeaders$1.from(
|
|
2817
|
+
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2818
|
+
);
|
|
2819
|
+
const responseData =
|
|
2820
|
+
!responseType || responseType === 'text' || responseType === 'json'
|
|
2821
|
+
? request.responseText
|
|
2822
|
+
: request.response;
|
|
2823
|
+
const response = {
|
|
2824
|
+
data: responseData,
|
|
2825
|
+
status: request.status,
|
|
2826
|
+
statusText: request.statusText,
|
|
2827
|
+
headers: responseHeaders,
|
|
2828
|
+
config,
|
|
2829
|
+
request,
|
|
2830
|
+
};
|
|
2831
|
+
|
|
2832
|
+
settle(
|
|
2833
|
+
function _resolve(value) {
|
|
2834
|
+
resolve(value);
|
|
2835
|
+
done();
|
|
2836
|
+
},
|
|
2837
|
+
function _reject(err) {
|
|
2838
|
+
reject(err);
|
|
2839
|
+
done();
|
|
2840
|
+
},
|
|
2841
|
+
response
|
|
2842
|
+
);
|
|
2843
|
+
|
|
2844
|
+
// Clean up request
|
|
2845
|
+
request = null;
|
|
2571
2846
|
}
|
|
2572
|
-
// Prepare the response
|
|
2573
|
-
const responseHeaders = AxiosHeaders$1.from(
|
|
2574
|
-
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2575
|
-
);
|
|
2576
|
-
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
2577
|
-
request.responseText : request.response;
|
|
2578
|
-
const response = {
|
|
2579
|
-
data: responseData,
|
|
2580
|
-
status: request.status,
|
|
2581
|
-
statusText: request.statusText,
|
|
2582
|
-
headers: responseHeaders,
|
|
2583
|
-
config,
|
|
2584
|
-
request
|
|
2585
|
-
};
|
|
2586
2847
|
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
}
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2848
|
+
if ('onloadend' in request) {
|
|
2849
|
+
// Use onloadend if available
|
|
2850
|
+
request.onloadend = onloadend;
|
|
2851
|
+
} else {
|
|
2852
|
+
// Listen for ready state to emulate onloadend
|
|
2853
|
+
request.onreadystatechange = function handleLoad() {
|
|
2854
|
+
if (!request || request.readyState !== 4) {
|
|
2855
|
+
return;
|
|
2856
|
+
}
|
|
2594
2857
|
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2858
|
+
// The request errored out and we didn't get a response, this will be
|
|
2859
|
+
// handled by onerror instead
|
|
2860
|
+
// With one exception: request that using file: protocol, most browsers
|
|
2861
|
+
// will return status as 0 even though it's a successful request
|
|
2862
|
+
if (
|
|
2863
|
+
request.status === 0 &&
|
|
2864
|
+
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
|
2865
|
+
) {
|
|
2866
|
+
return;
|
|
2867
|
+
}
|
|
2868
|
+
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2869
|
+
// so we should call onloadend on the next 'tick'
|
|
2870
|
+
setTimeout(onloadend);
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2598
2873
|
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
} else {
|
|
2603
|
-
// Listen for ready state to emulate onloadend
|
|
2604
|
-
request.onreadystatechange = function handleLoad() {
|
|
2605
|
-
if (!request || request.readyState !== 4) {
|
|
2874
|
+
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
2875
|
+
request.onabort = function handleAbort() {
|
|
2876
|
+
if (!request) {
|
|
2606
2877
|
return;
|
|
2607
2878
|
}
|
|
2608
2879
|
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
//
|
|
2612
|
-
|
|
2613
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
2614
|
-
return;
|
|
2615
|
-
}
|
|
2616
|
-
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2617
|
-
// so we should call onloadend on the next 'tick'
|
|
2618
|
-
setTimeout(onloadend);
|
|
2880
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
2881
|
+
|
|
2882
|
+
// Clean up request
|
|
2883
|
+
request = null;
|
|
2619
2884
|
};
|
|
2620
|
-
}
|
|
2621
2885
|
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2886
|
+
// Handle low level network errors
|
|
2887
|
+
request.onerror = function handleError(event) {
|
|
2888
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
2889
|
+
// (message may be empty; when present, surface it)
|
|
2890
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
2891
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
2892
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
2893
|
+
// attach the underlying event for consumers who want details
|
|
2894
|
+
err.event = event || null;
|
|
2895
|
+
reject(err);
|
|
2896
|
+
request = null;
|
|
2897
|
+
};
|
|
2627
2898
|
|
|
2628
|
-
|
|
2899
|
+
// Handle timeout
|
|
2900
|
+
request.ontimeout = function handleTimeout() {
|
|
2901
|
+
let timeoutErrorMessage = _config.timeout
|
|
2902
|
+
? 'timeout of ' + _config.timeout + 'ms exceeded'
|
|
2903
|
+
: 'timeout exceeded';
|
|
2904
|
+
const transitional = _config.transitional || transitionalDefaults;
|
|
2905
|
+
if (_config.timeoutErrorMessage) {
|
|
2906
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2907
|
+
}
|
|
2908
|
+
reject(
|
|
2909
|
+
new AxiosError$1(
|
|
2910
|
+
timeoutErrorMessage,
|
|
2911
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
2912
|
+
config,
|
|
2913
|
+
request
|
|
2914
|
+
)
|
|
2915
|
+
);
|
|
2629
2916
|
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2917
|
+
// Clean up request
|
|
2918
|
+
request = null;
|
|
2919
|
+
};
|
|
2633
2920
|
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
// Browsers deliver a ProgressEvent in XHR onerror
|
|
2637
|
-
// (message may be empty; when present, surface it)
|
|
2638
|
-
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
2639
|
-
const msg = event && event.message ? event.message : 'Network Error';
|
|
2640
|
-
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
2641
|
-
// attach the underlying event for consumers who want details
|
|
2642
|
-
err.event = event || null;
|
|
2643
|
-
reject(err);
|
|
2644
|
-
request = null;
|
|
2645
|
-
};
|
|
2646
|
-
|
|
2647
|
-
// Handle timeout
|
|
2648
|
-
request.ontimeout = function handleTimeout() {
|
|
2649
|
-
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
2650
|
-
const transitional = _config.transitional || transitionalDefaults;
|
|
2651
|
-
if (_config.timeoutErrorMessage) {
|
|
2652
|
-
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2653
|
-
}
|
|
2654
|
-
reject(new AxiosError$1(
|
|
2655
|
-
timeoutErrorMessage,
|
|
2656
|
-
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
2657
|
-
config,
|
|
2658
|
-
request));
|
|
2659
|
-
|
|
2660
|
-
// Clean up request
|
|
2661
|
-
request = null;
|
|
2662
|
-
};
|
|
2921
|
+
// Remove Content-Type if data is undefined
|
|
2922
|
+
requestData === undefined && requestHeaders.setContentType(null);
|
|
2663
2923
|
|
|
2664
|
-
|
|
2665
|
-
|
|
2924
|
+
// Add headers to the request
|
|
2925
|
+
if ('setRequestHeader' in request) {
|
|
2926
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
2927
|
+
request.setRequestHeader(key, val);
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2666
2930
|
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
});
|
|
2672
|
-
}
|
|
2931
|
+
// Add withCredentials to request if needed
|
|
2932
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
2933
|
+
request.withCredentials = !!_config.withCredentials;
|
|
2934
|
+
}
|
|
2673
2935
|
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2936
|
+
// Add responseType to request if needed
|
|
2937
|
+
if (responseType && responseType !== 'json') {
|
|
2938
|
+
request.responseType = _config.responseType;
|
|
2939
|
+
}
|
|
2678
2940
|
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2941
|
+
// Handle progress if needed
|
|
2942
|
+
if (onDownloadProgress) {
|
|
2943
|
+
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
|
2944
|
+
request.addEventListener('progress', downloadThrottled);
|
|
2945
|
+
}
|
|
2683
2946
|
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
request.addEventListener('progress', downloadThrottled);
|
|
2688
|
-
}
|
|
2947
|
+
// Not all browsers support upload events
|
|
2948
|
+
if (onUploadProgress && request.upload) {
|
|
2949
|
+
[uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
|
|
2689
2950
|
|
|
2690
|
-
|
|
2691
|
-
if (onUploadProgress && request.upload) {
|
|
2692
|
-
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
2951
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
2693
2952
|
|
|
2694
|
-
|
|
2953
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
2954
|
+
}
|
|
2695
2955
|
|
|
2696
|
-
|
|
2697
|
-
|
|
2956
|
+
if (_config.cancelToken || _config.signal) {
|
|
2957
|
+
// Handle cancellation
|
|
2958
|
+
// eslint-disable-next-line func-names
|
|
2959
|
+
onCanceled = (cancel) => {
|
|
2960
|
+
if (!request) {
|
|
2961
|
+
return;
|
|
2962
|
+
}
|
|
2963
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
2964
|
+
request.abort();
|
|
2965
|
+
request = null;
|
|
2966
|
+
};
|
|
2698
2967
|
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
return;
|
|
2968
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
2969
|
+
if (_config.signal) {
|
|
2970
|
+
_config.signal.aborted
|
|
2971
|
+
? onCanceled()
|
|
2972
|
+
: _config.signal.addEventListener('abort', onCanceled);
|
|
2705
2973
|
}
|
|
2706
|
-
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
2707
|
-
request.abort();
|
|
2708
|
-
request = null;
|
|
2709
|
-
};
|
|
2710
|
-
|
|
2711
|
-
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
2712
|
-
if (_config.signal) {
|
|
2713
|
-
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
2714
2974
|
}
|
|
2715
|
-
}
|
|
2716
2975
|
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
2720
|
-
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
|
2721
|
-
return;
|
|
2722
|
-
}
|
|
2976
|
+
const protocol = parseProtocol(_config.url);
|
|
2723
2977
|
|
|
2978
|
+
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
2979
|
+
reject(
|
|
2980
|
+
new AxiosError$1(
|
|
2981
|
+
'Unsupported protocol ' + protocol + ':',
|
|
2982
|
+
AxiosError$1.ERR_BAD_REQUEST,
|
|
2983
|
+
config
|
|
2984
|
+
)
|
|
2985
|
+
);
|
|
2986
|
+
return;
|
|
2987
|
+
}
|
|
2724
2988
|
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2989
|
+
// Send the request
|
|
2990
|
+
request.send(requestData || null);
|
|
2991
|
+
});
|
|
2992
|
+
};
|
|
2729
2993
|
|
|
2730
2994
|
const composeSignals = (signals, timeout) => {
|
|
2731
|
-
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
2995
|
+
const { length } = (signals = signals ? signals.filter(Boolean) : []);
|
|
2732
2996
|
|
|
2733
2997
|
if (timeout || length) {
|
|
2734
2998
|
let controller = new AbortController();
|
|
@@ -2740,21 +3004,29 @@
|
|
|
2740
3004
|
aborted = true;
|
|
2741
3005
|
unsubscribe();
|
|
2742
3006
|
const err = reason instanceof Error ? reason : this.reason;
|
|
2743
|
-
controller.abort(
|
|
3007
|
+
controller.abort(
|
|
3008
|
+
err instanceof AxiosError$1
|
|
3009
|
+
? err
|
|
3010
|
+
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3011
|
+
);
|
|
2744
3012
|
}
|
|
2745
3013
|
};
|
|
2746
3014
|
|
|
2747
|
-
let timer =
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
3015
|
+
let timer =
|
|
3016
|
+
timeout &&
|
|
3017
|
+
setTimeout(() => {
|
|
3018
|
+
timer = null;
|
|
3019
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
3020
|
+
}, timeout);
|
|
2751
3021
|
|
|
2752
3022
|
const unsubscribe = () => {
|
|
2753
3023
|
if (signals) {
|
|
2754
3024
|
timer && clearTimeout(timer);
|
|
2755
3025
|
timer = null;
|
|
2756
|
-
signals.forEach(signal => {
|
|
2757
|
-
signal.unsubscribe
|
|
3026
|
+
signals.forEach((signal) => {
|
|
3027
|
+
signal.unsubscribe
|
|
3028
|
+
? signal.unsubscribe(onabort)
|
|
3029
|
+
: signal.removeEventListener('abort', onabort);
|
|
2758
3030
|
});
|
|
2759
3031
|
signals = null;
|
|
2760
3032
|
}
|
|
@@ -2762,7 +3034,7 @@
|
|
|
2762
3034
|
|
|
2763
3035
|
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
2764
3036
|
|
|
2765
|
-
const {signal} = controller;
|
|
3037
|
+
const { signal } = controller;
|
|
2766
3038
|
|
|
2767
3039
|
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
2768
3040
|
|
|
@@ -2805,7 +3077,7 @@
|
|
|
2805
3077
|
const reader = stream.getReader();
|
|
2806
3078
|
try {
|
|
2807
3079
|
for (;;) {
|
|
2808
|
-
const {done, value} = await reader.read();
|
|
3080
|
+
const { done, value } = await reader.read();
|
|
2809
3081
|
if (done) {
|
|
2810
3082
|
break;
|
|
2811
3083
|
}
|
|
@@ -2828,64 +3100,69 @@
|
|
|
2828
3100
|
}
|
|
2829
3101
|
};
|
|
2830
3102
|
|
|
2831
|
-
return new ReadableStream(
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
3103
|
+
return new ReadableStream(
|
|
3104
|
+
{
|
|
3105
|
+
async pull(controller) {
|
|
3106
|
+
try {
|
|
3107
|
+
const { done, value } = await iterator.next();
|
|
2835
3108
|
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
3109
|
+
if (done) {
|
|
3110
|
+
_onFinish();
|
|
3111
|
+
controller.close();
|
|
3112
|
+
return;
|
|
3113
|
+
}
|
|
2841
3114
|
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
3115
|
+
let len = value.byteLength;
|
|
3116
|
+
if (onProgress) {
|
|
3117
|
+
let loadedBytes = (bytes += len);
|
|
3118
|
+
onProgress(loadedBytes);
|
|
3119
|
+
}
|
|
3120
|
+
controller.enqueue(new Uint8Array(value));
|
|
3121
|
+
} catch (err) {
|
|
3122
|
+
_onFinish(err);
|
|
3123
|
+
throw err;
|
|
2846
3124
|
}
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
_onFinish(
|
|
2850
|
-
|
|
2851
|
-
}
|
|
3125
|
+
},
|
|
3126
|
+
cancel(reason) {
|
|
3127
|
+
_onFinish(reason);
|
|
3128
|
+
return iterator.return();
|
|
3129
|
+
},
|
|
2852
3130
|
},
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
return iterator.return();
|
|
3131
|
+
{
|
|
3132
|
+
highWaterMark: 2,
|
|
2856
3133
|
}
|
|
2857
|
-
|
|
2858
|
-
highWaterMark: 2
|
|
2859
|
-
})
|
|
3134
|
+
);
|
|
2860
3135
|
};
|
|
2861
3136
|
|
|
2862
3137
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
2863
3138
|
|
|
2864
|
-
const {isFunction} = utils$1;
|
|
3139
|
+
const { isFunction } = utils$1;
|
|
2865
3140
|
|
|
2866
|
-
const globalFetchAPI = (({Request, Response}) => ({
|
|
2867
|
-
Request,
|
|
3141
|
+
const globalFetchAPI = (({ Request, Response }) => ({
|
|
3142
|
+
Request,
|
|
3143
|
+
Response,
|
|
2868
3144
|
}))(utils$1.global);
|
|
2869
3145
|
|
|
2870
|
-
const {
|
|
2871
|
-
ReadableStream: ReadableStream$1, TextEncoder
|
|
2872
|
-
} = utils$1.global;
|
|
2873
|
-
|
|
3146
|
+
const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
|
|
2874
3147
|
|
|
2875
3148
|
const test = (fn, ...args) => {
|
|
2876
3149
|
try {
|
|
2877
3150
|
return !!fn(...args);
|
|
2878
3151
|
} catch (e) {
|
|
2879
|
-
return false
|
|
3152
|
+
return false;
|
|
2880
3153
|
}
|
|
2881
3154
|
};
|
|
2882
3155
|
|
|
2883
3156
|
const factory = (env) => {
|
|
2884
|
-
env = utils$1.merge.call(
|
|
2885
|
-
|
|
2886
|
-
|
|
3157
|
+
env = utils$1.merge.call(
|
|
3158
|
+
{
|
|
3159
|
+
skipUndefined: true,
|
|
3160
|
+
},
|
|
3161
|
+
globalFetchAPI,
|
|
3162
|
+
env
|
|
3163
|
+
);
|
|
2887
3164
|
|
|
2888
|
-
const {fetch: envFetch, Request, Response} = env;
|
|
3165
|
+
const { fetch: envFetch, Request, Response } = env;
|
|
2889
3166
|
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
2890
3167
|
const isRequestSupported = isFunction(Request);
|
|
2891
3168
|
const isResponseSupported = isFunction(Response);
|
|
@@ -2896,46 +3173,67 @@
|
|
|
2896
3173
|
|
|
2897
3174
|
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
2898
3175
|
|
|
2899
|
-
const encodeText =
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
3176
|
+
const encodeText =
|
|
3177
|
+
isFetchSupported &&
|
|
3178
|
+
(typeof TextEncoder === 'function'
|
|
3179
|
+
? (
|
|
3180
|
+
(encoder) => (str) =>
|
|
3181
|
+
encoder.encode(str)
|
|
3182
|
+
)(new TextEncoder())
|
|
3183
|
+
: async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
3184
|
+
|
|
3185
|
+
const supportsRequestStream =
|
|
3186
|
+
isRequestSupported &&
|
|
3187
|
+
isReadableStreamSupported &&
|
|
3188
|
+
test(() => {
|
|
3189
|
+
let duplexAccessed = false;
|
|
3190
|
+
|
|
3191
|
+
const request = new Request(platform.origin, {
|
|
3192
|
+
body: new ReadableStream$1(),
|
|
3193
|
+
method: 'POST',
|
|
3194
|
+
get duplex() {
|
|
3195
|
+
duplexAccessed = true;
|
|
3196
|
+
return 'half';
|
|
3197
|
+
},
|
|
3198
|
+
});
|
|
2903
3199
|
|
|
2904
|
-
|
|
2905
|
-
let duplexAccessed = false;
|
|
3200
|
+
const hasContentType = request.headers.has('Content-Type');
|
|
2906
3201
|
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
get duplex() {
|
|
2911
|
-
duplexAccessed = true;
|
|
2912
|
-
return 'half';
|
|
2913
|
-
},
|
|
2914
|
-
}).headers.has('Content-Type');
|
|
3202
|
+
if (request.body != null) {
|
|
3203
|
+
request.body.cancel();
|
|
3204
|
+
}
|
|
2915
3205
|
|
|
2916
|
-
|
|
2917
|
-
|
|
3206
|
+
return duplexAccessed && !hasContentType;
|
|
3207
|
+
});
|
|
2918
3208
|
|
|
2919
|
-
const supportsResponseStream =
|
|
3209
|
+
const supportsResponseStream =
|
|
3210
|
+
isResponseSupported &&
|
|
3211
|
+
isReadableStreamSupported &&
|
|
2920
3212
|
test(() => utils$1.isReadableStream(new Response('').body));
|
|
2921
3213
|
|
|
2922
3214
|
const resolvers = {
|
|
2923
|
-
stream: supportsResponseStream && ((res) => res.body)
|
|
3215
|
+
stream: supportsResponseStream && ((res) => res.body),
|
|
2924
3216
|
};
|
|
2925
3217
|
|
|
2926
|
-
isFetchSupported &&
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
3218
|
+
isFetchSupported &&
|
|
3219
|
+
(() => {
|
|
3220
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
|
|
3221
|
+
!resolvers[type] &&
|
|
3222
|
+
(resolvers[type] = (res, config) => {
|
|
3223
|
+
let method = res && res[type];
|
|
2930
3224
|
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
3225
|
+
if (method) {
|
|
3226
|
+
return method.call(res);
|
|
3227
|
+
}
|
|
2934
3228
|
|
|
2935
|
-
|
|
3229
|
+
throw new AxiosError$1(
|
|
3230
|
+
`Response type '${type}' is not supported`,
|
|
3231
|
+
AxiosError$1.ERR_NOT_SUPPORT,
|
|
3232
|
+
config
|
|
3233
|
+
);
|
|
3234
|
+
});
|
|
2936
3235
|
});
|
|
2937
|
-
});
|
|
2938
|
-
})());
|
|
3236
|
+
})();
|
|
2939
3237
|
|
|
2940
3238
|
const getBodyLength = async (body) => {
|
|
2941
3239
|
if (body == null) {
|
|
@@ -2986,32 +3284,41 @@
|
|
|
2986
3284
|
responseType,
|
|
2987
3285
|
headers,
|
|
2988
3286
|
withCredentials = 'same-origin',
|
|
2989
|
-
fetchOptions
|
|
3287
|
+
fetchOptions,
|
|
2990
3288
|
} = resolveConfig(config);
|
|
2991
3289
|
|
|
2992
3290
|
let _fetch = envFetch || fetch;
|
|
2993
3291
|
|
|
2994
3292
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
2995
3293
|
|
|
2996
|
-
let composedSignal = composeSignals$1(
|
|
3294
|
+
let composedSignal = composeSignals$1(
|
|
3295
|
+
[signal, cancelToken && cancelToken.toAbortSignal()],
|
|
3296
|
+
timeout
|
|
3297
|
+
);
|
|
2997
3298
|
|
|
2998
3299
|
let request = null;
|
|
2999
3300
|
|
|
3000
|
-
const unsubscribe =
|
|
3001
|
-
composedSignal
|
|
3002
|
-
|
|
3301
|
+
const unsubscribe =
|
|
3302
|
+
composedSignal &&
|
|
3303
|
+
composedSignal.unsubscribe &&
|
|
3304
|
+
(() => {
|
|
3305
|
+
composedSignal.unsubscribe();
|
|
3306
|
+
});
|
|
3003
3307
|
|
|
3004
3308
|
let requestContentLength;
|
|
3005
3309
|
|
|
3006
3310
|
try {
|
|
3007
3311
|
if (
|
|
3008
|
-
onUploadProgress &&
|
|
3312
|
+
onUploadProgress &&
|
|
3313
|
+
supportsRequestStream &&
|
|
3314
|
+
method !== 'get' &&
|
|
3315
|
+
method !== 'head' &&
|
|
3009
3316
|
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
3010
3317
|
) {
|
|
3011
3318
|
let _request = new Request(url, {
|
|
3012
3319
|
method: 'POST',
|
|
3013
3320
|
body: data,
|
|
3014
|
-
duplex:
|
|
3321
|
+
duplex: 'half',
|
|
3015
3322
|
});
|
|
3016
3323
|
|
|
3017
3324
|
let contentTypeHeader;
|
|
@@ -3036,7 +3343,20 @@
|
|
|
3036
3343
|
|
|
3037
3344
|
// Cloudflare Workers throws when credentials are defined
|
|
3038
3345
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
3039
|
-
const isCredentialsSupported = isRequestSupported &&
|
|
3346
|
+
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
|
3347
|
+
|
|
3348
|
+
// If data is FormData and Content-Type is multipart/form-data without boundary,
|
|
3349
|
+
// delete it so fetch can set it correctly with the boundary
|
|
3350
|
+
if (utils$1.isFormData(data)) {
|
|
3351
|
+
const contentType = headers.getContentType();
|
|
3352
|
+
if (
|
|
3353
|
+
contentType &&
|
|
3354
|
+
/^multipart\/form-data/i.test(contentType) &&
|
|
3355
|
+
!/boundary=/i.test(contentType)
|
|
3356
|
+
) {
|
|
3357
|
+
headers.delete('content-type');
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3040
3360
|
|
|
3041
3361
|
const resolvedOptions = {
|
|
3042
3362
|
...fetchOptions,
|
|
@@ -3044,29 +3364,35 @@
|
|
|
3044
3364
|
method: method.toUpperCase(),
|
|
3045
3365
|
headers: headers.normalize().toJSON(),
|
|
3046
3366
|
body: data,
|
|
3047
|
-
duplex:
|
|
3048
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3367
|
+
duplex: 'half',
|
|
3368
|
+
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
3049
3369
|
};
|
|
3050
3370
|
|
|
3051
3371
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3052
3372
|
|
|
3053
|
-
let response = await (isRequestSupported
|
|
3373
|
+
let response = await (isRequestSupported
|
|
3374
|
+
? _fetch(request, fetchOptions)
|
|
3375
|
+
: _fetch(url, resolvedOptions));
|
|
3054
3376
|
|
|
3055
|
-
const isStreamResponse =
|
|
3377
|
+
const isStreamResponse =
|
|
3378
|
+
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3056
3379
|
|
|
3057
3380
|
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
3058
3381
|
const options = {};
|
|
3059
3382
|
|
|
3060
|
-
['status', 'statusText', 'headers'].forEach(prop => {
|
|
3383
|
+
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
3061
3384
|
options[prop] = response[prop];
|
|
3062
3385
|
});
|
|
3063
3386
|
|
|
3064
3387
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3065
3388
|
|
|
3066
|
-
const [onProgress, flush] =
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3389
|
+
const [onProgress, flush] =
|
|
3390
|
+
(onDownloadProgress &&
|
|
3391
|
+
progressEventDecorator(
|
|
3392
|
+
responseContentLength,
|
|
3393
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3394
|
+
)) ||
|
|
3395
|
+
[];
|
|
3070
3396
|
|
|
3071
3397
|
response = new Response(
|
|
3072
3398
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
@@ -3079,7 +3405,10 @@
|
|
|
3079
3405
|
|
|
3080
3406
|
responseType = responseType || 'text';
|
|
3081
3407
|
|
|
3082
|
-
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3408
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3409
|
+
response,
|
|
3410
|
+
config
|
|
3411
|
+
);
|
|
3083
3412
|
|
|
3084
3413
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3085
3414
|
|
|
@@ -3090,43 +3419,50 @@
|
|
|
3090
3419
|
status: response.status,
|
|
3091
3420
|
statusText: response.statusText,
|
|
3092
3421
|
config,
|
|
3093
|
-
request
|
|
3422
|
+
request,
|
|
3094
3423
|
});
|
|
3095
|
-
})
|
|
3424
|
+
});
|
|
3096
3425
|
} catch (err) {
|
|
3097
3426
|
unsubscribe && unsubscribe();
|
|
3098
3427
|
|
|
3099
3428
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3100
3429
|
throw Object.assign(
|
|
3101
|
-
new AxiosError$1(
|
|
3430
|
+
new AxiosError$1(
|
|
3431
|
+
'Network Error',
|
|
3432
|
+
AxiosError$1.ERR_NETWORK,
|
|
3433
|
+
config,
|
|
3434
|
+
request,
|
|
3435
|
+
err && err.response
|
|
3436
|
+
),
|
|
3102
3437
|
{
|
|
3103
|
-
cause: err.cause || err
|
|
3438
|
+
cause: err.cause || err,
|
|
3104
3439
|
}
|
|
3105
|
-
)
|
|
3440
|
+
);
|
|
3106
3441
|
}
|
|
3107
3442
|
|
|
3108
3443
|
throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
|
|
3109
3444
|
}
|
|
3110
|
-
}
|
|
3445
|
+
};
|
|
3111
3446
|
};
|
|
3112
3447
|
|
|
3113
3448
|
const seedCache = new Map();
|
|
3114
3449
|
|
|
3115
3450
|
const getFetch = (config) => {
|
|
3116
3451
|
let env = (config && config.env) || {};
|
|
3117
|
-
const {fetch, Request, Response} = env;
|
|
3118
|
-
const seeds = [
|
|
3119
|
-
Request, Response, fetch
|
|
3120
|
-
];
|
|
3452
|
+
const { fetch, Request, Response } = env;
|
|
3453
|
+
const seeds = [Request, Response, fetch];
|
|
3121
3454
|
|
|
3122
|
-
let len = seeds.length,
|
|
3123
|
-
|
|
3455
|
+
let len = seeds.length,
|
|
3456
|
+
i = len,
|
|
3457
|
+
seed,
|
|
3458
|
+
target,
|
|
3459
|
+
map = seedCache;
|
|
3124
3460
|
|
|
3125
3461
|
while (i--) {
|
|
3126
3462
|
seed = seeds[i];
|
|
3127
3463
|
target = map.get(seed);
|
|
3128
3464
|
|
|
3129
|
-
target === undefined && map.set(seed, target =
|
|
3465
|
+
target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
|
|
3130
3466
|
|
|
3131
3467
|
map = target;
|
|
3132
3468
|
}
|
|
@@ -3142,7 +3478,7 @@
|
|
|
3142
3478
|
* - `http` for Node.js
|
|
3143
3479
|
* - `xhr` for browsers
|
|
3144
3480
|
* - `fetch` for fetch API-based requests
|
|
3145
|
-
*
|
|
3481
|
+
*
|
|
3146
3482
|
* @type {Object<string, Function|Object>}
|
|
3147
3483
|
*/
|
|
3148
3484
|
const knownAdapters = {
|
|
@@ -3150,7 +3486,7 @@
|
|
|
3150
3486
|
xhr: xhrAdapter,
|
|
3151
3487
|
fetch: {
|
|
3152
3488
|
get: getFetch,
|
|
3153
|
-
}
|
|
3489
|
+
},
|
|
3154
3490
|
};
|
|
3155
3491
|
|
|
3156
3492
|
// Assign adapter names for easier debugging and identification
|
|
@@ -3167,7 +3503,7 @@
|
|
|
3167
3503
|
|
|
3168
3504
|
/**
|
|
3169
3505
|
* Render a rejection reason string for unknown or unsupported adapters
|
|
3170
|
-
*
|
|
3506
|
+
*
|
|
3171
3507
|
* @param {string} reason
|
|
3172
3508
|
* @returns {string}
|
|
3173
3509
|
*/
|
|
@@ -3175,17 +3511,18 @@
|
|
|
3175
3511
|
|
|
3176
3512
|
/**
|
|
3177
3513
|
* Check if the adapter is resolved (function, null, or false)
|
|
3178
|
-
*
|
|
3514
|
+
*
|
|
3179
3515
|
* @param {Function|null|false} adapter
|
|
3180
3516
|
* @returns {boolean}
|
|
3181
3517
|
*/
|
|
3182
|
-
const isResolvedHandle = (adapter) =>
|
|
3518
|
+
const isResolvedHandle = (adapter) =>
|
|
3519
|
+
utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3183
3520
|
|
|
3184
3521
|
/**
|
|
3185
3522
|
* Get the first suitable adapter from the provided list.
|
|
3186
3523
|
* Tries each adapter in order until a supported one is found.
|
|
3187
3524
|
* Throws an AxiosError if no adapter is suitable.
|
|
3188
|
-
*
|
|
3525
|
+
*
|
|
3189
3526
|
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3190
3527
|
* @param {Object} config - Axios request configuration
|
|
3191
3528
|
* @throws {AxiosError} If no suitable adapter is available
|
|
@@ -3222,14 +3559,17 @@
|
|
|
3222
3559
|
}
|
|
3223
3560
|
|
|
3224
3561
|
if (!adapter) {
|
|
3225
|
-
const reasons = Object.entries(rejectedReasons)
|
|
3226
|
-
|
|
3562
|
+
const reasons = Object.entries(rejectedReasons).map(
|
|
3563
|
+
([id, state]) =>
|
|
3564
|
+
`adapter ${id} ` +
|
|
3227
3565
|
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
3228
|
-
|
|
3566
|
+
);
|
|
3229
3567
|
|
|
3230
|
-
let s = length
|
|
3231
|
-
|
|
3232
|
-
|
|
3568
|
+
let s = length
|
|
3569
|
+
? reasons.length > 1
|
|
3570
|
+
? 'since :\n' + reasons.map(renderReason).join('\n')
|
|
3571
|
+
: ' ' + renderReason(reasons[0])
|
|
3572
|
+
: 'as no adapter specified';
|
|
3233
3573
|
|
|
3234
3574
|
throw new AxiosError$1(
|
|
3235
3575
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
@@ -3254,7 +3594,7 @@
|
|
|
3254
3594
|
* Exposes all known adapters
|
|
3255
3595
|
* @type {Object<string, Function|Object>}
|
|
3256
3596
|
*/
|
|
3257
|
-
adapters: knownAdapters
|
|
3597
|
+
adapters: knownAdapters,
|
|
3258
3598
|
};
|
|
3259
3599
|
|
|
3260
3600
|
/**
|
|
@@ -3287,10 +3627,7 @@
|
|
|
3287
3627
|
config.headers = AxiosHeaders$1.from(config.headers);
|
|
3288
3628
|
|
|
3289
3629
|
// Transform request data
|
|
3290
|
-
config.data = transformData.call(
|
|
3291
|
-
config,
|
|
3292
|
-
config.transformRequest
|
|
3293
|
-
);
|
|
3630
|
+
config.data = transformData.call(config, config.transformRequest);
|
|
3294
3631
|
|
|
3295
3632
|
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|
3296
3633
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
@@ -3298,39 +3635,38 @@
|
|
|
3298
3635
|
|
|
3299
3636
|
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
|
|
3300
3637
|
|
|
3301
|
-
return adapter(config).then(
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
// Transform response data
|
|
3305
|
-
response.data = transformData.call(
|
|
3306
|
-
config,
|
|
3307
|
-
config.transformResponse,
|
|
3308
|
-
response
|
|
3309
|
-
);
|
|
3310
|
-
|
|
3311
|
-
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3312
|
-
|
|
3313
|
-
return response;
|
|
3314
|
-
}, function onAdapterRejection(reason) {
|
|
3315
|
-
if (!isCancel(reason)) {
|
|
3638
|
+
return adapter(config).then(
|
|
3639
|
+
function onAdapterResolution(response) {
|
|
3316
3640
|
throwIfCancellationRequested(config);
|
|
3317
3641
|
|
|
3318
3642
|
// Transform response data
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3643
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
3644
|
+
|
|
3645
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3646
|
+
|
|
3647
|
+
return response;
|
|
3648
|
+
},
|
|
3649
|
+
function onAdapterRejection(reason) {
|
|
3650
|
+
if (!isCancel(reason)) {
|
|
3651
|
+
throwIfCancellationRequested(config);
|
|
3652
|
+
|
|
3653
|
+
// Transform response data
|
|
3654
|
+
if (reason && reason.response) {
|
|
3655
|
+
reason.response.data = transformData.call(
|
|
3656
|
+
config,
|
|
3657
|
+
config.transformResponse,
|
|
3658
|
+
reason.response
|
|
3659
|
+
);
|
|
3660
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
3661
|
+
}
|
|
3326
3662
|
}
|
|
3327
|
-
}
|
|
3328
3663
|
|
|
3329
|
-
|
|
3330
|
-
|
|
3664
|
+
return Promise.reject(reason);
|
|
3665
|
+
}
|
|
3666
|
+
);
|
|
3331
3667
|
}
|
|
3332
3668
|
|
|
3333
|
-
const VERSION = "1.
|
|
3669
|
+
const VERSION = "1.15.2";
|
|
3334
3670
|
|
|
3335
3671
|
const validators$1 = {};
|
|
3336
3672
|
|
|
@@ -3354,7 +3690,15 @@
|
|
|
3354
3690
|
*/
|
|
3355
3691
|
validators$1.transitional = function transitional(validator, version, message) {
|
|
3356
3692
|
function formatMessage(opt, desc) {
|
|
3357
|
-
return
|
|
3693
|
+
return (
|
|
3694
|
+
'[Axios v' +
|
|
3695
|
+
VERSION +
|
|
3696
|
+
"] Transitional option '" +
|
|
3697
|
+
opt +
|
|
3698
|
+
"'" +
|
|
3699
|
+
desc +
|
|
3700
|
+
(message ? '. ' + message : '')
|
|
3701
|
+
);
|
|
3358
3702
|
}
|
|
3359
3703
|
|
|
3360
3704
|
// eslint-disable-next-line func-names
|
|
@@ -3386,7 +3730,7 @@
|
|
|
3386
3730
|
// eslint-disable-next-line no-console
|
|
3387
3731
|
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
3388
3732
|
return true;
|
|
3389
|
-
}
|
|
3733
|
+
};
|
|
3390
3734
|
};
|
|
3391
3735
|
|
|
3392
3736
|
/**
|
|
@@ -3407,12 +3751,17 @@
|
|
|
3407
3751
|
let i = keys.length;
|
|
3408
3752
|
while (i-- > 0) {
|
|
3409
3753
|
const opt = keys[i];
|
|
3410
|
-
|
|
3754
|
+
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
3755
|
+
// a non-function validator and cause a TypeError. See GHSA-q8qp-cvcw-x6jj.
|
|
3756
|
+
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
3411
3757
|
if (validator) {
|
|
3412
3758
|
const value = options[opt];
|
|
3413
3759
|
const result = value === undefined || validator(value, opt, options);
|
|
3414
3760
|
if (result !== true) {
|
|
3415
|
-
throw new AxiosError$1(
|
|
3761
|
+
throw new AxiosError$1(
|
|
3762
|
+
'option ' + opt + ' must be ' + result,
|
|
3763
|
+
AxiosError$1.ERR_BAD_OPTION_VALUE
|
|
3764
|
+
);
|
|
3416
3765
|
}
|
|
3417
3766
|
continue;
|
|
3418
3767
|
}
|
|
@@ -3424,7 +3773,7 @@
|
|
|
3424
3773
|
|
|
3425
3774
|
var validator = {
|
|
3426
3775
|
assertOptions,
|
|
3427
|
-
validators: validators$1
|
|
3776
|
+
validators: validators$1,
|
|
3428
3777
|
};
|
|
3429
3778
|
|
|
3430
3779
|
const validators = validator.validators;
|
|
@@ -3441,7 +3790,7 @@
|
|
|
3441
3790
|
this.defaults = instanceConfig || {};
|
|
3442
3791
|
this.interceptors = {
|
|
3443
3792
|
request: new InterceptorManager$1(),
|
|
3444
|
-
response: new InterceptorManager$1()
|
|
3793
|
+
response: new InterceptorManager$1(),
|
|
3445
3794
|
};
|
|
3446
3795
|
}
|
|
3447
3796
|
|
|
@@ -3463,13 +3812,29 @@
|
|
|
3463
3812
|
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
3464
3813
|
|
|
3465
3814
|
// slice off the Error: ... line
|
|
3466
|
-
const stack =
|
|
3815
|
+
const stack = (() => {
|
|
3816
|
+
if (!dummy.stack) {
|
|
3817
|
+
return '';
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
const firstNewlineIndex = dummy.stack.indexOf('\n');
|
|
3821
|
+
|
|
3822
|
+
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
3823
|
+
})();
|
|
3467
3824
|
try {
|
|
3468
3825
|
if (!err.stack) {
|
|
3469
3826
|
err.stack = stack;
|
|
3470
3827
|
// match without the 2 top stack lines
|
|
3471
|
-
} else if (stack
|
|
3472
|
-
|
|
3828
|
+
} else if (stack) {
|
|
3829
|
+
const firstNewlineIndex = stack.indexOf('\n');
|
|
3830
|
+
const secondNewlineIndex =
|
|
3831
|
+
firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
3832
|
+
const stackWithoutTwoTopLines =
|
|
3833
|
+
secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
|
|
3834
|
+
|
|
3835
|
+
if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
|
|
3836
|
+
err.stack += '\n' + stack;
|
|
3837
|
+
}
|
|
3473
3838
|
}
|
|
3474
3839
|
} catch (e) {
|
|
3475
3840
|
// ignore the case where "stack" is an un-writable property
|
|
@@ -3492,27 +3857,35 @@
|
|
|
3492
3857
|
|
|
3493
3858
|
config = mergeConfig(this.defaults, config);
|
|
3494
3859
|
|
|
3495
|
-
const {transitional, paramsSerializer, headers} = config;
|
|
3860
|
+
const { transitional, paramsSerializer, headers } = config;
|
|
3496
3861
|
|
|
3497
3862
|
if (transitional !== undefined) {
|
|
3498
|
-
validator.assertOptions(
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3863
|
+
validator.assertOptions(
|
|
3864
|
+
transitional,
|
|
3865
|
+
{
|
|
3866
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
3867
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
3868
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
3869
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
3870
|
+
},
|
|
3871
|
+
false
|
|
3872
|
+
);
|
|
3504
3873
|
}
|
|
3505
3874
|
|
|
3506
3875
|
if (paramsSerializer != null) {
|
|
3507
3876
|
if (utils$1.isFunction(paramsSerializer)) {
|
|
3508
3877
|
config.paramsSerializer = {
|
|
3509
|
-
serialize: paramsSerializer
|
|
3878
|
+
serialize: paramsSerializer,
|
|
3510
3879
|
};
|
|
3511
3880
|
} else {
|
|
3512
|
-
validator.assertOptions(
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3881
|
+
validator.assertOptions(
|
|
3882
|
+
paramsSerializer,
|
|
3883
|
+
{
|
|
3884
|
+
encode: validators.function,
|
|
3885
|
+
serialize: validators.function,
|
|
3886
|
+
},
|
|
3887
|
+
true
|
|
3888
|
+
);
|
|
3516
3889
|
}
|
|
3517
3890
|
}
|
|
3518
3891
|
|
|
@@ -3523,26 +3896,25 @@
|
|
|
3523
3896
|
config.allowAbsoluteUrls = true;
|
|
3524
3897
|
}
|
|
3525
3898
|
|
|
3526
|
-
validator.assertOptions(
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3899
|
+
validator.assertOptions(
|
|
3900
|
+
config,
|
|
3901
|
+
{
|
|
3902
|
+
baseUrl: validators.spelling('baseURL'),
|
|
3903
|
+
withXsrfToken: validators.spelling('withXSRFToken'),
|
|
3904
|
+
},
|
|
3905
|
+
true
|
|
3906
|
+
);
|
|
3530
3907
|
|
|
3531
3908
|
// Set config.method
|
|
3532
3909
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
3533
3910
|
|
|
3534
3911
|
// Flatten headers
|
|
3535
|
-
let contextHeaders = headers && utils$1.merge(
|
|
3536
|
-
headers.common,
|
|
3537
|
-
headers[config.method]
|
|
3538
|
-
);
|
|
3912
|
+
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
3539
3913
|
|
|
3540
|
-
headers &&
|
|
3541
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
3542
|
-
(method) => {
|
|
3914
|
+
headers &&
|
|
3915
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
|
3543
3916
|
delete headers[method];
|
|
3544
|
-
}
|
|
3545
|
-
);
|
|
3917
|
+
});
|
|
3546
3918
|
|
|
3547
3919
|
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
3548
3920
|
|
|
@@ -3557,7 +3929,8 @@
|
|
|
3557
3929
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3558
3930
|
|
|
3559
3931
|
const transitional = config.transitional || transitionalDefaults;
|
|
3560
|
-
const legacyInterceptorReqResOrdering =
|
|
3932
|
+
const legacyInterceptorReqResOrdering =
|
|
3933
|
+
transitional && transitional.legacyInterceptorReqResOrdering;
|
|
3561
3934
|
|
|
3562
3935
|
if (legacyInterceptorReqResOrdering) {
|
|
3563
3936
|
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
@@ -3631,28 +4004,32 @@
|
|
|
3631
4004
|
// Provide aliases for supported request methods
|
|
3632
4005
|
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
3633
4006
|
/*eslint func-names:0*/
|
|
3634
|
-
Axios.prototype[method] = function(url, config) {
|
|
3635
|
-
return this.request(
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
4007
|
+
Axios.prototype[method] = function (url, config) {
|
|
4008
|
+
return this.request(
|
|
4009
|
+
mergeConfig(config || {}, {
|
|
4010
|
+
method,
|
|
4011
|
+
url,
|
|
4012
|
+
data: (config || {}).data,
|
|
4013
|
+
})
|
|
4014
|
+
);
|
|
3640
4015
|
};
|
|
3641
4016
|
});
|
|
3642
4017
|
|
|
3643
4018
|
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3644
|
-
/*eslint func-names:0*/
|
|
3645
|
-
|
|
3646
4019
|
function generateHTTPMethod(isForm) {
|
|
3647
4020
|
return function httpMethod(url, data, config) {
|
|
3648
|
-
return this.request(
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
4021
|
+
return this.request(
|
|
4022
|
+
mergeConfig(config || {}, {
|
|
4023
|
+
method,
|
|
4024
|
+
headers: isForm
|
|
4025
|
+
? {
|
|
4026
|
+
'Content-Type': 'multipart/form-data',
|
|
4027
|
+
}
|
|
4028
|
+
: {},
|
|
4029
|
+
url,
|
|
4030
|
+
data,
|
|
4031
|
+
})
|
|
4032
|
+
);
|
|
3656
4033
|
};
|
|
3657
4034
|
}
|
|
3658
4035
|
|
|
@@ -3685,7 +4062,7 @@
|
|
|
3685
4062
|
const token = this;
|
|
3686
4063
|
|
|
3687
4064
|
// eslint-disable-next-line func-names
|
|
3688
|
-
this.promise.then(cancel => {
|
|
4065
|
+
this.promise.then((cancel) => {
|
|
3689
4066
|
if (!token._listeners) return;
|
|
3690
4067
|
|
|
3691
4068
|
let i = token._listeners.length;
|
|
@@ -3697,10 +4074,10 @@
|
|
|
3697
4074
|
});
|
|
3698
4075
|
|
|
3699
4076
|
// eslint-disable-next-line func-names
|
|
3700
|
-
this.promise.then = onfulfilled => {
|
|
4077
|
+
this.promise.then = (onfulfilled) => {
|
|
3701
4078
|
let _resolve;
|
|
3702
4079
|
// eslint-disable-next-line func-names
|
|
3703
|
-
const promise = new Promise(resolve => {
|
|
4080
|
+
const promise = new Promise((resolve) => {
|
|
3704
4081
|
token.subscribe(resolve);
|
|
3705
4082
|
_resolve = resolve;
|
|
3706
4083
|
}).then(onfulfilled);
|
|
@@ -3788,7 +4165,7 @@
|
|
|
3788
4165
|
});
|
|
3789
4166
|
return {
|
|
3790
4167
|
token,
|
|
3791
|
-
cancel
|
|
4168
|
+
cancel,
|
|
3792
4169
|
};
|
|
3793
4170
|
}
|
|
3794
4171
|
}
|
|
@@ -3830,7 +4207,7 @@
|
|
|
3830
4207
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3831
4208
|
*/
|
|
3832
4209
|
function isAxiosError(payload) {
|
|
3833
|
-
return utils$1.isObject(payload) &&
|
|
4210
|
+
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
3834
4211
|
}
|
|
3835
4212
|
|
|
3836
4213
|
const HttpStatusCode = {
|
|
@@ -3923,10 +4300,10 @@
|
|
|
3923
4300
|
const instance = bind(Axios$1.prototype.request, context);
|
|
3924
4301
|
|
|
3925
4302
|
// Copy axios.prototype to instance
|
|
3926
|
-
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
|
4303
|
+
utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
|
|
3927
4304
|
|
|
3928
4305
|
// Copy context to instance
|
|
3929
|
-
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
4306
|
+
utils$1.extend(instance, context, null, { allOwnKeys: true });
|
|
3930
4307
|
|
|
3931
4308
|
// Factory for creating new instances
|
|
3932
4309
|
instance.create = function create(instanceConfig) {
|
|
@@ -3970,7 +4347,7 @@
|
|
|
3970
4347
|
|
|
3971
4348
|
axios.AxiosHeaders = AxiosHeaders$1;
|
|
3972
4349
|
|
|
3973
|
-
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4350
|
+
axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
3974
4351
|
|
|
3975
4352
|
axios.getAdapter = adapters.getAdapter;
|
|
3976
4353
|
|
|
@@ -4166,8 +4543,132 @@
|
|
|
4166
4543
|
HTML_PAGE_REQUEST: 'HTML_PAGE_REQUEST',
|
|
4167
4544
|
HTML_PAGE_RESPONSE: 'HTML_PAGE_RESPONSE',
|
|
4168
4545
|
HTML_PAGE_EVENT: 'HTML_PAGE_EVENT',
|
|
4546
|
+
HTML_PAGE_ENABLE_COMMENT_MODE: 'HTML_PAGE_ENABLE_COMMENT_MODE',
|
|
4547
|
+
HTML_PAGE_DISABLE_COMMENT_MODE: 'HTML_PAGE_DISABLE_COMMENT_MODE',
|
|
4548
|
+
HTML_PAGE_COMMENT_MODE_ELEMENT_HOVER: 'HTML_PAGE_COMMENT_MODE_ELEMENT_HOVER',
|
|
4549
|
+
HTML_PAGE_COMMENT_MODE_ELEMENT_SELECTED: 'HTML_PAGE_COMMENT_MODE_ELEMENT_SELECTED',
|
|
4169
4550
|
WINDOW_EVENT: 'WINDOW_EVENT'
|
|
4170
4551
|
};
|
|
4552
|
+
|
|
4553
|
+
const countSameTagSiblingsBefore = element => {
|
|
4554
|
+
let count = 0;
|
|
4555
|
+
let sibling = element.previousElementSibling;
|
|
4556
|
+
while (sibling) {
|
|
4557
|
+
if (sibling.tagName === element.tagName) count += 1;
|
|
4558
|
+
sibling = sibling.previousElementSibling;
|
|
4559
|
+
}
|
|
4560
|
+
return count;
|
|
4561
|
+
};
|
|
4562
|
+
const generateSelector = element => {
|
|
4563
|
+
if (!element || element === document.body) return null;
|
|
4564
|
+
const parts = [];
|
|
4565
|
+
let current = element;
|
|
4566
|
+
while (current && current !== document.body) {
|
|
4567
|
+
const tag = current.tagName.toLowerCase();
|
|
4568
|
+
const index = countSameTagSiblingsBefore(current) + 1;
|
|
4569
|
+
parts.unshift(`${tag}:nth-of-type(${index})`);
|
|
4570
|
+
current = current.parentElement;
|
|
4571
|
+
}
|
|
4572
|
+
return 'body > ' + parts.join(' > ');
|
|
4573
|
+
};
|
|
4574
|
+
const getHtmlHint = function (element) {
|
|
4575
|
+
let maxLen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 180;
|
|
4576
|
+
const html = element.outerHTML || '';
|
|
4577
|
+
return html.length > maxLen ? html.slice(0, maxLen) : html;
|
|
4578
|
+
};
|
|
4579
|
+
const getCurrentText = function (element) {
|
|
4580
|
+
let maxLen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 160;
|
|
4581
|
+
const text = (element.textContent || '').replace(/\s+/g, ' ').trim();
|
|
4582
|
+
return text.length > maxLen ? text.slice(0, maxLen) : text;
|
|
4583
|
+
};
|
|
4584
|
+
const computeStyle = element => {
|
|
4585
|
+
const style = window.getComputedStyle(element);
|
|
4586
|
+
return {
|
|
4587
|
+
backgroundColor: style.backgroundColor,
|
|
4588
|
+
color: style.color,
|
|
4589
|
+
fontSize: style.fontSize,
|
|
4590
|
+
fontWeight: style.fontWeight,
|
|
4591
|
+
fontFamily: style.fontFamily,
|
|
4592
|
+
lineHeight: style.lineHeight,
|
|
4593
|
+
borderRadius: style.borderRadius,
|
|
4594
|
+
paddingBottom: style.paddingBottom,
|
|
4595
|
+
paddingLeft: style.paddingLeft,
|
|
4596
|
+
paddingRight: style.paddingRight,
|
|
4597
|
+
paddingTop: style.paddingTop,
|
|
4598
|
+
marginBottom: style.marginBottom,
|
|
4599
|
+
marginLeft: style.marginLeft,
|
|
4600
|
+
marginRight: style.marginRight,
|
|
4601
|
+
marginTop: style.marginTop,
|
|
4602
|
+
textAlign: style.textAlign,
|
|
4603
|
+
display: style.display,
|
|
4604
|
+
width: style.width,
|
|
4605
|
+
height: style.height
|
|
4606
|
+
};
|
|
4607
|
+
};
|
|
4608
|
+
const generateLabel = element => {
|
|
4609
|
+
const tag = element.tagName.toLowerCase();
|
|
4610
|
+
const classes = element.classList.length > 0 ? '.' + Array.from(element.classList).join('.') : '';
|
|
4611
|
+
return `${tag}${classes}`;
|
|
4612
|
+
};
|
|
4613
|
+
class CommentModeAdapter {
|
|
4614
|
+
constructor() {
|
|
4615
|
+
this.isActive = false;
|
|
4616
|
+
this._handleEvent = this._handleEvent.bind(this);
|
|
4617
|
+
this.mouseEvents = ['click', 'dblclick', 'mousedown', 'mouseup', 'mousemove', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave', 'contextmenu'];
|
|
4618
|
+
}
|
|
4619
|
+
enable() {
|
|
4620
|
+
if (this.isActive) return;
|
|
4621
|
+
this.isActive = true;
|
|
4622
|
+
this.mouseEvents.forEach(eventType => {
|
|
4623
|
+
window.addEventListener(eventType, this._handleEvent, true);
|
|
4624
|
+
});
|
|
4625
|
+
}
|
|
4626
|
+
disable() {
|
|
4627
|
+
if (!this.isActive) return;
|
|
4628
|
+
this.isActive = false;
|
|
4629
|
+
this.mouseEvents.forEach(eventType => {
|
|
4630
|
+
window.removeEventListener(eventType, this._handleEvent, true);
|
|
4631
|
+
});
|
|
4632
|
+
}
|
|
4633
|
+
_handleEvent(event) {
|
|
4634
|
+
if (!this.isActive) return;
|
|
4635
|
+
event.preventDefault();
|
|
4636
|
+
event.stopPropagation();
|
|
4637
|
+
event.stopImmediatePropagation();
|
|
4638
|
+
const target = event.target;
|
|
4639
|
+
if (event.type === 'mouseover') {
|
|
4640
|
+
const data = this.buildElementData(target);
|
|
4641
|
+
if (data) {
|
|
4642
|
+
window.parent.postMessage({
|
|
4643
|
+
type: POST_MESSAGE_TYPE.HTML_PAGE_COMMENT_MODE_ELEMENT_HOVER,
|
|
4644
|
+
data
|
|
4645
|
+
}, '*');
|
|
4646
|
+
}
|
|
4647
|
+
} else if (event.type === 'click') {
|
|
4648
|
+
const data = this.buildElementData(target);
|
|
4649
|
+
if (data) {
|
|
4650
|
+
window.parent.postMessage({
|
|
4651
|
+
type: POST_MESSAGE_TYPE.HTML_PAGE_COMMENT_MODE_ELEMENT_SELECTED,
|
|
4652
|
+
data
|
|
4653
|
+
}, '*');
|
|
4654
|
+
}
|
|
4655
|
+
}
|
|
4656
|
+
}
|
|
4657
|
+
buildElementData(target) {
|
|
4658
|
+
const selector = generateSelector(target) || null;
|
|
4659
|
+
return {
|
|
4660
|
+
selector,
|
|
4661
|
+
currentText: getCurrentText(target),
|
|
4662
|
+
htmlHint: getHtmlHint(target),
|
|
4663
|
+
computedStyle: computeStyle(target),
|
|
4664
|
+
label: generateLabel(target)
|
|
4665
|
+
};
|
|
4666
|
+
}
|
|
4667
|
+
destroy() {
|
|
4668
|
+
this.disable();
|
|
4669
|
+
}
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4171
4672
|
const POST_MESSAGE_REQUEST_TYPE = {
|
|
4172
4673
|
GET_SERVER: 'get_server',
|
|
4173
4674
|
GET_ACCESS_TOKEN: 'get_access_token',
|
|
@@ -4182,6 +4683,7 @@
|
|
|
4182
4683
|
const SUPPORT_WINDOW_KEYBOARD_EVENT_TYPES = ['keydown', 'keyup', 'keypress'];
|
|
4183
4684
|
const SUPPORT_WINDOW_DRAG_EVENT_TYPES = ['dragstart', 'dragover', 'drag', 'dragend', 'dragenter', 'dragleave', 'drop'];
|
|
4184
4685
|
const HIGH_FREQUENCY_WINDOW_EVENT_TYPES = ['mousemove', 'dragover'];
|
|
4686
|
+
const INTERACTIVE_TAGS = ['SELECT', 'INPUT', 'TEXTAREA', 'BUTTON'];
|
|
4185
4687
|
const hasOwnProperty = (obj, key) => {
|
|
4186
4688
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
4187
4689
|
};
|
|
@@ -4243,6 +4745,8 @@
|
|
|
4243
4745
|
this.pendingRequests = {};
|
|
4244
4746
|
this.eventHandlers = {};
|
|
4245
4747
|
this.timeout = this.options.timeout || 10000;
|
|
4748
|
+
this.isCommentMode = false;
|
|
4749
|
+
this.commentModeAdapter = new CommentModeAdapter();
|
|
4246
4750
|
this.setupMessageListener();
|
|
4247
4751
|
}
|
|
4248
4752
|
generatorRequestId() {
|
|
@@ -4270,41 +4774,57 @@
|
|
|
4270
4774
|
}, this.targetOrigin);
|
|
4271
4775
|
}
|
|
4272
4776
|
setEventsListener() {
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
pendingEvent = createWindowEventData({
|
|
4283
|
-
eventType,
|
|
4284
|
-
event
|
|
4285
|
-
});
|
|
4286
|
-
|
|
4287
|
-
// Only schedule a new frame if one isn't already scheduled
|
|
4288
|
-
if (rafId === null) {
|
|
4289
|
-
rafId = requestAnimationFrame(() => {
|
|
4290
|
-
if (pendingEvent) {
|
|
4291
|
-
this.postWindowEvent(pendingEvent);
|
|
4292
|
-
pendingEvent = null;
|
|
4293
|
-
rafId = null;
|
|
4294
|
-
}
|
|
4295
|
-
});
|
|
4296
|
-
}
|
|
4297
|
-
return;
|
|
4298
|
-
}
|
|
4299
|
-
|
|
4300
|
-
// Low-frequency events
|
|
4301
|
-
this.postWindowEvent(createWindowEventData({
|
|
4302
|
-
eventType,
|
|
4303
|
-
event
|
|
4304
|
-
}));
|
|
4305
|
-
}, true);
|
|
4777
|
+
this._windowEventHandler = this._windowEventHandler.bind(this);
|
|
4778
|
+
this.interactiveEventTypes = [...SUPPORT_WINDOW_MOUSE_EVENT_TYPES, ...SUPPORT_WINDOW_KEYBOARD_EVENT_TYPES, ...SUPPORT_WINDOW_DRAG_EVENT_TYPES];
|
|
4779
|
+
this.rafId = null;
|
|
4780
|
+
this.pendingEvent = null;
|
|
4781
|
+
this.bindInteractiveEvents();
|
|
4782
|
+
}
|
|
4783
|
+
bindInteractiveEvents() {
|
|
4784
|
+
this.interactiveEventTypes.forEach(eventType => {
|
|
4785
|
+
window.addEventListener(eventType, this._windowEventHandler, true);
|
|
4306
4786
|
});
|
|
4307
4787
|
}
|
|
4788
|
+
unbindInteractiveEvents() {
|
|
4789
|
+
this.interactiveEventTypes.forEach(eventType => {
|
|
4790
|
+
window.removeEventListener(eventType, this._windowEventHandler, true);
|
|
4791
|
+
});
|
|
4792
|
+
if (this.rafId !== null) {
|
|
4793
|
+
cancelAnimationFrame(this.rafId);
|
|
4794
|
+
this.rafId = null;
|
|
4795
|
+
}
|
|
4796
|
+
this.pendingEvent = null;
|
|
4797
|
+
}
|
|
4798
|
+
_windowEventHandler(event) {
|
|
4799
|
+
if (event.source === WINDOW_EVENT_SOURCE_TYPE.APP) return;
|
|
4800
|
+
const target = event.target;
|
|
4801
|
+
if (target && INTERACTIVE_TAGS.includes(target.tagName)) return;
|
|
4802
|
+
const eventType = event.type;
|
|
4803
|
+
if (SUPPORT_WINDOW_KEYBOARD_EVENT_TYPES.includes(eventType)) {
|
|
4804
|
+
const active = document.activeElement;
|
|
4805
|
+
if (active && INTERACTIVE_TAGS.includes(active.tagName)) return;
|
|
4806
|
+
}
|
|
4807
|
+
if (HIGH_FREQUENCY_WINDOW_EVENT_TYPES.includes(eventType)) {
|
|
4808
|
+
this.pendingEvent = createWindowEventData({
|
|
4809
|
+
eventType,
|
|
4810
|
+
event
|
|
4811
|
+
});
|
|
4812
|
+
if (this.rafId === null) {
|
|
4813
|
+
this.rafId = requestAnimationFrame(() => {
|
|
4814
|
+
if (this.pendingEvent) {
|
|
4815
|
+
this.postWindowEvent(this.pendingEvent);
|
|
4816
|
+
this.pendingEvent = null;
|
|
4817
|
+
this.rafId = null;
|
|
4818
|
+
}
|
|
4819
|
+
});
|
|
4820
|
+
}
|
|
4821
|
+
return;
|
|
4822
|
+
}
|
|
4823
|
+
this.postWindowEvent(createWindowEventData({
|
|
4824
|
+
eventType,
|
|
4825
|
+
event
|
|
4826
|
+
}));
|
|
4827
|
+
}
|
|
4308
4828
|
async request(method, params) {
|
|
4309
4829
|
if (this.selfWindow) {
|
|
4310
4830
|
return new Promise(resolve => {
|
|
@@ -4362,62 +4882,75 @@
|
|
|
4362
4882
|
}
|
|
4363
4883
|
} else if (type === POST_MESSAGE_TYPE.HTML_PAGE_EVENT) {
|
|
4364
4884
|
this.emitEvent(eventType, payload);
|
|
4885
|
+
} else if (type === POST_MESSAGE_TYPE.HTML_PAGE_ENABLE_COMMENT_MODE) {
|
|
4886
|
+
this.isCommentMode = true;
|
|
4887
|
+
document.body.style.cursor = 'crosshair';
|
|
4888
|
+
this.unbindInteractiveEvents();
|
|
4889
|
+
if (this.commentModeAdapter) this.commentModeAdapter.enable();
|
|
4890
|
+
} else if (type === POST_MESSAGE_TYPE.HTML_PAGE_DISABLE_COMMENT_MODE) {
|
|
4891
|
+
this.isCommentMode = false;
|
|
4892
|
+
document.body.style.cursor = '';
|
|
4893
|
+
if (this.commentModeAdapter) this.commentModeAdapter.disable();
|
|
4894
|
+
this.bindInteractiveEvents();
|
|
4365
4895
|
} else if (type === POST_MESSAGE_TYPE.WINDOW_EVENT) {
|
|
4366
|
-
|
|
4367
|
-
if (!eventData) return;
|
|
4368
|
-
let syntheticEvent;
|
|
4369
|
-
let targetElement;
|
|
4370
|
-
if (SUPPORT_WINDOW_KEYBOARD_EVENT_TYPES.includes(eventData.type)) {
|
|
4371
|
-
syntheticEvent = new KeyboardEvent(eventData.type, {
|
|
4372
|
-
bubbles: true,
|
|
4373
|
-
cancelable: true,
|
|
4374
|
-
key: eventData.key,
|
|
4375
|
-
code: eventData.code,
|
|
4376
|
-
keyCode: eventData.keyCode,
|
|
4377
|
-
ctrlKey: eventData.ctrlKey,
|
|
4378
|
-
shiftKey: eventData.shiftKey,
|
|
4379
|
-
altKey: eventData.altKey,
|
|
4380
|
-
metaKey: eventData.metaKey,
|
|
4381
|
-
repeat: eventData.repeat,
|
|
4382
|
-
view: window
|
|
4383
|
-
});
|
|
4384
|
-
targetElement = document.activeElement || document.body;
|
|
4385
|
-
} else if (SUPPORT_WINDOW_MOUSE_EVENT_TYPES.includes(eventData.type)) {
|
|
4386
|
-
syntheticEvent = new MouseEvent(eventData.type, {
|
|
4387
|
-
bubbles: true,
|
|
4388
|
-
cancelable: true,
|
|
4389
|
-
view: window,
|
|
4390
|
-
clientX: eventData.x,
|
|
4391
|
-
clientY: eventData.y,
|
|
4392
|
-
screenX: eventData.x,
|
|
4393
|
-
screenY: eventData.y,
|
|
4394
|
-
button: eventData.button,
|
|
4395
|
-
buttons: eventData.buttons
|
|
4396
|
-
});
|
|
4397
|
-
const elementAtPoint = document.elementFromPoint(eventData.x, eventData.y);
|
|
4398
|
-
targetElement = elementAtPoint || document.body;
|
|
4399
|
-
} else if (SUPPORT_WINDOW_DRAG_EVENT_TYPES.includes(eventData.type)) {
|
|
4400
|
-
syntheticEvent = new DragEvent(eventData.type, {
|
|
4401
|
-
bubbles: true,
|
|
4402
|
-
cancelable: true,
|
|
4403
|
-
view: window,
|
|
4404
|
-
clientX: eventData.x,
|
|
4405
|
-
clientY: eventData.y,
|
|
4406
|
-
screenX: eventData.x,
|
|
4407
|
-
screenY: eventData.y,
|
|
4408
|
-
button: eventData.button,
|
|
4409
|
-
buttons: eventData.buttons
|
|
4410
|
-
});
|
|
4411
|
-
const elementAtPoint = document.elementFromPoint(eventData.x, eventData.y);
|
|
4412
|
-
targetElement = elementAtPoint || document.body;
|
|
4413
|
-
}
|
|
4414
|
-
if (!targetElement || !syntheticEvent) return;
|
|
4415
|
-
|
|
4416
|
-
// Dispatch once on the target element, it will bubble up naturally
|
|
4417
|
-
syntheticEvent.source = eventData.source;
|
|
4418
|
-
targetElement.dispatchEvent(syntheticEvent);
|
|
4896
|
+
this.handleWindowEvent(data);
|
|
4419
4897
|
}
|
|
4420
4898
|
}
|
|
4899
|
+
handleWindowEvent(data) {
|
|
4900
|
+
const eventData = data.event_data;
|
|
4901
|
+
if (!eventData || this.isCommentMode) return;
|
|
4902
|
+
let syntheticEvent;
|
|
4903
|
+
let targetElement;
|
|
4904
|
+
if (SUPPORT_WINDOW_KEYBOARD_EVENT_TYPES.includes(eventData.type)) {
|
|
4905
|
+
syntheticEvent = new KeyboardEvent(eventData.type, {
|
|
4906
|
+
bubbles: true,
|
|
4907
|
+
cancelable: true,
|
|
4908
|
+
key: eventData.key,
|
|
4909
|
+
code: eventData.code,
|
|
4910
|
+
keyCode: eventData.keyCode,
|
|
4911
|
+
ctrlKey: eventData.ctrlKey,
|
|
4912
|
+
shiftKey: eventData.shiftKey,
|
|
4913
|
+
altKey: eventData.altKey,
|
|
4914
|
+
metaKey: eventData.metaKey,
|
|
4915
|
+
repeat: eventData.repeat,
|
|
4916
|
+
view: window
|
|
4917
|
+
});
|
|
4918
|
+
targetElement = document.activeElement || document.body;
|
|
4919
|
+
} else if (SUPPORT_WINDOW_MOUSE_EVENT_TYPES.includes(eventData.type)) {
|
|
4920
|
+
syntheticEvent = new MouseEvent(eventData.type, {
|
|
4921
|
+
bubbles: true,
|
|
4922
|
+
cancelable: true,
|
|
4923
|
+
view: window,
|
|
4924
|
+
clientX: eventData.x,
|
|
4925
|
+
clientY: eventData.y,
|
|
4926
|
+
screenX: eventData.x,
|
|
4927
|
+
screenY: eventData.y,
|
|
4928
|
+
button: eventData.button,
|
|
4929
|
+
buttons: eventData.buttons
|
|
4930
|
+
});
|
|
4931
|
+
const elementAtPoint = document.elementFromPoint(eventData.x, eventData.y);
|
|
4932
|
+
targetElement = elementAtPoint || document.body;
|
|
4933
|
+
} else if (SUPPORT_WINDOW_DRAG_EVENT_TYPES.includes(eventData.type)) {
|
|
4934
|
+
syntheticEvent = new DragEvent(eventData.type, {
|
|
4935
|
+
bubbles: true,
|
|
4936
|
+
cancelable: true,
|
|
4937
|
+
view: window,
|
|
4938
|
+
clientX: eventData.x,
|
|
4939
|
+
clientY: eventData.y,
|
|
4940
|
+
screenX: eventData.x,
|
|
4941
|
+
screenY: eventData.y,
|
|
4942
|
+
button: eventData.button,
|
|
4943
|
+
buttons: eventData.buttons
|
|
4944
|
+
});
|
|
4945
|
+
const elementAtPoint = document.elementFromPoint(eventData.x, eventData.y);
|
|
4946
|
+
targetElement = elementAtPoint || document.body;
|
|
4947
|
+
}
|
|
4948
|
+
if (!targetElement || !syntheticEvent) return;
|
|
4949
|
+
|
|
4950
|
+
// Dispatch once on the target element, it will bubble up naturally
|
|
4951
|
+
syntheticEvent.source = eventData.source;
|
|
4952
|
+
targetElement.dispatchEvent(syntheticEvent);
|
|
4953
|
+
}
|
|
4421
4954
|
on(eventType, handler) {
|
|
4422
4955
|
if (!hasOwnProperty(this.eventHandlers, eventType)) {
|
|
4423
4956
|
this.eventHandlers[eventType] = [];
|
|
@@ -4452,6 +4985,9 @@
|
|
|
4452
4985
|
});
|
|
4453
4986
|
this.pendingRequests = {};
|
|
4454
4987
|
this.eventHandlers = {};
|
|
4988
|
+
if (this.commentModeAdapter) {
|
|
4989
|
+
this.commentModeAdapter.destroy();
|
|
4990
|
+
}
|
|
4455
4991
|
}
|
|
4456
4992
|
}
|
|
4457
4993
|
|