@gigadrive/sdk 0.8.0 → 0.8.2
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/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1018,11 +1018,15 @@ var sizeOf = (data) => {
|
|
|
1018
1018
|
if (data instanceof ArrayBuffer) return data.byteLength;
|
|
1019
1019
|
throw new Error("Cannot determine upload size. Pass a File, Blob, Buffer, Uint8Array, or ArrayBuffer.");
|
|
1020
1020
|
};
|
|
1021
|
-
var toTusFile = (data) => {
|
|
1022
|
-
if (
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1021
|
+
var toTusFile = async (data) => {
|
|
1022
|
+
if (!isNode()) {
|
|
1023
|
+
if (typeof Blob !== "undefined" && data instanceof Blob) return data;
|
|
1024
|
+
const bytes2 = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
1025
|
+
return new Blob([bytes2]);
|
|
1026
|
+
}
|
|
1027
|
+
const { Buffer } = await import("buffer");
|
|
1028
|
+
const bytes = typeof Blob !== "undefined" && data instanceof Blob ? new Uint8Array(await data.arrayBuffer()) : data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
1029
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1026
1030
|
};
|
|
1027
1031
|
var buildChecksums = (input, sha256) => {
|
|
1028
1032
|
const checksums = { sha256 };
|
|
@@ -1043,7 +1047,7 @@ var resolveUploadSource = async (input, options = {}) => {
|
|
|
1043
1047
|
const size = input.contentLength ?? sizeOf(input.data);
|
|
1044
1048
|
const sha256 = input.checksumSha256 ?? (hash ? (await computeChecksums(await toBytes(input.data))).sha256 : "");
|
|
1045
1049
|
return {
|
|
1046
|
-
tusFile: toTusFile(input.data),
|
|
1050
|
+
tusFile: await toTusFile(input.data),
|
|
1047
1051
|
size,
|
|
1048
1052
|
contentType,
|
|
1049
1053
|
checksums: buildChecksums(input, sha256),
|
|
@@ -1100,10 +1104,16 @@ var tusUploadTransport = (params) => new Promise((resolve, reject) => {
|
|
|
1100
1104
|
cleanup();
|
|
1101
1105
|
fn();
|
|
1102
1106
|
};
|
|
1107
|
+
const headers = Object.fromEntries(
|
|
1108
|
+
Object.entries(params.headers).filter(([name]) => name.toLowerCase() !== "tus-resumable")
|
|
1109
|
+
);
|
|
1103
1110
|
const upload = new tus.Upload(params.data, {
|
|
1104
1111
|
uploadUrl: params.uploadUrl,
|
|
1105
1112
|
uploadSize: params.uploadSize,
|
|
1106
|
-
|
|
1113
|
+
// tus-js-client sets Tus-Resumable itself. In browsers, forwarding the
|
|
1114
|
+
// session's copy makes XMLHttpRequest combine both values and produces
|
|
1115
|
+
// an invalid `1.0.0, 1.0.0` protocol header.
|
|
1116
|
+
headers,
|
|
1107
1117
|
chunkSize: params.chunkSize ?? Infinity,
|
|
1108
1118
|
retryDelays: params.retryDelays === void 0 ? DEFAULT_RETRY_DELAYS : params.retryDelays,
|
|
1109
1119
|
storeFingerprintForResuming: params.resume ?? false,
|