@arbidocs/sdk 0.5.138 → 0.5.140

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/browser.js CHANGED
@@ -6232,7 +6232,8 @@ async function presignedPut(url, body, onProgress, headers) {
6232
6232
  });
6233
6233
  xhr.addEventListener("error", () => reject(new Error("Presigned PUT network error")));
6234
6234
  xhr.addEventListener("abort", () => reject(new Error("Presigned PUT aborted")));
6235
- xhr.send(body);
6235
+ const BlobGlobal = globalThis.Blob;
6236
+ xhr.send(BlobGlobal ? new BlobGlobal([body]) : body);
6236
6237
  });
6237
6238
  return;
6238
6239
  }
@@ -6246,19 +6247,24 @@ async function presignedPut(url, body, onProgress, headers) {
6246
6247
  throw new Error(`Presigned PUT failed: ${putRes.status} ${snippet.slice(0, 200)}`);
6247
6248
  }
6248
6249
  }
6250
+ var yieldToEventLoop = () => new Promise((resolve) => setTimeout(resolve, 0));
6249
6251
  async function uploadDocumentsDirect(arbi, workspaceKey, files, options) {
6250
6252
  if (!options?.workspaceExtId) {
6251
6253
  throw new ArbiError("uploadDocumentsDirect needs options.workspaceExtId (the key's workspace)");
6252
6254
  }
6253
6255
  if (files.length === 0) return { doc_ext_ids: [], skipped: [] };
6254
6256
  const SECRETBOX_ENVELOPE_OVERHEAD = 40;
6255
- const declared = files.map((f2) => ({
6256
- file_name: f2.name,
6257
- file_size: f2.data.length,
6258
- encrypted_file_size: f2.data.length + SECRETBOX_ENVELOPE_OVERHEAD,
6259
- content_hash: createContentHash(f2.data, workspaceKey),
6260
- content_type: f2.contentType ?? null
6261
- }));
6257
+ const declared = [];
6258
+ for (const f2 of files) {
6259
+ declared.push({
6260
+ file_name: f2.name,
6261
+ file_size: f2.data.length,
6262
+ encrypted_file_size: f2.data.length + SECRETBOX_ENVELOPE_OVERHEAD,
6263
+ content_hash: createContentHash(f2.data, workspaceKey),
6264
+ content_type: f2.contentType ?? null
6265
+ });
6266
+ await yieldToEventLoop();
6267
+ }
6262
6268
  const initBody = {
6263
6269
  files: declared,
6264
6270
  shared: options.shared !== false,