@xchainjs/xchain-dash 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.esm.js +958 -443
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +958 -443
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
package/lib/index.esm.js
CHANGED
|
@@ -325,6 +325,8 @@ const isFormData = (thing) => {
|
|
|
325
325
|
*/
|
|
326
326
|
const isURLSearchParams = kindOfTest('URLSearchParams');
|
|
327
327
|
|
|
328
|
+
const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
|
|
329
|
+
|
|
328
330
|
/**
|
|
329
331
|
* Trim excess whitespace off the beginning and end of a string
|
|
330
332
|
*
|
|
@@ -656,8 +658,9 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
656
658
|
const reducedDescriptors = {};
|
|
657
659
|
|
|
658
660
|
forEach(descriptors, (descriptor, name) => {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
+
let ret;
|
|
662
|
+
if ((ret = reducer(descriptor, name, obj)) !== false) {
|
|
663
|
+
reducedDescriptors[name] = ret || descriptor;
|
|
661
664
|
}
|
|
662
665
|
});
|
|
663
666
|
|
|
@@ -712,8 +715,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
712
715
|
const noop = () => {};
|
|
713
716
|
|
|
714
717
|
const toFiniteNumber = (value, defaultValue) => {
|
|
715
|
-
value = +value;
|
|
716
|
-
return Number.isFinite(value) ? value : defaultValue;
|
|
718
|
+
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
717
719
|
};
|
|
718
720
|
|
|
719
721
|
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
|
@@ -778,7 +780,42 @@ const toJSONObject = (obj) => {
|
|
|
778
780
|
return visit(obj, 0);
|
|
779
781
|
};
|
|
780
782
|
|
|
781
|
-
|
|
783
|
+
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
784
|
+
|
|
785
|
+
const isThenable = (thing) =>
|
|
786
|
+
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
787
|
+
|
|
788
|
+
// original code
|
|
789
|
+
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
790
|
+
|
|
791
|
+
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
792
|
+
if (setImmediateSupported) {
|
|
793
|
+
return setImmediate;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
return postMessageSupported ? ((token, callbacks) => {
|
|
797
|
+
_global.addEventListener("message", ({source, data}) => {
|
|
798
|
+
if (source === _global && data === token) {
|
|
799
|
+
callbacks.length && callbacks.shift()();
|
|
800
|
+
}
|
|
801
|
+
}, false);
|
|
802
|
+
|
|
803
|
+
return (cb) => {
|
|
804
|
+
callbacks.push(cb);
|
|
805
|
+
_global.postMessage(token, "*");
|
|
806
|
+
}
|
|
807
|
+
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
808
|
+
})(
|
|
809
|
+
typeof setImmediate === 'function',
|
|
810
|
+
isFunction(_global.postMessage)
|
|
811
|
+
);
|
|
812
|
+
|
|
813
|
+
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
814
|
+
queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
|
|
815
|
+
|
|
816
|
+
// *********************
|
|
817
|
+
|
|
818
|
+
var utils$3 = {
|
|
782
819
|
isArray,
|
|
783
820
|
isArrayBuffer,
|
|
784
821
|
isBuffer,
|
|
@@ -789,6 +826,10 @@ var utils$2 = {
|
|
|
789
826
|
isBoolean,
|
|
790
827
|
isObject,
|
|
791
828
|
isPlainObject,
|
|
829
|
+
isReadableStream,
|
|
830
|
+
isRequest,
|
|
831
|
+
isResponse,
|
|
832
|
+
isHeaders,
|
|
792
833
|
isUndefined,
|
|
793
834
|
isDate,
|
|
794
835
|
isFile,
|
|
@@ -827,7 +868,11 @@ var utils$2 = {
|
|
|
827
868
|
ALPHABET,
|
|
828
869
|
generateString,
|
|
829
870
|
isSpecCompliantForm,
|
|
830
|
-
toJSONObject
|
|
871
|
+
toJSONObject,
|
|
872
|
+
isAsyncFn,
|
|
873
|
+
isThenable,
|
|
874
|
+
setImmediate: _setImmediate,
|
|
875
|
+
asap
|
|
831
876
|
};
|
|
832
877
|
|
|
833
878
|
/**
|
|
@@ -858,7 +903,7 @@ function AxiosError(message, code, config, request, response) {
|
|
|
858
903
|
response && (this.response = response);
|
|
859
904
|
}
|
|
860
905
|
|
|
861
|
-
utils$
|
|
906
|
+
utils$3.inherits(AxiosError, Error, {
|
|
862
907
|
toJSON: function toJSON() {
|
|
863
908
|
return {
|
|
864
909
|
// Standard
|
|
@@ -873,7 +918,7 @@ utils$2.inherits(AxiosError, Error, {
|
|
|
873
918
|
columnNumber: this.columnNumber,
|
|
874
919
|
stack: this.stack,
|
|
875
920
|
// Axios
|
|
876
|
-
config: utils$
|
|
921
|
+
config: utils$3.toJSONObject(this.config),
|
|
877
922
|
code: this.code,
|
|
878
923
|
status: this.response && this.response.status ? this.response.status : null
|
|
879
924
|
};
|
|
@@ -908,7 +953,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
|
908
953
|
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
909
954
|
const axiosError = Object.create(prototype$1);
|
|
910
955
|
|
|
911
|
-
utils$
|
|
956
|
+
utils$3.toFlatObject(error, axiosError, function filter(obj) {
|
|
912
957
|
return obj !== Error.prototype;
|
|
913
958
|
}, prop => {
|
|
914
959
|
return prop !== 'isAxiosError';
|
|
@@ -936,7 +981,7 @@ var httpAdapter = null;
|
|
|
936
981
|
* @returns {boolean}
|
|
937
982
|
*/
|
|
938
983
|
function isVisitable(thing) {
|
|
939
|
-
return utils$
|
|
984
|
+
return utils$3.isPlainObject(thing) || utils$3.isArray(thing);
|
|
940
985
|
}
|
|
941
986
|
|
|
942
987
|
/**
|
|
@@ -947,7 +992,7 @@ function isVisitable(thing) {
|
|
|
947
992
|
* @returns {string} the key without the brackets.
|
|
948
993
|
*/
|
|
949
994
|
function removeBrackets(key) {
|
|
950
|
-
return utils$
|
|
995
|
+
return utils$3.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
951
996
|
}
|
|
952
997
|
|
|
953
998
|
/**
|
|
@@ -976,10 +1021,10 @@ function renderKey(path, key, dots) {
|
|
|
976
1021
|
* @returns {boolean}
|
|
977
1022
|
*/
|
|
978
1023
|
function isFlatArray(arr) {
|
|
979
|
-
return utils$
|
|
1024
|
+
return utils$3.isArray(arr) && !arr.some(isVisitable);
|
|
980
1025
|
}
|
|
981
1026
|
|
|
982
|
-
const predicates = utils$
|
|
1027
|
+
const predicates = utils$3.toFlatObject(utils$3, {}, null, function filter(prop) {
|
|
983
1028
|
return /^is[A-Z]/.test(prop);
|
|
984
1029
|
});
|
|
985
1030
|
|
|
@@ -1007,7 +1052,7 @@ const predicates = utils$2.toFlatObject(utils$2, {}, null, function filter(prop)
|
|
|
1007
1052
|
* @returns
|
|
1008
1053
|
*/
|
|
1009
1054
|
function toFormData(obj, formData, options) {
|
|
1010
|
-
if (!utils$
|
|
1055
|
+
if (!utils$3.isObject(obj)) {
|
|
1011
1056
|
throw new TypeError('target must be an object');
|
|
1012
1057
|
}
|
|
1013
1058
|
|
|
@@ -1015,13 +1060,13 @@ function toFormData(obj, formData, options) {
|
|
|
1015
1060
|
formData = formData || new (FormData)();
|
|
1016
1061
|
|
|
1017
1062
|
// eslint-disable-next-line no-param-reassign
|
|
1018
|
-
options = utils$
|
|
1063
|
+
options = utils$3.toFlatObject(options, {
|
|
1019
1064
|
metaTokens: true,
|
|
1020
1065
|
dots: false,
|
|
1021
1066
|
indexes: false
|
|
1022
1067
|
}, false, function defined(option, source) {
|
|
1023
1068
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1024
|
-
return !utils$
|
|
1069
|
+
return !utils$3.isUndefined(source[option]);
|
|
1025
1070
|
});
|
|
1026
1071
|
|
|
1027
1072
|
const metaTokens = options.metaTokens;
|
|
@@ -1030,24 +1075,24 @@ function toFormData(obj, formData, options) {
|
|
|
1030
1075
|
const dots = options.dots;
|
|
1031
1076
|
const indexes = options.indexes;
|
|
1032
1077
|
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1033
|
-
const useBlob = _Blob && utils$
|
|
1078
|
+
const useBlob = _Blob && utils$3.isSpecCompliantForm(formData);
|
|
1034
1079
|
|
|
1035
|
-
if (!utils$
|
|
1080
|
+
if (!utils$3.isFunction(visitor)) {
|
|
1036
1081
|
throw new TypeError('visitor must be a function');
|
|
1037
1082
|
}
|
|
1038
1083
|
|
|
1039
1084
|
function convertValue(value) {
|
|
1040
1085
|
if (value === null) return '';
|
|
1041
1086
|
|
|
1042
|
-
if (utils$
|
|
1087
|
+
if (utils$3.isDate(value)) {
|
|
1043
1088
|
return value.toISOString();
|
|
1044
1089
|
}
|
|
1045
1090
|
|
|
1046
|
-
if (!useBlob && utils$
|
|
1091
|
+
if (!useBlob && utils$3.isBlob(value)) {
|
|
1047
1092
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1048
1093
|
}
|
|
1049
1094
|
|
|
1050
|
-
if (utils$
|
|
1095
|
+
if (utils$3.isArrayBuffer(value) || utils$3.isTypedArray(value)) {
|
|
1051
1096
|
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
1052
1097
|
}
|
|
1053
1098
|
|
|
@@ -1068,20 +1113,20 @@ function toFormData(obj, formData, options) {
|
|
|
1068
1113
|
let arr = value;
|
|
1069
1114
|
|
|
1070
1115
|
if (value && !path && typeof value === 'object') {
|
|
1071
|
-
if (utils$
|
|
1116
|
+
if (utils$3.endsWith(key, '{}')) {
|
|
1072
1117
|
// eslint-disable-next-line no-param-reassign
|
|
1073
1118
|
key = metaTokens ? key : key.slice(0, -2);
|
|
1074
1119
|
// eslint-disable-next-line no-param-reassign
|
|
1075
1120
|
value = JSON.stringify(value);
|
|
1076
1121
|
} else if (
|
|
1077
|
-
(utils$
|
|
1078
|
-
((utils$
|
|
1122
|
+
(utils$3.isArray(value) && isFlatArray(value)) ||
|
|
1123
|
+
((utils$3.isFileList(value) || utils$3.endsWith(key, '[]')) && (arr = utils$3.toArray(value))
|
|
1079
1124
|
)) {
|
|
1080
1125
|
// eslint-disable-next-line no-param-reassign
|
|
1081
1126
|
key = removeBrackets(key);
|
|
1082
1127
|
|
|
1083
1128
|
arr.forEach(function each(el, index) {
|
|
1084
|
-
!(utils$
|
|
1129
|
+
!(utils$3.isUndefined(el) || el === null) && formData.append(
|
|
1085
1130
|
// eslint-disable-next-line no-nested-ternary
|
|
1086
1131
|
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
1087
1132
|
convertValue(el)
|
|
@@ -1109,7 +1154,7 @@ function toFormData(obj, formData, options) {
|
|
|
1109
1154
|
});
|
|
1110
1155
|
|
|
1111
1156
|
function build(value, path) {
|
|
1112
|
-
if (utils$
|
|
1157
|
+
if (utils$3.isUndefined(value)) return;
|
|
1113
1158
|
|
|
1114
1159
|
if (stack.indexOf(value) !== -1) {
|
|
1115
1160
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
@@ -1117,9 +1162,9 @@ function toFormData(obj, formData, options) {
|
|
|
1117
1162
|
|
|
1118
1163
|
stack.push(value);
|
|
1119
1164
|
|
|
1120
|
-
utils$
|
|
1121
|
-
const result = !(utils$
|
|
1122
|
-
formData, el, utils$
|
|
1165
|
+
utils$3.forEach(value, function each(el, key) {
|
|
1166
|
+
const result = !(utils$3.isUndefined(el) || el === null) && visitor.call(
|
|
1167
|
+
formData, el, utils$3.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
1123
1168
|
);
|
|
1124
1169
|
|
|
1125
1170
|
if (result === true) {
|
|
@@ -1130,7 +1175,7 @@ function toFormData(obj, formData, options) {
|
|
|
1130
1175
|
stack.pop();
|
|
1131
1176
|
}
|
|
1132
1177
|
|
|
1133
|
-
if (!utils$
|
|
1178
|
+
if (!utils$3.isObject(obj)) {
|
|
1134
1179
|
throw new TypeError('data must be an object');
|
|
1135
1180
|
}
|
|
1136
1181
|
|
|
@@ -1234,7 +1279,7 @@ function buildURL(url, params, options) {
|
|
|
1234
1279
|
if (serializeFn) {
|
|
1235
1280
|
serializedParams = serializeFn(params, options);
|
|
1236
1281
|
} else {
|
|
1237
|
-
serializedParams = utils$
|
|
1282
|
+
serializedParams = utils$3.isURLSearchParams(params) ?
|
|
1238
1283
|
params.toString() :
|
|
1239
1284
|
new AxiosURLSearchParams(params, options).toString(_encode);
|
|
1240
1285
|
}
|
|
@@ -1309,7 +1354,7 @@ class InterceptorManager {
|
|
|
1309
1354
|
* @returns {void}
|
|
1310
1355
|
*/
|
|
1311
1356
|
forEach(fn) {
|
|
1312
|
-
utils$
|
|
1357
|
+
utils$3.forEach(this.handlers, function forEachHandler(h) {
|
|
1313
1358
|
if (h !== null) {
|
|
1314
1359
|
fn(h);
|
|
1315
1360
|
}
|
|
@@ -1331,6 +1376,18 @@ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
|
1331
1376
|
|
|
1332
1377
|
var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
1333
1378
|
|
|
1379
|
+
var platform$1 = {
|
|
1380
|
+
isBrowser: true,
|
|
1381
|
+
classes: {
|
|
1382
|
+
URLSearchParams: URLSearchParams$1,
|
|
1383
|
+
FormData: FormData$1,
|
|
1384
|
+
Blob: Blob$1
|
|
1385
|
+
},
|
|
1386
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1387
|
+
};
|
|
1388
|
+
|
|
1389
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1390
|
+
|
|
1334
1391
|
/**
|
|
1335
1392
|
* Determine if we're running in a standard browser environment
|
|
1336
1393
|
*
|
|
@@ -1348,18 +1405,10 @@ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
|
1348
1405
|
*
|
|
1349
1406
|
* @returns {boolean}
|
|
1350
1407
|
*/
|
|
1351
|
-
const
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
product === 'NativeScript' ||
|
|
1356
|
-
product === 'NS')
|
|
1357
|
-
) {
|
|
1358
|
-
return false;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1362
|
-
})();
|
|
1408
|
+
const hasStandardBrowserEnv = (
|
|
1409
|
+
(product) => {
|
|
1410
|
+
return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
|
|
1411
|
+
})(typeof navigator !== 'undefined' && navigator.product);
|
|
1363
1412
|
|
|
1364
1413
|
/**
|
|
1365
1414
|
* Determine if we're running in a standard browser webWorker environment
|
|
@@ -1370,7 +1419,7 @@ const isStandardBrowserEnv = (() => {
|
|
|
1370
1419
|
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
1371
1420
|
* This leads to a problem when axios post `FormData` in webWorker
|
|
1372
1421
|
*/
|
|
1373
|
-
|
|
1422
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
1374
1423
|
return (
|
|
1375
1424
|
typeof WorkerGlobalScope !== 'undefined' &&
|
|
1376
1425
|
// eslint-disable-next-line no-undef
|
|
@@ -1379,23 +1428,25 @@ const isStandardBrowserEnv = (() => {
|
|
|
1379
1428
|
);
|
|
1380
1429
|
})();
|
|
1381
1430
|
|
|
1431
|
+
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1432
|
+
|
|
1433
|
+
var utils$2 = /*#__PURE__*/Object.freeze({
|
|
1434
|
+
__proto__: null,
|
|
1435
|
+
hasBrowserEnv: hasBrowserEnv,
|
|
1436
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
1437
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
1438
|
+
origin: origin
|
|
1439
|
+
});
|
|
1382
1440
|
|
|
1383
1441
|
var platform = {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
URLSearchParams: URLSearchParams$1,
|
|
1387
|
-
FormData: FormData$1,
|
|
1388
|
-
Blob: Blob$1
|
|
1389
|
-
},
|
|
1390
|
-
isStandardBrowserEnv,
|
|
1391
|
-
isStandardBrowserWebWorkerEnv,
|
|
1392
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1442
|
+
...utils$2,
|
|
1443
|
+
...platform$1
|
|
1393
1444
|
};
|
|
1394
1445
|
|
|
1395
1446
|
function toURLEncodedForm(data, options) {
|
|
1396
1447
|
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
1397
1448
|
visitor: function(value, key, path, helpers) {
|
|
1398
|
-
if (platform.isNode && utils$
|
|
1449
|
+
if (platform.isNode && utils$3.isBuffer(value)) {
|
|
1399
1450
|
this.append(key, value.toString('base64'));
|
|
1400
1451
|
return false;
|
|
1401
1452
|
}
|
|
@@ -1417,7 +1468,7 @@ function parsePropPath(name) {
|
|
|
1417
1468
|
// foo.x.y.z
|
|
1418
1469
|
// foo-x-y-z
|
|
1419
1470
|
// foo x y z
|
|
1420
|
-
return utils$
|
|
1471
|
+
return utils$3.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1421
1472
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1422
1473
|
});
|
|
1423
1474
|
}
|
|
@@ -1452,12 +1503,15 @@ function arrayToObject(arr) {
|
|
|
1452
1503
|
function formDataToJSON(formData) {
|
|
1453
1504
|
function buildPath(path, value, target, index) {
|
|
1454
1505
|
let name = path[index++];
|
|
1506
|
+
|
|
1507
|
+
if (name === '__proto__') return true;
|
|
1508
|
+
|
|
1455
1509
|
const isNumericKey = Number.isFinite(+name);
|
|
1456
1510
|
const isLast = index >= path.length;
|
|
1457
|
-
name = !name && utils$
|
|
1511
|
+
name = !name && utils$3.isArray(target) ? target.length : name;
|
|
1458
1512
|
|
|
1459
1513
|
if (isLast) {
|
|
1460
|
-
if (utils$
|
|
1514
|
+
if (utils$3.hasOwnProp(target, name)) {
|
|
1461
1515
|
target[name] = [target[name], value];
|
|
1462
1516
|
} else {
|
|
1463
1517
|
target[name] = value;
|
|
@@ -1466,23 +1520,23 @@ function formDataToJSON(formData) {
|
|
|
1466
1520
|
return !isNumericKey;
|
|
1467
1521
|
}
|
|
1468
1522
|
|
|
1469
|
-
if (!target[name] || !utils$
|
|
1523
|
+
if (!target[name] || !utils$3.isObject(target[name])) {
|
|
1470
1524
|
target[name] = [];
|
|
1471
1525
|
}
|
|
1472
1526
|
|
|
1473
1527
|
const result = buildPath(path, value, target[name], index);
|
|
1474
1528
|
|
|
1475
|
-
if (result && utils$
|
|
1529
|
+
if (result && utils$3.isArray(target[name])) {
|
|
1476
1530
|
target[name] = arrayToObject(target[name]);
|
|
1477
1531
|
}
|
|
1478
1532
|
|
|
1479
1533
|
return !isNumericKey;
|
|
1480
1534
|
}
|
|
1481
1535
|
|
|
1482
|
-
if (utils$
|
|
1536
|
+
if (utils$3.isFormData(formData) && utils$3.isFunction(formData.entries)) {
|
|
1483
1537
|
const obj = {};
|
|
1484
1538
|
|
|
1485
|
-
utils$
|
|
1539
|
+
utils$3.forEachEntry(formData, (name, value) => {
|
|
1486
1540
|
buildPath(parsePropPath(name), value, obj, 0);
|
|
1487
1541
|
});
|
|
1488
1542
|
|
|
@@ -1492,10 +1546,6 @@ function formDataToJSON(formData) {
|
|
|
1492
1546
|
return null;
|
|
1493
1547
|
}
|
|
1494
1548
|
|
|
1495
|
-
const DEFAULT_CONTENT_TYPE = {
|
|
1496
|
-
'Content-Type': undefined
|
|
1497
|
-
};
|
|
1498
|
-
|
|
1499
1549
|
/**
|
|
1500
1550
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
1501
1551
|
* of the input
|
|
@@ -1507,10 +1557,10 @@ const DEFAULT_CONTENT_TYPE = {
|
|
|
1507
1557
|
* @returns {string} A stringified version of the rawValue.
|
|
1508
1558
|
*/
|
|
1509
1559
|
function stringifySafely(rawValue, parser, encoder) {
|
|
1510
|
-
if (utils$
|
|
1560
|
+
if (utils$3.isString(rawValue)) {
|
|
1511
1561
|
try {
|
|
1512
1562
|
(parser || JSON.parse)(rawValue);
|
|
1513
|
-
return utils$
|
|
1563
|
+
return utils$3.trim(rawValue);
|
|
1514
1564
|
} catch (e) {
|
|
1515
1565
|
if (e.name !== 'SyntaxError') {
|
|
1516
1566
|
throw e;
|
|
@@ -1525,38 +1575,36 @@ const defaults = {
|
|
|
1525
1575
|
|
|
1526
1576
|
transitional: transitionalDefaults,
|
|
1527
1577
|
|
|
1528
|
-
adapter: ['xhr', 'http'],
|
|
1578
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
1529
1579
|
|
|
1530
1580
|
transformRequest: [function transformRequest(data, headers) {
|
|
1531
1581
|
const contentType = headers.getContentType() || '';
|
|
1532
1582
|
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1533
|
-
const isObjectPayload = utils$
|
|
1583
|
+
const isObjectPayload = utils$3.isObject(data);
|
|
1534
1584
|
|
|
1535
|
-
if (isObjectPayload && utils$
|
|
1585
|
+
if (isObjectPayload && utils$3.isHTMLForm(data)) {
|
|
1536
1586
|
data = new FormData(data);
|
|
1537
1587
|
}
|
|
1538
1588
|
|
|
1539
|
-
const isFormData = utils$
|
|
1589
|
+
const isFormData = utils$3.isFormData(data);
|
|
1540
1590
|
|
|
1541
1591
|
if (isFormData) {
|
|
1542
|
-
if (!hasJSONContentType) {
|
|
1543
|
-
return data;
|
|
1544
|
-
}
|
|
1545
1592
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1546
1593
|
}
|
|
1547
1594
|
|
|
1548
|
-
if (utils$
|
|
1549
|
-
utils$
|
|
1550
|
-
utils$
|
|
1551
|
-
utils$
|
|
1552
|
-
utils$
|
|
1595
|
+
if (utils$3.isArrayBuffer(data) ||
|
|
1596
|
+
utils$3.isBuffer(data) ||
|
|
1597
|
+
utils$3.isStream(data) ||
|
|
1598
|
+
utils$3.isFile(data) ||
|
|
1599
|
+
utils$3.isBlob(data) ||
|
|
1600
|
+
utils$3.isReadableStream(data)
|
|
1553
1601
|
) {
|
|
1554
1602
|
return data;
|
|
1555
1603
|
}
|
|
1556
|
-
if (utils$
|
|
1604
|
+
if (utils$3.isArrayBufferView(data)) {
|
|
1557
1605
|
return data.buffer;
|
|
1558
1606
|
}
|
|
1559
|
-
if (utils$
|
|
1607
|
+
if (utils$3.isURLSearchParams(data)) {
|
|
1560
1608
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1561
1609
|
return data.toString();
|
|
1562
1610
|
}
|
|
@@ -1568,7 +1616,7 @@ const defaults = {
|
|
|
1568
1616
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
1569
1617
|
}
|
|
1570
1618
|
|
|
1571
|
-
if ((isFileList = utils$
|
|
1619
|
+
if ((isFileList = utils$3.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1572
1620
|
const _FormData = this.env && this.env.FormData;
|
|
1573
1621
|
|
|
1574
1622
|
return toFormData(
|
|
@@ -1592,7 +1640,11 @@ const defaults = {
|
|
|
1592
1640
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1593
1641
|
const JSONRequested = this.responseType === 'json';
|
|
1594
1642
|
|
|
1595
|
-
if (
|
|
1643
|
+
if (utils$3.isResponse(data) || utils$3.isReadableStream(data)) {
|
|
1644
|
+
return data;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
if (data && utils$3.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
1596
1648
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1597
1649
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1598
1650
|
|
|
@@ -1634,24 +1686,21 @@ const defaults = {
|
|
|
1634
1686
|
|
|
1635
1687
|
headers: {
|
|
1636
1688
|
common: {
|
|
1637
|
-
'Accept': 'application/json, text/plain, */*'
|
|
1689
|
+
'Accept': 'application/json, text/plain, */*',
|
|
1690
|
+
'Content-Type': undefined
|
|
1638
1691
|
}
|
|
1639
1692
|
}
|
|
1640
1693
|
};
|
|
1641
1694
|
|
|
1642
|
-
utils$
|
|
1695
|
+
utils$3.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
1643
1696
|
defaults.headers[method] = {};
|
|
1644
1697
|
});
|
|
1645
1698
|
|
|
1646
|
-
utils$2.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
1647
|
-
defaults.headers[method] = utils$2.merge(DEFAULT_CONTENT_TYPE);
|
|
1648
|
-
});
|
|
1649
|
-
|
|
1650
1699
|
var defaults$1 = defaults;
|
|
1651
1700
|
|
|
1652
1701
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1653
1702
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1654
|
-
const ignoreDuplicateOf = utils$
|
|
1703
|
+
const ignoreDuplicateOf = utils$3.toObjectSet([
|
|
1655
1704
|
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
1656
1705
|
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
1657
1706
|
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
@@ -1712,7 +1761,7 @@ function normalizeValue(value) {
|
|
|
1712
1761
|
return value;
|
|
1713
1762
|
}
|
|
1714
1763
|
|
|
1715
|
-
return utils$
|
|
1764
|
+
return utils$3.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
1716
1765
|
}
|
|
1717
1766
|
|
|
1718
1767
|
function parseTokens(str) {
|
|
@@ -1730,7 +1779,7 @@ function parseTokens(str) {
|
|
|
1730
1779
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1731
1780
|
|
|
1732
1781
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1733
|
-
if (utils$
|
|
1782
|
+
if (utils$3.isFunction(filter)) {
|
|
1734
1783
|
return filter.call(this, value, header);
|
|
1735
1784
|
}
|
|
1736
1785
|
|
|
@@ -1738,13 +1787,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
|
1738
1787
|
value = header;
|
|
1739
1788
|
}
|
|
1740
1789
|
|
|
1741
|
-
if (!utils$
|
|
1790
|
+
if (!utils$3.isString(value)) return;
|
|
1742
1791
|
|
|
1743
|
-
if (utils$
|
|
1792
|
+
if (utils$3.isString(filter)) {
|
|
1744
1793
|
return value.indexOf(filter) !== -1;
|
|
1745
1794
|
}
|
|
1746
1795
|
|
|
1747
|
-
if (utils$
|
|
1796
|
+
if (utils$3.isRegExp(filter)) {
|
|
1748
1797
|
return filter.test(value);
|
|
1749
1798
|
}
|
|
1750
1799
|
}
|
|
@@ -1757,7 +1806,7 @@ function formatHeader(header) {
|
|
|
1757
1806
|
}
|
|
1758
1807
|
|
|
1759
1808
|
function buildAccessors(obj, header) {
|
|
1760
|
-
const accessorName = utils$
|
|
1809
|
+
const accessorName = utils$3.toCamelCase(' ' + header);
|
|
1761
1810
|
|
|
1762
1811
|
['get', 'set', 'has'].forEach(methodName => {
|
|
1763
1812
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
@@ -1784,7 +1833,7 @@ class AxiosHeaders {
|
|
|
1784
1833
|
throw new Error('header name must be a non-empty string');
|
|
1785
1834
|
}
|
|
1786
1835
|
|
|
1787
|
-
const key = utils$
|
|
1836
|
+
const key = utils$3.findKey(self, lHeader);
|
|
1788
1837
|
|
|
1789
1838
|
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
|
1790
1839
|
self[key || _header] = normalizeValue(_value);
|
|
@@ -1792,12 +1841,16 @@ class AxiosHeaders {
|
|
|
1792
1841
|
}
|
|
1793
1842
|
|
|
1794
1843
|
const setHeaders = (headers, _rewrite) =>
|
|
1795
|
-
utils$
|
|
1844
|
+
utils$3.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1796
1845
|
|
|
1797
|
-
if (utils$
|
|
1846
|
+
if (utils$3.isPlainObject(header) || header instanceof this.constructor) {
|
|
1798
1847
|
setHeaders(header, valueOrRewrite);
|
|
1799
|
-
} else if(utils$
|
|
1848
|
+
} else if(utils$3.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1800
1849
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1850
|
+
} else if (utils$3.isHeaders(header)) {
|
|
1851
|
+
for (const [key, value] of header.entries()) {
|
|
1852
|
+
setHeader(value, key, rewrite);
|
|
1853
|
+
}
|
|
1801
1854
|
} else {
|
|
1802
1855
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1803
1856
|
}
|
|
@@ -1809,7 +1862,7 @@ class AxiosHeaders {
|
|
|
1809
1862
|
header = normalizeHeader(header);
|
|
1810
1863
|
|
|
1811
1864
|
if (header) {
|
|
1812
|
-
const key = utils$
|
|
1865
|
+
const key = utils$3.findKey(this, header);
|
|
1813
1866
|
|
|
1814
1867
|
if (key) {
|
|
1815
1868
|
const value = this[key];
|
|
@@ -1822,11 +1875,11 @@ class AxiosHeaders {
|
|
|
1822
1875
|
return parseTokens(value);
|
|
1823
1876
|
}
|
|
1824
1877
|
|
|
1825
|
-
if (utils$
|
|
1878
|
+
if (utils$3.isFunction(parser)) {
|
|
1826
1879
|
return parser.call(this, value, key);
|
|
1827
1880
|
}
|
|
1828
1881
|
|
|
1829
|
-
if (utils$
|
|
1882
|
+
if (utils$3.isRegExp(parser)) {
|
|
1830
1883
|
return parser.exec(value);
|
|
1831
1884
|
}
|
|
1832
1885
|
|
|
@@ -1839,7 +1892,7 @@ class AxiosHeaders {
|
|
|
1839
1892
|
header = normalizeHeader(header);
|
|
1840
1893
|
|
|
1841
1894
|
if (header) {
|
|
1842
|
-
const key = utils$
|
|
1895
|
+
const key = utils$3.findKey(this, header);
|
|
1843
1896
|
|
|
1844
1897
|
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
1845
1898
|
}
|
|
@@ -1855,7 +1908,7 @@ class AxiosHeaders {
|
|
|
1855
1908
|
_header = normalizeHeader(_header);
|
|
1856
1909
|
|
|
1857
1910
|
if (_header) {
|
|
1858
|
-
const key = utils$
|
|
1911
|
+
const key = utils$3.findKey(self, _header);
|
|
1859
1912
|
|
|
1860
1913
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1861
1914
|
delete self[key];
|
|
@@ -1865,7 +1918,7 @@ class AxiosHeaders {
|
|
|
1865
1918
|
}
|
|
1866
1919
|
}
|
|
1867
1920
|
|
|
1868
|
-
if (utils$
|
|
1921
|
+
if (utils$3.isArray(header)) {
|
|
1869
1922
|
header.forEach(deleteHeader);
|
|
1870
1923
|
} else {
|
|
1871
1924
|
deleteHeader(header);
|
|
@@ -1894,8 +1947,8 @@ class AxiosHeaders {
|
|
|
1894
1947
|
const self = this;
|
|
1895
1948
|
const headers = {};
|
|
1896
1949
|
|
|
1897
|
-
utils$
|
|
1898
|
-
const key = utils$
|
|
1950
|
+
utils$3.forEach(this, (value, header) => {
|
|
1951
|
+
const key = utils$3.findKey(headers, header);
|
|
1899
1952
|
|
|
1900
1953
|
if (key) {
|
|
1901
1954
|
self[key] = normalizeValue(value);
|
|
@@ -1924,8 +1977,8 @@ class AxiosHeaders {
|
|
|
1924
1977
|
toJSON(asStrings) {
|
|
1925
1978
|
const obj = Object.create(null);
|
|
1926
1979
|
|
|
1927
|
-
utils$
|
|
1928
|
-
value != null && value !== false && (obj[header] = asStrings && utils$
|
|
1980
|
+
utils$3.forEach(this, (value, header) => {
|
|
1981
|
+
value != null && value !== false && (obj[header] = asStrings && utils$3.isArray(value) ? value.join(', ') : value);
|
|
1929
1982
|
});
|
|
1930
1983
|
|
|
1931
1984
|
return obj;
|
|
@@ -1972,7 +2025,7 @@ class AxiosHeaders {
|
|
|
1972
2025
|
}
|
|
1973
2026
|
}
|
|
1974
2027
|
|
|
1975
|
-
utils$
|
|
2028
|
+
utils$3.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1976
2029
|
|
|
1977
2030
|
return this;
|
|
1978
2031
|
}
|
|
@@ -1980,8 +2033,18 @@ class AxiosHeaders {
|
|
|
1980
2033
|
|
|
1981
2034
|
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|
1982
2035
|
|
|
1983
|
-
|
|
1984
|
-
utils$
|
|
2036
|
+
// reserved names hotfix
|
|
2037
|
+
utils$3.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
2038
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2039
|
+
return {
|
|
2040
|
+
get: () => value,
|
|
2041
|
+
set(headerValue) {
|
|
2042
|
+
this[mapped] = headerValue;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
});
|
|
2046
|
+
|
|
2047
|
+
utils$3.freezeMethods(AxiosHeaders);
|
|
1985
2048
|
|
|
1986
2049
|
var AxiosHeaders$1 = AxiosHeaders;
|
|
1987
2050
|
|
|
@@ -1999,7 +2062,7 @@ function transformData(fns, response) {
|
|
|
1999
2062
|
const headers = AxiosHeaders$1.from(context.headers);
|
|
2000
2063
|
let data = context.data;
|
|
2001
2064
|
|
|
2002
|
-
utils$
|
|
2065
|
+
utils$3.forEach(fns, function transform(fn) {
|
|
2003
2066
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
2004
2067
|
});
|
|
2005
2068
|
|
|
@@ -2027,7 +2090,7 @@ function CanceledError(message, config, request) {
|
|
|
2027
2090
|
this.name = 'CanceledError';
|
|
2028
2091
|
}
|
|
2029
2092
|
|
|
2030
|
-
utils$
|
|
2093
|
+
utils$3.inherits(CanceledError, AxiosError, {
|
|
2031
2094
|
__CANCEL__: true
|
|
2032
2095
|
});
|
|
2033
2096
|
|
|
@@ -2055,100 +2118,148 @@ function settle(resolve, reject, response) {
|
|
|
2055
2118
|
}
|
|
2056
2119
|
}
|
|
2057
2120
|
|
|
2058
|
-
|
|
2121
|
+
function parseProtocol(url) {
|
|
2122
|
+
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
2123
|
+
return match && match[1] || '';
|
|
2124
|
+
}
|
|
2059
2125
|
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2126
|
+
/**
|
|
2127
|
+
* Calculate data maxRate
|
|
2128
|
+
* @param {Number} [samplesCount= 10]
|
|
2129
|
+
* @param {Number} [min= 1000]
|
|
2130
|
+
* @returns {Function}
|
|
2131
|
+
*/
|
|
2132
|
+
function speedometer(samplesCount, min) {
|
|
2133
|
+
samplesCount = samplesCount || 10;
|
|
2134
|
+
const bytes = new Array(samplesCount);
|
|
2135
|
+
const timestamps = new Array(samplesCount);
|
|
2136
|
+
let head = 0;
|
|
2137
|
+
let tail = 0;
|
|
2138
|
+
let firstSampleTS;
|
|
2066
2139
|
|
|
2067
|
-
|
|
2068
|
-
cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2069
|
-
}
|
|
2140
|
+
min = min !== undefined ? min : 1000;
|
|
2070
2141
|
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
}
|
|
2142
|
+
return function push(chunkLength) {
|
|
2143
|
+
const now = Date.now();
|
|
2074
2144
|
|
|
2075
|
-
|
|
2076
|
-
cookie.push('domain=' + domain);
|
|
2077
|
-
}
|
|
2145
|
+
const startedAt = timestamps[tail];
|
|
2078
2146
|
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2147
|
+
if (!firstSampleTS) {
|
|
2148
|
+
firstSampleTS = now;
|
|
2149
|
+
}
|
|
2082
2150
|
|
|
2083
|
-
|
|
2084
|
-
|
|
2151
|
+
bytes[head] = chunkLength;
|
|
2152
|
+
timestamps[head] = now;
|
|
2085
2153
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
return (match ? decodeURIComponent(match[3]) : null);
|
|
2089
|
-
},
|
|
2154
|
+
let i = tail;
|
|
2155
|
+
let bytesCount = 0;
|
|
2090
2156
|
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
}
|
|
2095
|
-
})() :
|
|
2157
|
+
while (i !== head) {
|
|
2158
|
+
bytesCount += bytes[i++];
|
|
2159
|
+
i = i % samplesCount;
|
|
2160
|
+
}
|
|
2096
2161
|
|
|
2097
|
-
|
|
2098
|
-
(function nonStandardBrowserEnv() {
|
|
2099
|
-
return {
|
|
2100
|
-
write: function write() {},
|
|
2101
|
-
read: function read() { return null; },
|
|
2102
|
-
remove: function remove() {}
|
|
2103
|
-
};
|
|
2104
|
-
})();
|
|
2162
|
+
head = (head + 1) % samplesCount;
|
|
2105
2163
|
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
* @param {string} url The URL to test
|
|
2110
|
-
*
|
|
2111
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
2112
|
-
*/
|
|
2113
|
-
function isAbsoluteURL(url) {
|
|
2114
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
2115
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
2116
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
|
2117
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
2118
|
-
}
|
|
2164
|
+
if (head === tail) {
|
|
2165
|
+
tail = (tail + 1) % samplesCount;
|
|
2166
|
+
}
|
|
2119
2167
|
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
*
|
|
2127
|
-
|
|
2128
|
-
function combineURLs(baseURL, relativeURL) {
|
|
2129
|
-
return relativeURL
|
|
2130
|
-
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
2131
|
-
: baseURL;
|
|
2168
|
+
if (now - firstSampleTS < min) {
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
const passed = startedAt && now - startedAt;
|
|
2173
|
+
|
|
2174
|
+
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
2175
|
+
};
|
|
2132
2176
|
}
|
|
2133
2177
|
|
|
2134
2178
|
/**
|
|
2135
|
-
*
|
|
2136
|
-
*
|
|
2137
|
-
*
|
|
2138
|
-
*
|
|
2139
|
-
* @param {string} baseURL The base URL
|
|
2140
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
|
2141
|
-
*
|
|
2142
|
-
* @returns {string} The combined full path
|
|
2179
|
+
* Throttle decorator
|
|
2180
|
+
* @param {Function} fn
|
|
2181
|
+
* @param {Number} freq
|
|
2182
|
+
* @return {Function}
|
|
2143
2183
|
*/
|
|
2144
|
-
function
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2184
|
+
function throttle(fn, freq) {
|
|
2185
|
+
let timestamp = 0;
|
|
2186
|
+
let threshold = 1000 / freq;
|
|
2187
|
+
let lastArgs;
|
|
2188
|
+
let timer;
|
|
2189
|
+
|
|
2190
|
+
const invoke = (args, now = Date.now()) => {
|
|
2191
|
+
timestamp = now;
|
|
2192
|
+
lastArgs = null;
|
|
2193
|
+
if (timer) {
|
|
2194
|
+
clearTimeout(timer);
|
|
2195
|
+
timer = null;
|
|
2196
|
+
}
|
|
2197
|
+
fn.apply(null, args);
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2200
|
+
const throttled = (...args) => {
|
|
2201
|
+
const now = Date.now();
|
|
2202
|
+
const passed = now - timestamp;
|
|
2203
|
+
if ( passed >= threshold) {
|
|
2204
|
+
invoke(args, now);
|
|
2205
|
+
} else {
|
|
2206
|
+
lastArgs = args;
|
|
2207
|
+
if (!timer) {
|
|
2208
|
+
timer = setTimeout(() => {
|
|
2209
|
+
timer = null;
|
|
2210
|
+
invoke(lastArgs);
|
|
2211
|
+
}, threshold - passed);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
|
|
2216
|
+
const flush = () => lastArgs && invoke(lastArgs);
|
|
2217
|
+
|
|
2218
|
+
return [throttled, flush];
|
|
2149
2219
|
}
|
|
2150
2220
|
|
|
2151
|
-
|
|
2221
|
+
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
2222
|
+
let bytesNotified = 0;
|
|
2223
|
+
const _speedometer = speedometer(50, 250);
|
|
2224
|
+
|
|
2225
|
+
return throttle(e => {
|
|
2226
|
+
const loaded = e.loaded;
|
|
2227
|
+
const total = e.lengthComputable ? e.total : undefined;
|
|
2228
|
+
const progressBytes = loaded - bytesNotified;
|
|
2229
|
+
const rate = _speedometer(progressBytes);
|
|
2230
|
+
const inRange = loaded <= total;
|
|
2231
|
+
|
|
2232
|
+
bytesNotified = loaded;
|
|
2233
|
+
|
|
2234
|
+
const data = {
|
|
2235
|
+
loaded,
|
|
2236
|
+
total,
|
|
2237
|
+
progress: total ? (loaded / total) : undefined,
|
|
2238
|
+
bytes: progressBytes,
|
|
2239
|
+
rate: rate ? rate : undefined,
|
|
2240
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
2241
|
+
event: e,
|
|
2242
|
+
lengthComputable: total != null,
|
|
2243
|
+
[isDownloadStream ? 'download' : 'upload']: true
|
|
2244
|
+
};
|
|
2245
|
+
|
|
2246
|
+
listener(data);
|
|
2247
|
+
}, freq);
|
|
2248
|
+
};
|
|
2249
|
+
|
|
2250
|
+
const progressEventDecorator = (total, throttled) => {
|
|
2251
|
+
const lengthComputable = total != null;
|
|
2252
|
+
|
|
2253
|
+
return [(loaded) => throttled[0]({
|
|
2254
|
+
lengthComputable,
|
|
2255
|
+
total,
|
|
2256
|
+
loaded
|
|
2257
|
+
}), throttled[1]];
|
|
2258
|
+
};
|
|
2259
|
+
|
|
2260
|
+
const asyncDecorator = (fn) => (...args) => utils$3.asap(() => fn(...args));
|
|
2261
|
+
|
|
2262
|
+
var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
2152
2263
|
|
|
2153
2264
|
// Standard browser envs have full support of the APIs needed to test
|
|
2154
2265
|
// whether the request URL is of the same origin as current location.
|
|
@@ -2158,7 +2269,7 @@ var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
|
|
2158
2269
|
let originURL;
|
|
2159
2270
|
|
|
2160
2271
|
/**
|
|
2161
|
-
* Parse a URL to discover
|
|
2272
|
+
* Parse a URL to discover its components
|
|
2162
2273
|
*
|
|
2163
2274
|
* @param {String} url The URL to be parsed
|
|
2164
2275
|
* @returns {Object}
|
|
@@ -2198,7 +2309,7 @@ var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
|
|
2198
2309
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
|
2199
2310
|
*/
|
|
2200
2311
|
return function isURLSameOrigin(requestURL) {
|
|
2201
|
-
const parsed = (utils$
|
|
2312
|
+
const parsed = (utils$3.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
2202
2313
|
return (parsed.protocol === originURL.protocol &&
|
|
2203
2314
|
parsed.host === originURL.host);
|
|
2204
2315
|
};
|
|
@@ -2211,129 +2322,267 @@ var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
|
|
2211
2322
|
};
|
|
2212
2323
|
})();
|
|
2213
2324
|
|
|
2214
|
-
|
|
2215
|
-
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
2216
|
-
return match && match[1] || '';
|
|
2217
|
-
}
|
|
2325
|
+
var cookies = platform.hasStandardBrowserEnv ?
|
|
2218
2326
|
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
* @returns {Function}
|
|
2224
|
-
*/
|
|
2225
|
-
function speedometer(samplesCount, min) {
|
|
2226
|
-
samplesCount = samplesCount || 10;
|
|
2227
|
-
const bytes = new Array(samplesCount);
|
|
2228
|
-
const timestamps = new Array(samplesCount);
|
|
2229
|
-
let head = 0;
|
|
2230
|
-
let tail = 0;
|
|
2231
|
-
let firstSampleTS;
|
|
2327
|
+
// Standard browser envs support document.cookie
|
|
2328
|
+
{
|
|
2329
|
+
write(name, value, expires, path, domain, secure) {
|
|
2330
|
+
const cookie = [name + '=' + encodeURIComponent(value)];
|
|
2232
2331
|
|
|
2233
|
-
|
|
2332
|
+
utils$3.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2234
2333
|
|
|
2235
|
-
|
|
2236
|
-
const now = Date.now();
|
|
2334
|
+
utils$3.isString(path) && cookie.push('path=' + path);
|
|
2237
2335
|
|
|
2238
|
-
|
|
2336
|
+
utils$3.isString(domain) && cookie.push('domain=' + domain);
|
|
2239
2337
|
|
|
2240
|
-
|
|
2241
|
-
firstSampleTS = now;
|
|
2242
|
-
}
|
|
2338
|
+
secure === true && cookie.push('secure');
|
|
2243
2339
|
|
|
2244
|
-
|
|
2245
|
-
|
|
2340
|
+
document.cookie = cookie.join('; ');
|
|
2341
|
+
},
|
|
2246
2342
|
|
|
2247
|
-
|
|
2248
|
-
|
|
2343
|
+
read(name) {
|
|
2344
|
+
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
2345
|
+
return (match ? decodeURIComponent(match[3]) : null);
|
|
2346
|
+
},
|
|
2249
2347
|
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
i = i % samplesCount;
|
|
2348
|
+
remove(name) {
|
|
2349
|
+
this.write(name, '', Date.now() - 86400000);
|
|
2253
2350
|
}
|
|
2351
|
+
}
|
|
2254
2352
|
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
if (head === tail) {
|
|
2258
|
-
tail = (tail + 1) % samplesCount;
|
|
2259
|
-
}
|
|
2353
|
+
:
|
|
2260
2354
|
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
}
|
|
2355
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
2356
|
+
{
|
|
2357
|
+
write() {},
|
|
2358
|
+
read() {
|
|
2359
|
+
return null;
|
|
2360
|
+
},
|
|
2361
|
+
remove() {}
|
|
2362
|
+
};
|
|
2264
2363
|
|
|
2265
|
-
|
|
2364
|
+
/**
|
|
2365
|
+
* Determines whether the specified URL is absolute
|
|
2366
|
+
*
|
|
2367
|
+
* @param {string} url The URL to test
|
|
2368
|
+
*
|
|
2369
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
2370
|
+
*/
|
|
2371
|
+
function isAbsoluteURL(url) {
|
|
2372
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
2373
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
2374
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
|
2375
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
2376
|
+
}
|
|
2266
2377
|
|
|
2267
|
-
|
|
2268
|
-
|
|
2378
|
+
/**
|
|
2379
|
+
* Creates a new URL by combining the specified URLs
|
|
2380
|
+
*
|
|
2381
|
+
* @param {string} baseURL The base URL
|
|
2382
|
+
* @param {string} relativeURL The relative URL
|
|
2383
|
+
*
|
|
2384
|
+
* @returns {string} The combined URL
|
|
2385
|
+
*/
|
|
2386
|
+
function combineURLs(baseURL, relativeURL) {
|
|
2387
|
+
return relativeURL
|
|
2388
|
+
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
2389
|
+
: baseURL;
|
|
2269
2390
|
}
|
|
2270
2391
|
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2392
|
+
/**
|
|
2393
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
2394
|
+
* only when the requestedURL is not already an absolute URL.
|
|
2395
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
2396
|
+
*
|
|
2397
|
+
* @param {string} baseURL The base URL
|
|
2398
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
|
2399
|
+
*
|
|
2400
|
+
* @returns {string} The combined full path
|
|
2401
|
+
*/
|
|
2402
|
+
function buildFullPath(baseURL, requestedURL) {
|
|
2403
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
2404
|
+
return combineURLs(baseURL, requestedURL);
|
|
2405
|
+
}
|
|
2406
|
+
return requestedURL;
|
|
2407
|
+
}
|
|
2274
2408
|
|
|
2275
|
-
|
|
2276
|
-
const loaded = e.loaded;
|
|
2277
|
-
const total = e.lengthComputable ? e.total : undefined;
|
|
2278
|
-
const progressBytes = loaded - bytesNotified;
|
|
2279
|
-
const rate = _speedometer(progressBytes);
|
|
2280
|
-
const inRange = loaded <= total;
|
|
2409
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
2281
2410
|
|
|
2282
|
-
|
|
2411
|
+
/**
|
|
2412
|
+
* Config-specific merge-function which creates a new config-object
|
|
2413
|
+
* by merging two configuration objects together.
|
|
2414
|
+
*
|
|
2415
|
+
* @param {Object} config1
|
|
2416
|
+
* @param {Object} config2
|
|
2417
|
+
*
|
|
2418
|
+
* @returns {Object} New object resulting from merging config2 to config1
|
|
2419
|
+
*/
|
|
2420
|
+
function mergeConfig(config1, config2) {
|
|
2421
|
+
// eslint-disable-next-line no-param-reassign
|
|
2422
|
+
config2 = config2 || {};
|
|
2423
|
+
const config = {};
|
|
2283
2424
|
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2425
|
+
function getMergedValue(target, source, caseless) {
|
|
2426
|
+
if (utils$3.isPlainObject(target) && utils$3.isPlainObject(source)) {
|
|
2427
|
+
return utils$3.merge.call({caseless}, target, source);
|
|
2428
|
+
} else if (utils$3.isPlainObject(source)) {
|
|
2429
|
+
return utils$3.merge({}, source);
|
|
2430
|
+
} else if (utils$3.isArray(source)) {
|
|
2431
|
+
return source.slice();
|
|
2432
|
+
}
|
|
2433
|
+
return source;
|
|
2434
|
+
}
|
|
2293
2435
|
|
|
2294
|
-
|
|
2436
|
+
// eslint-disable-next-line consistent-return
|
|
2437
|
+
function mergeDeepProperties(a, b, caseless) {
|
|
2438
|
+
if (!utils$3.isUndefined(b)) {
|
|
2439
|
+
return getMergedValue(a, b, caseless);
|
|
2440
|
+
} else if (!utils$3.isUndefined(a)) {
|
|
2441
|
+
return getMergedValue(undefined, a, caseless);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2295
2444
|
|
|
2296
|
-
|
|
2445
|
+
// eslint-disable-next-line consistent-return
|
|
2446
|
+
function valueFromConfig2(a, b) {
|
|
2447
|
+
if (!utils$3.isUndefined(b)) {
|
|
2448
|
+
return getMergedValue(undefined, b);
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
// eslint-disable-next-line consistent-return
|
|
2453
|
+
function defaultToConfig2(a, b) {
|
|
2454
|
+
if (!utils$3.isUndefined(b)) {
|
|
2455
|
+
return getMergedValue(undefined, b);
|
|
2456
|
+
} else if (!utils$3.isUndefined(a)) {
|
|
2457
|
+
return getMergedValue(undefined, a);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
// eslint-disable-next-line consistent-return
|
|
2462
|
+
function mergeDirectKeys(a, b, prop) {
|
|
2463
|
+
if (prop in config2) {
|
|
2464
|
+
return getMergedValue(a, b);
|
|
2465
|
+
} else if (prop in config1) {
|
|
2466
|
+
return getMergedValue(undefined, a);
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
const mergeMap = {
|
|
2471
|
+
url: valueFromConfig2,
|
|
2472
|
+
method: valueFromConfig2,
|
|
2473
|
+
data: valueFromConfig2,
|
|
2474
|
+
baseURL: defaultToConfig2,
|
|
2475
|
+
transformRequest: defaultToConfig2,
|
|
2476
|
+
transformResponse: defaultToConfig2,
|
|
2477
|
+
paramsSerializer: defaultToConfig2,
|
|
2478
|
+
timeout: defaultToConfig2,
|
|
2479
|
+
timeoutMessage: defaultToConfig2,
|
|
2480
|
+
withCredentials: defaultToConfig2,
|
|
2481
|
+
withXSRFToken: defaultToConfig2,
|
|
2482
|
+
adapter: defaultToConfig2,
|
|
2483
|
+
responseType: defaultToConfig2,
|
|
2484
|
+
xsrfCookieName: defaultToConfig2,
|
|
2485
|
+
xsrfHeaderName: defaultToConfig2,
|
|
2486
|
+
onUploadProgress: defaultToConfig2,
|
|
2487
|
+
onDownloadProgress: defaultToConfig2,
|
|
2488
|
+
decompress: defaultToConfig2,
|
|
2489
|
+
maxContentLength: defaultToConfig2,
|
|
2490
|
+
maxBodyLength: defaultToConfig2,
|
|
2491
|
+
beforeRedirect: defaultToConfig2,
|
|
2492
|
+
transport: defaultToConfig2,
|
|
2493
|
+
httpAgent: defaultToConfig2,
|
|
2494
|
+
httpsAgent: defaultToConfig2,
|
|
2495
|
+
cancelToken: defaultToConfig2,
|
|
2496
|
+
socketPath: defaultToConfig2,
|
|
2497
|
+
responseEncoding: defaultToConfig2,
|
|
2498
|
+
validateStatus: mergeDirectKeys,
|
|
2499
|
+
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
2297
2500
|
};
|
|
2501
|
+
|
|
2502
|
+
utils$3.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
2503
|
+
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
2504
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2505
|
+
(utils$3.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2506
|
+
});
|
|
2507
|
+
|
|
2508
|
+
return config;
|
|
2298
2509
|
}
|
|
2299
2510
|
|
|
2511
|
+
var resolveConfig = (config) => {
|
|
2512
|
+
const newConfig = mergeConfig({}, config);
|
|
2513
|
+
|
|
2514
|
+
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
2515
|
+
|
|
2516
|
+
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2517
|
+
|
|
2518
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
|
2519
|
+
|
|
2520
|
+
// HTTP basic authentication
|
|
2521
|
+
if (auth) {
|
|
2522
|
+
headers.set('Authorization', 'Basic ' +
|
|
2523
|
+
btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
|
|
2524
|
+
);
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
let contentType;
|
|
2528
|
+
|
|
2529
|
+
if (utils$3.isFormData(data)) {
|
|
2530
|
+
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
2531
|
+
headers.setContentType(undefined); // Let the browser set it
|
|
2532
|
+
} else if ((contentType = headers.getContentType()) !== false) {
|
|
2533
|
+
// fix semicolon duplication issue for ReactNative FormData implementation
|
|
2534
|
+
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
|
2535
|
+
headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
// Add xsrf header
|
|
2540
|
+
// This is only done if running in a standard browser environment.
|
|
2541
|
+
// Specifically not if we're in a web worker, or react-native.
|
|
2542
|
+
|
|
2543
|
+
if (platform.hasStandardBrowserEnv) {
|
|
2544
|
+
withXSRFToken && utils$3.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
2545
|
+
|
|
2546
|
+
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
|
2547
|
+
// Add xsrf header
|
|
2548
|
+
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
2549
|
+
|
|
2550
|
+
if (xsrfValue) {
|
|
2551
|
+
headers.set(xsrfHeaderName, xsrfValue);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
return newConfig;
|
|
2557
|
+
};
|
|
2558
|
+
|
|
2300
2559
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
2301
2560
|
|
|
2302
2561
|
var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
2303
2562
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
const
|
|
2563
|
+
const _config = resolveConfig(config);
|
|
2564
|
+
let requestData = _config.data;
|
|
2565
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
2566
|
+
let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
|
2307
2567
|
let onCanceled;
|
|
2568
|
+
let uploadThrottled, downloadThrottled;
|
|
2569
|
+
let flushUpload, flushDownload;
|
|
2570
|
+
|
|
2308
2571
|
function done() {
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
}
|
|
2572
|
+
flushUpload && flushUpload(); // flush events
|
|
2573
|
+
flushDownload && flushDownload(); // flush events
|
|
2312
2574
|
|
|
2313
|
-
|
|
2314
|
-
config.signal.removeEventListener('abort', onCanceled);
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2575
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
2317
2576
|
|
|
2318
|
-
|
|
2319
|
-
requestHeaders.setContentType(false); // Let the browser set it
|
|
2577
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
2320
2578
|
}
|
|
2321
2579
|
|
|
2322
2580
|
let request = new XMLHttpRequest();
|
|
2323
2581
|
|
|
2324
|
-
|
|
2325
|
-
if (config.auth) {
|
|
2326
|
-
const username = config.auth.username || '';
|
|
2327
|
-
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
|
2328
|
-
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
|
|
2329
|
-
}
|
|
2330
|
-
|
|
2331
|
-
const fullPath = buildFullPath(config.baseURL, config.url);
|
|
2332
|
-
|
|
2333
|
-
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
|
2582
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
2334
2583
|
|
|
2335
2584
|
// Set the request timeout in MS
|
|
2336
|
-
request.timeout =
|
|
2585
|
+
request.timeout = _config.timeout;
|
|
2337
2586
|
|
|
2338
2587
|
function onloadend() {
|
|
2339
2588
|
if (!request) {
|
|
@@ -2413,10 +2662,10 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2413
2662
|
|
|
2414
2663
|
// Handle timeout
|
|
2415
2664
|
request.ontimeout = function handleTimeout() {
|
|
2416
|
-
let timeoutErrorMessage =
|
|
2417
|
-
const transitional =
|
|
2418
|
-
if (
|
|
2419
|
-
timeoutErrorMessage =
|
|
2665
|
+
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
2666
|
+
const transitional = _config.transitional || transitionalDefaults;
|
|
2667
|
+
if (_config.timeoutErrorMessage) {
|
|
2668
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2420
2669
|
}
|
|
2421
2670
|
reject(new AxiosError(
|
|
2422
2671
|
timeoutErrorMessage,
|
|
@@ -2428,50 +2677,42 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2428
2677
|
request = null;
|
|
2429
2678
|
};
|
|
2430
2679
|
|
|
2431
|
-
// Add xsrf header
|
|
2432
|
-
// This is only done if running in a standard browser environment.
|
|
2433
|
-
// Specifically not if we're in a web worker, or react-native.
|
|
2434
|
-
if (platform.isStandardBrowserEnv) {
|
|
2435
|
-
// Add xsrf header
|
|
2436
|
-
const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
|
|
2437
|
-
&& config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
|
2438
|
-
|
|
2439
|
-
if (xsrfValue) {
|
|
2440
|
-
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
|
2441
|
-
}
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
2680
|
// Remove Content-Type if data is undefined
|
|
2445
2681
|
requestData === undefined && requestHeaders.setContentType(null);
|
|
2446
2682
|
|
|
2447
2683
|
// Add headers to the request
|
|
2448
2684
|
if ('setRequestHeader' in request) {
|
|
2449
|
-
utils$
|
|
2685
|
+
utils$3.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
2450
2686
|
request.setRequestHeader(key, val);
|
|
2451
2687
|
});
|
|
2452
2688
|
}
|
|
2453
2689
|
|
|
2454
2690
|
// Add withCredentials to request if needed
|
|
2455
|
-
if (!utils$
|
|
2456
|
-
request.withCredentials = !!
|
|
2691
|
+
if (!utils$3.isUndefined(_config.withCredentials)) {
|
|
2692
|
+
request.withCredentials = !!_config.withCredentials;
|
|
2457
2693
|
}
|
|
2458
2694
|
|
|
2459
2695
|
// Add responseType to request if needed
|
|
2460
2696
|
if (responseType && responseType !== 'json') {
|
|
2461
|
-
request.responseType =
|
|
2697
|
+
request.responseType = _config.responseType;
|
|
2462
2698
|
}
|
|
2463
2699
|
|
|
2464
2700
|
// Handle progress if needed
|
|
2465
|
-
if (
|
|
2466
|
-
|
|
2701
|
+
if (onDownloadProgress) {
|
|
2702
|
+
([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
|
|
2703
|
+
request.addEventListener('progress', downloadThrottled);
|
|
2467
2704
|
}
|
|
2468
2705
|
|
|
2469
2706
|
// Not all browsers support upload events
|
|
2470
|
-
if (
|
|
2471
|
-
|
|
2707
|
+
if (onUploadProgress && request.upload) {
|
|
2708
|
+
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
2709
|
+
|
|
2710
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
2711
|
+
|
|
2712
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
2472
2713
|
}
|
|
2473
2714
|
|
|
2474
|
-
if (
|
|
2715
|
+
if (_config.cancelToken || _config.signal) {
|
|
2475
2716
|
// Handle cancellation
|
|
2476
2717
|
// eslint-disable-next-line func-names
|
|
2477
2718
|
onCanceled = cancel => {
|
|
@@ -2483,13 +2724,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2483
2724
|
request = null;
|
|
2484
2725
|
};
|
|
2485
2726
|
|
|
2486
|
-
|
|
2487
|
-
if (
|
|
2488
|
-
|
|
2727
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
2728
|
+
if (_config.signal) {
|
|
2729
|
+
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
2489
2730
|
}
|
|
2490
2731
|
}
|
|
2491
2732
|
|
|
2492
|
-
const protocol = parseProtocol(
|
|
2733
|
+
const protocol = parseProtocol(_config.url);
|
|
2493
2734
|
|
|
2494
2735
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
2495
2736
|
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|
@@ -2502,13 +2743,343 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2502
2743
|
});
|
|
2503
2744
|
};
|
|
2504
2745
|
|
|
2746
|
+
const composeSignals = (signals, timeout) => {
|
|
2747
|
+
let controller = new AbortController();
|
|
2748
|
+
|
|
2749
|
+
let aborted;
|
|
2750
|
+
|
|
2751
|
+
const onabort = function (cancel) {
|
|
2752
|
+
if (!aborted) {
|
|
2753
|
+
aborted = true;
|
|
2754
|
+
unsubscribe();
|
|
2755
|
+
const err = cancel instanceof Error ? cancel : this.reason;
|
|
2756
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
2757
|
+
}
|
|
2758
|
+
};
|
|
2759
|
+
|
|
2760
|
+
let timer = timeout && setTimeout(() => {
|
|
2761
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
2762
|
+
}, timeout);
|
|
2763
|
+
|
|
2764
|
+
const unsubscribe = () => {
|
|
2765
|
+
if (signals) {
|
|
2766
|
+
timer && clearTimeout(timer);
|
|
2767
|
+
timer = null;
|
|
2768
|
+
signals.forEach(signal => {
|
|
2769
|
+
signal &&
|
|
2770
|
+
(signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
|
|
2771
|
+
});
|
|
2772
|
+
signals = null;
|
|
2773
|
+
}
|
|
2774
|
+
};
|
|
2775
|
+
|
|
2776
|
+
signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
|
|
2777
|
+
|
|
2778
|
+
const {signal} = controller;
|
|
2779
|
+
|
|
2780
|
+
signal.unsubscribe = unsubscribe;
|
|
2781
|
+
|
|
2782
|
+
return [signal, () => {
|
|
2783
|
+
timer && clearTimeout(timer);
|
|
2784
|
+
timer = null;
|
|
2785
|
+
}];
|
|
2786
|
+
};
|
|
2787
|
+
|
|
2788
|
+
var composeSignals$1 = composeSignals;
|
|
2789
|
+
|
|
2790
|
+
const streamChunk = function* (chunk, chunkSize) {
|
|
2791
|
+
let len = chunk.byteLength;
|
|
2792
|
+
|
|
2793
|
+
if (!chunkSize || len < chunkSize) {
|
|
2794
|
+
yield chunk;
|
|
2795
|
+
return;
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
let pos = 0;
|
|
2799
|
+
let end;
|
|
2800
|
+
|
|
2801
|
+
while (pos < len) {
|
|
2802
|
+
end = pos + chunkSize;
|
|
2803
|
+
yield chunk.slice(pos, end);
|
|
2804
|
+
pos = end;
|
|
2805
|
+
}
|
|
2806
|
+
};
|
|
2807
|
+
|
|
2808
|
+
const readBytes = async function* (iterable, chunkSize, encode) {
|
|
2809
|
+
for await (const chunk of iterable) {
|
|
2810
|
+
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
|
|
2811
|
+
}
|
|
2812
|
+
};
|
|
2813
|
+
|
|
2814
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
|
2815
|
+
const iterator = readBytes(stream, chunkSize, encode);
|
|
2816
|
+
|
|
2817
|
+
let bytes = 0;
|
|
2818
|
+
let done;
|
|
2819
|
+
let _onFinish = (e) => {
|
|
2820
|
+
if (!done) {
|
|
2821
|
+
done = true;
|
|
2822
|
+
onFinish && onFinish(e);
|
|
2823
|
+
}
|
|
2824
|
+
};
|
|
2825
|
+
|
|
2826
|
+
return new ReadableStream({
|
|
2827
|
+
async pull(controller) {
|
|
2828
|
+
try {
|
|
2829
|
+
const {done, value} = await iterator.next();
|
|
2830
|
+
|
|
2831
|
+
if (done) {
|
|
2832
|
+
_onFinish();
|
|
2833
|
+
controller.close();
|
|
2834
|
+
return;
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
let len = value.byteLength;
|
|
2838
|
+
if (onProgress) {
|
|
2839
|
+
let loadedBytes = bytes += len;
|
|
2840
|
+
onProgress(loadedBytes);
|
|
2841
|
+
}
|
|
2842
|
+
controller.enqueue(new Uint8Array(value));
|
|
2843
|
+
} catch (err) {
|
|
2844
|
+
_onFinish(err);
|
|
2845
|
+
throw err;
|
|
2846
|
+
}
|
|
2847
|
+
},
|
|
2848
|
+
cancel(reason) {
|
|
2849
|
+
_onFinish(reason);
|
|
2850
|
+
return iterator.return();
|
|
2851
|
+
}
|
|
2852
|
+
}, {
|
|
2853
|
+
highWaterMark: 2
|
|
2854
|
+
})
|
|
2855
|
+
};
|
|
2856
|
+
|
|
2857
|
+
const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
|
|
2858
|
+
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
|
|
2859
|
+
|
|
2860
|
+
// used only inside the fetch adapter
|
|
2861
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
2862
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
2863
|
+
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
2864
|
+
);
|
|
2865
|
+
|
|
2866
|
+
const test = (fn, ...args) => {
|
|
2867
|
+
try {
|
|
2868
|
+
return !!fn(...args);
|
|
2869
|
+
} catch (e) {
|
|
2870
|
+
return false
|
|
2871
|
+
}
|
|
2872
|
+
};
|
|
2873
|
+
|
|
2874
|
+
const supportsRequestStream = isReadableStreamSupported && test(() => {
|
|
2875
|
+
let duplexAccessed = false;
|
|
2876
|
+
|
|
2877
|
+
const hasContentType = new Request(platform.origin, {
|
|
2878
|
+
body: new ReadableStream(),
|
|
2879
|
+
method: 'POST',
|
|
2880
|
+
get duplex() {
|
|
2881
|
+
duplexAccessed = true;
|
|
2882
|
+
return 'half';
|
|
2883
|
+
},
|
|
2884
|
+
}).headers.has('Content-Type');
|
|
2885
|
+
|
|
2886
|
+
return duplexAccessed && !hasContentType;
|
|
2887
|
+
});
|
|
2888
|
+
|
|
2889
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
2890
|
+
|
|
2891
|
+
const supportsResponseStream = isReadableStreamSupported &&
|
|
2892
|
+
test(() => utils$3.isReadableStream(new Response('').body));
|
|
2893
|
+
|
|
2894
|
+
|
|
2895
|
+
const resolvers = {
|
|
2896
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
2897
|
+
};
|
|
2898
|
+
|
|
2899
|
+
isFetchSupported && (((res) => {
|
|
2900
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
2901
|
+
!resolvers[type] && (resolvers[type] = utils$3.isFunction(res[type]) ? (res) => res[type]() :
|
|
2902
|
+
(_, config) => {
|
|
2903
|
+
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
2904
|
+
});
|
|
2905
|
+
});
|
|
2906
|
+
})(new Response));
|
|
2907
|
+
|
|
2908
|
+
const getBodyLength = async (body) => {
|
|
2909
|
+
if (body == null) {
|
|
2910
|
+
return 0;
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
if(utils$3.isBlob(body)) {
|
|
2914
|
+
return body.size;
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2917
|
+
if(utils$3.isSpecCompliantForm(body)) {
|
|
2918
|
+
return (await new Request(body).arrayBuffer()).byteLength;
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
if(utils$3.isArrayBufferView(body) || utils$3.isArrayBuffer(body)) {
|
|
2922
|
+
return body.byteLength;
|
|
2923
|
+
}
|
|
2924
|
+
|
|
2925
|
+
if(utils$3.isURLSearchParams(body)) {
|
|
2926
|
+
body = body + '';
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2929
|
+
if(utils$3.isString(body)) {
|
|
2930
|
+
return (await encodeText(body)).byteLength;
|
|
2931
|
+
}
|
|
2932
|
+
};
|
|
2933
|
+
|
|
2934
|
+
const resolveBodyLength = async (headers, body) => {
|
|
2935
|
+
const length = utils$3.toFiniteNumber(headers.getContentLength());
|
|
2936
|
+
|
|
2937
|
+
return length == null ? getBodyLength(body) : length;
|
|
2938
|
+
};
|
|
2939
|
+
|
|
2940
|
+
var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2941
|
+
let {
|
|
2942
|
+
url,
|
|
2943
|
+
method,
|
|
2944
|
+
data,
|
|
2945
|
+
signal,
|
|
2946
|
+
cancelToken,
|
|
2947
|
+
timeout,
|
|
2948
|
+
onDownloadProgress,
|
|
2949
|
+
onUploadProgress,
|
|
2950
|
+
responseType,
|
|
2951
|
+
headers,
|
|
2952
|
+
withCredentials = 'same-origin',
|
|
2953
|
+
fetchOptions
|
|
2954
|
+
} = resolveConfig(config);
|
|
2955
|
+
|
|
2956
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
2957
|
+
|
|
2958
|
+
let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
|
|
2959
|
+
composeSignals$1([signal, cancelToken], timeout) : [];
|
|
2960
|
+
|
|
2961
|
+
let finished, request;
|
|
2962
|
+
|
|
2963
|
+
const onFinish = () => {
|
|
2964
|
+
!finished && setTimeout(() => {
|
|
2965
|
+
composedSignal && composedSignal.unsubscribe();
|
|
2966
|
+
});
|
|
2967
|
+
|
|
2968
|
+
finished = true;
|
|
2969
|
+
};
|
|
2970
|
+
|
|
2971
|
+
let requestContentLength;
|
|
2972
|
+
|
|
2973
|
+
try {
|
|
2974
|
+
if (
|
|
2975
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
2976
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
2977
|
+
) {
|
|
2978
|
+
let _request = new Request(url, {
|
|
2979
|
+
method: 'POST',
|
|
2980
|
+
body: data,
|
|
2981
|
+
duplex: "half"
|
|
2982
|
+
});
|
|
2983
|
+
|
|
2984
|
+
let contentTypeHeader;
|
|
2985
|
+
|
|
2986
|
+
if (utils$3.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
2987
|
+
headers.setContentType(contentTypeHeader);
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
if (_request.body) {
|
|
2991
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
2992
|
+
requestContentLength,
|
|
2993
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
2994
|
+
);
|
|
2995
|
+
|
|
2996
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush, encodeText);
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
if (!utils$3.isString(withCredentials)) {
|
|
3001
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
request = new Request(url, {
|
|
3005
|
+
...fetchOptions,
|
|
3006
|
+
signal: composedSignal,
|
|
3007
|
+
method: method.toUpperCase(),
|
|
3008
|
+
headers: headers.normalize().toJSON(),
|
|
3009
|
+
body: data,
|
|
3010
|
+
duplex: "half",
|
|
3011
|
+
credentials: withCredentials
|
|
3012
|
+
});
|
|
3013
|
+
|
|
3014
|
+
let response = await fetch(request);
|
|
3015
|
+
|
|
3016
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3017
|
+
|
|
3018
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
|
3019
|
+
const options = {};
|
|
3020
|
+
|
|
3021
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
3022
|
+
options[prop] = response[prop];
|
|
3023
|
+
});
|
|
3024
|
+
|
|
3025
|
+
const responseContentLength = utils$3.toFiniteNumber(response.headers.get('content-length'));
|
|
3026
|
+
|
|
3027
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
3028
|
+
responseContentLength,
|
|
3029
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3030
|
+
) || [];
|
|
3031
|
+
|
|
3032
|
+
response = new Response(
|
|
3033
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
3034
|
+
flush && flush();
|
|
3035
|
+
isStreamResponse && onFinish();
|
|
3036
|
+
}, encodeText),
|
|
3037
|
+
options
|
|
3038
|
+
);
|
|
3039
|
+
}
|
|
3040
|
+
|
|
3041
|
+
responseType = responseType || 'text';
|
|
3042
|
+
|
|
3043
|
+
let responseData = await resolvers[utils$3.findKey(resolvers, responseType) || 'text'](response, config);
|
|
3044
|
+
|
|
3045
|
+
!isStreamResponse && onFinish();
|
|
3046
|
+
|
|
3047
|
+
stopTimeout && stopTimeout();
|
|
3048
|
+
|
|
3049
|
+
return await new Promise((resolve, reject) => {
|
|
3050
|
+
settle(resolve, reject, {
|
|
3051
|
+
data: responseData,
|
|
3052
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
3053
|
+
status: response.status,
|
|
3054
|
+
statusText: response.statusText,
|
|
3055
|
+
config,
|
|
3056
|
+
request
|
|
3057
|
+
});
|
|
3058
|
+
})
|
|
3059
|
+
} catch (err) {
|
|
3060
|
+
onFinish();
|
|
3061
|
+
|
|
3062
|
+
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
3063
|
+
throw Object.assign(
|
|
3064
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
3065
|
+
{
|
|
3066
|
+
cause: err.cause || err
|
|
3067
|
+
}
|
|
3068
|
+
)
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
throw AxiosError.from(err, err && err.code, config, request);
|
|
3072
|
+
}
|
|
3073
|
+
});
|
|
3074
|
+
|
|
2505
3075
|
const knownAdapters = {
|
|
2506
3076
|
http: httpAdapter,
|
|
2507
|
-
xhr: xhrAdapter
|
|
3077
|
+
xhr: xhrAdapter,
|
|
3078
|
+
fetch: fetchAdapter
|
|
2508
3079
|
};
|
|
2509
3080
|
|
|
2510
|
-
utils$
|
|
2511
|
-
if(fn) {
|
|
3081
|
+
utils$3.forEach(knownAdapters, (fn, value) => {
|
|
3082
|
+
if (fn) {
|
|
2512
3083
|
try {
|
|
2513
3084
|
Object.defineProperty(fn, 'name', {value});
|
|
2514
3085
|
} catch (e) {
|
|
@@ -2518,38 +3089,56 @@ utils$2.forEach(knownAdapters, (fn, value) => {
|
|
|
2518
3089
|
}
|
|
2519
3090
|
});
|
|
2520
3091
|
|
|
3092
|
+
const renderReason = (reason) => `- ${reason}`;
|
|
3093
|
+
|
|
3094
|
+
const isResolvedHandle = (adapter) => utils$3.isFunction(adapter) || adapter === null || adapter === false;
|
|
3095
|
+
|
|
2521
3096
|
var adapters = {
|
|
2522
3097
|
getAdapter: (adapters) => {
|
|
2523
|
-
adapters = utils$
|
|
3098
|
+
adapters = utils$3.isArray(adapters) ? adapters : [adapters];
|
|
2524
3099
|
|
|
2525
3100
|
const {length} = adapters;
|
|
2526
3101
|
let nameOrAdapter;
|
|
2527
3102
|
let adapter;
|
|
2528
3103
|
|
|
3104
|
+
const rejectedReasons = {};
|
|
3105
|
+
|
|
2529
3106
|
for (let i = 0; i < length; i++) {
|
|
2530
3107
|
nameOrAdapter = adapters[i];
|
|
2531
|
-
|
|
3108
|
+
let id;
|
|
3109
|
+
|
|
3110
|
+
adapter = nameOrAdapter;
|
|
3111
|
+
|
|
3112
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
3113
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
3114
|
+
|
|
3115
|
+
if (adapter === undefined) {
|
|
3116
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
if (adapter) {
|
|
2532
3121
|
break;
|
|
2533
3122
|
}
|
|
3123
|
+
|
|
3124
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
2534
3125
|
}
|
|
2535
3126
|
|
|
2536
3127
|
if (!adapter) {
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
'
|
|
3128
|
+
|
|
3129
|
+
const reasons = Object.entries(rejectedReasons)
|
|
3130
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
3131
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
2541
3132
|
);
|
|
2542
|
-
}
|
|
2543
3133
|
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
`Unknown adapter '${nameOrAdapter}'`
|
|
2548
|
-
);
|
|
2549
|
-
}
|
|
3134
|
+
let s = length ?
|
|
3135
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
3136
|
+
'as no adapter specified';
|
|
2550
3137
|
|
|
2551
|
-
|
|
2552
|
-
|
|
3138
|
+
throw new AxiosError(
|
|
3139
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
3140
|
+
'ERR_NOT_SUPPORT'
|
|
3141
|
+
);
|
|
2553
3142
|
}
|
|
2554
3143
|
|
|
2555
3144
|
return adapter;
|
|
@@ -2630,108 +3219,7 @@ function dispatchRequest(config) {
|
|
|
2630
3219
|
});
|
|
2631
3220
|
}
|
|
2632
3221
|
|
|
2633
|
-
const
|
|
2634
|
-
|
|
2635
|
-
/**
|
|
2636
|
-
* Config-specific merge-function which creates a new config-object
|
|
2637
|
-
* by merging two configuration objects together.
|
|
2638
|
-
*
|
|
2639
|
-
* @param {Object} config1
|
|
2640
|
-
* @param {Object} config2
|
|
2641
|
-
*
|
|
2642
|
-
* @returns {Object} New object resulting from merging config2 to config1
|
|
2643
|
-
*/
|
|
2644
|
-
function mergeConfig(config1, config2) {
|
|
2645
|
-
// eslint-disable-next-line no-param-reassign
|
|
2646
|
-
config2 = config2 || {};
|
|
2647
|
-
const config = {};
|
|
2648
|
-
|
|
2649
|
-
function getMergedValue(target, source, caseless) {
|
|
2650
|
-
if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source)) {
|
|
2651
|
-
return utils$2.merge.call({caseless}, target, source);
|
|
2652
|
-
} else if (utils$2.isPlainObject(source)) {
|
|
2653
|
-
return utils$2.merge({}, source);
|
|
2654
|
-
} else if (utils$2.isArray(source)) {
|
|
2655
|
-
return source.slice();
|
|
2656
|
-
}
|
|
2657
|
-
return source;
|
|
2658
|
-
}
|
|
2659
|
-
|
|
2660
|
-
// eslint-disable-next-line consistent-return
|
|
2661
|
-
function mergeDeepProperties(a, b, caseless) {
|
|
2662
|
-
if (!utils$2.isUndefined(b)) {
|
|
2663
|
-
return getMergedValue(a, b, caseless);
|
|
2664
|
-
} else if (!utils$2.isUndefined(a)) {
|
|
2665
|
-
return getMergedValue(undefined, a, caseless);
|
|
2666
|
-
}
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2669
|
-
// eslint-disable-next-line consistent-return
|
|
2670
|
-
function valueFromConfig2(a, b) {
|
|
2671
|
-
if (!utils$2.isUndefined(b)) {
|
|
2672
|
-
return getMergedValue(undefined, b);
|
|
2673
|
-
}
|
|
2674
|
-
}
|
|
2675
|
-
|
|
2676
|
-
// eslint-disable-next-line consistent-return
|
|
2677
|
-
function defaultToConfig2(a, b) {
|
|
2678
|
-
if (!utils$2.isUndefined(b)) {
|
|
2679
|
-
return getMergedValue(undefined, b);
|
|
2680
|
-
} else if (!utils$2.isUndefined(a)) {
|
|
2681
|
-
return getMergedValue(undefined, a);
|
|
2682
|
-
}
|
|
2683
|
-
}
|
|
2684
|
-
|
|
2685
|
-
// eslint-disable-next-line consistent-return
|
|
2686
|
-
function mergeDirectKeys(a, b, prop) {
|
|
2687
|
-
if (prop in config2) {
|
|
2688
|
-
return getMergedValue(a, b);
|
|
2689
|
-
} else if (prop in config1) {
|
|
2690
|
-
return getMergedValue(undefined, a);
|
|
2691
|
-
}
|
|
2692
|
-
}
|
|
2693
|
-
|
|
2694
|
-
const mergeMap = {
|
|
2695
|
-
url: valueFromConfig2,
|
|
2696
|
-
method: valueFromConfig2,
|
|
2697
|
-
data: valueFromConfig2,
|
|
2698
|
-
baseURL: defaultToConfig2,
|
|
2699
|
-
transformRequest: defaultToConfig2,
|
|
2700
|
-
transformResponse: defaultToConfig2,
|
|
2701
|
-
paramsSerializer: defaultToConfig2,
|
|
2702
|
-
timeout: defaultToConfig2,
|
|
2703
|
-
timeoutMessage: defaultToConfig2,
|
|
2704
|
-
withCredentials: defaultToConfig2,
|
|
2705
|
-
adapter: defaultToConfig2,
|
|
2706
|
-
responseType: defaultToConfig2,
|
|
2707
|
-
xsrfCookieName: defaultToConfig2,
|
|
2708
|
-
xsrfHeaderName: defaultToConfig2,
|
|
2709
|
-
onUploadProgress: defaultToConfig2,
|
|
2710
|
-
onDownloadProgress: defaultToConfig2,
|
|
2711
|
-
decompress: defaultToConfig2,
|
|
2712
|
-
maxContentLength: defaultToConfig2,
|
|
2713
|
-
maxBodyLength: defaultToConfig2,
|
|
2714
|
-
beforeRedirect: defaultToConfig2,
|
|
2715
|
-
transport: defaultToConfig2,
|
|
2716
|
-
httpAgent: defaultToConfig2,
|
|
2717
|
-
httpsAgent: defaultToConfig2,
|
|
2718
|
-
cancelToken: defaultToConfig2,
|
|
2719
|
-
socketPath: defaultToConfig2,
|
|
2720
|
-
responseEncoding: defaultToConfig2,
|
|
2721
|
-
validateStatus: mergeDirectKeys,
|
|
2722
|
-
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
2723
|
-
};
|
|
2724
|
-
|
|
2725
|
-
utils$2.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
|
2726
|
-
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
2727
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2728
|
-
(utils$2.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2729
|
-
});
|
|
2730
|
-
|
|
2731
|
-
return config;
|
|
2732
|
-
}
|
|
2733
|
-
|
|
2734
|
-
const VERSION = "1.3.6";
|
|
3222
|
+
const VERSION = "1.7.4";
|
|
2735
3223
|
|
|
2736
3224
|
const validators$1 = {};
|
|
2737
3225
|
|
|
@@ -2846,7 +3334,34 @@ class Axios {
|
|
|
2846
3334
|
*
|
|
2847
3335
|
* @returns {Promise} The Promise to be fulfilled
|
|
2848
3336
|
*/
|
|
2849
|
-
request(configOrUrl, config) {
|
|
3337
|
+
async request(configOrUrl, config) {
|
|
3338
|
+
try {
|
|
3339
|
+
return await this._request(configOrUrl, config);
|
|
3340
|
+
} catch (err) {
|
|
3341
|
+
if (err instanceof Error) {
|
|
3342
|
+
let dummy;
|
|
3343
|
+
|
|
3344
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
|
|
3345
|
+
|
|
3346
|
+
// slice off the Error: ... line
|
|
3347
|
+
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
|
3348
|
+
try {
|
|
3349
|
+
if (!err.stack) {
|
|
3350
|
+
err.stack = stack;
|
|
3351
|
+
// match without the 2 top stack lines
|
|
3352
|
+
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
|
3353
|
+
err.stack += '\n' + stack;
|
|
3354
|
+
}
|
|
3355
|
+
} catch (e) {
|
|
3356
|
+
// ignore the case where "stack" is an un-writable property
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
|
|
3360
|
+
throw err;
|
|
3361
|
+
}
|
|
3362
|
+
}
|
|
3363
|
+
|
|
3364
|
+
_request(configOrUrl, config) {
|
|
2850
3365
|
/*eslint no-param-reassign:0*/
|
|
2851
3366
|
// Allow for axios('example/url'[, config]) a la fetch API
|
|
2852
3367
|
if (typeof configOrUrl === 'string') {
|
|
@@ -2869,7 +3384,7 @@ class Axios {
|
|
|
2869
3384
|
}
|
|
2870
3385
|
|
|
2871
3386
|
if (paramsSerializer != null) {
|
|
2872
|
-
if (utils$
|
|
3387
|
+
if (utils$3.isFunction(paramsSerializer)) {
|
|
2873
3388
|
config.paramsSerializer = {
|
|
2874
3389
|
serialize: paramsSerializer
|
|
2875
3390
|
};
|
|
@@ -2884,15 +3399,13 @@ class Axios {
|
|
|
2884
3399
|
// Set config.method
|
|
2885
3400
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
2886
3401
|
|
|
2887
|
-
let contextHeaders;
|
|
2888
|
-
|
|
2889
3402
|
// Flatten headers
|
|
2890
|
-
contextHeaders = headers && utils$
|
|
3403
|
+
let contextHeaders = headers && utils$3.merge(
|
|
2891
3404
|
headers.common,
|
|
2892
3405
|
headers[config.method]
|
|
2893
3406
|
);
|
|
2894
3407
|
|
|
2895
|
-
|
|
3408
|
+
headers && utils$3.forEach(
|
|
2896
3409
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
2897
3410
|
(method) => {
|
|
2898
3411
|
delete headers[method];
|
|
@@ -2979,7 +3492,7 @@ class Axios {
|
|
|
2979
3492
|
}
|
|
2980
3493
|
|
|
2981
3494
|
// Provide aliases for supported request methods
|
|
2982
|
-
utils$
|
|
3495
|
+
utils$3.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
2983
3496
|
/*eslint func-names:0*/
|
|
2984
3497
|
Axios.prototype[method] = function(url, config) {
|
|
2985
3498
|
return this.request(mergeConfig(config || {}, {
|
|
@@ -2990,7 +3503,7 @@ utils$2.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
2990
3503
|
};
|
|
2991
3504
|
});
|
|
2992
3505
|
|
|
2993
|
-
utils$
|
|
3506
|
+
utils$3.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2994
3507
|
/*eslint func-names:0*/
|
|
2995
3508
|
|
|
2996
3509
|
function generateHTTPMethod(isForm) {
|
|
@@ -3166,7 +3679,7 @@ function spread(callback) {
|
|
|
3166
3679
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3167
3680
|
*/
|
|
3168
3681
|
function isAxiosError(payload) {
|
|
3169
|
-
return utils$
|
|
3682
|
+
return utils$3.isObject(payload) && (payload.isAxiosError === true);
|
|
3170
3683
|
}
|
|
3171
3684
|
|
|
3172
3685
|
const HttpStatusCode = {
|
|
@@ -3253,10 +3766,10 @@ function createInstance(defaultConfig) {
|
|
|
3253
3766
|
const instance = bind(Axios$1.prototype.request, context);
|
|
3254
3767
|
|
|
3255
3768
|
// Copy axios.prototype to instance
|
|
3256
|
-
utils$
|
|
3769
|
+
utils$3.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
|
3257
3770
|
|
|
3258
3771
|
// Copy context to instance
|
|
3259
|
-
utils$
|
|
3772
|
+
utils$3.extend(instance, context, null, {allOwnKeys: true});
|
|
3260
3773
|
|
|
3261
3774
|
// Factory for creating new instances
|
|
3262
3775
|
instance.create = function create(instanceConfig) {
|
|
@@ -3300,7 +3813,9 @@ axios.mergeConfig = mergeConfig;
|
|
|
3300
3813
|
|
|
3301
3814
|
axios.AxiosHeaders = AxiosHeaders$1;
|
|
3302
3815
|
|
|
3303
|
-
axios.formToJSON = thing => formDataToJSON(utils$
|
|
3816
|
+
axios.formToJSON = thing => formDataToJSON(utils$3.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
3817
|
+
|
|
3818
|
+
axios.getAdapter = adapters.getAdapter;
|
|
3304
3819
|
|
|
3305
3820
|
axios.HttpStatusCode = HttpStatusCode$1;
|
|
3306
3821
|
|