axios 1.7.5 → 1.7.7
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 +27 -0
- package/README.md +4 -3
- package/dist/axios.js +179 -131
- 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 +89 -57
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +89 -57
- 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 +90 -58
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/fetch.js +17 -20
- package/lib/adapters/http.js +1 -1
- package/lib/cancel/CancelToken.js +14 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/composeSignals.js +31 -29
- package/lib/helpers/trackStream.js +25 -5
- package/package.json +1 -1
package/dist/esm/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.7.
|
1
|
+
// Axios v1.7.7 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;
|
@@ -2696,14 +2697,34 @@ const streamChunk = function* (chunk, chunkSize) {
|
|
2696
2697
|
}
|
2697
2698
|
};
|
2698
2699
|
|
2699
|
-
const readBytes = async function* (iterable, chunkSize
|
2700
|
-
for await (const chunk of iterable) {
|
2701
|
-
yield* streamChunk(
|
2700
|
+
const readBytes = async function* (iterable, chunkSize) {
|
2701
|
+
for await (const chunk of readStream(iterable)) {
|
2702
|
+
yield* streamChunk(chunk, chunkSize);
|
2703
|
+
}
|
2704
|
+
};
|
2705
|
+
|
2706
|
+
const readStream = async function* (stream) {
|
2707
|
+
if (stream[Symbol.asyncIterator]) {
|
2708
|
+
yield* stream;
|
2709
|
+
return;
|
2710
|
+
}
|
2711
|
+
|
2712
|
+
const reader = stream.getReader();
|
2713
|
+
try {
|
2714
|
+
for (;;) {
|
2715
|
+
const {done, value} = await reader.read();
|
2716
|
+
if (done) {
|
2717
|
+
break;
|
2718
|
+
}
|
2719
|
+
yield value;
|
2720
|
+
}
|
2721
|
+
} finally {
|
2722
|
+
await reader.cancel();
|
2702
2723
|
}
|
2703
2724
|
};
|
2704
2725
|
|
2705
|
-
const trackStream = (stream, chunkSize, onProgress, onFinish
|
2706
|
-
const iterator = readBytes(stream, chunkSize
|
2726
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
2727
|
+
const iterator = readBytes(stream, chunkSize);
|
2707
2728
|
|
2708
2729
|
let bytes = 0;
|
2709
2730
|
let done;
|
@@ -2806,7 +2827,11 @@ const getBodyLength = async (body) => {
|
|
2806
2827
|
}
|
2807
2828
|
|
2808
2829
|
if(utils$1.isSpecCompliantForm(body)) {
|
2809
|
-
|
2830
|
+
const _request = new Request(platform.origin, {
|
2831
|
+
method: 'POST',
|
2832
|
+
body,
|
2833
|
+
});
|
2834
|
+
return (await _request.arrayBuffer()).byteLength;
|
2810
2835
|
}
|
2811
2836
|
|
2812
2837
|
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
@@ -2846,18 +2871,13 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2846
2871
|
|
2847
2872
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
2848
2873
|
|
2849
|
-
let
|
2850
|
-
composeSignals$1([signal, cancelToken], timeout) : [];
|
2874
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
2851
2875
|
|
2852
|
-
let
|
2876
|
+
let request;
|
2853
2877
|
|
2854
|
-
const
|
2855
|
-
|
2856
|
-
|
2857
|
-
});
|
2858
|
-
|
2859
|
-
finished = true;
|
2860
|
-
};
|
2878
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
2879
|
+
composedSignal.unsubscribe();
|
2880
|
+
});
|
2861
2881
|
|
2862
2882
|
let requestContentLength;
|
2863
2883
|
|
@@ -2884,7 +2904,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2884
2904
|
progressEventReducer(asyncDecorator(onUploadProgress))
|
2885
2905
|
);
|
2886
2906
|
|
2887
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush
|
2907
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
2888
2908
|
}
|
2889
2909
|
}
|
2890
2910
|
|
@@ -2894,7 +2914,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2894
2914
|
|
2895
2915
|
// Cloudflare Workers throws when credentials are defined
|
2896
2916
|
// see https://github.com/cloudflare/workerd/issues/902
|
2897
|
-
const isCredentialsSupported = "credentials" in Request.prototype;
|
2917
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
2898
2918
|
request = new Request(url, {
|
2899
2919
|
...fetchOptions,
|
2900
2920
|
signal: composedSignal,
|
@@ -2909,7 +2929,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2909
2929
|
|
2910
2930
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
2911
2931
|
|
2912
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
2932
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
2913
2933
|
const options = {};
|
2914
2934
|
|
2915
2935
|
['status', 'statusText', 'headers'].forEach(prop => {
|
@@ -2926,8 +2946,8 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2926
2946
|
response = new Response(
|
2927
2947
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
2928
2948
|
flush && flush();
|
2929
|
-
|
2930
|
-
}
|
2949
|
+
unsubscribe && unsubscribe();
|
2950
|
+
}),
|
2931
2951
|
options
|
2932
2952
|
);
|
2933
2953
|
}
|
@@ -2936,9 +2956,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2936
2956
|
|
2937
2957
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
2938
2958
|
|
2939
|
-
!isStreamResponse &&
|
2940
|
-
|
2941
|
-
stopTimeout && stopTimeout();
|
2959
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
2942
2960
|
|
2943
2961
|
return await new Promise((resolve, reject) => {
|
2944
2962
|
settle(resolve, reject, {
|
@@ -2951,7 +2969,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2951
2969
|
});
|
2952
2970
|
})
|
2953
2971
|
} catch (err) {
|
2954
|
-
|
2972
|
+
unsubscribe && unsubscribe();
|
2955
2973
|
|
2956
2974
|
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
2957
2975
|
throw Object.assign(
|
@@ -3113,7 +3131,7 @@ function dispatchRequest(config) {
|
|
3113
3131
|
});
|
3114
3132
|
}
|
3115
3133
|
|
3116
|
-
const VERSION$1 = "1.7.
|
3134
|
+
const VERSION$1 = "1.7.7";
|
3117
3135
|
|
3118
3136
|
const validators$1 = {};
|
3119
3137
|
|
@@ -3520,6 +3538,20 @@ class CancelToken$1 {
|
|
3520
3538
|
}
|
3521
3539
|
}
|
3522
3540
|
|
3541
|
+
toAbortSignal() {
|
3542
|
+
const controller = new AbortController();
|
3543
|
+
|
3544
|
+
const abort = (err) => {
|
3545
|
+
controller.abort(err);
|
3546
|
+
};
|
3547
|
+
|
3548
|
+
this.subscribe(abort);
|
3549
|
+
|
3550
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
3551
|
+
|
3552
|
+
return controller.signal;
|
3553
|
+
}
|
3554
|
+
|
3523
3555
|
/**
|
3524
3556
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
3525
3557
|
* cancels the `CancelToken`.
|