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/browser/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.7.
|
1
|
+
// Axios v1.7.6 Copyright (c) 2024 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
function bind(fn, thisArg) {
|
@@ -2637,45 +2637,46 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
2637
2637
|
};
|
2638
2638
|
|
2639
2639
|
const composeSignals = (signals, timeout) => {
|
2640
|
-
|
2640
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
2641
2641
|
|
2642
|
-
|
2642
|
+
if (timeout || length) {
|
2643
|
+
let controller = new AbortController();
|
2643
2644
|
|
2644
|
-
|
2645
|
-
if (!aborted) {
|
2646
|
-
aborted = true;
|
2647
|
-
unsubscribe();
|
2648
|
-
const err = cancel instanceof Error ? cancel : this.reason;
|
2649
|
-
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
2650
|
-
}
|
2651
|
-
};
|
2645
|
+
let aborted;
|
2652
2646
|
|
2653
|
-
|
2654
|
-
|
2655
|
-
|
2647
|
+
const onabort = function (reason) {
|
2648
|
+
if (!aborted) {
|
2649
|
+
aborted = true;
|
2650
|
+
unsubscribe();
|
2651
|
+
const err = reason instanceof Error ? reason : this.reason;
|
2652
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
2653
|
+
}
|
2654
|
+
};
|
2656
2655
|
|
2657
|
-
|
2658
|
-
if (signals) {
|
2659
|
-
timer && clearTimeout(timer);
|
2656
|
+
let timer = timeout && setTimeout(() => {
|
2660
2657
|
timer = null;
|
2661
|
-
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2665
|
-
signals
|
2666
|
-
|
2667
|
-
|
2658
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
2659
|
+
}, timeout);
|
2660
|
+
|
2661
|
+
const unsubscribe = () => {
|
2662
|
+
if (signals) {
|
2663
|
+
timer && clearTimeout(timer);
|
2664
|
+
timer = null;
|
2665
|
+
signals.forEach(signal => {
|
2666
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
2667
|
+
});
|
2668
|
+
signals = null;
|
2669
|
+
}
|
2670
|
+
};
|
2668
2671
|
|
2669
|
-
|
2672
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
2670
2673
|
|
2671
|
-
|
2674
|
+
const {signal} = controller;
|
2672
2675
|
|
2673
|
-
|
2676
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
2674
2677
|
|
2675
|
-
|
2676
|
-
|
2677
|
-
timer = null;
|
2678
|
-
}];
|
2678
|
+
return signal;
|
2679
|
+
}
|
2679
2680
|
};
|
2680
2681
|
|
2681
2682
|
var composeSignals$1 = composeSignals;
|
@@ -2808,7 +2809,11 @@ const getBodyLength = async (body) => {
|
|
2808
2809
|
}
|
2809
2810
|
|
2810
2811
|
if(utils$1.isSpecCompliantForm(body)) {
|
2811
|
-
|
2812
|
+
const _request = new Request(platform.origin, {
|
2813
|
+
method: 'POST',
|
2814
|
+
body,
|
2815
|
+
});
|
2816
|
+
return (await _request.arrayBuffer()).byteLength;
|
2812
2817
|
}
|
2813
2818
|
|
2814
2819
|
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
@@ -2848,18 +2853,13 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2848
2853
|
|
2849
2854
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
2850
2855
|
|
2851
|
-
let
|
2852
|
-
composeSignals$1([signal, cancelToken], timeout) : [];
|
2856
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
2853
2857
|
|
2854
|
-
let
|
2858
|
+
let request;
|
2855
2859
|
|
2856
|
-
const
|
2857
|
-
|
2858
|
-
|
2859
|
-
});
|
2860
|
-
|
2861
|
-
finished = true;
|
2862
|
-
};
|
2860
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
2861
|
+
composedSignal.unsubscribe();
|
2862
|
+
});
|
2863
2863
|
|
2864
2864
|
let requestContentLength;
|
2865
2865
|
|
@@ -2896,7 +2896,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2896
2896
|
|
2897
2897
|
// Cloudflare Workers throws when credentials are defined
|
2898
2898
|
// see https://github.com/cloudflare/workerd/issues/902
|
2899
|
-
const isCredentialsSupported = "credentials" in Request.prototype;
|
2899
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
2900
2900
|
request = new Request(url, {
|
2901
2901
|
...fetchOptions,
|
2902
2902
|
signal: composedSignal,
|
@@ -2911,7 +2911,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2911
2911
|
|
2912
2912
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
2913
2913
|
|
2914
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
2914
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
2915
2915
|
const options = {};
|
2916
2916
|
|
2917
2917
|
['status', 'statusText', 'headers'].forEach(prop => {
|
@@ -2928,7 +2928,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2928
2928
|
response = new Response(
|
2929
2929
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
2930
2930
|
flush && flush();
|
2931
|
-
|
2931
|
+
unsubscribe && unsubscribe();
|
2932
2932
|
}, encodeText),
|
2933
2933
|
options
|
2934
2934
|
);
|
@@ -2938,9 +2938,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2938
2938
|
|
2939
2939
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
2940
2940
|
|
2941
|
-
!isStreamResponse &&
|
2942
|
-
|
2943
|
-
stopTimeout && stopTimeout();
|
2941
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
2944
2942
|
|
2945
2943
|
return await new Promise((resolve, reject) => {
|
2946
2944
|
settle(resolve, reject, {
|
@@ -2953,7 +2951,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2953
2951
|
});
|
2954
2952
|
})
|
2955
2953
|
} catch (err) {
|
2956
|
-
|
2954
|
+
unsubscribe && unsubscribe();
|
2957
2955
|
|
2958
2956
|
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
2959
2957
|
throw Object.assign(
|
@@ -3115,7 +3113,7 @@ function dispatchRequest(config) {
|
|
3115
3113
|
});
|
3116
3114
|
}
|
3117
3115
|
|
3118
|
-
const VERSION = "1.7.
|
3116
|
+
const VERSION = "1.7.6";
|
3119
3117
|
|
3120
3118
|
const validators$1 = {};
|
3121
3119
|
|
@@ -3522,6 +3520,20 @@ class CancelToken {
|
|
3522
3520
|
}
|
3523
3521
|
}
|
3524
3522
|
|
3523
|
+
toAbortSignal() {
|
3524
|
+
const controller = new AbortController();
|
3525
|
+
|
3526
|
+
const abort = (err) => {
|
3527
|
+
controller.abort(err);
|
3528
|
+
};
|
3529
|
+
|
3530
|
+
this.subscribe(abort);
|
3531
|
+
|
3532
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
3533
|
+
|
3534
|
+
return controller.signal;
|
3535
|
+
}
|
3536
|
+
|
3525
3537
|
/**
|
3526
3538
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
3527
3539
|
* cancels the `CancelToken`.
|