axios 1.7.5 → 1.7.6
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.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +14 -0
- package/README.md +4 -3
- package/dist/axios.js +84 -65
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +62 -50
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +62 -50
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +62 -50
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/fetch.js +15 -18
- package/lib/cancel/CancelToken.js +14 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/composeSignals.js +31 -29
- package/package.json +1 -1
package/dist/esm/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.7.
|
1
|
+
// Axios v1.7.6 Copyright (c) 2024 Matt Zabriskie and contributors
|
2
2
|
function bind(fn, thisArg) {
|
3
3
|
return function wrap() {
|
4
4
|
return fn.apply(thisArg, arguments);
|
@@ -2635,45 +2635,46 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
2635
2635
|
};
|
2636
2636
|
|
2637
2637
|
const composeSignals = (signals, timeout) => {
|
2638
|
-
|
2638
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
2639
2639
|
|
2640
|
-
|
2640
|
+
if (timeout || length) {
|
2641
|
+
let controller = new AbortController();
|
2641
2642
|
|
2642
|
-
|
2643
|
-
if (!aborted) {
|
2644
|
-
aborted = true;
|
2645
|
-
unsubscribe();
|
2646
|
-
const err = cancel instanceof Error ? cancel : this.reason;
|
2647
|
-
controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
2648
|
-
}
|
2649
|
-
};
|
2643
|
+
let aborted;
|
2650
2644
|
|
2651
|
-
|
2652
|
-
|
2653
|
-
|
2645
|
+
const onabort = function (reason) {
|
2646
|
+
if (!aborted) {
|
2647
|
+
aborted = true;
|
2648
|
+
unsubscribe();
|
2649
|
+
const err = reason instanceof Error ? reason : this.reason;
|
2650
|
+
controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
2651
|
+
}
|
2652
|
+
};
|
2654
2653
|
|
2655
|
-
|
2656
|
-
if (signals) {
|
2657
|
-
timer && clearTimeout(timer);
|
2654
|
+
let timer = timeout && setTimeout(() => {
|
2658
2655
|
timer = null;
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2662
|
-
|
2663
|
-
signals
|
2664
|
-
|
2665
|
-
|
2656
|
+
onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
|
2657
|
+
}, timeout);
|
2658
|
+
|
2659
|
+
const unsubscribe = () => {
|
2660
|
+
if (signals) {
|
2661
|
+
timer && clearTimeout(timer);
|
2662
|
+
timer = null;
|
2663
|
+
signals.forEach(signal => {
|
2664
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
2665
|
+
});
|
2666
|
+
signals = null;
|
2667
|
+
}
|
2668
|
+
};
|
2666
2669
|
|
2667
|
-
|
2670
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
2668
2671
|
|
2669
|
-
|
2672
|
+
const {signal} = controller;
|
2670
2673
|
|
2671
|
-
|
2674
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
2672
2675
|
|
2673
|
-
|
2674
|
-
|
2675
|
-
timer = null;
|
2676
|
-
}];
|
2676
|
+
return signal;
|
2677
|
+
}
|
2677
2678
|
};
|
2678
2679
|
|
2679
2680
|
const composeSignals$1 = composeSignals;
|
@@ -2806,7 +2807,11 @@ const getBodyLength = async (body) => {
|
|
2806
2807
|
}
|
2807
2808
|
|
2808
2809
|
if(utils$1.isSpecCompliantForm(body)) {
|
2809
|
-
|
2810
|
+
const _request = new Request(platform.origin, {
|
2811
|
+
method: 'POST',
|
2812
|
+
body,
|
2813
|
+
});
|
2814
|
+
return (await _request.arrayBuffer()).byteLength;
|
2810
2815
|
}
|
2811
2816
|
|
2812
2817
|
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
@@ -2846,18 +2851,13 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2846
2851
|
|
2847
2852
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
2848
2853
|
|
2849
|
-
let
|
2850
|
-
composeSignals$1([signal, cancelToken], timeout) : [];
|
2854
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
2851
2855
|
|
2852
|
-
let
|
2856
|
+
let request;
|
2853
2857
|
|
2854
|
-
const
|
2855
|
-
|
2856
|
-
|
2857
|
-
});
|
2858
|
-
|
2859
|
-
finished = true;
|
2860
|
-
};
|
2858
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
2859
|
+
composedSignal.unsubscribe();
|
2860
|
+
});
|
2861
2861
|
|
2862
2862
|
let requestContentLength;
|
2863
2863
|
|
@@ -2894,7 +2894,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2894
2894
|
|
2895
2895
|
// Cloudflare Workers throws when credentials are defined
|
2896
2896
|
// see https://github.com/cloudflare/workerd/issues/902
|
2897
|
-
const isCredentialsSupported = "credentials" in Request.prototype;
|
2897
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
2898
2898
|
request = new Request(url, {
|
2899
2899
|
...fetchOptions,
|
2900
2900
|
signal: composedSignal,
|
@@ -2909,7 +2909,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2909
2909
|
|
2910
2910
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
2911
2911
|
|
2912
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
2912
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
2913
2913
|
const options = {};
|
2914
2914
|
|
2915
2915
|
['status', 'statusText', 'headers'].forEach(prop => {
|
@@ -2926,7 +2926,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2926
2926
|
response = new Response(
|
2927
2927
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
2928
2928
|
flush && flush();
|
2929
|
-
|
2929
|
+
unsubscribe && unsubscribe();
|
2930
2930
|
}, encodeText),
|
2931
2931
|
options
|
2932
2932
|
);
|
@@ -2936,9 +2936,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2936
2936
|
|
2937
2937
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
2938
2938
|
|
2939
|
-
!isStreamResponse &&
|
2940
|
-
|
2941
|
-
stopTimeout && stopTimeout();
|
2939
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
2942
2940
|
|
2943
2941
|
return await new Promise((resolve, reject) => {
|
2944
2942
|
settle(resolve, reject, {
|
@@ -2951,7 +2949,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2951
2949
|
});
|
2952
2950
|
})
|
2953
2951
|
} catch (err) {
|
2954
|
-
|
2952
|
+
unsubscribe && unsubscribe();
|
2955
2953
|
|
2956
2954
|
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
2957
2955
|
throw Object.assign(
|
@@ -3113,7 +3111,7 @@ function dispatchRequest(config) {
|
|
3113
3111
|
});
|
3114
3112
|
}
|
3115
3113
|
|
3116
|
-
const VERSION$1 = "1.7.
|
3114
|
+
const VERSION$1 = "1.7.6";
|
3117
3115
|
|
3118
3116
|
const validators$1 = {};
|
3119
3117
|
|
@@ -3520,6 +3518,20 @@ class CancelToken$1 {
|
|
3520
3518
|
}
|
3521
3519
|
}
|
3522
3520
|
|
3521
|
+
toAbortSignal() {
|
3522
|
+
const controller = new AbortController();
|
3523
|
+
|
3524
|
+
const abort = (err) => {
|
3525
|
+
controller.abort(err);
|
3526
|
+
};
|
3527
|
+
|
3528
|
+
this.subscribe(abort);
|
3529
|
+
|
3530
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
3531
|
+
|
3532
|
+
return controller.signal;
|
3533
|
+
}
|
3534
|
+
|
3523
3535
|
/**
|
3524
3536
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
3525
3537
|
* cancels the `CancelToken`.
|