orange-orm 4.4.0-beta.1 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/docs/changelog.md +6 -0
- package/package.json +1 -1
- package/src/client/index.mjs +906 -380
- package/src/table/column/date/tryParseISO.js +6 -8
package/src/client/index.mjs
CHANGED
|
@@ -1851,6 +1851,8 @@ const isFormData = (thing) => {
|
|
|
1851
1851
|
*/
|
|
1852
1852
|
const isURLSearchParams = kindOfTest('URLSearchParams');
|
|
1853
1853
|
|
|
1854
|
+
const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
|
|
1855
|
+
|
|
1854
1856
|
/**
|
|
1855
1857
|
* Trim excess whitespace off the beginning and end of a string
|
|
1856
1858
|
*
|
|
@@ -2239,8 +2241,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
2239
2241
|
const noop = () => {};
|
|
2240
2242
|
|
|
2241
2243
|
const toFiniteNumber = (value, defaultValue) => {
|
|
2242
|
-
value = +value;
|
|
2243
|
-
return Number.isFinite(value) ? value : defaultValue;
|
|
2244
|
+
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
2244
2245
|
};
|
|
2245
2246
|
|
|
2246
2247
|
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
|
@@ -2310,6 +2311,36 @@ const isAsyncFn = kindOfTest('AsyncFunction');
|
|
|
2310
2311
|
const isThenable = (thing) =>
|
|
2311
2312
|
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
2312
2313
|
|
|
2314
|
+
// original code
|
|
2315
|
+
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
2316
|
+
|
|
2317
|
+
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
2318
|
+
if (setImmediateSupported) {
|
|
2319
|
+
return setImmediate;
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
return postMessageSupported ? ((token, callbacks) => {
|
|
2323
|
+
_global.addEventListener("message", ({source, data}) => {
|
|
2324
|
+
if (source === _global && data === token) {
|
|
2325
|
+
callbacks.length && callbacks.shift()();
|
|
2326
|
+
}
|
|
2327
|
+
}, false);
|
|
2328
|
+
|
|
2329
|
+
return (cb) => {
|
|
2330
|
+
callbacks.push(cb);
|
|
2331
|
+
_global.postMessage(token, "*");
|
|
2332
|
+
}
|
|
2333
|
+
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
2334
|
+
})(
|
|
2335
|
+
typeof setImmediate === 'function',
|
|
2336
|
+
isFunction(_global.postMessage)
|
|
2337
|
+
);
|
|
2338
|
+
|
|
2339
|
+
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
2340
|
+
queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
|
|
2341
|
+
|
|
2342
|
+
// *********************
|
|
2343
|
+
|
|
2313
2344
|
var utils$1 = {
|
|
2314
2345
|
isArray,
|
|
2315
2346
|
isArrayBuffer,
|
|
@@ -2321,6 +2352,10 @@ var utils$1 = {
|
|
|
2321
2352
|
isBoolean,
|
|
2322
2353
|
isObject,
|
|
2323
2354
|
isPlainObject,
|
|
2355
|
+
isReadableStream,
|
|
2356
|
+
isRequest,
|
|
2357
|
+
isResponse,
|
|
2358
|
+
isHeaders,
|
|
2324
2359
|
isUndefined,
|
|
2325
2360
|
isDate,
|
|
2326
2361
|
isFile,
|
|
@@ -2361,7 +2396,9 @@ var utils$1 = {
|
|
|
2361
2396
|
isSpecCompliantForm,
|
|
2362
2397
|
toJSONObject,
|
|
2363
2398
|
isAsyncFn,
|
|
2364
|
-
isThenable
|
|
2399
|
+
isThenable,
|
|
2400
|
+
setImmediate: _setImmediate,
|
|
2401
|
+
asap
|
|
2365
2402
|
};
|
|
2366
2403
|
|
|
2367
2404
|
/**
|
|
@@ -2389,7 +2426,10 @@ function AxiosError(message, code, config, request, response) {
|
|
|
2389
2426
|
code && (this.code = code);
|
|
2390
2427
|
config && (this.config = config);
|
|
2391
2428
|
request && (this.request = request);
|
|
2392
|
-
|
|
2429
|
+
if (response) {
|
|
2430
|
+
this.response = response;
|
|
2431
|
+
this.status = response.status ? response.status : null;
|
|
2432
|
+
}
|
|
2393
2433
|
}
|
|
2394
2434
|
|
|
2395
2435
|
utils$1.inherits(AxiosError, Error, {
|
|
@@ -2409,7 +2449,7 @@ utils$1.inherits(AxiosError, Error, {
|
|
|
2409
2449
|
// Axios
|
|
2410
2450
|
config: utils$1.toJSONObject(this.config),
|
|
2411
2451
|
code: this.code,
|
|
2412
|
-
status: this.
|
|
2452
|
+
status: this.status
|
|
2413
2453
|
};
|
|
2414
2454
|
}
|
|
2415
2455
|
});
|
|
@@ -2877,6 +2917,8 @@ var platform$1 = {
|
|
|
2877
2917
|
|
|
2878
2918
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2879
2919
|
|
|
2920
|
+
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
2921
|
+
|
|
2880
2922
|
/**
|
|
2881
2923
|
* Determine if we're running in a standard browser environment
|
|
2882
2924
|
*
|
|
@@ -2894,10 +2936,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
|
|
|
2894
2936
|
*
|
|
2895
2937
|
* @returns {boolean}
|
|
2896
2938
|
*/
|
|
2897
|
-
const hasStandardBrowserEnv =
|
|
2898
|
-
(product)
|
|
2899
|
-
return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
|
|
2900
|
-
})(typeof navigator !== 'undefined' && navigator.product);
|
|
2939
|
+
const hasStandardBrowserEnv = hasBrowserEnv &&
|
|
2940
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
2901
2941
|
|
|
2902
2942
|
/**
|
|
2903
2943
|
* Determine if we're running in a standard browser webWorker environment
|
|
@@ -2917,11 +2957,15 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
2917
2957
|
);
|
|
2918
2958
|
})();
|
|
2919
2959
|
|
|
2960
|
+
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
2961
|
+
|
|
2920
2962
|
var utils = /*#__PURE__*/Object.freeze({
|
|
2921
2963
|
__proto__: null,
|
|
2922
2964
|
hasBrowserEnv: hasBrowserEnv,
|
|
2923
2965
|
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
2924
|
-
hasStandardBrowserEnv: hasStandardBrowserEnv
|
|
2966
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
2967
|
+
navigator: _navigator,
|
|
2968
|
+
origin: origin
|
|
2925
2969
|
});
|
|
2926
2970
|
|
|
2927
2971
|
var platform = {
|
|
@@ -2989,6 +3033,9 @@ function arrayToObject(arr) {
|
|
|
2989
3033
|
function formDataToJSON(formData) {
|
|
2990
3034
|
function buildPath(path, value, target, index) {
|
|
2991
3035
|
let name = path[index++];
|
|
3036
|
+
|
|
3037
|
+
if (name === '__proto__') return true;
|
|
3038
|
+
|
|
2992
3039
|
const isNumericKey = Number.isFinite(+name);
|
|
2993
3040
|
const isLast = index >= path.length;
|
|
2994
3041
|
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
@@ -3058,7 +3105,7 @@ const defaults = {
|
|
|
3058
3105
|
|
|
3059
3106
|
transitional: transitionalDefaults,
|
|
3060
3107
|
|
|
3061
|
-
adapter: ['xhr', 'http'],
|
|
3108
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
3062
3109
|
|
|
3063
3110
|
transformRequest: [function transformRequest(data, headers) {
|
|
3064
3111
|
const contentType = headers.getContentType() || '';
|
|
@@ -3072,9 +3119,6 @@ const defaults = {
|
|
|
3072
3119
|
const isFormData = utils$1.isFormData(data);
|
|
3073
3120
|
|
|
3074
3121
|
if (isFormData) {
|
|
3075
|
-
if (!hasJSONContentType) {
|
|
3076
|
-
return data;
|
|
3077
|
-
}
|
|
3078
3122
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
3079
3123
|
}
|
|
3080
3124
|
|
|
@@ -3082,7 +3126,8 @@ const defaults = {
|
|
|
3082
3126
|
utils$1.isBuffer(data) ||
|
|
3083
3127
|
utils$1.isStream(data) ||
|
|
3084
3128
|
utils$1.isFile(data) ||
|
|
3085
|
-
utils$1.isBlob(data)
|
|
3129
|
+
utils$1.isBlob(data) ||
|
|
3130
|
+
utils$1.isReadableStream(data)
|
|
3086
3131
|
) {
|
|
3087
3132
|
return data;
|
|
3088
3133
|
}
|
|
@@ -3125,6 +3170,10 @@ const defaults = {
|
|
|
3125
3170
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
3126
3171
|
const JSONRequested = this.responseType === 'json';
|
|
3127
3172
|
|
|
3173
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
3174
|
+
return data;
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3128
3177
|
if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
3129
3178
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
3130
3179
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
@@ -3328,6 +3377,10 @@ class AxiosHeaders {
|
|
|
3328
3377
|
setHeaders(header, valueOrRewrite);
|
|
3329
3378
|
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
3330
3379
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
3380
|
+
} else if (utils$1.isHeaders(header)) {
|
|
3381
|
+
for (const [key, value] of header.entries()) {
|
|
3382
|
+
setHeader(value, key, rewrite);
|
|
3383
|
+
}
|
|
3331
3384
|
} else {
|
|
3332
3385
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
3333
3386
|
}
|
|
@@ -3595,96 +3648,153 @@ function settle(resolve, reject, response) {
|
|
|
3595
3648
|
}
|
|
3596
3649
|
}
|
|
3597
3650
|
|
|
3598
|
-
|
|
3651
|
+
function parseProtocol(url) {
|
|
3652
|
+
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
3653
|
+
return match && match[1] || '';
|
|
3654
|
+
}
|
|
3599
3655
|
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3656
|
+
/**
|
|
3657
|
+
* Calculate data maxRate
|
|
3658
|
+
* @param {Number} [samplesCount= 10]
|
|
3659
|
+
* @param {Number} [min= 1000]
|
|
3660
|
+
* @returns {Function}
|
|
3661
|
+
*/
|
|
3662
|
+
function speedometer(samplesCount, min) {
|
|
3663
|
+
samplesCount = samplesCount || 10;
|
|
3664
|
+
const bytes = new Array(samplesCount);
|
|
3665
|
+
const timestamps = new Array(samplesCount);
|
|
3666
|
+
let head = 0;
|
|
3667
|
+
let tail = 0;
|
|
3668
|
+
let firstSampleTS;
|
|
3604
3669
|
|
|
3605
|
-
|
|
3670
|
+
min = min !== undefined ? min : 1000;
|
|
3606
3671
|
|
|
3607
|
-
|
|
3672
|
+
return function push(chunkLength) {
|
|
3673
|
+
const now = Date.now();
|
|
3608
3674
|
|
|
3609
|
-
|
|
3675
|
+
const startedAt = timestamps[tail];
|
|
3610
3676
|
|
|
3611
|
-
|
|
3677
|
+
if (!firstSampleTS) {
|
|
3678
|
+
firstSampleTS = now;
|
|
3679
|
+
}
|
|
3612
3680
|
|
|
3613
|
-
|
|
3614
|
-
|
|
3681
|
+
bytes[head] = chunkLength;
|
|
3682
|
+
timestamps[head] = now;
|
|
3615
3683
|
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
return (match ? decodeURIComponent(match[3]) : null);
|
|
3619
|
-
},
|
|
3684
|
+
let i = tail;
|
|
3685
|
+
let bytesCount = 0;
|
|
3620
3686
|
|
|
3621
|
-
|
|
3622
|
-
|
|
3687
|
+
while (i !== head) {
|
|
3688
|
+
bytesCount += bytes[i++];
|
|
3689
|
+
i = i % samplesCount;
|
|
3623
3690
|
}
|
|
3624
|
-
}
|
|
3625
3691
|
|
|
3626
|
-
|
|
3692
|
+
head = (head + 1) % samplesCount;
|
|
3627
3693
|
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
read() {
|
|
3632
|
-
return null;
|
|
3633
|
-
},
|
|
3634
|
-
remove() {}
|
|
3635
|
-
};
|
|
3694
|
+
if (head === tail) {
|
|
3695
|
+
tail = (tail + 1) % samplesCount;
|
|
3696
|
+
}
|
|
3636
3697
|
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
* @param {string} url The URL to test
|
|
3641
|
-
*
|
|
3642
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
3643
|
-
*/
|
|
3644
|
-
function isAbsoluteURL(url) {
|
|
3645
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
3646
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
3647
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
|
3648
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
3649
|
-
}
|
|
3698
|
+
if (now - firstSampleTS < min) {
|
|
3699
|
+
return;
|
|
3700
|
+
}
|
|
3650
3701
|
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
*
|
|
3654
|
-
|
|
3655
|
-
* @param {string} relativeURL The relative URL
|
|
3656
|
-
*
|
|
3657
|
-
* @returns {string} The combined URL
|
|
3658
|
-
*/
|
|
3659
|
-
function combineURLs(baseURL, relativeURL) {
|
|
3660
|
-
return relativeURL
|
|
3661
|
-
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
3662
|
-
: baseURL;
|
|
3702
|
+
const passed = startedAt && now - startedAt;
|
|
3703
|
+
|
|
3704
|
+
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
3705
|
+
};
|
|
3663
3706
|
}
|
|
3664
3707
|
|
|
3665
3708
|
/**
|
|
3666
|
-
*
|
|
3667
|
-
*
|
|
3668
|
-
*
|
|
3669
|
-
*
|
|
3670
|
-
* @param {string} baseURL The base URL
|
|
3671
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
|
3672
|
-
*
|
|
3673
|
-
* @returns {string} The combined full path
|
|
3709
|
+
* Throttle decorator
|
|
3710
|
+
* @param {Function} fn
|
|
3711
|
+
* @param {Number} freq
|
|
3712
|
+
* @return {Function}
|
|
3674
3713
|
*/
|
|
3675
|
-
function
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3714
|
+
function throttle(fn, freq) {
|
|
3715
|
+
let timestamp = 0;
|
|
3716
|
+
let threshold = 1000 / freq;
|
|
3717
|
+
let lastArgs;
|
|
3718
|
+
let timer;
|
|
3719
|
+
|
|
3720
|
+
const invoke = (args, now = Date.now()) => {
|
|
3721
|
+
timestamp = now;
|
|
3722
|
+
lastArgs = null;
|
|
3723
|
+
if (timer) {
|
|
3724
|
+
clearTimeout(timer);
|
|
3725
|
+
timer = null;
|
|
3726
|
+
}
|
|
3727
|
+
fn.apply(null, args);
|
|
3728
|
+
};
|
|
3729
|
+
|
|
3730
|
+
const throttled = (...args) => {
|
|
3731
|
+
const now = Date.now();
|
|
3732
|
+
const passed = now - timestamp;
|
|
3733
|
+
if ( passed >= threshold) {
|
|
3734
|
+
invoke(args, now);
|
|
3735
|
+
} else {
|
|
3736
|
+
lastArgs = args;
|
|
3737
|
+
if (!timer) {
|
|
3738
|
+
timer = setTimeout(() => {
|
|
3739
|
+
timer = null;
|
|
3740
|
+
invoke(lastArgs);
|
|
3741
|
+
}, threshold - passed);
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3744
|
+
};
|
|
3745
|
+
|
|
3746
|
+
const flush = () => lastArgs && invoke(lastArgs);
|
|
3747
|
+
|
|
3748
|
+
return [throttled, flush];
|
|
3680
3749
|
}
|
|
3681
3750
|
|
|
3751
|
+
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
3752
|
+
let bytesNotified = 0;
|
|
3753
|
+
const _speedometer = speedometer(50, 250);
|
|
3754
|
+
|
|
3755
|
+
return throttle(e => {
|
|
3756
|
+
const loaded = e.loaded;
|
|
3757
|
+
const total = e.lengthComputable ? e.total : undefined;
|
|
3758
|
+
const progressBytes = loaded - bytesNotified;
|
|
3759
|
+
const rate = _speedometer(progressBytes);
|
|
3760
|
+
const inRange = loaded <= total;
|
|
3761
|
+
|
|
3762
|
+
bytesNotified = loaded;
|
|
3763
|
+
|
|
3764
|
+
const data = {
|
|
3765
|
+
loaded,
|
|
3766
|
+
total,
|
|
3767
|
+
progress: total ? (loaded / total) : undefined,
|
|
3768
|
+
bytes: progressBytes,
|
|
3769
|
+
rate: rate ? rate : undefined,
|
|
3770
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
3771
|
+
event: e,
|
|
3772
|
+
lengthComputable: total != null,
|
|
3773
|
+
[isDownloadStream ? 'download' : 'upload']: true
|
|
3774
|
+
};
|
|
3775
|
+
|
|
3776
|
+
listener(data);
|
|
3777
|
+
}, freq);
|
|
3778
|
+
};
|
|
3779
|
+
|
|
3780
|
+
const progressEventDecorator = (total, throttled) => {
|
|
3781
|
+
const lengthComputable = total != null;
|
|
3782
|
+
|
|
3783
|
+
return [(loaded) => throttled[0]({
|
|
3784
|
+
lengthComputable,
|
|
3785
|
+
total,
|
|
3786
|
+
loaded
|
|
3787
|
+
}), throttled[1]];
|
|
3788
|
+
};
|
|
3789
|
+
|
|
3790
|
+
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
3791
|
+
|
|
3682
3792
|
var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
3683
3793
|
|
|
3684
3794
|
// Standard browser envs have full support of the APIs needed to test
|
|
3685
3795
|
// whether the request URL is of the same origin as current location.
|
|
3686
3796
|
(function standardBrowserEnv() {
|
|
3687
|
-
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
3797
|
+
const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
|
|
3688
3798
|
const urlParsingNode = document.createElement('a');
|
|
3689
3799
|
let originURL;
|
|
3690
3800
|
|
|
@@ -3742,137 +3852,267 @@ var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
|
3742
3852
|
};
|
|
3743
3853
|
})();
|
|
3744
3854
|
|
|
3745
|
-
|
|
3746
|
-
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
3747
|
-
return match && match[1] || '';
|
|
3748
|
-
}
|
|
3855
|
+
var cookies = platform.hasStandardBrowserEnv ?
|
|
3749
3856
|
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
* @returns {Function}
|
|
3755
|
-
*/
|
|
3756
|
-
function speedometer(samplesCount, min) {
|
|
3757
|
-
samplesCount = samplesCount || 10;
|
|
3758
|
-
const bytes = new Array(samplesCount);
|
|
3759
|
-
const timestamps = new Array(samplesCount);
|
|
3760
|
-
let head = 0;
|
|
3761
|
-
let tail = 0;
|
|
3762
|
-
let firstSampleTS;
|
|
3857
|
+
// Standard browser envs support document.cookie
|
|
3858
|
+
{
|
|
3859
|
+
write(name, value, expires, path, domain, secure) {
|
|
3860
|
+
const cookie = [name + '=' + encodeURIComponent(value)];
|
|
3763
3861
|
|
|
3764
|
-
|
|
3862
|
+
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
3765
3863
|
|
|
3766
|
-
|
|
3767
|
-
const now = Date.now();
|
|
3864
|
+
utils$1.isString(path) && cookie.push('path=' + path);
|
|
3768
3865
|
|
|
3769
|
-
|
|
3866
|
+
utils$1.isString(domain) && cookie.push('domain=' + domain);
|
|
3770
3867
|
|
|
3771
|
-
|
|
3772
|
-
firstSampleTS = now;
|
|
3773
|
-
}
|
|
3868
|
+
secure === true && cookie.push('secure');
|
|
3774
3869
|
|
|
3775
|
-
|
|
3776
|
-
|
|
3870
|
+
document.cookie = cookie.join('; ');
|
|
3871
|
+
},
|
|
3777
3872
|
|
|
3778
|
-
|
|
3779
|
-
|
|
3873
|
+
read(name) {
|
|
3874
|
+
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
3875
|
+
return (match ? decodeURIComponent(match[3]) : null);
|
|
3876
|
+
},
|
|
3780
3877
|
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
i = i % samplesCount;
|
|
3878
|
+
remove(name) {
|
|
3879
|
+
this.write(name, '', Date.now() - 86400000);
|
|
3784
3880
|
}
|
|
3881
|
+
}
|
|
3785
3882
|
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
if (head === tail) {
|
|
3789
|
-
tail = (tail + 1) % samplesCount;
|
|
3790
|
-
}
|
|
3883
|
+
:
|
|
3791
3884
|
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
}
|
|
3885
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
3886
|
+
{
|
|
3887
|
+
write() {},
|
|
3888
|
+
read() {
|
|
3889
|
+
return null;
|
|
3890
|
+
},
|
|
3891
|
+
remove() {}
|
|
3892
|
+
};
|
|
3795
3893
|
|
|
3796
|
-
|
|
3894
|
+
/**
|
|
3895
|
+
* Determines whether the specified URL is absolute
|
|
3896
|
+
*
|
|
3897
|
+
* @param {string} url The URL to test
|
|
3898
|
+
*
|
|
3899
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
3900
|
+
*/
|
|
3901
|
+
function isAbsoluteURL(url) {
|
|
3902
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
3903
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
3904
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
|
3905
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
3906
|
+
}
|
|
3797
3907
|
|
|
3798
|
-
|
|
3799
|
-
|
|
3908
|
+
/**
|
|
3909
|
+
* Creates a new URL by combining the specified URLs
|
|
3910
|
+
*
|
|
3911
|
+
* @param {string} baseURL The base URL
|
|
3912
|
+
* @param {string} relativeURL The relative URL
|
|
3913
|
+
*
|
|
3914
|
+
* @returns {string} The combined URL
|
|
3915
|
+
*/
|
|
3916
|
+
function combineURLs(baseURL, relativeURL) {
|
|
3917
|
+
return relativeURL
|
|
3918
|
+
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
3919
|
+
: baseURL;
|
|
3800
3920
|
}
|
|
3801
3921
|
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3922
|
+
/**
|
|
3923
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
3924
|
+
* only when the requestedURL is not already an absolute URL.
|
|
3925
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
3926
|
+
*
|
|
3927
|
+
* @param {string} baseURL The base URL
|
|
3928
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
|
3929
|
+
*
|
|
3930
|
+
* @returns {string} The combined full path
|
|
3931
|
+
*/
|
|
3932
|
+
function buildFullPath(baseURL, requestedURL) {
|
|
3933
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
3934
|
+
return combineURLs(baseURL, requestedURL);
|
|
3935
|
+
}
|
|
3936
|
+
return requestedURL;
|
|
3937
|
+
}
|
|
3805
3938
|
|
|
3806
|
-
|
|
3807
|
-
const loaded = e.loaded;
|
|
3808
|
-
const total = e.lengthComputable ? e.total : undefined;
|
|
3809
|
-
const progressBytes = loaded - bytesNotified;
|
|
3810
|
-
const rate = _speedometer(progressBytes);
|
|
3811
|
-
const inRange = loaded <= total;
|
|
3939
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
3812
3940
|
|
|
3813
|
-
|
|
3941
|
+
/**
|
|
3942
|
+
* Config-specific merge-function which creates a new config-object
|
|
3943
|
+
* by merging two configuration objects together.
|
|
3944
|
+
*
|
|
3945
|
+
* @param {Object} config1
|
|
3946
|
+
* @param {Object} config2
|
|
3947
|
+
*
|
|
3948
|
+
* @returns {Object} New object resulting from merging config2 to config1
|
|
3949
|
+
*/
|
|
3950
|
+
function mergeConfig(config1, config2) {
|
|
3951
|
+
// eslint-disable-next-line no-param-reassign
|
|
3952
|
+
config2 = config2 || {};
|
|
3953
|
+
const config = {};
|
|
3814
3954
|
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3955
|
+
function getMergedValue(target, source, caseless) {
|
|
3956
|
+
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
3957
|
+
return utils$1.merge.call({caseless}, target, source);
|
|
3958
|
+
} else if (utils$1.isPlainObject(source)) {
|
|
3959
|
+
return utils$1.merge({}, source);
|
|
3960
|
+
} else if (utils$1.isArray(source)) {
|
|
3961
|
+
return source.slice();
|
|
3962
|
+
}
|
|
3963
|
+
return source;
|
|
3964
|
+
}
|
|
3824
3965
|
|
|
3825
|
-
|
|
3966
|
+
// eslint-disable-next-line consistent-return
|
|
3967
|
+
function mergeDeepProperties(a, b, caseless) {
|
|
3968
|
+
if (!utils$1.isUndefined(b)) {
|
|
3969
|
+
return getMergedValue(a, b, caseless);
|
|
3970
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
3971
|
+
return getMergedValue(undefined, a, caseless);
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3826
3974
|
|
|
3827
|
-
|
|
3975
|
+
// eslint-disable-next-line consistent-return
|
|
3976
|
+
function valueFromConfig2(a, b) {
|
|
3977
|
+
if (!utils$1.isUndefined(b)) {
|
|
3978
|
+
return getMergedValue(undefined, b);
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3982
|
+
// eslint-disable-next-line consistent-return
|
|
3983
|
+
function defaultToConfig2(a, b) {
|
|
3984
|
+
if (!utils$1.isUndefined(b)) {
|
|
3985
|
+
return getMergedValue(undefined, b);
|
|
3986
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
3987
|
+
return getMergedValue(undefined, a);
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
|
|
3991
|
+
// eslint-disable-next-line consistent-return
|
|
3992
|
+
function mergeDirectKeys(a, b, prop) {
|
|
3993
|
+
if (prop in config2) {
|
|
3994
|
+
return getMergedValue(a, b);
|
|
3995
|
+
} else if (prop in config1) {
|
|
3996
|
+
return getMergedValue(undefined, a);
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
|
|
4000
|
+
const mergeMap = {
|
|
4001
|
+
url: valueFromConfig2,
|
|
4002
|
+
method: valueFromConfig2,
|
|
4003
|
+
data: valueFromConfig2,
|
|
4004
|
+
baseURL: defaultToConfig2,
|
|
4005
|
+
transformRequest: defaultToConfig2,
|
|
4006
|
+
transformResponse: defaultToConfig2,
|
|
4007
|
+
paramsSerializer: defaultToConfig2,
|
|
4008
|
+
timeout: defaultToConfig2,
|
|
4009
|
+
timeoutMessage: defaultToConfig2,
|
|
4010
|
+
withCredentials: defaultToConfig2,
|
|
4011
|
+
withXSRFToken: defaultToConfig2,
|
|
4012
|
+
adapter: defaultToConfig2,
|
|
4013
|
+
responseType: defaultToConfig2,
|
|
4014
|
+
xsrfCookieName: defaultToConfig2,
|
|
4015
|
+
xsrfHeaderName: defaultToConfig2,
|
|
4016
|
+
onUploadProgress: defaultToConfig2,
|
|
4017
|
+
onDownloadProgress: defaultToConfig2,
|
|
4018
|
+
decompress: defaultToConfig2,
|
|
4019
|
+
maxContentLength: defaultToConfig2,
|
|
4020
|
+
maxBodyLength: defaultToConfig2,
|
|
4021
|
+
beforeRedirect: defaultToConfig2,
|
|
4022
|
+
transport: defaultToConfig2,
|
|
4023
|
+
httpAgent: defaultToConfig2,
|
|
4024
|
+
httpsAgent: defaultToConfig2,
|
|
4025
|
+
cancelToken: defaultToConfig2,
|
|
4026
|
+
socketPath: defaultToConfig2,
|
|
4027
|
+
responseEncoding: defaultToConfig2,
|
|
4028
|
+
validateStatus: mergeDirectKeys,
|
|
4029
|
+
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
3828
4030
|
};
|
|
4031
|
+
|
|
4032
|
+
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
4033
|
+
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
4034
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
|
4035
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
4036
|
+
});
|
|
4037
|
+
|
|
4038
|
+
return config;
|
|
3829
4039
|
}
|
|
3830
4040
|
|
|
3831
|
-
|
|
4041
|
+
var resolveConfig = (config) => {
|
|
4042
|
+
const newConfig = mergeConfig({}, config);
|
|
3832
4043
|
|
|
3833
|
-
|
|
3834
|
-
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
3835
|
-
let requestData = config.data;
|
|
3836
|
-
const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
|
3837
|
-
let {responseType, withXSRFToken} = config;
|
|
3838
|
-
let onCanceled;
|
|
3839
|
-
function done() {
|
|
3840
|
-
if (config.cancelToken) {
|
|
3841
|
-
config.cancelToken.unsubscribe(onCanceled);
|
|
3842
|
-
}
|
|
4044
|
+
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
3843
4045
|
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
4046
|
+
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
4047
|
+
|
|
4048
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
|
4049
|
+
|
|
4050
|
+
// HTTP basic authentication
|
|
4051
|
+
if (auth) {
|
|
4052
|
+
headers.set('Authorization', 'Basic ' +
|
|
4053
|
+
btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
|
|
4054
|
+
);
|
|
4055
|
+
}
|
|
4056
|
+
|
|
4057
|
+
let contentType;
|
|
4058
|
+
|
|
4059
|
+
if (utils$1.isFormData(data)) {
|
|
4060
|
+
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
4061
|
+
headers.setContentType(undefined); // Let the browser set it
|
|
4062
|
+
} else if ((contentType = headers.getContentType()) !== false) {
|
|
4063
|
+
// fix semicolon duplication issue for ReactNative FormData implementation
|
|
4064
|
+
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
|
4065
|
+
headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
|
3847
4066
|
}
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
// Add xsrf header
|
|
4070
|
+
// This is only done if running in a standard browser environment.
|
|
4071
|
+
// Specifically not if we're in a web worker, or react-native.
|
|
3848
4072
|
|
|
3849
|
-
|
|
4073
|
+
if (platform.hasStandardBrowserEnv) {
|
|
4074
|
+
withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
3850
4075
|
|
|
3851
|
-
if (
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
|
4076
|
+
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
|
4077
|
+
// Add xsrf header
|
|
4078
|
+
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
4079
|
+
|
|
4080
|
+
if (xsrfValue) {
|
|
4081
|
+
headers.set(xsrfHeaderName, xsrfValue);
|
|
3858
4082
|
}
|
|
3859
4083
|
}
|
|
4084
|
+
}
|
|
3860
4085
|
|
|
3861
|
-
|
|
4086
|
+
return newConfig;
|
|
4087
|
+
};
|
|
4088
|
+
|
|
4089
|
+
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
3862
4090
|
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
4091
|
+
var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
4092
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
4093
|
+
const _config = resolveConfig(config);
|
|
4094
|
+
let requestData = _config.data;
|
|
4095
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
4096
|
+
let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
|
4097
|
+
let onCanceled;
|
|
4098
|
+
let uploadThrottled, downloadThrottled;
|
|
4099
|
+
let flushUpload, flushDownload;
|
|
4100
|
+
|
|
4101
|
+
function done() {
|
|
4102
|
+
flushUpload && flushUpload(); // flush events
|
|
4103
|
+
flushDownload && flushDownload(); // flush events
|
|
4104
|
+
|
|
4105
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
4106
|
+
|
|
4107
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
3868
4108
|
}
|
|
3869
4109
|
|
|
3870
|
-
|
|
4110
|
+
let request = new XMLHttpRequest();
|
|
3871
4111
|
|
|
3872
|
-
request.open(
|
|
4112
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
3873
4113
|
|
|
3874
4114
|
// Set the request timeout in MS
|
|
3875
|
-
request.timeout =
|
|
4115
|
+
request.timeout = _config.timeout;
|
|
3876
4116
|
|
|
3877
4117
|
function onloadend() {
|
|
3878
4118
|
if (!request) {
|
|
@@ -3952,10 +4192,10 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3952
4192
|
|
|
3953
4193
|
// Handle timeout
|
|
3954
4194
|
request.ontimeout = function handleTimeout() {
|
|
3955
|
-
let timeoutErrorMessage =
|
|
3956
|
-
const transitional =
|
|
3957
|
-
if (
|
|
3958
|
-
timeoutErrorMessage =
|
|
4195
|
+
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
4196
|
+
const transitional = _config.transitional || transitionalDefaults;
|
|
4197
|
+
if (_config.timeoutErrorMessage) {
|
|
4198
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
3959
4199
|
}
|
|
3960
4200
|
reject(new AxiosError(
|
|
3961
4201
|
timeoutErrorMessage,
|
|
@@ -3967,22 +4207,6 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3967
4207
|
request = null;
|
|
3968
4208
|
};
|
|
3969
4209
|
|
|
3970
|
-
// Add xsrf header
|
|
3971
|
-
// This is only done if running in a standard browser environment.
|
|
3972
|
-
// Specifically not if we're in a web worker, or react-native.
|
|
3973
|
-
if(platform.hasStandardBrowserEnv) {
|
|
3974
|
-
withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
|
|
3975
|
-
|
|
3976
|
-
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
|
|
3977
|
-
// Add xsrf header
|
|
3978
|
-
const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
|
3979
|
-
|
|
3980
|
-
if (xsrfValue) {
|
|
3981
|
-
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
|
3982
|
-
}
|
|
3983
|
-
}
|
|
3984
|
-
}
|
|
3985
|
-
|
|
3986
4210
|
// Remove Content-Type if data is undefined
|
|
3987
4211
|
requestData === undefined && requestHeaders.setContentType(null);
|
|
3988
4212
|
|
|
@@ -3994,26 +4218,31 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3994
4218
|
}
|
|
3995
4219
|
|
|
3996
4220
|
// Add withCredentials to request if needed
|
|
3997
|
-
if (!utils$1.isUndefined(
|
|
3998
|
-
request.withCredentials = !!
|
|
4221
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
4222
|
+
request.withCredentials = !!_config.withCredentials;
|
|
3999
4223
|
}
|
|
4000
4224
|
|
|
4001
4225
|
// Add responseType to request if needed
|
|
4002
4226
|
if (responseType && responseType !== 'json') {
|
|
4003
|
-
request.responseType =
|
|
4227
|
+
request.responseType = _config.responseType;
|
|
4004
4228
|
}
|
|
4005
4229
|
|
|
4006
4230
|
// Handle progress if needed
|
|
4007
|
-
if (
|
|
4008
|
-
|
|
4231
|
+
if (onDownloadProgress) {
|
|
4232
|
+
([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
|
|
4233
|
+
request.addEventListener('progress', downloadThrottled);
|
|
4009
4234
|
}
|
|
4010
4235
|
|
|
4011
4236
|
// Not all browsers support upload events
|
|
4012
|
-
if (
|
|
4013
|
-
|
|
4237
|
+
if (onUploadProgress && request.upload) {
|
|
4238
|
+
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
4239
|
+
|
|
4240
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
4241
|
+
|
|
4242
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
4014
4243
|
}
|
|
4015
4244
|
|
|
4016
|
-
if (
|
|
4245
|
+
if (_config.cancelToken || _config.signal) {
|
|
4017
4246
|
// Handle cancellation
|
|
4018
4247
|
// eslint-disable-next-line func-names
|
|
4019
4248
|
onCanceled = cancel => {
|
|
@@ -4025,13 +4254,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4025
4254
|
request = null;
|
|
4026
4255
|
};
|
|
4027
4256
|
|
|
4028
|
-
|
|
4029
|
-
if (
|
|
4030
|
-
|
|
4257
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
4258
|
+
if (_config.signal) {
|
|
4259
|
+
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
4031
4260
|
}
|
|
4032
4261
|
}
|
|
4033
4262
|
|
|
4034
|
-
const protocol = parseProtocol(
|
|
4263
|
+
const protocol = parseProtocol(_config.url);
|
|
4035
4264
|
|
|
4036
4265
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
4037
4266
|
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|
@@ -4044,9 +4273,360 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4044
4273
|
});
|
|
4045
4274
|
};
|
|
4046
4275
|
|
|
4276
|
+
const composeSignals = (signals, timeout) => {
|
|
4277
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
4278
|
+
|
|
4279
|
+
if (timeout || length) {
|
|
4280
|
+
let controller = new AbortController();
|
|
4281
|
+
|
|
4282
|
+
let aborted;
|
|
4283
|
+
|
|
4284
|
+
const onabort = function (reason) {
|
|
4285
|
+
if (!aborted) {
|
|
4286
|
+
aborted = true;
|
|
4287
|
+
unsubscribe();
|
|
4288
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
4289
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
4290
|
+
}
|
|
4291
|
+
};
|
|
4292
|
+
|
|
4293
|
+
let timer = timeout && setTimeout(() => {
|
|
4294
|
+
timer = null;
|
|
4295
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
4296
|
+
}, timeout);
|
|
4297
|
+
|
|
4298
|
+
const unsubscribe = () => {
|
|
4299
|
+
if (signals) {
|
|
4300
|
+
timer && clearTimeout(timer);
|
|
4301
|
+
timer = null;
|
|
4302
|
+
signals.forEach(signal => {
|
|
4303
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
|
4304
|
+
});
|
|
4305
|
+
signals = null;
|
|
4306
|
+
}
|
|
4307
|
+
};
|
|
4308
|
+
|
|
4309
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
4310
|
+
|
|
4311
|
+
const {signal} = controller;
|
|
4312
|
+
|
|
4313
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
4314
|
+
|
|
4315
|
+
return signal;
|
|
4316
|
+
}
|
|
4317
|
+
};
|
|
4318
|
+
|
|
4319
|
+
var composeSignals$1 = composeSignals;
|
|
4320
|
+
|
|
4321
|
+
const streamChunk = function* (chunk, chunkSize) {
|
|
4322
|
+
let len = chunk.byteLength;
|
|
4323
|
+
|
|
4324
|
+
if (!chunkSize || len < chunkSize) {
|
|
4325
|
+
yield chunk;
|
|
4326
|
+
return;
|
|
4327
|
+
}
|
|
4328
|
+
|
|
4329
|
+
let pos = 0;
|
|
4330
|
+
let end;
|
|
4331
|
+
|
|
4332
|
+
while (pos < len) {
|
|
4333
|
+
end = pos + chunkSize;
|
|
4334
|
+
yield chunk.slice(pos, end);
|
|
4335
|
+
pos = end;
|
|
4336
|
+
}
|
|
4337
|
+
};
|
|
4338
|
+
|
|
4339
|
+
const readBytes = async function* (iterable, chunkSize) {
|
|
4340
|
+
for await (const chunk of readStream(iterable)) {
|
|
4341
|
+
yield* streamChunk(chunk, chunkSize);
|
|
4342
|
+
}
|
|
4343
|
+
};
|
|
4344
|
+
|
|
4345
|
+
const readStream = async function* (stream) {
|
|
4346
|
+
if (stream[Symbol.asyncIterator]) {
|
|
4347
|
+
yield* stream;
|
|
4348
|
+
return;
|
|
4349
|
+
}
|
|
4350
|
+
|
|
4351
|
+
const reader = stream.getReader();
|
|
4352
|
+
try {
|
|
4353
|
+
for (;;) {
|
|
4354
|
+
const {done, value} = await reader.read();
|
|
4355
|
+
if (done) {
|
|
4356
|
+
break;
|
|
4357
|
+
}
|
|
4358
|
+
yield value;
|
|
4359
|
+
}
|
|
4360
|
+
} finally {
|
|
4361
|
+
await reader.cancel();
|
|
4362
|
+
}
|
|
4363
|
+
};
|
|
4364
|
+
|
|
4365
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
4366
|
+
const iterator = readBytes(stream, chunkSize);
|
|
4367
|
+
|
|
4368
|
+
let bytes = 0;
|
|
4369
|
+
let done;
|
|
4370
|
+
let _onFinish = (e) => {
|
|
4371
|
+
if (!done) {
|
|
4372
|
+
done = true;
|
|
4373
|
+
onFinish && onFinish(e);
|
|
4374
|
+
}
|
|
4375
|
+
};
|
|
4376
|
+
|
|
4377
|
+
return new ReadableStream({
|
|
4378
|
+
async pull(controller) {
|
|
4379
|
+
try {
|
|
4380
|
+
const {done, value} = await iterator.next();
|
|
4381
|
+
|
|
4382
|
+
if (done) {
|
|
4383
|
+
_onFinish();
|
|
4384
|
+
controller.close();
|
|
4385
|
+
return;
|
|
4386
|
+
}
|
|
4387
|
+
|
|
4388
|
+
let len = value.byteLength;
|
|
4389
|
+
if (onProgress) {
|
|
4390
|
+
let loadedBytes = bytes += len;
|
|
4391
|
+
onProgress(loadedBytes);
|
|
4392
|
+
}
|
|
4393
|
+
controller.enqueue(new Uint8Array(value));
|
|
4394
|
+
} catch (err) {
|
|
4395
|
+
_onFinish(err);
|
|
4396
|
+
throw err;
|
|
4397
|
+
}
|
|
4398
|
+
},
|
|
4399
|
+
cancel(reason) {
|
|
4400
|
+
_onFinish(reason);
|
|
4401
|
+
return iterator.return();
|
|
4402
|
+
}
|
|
4403
|
+
}, {
|
|
4404
|
+
highWaterMark: 2
|
|
4405
|
+
})
|
|
4406
|
+
};
|
|
4407
|
+
|
|
4408
|
+
const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
|
|
4409
|
+
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
|
|
4410
|
+
|
|
4411
|
+
// used only inside the fetch adapter
|
|
4412
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
4413
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
4414
|
+
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
4415
|
+
);
|
|
4416
|
+
|
|
4417
|
+
const test = (fn, ...args) => {
|
|
4418
|
+
try {
|
|
4419
|
+
return !!fn(...args);
|
|
4420
|
+
} catch (e) {
|
|
4421
|
+
return false
|
|
4422
|
+
}
|
|
4423
|
+
};
|
|
4424
|
+
|
|
4425
|
+
const supportsRequestStream = isReadableStreamSupported && test(() => {
|
|
4426
|
+
let duplexAccessed = false;
|
|
4427
|
+
|
|
4428
|
+
const hasContentType = new Request(platform.origin, {
|
|
4429
|
+
body: new ReadableStream(),
|
|
4430
|
+
method: 'POST',
|
|
4431
|
+
get duplex() {
|
|
4432
|
+
duplexAccessed = true;
|
|
4433
|
+
return 'half';
|
|
4434
|
+
},
|
|
4435
|
+
}).headers.has('Content-Type');
|
|
4436
|
+
|
|
4437
|
+
return duplexAccessed && !hasContentType;
|
|
4438
|
+
});
|
|
4439
|
+
|
|
4440
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
4441
|
+
|
|
4442
|
+
const supportsResponseStream = isReadableStreamSupported &&
|
|
4443
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
4444
|
+
|
|
4445
|
+
|
|
4446
|
+
const resolvers = {
|
|
4447
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
4448
|
+
};
|
|
4449
|
+
|
|
4450
|
+
isFetchSupported && (((res) => {
|
|
4451
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
4452
|
+
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
4453
|
+
(_, config) => {
|
|
4454
|
+
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
4455
|
+
});
|
|
4456
|
+
});
|
|
4457
|
+
})(new Response));
|
|
4458
|
+
|
|
4459
|
+
const getBodyLength = async (body) => {
|
|
4460
|
+
if (body == null) {
|
|
4461
|
+
return 0;
|
|
4462
|
+
}
|
|
4463
|
+
|
|
4464
|
+
if(utils$1.isBlob(body)) {
|
|
4465
|
+
return body.size;
|
|
4466
|
+
}
|
|
4467
|
+
|
|
4468
|
+
if(utils$1.isSpecCompliantForm(body)) {
|
|
4469
|
+
const _request = new Request(platform.origin, {
|
|
4470
|
+
method: 'POST',
|
|
4471
|
+
body,
|
|
4472
|
+
});
|
|
4473
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
4477
|
+
return body.byteLength;
|
|
4478
|
+
}
|
|
4479
|
+
|
|
4480
|
+
if(utils$1.isURLSearchParams(body)) {
|
|
4481
|
+
body = body + '';
|
|
4482
|
+
}
|
|
4483
|
+
|
|
4484
|
+
if(utils$1.isString(body)) {
|
|
4485
|
+
return (await encodeText(body)).byteLength;
|
|
4486
|
+
}
|
|
4487
|
+
};
|
|
4488
|
+
|
|
4489
|
+
const resolveBodyLength = async (headers, body) => {
|
|
4490
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
4491
|
+
|
|
4492
|
+
return length == null ? getBodyLength(body) : length;
|
|
4493
|
+
};
|
|
4494
|
+
|
|
4495
|
+
var fetchAdapter = isFetchSupported && (async (config) => {
|
|
4496
|
+
let {
|
|
4497
|
+
url,
|
|
4498
|
+
method,
|
|
4499
|
+
data,
|
|
4500
|
+
signal,
|
|
4501
|
+
cancelToken,
|
|
4502
|
+
timeout,
|
|
4503
|
+
onDownloadProgress,
|
|
4504
|
+
onUploadProgress,
|
|
4505
|
+
responseType,
|
|
4506
|
+
headers,
|
|
4507
|
+
withCredentials = 'same-origin',
|
|
4508
|
+
fetchOptions
|
|
4509
|
+
} = resolveConfig(config);
|
|
4510
|
+
|
|
4511
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
4512
|
+
|
|
4513
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
4514
|
+
|
|
4515
|
+
let request;
|
|
4516
|
+
|
|
4517
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
4518
|
+
composedSignal.unsubscribe();
|
|
4519
|
+
});
|
|
4520
|
+
|
|
4521
|
+
let requestContentLength;
|
|
4522
|
+
|
|
4523
|
+
try {
|
|
4524
|
+
if (
|
|
4525
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
4526
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
4527
|
+
) {
|
|
4528
|
+
let _request = new Request(url, {
|
|
4529
|
+
method: 'POST',
|
|
4530
|
+
body: data,
|
|
4531
|
+
duplex: "half"
|
|
4532
|
+
});
|
|
4533
|
+
|
|
4534
|
+
let contentTypeHeader;
|
|
4535
|
+
|
|
4536
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
4537
|
+
headers.setContentType(contentTypeHeader);
|
|
4538
|
+
}
|
|
4539
|
+
|
|
4540
|
+
if (_request.body) {
|
|
4541
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
4542
|
+
requestContentLength,
|
|
4543
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
4544
|
+
);
|
|
4545
|
+
|
|
4546
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4549
|
+
|
|
4550
|
+
if (!utils$1.isString(withCredentials)) {
|
|
4551
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
4552
|
+
}
|
|
4553
|
+
|
|
4554
|
+
// Cloudflare Workers throws when credentials are defined
|
|
4555
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
4556
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
4557
|
+
request = new Request(url, {
|
|
4558
|
+
...fetchOptions,
|
|
4559
|
+
signal: composedSignal,
|
|
4560
|
+
method: method.toUpperCase(),
|
|
4561
|
+
headers: headers.normalize().toJSON(),
|
|
4562
|
+
body: data,
|
|
4563
|
+
duplex: "half",
|
|
4564
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
4565
|
+
});
|
|
4566
|
+
|
|
4567
|
+
let response = await fetch(request);
|
|
4568
|
+
|
|
4569
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
4570
|
+
|
|
4571
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
4572
|
+
const options = {};
|
|
4573
|
+
|
|
4574
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
4575
|
+
options[prop] = response[prop];
|
|
4576
|
+
});
|
|
4577
|
+
|
|
4578
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
4579
|
+
|
|
4580
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
4581
|
+
responseContentLength,
|
|
4582
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
4583
|
+
) || [];
|
|
4584
|
+
|
|
4585
|
+
response = new Response(
|
|
4586
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
4587
|
+
flush && flush();
|
|
4588
|
+
unsubscribe && unsubscribe();
|
|
4589
|
+
}),
|
|
4590
|
+
options
|
|
4591
|
+
);
|
|
4592
|
+
}
|
|
4593
|
+
|
|
4594
|
+
responseType = responseType || 'text';
|
|
4595
|
+
|
|
4596
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
4597
|
+
|
|
4598
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
4599
|
+
|
|
4600
|
+
return await new Promise((resolve, reject) => {
|
|
4601
|
+
settle(resolve, reject, {
|
|
4602
|
+
data: responseData,
|
|
4603
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
4604
|
+
status: response.status,
|
|
4605
|
+
statusText: response.statusText,
|
|
4606
|
+
config,
|
|
4607
|
+
request
|
|
4608
|
+
});
|
|
4609
|
+
})
|
|
4610
|
+
} catch (err) {
|
|
4611
|
+
unsubscribe && unsubscribe();
|
|
4612
|
+
|
|
4613
|
+
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
4614
|
+
throw Object.assign(
|
|
4615
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
4616
|
+
{
|
|
4617
|
+
cause: err.cause || err
|
|
4618
|
+
}
|
|
4619
|
+
)
|
|
4620
|
+
}
|
|
4621
|
+
|
|
4622
|
+
throw AxiosError.from(err, err && err.code, config, request);
|
|
4623
|
+
}
|
|
4624
|
+
});
|
|
4625
|
+
|
|
4047
4626
|
const knownAdapters = {
|
|
4048
4627
|
http: httpAdapter$1,
|
|
4049
|
-
xhr: xhrAdapter
|
|
4628
|
+
xhr: xhrAdapter,
|
|
4629
|
+
fetch: fetchAdapter
|
|
4050
4630
|
};
|
|
4051
4631
|
|
|
4052
4632
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
@@ -4190,109 +4770,7 @@ function dispatchRequest(config) {
|
|
|
4190
4770
|
});
|
|
4191
4771
|
}
|
|
4192
4772
|
|
|
4193
|
-
const
|
|
4194
|
-
|
|
4195
|
-
/**
|
|
4196
|
-
* Config-specific merge-function which creates a new config-object
|
|
4197
|
-
* by merging two configuration objects together.
|
|
4198
|
-
*
|
|
4199
|
-
* @param {Object} config1
|
|
4200
|
-
* @param {Object} config2
|
|
4201
|
-
*
|
|
4202
|
-
* @returns {Object} New object resulting from merging config2 to config1
|
|
4203
|
-
*/
|
|
4204
|
-
function mergeConfig(config1, config2) {
|
|
4205
|
-
// eslint-disable-next-line no-param-reassign
|
|
4206
|
-
config2 = config2 || {};
|
|
4207
|
-
const config = {};
|
|
4208
|
-
|
|
4209
|
-
function getMergedValue(target, source, caseless) {
|
|
4210
|
-
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
4211
|
-
return utils$1.merge.call({caseless}, target, source);
|
|
4212
|
-
} else if (utils$1.isPlainObject(source)) {
|
|
4213
|
-
return utils$1.merge({}, source);
|
|
4214
|
-
} else if (utils$1.isArray(source)) {
|
|
4215
|
-
return source.slice();
|
|
4216
|
-
}
|
|
4217
|
-
return source;
|
|
4218
|
-
}
|
|
4219
|
-
|
|
4220
|
-
// eslint-disable-next-line consistent-return
|
|
4221
|
-
function mergeDeepProperties(a, b, caseless) {
|
|
4222
|
-
if (!utils$1.isUndefined(b)) {
|
|
4223
|
-
return getMergedValue(a, b, caseless);
|
|
4224
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
4225
|
-
return getMergedValue(undefined, a, caseless);
|
|
4226
|
-
}
|
|
4227
|
-
}
|
|
4228
|
-
|
|
4229
|
-
// eslint-disable-next-line consistent-return
|
|
4230
|
-
function valueFromConfig2(a, b) {
|
|
4231
|
-
if (!utils$1.isUndefined(b)) {
|
|
4232
|
-
return getMergedValue(undefined, b);
|
|
4233
|
-
}
|
|
4234
|
-
}
|
|
4235
|
-
|
|
4236
|
-
// eslint-disable-next-line consistent-return
|
|
4237
|
-
function defaultToConfig2(a, b) {
|
|
4238
|
-
if (!utils$1.isUndefined(b)) {
|
|
4239
|
-
return getMergedValue(undefined, b);
|
|
4240
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
4241
|
-
return getMergedValue(undefined, a);
|
|
4242
|
-
}
|
|
4243
|
-
}
|
|
4244
|
-
|
|
4245
|
-
// eslint-disable-next-line consistent-return
|
|
4246
|
-
function mergeDirectKeys(a, b, prop) {
|
|
4247
|
-
if (prop in config2) {
|
|
4248
|
-
return getMergedValue(a, b);
|
|
4249
|
-
} else if (prop in config1) {
|
|
4250
|
-
return getMergedValue(undefined, a);
|
|
4251
|
-
}
|
|
4252
|
-
}
|
|
4253
|
-
|
|
4254
|
-
const mergeMap = {
|
|
4255
|
-
url: valueFromConfig2,
|
|
4256
|
-
method: valueFromConfig2,
|
|
4257
|
-
data: valueFromConfig2,
|
|
4258
|
-
baseURL: defaultToConfig2,
|
|
4259
|
-
transformRequest: defaultToConfig2,
|
|
4260
|
-
transformResponse: defaultToConfig2,
|
|
4261
|
-
paramsSerializer: defaultToConfig2,
|
|
4262
|
-
timeout: defaultToConfig2,
|
|
4263
|
-
timeoutMessage: defaultToConfig2,
|
|
4264
|
-
withCredentials: defaultToConfig2,
|
|
4265
|
-
withXSRFToken: defaultToConfig2,
|
|
4266
|
-
adapter: defaultToConfig2,
|
|
4267
|
-
responseType: defaultToConfig2,
|
|
4268
|
-
xsrfCookieName: defaultToConfig2,
|
|
4269
|
-
xsrfHeaderName: defaultToConfig2,
|
|
4270
|
-
onUploadProgress: defaultToConfig2,
|
|
4271
|
-
onDownloadProgress: defaultToConfig2,
|
|
4272
|
-
decompress: defaultToConfig2,
|
|
4273
|
-
maxContentLength: defaultToConfig2,
|
|
4274
|
-
maxBodyLength: defaultToConfig2,
|
|
4275
|
-
beforeRedirect: defaultToConfig2,
|
|
4276
|
-
transport: defaultToConfig2,
|
|
4277
|
-
httpAgent: defaultToConfig2,
|
|
4278
|
-
httpsAgent: defaultToConfig2,
|
|
4279
|
-
cancelToken: defaultToConfig2,
|
|
4280
|
-
socketPath: defaultToConfig2,
|
|
4281
|
-
responseEncoding: defaultToConfig2,
|
|
4282
|
-
validateStatus: mergeDirectKeys,
|
|
4283
|
-
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
4284
|
-
};
|
|
4285
|
-
|
|
4286
|
-
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
4287
|
-
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
4288
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
4289
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
4290
|
-
});
|
|
4291
|
-
|
|
4292
|
-
return config;
|
|
4293
|
-
}
|
|
4294
|
-
|
|
4295
|
-
const VERSION = "1.6.2";
|
|
4773
|
+
const VERSION = "1.7.7";
|
|
4296
4774
|
|
|
4297
4775
|
const validators$1 = {};
|
|
4298
4776
|
|
|
@@ -4407,7 +4885,34 @@ class Axios {
|
|
|
4407
4885
|
*
|
|
4408
4886
|
* @returns {Promise} The Promise to be fulfilled
|
|
4409
4887
|
*/
|
|
4410
|
-
request(configOrUrl, config) {
|
|
4888
|
+
async request(configOrUrl, config) {
|
|
4889
|
+
try {
|
|
4890
|
+
return await this._request(configOrUrl, config);
|
|
4891
|
+
} catch (err) {
|
|
4892
|
+
if (err instanceof Error) {
|
|
4893
|
+
let dummy;
|
|
4894
|
+
|
|
4895
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
|
|
4896
|
+
|
|
4897
|
+
// slice off the Error: ... line
|
|
4898
|
+
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
|
4899
|
+
try {
|
|
4900
|
+
if (!err.stack) {
|
|
4901
|
+
err.stack = stack;
|
|
4902
|
+
// match without the 2 top stack lines
|
|
4903
|
+
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
|
4904
|
+
err.stack += '\n' + stack;
|
|
4905
|
+
}
|
|
4906
|
+
} catch (e) {
|
|
4907
|
+
// ignore the case where "stack" is an un-writable property
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
|
|
4911
|
+
throw err;
|
|
4912
|
+
}
|
|
4913
|
+
}
|
|
4914
|
+
|
|
4915
|
+
_request(configOrUrl, config) {
|
|
4411
4916
|
/*eslint no-param-reassign:0*/
|
|
4412
4917
|
// Allow for axios('example/url'[, config]) a la fetch API
|
|
4413
4918
|
if (typeof configOrUrl === 'string') {
|
|
@@ -4672,6 +5177,20 @@ class CancelToken {
|
|
|
4672
5177
|
}
|
|
4673
5178
|
}
|
|
4674
5179
|
|
|
5180
|
+
toAbortSignal() {
|
|
5181
|
+
const controller = new AbortController();
|
|
5182
|
+
|
|
5183
|
+
const abort = (err) => {
|
|
5184
|
+
controller.abort(err);
|
|
5185
|
+
};
|
|
5186
|
+
|
|
5187
|
+
this.subscribe(abort);
|
|
5188
|
+
|
|
5189
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
5190
|
+
|
|
5191
|
+
return controller.signal;
|
|
5192
|
+
}
|
|
5193
|
+
|
|
4675
5194
|
/**
|
|
4676
5195
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
4677
5196
|
* cancels the `CancelToken`.
|
|
@@ -5119,20 +5638,32 @@ function copyBuffer (cur) {
|
|
|
5119
5638
|
|
|
5120
5639
|
function rfdc (opts) {
|
|
5121
5640
|
opts = opts || {};
|
|
5122
|
-
|
|
5123
5641
|
if (opts.circles) return rfdcCircles(opts)
|
|
5642
|
+
|
|
5643
|
+
const constructorHandlers = new Map();
|
|
5644
|
+
constructorHandlers.set(Date, (o) => new Date(o));
|
|
5645
|
+
constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
|
|
5646
|
+
constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
|
|
5647
|
+
if (opts.constructorHandlers) {
|
|
5648
|
+
for (const handler of opts.constructorHandlers) {
|
|
5649
|
+
constructorHandlers.set(handler[0], handler[1]);
|
|
5650
|
+
}
|
|
5651
|
+
}
|
|
5652
|
+
|
|
5653
|
+
let handler = null;
|
|
5654
|
+
|
|
5124
5655
|
return opts.proto ? cloneProto : clone
|
|
5125
5656
|
|
|
5126
5657
|
function cloneArray (a, fn) {
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
for (
|
|
5130
|
-
|
|
5131
|
-
|
|
5658
|
+
const keys = Object.keys(a);
|
|
5659
|
+
const a2 = new Array(keys.length);
|
|
5660
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5661
|
+
const k = keys[i];
|
|
5662
|
+
const cur = a[k];
|
|
5132
5663
|
if (typeof cur !== 'object' || cur === null) {
|
|
5133
5664
|
a2[k] = cur;
|
|
5134
|
-
} else if (cur
|
|
5135
|
-
a2[k] =
|
|
5665
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5666
|
+
a2[k] = handler(cur, fn);
|
|
5136
5667
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5137
5668
|
a2[k] = copyBuffer(cur);
|
|
5138
5669
|
} else {
|
|
@@ -5144,22 +5675,18 @@ function rfdc (opts) {
|
|
|
5144
5675
|
|
|
5145
5676
|
function clone (o) {
|
|
5146
5677
|
if (typeof o !== 'object' || o === null) return o
|
|
5147
|
-
if (o instanceof Date) return new Date(o)
|
|
5148
5678
|
if (Array.isArray(o)) return cloneArray(o, clone)
|
|
5149
|
-
if (o
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5679
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
|
|
5680
|
+
return handler(o, clone)
|
|
5681
|
+
}
|
|
5682
|
+
const o2 = {};
|
|
5683
|
+
for (const k in o) {
|
|
5153
5684
|
if (Object.hasOwnProperty.call(o, k) === false) continue
|
|
5154
|
-
|
|
5685
|
+
const cur = o[k];
|
|
5155
5686
|
if (typeof cur !== 'object' || cur === null) {
|
|
5156
5687
|
o2[k] = cur;
|
|
5157
|
-
} else if (cur
|
|
5158
|
-
o2[k] =
|
|
5159
|
-
} else if (cur instanceof Map) {
|
|
5160
|
-
o2[k] = new Map(cloneArray(Array.from(cur), clone));
|
|
5161
|
-
} else if (cur instanceof Set) {
|
|
5162
|
-
o2[k] = new Set(cloneArray(Array.from(cur), clone));
|
|
5688
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5689
|
+
o2[k] = handler(cur, clone);
|
|
5163
5690
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5164
5691
|
o2[k] = copyBuffer(cur);
|
|
5165
5692
|
} else {
|
|
@@ -5171,21 +5698,17 @@ function rfdc (opts) {
|
|
|
5171
5698
|
|
|
5172
5699
|
function cloneProto (o) {
|
|
5173
5700
|
if (typeof o !== 'object' || o === null) return o
|
|
5174
|
-
if (o instanceof Date) return new Date(o)
|
|
5175
5701
|
if (Array.isArray(o)) return cloneArray(o, cloneProto)
|
|
5176
|
-
if (o
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5702
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
|
|
5703
|
+
return handler(o, cloneProto)
|
|
5704
|
+
}
|
|
5705
|
+
const o2 = {};
|
|
5706
|
+
for (const k in o) {
|
|
5707
|
+
const cur = o[k];
|
|
5181
5708
|
if (typeof cur !== 'object' || cur === null) {
|
|
5182
5709
|
o2[k] = cur;
|
|
5183
|
-
} else if (cur
|
|
5184
|
-
o2[k] =
|
|
5185
|
-
} else if (cur instanceof Map) {
|
|
5186
|
-
o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
|
|
5187
|
-
} else if (cur instanceof Set) {
|
|
5188
|
-
o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
|
|
5710
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5711
|
+
o2[k] = handler(cur, cloneProto);
|
|
5189
5712
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5190
5713
|
o2[k] = copyBuffer(cur);
|
|
5191
5714
|
} else {
|
|
@@ -5197,25 +5720,36 @@ function rfdc (opts) {
|
|
|
5197
5720
|
}
|
|
5198
5721
|
|
|
5199
5722
|
function rfdcCircles (opts) {
|
|
5200
|
-
|
|
5201
|
-
|
|
5723
|
+
const refs = [];
|
|
5724
|
+
const refsNew = [];
|
|
5725
|
+
|
|
5726
|
+
const constructorHandlers = new Map();
|
|
5727
|
+
constructorHandlers.set(Date, (o) => new Date(o));
|
|
5728
|
+
constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
|
|
5729
|
+
constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
|
|
5730
|
+
if (opts.constructorHandlers) {
|
|
5731
|
+
for (const handler of opts.constructorHandlers) {
|
|
5732
|
+
constructorHandlers.set(handler[0], handler[1]);
|
|
5733
|
+
}
|
|
5734
|
+
}
|
|
5202
5735
|
|
|
5736
|
+
let handler = null;
|
|
5203
5737
|
return opts.proto ? cloneProto : clone
|
|
5204
5738
|
|
|
5205
5739
|
function cloneArray (a, fn) {
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
for (
|
|
5209
|
-
|
|
5210
|
-
|
|
5740
|
+
const keys = Object.keys(a);
|
|
5741
|
+
const a2 = new Array(keys.length);
|
|
5742
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5743
|
+
const k = keys[i];
|
|
5744
|
+
const cur = a[k];
|
|
5211
5745
|
if (typeof cur !== 'object' || cur === null) {
|
|
5212
5746
|
a2[k] = cur;
|
|
5213
|
-
} else if (cur
|
|
5214
|
-
a2[k] =
|
|
5747
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5748
|
+
a2[k] = handler(cur, fn);
|
|
5215
5749
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5216
5750
|
a2[k] = copyBuffer(cur);
|
|
5217
5751
|
} else {
|
|
5218
|
-
|
|
5752
|
+
const index = refs.indexOf(cur);
|
|
5219
5753
|
if (index !== -1) {
|
|
5220
5754
|
a2[k] = refsNew[index];
|
|
5221
5755
|
} else {
|
|
@@ -5228,28 +5762,24 @@ function rfdcCircles (opts) {
|
|
|
5228
5762
|
|
|
5229
5763
|
function clone (o) {
|
|
5230
5764
|
if (typeof o !== 'object' || o === null) return o
|
|
5231
|
-
if (o instanceof Date) return new Date(o)
|
|
5232
5765
|
if (Array.isArray(o)) return cloneArray(o, clone)
|
|
5233
|
-
if (o
|
|
5234
|
-
|
|
5235
|
-
|
|
5766
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
|
|
5767
|
+
return handler(o, clone)
|
|
5768
|
+
}
|
|
5769
|
+
const o2 = {};
|
|
5236
5770
|
refs.push(o);
|
|
5237
5771
|
refsNew.push(o2);
|
|
5238
|
-
for (
|
|
5772
|
+
for (const k in o) {
|
|
5239
5773
|
if (Object.hasOwnProperty.call(o, k) === false) continue
|
|
5240
|
-
|
|
5774
|
+
const cur = o[k];
|
|
5241
5775
|
if (typeof cur !== 'object' || cur === null) {
|
|
5242
5776
|
o2[k] = cur;
|
|
5243
|
-
} else if (cur
|
|
5244
|
-
o2[k] =
|
|
5245
|
-
} else if (cur instanceof Map) {
|
|
5246
|
-
o2[k] = new Map(cloneArray(Array.from(cur), clone));
|
|
5247
|
-
} else if (cur instanceof Set) {
|
|
5248
|
-
o2[k] = new Set(cloneArray(Array.from(cur), clone));
|
|
5777
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5778
|
+
o2[k] = handler(cur, clone);
|
|
5249
5779
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5250
5780
|
o2[k] = copyBuffer(cur);
|
|
5251
5781
|
} else {
|
|
5252
|
-
|
|
5782
|
+
const i = refs.indexOf(cur);
|
|
5253
5783
|
if (i !== -1) {
|
|
5254
5784
|
o2[k] = refsNew[i];
|
|
5255
5785
|
} else {
|
|
@@ -5264,27 +5794,23 @@ function rfdcCircles (opts) {
|
|
|
5264
5794
|
|
|
5265
5795
|
function cloneProto (o) {
|
|
5266
5796
|
if (typeof o !== 'object' || o === null) return o
|
|
5267
|
-
if (o instanceof Date) return new Date(o)
|
|
5268
5797
|
if (Array.isArray(o)) return cloneArray(o, cloneProto)
|
|
5269
|
-
if (o
|
|
5270
|
-
|
|
5271
|
-
|
|
5798
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
|
|
5799
|
+
return handler(o, cloneProto)
|
|
5800
|
+
}
|
|
5801
|
+
const o2 = {};
|
|
5272
5802
|
refs.push(o);
|
|
5273
5803
|
refsNew.push(o2);
|
|
5274
|
-
for (
|
|
5275
|
-
|
|
5804
|
+
for (const k in o) {
|
|
5805
|
+
const cur = o[k];
|
|
5276
5806
|
if (typeof cur !== 'object' || cur === null) {
|
|
5277
5807
|
o2[k] = cur;
|
|
5278
|
-
} else if (cur
|
|
5279
|
-
o2[k] =
|
|
5280
|
-
} else if (cur instanceof Map) {
|
|
5281
|
-
o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
|
|
5282
|
-
} else if (cur instanceof Set) {
|
|
5283
|
-
o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
|
|
5808
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5809
|
+
o2[k] = handler(cur, cloneProto);
|
|
5284
5810
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5285
5811
|
o2[k] = copyBuffer(cur);
|
|
5286
5812
|
} else {
|
|
5287
|
-
|
|
5813
|
+
const i = refs.indexOf(cur);
|
|
5288
5814
|
if (i !== -1) {
|
|
5289
5815
|
o2[k] = refsNew[i];
|
|
5290
5816
|
} else {
|