@betterstore/react 0.2.24 → 0.2.25
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/CHANGELOG.md +6 -0
- package/dist/index.cjs.js +330 -4296
- package/dist/index.mjs +305 -4271
- package/package.json +3 -3
- package/rollup.config.mjs +1 -0
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
|
+
import { createStoreHelpers, createStoreClient } from '@betterstore/sdk';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import React__default, { createContext, useContext, useCallback, useState, useRef, useEffect, useLayoutEffect, useId as useId$1, useInsertionEffect, useMemo, Children, isValidElement, forwardRef, Fragment as Fragment$1, createElement, Component, cloneElement, useReducer, memo as memo$1 } from 'react';
|
|
4
5
|
import { z } from 'zod';
|
|
@@ -313,7 +314,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
313
314
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
314
315
|
};
|
|
315
316
|
|
|
316
|
-
const isString$
|
|
317
|
+
const isString$1 = obj => typeof obj === 'string';
|
|
317
318
|
const defer = () => {
|
|
318
319
|
let res;
|
|
319
320
|
let rej;
|
|
@@ -336,9 +337,9 @@ const copy = (a, s, t) => {
|
|
|
336
337
|
};
|
|
337
338
|
const lastOfPathSeparatorRegExp = /###/g;
|
|
338
339
|
const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
|
|
339
|
-
const canNotTraverseDeeper = object => !object || isString$
|
|
340
|
+
const canNotTraverseDeeper = object => !object || isString$1(object);
|
|
340
341
|
const getLastOfPath = (object, path, Empty) => {
|
|
341
|
-
const stack = !isString$
|
|
342
|
+
const stack = !isString$1(path) ? path : path.split('.');
|
|
342
343
|
let stackIndex = 0;
|
|
343
344
|
while (stackIndex < stack.length - 1) {
|
|
344
345
|
if (canNotTraverseDeeper(object)) return {};
|
|
@@ -407,7 +408,7 @@ const deepExtend = (target, source, overwrite) => {
|
|
|
407
408
|
for (const prop in source) {
|
|
408
409
|
if (prop !== '__proto__' && prop !== 'constructor') {
|
|
409
410
|
if (prop in target) {
|
|
410
|
-
if (isString$
|
|
411
|
+
if (isString$1(target[prop]) || target[prop] instanceof String || isString$1(source[prop]) || source[prop] instanceof String) {
|
|
411
412
|
if (overwrite) target[prop] = source[prop];
|
|
412
413
|
} else {
|
|
413
414
|
deepExtend(target[prop], source[prop], overwrite);
|
|
@@ -429,7 +430,7 @@ var _entityMap = {
|
|
|
429
430
|
'/': '/'
|
|
430
431
|
};
|
|
431
432
|
const escape = data => {
|
|
432
|
-
if (isString$
|
|
433
|
+
if (isString$1(data)) {
|
|
433
434
|
return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
|
|
434
435
|
}
|
|
435
436
|
return data;
|
|
@@ -559,7 +560,7 @@ class Logger {
|
|
|
559
560
|
}
|
|
560
561
|
forward(args, lvl, prefix, debugOnly) {
|
|
561
562
|
if (debugOnly && !this.debug) return null;
|
|
562
|
-
if (isString$
|
|
563
|
+
if (isString$1(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
|
|
563
564
|
return this.logger[lvl](args);
|
|
564
565
|
}
|
|
565
566
|
create(moduleName) {
|
|
@@ -662,7 +663,7 @@ class ResourceStore extends EventEmitter {
|
|
|
662
663
|
if (key) {
|
|
663
664
|
if (Array.isArray(key)) {
|
|
664
665
|
path.push(...key);
|
|
665
|
-
} else if (isString$
|
|
666
|
+
} else if (isString$1(key) && keySeparator) {
|
|
666
667
|
path.push(...key.split(keySeparator));
|
|
667
668
|
} else {
|
|
668
669
|
path.push(key);
|
|
@@ -675,7 +676,7 @@ class ResourceStore extends EventEmitter {
|
|
|
675
676
|
ns = path[1];
|
|
676
677
|
key = path.slice(2).join('.');
|
|
677
678
|
}
|
|
678
|
-
if (result || !ignoreJSONStructure || !isString$
|
|
679
|
+
if (result || !ignoreJSONStructure || !isString$1(key)) return result;
|
|
679
680
|
return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
|
|
680
681
|
}
|
|
681
682
|
addResource(lng, ns, key, value) {
|
|
@@ -699,7 +700,7 @@ class ResourceStore extends EventEmitter {
|
|
|
699
700
|
silent: false
|
|
700
701
|
};
|
|
701
702
|
for (const m in resources) {
|
|
702
|
-
if (isString$
|
|
703
|
+
if (isString$1(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
|
|
703
704
|
silent: true
|
|
704
705
|
});
|
|
705
706
|
}
|
|
@@ -772,7 +773,7 @@ var postProcessor = {
|
|
|
772
773
|
};
|
|
773
774
|
|
|
774
775
|
const checkedLoadedFor = {};
|
|
775
|
-
const shouldHandleAsObject = res => !isString$
|
|
776
|
+
const shouldHandleAsObject = res => !isString$1(res) && typeof res !== 'boolean' && typeof res !== 'number';
|
|
776
777
|
class Translator extends EventEmitter {
|
|
777
778
|
constructor(services) {
|
|
778
779
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -809,7 +810,7 @@ class Translator extends EventEmitter {
|
|
|
809
810
|
if (m && m.length > 0) {
|
|
810
811
|
return {
|
|
811
812
|
key,
|
|
812
|
-
namespaces: isString$
|
|
813
|
+
namespaces: isString$1(namespaces) ? [namespaces] : namespaces
|
|
813
814
|
};
|
|
814
815
|
}
|
|
815
816
|
const parts = key.split(nsSeparator);
|
|
@@ -818,7 +819,7 @@ class Translator extends EventEmitter {
|
|
|
818
819
|
}
|
|
819
820
|
return {
|
|
820
821
|
key,
|
|
821
|
-
namespaces: isString$
|
|
822
|
+
namespaces: isString$1(namespaces) ? [namespaces] : namespaces
|
|
822
823
|
};
|
|
823
824
|
}
|
|
824
825
|
translate(keys, options, lastKey) {
|
|
@@ -874,7 +875,7 @@ class Translator extends EventEmitter {
|
|
|
874
875
|
const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
|
|
875
876
|
const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
|
|
876
877
|
const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
877
|
-
const needsPluralHandling = options.count !== undefined && !isString$
|
|
878
|
+
const needsPluralHandling = options.count !== undefined && !isString$1(options.count);
|
|
878
879
|
const hasDefaultValue = Translator.hasDefaultValue(options);
|
|
879
880
|
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
|
|
880
881
|
const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
|
|
@@ -888,7 +889,7 @@ class Translator extends EventEmitter {
|
|
|
888
889
|
}
|
|
889
890
|
const handleAsObject = shouldHandleAsObject(resForObjHndl);
|
|
890
891
|
const resType = Object.prototype.toString.apply(resForObjHndl);
|
|
891
|
-
if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString$
|
|
892
|
+
if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString$1(joinArrays) && Array.isArray(resForObjHndl))) {
|
|
892
893
|
if (!options.returnObjects && !this.options.returnObjects) {
|
|
893
894
|
if (!this.options.returnedObjectHandler) {
|
|
894
895
|
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
@@ -934,7 +935,7 @@ class Translator extends EventEmitter {
|
|
|
934
935
|
}
|
|
935
936
|
res = copy;
|
|
936
937
|
}
|
|
937
|
-
} else if (handleAsObjectInI18nFormat && isString$
|
|
938
|
+
} else if (handleAsObjectInI18nFormat && isString$1(joinArrays) && Array.isArray(res)) {
|
|
938
939
|
res = res.join(joinArrays);
|
|
939
940
|
if (res) res = this.extendTranslation(res, keys, options, lastKey);
|
|
940
941
|
} else {
|
|
@@ -1028,13 +1029,13 @@ class Translator extends EventEmitter {
|
|
|
1028
1029
|
}
|
|
1029
1030
|
}
|
|
1030
1031
|
});
|
|
1031
|
-
const skipOnVariables = isString$
|
|
1032
|
+
const skipOnVariables = isString$1(res) && (options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
1032
1033
|
let nestBef;
|
|
1033
1034
|
if (skipOnVariables) {
|
|
1034
1035
|
const nb = res.match(this.interpolator.nestingRegexp);
|
|
1035
1036
|
nestBef = nb && nb.length;
|
|
1036
1037
|
}
|
|
1037
|
-
let data = options.replace && !isString$
|
|
1038
|
+
let data = options.replace && !isString$1(options.replace) ? options.replace : options;
|
|
1038
1039
|
if (this.options.interpolation.defaultVariables) data = {
|
|
1039
1040
|
...this.options.interpolation.defaultVariables,
|
|
1040
1041
|
...data
|
|
@@ -1059,7 +1060,7 @@ class Translator extends EventEmitter {
|
|
|
1059
1060
|
if (options.interpolation) this.interpolator.reset();
|
|
1060
1061
|
}
|
|
1061
1062
|
const postProcess = options.postProcess || this.options.postProcess;
|
|
1062
|
-
const postProcessorNames = isString$
|
|
1063
|
+
const postProcessorNames = isString$1(postProcess) ? [postProcess] : postProcess;
|
|
1063
1064
|
if (res != null && postProcessorNames?.length && options.applyPostProcessor !== false) {
|
|
1064
1065
|
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
|
|
1065
1066
|
i18nResolved: {
|
|
@@ -1078,7 +1079,7 @@ class Translator extends EventEmitter {
|
|
|
1078
1079
|
let exactUsedKey;
|
|
1079
1080
|
let usedLng;
|
|
1080
1081
|
let usedNS;
|
|
1081
|
-
if (isString$
|
|
1082
|
+
if (isString$1(keys)) keys = [keys];
|
|
1082
1083
|
keys.forEach(k => {
|
|
1083
1084
|
if (this.isValidLookup(found)) return;
|
|
1084
1085
|
const extracted = this.extractFromKey(k, options);
|
|
@@ -1086,9 +1087,9 @@ class Translator extends EventEmitter {
|
|
|
1086
1087
|
usedKey = key;
|
|
1087
1088
|
let namespaces = extracted.namespaces;
|
|
1088
1089
|
if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
|
|
1089
|
-
const needsPluralHandling = options.count !== undefined && !isString$
|
|
1090
|
+
const needsPluralHandling = options.count !== undefined && !isString$1(options.count);
|
|
1090
1091
|
const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
|
|
1091
|
-
const needsContextHandling = options.context !== undefined && (isString$
|
|
1092
|
+
const needsContextHandling = options.context !== undefined && (isString$1(options.context) || typeof options.context === 'number') && options.context !== '';
|
|
1092
1093
|
const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
|
|
1093
1094
|
namespaces.forEach(ns => {
|
|
1094
1095
|
if (this.isValidLookup(found)) return;
|
|
@@ -1160,7 +1161,7 @@ class Translator extends EventEmitter {
|
|
|
1160
1161
|
getUsedParamsDetails() {
|
|
1161
1162
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1162
1163
|
const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
|
|
1163
|
-
const useOptionsReplaceForData = options.replace && !isString$
|
|
1164
|
+
const useOptionsReplaceForData = options.replace && !isString$1(options.replace);
|
|
1164
1165
|
let data = useOptionsReplaceForData ? options.replace : options;
|
|
1165
1166
|
if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
|
|
1166
1167
|
data.count = options.count;
|
|
@@ -1214,7 +1215,7 @@ class LanguageUtil {
|
|
|
1214
1215
|
return this.formatLanguageCode(p[0]);
|
|
1215
1216
|
}
|
|
1216
1217
|
formatLanguageCode(code) {
|
|
1217
|
-
if (isString$
|
|
1218
|
+
if (isString$1(code) && code.indexOf('-') > -1) {
|
|
1218
1219
|
let formattedCode;
|
|
1219
1220
|
try {
|
|
1220
1221
|
formattedCode = Intl.getCanonicalLocales(code)[0];
|
|
@@ -1263,7 +1264,7 @@ class LanguageUtil {
|
|
|
1263
1264
|
getFallbackCodes(fallbacks, code) {
|
|
1264
1265
|
if (!fallbacks) return [];
|
|
1265
1266
|
if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
|
|
1266
|
-
if (isString$
|
|
1267
|
+
if (isString$1(fallbacks)) fallbacks = [fallbacks];
|
|
1267
1268
|
if (Array.isArray(fallbacks)) return fallbacks;
|
|
1268
1269
|
if (!code) return fallbacks.default || [];
|
|
1269
1270
|
let found = fallbacks[code];
|
|
@@ -1284,11 +1285,11 @@ class LanguageUtil {
|
|
|
1284
1285
|
this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
|
|
1285
1286
|
}
|
|
1286
1287
|
};
|
|
1287
|
-
if (isString$
|
|
1288
|
+
if (isString$1(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
|
|
1288
1289
|
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
|
1289
1290
|
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
|
1290
1291
|
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
|
1291
|
-
} else if (isString$
|
|
1292
|
+
} else if (isString$1(code)) {
|
|
1292
1293
|
addCode(this.formatLanguageCode(code));
|
|
1293
1294
|
}
|
|
1294
1295
|
fallbackCodes.forEach(fc => {
|
|
@@ -1386,7 +1387,7 @@ const deepFindWithDefaults = function (data, defaultData, key) {
|
|
|
1386
1387
|
let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
|
|
1387
1388
|
let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1388
1389
|
let path = getPathWithDefaults(data, defaultData, key);
|
|
1389
|
-
if (!path && ignoreJSONStructure && isString$
|
|
1390
|
+
if (!path && ignoreJSONStructure && isString$1(key)) {
|
|
1390
1391
|
path = deepFind(data, key, keySeparator);
|
|
1391
1392
|
if (path === undefined) path = deepFind(defaultData, key, keySeparator);
|
|
1392
1393
|
}
|
|
@@ -1496,7 +1497,7 @@ class Interpolator {
|
|
|
1496
1497
|
if (value === undefined) {
|
|
1497
1498
|
if (typeof missingInterpolationHandler === 'function') {
|
|
1498
1499
|
const temp = missingInterpolationHandler(str, match, options);
|
|
1499
|
-
value = isString$
|
|
1500
|
+
value = isString$1(temp) ? temp : '';
|
|
1500
1501
|
} else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
|
|
1501
1502
|
value = '';
|
|
1502
1503
|
} else if (skipOnVariables) {
|
|
@@ -1506,7 +1507,7 @@ class Interpolator {
|
|
|
1506
1507
|
this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
|
|
1507
1508
|
value = '';
|
|
1508
1509
|
}
|
|
1509
|
-
} else if (!isString$
|
|
1510
|
+
} else if (!isString$1(value) && !this.useRawValueToEscape) {
|
|
1510
1511
|
value = makeString(value);
|
|
1511
1512
|
}
|
|
1512
1513
|
const safeValue = todo.safeValue(value);
|
|
@@ -1560,7 +1561,7 @@ class Interpolator {
|
|
|
1560
1561
|
clonedOptions = {
|
|
1561
1562
|
...options
|
|
1562
1563
|
};
|
|
1563
|
-
clonedOptions = clonedOptions.replace && !isString$
|
|
1564
|
+
clonedOptions = clonedOptions.replace && !isString$1(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
|
|
1564
1565
|
clonedOptions.applyPostProcessor = false;
|
|
1565
1566
|
delete clonedOptions.defaultValue;
|
|
1566
1567
|
let doReduce = false;
|
|
@@ -1571,8 +1572,8 @@ class Interpolator {
|
|
|
1571
1572
|
doReduce = true;
|
|
1572
1573
|
}
|
|
1573
1574
|
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
|
1574
|
-
if (value && match[0] === str && !isString$
|
|
1575
|
-
if (!isString$
|
|
1575
|
+
if (value && match[0] === str && !isString$1(value)) return value;
|
|
1576
|
+
if (!isString$1(value)) value = makeString(value);
|
|
1576
1577
|
if (!value) {
|
|
1577
1578
|
this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
|
|
1578
1579
|
value = '';
|
|
@@ -1883,8 +1884,8 @@ class Connector extends EventEmitter {
|
|
|
1883
1884
|
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
|
1884
1885
|
return callback && callback();
|
|
1885
1886
|
}
|
|
1886
|
-
if (isString$
|
|
1887
|
-
if (isString$
|
|
1887
|
+
if (isString$1(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
|
|
1888
|
+
if (isString$1(namespaces)) namespaces = [namespaces];
|
|
1888
1889
|
const toLoad = this.queueLoad(languages, namespaces, options, callback);
|
|
1889
1890
|
if (!toLoad.toLoad.length) {
|
|
1890
1891
|
if (!toLoad.pending.length) callback();
|
|
@@ -1988,8 +1989,8 @@ const get = () => ({
|
|
|
1988
1989
|
overloadTranslationOptionHandler: args => {
|
|
1989
1990
|
let ret = {};
|
|
1990
1991
|
if (typeof args[1] === 'object') ret = args[1];
|
|
1991
|
-
if (isString$
|
|
1992
|
-
if (isString$
|
|
1992
|
+
if (isString$1(args[1])) ret.defaultValue = args[1];
|
|
1993
|
+
if (isString$1(args[2])) ret.tDescription = args[2];
|
|
1993
1994
|
if (typeof args[2] === 'object' || typeof args[3] === 'object') {
|
|
1994
1995
|
const options = args[3] || args[2];
|
|
1995
1996
|
Object.keys(options).forEach(key => {
|
|
@@ -2013,9 +2014,9 @@ const get = () => ({
|
|
|
2013
2014
|
}
|
|
2014
2015
|
});
|
|
2015
2016
|
const transformOptions = options => {
|
|
2016
|
-
if (isString$
|
|
2017
|
-
if (isString$
|
|
2018
|
-
if (isString$
|
|
2017
|
+
if (isString$1(options.ns)) options.ns = [options.ns];
|
|
2018
|
+
if (isString$1(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
|
|
2019
|
+
if (isString$1(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
|
|
2019
2020
|
if (options.supportedLngs?.indexOf?.('cimode') < 0) {
|
|
2020
2021
|
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
|
2021
2022
|
}
|
|
@@ -2023,7 +2024,7 @@ const transformOptions = options => {
|
|
|
2023
2024
|
return options;
|
|
2024
2025
|
};
|
|
2025
2026
|
|
|
2026
|
-
const noop$
|
|
2027
|
+
const noop$1 = () => {};
|
|
2027
2028
|
const bindMemberFunctions = inst => {
|
|
2028
2029
|
const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
2029
2030
|
mems.forEach(mem => {
|
|
@@ -2064,7 +2065,7 @@ class I18n extends EventEmitter {
|
|
|
2064
2065
|
options = {};
|
|
2065
2066
|
}
|
|
2066
2067
|
if (options.defaultNS == null && options.ns) {
|
|
2067
|
-
if (isString$
|
|
2068
|
+
if (isString$1(options.ns)) {
|
|
2068
2069
|
options.defaultNS = options.ns;
|
|
2069
2070
|
} else if (options.ns.indexOf('translation') < 0) {
|
|
2070
2071
|
options.defaultNS = options.ns[0];
|
|
@@ -2149,7 +2150,7 @@ class I18n extends EventEmitter {
|
|
|
2149
2150
|
});
|
|
2150
2151
|
}
|
|
2151
2152
|
this.format = this.options.interpolation.format;
|
|
2152
|
-
if (!callback) callback = noop$
|
|
2153
|
+
if (!callback) callback = noop$1;
|
|
2153
2154
|
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
2154
2155
|
const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2155
2156
|
if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
|
|
@@ -2192,9 +2193,9 @@ class I18n extends EventEmitter {
|
|
|
2192
2193
|
return deferred;
|
|
2193
2194
|
}
|
|
2194
2195
|
loadResources(language) {
|
|
2195
|
-
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$
|
|
2196
|
+
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
|
|
2196
2197
|
let usedCallback = callback;
|
|
2197
|
-
const usedLng = isString$
|
|
2198
|
+
const usedLng = isString$1(language) ? language : this.language;
|
|
2198
2199
|
if (typeof language === 'function') usedCallback = language;
|
|
2199
2200
|
if (!this.options.resources || this.options.partialBundledLanguages) {
|
|
2200
2201
|
if (usedLng?.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
|
|
@@ -2235,7 +2236,7 @@ class I18n extends EventEmitter {
|
|
|
2235
2236
|
}
|
|
2236
2237
|
if (!lngs) lngs = this.languages;
|
|
2237
2238
|
if (!ns) ns = this.options.ns;
|
|
2238
|
-
if (!callback) callback = noop$
|
|
2239
|
+
if (!callback) callback = noop$1;
|
|
2239
2240
|
this.services.backendConnector.reload(lngs, ns, err => {
|
|
2240
2241
|
deferred.resolve();
|
|
2241
2242
|
callback(err);
|
|
@@ -2310,7 +2311,7 @@ class I18n extends EventEmitter {
|
|
|
2310
2311
|
};
|
|
2311
2312
|
const setLng = lngs => {
|
|
2312
2313
|
if (!lng && !lngs && this.services.languageDetector) lngs = [];
|
|
2313
|
-
const l = isString$
|
|
2314
|
+
const l = isString$1(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
|
|
2314
2315
|
if (l) {
|
|
2315
2316
|
if (!this.language) {
|
|
2316
2317
|
setLngProps(l);
|
|
@@ -2362,7 +2363,7 @@ class I18n extends EventEmitter {
|
|
|
2362
2363
|
}
|
|
2363
2364
|
return _this3.t(resultKey, options);
|
|
2364
2365
|
};
|
|
2365
|
-
if (isString$
|
|
2366
|
+
if (isString$1(lng)) {
|
|
2366
2367
|
fixedT.lng = lng;
|
|
2367
2368
|
} else {
|
|
2368
2369
|
fixedT.lngs = lng;
|
|
@@ -2419,7 +2420,7 @@ class I18n extends EventEmitter {
|
|
|
2419
2420
|
if (callback) callback();
|
|
2420
2421
|
return Promise.resolve();
|
|
2421
2422
|
}
|
|
2422
|
-
if (isString$
|
|
2423
|
+
if (isString$1(ns)) ns = [ns];
|
|
2423
2424
|
ns.forEach(n => {
|
|
2424
2425
|
if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
|
|
2425
2426
|
});
|
|
@@ -2431,7 +2432,7 @@ class I18n extends EventEmitter {
|
|
|
2431
2432
|
}
|
|
2432
2433
|
loadLanguages(lngs, callback) {
|
|
2433
2434
|
const deferred = defer();
|
|
2434
|
-
if (isString$
|
|
2435
|
+
if (isString$1(lngs)) lngs = [lngs];
|
|
2435
2436
|
const preloaded = this.options.preload || [];
|
|
2436
2437
|
const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
|
|
2437
2438
|
if (!newLngs.length) {
|
|
@@ -2459,7 +2460,7 @@ class I18n extends EventEmitter {
|
|
|
2459
2460
|
}
|
|
2460
2461
|
cloneInstance() {
|
|
2461
2462
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2462
|
-
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$
|
|
2463
|
+
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
|
|
2463
2464
|
const forkResourceStore = options.forkResourceStore;
|
|
2464
2465
|
if (forkResourceStore) delete options.forkResourceStore;
|
|
2465
2466
|
const mergedOptions = {
|
|
@@ -2542,10 +2543,10 @@ instance.loadLanguages;
|
|
|
2542
2543
|
|
|
2543
2544
|
const {
|
|
2544
2545
|
slice,
|
|
2545
|
-
forEach
|
|
2546
|
+
forEach
|
|
2546
2547
|
} = [];
|
|
2547
|
-
function defaults
|
|
2548
|
-
forEach
|
|
2548
|
+
function defaults(obj) {
|
|
2549
|
+
forEach.call(slice.call(arguments, 1), source => {
|
|
2549
2550
|
if (source) {
|
|
2550
2551
|
for (const prop in source) {
|
|
2551
2552
|
if (obj[prop] === undefined) obj[prop] = source[prop];
|
|
@@ -2886,7 +2887,7 @@ class Browser {
|
|
|
2886
2887
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2887
2888
|
let i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2888
2889
|
this.services = services;
|
|
2889
|
-
this.options = defaults
|
|
2890
|
+
this.options = defaults(options, this.options || {}, getDefaults$1());
|
|
2890
2891
|
if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) {
|
|
2891
2892
|
this.options.convertDetectedLanguage = l => l.replace('-', '_');
|
|
2892
2893
|
}
|
|
@@ -2940,7 +2941,7 @@ const warn = (i18n, code, msg, rest) => {
|
|
|
2940
2941
|
if (i18n?.services?.logger?.forward) {
|
|
2941
2942
|
return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
|
|
2942
2943
|
}
|
|
2943
|
-
if (isString
|
|
2944
|
+
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
|
|
2944
2945
|
if (i18n?.services?.logger?.warn) {
|
|
2945
2946
|
i18n.services.logger.warn(...args);
|
|
2946
2947
|
} else if (console?.warn) {
|
|
@@ -2949,8 +2950,8 @@ const warn = (i18n, code, msg, rest) => {
|
|
|
2949
2950
|
};
|
|
2950
2951
|
const alreadyWarned = {};
|
|
2951
2952
|
const warnOnce$1 = (i18n, code, msg, rest) => {
|
|
2952
|
-
if (isString
|
|
2953
|
-
if (isString
|
|
2953
|
+
if (isString(msg) && alreadyWarned[msg]) return;
|
|
2954
|
+
if (isString(msg)) alreadyWarned[msg] = new Date();
|
|
2954
2955
|
warn(i18n, code, msg, rest);
|
|
2955
2956
|
};
|
|
2956
2957
|
const loadedClb = (i18n, cb) => () => {
|
|
@@ -2970,7 +2971,7 @@ const loadNamespaces = (i18n, ns, cb) => {
|
|
|
2970
2971
|
i18n.loadNamespaces(ns, loadedClb(i18n, cb));
|
|
2971
2972
|
};
|
|
2972
2973
|
const loadLanguages = (i18n, lng, ns, cb) => {
|
|
2973
|
-
if (isString
|
|
2974
|
+
if (isString(ns)) ns = [ns];
|
|
2974
2975
|
if (i18n.options.preload && i18n.options.preload.indexOf(lng) > -1) return loadNamespaces(i18n, ns, cb);
|
|
2975
2976
|
ns.forEach(n => {
|
|
2976
2977
|
if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
|
|
@@ -2991,8 +2992,8 @@ const hasLoadedNamespace = (ns, i18n, options = {}) => {
|
|
|
2991
2992
|
}
|
|
2992
2993
|
});
|
|
2993
2994
|
};
|
|
2994
|
-
const isString
|
|
2995
|
-
const isObject
|
|
2995
|
+
const isString = obj => typeof obj === 'string';
|
|
2996
|
+
const isObject = obj => typeof obj === 'object' && obj !== null;
|
|
2996
2997
|
|
|
2997
2998
|
const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
2998
2999
|
const htmlEntities = {
|
|
@@ -3018,7 +3019,7 @@ const htmlEntities = {
|
|
|
3018
3019
|
'/': '/'
|
|
3019
3020
|
};
|
|
3020
3021
|
const unescapeHtmlEntity = m => htmlEntities[m];
|
|
3021
|
-
const unescape
|
|
3022
|
+
const unescape = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
3022
3023
|
|
|
3023
3024
|
let defaultOptions = {
|
|
3024
3025
|
bindI18n: 'languageChanged',
|
|
@@ -3028,7 +3029,7 @@ let defaultOptions = {
|
|
|
3028
3029
|
transWrapTextNodes: '',
|
|
3029
3030
|
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
3030
3031
|
useSuspense: true,
|
|
3031
|
-
unescape
|
|
3032
|
+
unescape
|
|
3032
3033
|
};
|
|
3033
3034
|
const setDefaults = (options = {}) => {
|
|
3034
3035
|
defaultOptions = {
|
|
@@ -3089,8 +3090,8 @@ const useTranslation = (ns, props = {}) => {
|
|
|
3089
3090
|
if (!i18n) {
|
|
3090
3091
|
warnOnce$1(i18n, 'NO_I18NEXT_INSTANCE', 'useTranslation: You will need to pass in an i18next instance by using initReactI18next');
|
|
3091
3092
|
const notReadyT = (k, optsOrDefaultValue) => {
|
|
3092
|
-
if (isString
|
|
3093
|
-
if (isObject
|
|
3093
|
+
if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
|
|
3094
|
+
if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
|
|
3094
3095
|
return Array.isArray(k) ? k[k.length - 1] : k;
|
|
3095
3096
|
};
|
|
3096
3097
|
const retNotReady = [notReadyT, {}, false];
|
|
@@ -3110,7 +3111,7 @@ const useTranslation = (ns, props = {}) => {
|
|
|
3110
3111
|
keyPrefix
|
|
3111
3112
|
} = i18nOptions;
|
|
3112
3113
|
let namespaces = defaultNSFromContext || i18n.options?.defaultNS;
|
|
3113
|
-
namespaces = isString
|
|
3114
|
+
namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
|
|
3114
3115
|
i18n.reportNamespaces.addUsedNamespaces?.(namespaces);
|
|
3115
3116
|
const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
|
|
3116
3117
|
const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
|
|
@@ -3119,4191 +3120,223 @@ const useTranslation = (ns, props = {}) => {
|
|
|
3119
3120
|
const [t, setT] = useState(getT);
|
|
3120
3121
|
let joinedNS = namespaces.join();
|
|
3121
3122
|
if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
|
|
3122
|
-
const previousJoinedNS = usePrevious(joinedNS);
|
|
3123
|
-
const isMounted = useRef(true);
|
|
3124
|
-
useEffect(() => {
|
|
3125
|
-
const {
|
|
3126
|
-
bindI18n,
|
|
3127
|
-
bindI18nStore
|
|
3128
|
-
} = i18nOptions;
|
|
3129
|
-
isMounted.current = true;
|
|
3130
|
-
if (!ready && !useSuspense) {
|
|
3131
|
-
if (props.lng) {
|
|
3132
|
-
loadLanguages(i18n, props.lng, namespaces, () => {
|
|
3133
|
-
if (isMounted.current) setT(getNewT);
|
|
3134
|
-
});
|
|
3135
|
-
} else {
|
|
3136
|
-
loadNamespaces(i18n, namespaces, () => {
|
|
3137
|
-
if (isMounted.current) setT(getNewT);
|
|
3138
|
-
});
|
|
3139
|
-
}
|
|
3140
|
-
}
|
|
3141
|
-
if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
|
|
3142
|
-
setT(getNewT);
|
|
3143
|
-
}
|
|
3144
|
-
const boundReset = () => {
|
|
3145
|
-
if (isMounted.current) setT(getNewT);
|
|
3146
|
-
};
|
|
3147
|
-
if (bindI18n) i18n?.on(bindI18n, boundReset);
|
|
3148
|
-
if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset);
|
|
3149
|
-
return () => {
|
|
3150
|
-
isMounted.current = false;
|
|
3151
|
-
if (i18n) bindI18n?.split(' ').forEach(e => i18n.off(e, boundReset));
|
|
3152
|
-
if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
|
|
3153
|
-
};
|
|
3154
|
-
}, [i18n, joinedNS]);
|
|
3155
|
-
useEffect(() => {
|
|
3156
|
-
if (isMounted.current && ready) {
|
|
3157
|
-
setT(getT);
|
|
3158
|
-
}
|
|
3159
|
-
}, [i18n, keyPrefix, ready]);
|
|
3160
|
-
const ret = [t, i18n, ready];
|
|
3161
|
-
ret.t = t;
|
|
3162
|
-
ret.i18n = i18n;
|
|
3163
|
-
ret.ready = ready;
|
|
3164
|
-
if (ready) return ret;
|
|
3165
|
-
if (!ready && !useSuspense) return ret;
|
|
3166
|
-
throw new Promise(resolve => {
|
|
3167
|
-
if (props.lng) {
|
|
3168
|
-
loadLanguages(i18n, props.lng, namespaces, () => resolve());
|
|
3169
|
-
} else {
|
|
3170
|
-
loadNamespaces(i18n, namespaces, () => resolve());
|
|
3171
|
-
}
|
|
3172
|
-
});
|
|
3173
|
-
};
|
|
3174
|
-
|
|
3175
|
-
const CheckoutEmbed$2 = {
|
|
3176
|
-
CustomerForm: {
|
|
3177
|
-
address: {
|
|
3178
|
-
address: "Adresa",
|
|
3179
|
-
addressPlaceholder: "Zadejte svou adresu",
|
|
3180
|
-
button: "Uložit adresu",
|
|
3181
|
-
city: "Město",
|
|
3182
|
-
cityPlaceholder: "San Francisco",
|
|
3183
|
-
country: "Země",
|
|
3184
|
-
countryPlaceholder: "Vstoupit do své země",
|
|
3185
|
-
description: "Níže vyplňte údaje o vaší adrese.",
|
|
3186
|
-
line1: "Adresa ulice",
|
|
3187
|
-
line1Placeholder: "123 Hlavní ulice",
|
|
3188
|
-
line2: "Byt, apartmá, jednotka atd. (Volitelné)",
|
|
3189
|
-
line2Placeholder: "APT 4B, Suite 123, atd.",
|
|
3190
|
-
state: "Stát (volitelné)",
|
|
3191
|
-
statePlaceholder: "Kalifornie",
|
|
3192
|
-
title: "Zadejte svou adresu",
|
|
3193
|
-
zipCode: "PSČ",
|
|
3194
|
-
zipCodePlaceholder: "12345"
|
|
3195
|
-
},
|
|
3196
|
-
button: "Uložit a pokračovat",
|
|
3197
|
-
email: "E-mail",
|
|
3198
|
-
emailPlaceholder: "Zadejte svůj e -mail",
|
|
3199
|
-
firstName: "Křestní jméno",
|
|
3200
|
-
firstNamePlaceholder: "Zadejte své křestní jméno",
|
|
3201
|
-
lastName: "Příjmení",
|
|
3202
|
-
lastNamePlaceholder: "Zadejte své příjmení",
|
|
3203
|
-
phone: "Telefon",
|
|
3204
|
-
phonePlaceholder: "Zadejte své telefonní číslo",
|
|
3205
|
-
title: "Údaje o doručení"
|
|
3206
|
-
},
|
|
3207
|
-
Summary: {
|
|
3208
|
-
calculatedAtNextStep: "Vypočítáno v dalším kroku",
|
|
3209
|
-
edit: "Upravit",
|
|
3210
|
-
shipping: "Přeprava",
|
|
3211
|
-
subtotal: "Subtotál",
|
|
3212
|
-
tax: "Daň",
|
|
3213
|
-
title: "Shrnutí",
|
|
3214
|
-
total: "Celkový"
|
|
3215
|
-
},
|
|
3216
|
-
loading: "Načítání ...",
|
|
3217
|
-
Payment: {
|
|
3218
|
-
back: "Zpět na doručení",
|
|
3219
|
-
button: "Koupit hned teď",
|
|
3220
|
-
description: "Všechny transakce jsou bezpečné a šifrovány.",
|
|
3221
|
-
title: "Platba"
|
|
3222
|
-
},
|
|
3223
|
-
Shipping: {
|
|
3224
|
-
back: "Zpět k informacím",
|
|
3225
|
-
button: "Pokračujte v pokladně",
|
|
3226
|
-
change: "Přeměna",
|
|
3227
|
-
contact: "Kontakt:",
|
|
3228
|
-
day: "den",
|
|
3229
|
-
days: "dny",
|
|
3230
|
-
estimatedDeliveryDate: "Odhadované datum dodání:",
|
|
3231
|
-
shipTo: "Ship to:",
|
|
3232
|
-
shipping: "Doprava:",
|
|
3233
|
-
title: "Přeprava"
|
|
3234
|
-
}
|
|
3235
|
-
};
|
|
3236
|
-
const Errors$1 = {
|
|
3237
|
-
invalid_email: "Zadejte platnou e -mailovou adresu",
|
|
3238
|
-
invalid_phone: "Zadejte platné telefonní číslo",
|
|
3239
|
-
invalid_zipCode: "Zadejte platný PSČ",
|
|
3240
|
-
required_error: "Toto pole je nutné",
|
|
3241
|
-
unknown_error: "Došlo k neznámé chybě",
|
|
3242
|
-
invalid_address: "Zadejte platnou adresu"
|
|
3243
|
-
};
|
|
3244
|
-
var cs = {
|
|
3245
|
-
CheckoutEmbed: CheckoutEmbed$2,
|
|
3246
|
-
Errors: Errors$1
|
|
3247
|
-
};
|
|
3248
|
-
|
|
3249
|
-
const CheckoutEmbed$1 = {
|
|
3250
|
-
Summary: {
|
|
3251
|
-
title: "Summary",
|
|
3252
|
-
edit: "Edit",
|
|
3253
|
-
total: "Total",
|
|
3254
|
-
subtotal: "Subtotal",
|
|
3255
|
-
shipping: "Shipping",
|
|
3256
|
-
calculatedAtNextStep: "Calculated at next step",
|
|
3257
|
-
tax: "Tax"
|
|
3258
|
-
},
|
|
3259
|
-
CustomerForm: {
|
|
3260
|
-
address: {
|
|
3261
|
-
address: "Address",
|
|
3262
|
-
addressPlaceholder: "Enter your address",
|
|
3263
|
-
title: "Enter your address",
|
|
3264
|
-
description: "Fill in your address details below.",
|
|
3265
|
-
line1: "Street address",
|
|
3266
|
-
line1Placeholder: "123 Main Street",
|
|
3267
|
-
line2: "Apartment, suite, unit, etc. (optional)",
|
|
3268
|
-
line2Placeholder: "Apt 4B, Suite 123, etc.",
|
|
3269
|
-
city: "City",
|
|
3270
|
-
cityPlaceholder: "San Francisco",
|
|
3271
|
-
country: "Country",
|
|
3272
|
-
countryPlaceholder: "Enter your country",
|
|
3273
|
-
state: "State (optional)",
|
|
3274
|
-
statePlaceholder: "California",
|
|
3275
|
-
zipCode: "Zip code",
|
|
3276
|
-
zipCodePlaceholder: "12345",
|
|
3277
|
-
button: "Save address"
|
|
3278
|
-
},
|
|
3279
|
-
title: "Basic information",
|
|
3280
|
-
email: "Email",
|
|
3281
|
-
emailPlaceholder: "Enter your email",
|
|
3282
|
-
firstName: "First name",
|
|
3283
|
-
firstNamePlaceholder: "Enter your first name",
|
|
3284
|
-
lastName: "Last name",
|
|
3285
|
-
lastNamePlaceholder: "Enter your last name",
|
|
3286
|
-
phone: "Phone",
|
|
3287
|
-
phonePlaceholder: "Enter your phone number",
|
|
3288
|
-
button: "Save and continue"
|
|
3289
|
-
},
|
|
3290
|
-
loading: "Loading...",
|
|
3291
|
-
Shipping: {
|
|
3292
|
-
title: "Shipping",
|
|
3293
|
-
change: "Change",
|
|
3294
|
-
shipTo: "Ship to:",
|
|
3295
|
-
contact: "Contact:",
|
|
3296
|
-
button: "Continue to checkout",
|
|
3297
|
-
back: "Back to information",
|
|
3298
|
-
shipping: "Shipping:",
|
|
3299
|
-
estimatedDeliveryDate: "Estimated delivery date: ",
|
|
3300
|
-
day: "day",
|
|
3301
|
-
days: "days"
|
|
3302
|
-
},
|
|
3303
|
-
Payment: {
|
|
3304
|
-
title: "Payment",
|
|
3305
|
-
description: "All transactions are secure and encrypted.",
|
|
3306
|
-
back: "Back to shipping",
|
|
3307
|
-
button: "Buy now"
|
|
3308
|
-
}
|
|
3309
|
-
};
|
|
3310
|
-
const Errors = {
|
|
3311
|
-
required_error: "This field is required",
|
|
3312
|
-
invalid_email: "Please enter a valid email address",
|
|
3313
|
-
invalid_phone: "Please enter a valid phone number",
|
|
3314
|
-
invalid_zipCode: "Please enter a valid zip code",
|
|
3315
|
-
invalid_address: "Please enter a valid address",
|
|
3316
|
-
unknown_error: "An unknown error occurred"
|
|
3317
|
-
};
|
|
3318
|
-
var en = {
|
|
3319
|
-
CheckoutEmbed: CheckoutEmbed$1,
|
|
3320
|
-
Errors: Errors
|
|
3321
|
-
};
|
|
3322
|
-
|
|
3323
|
-
const createI18nInstance = (locale) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3324
|
-
yield instance
|
|
3325
|
-
.use(initReactI18next)
|
|
3326
|
-
.use(Browser)
|
|
3327
|
-
.init({
|
|
3328
|
-
lng: locale,
|
|
3329
|
-
fallbackLng: "en",
|
|
3330
|
-
// debug: true,
|
|
3331
|
-
interpolation: { escapeValue: false },
|
|
3332
|
-
resources: {
|
|
3333
|
-
en: { translation: en },
|
|
3334
|
-
cs: { translation: cs },
|
|
3335
|
-
},
|
|
3336
|
-
});
|
|
3337
|
-
return instance;
|
|
3338
|
-
});
|
|
3339
|
-
|
|
3340
|
-
function bind(fn, thisArg) {
|
|
3341
|
-
return function wrap() {
|
|
3342
|
-
return fn.apply(thisArg, arguments);
|
|
3343
|
-
};
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
// utils is a library of generic helper functions non-specific to axios
|
|
3347
|
-
|
|
3348
|
-
const {toString} = Object.prototype;
|
|
3349
|
-
const {getPrototypeOf} = Object;
|
|
3350
|
-
|
|
3351
|
-
const kindOf = (cache => thing => {
|
|
3352
|
-
const str = toString.call(thing);
|
|
3353
|
-
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
3354
|
-
})(Object.create(null));
|
|
3355
|
-
|
|
3356
|
-
const kindOfTest = (type) => {
|
|
3357
|
-
type = type.toLowerCase();
|
|
3358
|
-
return (thing) => kindOf(thing) === type
|
|
3359
|
-
};
|
|
3360
|
-
|
|
3361
|
-
const typeOfTest = type => thing => typeof thing === type;
|
|
3362
|
-
|
|
3363
|
-
/**
|
|
3364
|
-
* Determine if a value is an Array
|
|
3365
|
-
*
|
|
3366
|
-
* @param {Object} val The value to test
|
|
3367
|
-
*
|
|
3368
|
-
* @returns {boolean} True if value is an Array, otherwise false
|
|
3369
|
-
*/
|
|
3370
|
-
const {isArray} = Array;
|
|
3371
|
-
|
|
3372
|
-
/**
|
|
3373
|
-
* Determine if a value is undefined
|
|
3374
|
-
*
|
|
3375
|
-
* @param {*} val The value to test
|
|
3376
|
-
*
|
|
3377
|
-
* @returns {boolean} True if the value is undefined, otherwise false
|
|
3378
|
-
*/
|
|
3379
|
-
const isUndefined = typeOfTest('undefined');
|
|
3380
|
-
|
|
3381
|
-
/**
|
|
3382
|
-
* Determine if a value is a Buffer
|
|
3383
|
-
*
|
|
3384
|
-
* @param {*} val The value to test
|
|
3385
|
-
*
|
|
3386
|
-
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
3387
|
-
*/
|
|
3388
|
-
function isBuffer(val) {
|
|
3389
|
-
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
|
3390
|
-
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
3391
|
-
}
|
|
3392
|
-
|
|
3393
|
-
/**
|
|
3394
|
-
* Determine if a value is an ArrayBuffer
|
|
3395
|
-
*
|
|
3396
|
-
* @param {*} val The value to test
|
|
3397
|
-
*
|
|
3398
|
-
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
3399
|
-
*/
|
|
3400
|
-
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
/**
|
|
3404
|
-
* Determine if a value is a view on an ArrayBuffer
|
|
3405
|
-
*
|
|
3406
|
-
* @param {*} val The value to test
|
|
3407
|
-
*
|
|
3408
|
-
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
|
3409
|
-
*/
|
|
3410
|
-
function isArrayBufferView(val) {
|
|
3411
|
-
let result;
|
|
3412
|
-
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
|
3413
|
-
result = ArrayBuffer.isView(val);
|
|
3414
|
-
} else {
|
|
3415
|
-
result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
|
|
3416
|
-
}
|
|
3417
|
-
return result;
|
|
3418
|
-
}
|
|
3419
|
-
|
|
3420
|
-
/**
|
|
3421
|
-
* Determine if a value is a String
|
|
3422
|
-
*
|
|
3423
|
-
* @param {*} val The value to test
|
|
3424
|
-
*
|
|
3425
|
-
* @returns {boolean} True if value is a String, otherwise false
|
|
3426
|
-
*/
|
|
3427
|
-
const isString = typeOfTest('string');
|
|
3428
|
-
|
|
3429
|
-
/**
|
|
3430
|
-
* Determine if a value is a Function
|
|
3431
|
-
*
|
|
3432
|
-
* @param {*} val The value to test
|
|
3433
|
-
* @returns {boolean} True if value is a Function, otherwise false
|
|
3434
|
-
*/
|
|
3435
|
-
const isFunction = typeOfTest('function');
|
|
3436
|
-
|
|
3437
|
-
/**
|
|
3438
|
-
* Determine if a value is a Number
|
|
3439
|
-
*
|
|
3440
|
-
* @param {*} val The value to test
|
|
3441
|
-
*
|
|
3442
|
-
* @returns {boolean} True if value is a Number, otherwise false
|
|
3443
|
-
*/
|
|
3444
|
-
const isNumber = typeOfTest('number');
|
|
3445
|
-
|
|
3446
|
-
/**
|
|
3447
|
-
* Determine if a value is an Object
|
|
3448
|
-
*
|
|
3449
|
-
* @param {*} thing The value to test
|
|
3450
|
-
*
|
|
3451
|
-
* @returns {boolean} True if value is an Object, otherwise false
|
|
3452
|
-
*/
|
|
3453
|
-
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
3454
|
-
|
|
3455
|
-
/**
|
|
3456
|
-
* Determine if a value is a Boolean
|
|
3457
|
-
*
|
|
3458
|
-
* @param {*} thing The value to test
|
|
3459
|
-
* @returns {boolean} True if value is a Boolean, otherwise false
|
|
3460
|
-
*/
|
|
3461
|
-
const isBoolean = thing => thing === true || thing === false;
|
|
3462
|
-
|
|
3463
|
-
/**
|
|
3464
|
-
* Determine if a value is a plain Object
|
|
3465
|
-
*
|
|
3466
|
-
* @param {*} val The value to test
|
|
3467
|
-
*
|
|
3468
|
-
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
3469
|
-
*/
|
|
3470
|
-
const isPlainObject = (val) => {
|
|
3471
|
-
if (kindOf(val) !== 'object') {
|
|
3472
|
-
return false;
|
|
3473
|
-
}
|
|
3474
|
-
|
|
3475
|
-
const prototype = getPrototypeOf(val);
|
|
3476
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
|
3477
|
-
};
|
|
3478
|
-
|
|
3479
|
-
/**
|
|
3480
|
-
* Determine if a value is a Date
|
|
3481
|
-
*
|
|
3482
|
-
* @param {*} val The value to test
|
|
3483
|
-
*
|
|
3484
|
-
* @returns {boolean} True if value is a Date, otherwise false
|
|
3485
|
-
*/
|
|
3486
|
-
const isDate = kindOfTest('Date');
|
|
3487
|
-
|
|
3488
|
-
/**
|
|
3489
|
-
* Determine if a value is a File
|
|
3490
|
-
*
|
|
3491
|
-
* @param {*} val The value to test
|
|
3492
|
-
*
|
|
3493
|
-
* @returns {boolean} True if value is a File, otherwise false
|
|
3494
|
-
*/
|
|
3495
|
-
const isFile = kindOfTest('File');
|
|
3496
|
-
|
|
3497
|
-
/**
|
|
3498
|
-
* Determine if a value is a Blob
|
|
3499
|
-
*
|
|
3500
|
-
* @param {*} val The value to test
|
|
3501
|
-
*
|
|
3502
|
-
* @returns {boolean} True if value is a Blob, otherwise false
|
|
3503
|
-
*/
|
|
3504
|
-
const isBlob = kindOfTest('Blob');
|
|
3505
|
-
|
|
3506
|
-
/**
|
|
3507
|
-
* Determine if a value is a FileList
|
|
3508
|
-
*
|
|
3509
|
-
* @param {*} val The value to test
|
|
3510
|
-
*
|
|
3511
|
-
* @returns {boolean} True if value is a File, otherwise false
|
|
3512
|
-
*/
|
|
3513
|
-
const isFileList = kindOfTest('FileList');
|
|
3514
|
-
|
|
3515
|
-
/**
|
|
3516
|
-
* Determine if a value is a Stream
|
|
3517
|
-
*
|
|
3518
|
-
* @param {*} val The value to test
|
|
3519
|
-
*
|
|
3520
|
-
* @returns {boolean} True if value is a Stream, otherwise false
|
|
3521
|
-
*/
|
|
3522
|
-
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
3523
|
-
|
|
3524
|
-
/**
|
|
3525
|
-
* Determine if a value is a FormData
|
|
3526
|
-
*
|
|
3527
|
-
* @param {*} thing The value to test
|
|
3528
|
-
*
|
|
3529
|
-
* @returns {boolean} True if value is an FormData, otherwise false
|
|
3530
|
-
*/
|
|
3531
|
-
const isFormData = (thing) => {
|
|
3532
|
-
let kind;
|
|
3533
|
-
return thing && (
|
|
3534
|
-
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
3535
|
-
isFunction(thing.append) && (
|
|
3536
|
-
(kind = kindOf(thing)) === 'formdata' ||
|
|
3537
|
-
// detect form-data instance
|
|
3538
|
-
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
|
3539
|
-
)
|
|
3540
|
-
)
|
|
3541
|
-
)
|
|
3542
|
-
};
|
|
3543
|
-
|
|
3544
|
-
/**
|
|
3545
|
-
* Determine if a value is a URLSearchParams object
|
|
3546
|
-
*
|
|
3547
|
-
* @param {*} val The value to test
|
|
3548
|
-
*
|
|
3549
|
-
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
3550
|
-
*/
|
|
3551
|
-
const isURLSearchParams = kindOfTest('URLSearchParams');
|
|
3552
|
-
|
|
3553
|
-
const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
|
|
3554
|
-
|
|
3555
|
-
/**
|
|
3556
|
-
* Trim excess whitespace off the beginning and end of a string
|
|
3557
|
-
*
|
|
3558
|
-
* @param {String} str The String to trim
|
|
3559
|
-
*
|
|
3560
|
-
* @returns {String} The String freed of excess whitespace
|
|
3561
|
-
*/
|
|
3562
|
-
const trim = (str) => str.trim ?
|
|
3563
|
-
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
3564
|
-
|
|
3565
|
-
/**
|
|
3566
|
-
* Iterate over an Array or an Object invoking a function for each item.
|
|
3567
|
-
*
|
|
3568
|
-
* If `obj` is an Array callback will be called passing
|
|
3569
|
-
* the value, index, and complete array for each item.
|
|
3570
|
-
*
|
|
3571
|
-
* If 'obj' is an Object callback will be called passing
|
|
3572
|
-
* the value, key, and complete object for each property.
|
|
3573
|
-
*
|
|
3574
|
-
* @param {Object|Array} obj The object to iterate
|
|
3575
|
-
* @param {Function} fn The callback to invoke for each item
|
|
3576
|
-
*
|
|
3577
|
-
* @param {Boolean} [allOwnKeys = false]
|
|
3578
|
-
* @returns {any}
|
|
3579
|
-
*/
|
|
3580
|
-
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
3581
|
-
// Don't bother if no value provided
|
|
3582
|
-
if (obj === null || typeof obj === 'undefined') {
|
|
3583
|
-
return;
|
|
3584
|
-
}
|
|
3585
|
-
|
|
3586
|
-
let i;
|
|
3587
|
-
let l;
|
|
3588
|
-
|
|
3589
|
-
// Force an array if not already something iterable
|
|
3590
|
-
if (typeof obj !== 'object') {
|
|
3591
|
-
/*eslint no-param-reassign:0*/
|
|
3592
|
-
obj = [obj];
|
|
3593
|
-
}
|
|
3594
|
-
|
|
3595
|
-
if (isArray(obj)) {
|
|
3596
|
-
// Iterate over array values
|
|
3597
|
-
for (i = 0, l = obj.length; i < l; i++) {
|
|
3598
|
-
fn.call(null, obj[i], i, obj);
|
|
3599
|
-
}
|
|
3600
|
-
} else {
|
|
3601
|
-
// Iterate over object keys
|
|
3602
|
-
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
3603
|
-
const len = keys.length;
|
|
3604
|
-
let key;
|
|
3605
|
-
|
|
3606
|
-
for (i = 0; i < len; i++) {
|
|
3607
|
-
key = keys[i];
|
|
3608
|
-
fn.call(null, obj[key], key, obj);
|
|
3609
|
-
}
|
|
3610
|
-
}
|
|
3611
|
-
}
|
|
3612
|
-
|
|
3613
|
-
function findKey(obj, key) {
|
|
3614
|
-
key = key.toLowerCase();
|
|
3615
|
-
const keys = Object.keys(obj);
|
|
3616
|
-
let i = keys.length;
|
|
3617
|
-
let _key;
|
|
3618
|
-
while (i-- > 0) {
|
|
3619
|
-
_key = keys[i];
|
|
3620
|
-
if (key === _key.toLowerCase()) {
|
|
3621
|
-
return _key;
|
|
3622
|
-
}
|
|
3623
|
-
}
|
|
3624
|
-
return null;
|
|
3625
|
-
}
|
|
3626
|
-
|
|
3627
|
-
const _global = (() => {
|
|
3628
|
-
/*eslint no-undef:0*/
|
|
3629
|
-
if (typeof globalThis !== "undefined") return globalThis;
|
|
3630
|
-
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
|
|
3631
|
-
})();
|
|
3632
|
-
|
|
3633
|
-
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
3634
|
-
|
|
3635
|
-
/**
|
|
3636
|
-
* Accepts varargs expecting each argument to be an object, then
|
|
3637
|
-
* immutably merges the properties of each object and returns result.
|
|
3638
|
-
*
|
|
3639
|
-
* When multiple objects contain the same key the later object in
|
|
3640
|
-
* the arguments list will take precedence.
|
|
3641
|
-
*
|
|
3642
|
-
* Example:
|
|
3643
|
-
*
|
|
3644
|
-
* ```js
|
|
3645
|
-
* var result = merge({foo: 123}, {foo: 456});
|
|
3646
|
-
* console.log(result.foo); // outputs 456
|
|
3647
|
-
* ```
|
|
3648
|
-
*
|
|
3649
|
-
* @param {Object} obj1 Object to merge
|
|
3650
|
-
*
|
|
3651
|
-
* @returns {Object} Result of all merge properties
|
|
3652
|
-
*/
|
|
3653
|
-
function merge(/* obj1, obj2, obj3, ... */) {
|
|
3654
|
-
const {caseless} = isContextDefined(this) && this || {};
|
|
3655
|
-
const result = {};
|
|
3656
|
-
const assignValue = (val, key) => {
|
|
3657
|
-
const targetKey = caseless && findKey(result, key) || key;
|
|
3658
|
-
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
|
3659
|
-
result[targetKey] = merge(result[targetKey], val);
|
|
3660
|
-
} else if (isPlainObject(val)) {
|
|
3661
|
-
result[targetKey] = merge({}, val);
|
|
3662
|
-
} else if (isArray(val)) {
|
|
3663
|
-
result[targetKey] = val.slice();
|
|
3664
|
-
} else {
|
|
3665
|
-
result[targetKey] = val;
|
|
3666
|
-
}
|
|
3667
|
-
};
|
|
3668
|
-
|
|
3669
|
-
for (let i = 0, l = arguments.length; i < l; i++) {
|
|
3670
|
-
arguments[i] && forEach(arguments[i], assignValue);
|
|
3671
|
-
}
|
|
3672
|
-
return result;
|
|
3673
|
-
}
|
|
3674
|
-
|
|
3675
|
-
/**
|
|
3676
|
-
* Extends object a by mutably adding to it the properties of object b.
|
|
3677
|
-
*
|
|
3678
|
-
* @param {Object} a The object to be extended
|
|
3679
|
-
* @param {Object} b The object to copy properties from
|
|
3680
|
-
* @param {Object} thisArg The object to bind function to
|
|
3681
|
-
*
|
|
3682
|
-
* @param {Boolean} [allOwnKeys]
|
|
3683
|
-
* @returns {Object} The resulting value of object a
|
|
3684
|
-
*/
|
|
3685
|
-
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
3686
|
-
forEach(b, (val, key) => {
|
|
3687
|
-
if (thisArg && isFunction(val)) {
|
|
3688
|
-
a[key] = bind(val, thisArg);
|
|
3689
|
-
} else {
|
|
3690
|
-
a[key] = val;
|
|
3691
|
-
}
|
|
3692
|
-
}, {allOwnKeys});
|
|
3693
|
-
return a;
|
|
3694
|
-
};
|
|
3695
|
-
|
|
3696
|
-
/**
|
|
3697
|
-
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
|
3698
|
-
*
|
|
3699
|
-
* @param {string} content with BOM
|
|
3700
|
-
*
|
|
3701
|
-
* @returns {string} content value without BOM
|
|
3702
|
-
*/
|
|
3703
|
-
const stripBOM = (content) => {
|
|
3704
|
-
if (content.charCodeAt(0) === 0xFEFF) {
|
|
3705
|
-
content = content.slice(1);
|
|
3706
|
-
}
|
|
3707
|
-
return content;
|
|
3708
|
-
};
|
|
3709
|
-
|
|
3710
|
-
/**
|
|
3711
|
-
* Inherit the prototype methods from one constructor into another
|
|
3712
|
-
* @param {function} constructor
|
|
3713
|
-
* @param {function} superConstructor
|
|
3714
|
-
* @param {object} [props]
|
|
3715
|
-
* @param {object} [descriptors]
|
|
3716
|
-
*
|
|
3717
|
-
* @returns {void}
|
|
3718
|
-
*/
|
|
3719
|
-
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
3720
|
-
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
3721
|
-
constructor.prototype.constructor = constructor;
|
|
3722
|
-
Object.defineProperty(constructor, 'super', {
|
|
3723
|
-
value: superConstructor.prototype
|
|
3724
|
-
});
|
|
3725
|
-
props && Object.assign(constructor.prototype, props);
|
|
3726
|
-
};
|
|
3727
|
-
|
|
3728
|
-
/**
|
|
3729
|
-
* Resolve object with deep prototype chain to a flat object
|
|
3730
|
-
* @param {Object} sourceObj source object
|
|
3731
|
-
* @param {Object} [destObj]
|
|
3732
|
-
* @param {Function|Boolean} [filter]
|
|
3733
|
-
* @param {Function} [propFilter]
|
|
3734
|
-
*
|
|
3735
|
-
* @returns {Object}
|
|
3736
|
-
*/
|
|
3737
|
-
const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
|
3738
|
-
let props;
|
|
3739
|
-
let i;
|
|
3740
|
-
let prop;
|
|
3741
|
-
const merged = {};
|
|
3742
|
-
|
|
3743
|
-
destObj = destObj || {};
|
|
3744
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
3745
|
-
if (sourceObj == null) return destObj;
|
|
3746
|
-
|
|
3747
|
-
do {
|
|
3748
|
-
props = Object.getOwnPropertyNames(sourceObj);
|
|
3749
|
-
i = props.length;
|
|
3750
|
-
while (i-- > 0) {
|
|
3751
|
-
prop = props[i];
|
|
3752
|
-
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
3753
|
-
destObj[prop] = sourceObj[prop];
|
|
3754
|
-
merged[prop] = true;
|
|
3755
|
-
}
|
|
3756
|
-
}
|
|
3757
|
-
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
3758
|
-
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
3759
|
-
|
|
3760
|
-
return destObj;
|
|
3761
|
-
};
|
|
3762
|
-
|
|
3763
|
-
/**
|
|
3764
|
-
* Determines whether a string ends with the characters of a specified string
|
|
3765
|
-
*
|
|
3766
|
-
* @param {String} str
|
|
3767
|
-
* @param {String} searchString
|
|
3768
|
-
* @param {Number} [position= 0]
|
|
3769
|
-
*
|
|
3770
|
-
* @returns {boolean}
|
|
3771
|
-
*/
|
|
3772
|
-
const endsWith = (str, searchString, position) => {
|
|
3773
|
-
str = String(str);
|
|
3774
|
-
if (position === undefined || position > str.length) {
|
|
3775
|
-
position = str.length;
|
|
3776
|
-
}
|
|
3777
|
-
position -= searchString.length;
|
|
3778
|
-
const lastIndex = str.indexOf(searchString, position);
|
|
3779
|
-
return lastIndex !== -1 && lastIndex === position;
|
|
3780
|
-
};
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
/**
|
|
3784
|
-
* Returns new array from array like object or null if failed
|
|
3785
|
-
*
|
|
3786
|
-
* @param {*} [thing]
|
|
3787
|
-
*
|
|
3788
|
-
* @returns {?Array}
|
|
3789
|
-
*/
|
|
3790
|
-
const toArray = (thing) => {
|
|
3791
|
-
if (!thing) return null;
|
|
3792
|
-
if (isArray(thing)) return thing;
|
|
3793
|
-
let i = thing.length;
|
|
3794
|
-
if (!isNumber(i)) return null;
|
|
3795
|
-
const arr = new Array(i);
|
|
3796
|
-
while (i-- > 0) {
|
|
3797
|
-
arr[i] = thing[i];
|
|
3798
|
-
}
|
|
3799
|
-
return arr;
|
|
3800
|
-
};
|
|
3801
|
-
|
|
3802
|
-
/**
|
|
3803
|
-
* Checking if the Uint8Array exists and if it does, it returns a function that checks if the
|
|
3804
|
-
* thing passed in is an instance of Uint8Array
|
|
3805
|
-
*
|
|
3806
|
-
* @param {TypedArray}
|
|
3807
|
-
*
|
|
3808
|
-
* @returns {Array}
|
|
3809
|
-
*/
|
|
3810
|
-
// eslint-disable-next-line func-names
|
|
3811
|
-
const isTypedArray = (TypedArray => {
|
|
3812
|
-
// eslint-disable-next-line func-names
|
|
3813
|
-
return thing => {
|
|
3814
|
-
return TypedArray && thing instanceof TypedArray;
|
|
3815
|
-
};
|
|
3816
|
-
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
|
3817
|
-
|
|
3818
|
-
/**
|
|
3819
|
-
* For each entry in the object, call the function with the key and value.
|
|
3820
|
-
*
|
|
3821
|
-
* @param {Object<any, any>} obj - The object to iterate over.
|
|
3822
|
-
* @param {Function} fn - The function to call for each entry.
|
|
3823
|
-
*
|
|
3824
|
-
* @returns {void}
|
|
3825
|
-
*/
|
|
3826
|
-
const forEachEntry = (obj, fn) => {
|
|
3827
|
-
const generator = obj && obj[Symbol.iterator];
|
|
3828
|
-
|
|
3829
|
-
const iterator = generator.call(obj);
|
|
3830
|
-
|
|
3831
|
-
let result;
|
|
3832
|
-
|
|
3833
|
-
while ((result = iterator.next()) && !result.done) {
|
|
3834
|
-
const pair = result.value;
|
|
3835
|
-
fn.call(obj, pair[0], pair[1]);
|
|
3836
|
-
}
|
|
3837
|
-
};
|
|
3838
|
-
|
|
3839
|
-
/**
|
|
3840
|
-
* It takes a regular expression and a string, and returns an array of all the matches
|
|
3841
|
-
*
|
|
3842
|
-
* @param {string} regExp - The regular expression to match against.
|
|
3843
|
-
* @param {string} str - The string to search.
|
|
3844
|
-
*
|
|
3845
|
-
* @returns {Array<boolean>}
|
|
3846
|
-
*/
|
|
3847
|
-
const matchAll = (regExp, str) => {
|
|
3848
|
-
let matches;
|
|
3849
|
-
const arr = [];
|
|
3850
|
-
|
|
3851
|
-
while ((matches = regExp.exec(str)) !== null) {
|
|
3852
|
-
arr.push(matches);
|
|
3853
|
-
}
|
|
3854
|
-
|
|
3855
|
-
return arr;
|
|
3856
|
-
};
|
|
3857
|
-
|
|
3858
|
-
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
3859
|
-
const isHTMLForm = kindOfTest('HTMLFormElement');
|
|
3860
|
-
|
|
3861
|
-
const toCamelCase = str => {
|
|
3862
|
-
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
|
3863
|
-
function replacer(m, p1, p2) {
|
|
3864
|
-
return p1.toUpperCase() + p2;
|
|
3865
|
-
}
|
|
3866
|
-
);
|
|
3867
|
-
};
|
|
3868
|
-
|
|
3869
|
-
/* Creating a function that will check if an object has a property. */
|
|
3870
|
-
const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
|
|
3871
|
-
|
|
3872
|
-
/**
|
|
3873
|
-
* Determine if a value is a RegExp object
|
|
3874
|
-
*
|
|
3875
|
-
* @param {*} val The value to test
|
|
3876
|
-
*
|
|
3877
|
-
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
3878
|
-
*/
|
|
3879
|
-
const isRegExp = kindOfTest('RegExp');
|
|
3880
|
-
|
|
3881
|
-
const reduceDescriptors = (obj, reducer) => {
|
|
3882
|
-
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
3883
|
-
const reducedDescriptors = {};
|
|
3884
|
-
|
|
3885
|
-
forEach(descriptors, (descriptor, name) => {
|
|
3886
|
-
let ret;
|
|
3887
|
-
if ((ret = reducer(descriptor, name, obj)) !== false) {
|
|
3888
|
-
reducedDescriptors[name] = ret || descriptor;
|
|
3889
|
-
}
|
|
3890
|
-
});
|
|
3891
|
-
|
|
3892
|
-
Object.defineProperties(obj, reducedDescriptors);
|
|
3893
|
-
};
|
|
3894
|
-
|
|
3895
|
-
/**
|
|
3896
|
-
* Makes all methods read-only
|
|
3897
|
-
* @param {Object} obj
|
|
3898
|
-
*/
|
|
3899
|
-
|
|
3900
|
-
const freezeMethods = (obj) => {
|
|
3901
|
-
reduceDescriptors(obj, (descriptor, name) => {
|
|
3902
|
-
// skip restricted props in strict mode
|
|
3903
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
3904
|
-
return false;
|
|
3905
|
-
}
|
|
3906
|
-
|
|
3907
|
-
const value = obj[name];
|
|
3908
|
-
|
|
3909
|
-
if (!isFunction(value)) return;
|
|
3910
|
-
|
|
3911
|
-
descriptor.enumerable = false;
|
|
3912
|
-
|
|
3913
|
-
if ('writable' in descriptor) {
|
|
3914
|
-
descriptor.writable = false;
|
|
3915
|
-
return;
|
|
3916
|
-
}
|
|
3917
|
-
|
|
3918
|
-
if (!descriptor.set) {
|
|
3919
|
-
descriptor.set = () => {
|
|
3920
|
-
throw Error('Can not rewrite read-only method \'' + name + '\'');
|
|
3921
|
-
};
|
|
3922
|
-
}
|
|
3923
|
-
});
|
|
3924
|
-
};
|
|
3925
|
-
|
|
3926
|
-
const toObjectSet = (arrayOrString, delimiter) => {
|
|
3927
|
-
const obj = {};
|
|
3928
|
-
|
|
3929
|
-
const define = (arr) => {
|
|
3930
|
-
arr.forEach(value => {
|
|
3931
|
-
obj[value] = true;
|
|
3932
|
-
});
|
|
3933
|
-
};
|
|
3934
|
-
|
|
3935
|
-
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|
3936
|
-
|
|
3937
|
-
return obj;
|
|
3938
|
-
};
|
|
3939
|
-
|
|
3940
|
-
const noop$1 = () => {};
|
|
3941
|
-
|
|
3942
|
-
const toFiniteNumber = (value, defaultValue) => {
|
|
3943
|
-
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
3944
|
-
};
|
|
3945
|
-
|
|
3946
|
-
/**
|
|
3947
|
-
* If the thing is a FormData object, return true, otherwise return false.
|
|
3948
|
-
*
|
|
3949
|
-
* @param {unknown} thing - The thing to check.
|
|
3950
|
-
*
|
|
3951
|
-
* @returns {boolean}
|
|
3952
|
-
*/
|
|
3953
|
-
function isSpecCompliantForm(thing) {
|
|
3954
|
-
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
|
3955
|
-
}
|
|
3956
|
-
|
|
3957
|
-
const toJSONObject = (obj) => {
|
|
3958
|
-
const stack = new Array(10);
|
|
3959
|
-
|
|
3960
|
-
const visit = (source, i) => {
|
|
3961
|
-
|
|
3962
|
-
if (isObject(source)) {
|
|
3963
|
-
if (stack.indexOf(source) >= 0) {
|
|
3964
|
-
return;
|
|
3965
|
-
}
|
|
3966
|
-
|
|
3967
|
-
if(!('toJSON' in source)) {
|
|
3968
|
-
stack[i] = source;
|
|
3969
|
-
const target = isArray(source) ? [] : {};
|
|
3970
|
-
|
|
3971
|
-
forEach(source, (value, key) => {
|
|
3972
|
-
const reducedValue = visit(value, i + 1);
|
|
3973
|
-
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
3974
|
-
});
|
|
3975
|
-
|
|
3976
|
-
stack[i] = undefined;
|
|
3977
|
-
|
|
3978
|
-
return target;
|
|
3979
|
-
}
|
|
3980
|
-
}
|
|
3981
|
-
|
|
3982
|
-
return source;
|
|
3983
|
-
};
|
|
3984
|
-
|
|
3985
|
-
return visit(obj, 0);
|
|
3986
|
-
};
|
|
3987
|
-
|
|
3988
|
-
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
3989
|
-
|
|
3990
|
-
const isThenable = (thing) =>
|
|
3991
|
-
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
3992
|
-
|
|
3993
|
-
// original code
|
|
3994
|
-
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
3995
|
-
|
|
3996
|
-
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
3997
|
-
if (setImmediateSupported) {
|
|
3998
|
-
return setImmediate;
|
|
3999
|
-
}
|
|
4000
|
-
|
|
4001
|
-
return postMessageSupported ? ((token, callbacks) => {
|
|
4002
|
-
_global.addEventListener("message", ({source, data}) => {
|
|
4003
|
-
if (source === _global && data === token) {
|
|
4004
|
-
callbacks.length && callbacks.shift()();
|
|
4005
|
-
}
|
|
4006
|
-
}, false);
|
|
4007
|
-
|
|
4008
|
-
return (cb) => {
|
|
4009
|
-
callbacks.push(cb);
|
|
4010
|
-
_global.postMessage(token, "*");
|
|
4011
|
-
}
|
|
4012
|
-
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
4013
|
-
})(
|
|
4014
|
-
typeof setImmediate === 'function',
|
|
4015
|
-
isFunction(_global.postMessage)
|
|
4016
|
-
);
|
|
4017
|
-
|
|
4018
|
-
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
4019
|
-
queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
|
|
4020
|
-
|
|
4021
|
-
// *********************
|
|
4022
|
-
|
|
4023
|
-
var utils$1 = {
|
|
4024
|
-
isArray,
|
|
4025
|
-
isArrayBuffer,
|
|
4026
|
-
isBuffer,
|
|
4027
|
-
isFormData,
|
|
4028
|
-
isArrayBufferView,
|
|
4029
|
-
isString,
|
|
4030
|
-
isNumber,
|
|
4031
|
-
isBoolean,
|
|
4032
|
-
isObject,
|
|
4033
|
-
isPlainObject,
|
|
4034
|
-
isReadableStream,
|
|
4035
|
-
isRequest,
|
|
4036
|
-
isResponse,
|
|
4037
|
-
isHeaders,
|
|
4038
|
-
isUndefined,
|
|
4039
|
-
isDate,
|
|
4040
|
-
isFile,
|
|
4041
|
-
isBlob,
|
|
4042
|
-
isRegExp,
|
|
4043
|
-
isFunction,
|
|
4044
|
-
isStream,
|
|
4045
|
-
isURLSearchParams,
|
|
4046
|
-
isTypedArray,
|
|
4047
|
-
isFileList,
|
|
4048
|
-
forEach,
|
|
4049
|
-
merge,
|
|
4050
|
-
extend,
|
|
4051
|
-
trim,
|
|
4052
|
-
stripBOM,
|
|
4053
|
-
inherits,
|
|
4054
|
-
toFlatObject,
|
|
4055
|
-
kindOf,
|
|
4056
|
-
kindOfTest,
|
|
4057
|
-
endsWith,
|
|
4058
|
-
toArray,
|
|
4059
|
-
forEachEntry,
|
|
4060
|
-
matchAll,
|
|
4061
|
-
isHTMLForm,
|
|
4062
|
-
hasOwnProperty,
|
|
4063
|
-
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
|
4064
|
-
reduceDescriptors,
|
|
4065
|
-
freezeMethods,
|
|
4066
|
-
toObjectSet,
|
|
4067
|
-
toCamelCase,
|
|
4068
|
-
noop: noop$1,
|
|
4069
|
-
toFiniteNumber,
|
|
4070
|
-
findKey,
|
|
4071
|
-
global: _global,
|
|
4072
|
-
isContextDefined,
|
|
4073
|
-
isSpecCompliantForm,
|
|
4074
|
-
toJSONObject,
|
|
4075
|
-
isAsyncFn,
|
|
4076
|
-
isThenable,
|
|
4077
|
-
setImmediate: _setImmediate,
|
|
4078
|
-
asap
|
|
4079
|
-
};
|
|
4080
|
-
|
|
4081
|
-
/**
|
|
4082
|
-
* Create an Error with the specified message, config, error code, request and response.
|
|
4083
|
-
*
|
|
4084
|
-
* @param {string} message The error message.
|
|
4085
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
4086
|
-
* @param {Object} [config] The config.
|
|
4087
|
-
* @param {Object} [request] The request.
|
|
4088
|
-
* @param {Object} [response] The response.
|
|
4089
|
-
*
|
|
4090
|
-
* @returns {Error} The created error.
|
|
4091
|
-
*/
|
|
4092
|
-
function AxiosError$1(message, code, config, request, response) {
|
|
4093
|
-
Error.call(this);
|
|
4094
|
-
|
|
4095
|
-
if (Error.captureStackTrace) {
|
|
4096
|
-
Error.captureStackTrace(this, this.constructor);
|
|
4097
|
-
} else {
|
|
4098
|
-
this.stack = (new Error()).stack;
|
|
4099
|
-
}
|
|
4100
|
-
|
|
4101
|
-
this.message = message;
|
|
4102
|
-
this.name = 'AxiosError';
|
|
4103
|
-
code && (this.code = code);
|
|
4104
|
-
config && (this.config = config);
|
|
4105
|
-
request && (this.request = request);
|
|
4106
|
-
if (response) {
|
|
4107
|
-
this.response = response;
|
|
4108
|
-
this.status = response.status ? response.status : null;
|
|
4109
|
-
}
|
|
4110
|
-
}
|
|
4111
|
-
|
|
4112
|
-
utils$1.inherits(AxiosError$1, Error, {
|
|
4113
|
-
toJSON: function toJSON() {
|
|
4114
|
-
return {
|
|
4115
|
-
// Standard
|
|
4116
|
-
message: this.message,
|
|
4117
|
-
name: this.name,
|
|
4118
|
-
// Microsoft
|
|
4119
|
-
description: this.description,
|
|
4120
|
-
number: this.number,
|
|
4121
|
-
// Mozilla
|
|
4122
|
-
fileName: this.fileName,
|
|
4123
|
-
lineNumber: this.lineNumber,
|
|
4124
|
-
columnNumber: this.columnNumber,
|
|
4125
|
-
stack: this.stack,
|
|
4126
|
-
// Axios
|
|
4127
|
-
config: utils$1.toJSONObject(this.config),
|
|
4128
|
-
code: this.code,
|
|
4129
|
-
status: this.status
|
|
4130
|
-
};
|
|
4131
|
-
}
|
|
4132
|
-
});
|
|
4133
|
-
|
|
4134
|
-
const prototype$1 = AxiosError$1.prototype;
|
|
4135
|
-
const descriptors = {};
|
|
4136
|
-
|
|
4137
|
-
[
|
|
4138
|
-
'ERR_BAD_OPTION_VALUE',
|
|
4139
|
-
'ERR_BAD_OPTION',
|
|
4140
|
-
'ECONNABORTED',
|
|
4141
|
-
'ETIMEDOUT',
|
|
4142
|
-
'ERR_NETWORK',
|
|
4143
|
-
'ERR_FR_TOO_MANY_REDIRECTS',
|
|
4144
|
-
'ERR_DEPRECATED',
|
|
4145
|
-
'ERR_BAD_RESPONSE',
|
|
4146
|
-
'ERR_BAD_REQUEST',
|
|
4147
|
-
'ERR_CANCELED',
|
|
4148
|
-
'ERR_NOT_SUPPORT',
|
|
4149
|
-
'ERR_INVALID_URL'
|
|
4150
|
-
// eslint-disable-next-line func-names
|
|
4151
|
-
].forEach(code => {
|
|
4152
|
-
descriptors[code] = {value: code};
|
|
4153
|
-
});
|
|
4154
|
-
|
|
4155
|
-
Object.defineProperties(AxiosError$1, descriptors);
|
|
4156
|
-
Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
4157
|
-
|
|
4158
|
-
// eslint-disable-next-line func-names
|
|
4159
|
-
AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
|
4160
|
-
const axiosError = Object.create(prototype$1);
|
|
4161
|
-
|
|
4162
|
-
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
4163
|
-
return obj !== Error.prototype;
|
|
4164
|
-
}, prop => {
|
|
4165
|
-
return prop !== 'isAxiosError';
|
|
4166
|
-
});
|
|
4167
|
-
|
|
4168
|
-
AxiosError$1.call(axiosError, error.message, code, config, request, response);
|
|
4169
|
-
|
|
4170
|
-
axiosError.cause = error;
|
|
4171
|
-
|
|
4172
|
-
axiosError.name = error.name;
|
|
4173
|
-
|
|
4174
|
-
customProps && Object.assign(axiosError, customProps);
|
|
4175
|
-
|
|
4176
|
-
return axiosError;
|
|
4177
|
-
};
|
|
4178
|
-
|
|
4179
|
-
// eslint-disable-next-line strict
|
|
4180
|
-
var httpAdapter = null;
|
|
4181
|
-
|
|
4182
|
-
/**
|
|
4183
|
-
* Determines if the given thing is a array or js object.
|
|
4184
|
-
*
|
|
4185
|
-
* @param {string} thing - The object or array to be visited.
|
|
4186
|
-
*
|
|
4187
|
-
* @returns {boolean}
|
|
4188
|
-
*/
|
|
4189
|
-
function isVisitable(thing) {
|
|
4190
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
4191
|
-
}
|
|
4192
|
-
|
|
4193
|
-
/**
|
|
4194
|
-
* It removes the brackets from the end of a string
|
|
4195
|
-
*
|
|
4196
|
-
* @param {string} key - The key of the parameter.
|
|
4197
|
-
*
|
|
4198
|
-
* @returns {string} the key without the brackets.
|
|
4199
|
-
*/
|
|
4200
|
-
function removeBrackets(key) {
|
|
4201
|
-
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
4202
|
-
}
|
|
4203
|
-
|
|
4204
|
-
/**
|
|
4205
|
-
* It takes a path, a key, and a boolean, and returns a string
|
|
4206
|
-
*
|
|
4207
|
-
* @param {string} path - The path to the current key.
|
|
4208
|
-
* @param {string} key - The key of the current object being iterated over.
|
|
4209
|
-
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
4210
|
-
*
|
|
4211
|
-
* @returns {string} The path to the current key.
|
|
4212
|
-
*/
|
|
4213
|
-
function renderKey(path, key, dots) {
|
|
4214
|
-
if (!path) return key;
|
|
4215
|
-
return path.concat(key).map(function each(token, i) {
|
|
4216
|
-
// eslint-disable-next-line no-param-reassign
|
|
4217
|
-
token = removeBrackets(token);
|
|
4218
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
4219
|
-
}).join(dots ? '.' : '');
|
|
4220
|
-
}
|
|
4221
|
-
|
|
4222
|
-
/**
|
|
4223
|
-
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
4224
|
-
*
|
|
4225
|
-
* @param {Array<any>} arr - The array to check
|
|
4226
|
-
*
|
|
4227
|
-
* @returns {boolean}
|
|
4228
|
-
*/
|
|
4229
|
-
function isFlatArray(arr) {
|
|
4230
|
-
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
4231
|
-
}
|
|
4232
|
-
|
|
4233
|
-
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
4234
|
-
return /^is[A-Z]/.test(prop);
|
|
4235
|
-
});
|
|
4236
|
-
|
|
4237
|
-
/**
|
|
4238
|
-
* Convert a data object to FormData
|
|
4239
|
-
*
|
|
4240
|
-
* @param {Object} obj
|
|
4241
|
-
* @param {?Object} [formData]
|
|
4242
|
-
* @param {?Object} [options]
|
|
4243
|
-
* @param {Function} [options.visitor]
|
|
4244
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
4245
|
-
* @param {Boolean} [options.dots = false]
|
|
4246
|
-
* @param {?Boolean} [options.indexes = false]
|
|
4247
|
-
*
|
|
4248
|
-
* @returns {Object}
|
|
4249
|
-
**/
|
|
4250
|
-
|
|
4251
|
-
/**
|
|
4252
|
-
* It converts an object into a FormData object
|
|
4253
|
-
*
|
|
4254
|
-
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
4255
|
-
* @param {string} formData - The FormData object to append to.
|
|
4256
|
-
* @param {Object<string, any>} options
|
|
4257
|
-
*
|
|
4258
|
-
* @returns
|
|
4259
|
-
*/
|
|
4260
|
-
function toFormData$1(obj, formData, options) {
|
|
4261
|
-
if (!utils$1.isObject(obj)) {
|
|
4262
|
-
throw new TypeError('target must be an object');
|
|
4263
|
-
}
|
|
4264
|
-
|
|
4265
|
-
// eslint-disable-next-line no-param-reassign
|
|
4266
|
-
formData = formData || new (FormData)();
|
|
4267
|
-
|
|
4268
|
-
// eslint-disable-next-line no-param-reassign
|
|
4269
|
-
options = utils$1.toFlatObject(options, {
|
|
4270
|
-
metaTokens: true,
|
|
4271
|
-
dots: false,
|
|
4272
|
-
indexes: false
|
|
4273
|
-
}, false, function defined(option, source) {
|
|
4274
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
4275
|
-
return !utils$1.isUndefined(source[option]);
|
|
4276
|
-
});
|
|
4277
|
-
|
|
4278
|
-
const metaTokens = options.metaTokens;
|
|
4279
|
-
// eslint-disable-next-line no-use-before-define
|
|
4280
|
-
const visitor = options.visitor || defaultVisitor;
|
|
4281
|
-
const dots = options.dots;
|
|
4282
|
-
const indexes = options.indexes;
|
|
4283
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
4284
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
4285
|
-
|
|
4286
|
-
if (!utils$1.isFunction(visitor)) {
|
|
4287
|
-
throw new TypeError('visitor must be a function');
|
|
4288
|
-
}
|
|
4289
|
-
|
|
4290
|
-
function convertValue(value) {
|
|
4291
|
-
if (value === null) return '';
|
|
4292
|
-
|
|
4293
|
-
if (utils$1.isDate(value)) {
|
|
4294
|
-
return value.toISOString();
|
|
4295
|
-
}
|
|
4296
|
-
|
|
4297
|
-
if (!useBlob && utils$1.isBlob(value)) {
|
|
4298
|
-
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
|
4299
|
-
}
|
|
4300
|
-
|
|
4301
|
-
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
4302
|
-
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
4303
|
-
}
|
|
4304
|
-
|
|
4305
|
-
return value;
|
|
4306
|
-
}
|
|
4307
|
-
|
|
4308
|
-
/**
|
|
4309
|
-
* Default visitor.
|
|
4310
|
-
*
|
|
4311
|
-
* @param {*} value
|
|
4312
|
-
* @param {String|Number} key
|
|
4313
|
-
* @param {Array<String|Number>} path
|
|
4314
|
-
* @this {FormData}
|
|
4315
|
-
*
|
|
4316
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
4317
|
-
*/
|
|
4318
|
-
function defaultVisitor(value, key, path) {
|
|
4319
|
-
let arr = value;
|
|
4320
|
-
|
|
4321
|
-
if (value && !path && typeof value === 'object') {
|
|
4322
|
-
if (utils$1.endsWith(key, '{}')) {
|
|
4323
|
-
// eslint-disable-next-line no-param-reassign
|
|
4324
|
-
key = metaTokens ? key : key.slice(0, -2);
|
|
4325
|
-
// eslint-disable-next-line no-param-reassign
|
|
4326
|
-
value = JSON.stringify(value);
|
|
4327
|
-
} else if (
|
|
4328
|
-
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
4329
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
4330
|
-
)) {
|
|
4331
|
-
// eslint-disable-next-line no-param-reassign
|
|
4332
|
-
key = removeBrackets(key);
|
|
4333
|
-
|
|
4334
|
-
arr.forEach(function each(el, index) {
|
|
4335
|
-
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
|
4336
|
-
// eslint-disable-next-line no-nested-ternary
|
|
4337
|
-
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
4338
|
-
convertValue(el)
|
|
4339
|
-
);
|
|
4340
|
-
});
|
|
4341
|
-
return false;
|
|
4342
|
-
}
|
|
4343
|
-
}
|
|
4344
|
-
|
|
4345
|
-
if (isVisitable(value)) {
|
|
4346
|
-
return true;
|
|
4347
|
-
}
|
|
4348
|
-
|
|
4349
|
-
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
4350
|
-
|
|
4351
|
-
return false;
|
|
4352
|
-
}
|
|
4353
|
-
|
|
4354
|
-
const stack = [];
|
|
4355
|
-
|
|
4356
|
-
const exposedHelpers = Object.assign(predicates, {
|
|
4357
|
-
defaultVisitor,
|
|
4358
|
-
convertValue,
|
|
4359
|
-
isVisitable
|
|
4360
|
-
});
|
|
4361
|
-
|
|
4362
|
-
function build(value, path) {
|
|
4363
|
-
if (utils$1.isUndefined(value)) return;
|
|
4364
|
-
|
|
4365
|
-
if (stack.indexOf(value) !== -1) {
|
|
4366
|
-
throw Error('Circular reference detected in ' + path.join('.'));
|
|
4367
|
-
}
|
|
4368
|
-
|
|
4369
|
-
stack.push(value);
|
|
4370
|
-
|
|
4371
|
-
utils$1.forEach(value, function each(el, key) {
|
|
4372
|
-
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
|
4373
|
-
formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
4374
|
-
);
|
|
4375
|
-
|
|
4376
|
-
if (result === true) {
|
|
4377
|
-
build(el, path ? path.concat(key) : [key]);
|
|
4378
|
-
}
|
|
4379
|
-
});
|
|
4380
|
-
|
|
4381
|
-
stack.pop();
|
|
4382
|
-
}
|
|
4383
|
-
|
|
4384
|
-
if (!utils$1.isObject(obj)) {
|
|
4385
|
-
throw new TypeError('data must be an object');
|
|
4386
|
-
}
|
|
4387
|
-
|
|
4388
|
-
build(obj);
|
|
4389
|
-
|
|
4390
|
-
return formData;
|
|
4391
|
-
}
|
|
4392
|
-
|
|
4393
|
-
/**
|
|
4394
|
-
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
4395
|
-
* their percent-encoded equivalents
|
|
4396
|
-
*
|
|
4397
|
-
* @param {string} str - The string to encode.
|
|
4398
|
-
*
|
|
4399
|
-
* @returns {string} The encoded string.
|
|
4400
|
-
*/
|
|
4401
|
-
function encode$1(str) {
|
|
4402
|
-
const charMap = {
|
|
4403
|
-
'!': '%21',
|
|
4404
|
-
"'": '%27',
|
|
4405
|
-
'(': '%28',
|
|
4406
|
-
')': '%29',
|
|
4407
|
-
'~': '%7E',
|
|
4408
|
-
'%20': '+',
|
|
4409
|
-
'%00': '\x00'
|
|
4410
|
-
};
|
|
4411
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
4412
|
-
return charMap[match];
|
|
4413
|
-
});
|
|
4414
|
-
}
|
|
4415
|
-
|
|
4416
|
-
/**
|
|
4417
|
-
* It takes a params object and converts it to a FormData object
|
|
4418
|
-
*
|
|
4419
|
-
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
4420
|
-
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
4421
|
-
*
|
|
4422
|
-
* @returns {void}
|
|
4423
|
-
*/
|
|
4424
|
-
function AxiosURLSearchParams(params, options) {
|
|
4425
|
-
this._pairs = [];
|
|
4426
|
-
|
|
4427
|
-
params && toFormData$1(params, this, options);
|
|
4428
|
-
}
|
|
4429
|
-
|
|
4430
|
-
const prototype = AxiosURLSearchParams.prototype;
|
|
4431
|
-
|
|
4432
|
-
prototype.append = function append(name, value) {
|
|
4433
|
-
this._pairs.push([name, value]);
|
|
4434
|
-
};
|
|
4435
|
-
|
|
4436
|
-
prototype.toString = function toString(encoder) {
|
|
4437
|
-
const _encode = encoder ? function(value) {
|
|
4438
|
-
return encoder.call(this, value, encode$1);
|
|
4439
|
-
} : encode$1;
|
|
4440
|
-
|
|
4441
|
-
return this._pairs.map(function each(pair) {
|
|
4442
|
-
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
4443
|
-
}, '').join('&');
|
|
4444
|
-
};
|
|
4445
|
-
|
|
4446
|
-
/**
|
|
4447
|
-
* It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
|
|
4448
|
-
* URI encoded counterparts
|
|
4449
|
-
*
|
|
4450
|
-
* @param {string} val The value to be encoded.
|
|
4451
|
-
*
|
|
4452
|
-
* @returns {string} The encoded value.
|
|
4453
|
-
*/
|
|
4454
|
-
function encode(val) {
|
|
4455
|
-
return encodeURIComponent(val).
|
|
4456
|
-
replace(/%3A/gi, ':').
|
|
4457
|
-
replace(/%24/g, '$').
|
|
4458
|
-
replace(/%2C/gi, ',').
|
|
4459
|
-
replace(/%20/g, '+').
|
|
4460
|
-
replace(/%5B/gi, '[').
|
|
4461
|
-
replace(/%5D/gi, ']');
|
|
4462
|
-
}
|
|
4463
|
-
|
|
4464
|
-
/**
|
|
4465
|
-
* Build a URL by appending params to the end
|
|
4466
|
-
*
|
|
4467
|
-
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
4468
|
-
* @param {object} [params] The params to be appended
|
|
4469
|
-
* @param {?(object|Function)} options
|
|
4470
|
-
*
|
|
4471
|
-
* @returns {string} The formatted url
|
|
4472
|
-
*/
|
|
4473
|
-
function buildURL(url, params, options) {
|
|
4474
|
-
/*eslint no-param-reassign:0*/
|
|
4475
|
-
if (!params) {
|
|
4476
|
-
return url;
|
|
4477
|
-
}
|
|
4478
|
-
|
|
4479
|
-
const _encode = options && options.encode || encode;
|
|
4480
|
-
|
|
4481
|
-
if (utils$1.isFunction(options)) {
|
|
4482
|
-
options = {
|
|
4483
|
-
serialize: options
|
|
4484
|
-
};
|
|
4485
|
-
}
|
|
4486
|
-
|
|
4487
|
-
const serializeFn = options && options.serialize;
|
|
4488
|
-
|
|
4489
|
-
let serializedParams;
|
|
4490
|
-
|
|
4491
|
-
if (serializeFn) {
|
|
4492
|
-
serializedParams = serializeFn(params, options);
|
|
4493
|
-
} else {
|
|
4494
|
-
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
4495
|
-
params.toString() :
|
|
4496
|
-
new AxiosURLSearchParams(params, options).toString(_encode);
|
|
4497
|
-
}
|
|
4498
|
-
|
|
4499
|
-
if (serializedParams) {
|
|
4500
|
-
const hashmarkIndex = url.indexOf("#");
|
|
4501
|
-
|
|
4502
|
-
if (hashmarkIndex !== -1) {
|
|
4503
|
-
url = url.slice(0, hashmarkIndex);
|
|
4504
|
-
}
|
|
4505
|
-
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
4506
|
-
}
|
|
4507
|
-
|
|
4508
|
-
return url;
|
|
4509
|
-
}
|
|
4510
|
-
|
|
4511
|
-
class InterceptorManager {
|
|
4512
|
-
constructor() {
|
|
4513
|
-
this.handlers = [];
|
|
4514
|
-
}
|
|
4515
|
-
|
|
4516
|
-
/**
|
|
4517
|
-
* Add a new interceptor to the stack
|
|
4518
|
-
*
|
|
4519
|
-
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
4520
|
-
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
4521
|
-
*
|
|
4522
|
-
* @return {Number} An ID used to remove interceptor later
|
|
4523
|
-
*/
|
|
4524
|
-
use(fulfilled, rejected, options) {
|
|
4525
|
-
this.handlers.push({
|
|
4526
|
-
fulfilled,
|
|
4527
|
-
rejected,
|
|
4528
|
-
synchronous: options ? options.synchronous : false,
|
|
4529
|
-
runWhen: options ? options.runWhen : null
|
|
4530
|
-
});
|
|
4531
|
-
return this.handlers.length - 1;
|
|
4532
|
-
}
|
|
4533
|
-
|
|
4534
|
-
/**
|
|
4535
|
-
* Remove an interceptor from the stack
|
|
4536
|
-
*
|
|
4537
|
-
* @param {Number} id The ID that was returned by `use`
|
|
4538
|
-
*
|
|
4539
|
-
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
|
4540
|
-
*/
|
|
4541
|
-
eject(id) {
|
|
4542
|
-
if (this.handlers[id]) {
|
|
4543
|
-
this.handlers[id] = null;
|
|
4544
|
-
}
|
|
4545
|
-
}
|
|
4546
|
-
|
|
4547
|
-
/**
|
|
4548
|
-
* Clear all interceptors from the stack
|
|
4549
|
-
*
|
|
4550
|
-
* @returns {void}
|
|
4551
|
-
*/
|
|
4552
|
-
clear() {
|
|
4553
|
-
if (this.handlers) {
|
|
4554
|
-
this.handlers = [];
|
|
4555
|
-
}
|
|
4556
|
-
}
|
|
4557
|
-
|
|
4558
|
-
/**
|
|
4559
|
-
* Iterate over all the registered interceptors
|
|
4560
|
-
*
|
|
4561
|
-
* This method is particularly useful for skipping over any
|
|
4562
|
-
* interceptors that may have become `null` calling `eject`.
|
|
4563
|
-
*
|
|
4564
|
-
* @param {Function} fn The function to call for each interceptor
|
|
4565
|
-
*
|
|
4566
|
-
* @returns {void}
|
|
4567
|
-
*/
|
|
4568
|
-
forEach(fn) {
|
|
4569
|
-
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
4570
|
-
if (h !== null) {
|
|
4571
|
-
fn(h);
|
|
4572
|
-
}
|
|
4573
|
-
});
|
|
4574
|
-
}
|
|
4575
|
-
}
|
|
4576
|
-
|
|
4577
|
-
var transitionalDefaults = {
|
|
4578
|
-
silentJSONParsing: true,
|
|
4579
|
-
forcedJSONParsing: true,
|
|
4580
|
-
clarifyTimeoutError: false
|
|
4581
|
-
};
|
|
4582
|
-
|
|
4583
|
-
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
4584
|
-
|
|
4585
|
-
var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
4586
|
-
|
|
4587
|
-
var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
4588
|
-
|
|
4589
|
-
var platform$2 = {
|
|
4590
|
-
isBrowser: true,
|
|
4591
|
-
classes: {
|
|
4592
|
-
URLSearchParams: URLSearchParams$1,
|
|
4593
|
-
FormData: FormData$1,
|
|
4594
|
-
Blob: Blob$1
|
|
4595
|
-
},
|
|
4596
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
4597
|
-
};
|
|
4598
|
-
|
|
4599
|
-
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
4600
|
-
|
|
4601
|
-
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
4602
|
-
|
|
4603
|
-
/**
|
|
4604
|
-
* Determine if we're running in a standard browser environment
|
|
4605
|
-
*
|
|
4606
|
-
* This allows axios to run in a web worker, and react-native.
|
|
4607
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
4608
|
-
*
|
|
4609
|
-
* web workers:
|
|
4610
|
-
* typeof window -> undefined
|
|
4611
|
-
* typeof document -> undefined
|
|
4612
|
-
*
|
|
4613
|
-
* react-native:
|
|
4614
|
-
* navigator.product -> 'ReactNative'
|
|
4615
|
-
* nativescript
|
|
4616
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
|
4617
|
-
*
|
|
4618
|
-
* @returns {boolean}
|
|
4619
|
-
*/
|
|
4620
|
-
const hasStandardBrowserEnv = hasBrowserEnv &&
|
|
4621
|
-
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
4622
|
-
|
|
4623
|
-
/**
|
|
4624
|
-
* Determine if we're running in a standard browser webWorker environment
|
|
4625
|
-
*
|
|
4626
|
-
* Although the `isStandardBrowserEnv` method indicates that
|
|
4627
|
-
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
4628
|
-
* filtered out due to its judgment standard
|
|
4629
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
4630
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
|
4631
|
-
*/
|
|
4632
|
-
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
4633
|
-
return (
|
|
4634
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
|
4635
|
-
// eslint-disable-next-line no-undef
|
|
4636
|
-
self instanceof WorkerGlobalScope &&
|
|
4637
|
-
typeof self.importScripts === 'function'
|
|
4638
|
-
);
|
|
4639
|
-
})();
|
|
4640
|
-
|
|
4641
|
-
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
4642
|
-
|
|
4643
|
-
var utils = /*#__PURE__*/Object.freeze({
|
|
4644
|
-
__proto__: null,
|
|
4645
|
-
hasBrowserEnv: hasBrowserEnv,
|
|
4646
|
-
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
4647
|
-
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
4648
|
-
navigator: _navigator,
|
|
4649
|
-
origin: origin
|
|
4650
|
-
});
|
|
4651
|
-
|
|
4652
|
-
var platform$1 = {
|
|
4653
|
-
...utils,
|
|
4654
|
-
...platform$2
|
|
4655
|
-
};
|
|
4656
|
-
|
|
4657
|
-
function toURLEncodedForm(data, options) {
|
|
4658
|
-
return toFormData$1(data, new platform$1.classes.URLSearchParams(), Object.assign({
|
|
4659
|
-
visitor: function(value, key, path, helpers) {
|
|
4660
|
-
if (platform$1.isNode && utils$1.isBuffer(value)) {
|
|
4661
|
-
this.append(key, value.toString('base64'));
|
|
4662
|
-
return false;
|
|
4663
|
-
}
|
|
4664
|
-
|
|
4665
|
-
return helpers.defaultVisitor.apply(this, arguments);
|
|
4666
|
-
}
|
|
4667
|
-
}, options));
|
|
4668
|
-
}
|
|
4669
|
-
|
|
4670
|
-
/**
|
|
4671
|
-
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
4672
|
-
*
|
|
4673
|
-
* @param {string} name - The name of the property to get.
|
|
4674
|
-
*
|
|
4675
|
-
* @returns An array of strings.
|
|
4676
|
-
*/
|
|
4677
|
-
function parsePropPath(name) {
|
|
4678
|
-
// foo[x][y][z]
|
|
4679
|
-
// foo.x.y.z
|
|
4680
|
-
// foo-x-y-z
|
|
4681
|
-
// foo x y z
|
|
4682
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
4683
|
-
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
4684
|
-
});
|
|
4685
|
-
}
|
|
4686
|
-
|
|
4687
|
-
/**
|
|
4688
|
-
* Convert an array to an object.
|
|
4689
|
-
*
|
|
4690
|
-
* @param {Array<any>} arr - The array to convert to an object.
|
|
4691
|
-
*
|
|
4692
|
-
* @returns An object with the same keys and values as the array.
|
|
4693
|
-
*/
|
|
4694
|
-
function arrayToObject(arr) {
|
|
4695
|
-
const obj = {};
|
|
4696
|
-
const keys = Object.keys(arr);
|
|
4697
|
-
let i;
|
|
4698
|
-
const len = keys.length;
|
|
4699
|
-
let key;
|
|
4700
|
-
for (i = 0; i < len; i++) {
|
|
4701
|
-
key = keys[i];
|
|
4702
|
-
obj[key] = arr[key];
|
|
4703
|
-
}
|
|
4704
|
-
return obj;
|
|
4705
|
-
}
|
|
4706
|
-
|
|
4707
|
-
/**
|
|
4708
|
-
* It takes a FormData object and returns a JavaScript object
|
|
4709
|
-
*
|
|
4710
|
-
* @param {string} formData The FormData object to convert to JSON.
|
|
4711
|
-
*
|
|
4712
|
-
* @returns {Object<string, any> | null} The converted object.
|
|
4713
|
-
*/
|
|
4714
|
-
function formDataToJSON(formData) {
|
|
4715
|
-
function buildPath(path, value, target, index) {
|
|
4716
|
-
let name = path[index++];
|
|
4717
|
-
|
|
4718
|
-
if (name === '__proto__') return true;
|
|
4719
|
-
|
|
4720
|
-
const isNumericKey = Number.isFinite(+name);
|
|
4721
|
-
const isLast = index >= path.length;
|
|
4722
|
-
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
4723
|
-
|
|
4724
|
-
if (isLast) {
|
|
4725
|
-
if (utils$1.hasOwnProp(target, name)) {
|
|
4726
|
-
target[name] = [target[name], value];
|
|
4727
|
-
} else {
|
|
4728
|
-
target[name] = value;
|
|
4729
|
-
}
|
|
4730
|
-
|
|
4731
|
-
return !isNumericKey;
|
|
4732
|
-
}
|
|
4733
|
-
|
|
4734
|
-
if (!target[name] || !utils$1.isObject(target[name])) {
|
|
4735
|
-
target[name] = [];
|
|
4736
|
-
}
|
|
4737
|
-
|
|
4738
|
-
const result = buildPath(path, value, target[name], index);
|
|
4739
|
-
|
|
4740
|
-
if (result && utils$1.isArray(target[name])) {
|
|
4741
|
-
target[name] = arrayToObject(target[name]);
|
|
4742
|
-
}
|
|
4743
|
-
|
|
4744
|
-
return !isNumericKey;
|
|
4745
|
-
}
|
|
4746
|
-
|
|
4747
|
-
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
4748
|
-
const obj = {};
|
|
4749
|
-
|
|
4750
|
-
utils$1.forEachEntry(formData, (name, value) => {
|
|
4751
|
-
buildPath(parsePropPath(name), value, obj, 0);
|
|
4752
|
-
});
|
|
4753
|
-
|
|
4754
|
-
return obj;
|
|
4755
|
-
}
|
|
4756
|
-
|
|
4757
|
-
return null;
|
|
4758
|
-
}
|
|
4759
|
-
|
|
4760
|
-
/**
|
|
4761
|
-
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
4762
|
-
* of the input
|
|
4763
|
-
*
|
|
4764
|
-
* @param {any} rawValue - The value to be stringified.
|
|
4765
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
4766
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
4767
|
-
*
|
|
4768
|
-
* @returns {string} A stringified version of the rawValue.
|
|
4769
|
-
*/
|
|
4770
|
-
function stringifySafely(rawValue, parser, encoder) {
|
|
4771
|
-
if (utils$1.isString(rawValue)) {
|
|
4772
|
-
try {
|
|
4773
|
-
(parser || JSON.parse)(rawValue);
|
|
4774
|
-
return utils$1.trim(rawValue);
|
|
4775
|
-
} catch (e) {
|
|
4776
|
-
if (e.name !== 'SyntaxError') {
|
|
4777
|
-
throw e;
|
|
4778
|
-
}
|
|
4779
|
-
}
|
|
4780
|
-
}
|
|
4781
|
-
|
|
4782
|
-
return (encoder || JSON.stringify)(rawValue);
|
|
4783
|
-
}
|
|
4784
|
-
|
|
4785
|
-
const defaults = {
|
|
4786
|
-
|
|
4787
|
-
transitional: transitionalDefaults,
|
|
4788
|
-
|
|
4789
|
-
adapter: ['xhr', 'http', 'fetch'],
|
|
4790
|
-
|
|
4791
|
-
transformRequest: [function transformRequest(data, headers) {
|
|
4792
|
-
const contentType = headers.getContentType() || '';
|
|
4793
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
4794
|
-
const isObjectPayload = utils$1.isObject(data);
|
|
4795
|
-
|
|
4796
|
-
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
4797
|
-
data = new FormData(data);
|
|
4798
|
-
}
|
|
4799
|
-
|
|
4800
|
-
const isFormData = utils$1.isFormData(data);
|
|
4801
|
-
|
|
4802
|
-
if (isFormData) {
|
|
4803
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
4804
|
-
}
|
|
4805
|
-
|
|
4806
|
-
if (utils$1.isArrayBuffer(data) ||
|
|
4807
|
-
utils$1.isBuffer(data) ||
|
|
4808
|
-
utils$1.isStream(data) ||
|
|
4809
|
-
utils$1.isFile(data) ||
|
|
4810
|
-
utils$1.isBlob(data) ||
|
|
4811
|
-
utils$1.isReadableStream(data)
|
|
4812
|
-
) {
|
|
4813
|
-
return data;
|
|
4814
|
-
}
|
|
4815
|
-
if (utils$1.isArrayBufferView(data)) {
|
|
4816
|
-
return data.buffer;
|
|
4817
|
-
}
|
|
4818
|
-
if (utils$1.isURLSearchParams(data)) {
|
|
4819
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
4820
|
-
return data.toString();
|
|
4821
|
-
}
|
|
4822
|
-
|
|
4823
|
-
let isFileList;
|
|
4824
|
-
|
|
4825
|
-
if (isObjectPayload) {
|
|
4826
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
4827
|
-
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
4828
|
-
}
|
|
4829
|
-
|
|
4830
|
-
if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
4831
|
-
const _FormData = this.env && this.env.FormData;
|
|
4832
|
-
|
|
4833
|
-
return toFormData$1(
|
|
4834
|
-
isFileList ? {'files[]': data} : data,
|
|
4835
|
-
_FormData && new _FormData(),
|
|
4836
|
-
this.formSerializer
|
|
4837
|
-
);
|
|
4838
|
-
}
|
|
4839
|
-
}
|
|
4840
|
-
|
|
4841
|
-
if (isObjectPayload || hasJSONContentType ) {
|
|
4842
|
-
headers.setContentType('application/json', false);
|
|
4843
|
-
return stringifySafely(data);
|
|
4844
|
-
}
|
|
4845
|
-
|
|
4846
|
-
return data;
|
|
4847
|
-
}],
|
|
4848
|
-
|
|
4849
|
-
transformResponse: [function transformResponse(data) {
|
|
4850
|
-
const transitional = this.transitional || defaults.transitional;
|
|
4851
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
4852
|
-
const JSONRequested = this.responseType === 'json';
|
|
4853
|
-
|
|
4854
|
-
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
4855
|
-
return data;
|
|
4856
|
-
}
|
|
4857
|
-
|
|
4858
|
-
if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
4859
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
4860
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
4861
|
-
|
|
4862
|
-
try {
|
|
4863
|
-
return JSON.parse(data);
|
|
4864
|
-
} catch (e) {
|
|
4865
|
-
if (strictJSONParsing) {
|
|
4866
|
-
if (e.name === 'SyntaxError') {
|
|
4867
|
-
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
4868
|
-
}
|
|
4869
|
-
throw e;
|
|
4870
|
-
}
|
|
4871
|
-
}
|
|
4872
|
-
}
|
|
4873
|
-
|
|
4874
|
-
return data;
|
|
4875
|
-
}],
|
|
4876
|
-
|
|
4877
|
-
/**
|
|
4878
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
4879
|
-
* timeout is not created.
|
|
4880
|
-
*/
|
|
4881
|
-
timeout: 0,
|
|
4882
|
-
|
|
4883
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
|
4884
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
4885
|
-
|
|
4886
|
-
maxContentLength: -1,
|
|
4887
|
-
maxBodyLength: -1,
|
|
4888
|
-
|
|
4889
|
-
env: {
|
|
4890
|
-
FormData: platform$1.classes.FormData,
|
|
4891
|
-
Blob: platform$1.classes.Blob
|
|
4892
|
-
},
|
|
4893
|
-
|
|
4894
|
-
validateStatus: function validateStatus(status) {
|
|
4895
|
-
return status >= 200 && status < 300;
|
|
4896
|
-
},
|
|
4897
|
-
|
|
4898
|
-
headers: {
|
|
4899
|
-
common: {
|
|
4900
|
-
'Accept': 'application/json, text/plain, */*',
|
|
4901
|
-
'Content-Type': undefined
|
|
4902
|
-
}
|
|
4903
|
-
}
|
|
4904
|
-
};
|
|
4905
|
-
|
|
4906
|
-
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
4907
|
-
defaults.headers[method] = {};
|
|
4908
|
-
});
|
|
4909
|
-
|
|
4910
|
-
// RawAxiosHeaders whose duplicates are ignored by node
|
|
4911
|
-
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
4912
|
-
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
4913
|
-
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
4914
|
-
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
4915
|
-
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
4916
|
-
'referer', 'retry-after', 'user-agent'
|
|
4917
|
-
]);
|
|
4918
|
-
|
|
4919
|
-
/**
|
|
4920
|
-
* Parse headers into an object
|
|
4921
|
-
*
|
|
4922
|
-
* ```
|
|
4923
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
4924
|
-
* Content-Type: application/json
|
|
4925
|
-
* Connection: keep-alive
|
|
4926
|
-
* Transfer-Encoding: chunked
|
|
4927
|
-
* ```
|
|
4928
|
-
*
|
|
4929
|
-
* @param {String} rawHeaders Headers needing to be parsed
|
|
4930
|
-
*
|
|
4931
|
-
* @returns {Object} Headers parsed into an object
|
|
4932
|
-
*/
|
|
4933
|
-
var parseHeaders = rawHeaders => {
|
|
4934
|
-
const parsed = {};
|
|
4935
|
-
let key;
|
|
4936
|
-
let val;
|
|
4937
|
-
let i;
|
|
4938
|
-
|
|
4939
|
-
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
|
4940
|
-
i = line.indexOf(':');
|
|
4941
|
-
key = line.substring(0, i).trim().toLowerCase();
|
|
4942
|
-
val = line.substring(i + 1).trim();
|
|
4943
|
-
|
|
4944
|
-
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
4945
|
-
return;
|
|
4946
|
-
}
|
|
4947
|
-
|
|
4948
|
-
if (key === 'set-cookie') {
|
|
4949
|
-
if (parsed[key]) {
|
|
4950
|
-
parsed[key].push(val);
|
|
4951
|
-
} else {
|
|
4952
|
-
parsed[key] = [val];
|
|
4953
|
-
}
|
|
4954
|
-
} else {
|
|
4955
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
4956
|
-
}
|
|
4957
|
-
});
|
|
4958
|
-
|
|
4959
|
-
return parsed;
|
|
4960
|
-
};
|
|
4961
|
-
|
|
4962
|
-
const $internals = Symbol('internals');
|
|
4963
|
-
|
|
4964
|
-
function normalizeHeader(header) {
|
|
4965
|
-
return header && String(header).trim().toLowerCase();
|
|
4966
|
-
}
|
|
4967
|
-
|
|
4968
|
-
function normalizeValue(value) {
|
|
4969
|
-
if (value === false || value == null) {
|
|
4970
|
-
return value;
|
|
4971
|
-
}
|
|
4972
|
-
|
|
4973
|
-
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
4974
|
-
}
|
|
4975
|
-
|
|
4976
|
-
function parseTokens(str) {
|
|
4977
|
-
const tokens = Object.create(null);
|
|
4978
|
-
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
4979
|
-
let match;
|
|
4980
|
-
|
|
4981
|
-
while ((match = tokensRE.exec(str))) {
|
|
4982
|
-
tokens[match[1]] = match[2];
|
|
4983
|
-
}
|
|
4984
|
-
|
|
4985
|
-
return tokens;
|
|
4986
|
-
}
|
|
4987
|
-
|
|
4988
|
-
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
4989
|
-
|
|
4990
|
-
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
4991
|
-
if (utils$1.isFunction(filter)) {
|
|
4992
|
-
return filter.call(this, value, header);
|
|
4993
|
-
}
|
|
4994
|
-
|
|
4995
|
-
if (isHeaderNameFilter) {
|
|
4996
|
-
value = header;
|
|
4997
|
-
}
|
|
4998
|
-
|
|
4999
|
-
if (!utils$1.isString(value)) return;
|
|
5000
|
-
|
|
5001
|
-
if (utils$1.isString(filter)) {
|
|
5002
|
-
return value.indexOf(filter) !== -1;
|
|
5003
|
-
}
|
|
5004
|
-
|
|
5005
|
-
if (utils$1.isRegExp(filter)) {
|
|
5006
|
-
return filter.test(value);
|
|
5007
|
-
}
|
|
5008
|
-
}
|
|
5009
|
-
|
|
5010
|
-
function formatHeader(header) {
|
|
5011
|
-
return header.trim()
|
|
5012
|
-
.toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
5013
|
-
return char.toUpperCase() + str;
|
|
5014
|
-
});
|
|
5015
|
-
}
|
|
5016
|
-
|
|
5017
|
-
function buildAccessors(obj, header) {
|
|
5018
|
-
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
5019
|
-
|
|
5020
|
-
['get', 'set', 'has'].forEach(methodName => {
|
|
5021
|
-
Object.defineProperty(obj, methodName + accessorName, {
|
|
5022
|
-
value: function(arg1, arg2, arg3) {
|
|
5023
|
-
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
5024
|
-
},
|
|
5025
|
-
configurable: true
|
|
5026
|
-
});
|
|
5027
|
-
});
|
|
5028
|
-
}
|
|
5029
|
-
|
|
5030
|
-
let AxiosHeaders$1 = class AxiosHeaders {
|
|
5031
|
-
constructor(headers) {
|
|
5032
|
-
headers && this.set(headers);
|
|
5033
|
-
}
|
|
5034
|
-
|
|
5035
|
-
set(header, valueOrRewrite, rewrite) {
|
|
5036
|
-
const self = this;
|
|
5037
|
-
|
|
5038
|
-
function setHeader(_value, _header, _rewrite) {
|
|
5039
|
-
const lHeader = normalizeHeader(_header);
|
|
5040
|
-
|
|
5041
|
-
if (!lHeader) {
|
|
5042
|
-
throw new Error('header name must be a non-empty string');
|
|
5043
|
-
}
|
|
5044
|
-
|
|
5045
|
-
const key = utils$1.findKey(self, lHeader);
|
|
5046
|
-
|
|
5047
|
-
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
|
5048
|
-
self[key || _header] = normalizeValue(_value);
|
|
5049
|
-
}
|
|
5050
|
-
}
|
|
5051
|
-
|
|
5052
|
-
const setHeaders = (headers, _rewrite) =>
|
|
5053
|
-
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
5054
|
-
|
|
5055
|
-
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
5056
|
-
setHeaders(header, valueOrRewrite);
|
|
5057
|
-
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
5058
|
-
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
5059
|
-
} else if (utils$1.isHeaders(header)) {
|
|
5060
|
-
for (const [key, value] of header.entries()) {
|
|
5061
|
-
setHeader(value, key, rewrite);
|
|
5062
|
-
}
|
|
5063
|
-
} else {
|
|
5064
|
-
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
5065
|
-
}
|
|
5066
|
-
|
|
5067
|
-
return this;
|
|
5068
|
-
}
|
|
5069
|
-
|
|
5070
|
-
get(header, parser) {
|
|
5071
|
-
header = normalizeHeader(header);
|
|
5072
|
-
|
|
5073
|
-
if (header) {
|
|
5074
|
-
const key = utils$1.findKey(this, header);
|
|
5075
|
-
|
|
5076
|
-
if (key) {
|
|
5077
|
-
const value = this[key];
|
|
5078
|
-
|
|
5079
|
-
if (!parser) {
|
|
5080
|
-
return value;
|
|
5081
|
-
}
|
|
5082
|
-
|
|
5083
|
-
if (parser === true) {
|
|
5084
|
-
return parseTokens(value);
|
|
5085
|
-
}
|
|
5086
|
-
|
|
5087
|
-
if (utils$1.isFunction(parser)) {
|
|
5088
|
-
return parser.call(this, value, key);
|
|
5089
|
-
}
|
|
5090
|
-
|
|
5091
|
-
if (utils$1.isRegExp(parser)) {
|
|
5092
|
-
return parser.exec(value);
|
|
5093
|
-
}
|
|
5094
|
-
|
|
5095
|
-
throw new TypeError('parser must be boolean|regexp|function');
|
|
5096
|
-
}
|
|
5097
|
-
}
|
|
5098
|
-
}
|
|
5099
|
-
|
|
5100
|
-
has(header, matcher) {
|
|
5101
|
-
header = normalizeHeader(header);
|
|
5102
|
-
|
|
5103
|
-
if (header) {
|
|
5104
|
-
const key = utils$1.findKey(this, header);
|
|
5105
|
-
|
|
5106
|
-
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
5107
|
-
}
|
|
5108
|
-
|
|
5109
|
-
return false;
|
|
5110
|
-
}
|
|
5111
|
-
|
|
5112
|
-
delete(header, matcher) {
|
|
5113
|
-
const self = this;
|
|
5114
|
-
let deleted = false;
|
|
5115
|
-
|
|
5116
|
-
function deleteHeader(_header) {
|
|
5117
|
-
_header = normalizeHeader(_header);
|
|
5118
|
-
|
|
5119
|
-
if (_header) {
|
|
5120
|
-
const key = utils$1.findKey(self, _header);
|
|
5121
|
-
|
|
5122
|
-
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
5123
|
-
delete self[key];
|
|
5124
|
-
|
|
5125
|
-
deleted = true;
|
|
5126
|
-
}
|
|
5127
|
-
}
|
|
5128
|
-
}
|
|
5129
|
-
|
|
5130
|
-
if (utils$1.isArray(header)) {
|
|
5131
|
-
header.forEach(deleteHeader);
|
|
5132
|
-
} else {
|
|
5133
|
-
deleteHeader(header);
|
|
5134
|
-
}
|
|
5135
|
-
|
|
5136
|
-
return deleted;
|
|
5137
|
-
}
|
|
5138
|
-
|
|
5139
|
-
clear(matcher) {
|
|
5140
|
-
const keys = Object.keys(this);
|
|
5141
|
-
let i = keys.length;
|
|
5142
|
-
let deleted = false;
|
|
5143
|
-
|
|
5144
|
-
while (i--) {
|
|
5145
|
-
const key = keys[i];
|
|
5146
|
-
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
5147
|
-
delete this[key];
|
|
5148
|
-
deleted = true;
|
|
5149
|
-
}
|
|
5150
|
-
}
|
|
5151
|
-
|
|
5152
|
-
return deleted;
|
|
5153
|
-
}
|
|
5154
|
-
|
|
5155
|
-
normalize(format) {
|
|
5156
|
-
const self = this;
|
|
5157
|
-
const headers = {};
|
|
5158
|
-
|
|
5159
|
-
utils$1.forEach(this, (value, header) => {
|
|
5160
|
-
const key = utils$1.findKey(headers, header);
|
|
5161
|
-
|
|
5162
|
-
if (key) {
|
|
5163
|
-
self[key] = normalizeValue(value);
|
|
5164
|
-
delete self[header];
|
|
5165
|
-
return;
|
|
5166
|
-
}
|
|
5167
|
-
|
|
5168
|
-
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
5169
|
-
|
|
5170
|
-
if (normalized !== header) {
|
|
5171
|
-
delete self[header];
|
|
5172
|
-
}
|
|
5173
|
-
|
|
5174
|
-
self[normalized] = normalizeValue(value);
|
|
5175
|
-
|
|
5176
|
-
headers[normalized] = true;
|
|
5177
|
-
});
|
|
5178
|
-
|
|
5179
|
-
return this;
|
|
5180
|
-
}
|
|
5181
|
-
|
|
5182
|
-
concat(...targets) {
|
|
5183
|
-
return this.constructor.concat(this, ...targets);
|
|
5184
|
-
}
|
|
5185
|
-
|
|
5186
|
-
toJSON(asStrings) {
|
|
5187
|
-
const obj = Object.create(null);
|
|
5188
|
-
|
|
5189
|
-
utils$1.forEach(this, (value, header) => {
|
|
5190
|
-
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
5191
|
-
});
|
|
5192
|
-
|
|
5193
|
-
return obj;
|
|
5194
|
-
}
|
|
5195
|
-
|
|
5196
|
-
[Symbol.iterator]() {
|
|
5197
|
-
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
5198
|
-
}
|
|
5199
|
-
|
|
5200
|
-
toString() {
|
|
5201
|
-
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
|
5202
|
-
}
|
|
5203
|
-
|
|
5204
|
-
get [Symbol.toStringTag]() {
|
|
5205
|
-
return 'AxiosHeaders';
|
|
5206
|
-
}
|
|
5207
|
-
|
|
5208
|
-
static from(thing) {
|
|
5209
|
-
return thing instanceof this ? thing : new this(thing);
|
|
5210
|
-
}
|
|
5211
|
-
|
|
5212
|
-
static concat(first, ...targets) {
|
|
5213
|
-
const computed = new this(first);
|
|
5214
|
-
|
|
5215
|
-
targets.forEach((target) => computed.set(target));
|
|
5216
|
-
|
|
5217
|
-
return computed;
|
|
5218
|
-
}
|
|
5219
|
-
|
|
5220
|
-
static accessor(header) {
|
|
5221
|
-
const internals = this[$internals] = (this[$internals] = {
|
|
5222
|
-
accessors: {}
|
|
5223
|
-
});
|
|
5224
|
-
|
|
5225
|
-
const accessors = internals.accessors;
|
|
5226
|
-
const prototype = this.prototype;
|
|
5227
|
-
|
|
5228
|
-
function defineAccessor(_header) {
|
|
5229
|
-
const lHeader = normalizeHeader(_header);
|
|
5230
|
-
|
|
5231
|
-
if (!accessors[lHeader]) {
|
|
5232
|
-
buildAccessors(prototype, _header);
|
|
5233
|
-
accessors[lHeader] = true;
|
|
5234
|
-
}
|
|
5235
|
-
}
|
|
5236
|
-
|
|
5237
|
-
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
5238
|
-
|
|
5239
|
-
return this;
|
|
5240
|
-
}
|
|
5241
|
-
};
|
|
5242
|
-
|
|
5243
|
-
AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|
5244
|
-
|
|
5245
|
-
// reserved names hotfix
|
|
5246
|
-
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
|
|
5247
|
-
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
5248
|
-
return {
|
|
5249
|
-
get: () => value,
|
|
5250
|
-
set(headerValue) {
|
|
5251
|
-
this[mapped] = headerValue;
|
|
5252
|
-
}
|
|
5253
|
-
}
|
|
5254
|
-
});
|
|
5255
|
-
|
|
5256
|
-
utils$1.freezeMethods(AxiosHeaders$1);
|
|
5257
|
-
|
|
5258
|
-
/**
|
|
5259
|
-
* Transform the data for a request or a response
|
|
5260
|
-
*
|
|
5261
|
-
* @param {Array|Function} fns A single function or Array of functions
|
|
5262
|
-
* @param {?Object} response The response object
|
|
5263
|
-
*
|
|
5264
|
-
* @returns {*} The resulting transformed data
|
|
5265
|
-
*/
|
|
5266
|
-
function transformData(fns, response) {
|
|
5267
|
-
const config = this || defaults;
|
|
5268
|
-
const context = response || config;
|
|
5269
|
-
const headers = AxiosHeaders$1.from(context.headers);
|
|
5270
|
-
let data = context.data;
|
|
5271
|
-
|
|
5272
|
-
utils$1.forEach(fns, function transform(fn) {
|
|
5273
|
-
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
5274
|
-
});
|
|
5275
|
-
|
|
5276
|
-
headers.normalize();
|
|
5277
|
-
|
|
5278
|
-
return data;
|
|
5279
|
-
}
|
|
5280
|
-
|
|
5281
|
-
function isCancel$1(value) {
|
|
5282
|
-
return !!(value && value.__CANCEL__);
|
|
5283
|
-
}
|
|
5284
|
-
|
|
5285
|
-
/**
|
|
5286
|
-
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
5287
|
-
*
|
|
5288
|
-
* @param {string=} message The message.
|
|
5289
|
-
* @param {Object=} config The config.
|
|
5290
|
-
* @param {Object=} request The request.
|
|
5291
|
-
*
|
|
5292
|
-
* @returns {CanceledError} The created error.
|
|
5293
|
-
*/
|
|
5294
|
-
function CanceledError$1(message, config, request) {
|
|
5295
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
5296
|
-
AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
|
5297
|
-
this.name = 'CanceledError';
|
|
5298
|
-
}
|
|
5299
|
-
|
|
5300
|
-
utils$1.inherits(CanceledError$1, AxiosError$1, {
|
|
5301
|
-
__CANCEL__: true
|
|
5302
|
-
});
|
|
5303
|
-
|
|
5304
|
-
/**
|
|
5305
|
-
* Resolve or reject a Promise based on response status.
|
|
5306
|
-
*
|
|
5307
|
-
* @param {Function} resolve A function that resolves the promise.
|
|
5308
|
-
* @param {Function} reject A function that rejects the promise.
|
|
5309
|
-
* @param {object} response The response.
|
|
5310
|
-
*
|
|
5311
|
-
* @returns {object} The response.
|
|
5312
|
-
*/
|
|
5313
|
-
function settle(resolve, reject, response) {
|
|
5314
|
-
const validateStatus = response.config.validateStatus;
|
|
5315
|
-
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
5316
|
-
resolve(response);
|
|
5317
|
-
} else {
|
|
5318
|
-
reject(new AxiosError$1(
|
|
5319
|
-
'Request failed with status code ' + response.status,
|
|
5320
|
-
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
5321
|
-
response.config,
|
|
5322
|
-
response.request,
|
|
5323
|
-
response
|
|
5324
|
-
));
|
|
5325
|
-
}
|
|
5326
|
-
}
|
|
5327
|
-
|
|
5328
|
-
function parseProtocol(url) {
|
|
5329
|
-
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
5330
|
-
return match && match[1] || '';
|
|
5331
|
-
}
|
|
5332
|
-
|
|
5333
|
-
/**
|
|
5334
|
-
* Calculate data maxRate
|
|
5335
|
-
* @param {Number} [samplesCount= 10]
|
|
5336
|
-
* @param {Number} [min= 1000]
|
|
5337
|
-
* @returns {Function}
|
|
5338
|
-
*/
|
|
5339
|
-
function speedometer(samplesCount, min) {
|
|
5340
|
-
samplesCount = samplesCount || 10;
|
|
5341
|
-
const bytes = new Array(samplesCount);
|
|
5342
|
-
const timestamps = new Array(samplesCount);
|
|
5343
|
-
let head = 0;
|
|
5344
|
-
let tail = 0;
|
|
5345
|
-
let firstSampleTS;
|
|
5346
|
-
|
|
5347
|
-
min = min !== undefined ? min : 1000;
|
|
5348
|
-
|
|
5349
|
-
return function push(chunkLength) {
|
|
5350
|
-
const now = Date.now();
|
|
5351
|
-
|
|
5352
|
-
const startedAt = timestamps[tail];
|
|
5353
|
-
|
|
5354
|
-
if (!firstSampleTS) {
|
|
5355
|
-
firstSampleTS = now;
|
|
5356
|
-
}
|
|
5357
|
-
|
|
5358
|
-
bytes[head] = chunkLength;
|
|
5359
|
-
timestamps[head] = now;
|
|
5360
|
-
|
|
5361
|
-
let i = tail;
|
|
5362
|
-
let bytesCount = 0;
|
|
5363
|
-
|
|
5364
|
-
while (i !== head) {
|
|
5365
|
-
bytesCount += bytes[i++];
|
|
5366
|
-
i = i % samplesCount;
|
|
5367
|
-
}
|
|
5368
|
-
|
|
5369
|
-
head = (head + 1) % samplesCount;
|
|
5370
|
-
|
|
5371
|
-
if (head === tail) {
|
|
5372
|
-
tail = (tail + 1) % samplesCount;
|
|
5373
|
-
}
|
|
5374
|
-
|
|
5375
|
-
if (now - firstSampleTS < min) {
|
|
5376
|
-
return;
|
|
5377
|
-
}
|
|
5378
|
-
|
|
5379
|
-
const passed = startedAt && now - startedAt;
|
|
5380
|
-
|
|
5381
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
5382
|
-
};
|
|
5383
|
-
}
|
|
5384
|
-
|
|
5385
|
-
/**
|
|
5386
|
-
* Throttle decorator
|
|
5387
|
-
* @param {Function} fn
|
|
5388
|
-
* @param {Number} freq
|
|
5389
|
-
* @return {Function}
|
|
5390
|
-
*/
|
|
5391
|
-
function throttle(fn, freq) {
|
|
5392
|
-
let timestamp = 0;
|
|
5393
|
-
let threshold = 1000 / freq;
|
|
5394
|
-
let lastArgs;
|
|
5395
|
-
let timer;
|
|
5396
|
-
|
|
5397
|
-
const invoke = (args, now = Date.now()) => {
|
|
5398
|
-
timestamp = now;
|
|
5399
|
-
lastArgs = null;
|
|
5400
|
-
if (timer) {
|
|
5401
|
-
clearTimeout(timer);
|
|
5402
|
-
timer = null;
|
|
5403
|
-
}
|
|
5404
|
-
fn.apply(null, args);
|
|
5405
|
-
};
|
|
5406
|
-
|
|
5407
|
-
const throttled = (...args) => {
|
|
5408
|
-
const now = Date.now();
|
|
5409
|
-
const passed = now - timestamp;
|
|
5410
|
-
if ( passed >= threshold) {
|
|
5411
|
-
invoke(args, now);
|
|
5412
|
-
} else {
|
|
5413
|
-
lastArgs = args;
|
|
5414
|
-
if (!timer) {
|
|
5415
|
-
timer = setTimeout(() => {
|
|
5416
|
-
timer = null;
|
|
5417
|
-
invoke(lastArgs);
|
|
5418
|
-
}, threshold - passed);
|
|
5419
|
-
}
|
|
5420
|
-
}
|
|
5421
|
-
};
|
|
5422
|
-
|
|
5423
|
-
const flush = () => lastArgs && invoke(lastArgs);
|
|
5424
|
-
|
|
5425
|
-
return [throttled, flush];
|
|
5426
|
-
}
|
|
5427
|
-
|
|
5428
|
-
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
5429
|
-
let bytesNotified = 0;
|
|
5430
|
-
const _speedometer = speedometer(50, 250);
|
|
5431
|
-
|
|
5432
|
-
return throttle(e => {
|
|
5433
|
-
const loaded = e.loaded;
|
|
5434
|
-
const total = e.lengthComputable ? e.total : undefined;
|
|
5435
|
-
const progressBytes = loaded - bytesNotified;
|
|
5436
|
-
const rate = _speedometer(progressBytes);
|
|
5437
|
-
const inRange = loaded <= total;
|
|
5438
|
-
|
|
5439
|
-
bytesNotified = loaded;
|
|
5440
|
-
|
|
5441
|
-
const data = {
|
|
5442
|
-
loaded,
|
|
5443
|
-
total,
|
|
5444
|
-
progress: total ? (loaded / total) : undefined,
|
|
5445
|
-
bytes: progressBytes,
|
|
5446
|
-
rate: rate ? rate : undefined,
|
|
5447
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
5448
|
-
event: e,
|
|
5449
|
-
lengthComputable: total != null,
|
|
5450
|
-
[isDownloadStream ? 'download' : 'upload']: true
|
|
5451
|
-
};
|
|
5452
|
-
|
|
5453
|
-
listener(data);
|
|
5454
|
-
}, freq);
|
|
5455
|
-
};
|
|
5456
|
-
|
|
5457
|
-
const progressEventDecorator = (total, throttled) => {
|
|
5458
|
-
const lengthComputable = total != null;
|
|
5459
|
-
|
|
5460
|
-
return [(loaded) => throttled[0]({
|
|
5461
|
-
lengthComputable,
|
|
5462
|
-
total,
|
|
5463
|
-
loaded
|
|
5464
|
-
}), throttled[1]];
|
|
5465
|
-
};
|
|
5466
|
-
|
|
5467
|
-
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
5468
|
-
|
|
5469
|
-
var isURLSameOrigin = platform$1.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
|
|
5470
|
-
url = new URL(url, platform$1.origin);
|
|
5471
|
-
|
|
5472
|
-
return (
|
|
5473
|
-
origin.protocol === url.protocol &&
|
|
5474
|
-
origin.host === url.host &&
|
|
5475
|
-
(isMSIE || origin.port === url.port)
|
|
5476
|
-
);
|
|
5477
|
-
})(
|
|
5478
|
-
new URL(platform$1.origin),
|
|
5479
|
-
platform$1.navigator && /(msie|trident)/i.test(platform$1.navigator.userAgent)
|
|
5480
|
-
) : () => true;
|
|
5481
|
-
|
|
5482
|
-
var cookies = platform$1.hasStandardBrowserEnv ?
|
|
5483
|
-
|
|
5484
|
-
// Standard browser envs support document.cookie
|
|
5485
|
-
{
|
|
5486
|
-
write(name, value, expires, path, domain, secure) {
|
|
5487
|
-
const cookie = [name + '=' + encodeURIComponent(value)];
|
|
5488
|
-
|
|
5489
|
-
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
5490
|
-
|
|
5491
|
-
utils$1.isString(path) && cookie.push('path=' + path);
|
|
5492
|
-
|
|
5493
|
-
utils$1.isString(domain) && cookie.push('domain=' + domain);
|
|
5494
|
-
|
|
5495
|
-
secure === true && cookie.push('secure');
|
|
5496
|
-
|
|
5497
|
-
document.cookie = cookie.join('; ');
|
|
5498
|
-
},
|
|
5499
|
-
|
|
5500
|
-
read(name) {
|
|
5501
|
-
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
5502
|
-
return (match ? decodeURIComponent(match[3]) : null);
|
|
5503
|
-
},
|
|
5504
|
-
|
|
5505
|
-
remove(name) {
|
|
5506
|
-
this.write(name, '', Date.now() - 86400000);
|
|
5507
|
-
}
|
|
5508
|
-
}
|
|
5509
|
-
|
|
5510
|
-
:
|
|
5511
|
-
|
|
5512
|
-
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
5513
|
-
{
|
|
5514
|
-
write() {},
|
|
5515
|
-
read() {
|
|
5516
|
-
return null;
|
|
5517
|
-
},
|
|
5518
|
-
remove() {}
|
|
5519
|
-
};
|
|
5520
|
-
|
|
5521
|
-
/**
|
|
5522
|
-
* Determines whether the specified URL is absolute
|
|
5523
|
-
*
|
|
5524
|
-
* @param {string} url The URL to test
|
|
5525
|
-
*
|
|
5526
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
5527
|
-
*/
|
|
5528
|
-
function isAbsoluteURL(url) {
|
|
5529
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
5530
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
5531
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
|
5532
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
5533
|
-
}
|
|
5534
|
-
|
|
5535
|
-
/**
|
|
5536
|
-
* Creates a new URL by combining the specified URLs
|
|
5537
|
-
*
|
|
5538
|
-
* @param {string} baseURL The base URL
|
|
5539
|
-
* @param {string} relativeURL The relative URL
|
|
5540
|
-
*
|
|
5541
|
-
* @returns {string} The combined URL
|
|
5542
|
-
*/
|
|
5543
|
-
function combineURLs(baseURL, relativeURL) {
|
|
5544
|
-
return relativeURL
|
|
5545
|
-
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
5546
|
-
: baseURL;
|
|
5547
|
-
}
|
|
5548
|
-
|
|
5549
|
-
/**
|
|
5550
|
-
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
5551
|
-
* only when the requestedURL is not already an absolute URL.
|
|
5552
|
-
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
5553
|
-
*
|
|
5554
|
-
* @param {string} baseURL The base URL
|
|
5555
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
|
5556
|
-
*
|
|
5557
|
-
* @returns {string} The combined full path
|
|
5558
|
-
*/
|
|
5559
|
-
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
5560
|
-
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
5561
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
|
|
5562
|
-
return combineURLs(baseURL, requestedURL);
|
|
5563
|
-
}
|
|
5564
|
-
return requestedURL;
|
|
5565
|
-
}
|
|
5566
|
-
|
|
5567
|
-
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
5568
|
-
|
|
5569
|
-
/**
|
|
5570
|
-
* Config-specific merge-function which creates a new config-object
|
|
5571
|
-
* by merging two configuration objects together.
|
|
5572
|
-
*
|
|
5573
|
-
* @param {Object} config1
|
|
5574
|
-
* @param {Object} config2
|
|
5575
|
-
*
|
|
5576
|
-
* @returns {Object} New object resulting from merging config2 to config1
|
|
5577
|
-
*/
|
|
5578
|
-
function mergeConfig$1(config1, config2) {
|
|
5579
|
-
// eslint-disable-next-line no-param-reassign
|
|
5580
|
-
config2 = config2 || {};
|
|
5581
|
-
const config = {};
|
|
5582
|
-
|
|
5583
|
-
function getMergedValue(target, source, prop, caseless) {
|
|
5584
|
-
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
5585
|
-
return utils$1.merge.call({caseless}, target, source);
|
|
5586
|
-
} else if (utils$1.isPlainObject(source)) {
|
|
5587
|
-
return utils$1.merge({}, source);
|
|
5588
|
-
} else if (utils$1.isArray(source)) {
|
|
5589
|
-
return source.slice();
|
|
5590
|
-
}
|
|
5591
|
-
return source;
|
|
5592
|
-
}
|
|
5593
|
-
|
|
5594
|
-
// eslint-disable-next-line consistent-return
|
|
5595
|
-
function mergeDeepProperties(a, b, prop , caseless) {
|
|
5596
|
-
if (!utils$1.isUndefined(b)) {
|
|
5597
|
-
return getMergedValue(a, b, prop , caseless);
|
|
5598
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
5599
|
-
return getMergedValue(undefined, a, prop , caseless);
|
|
5600
|
-
}
|
|
5601
|
-
}
|
|
5602
|
-
|
|
5603
|
-
// eslint-disable-next-line consistent-return
|
|
5604
|
-
function valueFromConfig2(a, b) {
|
|
5605
|
-
if (!utils$1.isUndefined(b)) {
|
|
5606
|
-
return getMergedValue(undefined, b);
|
|
5607
|
-
}
|
|
5608
|
-
}
|
|
5609
|
-
|
|
5610
|
-
// eslint-disable-next-line consistent-return
|
|
5611
|
-
function defaultToConfig2(a, b) {
|
|
5612
|
-
if (!utils$1.isUndefined(b)) {
|
|
5613
|
-
return getMergedValue(undefined, b);
|
|
5614
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
5615
|
-
return getMergedValue(undefined, a);
|
|
5616
|
-
}
|
|
5617
|
-
}
|
|
5618
|
-
|
|
5619
|
-
// eslint-disable-next-line consistent-return
|
|
5620
|
-
function mergeDirectKeys(a, b, prop) {
|
|
5621
|
-
if (prop in config2) {
|
|
5622
|
-
return getMergedValue(a, b);
|
|
5623
|
-
} else if (prop in config1) {
|
|
5624
|
-
return getMergedValue(undefined, a);
|
|
5625
|
-
}
|
|
5626
|
-
}
|
|
5627
|
-
|
|
5628
|
-
const mergeMap = {
|
|
5629
|
-
url: valueFromConfig2,
|
|
5630
|
-
method: valueFromConfig2,
|
|
5631
|
-
data: valueFromConfig2,
|
|
5632
|
-
baseURL: defaultToConfig2,
|
|
5633
|
-
transformRequest: defaultToConfig2,
|
|
5634
|
-
transformResponse: defaultToConfig2,
|
|
5635
|
-
paramsSerializer: defaultToConfig2,
|
|
5636
|
-
timeout: defaultToConfig2,
|
|
5637
|
-
timeoutMessage: defaultToConfig2,
|
|
5638
|
-
withCredentials: defaultToConfig2,
|
|
5639
|
-
withXSRFToken: defaultToConfig2,
|
|
5640
|
-
adapter: defaultToConfig2,
|
|
5641
|
-
responseType: defaultToConfig2,
|
|
5642
|
-
xsrfCookieName: defaultToConfig2,
|
|
5643
|
-
xsrfHeaderName: defaultToConfig2,
|
|
5644
|
-
onUploadProgress: defaultToConfig2,
|
|
5645
|
-
onDownloadProgress: defaultToConfig2,
|
|
5646
|
-
decompress: defaultToConfig2,
|
|
5647
|
-
maxContentLength: defaultToConfig2,
|
|
5648
|
-
maxBodyLength: defaultToConfig2,
|
|
5649
|
-
beforeRedirect: defaultToConfig2,
|
|
5650
|
-
transport: defaultToConfig2,
|
|
5651
|
-
httpAgent: defaultToConfig2,
|
|
5652
|
-
httpsAgent: defaultToConfig2,
|
|
5653
|
-
cancelToken: defaultToConfig2,
|
|
5654
|
-
socketPath: defaultToConfig2,
|
|
5655
|
-
responseEncoding: defaultToConfig2,
|
|
5656
|
-
validateStatus: mergeDirectKeys,
|
|
5657
|
-
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
5658
|
-
};
|
|
5659
|
-
|
|
5660
|
-
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
5661
|
-
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
5662
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
5663
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
5664
|
-
});
|
|
5665
|
-
|
|
5666
|
-
return config;
|
|
5667
|
-
}
|
|
5668
|
-
|
|
5669
|
-
var resolveConfig = (config) => {
|
|
5670
|
-
const newConfig = mergeConfig$1({}, config);
|
|
5671
|
-
|
|
5672
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
5673
|
-
|
|
5674
|
-
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
5675
|
-
|
|
5676
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
5677
|
-
|
|
5678
|
-
// HTTP basic authentication
|
|
5679
|
-
if (auth) {
|
|
5680
|
-
headers.set('Authorization', 'Basic ' +
|
|
5681
|
-
btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
|
|
5682
|
-
);
|
|
5683
|
-
}
|
|
5684
|
-
|
|
5685
|
-
let contentType;
|
|
5686
|
-
|
|
5687
|
-
if (utils$1.isFormData(data)) {
|
|
5688
|
-
if (platform$1.hasStandardBrowserEnv || platform$1.hasStandardBrowserWebWorkerEnv) {
|
|
5689
|
-
headers.setContentType(undefined); // Let the browser set it
|
|
5690
|
-
} else if ((contentType = headers.getContentType()) !== false) {
|
|
5691
|
-
// fix semicolon duplication issue for ReactNative FormData implementation
|
|
5692
|
-
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
|
5693
|
-
headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
|
5694
|
-
}
|
|
5695
|
-
}
|
|
5696
|
-
|
|
5697
|
-
// Add xsrf header
|
|
5698
|
-
// This is only done if running in a standard browser environment.
|
|
5699
|
-
// Specifically not if we're in a web worker, or react-native.
|
|
5700
|
-
|
|
5701
|
-
if (platform$1.hasStandardBrowserEnv) {
|
|
5702
|
-
withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
5703
|
-
|
|
5704
|
-
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
|
5705
|
-
// Add xsrf header
|
|
5706
|
-
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
5707
|
-
|
|
5708
|
-
if (xsrfValue) {
|
|
5709
|
-
headers.set(xsrfHeaderName, xsrfValue);
|
|
5710
|
-
}
|
|
5711
|
-
}
|
|
5712
|
-
}
|
|
5713
|
-
|
|
5714
|
-
return newConfig;
|
|
5715
|
-
};
|
|
5716
|
-
|
|
5717
|
-
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
5718
|
-
|
|
5719
|
-
var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
5720
|
-
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
5721
|
-
const _config = resolveConfig(config);
|
|
5722
|
-
let requestData = _config.data;
|
|
5723
|
-
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
5724
|
-
let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
|
5725
|
-
let onCanceled;
|
|
5726
|
-
let uploadThrottled, downloadThrottled;
|
|
5727
|
-
let flushUpload, flushDownload;
|
|
5728
|
-
|
|
5729
|
-
function done() {
|
|
5730
|
-
flushUpload && flushUpload(); // flush events
|
|
5731
|
-
flushDownload && flushDownload(); // flush events
|
|
5732
|
-
|
|
5733
|
-
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
5734
|
-
|
|
5735
|
-
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
5736
|
-
}
|
|
5737
|
-
|
|
5738
|
-
let request = new XMLHttpRequest();
|
|
5739
|
-
|
|
5740
|
-
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
5741
|
-
|
|
5742
|
-
// Set the request timeout in MS
|
|
5743
|
-
request.timeout = _config.timeout;
|
|
5744
|
-
|
|
5745
|
-
function onloadend() {
|
|
5746
|
-
if (!request) {
|
|
5747
|
-
return;
|
|
5748
|
-
}
|
|
5749
|
-
// Prepare the response
|
|
5750
|
-
const responseHeaders = AxiosHeaders$1.from(
|
|
5751
|
-
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
5752
|
-
);
|
|
5753
|
-
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
5754
|
-
request.responseText : request.response;
|
|
5755
|
-
const response = {
|
|
5756
|
-
data: responseData,
|
|
5757
|
-
status: request.status,
|
|
5758
|
-
statusText: request.statusText,
|
|
5759
|
-
headers: responseHeaders,
|
|
5760
|
-
config,
|
|
5761
|
-
request
|
|
5762
|
-
};
|
|
5763
|
-
|
|
5764
|
-
settle(function _resolve(value) {
|
|
5765
|
-
resolve(value);
|
|
5766
|
-
done();
|
|
5767
|
-
}, function _reject(err) {
|
|
5768
|
-
reject(err);
|
|
5769
|
-
done();
|
|
5770
|
-
}, response);
|
|
5771
|
-
|
|
5772
|
-
// Clean up request
|
|
5773
|
-
request = null;
|
|
5774
|
-
}
|
|
5775
|
-
|
|
5776
|
-
if ('onloadend' in request) {
|
|
5777
|
-
// Use onloadend if available
|
|
5778
|
-
request.onloadend = onloadend;
|
|
5779
|
-
} else {
|
|
5780
|
-
// Listen for ready state to emulate onloadend
|
|
5781
|
-
request.onreadystatechange = function handleLoad() {
|
|
5782
|
-
if (!request || request.readyState !== 4) {
|
|
5783
|
-
return;
|
|
5784
|
-
}
|
|
5785
|
-
|
|
5786
|
-
// The request errored out and we didn't get a response, this will be
|
|
5787
|
-
// handled by onerror instead
|
|
5788
|
-
// With one exception: request that using file: protocol, most browsers
|
|
5789
|
-
// will return status as 0 even though it's a successful request
|
|
5790
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
5791
|
-
return;
|
|
5792
|
-
}
|
|
5793
|
-
// readystate handler is calling before onerror or ontimeout handlers,
|
|
5794
|
-
// so we should call onloadend on the next 'tick'
|
|
5795
|
-
setTimeout(onloadend);
|
|
5796
|
-
};
|
|
5797
|
-
}
|
|
5798
|
-
|
|
5799
|
-
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
5800
|
-
request.onabort = function handleAbort() {
|
|
5801
|
-
if (!request) {
|
|
5802
|
-
return;
|
|
5803
|
-
}
|
|
5804
|
-
|
|
5805
|
-
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
5806
|
-
|
|
5807
|
-
// Clean up request
|
|
5808
|
-
request = null;
|
|
5809
|
-
};
|
|
5810
|
-
|
|
5811
|
-
// Handle low level network errors
|
|
5812
|
-
request.onerror = function handleError() {
|
|
5813
|
-
// Real errors are hidden from us by the browser
|
|
5814
|
-
// onerror should only fire if it's a network error
|
|
5815
|
-
reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
|
|
5816
|
-
|
|
5817
|
-
// Clean up request
|
|
5818
|
-
request = null;
|
|
5819
|
-
};
|
|
5820
|
-
|
|
5821
|
-
// Handle timeout
|
|
5822
|
-
request.ontimeout = function handleTimeout() {
|
|
5823
|
-
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
5824
|
-
const transitional = _config.transitional || transitionalDefaults;
|
|
5825
|
-
if (_config.timeoutErrorMessage) {
|
|
5826
|
-
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
5827
|
-
}
|
|
5828
|
-
reject(new AxiosError$1(
|
|
5829
|
-
timeoutErrorMessage,
|
|
5830
|
-
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
5831
|
-
config,
|
|
5832
|
-
request));
|
|
5833
|
-
|
|
5834
|
-
// Clean up request
|
|
5835
|
-
request = null;
|
|
5836
|
-
};
|
|
5837
|
-
|
|
5838
|
-
// Remove Content-Type if data is undefined
|
|
5839
|
-
requestData === undefined && requestHeaders.setContentType(null);
|
|
5840
|
-
|
|
5841
|
-
// Add headers to the request
|
|
5842
|
-
if ('setRequestHeader' in request) {
|
|
5843
|
-
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
5844
|
-
request.setRequestHeader(key, val);
|
|
5845
|
-
});
|
|
5846
|
-
}
|
|
5847
|
-
|
|
5848
|
-
// Add withCredentials to request if needed
|
|
5849
|
-
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
5850
|
-
request.withCredentials = !!_config.withCredentials;
|
|
5851
|
-
}
|
|
5852
|
-
|
|
5853
|
-
// Add responseType to request if needed
|
|
5854
|
-
if (responseType && responseType !== 'json') {
|
|
5855
|
-
request.responseType = _config.responseType;
|
|
5856
|
-
}
|
|
5857
|
-
|
|
5858
|
-
// Handle progress if needed
|
|
5859
|
-
if (onDownloadProgress) {
|
|
5860
|
-
([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
|
|
5861
|
-
request.addEventListener('progress', downloadThrottled);
|
|
5862
|
-
}
|
|
5863
|
-
|
|
5864
|
-
// Not all browsers support upload events
|
|
5865
|
-
if (onUploadProgress && request.upload) {
|
|
5866
|
-
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
5867
|
-
|
|
5868
|
-
request.upload.addEventListener('progress', uploadThrottled);
|
|
5869
|
-
|
|
5870
|
-
request.upload.addEventListener('loadend', flushUpload);
|
|
5871
|
-
}
|
|
5872
|
-
|
|
5873
|
-
if (_config.cancelToken || _config.signal) {
|
|
5874
|
-
// Handle cancellation
|
|
5875
|
-
// eslint-disable-next-line func-names
|
|
5876
|
-
onCanceled = cancel => {
|
|
5877
|
-
if (!request) {
|
|
5878
|
-
return;
|
|
5879
|
-
}
|
|
5880
|
-
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
5881
|
-
request.abort();
|
|
5882
|
-
request = null;
|
|
5883
|
-
};
|
|
5884
|
-
|
|
5885
|
-
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
5886
|
-
if (_config.signal) {
|
|
5887
|
-
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
5888
|
-
}
|
|
5889
|
-
}
|
|
5890
|
-
|
|
5891
|
-
const protocol = parseProtocol(_config.url);
|
|
5892
|
-
|
|
5893
|
-
if (protocol && platform$1.protocols.indexOf(protocol) === -1) {
|
|
5894
|
-
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
|
5895
|
-
return;
|
|
5896
|
-
}
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
// Send the request
|
|
5900
|
-
request.send(requestData || null);
|
|
5901
|
-
});
|
|
5902
|
-
};
|
|
5903
|
-
|
|
5904
|
-
const composeSignals = (signals, timeout) => {
|
|
5905
|
-
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
5906
|
-
|
|
5907
|
-
if (timeout || length) {
|
|
5908
|
-
let controller = new AbortController();
|
|
5909
|
-
|
|
5910
|
-
let aborted;
|
|
5911
|
-
|
|
5912
|
-
const onabort = function (reason) {
|
|
5913
|
-
if (!aborted) {
|
|
5914
|
-
aborted = true;
|
|
5915
|
-
unsubscribe();
|
|
5916
|
-
const err = reason instanceof Error ? reason : this.reason;
|
|
5917
|
-
controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
|
5918
|
-
}
|
|
5919
|
-
};
|
|
5920
|
-
|
|
5921
|
-
let timer = timeout && setTimeout(() => {
|
|
5922
|
-
timer = null;
|
|
5923
|
-
onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
5924
|
-
}, timeout);
|
|
5925
|
-
|
|
5926
|
-
const unsubscribe = () => {
|
|
5927
|
-
if (signals) {
|
|
5928
|
-
timer && clearTimeout(timer);
|
|
5929
|
-
timer = null;
|
|
5930
|
-
signals.forEach(signal => {
|
|
5931
|
-
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
|
5932
|
-
});
|
|
5933
|
-
signals = null;
|
|
5934
|
-
}
|
|
5935
|
-
};
|
|
5936
|
-
|
|
5937
|
-
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
5938
|
-
|
|
5939
|
-
const {signal} = controller;
|
|
5940
|
-
|
|
5941
|
-
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
5942
|
-
|
|
5943
|
-
return signal;
|
|
5944
|
-
}
|
|
5945
|
-
};
|
|
5946
|
-
|
|
5947
|
-
const streamChunk = function* (chunk, chunkSize) {
|
|
5948
|
-
let len = chunk.byteLength;
|
|
5949
|
-
|
|
5950
|
-
if (len < chunkSize) {
|
|
5951
|
-
yield chunk;
|
|
5952
|
-
return;
|
|
5953
|
-
}
|
|
5954
|
-
|
|
5955
|
-
let pos = 0;
|
|
5956
|
-
let end;
|
|
5957
|
-
|
|
5958
|
-
while (pos < len) {
|
|
5959
|
-
end = pos + chunkSize;
|
|
5960
|
-
yield chunk.slice(pos, end);
|
|
5961
|
-
pos = end;
|
|
5962
|
-
}
|
|
5963
|
-
};
|
|
5964
|
-
|
|
5965
|
-
const readBytes = async function* (iterable, chunkSize) {
|
|
5966
|
-
for await (const chunk of readStream(iterable)) {
|
|
5967
|
-
yield* streamChunk(chunk, chunkSize);
|
|
5968
|
-
}
|
|
5969
|
-
};
|
|
5970
|
-
|
|
5971
|
-
const readStream = async function* (stream) {
|
|
5972
|
-
if (stream[Symbol.asyncIterator]) {
|
|
5973
|
-
yield* stream;
|
|
5974
|
-
return;
|
|
5975
|
-
}
|
|
5976
|
-
|
|
5977
|
-
const reader = stream.getReader();
|
|
5978
|
-
try {
|
|
5979
|
-
for (;;) {
|
|
5980
|
-
const {done, value} = await reader.read();
|
|
5981
|
-
if (done) {
|
|
5982
|
-
break;
|
|
5983
|
-
}
|
|
5984
|
-
yield value;
|
|
5985
|
-
}
|
|
5986
|
-
} finally {
|
|
5987
|
-
await reader.cancel();
|
|
5988
|
-
}
|
|
5989
|
-
};
|
|
5990
|
-
|
|
5991
|
-
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
5992
|
-
const iterator = readBytes(stream, chunkSize);
|
|
5993
|
-
|
|
5994
|
-
let bytes = 0;
|
|
5995
|
-
let done;
|
|
5996
|
-
let _onFinish = (e) => {
|
|
5997
|
-
if (!done) {
|
|
5998
|
-
done = true;
|
|
5999
|
-
onFinish && onFinish(e);
|
|
6000
|
-
}
|
|
6001
|
-
};
|
|
6002
|
-
|
|
6003
|
-
return new ReadableStream({
|
|
6004
|
-
async pull(controller) {
|
|
6005
|
-
try {
|
|
6006
|
-
const {done, value} = await iterator.next();
|
|
6007
|
-
|
|
6008
|
-
if (done) {
|
|
6009
|
-
_onFinish();
|
|
6010
|
-
controller.close();
|
|
6011
|
-
return;
|
|
6012
|
-
}
|
|
6013
|
-
|
|
6014
|
-
let len = value.byteLength;
|
|
6015
|
-
if (onProgress) {
|
|
6016
|
-
let loadedBytes = bytes += len;
|
|
6017
|
-
onProgress(loadedBytes);
|
|
6018
|
-
}
|
|
6019
|
-
controller.enqueue(new Uint8Array(value));
|
|
6020
|
-
} catch (err) {
|
|
6021
|
-
_onFinish(err);
|
|
6022
|
-
throw err;
|
|
6023
|
-
}
|
|
6024
|
-
},
|
|
6025
|
-
cancel(reason) {
|
|
6026
|
-
_onFinish(reason);
|
|
6027
|
-
return iterator.return();
|
|
6028
|
-
}
|
|
6029
|
-
}, {
|
|
6030
|
-
highWaterMark: 2
|
|
6031
|
-
})
|
|
6032
|
-
};
|
|
6033
|
-
|
|
6034
|
-
const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
|
|
6035
|
-
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
|
|
6036
|
-
|
|
6037
|
-
// used only inside the fetch adapter
|
|
6038
|
-
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
6039
|
-
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
6040
|
-
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
6041
|
-
);
|
|
6042
|
-
|
|
6043
|
-
const test$1 = (fn, ...args) => {
|
|
6044
|
-
try {
|
|
6045
|
-
return !!fn(...args);
|
|
6046
|
-
} catch (e) {
|
|
6047
|
-
return false
|
|
6048
|
-
}
|
|
6049
|
-
};
|
|
6050
|
-
|
|
6051
|
-
const supportsRequestStream = isReadableStreamSupported && test$1(() => {
|
|
6052
|
-
let duplexAccessed = false;
|
|
6053
|
-
|
|
6054
|
-
const hasContentType = new Request(platform$1.origin, {
|
|
6055
|
-
body: new ReadableStream(),
|
|
6056
|
-
method: 'POST',
|
|
6057
|
-
get duplex() {
|
|
6058
|
-
duplexAccessed = true;
|
|
6059
|
-
return 'half';
|
|
6060
|
-
},
|
|
6061
|
-
}).headers.has('Content-Type');
|
|
6062
|
-
|
|
6063
|
-
return duplexAccessed && !hasContentType;
|
|
6064
|
-
});
|
|
6065
|
-
|
|
6066
|
-
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
6067
|
-
|
|
6068
|
-
const supportsResponseStream = isReadableStreamSupported &&
|
|
6069
|
-
test$1(() => utils$1.isReadableStream(new Response('').body));
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
const resolvers = {
|
|
6073
|
-
stream: supportsResponseStream && ((res) => res.body)
|
|
6074
|
-
};
|
|
6075
|
-
|
|
6076
|
-
isFetchSupported && (((res) => {
|
|
6077
|
-
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
6078
|
-
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
6079
|
-
(_, config) => {
|
|
6080
|
-
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
|
6081
|
-
});
|
|
6082
|
-
});
|
|
6083
|
-
})(new Response));
|
|
6084
|
-
|
|
6085
|
-
const getBodyLength = async (body) => {
|
|
6086
|
-
if (body == null) {
|
|
6087
|
-
return 0;
|
|
6088
|
-
}
|
|
6089
|
-
|
|
6090
|
-
if(utils$1.isBlob(body)) {
|
|
6091
|
-
return body.size;
|
|
6092
|
-
}
|
|
6093
|
-
|
|
6094
|
-
if(utils$1.isSpecCompliantForm(body)) {
|
|
6095
|
-
const _request = new Request(platform$1.origin, {
|
|
6096
|
-
method: 'POST',
|
|
6097
|
-
body,
|
|
6098
|
-
});
|
|
6099
|
-
return (await _request.arrayBuffer()).byteLength;
|
|
6100
|
-
}
|
|
6101
|
-
|
|
6102
|
-
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
6103
|
-
return body.byteLength;
|
|
6104
|
-
}
|
|
6105
|
-
|
|
6106
|
-
if(utils$1.isURLSearchParams(body)) {
|
|
6107
|
-
body = body + '';
|
|
6108
|
-
}
|
|
6109
|
-
|
|
6110
|
-
if(utils$1.isString(body)) {
|
|
6111
|
-
return (await encodeText(body)).byteLength;
|
|
6112
|
-
}
|
|
6113
|
-
};
|
|
6114
|
-
|
|
6115
|
-
const resolveBodyLength = async (headers, body) => {
|
|
6116
|
-
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
6117
|
-
|
|
6118
|
-
return length == null ? getBodyLength(body) : length;
|
|
6119
|
-
};
|
|
6120
|
-
|
|
6121
|
-
var fetchAdapter = isFetchSupported && (async (config) => {
|
|
6122
|
-
let {
|
|
6123
|
-
url,
|
|
6124
|
-
method,
|
|
6125
|
-
data,
|
|
6126
|
-
signal,
|
|
6127
|
-
cancelToken,
|
|
6128
|
-
timeout,
|
|
6129
|
-
onDownloadProgress,
|
|
6130
|
-
onUploadProgress,
|
|
6131
|
-
responseType,
|
|
6132
|
-
headers,
|
|
6133
|
-
withCredentials = 'same-origin',
|
|
6134
|
-
fetchOptions
|
|
6135
|
-
} = resolveConfig(config);
|
|
6136
|
-
|
|
6137
|
-
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
6138
|
-
|
|
6139
|
-
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
6140
|
-
|
|
6141
|
-
let request;
|
|
6142
|
-
|
|
6143
|
-
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
6144
|
-
composedSignal.unsubscribe();
|
|
6145
|
-
});
|
|
6146
|
-
|
|
6147
|
-
let requestContentLength;
|
|
6148
|
-
|
|
6149
|
-
try {
|
|
6150
|
-
if (
|
|
6151
|
-
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
6152
|
-
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
6153
|
-
) {
|
|
6154
|
-
let _request = new Request(url, {
|
|
6155
|
-
method: 'POST',
|
|
6156
|
-
body: data,
|
|
6157
|
-
duplex: "half"
|
|
6158
|
-
});
|
|
6159
|
-
|
|
6160
|
-
let contentTypeHeader;
|
|
6161
|
-
|
|
6162
|
-
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
6163
|
-
headers.setContentType(contentTypeHeader);
|
|
6164
|
-
}
|
|
6165
|
-
|
|
6166
|
-
if (_request.body) {
|
|
6167
|
-
const [onProgress, flush] = progressEventDecorator(
|
|
6168
|
-
requestContentLength,
|
|
6169
|
-
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
6170
|
-
);
|
|
6171
|
-
|
|
6172
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
6173
|
-
}
|
|
6174
|
-
}
|
|
6175
|
-
|
|
6176
|
-
if (!utils$1.isString(withCredentials)) {
|
|
6177
|
-
withCredentials = withCredentials ? 'include' : 'omit';
|
|
6178
|
-
}
|
|
6179
|
-
|
|
6180
|
-
// Cloudflare Workers throws when credentials are defined
|
|
6181
|
-
// see https://github.com/cloudflare/workerd/issues/902
|
|
6182
|
-
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
6183
|
-
request = new Request(url, {
|
|
6184
|
-
...fetchOptions,
|
|
6185
|
-
signal: composedSignal,
|
|
6186
|
-
method: method.toUpperCase(),
|
|
6187
|
-
headers: headers.normalize().toJSON(),
|
|
6188
|
-
body: data,
|
|
6189
|
-
duplex: "half",
|
|
6190
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
6191
|
-
});
|
|
6192
|
-
|
|
6193
|
-
let response = await fetch(request);
|
|
6194
|
-
|
|
6195
|
-
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
6196
|
-
|
|
6197
|
-
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
6198
|
-
const options = {};
|
|
6199
|
-
|
|
6200
|
-
['status', 'statusText', 'headers'].forEach(prop => {
|
|
6201
|
-
options[prop] = response[prop];
|
|
6202
|
-
});
|
|
6203
|
-
|
|
6204
|
-
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
6205
|
-
|
|
6206
|
-
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
6207
|
-
responseContentLength,
|
|
6208
|
-
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
6209
|
-
) || [];
|
|
6210
|
-
|
|
6211
|
-
response = new Response(
|
|
6212
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
6213
|
-
flush && flush();
|
|
6214
|
-
unsubscribe && unsubscribe();
|
|
6215
|
-
}),
|
|
6216
|
-
options
|
|
6217
|
-
);
|
|
6218
|
-
}
|
|
6219
|
-
|
|
6220
|
-
responseType = responseType || 'text';
|
|
6221
|
-
|
|
6222
|
-
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
6223
|
-
|
|
6224
|
-
!isStreamResponse && unsubscribe && unsubscribe();
|
|
6225
|
-
|
|
6226
|
-
return await new Promise((resolve, reject) => {
|
|
6227
|
-
settle(resolve, reject, {
|
|
6228
|
-
data: responseData,
|
|
6229
|
-
headers: AxiosHeaders$1.from(response.headers),
|
|
6230
|
-
status: response.status,
|
|
6231
|
-
statusText: response.statusText,
|
|
6232
|
-
config,
|
|
6233
|
-
request
|
|
6234
|
-
});
|
|
6235
|
-
})
|
|
6236
|
-
} catch (err) {
|
|
6237
|
-
unsubscribe && unsubscribe();
|
|
6238
|
-
|
|
6239
|
-
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
6240
|
-
throw Object.assign(
|
|
6241
|
-
new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
|
|
6242
|
-
{
|
|
6243
|
-
cause: err.cause || err
|
|
6244
|
-
}
|
|
6245
|
-
)
|
|
6246
|
-
}
|
|
6247
|
-
|
|
6248
|
-
throw AxiosError$1.from(err, err && err.code, config, request);
|
|
6249
|
-
}
|
|
6250
|
-
});
|
|
6251
|
-
|
|
6252
|
-
const knownAdapters = {
|
|
6253
|
-
http: httpAdapter,
|
|
6254
|
-
xhr: xhrAdapter,
|
|
6255
|
-
fetch: fetchAdapter
|
|
6256
|
-
};
|
|
6257
|
-
|
|
6258
|
-
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
6259
|
-
if (fn) {
|
|
6260
|
-
try {
|
|
6261
|
-
Object.defineProperty(fn, 'name', {value});
|
|
6262
|
-
} catch (e) {
|
|
6263
|
-
// eslint-disable-next-line no-empty
|
|
6264
|
-
}
|
|
6265
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
6266
|
-
}
|
|
6267
|
-
});
|
|
6268
|
-
|
|
6269
|
-
const renderReason = (reason) => `- ${reason}`;
|
|
6270
|
-
|
|
6271
|
-
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
6272
|
-
|
|
6273
|
-
var adapters = {
|
|
6274
|
-
getAdapter: (adapters) => {
|
|
6275
|
-
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
6276
|
-
|
|
6277
|
-
const {length} = adapters;
|
|
6278
|
-
let nameOrAdapter;
|
|
6279
|
-
let adapter;
|
|
6280
|
-
|
|
6281
|
-
const rejectedReasons = {};
|
|
6282
|
-
|
|
6283
|
-
for (let i = 0; i < length; i++) {
|
|
6284
|
-
nameOrAdapter = adapters[i];
|
|
6285
|
-
let id;
|
|
6286
|
-
|
|
6287
|
-
adapter = nameOrAdapter;
|
|
6288
|
-
|
|
6289
|
-
if (!isResolvedHandle(nameOrAdapter)) {
|
|
6290
|
-
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
6291
|
-
|
|
6292
|
-
if (adapter === undefined) {
|
|
6293
|
-
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
|
6294
|
-
}
|
|
6295
|
-
}
|
|
6296
|
-
|
|
6297
|
-
if (adapter) {
|
|
6298
|
-
break;
|
|
6299
|
-
}
|
|
6300
|
-
|
|
6301
|
-
rejectedReasons[id || '#' + i] = adapter;
|
|
6302
|
-
}
|
|
6303
|
-
|
|
6304
|
-
if (!adapter) {
|
|
6305
|
-
|
|
6306
|
-
const reasons = Object.entries(rejectedReasons)
|
|
6307
|
-
.map(([id, state]) => `adapter ${id} ` +
|
|
6308
|
-
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
6309
|
-
);
|
|
6310
|
-
|
|
6311
|
-
let s = length ?
|
|
6312
|
-
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
6313
|
-
'as no adapter specified';
|
|
6314
|
-
|
|
6315
|
-
throw new AxiosError$1(
|
|
6316
|
-
`There is no suitable adapter to dispatch the request ` + s,
|
|
6317
|
-
'ERR_NOT_SUPPORT'
|
|
6318
|
-
);
|
|
6319
|
-
}
|
|
6320
|
-
|
|
6321
|
-
return adapter;
|
|
6322
|
-
},
|
|
6323
|
-
adapters: knownAdapters
|
|
6324
|
-
};
|
|
6325
|
-
|
|
6326
|
-
/**
|
|
6327
|
-
* Throws a `CanceledError` if cancellation has been requested.
|
|
6328
|
-
*
|
|
6329
|
-
* @param {Object} config The config that is to be used for the request
|
|
6330
|
-
*
|
|
6331
|
-
* @returns {void}
|
|
6332
|
-
*/
|
|
6333
|
-
function throwIfCancellationRequested(config) {
|
|
6334
|
-
if (config.cancelToken) {
|
|
6335
|
-
config.cancelToken.throwIfRequested();
|
|
6336
|
-
}
|
|
6337
|
-
|
|
6338
|
-
if (config.signal && config.signal.aborted) {
|
|
6339
|
-
throw new CanceledError$1(null, config);
|
|
6340
|
-
}
|
|
6341
|
-
}
|
|
6342
|
-
|
|
6343
|
-
/**
|
|
6344
|
-
* Dispatch a request to the server using the configured adapter.
|
|
6345
|
-
*
|
|
6346
|
-
* @param {object} config The config that is to be used for the request
|
|
6347
|
-
*
|
|
6348
|
-
* @returns {Promise} The Promise to be fulfilled
|
|
6349
|
-
*/
|
|
6350
|
-
function dispatchRequest(config) {
|
|
6351
|
-
throwIfCancellationRequested(config);
|
|
6352
|
-
|
|
6353
|
-
config.headers = AxiosHeaders$1.from(config.headers);
|
|
6354
|
-
|
|
6355
|
-
// Transform request data
|
|
6356
|
-
config.data = transformData.call(
|
|
6357
|
-
config,
|
|
6358
|
-
config.transformRequest
|
|
6359
|
-
);
|
|
6360
|
-
|
|
6361
|
-
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|
6362
|
-
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
6363
|
-
}
|
|
6364
|
-
|
|
6365
|
-
const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
|
|
6366
|
-
|
|
6367
|
-
return adapter(config).then(function onAdapterResolution(response) {
|
|
6368
|
-
throwIfCancellationRequested(config);
|
|
6369
|
-
|
|
6370
|
-
// Transform response data
|
|
6371
|
-
response.data = transformData.call(
|
|
6372
|
-
config,
|
|
6373
|
-
config.transformResponse,
|
|
6374
|
-
response
|
|
6375
|
-
);
|
|
6376
|
-
|
|
6377
|
-
response.headers = AxiosHeaders$1.from(response.headers);
|
|
6378
|
-
|
|
6379
|
-
return response;
|
|
6380
|
-
}, function onAdapterRejection(reason) {
|
|
6381
|
-
if (!isCancel$1(reason)) {
|
|
6382
|
-
throwIfCancellationRequested(config);
|
|
6383
|
-
|
|
6384
|
-
// Transform response data
|
|
6385
|
-
if (reason && reason.response) {
|
|
6386
|
-
reason.response.data = transformData.call(
|
|
6387
|
-
config,
|
|
6388
|
-
config.transformResponse,
|
|
6389
|
-
reason.response
|
|
6390
|
-
);
|
|
6391
|
-
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
6392
|
-
}
|
|
6393
|
-
}
|
|
6394
|
-
|
|
6395
|
-
return Promise.reject(reason);
|
|
6396
|
-
});
|
|
6397
|
-
}
|
|
6398
|
-
|
|
6399
|
-
const VERSION$1 = "1.8.4";
|
|
6400
|
-
|
|
6401
|
-
const validators$1 = {};
|
|
6402
|
-
|
|
6403
|
-
// eslint-disable-next-line func-names
|
|
6404
|
-
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
|
|
6405
|
-
validators$1[type] = function validator(thing) {
|
|
6406
|
-
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
|
6407
|
-
};
|
|
6408
|
-
});
|
|
6409
|
-
|
|
6410
|
-
const deprecatedWarnings = {};
|
|
6411
|
-
|
|
6412
|
-
/**
|
|
6413
|
-
* Transitional option validator
|
|
6414
|
-
*
|
|
6415
|
-
* @param {function|boolean?} validator - set to false if the transitional option has been removed
|
|
6416
|
-
* @param {string?} version - deprecated version / removed since version
|
|
6417
|
-
* @param {string?} message - some message with additional info
|
|
6418
|
-
*
|
|
6419
|
-
* @returns {function}
|
|
6420
|
-
*/
|
|
6421
|
-
validators$1.transitional = function transitional(validator, version, message) {
|
|
6422
|
-
function formatMessage(opt, desc) {
|
|
6423
|
-
return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
|
6424
|
-
}
|
|
6425
|
-
|
|
6426
|
-
// eslint-disable-next-line func-names
|
|
6427
|
-
return (value, opt, opts) => {
|
|
6428
|
-
if (validator === false) {
|
|
6429
|
-
throw new AxiosError$1(
|
|
6430
|
-
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
|
6431
|
-
AxiosError$1.ERR_DEPRECATED
|
|
6432
|
-
);
|
|
6433
|
-
}
|
|
6434
|
-
|
|
6435
|
-
if (version && !deprecatedWarnings[opt]) {
|
|
6436
|
-
deprecatedWarnings[opt] = true;
|
|
6437
|
-
// eslint-disable-next-line no-console
|
|
6438
|
-
console.warn(
|
|
6439
|
-
formatMessage(
|
|
6440
|
-
opt,
|
|
6441
|
-
' has been deprecated since v' + version + ' and will be removed in the near future'
|
|
6442
|
-
)
|
|
6443
|
-
);
|
|
6444
|
-
}
|
|
6445
|
-
|
|
6446
|
-
return validator ? validator(value, opt, opts) : true;
|
|
6447
|
-
};
|
|
6448
|
-
};
|
|
6449
|
-
|
|
6450
|
-
validators$1.spelling = function spelling(correctSpelling) {
|
|
6451
|
-
return (value, opt) => {
|
|
6452
|
-
// eslint-disable-next-line no-console
|
|
6453
|
-
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
6454
|
-
return true;
|
|
6455
|
-
}
|
|
6456
|
-
};
|
|
6457
|
-
|
|
6458
|
-
/**
|
|
6459
|
-
* Assert object's properties type
|
|
6460
|
-
*
|
|
6461
|
-
* @param {object} options
|
|
6462
|
-
* @param {object} schema
|
|
6463
|
-
* @param {boolean?} allowUnknown
|
|
6464
|
-
*
|
|
6465
|
-
* @returns {object}
|
|
6466
|
-
*/
|
|
6467
|
-
|
|
6468
|
-
function assertOptions(options, schema, allowUnknown) {
|
|
6469
|
-
if (typeof options !== 'object') {
|
|
6470
|
-
throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
6471
|
-
}
|
|
6472
|
-
const keys = Object.keys(options);
|
|
6473
|
-
let i = keys.length;
|
|
6474
|
-
while (i-- > 0) {
|
|
6475
|
-
const opt = keys[i];
|
|
6476
|
-
const validator = schema[opt];
|
|
6477
|
-
if (validator) {
|
|
6478
|
-
const value = options[opt];
|
|
6479
|
-
const result = value === undefined || validator(value, opt, options);
|
|
6480
|
-
if (result !== true) {
|
|
6481
|
-
throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
6482
|
-
}
|
|
6483
|
-
continue;
|
|
6484
|
-
}
|
|
6485
|
-
if (allowUnknown !== true) {
|
|
6486
|
-
throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
|
|
6487
|
-
}
|
|
6488
|
-
}
|
|
6489
|
-
}
|
|
6490
|
-
|
|
6491
|
-
var validator = {
|
|
6492
|
-
assertOptions,
|
|
6493
|
-
validators: validators$1
|
|
6494
|
-
};
|
|
6495
|
-
|
|
6496
|
-
const validators = validator.validators;
|
|
6497
|
-
|
|
6498
|
-
/**
|
|
6499
|
-
* Create a new instance of Axios
|
|
6500
|
-
*
|
|
6501
|
-
* @param {Object} instanceConfig The default config for the instance
|
|
6502
|
-
*
|
|
6503
|
-
* @return {Axios} A new instance of Axios
|
|
6504
|
-
*/
|
|
6505
|
-
let Axios$1 = class Axios {
|
|
6506
|
-
constructor(instanceConfig) {
|
|
6507
|
-
this.defaults = instanceConfig;
|
|
6508
|
-
this.interceptors = {
|
|
6509
|
-
request: new InterceptorManager(),
|
|
6510
|
-
response: new InterceptorManager()
|
|
6511
|
-
};
|
|
6512
|
-
}
|
|
6513
|
-
|
|
6514
|
-
/**
|
|
6515
|
-
* Dispatch a request
|
|
6516
|
-
*
|
|
6517
|
-
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
6518
|
-
* @param {?Object} config
|
|
6519
|
-
*
|
|
6520
|
-
* @returns {Promise} The Promise to be fulfilled
|
|
6521
|
-
*/
|
|
6522
|
-
async request(configOrUrl, config) {
|
|
6523
|
-
try {
|
|
6524
|
-
return await this._request(configOrUrl, config);
|
|
6525
|
-
} catch (err) {
|
|
6526
|
-
if (err instanceof Error) {
|
|
6527
|
-
let dummy = {};
|
|
6528
|
-
|
|
6529
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
6530
|
-
|
|
6531
|
-
// slice off the Error: ... line
|
|
6532
|
-
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
|
6533
|
-
try {
|
|
6534
|
-
if (!err.stack) {
|
|
6535
|
-
err.stack = stack;
|
|
6536
|
-
// match without the 2 top stack lines
|
|
6537
|
-
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
|
6538
|
-
err.stack += '\n' + stack;
|
|
6539
|
-
}
|
|
6540
|
-
} catch (e) {
|
|
6541
|
-
// ignore the case where "stack" is an un-writable property
|
|
6542
|
-
}
|
|
6543
|
-
}
|
|
6544
|
-
|
|
6545
|
-
throw err;
|
|
6546
|
-
}
|
|
6547
|
-
}
|
|
6548
|
-
|
|
6549
|
-
_request(configOrUrl, config) {
|
|
6550
|
-
/*eslint no-param-reassign:0*/
|
|
6551
|
-
// Allow for axios('example/url'[, config]) a la fetch API
|
|
6552
|
-
if (typeof configOrUrl === 'string') {
|
|
6553
|
-
config = config || {};
|
|
6554
|
-
config.url = configOrUrl;
|
|
6555
|
-
} else {
|
|
6556
|
-
config = configOrUrl || {};
|
|
6557
|
-
}
|
|
6558
|
-
|
|
6559
|
-
config = mergeConfig$1(this.defaults, config);
|
|
6560
|
-
|
|
6561
|
-
const {transitional, paramsSerializer, headers} = config;
|
|
6562
|
-
|
|
6563
|
-
if (transitional !== undefined) {
|
|
6564
|
-
validator.assertOptions(transitional, {
|
|
6565
|
-
silentJSONParsing: validators.transitional(validators.boolean),
|
|
6566
|
-
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
6567
|
-
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
6568
|
-
}, false);
|
|
6569
|
-
}
|
|
6570
|
-
|
|
6571
|
-
if (paramsSerializer != null) {
|
|
6572
|
-
if (utils$1.isFunction(paramsSerializer)) {
|
|
6573
|
-
config.paramsSerializer = {
|
|
6574
|
-
serialize: paramsSerializer
|
|
6575
|
-
};
|
|
6576
|
-
} else {
|
|
6577
|
-
validator.assertOptions(paramsSerializer, {
|
|
6578
|
-
encode: validators.function,
|
|
6579
|
-
serialize: validators.function
|
|
6580
|
-
}, true);
|
|
6581
|
-
}
|
|
6582
|
-
}
|
|
6583
|
-
|
|
6584
|
-
// Set config.allowAbsoluteUrls
|
|
6585
|
-
if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
|
6586
|
-
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
6587
|
-
} else {
|
|
6588
|
-
config.allowAbsoluteUrls = true;
|
|
6589
|
-
}
|
|
6590
|
-
|
|
6591
|
-
validator.assertOptions(config, {
|
|
6592
|
-
baseUrl: validators.spelling('baseURL'),
|
|
6593
|
-
withXsrfToken: validators.spelling('withXSRFToken')
|
|
6594
|
-
}, true);
|
|
6595
|
-
|
|
6596
|
-
// Set config.method
|
|
6597
|
-
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
6598
|
-
|
|
6599
|
-
// Flatten headers
|
|
6600
|
-
let contextHeaders = headers && utils$1.merge(
|
|
6601
|
-
headers.common,
|
|
6602
|
-
headers[config.method]
|
|
6603
|
-
);
|
|
6604
|
-
|
|
6605
|
-
headers && utils$1.forEach(
|
|
6606
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
6607
|
-
(method) => {
|
|
6608
|
-
delete headers[method];
|
|
6609
|
-
}
|
|
6610
|
-
);
|
|
6611
|
-
|
|
6612
|
-
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
6613
|
-
|
|
6614
|
-
// filter out skipped interceptors
|
|
6615
|
-
const requestInterceptorChain = [];
|
|
6616
|
-
let synchronousRequestInterceptors = true;
|
|
6617
|
-
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
6618
|
-
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
|
6619
|
-
return;
|
|
6620
|
-
}
|
|
6621
|
-
|
|
6622
|
-
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
6623
|
-
|
|
6624
|
-
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
6625
|
-
});
|
|
6626
|
-
|
|
6627
|
-
const responseInterceptorChain = [];
|
|
6628
|
-
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
6629
|
-
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
6630
|
-
});
|
|
6631
|
-
|
|
6632
|
-
let promise;
|
|
6633
|
-
let i = 0;
|
|
6634
|
-
let len;
|
|
6635
|
-
|
|
6636
|
-
if (!synchronousRequestInterceptors) {
|
|
6637
|
-
const chain = [dispatchRequest.bind(this), undefined];
|
|
6638
|
-
chain.unshift.apply(chain, requestInterceptorChain);
|
|
6639
|
-
chain.push.apply(chain, responseInterceptorChain);
|
|
6640
|
-
len = chain.length;
|
|
6641
|
-
|
|
6642
|
-
promise = Promise.resolve(config);
|
|
6643
|
-
|
|
6644
|
-
while (i < len) {
|
|
6645
|
-
promise = promise.then(chain[i++], chain[i++]);
|
|
6646
|
-
}
|
|
6647
|
-
|
|
6648
|
-
return promise;
|
|
6649
|
-
}
|
|
6650
|
-
|
|
6651
|
-
len = requestInterceptorChain.length;
|
|
6652
|
-
|
|
6653
|
-
let newConfig = config;
|
|
6654
|
-
|
|
6655
|
-
i = 0;
|
|
6656
|
-
|
|
6657
|
-
while (i < len) {
|
|
6658
|
-
const onFulfilled = requestInterceptorChain[i++];
|
|
6659
|
-
const onRejected = requestInterceptorChain[i++];
|
|
6660
|
-
try {
|
|
6661
|
-
newConfig = onFulfilled(newConfig);
|
|
6662
|
-
} catch (error) {
|
|
6663
|
-
onRejected.call(this, error);
|
|
6664
|
-
break;
|
|
6665
|
-
}
|
|
6666
|
-
}
|
|
6667
|
-
|
|
6668
|
-
try {
|
|
6669
|
-
promise = dispatchRequest.call(this, newConfig);
|
|
6670
|
-
} catch (error) {
|
|
6671
|
-
return Promise.reject(error);
|
|
6672
|
-
}
|
|
6673
|
-
|
|
6674
|
-
i = 0;
|
|
6675
|
-
len = responseInterceptorChain.length;
|
|
6676
|
-
|
|
6677
|
-
while (i < len) {
|
|
6678
|
-
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
|
6679
|
-
}
|
|
6680
|
-
|
|
6681
|
-
return promise;
|
|
6682
|
-
}
|
|
6683
|
-
|
|
6684
|
-
getUri(config) {
|
|
6685
|
-
config = mergeConfig$1(this.defaults, config);
|
|
6686
|
-
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
6687
|
-
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
6688
|
-
}
|
|
6689
|
-
};
|
|
6690
|
-
|
|
6691
|
-
// Provide aliases for supported request methods
|
|
6692
|
-
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
6693
|
-
/*eslint func-names:0*/
|
|
6694
|
-
Axios$1.prototype[method] = function(url, config) {
|
|
6695
|
-
return this.request(mergeConfig$1(config || {}, {
|
|
6696
|
-
method,
|
|
6697
|
-
url,
|
|
6698
|
-
data: (config || {}).data
|
|
6699
|
-
}));
|
|
6700
|
-
};
|
|
6701
|
-
});
|
|
6702
|
-
|
|
6703
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
6704
|
-
/*eslint func-names:0*/
|
|
6705
|
-
|
|
6706
|
-
function generateHTTPMethod(isForm) {
|
|
6707
|
-
return function httpMethod(url, data, config) {
|
|
6708
|
-
return this.request(mergeConfig$1(config || {}, {
|
|
6709
|
-
method,
|
|
6710
|
-
headers: isForm ? {
|
|
6711
|
-
'Content-Type': 'multipart/form-data'
|
|
6712
|
-
} : {},
|
|
6713
|
-
url,
|
|
6714
|
-
data
|
|
6715
|
-
}));
|
|
6716
|
-
};
|
|
6717
|
-
}
|
|
6718
|
-
|
|
6719
|
-
Axios$1.prototype[method] = generateHTTPMethod();
|
|
6720
|
-
|
|
6721
|
-
Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
6722
|
-
});
|
|
6723
|
-
|
|
6724
|
-
/**
|
|
6725
|
-
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
|
6726
|
-
*
|
|
6727
|
-
* @param {Function} executor The executor function.
|
|
6728
|
-
*
|
|
6729
|
-
* @returns {CancelToken}
|
|
6730
|
-
*/
|
|
6731
|
-
let CancelToken$1 = class CancelToken {
|
|
6732
|
-
constructor(executor) {
|
|
6733
|
-
if (typeof executor !== 'function') {
|
|
6734
|
-
throw new TypeError('executor must be a function.');
|
|
6735
|
-
}
|
|
6736
|
-
|
|
6737
|
-
let resolvePromise;
|
|
6738
|
-
|
|
6739
|
-
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
6740
|
-
resolvePromise = resolve;
|
|
6741
|
-
});
|
|
6742
|
-
|
|
6743
|
-
const token = this;
|
|
6744
|
-
|
|
6745
|
-
// eslint-disable-next-line func-names
|
|
6746
|
-
this.promise.then(cancel => {
|
|
6747
|
-
if (!token._listeners) return;
|
|
6748
|
-
|
|
6749
|
-
let i = token._listeners.length;
|
|
6750
|
-
|
|
6751
|
-
while (i-- > 0) {
|
|
6752
|
-
token._listeners[i](cancel);
|
|
6753
|
-
}
|
|
6754
|
-
token._listeners = null;
|
|
6755
|
-
});
|
|
6756
|
-
|
|
6757
|
-
// eslint-disable-next-line func-names
|
|
6758
|
-
this.promise.then = onfulfilled => {
|
|
6759
|
-
let _resolve;
|
|
6760
|
-
// eslint-disable-next-line func-names
|
|
6761
|
-
const promise = new Promise(resolve => {
|
|
6762
|
-
token.subscribe(resolve);
|
|
6763
|
-
_resolve = resolve;
|
|
6764
|
-
}).then(onfulfilled);
|
|
6765
|
-
|
|
6766
|
-
promise.cancel = function reject() {
|
|
6767
|
-
token.unsubscribe(_resolve);
|
|
6768
|
-
};
|
|
6769
|
-
|
|
6770
|
-
return promise;
|
|
6771
|
-
};
|
|
6772
|
-
|
|
6773
|
-
executor(function cancel(message, config, request) {
|
|
6774
|
-
if (token.reason) {
|
|
6775
|
-
// Cancellation has already been requested
|
|
6776
|
-
return;
|
|
6777
|
-
}
|
|
6778
|
-
|
|
6779
|
-
token.reason = new CanceledError$1(message, config, request);
|
|
6780
|
-
resolvePromise(token.reason);
|
|
6781
|
-
});
|
|
6782
|
-
}
|
|
6783
|
-
|
|
6784
|
-
/**
|
|
6785
|
-
* Throws a `CanceledError` if cancellation has been requested.
|
|
6786
|
-
*/
|
|
6787
|
-
throwIfRequested() {
|
|
6788
|
-
if (this.reason) {
|
|
6789
|
-
throw this.reason;
|
|
6790
|
-
}
|
|
6791
|
-
}
|
|
6792
|
-
|
|
6793
|
-
/**
|
|
6794
|
-
* Subscribe to the cancel signal
|
|
6795
|
-
*/
|
|
6796
|
-
|
|
6797
|
-
subscribe(listener) {
|
|
6798
|
-
if (this.reason) {
|
|
6799
|
-
listener(this.reason);
|
|
6800
|
-
return;
|
|
6801
|
-
}
|
|
6802
|
-
|
|
6803
|
-
if (this._listeners) {
|
|
6804
|
-
this._listeners.push(listener);
|
|
6805
|
-
} else {
|
|
6806
|
-
this._listeners = [listener];
|
|
6807
|
-
}
|
|
6808
|
-
}
|
|
6809
|
-
|
|
6810
|
-
/**
|
|
6811
|
-
* Unsubscribe from the cancel signal
|
|
6812
|
-
*/
|
|
6813
|
-
|
|
6814
|
-
unsubscribe(listener) {
|
|
6815
|
-
if (!this._listeners) {
|
|
6816
|
-
return;
|
|
6817
|
-
}
|
|
6818
|
-
const index = this._listeners.indexOf(listener);
|
|
6819
|
-
if (index !== -1) {
|
|
6820
|
-
this._listeners.splice(index, 1);
|
|
6821
|
-
}
|
|
6822
|
-
}
|
|
6823
|
-
|
|
6824
|
-
toAbortSignal() {
|
|
6825
|
-
const controller = new AbortController();
|
|
6826
|
-
|
|
6827
|
-
const abort = (err) => {
|
|
6828
|
-
controller.abort(err);
|
|
6829
|
-
};
|
|
6830
|
-
|
|
6831
|
-
this.subscribe(abort);
|
|
6832
|
-
|
|
6833
|
-
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
6834
|
-
|
|
6835
|
-
return controller.signal;
|
|
6836
|
-
}
|
|
6837
|
-
|
|
6838
|
-
/**
|
|
6839
|
-
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
6840
|
-
* cancels the `CancelToken`.
|
|
6841
|
-
*/
|
|
6842
|
-
static source() {
|
|
6843
|
-
let cancel;
|
|
6844
|
-
const token = new CancelToken(function executor(c) {
|
|
6845
|
-
cancel = c;
|
|
6846
|
-
});
|
|
6847
|
-
return {
|
|
6848
|
-
token,
|
|
6849
|
-
cancel
|
|
6850
|
-
};
|
|
6851
|
-
}
|
|
6852
|
-
};
|
|
6853
|
-
|
|
6854
|
-
/**
|
|
6855
|
-
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
|
6856
|
-
*
|
|
6857
|
-
* Common use case would be to use `Function.prototype.apply`.
|
|
6858
|
-
*
|
|
6859
|
-
* ```js
|
|
6860
|
-
* function f(x, y, z) {}
|
|
6861
|
-
* var args = [1, 2, 3];
|
|
6862
|
-
* f.apply(null, args);
|
|
6863
|
-
* ```
|
|
6864
|
-
*
|
|
6865
|
-
* With `spread` this example can be re-written.
|
|
6866
|
-
*
|
|
6867
|
-
* ```js
|
|
6868
|
-
* spread(function(x, y, z) {})([1, 2, 3]);
|
|
6869
|
-
* ```
|
|
6870
|
-
*
|
|
6871
|
-
* @param {Function} callback
|
|
6872
|
-
*
|
|
6873
|
-
* @returns {Function}
|
|
6874
|
-
*/
|
|
6875
|
-
function spread$1(callback) {
|
|
6876
|
-
return function wrap(arr) {
|
|
6877
|
-
return callback.apply(null, arr);
|
|
6878
|
-
};
|
|
6879
|
-
}
|
|
6880
|
-
|
|
6881
|
-
/**
|
|
6882
|
-
* Determines whether the payload is an error thrown by Axios
|
|
6883
|
-
*
|
|
6884
|
-
* @param {*} payload The value to test
|
|
6885
|
-
*
|
|
6886
|
-
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
6887
|
-
*/
|
|
6888
|
-
function isAxiosError$1(payload) {
|
|
6889
|
-
return utils$1.isObject(payload) && (payload.isAxiosError === true);
|
|
6890
|
-
}
|
|
6891
|
-
|
|
6892
|
-
const HttpStatusCode$1 = {
|
|
6893
|
-
Continue: 100,
|
|
6894
|
-
SwitchingProtocols: 101,
|
|
6895
|
-
Processing: 102,
|
|
6896
|
-
EarlyHints: 103,
|
|
6897
|
-
Ok: 200,
|
|
6898
|
-
Created: 201,
|
|
6899
|
-
Accepted: 202,
|
|
6900
|
-
NonAuthoritativeInformation: 203,
|
|
6901
|
-
NoContent: 204,
|
|
6902
|
-
ResetContent: 205,
|
|
6903
|
-
PartialContent: 206,
|
|
6904
|
-
MultiStatus: 207,
|
|
6905
|
-
AlreadyReported: 208,
|
|
6906
|
-
ImUsed: 226,
|
|
6907
|
-
MultipleChoices: 300,
|
|
6908
|
-
MovedPermanently: 301,
|
|
6909
|
-
Found: 302,
|
|
6910
|
-
SeeOther: 303,
|
|
6911
|
-
NotModified: 304,
|
|
6912
|
-
UseProxy: 305,
|
|
6913
|
-
Unused: 306,
|
|
6914
|
-
TemporaryRedirect: 307,
|
|
6915
|
-
PermanentRedirect: 308,
|
|
6916
|
-
BadRequest: 400,
|
|
6917
|
-
Unauthorized: 401,
|
|
6918
|
-
PaymentRequired: 402,
|
|
6919
|
-
Forbidden: 403,
|
|
6920
|
-
NotFound: 404,
|
|
6921
|
-
MethodNotAllowed: 405,
|
|
6922
|
-
NotAcceptable: 406,
|
|
6923
|
-
ProxyAuthenticationRequired: 407,
|
|
6924
|
-
RequestTimeout: 408,
|
|
6925
|
-
Conflict: 409,
|
|
6926
|
-
Gone: 410,
|
|
6927
|
-
LengthRequired: 411,
|
|
6928
|
-
PreconditionFailed: 412,
|
|
6929
|
-
PayloadTooLarge: 413,
|
|
6930
|
-
UriTooLong: 414,
|
|
6931
|
-
UnsupportedMediaType: 415,
|
|
6932
|
-
RangeNotSatisfiable: 416,
|
|
6933
|
-
ExpectationFailed: 417,
|
|
6934
|
-
ImATeapot: 418,
|
|
6935
|
-
MisdirectedRequest: 421,
|
|
6936
|
-
UnprocessableEntity: 422,
|
|
6937
|
-
Locked: 423,
|
|
6938
|
-
FailedDependency: 424,
|
|
6939
|
-
TooEarly: 425,
|
|
6940
|
-
UpgradeRequired: 426,
|
|
6941
|
-
PreconditionRequired: 428,
|
|
6942
|
-
TooManyRequests: 429,
|
|
6943
|
-
RequestHeaderFieldsTooLarge: 431,
|
|
6944
|
-
UnavailableForLegalReasons: 451,
|
|
6945
|
-
InternalServerError: 500,
|
|
6946
|
-
NotImplemented: 501,
|
|
6947
|
-
BadGateway: 502,
|
|
6948
|
-
ServiceUnavailable: 503,
|
|
6949
|
-
GatewayTimeout: 504,
|
|
6950
|
-
HttpVersionNotSupported: 505,
|
|
6951
|
-
VariantAlsoNegotiates: 506,
|
|
6952
|
-
InsufficientStorage: 507,
|
|
6953
|
-
LoopDetected: 508,
|
|
6954
|
-
NotExtended: 510,
|
|
6955
|
-
NetworkAuthenticationRequired: 511,
|
|
6956
|
-
};
|
|
6957
|
-
|
|
6958
|
-
Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|
|
6959
|
-
HttpStatusCode$1[value] = key;
|
|
6960
|
-
});
|
|
6961
|
-
|
|
6962
|
-
/**
|
|
6963
|
-
* Create an instance of Axios
|
|
6964
|
-
*
|
|
6965
|
-
* @param {Object} defaultConfig The default config for the instance
|
|
6966
|
-
*
|
|
6967
|
-
* @returns {Axios} A new instance of Axios
|
|
6968
|
-
*/
|
|
6969
|
-
function createInstance(defaultConfig) {
|
|
6970
|
-
const context = new Axios$1(defaultConfig);
|
|
6971
|
-
const instance = bind(Axios$1.prototype.request, context);
|
|
6972
|
-
|
|
6973
|
-
// Copy axios.prototype to instance
|
|
6974
|
-
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
|
6975
|
-
|
|
6976
|
-
// Copy context to instance
|
|
6977
|
-
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
6978
|
-
|
|
6979
|
-
// Factory for creating new instances
|
|
6980
|
-
instance.create = function create(instanceConfig) {
|
|
6981
|
-
return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
|
|
6982
|
-
};
|
|
6983
|
-
|
|
6984
|
-
return instance;
|
|
6985
|
-
}
|
|
6986
|
-
|
|
6987
|
-
// Create the default instance to be exported
|
|
6988
|
-
const axios = createInstance(defaults);
|
|
6989
|
-
|
|
6990
|
-
// Expose Axios class to allow class inheritance
|
|
6991
|
-
axios.Axios = Axios$1;
|
|
6992
|
-
|
|
6993
|
-
// Expose Cancel & CancelToken
|
|
6994
|
-
axios.CanceledError = CanceledError$1;
|
|
6995
|
-
axios.CancelToken = CancelToken$1;
|
|
6996
|
-
axios.isCancel = isCancel$1;
|
|
6997
|
-
axios.VERSION = VERSION$1;
|
|
6998
|
-
axios.toFormData = toFormData$1;
|
|
6999
|
-
|
|
7000
|
-
// Expose AxiosError class
|
|
7001
|
-
axios.AxiosError = AxiosError$1;
|
|
7002
|
-
|
|
7003
|
-
// alias for CanceledError for backward compatibility
|
|
7004
|
-
axios.Cancel = axios.CanceledError;
|
|
7005
|
-
|
|
7006
|
-
// Expose all/spread
|
|
7007
|
-
axios.all = function all(promises) {
|
|
7008
|
-
return Promise.all(promises);
|
|
7009
|
-
};
|
|
7010
|
-
|
|
7011
|
-
axios.spread = spread$1;
|
|
7012
|
-
|
|
7013
|
-
// Expose isAxiosError
|
|
7014
|
-
axios.isAxiosError = isAxiosError$1;
|
|
7015
|
-
|
|
7016
|
-
// Expose mergeConfig
|
|
7017
|
-
axios.mergeConfig = mergeConfig$1;
|
|
7018
|
-
|
|
7019
|
-
axios.AxiosHeaders = AxiosHeaders$1;
|
|
7020
|
-
|
|
7021
|
-
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
7022
|
-
|
|
7023
|
-
axios.getAdapter = adapters.getAdapter;
|
|
7024
|
-
|
|
7025
|
-
axios.HttpStatusCode = HttpStatusCode$1;
|
|
7026
|
-
|
|
7027
|
-
axios.default = axios;
|
|
7028
|
-
|
|
7029
|
-
// This module is intended to unwrap Axios default export as named.
|
|
7030
|
-
// Keep top-level export same with static properties
|
|
7031
|
-
// so that it can keep same with es module or cjs
|
|
7032
|
-
const {
|
|
7033
|
-
Axios,
|
|
7034
|
-
AxiosError,
|
|
7035
|
-
CanceledError,
|
|
7036
|
-
isCancel,
|
|
7037
|
-
CancelToken,
|
|
7038
|
-
VERSION,
|
|
7039
|
-
all,
|
|
7040
|
-
Cancel,
|
|
7041
|
-
isAxiosError,
|
|
7042
|
-
spread,
|
|
7043
|
-
toFormData,
|
|
7044
|
-
AxiosHeaders,
|
|
7045
|
-
HttpStatusCode,
|
|
7046
|
-
formToJSON,
|
|
7047
|
-
getAdapter,
|
|
7048
|
-
mergeConfig
|
|
7049
|
-
} = axios;
|
|
7050
|
-
|
|
7051
|
-
var __async = (__this, __arguments, generator) => {
|
|
7052
|
-
return new Promise((resolve, reject) => {
|
|
7053
|
-
var fulfilled = (value) => {
|
|
7054
|
-
try {
|
|
7055
|
-
step(generator.next(value));
|
|
7056
|
-
} catch (e) {
|
|
7057
|
-
reject(e);
|
|
3123
|
+
const previousJoinedNS = usePrevious(joinedNS);
|
|
3124
|
+
const isMounted = useRef(true);
|
|
3125
|
+
useEffect(() => {
|
|
3126
|
+
const {
|
|
3127
|
+
bindI18n,
|
|
3128
|
+
bindI18nStore
|
|
3129
|
+
} = i18nOptions;
|
|
3130
|
+
isMounted.current = true;
|
|
3131
|
+
if (!ready && !useSuspense) {
|
|
3132
|
+
if (props.lng) {
|
|
3133
|
+
loadLanguages(i18n, props.lng, namespaces, () => {
|
|
3134
|
+
if (isMounted.current) setT(getNewT);
|
|
3135
|
+
});
|
|
3136
|
+
} else {
|
|
3137
|
+
loadNamespaces(i18n, namespaces, () => {
|
|
3138
|
+
if (isMounted.current) setT(getNewT);
|
|
3139
|
+
});
|
|
7058
3140
|
}
|
|
3141
|
+
}
|
|
3142
|
+
if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
|
|
3143
|
+
setT(getNewT);
|
|
3144
|
+
}
|
|
3145
|
+
const boundReset = () => {
|
|
3146
|
+
if (isMounted.current) setT(getNewT);
|
|
7059
3147
|
};
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
3148
|
+
if (bindI18n) i18n?.on(bindI18n, boundReset);
|
|
3149
|
+
if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset);
|
|
3150
|
+
return () => {
|
|
3151
|
+
isMounted.current = false;
|
|
3152
|
+
if (i18n) bindI18n?.split(' ').forEach(e => i18n.off(e, boundReset));
|
|
3153
|
+
if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
|
|
7066
3154
|
};
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
var API_BASE_URL = "https://api.betterstore.io/v1";
|
|
7072
|
-
var createApiClient = (apiKey, proxy) => {
|
|
7073
|
-
const client = axios.create({
|
|
7074
|
-
baseURL: proxy != null ? proxy : API_BASE_URL,
|
|
7075
|
-
headers: {
|
|
7076
|
-
"Content-Type": "application/json",
|
|
7077
|
-
Authorization: `Bearer ${apiKey}`,
|
|
7078
|
-
"Access-Control-Allow-Origin": "*",
|
|
7079
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
7080
|
-
"Access-Control-Allow-Headers": "Content-Type, Authorization"
|
|
3155
|
+
}, [i18n, joinedNS]);
|
|
3156
|
+
useEffect(() => {
|
|
3157
|
+
if (isMounted.current && ready) {
|
|
3158
|
+
setT(getT);
|
|
7081
3159
|
}
|
|
7082
|
-
});
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
apiError.code = (_b = error.response.data) == null ? void 0 : _b.code;
|
|
7095
|
-
apiError.details = error.response.data;
|
|
7096
|
-
} else if (error.request) {
|
|
7097
|
-
apiError.status = 503;
|
|
7098
|
-
apiError.message = "Service unavailable - no response from server";
|
|
7099
|
-
apiError.code = "SERVICE_UNAVAILABLE";
|
|
7100
|
-
apiError.details = error;
|
|
7101
|
-
} else {
|
|
7102
|
-
apiError.status = 500;
|
|
7103
|
-
apiError.message = "Request configuration error";
|
|
7104
|
-
apiError.code = "REQUEST_SETUP_ERROR";
|
|
7105
|
-
apiError.details = error;
|
|
7106
|
-
}
|
|
7107
|
-
throw apiError;
|
|
3160
|
+
}, [i18n, keyPrefix, ready]);
|
|
3161
|
+
const ret = [t, i18n, ready];
|
|
3162
|
+
ret.t = t;
|
|
3163
|
+
ret.i18n = i18n;
|
|
3164
|
+
ret.ready = ready;
|
|
3165
|
+
if (ready) return ret;
|
|
3166
|
+
if (!ready && !useSuspense) return ret;
|
|
3167
|
+
throw new Promise(resolve => {
|
|
3168
|
+
if (props.lng) {
|
|
3169
|
+
loadLanguages(i18n, props.lng, namespaces, () => resolve());
|
|
3170
|
+
} else {
|
|
3171
|
+
loadNamespaces(i18n, namespaces, () => resolve());
|
|
7108
3172
|
}
|
|
7109
|
-
);
|
|
7110
|
-
return client;
|
|
3173
|
+
});
|
|
7111
3174
|
};
|
|
7112
3175
|
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
const data = yield apiClient.post("/customer", params);
|
|
7174
|
-
return data;
|
|
7175
|
-
});
|
|
7176
|
-
}
|
|
7177
|
-
/**
|
|
7178
|
-
* Retrieve a customer by ID or email
|
|
7179
|
-
*/
|
|
7180
|
-
retrieveCustomer(clientSecret, idOrEmail) {
|
|
7181
|
-
return __async(this, null, function* () {
|
|
7182
|
-
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
7183
|
-
const data = yield apiClient.get(`/customer/${idOrEmail}`);
|
|
7184
|
-
if (!data) {
|
|
7185
|
-
throw new Error("Customer not found");
|
|
7186
|
-
}
|
|
7187
|
-
return data;
|
|
7188
|
-
});
|
|
7189
|
-
}
|
|
7190
|
-
/**
|
|
7191
|
-
* Update a customer
|
|
7192
|
-
*/
|
|
7193
|
-
updateCustomer(clientSecret, customerId, params) {
|
|
7194
|
-
return __async(this, null, function* () {
|
|
7195
|
-
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
7196
|
-
const data = yield apiClient.put(
|
|
7197
|
-
`/customer/${customerId}`,
|
|
7198
|
-
params
|
|
7199
|
-
);
|
|
7200
|
-
return data;
|
|
7201
|
-
});
|
|
7202
|
-
}
|
|
3176
|
+
const CheckoutEmbed$2 = {
|
|
3177
|
+
CustomerForm: {
|
|
3178
|
+
address: {
|
|
3179
|
+
address: "Adresa",
|
|
3180
|
+
addressPlaceholder: "Zadejte svou adresu",
|
|
3181
|
+
button: "Uložit adresu",
|
|
3182
|
+
city: "Město",
|
|
3183
|
+
cityPlaceholder: "San Francisco",
|
|
3184
|
+
country: "Země",
|
|
3185
|
+
countryPlaceholder: "Vstoupit do své země",
|
|
3186
|
+
description: "Níže vyplňte údaje o vaší adrese.",
|
|
3187
|
+
line1: "Adresa ulice",
|
|
3188
|
+
line1Placeholder: "123 Hlavní ulice",
|
|
3189
|
+
line2: "Byt, apartmá, jednotka atd. (Volitelné)",
|
|
3190
|
+
line2Placeholder: "APT 4B, Suite 123, atd.",
|
|
3191
|
+
state: "Stát (volitelné)",
|
|
3192
|
+
statePlaceholder: "Kalifornie",
|
|
3193
|
+
title: "Zadejte svou adresu",
|
|
3194
|
+
zipCode: "PSČ",
|
|
3195
|
+
zipCodePlaceholder: "12345"
|
|
3196
|
+
},
|
|
3197
|
+
button: "Uložit a pokračovat",
|
|
3198
|
+
email: "E-mail",
|
|
3199
|
+
emailPlaceholder: "Zadejte svůj e -mail",
|
|
3200
|
+
firstName: "Křestní jméno",
|
|
3201
|
+
firstNamePlaceholder: "Zadejte své křestní jméno",
|
|
3202
|
+
lastName: "Příjmení",
|
|
3203
|
+
lastNamePlaceholder: "Zadejte své příjmení",
|
|
3204
|
+
phone: "Telefon",
|
|
3205
|
+
phonePlaceholder: "Zadejte své telefonní číslo",
|
|
3206
|
+
title: "Údaje o doručení"
|
|
3207
|
+
},
|
|
3208
|
+
Summary: {
|
|
3209
|
+
calculatedAtNextStep: "Vypočítáno v dalším kroku",
|
|
3210
|
+
edit: "Upravit",
|
|
3211
|
+
shipping: "Přeprava",
|
|
3212
|
+
subtotal: "Subtotál",
|
|
3213
|
+
tax: "Daň",
|
|
3214
|
+
title: "Shrnutí",
|
|
3215
|
+
total: "Celkový"
|
|
3216
|
+
},
|
|
3217
|
+
loading: "Načítání ...",
|
|
3218
|
+
Payment: {
|
|
3219
|
+
back: "Zpět na doručení",
|
|
3220
|
+
button: "Koupit hned teď",
|
|
3221
|
+
description: "Všechny transakce jsou bezpečné a šifrovány.",
|
|
3222
|
+
title: "Platba"
|
|
3223
|
+
},
|
|
3224
|
+
Shipping: {
|
|
3225
|
+
back: "Zpět k informacím",
|
|
3226
|
+
button: "Pokračujte v pokladně",
|
|
3227
|
+
change: "Přeměna",
|
|
3228
|
+
contact: "Kontakt:",
|
|
3229
|
+
day: "den",
|
|
3230
|
+
days: "dny",
|
|
3231
|
+
estimatedDeliveryDate: "Odhadované datum dodání:",
|
|
3232
|
+
shipTo: "Ship to:",
|
|
3233
|
+
shipping: "Doprava:",
|
|
3234
|
+
title: "Přeprava"
|
|
3235
|
+
}
|
|
7203
3236
|
};
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
|
|
7212
|
-
const isWhole = amount % 1 === 0;
|
|
7213
|
-
const currencyLocales = {
|
|
7214
|
-
CZK: "cs-CZ",
|
|
7215
|
-
// Czech Koruna
|
|
7216
|
-
USD: "en-US",
|
|
7217
|
-
// US Dollar
|
|
7218
|
-
EUR: "de-DE",
|
|
7219
|
-
// Euro (Germany locale)
|
|
7220
|
-
GBP: "en-GB",
|
|
7221
|
-
// British Pound
|
|
7222
|
-
JPY: "ja-JP",
|
|
7223
|
-
// Japanese Yen
|
|
7224
|
-
AUD: "en-AU",
|
|
7225
|
-
// Australian Dollar
|
|
7226
|
-
CAD: "en-CA",
|
|
7227
|
-
// Canadian Dollar
|
|
7228
|
-
NZD: "en-NZ",
|
|
7229
|
-
// New Zealand Dollar
|
|
7230
|
-
SEK: "sv-SE",
|
|
7231
|
-
// Swedish Krona
|
|
7232
|
-
NOK: "nb-NO",
|
|
7233
|
-
// Norwegian Krone
|
|
7234
|
-
DKK: "da-DK",
|
|
7235
|
-
// Danish Krone
|
|
7236
|
-
CHF: "de-CH",
|
|
7237
|
-
// Swiss Franc (German Switzerland)
|
|
7238
|
-
HUF: "hu-HU",
|
|
7239
|
-
// Hungarian Forint
|
|
7240
|
-
PLN: "pl-PL",
|
|
7241
|
-
// Polish Zloty
|
|
7242
|
-
BGN: "bg-BG",
|
|
7243
|
-
// Bulgarian Lev
|
|
7244
|
-
RON: "ro-RO",
|
|
7245
|
-
// Romanian Leu
|
|
7246
|
-
RUB: "ru-RU",
|
|
7247
|
-
// Russian Ruble
|
|
7248
|
-
CNY: "zh-CN",
|
|
7249
|
-
// Chinese Yuan
|
|
7250
|
-
INR: "en-IN",
|
|
7251
|
-
// Indian Rupee
|
|
7252
|
-
BRL: "pt-BR",
|
|
7253
|
-
// Brazilian Real
|
|
7254
|
-
MXN: "es-MX",
|
|
7255
|
-
// Mexican Peso
|
|
7256
|
-
ZAR: "en-ZA",
|
|
7257
|
-
// South African Rand
|
|
7258
|
-
KRW: "ko-KR",
|
|
7259
|
-
// South Korean Won
|
|
7260
|
-
MYR: "ms-MY",
|
|
7261
|
-
// Malaysian Ringgit
|
|
7262
|
-
SGD: "en-SG",
|
|
7263
|
-
// Singapore Dollar
|
|
7264
|
-
TWD: "zh-TW",
|
|
7265
|
-
// Taiwanese Dollar
|
|
7266
|
-
THB: "th-TH",
|
|
7267
|
-
// Thai Baht
|
|
7268
|
-
IDR: "id-ID",
|
|
7269
|
-
// Indonesian Rupiah
|
|
7270
|
-
AED: "ar-AE",
|
|
7271
|
-
// UAE Dirham
|
|
7272
|
-
SAR: "ar-SA",
|
|
7273
|
-
// Saudi Riyal
|
|
7274
|
-
TRY: "tr-TR"
|
|
7275
|
-
// Turkish Lira
|
|
7276
|
-
};
|
|
7277
|
-
const locale = (_a = currencyLocales[currency]) != null ? _a : void 0;
|
|
7278
|
-
const formattedPrice = new Intl.NumberFormat(locale, {
|
|
7279
|
-
style: "currency",
|
|
7280
|
-
currency,
|
|
7281
|
-
currencyDisplay: "symbol",
|
|
7282
|
-
minimumFractionDigits: isWhole ? 0 : 2,
|
|
7283
|
-
maximumFractionDigits: isWhole ? 0 : 2
|
|
7284
|
-
}).format(amount);
|
|
7285
|
-
return formattedPrice;
|
|
7286
|
-
}
|
|
7287
|
-
getExchangeRate(baseCurrency, targetCurrency) {
|
|
7288
|
-
return __async(this, null, function* () {
|
|
7289
|
-
const { data } = yield axios.get(
|
|
7290
|
-
`https://api.exchangerate-api.com/v4/latest/${baseCurrency}`
|
|
7291
|
-
);
|
|
7292
|
-
const rate = data.rates[targetCurrency];
|
|
7293
|
-
if (!rate) {
|
|
7294
|
-
throw new Error("Could not get exchange rate for target currency");
|
|
7295
|
-
}
|
|
7296
|
-
return rate;
|
|
7297
|
-
});
|
|
7298
|
-
}
|
|
3237
|
+
const Errors$1 = {
|
|
3238
|
+
invalid_email: "Zadejte platnou e -mailovou adresu",
|
|
3239
|
+
invalid_phone: "Zadejte platné telefonní číslo",
|
|
3240
|
+
invalid_zipCode: "Zadejte platný PSČ",
|
|
3241
|
+
required_error: "Toto pole je nutné",
|
|
3242
|
+
unknown_error: "Došlo k neznámé chybě",
|
|
3243
|
+
invalid_address: "Zadejte platnou adresu"
|
|
7299
3244
|
};
|
|
7300
|
-
var
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
}
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
3245
|
+
var cs = {
|
|
3246
|
+
CheckoutEmbed: CheckoutEmbed$2,
|
|
3247
|
+
Errors: Errors$1
|
|
3248
|
+
};
|
|
3249
|
+
|
|
3250
|
+
const CheckoutEmbed$1 = {
|
|
3251
|
+
Summary: {
|
|
3252
|
+
title: "Summary",
|
|
3253
|
+
edit: "Edit",
|
|
3254
|
+
total: "Total",
|
|
3255
|
+
subtotal: "Subtotal",
|
|
3256
|
+
shipping: "Shipping",
|
|
3257
|
+
calculatedAtNextStep: "Calculated at next step",
|
|
3258
|
+
tax: "Tax"
|
|
3259
|
+
},
|
|
3260
|
+
CustomerForm: {
|
|
3261
|
+
address: {
|
|
3262
|
+
address: "Address",
|
|
3263
|
+
addressPlaceholder: "Enter your address",
|
|
3264
|
+
title: "Enter your address",
|
|
3265
|
+
description: "Fill in your address details below.",
|
|
3266
|
+
line1: "Street address",
|
|
3267
|
+
line1Placeholder: "123 Main Street",
|
|
3268
|
+
line2: "Apartment, suite, unit, etc. (optional)",
|
|
3269
|
+
line2Placeholder: "Apt 4B, Suite 123, etc.",
|
|
3270
|
+
city: "City",
|
|
3271
|
+
cityPlaceholder: "San Francisco",
|
|
3272
|
+
country: "Country",
|
|
3273
|
+
countryPlaceholder: "Enter your country",
|
|
3274
|
+
state: "State (optional)",
|
|
3275
|
+
statePlaceholder: "California",
|
|
3276
|
+
zipCode: "Zip code",
|
|
3277
|
+
zipCodePlaceholder: "12345",
|
|
3278
|
+
button: "Save address"
|
|
3279
|
+
},
|
|
3280
|
+
title: "Basic information",
|
|
3281
|
+
email: "Email",
|
|
3282
|
+
emailPlaceholder: "Enter your email",
|
|
3283
|
+
firstName: "First name",
|
|
3284
|
+
firstNamePlaceholder: "Enter your first name",
|
|
3285
|
+
lastName: "Last name",
|
|
3286
|
+
lastNamePlaceholder: "Enter your last name",
|
|
3287
|
+
phone: "Phone",
|
|
3288
|
+
phonePlaceholder: "Enter your phone number",
|
|
3289
|
+
button: "Save and continue"
|
|
3290
|
+
},
|
|
3291
|
+
loading: "Loading...",
|
|
3292
|
+
Shipping: {
|
|
3293
|
+
title: "Shipping",
|
|
3294
|
+
change: "Change",
|
|
3295
|
+
shipTo: "Ship to:",
|
|
3296
|
+
contact: "Contact:",
|
|
3297
|
+
button: "Continue to checkout",
|
|
3298
|
+
back: "Back to information",
|
|
3299
|
+
shipping: "Shipping:",
|
|
3300
|
+
estimatedDeliveryDate: "Estimated delivery date: ",
|
|
3301
|
+
day: "day",
|
|
3302
|
+
days: "days"
|
|
3303
|
+
},
|
|
3304
|
+
Payment: {
|
|
3305
|
+
title: "Payment",
|
|
3306
|
+
description: "All transactions are secure and encrypted.",
|
|
3307
|
+
back: "Back to shipping",
|
|
3308
|
+
button: "Buy now"
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
const Errors = {
|
|
3312
|
+
required_error: "This field is required",
|
|
3313
|
+
invalid_email: "Please enter a valid email address",
|
|
3314
|
+
invalid_phone: "Please enter a valid phone number",
|
|
3315
|
+
invalid_zipCode: "Please enter a valid zip code",
|
|
3316
|
+
invalid_address: "Please enter a valid address",
|
|
3317
|
+
unknown_error: "An unknown error occurred"
|
|
3318
|
+
};
|
|
3319
|
+
var en = {
|
|
3320
|
+
CheckoutEmbed: CheckoutEmbed$1,
|
|
3321
|
+
Errors: Errors
|
|
3322
|
+
};
|
|
3323
|
+
|
|
3324
|
+
const createI18nInstance = (locale) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3325
|
+
yield instance
|
|
3326
|
+
.use(initReactI18next)
|
|
3327
|
+
.use(Browser)
|
|
3328
|
+
.init({
|
|
3329
|
+
lng: locale,
|
|
3330
|
+
fallbackLng: "en",
|
|
3331
|
+
// debug: true,
|
|
3332
|
+
interpolation: { escapeValue: false },
|
|
3333
|
+
resources: {
|
|
3334
|
+
en: { translation: en },
|
|
3335
|
+
cs: { translation: cs },
|
|
3336
|
+
},
|
|
3337
|
+
});
|
|
3338
|
+
return instance;
|
|
3339
|
+
});
|
|
7307
3340
|
|
|
7308
3341
|
function Appearance({ appearance, }) {
|
|
7309
3342
|
useEffect(() => {
|
|
@@ -32990,7 +29023,7 @@ function AddressInput() {
|
|
|
32990
29023
|
return;
|
|
32991
29024
|
}
|
|
32992
29025
|
const newAddress = form.getValues("address");
|
|
32993
|
-
form.setValue("address", newAddress, { shouldValidate:
|
|
29026
|
+
form.setValue("address", newAddress, { shouldValidate: false });
|
|
32994
29027
|
setOpen(false);
|
|
32995
29028
|
}
|
|
32996
29029
|
finally {
|
|
@@ -32998,17 +29031,17 @@ function AddressInput() {
|
|
|
32998
29031
|
}
|
|
32999
29032
|
}), [form, isValidating]);
|
|
33000
29033
|
useEffect(() => {
|
|
33001
|
-
if (open)
|
|
33002
|
-
|
|
33003
|
-
|
|
33004
|
-
|
|
33005
|
-
|
|
33006
|
-
|
|
33007
|
-
|
|
33008
|
-
}
|
|
33009
|
-
|
|
33010
|
-
|
|
33011
|
-
|
|
29034
|
+
if (!open)
|
|
29035
|
+
return;
|
|
29036
|
+
const isAddressInvalid = form.getFieldState("address").invalid;
|
|
29037
|
+
if (isAddressInvalid) {
|
|
29038
|
+
form.setError("address", {
|
|
29039
|
+
message: "invalid_address",
|
|
29040
|
+
type: "custom",
|
|
29041
|
+
});
|
|
29042
|
+
}
|
|
29043
|
+
else {
|
|
29044
|
+
form.clearErrors("address");
|
|
33012
29045
|
}
|
|
33013
29046
|
}, [open, form]);
|
|
33014
29047
|
return (React__default.createElement("div", { className: "w-full md:col-span-2" },
|
|
@@ -33020,24 +29053,25 @@ function AddressInput() {
|
|
|
33020
29053
|
React__default.createElement(FormControl, null,
|
|
33021
29054
|
React__default.createElement(Input, { placeholder: t("CheckoutEmbed.CustomerForm.address.addressPlaceholder"), value: (currentValue === null || currentValue === void 0 ? void 0 : currentValue.line1) ? formatAddress(currentValue) : "", readOnly: true, className: "cursor-pointer" })),
|
|
33022
29055
|
React__default.createElement(FormMessage, null))) }))),
|
|
33023
|
-
React__default.createElement(DialogContent, { className: "sm:max-w-[500px]" },
|
|
33024
|
-
React__default.createElement(
|
|
33025
|
-
React__default.createElement(
|
|
33026
|
-
|
|
33027
|
-
|
|
33028
|
-
React__default.createElement(
|
|
33029
|
-
|
|
33030
|
-
|
|
33031
|
-
|
|
33032
|
-
|
|
33033
|
-
|
|
33034
|
-
|
|
33035
|
-
|
|
33036
|
-
|
|
33037
|
-
|
|
33038
|
-
|
|
33039
|
-
|
|
33040
|
-
React__default.createElement(
|
|
29056
|
+
React__default.createElement(DialogContent, { className: "sm:max-w-[500px] fixed top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]" },
|
|
29057
|
+
React__default.createElement("div", { className: "relative" },
|
|
29058
|
+
React__default.createElement(DialogHeader, null,
|
|
29059
|
+
React__default.createElement(DialogTitle, null, t("CheckoutEmbed.CustomerForm.address.title")),
|
|
29060
|
+
React__default.createElement(DialogDescription, null, t("CheckoutEmbed.CustomerForm.address.description"))),
|
|
29061
|
+
React__default.createElement("div", { className: "grid grid-cols-2 gap-4" },
|
|
29062
|
+
React__default.createElement(InputGroup, { className: "col-span-2", name: "address.line1", label: t("CheckoutEmbed.CustomerForm.address.line1"), placeholder: t("CheckoutEmbed.CustomerForm.address.line1Placeholder"), autoComplete: "address-line1" }),
|
|
29063
|
+
React__default.createElement(InputGroup, { className: "col-span-2", name: "address.line2", label: t("CheckoutEmbed.CustomerForm.address.line2"), placeholder: t("CheckoutEmbed.CustomerForm.address.line2Placeholder"), autoComplete: "address-line2" }),
|
|
29064
|
+
React__default.createElement(InputGroup, { name: "address.city", label: t("CheckoutEmbed.CustomerForm.address.city"), placeholder: t("CheckoutEmbed.CustomerForm.address.cityPlaceholder"), autoComplete: "address-level2" }),
|
|
29065
|
+
React__default.createElement(InputGroup, { name: "address.state", label: t("CheckoutEmbed.CustomerForm.address.state"), placeholder: t("CheckoutEmbed.CustomerForm.address.statePlaceholder"), autoComplete: "address-level1" }),
|
|
29066
|
+
React__default.createElement(InputGroup, { name: "address.zipCode", label: t("CheckoutEmbed.CustomerForm.address.zipCode"), placeholder: t("CheckoutEmbed.CustomerForm.address.zipCodePlaceholder"), autoComplete: "postal-code" }),
|
|
29067
|
+
React__default.createElement(FormField, { control: form.control, name: "address.country", render: ({ field }) => (React__default.createElement(FormItem, null,
|
|
29068
|
+
React__default.createElement(FormLabel, null, t("CheckoutEmbed.CustomerForm.address.country")),
|
|
29069
|
+
React__default.createElement(CountryDropdown, { placeholder: t("CheckoutEmbed.CustomerForm.address.countryPlaceholder"), defaultValue: field.value, onChange: (country) => {
|
|
29070
|
+
field.onChange(country.name);
|
|
29071
|
+
} }),
|
|
29072
|
+
React__default.createElement(FormMessage, null))) })),
|
|
29073
|
+
React__default.createElement(DialogFooter, null,
|
|
29074
|
+
React__default.createElement(Button, { onClick: handleSave, type: "button", disabled: isValidating }, t("CheckoutEmbed.CustomerForm.address.button"))))))));
|
|
33041
29075
|
}
|
|
33042
29076
|
|
|
33043
29077
|
function CustomerForm({ initialData, onSubmit, }) {
|