orange-orm 4.4.0-beta.1 → 4.4.0
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/docs/changelog.md +4 -0
- package/package.json +1 -1
- package/src/client/index.mjs +784 -373
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';
|
|
@@ -2321,6 +2322,10 @@ var utils$1 = {
|
|
|
2321
2322
|
isBoolean,
|
|
2322
2323
|
isObject,
|
|
2323
2324
|
isPlainObject,
|
|
2325
|
+
isReadableStream,
|
|
2326
|
+
isRequest,
|
|
2327
|
+
isResponse,
|
|
2328
|
+
isHeaders,
|
|
2324
2329
|
isUndefined,
|
|
2325
2330
|
isDate,
|
|
2326
2331
|
isFile,
|
|
@@ -2917,11 +2922,14 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
2917
2922
|
);
|
|
2918
2923
|
})();
|
|
2919
2924
|
|
|
2925
|
+
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
2926
|
+
|
|
2920
2927
|
var utils = /*#__PURE__*/Object.freeze({
|
|
2921
2928
|
__proto__: null,
|
|
2922
2929
|
hasBrowserEnv: hasBrowserEnv,
|
|
2923
2930
|
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
2924
|
-
hasStandardBrowserEnv: hasStandardBrowserEnv
|
|
2931
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
2932
|
+
origin: origin
|
|
2925
2933
|
});
|
|
2926
2934
|
|
|
2927
2935
|
var platform = {
|
|
@@ -2989,6 +2997,9 @@ function arrayToObject(arr) {
|
|
|
2989
2997
|
function formDataToJSON(formData) {
|
|
2990
2998
|
function buildPath(path, value, target, index) {
|
|
2991
2999
|
let name = path[index++];
|
|
3000
|
+
|
|
3001
|
+
if (name === '__proto__') return true;
|
|
3002
|
+
|
|
2992
3003
|
const isNumericKey = Number.isFinite(+name);
|
|
2993
3004
|
const isLast = index >= path.length;
|
|
2994
3005
|
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
@@ -3058,7 +3069,7 @@ const defaults = {
|
|
|
3058
3069
|
|
|
3059
3070
|
transitional: transitionalDefaults,
|
|
3060
3071
|
|
|
3061
|
-
adapter: ['xhr', 'http'],
|
|
3072
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
3062
3073
|
|
|
3063
3074
|
transformRequest: [function transformRequest(data, headers) {
|
|
3064
3075
|
const contentType = headers.getContentType() || '';
|
|
@@ -3072,9 +3083,6 @@ const defaults = {
|
|
|
3072
3083
|
const isFormData = utils$1.isFormData(data);
|
|
3073
3084
|
|
|
3074
3085
|
if (isFormData) {
|
|
3075
|
-
if (!hasJSONContentType) {
|
|
3076
|
-
return data;
|
|
3077
|
-
}
|
|
3078
3086
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
3079
3087
|
}
|
|
3080
3088
|
|
|
@@ -3082,7 +3090,8 @@ const defaults = {
|
|
|
3082
3090
|
utils$1.isBuffer(data) ||
|
|
3083
3091
|
utils$1.isStream(data) ||
|
|
3084
3092
|
utils$1.isFile(data) ||
|
|
3085
|
-
utils$1.isBlob(data)
|
|
3093
|
+
utils$1.isBlob(data) ||
|
|
3094
|
+
utils$1.isReadableStream(data)
|
|
3086
3095
|
) {
|
|
3087
3096
|
return data;
|
|
3088
3097
|
}
|
|
@@ -3125,6 +3134,10 @@ const defaults = {
|
|
|
3125
3134
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
3126
3135
|
const JSONRequested = this.responseType === 'json';
|
|
3127
3136
|
|
|
3137
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
3138
|
+
return data;
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3128
3141
|
if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
3129
3142
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
3130
3143
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
@@ -3328,6 +3341,10 @@ class AxiosHeaders {
|
|
|
3328
3341
|
setHeaders(header, valueOrRewrite);
|
|
3329
3342
|
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
3330
3343
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
3344
|
+
} else if (utils$1.isHeaders(header)) {
|
|
3345
|
+
for (const [key, value] of header.entries()) {
|
|
3346
|
+
setHeader(value, key, rewrite);
|
|
3347
|
+
}
|
|
3331
3348
|
} else {
|
|
3332
3349
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
3333
3350
|
}
|
|
@@ -3595,90 +3612,125 @@ function settle(resolve, reject, response) {
|
|
|
3595
3612
|
}
|
|
3596
3613
|
}
|
|
3597
3614
|
|
|
3598
|
-
|
|
3615
|
+
function parseProtocol(url) {
|
|
3616
|
+
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
3617
|
+
return match && match[1] || '';
|
|
3618
|
+
}
|
|
3599
3619
|
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3620
|
+
/**
|
|
3621
|
+
* Calculate data maxRate
|
|
3622
|
+
* @param {Number} [samplesCount= 10]
|
|
3623
|
+
* @param {Number} [min= 1000]
|
|
3624
|
+
* @returns {Function}
|
|
3625
|
+
*/
|
|
3626
|
+
function speedometer(samplesCount, min) {
|
|
3627
|
+
samplesCount = samplesCount || 10;
|
|
3628
|
+
const bytes = new Array(samplesCount);
|
|
3629
|
+
const timestamps = new Array(samplesCount);
|
|
3630
|
+
let head = 0;
|
|
3631
|
+
let tail = 0;
|
|
3632
|
+
let firstSampleTS;
|
|
3604
3633
|
|
|
3605
|
-
|
|
3634
|
+
min = min !== undefined ? min : 1000;
|
|
3606
3635
|
|
|
3607
|
-
|
|
3636
|
+
return function push(chunkLength) {
|
|
3637
|
+
const now = Date.now();
|
|
3608
3638
|
|
|
3609
|
-
|
|
3639
|
+
const startedAt = timestamps[tail];
|
|
3610
3640
|
|
|
3611
|
-
|
|
3641
|
+
if (!firstSampleTS) {
|
|
3642
|
+
firstSampleTS = now;
|
|
3643
|
+
}
|
|
3612
3644
|
|
|
3613
|
-
|
|
3614
|
-
|
|
3645
|
+
bytes[head] = chunkLength;
|
|
3646
|
+
timestamps[head] = now;
|
|
3615
3647
|
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
return (match ? decodeURIComponent(match[3]) : null);
|
|
3619
|
-
},
|
|
3648
|
+
let i = tail;
|
|
3649
|
+
let bytesCount = 0;
|
|
3620
3650
|
|
|
3621
|
-
|
|
3622
|
-
|
|
3651
|
+
while (i !== head) {
|
|
3652
|
+
bytesCount += bytes[i++];
|
|
3653
|
+
i = i % samplesCount;
|
|
3623
3654
|
}
|
|
3624
|
-
}
|
|
3625
3655
|
|
|
3626
|
-
|
|
3656
|
+
head = (head + 1) % samplesCount;
|
|
3627
3657
|
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
read() {
|
|
3632
|
-
return null;
|
|
3633
|
-
},
|
|
3634
|
-
remove() {}
|
|
3635
|
-
};
|
|
3658
|
+
if (head === tail) {
|
|
3659
|
+
tail = (tail + 1) % samplesCount;
|
|
3660
|
+
}
|
|
3636
3661
|
|
|
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
|
-
}
|
|
3662
|
+
if (now - firstSampleTS < min) {
|
|
3663
|
+
return;
|
|
3664
|
+
}
|
|
3650
3665
|
|
|
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;
|
|
3666
|
+
const passed = startedAt && now - startedAt;
|
|
3667
|
+
|
|
3668
|
+
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
3669
|
+
};
|
|
3663
3670
|
}
|
|
3664
3671
|
|
|
3665
3672
|
/**
|
|
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
|
|
3673
|
+
* Throttle decorator
|
|
3674
|
+
* @param {Function} fn
|
|
3675
|
+
* @param {Number} freq
|
|
3676
|
+
* @return {Function}
|
|
3674
3677
|
*/
|
|
3675
|
-
function
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
return
|
|
3678
|
+
function throttle(fn, freq) {
|
|
3679
|
+
let timestamp = 0;
|
|
3680
|
+
const threshold = 1000 / freq;
|
|
3681
|
+
let timer = null;
|
|
3682
|
+
return function throttled() {
|
|
3683
|
+
const force = this === true;
|
|
3684
|
+
|
|
3685
|
+
const now = Date.now();
|
|
3686
|
+
if (force || now - timestamp > threshold) {
|
|
3687
|
+
if (timer) {
|
|
3688
|
+
clearTimeout(timer);
|
|
3689
|
+
timer = null;
|
|
3690
|
+
}
|
|
3691
|
+
timestamp = now;
|
|
3692
|
+
return fn.apply(null, arguments);
|
|
3693
|
+
}
|
|
3694
|
+
if (!timer) {
|
|
3695
|
+
timer = setTimeout(() => {
|
|
3696
|
+
timer = null;
|
|
3697
|
+
timestamp = Date.now();
|
|
3698
|
+
return fn.apply(null, arguments);
|
|
3699
|
+
}, threshold - (now - timestamp));
|
|
3700
|
+
}
|
|
3701
|
+
};
|
|
3680
3702
|
}
|
|
3681
3703
|
|
|
3704
|
+
var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
3705
|
+
let bytesNotified = 0;
|
|
3706
|
+
const _speedometer = speedometer(50, 250);
|
|
3707
|
+
|
|
3708
|
+
return throttle(e => {
|
|
3709
|
+
const loaded = e.loaded;
|
|
3710
|
+
const total = e.lengthComputable ? e.total : undefined;
|
|
3711
|
+
const progressBytes = loaded - bytesNotified;
|
|
3712
|
+
const rate = _speedometer(progressBytes);
|
|
3713
|
+
const inRange = loaded <= total;
|
|
3714
|
+
|
|
3715
|
+
bytesNotified = loaded;
|
|
3716
|
+
|
|
3717
|
+
const data = {
|
|
3718
|
+
loaded,
|
|
3719
|
+
total,
|
|
3720
|
+
progress: total ? (loaded / total) : undefined,
|
|
3721
|
+
bytes: progressBytes,
|
|
3722
|
+
rate: rate ? rate : undefined,
|
|
3723
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
3724
|
+
event: e,
|
|
3725
|
+
lengthComputable: total != null
|
|
3726
|
+
};
|
|
3727
|
+
|
|
3728
|
+
data[isDownloadStream ? 'download' : 'upload'] = true;
|
|
3729
|
+
|
|
3730
|
+
listener(data);
|
|
3731
|
+
}, freq);
|
|
3732
|
+
};
|
|
3733
|
+
|
|
3682
3734
|
var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
3683
3735
|
|
|
3684
3736
|
// Standard browser envs have full support of the APIs needed to test
|
|
@@ -3742,137 +3794,265 @@ var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
|
3742
3794
|
};
|
|
3743
3795
|
})();
|
|
3744
3796
|
|
|
3745
|
-
|
|
3746
|
-
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
3747
|
-
return match && match[1] || '';
|
|
3748
|
-
}
|
|
3797
|
+
var cookies = platform.hasStandardBrowserEnv ?
|
|
3749
3798
|
|
|
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;
|
|
3799
|
+
// Standard browser envs support document.cookie
|
|
3800
|
+
{
|
|
3801
|
+
write(name, value, expires, path, domain, secure) {
|
|
3802
|
+
const cookie = [name + '=' + encodeURIComponent(value)];
|
|
3763
3803
|
|
|
3764
|
-
|
|
3804
|
+
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
3765
3805
|
|
|
3766
|
-
|
|
3767
|
-
const now = Date.now();
|
|
3806
|
+
utils$1.isString(path) && cookie.push('path=' + path);
|
|
3768
3807
|
|
|
3769
|
-
|
|
3808
|
+
utils$1.isString(domain) && cookie.push('domain=' + domain);
|
|
3770
3809
|
|
|
3771
|
-
|
|
3772
|
-
firstSampleTS = now;
|
|
3773
|
-
}
|
|
3810
|
+
secure === true && cookie.push('secure');
|
|
3774
3811
|
|
|
3775
|
-
|
|
3776
|
-
|
|
3812
|
+
document.cookie = cookie.join('; ');
|
|
3813
|
+
},
|
|
3777
3814
|
|
|
3778
|
-
|
|
3779
|
-
|
|
3815
|
+
read(name) {
|
|
3816
|
+
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
3817
|
+
return (match ? decodeURIComponent(match[3]) : null);
|
|
3818
|
+
},
|
|
3780
3819
|
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
i = i % samplesCount;
|
|
3820
|
+
remove(name) {
|
|
3821
|
+
this.write(name, '', Date.now() - 86400000);
|
|
3784
3822
|
}
|
|
3823
|
+
}
|
|
3785
3824
|
|
|
3786
|
-
|
|
3825
|
+
:
|
|
3787
3826
|
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
}
|
|
3827
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
3828
|
+
{
|
|
3829
|
+
write() {},
|
|
3830
|
+
read() {
|
|
3831
|
+
return null;
|
|
3832
|
+
},
|
|
3833
|
+
remove() {}
|
|
3834
|
+
};
|
|
3791
3835
|
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3836
|
+
/**
|
|
3837
|
+
* Determines whether the specified URL is absolute
|
|
3838
|
+
*
|
|
3839
|
+
* @param {string} url The URL to test
|
|
3840
|
+
*
|
|
3841
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
3842
|
+
*/
|
|
3843
|
+
function isAbsoluteURL(url) {
|
|
3844
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
3845
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
3846
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
|
3847
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
3848
|
+
}
|
|
3795
3849
|
|
|
3796
|
-
|
|
3850
|
+
/**
|
|
3851
|
+
* Creates a new URL by combining the specified URLs
|
|
3852
|
+
*
|
|
3853
|
+
* @param {string} baseURL The base URL
|
|
3854
|
+
* @param {string} relativeURL The relative URL
|
|
3855
|
+
*
|
|
3856
|
+
* @returns {string} The combined URL
|
|
3857
|
+
*/
|
|
3858
|
+
function combineURLs(baseURL, relativeURL) {
|
|
3859
|
+
return relativeURL
|
|
3860
|
+
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
3861
|
+
: baseURL;
|
|
3862
|
+
}
|
|
3797
3863
|
|
|
3798
|
-
|
|
3799
|
-
|
|
3864
|
+
/**
|
|
3865
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
3866
|
+
* only when the requestedURL is not already an absolute URL.
|
|
3867
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
3868
|
+
*
|
|
3869
|
+
* @param {string} baseURL The base URL
|
|
3870
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
|
3871
|
+
*
|
|
3872
|
+
* @returns {string} The combined full path
|
|
3873
|
+
*/
|
|
3874
|
+
function buildFullPath(baseURL, requestedURL) {
|
|
3875
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
3876
|
+
return combineURLs(baseURL, requestedURL);
|
|
3877
|
+
}
|
|
3878
|
+
return requestedURL;
|
|
3800
3879
|
}
|
|
3801
3880
|
|
|
3802
|
-
|
|
3803
|
-
let bytesNotified = 0;
|
|
3804
|
-
const _speedometer = speedometer(50, 250);
|
|
3881
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
3805
3882
|
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3883
|
+
/**
|
|
3884
|
+
* Config-specific merge-function which creates a new config-object
|
|
3885
|
+
* by merging two configuration objects together.
|
|
3886
|
+
*
|
|
3887
|
+
* @param {Object} config1
|
|
3888
|
+
* @param {Object} config2
|
|
3889
|
+
*
|
|
3890
|
+
* @returns {Object} New object resulting from merging config2 to config1
|
|
3891
|
+
*/
|
|
3892
|
+
function mergeConfig(config1, config2) {
|
|
3893
|
+
// eslint-disable-next-line no-param-reassign
|
|
3894
|
+
config2 = config2 || {};
|
|
3895
|
+
const config = {};
|
|
3812
3896
|
|
|
3813
|
-
|
|
3897
|
+
function getMergedValue(target, source, caseless) {
|
|
3898
|
+
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
3899
|
+
return utils$1.merge.call({caseless}, target, source);
|
|
3900
|
+
} else if (utils$1.isPlainObject(source)) {
|
|
3901
|
+
return utils$1.merge({}, source);
|
|
3902
|
+
} else if (utils$1.isArray(source)) {
|
|
3903
|
+
return source.slice();
|
|
3904
|
+
}
|
|
3905
|
+
return source;
|
|
3906
|
+
}
|
|
3814
3907
|
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
};
|
|
3908
|
+
// eslint-disable-next-line consistent-return
|
|
3909
|
+
function mergeDeepProperties(a, b, caseless) {
|
|
3910
|
+
if (!utils$1.isUndefined(b)) {
|
|
3911
|
+
return getMergedValue(a, b, caseless);
|
|
3912
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
3913
|
+
return getMergedValue(undefined, a, caseless);
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3824
3916
|
|
|
3825
|
-
|
|
3917
|
+
// eslint-disable-next-line consistent-return
|
|
3918
|
+
function valueFromConfig2(a, b) {
|
|
3919
|
+
if (!utils$1.isUndefined(b)) {
|
|
3920
|
+
return getMergedValue(undefined, b);
|
|
3921
|
+
}
|
|
3922
|
+
}
|
|
3826
3923
|
|
|
3827
|
-
|
|
3924
|
+
// eslint-disable-next-line consistent-return
|
|
3925
|
+
function defaultToConfig2(a, b) {
|
|
3926
|
+
if (!utils$1.isUndefined(b)) {
|
|
3927
|
+
return getMergedValue(undefined, b);
|
|
3928
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
3929
|
+
return getMergedValue(undefined, a);
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3933
|
+
// eslint-disable-next-line consistent-return
|
|
3934
|
+
function mergeDirectKeys(a, b, prop) {
|
|
3935
|
+
if (prop in config2) {
|
|
3936
|
+
return getMergedValue(a, b);
|
|
3937
|
+
} else if (prop in config1) {
|
|
3938
|
+
return getMergedValue(undefined, a);
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
const mergeMap = {
|
|
3943
|
+
url: valueFromConfig2,
|
|
3944
|
+
method: valueFromConfig2,
|
|
3945
|
+
data: valueFromConfig2,
|
|
3946
|
+
baseURL: defaultToConfig2,
|
|
3947
|
+
transformRequest: defaultToConfig2,
|
|
3948
|
+
transformResponse: defaultToConfig2,
|
|
3949
|
+
paramsSerializer: defaultToConfig2,
|
|
3950
|
+
timeout: defaultToConfig2,
|
|
3951
|
+
timeoutMessage: defaultToConfig2,
|
|
3952
|
+
withCredentials: defaultToConfig2,
|
|
3953
|
+
withXSRFToken: defaultToConfig2,
|
|
3954
|
+
adapter: defaultToConfig2,
|
|
3955
|
+
responseType: defaultToConfig2,
|
|
3956
|
+
xsrfCookieName: defaultToConfig2,
|
|
3957
|
+
xsrfHeaderName: defaultToConfig2,
|
|
3958
|
+
onUploadProgress: defaultToConfig2,
|
|
3959
|
+
onDownloadProgress: defaultToConfig2,
|
|
3960
|
+
decompress: defaultToConfig2,
|
|
3961
|
+
maxContentLength: defaultToConfig2,
|
|
3962
|
+
maxBodyLength: defaultToConfig2,
|
|
3963
|
+
beforeRedirect: defaultToConfig2,
|
|
3964
|
+
transport: defaultToConfig2,
|
|
3965
|
+
httpAgent: defaultToConfig2,
|
|
3966
|
+
httpsAgent: defaultToConfig2,
|
|
3967
|
+
cancelToken: defaultToConfig2,
|
|
3968
|
+
socketPath: defaultToConfig2,
|
|
3969
|
+
responseEncoding: defaultToConfig2,
|
|
3970
|
+
validateStatus: mergeDirectKeys,
|
|
3971
|
+
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
3828
3972
|
};
|
|
3973
|
+
|
|
3974
|
+
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
3975
|
+
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
3976
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
|
3977
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
3978
|
+
});
|
|
3979
|
+
|
|
3980
|
+
return config;
|
|
3829
3981
|
}
|
|
3830
3982
|
|
|
3983
|
+
var resolveConfig = (config) => {
|
|
3984
|
+
const newConfig = mergeConfig({}, config);
|
|
3985
|
+
|
|
3986
|
+
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
3987
|
+
|
|
3988
|
+
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
3989
|
+
|
|
3990
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
|
3991
|
+
|
|
3992
|
+
// HTTP basic authentication
|
|
3993
|
+
if (auth) {
|
|
3994
|
+
headers.set('Authorization', 'Basic ' +
|
|
3995
|
+
btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
|
|
3996
|
+
);
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
let contentType;
|
|
4000
|
+
|
|
4001
|
+
if (utils$1.isFormData(data)) {
|
|
4002
|
+
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
4003
|
+
headers.setContentType(undefined); // Let the browser set it
|
|
4004
|
+
} else if ((contentType = headers.getContentType()) !== false) {
|
|
4005
|
+
// fix semicolon duplication issue for ReactNative FormData implementation
|
|
4006
|
+
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
|
4007
|
+
headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
|
4008
|
+
}
|
|
4009
|
+
}
|
|
4010
|
+
|
|
4011
|
+
// Add xsrf header
|
|
4012
|
+
// This is only done if running in a standard browser environment.
|
|
4013
|
+
// Specifically not if we're in a web worker, or react-native.
|
|
4014
|
+
|
|
4015
|
+
if (platform.hasStandardBrowserEnv) {
|
|
4016
|
+
withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
4017
|
+
|
|
4018
|
+
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
|
4019
|
+
// Add xsrf header
|
|
4020
|
+
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
4021
|
+
|
|
4022
|
+
if (xsrfValue) {
|
|
4023
|
+
headers.set(xsrfHeaderName, xsrfValue);
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
return newConfig;
|
|
4029
|
+
};
|
|
4030
|
+
|
|
3831
4031
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
3832
4032
|
|
|
3833
4033
|
var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
3834
4034
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
4035
|
+
const _config = resolveConfig(config);
|
|
4036
|
+
let requestData = _config.data;
|
|
4037
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
4038
|
+
let {responseType} = _config;
|
|
3838
4039
|
let onCanceled;
|
|
3839
4040
|
function done() {
|
|
3840
|
-
if (
|
|
3841
|
-
|
|
4041
|
+
if (_config.cancelToken) {
|
|
4042
|
+
_config.cancelToken.unsubscribe(onCanceled);
|
|
3842
4043
|
}
|
|
3843
4044
|
|
|
3844
|
-
if (
|
|
3845
|
-
|
|
3846
|
-
}
|
|
3847
|
-
}
|
|
3848
|
-
|
|
3849
|
-
let contentType;
|
|
3850
|
-
|
|
3851
|
-
if (utils$1.isFormData(requestData)) {
|
|
3852
|
-
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
3853
|
-
requestHeaders.setContentType(false); // Let the browser set it
|
|
3854
|
-
} else if ((contentType = requestHeaders.getContentType()) !== false) {
|
|
3855
|
-
// fix semicolon duplication issue for ReactNative FormData implementation
|
|
3856
|
-
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
|
3857
|
-
requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
|
4045
|
+
if (_config.signal) {
|
|
4046
|
+
_config.signal.removeEventListener('abort', onCanceled);
|
|
3858
4047
|
}
|
|
3859
4048
|
}
|
|
3860
4049
|
|
|
3861
4050
|
let request = new XMLHttpRequest();
|
|
3862
4051
|
|
|
3863
|
-
|
|
3864
|
-
if (config.auth) {
|
|
3865
|
-
const username = config.auth.username || '';
|
|
3866
|
-
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
|
3867
|
-
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
|
|
3868
|
-
}
|
|
3869
|
-
|
|
3870
|
-
const fullPath = buildFullPath(config.baseURL, config.url);
|
|
3871
|
-
|
|
3872
|
-
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
|
4052
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
3873
4053
|
|
|
3874
4054
|
// Set the request timeout in MS
|
|
3875
|
-
request.timeout =
|
|
4055
|
+
request.timeout = _config.timeout;
|
|
3876
4056
|
|
|
3877
4057
|
function onloadend() {
|
|
3878
4058
|
if (!request) {
|
|
@@ -3934,7 +4114,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3934
4114
|
return;
|
|
3935
4115
|
}
|
|
3936
4116
|
|
|
3937
|
-
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED,
|
|
4117
|
+
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, _config, request));
|
|
3938
4118
|
|
|
3939
4119
|
// Clean up request
|
|
3940
4120
|
request = null;
|
|
@@ -3944,7 +4124,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3944
4124
|
request.onerror = function handleError() {
|
|
3945
4125
|
// Real errors are hidden from us by the browser
|
|
3946
4126
|
// onerror should only fire if it's a network error
|
|
3947
|
-
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK,
|
|
4127
|
+
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, _config, request));
|
|
3948
4128
|
|
|
3949
4129
|
// Clean up request
|
|
3950
4130
|
request = null;
|
|
@@ -3952,37 +4132,21 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3952
4132
|
|
|
3953
4133
|
// Handle timeout
|
|
3954
4134
|
request.ontimeout = function handleTimeout() {
|
|
3955
|
-
let timeoutErrorMessage =
|
|
3956
|
-
const transitional =
|
|
3957
|
-
if (
|
|
3958
|
-
timeoutErrorMessage =
|
|
4135
|
+
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
4136
|
+
const transitional = _config.transitional || transitionalDefaults;
|
|
4137
|
+
if (_config.timeoutErrorMessage) {
|
|
4138
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
3959
4139
|
}
|
|
3960
4140
|
reject(new AxiosError(
|
|
3961
4141
|
timeoutErrorMessage,
|
|
3962
4142
|
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
3963
|
-
|
|
4143
|
+
_config,
|
|
3964
4144
|
request));
|
|
3965
4145
|
|
|
3966
4146
|
// Clean up request
|
|
3967
4147
|
request = null;
|
|
3968
4148
|
};
|
|
3969
4149
|
|
|
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
4150
|
// Remove Content-Type if data is undefined
|
|
3987
4151
|
requestData === undefined && requestHeaders.setContentType(null);
|
|
3988
4152
|
|
|
@@ -3994,26 +4158,26 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3994
4158
|
}
|
|
3995
4159
|
|
|
3996
4160
|
// Add withCredentials to request if needed
|
|
3997
|
-
if (!utils$1.isUndefined(
|
|
3998
|
-
request.withCredentials = !!
|
|
4161
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
4162
|
+
request.withCredentials = !!_config.withCredentials;
|
|
3999
4163
|
}
|
|
4000
4164
|
|
|
4001
4165
|
// Add responseType to request if needed
|
|
4002
4166
|
if (responseType && responseType !== 'json') {
|
|
4003
|
-
request.responseType =
|
|
4167
|
+
request.responseType = _config.responseType;
|
|
4004
4168
|
}
|
|
4005
4169
|
|
|
4006
4170
|
// Handle progress if needed
|
|
4007
|
-
if (typeof
|
|
4008
|
-
request.addEventListener('progress', progressEventReducer(
|
|
4171
|
+
if (typeof _config.onDownloadProgress === 'function') {
|
|
4172
|
+
request.addEventListener('progress', progressEventReducer(_config.onDownloadProgress, true));
|
|
4009
4173
|
}
|
|
4010
4174
|
|
|
4011
4175
|
// Not all browsers support upload events
|
|
4012
|
-
if (typeof
|
|
4013
|
-
request.upload.addEventListener('progress', progressEventReducer(
|
|
4176
|
+
if (typeof _config.onUploadProgress === 'function' && request.upload) {
|
|
4177
|
+
request.upload.addEventListener('progress', progressEventReducer(_config.onUploadProgress));
|
|
4014
4178
|
}
|
|
4015
4179
|
|
|
4016
|
-
if (
|
|
4180
|
+
if (_config.cancelToken || _config.signal) {
|
|
4017
4181
|
// Handle cancellation
|
|
4018
4182
|
// eslint-disable-next-line func-names
|
|
4019
4183
|
onCanceled = cancel => {
|
|
@@ -4025,13 +4189,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4025
4189
|
request = null;
|
|
4026
4190
|
};
|
|
4027
4191
|
|
|
4028
|
-
|
|
4029
|
-
if (
|
|
4030
|
-
|
|
4192
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
4193
|
+
if (_config.signal) {
|
|
4194
|
+
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
4031
4195
|
}
|
|
4032
4196
|
}
|
|
4033
4197
|
|
|
4034
|
-
const protocol = parseProtocol(
|
|
4198
|
+
const protocol = parseProtocol(_config.url);
|
|
4035
4199
|
|
|
4036
4200
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
4037
4201
|
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|
@@ -4044,9 +4208,324 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4044
4208
|
});
|
|
4045
4209
|
};
|
|
4046
4210
|
|
|
4211
|
+
const composeSignals = (signals, timeout) => {
|
|
4212
|
+
let controller = new AbortController();
|
|
4213
|
+
|
|
4214
|
+
let aborted;
|
|
4215
|
+
|
|
4216
|
+
const onabort = function (cancel) {
|
|
4217
|
+
if (!aborted) {
|
|
4218
|
+
aborted = true;
|
|
4219
|
+
unsubscribe();
|
|
4220
|
+
const err = cancel instanceof Error ? cancel : this.reason;
|
|
4221
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
4222
|
+
}
|
|
4223
|
+
};
|
|
4224
|
+
|
|
4225
|
+
let timer = timeout && setTimeout(() => {
|
|
4226
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
4227
|
+
}, timeout);
|
|
4228
|
+
|
|
4229
|
+
const unsubscribe = () => {
|
|
4230
|
+
if (signals) {
|
|
4231
|
+
timer && clearTimeout(timer);
|
|
4232
|
+
timer = null;
|
|
4233
|
+
signals.forEach(signal => {
|
|
4234
|
+
signal &&
|
|
4235
|
+
(signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
|
|
4236
|
+
});
|
|
4237
|
+
signals = null;
|
|
4238
|
+
}
|
|
4239
|
+
};
|
|
4240
|
+
|
|
4241
|
+
signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
|
|
4242
|
+
|
|
4243
|
+
const {signal} = controller;
|
|
4244
|
+
|
|
4245
|
+
signal.unsubscribe = unsubscribe;
|
|
4246
|
+
|
|
4247
|
+
return [signal, () => {
|
|
4248
|
+
timer && clearTimeout(timer);
|
|
4249
|
+
timer = null;
|
|
4250
|
+
}];
|
|
4251
|
+
};
|
|
4252
|
+
|
|
4253
|
+
var composeSignals$1 = composeSignals;
|
|
4254
|
+
|
|
4255
|
+
const streamChunk = function* (chunk, chunkSize) {
|
|
4256
|
+
let len = chunk.byteLength;
|
|
4257
|
+
|
|
4258
|
+
if (!chunkSize || len < chunkSize) {
|
|
4259
|
+
yield chunk;
|
|
4260
|
+
return;
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4263
|
+
let pos = 0;
|
|
4264
|
+
let end;
|
|
4265
|
+
|
|
4266
|
+
while (pos < len) {
|
|
4267
|
+
end = pos + chunkSize;
|
|
4268
|
+
yield chunk.slice(pos, end);
|
|
4269
|
+
pos = end;
|
|
4270
|
+
}
|
|
4271
|
+
};
|
|
4272
|
+
|
|
4273
|
+
const readBytes = async function* (iterable, chunkSize, encode) {
|
|
4274
|
+
for await (const chunk of iterable) {
|
|
4275
|
+
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
|
|
4276
|
+
}
|
|
4277
|
+
};
|
|
4278
|
+
|
|
4279
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
|
4280
|
+
const iterator = readBytes(stream, chunkSize, encode);
|
|
4281
|
+
|
|
4282
|
+
let bytes = 0;
|
|
4283
|
+
|
|
4284
|
+
return new ReadableStream({
|
|
4285
|
+
type: 'bytes',
|
|
4286
|
+
|
|
4287
|
+
async pull(controller) {
|
|
4288
|
+
const {done, value} = await iterator.next();
|
|
4289
|
+
|
|
4290
|
+
if (done) {
|
|
4291
|
+
controller.close();
|
|
4292
|
+
onFinish();
|
|
4293
|
+
return;
|
|
4294
|
+
}
|
|
4295
|
+
|
|
4296
|
+
let len = value.byteLength;
|
|
4297
|
+
onProgress && onProgress(bytes += len);
|
|
4298
|
+
controller.enqueue(new Uint8Array(value));
|
|
4299
|
+
},
|
|
4300
|
+
cancel(reason) {
|
|
4301
|
+
onFinish(reason);
|
|
4302
|
+
return iterator.return();
|
|
4303
|
+
}
|
|
4304
|
+
}, {
|
|
4305
|
+
highWaterMark: 2
|
|
4306
|
+
})
|
|
4307
|
+
};
|
|
4308
|
+
|
|
4309
|
+
const fetchProgressDecorator = (total, fn) => {
|
|
4310
|
+
const lengthComputable = total != null;
|
|
4311
|
+
return (loaded) => setTimeout(() => fn({
|
|
4312
|
+
lengthComputable,
|
|
4313
|
+
total,
|
|
4314
|
+
loaded
|
|
4315
|
+
}));
|
|
4316
|
+
};
|
|
4317
|
+
|
|
4318
|
+
const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
|
|
4319
|
+
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
|
|
4320
|
+
|
|
4321
|
+
// used only inside the fetch adapter
|
|
4322
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
4323
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
4324
|
+
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
4325
|
+
);
|
|
4326
|
+
|
|
4327
|
+
const supportsRequestStream = isReadableStreamSupported && (() => {
|
|
4328
|
+
let duplexAccessed = false;
|
|
4329
|
+
|
|
4330
|
+
const hasContentType = new Request(platform.origin, {
|
|
4331
|
+
body: new ReadableStream(),
|
|
4332
|
+
method: 'POST',
|
|
4333
|
+
get duplex() {
|
|
4334
|
+
duplexAccessed = true;
|
|
4335
|
+
return 'half';
|
|
4336
|
+
},
|
|
4337
|
+
}).headers.has('Content-Type');
|
|
4338
|
+
|
|
4339
|
+
return duplexAccessed && !hasContentType;
|
|
4340
|
+
})();
|
|
4341
|
+
|
|
4342
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
4343
|
+
|
|
4344
|
+
const supportsResponseStream = isReadableStreamSupported && !!(()=> {
|
|
4345
|
+
try {
|
|
4346
|
+
return utils$1.isReadableStream(new Response('').body);
|
|
4347
|
+
} catch(err) {
|
|
4348
|
+
// return undefined
|
|
4349
|
+
}
|
|
4350
|
+
})();
|
|
4351
|
+
|
|
4352
|
+
const resolvers = {
|
|
4353
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
4354
|
+
};
|
|
4355
|
+
|
|
4356
|
+
isFetchSupported && (((res) => {
|
|
4357
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
4358
|
+
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
4359
|
+
(_, config) => {
|
|
4360
|
+
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
4361
|
+
});
|
|
4362
|
+
});
|
|
4363
|
+
})(new Response));
|
|
4364
|
+
|
|
4365
|
+
const getBodyLength = async (body) => {
|
|
4366
|
+
if (body == null) {
|
|
4367
|
+
return 0;
|
|
4368
|
+
}
|
|
4369
|
+
|
|
4370
|
+
if(utils$1.isBlob(body)) {
|
|
4371
|
+
return body.size;
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4374
|
+
if(utils$1.isSpecCompliantForm(body)) {
|
|
4375
|
+
return (await new Request(body).arrayBuffer()).byteLength;
|
|
4376
|
+
}
|
|
4377
|
+
|
|
4378
|
+
if(utils$1.isArrayBufferView(body)) {
|
|
4379
|
+
return body.byteLength;
|
|
4380
|
+
}
|
|
4381
|
+
|
|
4382
|
+
if(utils$1.isURLSearchParams(body)) {
|
|
4383
|
+
body = body + '';
|
|
4384
|
+
}
|
|
4385
|
+
|
|
4386
|
+
if(utils$1.isString(body)) {
|
|
4387
|
+
return (await encodeText(body)).byteLength;
|
|
4388
|
+
}
|
|
4389
|
+
};
|
|
4390
|
+
|
|
4391
|
+
const resolveBodyLength = async (headers, body) => {
|
|
4392
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
4393
|
+
|
|
4394
|
+
return length == null ? getBodyLength(body) : length;
|
|
4395
|
+
};
|
|
4396
|
+
|
|
4397
|
+
var fetchAdapter = isFetchSupported && (async (config) => {
|
|
4398
|
+
let {
|
|
4399
|
+
url,
|
|
4400
|
+
method,
|
|
4401
|
+
data,
|
|
4402
|
+
signal,
|
|
4403
|
+
cancelToken,
|
|
4404
|
+
timeout,
|
|
4405
|
+
onDownloadProgress,
|
|
4406
|
+
onUploadProgress,
|
|
4407
|
+
responseType,
|
|
4408
|
+
headers,
|
|
4409
|
+
withCredentials = 'same-origin',
|
|
4410
|
+
fetchOptions
|
|
4411
|
+
} = resolveConfig(config);
|
|
4412
|
+
|
|
4413
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
4414
|
+
|
|
4415
|
+
let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
|
|
4416
|
+
composeSignals$1([signal, cancelToken], timeout) : [];
|
|
4417
|
+
|
|
4418
|
+
let finished, request;
|
|
4419
|
+
|
|
4420
|
+
const onFinish = () => {
|
|
4421
|
+
!finished && setTimeout(() => {
|
|
4422
|
+
composedSignal && composedSignal.unsubscribe();
|
|
4423
|
+
});
|
|
4424
|
+
|
|
4425
|
+
finished = true;
|
|
4426
|
+
};
|
|
4427
|
+
|
|
4428
|
+
let requestContentLength;
|
|
4429
|
+
|
|
4430
|
+
try {
|
|
4431
|
+
if (
|
|
4432
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
4433
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
4434
|
+
) {
|
|
4435
|
+
let _request = new Request(url, {
|
|
4436
|
+
method: 'POST',
|
|
4437
|
+
body: data,
|
|
4438
|
+
duplex: "half"
|
|
4439
|
+
});
|
|
4440
|
+
|
|
4441
|
+
let contentTypeHeader;
|
|
4442
|
+
|
|
4443
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
4444
|
+
headers.setContentType(contentTypeHeader);
|
|
4445
|
+
}
|
|
4446
|
+
|
|
4447
|
+
if (_request.body) {
|
|
4448
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
|
|
4449
|
+
requestContentLength,
|
|
4450
|
+
progressEventReducer(onUploadProgress)
|
|
4451
|
+
), null, encodeText);
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4454
|
+
|
|
4455
|
+
if (!utils$1.isString(withCredentials)) {
|
|
4456
|
+
withCredentials = withCredentials ? 'cors' : 'omit';
|
|
4457
|
+
}
|
|
4458
|
+
|
|
4459
|
+
request = new Request(url, {
|
|
4460
|
+
...fetchOptions,
|
|
4461
|
+
signal: composedSignal,
|
|
4462
|
+
method: method.toUpperCase(),
|
|
4463
|
+
headers: headers.normalize().toJSON(),
|
|
4464
|
+
body: data,
|
|
4465
|
+
duplex: "half",
|
|
4466
|
+
withCredentials
|
|
4467
|
+
});
|
|
4468
|
+
|
|
4469
|
+
let response = await fetch(request);
|
|
4470
|
+
|
|
4471
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
4472
|
+
|
|
4473
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
|
4474
|
+
const options = {};
|
|
4475
|
+
|
|
4476
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
4477
|
+
options[prop] = response[prop];
|
|
4478
|
+
});
|
|
4479
|
+
|
|
4480
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
4481
|
+
|
|
4482
|
+
response = new Response(
|
|
4483
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
|
|
4484
|
+
responseContentLength,
|
|
4485
|
+
progressEventReducer(onDownloadProgress, true)
|
|
4486
|
+
), isStreamResponse && onFinish, encodeText),
|
|
4487
|
+
options
|
|
4488
|
+
);
|
|
4489
|
+
}
|
|
4490
|
+
|
|
4491
|
+
responseType = responseType || 'text';
|
|
4492
|
+
|
|
4493
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
4494
|
+
|
|
4495
|
+
!isStreamResponse && onFinish();
|
|
4496
|
+
|
|
4497
|
+
stopTimeout && stopTimeout();
|
|
4498
|
+
|
|
4499
|
+
return await new Promise((resolve, reject) => {
|
|
4500
|
+
settle(resolve, reject, {
|
|
4501
|
+
data: responseData,
|
|
4502
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
4503
|
+
status: response.status,
|
|
4504
|
+
statusText: response.statusText,
|
|
4505
|
+
config,
|
|
4506
|
+
request
|
|
4507
|
+
});
|
|
4508
|
+
})
|
|
4509
|
+
} catch (err) {
|
|
4510
|
+
onFinish();
|
|
4511
|
+
|
|
4512
|
+
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
4513
|
+
throw Object.assign(
|
|
4514
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
4515
|
+
{
|
|
4516
|
+
cause: err.cause || err
|
|
4517
|
+
}
|
|
4518
|
+
)
|
|
4519
|
+
}
|
|
4520
|
+
|
|
4521
|
+
throw AxiosError.from(err, err && err.code, config, request);
|
|
4522
|
+
}
|
|
4523
|
+
});
|
|
4524
|
+
|
|
4047
4525
|
const knownAdapters = {
|
|
4048
4526
|
http: httpAdapter$1,
|
|
4049
|
-
xhr: xhrAdapter
|
|
4527
|
+
xhr: xhrAdapter,
|
|
4528
|
+
fetch: fetchAdapter
|
|
4050
4529
|
};
|
|
4051
4530
|
|
|
4052
4531
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
@@ -4190,109 +4669,7 @@ function dispatchRequest(config) {
|
|
|
4190
4669
|
});
|
|
4191
4670
|
}
|
|
4192
4671
|
|
|
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";
|
|
4672
|
+
const VERSION = "1.7.2";
|
|
4296
4673
|
|
|
4297
4674
|
const validators$1 = {};
|
|
4298
4675
|
|
|
@@ -4407,7 +4784,34 @@ class Axios {
|
|
|
4407
4784
|
*
|
|
4408
4785
|
* @returns {Promise} The Promise to be fulfilled
|
|
4409
4786
|
*/
|
|
4410
|
-
request(configOrUrl, config) {
|
|
4787
|
+
async request(configOrUrl, config) {
|
|
4788
|
+
try {
|
|
4789
|
+
return await this._request(configOrUrl, config);
|
|
4790
|
+
} catch (err) {
|
|
4791
|
+
if (err instanceof Error) {
|
|
4792
|
+
let dummy;
|
|
4793
|
+
|
|
4794
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
|
|
4795
|
+
|
|
4796
|
+
// slice off the Error: ... line
|
|
4797
|
+
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
|
4798
|
+
try {
|
|
4799
|
+
if (!err.stack) {
|
|
4800
|
+
err.stack = stack;
|
|
4801
|
+
// match without the 2 top stack lines
|
|
4802
|
+
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
|
4803
|
+
err.stack += '\n' + stack;
|
|
4804
|
+
}
|
|
4805
|
+
} catch (e) {
|
|
4806
|
+
// ignore the case where "stack" is an un-writable property
|
|
4807
|
+
}
|
|
4808
|
+
}
|
|
4809
|
+
|
|
4810
|
+
throw err;
|
|
4811
|
+
}
|
|
4812
|
+
}
|
|
4813
|
+
|
|
4814
|
+
_request(configOrUrl, config) {
|
|
4411
4815
|
/*eslint no-param-reassign:0*/
|
|
4412
4816
|
// Allow for axios('example/url'[, config]) a la fetch API
|
|
4413
4817
|
if (typeof configOrUrl === 'string') {
|
|
@@ -5119,20 +5523,32 @@ function copyBuffer (cur) {
|
|
|
5119
5523
|
|
|
5120
5524
|
function rfdc (opts) {
|
|
5121
5525
|
opts = opts || {};
|
|
5122
|
-
|
|
5123
5526
|
if (opts.circles) return rfdcCircles(opts)
|
|
5527
|
+
|
|
5528
|
+
const constructorHandlers = new Map();
|
|
5529
|
+
constructorHandlers.set(Date, (o) => new Date(o));
|
|
5530
|
+
constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
|
|
5531
|
+
constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
|
|
5532
|
+
if (opts.constructorHandlers) {
|
|
5533
|
+
for (const handler of opts.constructorHandlers) {
|
|
5534
|
+
constructorHandlers.set(handler[0], handler[1]);
|
|
5535
|
+
}
|
|
5536
|
+
}
|
|
5537
|
+
|
|
5538
|
+
let handler = null;
|
|
5539
|
+
|
|
5124
5540
|
return opts.proto ? cloneProto : clone
|
|
5125
5541
|
|
|
5126
5542
|
function cloneArray (a, fn) {
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
for (
|
|
5130
|
-
|
|
5131
|
-
|
|
5543
|
+
const keys = Object.keys(a);
|
|
5544
|
+
const a2 = new Array(keys.length);
|
|
5545
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5546
|
+
const k = keys[i];
|
|
5547
|
+
const cur = a[k];
|
|
5132
5548
|
if (typeof cur !== 'object' || cur === null) {
|
|
5133
5549
|
a2[k] = cur;
|
|
5134
|
-
} else if (cur
|
|
5135
|
-
a2[k] =
|
|
5550
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5551
|
+
a2[k] = handler(cur, fn);
|
|
5136
5552
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5137
5553
|
a2[k] = copyBuffer(cur);
|
|
5138
5554
|
} else {
|
|
@@ -5144,22 +5560,18 @@ function rfdc (opts) {
|
|
|
5144
5560
|
|
|
5145
5561
|
function clone (o) {
|
|
5146
5562
|
if (typeof o !== 'object' || o === null) return o
|
|
5147
|
-
if (o instanceof Date) return new Date(o)
|
|
5148
5563
|
if (Array.isArray(o)) return cloneArray(o, clone)
|
|
5149
|
-
if (o
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5564
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
|
|
5565
|
+
return handler(o, clone)
|
|
5566
|
+
}
|
|
5567
|
+
const o2 = {};
|
|
5568
|
+
for (const k in o) {
|
|
5153
5569
|
if (Object.hasOwnProperty.call(o, k) === false) continue
|
|
5154
|
-
|
|
5570
|
+
const cur = o[k];
|
|
5155
5571
|
if (typeof cur !== 'object' || cur === null) {
|
|
5156
5572
|
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));
|
|
5573
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5574
|
+
o2[k] = handler(cur, clone);
|
|
5163
5575
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5164
5576
|
o2[k] = copyBuffer(cur);
|
|
5165
5577
|
} else {
|
|
@@ -5171,21 +5583,17 @@ function rfdc (opts) {
|
|
|
5171
5583
|
|
|
5172
5584
|
function cloneProto (o) {
|
|
5173
5585
|
if (typeof o !== 'object' || o === null) return o
|
|
5174
|
-
if (o instanceof Date) return new Date(o)
|
|
5175
5586
|
if (Array.isArray(o)) return cloneArray(o, cloneProto)
|
|
5176
|
-
if (o
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5587
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
|
|
5588
|
+
return handler(o, cloneProto)
|
|
5589
|
+
}
|
|
5590
|
+
const o2 = {};
|
|
5591
|
+
for (const k in o) {
|
|
5592
|
+
const cur = o[k];
|
|
5181
5593
|
if (typeof cur !== 'object' || cur === null) {
|
|
5182
5594
|
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));
|
|
5595
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5596
|
+
o2[k] = handler(cur, cloneProto);
|
|
5189
5597
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5190
5598
|
o2[k] = copyBuffer(cur);
|
|
5191
5599
|
} else {
|
|
@@ -5197,25 +5605,36 @@ function rfdc (opts) {
|
|
|
5197
5605
|
}
|
|
5198
5606
|
|
|
5199
5607
|
function rfdcCircles (opts) {
|
|
5200
|
-
|
|
5201
|
-
|
|
5608
|
+
const refs = [];
|
|
5609
|
+
const refsNew = [];
|
|
5202
5610
|
|
|
5611
|
+
const constructorHandlers = new Map();
|
|
5612
|
+
constructorHandlers.set(Date, (o) => new Date(o));
|
|
5613
|
+
constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
|
|
5614
|
+
constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
|
|
5615
|
+
if (opts.constructorHandlers) {
|
|
5616
|
+
for (const handler of opts.constructorHandlers) {
|
|
5617
|
+
constructorHandlers.set(handler[0], handler[1]);
|
|
5618
|
+
}
|
|
5619
|
+
}
|
|
5620
|
+
|
|
5621
|
+
let handler = null;
|
|
5203
5622
|
return opts.proto ? cloneProto : clone
|
|
5204
5623
|
|
|
5205
5624
|
function cloneArray (a, fn) {
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
for (
|
|
5209
|
-
|
|
5210
|
-
|
|
5625
|
+
const keys = Object.keys(a);
|
|
5626
|
+
const a2 = new Array(keys.length);
|
|
5627
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5628
|
+
const k = keys[i];
|
|
5629
|
+
const cur = a[k];
|
|
5211
5630
|
if (typeof cur !== 'object' || cur === null) {
|
|
5212
5631
|
a2[k] = cur;
|
|
5213
|
-
} else if (cur
|
|
5214
|
-
a2[k] =
|
|
5632
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5633
|
+
a2[k] = handler(cur, fn);
|
|
5215
5634
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5216
5635
|
a2[k] = copyBuffer(cur);
|
|
5217
5636
|
} else {
|
|
5218
|
-
|
|
5637
|
+
const index = refs.indexOf(cur);
|
|
5219
5638
|
if (index !== -1) {
|
|
5220
5639
|
a2[k] = refsNew[index];
|
|
5221
5640
|
} else {
|
|
@@ -5228,28 +5647,24 @@ function rfdcCircles (opts) {
|
|
|
5228
5647
|
|
|
5229
5648
|
function clone (o) {
|
|
5230
5649
|
if (typeof o !== 'object' || o === null) return o
|
|
5231
|
-
if (o instanceof Date) return new Date(o)
|
|
5232
5650
|
if (Array.isArray(o)) return cloneArray(o, clone)
|
|
5233
|
-
if (o
|
|
5234
|
-
|
|
5235
|
-
|
|
5651
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
|
|
5652
|
+
return handler(o, clone)
|
|
5653
|
+
}
|
|
5654
|
+
const o2 = {};
|
|
5236
5655
|
refs.push(o);
|
|
5237
5656
|
refsNew.push(o2);
|
|
5238
|
-
for (
|
|
5657
|
+
for (const k in o) {
|
|
5239
5658
|
if (Object.hasOwnProperty.call(o, k) === false) continue
|
|
5240
|
-
|
|
5659
|
+
const cur = o[k];
|
|
5241
5660
|
if (typeof cur !== 'object' || cur === null) {
|
|
5242
5661
|
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));
|
|
5662
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5663
|
+
o2[k] = handler(cur, clone);
|
|
5249
5664
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5250
5665
|
o2[k] = copyBuffer(cur);
|
|
5251
5666
|
} else {
|
|
5252
|
-
|
|
5667
|
+
const i = refs.indexOf(cur);
|
|
5253
5668
|
if (i !== -1) {
|
|
5254
5669
|
o2[k] = refsNew[i];
|
|
5255
5670
|
} else {
|
|
@@ -5264,27 +5679,23 @@ function rfdcCircles (opts) {
|
|
|
5264
5679
|
|
|
5265
5680
|
function cloneProto (o) {
|
|
5266
5681
|
if (typeof o !== 'object' || o === null) return o
|
|
5267
|
-
if (o instanceof Date) return new Date(o)
|
|
5268
5682
|
if (Array.isArray(o)) return cloneArray(o, cloneProto)
|
|
5269
|
-
if (o
|
|
5270
|
-
|
|
5271
|
-
|
|
5683
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
|
|
5684
|
+
return handler(o, cloneProto)
|
|
5685
|
+
}
|
|
5686
|
+
const o2 = {};
|
|
5272
5687
|
refs.push(o);
|
|
5273
5688
|
refsNew.push(o2);
|
|
5274
|
-
for (
|
|
5275
|
-
|
|
5689
|
+
for (const k in o) {
|
|
5690
|
+
const cur = o[k];
|
|
5276
5691
|
if (typeof cur !== 'object' || cur === null) {
|
|
5277
5692
|
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));
|
|
5693
|
+
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
|
|
5694
|
+
o2[k] = handler(cur, cloneProto);
|
|
5284
5695
|
} else if (ArrayBuffer.isView(cur)) {
|
|
5285
5696
|
o2[k] = copyBuffer(cur);
|
|
5286
5697
|
} else {
|
|
5287
|
-
|
|
5698
|
+
const i = refs.indexOf(cur);
|
|
5288
5699
|
if (i !== -1) {
|
|
5289
5700
|
o2[k] = refsNew[i];
|
|
5290
5701
|
} else {
|