@kontent-ai/core-sdk 10.6.0 → 10.8.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/dist/cjs/sdk-info.generated.js +1 -1
- package/dist/es6/sdk-info.generated.js +1 -1
- package/dist/esnext/sdk-info.generated.js +1 -1
- package/dist/umd/kontent-core.umd.js +251 -136
- package/dist/umd/kontent-core.umd.js.map +1 -1
- package/dist/umd/kontent-core.umd.min.js +1 -1
- package/dist/umd/kontent-core.umd.min.js.map +1 -1
- package/dist/umd/report.json +1 -1
- package/dist/umd/report.min.json +1 -1
- package/dist/umd/stats.json +28 -28
- package/dist/umd/stats.min.json +28 -28
- package/lib/sdk-info.generated.ts +1 -1
- package/package.json +19 -15
|
@@ -899,7 +899,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
899
899
|
\***************************************************/
|
|
900
900
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
901
901
|
|
|
902
|
-
// Axios v1.7.
|
|
902
|
+
// Axios v1.7.7 Copyright (c) 2024 Matt Zabriskie and contributors
|
|
903
903
|
|
|
904
904
|
|
|
905
905
|
function bind(fn, thisArg) {
|
|
@@ -1575,6 +1575,36 @@ const isAsyncFn = kindOfTest('AsyncFunction');
|
|
|
1575
1575
|
const isThenable = (thing) =>
|
|
1576
1576
|
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
1577
1577
|
|
|
1578
|
+
// original code
|
|
1579
|
+
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
1580
|
+
|
|
1581
|
+
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
1582
|
+
if (setImmediateSupported) {
|
|
1583
|
+
return setImmediate;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
return postMessageSupported ? ((token, callbacks) => {
|
|
1587
|
+
_global.addEventListener("message", ({source, data}) => {
|
|
1588
|
+
if (source === _global && data === token) {
|
|
1589
|
+
callbacks.length && callbacks.shift()();
|
|
1590
|
+
}
|
|
1591
|
+
}, false);
|
|
1592
|
+
|
|
1593
|
+
return (cb) => {
|
|
1594
|
+
callbacks.push(cb);
|
|
1595
|
+
_global.postMessage(token, "*");
|
|
1596
|
+
}
|
|
1597
|
+
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
1598
|
+
})(
|
|
1599
|
+
typeof setImmediate === 'function',
|
|
1600
|
+
isFunction(_global.postMessage)
|
|
1601
|
+
);
|
|
1602
|
+
|
|
1603
|
+
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
1604
|
+
queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
|
|
1605
|
+
|
|
1606
|
+
// *********************
|
|
1607
|
+
|
|
1578
1608
|
var utils$1 = {
|
|
1579
1609
|
isArray,
|
|
1580
1610
|
isArrayBuffer,
|
|
@@ -1630,7 +1660,9 @@ var utils$1 = {
|
|
|
1630
1660
|
isSpecCompliantForm,
|
|
1631
1661
|
toJSONObject,
|
|
1632
1662
|
isAsyncFn,
|
|
1633
|
-
isThenable
|
|
1663
|
+
isThenable,
|
|
1664
|
+
setImmediate: _setImmediate,
|
|
1665
|
+
asap
|
|
1634
1666
|
};
|
|
1635
1667
|
|
|
1636
1668
|
/**
|
|
@@ -1658,7 +1690,10 @@ function AxiosError(message, code, config, request, response) {
|
|
|
1658
1690
|
code && (this.code = code);
|
|
1659
1691
|
config && (this.config = config);
|
|
1660
1692
|
request && (this.request = request);
|
|
1661
|
-
|
|
1693
|
+
if (response) {
|
|
1694
|
+
this.response = response;
|
|
1695
|
+
this.status = response.status ? response.status : null;
|
|
1696
|
+
}
|
|
1662
1697
|
}
|
|
1663
1698
|
|
|
1664
1699
|
utils$1.inherits(AxiosError, Error, {
|
|
@@ -1678,7 +1713,7 @@ utils$1.inherits(AxiosError, Error, {
|
|
|
1678
1713
|
// Axios
|
|
1679
1714
|
config: utils$1.toJSONObject(this.config),
|
|
1680
1715
|
code: this.code,
|
|
1681
|
-
status: this.
|
|
1716
|
+
status: this.status
|
|
1682
1717
|
};
|
|
1683
1718
|
}
|
|
1684
1719
|
});
|
|
@@ -2146,6 +2181,8 @@ var platform$1 = {
|
|
|
2146
2181
|
|
|
2147
2182
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2148
2183
|
|
|
2184
|
+
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
2185
|
+
|
|
2149
2186
|
/**
|
|
2150
2187
|
* Determine if we're running in a standard browser environment
|
|
2151
2188
|
*
|
|
@@ -2163,10 +2200,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
|
|
|
2163
2200
|
*
|
|
2164
2201
|
* @returns {boolean}
|
|
2165
2202
|
*/
|
|
2166
|
-
const hasStandardBrowserEnv =
|
|
2167
|
-
(product)
|
|
2168
|
-
return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
|
|
2169
|
-
})(typeof navigator !== 'undefined' && navigator.product);
|
|
2203
|
+
const hasStandardBrowserEnv = hasBrowserEnv &&
|
|
2204
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
2170
2205
|
|
|
2171
2206
|
/**
|
|
2172
2207
|
* Determine if we're running in a standard browser webWorker environment
|
|
@@ -2193,6 +2228,7 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
2193
2228
|
hasBrowserEnv: hasBrowserEnv,
|
|
2194
2229
|
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
2195
2230
|
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
2231
|
+
navigator: _navigator,
|
|
2196
2232
|
origin: origin
|
|
2197
2233
|
});
|
|
2198
2234
|
|
|
@@ -2941,31 +2977,42 @@ function speedometer(samplesCount, min) {
|
|
|
2941
2977
|
*/
|
|
2942
2978
|
function throttle(fn, freq) {
|
|
2943
2979
|
let timestamp = 0;
|
|
2944
|
-
|
|
2945
|
-
let
|
|
2946
|
-
|
|
2947
|
-
|
|
2980
|
+
let threshold = 1000 / freq;
|
|
2981
|
+
let lastArgs;
|
|
2982
|
+
let timer;
|
|
2983
|
+
|
|
2984
|
+
const invoke = (args, now = Date.now()) => {
|
|
2985
|
+
timestamp = now;
|
|
2986
|
+
lastArgs = null;
|
|
2987
|
+
if (timer) {
|
|
2988
|
+
clearTimeout(timer);
|
|
2989
|
+
timer = null;
|
|
2990
|
+
}
|
|
2991
|
+
fn.apply(null, args);
|
|
2992
|
+
};
|
|
2948
2993
|
|
|
2994
|
+
const throttled = (...args) => {
|
|
2949
2995
|
const now = Date.now();
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2996
|
+
const passed = now - timestamp;
|
|
2997
|
+
if ( passed >= threshold) {
|
|
2998
|
+
invoke(args, now);
|
|
2999
|
+
} else {
|
|
3000
|
+
lastArgs = args;
|
|
3001
|
+
if (!timer) {
|
|
3002
|
+
timer = setTimeout(() => {
|
|
3003
|
+
timer = null;
|
|
3004
|
+
invoke(lastArgs);
|
|
3005
|
+
}, threshold - passed);
|
|
2954
3006
|
}
|
|
2955
|
-
timestamp = now;
|
|
2956
|
-
return fn.apply(null, arguments);
|
|
2957
|
-
}
|
|
2958
|
-
if (!timer) {
|
|
2959
|
-
timer = setTimeout(() => {
|
|
2960
|
-
timer = null;
|
|
2961
|
-
timestamp = Date.now();
|
|
2962
|
-
return fn.apply(null, arguments);
|
|
2963
|
-
}, threshold - (now - timestamp));
|
|
2964
3007
|
}
|
|
2965
3008
|
};
|
|
3009
|
+
|
|
3010
|
+
const flush = () => lastArgs && invoke(lastArgs);
|
|
3011
|
+
|
|
3012
|
+
return [throttled, flush];
|
|
2966
3013
|
}
|
|
2967
3014
|
|
|
2968
|
-
|
|
3015
|
+
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
2969
3016
|
let bytesNotified = 0;
|
|
2970
3017
|
const _speedometer = speedometer(50, 250);
|
|
2971
3018
|
|
|
@@ -2986,21 +3033,32 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2986
3033
|
rate: rate ? rate : undefined,
|
|
2987
3034
|
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
2988
3035
|
event: e,
|
|
2989
|
-
lengthComputable: total != null
|
|
3036
|
+
lengthComputable: total != null,
|
|
3037
|
+
[isDownloadStream ? 'download' : 'upload']: true
|
|
2990
3038
|
};
|
|
2991
3039
|
|
|
2992
|
-
data[isDownloadStream ? 'download' : 'upload'] = true;
|
|
2993
|
-
|
|
2994
3040
|
listener(data);
|
|
2995
3041
|
}, freq);
|
|
2996
3042
|
};
|
|
2997
3043
|
|
|
3044
|
+
const progressEventDecorator = (total, throttled) => {
|
|
3045
|
+
const lengthComputable = total != null;
|
|
3046
|
+
|
|
3047
|
+
return [(loaded) => throttled[0]({
|
|
3048
|
+
lengthComputable,
|
|
3049
|
+
total,
|
|
3050
|
+
loaded
|
|
3051
|
+
}), throttled[1]];
|
|
3052
|
+
};
|
|
3053
|
+
|
|
3054
|
+
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
3055
|
+
|
|
2998
3056
|
var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
2999
3057
|
|
|
3000
3058
|
// Standard browser envs have full support of the APIs needed to test
|
|
3001
3059
|
// whether the request URL is of the same origin as current location.
|
|
3002
3060
|
(function standardBrowserEnv() {
|
|
3003
|
-
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
3061
|
+
const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
|
|
3004
3062
|
const urlParsingNode = document.createElement('a');
|
|
3005
3063
|
let originURL;
|
|
3006
3064
|
|
|
@@ -3299,16 +3357,18 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3299
3357
|
const _config = resolveConfig(config);
|
|
3300
3358
|
let requestData = _config.data;
|
|
3301
3359
|
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
3302
|
-
let {responseType} = _config;
|
|
3360
|
+
let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
|
3303
3361
|
let onCanceled;
|
|
3362
|
+
let uploadThrottled, downloadThrottled;
|
|
3363
|
+
let flushUpload, flushDownload;
|
|
3364
|
+
|
|
3304
3365
|
function done() {
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
}
|
|
3366
|
+
flushUpload && flushUpload(); // flush events
|
|
3367
|
+
flushDownload && flushDownload(); // flush events
|
|
3308
3368
|
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3369
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
3370
|
+
|
|
3371
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
3312
3372
|
}
|
|
3313
3373
|
|
|
3314
3374
|
let request = new XMLHttpRequest();
|
|
@@ -3378,7 +3438,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3378
3438
|
return;
|
|
3379
3439
|
}
|
|
3380
3440
|
|
|
3381
|
-
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED,
|
|
3441
|
+
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
3382
3442
|
|
|
3383
3443
|
// Clean up request
|
|
3384
3444
|
request = null;
|
|
@@ -3388,7 +3448,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3388
3448
|
request.onerror = function handleError() {
|
|
3389
3449
|
// Real errors are hidden from us by the browser
|
|
3390
3450
|
// onerror should only fire if it's a network error
|
|
3391
|
-
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK,
|
|
3451
|
+
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
|
|
3392
3452
|
|
|
3393
3453
|
// Clean up request
|
|
3394
3454
|
request = null;
|
|
@@ -3404,7 +3464,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3404
3464
|
reject(new AxiosError(
|
|
3405
3465
|
timeoutErrorMessage,
|
|
3406
3466
|
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
3407
|
-
|
|
3467
|
+
config,
|
|
3408
3468
|
request));
|
|
3409
3469
|
|
|
3410
3470
|
// Clean up request
|
|
@@ -3432,13 +3492,18 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3432
3492
|
}
|
|
3433
3493
|
|
|
3434
3494
|
// Handle progress if needed
|
|
3435
|
-
if (
|
|
3436
|
-
|
|
3495
|
+
if (onDownloadProgress) {
|
|
3496
|
+
([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
|
|
3497
|
+
request.addEventListener('progress', downloadThrottled);
|
|
3437
3498
|
}
|
|
3438
3499
|
|
|
3439
3500
|
// Not all browsers support upload events
|
|
3440
|
-
if (
|
|
3441
|
-
|
|
3501
|
+
if (onUploadProgress && request.upload) {
|
|
3502
|
+
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
3503
|
+
|
|
3504
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
3505
|
+
|
|
3506
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
3442
3507
|
}
|
|
3443
3508
|
|
|
3444
3509
|
if (_config.cancelToken || _config.signal) {
|
|
@@ -3473,45 +3538,46 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3473
3538
|
};
|
|
3474
3539
|
|
|
3475
3540
|
const composeSignals = (signals, timeout) => {
|
|
3476
|
-
|
|
3541
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
3477
3542
|
|
|
3478
|
-
|
|
3543
|
+
if (timeout || length) {
|
|
3544
|
+
let controller = new AbortController();
|
|
3479
3545
|
|
|
3480
|
-
|
|
3481
|
-
if (!aborted) {
|
|
3482
|
-
aborted = true;
|
|
3483
|
-
unsubscribe();
|
|
3484
|
-
const err = cancel instanceof Error ? cancel : this.reason;
|
|
3485
|
-
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
3486
|
-
}
|
|
3487
|
-
};
|
|
3546
|
+
let aborted;
|
|
3488
3547
|
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3548
|
+
const onabort = function (reason) {
|
|
3549
|
+
if (!aborted) {
|
|
3550
|
+
aborted = true;
|
|
3551
|
+
unsubscribe();
|
|
3552
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
3553
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3492
3556
|
|
|
3493
|
-
|
|
3494
|
-
if (signals) {
|
|
3495
|
-
timer && clearTimeout(timer);
|
|
3557
|
+
let timer = timeout && setTimeout(() => {
|
|
3496
3558
|
timer = null;
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
(signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
|
|
3500
|
-
});
|
|
3501
|
-
signals = null;
|
|
3502
|
-
}
|
|
3503
|
-
};
|
|
3559
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
3560
|
+
}, timeout);
|
|
3504
3561
|
|
|
3505
|
-
|
|
3562
|
+
const unsubscribe = () => {
|
|
3563
|
+
if (signals) {
|
|
3564
|
+
timer && clearTimeout(timer);
|
|
3565
|
+
timer = null;
|
|
3566
|
+
signals.forEach(signal => {
|
|
3567
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
|
3568
|
+
});
|
|
3569
|
+
signals = null;
|
|
3570
|
+
}
|
|
3571
|
+
};
|
|
3572
|
+
|
|
3573
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
3506
3574
|
|
|
3507
|
-
|
|
3575
|
+
const {signal} = controller;
|
|
3508
3576
|
|
|
3509
|
-
|
|
3577
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
3510
3578
|
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
timer = null;
|
|
3514
|
-
}];
|
|
3579
|
+
return signal;
|
|
3580
|
+
}
|
|
3515
3581
|
};
|
|
3516
3582
|
|
|
3517
3583
|
var composeSignals$1 = composeSignals;
|
|
@@ -3534,35 +3600,68 @@ const streamChunk = function* (chunk, chunkSize) {
|
|
|
3534
3600
|
}
|
|
3535
3601
|
};
|
|
3536
3602
|
|
|
3537
|
-
const readBytes = async function* (iterable, chunkSize
|
|
3538
|
-
for await (const chunk of iterable) {
|
|
3539
|
-
yield* streamChunk(
|
|
3603
|
+
const readBytes = async function* (iterable, chunkSize) {
|
|
3604
|
+
for await (const chunk of readStream(iterable)) {
|
|
3605
|
+
yield* streamChunk(chunk, chunkSize);
|
|
3540
3606
|
}
|
|
3541
3607
|
};
|
|
3542
3608
|
|
|
3543
|
-
const
|
|
3544
|
-
|
|
3609
|
+
const readStream = async function* (stream) {
|
|
3610
|
+
if (stream[Symbol.asyncIterator]) {
|
|
3611
|
+
yield* stream;
|
|
3612
|
+
return;
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3615
|
+
const reader = stream.getReader();
|
|
3616
|
+
try {
|
|
3617
|
+
for (;;) {
|
|
3618
|
+
const {done, value} = await reader.read();
|
|
3619
|
+
if (done) {
|
|
3620
|
+
break;
|
|
3621
|
+
}
|
|
3622
|
+
yield value;
|
|
3623
|
+
}
|
|
3624
|
+
} finally {
|
|
3625
|
+
await reader.cancel();
|
|
3626
|
+
}
|
|
3627
|
+
};
|
|
3628
|
+
|
|
3629
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
3630
|
+
const iterator = readBytes(stream, chunkSize);
|
|
3545
3631
|
|
|
3546
3632
|
let bytes = 0;
|
|
3633
|
+
let done;
|
|
3634
|
+
let _onFinish = (e) => {
|
|
3635
|
+
if (!done) {
|
|
3636
|
+
done = true;
|
|
3637
|
+
onFinish && onFinish(e);
|
|
3638
|
+
}
|
|
3639
|
+
};
|
|
3547
3640
|
|
|
3548
3641
|
return new ReadableStream({
|
|
3549
|
-
type: 'bytes',
|
|
3550
|
-
|
|
3551
3642
|
async pull(controller) {
|
|
3552
|
-
|
|
3643
|
+
try {
|
|
3644
|
+
const {done, value} = await iterator.next();
|
|
3553
3645
|
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3646
|
+
if (done) {
|
|
3647
|
+
_onFinish();
|
|
3648
|
+
controller.close();
|
|
3649
|
+
return;
|
|
3650
|
+
}
|
|
3559
3651
|
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3652
|
+
let len = value.byteLength;
|
|
3653
|
+
if (onProgress) {
|
|
3654
|
+
let loadedBytes = bytes += len;
|
|
3655
|
+
onProgress(loadedBytes);
|
|
3656
|
+
}
|
|
3657
|
+
controller.enqueue(new Uint8Array(value));
|
|
3658
|
+
} catch (err) {
|
|
3659
|
+
_onFinish(err);
|
|
3660
|
+
throw err;
|
|
3661
|
+
}
|
|
3563
3662
|
},
|
|
3564
3663
|
cancel(reason) {
|
|
3565
|
-
|
|
3664
|
+
_onFinish(reason);
|
|
3566
3665
|
return iterator.return();
|
|
3567
3666
|
}
|
|
3568
3667
|
}, {
|
|
@@ -3570,15 +3669,6 @@ const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
|
|
3570
3669
|
})
|
|
3571
3670
|
};
|
|
3572
3671
|
|
|
3573
|
-
const fetchProgressDecorator = (total, fn) => {
|
|
3574
|
-
const lengthComputable = total != null;
|
|
3575
|
-
return (loaded) => setTimeout(() => fn({
|
|
3576
|
-
lengthComputable,
|
|
3577
|
-
total,
|
|
3578
|
-
loaded
|
|
3579
|
-
}));
|
|
3580
|
-
};
|
|
3581
|
-
|
|
3582
3672
|
const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
|
|
3583
3673
|
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
|
|
3584
3674
|
|
|
@@ -3588,7 +3678,15 @@ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
|
3588
3678
|
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
3589
3679
|
);
|
|
3590
3680
|
|
|
3591
|
-
const
|
|
3681
|
+
const test = (fn, ...args) => {
|
|
3682
|
+
try {
|
|
3683
|
+
return !!fn(...args);
|
|
3684
|
+
} catch (e) {
|
|
3685
|
+
return false
|
|
3686
|
+
}
|
|
3687
|
+
};
|
|
3688
|
+
|
|
3689
|
+
const supportsRequestStream = isReadableStreamSupported && test(() => {
|
|
3592
3690
|
let duplexAccessed = false;
|
|
3593
3691
|
|
|
3594
3692
|
const hasContentType = new Request(platform.origin, {
|
|
@@ -3601,17 +3699,13 @@ const supportsRequestStream = isReadableStreamSupported && (() => {
|
|
|
3601
3699
|
}).headers.has('Content-Type');
|
|
3602
3700
|
|
|
3603
3701
|
return duplexAccessed && !hasContentType;
|
|
3604
|
-
})
|
|
3702
|
+
});
|
|
3605
3703
|
|
|
3606
3704
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3607
3705
|
|
|
3608
|
-
const supportsResponseStream = isReadableStreamSupported &&
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
} catch(err) {
|
|
3612
|
-
// return undefined
|
|
3613
|
-
}
|
|
3614
|
-
})();
|
|
3706
|
+
const supportsResponseStream = isReadableStreamSupported &&
|
|
3707
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
3708
|
+
|
|
3615
3709
|
|
|
3616
3710
|
const resolvers = {
|
|
3617
3711
|
stream: supportsResponseStream && ((res) => res.body)
|
|
@@ -3636,10 +3730,14 @@ const getBodyLength = async (body) => {
|
|
|
3636
3730
|
}
|
|
3637
3731
|
|
|
3638
3732
|
if(utils$1.isSpecCompliantForm(body)) {
|
|
3639
|
-
|
|
3733
|
+
const _request = new Request(platform.origin, {
|
|
3734
|
+
method: 'POST',
|
|
3735
|
+
body,
|
|
3736
|
+
});
|
|
3737
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
3640
3738
|
}
|
|
3641
3739
|
|
|
3642
|
-
if(utils$1.isArrayBufferView(body)) {
|
|
3740
|
+
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
3643
3741
|
return body.byteLength;
|
|
3644
3742
|
}
|
|
3645
3743
|
|
|
@@ -3676,18 +3774,13 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3676
3774
|
|
|
3677
3775
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3678
3776
|
|
|
3679
|
-
let
|
|
3680
|
-
composeSignals$1([signal, cancelToken], timeout) : [];
|
|
3681
|
-
|
|
3682
|
-
let finished, request;
|
|
3777
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
3683
3778
|
|
|
3684
|
-
|
|
3685
|
-
!finished && setTimeout(() => {
|
|
3686
|
-
composedSignal && composedSignal.unsubscribe();
|
|
3687
|
-
});
|
|
3779
|
+
let request;
|
|
3688
3780
|
|
|
3689
|
-
|
|
3690
|
-
|
|
3781
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
3782
|
+
composedSignal.unsubscribe();
|
|
3783
|
+
});
|
|
3691
3784
|
|
|
3692
3785
|
let requestContentLength;
|
|
3693
3786
|
|
|
@@ -3709,17 +3802,22 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3709
3802
|
}
|
|
3710
3803
|
|
|
3711
3804
|
if (_request.body) {
|
|
3712
|
-
|
|
3805
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
3713
3806
|
requestContentLength,
|
|
3714
|
-
progressEventReducer(onUploadProgress)
|
|
3715
|
-
)
|
|
3807
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
3808
|
+
);
|
|
3809
|
+
|
|
3810
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
3716
3811
|
}
|
|
3717
3812
|
}
|
|
3718
3813
|
|
|
3719
3814
|
if (!utils$1.isString(withCredentials)) {
|
|
3720
|
-
withCredentials = withCredentials ? '
|
|
3815
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
3721
3816
|
}
|
|
3722
3817
|
|
|
3818
|
+
// Cloudflare Workers throws when credentials are defined
|
|
3819
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
3820
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
3723
3821
|
request = new Request(url, {
|
|
3724
3822
|
...fetchOptions,
|
|
3725
3823
|
signal: composedSignal,
|
|
@@ -3727,14 +3825,14 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3727
3825
|
headers: headers.normalize().toJSON(),
|
|
3728
3826
|
body: data,
|
|
3729
3827
|
duplex: "half",
|
|
3730
|
-
withCredentials
|
|
3828
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3731
3829
|
});
|
|
3732
3830
|
|
|
3733
3831
|
let response = await fetch(request);
|
|
3734
3832
|
|
|
3735
3833
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3736
3834
|
|
|
3737
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
|
3835
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
3738
3836
|
const options = {};
|
|
3739
3837
|
|
|
3740
3838
|
['status', 'statusText', 'headers'].forEach(prop => {
|
|
@@ -3743,11 +3841,16 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3743
3841
|
|
|
3744
3842
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3745
3843
|
|
|
3844
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
3845
|
+
responseContentLength,
|
|
3846
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3847
|
+
) || [];
|
|
3848
|
+
|
|
3746
3849
|
response = new Response(
|
|
3747
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE,
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
),
|
|
3850
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
3851
|
+
flush && flush();
|
|
3852
|
+
unsubscribe && unsubscribe();
|
|
3853
|
+
}),
|
|
3751
3854
|
options
|
|
3752
3855
|
);
|
|
3753
3856
|
}
|
|
@@ -3756,9 +3859,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3756
3859
|
|
|
3757
3860
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
3758
3861
|
|
|
3759
|
-
!isStreamResponse &&
|
|
3760
|
-
|
|
3761
|
-
stopTimeout && stopTimeout();
|
|
3862
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3762
3863
|
|
|
3763
3864
|
return await new Promise((resolve, reject) => {
|
|
3764
3865
|
settle(resolve, reject, {
|
|
@@ -3771,7 +3872,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3771
3872
|
});
|
|
3772
3873
|
})
|
|
3773
3874
|
} catch (err) {
|
|
3774
|
-
|
|
3875
|
+
unsubscribe && unsubscribe();
|
|
3775
3876
|
|
|
3776
3877
|
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
3777
3878
|
throw Object.assign(
|
|
@@ -3933,7 +4034,7 @@ function dispatchRequest(config) {
|
|
|
3933
4034
|
});
|
|
3934
4035
|
}
|
|
3935
4036
|
|
|
3936
|
-
const VERSION = "1.7.
|
|
4037
|
+
const VERSION = "1.7.7";
|
|
3937
4038
|
|
|
3938
4039
|
const validators$1 = {};
|
|
3939
4040
|
|
|
@@ -4340,6 +4441,20 @@ class CancelToken {
|
|
|
4340
4441
|
}
|
|
4341
4442
|
}
|
|
4342
4443
|
|
|
4444
|
+
toAbortSignal() {
|
|
4445
|
+
const controller = new AbortController();
|
|
4446
|
+
|
|
4447
|
+
const abort = (err) => {
|
|
4448
|
+
controller.abort(err);
|
|
4449
|
+
};
|
|
4450
|
+
|
|
4451
|
+
this.subscribe(abort);
|
|
4452
|
+
|
|
4453
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
4454
|
+
|
|
4455
|
+
return controller.signal;
|
|
4456
|
+
}
|
|
4457
|
+
|
|
4343
4458
|
/**
|
|
4344
4459
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
4345
4460
|
* cancels the `CancelToken`.
|