@liveblocks/core 2.0.2 → 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,
@@ -1387,6 +1361,32 @@ declare namespace DevToolsTreeNode {
1387
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 };
1388
1362
  }
1389
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
+
1390
1390
  /**
1391
1391
  * Represents a user connected in a room. Treated as immutable.
1392
1392
  */
@@ -1976,25 +1976,28 @@ declare type Polyfills = {
1976
1976
  fetch?: typeof fetch;
1977
1977
  WebSocket?: IWebSocket;
1978
1978
  };
1979
- declare type RoomInitializers<P extends JsonObject, S extends LsonObject> = Resolve<{
1980
- /**
1981
- * The initial Presence to use and announce when you enter the Room. The
1982
- * Presence is available on all users in the Room (me & others).
1983
- */
1984
- initialPresence: P | ((roomId: string) => P);
1985
- /**
1986
- * The initial Storage to use when entering a new Room.
1987
- */
1988
- initialStorage?: S | ((roomId: string) => S);
1989
- /**
1990
- * Whether or not the room automatically connects to Liveblock servers.
1991
- * Default is true.
1992
- *
1993
- * Usually set to false when the client is used from the server to not call
1994
- * the authentication endpoint or connect via WebSocket.
1995
- */
1996
- autoConnect?: boolean;
1997
- }>;
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;
1998
2001
  declare class CommentsApiError extends Error {
1999
2002
  message: string;
2000
2003
  status: number;
@@ -2174,7 +2177,15 @@ declare type ResolveRoomsInfoArgs = {
2174
2177
  */
2175
2178
  roomIds: string[];
2176
2179
  };
2177
- 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;
2178
2189
  /**
2179
2190
  * Only necessary when you’re using Liveblocks with React v17 or lower.
2180
2191
  *
@@ -2184,7 +2195,18 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
2184
2195
  * https://liveblocks.io/docs/guides/troubleshooting#stale-props-zombie-child
2185
2196
  */
2186
2197
  unstable_batchedUpdates?: (cb: () => void) => void;
2187
- }>;
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
+ }>>;
2188
2210
  /**
2189
2211
  * @private
2190
2212
  *
@@ -2235,7 +2257,9 @@ declare type Client<U extends BaseUserMeta = DU> = {
2235
2257
  * @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
2236
2258
  * @returns The room and a leave function. Call the returned leave() function when you no longer need the room.
2237
2259
  */
2238
- 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
+ ]>): {
2239
2263
  room: Room<P, S, U, E, M>;
2240
2264
  leave: () => void;
2241
2265
  };
@@ -2818,4 +2842,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
2818
2842
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
2819
2843
  };
2820
2844
 
2821
- 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,
@@ -1387,6 +1361,32 @@ declare namespace DevToolsTreeNode {
1387
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 };
1388
1362
  }
1389
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
+
1390
1390
  /**
1391
1391
  * Represents a user connected in a room. Treated as immutable.
1392
1392
  */
@@ -1976,25 +1976,28 @@ declare type Polyfills = {
1976
1976
  fetch?: typeof fetch;
1977
1977
  WebSocket?: IWebSocket;
1978
1978
  };
1979
- declare type RoomInitializers<P extends JsonObject, S extends LsonObject> = Resolve<{
1980
- /**
1981
- * The initial Presence to use and announce when you enter the Room. The
1982
- * Presence is available on all users in the Room (me & others).
1983
- */
1984
- initialPresence: P | ((roomId: string) => P);
1985
- /**
1986
- * The initial Storage to use when entering a new Room.
1987
- */
1988
- initialStorage?: S | ((roomId: string) => S);
1989
- /**
1990
- * Whether or not the room automatically connects to Liveblock servers.
1991
- * Default is true.
1992
- *
1993
- * Usually set to false when the client is used from the server to not call
1994
- * the authentication endpoint or connect via WebSocket.
1995
- */
1996
- autoConnect?: boolean;
1997
- }>;
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;
1998
2001
  declare class CommentsApiError extends Error {
1999
2002
  message: string;
2000
2003
  status: number;
@@ -2174,7 +2177,15 @@ declare type ResolveRoomsInfoArgs = {
2174
2177
  */
2175
2178
  roomIds: string[];
2176
2179
  };
2177
- 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;
2178
2189
  /**
2179
2190
  * Only necessary when you’re using Liveblocks with React v17 or lower.
2180
2191
  *
@@ -2184,7 +2195,18 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
2184
2195
  * https://liveblocks.io/docs/guides/troubleshooting#stale-props-zombie-child
2185
2196
  */
2186
2197
  unstable_batchedUpdates?: (cb: () => void) => void;
2187
- }>;
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
+ }>>;
2188
2210
  /**
2189
2211
  * @private
2190
2212
  *
@@ -2235,7 +2257,9 @@ declare type Client<U extends BaseUserMeta = DU> = {
2235
2257
  * @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
2236
2258
  * @returns The room and a leave function. Call the returned leave() function when you no longer need the room.
2237
2259
  */
2238
- 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
+ ]>): {
2239
2263
  room: Room<P, S, U, E, M>;
2240
2264
  leave: () => void;
2241
2265
  };
@@ -2818,4 +2842,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
2818
2842
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
2819
2843
  };
2820
2844
 
2821
- 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.2";
9
+ var PKG_VERSION = "2.0.3-test1";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -1917,39 +1917,6 @@ function createStore(initialState) {
1917
1917
  };
1918
1918
  }
1919
1919
 
1920
- // src/lib/deprecation.ts
1921
- var _emittedDeprecationWarnings = /* @__PURE__ */ new Set();
1922
- function deprecate(message, key = message) {
1923
- if (process.env.NODE_ENV !== "production") {
1924
- if (!_emittedDeprecationWarnings.has(key)) {
1925
- _emittedDeprecationWarnings.add(key);
1926
- errorWithTitle("Deprecation warning", message);
1927
- }
1928
- }
1929
- }
1930
- function deprecateIf(condition, message, key = message) {
1931
- if (process.env.NODE_ENV !== "production") {
1932
- if (condition) {
1933
- deprecate(message, key);
1934
- }
1935
- }
1936
- }
1937
- function throwUsageError(message) {
1938
- if (process.env.NODE_ENV !== "production") {
1939
- const usageError = new Error(message);
1940
- usageError.name = "Usage error";
1941
- errorWithTitle("Usage error", message);
1942
- throw usageError;
1943
- }
1944
- }
1945
- function errorIf(condition, message) {
1946
- if (process.env.NODE_ENV !== "production") {
1947
- if (condition) {
1948
- throwUsageError(message);
1949
- }
1950
- }
1951
- }
1952
-
1953
1920
  // src/convert-plain-data.ts
1954
1921
  function convertToCommentData(data) {
1955
1922
  const editedAt = data.editedAt ? new Date(data.editedAt) : void 0;
@@ -5361,8 +5328,8 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5361
5328
  }
5362
5329
  var MARK_INBOX_NOTIFICATIONS_AS_READ_BATCH_DELAY2 = 50;
5363
5330
  function createRoom(options, config) {
5364
- const initialPresence = typeof options.initialPresence === "function" ? options.initialPresence(config.roomId) : options.initialPresence;
5365
- const initialStorage = typeof options.initialStorage === "function" ? options.initialStorage(config.roomId) : options.initialStorage;
5331
+ const initialPresence = options.initialPresence;
5332
+ const initialStorage = options.initialStorage;
5366
5333
  const [inBackgroundSince, uninstallBgTabSpy] = installBackgroundTabSpy();
5367
5334
  const delegates = {
5368
5335
  ...config.delegates,
@@ -7259,15 +7226,10 @@ function createClient(options) {
7259
7226
  if (existing !== void 0) {
7260
7227
  return leaseRoom(existing);
7261
7228
  }
7262
- deprecateIf(
7263
- options2.initialPresence === null || options2.initialPresence === void 0,
7264
- "Please provide an initial presence value for the current user when entering the room."
7265
- );
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), () => ( {}));
7266
7231
  const newRoom = createRoom(
7267
- {
7268
- initialPresence: _nullishCoalesce(options2.initialPresence, () => ( {})),
7269
- initialStorage: options2.initialStorage
7270
- },
7232
+ { initialPresence, initialStorage },
7271
7233
  {
7272
7234
  roomId,
7273
7235
  throttleDelay,
@@ -8084,6 +8046,39 @@ function legacy_patchImmutableNode(state, path, update) {
8084
8046
  }
8085
8047
  }
8086
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
+
8087
8082
  // src/lib/Poller.ts
8088
8083
  function makePoller(callback) {
8089
8084
  let context = {