@arbidocs/react 0.5.109 → 0.5.110
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.cjs +19 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -15529,6 +15529,7 @@ interface UploadFilesInput {
|
|
|
15529
15529
|
interface UploadFilesProgress {
|
|
15530
15530
|
loaded: number;
|
|
15531
15531
|
total: number;
|
|
15532
|
+
/** Share of the files sent (one on the wire counts by its bytes sent); it never goes back. */
|
|
15532
15533
|
percentage: number;
|
|
15533
15534
|
/** Batches done of all, when there is more than one. */
|
|
15534
15535
|
batches: {
|
package/dist/index.d.ts
CHANGED
|
@@ -15529,6 +15529,7 @@ interface UploadFilesInput {
|
|
|
15529
15529
|
interface UploadFilesProgress {
|
|
15530
15530
|
loaded: number;
|
|
15531
15531
|
total: number;
|
|
15532
|
+
/** Share of the files sent (one on the wire counts by its bytes sent); it never goes back. */
|
|
15532
15533
|
percentage: number;
|
|
15533
15534
|
/** Batches done of all, when there is more than one. */
|
|
15534
15535
|
batches: {
|
package/dist/index.js
CHANGED
|
@@ -3339,13 +3339,18 @@ function useUploadFiles() {
|
|
|
3339
3339
|
}
|
|
3340
3340
|
const total = input.files.reduce((sum, file) => sum + file.size, 0);
|
|
3341
3341
|
const loadedByBatch = new Array(batches.length).fill(0);
|
|
3342
|
+
const filesByBatch = new Array(batches.length).fill(0);
|
|
3342
3343
|
let done = 0;
|
|
3344
|
+
let highest = 0;
|
|
3343
3345
|
const report = () => {
|
|
3344
3346
|
const loaded = loadedByBatch.reduce((sum, bytes) => sum + bytes, 0);
|
|
3347
|
+
const sent = filesByBatch.reduce((sum, files) => sum + files, 0);
|
|
3348
|
+
const share = input.files.length > 0 ? sent / input.files.length : 0;
|
|
3349
|
+
highest = Math.max(highest, Math.min(Math.round(share * 100), 100));
|
|
3345
3350
|
onProgress?.({
|
|
3346
3351
|
loaded,
|
|
3347
3352
|
total,
|
|
3348
|
-
percentage:
|
|
3353
|
+
percentage: highest,
|
|
3349
3354
|
batches: batches.length > 1 ? { current: done, total: batches.length } : null
|
|
3350
3355
|
});
|
|
3351
3356
|
};
|
|
@@ -3359,11 +3364,14 @@ function useUploadFiles() {
|
|
|
3359
3364
|
configExtId: input.configExtId ?? void 0,
|
|
3360
3365
|
// Named even when it is the open one: batches sent after a switch stay in this workspace.
|
|
3361
3366
|
workspaceExtId: workspaceId,
|
|
3367
|
+
// One request for the batch: its files count by the share of its bytes sent.
|
|
3362
3368
|
onProgress: (loaded) => {
|
|
3363
3369
|
loadedByBatch[index] = Math.min(loaded, bytes);
|
|
3370
|
+
filesByBatch[index] = bytes > 0 ? loadedByBatch[index] / bytes * files.length : 0;
|
|
3364
3371
|
report();
|
|
3365
3372
|
}
|
|
3366
3373
|
});
|
|
3374
|
+
const fileShares = new Array(files.length).fill(0);
|
|
3367
3375
|
const directly = async (key, workspace) => arbi.documents.uploadDirect(
|
|
3368
3376
|
workspace,
|
|
3369
3377
|
key,
|
|
@@ -3378,9 +3386,15 @@ function useUploadFiles() {
|
|
|
3378
3386
|
shared: input.shared,
|
|
3379
3387
|
folder: folder ?? void 0,
|
|
3380
3388
|
configExtId: input.configExtId ?? void 0,
|
|
3381
|
-
//
|
|
3382
|
-
|
|
3383
|
-
|
|
3389
|
+
// Per file, in ciphertext bytes: that file's share sent, scaled back to its own
|
|
3390
|
+
// size so the byte total stays true.
|
|
3391
|
+
onBytesProgress: ({ fileIndex, loaded, total: sent }) => {
|
|
3392
|
+
const share = sent > 0 ? Math.min(loaded / sent, 1) : 0;
|
|
3393
|
+
fileShares[fileIndex] = Math.max(fileShares[fileIndex] ?? 0, share);
|
|
3394
|
+
loadedByBatch[index] = Math.round(
|
|
3395
|
+
files.reduce((sum, file, i) => sum + (fileShares[i] ?? 0) * file.size, 0)
|
|
3396
|
+
);
|
|
3397
|
+
filesByBatch[index] = fileShares.reduce((sum, part) => sum + part, 0);
|
|
3384
3398
|
report();
|
|
3385
3399
|
}
|
|
3386
3400
|
}
|
|
@@ -3397,6 +3411,7 @@ function useUploadFiles() {
|
|
|
3397
3411
|
);
|
|
3398
3412
|
}
|
|
3399
3413
|
loadedByBatch[index] = bytes;
|
|
3414
|
+
filesByBatch[index] = files.length;
|
|
3400
3415
|
done += 1;
|
|
3401
3416
|
report();
|
|
3402
3417
|
return result;
|