@liveblocks/core 1.3.5 → 1.4.0-test1

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
@@ -681,6 +681,11 @@ declare type CommentBody = {
681
681
  content: CommentBodyBlockElement[];
682
682
  };
683
683
 
684
+ declare type CommentReaction = {
685
+ emoji: string;
686
+ userId: string;
687
+ createdAt: string;
688
+ };
684
689
  /**
685
690
  * Represents a comment.
686
691
  */
@@ -692,6 +697,7 @@ declare type CommentData = {
692
697
  userId: string;
693
698
  createdAt: string;
694
699
  editedAt?: string;
700
+ reactions: CommentReaction[];
695
701
  } & ({
696
702
  body: CommentBody;
697
703
  deletedAt?: never;
@@ -742,6 +748,16 @@ declare type CommentsApi<ThreadMetadata extends BaseMetadata> = {
742
748
  threadId: string;
743
749
  commentId: string;
744
750
  }): Promise<void>;
751
+ addReaction(options: {
752
+ threadId: string;
753
+ commentId: string;
754
+ emoji: string;
755
+ }): Promise<CommentData>;
756
+ removeReaction(options: {
757
+ threadId: string;
758
+ commentId: string;
759
+ emoji: string;
760
+ }): Promise<CommentData>;
745
761
  };
746
762
  declare function createCommentsApi<ThreadMetadata extends BaseMetadata>(roomId: string, getAuthValue: () => Promise<AuthValue>, { serverEndpoint }: Options): CommentsApi<ThreadMetadata>;
747
763
 
@@ -924,6 +940,64 @@ declare type Delegates<T extends BaseAuthResult> = {
924
940
  createSocket: (authValue: T) => IWebSocketInstance;
925
941
  };
926
942
 
943
+ declare enum ClientMsgCode {
944
+ UPDATE_PRESENCE = 100,
945
+ BROADCAST_EVENT = 103,
946
+ FETCH_STORAGE = 200,
947
+ UPDATE_STORAGE = 201,
948
+ FETCH_YDOC = 300,
949
+ UPDATE_YDOC = 301
950
+ }
951
+ /**
952
+ * Messages that can be sent from the client to the server.
953
+ */
954
+ declare type ClientMsg<TPresence extends JsonObject, TRoomEvent extends Json> = BroadcastEventClientMsg<TRoomEvent> | UpdatePresenceClientMsg<TPresence> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
955
+ declare type BroadcastEventClientMsg<TRoomEvent extends Json> = {
956
+ type: ClientMsgCode.BROADCAST_EVENT;
957
+ event: TRoomEvent;
958
+ };
959
+ declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
960
+ readonly type: ClientMsgCode.UPDATE_PRESENCE;
961
+ /**
962
+ * Set this to any number to signify that this is a Full Presence™
963
+ * update, not a patch.
964
+ *
965
+ * The numeric value itself no longer has specific meaning. Historically,
966
+ * this field was intended so that clients could ignore these broadcasted
967
+ * full presence messages, but it turned out that getting a full presence
968
+ * "keyframe" from time to time was useful.
969
+ *
970
+ * So nowadays, the presence (pun intended) of this `targetActor` field
971
+ * is a backward-compatible way of expressing that the `data` contains
972
+ * all presence fields, and isn't a partial "patch".
973
+ */
974
+ readonly targetActor: number;
975
+ readonly data: TPresence;
976
+ } | {
977
+ readonly type: ClientMsgCode.UPDATE_PRESENCE;
978
+ /**
979
+ * Absence of the `targetActor` field signifies that this is a Partial
980
+ * Presence™ "patch".
981
+ */
982
+ readonly targetActor?: undefined;
983
+ readonly data: Partial<TPresence>;
984
+ };
985
+ declare type UpdateStorageClientMsg = {
986
+ readonly type: ClientMsgCode.UPDATE_STORAGE;
987
+ readonly ops: Op[];
988
+ };
989
+ declare type FetchStorageClientMsg = {
990
+ readonly type: ClientMsgCode.FETCH_STORAGE;
991
+ };
992
+ declare type FetchYDocClientMsg = {
993
+ readonly type: ClientMsgCode.FETCH_YDOC;
994
+ readonly vector: string;
995
+ };
996
+ declare type UpdateYDocClientMsg = {
997
+ readonly type: ClientMsgCode.UPDATE_YDOC;
998
+ readonly update: string;
999
+ };
1000
+
927
1001
  declare type IdTuple<T> = [id: string, value: T];
928
1002
  declare enum CrdtType {
929
1003
  OBJECT = 0,
@@ -983,7 +1057,7 @@ declare enum ServerMsgCode {
983
1057
  /**
984
1058
  * Messages that can be sent from the server to the client.
985
1059
  */
986
- declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdate | CommentsEventServerMsg;
1060
+ declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdateServerMsg | CommentsEventServerMsg;
987
1061
  declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent;
988
1062
  declare type ThreadCreatedEvent = {
989
1063
  type: ServerMsgCode.THREAD_CREATED;
@@ -1094,7 +1168,7 @@ declare type UserLeftServerMsg = {
1094
1168
  * Sent by the WebSocket server when the ydoc is updated or when requested based on stateVector passed.
1095
1169
  * Contains a base64 encoded update
1096
1170
  */
1097
- declare type YDocUpdate = {
1171
+ declare type YDocUpdateServerMsg = {
1098
1172
  readonly type: ServerMsgCode.UPDATE_YDOC;
1099
1173
  readonly update: string;
1100
1174
  readonly isSync: boolean;
@@ -1232,13 +1306,19 @@ declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUse
1232
1306
  type: "reset";
1233
1307
  };
1234
1308
 
1235
- declare type CustomEvent<TRoomEvent extends Json> = {
1309
+ declare type RoomEventMessage<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
1236
1310
  /**
1237
1311
  * The connection ID of the client that sent the event.
1238
1312
  * If this message was broadcast from the server (via the REST API), then
1239
1313
  * this value will be -1.
1240
1314
  */
1241
1315
  connectionId: number;
1316
+ /**
1317
+ * The User (from the others list) that sent the event.
1318
+ * If this message was broadcast from the server (via the REST API), then
1319
+ * this value will be null.
1320
+ */
1321
+ user: User<TPresence, TUserMeta> | null;
1242
1322
  event: TRoomEvent;
1243
1323
  };
1244
1324
  declare type StorageStatus = "not-loaded" | "loading" | "synchronizing" | "synchronized";
@@ -1372,7 +1452,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1372
1452
  * });
1373
1453
  *
1374
1454
  */
1375
- (type: "event", listener: Callback<CustomEvent<TRoomEvent>>): () => void;
1455
+ (type: "event", listener: Callback<RoomEventMessage<TPresence, TUserMeta, TRoomEvent>>): () => void;
1376
1456
  /**
1377
1457
  * Subscribe to errors thrown in the room.
1378
1458
  *
@@ -1612,10 +1692,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1612
1692
  readonly connection: Observable<LegacyConnectionStatus>;
1613
1693
  readonly status: Observable<Status>;
1614
1694
  readonly lostConnection: Observable<LostConnectionEvent>;
1615
- readonly customEvent: Observable<{
1616
- connectionId: number;
1617
- event: TRoomEvent;
1618
- }>;
1695
+ readonly customEvent: Observable<RoomEventMessage<TPresence, TUserMeta, TRoomEvent>>;
1619
1696
  readonly self: Observable<User<TPresence, TUserMeta>>;
1620
1697
  readonly myPresence: Observable<TPresence>;
1621
1698
  readonly others: Observable<{
@@ -1632,7 +1709,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1632
1709
  */
1633
1710
  readonly storageDidLoad: Observable<void>;
1634
1711
  readonly storageStatus: Observable<StorageStatus>;
1635
- readonly ydoc: Observable<YDocUpdate>;
1712
+ readonly ydoc: Observable<YDocUpdateServerMsg | UpdateYDocClientMsg>;
1636
1713
  readonly comments: Observable<CommentsEventServerMsg>;
1637
1714
  };
1638
1715
  /**
@@ -2078,64 +2155,6 @@ declare function asPos(str: string): Pos;
2078
2155
  */
2079
2156
  declare function shallow(a: unknown, b: unknown): boolean;
2080
2157
 
2081
- declare enum ClientMsgCode {
2082
- UPDATE_PRESENCE = 100,
2083
- BROADCAST_EVENT = 103,
2084
- FETCH_STORAGE = 200,
2085
- UPDATE_STORAGE = 201,
2086
- FETCH_YDOC = 300,
2087
- UPDATE_YDOC = 301
2088
- }
2089
- /**
2090
- * Messages that can be sent from the client to the server.
2091
- */
2092
- declare type ClientMsg<TPresence extends JsonObject, TRoomEvent extends Json> = BroadcastEventClientMsg<TRoomEvent> | UpdatePresenceClientMsg<TPresence> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
2093
- declare type BroadcastEventClientMsg<TRoomEvent extends Json> = {
2094
- type: ClientMsgCode.BROADCAST_EVENT;
2095
- event: TRoomEvent;
2096
- };
2097
- declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
2098
- readonly type: ClientMsgCode.UPDATE_PRESENCE;
2099
- /**
2100
- * Set this to any number to signify that this is a Full Presence™
2101
- * update, not a patch.
2102
- *
2103
- * The numeric value itself no longer has specific meaning. Historically,
2104
- * this field was intended so that clients could ignore these broadcasted
2105
- * full presence messages, but it turned out that getting a full presence
2106
- * "keyframe" from time to time was useful.
2107
- *
2108
- * So nowadays, the presence (pun intended) of this `targetActor` field
2109
- * is a backward-compatible way of expressing that the `data` contains
2110
- * all presence fields, and isn't a partial "patch".
2111
- */
2112
- readonly targetActor: number;
2113
- readonly data: TPresence;
2114
- } | {
2115
- readonly type: ClientMsgCode.UPDATE_PRESENCE;
2116
- /**
2117
- * Absence of the `targetActor` field signifies that this is a Partial
2118
- * Presence™ "patch".
2119
- */
2120
- readonly targetActor?: undefined;
2121
- readonly data: Partial<TPresence>;
2122
- };
2123
- declare type UpdateStorageClientMsg = {
2124
- readonly type: ClientMsgCode.UPDATE_STORAGE;
2125
- readonly ops: Op[];
2126
- };
2127
- declare type FetchStorageClientMsg = {
2128
- readonly type: ClientMsgCode.FETCH_STORAGE;
2129
- };
2130
- declare type FetchYDocClientMsg = {
2131
- readonly type: ClientMsgCode.FETCH_YDOC;
2132
- readonly vector: string;
2133
- };
2134
- declare type UpdateYDocClientMsg = {
2135
- readonly type: ClientMsgCode.UPDATE_YDOC;
2136
- readonly update: string;
2137
- };
2138
-
2139
2158
  declare type JsonTreeNode = {
2140
2159
  readonly type: "Json";
2141
2160
  readonly id: string;
@@ -2265,6 +2284,14 @@ declare type ClientToPanelMessage =
2265
2284
  storage?: readonly LsonTreeNode[];
2266
2285
  me?: UserTreeNode;
2267
2286
  others?: readonly UserTreeNode[];
2287
+ }
2288
+ /**
2289
+ * Sent whenever the ydoc is updated
2290
+ */
2291
+ | {
2292
+ msg: "room::sync::ydoc";
2293
+ roomId: string;
2294
+ update: YDocUpdateServerMsg | UpdateYDocClientMsg;
2268
2295
  };
2269
2296
  declare type FullPanelToClientMessage = PanelToClientMessage & {
2270
2297
  source: "liveblocks-devtools-panel";
@@ -2299,4 +2326,4 @@ declare type EnsureJson<T> = [
2299
2326
  [K in keyof T]: EnsureJson<T[K]>;
2300
2327
  };
2301
2328
 
2302
- export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, toPlainLson, tryParseJson, withTimeout };
2329
+ export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, toPlainLson, tryParseJson, withTimeout };
package/dist/index.d.ts CHANGED
@@ -681,6 +681,11 @@ declare type CommentBody = {
681
681
  content: CommentBodyBlockElement[];
682
682
  };
683
683
 
684
+ declare type CommentReaction = {
685
+ emoji: string;
686
+ userId: string;
687
+ createdAt: string;
688
+ };
684
689
  /**
685
690
  * Represents a comment.
686
691
  */
@@ -692,6 +697,7 @@ declare type CommentData = {
692
697
  userId: string;
693
698
  createdAt: string;
694
699
  editedAt?: string;
700
+ reactions: CommentReaction[];
695
701
  } & ({
696
702
  body: CommentBody;
697
703
  deletedAt?: never;
@@ -742,6 +748,16 @@ declare type CommentsApi<ThreadMetadata extends BaseMetadata> = {
742
748
  threadId: string;
743
749
  commentId: string;
744
750
  }): Promise<void>;
751
+ addReaction(options: {
752
+ threadId: string;
753
+ commentId: string;
754
+ emoji: string;
755
+ }): Promise<CommentData>;
756
+ removeReaction(options: {
757
+ threadId: string;
758
+ commentId: string;
759
+ emoji: string;
760
+ }): Promise<CommentData>;
745
761
  };
746
762
  declare function createCommentsApi<ThreadMetadata extends BaseMetadata>(roomId: string, getAuthValue: () => Promise<AuthValue>, { serverEndpoint }: Options): CommentsApi<ThreadMetadata>;
747
763
 
@@ -924,6 +940,64 @@ declare type Delegates<T extends BaseAuthResult> = {
924
940
  createSocket: (authValue: T) => IWebSocketInstance;
925
941
  };
926
942
 
943
+ declare enum ClientMsgCode {
944
+ UPDATE_PRESENCE = 100,
945
+ BROADCAST_EVENT = 103,
946
+ FETCH_STORAGE = 200,
947
+ UPDATE_STORAGE = 201,
948
+ FETCH_YDOC = 300,
949
+ UPDATE_YDOC = 301
950
+ }
951
+ /**
952
+ * Messages that can be sent from the client to the server.
953
+ */
954
+ declare type ClientMsg<TPresence extends JsonObject, TRoomEvent extends Json> = BroadcastEventClientMsg<TRoomEvent> | UpdatePresenceClientMsg<TPresence> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
955
+ declare type BroadcastEventClientMsg<TRoomEvent extends Json> = {
956
+ type: ClientMsgCode.BROADCAST_EVENT;
957
+ event: TRoomEvent;
958
+ };
959
+ declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
960
+ readonly type: ClientMsgCode.UPDATE_PRESENCE;
961
+ /**
962
+ * Set this to any number to signify that this is a Full Presence™
963
+ * update, not a patch.
964
+ *
965
+ * The numeric value itself no longer has specific meaning. Historically,
966
+ * this field was intended so that clients could ignore these broadcasted
967
+ * full presence messages, but it turned out that getting a full presence
968
+ * "keyframe" from time to time was useful.
969
+ *
970
+ * So nowadays, the presence (pun intended) of this `targetActor` field
971
+ * is a backward-compatible way of expressing that the `data` contains
972
+ * all presence fields, and isn't a partial "patch".
973
+ */
974
+ readonly targetActor: number;
975
+ readonly data: TPresence;
976
+ } | {
977
+ readonly type: ClientMsgCode.UPDATE_PRESENCE;
978
+ /**
979
+ * Absence of the `targetActor` field signifies that this is a Partial
980
+ * Presence™ "patch".
981
+ */
982
+ readonly targetActor?: undefined;
983
+ readonly data: Partial<TPresence>;
984
+ };
985
+ declare type UpdateStorageClientMsg = {
986
+ readonly type: ClientMsgCode.UPDATE_STORAGE;
987
+ readonly ops: Op[];
988
+ };
989
+ declare type FetchStorageClientMsg = {
990
+ readonly type: ClientMsgCode.FETCH_STORAGE;
991
+ };
992
+ declare type FetchYDocClientMsg = {
993
+ readonly type: ClientMsgCode.FETCH_YDOC;
994
+ readonly vector: string;
995
+ };
996
+ declare type UpdateYDocClientMsg = {
997
+ readonly type: ClientMsgCode.UPDATE_YDOC;
998
+ readonly update: string;
999
+ };
1000
+
927
1001
  declare type IdTuple<T> = [id: string, value: T];
928
1002
  declare enum CrdtType {
929
1003
  OBJECT = 0,
@@ -983,7 +1057,7 @@ declare enum ServerMsgCode {
983
1057
  /**
984
1058
  * Messages that can be sent from the server to the client.
985
1059
  */
986
- declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdate | CommentsEventServerMsg;
1060
+ declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdateServerMsg | CommentsEventServerMsg;
987
1061
  declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent;
988
1062
  declare type ThreadCreatedEvent = {
989
1063
  type: ServerMsgCode.THREAD_CREATED;
@@ -1094,7 +1168,7 @@ declare type UserLeftServerMsg = {
1094
1168
  * Sent by the WebSocket server when the ydoc is updated or when requested based on stateVector passed.
1095
1169
  * Contains a base64 encoded update
1096
1170
  */
1097
- declare type YDocUpdate = {
1171
+ declare type YDocUpdateServerMsg = {
1098
1172
  readonly type: ServerMsgCode.UPDATE_YDOC;
1099
1173
  readonly update: string;
1100
1174
  readonly isSync: boolean;
@@ -1232,13 +1306,19 @@ declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUse
1232
1306
  type: "reset";
1233
1307
  };
1234
1308
 
1235
- declare type CustomEvent<TRoomEvent extends Json> = {
1309
+ declare type RoomEventMessage<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
1236
1310
  /**
1237
1311
  * The connection ID of the client that sent the event.
1238
1312
  * If this message was broadcast from the server (via the REST API), then
1239
1313
  * this value will be -1.
1240
1314
  */
1241
1315
  connectionId: number;
1316
+ /**
1317
+ * The User (from the others list) that sent the event.
1318
+ * If this message was broadcast from the server (via the REST API), then
1319
+ * this value will be null.
1320
+ */
1321
+ user: User<TPresence, TUserMeta> | null;
1242
1322
  event: TRoomEvent;
1243
1323
  };
1244
1324
  declare type StorageStatus = "not-loaded" | "loading" | "synchronizing" | "synchronized";
@@ -1372,7 +1452,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1372
1452
  * });
1373
1453
  *
1374
1454
  */
1375
- (type: "event", listener: Callback<CustomEvent<TRoomEvent>>): () => void;
1455
+ (type: "event", listener: Callback<RoomEventMessage<TPresence, TUserMeta, TRoomEvent>>): () => void;
1376
1456
  /**
1377
1457
  * Subscribe to errors thrown in the room.
1378
1458
  *
@@ -1612,10 +1692,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1612
1692
  readonly connection: Observable<LegacyConnectionStatus>;
1613
1693
  readonly status: Observable<Status>;
1614
1694
  readonly lostConnection: Observable<LostConnectionEvent>;
1615
- readonly customEvent: Observable<{
1616
- connectionId: number;
1617
- event: TRoomEvent;
1618
- }>;
1695
+ readonly customEvent: Observable<RoomEventMessage<TPresence, TUserMeta, TRoomEvent>>;
1619
1696
  readonly self: Observable<User<TPresence, TUserMeta>>;
1620
1697
  readonly myPresence: Observable<TPresence>;
1621
1698
  readonly others: Observable<{
@@ -1632,7 +1709,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1632
1709
  */
1633
1710
  readonly storageDidLoad: Observable<void>;
1634
1711
  readonly storageStatus: Observable<StorageStatus>;
1635
- readonly ydoc: Observable<YDocUpdate>;
1712
+ readonly ydoc: Observable<YDocUpdateServerMsg | UpdateYDocClientMsg>;
1636
1713
  readonly comments: Observable<CommentsEventServerMsg>;
1637
1714
  };
1638
1715
  /**
@@ -2078,64 +2155,6 @@ declare function asPos(str: string): Pos;
2078
2155
  */
2079
2156
  declare function shallow(a: unknown, b: unknown): boolean;
2080
2157
 
2081
- declare enum ClientMsgCode {
2082
- UPDATE_PRESENCE = 100,
2083
- BROADCAST_EVENT = 103,
2084
- FETCH_STORAGE = 200,
2085
- UPDATE_STORAGE = 201,
2086
- FETCH_YDOC = 300,
2087
- UPDATE_YDOC = 301
2088
- }
2089
- /**
2090
- * Messages that can be sent from the client to the server.
2091
- */
2092
- declare type ClientMsg<TPresence extends JsonObject, TRoomEvent extends Json> = BroadcastEventClientMsg<TRoomEvent> | UpdatePresenceClientMsg<TPresence> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
2093
- declare type BroadcastEventClientMsg<TRoomEvent extends Json> = {
2094
- type: ClientMsgCode.BROADCAST_EVENT;
2095
- event: TRoomEvent;
2096
- };
2097
- declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
2098
- readonly type: ClientMsgCode.UPDATE_PRESENCE;
2099
- /**
2100
- * Set this to any number to signify that this is a Full Presence™
2101
- * update, not a patch.
2102
- *
2103
- * The numeric value itself no longer has specific meaning. Historically,
2104
- * this field was intended so that clients could ignore these broadcasted
2105
- * full presence messages, but it turned out that getting a full presence
2106
- * "keyframe" from time to time was useful.
2107
- *
2108
- * So nowadays, the presence (pun intended) of this `targetActor` field
2109
- * is a backward-compatible way of expressing that the `data` contains
2110
- * all presence fields, and isn't a partial "patch".
2111
- */
2112
- readonly targetActor: number;
2113
- readonly data: TPresence;
2114
- } | {
2115
- readonly type: ClientMsgCode.UPDATE_PRESENCE;
2116
- /**
2117
- * Absence of the `targetActor` field signifies that this is a Partial
2118
- * Presence™ "patch".
2119
- */
2120
- readonly targetActor?: undefined;
2121
- readonly data: Partial<TPresence>;
2122
- };
2123
- declare type UpdateStorageClientMsg = {
2124
- readonly type: ClientMsgCode.UPDATE_STORAGE;
2125
- readonly ops: Op[];
2126
- };
2127
- declare type FetchStorageClientMsg = {
2128
- readonly type: ClientMsgCode.FETCH_STORAGE;
2129
- };
2130
- declare type FetchYDocClientMsg = {
2131
- readonly type: ClientMsgCode.FETCH_YDOC;
2132
- readonly vector: string;
2133
- };
2134
- declare type UpdateYDocClientMsg = {
2135
- readonly type: ClientMsgCode.UPDATE_YDOC;
2136
- readonly update: string;
2137
- };
2138
-
2139
2158
  declare type JsonTreeNode = {
2140
2159
  readonly type: "Json";
2141
2160
  readonly id: string;
@@ -2265,6 +2284,14 @@ declare type ClientToPanelMessage =
2265
2284
  storage?: readonly LsonTreeNode[];
2266
2285
  me?: UserTreeNode;
2267
2286
  others?: readonly UserTreeNode[];
2287
+ }
2288
+ /**
2289
+ * Sent whenever the ydoc is updated
2290
+ */
2291
+ | {
2292
+ msg: "room::sync::ydoc";
2293
+ roomId: string;
2294
+ update: YDocUpdateServerMsg | UpdateYDocClientMsg;
2268
2295
  };
2269
2296
  declare type FullPanelToClientMessage = PanelToClientMessage & {
2270
2297
  source: "liveblocks-devtools-panel";
@@ -2299,4 +2326,4 @@ declare type EnsureJson<T> = [
2299
2326
  [K in keyof T]: EnsureJson<T[K]>;
2300
2327
  };
2301
2328
 
2302
- export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, toPlainLson, tryParseJson, withTimeout };
2329
+ export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, toPlainLson, tryParseJson, withTimeout };