@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.d.mts
CHANGED
|
@@ -611,7 +611,7 @@ interface TusUploadParams {
|
|
|
611
611
|
uploadUrl: string;
|
|
612
612
|
/** Total upload size in bytes. */
|
|
613
613
|
uploadSize: number;
|
|
614
|
-
/** Headers
|
|
614
|
+
/** Headers issued with the upload session. */
|
|
615
615
|
headers: Record<string, string>;
|
|
616
616
|
/** Maximum chunk size in bytes. Required for streamed inputs. */
|
|
617
617
|
chunkSize?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -611,7 +611,7 @@ interface TusUploadParams {
|
|
|
611
611
|
uploadUrl: string;
|
|
612
612
|
/** Total upload size in bytes. */
|
|
613
613
|
uploadSize: number;
|
|
614
|
-
/** Headers
|
|
614
|
+
/** Headers issued with the upload session. */
|
|
615
615
|
headers: Record<string, string>;
|
|
616
616
|
/** Maximum chunk size in bytes. Required for streamed inputs. */
|
|
617
617
|
chunkSize?: number;
|
package/dist/index.js
CHANGED
|
@@ -1086,11 +1086,15 @@ var sizeOf = (data) => {
|
|
|
1086
1086
|
if (data instanceof ArrayBuffer) return data.byteLength;
|
|
1087
1087
|
throw new Error("Cannot determine upload size. Pass a File, Blob, Buffer, Uint8Array, or ArrayBuffer.");
|
|
1088
1088
|
};
|
|
1089
|
-
var toTusFile = (data) => {
|
|
1090
|
-
if (
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1089
|
+
var toTusFile = async (data) => {
|
|
1090
|
+
if (!isNode()) {
|
|
1091
|
+
if (typeof Blob !== "undefined" && data instanceof Blob) return data;
|
|
1092
|
+
const bytes2 = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
1093
|
+
return new Blob([bytes2]);
|
|
1094
|
+
}
|
|
1095
|
+
const { Buffer: Buffer2 } = await import("buffer");
|
|
1096
|
+
const bytes = typeof Blob !== "undefined" && data instanceof Blob ? new Uint8Array(await data.arrayBuffer()) : data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
1097
|
+
return Buffer2.isBuffer(data) ? data : Buffer2.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1094
1098
|
};
|
|
1095
1099
|
var buildChecksums = (input, sha256) => {
|
|
1096
1100
|
const checksums = { sha256 };
|
|
@@ -1111,7 +1115,7 @@ var resolveUploadSource = async (input, options = {}) => {
|
|
|
1111
1115
|
const size = input.contentLength ?? sizeOf(input.data);
|
|
1112
1116
|
const sha256 = input.checksumSha256 ?? (hash ? (await computeChecksums(await toBytes(input.data))).sha256 : "");
|
|
1113
1117
|
return {
|
|
1114
|
-
tusFile: toTusFile(input.data),
|
|
1118
|
+
tusFile: await toTusFile(input.data),
|
|
1115
1119
|
size,
|
|
1116
1120
|
contentType,
|
|
1117
1121
|
checksums: buildChecksums(input, sha256),
|
|
@@ -1168,10 +1172,16 @@ var tusUploadTransport = (params) => new Promise((resolve, reject) => {
|
|
|
1168
1172
|
cleanup();
|
|
1169
1173
|
fn();
|
|
1170
1174
|
};
|
|
1175
|
+
const headers = Object.fromEntries(
|
|
1176
|
+
Object.entries(params.headers).filter(([name]) => name.toLowerCase() !== "tus-resumable")
|
|
1177
|
+
);
|
|
1171
1178
|
const upload = new tus.Upload(params.data, {
|
|
1172
1179
|
uploadUrl: params.uploadUrl,
|
|
1173
1180
|
uploadSize: params.uploadSize,
|
|
1174
|
-
|
|
1181
|
+
// tus-js-client sets Tus-Resumable itself. In browsers, forwarding the
|
|
1182
|
+
// session's copy makes XMLHttpRequest combine both values and produces
|
|
1183
|
+
// an invalid `1.0.0, 1.0.0` protocol header.
|
|
1184
|
+
headers,
|
|
1175
1185
|
chunkSize: params.chunkSize ?? Infinity,
|
|
1176
1186
|
retryDelays: params.retryDelays === void 0 ? DEFAULT_RETRY_DELAYS : params.retryDelays,
|
|
1177
1187
|
storeFingerprintForResuming: params.resume ?? false,
|