@liveblocks/core 2.0.0 → 2.0.3-test1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -985,32 +985,6 @@ declare type DAD = ExtendedType<"ActivitiesData", BaseActivitiesData>;
985
985
  */
986
986
  declare const kInternal: unique symbol;
987
987
 
988
- /**
989
- * This helper type is effectively a no-op, but will force TypeScript to
990
- * "evaluate" any named helper types in its definition. This can sometimes make
991
- * API signatures clearer in IDEs.
992
- *
993
- * For example, in:
994
- *
995
- * type Payload<T> = { data: T };
996
- *
997
- * let r1: Payload<string>;
998
- * let r2: Resolve<Payload<string>>;
999
- *
1000
- * The inferred type of `r1` is going to be `Payload<string>` which shows up in
1001
- * editor hints, and it may be unclear what's inside if you don't know the
1002
- * definition of `Payload`.
1003
- *
1004
- * The inferred type of `r2` is going to be `{ data: string }`, which may be
1005
- * more helpful.
1006
- *
1007
- * This trick comes from:
1008
- * https://effectivetypescript.com/2022/02/25/gentips-4-display/
1009
- */
1010
- declare type Resolve<T> = T extends (...args: unknown[]) => unknown ? T : {
1011
- [K in keyof T]: T[K];
1012
- };
1013
-
1014
988
  declare enum ClientMsgCode {
1015
989
  UPDATE_PRESENCE = 100,
1016
990
  BROADCAST_EVENT = 103,
@@ -1122,6 +1096,7 @@ declare enum ServerMsgCode {
1122
1096
  REJECT_STORAGE_OP = 299,
1123
1097
  UPDATE_YDOC = 300,
1124
1098
  THREAD_CREATED = 400,
1099
+ THREAD_DELETED = 407,
1125
1100
  THREAD_METADATA_UPDATED = 401,
1126
1101
  COMMENT_CREATED = 402,
1127
1102
  COMMENT_EDITED = 403,
@@ -1133,11 +1108,15 @@ declare enum ServerMsgCode {
1133
1108
  * Messages that can be sent from the server to the client.
1134
1109
  */
1135
1110
  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;
1136
- declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1111
+ declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1137
1112
  declare type ThreadCreatedEvent = {
1138
1113
  type: ServerMsgCode.THREAD_CREATED;
1139
1114
  threadId: string;
1140
1115
  };
1116
+ declare type ThreadDeletedEvent = {
1117
+ type: ServerMsgCode.THREAD_DELETED;
1118
+ threadId: string;
1119
+ };
1141
1120
  declare type ThreadMetadataUpdatedEvent = {
1142
1121
  type: ServerMsgCode.THREAD_METADATA_UPDATED;
1143
1122
  threadId: string;
@@ -1382,6 +1361,32 @@ declare namespace DevToolsTreeNode {
1382
1361
  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 };
1383
1362
  }
1384
1363
 
1364
+ /**
1365
+ * This helper type is effectively a no-op, but will force TypeScript to
1366
+ * "evaluate" any named helper types in its definition. This can sometimes make
1367
+ * API signatures clearer in IDEs.
1368
+ *
1369
+ * For example, in:
1370
+ *
1371
+ * type Payload<T> = { data: T };
1372
+ *
1373
+ * let r1: Payload<string>;
1374
+ * let r2: Resolve<Payload<string>>;
1375
+ *
1376
+ * The inferred type of `r1` is going to be `Payload<string>` which shows up in
1377
+ * editor hints, and it may be unclear what's inside if you don't know the
1378
+ * definition of `Payload`.
1379
+ *
1380
+ * The inferred type of `r2` is going to be `{ data: string }`, which may be
1381
+ * more helpful.
1382
+ *
1383
+ * This trick comes from:
1384
+ * https://effectivetypescript.com/2022/02/25/gentips-4-display/
1385
+ */
1386
+ declare type Resolve<T> = T extends (...args: unknown[]) => unknown ? T : {
1387
+ [K in keyof T]: T[K];
1388
+ };
1389
+
1385
1390
  /**
1386
1391
  * Represents a user connected in a room. Treated as immutable.
1387
1392
  */
@@ -1971,25 +1976,28 @@ declare type Polyfills = {
1971
1976
  fetch?: typeof fetch;
1972
1977
  WebSocket?: IWebSocket;
1973
1978
  };
1974
- declare type RoomInitializers<P extends JsonObject, S extends LsonObject> = Resolve<{
1975
- /**
1976
- * The initial Presence to use and announce when you enter the Room. The
1977
- * Presence is available on all users in the Room (me & others).
1978
- */
1979
- initialPresence: P | ((roomId: string) => P);
1980
- /**
1981
- * The initial Storage to use when entering a new Room.
1982
- */
1983
- initialStorage?: S | ((roomId: string) => S);
1984
- /**
1985
- * Whether or not the room automatically connects to Liveblock servers.
1986
- * Default is true.
1987
- *
1988
- * Usually set to false when the client is used from the server to not call
1989
- * the authentication endpoint or connect via WebSocket.
1990
- */
1991
- autoConnect?: boolean;
1992
- }>;
1979
+ /**
1980
+ * Makes all tuple positions optional.
1981
+ * Example, turns:
1982
+ * [foo: string; bar: number]
1983
+ * into:
1984
+ * [foo?: string; bar?: number]
1985
+ */
1986
+ declare type OptionalTuple<T extends any[]> = {
1987
+ [K in keyof T]?: T[K];
1988
+ };
1989
+ /**
1990
+ * Returns Partial<T> if all fields on C are optional, T otherwise.
1991
+ */
1992
+ declare type PartialUnless<C, T> = Record<string, never> extends C ? Partial<T> : [
1993
+ C
1994
+ ] extends [never] ? Partial<T> : T;
1995
+ /**
1996
+ * Returns OptionalTupleUnless<T> if all fields on C are optional, T otherwise.
1997
+ */
1998
+ declare type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ? OptionalTuple<T> : [
1999
+ C
2000
+ ] extends [never] ? OptionalTuple<T> : T;
1993
2001
  declare class CommentsApiError extends Error {
1994
2002
  message: string;
1995
2003
  status: number;
@@ -2169,7 +2177,15 @@ declare type ResolveRoomsInfoArgs = {
2169
2177
  */
2170
2178
  roomIds: string[];
2171
2179
  };
2172
- declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS> = Resolve<RoomInitializers<P, S> & {
2180
+ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS> = Resolve<{
2181
+ /**
2182
+ * Whether or not the room automatically connects to Liveblock servers.
2183
+ * Default is true.
2184
+ *
2185
+ * Usually set to false when the client is used from the server to not call
2186
+ * the authentication endpoint or connect via WebSocket.
2187
+ */
2188
+ autoConnect?: boolean;
2173
2189
  /**
2174
2190
  * Only necessary when you’re using Liveblocks with React v17 or lower.
2175
2191
  *
@@ -2179,7 +2195,18 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
2179
2195
  * https://liveblocks.io/docs/guides/troubleshooting#stale-props-zombie-child
2180
2196
  */
2181
2197
  unstable_batchedUpdates?: (cb: () => void) => void;
2182
- }>;
2198
+ } & PartialUnless<P, {
2199
+ /**
2200
+ * The initial Presence to use and announce when you enter the Room. The
2201
+ * Presence is available on all users in the Room (me & others).
2202
+ */
2203
+ initialPresence: P | ((roomId: string) => P);
2204
+ }> & PartialUnless<S, {
2205
+ /**
2206
+ * The initial Storage to use when entering a new Room.
2207
+ */
2208
+ initialStorage: S | ((roomId: string) => S);
2209
+ }>>;
2183
2210
  /**
2184
2211
  * @private
2185
2212
  *
@@ -2230,7 +2257,9 @@ declare type Client<U extends BaseUserMeta = DU> = {
2230
2257
  * @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
2231
2258
  * @returns The room and a leave function. Call the returned leave() function when you no longer need the room.
2232
2259
  */
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>>): {
2260
+ enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, M extends BaseMetadata = DM>(roomId: string, ...args: OptionalTupleUnless<P & S, [
2261
+ options: EnterOptions<NoInfr<P>, NoInfr<S>>
2262
+ ]>): {
2234
2263
  room: Room<P, S, U, E, M>;
2235
2264
  leave: () => void;
2236
2265
  };
@@ -2813,4 +2842,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
2813
2842
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
2814
2843
  };
2815
2844
 
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 };
2845
+ 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 OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, 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 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
@@ -985,32 +985,6 @@ declare type DAD = ExtendedType<"ActivitiesData", BaseActivitiesData>;
985
985
  */
986
986
  declare const kInternal: unique symbol;
987
987
 
988
- /**
989
- * This helper type is effectively a no-op, but will force TypeScript to
990
- * "evaluate" any named helper types in its definition. This can sometimes make
991
- * API signatures clearer in IDEs.
992
- *
993
- * For example, in:
994
- *
995
- * type Payload<T> = { data: T };
996
- *
997
- * let r1: Payload<string>;
998
- * let r2: Resolve<Payload<string>>;
999
- *
1000
- * The inferred type of `r1` is going to be `Payload<string>` which shows up in
1001
- * editor hints, and it may be unclear what's inside if you don't know the
1002
- * definition of `Payload`.
1003
- *
1004
- * The inferred type of `r2` is going to be `{ data: string }`, which may be
1005
- * more helpful.
1006
- *
1007
- * This trick comes from:
1008
- * https://effectivetypescript.com/2022/02/25/gentips-4-display/
1009
- */
1010
- declare type Resolve<T> = T extends (...args: unknown[]) => unknown ? T : {
1011
- [K in keyof T]: T[K];
1012
- };
1013
-
1014
988
  declare enum ClientMsgCode {
1015
989
  UPDATE_PRESENCE = 100,
1016
990
  BROADCAST_EVENT = 103,
@@ -1122,6 +1096,7 @@ declare enum ServerMsgCode {
1122
1096
  REJECT_STORAGE_OP = 299,
1123
1097
  UPDATE_YDOC = 300,
1124
1098
  THREAD_CREATED = 400,
1099
+ THREAD_DELETED = 407,
1125
1100
  THREAD_METADATA_UPDATED = 401,
1126
1101
  COMMENT_CREATED = 402,
1127
1102
  COMMENT_EDITED = 403,
@@ -1133,11 +1108,15 @@ declare enum ServerMsgCode {
1133
1108
  * Messages that can be sent from the server to the client.
1134
1109
  */
1135
1110
  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;
1136
- declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1111
+ declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1137
1112
  declare type ThreadCreatedEvent = {
1138
1113
  type: ServerMsgCode.THREAD_CREATED;
1139
1114
  threadId: string;
1140
1115
  };
1116
+ declare type ThreadDeletedEvent = {
1117
+ type: ServerMsgCode.THREAD_DELETED;
1118
+ threadId: string;
1119
+ };
1141
1120
  declare type ThreadMetadataUpdatedEvent = {
1142
1121
  type: ServerMsgCode.THREAD_METADATA_UPDATED;
1143
1122
  threadId: string;
@@ -1382,6 +1361,32 @@ declare namespace DevToolsTreeNode {
1382
1361
  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 };
1383
1362
  }
1384
1363
 
1364
+ /**
1365
+ * This helper type is effectively a no-op, but will force TypeScript to
1366
+ * "evaluate" any named helper types in its definition. This can sometimes make
1367
+ * API signatures clearer in IDEs.
1368
+ *
1369
+ * For example, in:
1370
+ *
1371
+ * type Payload<T> = { data: T };
1372
+ *
1373
+ * let r1: Payload<string>;
1374
+ * let r2: Resolve<Payload<string>>;
1375
+ *
1376
+ * The inferred type of `r1` is going to be `Payload<string>` which shows up in
1377
+ * editor hints, and it may be unclear what's inside if you don't know the
1378
+ * definition of `Payload`.
1379
+ *
1380
+ * The inferred type of `r2` is going to be `{ data: string }`, which may be
1381
+ * more helpful.
1382
+ *
1383
+ * This trick comes from:
1384
+ * https://effectivetypescript.com/2022/02/25/gentips-4-display/
1385
+ */
1386
+ declare type Resolve<T> = T extends (...args: unknown[]) => unknown ? T : {
1387
+ [K in keyof T]: T[K];
1388
+ };
1389
+
1385
1390
  /**
1386
1391
  * Represents a user connected in a room. Treated as immutable.
1387
1392
  */
@@ -1971,25 +1976,28 @@ declare type Polyfills = {
1971
1976
  fetch?: typeof fetch;
1972
1977
  WebSocket?: IWebSocket;
1973
1978
  };
1974
- declare type RoomInitializers<P extends JsonObject, S extends LsonObject> = Resolve<{
1975
- /**
1976
- * The initial Presence to use and announce when you enter the Room. The
1977
- * Presence is available on all users in the Room (me & others).
1978
- */
1979
- initialPresence: P | ((roomId: string) => P);
1980
- /**
1981
- * The initial Storage to use when entering a new Room.
1982
- */
1983
- initialStorage?: S | ((roomId: string) => S);
1984
- /**
1985
- * Whether or not the room automatically connects to Liveblock servers.
1986
- * Default is true.
1987
- *
1988
- * Usually set to false when the client is used from the server to not call
1989
- * the authentication endpoint or connect via WebSocket.
1990
- */
1991
- autoConnect?: boolean;
1992
- }>;
1979
+ /**
1980
+ * Makes all tuple positions optional.
1981
+ * Example, turns:
1982
+ * [foo: string; bar: number]
1983
+ * into:
1984
+ * [foo?: string; bar?: number]
1985
+ */
1986
+ declare type OptionalTuple<T extends any[]> = {
1987
+ [K in keyof T]?: T[K];
1988
+ };
1989
+ /**
1990
+ * Returns Partial<T> if all fields on C are optional, T otherwise.
1991
+ */
1992
+ declare type PartialUnless<C, T> = Record<string, never> extends C ? Partial<T> : [
1993
+ C
1994
+ ] extends [never] ? Partial<T> : T;
1995
+ /**
1996
+ * Returns OptionalTupleUnless<T> if all fields on C are optional, T otherwise.
1997
+ */
1998
+ declare type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ? OptionalTuple<T> : [
1999
+ C
2000
+ ] extends [never] ? OptionalTuple<T> : T;
1993
2001
  declare class CommentsApiError extends Error {
1994
2002
  message: string;
1995
2003
  status: number;
@@ -2169,7 +2177,15 @@ declare type ResolveRoomsInfoArgs = {
2169
2177
  */
2170
2178
  roomIds: string[];
2171
2179
  };
2172
- declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS> = Resolve<RoomInitializers<P, S> & {
2180
+ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS> = Resolve<{
2181
+ /**
2182
+ * Whether or not the room automatically connects to Liveblock servers.
2183
+ * Default is true.
2184
+ *
2185
+ * Usually set to false when the client is used from the server to not call
2186
+ * the authentication endpoint or connect via WebSocket.
2187
+ */
2188
+ autoConnect?: boolean;
2173
2189
  /**
2174
2190
  * Only necessary when you’re using Liveblocks with React v17 or lower.
2175
2191
  *
@@ -2179,7 +2195,18 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
2179
2195
  * https://liveblocks.io/docs/guides/troubleshooting#stale-props-zombie-child
2180
2196
  */
2181
2197
  unstable_batchedUpdates?: (cb: () => void) => void;
2182
- }>;
2198
+ } & PartialUnless<P, {
2199
+ /**
2200
+ * The initial Presence to use and announce when you enter the Room. The
2201
+ * Presence is available on all users in the Room (me & others).
2202
+ */
2203
+ initialPresence: P | ((roomId: string) => P);
2204
+ }> & PartialUnless<S, {
2205
+ /**
2206
+ * The initial Storage to use when entering a new Room.
2207
+ */
2208
+ initialStorage: S | ((roomId: string) => S);
2209
+ }>>;
2183
2210
  /**
2184
2211
  * @private
2185
2212
  *
@@ -2230,7 +2257,9 @@ declare type Client<U extends BaseUserMeta = DU> = {
2230
2257
  * @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
2231
2258
  * @returns The room and a leave function. Call the returned leave() function when you no longer need the room.
2232
2259
  */
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>>): {
2260
+ enterRoom<P extends JsonObject = DP, S extends LsonObject = DS, E extends Json = DE, M extends BaseMetadata = DM>(roomId: string, ...args: OptionalTupleUnless<P & S, [
2261
+ options: EnterOptions<NoInfr<P>, NoInfr<S>>
2262
+ ]>): {
2234
2263
  room: Room<P, S, U, E, M>;
2235
2264
  leave: () => void;
2236
2265
  };
@@ -2813,4 +2842,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
2813
2842
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
2814
2843
  };
2815
2844
 
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 };
2845
+ 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 OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, 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 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.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "2.0.0";
9
+ var PKG_VERSION = "2.0.3-test1";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -647,6 +647,7 @@ var ServerMsgCode = /* @__PURE__ */ ((ServerMsgCode2) => {
647
647
  ServerMsgCode2[ServerMsgCode2["REJECT_STORAGE_OP"] = 299] = "REJECT_STORAGE_OP";
648
648
  ServerMsgCode2[ServerMsgCode2["UPDATE_YDOC"] = 300] = "UPDATE_YDOC";
649
649
  ServerMsgCode2[ServerMsgCode2["THREAD_CREATED"] = 400] = "THREAD_CREATED";
650
+ ServerMsgCode2[ServerMsgCode2["THREAD_DELETED"] = 407] = "THREAD_DELETED";
650
651
  ServerMsgCode2[ServerMsgCode2["THREAD_METADATA_UPDATED"] = 401] = "THREAD_METADATA_UPDATED";
651
652
  ServerMsgCode2[ServerMsgCode2["COMMENT_CREATED"] = 402] = "COMMENT_CREATED";
652
653
  ServerMsgCode2[ServerMsgCode2["COMMENT_EDITED"] = 403] = "COMMENT_EDITED";
@@ -1916,39 +1917,6 @@ function createStore(initialState) {
1916
1917
  };
1917
1918
  }
1918
1919
 
1919
- // src/lib/deprecation.ts
1920
- var _emittedDeprecationWarnings = /* @__PURE__ */ new Set();
1921
- function deprecate(message, key = message) {
1922
- if (process.env.NODE_ENV !== "production") {
1923
- if (!_emittedDeprecationWarnings.has(key)) {
1924
- _emittedDeprecationWarnings.add(key);
1925
- errorWithTitle("Deprecation warning", message);
1926
- }
1927
- }
1928
- }
1929
- function deprecateIf(condition, message, key = message) {
1930
- if (process.env.NODE_ENV !== "production") {
1931
- if (condition) {
1932
- deprecate(message, key);
1933
- }
1934
- }
1935
- }
1936
- function throwUsageError(message) {
1937
- if (process.env.NODE_ENV !== "production") {
1938
- const usageError = new Error(message);
1939
- usageError.name = "Usage error";
1940
- errorWithTitle("Usage error", message);
1941
- throw usageError;
1942
- }
1943
- }
1944
- function errorIf(condition, message) {
1945
- if (process.env.NODE_ENV !== "production") {
1946
- if (condition) {
1947
- throwUsageError(message);
1948
- }
1949
- }
1950
- }
1951
-
1952
1920
  // src/convert-plain-data.ts
1953
1921
  function convertToCommentData(data) {
1954
1922
  const editedAt = data.editedAt ? new Date(data.editedAt) : void 0;
@@ -5360,8 +5328,8 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5360
5328
  }
5361
5329
  var MARK_INBOX_NOTIFICATIONS_AS_READ_BATCH_DELAY2 = 50;
5362
5330
  function createRoom(options, config) {
5363
- const initialPresence = typeof options.initialPresence === "function" ? options.initialPresence(config.roomId) : options.initialPresence;
5364
- const initialStorage = typeof options.initialStorage === "function" ? options.initialStorage(config.roomId) : options.initialStorage;
5331
+ const initialPresence = options.initialPresence;
5332
+ const initialStorage = options.initialStorage;
5365
5333
  const [inBackgroundSince, uninstallBgTabSpy] = installBackgroundTabSpy();
5366
5334
  const delegates = {
5367
5335
  ...config.delegates,
@@ -6146,6 +6114,7 @@ ${Array.from(traces).join("\n\n")}`
6146
6114
  break;
6147
6115
  }
6148
6116
  case 400 /* THREAD_CREATED */:
6117
+ case 407 /* THREAD_DELETED */:
6149
6118
  case 401 /* THREAD_METADATA_UPDATED */:
6150
6119
  case 405 /* COMMENT_REACTION_ADDED */:
6151
6120
  case 406 /* COMMENT_REACTION_REMOVED */:
@@ -7257,15 +7226,10 @@ function createClient(options) {
7257
7226
  if (existing !== void 0) {
7258
7227
  return leaseRoom(existing);
7259
7228
  }
7260
- deprecateIf(
7261
- options2.initialPresence === null || options2.initialPresence === void 0,
7262
- "Please provide an initial presence value for the current user when entering the room."
7263
- );
7229
+ const initialPresence = _nullishCoalesce((typeof options2.initialPresence === "function" ? options2.initialPresence(roomId) : options2.initialPresence), () => ( {}));
7230
+ const initialStorage = _nullishCoalesce((typeof options2.initialStorage === "function" ? options2.initialStorage(roomId) : options2.initialStorage), () => ( {}));
7264
7231
  const newRoom = createRoom(
7265
- {
7266
- initialPresence: _nullishCoalesce(options2.initialPresence, () => ( {})),
7267
- initialStorage: options2.initialStorage
7268
- },
7232
+ { initialPresence, initialStorage },
7269
7233
  {
7270
7234
  roomId,
7271
7235
  throttleDelay,
@@ -8082,6 +8046,39 @@ function legacy_patchImmutableNode(state, path, update) {
8082
8046
  }
8083
8047
  }
8084
8048
 
8049
+ // src/lib/deprecation.ts
8050
+ var _emittedDeprecationWarnings = /* @__PURE__ */ new Set();
8051
+ function deprecate(message, key = message) {
8052
+ if (process.env.NODE_ENV !== "production") {
8053
+ if (!_emittedDeprecationWarnings.has(key)) {
8054
+ _emittedDeprecationWarnings.add(key);
8055
+ errorWithTitle("Deprecation warning", message);
8056
+ }
8057
+ }
8058
+ }
8059
+ function deprecateIf(condition, message, key = message) {
8060
+ if (process.env.NODE_ENV !== "production") {
8061
+ if (condition) {
8062
+ deprecate(message, key);
8063
+ }
8064
+ }
8065
+ }
8066
+ function throwUsageError(message) {
8067
+ if (process.env.NODE_ENV !== "production") {
8068
+ const usageError = new Error(message);
8069
+ usageError.name = "Usage error";
8070
+ errorWithTitle("Usage error", message);
8071
+ throw usageError;
8072
+ }
8073
+ }
8074
+ function errorIf(condition, message) {
8075
+ if (process.env.NODE_ENV !== "production") {
8076
+ if (condition) {
8077
+ throwUsageError(message);
8078
+ }
8079
+ }
8080
+ }
8081
+
8085
8082
  // src/lib/Poller.ts
8086
8083
  function makePoller(callback) {
8087
8084
  let context = {