axios 1.7.0-beta.2 → 1.7.1
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 +865 -837
- package/README.md +30 -1
- package/dist/axios.js +95 -69
- 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 +16 -12
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +16 -12
- 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 +16 -12
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/fetch.js +10 -4
- package/lib/env/data.js +1 -1
- package/lib/helpers/trackStream.js +5 -6
- package/package.json +1 -1
package/dist/esm/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.7.
|
1
|
+
// Axios v1.7.1 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);
|
@@ -2631,16 +2631,14 @@ const streamChunk = function* (chunk, chunkSize) {
|
|
2631
2631
|
}
|
2632
2632
|
};
|
2633
2633
|
|
2634
|
-
const
|
2635
|
-
|
2636
|
-
const readBytes = async function* (iterable, chunkSize) {
|
2634
|
+
const readBytes = async function* (iterable, chunkSize, encode) {
|
2637
2635
|
for await (const chunk of iterable) {
|
2638
|
-
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await
|
2636
|
+
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
|
2639
2637
|
}
|
2640
2638
|
};
|
2641
2639
|
|
2642
|
-
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
2643
|
-
const iterator = readBytes(stream, chunkSize);
|
2640
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
2641
|
+
const iterator = readBytes(stream, chunkSize, encode);
|
2644
2642
|
|
2645
2643
|
let bytes = 0;
|
2646
2644
|
|
@@ -2681,6 +2679,12 @@ const fetchProgressDecorator = (total, fn) => {
|
|
2681
2679
|
const isFetchSupported = typeof fetch !== 'undefined';
|
2682
2680
|
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
|
2683
2681
|
|
2682
|
+
// used only inside the fetch adapter
|
2683
|
+
const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ?
|
2684
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
2685
|
+
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
2686
|
+
);
|
2687
|
+
|
2684
2688
|
const supportsRequestStream = isReadableStreamSupported && (() => {
|
2685
2689
|
let duplexAccessed = false;
|
2686
2690
|
|
@@ -2741,7 +2745,7 @@ const getBodyLength = async (body) => {
|
|
2741
2745
|
}
|
2742
2746
|
|
2743
2747
|
if(utils$1.isString(body)) {
|
2744
|
-
return (await
|
2748
|
+
return (await encodeText(body)).byteLength;
|
2745
2749
|
}
|
2746
2750
|
};
|
2747
2751
|
|
@@ -2805,7 +2809,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2805
2809
|
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
|
2806
2810
|
requestContentLength,
|
2807
2811
|
progressEventReducer(onUploadProgress)
|
2808
|
-
));
|
2812
|
+
), null, encodeText);
|
2809
2813
|
}
|
2810
2814
|
}
|
2811
2815
|
|
@@ -2825,7 +2829,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2825
2829
|
|
2826
2830
|
let response = await fetch(request);
|
2827
2831
|
|
2828
|
-
const isStreamResponse = responseType === 'stream' || responseType === 'response';
|
2832
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
2829
2833
|
|
2830
2834
|
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
2831
2835
|
const options = {};
|
@@ -2840,7 +2844,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
2840
2844
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
|
2841
2845
|
responseContentLength,
|
2842
2846
|
progressEventReducer(onDownloadProgress, true)
|
2843
|
-
), isStreamResponse && onFinish),
|
2847
|
+
), isStreamResponse && onFinish, encodeText),
|
2844
2848
|
options
|
2845
2849
|
);
|
2846
2850
|
}
|
@@ -3026,7 +3030,7 @@ function dispatchRequest(config) {
|
|
3026
3030
|
});
|
3027
3031
|
}
|
3028
3032
|
|
3029
|
-
const VERSION$1 = "1.7.
|
3033
|
+
const VERSION$1 = "1.7.1";
|
3030
3034
|
|
3031
3035
|
const validators$1 = {};
|
3032
3036
|
|