@liveblocks/core 1.11.2 → 1.12.0-lexical2

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.ts CHANGED
@@ -834,12 +834,12 @@ declare enum ClientMsgCode {
834
834
  /**
835
835
  * Messages that can be sent from the client to the server.
836
836
  */
837
- declare type ClientMsg<TPresence extends JsonObject, TRoomEvent extends Json> = BroadcastEventClientMsg<TRoomEvent> | UpdatePresenceClientMsg<TPresence> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
838
- declare type BroadcastEventClientMsg<TRoomEvent extends Json> = {
837
+ declare type ClientMsg<P extends JsonObject, E extends Json> = BroadcastEventClientMsg<E> | UpdatePresenceClientMsg<P> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
838
+ declare type BroadcastEventClientMsg<E extends Json> = {
839
839
  type: ClientMsgCode.BROADCAST_EVENT;
840
- event: TRoomEvent;
840
+ event: E;
841
841
  };
842
- declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
842
+ declare type UpdatePresenceClientMsg<P extends JsonObject> = {
843
843
  readonly type: ClientMsgCode.UPDATE_PRESENCE;
844
844
  /**
845
845
  * Set this to any number to signify that this is a Full Presence™
@@ -855,7 +855,7 @@ declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
855
855
  * all presence fields, and isn't a partial "patch".
856
856
  */
857
857
  readonly targetActor: number;
858
- readonly data: TPresence;
858
+ readonly data: P;
859
859
  } | {
860
860
  readonly type: ClientMsgCode.UPDATE_PRESENCE;
861
861
  /**
@@ -863,7 +863,7 @@ declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
863
863
  * Presence™ "patch".
864
864
  */
865
865
  readonly targetActor?: undefined;
866
- readonly data: Partial<TPresence>;
866
+ readonly data: Partial<P>;
867
867
  };
868
868
  declare type UpdateStorageClientMsg = {
869
869
  readonly type: ClientMsgCode.UPDATE_STORAGE;
@@ -883,6 +883,164 @@ declare type UpdateYDocClientMsg = {
883
883
  readonly guid?: string;
884
884
  };
885
885
 
886
+ declare type DateToString<T> = {
887
+ [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];
888
+ };
889
+
890
+ declare type BaseMetadata = Record<string, string | boolean | number | undefined>;
891
+ declare type CommentReaction = {
892
+ emoji: string;
893
+ createdAt: Date;
894
+ users: {
895
+ id: string;
896
+ }[];
897
+ };
898
+ /**
899
+ * Represents a comment.
900
+ */
901
+ declare type CommentData = {
902
+ type: "comment";
903
+ id: string;
904
+ threadId: string;
905
+ roomId: string;
906
+ userId: string;
907
+ createdAt: Date;
908
+ editedAt?: Date;
909
+ reactions: CommentReaction[];
910
+ } & ({
911
+ body: CommentBody;
912
+ deletedAt?: never;
913
+ } | {
914
+ body?: never;
915
+ deletedAt: Date;
916
+ });
917
+ declare type CommentDataPlain = Omit<DateToString<CommentData>, "reactions" | "body"> & {
918
+ reactions: DateToString<CommentReaction>[];
919
+ } & ({
920
+ body: CommentBody;
921
+ deletedAt?: never;
922
+ } | {
923
+ body?: never;
924
+ deletedAt: string;
925
+ });
926
+ declare type CommentBodyBlockElement = CommentBodyParagraph;
927
+ declare type CommentBodyInlineElement = CommentBodyText | CommentBodyMention | CommentBodyLink;
928
+ declare type CommentBodyElement = CommentBodyBlockElement | CommentBodyInlineElement;
929
+ declare type CommentBodyParagraph = {
930
+ type: "paragraph";
931
+ children: CommentBodyInlineElement[];
932
+ };
933
+ declare type CommentBodyMention = {
934
+ type: "mention";
935
+ id: string;
936
+ };
937
+ declare type CommentBodyLink = {
938
+ type: "link";
939
+ url: string;
940
+ };
941
+ declare type CommentBodyText = {
942
+ bold?: boolean;
943
+ italic?: boolean;
944
+ strikethrough?: boolean;
945
+ code?: boolean;
946
+ text: string;
947
+ };
948
+ declare type CommentBody = {
949
+ version: 1;
950
+ content: CommentBodyBlockElement[];
951
+ };
952
+ declare type CommentUserReaction = {
953
+ emoji: string;
954
+ createdAt: Date;
955
+ userId: string;
956
+ };
957
+ declare type CommentUserReactionPlain = DateToString<CommentUserReaction>;
958
+ /**
959
+ * Represents a thread of comments.
960
+ */
961
+ declare type ThreadData<M extends BaseMetadata = never> = {
962
+ type: "thread";
963
+ id: string;
964
+ roomId: string;
965
+ createdAt: Date;
966
+ updatedAt?: Date;
967
+ comments: CommentData[];
968
+ metadata: [M] extends [never] ? Record<string, never> : M;
969
+ };
970
+ interface ThreadDataWithDeleteInfo<M extends BaseMetadata = never> extends ThreadData<M> {
971
+ deletedAt?: Date;
972
+ }
973
+ declare type ThreadDataPlain<M extends BaseMetadata = never> = Omit<DateToString<ThreadData<M>>, "comments" | "metadata"> & {
974
+ comments: CommentDataPlain[];
975
+ metadata: [M] extends [never] ? Record<string, never> : M;
976
+ };
977
+ declare type ThreadDeleteInfo = {
978
+ type: "deletedThread";
979
+ id: string;
980
+ roomId: string;
981
+ deletedAt: Date;
982
+ };
983
+ declare type QueryMetadataStringValue<T extends string> = T | {
984
+ startsWith: string;
985
+ };
986
+ /**
987
+ * This type can be used to build a metadata query string (compatible
988
+ * with `@liveblocks/query-parser`) through a type-safe API.
989
+ *
990
+ * In addition to exact values (`:` in query string), it adds:
991
+ * - to strings:
992
+ * - `startsWith` (`^` in query string)
993
+ */
994
+ declare type QueryMetadata<M extends BaseMetadata> = {
995
+ [K in keyof M]: M[K] extends string ? QueryMetadataStringValue<M[K]> : M[K];
996
+ };
997
+
998
+ declare type InboxNotificationThreadData = {
999
+ kind: "thread";
1000
+ id: string;
1001
+ roomId: string;
1002
+ threadId: string;
1003
+ notifiedAt: Date;
1004
+ readAt: Date | null;
1005
+ };
1006
+ declare type InboxNotificationTextMentionData = {
1007
+ kind: "textMention";
1008
+ id: string;
1009
+ roomId: string;
1010
+ notifiedAt: Date;
1011
+ readAt: Date | null;
1012
+ createdBy: string;
1013
+ mentionId: string;
1014
+ };
1015
+ declare type InboxNotificationTextMentionDataPlain = DateToString<InboxNotificationTextMentionData>;
1016
+ declare type ActivityData = Record<string, string | boolean | number | undefined>;
1017
+ declare type InboxNotificationActivity = {
1018
+ id: string;
1019
+ createdAt: Date;
1020
+ data: ActivityData;
1021
+ };
1022
+ declare type InboxNotificationCustomData = {
1023
+ kind: `$${string}`;
1024
+ id: string;
1025
+ roomId?: string;
1026
+ subjectId: string;
1027
+ notifiedAt: Date;
1028
+ readAt: Date | null;
1029
+ activities: InboxNotificationActivity[];
1030
+ };
1031
+ declare type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData;
1032
+ declare type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
1033
+ declare type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
1034
+ activities: DateToString<InboxNotificationActivity>[];
1035
+ };
1036
+ declare type InboxNotificationDataPlain = InboxNotificationThreadDataPlain | InboxNotificationCustomDataPlain | InboxNotificationTextMentionDataPlain;
1037
+ declare type InboxNotificationDeleteInfo = {
1038
+ type: "deletedInboxNotification";
1039
+ id: string;
1040
+ roomId: string;
1041
+ deletedAt: Date;
1042
+ };
1043
+
886
1044
  declare type IdTuple<T> = [id: string, value: T];
887
1045
  declare enum CrdtType {
888
1046
  OBJECT = 0,
@@ -944,7 +1102,7 @@ declare enum ServerMsgCode {
944
1102
  /**
945
1103
  * Messages that can be sent from the server to the client.
946
1104
  */
947
- 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;
1105
+ 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;
948
1106
  declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
949
1107
  declare type ThreadCreatedEvent = {
950
1108
  type: ServerMsgCode.THREAD_CREATED;
@@ -992,7 +1150,7 @@ declare type CommentReactionRemoved = {
992
1150
  * those cases, the `targetActor` field indicates the newly connected client,
993
1151
  * so all other existing clients can ignore this broadcasted message.
994
1152
  */
995
- declare type UpdatePresenceServerMsg<TPresence extends JsonObject> = {
1153
+ declare type UpdatePresenceServerMsg<P extends JsonObject> = {
996
1154
  readonly type: ServerMsgCode.UPDATE_PRESENCE;
997
1155
  /**
998
1156
  * The User whose Presence has changed.
@@ -1016,7 +1174,7 @@ declare type UpdatePresenceServerMsg<TPresence extends JsonObject> = {
1016
1174
  * this will be the full Presence, otherwise it only contain the fields that
1017
1175
  * have changed since the last broadcast.
1018
1176
  */
1019
- readonly data: TPresence;
1177
+ readonly data: P;
1020
1178
  } | {
1021
1179
  readonly type: ServerMsgCode.UPDATE_PRESENCE;
1022
1180
  /**
@@ -1031,25 +1189,25 @@ declare type UpdatePresenceServerMsg<TPresence extends JsonObject> = {
1031
1189
  * A partial Presence patch to apply to the User. It will only contain the
1032
1190
  * fields that have changed since the last broadcast.
1033
1191
  */
1034
- readonly data: Partial<TPresence>;
1192
+ readonly data: Partial<P>;
1035
1193
  };
1036
1194
  /**
1037
1195
  * Sent by the WebSocket server and broadcasted to all clients to announce that
1038
1196
  * a new User has joined the Room.
1039
1197
  */
1040
- declare type UserJoinServerMsg<TUserMeta extends BaseUserMeta> = {
1198
+ declare type UserJoinServerMsg<U extends BaseUserMeta> = {
1041
1199
  readonly type: ServerMsgCode.USER_JOINED;
1042
1200
  readonly actor: number;
1043
1201
  /**
1044
1202
  * The id of the User that has been set in the authentication endpoint.
1045
1203
  * Useful to get additional information about the connected user.
1046
1204
  */
1047
- readonly id: TUserMeta["id"];
1205
+ readonly id: U["id"];
1048
1206
  /**
1049
1207
  * Additional user information that has been set in the authentication
1050
1208
  * endpoint.
1051
1209
  */
1052
- readonly info: TUserMeta["info"];
1210
+ readonly info: U["info"];
1053
1211
  /**
1054
1212
  * Informs the client what (public) permissions this (other) User has.
1055
1213
  */
@@ -1078,7 +1236,7 @@ declare type YDocUpdateServerMsg = {
1078
1236
  * Sent by the WebSocket server and broadcasted to all clients to announce that
1079
1237
  * a User broadcasted an Event to everyone in the Room.
1080
1238
  */
1081
- declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
1239
+ declare type BroadcastedEventServerMsg<E extends Json> = {
1082
1240
  readonly type: ServerMsgCode.BROADCASTED_EVENT;
1083
1241
  /**
1084
1242
  * The User who broadcast the Event. Absent when this event is broadcast from
@@ -1089,14 +1247,14 @@ declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
1089
1247
  * The arbitrary payload of the Event. This can be any JSON value. Clients
1090
1248
  * will have to manually verify/decode this event.
1091
1249
  */
1092
- readonly event: TRoomEvent;
1250
+ readonly event: E;
1093
1251
  };
1094
1252
  /**
1095
1253
  * Sent by the WebSocket server to a single client in response to the client
1096
1254
  * joining the Room, to provide the initial state of the Room. The payload
1097
1255
  * includes a list of all other Users that already are in the Room.
1098
1256
  */
1099
- declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
1257
+ declare type RoomStateServerMsg<U extends BaseUserMeta> = {
1100
1258
  readonly type: ServerMsgCode.ROOM_STATE;
1101
1259
  /**
1102
1260
  * Informs the client what their actor ID is going to be.
@@ -1114,7 +1272,7 @@ declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
1114
1272
  */
1115
1273
  readonly scopes: string[];
1116
1274
  readonly users: {
1117
- readonly [otherActor: number]: TUserMeta & {
1275
+ readonly [otherActor: number]: U & {
1118
1276
  scopes: string[];
1119
1277
  };
1120
1278
  };
@@ -1150,82 +1308,6 @@ declare type RejectedStorageOpServerMsg = {
1150
1308
  readonly reason: string;
1151
1309
  };
1152
1310
 
1153
- declare type BaseMetadata = Record<string, string | boolean | number>;
1154
-
1155
- declare type CommentBodyBlockElement = CommentBodyParagraph;
1156
- declare type CommentBodyInlineElement = CommentBodyText | CommentBodyMention | CommentBodyLink;
1157
- declare type CommentBodyElement = CommentBodyBlockElement | CommentBodyInlineElement;
1158
- declare type CommentBodyParagraph = {
1159
- type: "paragraph";
1160
- children: CommentBodyInlineElement[];
1161
- };
1162
- declare type CommentBodyMention = {
1163
- type: "mention";
1164
- id: string;
1165
- };
1166
- declare type CommentBodyLink = {
1167
- type: "link";
1168
- url: string;
1169
- };
1170
- declare type CommentBodyText = {
1171
- bold?: boolean;
1172
- italic?: boolean;
1173
- strikethrough?: boolean;
1174
- code?: boolean;
1175
- text: string;
1176
- };
1177
- declare type CommentBody = {
1178
- version: 1;
1179
- content: CommentBodyBlockElement[];
1180
- };
1181
-
1182
- declare type DateToString<T> = {
1183
- [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];
1184
- };
1185
-
1186
- declare type CommentReaction = {
1187
- emoji: string;
1188
- createdAt: Date;
1189
- users: {
1190
- id: string;
1191
- }[];
1192
- };
1193
- /**
1194
- * Represents a comment.
1195
- */
1196
- declare type CommentData = {
1197
- type: "comment";
1198
- id: string;
1199
- threadId: string;
1200
- roomId: string;
1201
- userId: string;
1202
- createdAt: Date;
1203
- editedAt?: Date;
1204
- reactions: CommentReaction[];
1205
- } & ({
1206
- body: CommentBody;
1207
- deletedAt?: never;
1208
- } | {
1209
- body?: never;
1210
- deletedAt: Date;
1211
- });
1212
- declare type CommentDataPlain = Omit<DateToString<CommentData>, "reactions" | "body"> & {
1213
- reactions: DateToString<CommentReaction>[];
1214
- } & ({
1215
- body: CommentBody;
1216
- deletedAt?: never;
1217
- } | {
1218
- body?: never;
1219
- deletedAt: string;
1220
- });
1221
-
1222
- declare type CommentUserReaction = {
1223
- emoji: string;
1224
- createdAt: Date;
1225
- userId: string;
1226
- };
1227
- declare type CommentUserReactionPlain = DateToString<CommentUserReaction>;
1228
-
1229
1311
  declare type JsonTreeNode = {
1230
1312
  readonly type: "Json";
1231
1313
  readonly id: string;
@@ -1270,28 +1352,10 @@ declare namespace DevToolsTreeNode {
1270
1352
  export type { DevToolsTreeNode_CustomEventTreeNode as CustomEventTreeNode, DevToolsTreeNode_JsonTreeNode as JsonTreeNode, DevToolsTreeNode_LiveTreeNode as LiveTreeNode, DevToolsTreeNode_LsonTreeNode as LsonTreeNode, DevToolsTreeNode_TreeNode as TreeNode, DevToolsTreeNode_UserTreeNode as UserTreeNode };
1271
1353
  }
1272
1354
 
1273
- declare type InboxNotificationThreadData = {
1274
- kind: "thread";
1275
- id: string;
1276
- roomId: string;
1277
- threadId: string;
1278
- notifiedAt: Date;
1279
- readAt: Date | null;
1280
- };
1281
- declare type InboxNotificationData = InboxNotificationThreadData;
1282
- declare type InboxNotificationDataPlain = DateToString<InboxNotificationData>;
1283
-
1284
- declare type InboxNotificationDeleteInfo = {
1285
- type: "deletedInboxNotification";
1286
- id: string;
1287
- roomId: string;
1288
- deletedAt: Date;
1289
- };
1290
-
1291
1355
  /**
1292
1356
  * Represents a user connected in a room. Treated as immutable.
1293
1357
  */
1294
- declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
1358
+ declare type User<P extends JsonObject, U extends BaseUserMeta> = {
1295
1359
  /**
1296
1360
  * The connection ID of the User. It is unique and increment at every new connection.
1297
1361
  */
@@ -1300,15 +1364,15 @@ declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta>
1300
1364
  * The ID of the User that has been set in the authentication endpoint.
1301
1365
  * Useful to get additional information about the connected user.
1302
1366
  */
1303
- readonly id: TUserMeta["id"];
1367
+ readonly id: U["id"];
1304
1368
  /**
1305
1369
  * Additional user information that has been set in the authentication endpoint.
1306
1370
  */
1307
- readonly info: TUserMeta["info"];
1371
+ readonly info: U["info"];
1308
1372
  /**
1309
1373
  * The user’s presence data.
1310
1374
  */
1311
- readonly presence: TPresence;
1375
+ readonly presence: P;
1312
1376
  /**
1313
1377
  * @deprecated Use `!user.canWrite` instead.
1314
1378
  * False if the user can mutate the Room’s Storage and/or YDoc, true if they
@@ -1327,25 +1391,25 @@ declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta>
1327
1391
  };
1328
1392
 
1329
1393
  /**
1330
- * @deprecated Use `readonly User<TPresence, TUserMeta>[]` instead of `Others<TPresence, TUserMeta>`.
1394
+ * @deprecated Use `readonly User<P, U>[]` instead of `Others<P, U>`.
1331
1395
  */
1332
- declare type Others<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = readonly User<TPresence, TUserMeta>[];
1333
- declare type InternalOthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
1396
+ declare type Others<P extends JsonObject, U extends BaseUserMeta> = readonly User<P, U>[];
1397
+ declare type InternalOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
1334
1398
  type: "leave";
1335
- user: User<TPresence, TUserMeta>;
1399
+ user: User<P, U>;
1336
1400
  } | {
1337
1401
  type: "enter";
1338
- user: User<TPresence, TUserMeta>;
1402
+ user: User<P, U>;
1339
1403
  } | {
1340
1404
  type: "update";
1341
- user: User<TPresence, TUserMeta>;
1342
- updates: Partial<TPresence>;
1405
+ user: User<P, U>;
1406
+ updates: Partial<P>;
1343
1407
  } | {
1344
1408
  type: "reset";
1345
1409
  user?: never;
1346
1410
  };
1347
- declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = Resolve<InternalOthersEvent<TPresence, TUserMeta> & {
1348
- others: readonly User<TPresence, TUserMeta>[];
1411
+ declare type OthersEvent<P extends JsonObject, U extends BaseUserMeta> = Resolve<InternalOthersEvent<P, U> & {
1412
+ others: readonly User<P, U>[];
1349
1413
  }>;
1350
1414
 
1351
1415
  declare type PartialNullable<T> = {
@@ -1357,48 +1421,21 @@ declare type RoomNotificationSettings = {
1357
1421
  threads: RoomThreadsNotificationSettings;
1358
1422
  };
1359
1423
 
1360
- /**
1361
- * Represents a thread of comments.
1362
- */
1363
- declare type ThreadData<TThreadMetadata extends BaseMetadata = never> = {
1364
- type: "thread";
1365
- id: string;
1366
- roomId: string;
1367
- createdAt: Date;
1368
- updatedAt?: Date;
1369
- comments: CommentData[];
1370
- metadata: [TThreadMetadata] extends [never] ? Record<string, never> : TThreadMetadata;
1371
- };
1372
- interface ThreadDataWithDeleteInfo<TThreadMetadata extends BaseMetadata = never> extends ThreadData<TThreadMetadata> {
1373
- deletedAt?: Date;
1374
- }
1375
- declare type ThreadDataPlain<TThreadMetadata extends BaseMetadata = never> = Omit<DateToString<ThreadData<TThreadMetadata>>, "comments" | "metadata"> & {
1376
- comments: CommentDataPlain[];
1377
- metadata: [TThreadMetadata] extends [never] ? Record<string, never> : TThreadMetadata;
1378
- };
1379
-
1380
- declare type ThreadDeleteInfo = {
1381
- type: "deletedThread";
1382
- id: string;
1383
- roomId: string;
1384
- deletedAt: Date;
1385
- };
1386
-
1387
- declare type LegacyOthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
1424
+ declare type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
1388
1425
  type: "leave";
1389
- user: User<TPresence, TUserMeta>;
1426
+ user: User<P, U>;
1390
1427
  } | {
1391
1428
  type: "enter";
1392
- user: User<TPresence, TUserMeta>;
1429
+ user: User<P, U>;
1393
1430
  } | {
1394
1431
  type: "update";
1395
- user: User<TPresence, TUserMeta>;
1396
- updates: Partial<TPresence>;
1432
+ user: User<P, U>;
1433
+ updates: Partial<P>;
1397
1434
  } | {
1398
1435
  type: "reset";
1399
1436
  };
1400
- declare type LegacyOthersEventCallback<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = (others: readonly User<TPresence, TUserMeta>[], event: LegacyOthersEvent<TPresence, TUserMeta>) => void;
1401
- declare type RoomEventMessage<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
1437
+ declare type LegacyOthersEventCallback<P extends JsonObject, U extends BaseUserMeta> = (others: readonly User<P, U>[], event: LegacyOthersEvent<P, U>) => void;
1438
+ declare type RoomEventMessage<P extends JsonObject, U extends BaseUserMeta, E extends Json> = {
1402
1439
  /**
1403
1440
  * The connection ID of the client that sent the event.
1404
1441
  * If this message was broadcast from the server (via the REST API), then
@@ -1410,8 +1447,8 @@ declare type RoomEventMessage<TPresence extends JsonObject, TUserMeta extends Ba
1410
1447
  * If this message was broadcast from the server (via the REST API), then
1411
1448
  * this value will be null.
1412
1449
  */
1413
- user: User<TPresence, TUserMeta> | null;
1414
- event: TRoomEvent;
1450
+ user: User<P, U> | null;
1451
+ event: E;
1415
1452
  };
1416
1453
  declare type StorageStatus = "not-loaded" | "loading" | "synchronizing" | "synchronized";
1417
1454
  interface History {
@@ -1503,7 +1540,7 @@ declare type BroadcastOptions = {
1503
1540
  */
1504
1541
  shouldQueueEventIfNotReady: boolean;
1505
1542
  };
1506
- declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
1543
+ declare type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U extends BaseUserMeta, E extends Json> = {
1507
1544
  /**
1508
1545
  * Subscribe to the current user presence updates.
1509
1546
  *
@@ -1516,7 +1553,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1516
1553
  * // Do something
1517
1554
  * });
1518
1555
  */
1519
- (type: "my-presence", listener: Callback<TPresence>): () => void;
1556
+ (type: "my-presence", listener: Callback<P>): () => void;
1520
1557
  /**
1521
1558
  * Subscribe to the other users updates.
1522
1559
  *
@@ -1530,7 +1567,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1530
1567
  * });
1531
1568
  *
1532
1569
  */
1533
- (type: "others", listener: LegacyOthersEventCallback<TPresence, TUserMeta>): () => void;
1570
+ (type: "others", listener: LegacyOthersEventCallback<P, U>): () => void;
1534
1571
  /**
1535
1572
  * Subscribe to events broadcasted by {@link Room.broadcastEvent}
1536
1573
  *
@@ -1544,7 +1581,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1544
1581
  * });
1545
1582
  *
1546
1583
  */
1547
- (type: "event", listener: Callback<RoomEventMessage<TPresence, TUserMeta, TRoomEvent>>): () => void;
1584
+ (type: "event", listener: Callback<RoomEventMessage<P, U, E>>): () => void;
1548
1585
  /**
1549
1586
  * Subscribe to errors thrown in the room.
1550
1587
  *
@@ -1660,15 +1697,15 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
1660
1697
  */
1661
1698
  (type: "storage-status", listener: Callback<StorageStatus>): () => void;
1662
1699
  };
1663
- declare type GetThreadsOptions<TThreadMetadata extends BaseMetadata> = {
1700
+ declare type GetThreadsOptions<M extends BaseMetadata> = {
1664
1701
  query?: {
1665
- metadata?: Partial<TThreadMetadata>;
1702
+ metadata?: Partial<QueryMetadata<M>>;
1666
1703
  };
1667
1704
  since?: Date;
1668
1705
  };
1669
- declare type CommentsApi = {
1670
- getThreads<TThreadMetadata extends BaseMetadata = never>(options?: GetThreadsOptions<TThreadMetadata>): Promise<{
1671
- threads: ThreadData<TThreadMetadata>[];
1706
+ declare type CommentsApi$1<M extends BaseMetadata> = {
1707
+ getThreads(options?: GetThreadsOptions<M>): Promise<{
1708
+ threads: ThreadData<M>[];
1672
1709
  inboxNotifications: InboxNotificationData[];
1673
1710
  deletedThreads: ThreadDeleteInfo[];
1674
1711
  deletedInboxNotifications: InboxNotificationDeleteInfo[];
@@ -1676,22 +1713,22 @@ declare type CommentsApi = {
1676
1713
  requestedAt: Date;
1677
1714
  };
1678
1715
  }>;
1679
- getThread<TThreadMetadata extends BaseMetadata = never>(options: {
1716
+ getThread(options: {
1680
1717
  threadId: string;
1681
1718
  }): Promise<{
1682
- thread: ThreadData<TThreadMetadata>;
1719
+ thread: ThreadData<M>;
1683
1720
  inboxNotification?: InboxNotificationData;
1684
1721
  } | undefined>;
1685
- createThread<TThreadMetadata extends BaseMetadata = never>(options: {
1722
+ createThread(options: {
1686
1723
  threadId: string;
1687
1724
  commentId: string;
1688
- metadata: TThreadMetadata | undefined;
1725
+ metadata: M | undefined;
1689
1726
  body: CommentBody;
1690
- }): Promise<ThreadData<TThreadMetadata>>;
1691
- editThreadMetadata<TThreadMetadata extends BaseMetadata = never>(options: {
1692
- metadata: PartialNullable<TThreadMetadata>;
1727
+ }): Promise<ThreadData<M>>;
1728
+ editThreadMetadata(options: {
1729
+ metadata: PartialNullable<M>;
1693
1730
  threadId: string;
1694
- }): Promise<TThreadMetadata>;
1731
+ }): Promise<M>;
1695
1732
  createComment(options: {
1696
1733
  threadId: string;
1697
1734
  commentId: string;
@@ -1717,7 +1754,7 @@ declare type CommentsApi = {
1717
1754
  emoji: string;
1718
1755
  }): Promise<void>;
1719
1756
  };
1720
- declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
1757
+ declare type Room<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json> = {
1721
1758
  /**
1722
1759
  * @private
1723
1760
  *
@@ -1725,7 +1762,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1725
1762
  * of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
1726
1763
  * will probably happen if you do.
1727
1764
  */
1728
- readonly [kInternal]: PrivateRoomApi;
1765
+ readonly [kInternal]: PrivateRoomApi<never>;
1729
1766
  /**
1730
1767
  * The id of the room.
1731
1768
  */
@@ -1754,7 +1791,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1754
1791
  * a status badge for your Liveblocks connection.
1755
1792
  */
1756
1793
  getStatus(): Status;
1757
- readonly subscribe: SubscribeFn<TPresence, TStorage, TUserMeta, TRoomEvent>;
1794
+ readonly subscribe: SubscribeFn<P, S, U, E>;
1758
1795
  /**
1759
1796
  * Room's history contains functions that let you undo and redo operation made on by the current client on the presence and storage.
1760
1797
  */
@@ -1766,21 +1803,21 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1766
1803
  * @example
1767
1804
  * const user = room.getSelf();
1768
1805
  */
1769
- getSelf(): User<TPresence, TUserMeta> | null;
1806
+ getSelf(): User<P, U> | null;
1770
1807
  /**
1771
1808
  * Gets the presence of the current user.
1772
1809
  *
1773
1810
  * @example
1774
1811
  * const presence = room.getPresence();
1775
1812
  */
1776
- getPresence(): TPresence;
1813
+ getPresence(): P;
1777
1814
  /**
1778
1815
  * Gets all the other users in the room.
1779
1816
  *
1780
1817
  * @example
1781
1818
  * const others = room.getOthers();
1782
1819
  */
1783
- getOthers(): readonly User<TPresence, TUserMeta>[];
1820
+ getOthers(): readonly User<P, U>[];
1784
1821
  /**
1785
1822
  * Updates the presence of the current user. Only pass the properties you want to update. No need to send the full presence.
1786
1823
  * @param patch A partial object that contains the properties you want to update.
@@ -1793,7 +1830,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1793
1830
  * const presence = room.getPresence();
1794
1831
  * // presence is equivalent to { x: 0, y: 0 }
1795
1832
  */
1796
- updatePresence(patch: Partial<TPresence>, options?: {
1833
+ updatePresence(patch: Partial<P>, options?: {
1797
1834
  /**
1798
1835
  * Whether or not the presence should have an impact on the undo/redo history.
1799
1836
  */
@@ -1824,7 +1861,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1824
1861
  * }
1825
1862
  * });
1826
1863
  */
1827
- broadcastEvent(event: TRoomEvent, options?: BroadcastOptions): void;
1864
+ broadcastEvent(event: E, options?: BroadcastOptions): void;
1828
1865
  /**
1829
1866
  * Get the room's storage asynchronously.
1830
1867
  * The storage's root is a {@link LiveObject}.
@@ -1833,7 +1870,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1833
1870
  * const { root } = await room.getStorage();
1834
1871
  */
1835
1872
  getStorage(): Promise<{
1836
- root: LiveObject<TStorage>;
1873
+ root: LiveObject<S>;
1837
1874
  }>;
1838
1875
  /**
1839
1876
  * Get the room's storage synchronously.
@@ -1842,14 +1879,14 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1842
1879
  * @example
1843
1880
  * const root = room.getStorageSnapshot();
1844
1881
  */
1845
- getStorageSnapshot(): LiveObject<TStorage> | null;
1882
+ getStorageSnapshot(): LiveObject<S> | null;
1846
1883
  readonly events: {
1847
1884
  readonly status: Observable<Status>;
1848
1885
  readonly lostConnection: Observable<LostConnectionEvent>;
1849
- readonly customEvent: Observable<RoomEventMessage<TPresence, TUserMeta, TRoomEvent>>;
1850
- readonly self: Observable<User<TPresence, TUserMeta>>;
1851
- readonly myPresence: Observable<TPresence>;
1852
- readonly others: Observable<OthersEvent<TPresence, TUserMeta>>;
1886
+ readonly customEvent: Observable<RoomEventMessage<P, U, E>>;
1887
+ readonly self: Observable<User<P, U>>;
1888
+ readonly myPresence: Observable<P>;
1889
+ readonly others: Observable<OthersEvent<P, U>>;
1853
1890
  readonly error: Observable<LiveblocksError>;
1854
1891
  readonly storage: Observable<StorageUpdate[]>;
1855
1892
  readonly history: Observable<HistoryEvent>;
@@ -1918,42 +1955,45 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1918
1955
  * Liveblocks, NEVER USE ANY OF THESE METHODS DIRECTLY, because bad things
1919
1956
  * will probably happen if you do.
1920
1957
  */
1921
- declare type PrivateRoomApi = {
1958
+ declare type PrivateRoomApi<M extends BaseMetadata> = {
1922
1959
  presenceBuffer: Json | undefined;
1923
1960
  undoStack: readonly (readonly Readonly<HistoryOp<JsonObject>>[])[];
1924
1961
  nodeCount: number;
1925
1962
  getSelf_forDevTools(): UserTreeNode | null;
1926
1963
  getOthers_forDevTools(): readonly UserTreeNode[];
1964
+ reportTextEditor(editor: "lexical", rootKey: string): void;
1965
+ createTextMention(userId: string, mentionId: string): Promise<Response>;
1966
+ deleteTextMention(mentionId: string): Promise<Response>;
1927
1967
  simulate: {
1928
1968
  explicitClose(event: IWebSocketCloseEvent): void;
1929
1969
  rawSend(data: string): void;
1930
1970
  };
1931
- comments: CommentsApi;
1971
+ comments: CommentsApi$1<M>;
1932
1972
  notifications: {
1933
1973
  getRoomNotificationSettings(): Promise<RoomNotificationSettings>;
1934
1974
  updateRoomNotificationSettings(settings: Partial<RoomNotificationSettings>): Promise<RoomNotificationSettings>;
1935
1975
  markInboxNotificationAsRead(notificationId: string): Promise<void>;
1936
1976
  };
1937
1977
  };
1938
- declare type HistoryOp<TPresence extends JsonObject> = Op | {
1978
+ declare type HistoryOp<P extends JsonObject> = Op | {
1939
1979
  readonly type: "presence";
1940
- readonly data: TPresence;
1980
+ readonly data: P;
1941
1981
  };
1942
1982
  declare type Polyfills = {
1943
1983
  atob?: (data: string) => string;
1944
1984
  fetch?: typeof fetch;
1945
1985
  WebSocket?: IWebSocket;
1946
1986
  };
1947
- declare type RoomInitializers<TPresence extends JsonObject, TStorage extends LsonObject> = Resolve<{
1987
+ declare type RoomInitializers<P extends JsonObject, S extends LsonObject> = Resolve<{
1948
1988
  /**
1949
1989
  * The initial Presence to use and announce when you enter the Room. The
1950
1990
  * Presence is available on all users in the Room (me & others).
1951
1991
  */
1952
- initialPresence: TPresence | ((roomId: string) => TPresence);
1992
+ initialPresence: P | ((roomId: string) => P);
1953
1993
  /**
1954
1994
  * The initial Storage to use when entering a new Room.
1955
1995
  */
1956
- initialStorage?: TStorage | ((roomId: string) => TStorage);
1996
+ initialStorage?: S | ((roomId: string) => S);
1957
1997
  /**
1958
1998
  * Whether or not the room automatically connects to Liveblock servers.
1959
1999
  * Default is true.
@@ -2004,17 +2044,18 @@ declare type GetInboxNotificationsOptions = {
2004
2044
  since?: Date;
2005
2045
  };
2006
2046
 
2007
- declare type OptimisticUpdate<TThreadMetadata extends BaseMetadata> = CreateThreadOptimisticUpdate<TThreadMetadata> | EditThreadMetadataOptimisticUpdate<TThreadMetadata> | CreateCommentOptimisticUpdate | EditCommentOptimisticUpdate | DeleteCommentOptimisticUpdate | AddReactionOptimisticUpdate | RemoveReactionOptimisticUpdate | MarkInboxNotificationAsReadOptimisticUpdate | MarkAllInboxNotificationsAsReadOptimisticUpdate | UpdateNotificationSettingsOptimisticUpdate;
2008
- declare type CreateThreadOptimisticUpdate<TThreadMetadata extends BaseMetadata> = {
2047
+ declare type OptimisticUpdate<M extends BaseMetadata> = CreateThreadOptimisticUpdate<M> | EditThreadMetadataOptimisticUpdate<M> | CreateCommentOptimisticUpdate | EditCommentOptimisticUpdate | DeleteCommentOptimisticUpdate | AddReactionOptimisticUpdate | RemoveReactionOptimisticUpdate | MarkInboxNotificationAsReadOptimisticUpdate | MarkAllInboxNotificationsAsReadOptimisticUpdate | UpdateNotificationSettingsOptimisticUpdate;
2048
+ declare type CreateThreadOptimisticUpdate<M extends BaseMetadata> = {
2009
2049
  type: "create-thread";
2010
2050
  id: string;
2011
- thread: ThreadData<TThreadMetadata>;
2051
+ roomId: string;
2052
+ thread: ThreadData<M>;
2012
2053
  };
2013
- declare type EditThreadMetadataOptimisticUpdate<TThreadMetadata extends BaseMetadata> = {
2054
+ declare type EditThreadMetadataOptimisticUpdate<M extends BaseMetadata> = {
2014
2055
  type: "edit-thread-metadata";
2015
2056
  id: string;
2016
2057
  threadId: string;
2017
- metadata: Resolve<PartialNullable<TThreadMetadata>>;
2058
+ metadata: Resolve<PartialNullable<M>>;
2018
2059
  updatedAt: Date;
2019
2060
  };
2020
2061
  declare type CreateCommentOptimisticUpdate = {
@@ -2030,6 +2071,7 @@ declare type EditCommentOptimisticUpdate = {
2030
2071
  declare type DeleteCommentOptimisticUpdate = {
2031
2072
  type: "delete-comment";
2032
2073
  id: string;
2074
+ roomId: string;
2033
2075
  threadId: string;
2034
2076
  deletedAt: Date;
2035
2077
  commentId: string;
@@ -2074,11 +2116,11 @@ declare type QueryState = {
2074
2116
  isLoading: false;
2075
2117
  error?: Error;
2076
2118
  };
2077
- declare type CacheState<TThreadMetadata extends BaseMetadata> = {
2119
+ declare type CacheState<M extends BaseMetadata> = {
2078
2120
  /**
2079
2121
  * Threads by ID.
2080
2122
  */
2081
- threads: Record<string, ThreadDataWithDeleteInfo<TThreadMetadata>>;
2123
+ threads: Record<string, ThreadDataWithDeleteInfo<M>>;
2082
2124
  /**
2083
2125
  * Keep track of loading and error status of all the queries made by the client.
2084
2126
  */
@@ -2087,7 +2129,7 @@ declare type CacheState<TThreadMetadata extends BaseMetadata> = {
2087
2129
  * Optimistic updates that have not been acknowledged by the server yet.
2088
2130
  * They are applied on top of the threads in selectors.
2089
2131
  */
2090
- optimisticUpdates: OptimisticUpdate<TThreadMetadata>[];
2132
+ optimisticUpdates: OptimisticUpdate<M>[];
2091
2133
  /**
2092
2134
  * Inbox notifications by ID.
2093
2135
  */
@@ -2097,19 +2139,20 @@ declare type CacheState<TThreadMetadata extends BaseMetadata> = {
2097
2139
  */
2098
2140
  notificationSettings: Record<string, RoomNotificationSettings>;
2099
2141
  };
2100
- interface CacheStore<TThreadMetadata extends BaseMetadata> extends Store<CacheState<TThreadMetadata>> {
2142
+ interface CacheStore<M extends BaseMetadata> extends Store<CacheState<M>> {
2101
2143
  deleteThread(threadId: string): void;
2102
- updateThreadAndNotification(thread: ThreadData<TThreadMetadata>, inboxNotification?: InboxNotificationData): void;
2103
- updateThreadsAndNotifications(threads: ThreadData<TThreadMetadata>[], inboxNotifications: InboxNotificationData[], deletedThreads: ThreadDeleteInfo[], deletedInboxNotifications: InboxNotificationDeleteInfo[], queryKey?: string): void;
2144
+ updateThreadAndNotification(thread: ThreadData<M>, inboxNotification?: InboxNotificationData): void;
2145
+ updateThreadsAndNotifications(threads: ThreadData<M>[], inboxNotifications: InboxNotificationData[], deletedThreads: ThreadDeleteInfo[], deletedInboxNotifications: InboxNotificationDeleteInfo[], queryKey?: string): void;
2104
2146
  updateRoomInboxNotificationSettings(roomId: string, settings: RoomNotificationSettings, queryKey: string): void;
2105
- pushOptimisticUpdate(optimisticUpdate: OptimisticUpdate<TThreadMetadata>): void;
2147
+ pushOptimisticUpdate(optimisticUpdate: OptimisticUpdate<M>): void;
2106
2148
  setQueryState(queryKey: string, queryState: QueryState): void;
2149
+ optimisticUpdatesEventSource: ReturnType<typeof makeEventSource<OptimisticUpdate<M>>>;
2107
2150
  }
2108
- declare function applyOptimisticUpdates<TThreadMetadata extends BaseMetadata>(state: CacheState<TThreadMetadata>): Pick<CacheState<TThreadMetadata>, "threads" | "inboxNotifications" | "notificationSettings">;
2109
- declare function upsertComment<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, comment: CommentData): ThreadDataWithDeleteInfo<TThreadMetadata>;
2110
- declare function deleteComment<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, commentId: string, deletedAt: Date): ThreadDataWithDeleteInfo<TThreadMetadata>;
2111
- declare function addReaction<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, commentId: string, reaction: CommentUserReaction): ThreadDataWithDeleteInfo<TThreadMetadata>;
2112
- declare function removeReaction<TThreadMetadata extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<TThreadMetadata>, commentId: string, emoji: string, userId: string, removedAt: Date): ThreadDataWithDeleteInfo<TThreadMetadata>;
2151
+ declare function applyOptimisticUpdates<M extends BaseMetadata>(state: CacheState<M>): Pick<CacheState<M>, "threads" | "inboxNotifications" | "notificationSettings">;
2152
+ declare function upsertComment<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, comment: CommentData): ThreadDataWithDeleteInfo<M>;
2153
+ declare function deleteComment<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, commentId: string, deletedAt: Date): ThreadDataWithDeleteInfo<M>;
2154
+ declare function addReaction<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, commentId: string, reaction: CommentUserReaction): ThreadDataWithDeleteInfo<M>;
2155
+ declare function removeReaction<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, commentId: string, emoji: string, userId: string, removedAt: Date): ThreadDataWithDeleteInfo<M>;
2113
2156
 
2114
2157
  declare type OptionalPromise<T> = T | Promise<T>;
2115
2158
 
@@ -2124,6 +2167,12 @@ declare type RoomInfo = {
2124
2167
  url?: string;
2125
2168
  };
2126
2169
 
2170
+ /** DP = Default Presence type */
2171
+ declare type DP = JsonObject;
2172
+ /** DS = Default Storage type */
2173
+ declare type DS = LsonObject;
2174
+ /** DU = Default UserMeta type */
2175
+ declare type DU = BaseUserMeta;
2127
2176
  declare type ResolveMentionSuggestionsArgs = {
2128
2177
  /**
2129
2178
  * The ID of the current room.
@@ -2146,7 +2195,7 @@ declare type ResolveRoomsInfoArgs = {
2146
2195
  */
2147
2196
  roomIds: string[];
2148
2197
  };
2149
- declare type EnterOptions<TPresence extends JsonObject, TStorage extends LsonObject> = Resolve<RoomInitializers<TPresence, TStorage> & {
2198
+ declare type EnterOptions<P extends JsonObject, S extends LsonObject> = Resolve<RoomInitializers<P, S> & {
2150
2199
  /**
2151
2200
  * Only necessary when you’re using Liveblocks with React v17 or lower.
2152
2201
  *
@@ -2164,19 +2213,20 @@ declare type EnterOptions<TPresence extends JsonObject, TStorage extends LsonObj
2164
2213
  * of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
2165
2214
  * will probably happen if you do.
2166
2215
  */
2167
- declare type PrivateClientApi<TUserMeta extends BaseUserMeta> = {
2168
- notifications: NotificationsApi;
2169
- currentUserIdStore: Store<string | null>;
2170
- resolveMentionSuggestions: ClientOptions["resolveMentionSuggestions"];
2171
- cacheStore: CacheStore<BaseMetadata>;
2172
- usersStore: BatchStore<TUserMeta["info"] | undefined, [string]>;
2173
- roomsInfoStore: BatchStore<RoomInfo | undefined, [string]>;
2174
- getRoomIds: () => string[];
2175
- };
2176
- declare type NotificationsApi<TThreadMetadata extends BaseMetadata = never> = {
2216
+ declare type PrivateClientApi<U extends BaseUserMeta> = {
2217
+ readonly notifications: NotificationsApi;
2218
+ readonly comments: CommentsApi;
2219
+ readonly currentUserIdStore: Store<string | null>;
2220
+ readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
2221
+ readonly cacheStore: CacheStore<BaseMetadata>;
2222
+ readonly usersStore: BatchStore<U["info"] | undefined, [string]>;
2223
+ readonly roomsInfoStore: BatchStore<RoomInfo | undefined, [string]>;
2224
+ readonly getRoomIds: () => string[];
2225
+ };
2226
+ declare type NotificationsApi<M extends BaseMetadata = never> = {
2177
2227
  getInboxNotifications(options?: GetInboxNotificationsOptions): Promise<{
2178
2228
  inboxNotifications: InboxNotificationData[];
2179
- threads: ThreadData<TThreadMetadata>[];
2229
+ threads: ThreadData<M>[];
2180
2230
  deletedThreads: ThreadDeleteInfo[];
2181
2231
  deletedInboxNotifications: InboxNotificationDeleteInfo[];
2182
2232
  meta: {
@@ -2187,21 +2237,31 @@ declare type NotificationsApi<TThreadMetadata extends BaseMetadata = never> = {
2187
2237
  markAllInboxNotificationsAsRead(): Promise<void>;
2188
2238
  markInboxNotificationAsRead(inboxNotificationId: string): Promise<void>;
2189
2239
  };
2190
- declare type Client<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2240
+ declare type CommentsApi = {
2241
+ createThreadId(): string;
2242
+ createCommentId(): string;
2243
+ createInboxNotificationId(): string;
2244
+ selectedThreads<M extends BaseMetadata>(roomId: string, state: CacheState<M>, options: GetThreadsOptions<M>): ThreadData<M>[];
2245
+ selectedInboxNotifications<M extends BaseMetadata>(state: CacheState<M>): InboxNotificationData[];
2246
+ selectNotificationSettings<M extends BaseMetadata>(roomId: string, state: CacheState<M>): RoomNotificationSettings;
2247
+ };
2248
+ declare type Client<U extends BaseUserMeta = DU> = {
2191
2249
  /**
2192
2250
  * Gets a room. Returns null if {@link Client.enter} has not been called previously.
2193
2251
  *
2194
2252
  * @param roomId The id of the room
2195
2253
  */
2196
- getRoom<TPresence extends JsonObject, TStorage extends LsonObject = LsonObject, TUserMeta extends BaseUserMeta = BaseUserMeta, TRoomEvent extends Json = never>(roomId: string): Room<TPresence, TStorage, TUserMeta, TRoomEvent> | null;
2254
+ getRoom<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, // TODO Remove in 2.0, this is shadowing the Client-level type arg
2255
+ E extends Json = never>(roomId: string): Room<P, S, U, E> | null;
2197
2256
  /**
2198
2257
  * Enter a room.
2199
2258
  * @param roomId The id of the room
2200
2259
  * @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
2201
2260
  * @returns The room and a leave function. Call the returned leave() function when you no longer need the room.
2202
2261
  */
2203
- enterRoom<TPresence extends JsonObject, TStorage extends LsonObject = LsonObject, TUserMeta extends BaseUserMeta = BaseUserMeta, TRoomEvent extends Json = never>(roomId: string, options: EnterOptions<TPresence, TStorage>): {
2204
- room: Room<TPresence, TStorage, TUserMeta, TRoomEvent>;
2262
+ enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, // TODO Remove in 2.0, this is shadowing the Client-level type arg
2263
+ E extends Json = never>(roomId: string, options: EnterOptions<P, S>): {
2264
+ room: Room<P, S, U, E>;
2205
2265
  leave: () => void;
2206
2266
  };
2207
2267
  /**
@@ -2211,7 +2271,8 @@ declare type Client<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2211
2271
  * @param roomId The id of the room
2212
2272
  * @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
2213
2273
  */
2214
- enter<TPresence extends JsonObject, TStorage extends LsonObject = LsonObject, TUserMeta extends BaseUserMeta = BaseUserMeta, TRoomEvent extends Json = never>(roomId: string, options: EnterOptions<TPresence, TStorage>): Room<TPresence, TStorage, TUserMeta, TRoomEvent>;
2274
+ enter<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, // TODO Remove in 2.0, this is shadowing the Client-level type arg
2275
+ E extends Json = never>(roomId: string, options: EnterOptions<P, S>): Room<P, S, U, E>;
2215
2276
  /**
2216
2277
  * @deprecated - Prefer using {@link Client.enterRoom} and calling the returned leave function instead, which is safer.
2217
2278
  *
@@ -2239,14 +2300,14 @@ declare type Client<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2239
2300
  * of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
2240
2301
  * will probably happen if you do.
2241
2302
  */
2242
- readonly [kInternal]: PrivateClientApi<TUserMeta>;
2303
+ readonly [kInternal]: PrivateClientApi<U>;
2243
2304
  };
2244
2305
  declare type AuthEndpoint = string | ((room?: string) => Promise<CustomAuthenticationResult>);
2245
2306
  /**
2246
2307
  * The authentication endpoint that is called to ensure that the current user has access to a room.
2247
2308
  * Can be an url or a callback if you need to add additional headers.
2248
2309
  */
2249
- declare type ClientOptions<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2310
+ declare type ClientOptions<U extends BaseUserMeta = DU> = {
2250
2311
  throttle?: number;
2251
2312
  lostConnectionTimeout?: number;
2252
2313
  backgroundKeepAliveTimeout?: number;
@@ -2274,7 +2335,7 @@ declare type ClientOptions<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2274
2335
  *
2275
2336
  * A function that returns user info from user IDs.
2276
2337
  */
2277
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(TUserMeta["info"] | undefined)[] | undefined>;
2338
+ resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
2278
2339
  /**
2279
2340
  * @beta
2280
2341
  *
@@ -2313,7 +2374,7 @@ declare type ClientOptions<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2313
2374
  * }
2314
2375
  * });
2315
2376
  */
2316
- declare function createClient<TUserMeta extends BaseUserMeta = BaseUserMeta>(options: ClientOptions<TUserMeta>): Client<TUserMeta>;
2377
+ declare function createClient<U extends BaseUserMeta = DU>(options: ClientOptions<U>): Client<U>;
2317
2378
  declare class NotificationsApiError extends Error {
2318
2379
  message: string;
2319
2380
  status: number;
@@ -2347,7 +2408,7 @@ declare type CommentBodyLinkElementArgs = {
2347
2408
  */
2348
2409
  href: string;
2349
2410
  };
2350
- declare type CommentBodyMentionElementArgs<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2411
+ declare type CommentBodyMentionElementArgs<U extends BaseUserMeta = BaseUserMeta> = {
2351
2412
  /**
2352
2413
  * The mention element.
2353
2414
  */
@@ -2355,9 +2416,9 @@ declare type CommentBodyMentionElementArgs<TUserMeta extends BaseUserMeta = Base
2355
2416
  /**
2356
2417
  * The mention's user info, if the `resolvedUsers` option was provided.
2357
2418
  */
2358
- user?: TUserMeta["info"];
2419
+ user?: U["info"];
2359
2420
  };
2360
- declare type StringifyCommentBodyElements<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2421
+ declare type StringifyCommentBodyElements<U extends BaseUserMeta = BaseUserMeta> = {
2361
2422
  /**
2362
2423
  * The element used to display paragraphs.
2363
2424
  */
@@ -2373,9 +2434,9 @@ declare type StringifyCommentBodyElements<TUserMeta extends BaseUserMeta = BaseU
2373
2434
  /**
2374
2435
  * The element used to display mentions.
2375
2436
  */
2376
- mention: (args: CommentBodyMentionElementArgs<TUserMeta>, index: number) => string;
2437
+ mention: (args: CommentBodyMentionElementArgs<U>, index: number) => string;
2377
2438
  };
2378
- declare type StringifyCommentBodyOptions<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
2439
+ declare type StringifyCommentBodyOptions<U extends BaseUserMeta = BaseUserMeta> = {
2379
2440
  /**
2380
2441
  * Which format to convert the comment to.
2381
2442
  */
@@ -2384,7 +2445,7 @@ declare type StringifyCommentBodyOptions<TUserMeta extends BaseUserMeta = BaseUs
2384
2445
  * The elements used to customize the resulting string. Each element has
2385
2446
  * priority over the defaults inherited from the `format` option.
2386
2447
  */
2387
- elements?: Partial<StringifyCommentBodyElements<TUserMeta>>;
2448
+ elements?: Partial<StringifyCommentBodyElements<U>>;
2388
2449
  /**
2389
2450
  * The separator used between paragraphs.
2390
2451
  */
@@ -2392,7 +2453,7 @@ declare type StringifyCommentBodyOptions<TUserMeta extends BaseUserMeta = BaseUs
2392
2453
  /**
2393
2454
  * A function that returns user info from user IDs.
2394
2455
  */
2395
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(TUserMeta["info"] | undefined)[] | undefined>;
2456
+ resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
2396
2457
  };
2397
2458
  /**
2398
2459
  * Get an array of each user's ID that has been mentioned in a `CommentBody`.
@@ -2402,7 +2463,7 @@ declare function getMentionedIdsFromCommentBody(body: CommentBody): string[];
2402
2463
  * Convert a `CommentBody` into either a plain string,
2403
2464
  * Markdown, HTML, or a custom format.
2404
2465
  */
2405
- declare function stringifyCommentBody<TUserMeta extends BaseUserMeta = BaseUserMeta>(body: CommentBody, options?: StringifyCommentBodyOptions<TUserMeta>): Promise<string>;
2466
+ declare function stringifyCommentBody(body: CommentBody, options?: StringifyCommentBodyOptions<BaseUserMeta>): Promise<string>;
2406
2467
 
2407
2468
  /**
2408
2469
  * Converts a plain comment data object (usually returned by the API) to a comment data object that can be used by the client.
@@ -2417,7 +2478,7 @@ declare function convertToCommentData(data: CommentDataPlain): CommentData;
2417
2478
  * @param data The plain thread data object (usually returned by the API)
2418
2479
  * @returns The rich thread data object that can be used by the client.
2419
2480
  */
2420
- declare function convertToThreadData<TThreadMetadata extends BaseMetadata = never>(data: ThreadDataPlain<TThreadMetadata>): ThreadData<TThreadMetadata>;
2481
+ declare function convertToThreadData<M extends BaseMetadata>(data: ThreadDataPlain<M>): ThreadData<M>;
2421
2482
  /**
2422
2483
  * Converts a plain comment reaction object (usually returned by the API) to a comment reaction object that can be used by the client.
2423
2484
  * This is necessary because the plain data object stores dates as ISO strings, but the client expects them as Date objects.
@@ -2425,6 +2486,13 @@ declare function convertToThreadData<TThreadMetadata extends BaseMetadata = neve
2425
2486
  * @returns The rich comment reaction object that can be used by the client.
2426
2487
  */
2427
2488
  declare function convertToCommentUserReaction(data: CommentUserReactionPlain): CommentUserReaction;
2489
+ /**
2490
+ * Converts a plain inbox notification data object (usually returned by the API) to an inbox notification data object that can be used by the client.
2491
+ * This is necessary because the plain data object stores dates as ISO strings, but the client expects them as Date objects.
2492
+ * @param data The plain inbox notification data object (usually returned by the API)
2493
+ * @returns The rich inbox notification data object that can be used by the client.
2494
+ */
2495
+ declare function convertToInboxNotificationData(data: InboxNotificationDataPlain): InboxNotificationData;
2428
2496
 
2429
2497
  /**
2430
2498
  * Lookup table for nodes (= SerializedCrdt values) by their IDs.
@@ -2443,7 +2511,7 @@ declare function cloneLson<L extends Lson | undefined>(value: L): L;
2443
2511
 
2444
2512
  declare function lsonToJson(value: Lson): Json;
2445
2513
  declare function patchLiveObjectKey<O extends LsonObject, K extends keyof O, V extends Json>(liveObject: LiveObject<O>, key: K, prev?: V, next?: V): void;
2446
- declare function legacy_patchImmutableObject<S extends JsonObject>(state: S, updates: StorageUpdate[]): S;
2514
+ declare function legacy_patchImmutableObject<TState extends JsonObject>(state: TState, updates: StorageUpdate[]): TState;
2447
2515
 
2448
2516
  /**
2449
2517
  * Helper function that can be used to implement exhaustive switch statements
@@ -2533,6 +2601,39 @@ declare namespace fancyConsole {
2533
2601
  */
2534
2602
  declare const freeze: typeof Object.freeze;
2535
2603
 
2604
+ /**
2605
+ * Converts an object to a query string
2606
+ * Example:
2607
+ * ```ts
2608
+ * const query = objectToQuery({
2609
+ resolved: true,
2610
+ metadata: {
2611
+ status: "open",
2612
+ priority: 3,
2613
+ org: {
2614
+ startsWith: "liveblocks:",
2615
+ },
2616
+ },
2617
+ });
2618
+
2619
+ console.log(query);
2620
+ // resolved:true AND metadata["status"]:open AND metadata["priority"]:3 AND metadata["org"]^"liveblocks:"
2621
+
2622
+ * ```
2623
+ *
2624
+ *
2625
+ */
2626
+ declare type SimpleFilterValue = string | number | boolean;
2627
+ declare type OperatorFilterValue = {
2628
+ startsWith: string;
2629
+ };
2630
+ declare type FilterValue = SimpleFilterValue | OperatorFilterValue;
2631
+ declare function objectToQuery(obj: {
2632
+ [key: string]: FilterValue | {
2633
+ [key: string]: FilterValue | undefined;
2634
+ } | undefined;
2635
+ }): string;
2636
+
2536
2637
  declare type Poller = {
2537
2638
  start(interval: number): void;
2538
2639
  restart(interval: number): void;
@@ -2780,4 +2881,4 @@ declare type EnsureJson<T> = [
2780
2881
  [K in keyof T]: EnsureJson<T[K]>;
2781
2882
  };
2782
2883
 
2783
- export { type AckOp, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type CacheState, type CacheStore, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, 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 CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationThreadData, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, NotificationsApiError, type Op, OpCode, type OptionalPromise, type Others, type OthersEvent, type ParentToChildNodeMap, type PartialNullable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomInfo, type RoomInitializers, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, addReaction, applyOptimisticUpdates, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToThreadData, createClient, deleteComment, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, raise, removeReaction, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, upsertComment, withTimeout };
2884
+ export { type AckOp, type ActivityData, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type CacheState, type CacheStore, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, 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 CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, 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 LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, NotificationsApiError, type Op, OpCode, type OptionalPromise, type Others, type OthersEvent, type ParentToChildNodeMap, type PartialNullable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PrivateRoomApi, type QueryMetadata, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomInfo, type RoomInitializers, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, addReaction, applyOptimisticUpdates, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, deleteComment, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, objectToQuery, patchLiveObjectKey, raise, removeReaction, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, upsertComment, withTimeout };