@xchainjs/xchain-dash 2.2.2 → 2.2.3
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/lib/index.esm.js +1071 -759
- package/lib/index.js +1071 -759
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -197,7 +197,7 @@ const { isArray } = Array;
|
|
|
197
197
|
*
|
|
198
198
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
199
199
|
*/
|
|
200
|
-
const isUndefined = typeOfTest(
|
|
200
|
+
const isUndefined = typeOfTest('undefined');
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
203
|
* Determine if a value is a Buffer
|
|
@@ -224,7 +224,7 @@ function isBuffer(val) {
|
|
|
224
224
|
*
|
|
225
225
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
226
226
|
*/
|
|
227
|
-
const isArrayBuffer = kindOfTest(
|
|
227
|
+
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
230
|
* Determine if a value is a view on an ArrayBuffer
|
|
@@ -235,7 +235,7 @@ const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
|
235
235
|
*/
|
|
236
236
|
function isArrayBufferView(val) {
|
|
237
237
|
let result;
|
|
238
|
-
if (typeof ArrayBuffer !==
|
|
238
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|
239
239
|
result = ArrayBuffer.isView(val);
|
|
240
240
|
} else {
|
|
241
241
|
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
@@ -250,7 +250,7 @@ function isArrayBufferView(val) {
|
|
|
250
250
|
*
|
|
251
251
|
* @returns {boolean} True if value is a String, otherwise false
|
|
252
252
|
*/
|
|
253
|
-
const isString = typeOfTest(
|
|
253
|
+
const isString = typeOfTest('string');
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
256
|
* Determine if a value is a Function
|
|
@@ -258,7 +258,7 @@ const isString = typeOfTest("string");
|
|
|
258
258
|
* @param {*} val The value to test
|
|
259
259
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
260
260
|
*/
|
|
261
|
-
const isFunction$1 = typeOfTest(
|
|
261
|
+
const isFunction$1 = typeOfTest('function');
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* Determine if a value is a Number
|
|
@@ -267,7 +267,7 @@ const isFunction$1 = typeOfTest("function");
|
|
|
267
267
|
*
|
|
268
268
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
269
269
|
*/
|
|
270
|
-
const isNumber = typeOfTest(
|
|
270
|
+
const isNumber = typeOfTest('number');
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
273
|
* Determine if a value is an Object
|
|
@@ -276,7 +276,7 @@ const isNumber = typeOfTest("number");
|
|
|
276
276
|
*
|
|
277
277
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
278
278
|
*/
|
|
279
|
-
const isObject = (thing) => thing !== null && typeof thing ===
|
|
279
|
+
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
280
280
|
|
|
281
281
|
/**
|
|
282
282
|
* Determine if a value is a Boolean
|
|
@@ -294,7 +294,7 @@ const isBoolean = (thing) => thing === true || thing === false;
|
|
|
294
294
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
295
295
|
*/
|
|
296
296
|
const isPlainObject = (val) => {
|
|
297
|
-
if (kindOf(val) !==
|
|
297
|
+
if (kindOf(val) !== 'object') {
|
|
298
298
|
return false;
|
|
299
299
|
}
|
|
300
300
|
|
|
@@ -322,10 +322,7 @@ const isEmptyObject = (val) => {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
try {
|
|
325
|
-
return (
|
|
326
|
-
Object.keys(val).length === 0 &&
|
|
327
|
-
Object.getPrototypeOf(val) === Object.prototype
|
|
328
|
-
);
|
|
325
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
329
326
|
} catch (e) {
|
|
330
327
|
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
331
328
|
return false;
|
|
@@ -339,7 +336,7 @@ const isEmptyObject = (val) => {
|
|
|
339
336
|
*
|
|
340
337
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
341
338
|
*/
|
|
342
|
-
const isDate = kindOfTest(
|
|
339
|
+
const isDate = kindOfTest('Date');
|
|
343
340
|
|
|
344
341
|
/**
|
|
345
342
|
* Determine if a value is a File
|
|
@@ -348,7 +345,32 @@ const isDate = kindOfTest("Date");
|
|
|
348
345
|
*
|
|
349
346
|
* @returns {boolean} True if value is a File, otherwise false
|
|
350
347
|
*/
|
|
351
|
-
const isFile = kindOfTest(
|
|
348
|
+
const isFile = kindOfTest('File');
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Determine if a value is a React Native Blob
|
|
352
|
+
* React Native "blob": an object with a `uri` attribute. Optionally, it can
|
|
353
|
+
* also have a `name` and `type` attribute to specify filename and content type
|
|
354
|
+
*
|
|
355
|
+
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
356
|
+
*
|
|
357
|
+
* @param {*} value The value to test
|
|
358
|
+
*
|
|
359
|
+
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
360
|
+
*/
|
|
361
|
+
const isReactNativeBlob = (value) => {
|
|
362
|
+
return !!(value && typeof value.uri !== 'undefined');
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Determine if environment is React Native
|
|
367
|
+
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
368
|
+
*
|
|
369
|
+
* @param {*} formData The formData to test
|
|
370
|
+
*
|
|
371
|
+
* @returns {boolean} True if environment is React Native, otherwise false
|
|
372
|
+
*/
|
|
373
|
+
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
352
374
|
|
|
353
375
|
/**
|
|
354
376
|
* Determine if a value is a Blob
|
|
@@ -357,7 +379,7 @@ const isFile = kindOfTest("File");
|
|
|
357
379
|
*
|
|
358
380
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
359
381
|
*/
|
|
360
|
-
const isBlob = kindOfTest(
|
|
382
|
+
const isBlob = kindOfTest('Blob');
|
|
361
383
|
|
|
362
384
|
/**
|
|
363
385
|
* Determine if a value is a FileList
|
|
@@ -366,7 +388,7 @@ const isBlob = kindOfTest("Blob");
|
|
|
366
388
|
*
|
|
367
389
|
* @returns {boolean} True if value is a File, otherwise false
|
|
368
390
|
*/
|
|
369
|
-
const isFileList = kindOfTest(
|
|
391
|
+
const isFileList = kindOfTest('FileList');
|
|
370
392
|
|
|
371
393
|
/**
|
|
372
394
|
* Determine if a value is a Stream
|
|
@@ -384,17 +406,27 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
|
384
406
|
*
|
|
385
407
|
* @returns {boolean} True if value is an FormData, otherwise false
|
|
386
408
|
*/
|
|
409
|
+
function getGlobal() {
|
|
410
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
411
|
+
if (typeof self !== 'undefined') return self;
|
|
412
|
+
if (typeof window !== 'undefined') return window;
|
|
413
|
+
if (typeof global !== 'undefined') return global;
|
|
414
|
+
return {};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const G = getGlobal();
|
|
418
|
+
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
419
|
+
|
|
387
420
|
const isFormData = (thing) => {
|
|
388
421
|
let kind;
|
|
389
|
-
return (
|
|
390
|
-
thing
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
thing.toString() === "[object FormData]"))))
|
|
422
|
+
return thing && (
|
|
423
|
+
(FormDataCtor && thing instanceof FormDataCtor) || (
|
|
424
|
+
isFunction$1(thing.append) && (
|
|
425
|
+
(kind = kindOf(thing)) === 'formdata' ||
|
|
426
|
+
// detect form-data instance
|
|
427
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
428
|
+
)
|
|
429
|
+
)
|
|
398
430
|
);
|
|
399
431
|
};
|
|
400
432
|
|
|
@@ -405,13 +437,13 @@ const isFormData = (thing) => {
|
|
|
405
437
|
*
|
|
406
438
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
407
439
|
*/
|
|
408
|
-
const isURLSearchParams = kindOfTest(
|
|
440
|
+
const isURLSearchParams = kindOfTest('URLSearchParams');
|
|
409
441
|
|
|
410
442
|
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
443
|
+
'ReadableStream',
|
|
444
|
+
'Request',
|
|
445
|
+
'Response',
|
|
446
|
+
'Headers',
|
|
415
447
|
].map(kindOfTest);
|
|
416
448
|
|
|
417
449
|
/**
|
|
@@ -421,9 +453,9 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
|
421
453
|
*
|
|
422
454
|
* @returns {String} The String freed of excess whitespace
|
|
423
455
|
*/
|
|
424
|
-
const trim = (str) =>
|
|
425
|
-
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
426
|
-
|
|
456
|
+
const trim = (str) => {
|
|
457
|
+
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
458
|
+
};
|
|
427
459
|
/**
|
|
428
460
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
429
461
|
*
|
|
@@ -442,7 +474,7 @@ const trim = (str) =>
|
|
|
442
474
|
*/
|
|
443
475
|
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
444
476
|
// Don't bother if no value provided
|
|
445
|
-
if (obj === null || typeof obj ===
|
|
477
|
+
if (obj === null || typeof obj === 'undefined') {
|
|
446
478
|
return;
|
|
447
479
|
}
|
|
448
480
|
|
|
@@ -450,7 +482,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
450
482
|
let l;
|
|
451
483
|
|
|
452
484
|
// Force an array if not already something iterable
|
|
453
|
-
if (typeof obj !==
|
|
485
|
+
if (typeof obj !== 'object') {
|
|
454
486
|
/*eslint no-param-reassign:0*/
|
|
455
487
|
obj = [obj];
|
|
456
488
|
}
|
|
@@ -467,9 +499,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
467
499
|
}
|
|
468
500
|
|
|
469
501
|
// Iterate over object keys
|
|
470
|
-
const keys = allOwnKeys
|
|
471
|
-
? Object.getOwnPropertyNames(obj)
|
|
472
|
-
: Object.keys(obj);
|
|
502
|
+
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
473
503
|
const len = keys.length;
|
|
474
504
|
let key;
|
|
475
505
|
|
|
@@ -480,6 +510,14 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
480
510
|
}
|
|
481
511
|
}
|
|
482
512
|
|
|
513
|
+
/**
|
|
514
|
+
* Finds a key in an object, case-insensitive, returning the actual key name.
|
|
515
|
+
* Returns null if the object is a Buffer or if no match is found.
|
|
516
|
+
*
|
|
517
|
+
* @param {Object} obj - The object to search.
|
|
518
|
+
* @param {string} key - The key to find (case-insensitive).
|
|
519
|
+
* @returns {?string} The actual key name if found, otherwise null.
|
|
520
|
+
*/
|
|
483
521
|
function findKey(obj, key) {
|
|
484
522
|
if (isBuffer(obj)) {
|
|
485
523
|
return null;
|
|
@@ -500,16 +538,11 @@ function findKey(obj, key) {
|
|
|
500
538
|
|
|
501
539
|
const _global = (() => {
|
|
502
540
|
/*eslint no-undef:0*/
|
|
503
|
-
if (typeof globalThis !==
|
|
504
|
-
return typeof self !==
|
|
505
|
-
? self
|
|
506
|
-
: typeof window !== "undefined"
|
|
507
|
-
? window
|
|
508
|
-
: global;
|
|
541
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
542
|
+
return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
|
|
509
543
|
})();
|
|
510
544
|
|
|
511
|
-
const isContextDefined = (context) =>
|
|
512
|
-
!isUndefined(context) && context !== _global;
|
|
545
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
513
546
|
|
|
514
547
|
/**
|
|
515
548
|
* Accepts varargs expecting each argument to be an object, then
|
|
@@ -534,7 +567,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
534
567
|
const result = {};
|
|
535
568
|
const assignValue = (val, key) => {
|
|
536
569
|
// Skip dangerous property names to prevent prototype pollution
|
|
537
|
-
if (key ===
|
|
570
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
538
571
|
return;
|
|
539
572
|
}
|
|
540
573
|
|
|
@@ -587,7 +620,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
587
620
|
});
|
|
588
621
|
}
|
|
589
622
|
},
|
|
590
|
-
{ allOwnKeys }
|
|
623
|
+
{ allOwnKeys }
|
|
591
624
|
);
|
|
592
625
|
return a;
|
|
593
626
|
};
|
|
@@ -616,17 +649,14 @@ const stripBOM = (content) => {
|
|
|
616
649
|
* @returns {void}
|
|
617
650
|
*/
|
|
618
651
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
619
|
-
constructor.prototype = Object.create(
|
|
620
|
-
|
|
621
|
-
descriptors,
|
|
622
|
-
);
|
|
623
|
-
Object.defineProperty(constructor.prototype, "constructor", {
|
|
652
|
+
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
653
|
+
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
624
654
|
value: constructor,
|
|
625
655
|
writable: true,
|
|
626
656
|
enumerable: false,
|
|
627
657
|
configurable: true,
|
|
628
658
|
});
|
|
629
|
-
Object.defineProperty(constructor,
|
|
659
|
+
Object.defineProperty(constructor, 'super', {
|
|
630
660
|
value: superConstructor.prototype,
|
|
631
661
|
});
|
|
632
662
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -656,20 +686,13 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
|
|
656
686
|
i = props.length;
|
|
657
687
|
while (i-- > 0) {
|
|
658
688
|
prop = props[i];
|
|
659
|
-
if (
|
|
660
|
-
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
661
|
-
!merged[prop]
|
|
662
|
-
) {
|
|
689
|
+
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
663
690
|
destObj[prop] = sourceObj[prop];
|
|
664
691
|
merged[prop] = true;
|
|
665
692
|
}
|
|
666
693
|
}
|
|
667
694
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
668
|
-
} while (
|
|
669
|
-
sourceObj &&
|
|
670
|
-
(!filter || filter(sourceObj, destObj)) &&
|
|
671
|
-
sourceObj !== Object.prototype
|
|
672
|
-
);
|
|
695
|
+
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
673
696
|
|
|
674
697
|
return destObj;
|
|
675
698
|
};
|
|
@@ -726,7 +749,7 @@ const isTypedArray = ((TypedArray) => {
|
|
|
726
749
|
return (thing) => {
|
|
727
750
|
return TypedArray && thing instanceof TypedArray;
|
|
728
751
|
};
|
|
729
|
-
})(typeof Uint8Array !==
|
|
752
|
+
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
|
730
753
|
|
|
731
754
|
/**
|
|
732
755
|
* For each entry in the object, call the function with the key and value.
|
|
@@ -769,14 +792,12 @@ const matchAll = (regExp, str) => {
|
|
|
769
792
|
};
|
|
770
793
|
|
|
771
794
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
772
|
-
const isHTMLForm = kindOfTest(
|
|
795
|
+
const isHTMLForm = kindOfTest('HTMLFormElement');
|
|
773
796
|
|
|
774
797
|
const toCamelCase = (str) => {
|
|
775
|
-
return str
|
|
776
|
-
.
|
|
777
|
-
|
|
778
|
-
return p1.toUpperCase() + p2;
|
|
779
|
-
});
|
|
798
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|
799
|
+
return p1.toUpperCase() + p2;
|
|
800
|
+
});
|
|
780
801
|
};
|
|
781
802
|
|
|
782
803
|
/* Creating a function that will check if an object has a property. */
|
|
@@ -793,7 +814,7 @@ const hasOwnProperty = (
|
|
|
793
814
|
*
|
|
794
815
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
795
816
|
*/
|
|
796
|
-
const isRegExp = kindOfTest(
|
|
817
|
+
const isRegExp = kindOfTest('RegExp');
|
|
797
818
|
|
|
798
819
|
const reduceDescriptors = (obj, reducer) => {
|
|
799
820
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -817,10 +838,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
817
838
|
const freezeMethods = (obj) => {
|
|
818
839
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
819
840
|
// skip restricted props in strict mode
|
|
820
|
-
if (
|
|
821
|
-
isFunction$1(obj) &&
|
|
822
|
-
["arguments", "caller", "callee"].indexOf(name) !== -1
|
|
823
|
-
) {
|
|
841
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
824
842
|
return false;
|
|
825
843
|
}
|
|
826
844
|
|
|
@@ -830,7 +848,7 @@ const freezeMethods = (obj) => {
|
|
|
830
848
|
|
|
831
849
|
descriptor.enumerable = false;
|
|
832
850
|
|
|
833
|
-
if (
|
|
851
|
+
if ('writable' in descriptor) {
|
|
834
852
|
descriptor.writable = false;
|
|
835
853
|
return;
|
|
836
854
|
}
|
|
@@ -843,6 +861,14 @@ const freezeMethods = (obj) => {
|
|
|
843
861
|
});
|
|
844
862
|
};
|
|
845
863
|
|
|
864
|
+
/**
|
|
865
|
+
* Converts an array or a delimited string into an object set with values as keys and true as values.
|
|
866
|
+
* Useful for fast membership checks.
|
|
867
|
+
*
|
|
868
|
+
* @param {Array|string} arrayOrString - The array or string to convert.
|
|
869
|
+
* @param {string} delimiter - The delimiter to use if input is a string.
|
|
870
|
+
* @returns {Object} An object with keys from the array or string, values set to true.
|
|
871
|
+
*/
|
|
846
872
|
const toObjectSet = (arrayOrString, delimiter) => {
|
|
847
873
|
const obj = {};
|
|
848
874
|
|
|
@@ -852,9 +878,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
852
878
|
});
|
|
853
879
|
};
|
|
854
880
|
|
|
855
|
-
isArray(arrayOrString)
|
|
856
|
-
? define(arrayOrString)
|
|
857
|
-
: define(String(arrayOrString).split(delimiter));
|
|
881
|
+
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|
858
882
|
|
|
859
883
|
return obj;
|
|
860
884
|
};
|
|
@@ -862,9 +886,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
862
886
|
const noop = () => {};
|
|
863
887
|
|
|
864
888
|
const toFiniteNumber = (value, defaultValue) => {
|
|
865
|
-
return value != null && Number.isFinite((value = +value))
|
|
866
|
-
? value
|
|
867
|
-
: defaultValue;
|
|
889
|
+
return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
|
|
868
890
|
};
|
|
869
891
|
|
|
870
892
|
/**
|
|
@@ -878,11 +900,17 @@ function isSpecCompliantForm(thing) {
|
|
|
878
900
|
return !!(
|
|
879
901
|
thing &&
|
|
880
902
|
isFunction$1(thing.append) &&
|
|
881
|
-
thing[toStringTag] ===
|
|
903
|
+
thing[toStringTag] === 'FormData' &&
|
|
882
904
|
thing[iterator]
|
|
883
905
|
);
|
|
884
906
|
}
|
|
885
907
|
|
|
908
|
+
/**
|
|
909
|
+
* Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
|
|
910
|
+
*
|
|
911
|
+
* @param {Object} obj - The object to convert.
|
|
912
|
+
* @returns {Object} The JSON-compatible object.
|
|
913
|
+
*/
|
|
886
914
|
const toJSONObject = (obj) => {
|
|
887
915
|
const stack = new Array(10);
|
|
888
916
|
|
|
@@ -897,7 +925,7 @@ const toJSONObject = (obj) => {
|
|
|
897
925
|
return source;
|
|
898
926
|
}
|
|
899
927
|
|
|
900
|
-
if (!(
|
|
928
|
+
if (!('toJSON' in source)) {
|
|
901
929
|
stack[i] = source;
|
|
902
930
|
const target = isArray(source) ? [] : {};
|
|
903
931
|
|
|
@@ -918,8 +946,20 @@ const toJSONObject = (obj) => {
|
|
|
918
946
|
return visit(obj, 0);
|
|
919
947
|
};
|
|
920
948
|
|
|
921
|
-
|
|
949
|
+
/**
|
|
950
|
+
* Determines if a value is an async function.
|
|
951
|
+
*
|
|
952
|
+
* @param {*} thing - The value to test.
|
|
953
|
+
* @returns {boolean} True if value is an async function, otherwise false.
|
|
954
|
+
*/
|
|
955
|
+
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
922
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Determines if a value is thenable (has then and catch methods).
|
|
959
|
+
*
|
|
960
|
+
* @param {*} thing - The value to test.
|
|
961
|
+
* @returns {boolean} True if value is thenable, otherwise false.
|
|
962
|
+
*/
|
|
923
963
|
const isThenable = (thing) =>
|
|
924
964
|
thing &&
|
|
925
965
|
(isObject(thing) || isFunction$1(thing)) &&
|
|
@@ -929,6 +969,14 @@ const isThenable = (thing) =>
|
|
|
929
969
|
// original code
|
|
930
970
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
931
971
|
|
|
972
|
+
/**
|
|
973
|
+
* Provides a cross-platform setImmediate implementation.
|
|
974
|
+
* Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
|
|
975
|
+
*
|
|
976
|
+
* @param {boolean} setImmediateSupported - Whether setImmediate is supported.
|
|
977
|
+
* @param {boolean} postMessageSupported - Whether postMessage is supported.
|
|
978
|
+
* @returns {Function} A function to schedule a callback asynchronously.
|
|
979
|
+
*/
|
|
932
980
|
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
933
981
|
if (setImmediateSupported) {
|
|
934
982
|
return setImmediate;
|
|
@@ -937,27 +985,33 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
937
985
|
return postMessageSupported
|
|
938
986
|
? ((token, callbacks) => {
|
|
939
987
|
_global.addEventListener(
|
|
940
|
-
|
|
988
|
+
'message',
|
|
941
989
|
({ source, data }) => {
|
|
942
990
|
if (source === _global && data === token) {
|
|
943
991
|
callbacks.length && callbacks.shift()();
|
|
944
992
|
}
|
|
945
993
|
},
|
|
946
|
-
false
|
|
994
|
+
false
|
|
947
995
|
);
|
|
948
996
|
|
|
949
997
|
return (cb) => {
|
|
950
998
|
callbacks.push(cb);
|
|
951
|
-
_global.postMessage(token,
|
|
999
|
+
_global.postMessage(token, '*');
|
|
952
1000
|
};
|
|
953
1001
|
})(`axios@${Math.random()}`, [])
|
|
954
1002
|
: (cb) => setTimeout(cb);
|
|
955
|
-
})(typeof setImmediate ===
|
|
1003
|
+
})(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
|
|
956
1004
|
|
|
1005
|
+
/**
|
|
1006
|
+
* Schedules a microtask or asynchronous callback as soon as possible.
|
|
1007
|
+
* Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
|
|
1008
|
+
*
|
|
1009
|
+
* @type {Function}
|
|
1010
|
+
*/
|
|
957
1011
|
const asap =
|
|
958
|
-
typeof queueMicrotask !==
|
|
1012
|
+
typeof queueMicrotask !== 'undefined'
|
|
959
1013
|
? queueMicrotask.bind(_global)
|
|
960
|
-
: (typeof process !==
|
|
1014
|
+
: (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
|
|
961
1015
|
|
|
962
1016
|
// *********************
|
|
963
1017
|
|
|
@@ -982,6 +1036,8 @@ var utils$1 = {
|
|
|
982
1036
|
isUndefined,
|
|
983
1037
|
isDate,
|
|
984
1038
|
isFile,
|
|
1039
|
+
isReactNativeBlob,
|
|
1040
|
+
isReactNative,
|
|
985
1041
|
isBlob,
|
|
986
1042
|
isRegExp,
|
|
987
1043
|
isFunction: isFunction$1,
|
|
@@ -1024,14 +1080,20 @@ var utils$1 = {
|
|
|
1024
1080
|
};
|
|
1025
1081
|
|
|
1026
1082
|
let AxiosError$1 = class AxiosError extends Error {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1083
|
+
static from(error, code, config, request, response, customProps) {
|
|
1084
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1085
|
+
axiosError.cause = error;
|
|
1086
|
+
axiosError.name = error.name;
|
|
1087
|
+
|
|
1088
|
+
// Preserve status from the original error if not already set from response
|
|
1089
|
+
if (error.status != null && axiosError.status == null) {
|
|
1090
|
+
axiosError.status = error.status;
|
|
1033
1091
|
}
|
|
1034
1092
|
|
|
1093
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1094
|
+
return axiosError;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1035
1097
|
/**
|
|
1036
1098
|
* Create an Error with the specified message, config, error code, request and response.
|
|
1037
1099
|
*
|
|
@@ -1044,37 +1106,48 @@ let AxiosError$1 = class AxiosError extends Error {
|
|
|
1044
1106
|
* @returns {Error} The created error.
|
|
1045
1107
|
*/
|
|
1046
1108
|
constructor(message, code, config, request, response) {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1109
|
+
super(message);
|
|
1110
|
+
|
|
1111
|
+
// Make message enumerable to maintain backward compatibility
|
|
1112
|
+
// The native Error constructor sets message as non-enumerable,
|
|
1113
|
+
// but axios < v1.13.3 had it as enumerable
|
|
1114
|
+
Object.defineProperty(this, 'message', {
|
|
1115
|
+
value: message,
|
|
1116
|
+
enumerable: true,
|
|
1117
|
+
writable: true,
|
|
1118
|
+
configurable: true
|
|
1119
|
+
});
|
|
1120
|
+
|
|
1121
|
+
this.name = 'AxiosError';
|
|
1122
|
+
this.isAxiosError = true;
|
|
1123
|
+
code && (this.code = code);
|
|
1124
|
+
config && (this.config = config);
|
|
1125
|
+
request && (this.request = request);
|
|
1126
|
+
if (response) {
|
|
1127
|
+
this.response = response;
|
|
1128
|
+
this.status = response.status;
|
|
1129
|
+
}
|
|
1057
1130
|
}
|
|
1058
1131
|
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1132
|
+
toJSON() {
|
|
1133
|
+
return {
|
|
1134
|
+
// Standard
|
|
1135
|
+
message: this.message,
|
|
1136
|
+
name: this.name,
|
|
1137
|
+
// Microsoft
|
|
1138
|
+
description: this.description,
|
|
1139
|
+
number: this.number,
|
|
1140
|
+
// Mozilla
|
|
1141
|
+
fileName: this.fileName,
|
|
1142
|
+
lineNumber: this.lineNumber,
|
|
1143
|
+
columnNumber: this.columnNumber,
|
|
1144
|
+
stack: this.stack,
|
|
1145
|
+
// Axios
|
|
1146
|
+
config: utils$1.toJSONObject(this.config),
|
|
1147
|
+
code: this.code,
|
|
1148
|
+
status: this.status,
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1078
1151
|
};
|
|
1079
1152
|
|
|
1080
1153
|
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
@@ -1127,11 +1200,14 @@ function removeBrackets(key) {
|
|
|
1127
1200
|
*/
|
|
1128
1201
|
function renderKey(path, key, dots) {
|
|
1129
1202
|
if (!path) return key;
|
|
1130
|
-
return path
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1203
|
+
return path
|
|
1204
|
+
.concat(key)
|
|
1205
|
+
.map(function each(token, i) {
|
|
1206
|
+
// eslint-disable-next-line no-param-reassign
|
|
1207
|
+
token = removeBrackets(token);
|
|
1208
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
1209
|
+
})
|
|
1210
|
+
.join(dots ? '.' : '');
|
|
1135
1211
|
}
|
|
1136
1212
|
|
|
1137
1213
|
/**
|
|
@@ -1181,21 +1257,26 @@ function toFormData$1(obj, formData, options) {
|
|
|
1181
1257
|
formData = formData || new (FormData)();
|
|
1182
1258
|
|
|
1183
1259
|
// eslint-disable-next-line no-param-reassign
|
|
1184
|
-
options = utils$1.toFlatObject(
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1260
|
+
options = utils$1.toFlatObject(
|
|
1261
|
+
options,
|
|
1262
|
+
{
|
|
1263
|
+
metaTokens: true,
|
|
1264
|
+
dots: false,
|
|
1265
|
+
indexes: false,
|
|
1266
|
+
},
|
|
1267
|
+
false,
|
|
1268
|
+
function defined(option, source) {
|
|
1269
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1270
|
+
return !utils$1.isUndefined(source[option]);
|
|
1271
|
+
}
|
|
1272
|
+
);
|
|
1192
1273
|
|
|
1193
1274
|
const metaTokens = options.metaTokens;
|
|
1194
1275
|
// eslint-disable-next-line no-use-before-define
|
|
1195
1276
|
const visitor = options.visitor || defaultVisitor;
|
|
1196
1277
|
const dots = options.dots;
|
|
1197
1278
|
const indexes = options.indexes;
|
|
1198
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1279
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1199
1280
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1200
1281
|
|
|
1201
1282
|
if (!utils$1.isFunction(visitor)) {
|
|
@@ -1237,6 +1318,11 @@ function toFormData$1(obj, formData, options) {
|
|
|
1237
1318
|
function defaultVisitor(value, key, path) {
|
|
1238
1319
|
let arr = value;
|
|
1239
1320
|
|
|
1321
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
1322
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1323
|
+
return false;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1240
1326
|
if (value && !path && typeof value === 'object') {
|
|
1241
1327
|
if (utils$1.endsWith(key, '{}')) {
|
|
1242
1328
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -1245,17 +1331,22 @@ function toFormData$1(obj, formData, options) {
|
|
|
1245
1331
|
value = JSON.stringify(value);
|
|
1246
1332
|
} else if (
|
|
1247
1333
|
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1248
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
1249
|
-
|
|
1334
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1335
|
+
) {
|
|
1250
1336
|
// eslint-disable-next-line no-param-reassign
|
|
1251
1337
|
key = removeBrackets(key);
|
|
1252
1338
|
|
|
1253
1339
|
arr.forEach(function each(el, index) {
|
|
1254
|
-
!(utils$1.isUndefined(el) || el === null) &&
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1340
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1341
|
+
formData.append(
|
|
1342
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1343
|
+
indexes === true
|
|
1344
|
+
? renderKey([key], index, dots)
|
|
1345
|
+
: indexes === null
|
|
1346
|
+
? key
|
|
1347
|
+
: key + '[]',
|
|
1348
|
+
convertValue(el)
|
|
1349
|
+
);
|
|
1259
1350
|
});
|
|
1260
1351
|
return false;
|
|
1261
1352
|
}
|
|
@@ -1275,7 +1366,7 @@ function toFormData$1(obj, formData, options) {
|
|
|
1275
1366
|
const exposedHelpers = Object.assign(predicates, {
|
|
1276
1367
|
defaultVisitor,
|
|
1277
1368
|
convertValue,
|
|
1278
|
-
isVisitable
|
|
1369
|
+
isVisitable,
|
|
1279
1370
|
});
|
|
1280
1371
|
|
|
1281
1372
|
function build(value, path) {
|
|
@@ -1288,9 +1379,9 @@ function toFormData$1(obj, formData, options) {
|
|
|
1288
1379
|
stack.push(value);
|
|
1289
1380
|
|
|
1290
1381
|
utils$1.forEach(value, function each(el, key) {
|
|
1291
|
-
const result =
|
|
1292
|
-
|
|
1293
|
-
|
|
1382
|
+
const result =
|
|
1383
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1384
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
1294
1385
|
|
|
1295
1386
|
if (result === true) {
|
|
1296
1387
|
build(el, path ? path.concat(key) : [key]);
|
|
@@ -1325,7 +1416,7 @@ function encode$1(str) {
|
|
|
1325
1416
|
')': '%29',
|
|
1326
1417
|
'~': '%7E',
|
|
1327
1418
|
'%20': '+',
|
|
1328
|
-
'%00': '\x00'
|
|
1419
|
+
'%00': '\x00',
|
|
1329
1420
|
};
|
|
1330
1421
|
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
1331
1422
|
return charMap[match];
|
|
@@ -1353,29 +1444,33 @@ prototype.append = function append(name, value) {
|
|
|
1353
1444
|
};
|
|
1354
1445
|
|
|
1355
1446
|
prototype.toString = function toString(encoder) {
|
|
1356
|
-
const _encode = encoder
|
|
1357
|
-
|
|
1358
|
-
|
|
1447
|
+
const _encode = encoder
|
|
1448
|
+
? function (value) {
|
|
1449
|
+
return encoder.call(this, value, encode$1);
|
|
1450
|
+
}
|
|
1451
|
+
: encode$1;
|
|
1359
1452
|
|
|
1360
|
-
return this._pairs
|
|
1361
|
-
|
|
1362
|
-
|
|
1453
|
+
return this._pairs
|
|
1454
|
+
.map(function each(pair) {
|
|
1455
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1456
|
+
}, '')
|
|
1457
|
+
.join('&');
|
|
1363
1458
|
};
|
|
1364
1459
|
|
|
1365
1460
|
/**
|
|
1366
|
-
* It replaces
|
|
1367
|
-
*
|
|
1461
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
1462
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1368
1463
|
*
|
|
1369
1464
|
* @param {string} val The value to be encoded.
|
|
1370
1465
|
*
|
|
1371
1466
|
* @returns {string} The encoded value.
|
|
1372
1467
|
*/
|
|
1373
1468
|
function encode(val) {
|
|
1374
|
-
return encodeURIComponent(val)
|
|
1375
|
-
replace(/%3A/gi, ':')
|
|
1376
|
-
replace(/%24/g, '$')
|
|
1377
|
-
replace(/%2C/gi, ',')
|
|
1378
|
-
replace(/%20/g, '+');
|
|
1469
|
+
return encodeURIComponent(val)
|
|
1470
|
+
.replace(/%3A/gi, ':')
|
|
1471
|
+
.replace(/%24/g, '$')
|
|
1472
|
+
.replace(/%2C/gi, ',')
|
|
1473
|
+
.replace(/%20/g, '+');
|
|
1379
1474
|
}
|
|
1380
1475
|
|
|
1381
1476
|
/**
|
|
@@ -1392,11 +1487,13 @@ function buildURL(url, params, options) {
|
|
|
1392
1487
|
return url;
|
|
1393
1488
|
}
|
|
1394
1489
|
|
|
1395
|
-
const _encode = options && options.encode || encode;
|
|
1490
|
+
const _encode = (options && options.encode) || encode;
|
|
1396
1491
|
|
|
1397
|
-
const _options = utils$1.isFunction(options)
|
|
1398
|
-
|
|
1399
|
-
|
|
1492
|
+
const _options = utils$1.isFunction(options)
|
|
1493
|
+
? {
|
|
1494
|
+
serialize: options,
|
|
1495
|
+
}
|
|
1496
|
+
: options;
|
|
1400
1497
|
|
|
1401
1498
|
const serializeFn = _options && _options.serialize;
|
|
1402
1499
|
|
|
@@ -1405,13 +1502,13 @@ function buildURL(url, params, options) {
|
|
|
1405
1502
|
if (serializeFn) {
|
|
1406
1503
|
serializedParams = serializeFn(params, _options);
|
|
1407
1504
|
} else {
|
|
1408
|
-
serializedParams = utils$1.isURLSearchParams(params)
|
|
1409
|
-
params.toString()
|
|
1410
|
-
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1505
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
1506
|
+
? params.toString()
|
|
1507
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1411
1508
|
}
|
|
1412
1509
|
|
|
1413
1510
|
if (serializedParams) {
|
|
1414
|
-
const hashmarkIndex = url.indexOf(
|
|
1511
|
+
const hashmarkIndex = url.indexOf('#');
|
|
1415
1512
|
|
|
1416
1513
|
if (hashmarkIndex !== -1) {
|
|
1417
1514
|
url = url.slice(0, hashmarkIndex);
|
|
@@ -1441,7 +1538,7 @@ class InterceptorManager {
|
|
|
1441
1538
|
fulfilled,
|
|
1442
1539
|
rejected,
|
|
1443
1540
|
synchronous: options ? options.synchronous : false,
|
|
1444
|
-
runWhen: options ? options.runWhen : null
|
|
1541
|
+
runWhen: options ? options.runWhen : null,
|
|
1445
1542
|
});
|
|
1446
1543
|
return this.handlers.length - 1;
|
|
1447
1544
|
}
|
|
@@ -1493,7 +1590,7 @@ var transitionalDefaults = {
|
|
|
1493
1590
|
silentJSONParsing: true,
|
|
1494
1591
|
forcedJSONParsing: true,
|
|
1495
1592
|
clarifyTimeoutError: false,
|
|
1496
|
-
legacyInterceptorReqResOrdering: true
|
|
1593
|
+
legacyInterceptorReqResOrdering: true,
|
|
1497
1594
|
};
|
|
1498
1595
|
|
|
1499
1596
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -1507,14 +1604,14 @@ var platform$1 = {
|
|
|
1507
1604
|
classes: {
|
|
1508
1605
|
URLSearchParams: URLSearchParams$1,
|
|
1509
1606
|
FormData: FormData$1,
|
|
1510
|
-
Blob: Blob$1
|
|
1607
|
+
Blob: Blob$1,
|
|
1511
1608
|
},
|
|
1512
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1609
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
1513
1610
|
};
|
|
1514
1611
|
|
|
1515
1612
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1516
1613
|
|
|
1517
|
-
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
1614
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
1518
1615
|
|
|
1519
1616
|
/**
|
|
1520
1617
|
* Determine if we're running in a standard browser environment
|
|
@@ -1533,7 +1630,8 @@ const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
|
1533
1630
|
*
|
|
1534
1631
|
* @returns {boolean}
|
|
1535
1632
|
*/
|
|
1536
|
-
const hasStandardBrowserEnv =
|
|
1633
|
+
const hasStandardBrowserEnv =
|
|
1634
|
+
hasBrowserEnv &&
|
|
1537
1635
|
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1538
1636
|
|
|
1539
1637
|
/**
|
|
@@ -1554,7 +1652,7 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
1554
1652
|
);
|
|
1555
1653
|
})();
|
|
1556
1654
|
|
|
1557
|
-
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1655
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
1558
1656
|
|
|
1559
1657
|
var utils = /*#__PURE__*/Object.freeze({
|
|
1560
1658
|
__proto__: null,
|
|
@@ -1567,12 +1665,12 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
1567
1665
|
|
|
1568
1666
|
var platform = {
|
|
1569
1667
|
...utils,
|
|
1570
|
-
...platform$1
|
|
1668
|
+
...platform$1,
|
|
1571
1669
|
};
|
|
1572
1670
|
|
|
1573
1671
|
function toURLEncodedForm(data, options) {
|
|
1574
1672
|
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
1575
|
-
visitor: function(value, key, path, helpers) {
|
|
1673
|
+
visitor: function (value, key, path, helpers) {
|
|
1576
1674
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1577
1675
|
this.append(key, value.toString('base64'));
|
|
1578
1676
|
return false;
|
|
@@ -1580,7 +1678,7 @@ function toURLEncodedForm(data, options) {
|
|
|
1580
1678
|
|
|
1581
1679
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
1582
1680
|
},
|
|
1583
|
-
...options
|
|
1681
|
+
...options,
|
|
1584
1682
|
});
|
|
1585
1683
|
}
|
|
1586
1684
|
|
|
@@ -1596,7 +1694,7 @@ function parsePropPath(name) {
|
|
|
1596
1694
|
// foo.x.y.z
|
|
1597
1695
|
// foo-x-y-z
|
|
1598
1696
|
// foo x y z
|
|
1599
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1697
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
1600
1698
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1601
1699
|
});
|
|
1602
1700
|
}
|
|
@@ -1700,96 +1798,107 @@ function stringifySafely(rawValue, parser, encoder) {
|
|
|
1700
1798
|
}
|
|
1701
1799
|
|
|
1702
1800
|
const defaults = {
|
|
1703
|
-
|
|
1704
1801
|
transitional: transitionalDefaults,
|
|
1705
1802
|
|
|
1706
1803
|
adapter: ['xhr', 'http', 'fetch'],
|
|
1707
1804
|
|
|
1708
|
-
transformRequest: [
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1805
|
+
transformRequest: [
|
|
1806
|
+
function transformRequest(data, headers) {
|
|
1807
|
+
const contentType = headers.getContentType() || '';
|
|
1808
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1809
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
1712
1810
|
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1811
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1812
|
+
data = new FormData(data);
|
|
1813
|
+
}
|
|
1716
1814
|
|
|
1717
|
-
|
|
1815
|
+
const isFormData = utils$1.isFormData(data);
|
|
1718
1816
|
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1817
|
+
if (isFormData) {
|
|
1818
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1819
|
+
}
|
|
1722
1820
|
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1821
|
+
if (
|
|
1822
|
+
utils$1.isArrayBuffer(data) ||
|
|
1823
|
+
utils$1.isBuffer(data) ||
|
|
1824
|
+
utils$1.isStream(data) ||
|
|
1825
|
+
utils$1.isFile(data) ||
|
|
1826
|
+
utils$1.isBlob(data) ||
|
|
1827
|
+
utils$1.isReadableStream(data)
|
|
1828
|
+
) {
|
|
1829
|
+
return data;
|
|
1830
|
+
}
|
|
1831
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
1832
|
+
return data.buffer;
|
|
1833
|
+
}
|
|
1834
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
1835
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1836
|
+
return data.toString();
|
|
1837
|
+
}
|
|
1739
1838
|
|
|
1740
|
-
|
|
1839
|
+
let isFileList;
|
|
1741
1840
|
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1841
|
+
if (isObjectPayload) {
|
|
1842
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
1843
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
1844
|
+
}
|
|
1746
1845
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1846
|
+
if (
|
|
1847
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
1848
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
1849
|
+
) {
|
|
1850
|
+
const _FormData = this.env && this.env.FormData;
|
|
1749
1851
|
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1852
|
+
return toFormData$1(
|
|
1853
|
+
isFileList ? { 'files[]': data } : data,
|
|
1854
|
+
_FormData && new _FormData(),
|
|
1855
|
+
this.formSerializer
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1755
1858
|
}
|
|
1756
|
-
}
|
|
1757
1859
|
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1860
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
1861
|
+
headers.setContentType('application/json', false);
|
|
1862
|
+
return stringifySafely(data);
|
|
1863
|
+
}
|
|
1762
1864
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1865
|
+
return data;
|
|
1866
|
+
},
|
|
1867
|
+
],
|
|
1765
1868
|
|
|
1766
|
-
transformResponse: [
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1869
|
+
transformResponse: [
|
|
1870
|
+
function transformResponse(data) {
|
|
1871
|
+
const transitional = this.transitional || defaults.transitional;
|
|
1872
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1873
|
+
const JSONRequested = this.responseType === 'json';
|
|
1770
1874
|
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1875
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
1876
|
+
return data;
|
|
1877
|
+
}
|
|
1774
1878
|
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1879
|
+
if (
|
|
1880
|
+
data &&
|
|
1881
|
+
utils$1.isString(data) &&
|
|
1882
|
+
((forcedJSONParsing && !this.responseType) || JSONRequested)
|
|
1883
|
+
) {
|
|
1884
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1885
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1778
1886
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1887
|
+
try {
|
|
1888
|
+
return JSON.parse(data, this.parseReviver);
|
|
1889
|
+
} catch (e) {
|
|
1890
|
+
if (strictJSONParsing) {
|
|
1891
|
+
if (e.name === 'SyntaxError') {
|
|
1892
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
1893
|
+
}
|
|
1894
|
+
throw e;
|
|
1785
1895
|
}
|
|
1786
|
-
throw e;
|
|
1787
1896
|
}
|
|
1788
1897
|
}
|
|
1789
|
-
}
|
|
1790
1898
|
|
|
1791
|
-
|
|
1792
|
-
|
|
1899
|
+
return data;
|
|
1900
|
+
},
|
|
1901
|
+
],
|
|
1793
1902
|
|
|
1794
1903
|
/**
|
|
1795
1904
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
@@ -1805,7 +1914,7 @@ const defaults = {
|
|
|
1805
1914
|
|
|
1806
1915
|
env: {
|
|
1807
1916
|
FormData: platform.classes.FormData,
|
|
1808
|
-
Blob: platform.classes.Blob
|
|
1917
|
+
Blob: platform.classes.Blob,
|
|
1809
1918
|
},
|
|
1810
1919
|
|
|
1811
1920
|
validateStatus: function validateStatus(status) {
|
|
@@ -1814,10 +1923,10 @@ const defaults = {
|
|
|
1814
1923
|
|
|
1815
1924
|
headers: {
|
|
1816
1925
|
common: {
|
|
1817
|
-
|
|
1818
|
-
'Content-Type': undefined
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1926
|
+
Accept: 'application/json, text/plain, */*',
|
|
1927
|
+
'Content-Type': undefined,
|
|
1928
|
+
},
|
|
1929
|
+
},
|
|
1821
1930
|
};
|
|
1822
1931
|
|
|
1823
1932
|
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
@@ -1827,10 +1936,23 @@ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
|
1827
1936
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1828
1937
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1829
1938
|
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1830
|
-
'age',
|
|
1831
|
-
'
|
|
1832
|
-
'
|
|
1833
|
-
'
|
|
1939
|
+
'age',
|
|
1940
|
+
'authorization',
|
|
1941
|
+
'content-length',
|
|
1942
|
+
'content-type',
|
|
1943
|
+
'etag',
|
|
1944
|
+
'expires',
|
|
1945
|
+
'from',
|
|
1946
|
+
'host',
|
|
1947
|
+
'if-modified-since',
|
|
1948
|
+
'if-unmodified-since',
|
|
1949
|
+
'last-modified',
|
|
1950
|
+
'location',
|
|
1951
|
+
'max-forwards',
|
|
1952
|
+
'proxy-authorization',
|
|
1953
|
+
'referer',
|
|
1954
|
+
'retry-after',
|
|
1955
|
+
'user-agent',
|
|
1834
1956
|
]);
|
|
1835
1957
|
|
|
1836
1958
|
/**
|
|
@@ -1847,47 +1969,81 @@ const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
|
1847
1969
|
*
|
|
1848
1970
|
* @returns {Object} Headers parsed into an object
|
|
1849
1971
|
*/
|
|
1850
|
-
var parseHeaders = rawHeaders => {
|
|
1972
|
+
var parseHeaders = (rawHeaders) => {
|
|
1851
1973
|
const parsed = {};
|
|
1852
1974
|
let key;
|
|
1853
1975
|
let val;
|
|
1854
1976
|
let i;
|
|
1855
1977
|
|
|
1856
|
-
rawHeaders &&
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1978
|
+
rawHeaders &&
|
|
1979
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
1980
|
+
i = line.indexOf(':');
|
|
1981
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1982
|
+
val = line.substring(i + 1).trim();
|
|
1860
1983
|
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1984
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1864
1987
|
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1988
|
+
if (key === 'set-cookie') {
|
|
1989
|
+
if (parsed[key]) {
|
|
1990
|
+
parsed[key].push(val);
|
|
1991
|
+
} else {
|
|
1992
|
+
parsed[key] = [val];
|
|
1993
|
+
}
|
|
1868
1994
|
} else {
|
|
1869
|
-
parsed[key] = [val
|
|
1995
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1870
1996
|
}
|
|
1871
|
-
}
|
|
1872
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1873
|
-
}
|
|
1874
|
-
});
|
|
1997
|
+
});
|
|
1875
1998
|
|
|
1876
1999
|
return parsed;
|
|
1877
2000
|
};
|
|
1878
2001
|
|
|
1879
2002
|
const $internals = Symbol('internals');
|
|
1880
2003
|
|
|
2004
|
+
const isValidHeaderValue = (value) => !/[\r\n]/.test(value);
|
|
2005
|
+
|
|
2006
|
+
function assertValidHeaderValue(value, header) {
|
|
2007
|
+
if (value === false || value == null) {
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
if (utils$1.isArray(value)) {
|
|
2012
|
+
value.forEach((v) => assertValidHeaderValue(v, header));
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
if (!isValidHeaderValue(String(value))) {
|
|
2017
|
+
throw new Error(`Invalid character in header content ["${header}"]`);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
|
|
1881
2021
|
function normalizeHeader(header) {
|
|
1882
2022
|
return header && String(header).trim().toLowerCase();
|
|
1883
2023
|
}
|
|
1884
2024
|
|
|
2025
|
+
function stripTrailingCRLF(str) {
|
|
2026
|
+
let end = str.length;
|
|
2027
|
+
|
|
2028
|
+
while (end > 0) {
|
|
2029
|
+
const charCode = str.charCodeAt(end - 1);
|
|
2030
|
+
|
|
2031
|
+
if (charCode !== 10 && charCode !== 13) {
|
|
2032
|
+
break;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
end -= 1;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
return end === str.length ? str : str.slice(0, end);
|
|
2039
|
+
}
|
|
2040
|
+
|
|
1885
2041
|
function normalizeValue(value) {
|
|
1886
2042
|
if (value === false || value == null) {
|
|
1887
2043
|
return value;
|
|
1888
2044
|
}
|
|
1889
2045
|
|
|
1890
|
-
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
2046
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value));
|
|
1891
2047
|
}
|
|
1892
2048
|
|
|
1893
2049
|
function parseTokens(str) {
|
|
@@ -1925,8 +2081,10 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
|
1925
2081
|
}
|
|
1926
2082
|
|
|
1927
2083
|
function formatHeader(header) {
|
|
1928
|
-
return header
|
|
1929
|
-
.
|
|
2084
|
+
return header
|
|
2085
|
+
.trim()
|
|
2086
|
+
.toLowerCase()
|
|
2087
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1930
2088
|
return char.toUpperCase() + str;
|
|
1931
2089
|
});
|
|
1932
2090
|
}
|
|
@@ -1934,12 +2092,12 @@ function formatHeader(header) {
|
|
|
1934
2092
|
function buildAccessors(obj, header) {
|
|
1935
2093
|
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1936
2094
|
|
|
1937
|
-
['get', 'set', 'has'].forEach(methodName => {
|
|
2095
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
1938
2096
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
1939
|
-
value: function(arg1, arg2, arg3) {
|
|
2097
|
+
value: function (arg1, arg2, arg3) {
|
|
1940
2098
|
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1941
2099
|
},
|
|
1942
|
-
configurable: true
|
|
2100
|
+
configurable: true,
|
|
1943
2101
|
});
|
|
1944
2102
|
});
|
|
1945
2103
|
}
|
|
@@ -1961,7 +2119,13 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
1961
2119
|
|
|
1962
2120
|
const key = utils$1.findKey(self, lHeader);
|
|
1963
2121
|
|
|
1964
|
-
if
|
|
2122
|
+
if (
|
|
2123
|
+
!key ||
|
|
2124
|
+
self[key] === undefined ||
|
|
2125
|
+
_rewrite === true ||
|
|
2126
|
+
(_rewrite === undefined && self[key] !== false)
|
|
2127
|
+
) {
|
|
2128
|
+
assertValidHeaderValue(_value, _header);
|
|
1965
2129
|
self[key || _header] = normalizeValue(_value);
|
|
1966
2130
|
}
|
|
1967
2131
|
}
|
|
@@ -1971,17 +2135,22 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
1971
2135
|
|
|
1972
2136
|
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1973
2137
|
setHeaders(header, valueOrRewrite);
|
|
1974
|
-
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2138
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1975
2139
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1976
2140
|
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1977
|
-
let obj = {},
|
|
2141
|
+
let obj = {},
|
|
2142
|
+
dest,
|
|
2143
|
+
key;
|
|
1978
2144
|
for (const entry of header) {
|
|
1979
2145
|
if (!utils$1.isArray(entry)) {
|
|
1980
2146
|
throw TypeError('Object iterator must return a key-value pair');
|
|
1981
2147
|
}
|
|
1982
2148
|
|
|
1983
|
-
obj[key = entry[0]] = (dest = obj[key])
|
|
1984
|
-
|
|
2149
|
+
obj[(key = entry[0])] = (dest = obj[key])
|
|
2150
|
+
? utils$1.isArray(dest)
|
|
2151
|
+
? [...dest, entry[1]]
|
|
2152
|
+
: [dest, entry[1]]
|
|
2153
|
+
: entry[1];
|
|
1985
2154
|
}
|
|
1986
2155
|
|
|
1987
2156
|
setHeaders(obj, valueOrRewrite);
|
|
@@ -2028,7 +2197,11 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2028
2197
|
if (header) {
|
|
2029
2198
|
const key = utils$1.findKey(this, header);
|
|
2030
2199
|
|
|
2031
|
-
return !!(
|
|
2200
|
+
return !!(
|
|
2201
|
+
key &&
|
|
2202
|
+
this[key] !== undefined &&
|
|
2203
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2204
|
+
);
|
|
2032
2205
|
}
|
|
2033
2206
|
|
|
2034
2207
|
return false;
|
|
@@ -2068,7 +2241,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2068
2241
|
|
|
2069
2242
|
while (i--) {
|
|
2070
2243
|
const key = keys[i];
|
|
2071
|
-
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2244
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2072
2245
|
delete this[key];
|
|
2073
2246
|
deleted = true;
|
|
2074
2247
|
}
|
|
@@ -2112,7 +2285,9 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2112
2285
|
const obj = Object.create(null);
|
|
2113
2286
|
|
|
2114
2287
|
utils$1.forEach(this, (value, header) => {
|
|
2115
|
-
value != null &&
|
|
2288
|
+
value != null &&
|
|
2289
|
+
value !== false &&
|
|
2290
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
2116
2291
|
});
|
|
2117
2292
|
|
|
2118
2293
|
return obj;
|
|
@@ -2123,11 +2298,13 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2123
2298
|
}
|
|
2124
2299
|
|
|
2125
2300
|
toString() {
|
|
2126
|
-
return Object.entries(this.toJSON())
|
|
2301
|
+
return Object.entries(this.toJSON())
|
|
2302
|
+
.map(([header, value]) => header + ': ' + value)
|
|
2303
|
+
.join('\n');
|
|
2127
2304
|
}
|
|
2128
2305
|
|
|
2129
2306
|
getSetCookie() {
|
|
2130
|
-
return this.get(
|
|
2307
|
+
return this.get('set-cookie') || [];
|
|
2131
2308
|
}
|
|
2132
2309
|
|
|
2133
2310
|
get [Symbol.toStringTag]() {
|
|
@@ -2147,9 +2324,12 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2147
2324
|
}
|
|
2148
2325
|
|
|
2149
2326
|
static accessor(header) {
|
|
2150
|
-
const internals =
|
|
2151
|
-
|
|
2152
|
-
|
|
2327
|
+
const internals =
|
|
2328
|
+
(this[$internals] =
|
|
2329
|
+
this[$internals] =
|
|
2330
|
+
{
|
|
2331
|
+
accessors: {},
|
|
2332
|
+
});
|
|
2153
2333
|
|
|
2154
2334
|
const accessors = internals.accessors;
|
|
2155
2335
|
const prototype = this.prototype;
|
|
@@ -2169,17 +2349,24 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2169
2349
|
}
|
|
2170
2350
|
};
|
|
2171
2351
|
|
|
2172
|
-
AxiosHeaders$1.accessor([
|
|
2352
|
+
AxiosHeaders$1.accessor([
|
|
2353
|
+
'Content-Type',
|
|
2354
|
+
'Content-Length',
|
|
2355
|
+
'Accept',
|
|
2356
|
+
'Accept-Encoding',
|
|
2357
|
+
'User-Agent',
|
|
2358
|
+
'Authorization',
|
|
2359
|
+
]);
|
|
2173
2360
|
|
|
2174
2361
|
// reserved names hotfix
|
|
2175
|
-
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
|
|
2362
|
+
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
2176
2363
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2177
2364
|
return {
|
|
2178
2365
|
get: () => value,
|
|
2179
2366
|
set(headerValue) {
|
|
2180
2367
|
this[mapped] = headerValue;
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2368
|
+
},
|
|
2369
|
+
};
|
|
2183
2370
|
});
|
|
2184
2371
|
|
|
2185
2372
|
utils$1.freezeMethods(AxiosHeaders$1);
|
|
@@ -2242,19 +2429,23 @@ function settle(resolve, reject, response) {
|
|
|
2242
2429
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2243
2430
|
resolve(response);
|
|
2244
2431
|
} else {
|
|
2245
|
-
reject(
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2432
|
+
reject(
|
|
2433
|
+
new AxiosError$1(
|
|
2434
|
+
'Request failed with status code ' + response.status,
|
|
2435
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][
|
|
2436
|
+
Math.floor(response.status / 100) - 4
|
|
2437
|
+
],
|
|
2438
|
+
response.config,
|
|
2439
|
+
response.request,
|
|
2440
|
+
response
|
|
2441
|
+
)
|
|
2442
|
+
);
|
|
2252
2443
|
}
|
|
2253
2444
|
}
|
|
2254
2445
|
|
|
2255
2446
|
function parseProtocol(url) {
|
|
2256
2447
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
2257
|
-
return match && match[1] || '';
|
|
2448
|
+
return (match && match[1]) || '';
|
|
2258
2449
|
}
|
|
2259
2450
|
|
|
2260
2451
|
/**
|
|
@@ -2305,7 +2496,7 @@ function speedometer(samplesCount, min) {
|
|
|
2305
2496
|
|
|
2306
2497
|
const passed = startedAt && now - startedAt;
|
|
2307
2498
|
|
|
2308
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
2499
|
+
return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
|
|
2309
2500
|
};
|
|
2310
2501
|
}
|
|
2311
2502
|
|
|
@@ -2334,7 +2525,7 @@ function throttle(fn, freq) {
|
|
|
2334
2525
|
const throttled = (...args) => {
|
|
2335
2526
|
const now = Date.now();
|
|
2336
2527
|
const passed = now - timestamp;
|
|
2337
|
-
if (
|
|
2528
|
+
if (passed >= threshold) {
|
|
2338
2529
|
invoke(args, now);
|
|
2339
2530
|
} else {
|
|
2340
2531
|
lastArgs = args;
|
|
@@ -2356,7 +2547,7 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2356
2547
|
let bytesNotified = 0;
|
|
2357
2548
|
const _speedometer = speedometer(50, 250);
|
|
2358
2549
|
|
|
2359
|
-
return throttle(e => {
|
|
2550
|
+
return throttle((e) => {
|
|
2360
2551
|
const loaded = e.loaded;
|
|
2361
2552
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2362
2553
|
const progressBytes = loaded - bytesNotified;
|
|
@@ -2368,13 +2559,13 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2368
2559
|
const data = {
|
|
2369
2560
|
loaded,
|
|
2370
2561
|
total,
|
|
2371
|
-
progress: total ?
|
|
2562
|
+
progress: total ? loaded / total : undefined,
|
|
2372
2563
|
bytes: progressBytes,
|
|
2373
2564
|
rate: rate ? rate : undefined,
|
|
2374
2565
|
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
2375
2566
|
event: e,
|
|
2376
2567
|
lengthComputable: total != null,
|
|
2377
|
-
[isDownloadStream ? 'download' : 'upload']: true
|
|
2568
|
+
[isDownloadStream ? 'download' : 'upload']: true,
|
|
2378
2569
|
};
|
|
2379
2570
|
|
|
2380
2571
|
listener(data);
|
|
@@ -2384,77 +2575,82 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2384
2575
|
const progressEventDecorator = (total, throttled) => {
|
|
2385
2576
|
const lengthComputable = total != null;
|
|
2386
2577
|
|
|
2387
|
-
return [
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2578
|
+
return [
|
|
2579
|
+
(loaded) =>
|
|
2580
|
+
throttled[0]({
|
|
2581
|
+
lengthComputable,
|
|
2582
|
+
total,
|
|
2583
|
+
loaded,
|
|
2584
|
+
}),
|
|
2585
|
+
throttled[1],
|
|
2586
|
+
];
|
|
2392
2587
|
};
|
|
2393
2588
|
|
|
2394
|
-
const asyncDecorator =
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
return (
|
|
2400
|
-
origin.protocol === url.protocol &&
|
|
2401
|
-
origin.host === url.host &&
|
|
2402
|
-
(isMSIE || origin.port === url.port)
|
|
2403
|
-
);
|
|
2404
|
-
})(
|
|
2405
|
-
new URL(platform.origin),
|
|
2406
|
-
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
2407
|
-
) : () => true;
|
|
2408
|
-
|
|
2409
|
-
var cookies = platform.hasStandardBrowserEnv ?
|
|
2589
|
+
const asyncDecorator =
|
|
2590
|
+
(fn) =>
|
|
2591
|
+
(...args) =>
|
|
2592
|
+
utils$1.asap(() => fn(...args));
|
|
2410
2593
|
|
|
2411
|
-
|
|
2412
|
-
{
|
|
2413
|
-
|
|
2414
|
-
if (typeof document === 'undefined') return;
|
|
2594
|
+
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2595
|
+
? ((origin, isMSIE) => (url) => {
|
|
2596
|
+
url = new URL(url, platform.origin);
|
|
2415
2597
|
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2598
|
+
return (
|
|
2599
|
+
origin.protocol === url.protocol &&
|
|
2600
|
+
origin.host === url.host &&
|
|
2601
|
+
(isMSIE || origin.port === url.port)
|
|
2602
|
+
);
|
|
2603
|
+
})(
|
|
2604
|
+
new URL(platform.origin),
|
|
2605
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
2606
|
+
)
|
|
2607
|
+
: () => true;
|
|
2608
|
+
|
|
2609
|
+
var cookies = platform.hasStandardBrowserEnv
|
|
2610
|
+
? // Standard browser envs support document.cookie
|
|
2611
|
+
{
|
|
2612
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2613
|
+
if (typeof document === 'undefined') return;
|
|
2614
|
+
|
|
2615
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
2616
|
+
|
|
2617
|
+
if (utils$1.isNumber(expires)) {
|
|
2618
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
2619
|
+
}
|
|
2620
|
+
if (utils$1.isString(path)) {
|
|
2621
|
+
cookie.push(`path=${path}`);
|
|
2622
|
+
}
|
|
2623
|
+
if (utils$1.isString(domain)) {
|
|
2624
|
+
cookie.push(`domain=${domain}`);
|
|
2625
|
+
}
|
|
2626
|
+
if (secure === true) {
|
|
2627
|
+
cookie.push('secure');
|
|
2628
|
+
}
|
|
2629
|
+
if (utils$1.isString(sameSite)) {
|
|
2630
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
2631
|
+
}
|
|
2433
2632
|
|
|
2434
|
-
|
|
2435
|
-
|
|
2633
|
+
document.cookie = cookie.join('; ');
|
|
2634
|
+
},
|
|
2436
2635
|
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2636
|
+
read(name) {
|
|
2637
|
+
if (typeof document === 'undefined') return null;
|
|
2638
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
2639
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
2640
|
+
},
|
|
2442
2641
|
|
|
2443
|
-
|
|
2444
|
-
|
|
2642
|
+
remove(name) {
|
|
2643
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
2644
|
+
},
|
|
2445
2645
|
}
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
return null;
|
|
2455
|
-
},
|
|
2456
|
-
remove() {}
|
|
2457
|
-
};
|
|
2646
|
+
: // Non-standard browser env (web workers, react-native) lack needed support.
|
|
2647
|
+
{
|
|
2648
|
+
write() {},
|
|
2649
|
+
read() {
|
|
2650
|
+
return null;
|
|
2651
|
+
},
|
|
2652
|
+
remove() {},
|
|
2653
|
+
};
|
|
2458
2654
|
|
|
2459
2655
|
/**
|
|
2460
2656
|
* Determines whether the specified URL is absolute
|
|
@@ -2506,8 +2702,7 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
|
2506
2702
|
return requestedURL;
|
|
2507
2703
|
}
|
|
2508
2704
|
|
|
2509
|
-
const headersToObject = (thing) =>
|
|
2510
|
-
thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
2705
|
+
const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
|
|
2511
2706
|
|
|
2512
2707
|
/**
|
|
2513
2708
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2600,23 +2795,12 @@ function mergeConfig$1(config1, config2) {
|
|
|
2600
2795
|
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2601
2796
|
};
|
|
2602
2797
|
|
|
2603
|
-
utils$1.forEach(
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
prop === "prototype"
|
|
2610
|
-
)
|
|
2611
|
-
return;
|
|
2612
|
-
const merge = utils$1.hasOwnProp(mergeMap, prop)
|
|
2613
|
-
? mergeMap[prop]
|
|
2614
|
-
: mergeDeepProperties;
|
|
2615
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2616
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
|
2617
|
-
(config[prop] = configValue);
|
|
2618
|
-
},
|
|
2619
|
-
);
|
|
2798
|
+
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
2799
|
+
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
2800
|
+
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
2801
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2802
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2803
|
+
});
|
|
2620
2804
|
|
|
2621
2805
|
return config;
|
|
2622
2806
|
}
|
|
@@ -2628,12 +2812,22 @@ var resolveConfig = (config) => {
|
|
|
2628
2812
|
|
|
2629
2813
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2630
2814
|
|
|
2631
|
-
newConfig.url = buildURL(
|
|
2815
|
+
newConfig.url = buildURL(
|
|
2816
|
+
buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls),
|
|
2817
|
+
config.params,
|
|
2818
|
+
config.paramsSerializer
|
|
2819
|
+
);
|
|
2632
2820
|
|
|
2633
2821
|
// HTTP basic authentication
|
|
2634
2822
|
if (auth) {
|
|
2635
|
-
headers.set(
|
|
2636
|
-
|
|
2823
|
+
headers.set(
|
|
2824
|
+
'Authorization',
|
|
2825
|
+
'Basic ' +
|
|
2826
|
+
btoa(
|
|
2827
|
+
(auth.username || '') +
|
|
2828
|
+
':' +
|
|
2829
|
+
(auth.password ? unescape(encodeURIComponent(auth.password)) : '')
|
|
2830
|
+
)
|
|
2637
2831
|
);
|
|
2638
2832
|
}
|
|
2639
2833
|
|
|
@@ -2651,7 +2845,7 @@ var resolveConfig = (config) => {
|
|
|
2651
2845
|
}
|
|
2652
2846
|
});
|
|
2653
2847
|
}
|
|
2654
|
-
}
|
|
2848
|
+
}
|
|
2655
2849
|
|
|
2656
2850
|
// Add xsrf header
|
|
2657
2851
|
// This is only done if running in a standard browser environment.
|
|
@@ -2675,196 +2869,218 @@ var resolveConfig = (config) => {
|
|
|
2675
2869
|
|
|
2676
2870
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
2677
2871
|
|
|
2678
|
-
var xhrAdapter = isXHRAdapterSupported &&
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2872
|
+
var xhrAdapter = isXHRAdapterSupported &&
|
|
2873
|
+
function (config) {
|
|
2874
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2875
|
+
const _config = resolveConfig(config);
|
|
2876
|
+
let requestData = _config.data;
|
|
2877
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
2878
|
+
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
2879
|
+
let onCanceled;
|
|
2880
|
+
let uploadThrottled, downloadThrottled;
|
|
2881
|
+
let flushUpload, flushDownload;
|
|
2687
2882
|
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2883
|
+
function done() {
|
|
2884
|
+
flushUpload && flushUpload(); // flush events
|
|
2885
|
+
flushDownload && flushDownload(); // flush events
|
|
2691
2886
|
|
|
2692
|
-
|
|
2887
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
2693
2888
|
|
|
2694
|
-
|
|
2695
|
-
|
|
2889
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
2890
|
+
}
|
|
2696
2891
|
|
|
2697
|
-
|
|
2892
|
+
let request = new XMLHttpRequest();
|
|
2698
2893
|
|
|
2699
|
-
|
|
2894
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
2700
2895
|
|
|
2701
|
-
|
|
2702
|
-
|
|
2896
|
+
// Set the request timeout in MS
|
|
2897
|
+
request.timeout = _config.timeout;
|
|
2703
2898
|
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2899
|
+
function onloadend() {
|
|
2900
|
+
if (!request) {
|
|
2901
|
+
return;
|
|
2902
|
+
}
|
|
2903
|
+
// Prepare the response
|
|
2904
|
+
const responseHeaders = AxiosHeaders$1.from(
|
|
2905
|
+
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2906
|
+
);
|
|
2907
|
+
const responseData =
|
|
2908
|
+
!responseType || responseType === 'text' || responseType === 'json'
|
|
2909
|
+
? request.responseText
|
|
2910
|
+
: request.response;
|
|
2911
|
+
const response = {
|
|
2912
|
+
data: responseData,
|
|
2913
|
+
status: request.status,
|
|
2914
|
+
statusText: request.statusText,
|
|
2915
|
+
headers: responseHeaders,
|
|
2916
|
+
config,
|
|
2917
|
+
request,
|
|
2918
|
+
};
|
|
2919
|
+
|
|
2920
|
+
settle(
|
|
2921
|
+
function _resolve(value) {
|
|
2922
|
+
resolve(value);
|
|
2923
|
+
done();
|
|
2924
|
+
},
|
|
2925
|
+
function _reject(err) {
|
|
2926
|
+
reject(err);
|
|
2927
|
+
done();
|
|
2928
|
+
},
|
|
2929
|
+
response
|
|
2930
|
+
);
|
|
2931
|
+
|
|
2932
|
+
// Clean up request
|
|
2933
|
+
request = null;
|
|
2707
2934
|
}
|
|
2708
|
-
// Prepare the response
|
|
2709
|
-
const responseHeaders = AxiosHeaders$1.from(
|
|
2710
|
-
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2711
|
-
);
|
|
2712
|
-
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
2713
|
-
request.responseText : request.response;
|
|
2714
|
-
const response = {
|
|
2715
|
-
data: responseData,
|
|
2716
|
-
status: request.status,
|
|
2717
|
-
statusText: request.statusText,
|
|
2718
|
-
headers: responseHeaders,
|
|
2719
|
-
config,
|
|
2720
|
-
request
|
|
2721
|
-
};
|
|
2722
2935
|
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
}
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2936
|
+
if ('onloadend' in request) {
|
|
2937
|
+
// Use onloadend if available
|
|
2938
|
+
request.onloadend = onloadend;
|
|
2939
|
+
} else {
|
|
2940
|
+
// Listen for ready state to emulate onloadend
|
|
2941
|
+
request.onreadystatechange = function handleLoad() {
|
|
2942
|
+
if (!request || request.readyState !== 4) {
|
|
2943
|
+
return;
|
|
2944
|
+
}
|
|
2730
2945
|
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2946
|
+
// The request errored out and we didn't get a response, this will be
|
|
2947
|
+
// handled by onerror instead
|
|
2948
|
+
// With one exception: request that using file: protocol, most browsers
|
|
2949
|
+
// will return status as 0 even though it's a successful request
|
|
2950
|
+
if (
|
|
2951
|
+
request.status === 0 &&
|
|
2952
|
+
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
|
2953
|
+
) {
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2956
|
+
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2957
|
+
// so we should call onloadend on the next 'tick'
|
|
2958
|
+
setTimeout(onloadend);
|
|
2959
|
+
};
|
|
2960
|
+
}
|
|
2734
2961
|
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
} else {
|
|
2739
|
-
// Listen for ready state to emulate onloadend
|
|
2740
|
-
request.onreadystatechange = function handleLoad() {
|
|
2741
|
-
if (!request || request.readyState !== 4) {
|
|
2962
|
+
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
2963
|
+
request.onabort = function handleAbort() {
|
|
2964
|
+
if (!request) {
|
|
2742
2965
|
return;
|
|
2743
2966
|
}
|
|
2744
2967
|
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
//
|
|
2748
|
-
|
|
2749
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
2750
|
-
return;
|
|
2751
|
-
}
|
|
2752
|
-
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2753
|
-
// so we should call onloadend on the next 'tick'
|
|
2754
|
-
setTimeout(onloadend);
|
|
2968
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
2969
|
+
|
|
2970
|
+
// Clean up request
|
|
2971
|
+
request = null;
|
|
2755
2972
|
};
|
|
2756
|
-
}
|
|
2757
2973
|
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2974
|
+
// Handle low level network errors
|
|
2975
|
+
request.onerror = function handleError(event) {
|
|
2976
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
2977
|
+
// (message may be empty; when present, surface it)
|
|
2978
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
2979
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
2980
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
2981
|
+
// attach the underlying event for consumers who want details
|
|
2982
|
+
err.event = event || null;
|
|
2983
|
+
reject(err);
|
|
2984
|
+
request = null;
|
|
2985
|
+
};
|
|
2763
2986
|
|
|
2764
|
-
|
|
2987
|
+
// Handle timeout
|
|
2988
|
+
request.ontimeout = function handleTimeout() {
|
|
2989
|
+
let timeoutErrorMessage = _config.timeout
|
|
2990
|
+
? 'timeout of ' + _config.timeout + 'ms exceeded'
|
|
2991
|
+
: 'timeout exceeded';
|
|
2992
|
+
const transitional = _config.transitional || transitionalDefaults;
|
|
2993
|
+
if (_config.timeoutErrorMessage) {
|
|
2994
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2995
|
+
}
|
|
2996
|
+
reject(
|
|
2997
|
+
new AxiosError$1(
|
|
2998
|
+
timeoutErrorMessage,
|
|
2999
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
3000
|
+
config,
|
|
3001
|
+
request
|
|
3002
|
+
)
|
|
3003
|
+
);
|
|
2765
3004
|
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
3005
|
+
// Clean up request
|
|
3006
|
+
request = null;
|
|
3007
|
+
};
|
|
2769
3008
|
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
// Browsers deliver a ProgressEvent in XHR onerror
|
|
2773
|
-
// (message may be empty; when present, surface it)
|
|
2774
|
-
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
2775
|
-
const msg = event && event.message ? event.message : 'Network Error';
|
|
2776
|
-
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
2777
|
-
// attach the underlying event for consumers who want details
|
|
2778
|
-
err.event = event || null;
|
|
2779
|
-
reject(err);
|
|
2780
|
-
request = null;
|
|
2781
|
-
};
|
|
2782
|
-
|
|
2783
|
-
// Handle timeout
|
|
2784
|
-
request.ontimeout = function handleTimeout() {
|
|
2785
|
-
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
2786
|
-
const transitional = _config.transitional || transitionalDefaults;
|
|
2787
|
-
if (_config.timeoutErrorMessage) {
|
|
2788
|
-
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2789
|
-
}
|
|
2790
|
-
reject(new AxiosError$1(
|
|
2791
|
-
timeoutErrorMessage,
|
|
2792
|
-
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
2793
|
-
config,
|
|
2794
|
-
request));
|
|
2795
|
-
|
|
2796
|
-
// Clean up request
|
|
2797
|
-
request = null;
|
|
2798
|
-
};
|
|
3009
|
+
// Remove Content-Type if data is undefined
|
|
3010
|
+
requestData === undefined && requestHeaders.setContentType(null);
|
|
2799
3011
|
|
|
2800
|
-
|
|
2801
|
-
|
|
3012
|
+
// Add headers to the request
|
|
3013
|
+
if ('setRequestHeader' in request) {
|
|
3014
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
3015
|
+
request.setRequestHeader(key, val);
|
|
3016
|
+
});
|
|
3017
|
+
}
|
|
2802
3018
|
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
});
|
|
2808
|
-
}
|
|
3019
|
+
// Add withCredentials to request if needed
|
|
3020
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
3021
|
+
request.withCredentials = !!_config.withCredentials;
|
|
3022
|
+
}
|
|
2809
3023
|
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
3024
|
+
// Add responseType to request if needed
|
|
3025
|
+
if (responseType && responseType !== 'json') {
|
|
3026
|
+
request.responseType = _config.responseType;
|
|
3027
|
+
}
|
|
2814
3028
|
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
3029
|
+
// Handle progress if needed
|
|
3030
|
+
if (onDownloadProgress) {
|
|
3031
|
+
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
|
3032
|
+
request.addEventListener('progress', downloadThrottled);
|
|
3033
|
+
}
|
|
2819
3034
|
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
request.addEventListener('progress', downloadThrottled);
|
|
2824
|
-
}
|
|
3035
|
+
// Not all browsers support upload events
|
|
3036
|
+
if (onUploadProgress && request.upload) {
|
|
3037
|
+
[uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
|
|
2825
3038
|
|
|
2826
|
-
|
|
2827
|
-
if (onUploadProgress && request.upload) {
|
|
2828
|
-
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
3039
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
2829
3040
|
|
|
2830
|
-
|
|
3041
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
3042
|
+
}
|
|
2831
3043
|
|
|
2832
|
-
|
|
2833
|
-
|
|
3044
|
+
if (_config.cancelToken || _config.signal) {
|
|
3045
|
+
// Handle cancellation
|
|
3046
|
+
// eslint-disable-next-line func-names
|
|
3047
|
+
onCanceled = (cancel) => {
|
|
3048
|
+
if (!request) {
|
|
3049
|
+
return;
|
|
3050
|
+
}
|
|
3051
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
3052
|
+
request.abort();
|
|
3053
|
+
request = null;
|
|
3054
|
+
};
|
|
2834
3055
|
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
return;
|
|
3056
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
3057
|
+
if (_config.signal) {
|
|
3058
|
+
_config.signal.aborted
|
|
3059
|
+
? onCanceled()
|
|
3060
|
+
: _config.signal.addEventListener('abort', onCanceled);
|
|
2841
3061
|
}
|
|
2842
|
-
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
2843
|
-
request.abort();
|
|
2844
|
-
request = null;
|
|
2845
|
-
};
|
|
2846
|
-
|
|
2847
|
-
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
2848
|
-
if (_config.signal) {
|
|
2849
|
-
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
2850
3062
|
}
|
|
2851
|
-
}
|
|
2852
|
-
|
|
2853
|
-
const protocol = parseProtocol(_config.url);
|
|
2854
3063
|
|
|
2855
|
-
|
|
2856
|
-
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
|
2857
|
-
return;
|
|
2858
|
-
}
|
|
3064
|
+
const protocol = parseProtocol(_config.url);
|
|
2859
3065
|
|
|
3066
|
+
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
3067
|
+
reject(
|
|
3068
|
+
new AxiosError$1(
|
|
3069
|
+
'Unsupported protocol ' + protocol + ':',
|
|
3070
|
+
AxiosError$1.ERR_BAD_REQUEST,
|
|
3071
|
+
config
|
|
3072
|
+
)
|
|
3073
|
+
);
|
|
3074
|
+
return;
|
|
3075
|
+
}
|
|
2860
3076
|
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
};
|
|
3077
|
+
// Send the request
|
|
3078
|
+
request.send(requestData || null);
|
|
3079
|
+
});
|
|
3080
|
+
};
|
|
2865
3081
|
|
|
2866
3082
|
const composeSignals = (signals, timeout) => {
|
|
2867
|
-
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
3083
|
+
const { length } = (signals = signals ? signals.filter(Boolean) : []);
|
|
2868
3084
|
|
|
2869
3085
|
if (timeout || length) {
|
|
2870
3086
|
let controller = new AbortController();
|
|
@@ -2876,21 +3092,29 @@ const composeSignals = (signals, timeout) => {
|
|
|
2876
3092
|
aborted = true;
|
|
2877
3093
|
unsubscribe();
|
|
2878
3094
|
const err = reason instanceof Error ? reason : this.reason;
|
|
2879
|
-
controller.abort(
|
|
3095
|
+
controller.abort(
|
|
3096
|
+
err instanceof AxiosError$1
|
|
3097
|
+
? err
|
|
3098
|
+
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3099
|
+
);
|
|
2880
3100
|
}
|
|
2881
3101
|
};
|
|
2882
3102
|
|
|
2883
|
-
let timer =
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
3103
|
+
let timer =
|
|
3104
|
+
timeout &&
|
|
3105
|
+
setTimeout(() => {
|
|
3106
|
+
timer = null;
|
|
3107
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
3108
|
+
}, timeout);
|
|
2887
3109
|
|
|
2888
3110
|
const unsubscribe = () => {
|
|
2889
3111
|
if (signals) {
|
|
2890
3112
|
timer && clearTimeout(timer);
|
|
2891
3113
|
timer = null;
|
|
2892
|
-
signals.forEach(signal => {
|
|
2893
|
-
signal.unsubscribe
|
|
3114
|
+
signals.forEach((signal) => {
|
|
3115
|
+
signal.unsubscribe
|
|
3116
|
+
? signal.unsubscribe(onabort)
|
|
3117
|
+
: signal.removeEventListener('abort', onabort);
|
|
2894
3118
|
});
|
|
2895
3119
|
signals = null;
|
|
2896
3120
|
}
|
|
@@ -2898,7 +3122,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
2898
3122
|
|
|
2899
3123
|
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
2900
3124
|
|
|
2901
|
-
const {signal} = controller;
|
|
3125
|
+
const { signal } = controller;
|
|
2902
3126
|
|
|
2903
3127
|
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
2904
3128
|
|
|
@@ -2939,7 +3163,7 @@ const readStream = async function* (stream) {
|
|
|
2939
3163
|
const reader = stream.getReader();
|
|
2940
3164
|
try {
|
|
2941
3165
|
for (;;) {
|
|
2942
|
-
const {done, value} = await reader.read();
|
|
3166
|
+
const { done, value } = await reader.read();
|
|
2943
3167
|
if (done) {
|
|
2944
3168
|
break;
|
|
2945
3169
|
}
|
|
@@ -2962,64 +3186,69 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
2962
3186
|
}
|
|
2963
3187
|
};
|
|
2964
3188
|
|
|
2965
|
-
return new ReadableStream(
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
3189
|
+
return new ReadableStream(
|
|
3190
|
+
{
|
|
3191
|
+
async pull(controller) {
|
|
3192
|
+
try {
|
|
3193
|
+
const { done, value } = await iterator.next();
|
|
2969
3194
|
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
3195
|
+
if (done) {
|
|
3196
|
+
_onFinish();
|
|
3197
|
+
controller.close();
|
|
3198
|
+
return;
|
|
3199
|
+
}
|
|
2975
3200
|
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
3201
|
+
let len = value.byteLength;
|
|
3202
|
+
if (onProgress) {
|
|
3203
|
+
let loadedBytes = (bytes += len);
|
|
3204
|
+
onProgress(loadedBytes);
|
|
3205
|
+
}
|
|
3206
|
+
controller.enqueue(new Uint8Array(value));
|
|
3207
|
+
} catch (err) {
|
|
3208
|
+
_onFinish(err);
|
|
3209
|
+
throw err;
|
|
2980
3210
|
}
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
_onFinish(
|
|
2984
|
-
|
|
2985
|
-
}
|
|
3211
|
+
},
|
|
3212
|
+
cancel(reason) {
|
|
3213
|
+
_onFinish(reason);
|
|
3214
|
+
return iterator.return();
|
|
3215
|
+
},
|
|
2986
3216
|
},
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
return iterator.return();
|
|
3217
|
+
{
|
|
3218
|
+
highWaterMark: 2,
|
|
2990
3219
|
}
|
|
2991
|
-
|
|
2992
|
-
highWaterMark: 2
|
|
2993
|
-
})
|
|
3220
|
+
);
|
|
2994
3221
|
};
|
|
2995
3222
|
|
|
2996
3223
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
2997
3224
|
|
|
2998
|
-
const {isFunction} = utils$1;
|
|
3225
|
+
const { isFunction } = utils$1;
|
|
2999
3226
|
|
|
3000
|
-
const globalFetchAPI = (({Request, Response}) => ({
|
|
3001
|
-
Request,
|
|
3227
|
+
const globalFetchAPI = (({ Request, Response }) => ({
|
|
3228
|
+
Request,
|
|
3229
|
+
Response,
|
|
3002
3230
|
}))(utils$1.global);
|
|
3003
3231
|
|
|
3004
|
-
const {
|
|
3005
|
-
ReadableStream: ReadableStream$1, TextEncoder
|
|
3006
|
-
} = utils$1.global;
|
|
3007
|
-
|
|
3232
|
+
const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
|
|
3008
3233
|
|
|
3009
3234
|
const test = (fn, ...args) => {
|
|
3010
3235
|
try {
|
|
3011
3236
|
return !!fn(...args);
|
|
3012
3237
|
} catch (e) {
|
|
3013
|
-
return false
|
|
3238
|
+
return false;
|
|
3014
3239
|
}
|
|
3015
3240
|
};
|
|
3016
3241
|
|
|
3017
3242
|
const factory = (env) => {
|
|
3018
|
-
env = utils$1.merge.call(
|
|
3019
|
-
|
|
3020
|
-
|
|
3243
|
+
env = utils$1.merge.call(
|
|
3244
|
+
{
|
|
3245
|
+
skipUndefined: true,
|
|
3246
|
+
},
|
|
3247
|
+
globalFetchAPI,
|
|
3248
|
+
env
|
|
3249
|
+
);
|
|
3021
3250
|
|
|
3022
|
-
const {fetch: envFetch, Request, Response} = env;
|
|
3251
|
+
const { fetch: envFetch, Request, Response } = env;
|
|
3023
3252
|
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
3024
3253
|
const isRequestSupported = isFunction(Request);
|
|
3025
3254
|
const isResponseSupported = isFunction(Response);
|
|
@@ -3030,46 +3259,65 @@ const factory = (env) => {
|
|
|
3030
3259
|
|
|
3031
3260
|
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
3032
3261
|
|
|
3033
|
-
const encodeText =
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3262
|
+
const encodeText =
|
|
3263
|
+
isFetchSupported &&
|
|
3264
|
+
(typeof TextEncoder === 'function'
|
|
3265
|
+
? (
|
|
3266
|
+
(encoder) => (str) =>
|
|
3267
|
+
encoder.encode(str)
|
|
3268
|
+
)(new TextEncoder())
|
|
3269
|
+
: async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
3037
3270
|
|
|
3038
|
-
const supportsRequestStream =
|
|
3039
|
-
|
|
3271
|
+
const supportsRequestStream =
|
|
3272
|
+
isRequestSupported &&
|
|
3273
|
+
isReadableStreamSupported &&
|
|
3274
|
+
test(() => {
|
|
3275
|
+
let duplexAccessed = false;
|
|
3040
3276
|
|
|
3041
|
-
|
|
3042
|
-
body: new ReadableStream$1(),
|
|
3043
|
-
method: 'POST',
|
|
3044
|
-
get duplex() {
|
|
3045
|
-
duplexAccessed = true;
|
|
3046
|
-
return 'half';
|
|
3047
|
-
},
|
|
3048
|
-
}).headers.has('Content-Type');
|
|
3277
|
+
const body = new ReadableStream$1();
|
|
3049
3278
|
|
|
3050
|
-
|
|
3051
|
-
|
|
3279
|
+
const hasContentType = new Request(platform.origin, {
|
|
3280
|
+
body,
|
|
3281
|
+
method: 'POST',
|
|
3282
|
+
get duplex() {
|
|
3283
|
+
duplexAccessed = true;
|
|
3284
|
+
return 'half';
|
|
3285
|
+
},
|
|
3286
|
+
}).headers.has('Content-Type');
|
|
3287
|
+
|
|
3288
|
+
body.cancel();
|
|
3289
|
+
|
|
3290
|
+
return duplexAccessed && !hasContentType;
|
|
3291
|
+
});
|
|
3052
3292
|
|
|
3053
|
-
const supportsResponseStream =
|
|
3293
|
+
const supportsResponseStream =
|
|
3294
|
+
isResponseSupported &&
|
|
3295
|
+
isReadableStreamSupported &&
|
|
3054
3296
|
test(() => utils$1.isReadableStream(new Response('').body));
|
|
3055
3297
|
|
|
3056
3298
|
const resolvers = {
|
|
3057
|
-
stream: supportsResponseStream && ((res) => res.body)
|
|
3299
|
+
stream: supportsResponseStream && ((res) => res.body),
|
|
3058
3300
|
};
|
|
3059
3301
|
|
|
3060
|
-
isFetchSupported &&
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3302
|
+
isFetchSupported &&
|
|
3303
|
+
(() => {
|
|
3304
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
|
|
3305
|
+
!resolvers[type] &&
|
|
3306
|
+
(resolvers[type] = (res, config) => {
|
|
3307
|
+
let method = res && res[type];
|
|
3064
3308
|
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3309
|
+
if (method) {
|
|
3310
|
+
return method.call(res);
|
|
3311
|
+
}
|
|
3068
3312
|
|
|
3069
|
-
|
|
3313
|
+
throw new AxiosError$1(
|
|
3314
|
+
`Response type '${type}' is not supported`,
|
|
3315
|
+
AxiosError$1.ERR_NOT_SUPPORT,
|
|
3316
|
+
config
|
|
3317
|
+
);
|
|
3318
|
+
});
|
|
3070
3319
|
});
|
|
3071
|
-
});
|
|
3072
|
-
})());
|
|
3320
|
+
})();
|
|
3073
3321
|
|
|
3074
3322
|
const getBodyLength = async (body) => {
|
|
3075
3323
|
if (body == null) {
|
|
@@ -3120,32 +3368,41 @@ const factory = (env) => {
|
|
|
3120
3368
|
responseType,
|
|
3121
3369
|
headers,
|
|
3122
3370
|
withCredentials = 'same-origin',
|
|
3123
|
-
fetchOptions
|
|
3371
|
+
fetchOptions,
|
|
3124
3372
|
} = resolveConfig(config);
|
|
3125
3373
|
|
|
3126
3374
|
let _fetch = envFetch || fetch;
|
|
3127
3375
|
|
|
3128
3376
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3129
3377
|
|
|
3130
|
-
let composedSignal = composeSignals(
|
|
3378
|
+
let composedSignal = composeSignals(
|
|
3379
|
+
[signal, cancelToken && cancelToken.toAbortSignal()],
|
|
3380
|
+
timeout
|
|
3381
|
+
);
|
|
3131
3382
|
|
|
3132
3383
|
let request = null;
|
|
3133
3384
|
|
|
3134
|
-
const unsubscribe =
|
|
3135
|
-
composedSignal
|
|
3136
|
-
|
|
3385
|
+
const unsubscribe =
|
|
3386
|
+
composedSignal &&
|
|
3387
|
+
composedSignal.unsubscribe &&
|
|
3388
|
+
(() => {
|
|
3389
|
+
composedSignal.unsubscribe();
|
|
3390
|
+
});
|
|
3137
3391
|
|
|
3138
3392
|
let requestContentLength;
|
|
3139
3393
|
|
|
3140
3394
|
try {
|
|
3141
3395
|
if (
|
|
3142
|
-
onUploadProgress &&
|
|
3396
|
+
onUploadProgress &&
|
|
3397
|
+
supportsRequestStream &&
|
|
3398
|
+
method !== 'get' &&
|
|
3399
|
+
method !== 'head' &&
|
|
3143
3400
|
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
3144
3401
|
) {
|
|
3145
3402
|
let _request = new Request(url, {
|
|
3146
3403
|
method: 'POST',
|
|
3147
3404
|
body: data,
|
|
3148
|
-
duplex:
|
|
3405
|
+
duplex: 'half',
|
|
3149
3406
|
});
|
|
3150
3407
|
|
|
3151
3408
|
let contentTypeHeader;
|
|
@@ -3170,7 +3427,7 @@ const factory = (env) => {
|
|
|
3170
3427
|
|
|
3171
3428
|
// Cloudflare Workers throws when credentials are defined
|
|
3172
3429
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
3173
|
-
const isCredentialsSupported = isRequestSupported &&
|
|
3430
|
+
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
|
3174
3431
|
|
|
3175
3432
|
const resolvedOptions = {
|
|
3176
3433
|
...fetchOptions,
|
|
@@ -3178,29 +3435,35 @@ const factory = (env) => {
|
|
|
3178
3435
|
method: method.toUpperCase(),
|
|
3179
3436
|
headers: headers.normalize().toJSON(),
|
|
3180
3437
|
body: data,
|
|
3181
|
-
duplex:
|
|
3182
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3438
|
+
duplex: 'half',
|
|
3439
|
+
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
3183
3440
|
};
|
|
3184
3441
|
|
|
3185
3442
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3186
3443
|
|
|
3187
|
-
let response = await (isRequestSupported
|
|
3444
|
+
let response = await (isRequestSupported
|
|
3445
|
+
? _fetch(request, fetchOptions)
|
|
3446
|
+
: _fetch(url, resolvedOptions));
|
|
3188
3447
|
|
|
3189
|
-
const isStreamResponse =
|
|
3448
|
+
const isStreamResponse =
|
|
3449
|
+
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3190
3450
|
|
|
3191
3451
|
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
3192
3452
|
const options = {};
|
|
3193
3453
|
|
|
3194
|
-
['status', 'statusText', 'headers'].forEach(prop => {
|
|
3454
|
+
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
3195
3455
|
options[prop] = response[prop];
|
|
3196
3456
|
});
|
|
3197
3457
|
|
|
3198
3458
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3199
3459
|
|
|
3200
|
-
const [onProgress, flush] =
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3460
|
+
const [onProgress, flush] =
|
|
3461
|
+
(onDownloadProgress &&
|
|
3462
|
+
progressEventDecorator(
|
|
3463
|
+
responseContentLength,
|
|
3464
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3465
|
+
)) ||
|
|
3466
|
+
[];
|
|
3204
3467
|
|
|
3205
3468
|
response = new Response(
|
|
3206
3469
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
@@ -3213,7 +3476,10 @@ const factory = (env) => {
|
|
|
3213
3476
|
|
|
3214
3477
|
responseType = responseType || 'text';
|
|
3215
3478
|
|
|
3216
|
-
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3479
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3480
|
+
response,
|
|
3481
|
+
config
|
|
3482
|
+
);
|
|
3217
3483
|
|
|
3218
3484
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3219
3485
|
|
|
@@ -3224,43 +3490,50 @@ const factory = (env) => {
|
|
|
3224
3490
|
status: response.status,
|
|
3225
3491
|
statusText: response.statusText,
|
|
3226
3492
|
config,
|
|
3227
|
-
request
|
|
3493
|
+
request,
|
|
3228
3494
|
});
|
|
3229
|
-
})
|
|
3495
|
+
});
|
|
3230
3496
|
} catch (err) {
|
|
3231
3497
|
unsubscribe && unsubscribe();
|
|
3232
3498
|
|
|
3233
3499
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3234
3500
|
throw Object.assign(
|
|
3235
|
-
new AxiosError$1(
|
|
3501
|
+
new AxiosError$1(
|
|
3502
|
+
'Network Error',
|
|
3503
|
+
AxiosError$1.ERR_NETWORK,
|
|
3504
|
+
config,
|
|
3505
|
+
request,
|
|
3506
|
+
err && err.response
|
|
3507
|
+
),
|
|
3236
3508
|
{
|
|
3237
|
-
cause: err.cause || err
|
|
3509
|
+
cause: err.cause || err,
|
|
3238
3510
|
}
|
|
3239
|
-
)
|
|
3511
|
+
);
|
|
3240
3512
|
}
|
|
3241
3513
|
|
|
3242
3514
|
throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
|
|
3243
3515
|
}
|
|
3244
|
-
}
|
|
3516
|
+
};
|
|
3245
3517
|
};
|
|
3246
3518
|
|
|
3247
3519
|
const seedCache = new Map();
|
|
3248
3520
|
|
|
3249
3521
|
const getFetch = (config) => {
|
|
3250
3522
|
let env = (config && config.env) || {};
|
|
3251
|
-
const {fetch, Request, Response} = env;
|
|
3252
|
-
const seeds = [
|
|
3253
|
-
Request, Response, fetch
|
|
3254
|
-
];
|
|
3523
|
+
const { fetch, Request, Response } = env;
|
|
3524
|
+
const seeds = [Request, Response, fetch];
|
|
3255
3525
|
|
|
3256
|
-
let len = seeds.length,
|
|
3257
|
-
|
|
3526
|
+
let len = seeds.length,
|
|
3527
|
+
i = len,
|
|
3528
|
+
seed,
|
|
3529
|
+
target,
|
|
3530
|
+
map = seedCache;
|
|
3258
3531
|
|
|
3259
3532
|
while (i--) {
|
|
3260
3533
|
seed = seeds[i];
|
|
3261
3534
|
target = map.get(seed);
|
|
3262
3535
|
|
|
3263
|
-
target === undefined && map.set(seed, target =
|
|
3536
|
+
target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
|
|
3264
3537
|
|
|
3265
3538
|
map = target;
|
|
3266
3539
|
}
|
|
@@ -3276,7 +3549,7 @@ getFetch();
|
|
|
3276
3549
|
* - `http` for Node.js
|
|
3277
3550
|
* - `xhr` for browsers
|
|
3278
3551
|
* - `fetch` for fetch API-based requests
|
|
3279
|
-
*
|
|
3552
|
+
*
|
|
3280
3553
|
* @type {Object<string, Function|Object>}
|
|
3281
3554
|
*/
|
|
3282
3555
|
const knownAdapters = {
|
|
@@ -3284,7 +3557,7 @@ const knownAdapters = {
|
|
|
3284
3557
|
xhr: xhrAdapter,
|
|
3285
3558
|
fetch: {
|
|
3286
3559
|
get: getFetch,
|
|
3287
|
-
}
|
|
3560
|
+
},
|
|
3288
3561
|
};
|
|
3289
3562
|
|
|
3290
3563
|
// Assign adapter names for easier debugging and identification
|
|
@@ -3301,7 +3574,7 @@ utils$1.forEach(knownAdapters, (fn, value) => {
|
|
|
3301
3574
|
|
|
3302
3575
|
/**
|
|
3303
3576
|
* Render a rejection reason string for unknown or unsupported adapters
|
|
3304
|
-
*
|
|
3577
|
+
*
|
|
3305
3578
|
* @param {string} reason
|
|
3306
3579
|
* @returns {string}
|
|
3307
3580
|
*/
|
|
@@ -3309,17 +3582,18 @@ const renderReason = (reason) => `- ${reason}`;
|
|
|
3309
3582
|
|
|
3310
3583
|
/**
|
|
3311
3584
|
* Check if the adapter is resolved (function, null, or false)
|
|
3312
|
-
*
|
|
3585
|
+
*
|
|
3313
3586
|
* @param {Function|null|false} adapter
|
|
3314
3587
|
* @returns {boolean}
|
|
3315
3588
|
*/
|
|
3316
|
-
const isResolvedHandle = (adapter) =>
|
|
3589
|
+
const isResolvedHandle = (adapter) =>
|
|
3590
|
+
utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3317
3591
|
|
|
3318
3592
|
/**
|
|
3319
3593
|
* Get the first suitable adapter from the provided list.
|
|
3320
3594
|
* Tries each adapter in order until a supported one is found.
|
|
3321
3595
|
* Throws an AxiosError if no adapter is suitable.
|
|
3322
|
-
*
|
|
3596
|
+
*
|
|
3323
3597
|
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3324
3598
|
* @param {Object} config - Axios request configuration
|
|
3325
3599
|
* @throws {AxiosError} If no suitable adapter is available
|
|
@@ -3356,14 +3630,17 @@ function getAdapter$1(adapters, config) {
|
|
|
3356
3630
|
}
|
|
3357
3631
|
|
|
3358
3632
|
if (!adapter) {
|
|
3359
|
-
const reasons = Object.entries(rejectedReasons)
|
|
3360
|
-
|
|
3633
|
+
const reasons = Object.entries(rejectedReasons).map(
|
|
3634
|
+
([id, state]) =>
|
|
3635
|
+
`adapter ${id} ` +
|
|
3361
3636
|
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
3362
|
-
|
|
3637
|
+
);
|
|
3363
3638
|
|
|
3364
|
-
let s = length
|
|
3365
|
-
|
|
3366
|
-
|
|
3639
|
+
let s = length
|
|
3640
|
+
? reasons.length > 1
|
|
3641
|
+
? 'since :\n' + reasons.map(renderReason).join('\n')
|
|
3642
|
+
: ' ' + renderReason(reasons[0])
|
|
3643
|
+
: 'as no adapter specified';
|
|
3367
3644
|
|
|
3368
3645
|
throw new AxiosError$1(
|
|
3369
3646
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
@@ -3388,7 +3665,7 @@ var adapters = {
|
|
|
3388
3665
|
* Exposes all known adapters
|
|
3389
3666
|
* @type {Object<string, Function|Object>}
|
|
3390
3667
|
*/
|
|
3391
|
-
adapters: knownAdapters
|
|
3668
|
+
adapters: knownAdapters,
|
|
3392
3669
|
};
|
|
3393
3670
|
|
|
3394
3671
|
/**
|
|
@@ -3421,10 +3698,7 @@ function dispatchRequest(config) {
|
|
|
3421
3698
|
config.headers = AxiosHeaders$1.from(config.headers);
|
|
3422
3699
|
|
|
3423
3700
|
// Transform request data
|
|
3424
|
-
config.data = transformData.call(
|
|
3425
|
-
config,
|
|
3426
|
-
config.transformRequest
|
|
3427
|
-
);
|
|
3701
|
+
config.data = transformData.call(config, config.transformRequest);
|
|
3428
3702
|
|
|
3429
3703
|
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|
3430
3704
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
@@ -3432,39 +3706,38 @@ function dispatchRequest(config) {
|
|
|
3432
3706
|
|
|
3433
3707
|
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|
3434
3708
|
|
|
3435
|
-
return adapter(config).then(
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
// Transform response data
|
|
3439
|
-
response.data = transformData.call(
|
|
3440
|
-
config,
|
|
3441
|
-
config.transformResponse,
|
|
3442
|
-
response
|
|
3443
|
-
);
|
|
3444
|
-
|
|
3445
|
-
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3446
|
-
|
|
3447
|
-
return response;
|
|
3448
|
-
}, function onAdapterRejection(reason) {
|
|
3449
|
-
if (!isCancel$1(reason)) {
|
|
3709
|
+
return adapter(config).then(
|
|
3710
|
+
function onAdapterResolution(response) {
|
|
3450
3711
|
throwIfCancellationRequested(config);
|
|
3451
3712
|
|
|
3452
3713
|
// Transform response data
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3714
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
3715
|
+
|
|
3716
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3717
|
+
|
|
3718
|
+
return response;
|
|
3719
|
+
},
|
|
3720
|
+
function onAdapterRejection(reason) {
|
|
3721
|
+
if (!isCancel$1(reason)) {
|
|
3722
|
+
throwIfCancellationRequested(config);
|
|
3723
|
+
|
|
3724
|
+
// Transform response data
|
|
3725
|
+
if (reason && reason.response) {
|
|
3726
|
+
reason.response.data = transformData.call(
|
|
3727
|
+
config,
|
|
3728
|
+
config.transformResponse,
|
|
3729
|
+
reason.response
|
|
3730
|
+
);
|
|
3731
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
3732
|
+
}
|
|
3460
3733
|
}
|
|
3461
|
-
}
|
|
3462
3734
|
|
|
3463
|
-
|
|
3464
|
-
|
|
3735
|
+
return Promise.reject(reason);
|
|
3736
|
+
}
|
|
3737
|
+
);
|
|
3465
3738
|
}
|
|
3466
3739
|
|
|
3467
|
-
const VERSION$1 = "1.
|
|
3740
|
+
const VERSION$1 = "1.15.0";
|
|
3468
3741
|
|
|
3469
3742
|
const validators$1 = {};
|
|
3470
3743
|
|
|
@@ -3488,7 +3761,15 @@ const deprecatedWarnings = {};
|
|
|
3488
3761
|
*/
|
|
3489
3762
|
validators$1.transitional = function transitional(validator, version, message) {
|
|
3490
3763
|
function formatMessage(opt, desc) {
|
|
3491
|
-
return
|
|
3764
|
+
return (
|
|
3765
|
+
'[Axios v' +
|
|
3766
|
+
VERSION$1 +
|
|
3767
|
+
"] Transitional option '" +
|
|
3768
|
+
opt +
|
|
3769
|
+
"'" +
|
|
3770
|
+
desc +
|
|
3771
|
+
(message ? '. ' + message : '')
|
|
3772
|
+
);
|
|
3492
3773
|
}
|
|
3493
3774
|
|
|
3494
3775
|
// eslint-disable-next-line func-names
|
|
@@ -3520,7 +3801,7 @@ validators$1.spelling = function spelling(correctSpelling) {
|
|
|
3520
3801
|
// eslint-disable-next-line no-console
|
|
3521
3802
|
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
3522
3803
|
return true;
|
|
3523
|
-
}
|
|
3804
|
+
};
|
|
3524
3805
|
};
|
|
3525
3806
|
|
|
3526
3807
|
/**
|
|
@@ -3546,7 +3827,10 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3546
3827
|
const value = options[opt];
|
|
3547
3828
|
const result = value === undefined || validator(value, opt, options);
|
|
3548
3829
|
if (result !== true) {
|
|
3549
|
-
throw new AxiosError$1(
|
|
3830
|
+
throw new AxiosError$1(
|
|
3831
|
+
'option ' + opt + ' must be ' + result,
|
|
3832
|
+
AxiosError$1.ERR_BAD_OPTION_VALUE
|
|
3833
|
+
);
|
|
3550
3834
|
}
|
|
3551
3835
|
continue;
|
|
3552
3836
|
}
|
|
@@ -3558,7 +3842,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3558
3842
|
|
|
3559
3843
|
var validator = {
|
|
3560
3844
|
assertOptions,
|
|
3561
|
-
validators: validators$1
|
|
3845
|
+
validators: validators$1,
|
|
3562
3846
|
};
|
|
3563
3847
|
|
|
3564
3848
|
const validators = validator.validators;
|
|
@@ -3575,7 +3859,7 @@ let Axios$1 = class Axios {
|
|
|
3575
3859
|
this.defaults = instanceConfig || {};
|
|
3576
3860
|
this.interceptors = {
|
|
3577
3861
|
request: new InterceptorManager(),
|
|
3578
|
-
response: new InterceptorManager()
|
|
3862
|
+
response: new InterceptorManager(),
|
|
3579
3863
|
};
|
|
3580
3864
|
}
|
|
3581
3865
|
|
|
@@ -3597,13 +3881,29 @@ let Axios$1 = class Axios {
|
|
|
3597
3881
|
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
3598
3882
|
|
|
3599
3883
|
// slice off the Error: ... line
|
|
3600
|
-
const stack =
|
|
3884
|
+
const stack = (() => {
|
|
3885
|
+
if (!dummy.stack) {
|
|
3886
|
+
return '';
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3889
|
+
const firstNewlineIndex = dummy.stack.indexOf('\n');
|
|
3890
|
+
|
|
3891
|
+
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
3892
|
+
})();
|
|
3601
3893
|
try {
|
|
3602
3894
|
if (!err.stack) {
|
|
3603
3895
|
err.stack = stack;
|
|
3604
3896
|
// match without the 2 top stack lines
|
|
3605
|
-
} else if (stack
|
|
3606
|
-
|
|
3897
|
+
} else if (stack) {
|
|
3898
|
+
const firstNewlineIndex = stack.indexOf('\n');
|
|
3899
|
+
const secondNewlineIndex =
|
|
3900
|
+
firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
3901
|
+
const stackWithoutTwoTopLines =
|
|
3902
|
+
secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
|
|
3903
|
+
|
|
3904
|
+
if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
|
|
3905
|
+
err.stack += '\n' + stack;
|
|
3906
|
+
}
|
|
3607
3907
|
}
|
|
3608
3908
|
} catch (e) {
|
|
3609
3909
|
// ignore the case where "stack" is an un-writable property
|
|
@@ -3626,27 +3926,35 @@ let Axios$1 = class Axios {
|
|
|
3626
3926
|
|
|
3627
3927
|
config = mergeConfig$1(this.defaults, config);
|
|
3628
3928
|
|
|
3629
|
-
const {transitional, paramsSerializer, headers} = config;
|
|
3929
|
+
const { transitional, paramsSerializer, headers } = config;
|
|
3630
3930
|
|
|
3631
3931
|
if (transitional !== undefined) {
|
|
3632
|
-
validator.assertOptions(
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3932
|
+
validator.assertOptions(
|
|
3933
|
+
transitional,
|
|
3934
|
+
{
|
|
3935
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
3936
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
3937
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
3938
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
3939
|
+
},
|
|
3940
|
+
false
|
|
3941
|
+
);
|
|
3638
3942
|
}
|
|
3639
3943
|
|
|
3640
3944
|
if (paramsSerializer != null) {
|
|
3641
3945
|
if (utils$1.isFunction(paramsSerializer)) {
|
|
3642
3946
|
config.paramsSerializer = {
|
|
3643
|
-
serialize: paramsSerializer
|
|
3947
|
+
serialize: paramsSerializer,
|
|
3644
3948
|
};
|
|
3645
3949
|
} else {
|
|
3646
|
-
validator.assertOptions(
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3950
|
+
validator.assertOptions(
|
|
3951
|
+
paramsSerializer,
|
|
3952
|
+
{
|
|
3953
|
+
encode: validators.function,
|
|
3954
|
+
serialize: validators.function,
|
|
3955
|
+
},
|
|
3956
|
+
true
|
|
3957
|
+
);
|
|
3650
3958
|
}
|
|
3651
3959
|
}
|
|
3652
3960
|
|
|
@@ -3657,26 +3965,25 @@ let Axios$1 = class Axios {
|
|
|
3657
3965
|
config.allowAbsoluteUrls = true;
|
|
3658
3966
|
}
|
|
3659
3967
|
|
|
3660
|
-
validator.assertOptions(
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3968
|
+
validator.assertOptions(
|
|
3969
|
+
config,
|
|
3970
|
+
{
|
|
3971
|
+
baseUrl: validators.spelling('baseURL'),
|
|
3972
|
+
withXsrfToken: validators.spelling('withXSRFToken'),
|
|
3973
|
+
},
|
|
3974
|
+
true
|
|
3975
|
+
);
|
|
3664
3976
|
|
|
3665
3977
|
// Set config.method
|
|
3666
3978
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
3667
3979
|
|
|
3668
3980
|
// Flatten headers
|
|
3669
|
-
let contextHeaders = headers && utils$1.merge(
|
|
3670
|
-
headers.common,
|
|
3671
|
-
headers[config.method]
|
|
3672
|
-
);
|
|
3981
|
+
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
3673
3982
|
|
|
3674
|
-
headers &&
|
|
3675
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
3676
|
-
(method) => {
|
|
3983
|
+
headers &&
|
|
3984
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
|
3677
3985
|
delete headers[method];
|
|
3678
|
-
}
|
|
3679
|
-
);
|
|
3986
|
+
});
|
|
3680
3987
|
|
|
3681
3988
|
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
3682
3989
|
|
|
@@ -3691,7 +3998,8 @@ let Axios$1 = class Axios {
|
|
|
3691
3998
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3692
3999
|
|
|
3693
4000
|
const transitional = config.transitional || transitionalDefaults;
|
|
3694
|
-
const legacyInterceptorReqResOrdering =
|
|
4001
|
+
const legacyInterceptorReqResOrdering =
|
|
4002
|
+
transitional && transitional.legacyInterceptorReqResOrdering;
|
|
3695
4003
|
|
|
3696
4004
|
if (legacyInterceptorReqResOrdering) {
|
|
3697
4005
|
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
@@ -3765,28 +4073,32 @@ let Axios$1 = class Axios {
|
|
|
3765
4073
|
// Provide aliases for supported request methods
|
|
3766
4074
|
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
3767
4075
|
/*eslint func-names:0*/
|
|
3768
|
-
Axios$1.prototype[method] = function(url, config) {
|
|
3769
|
-
return this.request(
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
4076
|
+
Axios$1.prototype[method] = function (url, config) {
|
|
4077
|
+
return this.request(
|
|
4078
|
+
mergeConfig$1(config || {}, {
|
|
4079
|
+
method,
|
|
4080
|
+
url,
|
|
4081
|
+
data: (config || {}).data,
|
|
4082
|
+
})
|
|
4083
|
+
);
|
|
3774
4084
|
};
|
|
3775
4085
|
});
|
|
3776
4086
|
|
|
3777
4087
|
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3778
|
-
/*eslint func-names:0*/
|
|
3779
|
-
|
|
3780
4088
|
function generateHTTPMethod(isForm) {
|
|
3781
4089
|
return function httpMethod(url, data, config) {
|
|
3782
|
-
return this.request(
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
4090
|
+
return this.request(
|
|
4091
|
+
mergeConfig$1(config || {}, {
|
|
4092
|
+
method,
|
|
4093
|
+
headers: isForm
|
|
4094
|
+
? {
|
|
4095
|
+
'Content-Type': 'multipart/form-data',
|
|
4096
|
+
}
|
|
4097
|
+
: {},
|
|
4098
|
+
url,
|
|
4099
|
+
data,
|
|
4100
|
+
})
|
|
4101
|
+
);
|
|
3790
4102
|
};
|
|
3791
4103
|
}
|
|
3792
4104
|
|
|
@@ -3817,7 +4129,7 @@ let CancelToken$1 = class CancelToken {
|
|
|
3817
4129
|
const token = this;
|
|
3818
4130
|
|
|
3819
4131
|
// eslint-disable-next-line func-names
|
|
3820
|
-
this.promise.then(cancel => {
|
|
4132
|
+
this.promise.then((cancel) => {
|
|
3821
4133
|
if (!token._listeners) return;
|
|
3822
4134
|
|
|
3823
4135
|
let i = token._listeners.length;
|
|
@@ -3829,10 +4141,10 @@ let CancelToken$1 = class CancelToken {
|
|
|
3829
4141
|
});
|
|
3830
4142
|
|
|
3831
4143
|
// eslint-disable-next-line func-names
|
|
3832
|
-
this.promise.then = onfulfilled => {
|
|
4144
|
+
this.promise.then = (onfulfilled) => {
|
|
3833
4145
|
let _resolve;
|
|
3834
4146
|
// eslint-disable-next-line func-names
|
|
3835
|
-
const promise = new Promise(resolve => {
|
|
4147
|
+
const promise = new Promise((resolve) => {
|
|
3836
4148
|
token.subscribe(resolve);
|
|
3837
4149
|
_resolve = resolve;
|
|
3838
4150
|
}).then(onfulfilled);
|
|
@@ -3920,7 +4232,7 @@ let CancelToken$1 = class CancelToken {
|
|
|
3920
4232
|
});
|
|
3921
4233
|
return {
|
|
3922
4234
|
token,
|
|
3923
|
-
cancel
|
|
4235
|
+
cancel,
|
|
3924
4236
|
};
|
|
3925
4237
|
}
|
|
3926
4238
|
};
|
|
@@ -3960,7 +4272,7 @@ function spread$1(callback) {
|
|
|
3960
4272
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3961
4273
|
*/
|
|
3962
4274
|
function isAxiosError$1(payload) {
|
|
3963
|
-
return utils$1.isObject(payload) &&
|
|
4275
|
+
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
3964
4276
|
}
|
|
3965
4277
|
|
|
3966
4278
|
const HttpStatusCode$1 = {
|
|
@@ -4051,10 +4363,10 @@ function createInstance(defaultConfig) {
|
|
|
4051
4363
|
const instance = bind(Axios$1.prototype.request, context);
|
|
4052
4364
|
|
|
4053
4365
|
// Copy axios.prototype to instance
|
|
4054
|
-
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
|
4366
|
+
utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
|
|
4055
4367
|
|
|
4056
4368
|
// Copy context to instance
|
|
4057
|
-
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
4369
|
+
utils$1.extend(instance, context, null, { allOwnKeys: true });
|
|
4058
4370
|
|
|
4059
4371
|
// Factory for creating new instances
|
|
4060
4372
|
instance.create = function create(instanceConfig) {
|
|
@@ -4098,7 +4410,7 @@ axios.mergeConfig = mergeConfig$1;
|
|
|
4098
4410
|
|
|
4099
4411
|
axios.AxiosHeaders = AxiosHeaders$1;
|
|
4100
4412
|
|
|
4101
|
-
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4413
|
+
axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4102
4414
|
|
|
4103
4415
|
axios.getAdapter = adapters.getAdapter;
|
|
4104
4416
|
|
|
@@ -4125,7 +4437,7 @@ const {
|
|
|
4125
4437
|
HttpStatusCode,
|
|
4126
4438
|
formToJSON,
|
|
4127
4439
|
getAdapter,
|
|
4128
|
-
mergeConfig
|
|
4440
|
+
mergeConfig,
|
|
4129
4441
|
} = axios;
|
|
4130
4442
|
|
|
4131
4443
|
/**
|