@liveblocks/core 3.21.0 → 3.22.0-file1

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
@@ -334,6 +334,118 @@ type ContextualPromptContext = {
334
334
  afterSelection: string;
335
335
  };
336
336
 
337
+ type CrdtType = (typeof CrdtType)[keyof typeof CrdtType];
338
+ declare const CrdtType: Readonly<{
339
+ OBJECT: 0;
340
+ LIST: 1;
341
+ MAP: 2;
342
+ REGISTER: 3;
343
+ FILE: 5;
344
+ }>;
345
+ declare namespace CrdtType {
346
+ type OBJECT = typeof CrdtType.OBJECT;
347
+ type LIST = typeof CrdtType.LIST;
348
+ type MAP = typeof CrdtType.MAP;
349
+ type REGISTER = typeof CrdtType.REGISTER;
350
+ type FILE = typeof CrdtType.FILE;
351
+ }
352
+ type SerializedCrdt = SerializedRootObject | SerializedChild;
353
+ type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister | SerializedFile;
354
+ type LiveFileData = {
355
+ readonly id: string;
356
+ readonly name: string;
357
+ readonly size: number;
358
+ readonly mimeType: string;
359
+ };
360
+ type SerializedRootObject = {
361
+ readonly type: CrdtType.OBJECT;
362
+ readonly data: JsonObject;
363
+ readonly parentId?: never;
364
+ readonly parentKey?: never;
365
+ };
366
+ type SerializedObject = {
367
+ readonly type: CrdtType.OBJECT;
368
+ readonly parentId: string;
369
+ readonly parentKey: string;
370
+ readonly data: JsonObject;
371
+ };
372
+ type SerializedList = {
373
+ readonly type: CrdtType.LIST;
374
+ readonly parentId: string;
375
+ readonly parentKey: string;
376
+ };
377
+ type SerializedMap = {
378
+ readonly type: CrdtType.MAP;
379
+ readonly parentId: string;
380
+ readonly parentKey: string;
381
+ };
382
+ type SerializedRegister = {
383
+ readonly type: CrdtType.REGISTER;
384
+ readonly parentId: string;
385
+ readonly parentKey: string;
386
+ readonly data: Json;
387
+ };
388
+ type SerializedFile = {
389
+ readonly type: CrdtType.FILE;
390
+ readonly parentId: string;
391
+ readonly parentKey: string;
392
+ readonly data: LiveFileData;
393
+ };
394
+ type StorageNode = RootStorageNode | ChildStorageNode;
395
+ type ChildStorageNode = ObjectStorageNode | ListStorageNode | MapStorageNode | RegisterStorageNode | FileStorageNode;
396
+ type RootStorageNode = [id: "root", value: SerializedRootObject];
397
+ type ObjectStorageNode = [id: string, value: SerializedObject];
398
+ type ListStorageNode = [id: string, value: SerializedList];
399
+ type MapStorageNode = [id: string, value: SerializedMap];
400
+ type RegisterStorageNode = [id: string, value: SerializedRegister];
401
+ type FileStorageNode = [id: string, value: SerializedFile];
402
+ type NodeMap = Map<string, SerializedCrdt>;
403
+ type NodeStream = Iterable<StorageNode>;
404
+ declare function isRootStorageNode(node: StorageNode): node is RootStorageNode;
405
+ declare function isObjectStorageNode(node: StorageNode): node is RootStorageNode | ObjectStorageNode;
406
+ declare function isListStorageNode(node: StorageNode): node is ListStorageNode;
407
+ declare function isMapStorageNode(node: StorageNode): node is MapStorageNode;
408
+ declare function isRegisterStorageNode(node: StorageNode): node is RegisterStorageNode;
409
+ declare function isFileStorageNode(node: StorageNode): node is FileStorageNode;
410
+ type CompactNode = CompactRootNode | CompactChildNode;
411
+ type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode | CompactFileNode;
412
+ type CompactRootNode = readonly [id: "root", data: JsonObject];
413
+ type CompactObjectNode = readonly [
414
+ id: string,
415
+ type: CrdtType.OBJECT,
416
+ parentId: string,
417
+ parentKey: string,
418
+ data: JsonObject
419
+ ];
420
+ type CompactListNode = readonly [
421
+ id: string,
422
+ type: CrdtType.LIST,
423
+ parentId: string,
424
+ parentKey: string
425
+ ];
426
+ type CompactMapNode = readonly [
427
+ id: string,
428
+ type: CrdtType.MAP,
429
+ parentId: string,
430
+ parentKey: string
431
+ ];
432
+ type CompactRegisterNode = readonly [
433
+ id: string,
434
+ type: CrdtType.REGISTER,
435
+ parentId: string,
436
+ parentKey: string,
437
+ data: Json
438
+ ];
439
+ type CompactFileNode = readonly [
440
+ id: string,
441
+ type: CrdtType.FILE,
442
+ parentId: string,
443
+ parentKey: string,
444
+ data: LiveFileData
445
+ ];
446
+ declare function compactNodesToNodeStream(compactNodes: CompactNode[]): NodeStream;
447
+ declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
448
+
337
449
  declare const brand: unique symbol;
338
450
  type Brand<T, TBrand extends string> = T & {
339
451
  [brand]: TBrand;
@@ -419,6 +531,7 @@ declare const OpCode: Readonly<{
419
531
  DELETE_OBJECT_KEY: 6;
420
532
  CREATE_MAP: 7;
421
533
  CREATE_REGISTER: 8;
534
+ CREATE_FILE: 11;
422
535
  }>;
423
536
  declare namespace OpCode {
424
537
  type INIT = typeof OpCode.INIT;
@@ -430,13 +543,14 @@ declare namespace OpCode {
430
543
  type DELETE_OBJECT_KEY = typeof OpCode.DELETE_OBJECT_KEY;
431
544
  type CREATE_MAP = typeof OpCode.CREATE_MAP;
432
545
  type CREATE_REGISTER = typeof OpCode.CREATE_REGISTER;
546
+ type CREATE_FILE = typeof OpCode.CREATE_FILE;
433
547
  }
434
548
  /**
435
549
  * These operations are the payload for {@link UpdateStorageServerMsg} messages
436
550
  * only.
437
551
  */
438
552
  type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
439
- type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
553
+ type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp | CreateFileOp;
440
554
  type UpdateObjectOp = {
441
555
  readonly opId?: string;
442
556
  readonly id: string;
@@ -481,6 +595,16 @@ type CreateRegisterOp = {
481
595
  readonly intent?: "set" | "push";
482
596
  readonly deletedId?: string;
483
597
  };
598
+ type CreateFileOp = {
599
+ readonly opId?: string;
600
+ readonly id: string;
601
+ readonly type: OpCode.CREATE_FILE;
602
+ readonly parentId: string;
603
+ readonly parentKey: string;
604
+ readonly data: LiveFileData;
605
+ readonly intent?: "set" | "push";
606
+ readonly deletedId?: string;
607
+ };
484
608
  type DeleteCrdtOp = {
485
609
  readonly opId?: string;
486
610
  readonly id: string;
@@ -523,6 +647,133 @@ type TheirOp = DistributiveOmit<Op, "opId"> & {
523
647
  opId?: undefined;
524
648
  };
525
649
 
650
+ type LiveListUpdateDelta = {
651
+ type: "insert";
652
+ index: number;
653
+ item: Lson;
654
+ } | {
655
+ type: "delete";
656
+ index: number;
657
+ deletedItem: Lson;
658
+ } | {
659
+ type: "move";
660
+ index: number;
661
+ previousIndex: number;
662
+ item: Lson;
663
+ } | {
664
+ type: "set";
665
+ index: number;
666
+ item: Lson;
667
+ };
668
+ /**
669
+ * A LiveList notification that is sent in-client to any subscribers whenever
670
+ * one or more of the items inside the LiveList instance have changed.
671
+ */
672
+ type LiveListUpdates<TItem extends Lson> = {
673
+ type: "LiveList";
674
+ node: LiveList<TItem>;
675
+ updates: LiveListUpdateDelta[];
676
+ };
677
+ /**
678
+ * The LiveList class represents an ordered collection of items that is synchronized across clients.
679
+ */
680
+ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
681
+ #private;
682
+ constructor(items: TItem[]);
683
+ /**
684
+ * Returns the number of elements.
685
+ */
686
+ get length(): number;
687
+ /**
688
+ * Adds one element to the end of the LiveList.
689
+ * @param element The element to add to the end of the LiveList.
690
+ */
691
+ push(element: TItem): void;
692
+ /**
693
+ * Inserts one element at a specified index.
694
+ * @param element The element to insert.
695
+ * @param index The index at which you want to insert the element.
696
+ */
697
+ insert(element: TItem, index: number): void;
698
+ /**
699
+ * Move one element from one index to another.
700
+ * @param index The index of the element to move
701
+ * @param targetIndex The index where the element should be after moving.
702
+ */
703
+ move(index: number, targetIndex: number): void;
704
+ /**
705
+ * Deletes an element at the specified index
706
+ * @param index The index of the element to delete
707
+ */
708
+ delete(index: number): void;
709
+ clear(): void;
710
+ set(index: number, item: TItem): void;
711
+ /**
712
+ * Tests whether all elements pass the test implemented by the provided function.
713
+ * @param predicate Function to test for each element, taking two arguments (the element and its index).
714
+ * @returns true if the predicate function returns a truthy value for every element. Otherwise, false.
715
+ */
716
+ every(predicate: (value: TItem, index: number) => unknown): boolean;
717
+ /**
718
+ * Creates an array with all elements that pass the test implemented by the provided function.
719
+ * @param predicate Function to test each element of the LiveList. Return a value that coerces to true to keep the element, or to false otherwise.
720
+ * @returns An array with the elements that pass the test.
721
+ */
722
+ filter(predicate: (value: TItem, index: number) => unknown): TItem[];
723
+ /**
724
+ * Returns the first element that satisfies the provided testing function.
725
+ * @param predicate Function to execute on each value.
726
+ * @returns The value of the first element in the LiveList that satisfies the provided testing function. Otherwise, undefined is returned.
727
+ */
728
+ find(predicate: (value: TItem, index: number) => unknown): TItem | undefined;
729
+ /**
730
+ * Returns the index of the first element in the LiveList that satisfies the provided testing function.
731
+ * @param predicate Function to execute on each value until the function returns true, indicating that the satisfying element was found.
732
+ * @returns The index of the first element in the LiveList that passes the test. Otherwise, -1.
733
+ */
734
+ findIndex(predicate: (value: TItem, index: number) => unknown): number;
735
+ /**
736
+ * Executes a provided function once for each element.
737
+ * @param callbackfn Function to execute on each element.
738
+ */
739
+ forEach(callbackfn: (value: TItem, index: number) => void): void;
740
+ /**
741
+ * Get the element at the specified index.
742
+ * @param index The index on the element to get.
743
+ * @returns The element at the specified index or undefined.
744
+ */
745
+ get(index: number): TItem | undefined;
746
+ /**
747
+ * Returns the first index at which a given element can be found in the LiveList, or -1 if it is not present.
748
+ * @param searchElement Element to locate.
749
+ * @param fromIndex The index to start the search at.
750
+ * @returns The first index of the element in the LiveList; -1 if not found.
751
+ */
752
+ indexOf(searchElement: TItem, fromIndex?: number): number;
753
+ /**
754
+ * Returns the last index at which a given element can be found in the LiveList, or -1 if it is not present. The LiveList is searched backwards, starting at fromIndex.
755
+ * @param searchElement Element to locate.
756
+ * @param fromIndex The index at which to start searching backwards.
757
+ * @returns The last index of the element in the LiveList; -1 if not found.
758
+ */
759
+ lastIndexOf(searchElement: TItem, fromIndex?: number): number;
760
+ /**
761
+ * Creates an array populated with the results of calling a provided function on every element.
762
+ * @param callback Function that is called for every element.
763
+ * @returns An array with each element being the result of the callback function.
764
+ */
765
+ map<U>(callback: (value: TItem, index: number) => U): U[];
766
+ /**
767
+ * Tests whether at least one element in the LiveList passes the test implemented by the provided function.
768
+ * @param predicate Function to test for each element.
769
+ * @returns true if the callback function returns a truthy value for at least one element. Otherwise, false.
770
+ */
771
+ some(predicate: (value: TItem, index: number) => unknown): boolean;
772
+ [Symbol.iterator](): IterableIterator<TItem>;
773
+ toJSON(): readonly ToJson<TItem>[];
774
+ clone(): LiveList<TItem>;
775
+ }
776
+
526
777
  type UpdateDelta = {
527
778
  type: "update";
528
779
  } | {
@@ -603,95 +854,6 @@ declare class LiveMap<TKey extends string, TValue extends Lson> extends Abstract
603
854
  clone(): LiveMap<TKey, TValue>;
604
855
  }
605
856
 
606
- type CrdtType = (typeof CrdtType)[keyof typeof CrdtType];
607
- declare const CrdtType: Readonly<{
608
- OBJECT: 0;
609
- LIST: 1;
610
- MAP: 2;
611
- REGISTER: 3;
612
- }>;
613
- declare namespace CrdtType {
614
- type OBJECT = typeof CrdtType.OBJECT;
615
- type LIST = typeof CrdtType.LIST;
616
- type MAP = typeof CrdtType.MAP;
617
- type REGISTER = typeof CrdtType.REGISTER;
618
- }
619
- type SerializedCrdt = SerializedRootObject | SerializedChild;
620
- type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
621
- type SerializedRootObject = {
622
- readonly type: CrdtType.OBJECT;
623
- readonly data: JsonObject;
624
- readonly parentId?: never;
625
- readonly parentKey?: never;
626
- };
627
- type SerializedObject = {
628
- readonly type: CrdtType.OBJECT;
629
- readonly parentId: string;
630
- readonly parentKey: string;
631
- readonly data: JsonObject;
632
- };
633
- type SerializedList = {
634
- readonly type: CrdtType.LIST;
635
- readonly parentId: string;
636
- readonly parentKey: string;
637
- };
638
- type SerializedMap = {
639
- readonly type: CrdtType.MAP;
640
- readonly parentId: string;
641
- readonly parentKey: string;
642
- };
643
- type SerializedRegister = {
644
- readonly type: CrdtType.REGISTER;
645
- readonly parentId: string;
646
- readonly parentKey: string;
647
- readonly data: Json;
648
- };
649
- type StorageNode = RootStorageNode | ChildStorageNode;
650
- type ChildStorageNode = ObjectStorageNode | ListStorageNode | MapStorageNode | RegisterStorageNode;
651
- type RootStorageNode = [id: "root", value: SerializedRootObject];
652
- type ObjectStorageNode = [id: string, value: SerializedObject];
653
- type ListStorageNode = [id: string, value: SerializedList];
654
- type MapStorageNode = [id: string, value: SerializedMap];
655
- type RegisterStorageNode = [id: string, value: SerializedRegister];
656
- type NodeMap = Map<string, SerializedCrdt>;
657
- type NodeStream = Iterable<StorageNode>;
658
- declare function isRootStorageNode(node: StorageNode): node is RootStorageNode;
659
- declare function isObjectStorageNode(node: StorageNode): node is RootStorageNode | ObjectStorageNode;
660
- declare function isListStorageNode(node: StorageNode): node is ListStorageNode;
661
- declare function isMapStorageNode(node: StorageNode): node is MapStorageNode;
662
- declare function isRegisterStorageNode(node: StorageNode): node is RegisterStorageNode;
663
- type CompactNode = CompactRootNode | CompactChildNode;
664
- type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode;
665
- type CompactRootNode = readonly [id: "root", data: JsonObject];
666
- type CompactObjectNode = readonly [
667
- id: string,
668
- type: CrdtType.OBJECT,
669
- parentId: string,
670
- parentKey: string,
671
- data: JsonObject
672
- ];
673
- type CompactListNode = readonly [
674
- id: string,
675
- type: CrdtType.LIST,
676
- parentId: string,
677
- parentKey: string
678
- ];
679
- type CompactMapNode = readonly [
680
- id: string,
681
- type: CrdtType.MAP,
682
- parentId: string,
683
- parentKey: string
684
- ];
685
- type CompactRegisterNode = readonly [
686
- id: string,
687
- type: CrdtType.REGISTER,
688
- parentId: string,
689
- parentKey: string,
690
- data: Json
691
- ];
692
- declare function compactNodesToNodeStream(compactNodes: CompactNode[]): NodeStream;
693
- declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
694
-
695
857
  /**
696
858
  * Extracts only the explicitly-named string keys of a type, filtering out
697
859
  * any index signature (e.g. `[key: string]: ...`).
@@ -976,131 +1138,19 @@ declare abstract class AbstractCrdt {
976
1138
  abstract clone(): Lson;
977
1139
  }
978
1140
 
979
- type LiveListUpdateDelta = {
980
- type: "insert";
981
- index: number;
982
- item: Lson;
983
- } | {
984
- type: "delete";
985
- index: number;
986
- deletedItem: Lson;
987
- } | {
988
- type: "move";
989
- index: number;
990
- previousIndex: number;
991
- item: Lson;
992
- } | {
993
- type: "set";
994
- index: number;
995
- item: Lson;
996
- };
997
- /**
998
- * A LiveList notification that is sent in-client to any subscribers whenever
999
- * one or more of the items inside the LiveList instance have changed.
1000
- */
1001
- type LiveListUpdates<TItem extends Lson> = {
1002
- type: "LiveList";
1003
- node: LiveList<TItem>;
1004
- updates: LiveListUpdateDelta[];
1005
- };
1006
1141
  /**
1007
- * The LiveList class represents an ordered collection of items that is synchronized across clients.
1142
+ * A LiveFile is an immutable Storage leaf that references file bytes stored
1143
+ * outside the realtime Storage tree.
1008
1144
  */
1009
- declare class LiveList<TItem extends Lson> extends AbstractCrdt {
1145
+ declare class LiveFile extends AbstractCrdt {
1010
1146
  #private;
1011
- constructor(items: TItem[]);
1012
- /**
1013
- * Returns the number of elements.
1014
- */
1015
- get length(): number;
1016
- /**
1017
- * Adds one element to the end of the LiveList.
1018
- * @param element The element to add to the end of the LiveList.
1019
- */
1020
- push(element: TItem): void;
1021
- /**
1022
- * Inserts one element at a specified index.
1023
- * @param element The element to insert.
1024
- * @param index The index at which you want to insert the element.
1025
- */
1026
- insert(element: TItem, index: number): void;
1027
- /**
1028
- * Move one element from one index to another.
1029
- * @param index The index of the element to move
1030
- * @param targetIndex The index where the element should be after moving.
1031
- */
1032
- move(index: number, targetIndex: number): void;
1033
- /**
1034
- * Deletes an element at the specified index
1035
- * @param index The index of the element to delete
1036
- */
1037
- delete(index: number): void;
1038
- clear(): void;
1039
- set(index: number, item: TItem): void;
1040
- /**
1041
- * Tests whether all elements pass the test implemented by the provided function.
1042
- * @param predicate Function to test for each element, taking two arguments (the element and its index).
1043
- * @returns true if the predicate function returns a truthy value for every element. Otherwise, false.
1044
- */
1045
- every(predicate: (value: TItem, index: number) => unknown): boolean;
1046
- /**
1047
- * Creates an array with all elements that pass the test implemented by the provided function.
1048
- * @param predicate Function to test each element of the LiveList. Return a value that coerces to true to keep the element, or to false otherwise.
1049
- * @returns An array with the elements that pass the test.
1050
- */
1051
- filter(predicate: (value: TItem, index: number) => unknown): TItem[];
1052
- /**
1053
- * Returns the first element that satisfies the provided testing function.
1054
- * @param predicate Function to execute on each value.
1055
- * @returns The value of the first element in the LiveList that satisfies the provided testing function. Otherwise, undefined is returned.
1056
- */
1057
- find(predicate: (value: TItem, index: number) => unknown): TItem | undefined;
1058
- /**
1059
- * Returns the index of the first element in the LiveList that satisfies the provided testing function.
1060
- * @param predicate Function to execute on each value until the function returns true, indicating that the satisfying element was found.
1061
- * @returns The index of the first element in the LiveList that passes the test. Otherwise, -1.
1062
- */
1063
- findIndex(predicate: (value: TItem, index: number) => unknown): number;
1064
- /**
1065
- * Executes a provided function once for each element.
1066
- * @param callbackfn Function to execute on each element.
1067
- */
1068
- forEach(callbackfn: (value: TItem, index: number) => void): void;
1069
- /**
1070
- * Get the element at the specified index.
1071
- * @param index The index on the element to get.
1072
- * @returns The element at the specified index or undefined.
1073
- */
1074
- get(index: number): TItem | undefined;
1075
- /**
1076
- * Returns the first index at which a given element can be found in the LiveList, or -1 if it is not present.
1077
- * @param searchElement Element to locate.
1078
- * @param fromIndex The index to start the search at.
1079
- * @returns The first index of the element in the LiveList; -1 if not found.
1080
- */
1081
- indexOf(searchElement: TItem, fromIndex?: number): number;
1082
- /**
1083
- * Returns the last index at which a given element can be found in the LiveList, or -1 if it is not present. The LiveList is searched backwards, starting at fromIndex.
1084
- * @param searchElement Element to locate.
1085
- * @param fromIndex The index at which to start searching backwards.
1086
- * @returns The last index of the element in the LiveList; -1 if not found.
1087
- */
1088
- lastIndexOf(searchElement: TItem, fromIndex?: number): number;
1089
- /**
1090
- * Creates an array populated with the results of calling a provided function on every element.
1091
- * @param callback Function that is called for every element.
1092
- * @returns An array with each element being the result of the callback function.
1093
- */
1094
- map<U>(callback: (value: TItem, index: number) => U): U[];
1095
- /**
1096
- * Tests whether at least one element in the LiveList passes the test implemented by the provided function.
1097
- * @param predicate Function to test for each element.
1098
- * @returns true if the callback function returns a truthy value for at least one element. Otherwise, false.
1099
- */
1100
- some(predicate: (value: TItem, index: number) => unknown): boolean;
1101
- [Symbol.iterator](): IterableIterator<TItem>;
1102
- toJSON(): readonly ToJson<TItem>[];
1103
- clone(): LiveList<TItem>;
1147
+ constructor(data: LiveFileData);
1148
+ get data(): Readonly<LiveFileData>;
1149
+ get id(): string;
1150
+ get name(): string;
1151
+ get size(): number;
1152
+ get mimeType(): string;
1153
+ clone(): LiveFile;
1104
1154
  }
1105
1155
 
1106
1156
  /**
@@ -1113,7 +1163,7 @@ declare class LiveRegister<TValue extends Json> extends AbstractCrdt {
1113
1163
  clone(): TValue;
1114
1164
  }
1115
1165
 
1116
- type LiveStructure = LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
1166
+ type LiveStructure = LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson> | LiveFile;
1117
1167
  /**
1118
1168
  * Think of Lson as a sibling of the Json data tree, except that the nested
1119
1169
  * data structure can contain a mix of Json values and LiveStructure instances.
@@ -1149,7 +1199,7 @@ type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Ls
1149
1199
  readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
1150
1200
  } : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
1151
1201
  readonly [K in KS]: ToJson<V>;
1152
- } : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
1202
+ } : L extends LiveFile ? LiveFileData : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
1153
1203
  readonly [K in keyof L]: ToJson<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
1154
1204
  } : L extends Json ? L : never;
1155
1205
 
@@ -1847,6 +1897,16 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
1847
1897
  signal?: AbortSignal;
1848
1898
  }): Promise<CommentAttachment>;
1849
1899
  getOrCreateAttachmentUrlsStore(roomId: string): BatchStore<string, string>;
1900
+ getFileUrl(options: {
1901
+ roomId: string;
1902
+ fileId: string;
1903
+ }): Promise<string>;
1904
+ uploadFile({ roomId, file, signal, }: {
1905
+ roomId: string;
1906
+ file: File;
1907
+ signal?: AbortSignal;
1908
+ }): Promise<LiveFileData>;
1909
+ getOrCreateFileUrlsStore(roomId: string): BatchStore<string, string>;
1850
1910
  createTextMention({ roomId, mentionId, mention, }: {
1851
1911
  roomId: string;
1852
1912
  mentionId: string;
@@ -3565,6 +3625,9 @@ type GetThreadsSinceOptions = {
3565
3625
  type UploadAttachmentOptions = {
3566
3626
  signal?: AbortSignal;
3567
3627
  };
3628
+ type UploadFileOptions = {
3629
+ signal?: AbortSignal;
3630
+ };
3568
3631
  type ListTextVersionsSinceOptions = {
3569
3632
  since: Date;
3570
3633
  signal?: AbortSignal;
@@ -4073,6 +4136,8 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
4073
4136
  * await room.getAttachmentUrl("at_xxx");
4074
4137
  */
4075
4138
  getAttachmentUrl(attachmentId: string): Promise<string>;
4139
+ uploadFile(file: File, options?: UploadFileOptions): Promise<LiveFile>;
4140
+ getFileUrl(file: LiveFile | LiveFileData | string): Promise<string>;
4076
4141
  /**
4077
4142
  * Gets the user's subscription settings for the current room.
4078
4143
  *
@@ -4166,6 +4231,7 @@ type PrivateRoomApi = {
4166
4231
  incomingMessage(data: string): void;
4167
4232
  };
4168
4233
  attachmentUrlsStore: BatchStore<string, string>;
4234
+ fileUrlsStore: BatchStore<string, string>;
4169
4235
  };
4170
4236
  type Stackframe<P extends JsonObject> = Op | PresenceStackframe<P>;
4171
4237
  type PresenceStackframe<P extends JsonObject> = {
@@ -5065,7 +5131,11 @@ type PlainLsonList = {
5065
5131
  liveblocksType: "LiveList";
5066
5132
  data: PlainLson[];
5067
5133
  };
5068
- type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
5134
+ type PlainLsonFile = {
5135
+ liveblocksType: "LiveFile";
5136
+ data: LiveFileData;
5137
+ };
5138
+ type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | PlainLsonFile | Json;
5069
5139
 
5070
5140
  /**
5071
5141
  * Returns PlainLson for a given Json or LiveStructure, suitable for calling the storage init api
@@ -5173,6 +5243,7 @@ declare function Promise_withResolvers<T>(): ControlledPromise<T>;
5173
5243
  declare function createThreadId(): string;
5174
5244
  declare function createCommentId(): string;
5175
5245
  declare function createCommentAttachmentId(): string;
5246
+ declare function createStorageFileId(): string;
5176
5247
  declare function createInboxNotificationId(): string;
5177
5248
 
5178
5249
  /**
@@ -5780,4 +5851,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
5780
5851
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
5781
5852
  };
5782
5853
 
5783
- export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ThreadVisibility, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, validatePermissionsSet, wait, warnOnce, warnOnceIf, withTimeout };
5854
+ export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type CompactChildNode, type CompactFileNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateFileOp, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type FileStorageNode, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveFile, type LiveFileData, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonFile, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedFile, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ThreadVisibility, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UploadFileOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createStorageFileId, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isFileStorageNode, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, validatePermissionsSet, wait, warnOnce, warnOnceIf, withTimeout };