@liveblocks/core 2.15.1 → 2.16.0-toolbars1

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 CHANGED
@@ -5,7 +5,7 @@
5
5
  declare function detectDupes(pkgName: string, pkgVersion: string | false, // false if not built yet
6
6
  pkgFormat: string | false): void;
7
7
 
8
- declare type CustomAuthenticationResult = {
8
+ type CustomAuthenticationResult = {
9
9
  token: string;
10
10
  error?: never;
11
11
  } | {
@@ -28,13 +28,13 @@ declare type CustomAuthenticationResult = {
28
28
  * - JsonObject a JSON value whose outer type is an object
29
29
  *
30
30
  */
31
- declare type Json = JsonScalar | JsonArray | JsonObject;
32
- declare type JsonScalar = string | number | boolean | null;
33
- declare type JsonArray = Json[];
31
+ type Json = JsonScalar | JsonArray | JsonObject;
32
+ type JsonScalar = string | number | boolean | null;
33
+ type JsonArray = Json[];
34
34
  /**
35
35
  * Any valid JSON object.
36
36
  */
37
- declare type JsonObject = {
37
+ type JsonObject = {
38
38
  [key: string]: Json | undefined;
39
39
  };
40
40
  declare function isJsonScalar(data: Json): data is JsonScalar;
@@ -46,7 +46,7 @@ declare function isJsonObject(data: Json): data is JsonObject;
46
46
  * object is fine, but _if_ it has a name field, it _must_ be a string."
47
47
  * (Ditto for avatar.)
48
48
  */
49
- declare type IUserInfo = {
49
+ type IUserInfo = {
50
50
  [key: string]: Json | undefined;
51
51
  name?: string;
52
52
  avatar?: string;
@@ -54,7 +54,7 @@ declare type IUserInfo = {
54
54
  /**
55
55
  * This type is used by clients to define the metadata for a user.
56
56
  */
57
- declare type BaseUserMeta = {
57
+ type BaseUserMeta = {
58
58
  /**
59
59
  * The id of the user that has been set in the authentication endpoint.
60
60
  * Useful to get additional information about the connected user.
@@ -74,9 +74,9 @@ declare enum Permission {
74
74
  CommentsRead = "comments:read"
75
75
  }
76
76
 
77
- declare type Callback<T> = (event: T) => void;
78
- declare type UnsubscribeCallback = () => void;
79
- declare type Observable<T> = {
77
+ type Callback<T> = (event: T) => void;
78
+ type UnsubscribeCallback = () => void;
79
+ type Observable<T> = {
80
80
  /**
81
81
  * Register a callback function to be called whenever the event source emits
82
82
  * an event.
@@ -95,7 +95,7 @@ declare type Observable<T> = {
95
95
  */
96
96
  waitUntil(predicate?: (event: T) => boolean): Promise<T>;
97
97
  };
98
- declare type EventSource<T> = Observable<T> & {
98
+ type EventSource<T> = Observable<T> & {
99
99
  /**
100
100
  * Notify all subscribers about the event.
101
101
  */
@@ -227,7 +227,7 @@ declare enum WebsocketCloseCodes {
227
227
  * a Room, as returned by `room.getStatus()`. Can be used to implement
228
228
  * a connection status badge.
229
229
  */
230
- declare type Status = "initial" | "connecting" | "connected" | "reconnecting" | "disconnected";
230
+ type Status = "initial" | "connecting" | "connected" | "reconnecting" | "disconnected";
231
231
  /**
232
232
  * Used to report about app-level reconnection issues.
233
233
  *
@@ -237,7 +237,7 @@ declare type Status = "initial" | "connecting" | "connected" | "reconnecting" |
237
237
  * to inform your users about, for example, by throwing a toast message on
238
238
  * screen, or show a "trying to reconnect" banner.
239
239
  */
240
- declare type LostConnectionEvent = "lost" | "restored" | "failed";
240
+ type LostConnectionEvent = "lost" | "restored" | "failed";
241
241
  /**
242
242
  * Arbitrary record that will be used as the authentication "authValue". It's the
243
243
  * value that is returned by calling the authentication delegate, and will get
@@ -245,11 +245,11 @@ declare type LostConnectionEvent = "lost" | "restored" | "failed";
245
245
  * the connection manager, but its value will not be interpreted, so it can be
246
246
  * any value (except null).
247
247
  */
248
- declare type BaseAuthResult = NonNullable<Json>;
248
+ type BaseAuthResult = NonNullable<Json>;
249
249
  declare class LiveblocksError extends Error {
250
250
  code: number;
251
251
  }
252
- declare type Delegates<T extends BaseAuthResult> = {
252
+ type Delegates<T extends BaseAuthResult> = {
253
253
  authenticate: () => Promise<T>;
254
254
  createSocket: (authValue: T) => IWebSocketInstance;
255
255
  canZombie: () => boolean;
@@ -270,15 +270,15 @@ declare enum OpCode {
270
270
  * These operations are the payload for {@link UpdateStorageServerMsg} messages
271
271
  * only.
272
272
  */
273
- declare type Op = AckOp | CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
274
- declare type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
275
- declare type UpdateObjectOp = {
273
+ type Op = AckOp | CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
274
+ type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
275
+ type UpdateObjectOp = {
276
276
  readonly opId?: string;
277
277
  readonly id: string;
278
278
  readonly type: OpCode.UPDATE_OBJECT;
279
279
  readonly data: Partial<JsonObject>;
280
280
  };
281
- declare type CreateObjectOp = {
281
+ type CreateObjectOp = {
282
282
  readonly opId?: string;
283
283
  readonly id: string;
284
284
  readonly intent?: "set";
@@ -288,7 +288,7 @@ declare type CreateObjectOp = {
288
288
  readonly parentKey: string;
289
289
  readonly data: JsonObject;
290
290
  };
291
- declare type CreateListOp = {
291
+ type CreateListOp = {
292
292
  readonly opId?: string;
293
293
  readonly id: string;
294
294
  readonly intent?: "set";
@@ -297,7 +297,7 @@ declare type CreateListOp = {
297
297
  readonly parentId: string;
298
298
  readonly parentKey: string;
299
299
  };
300
- declare type CreateMapOp = {
300
+ type CreateMapOp = {
301
301
  readonly opId?: string;
302
302
  readonly id: string;
303
303
  readonly intent?: "set";
@@ -306,7 +306,7 @@ declare type CreateMapOp = {
306
306
  readonly parentId: string;
307
307
  readonly parentKey: string;
308
308
  };
309
- declare type CreateRegisterOp = {
309
+ type CreateRegisterOp = {
310
310
  readonly opId?: string;
311
311
  readonly id: string;
312
312
  readonly intent?: "set";
@@ -316,12 +316,12 @@ declare type CreateRegisterOp = {
316
316
  readonly parentKey: string;
317
317
  readonly data: Json;
318
318
  };
319
- declare type DeleteCrdtOp = {
319
+ type DeleteCrdtOp = {
320
320
  readonly opId?: string;
321
321
  readonly id: string;
322
322
  readonly type: OpCode.DELETE_CRDT;
323
323
  };
324
- declare type AckOp = {
324
+ type AckOp = {
325
325
  readonly type: OpCode.DELETE_CRDT;
326
326
  readonly id: "ACK";
327
327
  readonly opId: string;
@@ -345,13 +345,13 @@ declare type AckOp = {
345
345
  * node does not exist, but as a side-effect the Op will get acknowledged.
346
346
  */
347
347
  declare function ackOp(opId: string): AckOp;
348
- declare type SetParentKeyOp = {
348
+ type SetParentKeyOp = {
349
349
  readonly opId?: string;
350
350
  readonly id: string;
351
351
  readonly type: OpCode.SET_PARENT_KEY;
352
352
  readonly parentKey: string;
353
353
  };
354
- declare type DeleteObjectKeyOp = {
354
+ type DeleteObjectKeyOp = {
355
355
  readonly opId?: string;
356
356
  readonly id: string;
357
357
  readonly type: OpCode.DELETE_OBJECT_KEY;
@@ -362,15 +362,15 @@ declare type DeleteObjectKeyOp = {
362
362
  * Represents an indefinitely deep arbitrary immutable data
363
363
  * structure, as returned by the .toImmutable().
364
364
  */
365
- declare type Immutable = Scalar | ImmutableList | ImmutableObject | ImmutableMap;
366
- declare type Scalar = string | number | boolean | null;
367
- declare type ImmutableList = readonly Immutable[];
368
- declare type ImmutableObject = {
365
+ type Immutable = Scalar | ImmutableList | ImmutableObject | ImmutableMap;
366
+ type Scalar = string | number | boolean | null;
367
+ type ImmutableList = readonly Immutable[];
368
+ type ImmutableObject = {
369
369
  readonly [key: string]: Immutable | undefined;
370
370
  };
371
- declare type ImmutableMap = ReadonlyMap<string, Immutable>;
371
+ type ImmutableMap = ReadonlyMap<string, Immutable>;
372
372
 
373
- declare type UpdateDelta = {
373
+ type UpdateDelta = {
374
374
  type: "update";
375
375
  } | {
376
376
  type: "delete";
@@ -418,20 +418,20 @@ declare type UpdateDelta = {
418
418
  *
419
419
  */
420
420
 
421
- declare type PlainLsonFields = Record<string, PlainLson>;
422
- declare type PlainLsonObject = {
421
+ type PlainLsonFields = Record<string, PlainLson>;
422
+ type PlainLsonObject = {
423
423
  liveblocksType: "LiveObject";
424
424
  data: PlainLsonFields;
425
425
  };
426
- declare type PlainLsonMap = {
426
+ type PlainLsonMap = {
427
427
  liveblocksType: "LiveMap";
428
428
  data: PlainLsonFields;
429
429
  };
430
- declare type PlainLsonList = {
430
+ type PlainLsonList = {
431
431
  liveblocksType: "LiveList";
432
432
  data: PlainLson[];
433
433
  };
434
- declare type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
434
+ type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
435
435
 
436
436
  /**
437
437
  * Helper type to convert any valid Lson type to the equivalent Json type.
@@ -449,7 +449,7 @@ declare type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
449
449
  * // { readonly a: null, readonly b: readonly string[], readonly c?: number }
450
450
  *
451
451
  */
452
- declare type ToImmutable<L extends Lson | LsonObject> = L extends LiveList<infer I> ? readonly ToImmutable<I>[] : L extends LiveObject<infer O> ? ToImmutable<O> : L extends LiveMap<infer K, infer V> ? ReadonlyMap<K, ToImmutable<V>> : L extends LsonObject ? {
452
+ type ToImmutable<L extends Lson | LsonObject> = L extends LiveList<infer I> ? readonly ToImmutable<I>[] : L extends LiveObject<infer O> ? ToImmutable<O> : L extends LiveMap<infer K, infer V> ? ReadonlyMap<K, ToImmutable<V>> : L extends LsonObject ? {
453
453
  readonly [K in keyof L]: ToImmutable<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
454
454
  } : L extends Json ? L : never;
455
455
  /**
@@ -461,7 +461,7 @@ declare function toPlainLson(lson: Lson): PlainLson;
461
461
  * A LiveMap notification that is sent in-client to any subscribers whenever
462
462
  * one or more of the values inside the LiveMap instance have changed.
463
463
  */
464
- declare type LiveMapUpdates<TKey extends string, TValue extends Lson> = {
464
+ type LiveMapUpdates<TKey extends string, TValue extends Lson> = {
465
465
  type: "LiveMap";
466
466
  node: LiveMap<TKey, TValue>;
467
467
  updates: {
@@ -528,16 +528,16 @@ declare class LiveMap<TKey extends string, TValue extends Lson> extends Abstract
528
528
  clone(): LiveMap<TKey, TValue>;
529
529
  }
530
530
 
531
- declare type StorageCallback = (updates: StorageUpdate[]) => void;
532
- declare type LiveMapUpdate = LiveMapUpdates<string, Lson>;
533
- declare type LiveObjectUpdate = LiveObjectUpdates<LsonObject>;
534
- declare type LiveListUpdate = LiveListUpdates<Lson>;
531
+ type StorageCallback = (updates: StorageUpdate[]) => void;
532
+ type LiveMapUpdate = LiveMapUpdates<string, Lson>;
533
+ type LiveObjectUpdate = LiveObjectUpdates<LsonObject>;
534
+ type LiveListUpdate = LiveListUpdates<Lson>;
535
535
  /**
536
536
  * The payload of notifications sent (in-client) when LiveStructures change.
537
537
  * Messages of this kind are not originating from the network, but are 100%
538
538
  * in-client.
539
539
  */
540
- declare type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
540
+ type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
541
541
 
542
542
  declare abstract class AbstractCrdt {
543
543
  #private;
@@ -553,7 +553,7 @@ declare abstract class AbstractCrdt {
553
553
  abstract clone(): Lson;
554
554
  }
555
555
 
556
- declare type LiveListUpdateDelta = {
556
+ type LiveListUpdateDelta = {
557
557
  type: "insert";
558
558
  index: number;
559
559
  item: Lson;
@@ -575,7 +575,7 @@ declare type LiveListUpdateDelta = {
575
575
  * A LiveList notification that is sent in-client to any subscribers whenever
576
576
  * one or more of the items inside the LiveList instance have changed.
577
577
  */
578
- declare type LiveListUpdates<TItem extends Lson> = {
578
+ type LiveListUpdates<TItem extends Lson> = {
579
579
  type: "LiveList";
580
580
  node: LiveList<TItem>;
581
581
  updates: LiveListUpdateDelta[];
@@ -694,23 +694,23 @@ declare class LiveRegister<TValue extends Json> extends AbstractCrdt {
694
694
  clone(): TValue;
695
695
  }
696
696
 
697
- declare type LiveStructure = LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
697
+ type LiveStructure = LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
698
698
  /**
699
699
  * Think of Lson as a sibling of the Json data tree, except that the nested
700
700
  * data structure can contain a mix of Json values and LiveStructure instances.
701
701
  */
702
- declare type Lson = Json | LiveStructure;
702
+ type Lson = Json | LiveStructure;
703
703
  /**
704
704
  * LiveNode is the internal tree for managing Live data structures. The key
705
705
  * difference with Lson is that all the Json values get represented in
706
706
  * a LiveRegister node.
707
707
  */
708
- declare type LiveNode = LiveStructure | LiveRegister<Json>;
708
+ type LiveNode = LiveStructure | LiveRegister<Json>;
709
709
  /**
710
710
  * A mapping of keys to Lson values. A Lson value is any valid JSON
711
711
  * value or a Live storage data structure (LiveMap, LiveList, etc.)
712
712
  */
713
- declare type LsonObject = {
713
+ type LsonObject = {
714
714
  [key: string]: Lson | undefined;
715
715
  };
716
716
  /**
@@ -729,13 +729,13 @@ declare type LsonObject = {
729
729
  * // { a: null, b: string[], c?: number }
730
730
  *
731
731
  */
732
- declare type ToJson<T extends Lson | LsonObject> = T extends Json ? T : T extends LsonObject ? {
732
+ type ToJson<T extends Lson | LsonObject> = T extends Json ? T : T extends LsonObject ? {
733
733
  [K in keyof T]: ToJson<Exclude<T[K], undefined>> | (undefined extends T[K] ? undefined : never);
734
734
  } : T extends LiveList<infer I> ? ToJson<I>[] : T extends LiveObject<infer O> ? ToJson<O> : T extends LiveMap<infer KS, infer V> ? {
735
735
  [K in KS]: ToJson<V>;
736
736
  } : never;
737
737
 
738
- declare type LiveObjectUpdateDelta<O extends {
738
+ type LiveObjectUpdateDelta<O extends {
739
739
  [key: string]: unknown;
740
740
  }> = {
741
741
  [K in keyof O]?: UpdateDelta | undefined;
@@ -744,7 +744,7 @@ declare type LiveObjectUpdateDelta<O extends {
744
744
  * A LiveObject notification that is sent in-client to any subscribers whenever
745
745
  * one or more of the entries inside the LiveObject instance have changed.
746
746
  */
747
- declare type LiveObjectUpdates<TData extends LsonObject> = {
747
+ type LiveObjectUpdates<TData extends LsonObject> = {
748
748
  type: "LiveObject";
749
749
  node: LiveObject<TData>;
750
750
  updates: LiveObjectUpdateDelta<TData>;
@@ -786,11 +786,11 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
786
786
  clone(): LiveObject<O>;
787
787
  }
788
788
 
789
- declare type DateToString<T> = {
789
+ type DateToString<T> = {
790
790
  [P in keyof T]: T[P] extends Date ? string : T[P] extends Date | null ? string | null : T[P] extends Date | undefined ? string | undefined : T[P];
791
791
  };
792
792
 
793
- declare type InboxNotificationThreadData = {
793
+ type InboxNotificationThreadData = {
794
794
  kind: "thread";
795
795
  id: string;
796
796
  roomId: string;
@@ -798,7 +798,7 @@ declare type InboxNotificationThreadData = {
798
798
  notifiedAt: Date;
799
799
  readAt: Date | null;
800
800
  };
801
- declare type InboxNotificationTextMentionData = {
801
+ type InboxNotificationTextMentionData = {
802
802
  kind: "textMention";
803
803
  id: string;
804
804
  roomId: string;
@@ -807,14 +807,14 @@ declare type InboxNotificationTextMentionData = {
807
807
  createdBy: string;
808
808
  mentionId: string;
809
809
  };
810
- declare type InboxNotificationTextMentionDataPlain = DateToString<InboxNotificationTextMentionData>;
811
- declare type ActivityData = Record<string, string | boolean | number | undefined>;
812
- declare type InboxNotificationActivity<K extends keyof DAD = keyof DAD> = {
810
+ type InboxNotificationTextMentionDataPlain = DateToString<InboxNotificationTextMentionData>;
811
+ type ActivityData = Record<string, string | boolean | number | undefined>;
812
+ type InboxNotificationActivity<K extends keyof DAD = keyof DAD> = {
813
813
  id: string;
814
814
  createdAt: Date;
815
815
  data: DAD[K];
816
816
  };
817
- declare type InboxNotificationCustomData<K extends keyof DAD = keyof DAD> = {
817
+ type InboxNotificationCustomData<K extends keyof DAD = keyof DAD> = {
818
818
  kind: K;
819
819
  id: string;
820
820
  roomId?: string;
@@ -823,24 +823,24 @@ declare type InboxNotificationCustomData<K extends keyof DAD = keyof DAD> = {
823
823
  readAt: Date | null;
824
824
  activities: InboxNotificationActivity<K>[];
825
825
  };
826
- declare type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData;
827
- declare type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
828
- declare type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
826
+ type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData;
827
+ type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
828
+ type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
829
829
  activities: DateToString<InboxNotificationActivity>[];
830
830
  };
831
- declare type InboxNotificationDataPlain = InboxNotificationThreadDataPlain | InboxNotificationCustomDataPlain | InboxNotificationTextMentionDataPlain;
832
- declare type InboxNotificationDeleteInfo = {
831
+ type InboxNotificationDataPlain = InboxNotificationThreadDataPlain | InboxNotificationCustomDataPlain | InboxNotificationTextMentionDataPlain;
832
+ type InboxNotificationDeleteInfo = {
833
833
  type: "deletedInboxNotification";
834
834
  id: string;
835
835
  roomId: string;
836
836
  deletedAt: Date;
837
837
  };
838
838
 
839
- declare type BaseActivitiesData = {
839
+ type BaseActivitiesData = {
840
840
  [key: `$${string}`]: ActivityData;
841
841
  };
842
842
 
843
- declare type BaseRoomInfo = {
843
+ type BaseRoomInfo = {
844
844
  [key: string]: Json | undefined;
845
845
  /**
846
846
  * The name of the room.
@@ -852,22 +852,22 @@ declare type BaseRoomInfo = {
852
852
  url?: string;
853
853
  };
854
854
 
855
- declare type BaseMetadata = Record<string, string | boolean | number | undefined>;
856
- declare type CommentReaction = {
855
+ type BaseMetadata = Record<string, string | boolean | number | undefined>;
856
+ type CommentReaction = {
857
857
  emoji: string;
858
858
  createdAt: Date;
859
859
  users: {
860
860
  id: string;
861
861
  }[];
862
862
  };
863
- declare type CommentAttachment = {
863
+ type CommentAttachment = {
864
864
  type: "attachment";
865
865
  id: string;
866
866
  name: string;
867
867
  size: number;
868
868
  mimeType: string;
869
869
  };
870
- declare type CommentLocalAttachmentIdle = {
870
+ type CommentLocalAttachmentIdle = {
871
871
  type: "localAttachment";
872
872
  status: "idle";
873
873
  id: string;
@@ -876,7 +876,7 @@ declare type CommentLocalAttachmentIdle = {
876
876
  mimeType: string;
877
877
  file: File;
878
878
  };
879
- declare type CommentLocalAttachmentUploading = {
879
+ type CommentLocalAttachmentUploading = {
880
880
  type: "localAttachment";
881
881
  status: "uploading";
882
882
  id: string;
@@ -885,7 +885,7 @@ declare type CommentLocalAttachmentUploading = {
885
885
  mimeType: string;
886
886
  file: File;
887
887
  };
888
- declare type CommentLocalAttachmentUploaded = {
888
+ type CommentLocalAttachmentUploaded = {
889
889
  type: "localAttachment";
890
890
  status: "uploaded";
891
891
  id: string;
@@ -894,7 +894,7 @@ declare type CommentLocalAttachmentUploaded = {
894
894
  mimeType: string;
895
895
  file: File;
896
896
  };
897
- declare type CommentLocalAttachmentError = {
897
+ type CommentLocalAttachmentError = {
898
898
  type: "localAttachment";
899
899
  status: "error";
900
900
  id: string;
@@ -904,12 +904,12 @@ declare type CommentLocalAttachmentError = {
904
904
  file: File;
905
905
  error: Error;
906
906
  };
907
- declare type CommentLocalAttachment = CommentLocalAttachmentIdle | CommentLocalAttachmentUploading | CommentLocalAttachmentUploaded | CommentLocalAttachmentError;
908
- declare type CommentMixedAttachment = CommentAttachment | CommentLocalAttachment;
907
+ type CommentLocalAttachment = CommentLocalAttachmentIdle | CommentLocalAttachmentUploading | CommentLocalAttachmentUploaded | CommentLocalAttachmentError;
908
+ type CommentMixedAttachment = CommentAttachment | CommentLocalAttachment;
909
909
  /**
910
910
  * Represents a comment.
911
911
  */
912
- declare type CommentData = {
912
+ type CommentData = {
913
913
  type: "comment";
914
914
  id: string;
915
915
  threadId: string;
@@ -926,7 +926,7 @@ declare type CommentData = {
926
926
  body?: never;
927
927
  deletedAt: Date;
928
928
  });
929
- declare type CommentDataPlain = Omit<DateToString<CommentData>, "reactions" | "body"> & {
929
+ type CommentDataPlain = Omit<DateToString<CommentData>, "reactions" | "body"> & {
930
930
  reactions: DateToString<CommentReaction>[];
931
931
  } & ({
932
932
  body: CommentBody;
@@ -935,43 +935,43 @@ declare type CommentDataPlain = Omit<DateToString<CommentData>, "reactions" | "b
935
935
  body?: never;
936
936
  deletedAt: string;
937
937
  });
938
- declare type CommentBodyBlockElement = CommentBodyParagraph;
939
- declare type CommentBodyInlineElement = CommentBodyText | CommentBodyMention | CommentBodyLink;
940
- declare type CommentBodyElement = CommentBodyBlockElement | CommentBodyInlineElement;
941
- declare type CommentBodyParagraph = {
938
+ type CommentBodyBlockElement = CommentBodyParagraph;
939
+ type CommentBodyInlineElement = CommentBodyText | CommentBodyMention | CommentBodyLink;
940
+ type CommentBodyElement = CommentBodyBlockElement | CommentBodyInlineElement;
941
+ type CommentBodyParagraph = {
942
942
  type: "paragraph";
943
943
  children: CommentBodyInlineElement[];
944
944
  };
945
- declare type CommentBodyMention = {
945
+ type CommentBodyMention = {
946
946
  type: "mention";
947
947
  id: string;
948
948
  };
949
- declare type CommentBodyLink = {
949
+ type CommentBodyLink = {
950
950
  type: "link";
951
951
  url: string;
952
952
  text?: string;
953
953
  };
954
- declare type CommentBodyText = {
954
+ type CommentBodyText = {
955
955
  bold?: boolean;
956
956
  italic?: boolean;
957
957
  strikethrough?: boolean;
958
958
  code?: boolean;
959
959
  text: string;
960
960
  };
961
- declare type CommentBody = {
961
+ type CommentBody = {
962
962
  version: 1;
963
963
  content: CommentBodyBlockElement[];
964
964
  };
965
- declare type CommentUserReaction = {
965
+ type CommentUserReaction = {
966
966
  emoji: string;
967
967
  createdAt: Date;
968
968
  userId: string;
969
969
  };
970
- declare type CommentUserReactionPlain = DateToString<CommentUserReaction>;
970
+ type CommentUserReactionPlain = DateToString<CommentUserReaction>;
971
971
  /**
972
972
  * Represents a thread of comments.
973
973
  */
974
- declare type ThreadData<M extends BaseMetadata = DM> = {
974
+ type ThreadData<M extends BaseMetadata = DM> = {
975
975
  type: "thread";
976
976
  id: string;
977
977
  roomId: string;
@@ -984,17 +984,17 @@ declare type ThreadData<M extends BaseMetadata = DM> = {
984
984
  interface ThreadDataWithDeleteInfo<M extends BaseMetadata = DM> extends ThreadData<M> {
985
985
  deletedAt?: Date;
986
986
  }
987
- declare type ThreadDataPlain<M extends BaseMetadata> = Omit<DateToString<ThreadData<M>>, "comments" | "metadata"> & {
987
+ type ThreadDataPlain<M extends BaseMetadata> = Omit<DateToString<ThreadData<M>>, "comments" | "metadata"> & {
988
988
  comments: CommentDataPlain[];
989
989
  metadata: M;
990
990
  };
991
- declare type ThreadDeleteInfo = {
991
+ type ThreadDeleteInfo = {
992
992
  type: "deletedThread";
993
993
  id: string;
994
994
  roomId: string;
995
995
  deletedAt: Date;
996
996
  };
997
- declare type StringOperators<T> = T | {
997
+ type StringOperators<T> = T | {
998
998
  startsWith: string;
999
999
  };
1000
1000
  /**
@@ -1005,7 +1005,7 @@ declare type StringOperators<T> = T | {
1005
1005
  * - to strings:
1006
1006
  * - `startsWith` (`^` in query string)
1007
1007
  */
1008
- declare type QueryMetadata<M extends BaseMetadata> = {
1008
+ type QueryMetadata<M extends BaseMetadata> = {
1009
1009
  [K in keyof M]: string extends M[K] ? StringOperators<M[K]> : M[K];
1010
1010
  };
1011
1011
 
@@ -1017,20 +1017,20 @@ declare global {
1017
1017
  [key: string]: unknown;
1018
1018
  }
1019
1019
  }
1020
- declare type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "RoomInfo" | "ActivitiesData";
1021
- declare type MakeErrorString<K extends ExtendableTypes, Reason extends string = "does not match its requirements"> = `The type you provided for '${K}' ${Reason}. To learn how to fix this, see https://liveblocks.io/docs/errors/${K}`;
1022
- declare type GetOverride<K extends ExtendableTypes, B, Reason extends string = "does not match its requirements"> = GetOverrideOrErrorValue<K, B, MakeErrorString<K, Reason>>;
1023
- declare type GetOverrideOrErrorValue<K extends ExtendableTypes, B, ErrorType> = unknown extends Liveblocks[K] ? B : Liveblocks[K] extends B ? Liveblocks[K] : ErrorType;
1024
- declare type DP = GetOverride<"Presence", JsonObject, "is not a valid JSON object">;
1025
- declare type DS = GetOverride<"Storage", LsonObject, "is not a valid LSON value">;
1026
- declare type DU = GetOverrideOrErrorValue<"UserMeta", BaseUserMeta, Record<"id" | "info", MakeErrorString<"UserMeta">>>;
1027
- declare type DE = GetOverride<"RoomEvent", Json, "is not a valid JSON value">;
1028
- declare type DM = GetOverride<"ThreadMetadata", BaseMetadata>;
1029
- declare type DRI = GetOverride<"RoomInfo", BaseRoomInfo>;
1030
- declare type DAD = GetOverrideOrErrorValue<"ActivitiesData", BaseActivitiesData, {
1020
+ type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "RoomInfo" | "ActivitiesData";
1021
+ type MakeErrorString<K extends ExtendableTypes, Reason extends string = "does not match its requirements"> = `The type you provided for '${K}' ${Reason}. To learn how to fix this, see https://liveblocks.io/docs/errors/${K}`;
1022
+ type GetOverride<K extends ExtendableTypes, B, Reason extends string = "does not match its requirements"> = GetOverrideOrErrorValue<K, B, MakeErrorString<K, Reason>>;
1023
+ type GetOverrideOrErrorValue<K extends ExtendableTypes, B, ErrorType> = unknown extends Liveblocks[K] ? B : Liveblocks[K] extends B ? Liveblocks[K] : ErrorType;
1024
+ type DP = GetOverride<"Presence", JsonObject, "is not a valid JSON object">;
1025
+ type DS = GetOverride<"Storage", LsonObject, "is not a valid LSON value">;
1026
+ type DU = GetOverrideOrErrorValue<"UserMeta", BaseUserMeta, Record<"id" | "info", MakeErrorString<"UserMeta">>>;
1027
+ type DE = GetOverride<"RoomEvent", Json, "is not a valid JSON value">;
1028
+ type DM = GetOverride<"ThreadMetadata", BaseMetadata>;
1029
+ type DRI = GetOverride<"RoomInfo", BaseRoomInfo>;
1030
+ type DAD = GetOverrideOrErrorValue<"ActivitiesData", BaseActivitiesData, {
1031
1031
  [K in keyof Liveblocks["ActivitiesData"]]: "At least one of the custom notification kinds you provided for 'ActivitiesData' does not match its requirements. To learn how to fix this, see https://liveblocks.io/docs/errors/ActivitiesData";
1032
1032
  }>;
1033
- declare type KDAD = keyof DAD extends `$${string}` ? keyof DAD : "Custom notification kinds must start with '$' but your custom 'ActivitiesData' type contains at least one kind which doesn't. To learn how to fix this, see https://liveblocks.io/docs/errors/ActivitiesData";
1033
+ type KDAD = keyof DAD extends `$${string}` ? keyof DAD : "Custom notification kinds must start with '$' but your custom 'ActivitiesData' type contains at least one kind which doesn't. To learn how to fix this, see https://liveblocks.io/docs/errors/ActivitiesData";
1034
1034
 
1035
1035
  /**
1036
1036
  * Use this symbol to brand an object property as internal.
@@ -1051,29 +1051,30 @@ declare type KDAD = keyof DAD extends `$${string}` ? keyof DAD : "Custom notific
1051
1051
  */
1052
1052
  declare const kInternal: unique symbol;
1053
1053
 
1054
- declare type RenameDataField<T, TFieldName extends string> = T extends any ? {
1054
+ type RenameDataField<T, TFieldName extends string> = T extends any ? {
1055
1055
  [K in keyof T as K extends "data" ? TFieldName : K]: T[K];
1056
1056
  } : never;
1057
- declare type AsyncLoading<F extends string = "data"> = RenameDataField<{
1057
+ type AsyncLoading<F extends string = "data"> = RenameDataField<{
1058
1058
  readonly isLoading: true;
1059
1059
  readonly data?: never;
1060
1060
  readonly error?: never;
1061
1061
  }, F>;
1062
- declare type AsyncSuccess<T, F extends string = "data"> = RenameDataField<{
1062
+ type AsyncSuccess<T, F extends string = "data"> = RenameDataField<{
1063
1063
  readonly isLoading: false;
1064
1064
  readonly data: T;
1065
1065
  readonly error?: never;
1066
1066
  }, F>;
1067
- declare type AsyncError<F extends string = "data"> = RenameDataField<{
1067
+ type AsyncError<F extends string = "data"> = RenameDataField<{
1068
1068
  readonly isLoading: false;
1069
1069
  readonly data?: never;
1070
1070
  readonly error: Error;
1071
1071
  }, F>;
1072
- declare type AsyncResult<T, F extends string = "data"> = AsyncLoading<F> | AsyncSuccess<T, F> | AsyncError<F>;
1072
+ type AsyncResult<T, F extends string = "data"> = AsyncLoading<F> | AsyncSuccess<T, F> | AsyncError<F>;
1073
1073
 
1074
- declare type BatchStore<O, I> = Observable<void> & {
1075
- get: (input: I) => Promise<void>;
1076
- getState: (input: I) => AsyncResult<O> | undefined;
1074
+ type BatchStore<O, I> = {
1075
+ subscribe: (callback: Callback<void>) => UnsubscribeCallback;
1076
+ enqueue: (input: I) => Promise<void>;
1077
+ getItemState: (input: I) => AsyncResult<O> | undefined;
1077
1078
  invalidate: (inputs?: I[]) => void;
1078
1079
  };
1079
1080
 
@@ -1088,12 +1089,12 @@ declare enum ClientMsgCode {
1088
1089
  /**
1089
1090
  * Messages that can be sent from the client to the server.
1090
1091
  */
1091
- declare type ClientMsg<P extends JsonObject, E extends Json> = BroadcastEventClientMsg<E> | UpdatePresenceClientMsg<P> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
1092
- declare type BroadcastEventClientMsg<E extends Json> = {
1092
+ type ClientMsg<P extends JsonObject, E extends Json> = BroadcastEventClientMsg<E> | UpdatePresenceClientMsg<P> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
1093
+ type BroadcastEventClientMsg<E extends Json> = {
1093
1094
  type: ClientMsgCode.BROADCAST_EVENT;
1094
1095
  event: E;
1095
1096
  };
1096
- declare type UpdatePresenceClientMsg<P extends JsonObject> = {
1097
+ type UpdatePresenceClientMsg<P extends JsonObject> = {
1097
1098
  readonly type: ClientMsgCode.UPDATE_PRESENCE;
1098
1099
  /**
1099
1100
  * Set this to any number to signify that this is a Full Presence™
@@ -1119,56 +1120,56 @@ declare type UpdatePresenceClientMsg<P extends JsonObject> = {
1119
1120
  readonly targetActor?: undefined;
1120
1121
  readonly data: Partial<P>;
1121
1122
  };
1122
- declare type UpdateStorageClientMsg = {
1123
+ type UpdateStorageClientMsg = {
1123
1124
  readonly type: ClientMsgCode.UPDATE_STORAGE;
1124
1125
  readonly ops: Op[];
1125
1126
  };
1126
- declare type FetchStorageClientMsg = {
1127
+ type FetchStorageClientMsg = {
1127
1128
  readonly type: ClientMsgCode.FETCH_STORAGE;
1128
1129
  };
1129
- declare type FetchYDocClientMsg = {
1130
+ type FetchYDocClientMsg = {
1130
1131
  readonly type: ClientMsgCode.FETCH_YDOC;
1131
1132
  readonly vector: string;
1132
1133
  readonly guid?: string;
1133
1134
  };
1134
- declare type UpdateYDocClientMsg = {
1135
+ type UpdateYDocClientMsg = {
1135
1136
  readonly type: ClientMsgCode.UPDATE_YDOC;
1136
1137
  readonly update: string;
1137
1138
  readonly guid?: string;
1138
1139
  };
1139
1140
 
1140
- declare type IdTuple<T> = [id: string, value: T];
1141
+ type IdTuple<T> = [id: string, value: T];
1141
1142
  declare enum CrdtType {
1142
1143
  OBJECT = 0,
1143
1144
  LIST = 1,
1144
1145
  MAP = 2,
1145
1146
  REGISTER = 3
1146
1147
  }
1147
- declare type SerializedCrdt = SerializedRootObject | SerializedChild;
1148
- declare type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
1149
- declare type SerializedRootObject = {
1148
+ type SerializedCrdt = SerializedRootObject | SerializedChild;
1149
+ type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
1150
+ type SerializedRootObject = {
1150
1151
  readonly type: CrdtType.OBJECT;
1151
1152
  readonly data: JsonObject;
1152
1153
  readonly parentId?: never;
1153
1154
  readonly parentKey?: never;
1154
1155
  };
1155
- declare type SerializedObject = {
1156
+ type SerializedObject = {
1156
1157
  readonly type: CrdtType.OBJECT;
1157
1158
  readonly parentId: string;
1158
1159
  readonly parentKey: string;
1159
1160
  readonly data: JsonObject;
1160
1161
  };
1161
- declare type SerializedList = {
1162
+ type SerializedList = {
1162
1163
  readonly type: CrdtType.LIST;
1163
1164
  readonly parentId: string;
1164
1165
  readonly parentKey: string;
1165
1166
  };
1166
- declare type SerializedMap = {
1167
+ type SerializedMap = {
1167
1168
  readonly type: CrdtType.MAP;
1168
1169
  readonly parentId: string;
1169
1170
  readonly parentKey: string;
1170
1171
  };
1171
- declare type SerializedRegister = {
1172
+ type SerializedRegister = {
1172
1173
  readonly type: CrdtType.REGISTER;
1173
1174
  readonly parentId: string;
1174
1175
  readonly parentKey: string;
@@ -1200,46 +1201,46 @@ declare enum ServerMsgCode {
1200
1201
  /**
1201
1202
  * Messages that can be sent from the server to the client.
1202
1203
  */
1203
- declare type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdateServerMsg | CommentsEventServerMsg;
1204
- declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1205
- declare type ThreadCreatedEvent = {
1204
+ type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdateServerMsg | CommentsEventServerMsg;
1205
+ type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1206
+ type ThreadCreatedEvent = {
1206
1207
  type: ServerMsgCode.THREAD_CREATED;
1207
1208
  threadId: string;
1208
1209
  };
1209
- declare type ThreadDeletedEvent = {
1210
+ type ThreadDeletedEvent = {
1210
1211
  type: ServerMsgCode.THREAD_DELETED;
1211
1212
  threadId: string;
1212
1213
  };
1213
- declare type ThreadMetadataUpdatedEvent = {
1214
+ type ThreadMetadataUpdatedEvent = {
1214
1215
  type: ServerMsgCode.THREAD_METADATA_UPDATED;
1215
1216
  threadId: string;
1216
1217
  };
1217
- declare type ThreadUpdatedEvent = {
1218
+ type ThreadUpdatedEvent = {
1218
1219
  type: ServerMsgCode.THREAD_UPDATED;
1219
1220
  threadId: string;
1220
1221
  };
1221
- declare type CommentCreatedEvent = {
1222
+ type CommentCreatedEvent = {
1222
1223
  type: ServerMsgCode.COMMENT_CREATED;
1223
1224
  threadId: string;
1224
1225
  commentId: string;
1225
1226
  };
1226
- declare type CommentEditedEvent = {
1227
+ type CommentEditedEvent = {
1227
1228
  type: ServerMsgCode.COMMENT_EDITED;
1228
1229
  threadId: string;
1229
1230
  commentId: string;
1230
1231
  };
1231
- declare type CommentDeletedEvent = {
1232
+ type CommentDeletedEvent = {
1232
1233
  type: ServerMsgCode.COMMENT_DELETED;
1233
1234
  threadId: string;
1234
1235
  commentId: string;
1235
1236
  };
1236
- declare type CommentReactionAdded = {
1237
+ type CommentReactionAdded = {
1237
1238
  type: ServerMsgCode.COMMENT_REACTION_ADDED;
1238
1239
  threadId: string;
1239
1240
  commentId: string;
1240
1241
  emoji: string;
1241
1242
  };
1242
- declare type CommentReactionRemoved = {
1243
+ type CommentReactionRemoved = {
1243
1244
  type: ServerMsgCode.COMMENT_REACTION_REMOVED;
1244
1245
  threadId: string;
1245
1246
  commentId: string;
@@ -1256,7 +1257,7 @@ declare type CommentReactionRemoved = {
1256
1257
  * those cases, the `targetActor` field indicates the newly connected client,
1257
1258
  * so all other existing clients can ignore this broadcasted message.
1258
1259
  */
1259
- declare type UpdatePresenceServerMsg<P extends JsonObject> = {
1260
+ type UpdatePresenceServerMsg<P extends JsonObject> = {
1260
1261
  readonly type: ServerMsgCode.UPDATE_PRESENCE;
1261
1262
  /**
1262
1263
  * The User whose Presence has changed.
@@ -1301,7 +1302,7 @@ declare type UpdatePresenceServerMsg<P extends JsonObject> = {
1301
1302
  * Sent by the WebSocket server and broadcasted to all clients to announce that
1302
1303
  * a new User has joined the Room.
1303
1304
  */
1304
- declare type UserJoinServerMsg<U extends BaseUserMeta> = {
1305
+ type UserJoinServerMsg<U extends BaseUserMeta> = {
1305
1306
  readonly type: ServerMsgCode.USER_JOINED;
1306
1307
  readonly actor: number;
1307
1308
  /**
@@ -1323,7 +1324,7 @@ declare type UserJoinServerMsg<U extends BaseUserMeta> = {
1323
1324
  * Sent by the WebSocket server and broadcasted to all clients to announce that
1324
1325
  * a new User has left the Room.
1325
1326
  */
1326
- declare type UserLeftServerMsg = {
1327
+ type UserLeftServerMsg = {
1327
1328
  readonly type: ServerMsgCode.USER_LEFT;
1328
1329
  readonly actor: number;
1329
1330
  };
@@ -1331,7 +1332,7 @@ declare type UserLeftServerMsg = {
1331
1332
  * Sent by the WebSocket server when the ydoc is updated or when requested based on stateVector passed.
1332
1333
  * Contains a base64 encoded update
1333
1334
  */
1334
- declare type YDocUpdateServerMsg = {
1335
+ type YDocUpdateServerMsg = {
1335
1336
  readonly type: ServerMsgCode.UPDATE_YDOC;
1336
1337
  readonly update: string;
1337
1338
  readonly isSync: boolean;
@@ -1342,7 +1343,7 @@ declare type YDocUpdateServerMsg = {
1342
1343
  * Sent by the WebSocket server and broadcasted to all clients to announce that
1343
1344
  * a User broadcasted an Event to everyone in the Room.
1344
1345
  */
1345
- declare type BroadcastedEventServerMsg<E extends Json> = {
1346
+ type BroadcastedEventServerMsg<E extends Json> = {
1346
1347
  readonly type: ServerMsgCode.BROADCASTED_EVENT;
1347
1348
  /**
1348
1349
  * The User who broadcast the Event. Absent when this event is broadcast from
@@ -1360,7 +1361,7 @@ declare type BroadcastedEventServerMsg<E extends Json> = {
1360
1361
  * joining the Room, to provide the initial state of the Room. The payload
1361
1362
  * includes a list of all other Users that already are in the Room.
1362
1363
  */
1363
- declare type RoomStateServerMsg<U extends BaseUserMeta> = {
1364
+ type RoomStateServerMsg<U extends BaseUserMeta> = {
1364
1365
  readonly type: ServerMsgCode.ROOM_STATE;
1365
1366
  /**
1366
1367
  * Informs the client what their actor ID is going to be.
@@ -1388,7 +1389,7 @@ declare type RoomStateServerMsg<U extends BaseUserMeta> = {
1388
1389
  * joining the Room, to provide the initial Storage state of the Room. The
1389
1390
  * payload includes the entire Storage document.
1390
1391
  */
1391
- declare type InitialDocumentStateServerMsg = {
1392
+ type InitialDocumentStateServerMsg = {
1392
1393
  readonly type: ServerMsgCode.INITIAL_STORAGE_STATE;
1393
1394
  readonly items: IdTuple<SerializedCrdt>[];
1394
1395
  };
@@ -1399,7 +1400,7 @@ declare type InitialDocumentStateServerMsg = {
1399
1400
  * The payload of this message contains a list of Ops (aka incremental
1400
1401
  * mutations to make to the initially loaded document).
1401
1402
  */
1402
- declare type UpdateStorageServerMsg = {
1403
+ type UpdateStorageServerMsg = {
1403
1404
  readonly type: ServerMsgCode.UPDATE_STORAGE;
1404
1405
  readonly ops: Op[];
1405
1406
  };
@@ -1408,13 +1409,13 @@ declare type UpdateStorageServerMsg = {
1408
1409
  * have been received but were rejected because they caused mutations that are
1409
1410
  * incompatible with the Room's schema.
1410
1411
  */
1411
- declare type RejectedStorageOpServerMsg = {
1412
+ type RejectedStorageOpServerMsg = {
1412
1413
  readonly type: ServerMsgCode.REJECT_STORAGE_OP;
1413
1414
  readonly opIds: string[];
1414
1415
  readonly reason: string;
1415
1416
  };
1416
1417
 
1417
- declare type HistoryVersion = {
1418
+ type HistoryVersion = {
1418
1419
  type: "historyVersion";
1419
1420
  kind: "yjs";
1420
1421
  createdAt: Date;
@@ -1424,20 +1425,20 @@ declare type HistoryVersion = {
1424
1425
  }[];
1425
1426
  };
1426
1427
 
1427
- declare type JsonTreeNode = {
1428
+ type JsonTreeNode = {
1428
1429
  readonly type: "Json";
1429
1430
  readonly id: string;
1430
1431
  readonly key: string;
1431
1432
  readonly payload: Json;
1432
1433
  };
1433
- declare type LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = {
1434
+ type LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = {
1434
1435
  readonly type: TName;
1435
1436
  readonly id: string;
1436
1437
  readonly key: string;
1437
1438
  readonly payload: LsonTreeNode[];
1438
1439
  };
1439
- declare type LsonTreeNode = LiveTreeNode | JsonTreeNode;
1440
- declare type UserTreeNode = {
1440
+ type LsonTreeNode = LiveTreeNode | JsonTreeNode;
1441
+ type UserTreeNode = {
1441
1442
  readonly type: "User";
1442
1443
  readonly id: string;
1443
1444
  readonly key: string;
@@ -1449,14 +1450,14 @@ declare type UserTreeNode = {
1449
1450
  readonly isReadOnly: boolean;
1450
1451
  };
1451
1452
  };
1452
- declare type CustomEventTreeNode = {
1453
+ type CustomEventTreeNode = {
1453
1454
  readonly type: "CustomEvent";
1454
1455
  readonly id: string;
1455
1456
  readonly key: string;
1456
1457
  readonly connectionId: number;
1457
1458
  readonly payload: Json;
1458
1459
  };
1459
- declare type TreeNode = LsonTreeNode | UserTreeNode | CustomEventTreeNode;
1460
+ type TreeNode = LsonTreeNode | UserTreeNode | CustomEventTreeNode;
1460
1461
 
1461
1462
  type DevToolsTreeNode_CustomEventTreeNode = CustomEventTreeNode;
1462
1463
  type DevToolsTreeNode_JsonTreeNode = JsonTreeNode;
@@ -1490,14 +1491,14 @@ declare namespace DevToolsTreeNode {
1490
1491
  * This trick comes from:
1491
1492
  * https://effectivetypescript.com/2022/02/25/gentips-4-display/
1492
1493
  */
1493
- declare type Resolve<T> = T extends (...args: unknown[]) => unknown ? T : {
1494
+ type Resolve<T> = T extends (...args: unknown[]) => unknown ? T : {
1494
1495
  [K in keyof T]: T[K];
1495
1496
  };
1496
1497
 
1497
1498
  /**
1498
1499
  * Represents a user connected in a room. Treated as immutable.
1499
1500
  */
1500
- declare type User<P extends JsonObject = DP, U extends BaseUserMeta = DU> = {
1501
+ type User<P extends JsonObject = DP, U extends BaseUserMeta = DU> = {
1501
1502
  /**
1502
1503
  * The connection ID of the User. It is unique and increment at every new connection.
1503
1504
  */
@@ -1526,7 +1527,7 @@ declare type User<P extends JsonObject = DP, U extends BaseUserMeta = DU> = {
1526
1527
  readonly canComment: boolean;
1527
1528
  };
1528
1529
 
1529
- declare type InternalOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
1530
+ type InternalOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
1530
1531
  type: "leave";
1531
1532
  user: User<P, U>;
1532
1533
  } | {
@@ -1540,7 +1541,7 @@ declare type InternalOthersEvent<P extends JsonObject, U extends BaseUserMeta> =
1540
1541
  type: "reset";
1541
1542
  user?: never;
1542
1543
  };
1543
- declare type OthersEvent<P extends JsonObject = DP, U extends BaseUserMeta = DU> = Resolve<InternalOthersEvent<P, U> & {
1544
+ type OthersEvent<P extends JsonObject = DP, U extends BaseUserMeta = DU> = Resolve<InternalOthersEvent<P, U> & {
1544
1545
  others: readonly User<P, U>[];
1545
1546
  }>;
1546
1547
  declare enum TextEditorType {
@@ -1548,20 +1549,20 @@ declare enum TextEditorType {
1548
1549
  TipTap = "tiptap"
1549
1550
  }
1550
1551
 
1551
- declare type OptionalKeys<T> = {
1552
+ type OptionalKeys<T> = {
1552
1553
  [K in keyof T]-?: undefined extends T[K] ? K : never;
1553
1554
  }[keyof T];
1554
- declare type MakeOptionalFieldsNullable<T> = {
1555
+ type MakeOptionalFieldsNullable<T> = {
1555
1556
  [K in keyof T]: K extends OptionalKeys<T> ? T[K] | null : T[K];
1556
1557
  };
1557
- declare type Patchable<T> = Partial<MakeOptionalFieldsNullable<T>>;
1558
+ type Patchable<T> = Partial<MakeOptionalFieldsNullable<T>>;
1558
1559
 
1559
- declare type RoomThreadsNotificationSettings = "all" | "replies_and_mentions" | "none";
1560
- declare type RoomNotificationSettings = {
1560
+ type RoomThreadsNotificationSettings = "all" | "replies_and_mentions" | "none";
1561
+ type RoomNotificationSettings = {
1561
1562
  threads: RoomThreadsNotificationSettings;
1562
1563
  };
1563
1564
 
1564
- declare type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
1565
+ type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
1565
1566
  type: "leave";
1566
1567
  user: User<P, U>;
1567
1568
  } | {
@@ -1574,8 +1575,8 @@ declare type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
1574
1575
  } | {
1575
1576
  type: "reset";
1576
1577
  };
1577
- declare type LegacyOthersEventCallback<P extends JsonObject, U extends BaseUserMeta> = (others: readonly User<P, U>[], event: LegacyOthersEvent<P, U>) => void;
1578
- declare type RoomEventMessage<P extends JsonObject, U extends BaseUserMeta, E extends Json> = {
1578
+ type LegacyOthersEventCallback<P extends JsonObject, U extends BaseUserMeta> = (others: readonly User<P, U>[], event: LegacyOthersEvent<P, U>) => void;
1579
+ type RoomEventMessage<P extends JsonObject, U extends BaseUserMeta, E extends Json> = {
1579
1580
  /**
1580
1581
  * The connection ID of the client that sent the event.
1581
1582
  * If this message was broadcast from the server (via the REST API), then
@@ -1590,7 +1591,7 @@ declare type RoomEventMessage<P extends JsonObject, U extends BaseUserMeta, E ex
1590
1591
  user: User<P, U> | null;
1591
1592
  event: E;
1592
1593
  };
1593
- declare type StorageStatus = "not-loaded" | "loading" | "synchronizing" | "synchronized";
1594
+ type StorageStatus = "not-loaded" | "loading" | "synchronizing" | "synchronized";
1594
1595
  interface History {
1595
1596
  /**
1596
1597
  * Undoes the last operation executed by the current client.
@@ -1668,11 +1669,11 @@ interface History {
1668
1669
  */
1669
1670
  resume: () => void;
1670
1671
  }
1671
- declare type HistoryEvent = {
1672
+ type HistoryEvent = {
1672
1673
  canUndo: boolean;
1673
1674
  canRedo: boolean;
1674
1675
  };
1675
- declare type BroadcastOptions = {
1676
+ type BroadcastOptions = {
1676
1677
  /**
1677
1678
  * Whether or not event is queued if the connection is currently closed.
1678
1679
  *
@@ -1680,7 +1681,7 @@ declare type BroadcastOptions = {
1680
1681
  */
1681
1682
  shouldQueueEventIfNotReady: boolean;
1682
1683
  };
1683
- declare type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U extends BaseUserMeta, E extends Json> = {
1684
+ type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U extends BaseUserMeta, E extends Json> = {
1684
1685
  /**
1685
1686
  * Subscribe to the current user presence updates.
1686
1687
  *
@@ -1813,25 +1814,25 @@ declare type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U e
1813
1814
  (type: "storage-status", listener: Callback<StorageStatus>): () => void;
1814
1815
  (type: "comments", listener: Callback<CommentsEventServerMsg>): () => void;
1815
1816
  };
1816
- declare type GetThreadsOptions<M extends BaseMetadata> = {
1817
+ type GetThreadsOptions<M extends BaseMetadata> = {
1817
1818
  cursor?: string;
1818
1819
  query?: {
1819
1820
  resolved?: boolean;
1820
1821
  metadata?: Partial<QueryMetadata<M>>;
1821
1822
  };
1822
1823
  };
1823
- declare type GetThreadsSinceOptions = {
1824
+ type GetThreadsSinceOptions = {
1824
1825
  since: Date;
1825
1826
  signal?: AbortSignal;
1826
1827
  };
1827
- declare type UploadAttachmentOptions = {
1828
+ type UploadAttachmentOptions = {
1828
1829
  signal?: AbortSignal;
1829
1830
  };
1830
- declare type ListTextVersionsSinceOptions = {
1831
+ type ListTextVersionsSinceOptions = {
1831
1832
  since: Date;
1832
1833
  signal?: AbortSignal;
1833
1834
  };
1834
- declare type GetNotificationSettingsOptions = {
1835
+ type GetNotificationSettingsOptions = {
1835
1836
  signal?: AbortSignal;
1836
1837
  };
1837
1838
  /**
@@ -1839,8 +1840,8 @@ declare type GetNotificationSettingsOptions = {
1839
1840
  * this type is different from `Room`-without-type-arguments. That represents
1840
1841
  * a Room instance using globally augmented types only, which is narrower.
1841
1842
  */
1842
- declare type OpaqueRoom = Room<JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata>;
1843
- declare type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE, M extends BaseMetadata = DM> = {
1843
+ type OpaqueRoom = Room<JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata>;
1844
+ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE, M extends BaseMetadata = DM> = {
1844
1845
  /**
1845
1846
  * @private
1846
1847
  *
@@ -2254,7 +2255,7 @@ declare type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extend
2254
2255
  */
2255
2256
  markInboxNotificationAsRead(notificationId: string): Promise<void>;
2256
2257
  };
2257
- declare type YjsSyncStatus = "loading" | "synchronizing" | "synchronized";
2258
+ type YjsSyncStatus = "loading" | "synchronizing" | "synchronized";
2258
2259
  /**
2259
2260
  * Interface that @liveblocks/yjs must respect.
2260
2261
  * This interface type is declare in @liveblocks/core, so we don't have to
@@ -2287,7 +2288,7 @@ interface SyncSource {
2287
2288
  * Liveblocks, NEVER USE ANY OF THESE METHODS DIRECTLY, because bad things
2288
2289
  * will probably happen if you do.
2289
2290
  */
2290
- declare type PrivateRoomApi = {
2291
+ type PrivateRoomApi = {
2291
2292
  presenceBuffer: Json | undefined;
2292
2293
  undoStack: readonly (readonly Readonly<HistoryOp<JsonObject>>[])[];
2293
2294
  nodeCount: number;
@@ -2315,11 +2316,11 @@ declare type PrivateRoomApi = {
2315
2316
  };
2316
2317
  attachmentUrlsStore: BatchStore<string, string>;
2317
2318
  };
2318
- declare type HistoryOp<P extends JsonObject> = Op | {
2319
+ type HistoryOp<P extends JsonObject> = Op | {
2319
2320
  readonly type: "presence";
2320
2321
  readonly data: P;
2321
2322
  };
2322
- declare type Polyfills = {
2323
+ type Polyfills = {
2323
2324
  atob?: (data: string) => string;
2324
2325
  fetch?: typeof fetch;
2325
2326
  WebSocket?: IWebSocket;
@@ -2331,19 +2332,19 @@ declare type Polyfills = {
2331
2332
  * into:
2332
2333
  * [foo?: string; bar?: number]
2333
2334
  */
2334
- declare type OptionalTuple<T extends any[]> = {
2335
+ type OptionalTuple<T extends any[]> = {
2335
2336
  [K in keyof T]?: T[K];
2336
2337
  };
2337
2338
  /**
2338
2339
  * Returns Partial<T> if all fields on C are optional, T otherwise.
2339
2340
  */
2340
- declare type PartialUnless<C, T> = Record<string, never> extends C ? Partial<T> : [
2341
+ type PartialUnless<C, T> = Record<string, never> extends C ? Partial<T> : [
2341
2342
  C
2342
2343
  ] extends [never] ? Partial<T> : T;
2343
2344
  /**
2344
2345
  * Returns OptionalTupleUnless<T> if all fields on C are optional, T otherwise.
2345
2346
  */
2346
- declare type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ? OptionalTuple<T> : [
2347
+ type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ? OptionalTuple<T> : [
2347
2348
  C
2348
2349
  ] extends [never] ? OptionalTuple<T> : T;
2349
2350
 
@@ -2587,7 +2588,7 @@ interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, Noti
2587
2588
  * Back-port of TypeScript 5.4's built-in NoInfer utility type.
2588
2589
  * See https://stackoverflow.com/a/56688073/148872
2589
2590
  */
2590
- declare type NoInfr<A> = [A][A extends any ? 0 : never];
2591
+ type NoInfr<A> = [A][A extends any ? 0 : never];
2591
2592
 
2592
2593
  declare const kTrigger: unique symbol;
2593
2594
  /**
@@ -2597,7 +2598,7 @@ declare const kTrigger: unique symbol;
2597
2598
  * Nesting batches is supported.
2598
2599
  */
2599
2600
  declare function batch(callback: Callback<void>): void;
2600
- declare type SignalType<S extends ISignal<any>> = S extends ISignal<infer T> ? T : never;
2601
+ type SignalType<S extends ISignal<any>> = S extends ISignal<infer T> ? T : never;
2601
2602
  interface ISignal<T> {
2602
2603
  get(): T;
2603
2604
  subscribe(callback: Callback<void>): UnsubscribeCallback;
@@ -2631,10 +2632,10 @@ declare class Signal<T> extends AbstractSignal<T> {
2631
2632
  }
2632
2633
  declare class DerivedSignal<T> extends AbstractSignal<T> {
2633
2634
  #private;
2634
- static from<Ts extends [unknown, ...unknown[]], V>(...args: [...signals: {
2635
+ static from<Ts extends unknown[], V>(...args: [...signals: {
2635
2636
  [K in keyof Ts]: ISignal<Ts[K]>;
2636
2637
  }, transform: (...values: Ts) => V]): DerivedSignal<V>;
2637
- static from<Ts extends [unknown, ...unknown[]], V>(...args: [...signals: {
2638
+ static from<Ts extends unknown[], V>(...args: [...signals: {
2638
2639
  [K in keyof Ts]: ISignal<Ts[K]>;
2639
2640
  }, transform: (...values: Ts) => V, equals: (a: V, b: V) => boolean]): DerivedSignal<V>;
2640
2641
  private constructor();
@@ -2673,9 +2674,9 @@ declare class MutableSignal<T extends object> extends AbstractSignal<T> {
2673
2674
  mutate(callback?: (state: T) => void | boolean): void;
2674
2675
  }
2675
2676
 
2676
- declare type OptionalPromise<T> = T | Promise<T>;
2677
+ type OptionalPromise<T> = T | Promise<T>;
2677
2678
 
2678
- declare type ResolveMentionSuggestionsArgs = {
2679
+ type ResolveMentionSuggestionsArgs = {
2679
2680
  /**
2680
2681
  * The ID of the current room.
2681
2682
  */
@@ -2685,19 +2686,19 @@ declare type ResolveMentionSuggestionsArgs = {
2685
2686
  */
2686
2687
  text: string;
2687
2688
  };
2688
- declare type ResolveUsersArgs = {
2689
+ type ResolveUsersArgs = {
2689
2690
  /**
2690
2691
  * The IDs of the users to resolve.
2691
2692
  */
2692
2693
  userIds: string[];
2693
2694
  };
2694
- declare type ResolveRoomsInfoArgs = {
2695
+ type ResolveRoomsInfoArgs = {
2695
2696
  /**
2696
2697
  * The IDs of the rooms to resolve.
2697
2698
  */
2698
2699
  roomIds: string[];
2699
2700
  };
2700
- declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS> = Resolve<{
2701
+ type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS> = Resolve<{
2701
2702
  /**
2702
2703
  * Whether or not the room automatically connects to Liveblock servers.
2703
2704
  * Default is true.
@@ -2718,7 +2719,7 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
2718
2719
  */
2719
2720
  initialStorage: S | ((roomId: string) => S);
2720
2721
  }>>;
2721
- declare type SyncStatus = "synchronizing" | "synchronized";
2722
+ type SyncStatus = "synchronizing" | "synchronized";
2722
2723
  /**
2723
2724
  * "synchronizing" - Liveblocks is in the process of writing changes
2724
2725
  * "synchronized" - Liveblocks has persisted all pending changes
@@ -2726,7 +2727,7 @@ declare type SyncStatus = "synchronizing" | "synchronized";
2726
2727
  * we're not yet "synchronizing" it until a user
2727
2728
  * interaction, like the draft text in a comment box.
2728
2729
  */
2729
- declare type InternalSyncStatus = SyncStatus | "has-local-changes";
2730
+ type InternalSyncStatus = SyncStatus | "has-local-changes";
2730
2731
  /**
2731
2732
  * @private
2732
2733
  *
@@ -2734,7 +2735,7 @@ declare type InternalSyncStatus = SyncStatus | "has-local-changes";
2734
2735
  * of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
2735
2736
  * will probably happen if you do.
2736
2737
  */
2737
- declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
2738
+ type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
2738
2739
  readonly currentUserId: Signal<string | undefined>;
2739
2740
  readonly mentionSuggestionsCache: Map<string, string[]>;
2740
2741
  readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
@@ -2745,7 +2746,7 @@ declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> =
2745
2746
  as<M2 extends BaseMetadata>(): Client<U, M2>;
2746
2747
  createSyncSource(): SyncSource;
2747
2748
  };
2748
- declare type NotificationsApi<M extends BaseMetadata> = {
2749
+ type NotificationsApi<M extends BaseMetadata> = {
2749
2750
  /**
2750
2751
  * Gets a page (or the initial page) for user inbox notifications and their
2751
2752
  * associated threads.
@@ -2846,8 +2847,8 @@ declare type NotificationsApi<M extends BaseMetadata> = {
2846
2847
  * represents a Client instance using globally augmented types only, which is
2847
2848
  * narrower.
2848
2849
  */
2849
- declare type OpaqueClient = Client<BaseUserMeta>;
2850
- declare type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> = {
2850
+ type OpaqueClient = Client<BaseUserMeta>;
2851
+ type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> = {
2851
2852
  /**
2852
2853
  * Gets a room. Returns null if {@link Client.enter} has not been called previously.
2853
2854
  *
@@ -2944,12 +2945,12 @@ declare type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> =
2944
2945
  readonly syncStatus: Observable<void>;
2945
2946
  };
2946
2947
  } & NotificationsApi<M>;
2947
- declare type AuthEndpoint = string | ((room?: string) => Promise<CustomAuthenticationResult>);
2948
+ type AuthEndpoint = string | ((room?: string) => Promise<CustomAuthenticationResult>);
2948
2949
  /**
2949
2950
  * The authentication endpoint that is called to ensure that the current user has access to a room.
2950
2951
  * Can be an url or a callback if you need to add additional headers.
2951
2952
  */
2952
- declare type ClientOptions<U extends BaseUserMeta = DU> = {
2953
+ type ClientOptions<U extends BaseUserMeta = DU> = {
2953
2954
  throttle?: number;
2954
2955
  lostConnectionTimeout?: number;
2955
2956
  backgroundKeepAliveTimeout?: number;
@@ -3010,7 +3011,7 @@ declare type ClientOptions<U extends BaseUserMeta = DU> = {
3010
3011
  */
3011
3012
  declare function createClient<U extends BaseUserMeta = DU>(options: ClientOptions<U>): Client<U>;
3012
3013
 
3013
- declare type CommentBodyParagraphElementArgs = {
3014
+ type CommentBodyParagraphElementArgs = {
3014
3015
  /**
3015
3016
  * The paragraph element.
3016
3017
  */
@@ -3020,13 +3021,13 @@ declare type CommentBodyParagraphElementArgs = {
3020
3021
  */
3021
3022
  children: string;
3022
3023
  };
3023
- declare type CommentBodyTextElementArgs = {
3024
+ type CommentBodyTextElementArgs = {
3024
3025
  /**
3025
3026
  * The text element.
3026
3027
  */
3027
3028
  element: CommentBodyText;
3028
3029
  };
3029
- declare type CommentBodyLinkElementArgs = {
3030
+ type CommentBodyLinkElementArgs = {
3030
3031
  /**
3031
3032
  * The link element.
3032
3033
  */
@@ -3036,7 +3037,7 @@ declare type CommentBodyLinkElementArgs = {
3036
3037
  */
3037
3038
  href: string;
3038
3039
  };
3039
- declare type CommentBodyMentionElementArgs<U extends BaseUserMeta = DU> = {
3040
+ type CommentBodyMentionElementArgs<U extends BaseUserMeta = DU> = {
3040
3041
  /**
3041
3042
  * The mention element.
3042
3043
  */
@@ -3046,7 +3047,7 @@ declare type CommentBodyMentionElementArgs<U extends BaseUserMeta = DU> = {
3046
3047
  */
3047
3048
  user?: U["info"];
3048
3049
  };
3049
- declare type StringifyCommentBodyElements<U extends BaseUserMeta = DU> = {
3050
+ type StringifyCommentBodyElements<U extends BaseUserMeta = DU> = {
3050
3051
  /**
3051
3052
  * The element used to display paragraphs.
3052
3053
  */
@@ -3064,7 +3065,7 @@ declare type StringifyCommentBodyElements<U extends BaseUserMeta = DU> = {
3064
3065
  */
3065
3066
  mention: (args: CommentBodyMentionElementArgs<U>, index: number) => string;
3066
3067
  };
3067
- declare type StringifyCommentBodyOptions<U extends BaseUserMeta = DU> = {
3068
+ type StringifyCommentBodyOptions<U extends BaseUserMeta = DU> = {
3068
3069
  /**
3069
3070
  * Which format to convert the comment to.
3070
3071
  */
@@ -3153,13 +3154,13 @@ declare function convertToInboxNotificationData(data: InboxNotificationDataPlain
3153
3154
  /**
3154
3155
  * Lookup table for nodes (= SerializedCrdt values) by their IDs.
3155
3156
  */
3156
- declare type NodeMap = Map<string, // Node ID
3157
+ type NodeMap = Map<string, // Node ID
3157
3158
  SerializedCrdt>;
3158
3159
  /**
3159
3160
  * Reverse lookup table for all child nodes (= list of SerializedCrdt values)
3160
3161
  * by their parent node's IDs.
3161
3162
  */
3162
- declare type ParentToChildNodeMap = Map<string, // Parent's node ID
3163
+ type ParentToChildNodeMap = Map<string, // Parent's node ID
3163
3164
  IdTuple<SerializedChild>[]>;
3164
3165
 
3165
3166
  declare function isLiveNode(value: unknown): value is LiveNode;
@@ -3250,6 +3251,36 @@ declare function createCommentId(): string;
3250
3251
  declare function createCommentAttachmentId(): string;
3251
3252
  declare function createInboxNotificationId(): string;
3252
3253
 
3254
+ /**
3255
+ * Like ES6 map, but takes a default (factory) function which will be used
3256
+ * to create entries for missing keys on the fly.
3257
+ *
3258
+ * Useful for code like:
3259
+ *
3260
+ * const map = new DefaultMap(() => []);
3261
+ * map.getOrCreate('foo').push('hello');
3262
+ * map.getOrCreate('foo').push('world');
3263
+ * map.getOrCreate('foo')
3264
+ * // ['hello', 'world']
3265
+ *
3266
+ */
3267
+ declare class DefaultMap<K, V> extends Map<K, V> {
3268
+ #private;
3269
+ /**
3270
+ * If the default function is not provided to the constructor, it has to be
3271
+ * provided in each .getOrCreate() call individually.
3272
+ */
3273
+ constructor(defaultFn?: (key: K) => V, entries?: readonly (readonly [K, V])[] | null);
3274
+ /**
3275
+ * Gets the value at the given key, or creates it.
3276
+ *
3277
+ * Difference from normal Map: if the key does not exist, it will be created
3278
+ * on the fly using the factory function, and that value will get returned
3279
+ * instead of `undefined`.
3280
+ */
3281
+ getOrCreate(key: K, defaultFn?: (key: K) => V): V;
3282
+ }
3283
+
3253
3284
  /**
3254
3285
  * Displays a deprecation warning in the dev console. Only in dev mode, and
3255
3286
  * only once per message/key. In production, this is a no-op.
@@ -3295,6 +3326,16 @@ declare namespace fancyConsole {
3295
3326
  */
3296
3327
  declare const freeze: typeof Object.freeze;
3297
3328
 
3329
+ declare function isPlainObject(blob: unknown): blob is {
3330
+ [key: string]: unknown;
3331
+ };
3332
+ /**
3333
+ * Check if value is of shape { startsWith: string }
3334
+ */
3335
+ declare function isStartsWithOperator(blob: unknown): blob is {
3336
+ startsWith: string;
3337
+ };
3338
+
3298
3339
  declare const nanoid: (t?: number) => string;
3299
3340
 
3300
3341
  /**
@@ -3302,35 +3343,32 @@ declare const nanoid: (t?: number) => string;
3302
3343
  * Example:
3303
3344
  * ```ts
3304
3345
  * const query = objectToQuery({
3305
- resolved: true,
3306
- metadata: {
3307
- status: "open",
3308
- priority: 3,
3309
- org: {
3310
- startsWith: "liveblocks:",
3311
- },
3312
- },
3313
- });
3314
-
3315
- console.log(query);
3316
- // resolved:true AND metadata["status"]:open AND metadata["priority"]:3 AND metadata["org"]^"liveblocks:"
3317
-
3318
- * ```
3319
- *
3346
+ * resolved: true,
3347
+ * metadata: {
3348
+ * status: "open",
3349
+ * priority: 3,
3350
+ * org: {
3351
+ * startsWith: "liveblocks:",
3352
+ * },
3353
+ * },
3354
+ * });
3320
3355
  *
3356
+ * console.log(query);
3357
+ * // resolved:true AND metadata["status"]:open AND metadata["priority"]:3 AND metadata["org"]^"liveblocks:"
3358
+ * ```
3321
3359
  */
3322
- declare type SimpleFilterValue = string | number | boolean;
3323
- declare type OperatorFilterValue = {
3360
+ type SimpleFilterValue = string | number | boolean;
3361
+ type OperatorFilterValue = {
3324
3362
  startsWith: string;
3325
3363
  };
3326
- declare type FilterValue = SimpleFilterValue | OperatorFilterValue;
3364
+ type FilterValue = SimpleFilterValue | OperatorFilterValue;
3327
3365
  declare function objectToQuery(obj: {
3328
3366
  [key: string]: FilterValue | {
3329
3367
  [key: string]: FilterValue | undefined;
3330
3368
  } | undefined;
3331
3369
  }): string;
3332
3370
 
3333
- declare type Poller = {
3371
+ type Poller = {
3334
3372
  /**
3335
3373
  * Increments the subscriber count for this poller. If it becomes > 0, the
3336
3374
  * poller will be enabled.
@@ -3383,17 +3421,14 @@ declare function makePoller(callback: (signal: AbortSignal) => Promise<void> | v
3383
3421
  }): Poller;
3384
3422
 
3385
3423
  declare const brand: unique symbol;
3386
- declare type Brand<T, TBrand extends string> = T & {
3424
+ type Brand<T, TBrand extends string> = T & {
3387
3425
  [brand]: TBrand;
3388
3426
  };
3389
- declare type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
3427
+ type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
3390
3428
  /**
3391
3429
  * Throw an error, but as an expression instead of a statement.
3392
3430
  */
3393
3431
  declare function raise(msg: string): never;
3394
- declare function isPlainObject(blob: unknown): blob is {
3395
- [key: string]: unknown;
3396
- };
3397
3432
  /**
3398
3433
  * Creates a new object by mapping a function over all values. Keys remain the
3399
3434
  * same. Think Array.prototype.map(), but for values in an object.
@@ -3410,7 +3445,7 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
3410
3445
  * Decode base64 string.
3411
3446
  */
3412
3447
  declare function b64decode(b64value: string): string;
3413
- declare type RemoveUndefinedValues<T> = {
3448
+ type RemoveUndefinedValues<T> = {
3414
3449
  [K in keyof T]-?: Exclude<T[K], undefined>;
3415
3450
  };
3416
3451
  /**
@@ -3487,7 +3522,7 @@ declare function memoizeOnSuccess<T>(factoryFn: () => Promise<T>): () => Promise
3487
3522
  * A valid/verified "position" string. These values are used as "parentKey"s by
3488
3523
  * LiveList children, and define their relative ordering.
3489
3524
  */
3490
- declare type Pos = Brand<string, "Pos">;
3525
+ type Pos = Brand<string, "Pos">;
3491
3526
  /**
3492
3527
  * Given two positions, returns the position value that lies in the middle.
3493
3528
  * When given only a high bound, computes the canonical position "before" it.
@@ -3552,14 +3587,18 @@ declare class SortedList<T> {
3552
3587
  [Symbol.iterator](): IterableIterator<T>;
3553
3588
  }
3554
3589
 
3555
- declare type OmitFirstTupleElement<T extends any[]> = T extends [any, ...infer R] ? R : never;
3556
3590
  /**
3557
- * Like JSON.stringify(), but returns the same value no matter how the keys in
3558
- * objects are ordered.
3591
+ * Like JSON.stringify(), but returns the same value no matter how keys in any
3592
+ * nested objects are ordered.
3593
+ */
3594
+ declare function stringify(value: unknown): string;
3595
+ /**
3596
+ * Like JSON.stringify(), but returns the same value no matter how keys in any
3597
+ * nested objects are ordered.
3559
3598
  */
3560
- declare function stringify(object: Parameters<typeof JSON.stringify>[0], ...args: OmitFirstTupleElement<Parameters<typeof JSON.stringify>>): string;
3599
+ declare function unstringify(value: string): unknown;
3561
3600
 
3562
- declare type QueryParams = Record<string, string | number | null | undefined> | URLSearchParams;
3601
+ type QueryParams = Record<string, string | number | null | undefined> | URLSearchParams;
3563
3602
  /**
3564
3603
  * Concatenates a path to an existing URL.
3565
3604
  */
@@ -3568,7 +3607,7 @@ declare function urljoin(baseUrl: string | URL, path: string, params?: QueryPara
3568
3607
  * A string that is guaranteed to be URL safe (where all arguments are properly
3569
3608
  * encoded), only obtainable as the result of using `url` template strings.
3570
3609
  */
3571
- declare type URLSafeString = Brand<string, "URLSafeString">;
3610
+ type URLSafeString = Brand<string, "URLSafeString">;
3572
3611
  /**
3573
3612
  * Builds a URL where each "hole" in the template string will automatically be
3574
3613
  * encodeURIComponent()-escaped, so it's impossible to build invalid URLs.
@@ -3578,7 +3617,7 @@ declare function url(strings: TemplateStringsArray, ...values: string[]): URLSaf
3578
3617
  /**
3579
3618
  * Definition of all messages the Panel can send to the Client.
3580
3619
  */
3581
- declare type PanelToClientMessage =
3620
+ type PanelToClientMessage =
3582
3621
  /**
3583
3622
  * Initial message from the panel to the client, used for two purposes.
3584
3623
  * 1. First, it’s eavesdropped by the background script, which uses this
@@ -3612,7 +3651,7 @@ declare type PanelToClientMessage =
3612
3651
  /**
3613
3652
  * Definition of all messages the Client can send to the Panel.
3614
3653
  */
3615
- declare type ClientToPanelMessage =
3654
+ type ClientToPanelMessage =
3616
3655
  /**
3617
3656
  * Initial message sent by the client to test if a dev panel is listening.
3618
3657
  * This is necessary in cases where the dev panel is already opened and
@@ -3679,11 +3718,11 @@ declare type ClientToPanelMessage =
3679
3718
  roomId: string;
3680
3719
  update: YDocUpdateServerMsg | UpdateYDocClientMsg;
3681
3720
  };
3682
- declare type FullPanelToClientMessage = PanelToClientMessage & {
3721
+ type FullPanelToClientMessage = PanelToClientMessage & {
3683
3722
  source: "liveblocks-devtools-panel";
3684
3723
  tabId: number;
3685
3724
  };
3686
- declare type FullClientToPanelMessage = ClientToPanelMessage & {
3725
+ type FullClientToPanelMessage = ClientToPanelMessage & {
3687
3726
  source: "liveblocks-devtools-client";
3688
3727
  };
3689
3728
 
@@ -3701,7 +3740,7 @@ declare namespace protocol {
3701
3740
  * information, see
3702
3741
  * https://liveblocks.io/docs/guides/limits#lson-constraint-and-interfaces
3703
3742
  */
3704
- declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson<I>)[] : [
3743
+ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson<I>)[] : [
3705
3744
  unknown
3706
3745
  ] extends [T] ? Json | undefined : T extends Date ? string : T extends (...args: any[]) => any ? never : {
3707
3746
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
@@ -3712,4 +3751,4 @@ declare const CommentsApiError: typeof HttpError;
3712
3751
  /** @deprecated Use HttpError instead. */
3713
3752
  declare const NotificationsApiError: typeof HttpError;
3714
3753
 
3715
- export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, 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, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
3754
+ export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, 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, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, unstringify, url, urljoin, wait, withTimeout };