@liveblocks/core 3.23.0-file3 → 3.23.0-file4

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.cts CHANGED
@@ -217,6 +217,118 @@ type BaseUserMeta = {
217
217
  info?: IUserInfo;
218
218
  };
219
219
 
220
+ type CrdtType = (typeof CrdtType)[keyof typeof CrdtType];
221
+ declare const CrdtType: Readonly<{
222
+ OBJECT: 0;
223
+ LIST: 1;
224
+ MAP: 2;
225
+ REGISTER: 3;
226
+ FILE: 5;
227
+ }>;
228
+ declare namespace CrdtType {
229
+ type OBJECT = typeof CrdtType.OBJECT;
230
+ type LIST = typeof CrdtType.LIST;
231
+ type MAP = typeof CrdtType.MAP;
232
+ type REGISTER = typeof CrdtType.REGISTER;
233
+ type FILE = typeof CrdtType.FILE;
234
+ }
235
+ type SerializedCrdt = SerializedRootObject | SerializedChild;
236
+ type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister | SerializedFile;
237
+ type LiveFileData = {
238
+ readonly id: string;
239
+ readonly name: string;
240
+ readonly size: number;
241
+ readonly mimeType: string;
242
+ };
243
+ type SerializedRootObject = {
244
+ readonly type: CrdtType.OBJECT;
245
+ readonly data: JsonObject;
246
+ readonly parentId?: never;
247
+ readonly parentKey?: never;
248
+ };
249
+ type SerializedObject = {
250
+ readonly type: CrdtType.OBJECT;
251
+ readonly parentId: string;
252
+ readonly parentKey: string;
253
+ readonly data: JsonObject;
254
+ };
255
+ type SerializedList = {
256
+ readonly type: CrdtType.LIST;
257
+ readonly parentId: string;
258
+ readonly parentKey: string;
259
+ };
260
+ type SerializedMap = {
261
+ readonly type: CrdtType.MAP;
262
+ readonly parentId: string;
263
+ readonly parentKey: string;
264
+ };
265
+ type SerializedRegister = {
266
+ readonly type: CrdtType.REGISTER;
267
+ readonly parentId: string;
268
+ readonly parentKey: string;
269
+ readonly data: Json;
270
+ };
271
+ type SerializedFile = {
272
+ readonly type: CrdtType.FILE;
273
+ readonly parentId: string;
274
+ readonly parentKey: string;
275
+ readonly data: LiveFileData;
276
+ };
277
+ type StorageNode = RootStorageNode | ChildStorageNode;
278
+ type ChildStorageNode = ObjectStorageNode | ListStorageNode | MapStorageNode | RegisterStorageNode | FileStorageNode;
279
+ type RootStorageNode = [id: "root", value: SerializedRootObject];
280
+ type ObjectStorageNode = [id: string, value: SerializedObject];
281
+ type ListStorageNode = [id: string, value: SerializedList];
282
+ type MapStorageNode = [id: string, value: SerializedMap];
283
+ type RegisterStorageNode = [id: string, value: SerializedRegister];
284
+ type FileStorageNode = [id: string, value: SerializedFile];
285
+ type NodeMap = Map<string, SerializedCrdt>;
286
+ type NodeStream = Iterable<StorageNode>;
287
+ declare function isRootStorageNode(node: StorageNode): node is RootStorageNode;
288
+ declare function isObjectStorageNode(node: StorageNode): node is RootStorageNode | ObjectStorageNode;
289
+ declare function isListStorageNode(node: StorageNode): node is ListStorageNode;
290
+ declare function isMapStorageNode(node: StorageNode): node is MapStorageNode;
291
+ declare function isRegisterStorageNode(node: StorageNode): node is RegisterStorageNode;
292
+ declare function isFileStorageNode(node: StorageNode): node is FileStorageNode;
293
+ type CompactNode = CompactRootNode | CompactChildNode;
294
+ type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode | CompactFileNode;
295
+ type CompactRootNode = readonly [id: "root", data: JsonObject];
296
+ type CompactObjectNode = readonly [
297
+ id: string,
298
+ type: CrdtType.OBJECT,
299
+ parentId: string,
300
+ parentKey: string,
301
+ data: JsonObject
302
+ ];
303
+ type CompactListNode = readonly [
304
+ id: string,
305
+ type: CrdtType.LIST,
306
+ parentId: string,
307
+ parentKey: string
308
+ ];
309
+ type CompactMapNode = readonly [
310
+ id: string,
311
+ type: CrdtType.MAP,
312
+ parentId: string,
313
+ parentKey: string
314
+ ];
315
+ type CompactRegisterNode = readonly [
316
+ id: string,
317
+ type: CrdtType.REGISTER,
318
+ parentId: string,
319
+ parentKey: string,
320
+ data: Json
321
+ ];
322
+ type CompactFileNode = readonly [
323
+ id: string,
324
+ type: CrdtType.FILE,
325
+ parentId: string,
326
+ parentKey: string,
327
+ data: LiveFileData
328
+ ];
329
+ declare function compactNodesToNodeStream(compactNodes: CompactNode[]): NodeStream;
330
+ declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
331
+
220
332
  declare const brand: unique symbol;
221
333
  type Brand<T, TBrand extends string> = T & {
222
334
  [brand]: TBrand;
@@ -625,112 +737,6 @@ declare class LiveMap<TKey extends string, TValue extends Lson> extends Abstract
625
737
  clone(): LiveMap<TKey, TValue>;
626
738
  }
627
739
 
628
- type CrdtType = (typeof CrdtType)[keyof typeof CrdtType];
629
- declare const CrdtType: Readonly<{
630
- OBJECT: 0;
631
- LIST: 1;
632
- MAP: 2;
633
- REGISTER: 3;
634
- FILE: 5;
635
- }>;
636
- declare namespace CrdtType {
637
- type OBJECT = typeof CrdtType.OBJECT;
638
- type LIST = typeof CrdtType.LIST;
639
- type MAP = typeof CrdtType.MAP;
640
- type REGISTER = typeof CrdtType.REGISTER;
641
- type FILE = typeof CrdtType.FILE;
642
- }
643
- type SerializedCrdt = SerializedRootObject | SerializedChild;
644
- type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister | SerializedFile;
645
- type SerializedRootObject = {
646
- readonly type: CrdtType.OBJECT;
647
- readonly data: JsonObject;
648
- readonly parentId?: never;
649
- readonly parentKey?: never;
650
- };
651
- type SerializedObject = {
652
- readonly type: CrdtType.OBJECT;
653
- readonly parentId: string;
654
- readonly parentKey: string;
655
- readonly data: JsonObject;
656
- };
657
- type SerializedList = {
658
- readonly type: CrdtType.LIST;
659
- readonly parentId: string;
660
- readonly parentKey: string;
661
- };
662
- type SerializedMap = {
663
- readonly type: CrdtType.MAP;
664
- readonly parentId: string;
665
- readonly parentKey: string;
666
- };
667
- type SerializedRegister = {
668
- readonly type: CrdtType.REGISTER;
669
- readonly parentId: string;
670
- readonly parentKey: string;
671
- readonly data: Json;
672
- };
673
- type SerializedFile = {
674
- readonly type: CrdtType.FILE;
675
- readonly parentId: string;
676
- readonly parentKey: string;
677
- readonly data: LiveFileData;
678
- };
679
- type StorageNode = RootStorageNode | ChildStorageNode;
680
- type ChildStorageNode = ObjectStorageNode | ListStorageNode | MapStorageNode | RegisterStorageNode | FileStorageNode;
681
- type RootStorageNode = [id: "root", value: SerializedRootObject];
682
- type ObjectStorageNode = [id: string, value: SerializedObject];
683
- type ListStorageNode = [id: string, value: SerializedList];
684
- type MapStorageNode = [id: string, value: SerializedMap];
685
- type RegisterStorageNode = [id: string, value: SerializedRegister];
686
- type FileStorageNode = [id: string, value: SerializedFile];
687
- type NodeMap = Map<string, SerializedCrdt>;
688
- type NodeStream = Iterable<StorageNode>;
689
- declare function isRootStorageNode(node: StorageNode): node is RootStorageNode;
690
- declare function isObjectStorageNode(node: StorageNode): node is RootStorageNode | ObjectStorageNode;
691
- declare function isListStorageNode(node: StorageNode): node is ListStorageNode;
692
- declare function isMapStorageNode(node: StorageNode): node is MapStorageNode;
693
- declare function isRegisterStorageNode(node: StorageNode): node is RegisterStorageNode;
694
- declare function isFileStorageNode(node: StorageNode): node is FileStorageNode;
695
- type CompactNode = CompactRootNode | CompactChildNode;
696
- type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode | CompactFileNode;
697
- type CompactRootNode = readonly [id: "root", data: JsonObject];
698
- type CompactObjectNode = readonly [
699
- id: string,
700
- type: CrdtType.OBJECT,
701
- parentId: string,
702
- parentKey: string,
703
- data: JsonObject
704
- ];
705
- type CompactListNode = readonly [
706
- id: string,
707
- type: CrdtType.LIST,
708
- parentId: string,
709
- parentKey: string
710
- ];
711
- type CompactMapNode = readonly [
712
- id: string,
713
- type: CrdtType.MAP,
714
- parentId: string,
715
- parentKey: string
716
- ];
717
- type CompactRegisterNode = readonly [
718
- id: string,
719
- type: CrdtType.REGISTER,
720
- parentId: string,
721
- parentKey: string,
722
- data: Json
723
- ];
724
- type CompactFileNode = readonly [
725
- id: string,
726
- type: CrdtType.FILE,
727
- parentId: string,
728
- parentKey: string,
729
- data: LiveFileData
730
- ];
731
- declare function compactNodesToNodeStream(compactNodes: CompactNode[]): NodeStream;
732
- declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
733
-
734
740
  /**
735
741
  * Extracts only the explicitly-named string keys of a type, filtering out
736
742
  * any index signature (e.g. `[key: string]: ...`).
@@ -1063,12 +1069,6 @@ declare abstract class AbstractCrdt {
1063
1069
  abstract clone(): Lson;
1064
1070
  }
1065
1071
 
1066
- type LiveFileData = {
1067
- readonly id: string;
1068
- readonly name: string;
1069
- readonly size: number;
1070
- readonly mimeType: string;
1071
- };
1072
1072
  type LiveFileReference = LiveFile | LiveFileData | string;
1073
1073
  declare function getLiveFileId(file: LiveFileReference): string;
1074
1074
  /**
package/dist/index.d.ts CHANGED
@@ -217,6 +217,118 @@ type BaseUserMeta = {
217
217
  info?: IUserInfo;
218
218
  };
219
219
 
220
+ type CrdtType = (typeof CrdtType)[keyof typeof CrdtType];
221
+ declare const CrdtType: Readonly<{
222
+ OBJECT: 0;
223
+ LIST: 1;
224
+ MAP: 2;
225
+ REGISTER: 3;
226
+ FILE: 5;
227
+ }>;
228
+ declare namespace CrdtType {
229
+ type OBJECT = typeof CrdtType.OBJECT;
230
+ type LIST = typeof CrdtType.LIST;
231
+ type MAP = typeof CrdtType.MAP;
232
+ type REGISTER = typeof CrdtType.REGISTER;
233
+ type FILE = typeof CrdtType.FILE;
234
+ }
235
+ type SerializedCrdt = SerializedRootObject | SerializedChild;
236
+ type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister | SerializedFile;
237
+ type LiveFileData = {
238
+ readonly id: string;
239
+ readonly name: string;
240
+ readonly size: number;
241
+ readonly mimeType: string;
242
+ };
243
+ type SerializedRootObject = {
244
+ readonly type: CrdtType.OBJECT;
245
+ readonly data: JsonObject;
246
+ readonly parentId?: never;
247
+ readonly parentKey?: never;
248
+ };
249
+ type SerializedObject = {
250
+ readonly type: CrdtType.OBJECT;
251
+ readonly parentId: string;
252
+ readonly parentKey: string;
253
+ readonly data: JsonObject;
254
+ };
255
+ type SerializedList = {
256
+ readonly type: CrdtType.LIST;
257
+ readonly parentId: string;
258
+ readonly parentKey: string;
259
+ };
260
+ type SerializedMap = {
261
+ readonly type: CrdtType.MAP;
262
+ readonly parentId: string;
263
+ readonly parentKey: string;
264
+ };
265
+ type SerializedRegister = {
266
+ readonly type: CrdtType.REGISTER;
267
+ readonly parentId: string;
268
+ readonly parentKey: string;
269
+ readonly data: Json;
270
+ };
271
+ type SerializedFile = {
272
+ readonly type: CrdtType.FILE;
273
+ readonly parentId: string;
274
+ readonly parentKey: string;
275
+ readonly data: LiveFileData;
276
+ };
277
+ type StorageNode = RootStorageNode | ChildStorageNode;
278
+ type ChildStorageNode = ObjectStorageNode | ListStorageNode | MapStorageNode | RegisterStorageNode | FileStorageNode;
279
+ type RootStorageNode = [id: "root", value: SerializedRootObject];
280
+ type ObjectStorageNode = [id: string, value: SerializedObject];
281
+ type ListStorageNode = [id: string, value: SerializedList];
282
+ type MapStorageNode = [id: string, value: SerializedMap];
283
+ type RegisterStorageNode = [id: string, value: SerializedRegister];
284
+ type FileStorageNode = [id: string, value: SerializedFile];
285
+ type NodeMap = Map<string, SerializedCrdt>;
286
+ type NodeStream = Iterable<StorageNode>;
287
+ declare function isRootStorageNode(node: StorageNode): node is RootStorageNode;
288
+ declare function isObjectStorageNode(node: StorageNode): node is RootStorageNode | ObjectStorageNode;
289
+ declare function isListStorageNode(node: StorageNode): node is ListStorageNode;
290
+ declare function isMapStorageNode(node: StorageNode): node is MapStorageNode;
291
+ declare function isRegisterStorageNode(node: StorageNode): node is RegisterStorageNode;
292
+ declare function isFileStorageNode(node: StorageNode): node is FileStorageNode;
293
+ type CompactNode = CompactRootNode | CompactChildNode;
294
+ type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode | CompactFileNode;
295
+ type CompactRootNode = readonly [id: "root", data: JsonObject];
296
+ type CompactObjectNode = readonly [
297
+ id: string,
298
+ type: CrdtType.OBJECT,
299
+ parentId: string,
300
+ parentKey: string,
301
+ data: JsonObject
302
+ ];
303
+ type CompactListNode = readonly [
304
+ id: string,
305
+ type: CrdtType.LIST,
306
+ parentId: string,
307
+ parentKey: string
308
+ ];
309
+ type CompactMapNode = readonly [
310
+ id: string,
311
+ type: CrdtType.MAP,
312
+ parentId: string,
313
+ parentKey: string
314
+ ];
315
+ type CompactRegisterNode = readonly [
316
+ id: string,
317
+ type: CrdtType.REGISTER,
318
+ parentId: string,
319
+ parentKey: string,
320
+ data: Json
321
+ ];
322
+ type CompactFileNode = readonly [
323
+ id: string,
324
+ type: CrdtType.FILE,
325
+ parentId: string,
326
+ parentKey: string,
327
+ data: LiveFileData
328
+ ];
329
+ declare function compactNodesToNodeStream(compactNodes: CompactNode[]): NodeStream;
330
+ declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
331
+
220
332
  declare const brand: unique symbol;
221
333
  type Brand<T, TBrand extends string> = T & {
222
334
  [brand]: TBrand;
@@ -625,112 +737,6 @@ declare class LiveMap<TKey extends string, TValue extends Lson> extends Abstract
625
737
  clone(): LiveMap<TKey, TValue>;
626
738
  }
627
739
 
628
- type CrdtType = (typeof CrdtType)[keyof typeof CrdtType];
629
- declare const CrdtType: Readonly<{
630
- OBJECT: 0;
631
- LIST: 1;
632
- MAP: 2;
633
- REGISTER: 3;
634
- FILE: 5;
635
- }>;
636
- declare namespace CrdtType {
637
- type OBJECT = typeof CrdtType.OBJECT;
638
- type LIST = typeof CrdtType.LIST;
639
- type MAP = typeof CrdtType.MAP;
640
- type REGISTER = typeof CrdtType.REGISTER;
641
- type FILE = typeof CrdtType.FILE;
642
- }
643
- type SerializedCrdt = SerializedRootObject | SerializedChild;
644
- type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister | SerializedFile;
645
- type SerializedRootObject = {
646
- readonly type: CrdtType.OBJECT;
647
- readonly data: JsonObject;
648
- readonly parentId?: never;
649
- readonly parentKey?: never;
650
- };
651
- type SerializedObject = {
652
- readonly type: CrdtType.OBJECT;
653
- readonly parentId: string;
654
- readonly parentKey: string;
655
- readonly data: JsonObject;
656
- };
657
- type SerializedList = {
658
- readonly type: CrdtType.LIST;
659
- readonly parentId: string;
660
- readonly parentKey: string;
661
- };
662
- type SerializedMap = {
663
- readonly type: CrdtType.MAP;
664
- readonly parentId: string;
665
- readonly parentKey: string;
666
- };
667
- type SerializedRegister = {
668
- readonly type: CrdtType.REGISTER;
669
- readonly parentId: string;
670
- readonly parentKey: string;
671
- readonly data: Json;
672
- };
673
- type SerializedFile = {
674
- readonly type: CrdtType.FILE;
675
- readonly parentId: string;
676
- readonly parentKey: string;
677
- readonly data: LiveFileData;
678
- };
679
- type StorageNode = RootStorageNode | ChildStorageNode;
680
- type ChildStorageNode = ObjectStorageNode | ListStorageNode | MapStorageNode | RegisterStorageNode | FileStorageNode;
681
- type RootStorageNode = [id: "root", value: SerializedRootObject];
682
- type ObjectStorageNode = [id: string, value: SerializedObject];
683
- type ListStorageNode = [id: string, value: SerializedList];
684
- type MapStorageNode = [id: string, value: SerializedMap];
685
- type RegisterStorageNode = [id: string, value: SerializedRegister];
686
- type FileStorageNode = [id: string, value: SerializedFile];
687
- type NodeMap = Map<string, SerializedCrdt>;
688
- type NodeStream = Iterable<StorageNode>;
689
- declare function isRootStorageNode(node: StorageNode): node is RootStorageNode;
690
- declare function isObjectStorageNode(node: StorageNode): node is RootStorageNode | ObjectStorageNode;
691
- declare function isListStorageNode(node: StorageNode): node is ListStorageNode;
692
- declare function isMapStorageNode(node: StorageNode): node is MapStorageNode;
693
- declare function isRegisterStorageNode(node: StorageNode): node is RegisterStorageNode;
694
- declare function isFileStorageNode(node: StorageNode): node is FileStorageNode;
695
- type CompactNode = CompactRootNode | CompactChildNode;
696
- type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode | CompactFileNode;
697
- type CompactRootNode = readonly [id: "root", data: JsonObject];
698
- type CompactObjectNode = readonly [
699
- id: string,
700
- type: CrdtType.OBJECT,
701
- parentId: string,
702
- parentKey: string,
703
- data: JsonObject
704
- ];
705
- type CompactListNode = readonly [
706
- id: string,
707
- type: CrdtType.LIST,
708
- parentId: string,
709
- parentKey: string
710
- ];
711
- type CompactMapNode = readonly [
712
- id: string,
713
- type: CrdtType.MAP,
714
- parentId: string,
715
- parentKey: string
716
- ];
717
- type CompactRegisterNode = readonly [
718
- id: string,
719
- type: CrdtType.REGISTER,
720
- parentId: string,
721
- parentKey: string,
722
- data: Json
723
- ];
724
- type CompactFileNode = readonly [
725
- id: string,
726
- type: CrdtType.FILE,
727
- parentId: string,
728
- parentKey: string,
729
- data: LiveFileData
730
- ];
731
- declare function compactNodesToNodeStream(compactNodes: CompactNode[]): NodeStream;
732
- declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
733
-
734
740
  /**
735
741
  * Extracts only the explicitly-named string keys of a type, filtering out
736
742
  * any index signature (e.g. `[key: string]: ...`).
@@ -1063,12 +1069,6 @@ declare abstract class AbstractCrdt {
1063
1069
  abstract clone(): Lson;
1064
1070
  }
1065
1071
 
1066
- type LiveFileData = {
1067
- readonly id: string;
1068
- readonly name: string;
1069
- readonly size: number;
1070
- readonly mimeType: string;
1071
- };
1072
1072
  type LiveFileReference = LiveFile | LiveFileData | string;
1073
1073
  declare function getLiveFileId(file: LiveFileReference): string;
1074
1074
  /**
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "3.23.0-file3";
9
+ var PKG_VERSION = "3.23.0-file4";
10
10
  var PKG_FORMAT = "esm";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -2362,7 +2362,7 @@ function isUrl(string) {
2362
2362
  var ROOM_FILE_PART_SIZE = 5 * 1024 * 1024;
2363
2363
  var ROOM_FILE_RETRY_ATTEMPTS = 10;
2364
2364
  var FILE_URL_EXPIRY_BUFFER = 3e4;
2365
- var FILE_URL_ERROR_RETRY_DELAY = 1e3;
2365
+ var FILE_URL_ERROR_CACHE_TTL = 1e3;
2366
2366
  var FILE_URL_ERROR_MAX_ATTEMPTS = 3;
2367
2367
  var FILE_URL_ERROR_ATTEMPTS_EXPIRY = 3e4;
2368
2368
  var ROOM_FILE_RETRY_DELAYS = [
@@ -2377,7 +2377,7 @@ var ROOM_FILE_RETRY_DELAYS = [
2377
2377
  2e3,
2378
2378
  2e3
2379
2379
  ];
2380
- var FileUrlRetryableError = class extends Error {
2380
+ var FileUrlUnavailableError = class extends Error {
2381
2381
  };
2382
2382
  async function uploadRoomFile({
2383
2383
  file,
@@ -2410,7 +2410,23 @@ async function uploadRoomFile({
2410
2410
  }
2411
2411
  let uploadId;
2412
2412
  const uploadedParts = [];
2413
- const multipartUpload = await createMultipartUpload();
2413
+ const multipartUpload = await autoRetry(
2414
+ createMultipartUpload,
2415
+ ROOM_FILE_RETRY_ATTEMPTS,
2416
+ ROOM_FILE_RETRY_DELAYS,
2417
+ handleRetryError
2418
+ );
2419
+ const partUploadController = new AbortController();
2420
+ const partUploadSignal = partUploadController.signal;
2421
+ const abortPartUploads = (reason) => {
2422
+ partUploadController.abort(reason);
2423
+ };
2424
+ const handleExternalAbort = () => abortPartUploads();
2425
+ if (signal?.aborted) {
2426
+ handleExternalAbort();
2427
+ } else {
2428
+ signal?.addEventListener("abort", handleExternalAbort, { once: true });
2429
+ }
2414
2430
  try {
2415
2431
  uploadId = multipartUpload.uploadId;
2416
2432
  if (signal?.aborted) {
@@ -2418,18 +2434,43 @@ async function uploadRoomFile({
2418
2434
  }
2419
2435
  const batches = chunk(splitFileIntoParts(file), 5);
2420
2436
  for (const parts of batches) {
2421
- const uploadedPartsPromises = [];
2437
+ const firstPartUploadFailure = {};
2438
+ const partUploads$ = [];
2422
2439
  for (const { part, partNumber } of parts) {
2423
- uploadedPartsPromises.push(
2440
+ partUploads$.push(
2424
2441
  autoRetry(
2425
- () => uploadMultipartPart(multipartUpload.uploadId, partNumber, part),
2442
+ () => uploadMultipartPart(
2443
+ multipartUpload.uploadId,
2444
+ partNumber,
2445
+ part,
2446
+ partUploadSignal
2447
+ ),
2426
2448
  ROOM_FILE_RETRY_ATTEMPTS,
2427
2449
  ROOM_FILE_RETRY_DELAYS,
2428
- handleRetryError
2429
- )
2450
+ (error3) => {
2451
+ if (signal?.aborted) {
2452
+ throw abortError;
2453
+ }
2454
+ return partUploadSignal.aborted || handleRetryError(error3);
2455
+ }
2456
+ ).catch((error3) => {
2457
+ if (firstPartUploadFailure.value === void 0) {
2458
+ firstPartUploadFailure.value = { error: error3 };
2459
+ abortPartUploads(error3);
2460
+ }
2461
+ throw error3;
2462
+ })
2430
2463
  );
2431
2464
  }
2432
- uploadedParts.push(...await Promise.all(uploadedPartsPromises));
2465
+ const settledPartUploads = await Promise.allSettled(partUploads$);
2466
+ if (firstPartUploadFailure.value !== void 0) {
2467
+ throw firstPartUploadFailure.value.error;
2468
+ }
2469
+ for (const settledPartUpload of settledPartUploads) {
2470
+ if (settledPartUpload.status === "fulfilled") {
2471
+ uploadedParts.push(settledPartUpload.value);
2472
+ }
2473
+ }
2433
2474
  }
2434
2475
  if (signal?.aborted) {
2435
2476
  throw abortError;
@@ -2451,6 +2492,8 @@ async function uploadRoomFile({
2451
2492
  }
2452
2493
  }
2453
2494
  throw error3;
2495
+ } finally {
2496
+ signal?.removeEventListener("abort", handleExternalAbort);
2454
2497
  }
2455
2498
  }
2456
2499
  function splitFileIntoParts(file) {
@@ -2817,7 +2860,7 @@ function createApiClient({
2817
2860
  { signal: options.signal },
2818
2861
  { fileSize: attachment.size }
2819
2862
  ),
2820
- uploadMultipartPart: async (uploadId, partNumber, part) => httpClient.putBlob(
2863
+ uploadMultipartPart: async (uploadId, partNumber, part, signal) => httpClient.putBlob(
2821
2864
  url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}/${String(partNumber)}`,
2822
2865
  await authManager.getAuthValue({
2823
2866
  roomId,
@@ -2826,7 +2869,7 @@ function createApiClient({
2826
2869
  }),
2827
2870
  part,
2828
2871
  void 0,
2829
- { signal: options.signal }
2872
+ { signal }
2830
2873
  ),
2831
2874
  completeMultipartUpload: async (uploadId, parts) => httpClient.post(
2832
2875
  url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}/complete`,
@@ -2881,7 +2924,7 @@ function createApiClient({
2881
2924
  { signal: options.signal },
2882
2925
  { fileSize: file.size }
2883
2926
  ),
2884
- uploadMultipartPart: async (uploadId, partNumber, part) => httpClient.putBlob(
2927
+ uploadMultipartPart: async (uploadId, partNumber, part, signal) => httpClient.putBlob(
2885
2928
  url`/v2/c/rooms/${roomId}/storage/files/${fileId}/multipart/${uploadId}/${String(partNumber)}`,
2886
2929
  await authManager.getAuthValue({
2887
2930
  roomId,
@@ -2890,7 +2933,7 @@ function createApiClient({
2890
2933
  }),
2891
2934
  part,
2892
2935
  void 0,
2893
- { signal: options.signal }
2936
+ { signal }
2894
2937
  ),
2895
2938
  completeMultipartUpload: async (uploadId, parts) => httpClient.post(
2896
2939
  url`/v2/c/rooms/${roomId}/storage/files/${fileId}/multipart/${uploadId}/complete`,
@@ -2944,28 +2987,28 @@ function createApiClient({
2944
2987
  return batch2.get(options.attachmentId);
2945
2988
  }
2946
2989
  const fileUrlsBatchStoresByRoom = new DefaultMap((roomId) => {
2947
- const errorAttempts = /* @__PURE__ */ new Map();
2948
- const clearErrorAttempts = (fileId) => {
2949
- const attempts = errorAttempts.get(fileId);
2990
+ const pendingFileUrlAttempts = /* @__PURE__ */ new Map();
2991
+ const clearPendingFileUrlAttempts = (fileId) => {
2992
+ const attempts = pendingFileUrlAttempts.get(fileId);
2950
2993
  if (attempts !== void 0) {
2951
2994
  clearTimeout(attempts.cleanupTimeoutId);
2952
- errorAttempts.delete(fileId);
2995
+ pendingFileUrlAttempts.delete(fileId);
2953
2996
  }
2954
2997
  };
2955
- const shouldRetryFileUrlError = (fileId) => {
2956
- const previousAttempts = errorAttempts.get(fileId);
2998
+ const shouldRetryPendingFileUrl = (fileId) => {
2999
+ const previousAttempts = pendingFileUrlAttempts.get(fileId);
2957
3000
  if (previousAttempts !== void 0) {
2958
3001
  clearTimeout(previousAttempts.cleanupTimeoutId);
2959
3002
  }
2960
3003
  const count = (previousAttempts?.count ?? 0) + 1;
2961
3004
  if (count >= FILE_URL_ERROR_MAX_ATTEMPTS) {
2962
- errorAttempts.delete(fileId);
3005
+ pendingFileUrlAttempts.delete(fileId);
2963
3006
  return false;
2964
3007
  }
2965
- errorAttempts.set(fileId, {
3008
+ pendingFileUrlAttempts.set(fileId, {
2966
3009
  count,
2967
3010
  cleanupTimeoutId: setTimeout(
2968
- () => errorAttempts.delete(fileId),
3011
+ () => pendingFileUrlAttempts.delete(fileId),
2969
3012
  FILE_URL_ERROR_ATTEMPTS_EXPIRY
2970
3013
  )
2971
3014
  });
@@ -2986,23 +3029,20 @@ function createApiClient({
2986
3029
  const expiresAtTimestamp = Date.parse(expiresAt);
2987
3030
  return urls.map((url2, index) => {
2988
3031
  const fileId = fileIds[index];
2989
- if (url2 !== null) {
2990
- clearErrorAttempts(fileId);
2991
- return { url: url2, expiresAt: expiresAtTimestamp };
2992
- }
2993
- if (shouldRetryFileUrlError(fileId)) {
2994
- return new FileUrlRetryableError(
3032
+ if (url2 === false) {
3033
+ return shouldRetryPendingFileUrl(fileId) ? new FileUrlUnavailableError(
2995
3034
  "There was an error while getting this file's URL"
2996
- );
3035
+ ) : new Error("There was an error while getting this file's URL");
2997
3036
  }
2998
- return new Error("There was an error while getting this file's URL");
3037
+ clearPendingFileUrlAttempts(fileId);
3038
+ return url2 !== null ? { url: url2, expiresAt: expiresAtTimestamp } : new Error("There was an error while getting this file's URL");
2999
3039
  });
3000
3040
  },
3001
3041
  { delay: 50 }
3002
3042
  );
3003
3043
  return createBatchStore(batch2, {
3004
3044
  getCacheExpiry: ({ expiresAt }) => expiresAt - FILE_URL_EXPIRY_BUFFER,
3005
- getErrorCacheExpiry: (error3) => error3 instanceof FileUrlRetryableError ? Date.now() + FILE_URL_ERROR_RETRY_DELAY : void 0
3045
+ getErrorCacheExpiry: (error3) => error3 instanceof FileUrlUnavailableError ? Date.now() + FILE_URL_ERROR_CACHE_TTL : void 0
3006
3046
  });
3007
3047
  });
3008
3048
  function getOrCreateFileUrlsStore(roomId) {