@smithy/fetch-http-handler 3.2.8 → 4.0.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/index.js +2 -27
- package/dist-es/stream-collector.js +2 -25
- package/package.json +5 -5
package/dist-cjs/index.js
CHANGED
|
@@ -192,19 +192,12 @@ __name(_FetchHttpHandler, "FetchHttpHandler");
|
|
|
192
192
|
var FetchHttpHandler = _FetchHttpHandler;
|
|
193
193
|
|
|
194
194
|
// src/stream-collector.ts
|
|
195
|
-
var
|
|
196
|
-
var streamCollector = /* @__PURE__ */ __name((stream) => {
|
|
195
|
+
var streamCollector = /* @__PURE__ */ __name(async (stream) => {
|
|
197
196
|
if (typeof Blob === "function" && stream instanceof Blob) {
|
|
198
|
-
return
|
|
197
|
+
return new Uint8Array(await stream.arrayBuffer());
|
|
199
198
|
}
|
|
200
199
|
return collectStream(stream);
|
|
201
200
|
}, "streamCollector");
|
|
202
|
-
async function collectBlob(blob) {
|
|
203
|
-
const base64 = await readToBase64(blob);
|
|
204
|
-
const arrayBuffer = (0, import_util_base64.fromBase64)(base64);
|
|
205
|
-
return new Uint8Array(arrayBuffer);
|
|
206
|
-
}
|
|
207
|
-
__name(collectBlob, "collectBlob");
|
|
208
201
|
async function collectStream(stream) {
|
|
209
202
|
const chunks = [];
|
|
210
203
|
const reader = stream.getReader();
|
|
@@ -227,24 +220,6 @@ async function collectStream(stream) {
|
|
|
227
220
|
return collected;
|
|
228
221
|
}
|
|
229
222
|
__name(collectStream, "collectStream");
|
|
230
|
-
function readToBase64(blob) {
|
|
231
|
-
return new Promise((resolve, reject) => {
|
|
232
|
-
const reader = new FileReader();
|
|
233
|
-
reader.onloadend = () => {
|
|
234
|
-
if (reader.readyState !== 2) {
|
|
235
|
-
return reject(new Error("Reader aborted too early"));
|
|
236
|
-
}
|
|
237
|
-
const result = reader.result ?? "";
|
|
238
|
-
const commaIndex = result.indexOf(",");
|
|
239
|
-
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
|
|
240
|
-
resolve(result.substring(dataOffset));
|
|
241
|
-
};
|
|
242
|
-
reader.onabort = () => reject(new Error("Read aborted"));
|
|
243
|
-
reader.onerror = () => reject(reader.error);
|
|
244
|
-
reader.readAsDataURL(blob);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
__name(readToBase64, "readToBase64");
|
|
248
223
|
// Annotate the CommonJS export names for ESM import in node:
|
|
249
224
|
|
|
250
225
|
0 && (module.exports = {
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export const streamCollector = (stream) => {
|
|
1
|
+
export const streamCollector = async (stream) => {
|
|
3
2
|
if (typeof Blob === "function" && stream instanceof Blob) {
|
|
4
|
-
return
|
|
3
|
+
return new Uint8Array(await stream.arrayBuffer());
|
|
5
4
|
}
|
|
6
5
|
return collectStream(stream);
|
|
7
6
|
};
|
|
8
|
-
async function collectBlob(blob) {
|
|
9
|
-
const base64 = await readToBase64(blob);
|
|
10
|
-
const arrayBuffer = fromBase64(base64);
|
|
11
|
-
return new Uint8Array(arrayBuffer);
|
|
12
|
-
}
|
|
13
7
|
async function collectStream(stream) {
|
|
14
8
|
const chunks = [];
|
|
15
9
|
const reader = stream.getReader();
|
|
@@ -31,20 +25,3 @@ async function collectStream(stream) {
|
|
|
31
25
|
}
|
|
32
26
|
return collected;
|
|
33
27
|
}
|
|
34
|
-
function readToBase64(blob) {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
const reader = new FileReader();
|
|
37
|
-
reader.onloadend = () => {
|
|
38
|
-
if (reader.readyState !== 2) {
|
|
39
|
-
return reject(new Error("Reader aborted too early"));
|
|
40
|
-
}
|
|
41
|
-
const result = (reader.result ?? "");
|
|
42
|
-
const commaIndex = result.indexOf(",");
|
|
43
|
-
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
|
|
44
|
-
resolve(result.substring(dataOffset));
|
|
45
|
-
};
|
|
46
|
-
reader.onabort = () => reject(new Error("Read aborted"));
|
|
47
|
-
reader.onerror = () => reject(reader.error);
|
|
48
|
-
reader.readAsDataURL(blob);
|
|
49
|
-
});
|
|
50
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/fetch-http-handler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Provides a way to make requests",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"module": "./dist-es/index.js",
|
|
25
25
|
"types": "./dist-types/index.d.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@smithy/protocol-http": "^4.1.
|
|
28
|
-
"@smithy/querystring-builder": "^3.0.
|
|
29
|
-
"@smithy/types": "^3.
|
|
27
|
+
"@smithy/protocol-http": "^4.1.5",
|
|
28
|
+
"@smithy/querystring-builder": "^3.0.8",
|
|
29
|
+
"@smithy/types": "^3.6.0",
|
|
30
30
|
"@smithy/util-base64": "^3.0.0",
|
|
31
31
|
"tslib": "^2.6.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@smithy/abort-controller": "^3.1.
|
|
34
|
+
"@smithy/abort-controller": "^3.1.6",
|
|
35
35
|
"concurrently": "7.0.0",
|
|
36
36
|
"downlevel-dts": "0.10.1",
|
|
37
37
|
"rimraf": "3.0.2",
|