@liveblocks/core 2.0.0-alpha1 → 2.0.0-alpha3

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
@@ -575,7 +575,7 @@ declare type LiveListUpdates<TItem extends Lson> = {
575
575
  * The LiveList class represents an ordered collection of items that is synchronized across clients.
576
576
  */
577
577
  declare class LiveList<TItem extends Lson> extends AbstractCrdt {
578
- constructor(items?: TItem[]);
578
+ constructor(items: TItem[]);
579
579
  /**
580
580
  * Returns the number of elements.
581
581
  */
@@ -774,6 +774,60 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
774
774
  clone(): LiveObject<O>;
775
775
  }
776
776
 
777
+ declare type DateToString<T> = {
778
+ [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];
779
+ };
780
+
781
+ declare type InboxNotificationThreadData = {
782
+ kind: "thread";
783
+ id: string;
784
+ roomId: string;
785
+ threadId: string;
786
+ notifiedAt: Date;
787
+ readAt: Date | null;
788
+ };
789
+ declare type InboxNotificationTextMentionData = {
790
+ kind: "textMention";
791
+ id: string;
792
+ roomId: string;
793
+ notifiedAt: Date;
794
+ readAt: Date | null;
795
+ createdBy: string;
796
+ mentionId: string;
797
+ };
798
+ declare type InboxNotificationTextMentionDataPlain = DateToString<InboxNotificationTextMentionData>;
799
+ declare type ActivityData = Record<string, string | boolean | number | undefined>;
800
+ declare type InboxNotificationActivity<K extends `$${string}` = `$${string}`> = {
801
+ id: string;
802
+ createdAt: Date;
803
+ data: K extends keyof DAD ? DAD[K] : ActivityData;
804
+ };
805
+ declare type InboxNotificationCustomData<K extends `$${string}` = `$${string}`> = {
806
+ kind: `$${string}`;
807
+ id: string;
808
+ roomId?: string;
809
+ subjectId: string;
810
+ notifiedAt: Date;
811
+ readAt: Date | null;
812
+ activities: InboxNotificationActivity<K>[];
813
+ };
814
+ declare type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData;
815
+ declare type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
816
+ declare type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
817
+ activities: DateToString<InboxNotificationActivity>[];
818
+ };
819
+ declare type InboxNotificationDataPlain = InboxNotificationThreadDataPlain | InboxNotificationCustomDataPlain | InboxNotificationTextMentionDataPlain;
820
+ declare type InboxNotificationDeleteInfo = {
821
+ type: "deletedInboxNotification";
822
+ id: string;
823
+ roomId: string;
824
+ deletedAt: Date;
825
+ };
826
+
827
+ declare type BaseActivitiesData = {
828
+ [key: `$${string}`]: ActivityData;
829
+ };
830
+
777
831
  declare type BaseRoomInfo = {
778
832
  [key: string]: Json | undefined;
779
833
  /**
@@ -786,10 +840,6 @@ declare type BaseRoomInfo = {
786
840
  url?: string;
787
841
  };
788
842
 
789
- declare type DateToString<T> = {
790
- [P in keyof T]: T[P] extends Date ? string : T[P] extends Date | null ? string | null : T[P] extends Date | undefined ? string | undefined : T[P];
791
- };
792
-
793
843
  declare type BaseMetadata = Record<string, string | boolean | number | undefined>;
794
844
  declare type CommentReaction = {
795
845
  emoji: string;
@@ -883,7 +933,7 @@ declare type ThreadDeleteInfo = {
883
933
  roomId: string;
884
934
  deletedAt: Date;
885
935
  };
886
- declare type QueryMetadataStringValue<T extends string> = T | {
936
+ declare type StringOperators<T> = T | {
887
937
  startsWith: string;
888
938
  };
889
939
  /**
@@ -895,7 +945,7 @@ declare type QueryMetadataStringValue<T extends string> = T | {
895
945
  * - `startsWith` (`^` in query string)
896
946
  */
897
947
  declare type QueryMetadata<M extends BaseMetadata> = {
898
- [K in keyof M]: M[K] extends string ? QueryMetadataStringValue<M[K]> : M[K];
948
+ [K in keyof M]: string extends M[K] ? StringOperators<M[K]> : M[K];
899
949
  };
900
950
 
901
951
  declare global {
@@ -906,14 +956,15 @@ declare global {
906
956
  [key: string]: unknown;
907
957
  }
908
958
  }
909
- declare type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "RoomInfo";
910
- declare type ExtendedType<K extends ExtendableTypes, B> = unknown extends Liveblocks[K] ? B : Liveblocks[K] extends B ? Liveblocks[K] : `The type you provided for '${K}' does not match its requirements. To learn how to fix this, see https://liveblocks.io/errors/${K}`;
911
- declare type DP = ExtendedType<"Presence", JsonObject>;
912
- declare type DS = ExtendedType<"Storage", LsonObject>;
959
+ declare type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "RoomInfo" | "ActivitiesData";
960
+ declare type ExtendedType<K extends ExtendableTypes, B, ErrorReason extends string = "does not match its requirements"> = unknown extends Liveblocks[K] ? B : Liveblocks[K] extends B ? Liveblocks[K] : `The type you provided for '${K}' ${ErrorReason}. To learn how to fix this, see https://liveblocks.io/docs/errors/${K}`;
961
+ declare type DP = ExtendedType<"Presence", JsonObject, "is not a valid JSON object">;
962
+ declare type DS = ExtendedType<"Storage", LsonObject, "is not a valid LSON value">;
913
963
  declare type DU = ExtendedType<"UserMeta", BaseUserMeta>;
914
- declare type DE = ExtendedType<"RoomEvent", Json>;
964
+ declare type DE = ExtendedType<"RoomEvent", Json, "is not a valid JSON value">;
915
965
  declare type DM = ExtendedType<"ThreadMetadata", BaseMetadata>;
916
966
  declare type DRI = ExtendedType<"RoomInfo", BaseRoomInfo>;
967
+ declare type DAD = ExtendedType<"ActivitiesData", BaseActivitiesData>;
917
968
 
918
969
  /**
919
970
  * Use this symbol to brand an object property as internal.
@@ -1020,42 +1071,6 @@ declare type UpdateYDocClientMsg = {
1020
1071
  readonly guid?: string;
1021
1072
  };
1022
1073
 
1023
- declare type InboxNotificationThreadData = {
1024
- kind: "thread";
1025
- id: string;
1026
- roomId: string;
1027
- threadId: string;
1028
- notifiedAt: Date;
1029
- readAt: Date | null;
1030
- };
1031
- declare type ActivityData = Record<string, string | boolean | number | undefined>;
1032
- declare type InboxNotificationActivity = {
1033
- id: string;
1034
- createdAt: Date;
1035
- data: ActivityData;
1036
- };
1037
- declare type InboxNotificationCustomData = {
1038
- kind: `$${string}`;
1039
- id: string;
1040
- roomId?: string;
1041
- subjectId: string;
1042
- notifiedAt: Date;
1043
- readAt: Date | null;
1044
- activities: InboxNotificationActivity[];
1045
- };
1046
- declare type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData;
1047
- declare type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
1048
- declare type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
1049
- activities: DateToString<InboxNotificationActivity>[];
1050
- };
1051
- declare type InboxNotificationDataPlain = InboxNotificationThreadDataPlain | InboxNotificationCustomDataPlain;
1052
- declare type InboxNotificationDeleteInfo = {
1053
- type: "deletedInboxNotification";
1054
- id: string;
1055
- roomId: string;
1056
- deletedAt: Date;
1057
- };
1058
-
1059
1074
  declare type IdTuple<T> = [id: string, value: T];
1060
1075
  declare enum CrdtType {
1061
1076
  OBJECT = 0,
@@ -1417,9 +1432,13 @@ declare type OthersEvent<P extends JsonObject = DP, U extends BaseUserMeta = DU>
1417
1432
  others: readonly User<P, U>[];
1418
1433
  }>;
1419
1434
 
1420
- declare type PartialNullable<T> = {
1421
- [P in keyof T]?: T[P] | null;
1435
+ declare type OptionalKeys<T> = {
1436
+ [K in keyof T]-?: undefined extends T[K] ? K : never;
1437
+ }[keyof T];
1438
+ declare type MakeOptionalFieldsNullable<T> = {
1439
+ [K in keyof T]: K extends OptionalKeys<T> ? T[K] | null : T[K];
1422
1440
  };
1441
+ declare type Patchable<T> = Partial<MakeOptionalFieldsNullable<T>>;
1423
1442
 
1424
1443
  declare type RoomThreadsNotificationSettings = "all" | "replies_and_mentions" | "none";
1425
1444
  declare type RoomNotificationSettings = {
@@ -1707,7 +1726,7 @@ declare type CommentsApi<M extends BaseMetadata> = {
1707
1726
  body: CommentBody;
1708
1727
  }): Promise<ThreadData<M>>;
1709
1728
  editThreadMetadata(options: {
1710
- metadata: PartialNullable<M>;
1729
+ metadata: Patchable<M>;
1711
1730
  threadId: string;
1712
1731
  }): Promise<M>;
1713
1732
  createComment(options: {
@@ -1929,6 +1948,9 @@ declare type PrivateRoomApi<M extends BaseMetadata> = {
1929
1948
  nodeCount: number;
1930
1949
  getSelf_forDevTools(): UserTreeNode | null;
1931
1950
  getOthers_forDevTools(): readonly UserTreeNode[];
1951
+ reportTextEditor(editor: "lexical", rootKey: string): void;
1952
+ createTextMention(userId: string, mentionId: string): Promise<Response>;
1953
+ deleteTextMention(mentionId: string): Promise<Response>;
1932
1954
  simulate: {
1933
1955
  explicitClose(event: IWebSocketCloseEvent): void;
1934
1956
  rawSend(data: string): void;
@@ -2002,6 +2024,12 @@ declare type Store<T> = {
2002
2024
  subscribe: (callback: (state: T) => void) => () => void;
2003
2025
  };
2004
2026
 
2027
+ /**
2028
+ * Back-port of TypeScript 5.4's built-in NoInfer utility type.
2029
+ * See https://stackoverflow.com/a/56688073/148872
2030
+ */
2031
+ declare type NoInfr<A> = [A][A extends any ? 0 : never];
2032
+
2005
2033
  declare type GetInboxNotificationsOptions = {
2006
2034
  limit?: number;
2007
2035
  since?: Date;
@@ -2011,13 +2039,14 @@ declare type OptimisticUpdate<M extends BaseMetadata> = CreateThreadOptimisticUp
2011
2039
  declare type CreateThreadOptimisticUpdate<M extends BaseMetadata> = {
2012
2040
  type: "create-thread";
2013
2041
  id: string;
2042
+ roomId: string;
2014
2043
  thread: ThreadData<M>;
2015
2044
  };
2016
2045
  declare type EditThreadMetadataOptimisticUpdate<M extends BaseMetadata> = {
2017
2046
  type: "edit-thread-metadata";
2018
2047
  id: string;
2019
2048
  threadId: string;
2020
- metadata: Resolve<PartialNullable<M>>;
2049
+ metadata: Resolve<Patchable<M>>;
2021
2050
  updatedAt: Date;
2022
2051
  };
2023
2052
  declare type CreateCommentOptimisticUpdate = {
@@ -2033,6 +2062,7 @@ declare type EditCommentOptimisticUpdate = {
2033
2062
  declare type DeleteCommentOptimisticUpdate = {
2034
2063
  type: "delete-comment";
2035
2064
  id: string;
2065
+ roomId: string;
2036
2066
  threadId: string;
2037
2067
  deletedAt: Date;
2038
2068
  commentId: string;
@@ -2107,6 +2137,7 @@ interface CacheStore<M extends BaseMetadata> extends Store<CacheState<M>> {
2107
2137
  updateRoomInboxNotificationSettings(roomId: string, settings: RoomNotificationSettings, queryKey: string): void;
2108
2138
  pushOptimisticUpdate(optimisticUpdate: OptimisticUpdate<M>): void;
2109
2139
  setQueryState(queryKey: string, queryState: QueryState): void;
2140
+ optimisticUpdatesEventSource: ReturnType<typeof makeEventSource<OptimisticUpdate<M>>>;
2110
2141
  }
2111
2142
  declare function applyOptimisticUpdates<M extends BaseMetadata>(state: CacheState<M>): Pick<CacheState<M>, "threads" | "inboxNotifications" | "notificationSettings">;
2112
2143
  declare function upsertComment<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, comment: CommentData): ThreadDataWithDeleteInfo<M>;
@@ -2199,7 +2230,7 @@ declare type Client<U extends BaseUserMeta = DU> = {
2199
2230
  * @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
2200
2231
  * @returns The room and a leave function. Call the returned leave() function when you no longer need the room.
2201
2232
  */
2202
- enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, M extends BaseMetadata = DM>(roomId: string, options: EnterOptions<P, S>): {
2233
+ enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, M extends BaseMetadata = DM>(roomId: string, options: EnterOptions<NoInfr<P>, NoInfr<S>>): {
2203
2234
  room: Room<P, S, U, E, M>;
2204
2235
  leave: () => void;
2205
2236
  };
@@ -2776,10 +2807,10 @@ declare namespace protocol {
2776
2807
  * information, see
2777
2808
  * https://liveblocks.io/docs/guides/limits#lson-constraint-and-interfaces
2778
2809
  */
2779
- declare type EnsureJson<T> = [
2810
+ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson<I>)[] : [
2780
2811
  unknown
2781
- ] extends [T] ? T : T extends (...args: unknown[]) => unknown ? T : {
2782
- [K in keyof T]: EnsureJson<T[K]>;
2812
+ ] extends [T] ? Json | undefined : T extends Date ? string : T extends (...args: any[]) => any ? never : {
2813
+ [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
2783
2814
  };
2784
2815
 
2785
- export { type AckOp, type ActivityData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, 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 DE, type DM, type DP, type DRI, type DS, type DU, 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 InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, 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 OpaqueClient, type OpaqueRoom, type OptionalPromise, type OthersEvent, type ParentToChildNodeMap, type PartialNullable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PrivateClientApi, type PrivateRoomApi, type QueryMetadata, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, 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 };
2816
+ export { type AckOp, type ActivityData, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, 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 DAD, type DE, type DM, type DP, type DRI, type DS, type DU, 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, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OthersEvent, type ParentToChildNodeMap, type Patchable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PrivateClientApi, type PrivateRoomApi, type QueryMetadata, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, 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 };
package/dist/index.d.ts CHANGED
@@ -575,7 +575,7 @@ declare type LiveListUpdates<TItem extends Lson> = {
575
575
  * The LiveList class represents an ordered collection of items that is synchronized across clients.
576
576
  */
577
577
  declare class LiveList<TItem extends Lson> extends AbstractCrdt {
578
- constructor(items?: TItem[]);
578
+ constructor(items: TItem[]);
579
579
  /**
580
580
  * Returns the number of elements.
581
581
  */
@@ -774,6 +774,60 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
774
774
  clone(): LiveObject<O>;
775
775
  }
776
776
 
777
+ declare type DateToString<T> = {
778
+ [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];
779
+ };
780
+
781
+ declare type InboxNotificationThreadData = {
782
+ kind: "thread";
783
+ id: string;
784
+ roomId: string;
785
+ threadId: string;
786
+ notifiedAt: Date;
787
+ readAt: Date | null;
788
+ };
789
+ declare type InboxNotificationTextMentionData = {
790
+ kind: "textMention";
791
+ id: string;
792
+ roomId: string;
793
+ notifiedAt: Date;
794
+ readAt: Date | null;
795
+ createdBy: string;
796
+ mentionId: string;
797
+ };
798
+ declare type InboxNotificationTextMentionDataPlain = DateToString<InboxNotificationTextMentionData>;
799
+ declare type ActivityData = Record<string, string | boolean | number | undefined>;
800
+ declare type InboxNotificationActivity<K extends `$${string}` = `$${string}`> = {
801
+ id: string;
802
+ createdAt: Date;
803
+ data: K extends keyof DAD ? DAD[K] : ActivityData;
804
+ };
805
+ declare type InboxNotificationCustomData<K extends `$${string}` = `$${string}`> = {
806
+ kind: `$${string}`;
807
+ id: string;
808
+ roomId?: string;
809
+ subjectId: string;
810
+ notifiedAt: Date;
811
+ readAt: Date | null;
812
+ activities: InboxNotificationActivity<K>[];
813
+ };
814
+ declare type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData;
815
+ declare type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
816
+ declare type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
817
+ activities: DateToString<InboxNotificationActivity>[];
818
+ };
819
+ declare type InboxNotificationDataPlain = InboxNotificationThreadDataPlain | InboxNotificationCustomDataPlain | InboxNotificationTextMentionDataPlain;
820
+ declare type InboxNotificationDeleteInfo = {
821
+ type: "deletedInboxNotification";
822
+ id: string;
823
+ roomId: string;
824
+ deletedAt: Date;
825
+ };
826
+
827
+ declare type BaseActivitiesData = {
828
+ [key: `$${string}`]: ActivityData;
829
+ };
830
+
777
831
  declare type BaseRoomInfo = {
778
832
  [key: string]: Json | undefined;
779
833
  /**
@@ -786,10 +840,6 @@ declare type BaseRoomInfo = {
786
840
  url?: string;
787
841
  };
788
842
 
789
- declare type DateToString<T> = {
790
- [P in keyof T]: T[P] extends Date ? string : T[P] extends Date | null ? string | null : T[P] extends Date | undefined ? string | undefined : T[P];
791
- };
792
-
793
843
  declare type BaseMetadata = Record<string, string | boolean | number | undefined>;
794
844
  declare type CommentReaction = {
795
845
  emoji: string;
@@ -883,7 +933,7 @@ declare type ThreadDeleteInfo = {
883
933
  roomId: string;
884
934
  deletedAt: Date;
885
935
  };
886
- declare type QueryMetadataStringValue<T extends string> = T | {
936
+ declare type StringOperators<T> = T | {
887
937
  startsWith: string;
888
938
  };
889
939
  /**
@@ -895,7 +945,7 @@ declare type QueryMetadataStringValue<T extends string> = T | {
895
945
  * - `startsWith` (`^` in query string)
896
946
  */
897
947
  declare type QueryMetadata<M extends BaseMetadata> = {
898
- [K in keyof M]: M[K] extends string ? QueryMetadataStringValue<M[K]> : M[K];
948
+ [K in keyof M]: string extends M[K] ? StringOperators<M[K]> : M[K];
899
949
  };
900
950
 
901
951
  declare global {
@@ -906,14 +956,15 @@ declare global {
906
956
  [key: string]: unknown;
907
957
  }
908
958
  }
909
- declare type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "RoomInfo";
910
- declare type ExtendedType<K extends ExtendableTypes, B> = unknown extends Liveblocks[K] ? B : Liveblocks[K] extends B ? Liveblocks[K] : `The type you provided for '${K}' does not match its requirements. To learn how to fix this, see https://liveblocks.io/errors/${K}`;
911
- declare type DP = ExtendedType<"Presence", JsonObject>;
912
- declare type DS = ExtendedType<"Storage", LsonObject>;
959
+ declare type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "RoomInfo" | "ActivitiesData";
960
+ declare type ExtendedType<K extends ExtendableTypes, B, ErrorReason extends string = "does not match its requirements"> = unknown extends Liveblocks[K] ? B : Liveblocks[K] extends B ? Liveblocks[K] : `The type you provided for '${K}' ${ErrorReason}. To learn how to fix this, see https://liveblocks.io/docs/errors/${K}`;
961
+ declare type DP = ExtendedType<"Presence", JsonObject, "is not a valid JSON object">;
962
+ declare type DS = ExtendedType<"Storage", LsonObject, "is not a valid LSON value">;
913
963
  declare type DU = ExtendedType<"UserMeta", BaseUserMeta>;
914
- declare type DE = ExtendedType<"RoomEvent", Json>;
964
+ declare type DE = ExtendedType<"RoomEvent", Json, "is not a valid JSON value">;
915
965
  declare type DM = ExtendedType<"ThreadMetadata", BaseMetadata>;
916
966
  declare type DRI = ExtendedType<"RoomInfo", BaseRoomInfo>;
967
+ declare type DAD = ExtendedType<"ActivitiesData", BaseActivitiesData>;
917
968
 
918
969
  /**
919
970
  * Use this symbol to brand an object property as internal.
@@ -1020,42 +1071,6 @@ declare type UpdateYDocClientMsg = {
1020
1071
  readonly guid?: string;
1021
1072
  };
1022
1073
 
1023
- declare type InboxNotificationThreadData = {
1024
- kind: "thread";
1025
- id: string;
1026
- roomId: string;
1027
- threadId: string;
1028
- notifiedAt: Date;
1029
- readAt: Date | null;
1030
- };
1031
- declare type ActivityData = Record<string, string | boolean | number | undefined>;
1032
- declare type InboxNotificationActivity = {
1033
- id: string;
1034
- createdAt: Date;
1035
- data: ActivityData;
1036
- };
1037
- declare type InboxNotificationCustomData = {
1038
- kind: `$${string}`;
1039
- id: string;
1040
- roomId?: string;
1041
- subjectId: string;
1042
- notifiedAt: Date;
1043
- readAt: Date | null;
1044
- activities: InboxNotificationActivity[];
1045
- };
1046
- declare type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData;
1047
- declare type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
1048
- declare type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
1049
- activities: DateToString<InboxNotificationActivity>[];
1050
- };
1051
- declare type InboxNotificationDataPlain = InboxNotificationThreadDataPlain | InboxNotificationCustomDataPlain;
1052
- declare type InboxNotificationDeleteInfo = {
1053
- type: "deletedInboxNotification";
1054
- id: string;
1055
- roomId: string;
1056
- deletedAt: Date;
1057
- };
1058
-
1059
1074
  declare type IdTuple<T> = [id: string, value: T];
1060
1075
  declare enum CrdtType {
1061
1076
  OBJECT = 0,
@@ -1417,9 +1432,13 @@ declare type OthersEvent<P extends JsonObject = DP, U extends BaseUserMeta = DU>
1417
1432
  others: readonly User<P, U>[];
1418
1433
  }>;
1419
1434
 
1420
- declare type PartialNullable<T> = {
1421
- [P in keyof T]?: T[P] | null;
1435
+ declare type OptionalKeys<T> = {
1436
+ [K in keyof T]-?: undefined extends T[K] ? K : never;
1437
+ }[keyof T];
1438
+ declare type MakeOptionalFieldsNullable<T> = {
1439
+ [K in keyof T]: K extends OptionalKeys<T> ? T[K] | null : T[K];
1422
1440
  };
1441
+ declare type Patchable<T> = Partial<MakeOptionalFieldsNullable<T>>;
1423
1442
 
1424
1443
  declare type RoomThreadsNotificationSettings = "all" | "replies_and_mentions" | "none";
1425
1444
  declare type RoomNotificationSettings = {
@@ -1707,7 +1726,7 @@ declare type CommentsApi<M extends BaseMetadata> = {
1707
1726
  body: CommentBody;
1708
1727
  }): Promise<ThreadData<M>>;
1709
1728
  editThreadMetadata(options: {
1710
- metadata: PartialNullable<M>;
1729
+ metadata: Patchable<M>;
1711
1730
  threadId: string;
1712
1731
  }): Promise<M>;
1713
1732
  createComment(options: {
@@ -1929,6 +1948,9 @@ declare type PrivateRoomApi<M extends BaseMetadata> = {
1929
1948
  nodeCount: number;
1930
1949
  getSelf_forDevTools(): UserTreeNode | null;
1931
1950
  getOthers_forDevTools(): readonly UserTreeNode[];
1951
+ reportTextEditor(editor: "lexical", rootKey: string): void;
1952
+ createTextMention(userId: string, mentionId: string): Promise<Response>;
1953
+ deleteTextMention(mentionId: string): Promise<Response>;
1932
1954
  simulate: {
1933
1955
  explicitClose(event: IWebSocketCloseEvent): void;
1934
1956
  rawSend(data: string): void;
@@ -2002,6 +2024,12 @@ declare type Store<T> = {
2002
2024
  subscribe: (callback: (state: T) => void) => () => void;
2003
2025
  };
2004
2026
 
2027
+ /**
2028
+ * Back-port of TypeScript 5.4's built-in NoInfer utility type.
2029
+ * See https://stackoverflow.com/a/56688073/148872
2030
+ */
2031
+ declare type NoInfr<A> = [A][A extends any ? 0 : never];
2032
+
2005
2033
  declare type GetInboxNotificationsOptions = {
2006
2034
  limit?: number;
2007
2035
  since?: Date;
@@ -2011,13 +2039,14 @@ declare type OptimisticUpdate<M extends BaseMetadata> = CreateThreadOptimisticUp
2011
2039
  declare type CreateThreadOptimisticUpdate<M extends BaseMetadata> = {
2012
2040
  type: "create-thread";
2013
2041
  id: string;
2042
+ roomId: string;
2014
2043
  thread: ThreadData<M>;
2015
2044
  };
2016
2045
  declare type EditThreadMetadataOptimisticUpdate<M extends BaseMetadata> = {
2017
2046
  type: "edit-thread-metadata";
2018
2047
  id: string;
2019
2048
  threadId: string;
2020
- metadata: Resolve<PartialNullable<M>>;
2049
+ metadata: Resolve<Patchable<M>>;
2021
2050
  updatedAt: Date;
2022
2051
  };
2023
2052
  declare type CreateCommentOptimisticUpdate = {
@@ -2033,6 +2062,7 @@ declare type EditCommentOptimisticUpdate = {
2033
2062
  declare type DeleteCommentOptimisticUpdate = {
2034
2063
  type: "delete-comment";
2035
2064
  id: string;
2065
+ roomId: string;
2036
2066
  threadId: string;
2037
2067
  deletedAt: Date;
2038
2068
  commentId: string;
@@ -2107,6 +2137,7 @@ interface CacheStore<M extends BaseMetadata> extends Store<CacheState<M>> {
2107
2137
  updateRoomInboxNotificationSettings(roomId: string, settings: RoomNotificationSettings, queryKey: string): void;
2108
2138
  pushOptimisticUpdate(optimisticUpdate: OptimisticUpdate<M>): void;
2109
2139
  setQueryState(queryKey: string, queryState: QueryState): void;
2140
+ optimisticUpdatesEventSource: ReturnType<typeof makeEventSource<OptimisticUpdate<M>>>;
2110
2141
  }
2111
2142
  declare function applyOptimisticUpdates<M extends BaseMetadata>(state: CacheState<M>): Pick<CacheState<M>, "threads" | "inboxNotifications" | "notificationSettings">;
2112
2143
  declare function upsertComment<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, comment: CommentData): ThreadDataWithDeleteInfo<M>;
@@ -2199,7 +2230,7 @@ declare type Client<U extends BaseUserMeta = DU> = {
2199
2230
  * @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
2200
2231
  * @returns The room and a leave function. Call the returned leave() function when you no longer need the room.
2201
2232
  */
2202
- enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, M extends BaseMetadata = DM>(roomId: string, options: EnterOptions<P, S>): {
2233
+ enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, M extends BaseMetadata = DM>(roomId: string, options: EnterOptions<NoInfr<P>, NoInfr<S>>): {
2203
2234
  room: Room<P, S, U, E, M>;
2204
2235
  leave: () => void;
2205
2236
  };
@@ -2776,10 +2807,10 @@ declare namespace protocol {
2776
2807
  * information, see
2777
2808
  * https://liveblocks.io/docs/guides/limits#lson-constraint-and-interfaces
2778
2809
  */
2779
- declare type EnsureJson<T> = [
2810
+ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson<I>)[] : [
2780
2811
  unknown
2781
- ] extends [T] ? T : T extends (...args: unknown[]) => unknown ? T : {
2782
- [K in keyof T]: EnsureJson<T[K]>;
2812
+ ] extends [T] ? Json | undefined : T extends Date ? string : T extends (...args: any[]) => any ? never : {
2813
+ [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
2783
2814
  };
2784
2815
 
2785
- export { type AckOp, type ActivityData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, 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 DE, type DM, type DP, type DRI, type DS, type DU, 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 InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, 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 OpaqueClient, type OpaqueRoom, type OptionalPromise, type OthersEvent, type ParentToChildNodeMap, type PartialNullable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PrivateClientApi, type PrivateRoomApi, type QueryMetadata, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, 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 };
2816
+ export { type AckOp, type ActivityData, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, 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 DAD, type DE, type DM, type DP, type DRI, type DS, type DU, 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, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OthersEvent, type ParentToChildNodeMap, type Patchable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PrivateClientApi, type PrivateRoomApi, type QueryMetadata, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, 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 };