@liveblocks/core 2.1.1-test1 → 2.2.0

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
@@ -893,6 +893,7 @@ declare type CommentBodyMention = {
893
893
  declare type CommentBodyLink = {
894
894
  type: "link";
895
895
  url: string;
896
+ text?: string;
896
897
  };
897
898
  declare type CommentBodyText = {
898
899
  bold?: boolean;
@@ -922,6 +923,7 @@ declare type ThreadData<M extends BaseMetadata = DM> = {
922
923
  updatedAt?: Date;
923
924
  comments: CommentData[];
924
925
  metadata: M;
926
+ resolved: boolean;
925
927
  };
926
928
  interface ThreadDataWithDeleteInfo<M extends BaseMetadata = DM> extends ThreadData<M> {
927
929
  deletedAt?: Date;
@@ -1106,6 +1108,7 @@ declare enum ServerMsgCode {
1106
1108
  THREAD_CREATED = 400,
1107
1109
  THREAD_DELETED = 407,
1108
1110
  THREAD_METADATA_UPDATED = 401,
1111
+ THREAD_UPDATED = 408,
1109
1112
  COMMENT_CREATED = 402,
1110
1113
  COMMENT_EDITED = 403,
1111
1114
  COMMENT_DELETED = 404,
@@ -1116,7 +1119,7 @@ declare enum ServerMsgCode {
1116
1119
  * Messages that can be sent from the server to the client.
1117
1120
  */
1118
1121
  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;
1119
- declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1122
+ declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1120
1123
  declare type ThreadCreatedEvent = {
1121
1124
  type: ServerMsgCode.THREAD_CREATED;
1122
1125
  threadId: string;
@@ -1129,6 +1132,10 @@ declare type ThreadMetadataUpdatedEvent = {
1129
1132
  type: ServerMsgCode.THREAD_METADATA_UPDATED;
1130
1133
  threadId: string;
1131
1134
  };
1135
+ declare type ThreadUpdatedEvent = {
1136
+ type: ServerMsgCode.THREAD_UPDATED;
1137
+ threadId: string;
1138
+ };
1132
1139
  declare type CommentCreatedEvent = {
1133
1140
  type: ServerMsgCode.COMMENT_CREATED;
1134
1141
  threadId: string;
@@ -1712,6 +1719,7 @@ declare type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U e
1712
1719
  };
1713
1720
  declare type GetThreadsOptions<M extends BaseMetadata> = {
1714
1721
  query?: {
1722
+ resolved?: boolean;
1715
1723
  metadata?: Partial<QueryMetadata<M>>;
1716
1724
  };
1717
1725
  since?: Date;
@@ -1745,6 +1753,12 @@ declare type CommentsApi<M extends BaseMetadata> = {
1745
1753
  metadata: Patchable<M>;
1746
1754
  threadId: string;
1747
1755
  }): Promise<M>;
1756
+ markThreadAsResolved(options: {
1757
+ threadId: string;
1758
+ }): Promise<void>;
1759
+ markThreadAsUnresolved(options: {
1760
+ threadId: string;
1761
+ }): Promise<void>;
1748
1762
  createComment(options: {
1749
1763
  threadId: string;
1750
1764
  commentId: string;
@@ -2083,7 +2097,7 @@ declare type GetInboxNotificationsOptions = {
2083
2097
  since?: Date;
2084
2098
  };
2085
2099
 
2086
- declare type OptimisticUpdate<M extends BaseMetadata> = CreateThreadOptimisticUpdate<M> | DeleteThreadOptimisticUpdate | EditThreadMetadataOptimisticUpdate<M> | CreateCommentOptimisticUpdate | EditCommentOptimisticUpdate | DeleteCommentOptimisticUpdate | AddReactionOptimisticUpdate | RemoveReactionOptimisticUpdate | MarkInboxNotificationAsReadOptimisticUpdate | MarkAllInboxNotificationsAsReadOptimisticUpdate | UpdateNotificationSettingsOptimisticUpdate;
2100
+ declare type OptimisticUpdate<M extends BaseMetadata> = CreateThreadOptimisticUpdate<M> | DeleteThreadOptimisticUpdate | EditThreadMetadataOptimisticUpdate<M> | MarkThreadAsResolvedOptimisticUpdate | MarkThreadAsUnresolvedOptimisticUpdate | CreateCommentOptimisticUpdate | EditCommentOptimisticUpdate | DeleteCommentOptimisticUpdate | AddReactionOptimisticUpdate | RemoveReactionOptimisticUpdate | MarkInboxNotificationAsReadOptimisticUpdate | MarkAllInboxNotificationsAsReadOptimisticUpdate | UpdateNotificationSettingsOptimisticUpdate;
2087
2101
  declare type CreateThreadOptimisticUpdate<M extends BaseMetadata> = {
2088
2102
  type: "create-thread";
2089
2103
  id: string;
@@ -2104,6 +2118,18 @@ declare type EditThreadMetadataOptimisticUpdate<M extends BaseMetadata> = {
2104
2118
  metadata: Resolve<Patchable<M>>;
2105
2119
  updatedAt: Date;
2106
2120
  };
2121
+ declare type MarkThreadAsResolvedOptimisticUpdate = {
2122
+ type: "mark-thread-as-resolved";
2123
+ id: string;
2124
+ threadId: string;
2125
+ updatedAt: Date;
2126
+ };
2127
+ declare type MarkThreadAsUnresolvedOptimisticUpdate = {
2128
+ type: "mark-thread-as-unresolved";
2129
+ id: string;
2130
+ threadId: string;
2131
+ updatedAt: Date;
2132
+ };
2107
2133
  declare type CreateCommentOptimisticUpdate = {
2108
2134
  type: "create-comment";
2109
2135
  id: string;
@@ -2671,12 +2697,22 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
2671
2697
  * Decode base64 string.
2672
2698
  */
2673
2699
  declare function b64decode(b64value: string): string;
2700
+ /**
2701
+ * Returns a promise that resolves after the given number of milliseconds.
2702
+ */
2703
+ declare function wait(millis: number): Promise<void>;
2674
2704
  /**
2675
2705
  * Returns whatever the given promise returns, but will be rejected with
2676
2706
  * a "Timed out" error if the given promise does not return or reject within
2677
2707
  * the given timeout period (in milliseconds).
2678
2708
  */
2679
2709
  declare function withTimeout<T>(promise: Promise<T>, millis: number, errmsg: string): Promise<T>;
2710
+ /**
2711
+ * Memoize a promise factory, so that each subsequent call will return the same
2712
+ * pending or success promise, but if the promise rejects, the next call to the
2713
+ * function will start a new promise.
2714
+ */
2715
+ declare function memoizeOnSuccess<T>(factoryFn: () => Promise<T>): () => Promise<T>;
2680
2716
 
2681
2717
  /**
2682
2718
  * Positions, aka the Pos type, are efficient encodings of "positions" in
@@ -2889,4 +2925,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
2889
2925
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
2890
2926
  };
2891
2927
 
2892
- 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, type KDAD, 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 };
2928
+ 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, type KDAD, 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, memoizeOnSuccess, nn, objectToQuery, patchLiveObjectKey, raise, removeReaction, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, upsertComment, wait, withTimeout };
package/dist/index.d.ts CHANGED
@@ -893,6 +893,7 @@ declare type CommentBodyMention = {
893
893
  declare type CommentBodyLink = {
894
894
  type: "link";
895
895
  url: string;
896
+ text?: string;
896
897
  };
897
898
  declare type CommentBodyText = {
898
899
  bold?: boolean;
@@ -922,6 +923,7 @@ declare type ThreadData<M extends BaseMetadata = DM> = {
922
923
  updatedAt?: Date;
923
924
  comments: CommentData[];
924
925
  metadata: M;
926
+ resolved: boolean;
925
927
  };
926
928
  interface ThreadDataWithDeleteInfo<M extends BaseMetadata = DM> extends ThreadData<M> {
927
929
  deletedAt?: Date;
@@ -1106,6 +1108,7 @@ declare enum ServerMsgCode {
1106
1108
  THREAD_CREATED = 400,
1107
1109
  THREAD_DELETED = 407,
1108
1110
  THREAD_METADATA_UPDATED = 401,
1111
+ THREAD_UPDATED = 408,
1109
1112
  COMMENT_CREATED = 402,
1110
1113
  COMMENT_EDITED = 403,
1111
1114
  COMMENT_DELETED = 404,
@@ -1116,7 +1119,7 @@ declare enum ServerMsgCode {
1116
1119
  * Messages that can be sent from the server to the client.
1117
1120
  */
1118
1121
  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;
1119
- declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1122
+ declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
1120
1123
  declare type ThreadCreatedEvent = {
1121
1124
  type: ServerMsgCode.THREAD_CREATED;
1122
1125
  threadId: string;
@@ -1129,6 +1132,10 @@ declare type ThreadMetadataUpdatedEvent = {
1129
1132
  type: ServerMsgCode.THREAD_METADATA_UPDATED;
1130
1133
  threadId: string;
1131
1134
  };
1135
+ declare type ThreadUpdatedEvent = {
1136
+ type: ServerMsgCode.THREAD_UPDATED;
1137
+ threadId: string;
1138
+ };
1132
1139
  declare type CommentCreatedEvent = {
1133
1140
  type: ServerMsgCode.COMMENT_CREATED;
1134
1141
  threadId: string;
@@ -1712,6 +1719,7 @@ declare type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U e
1712
1719
  };
1713
1720
  declare type GetThreadsOptions<M extends BaseMetadata> = {
1714
1721
  query?: {
1722
+ resolved?: boolean;
1715
1723
  metadata?: Partial<QueryMetadata<M>>;
1716
1724
  };
1717
1725
  since?: Date;
@@ -1745,6 +1753,12 @@ declare type CommentsApi<M extends BaseMetadata> = {
1745
1753
  metadata: Patchable<M>;
1746
1754
  threadId: string;
1747
1755
  }): Promise<M>;
1756
+ markThreadAsResolved(options: {
1757
+ threadId: string;
1758
+ }): Promise<void>;
1759
+ markThreadAsUnresolved(options: {
1760
+ threadId: string;
1761
+ }): Promise<void>;
1748
1762
  createComment(options: {
1749
1763
  threadId: string;
1750
1764
  commentId: string;
@@ -2083,7 +2097,7 @@ declare type GetInboxNotificationsOptions = {
2083
2097
  since?: Date;
2084
2098
  };
2085
2099
 
2086
- declare type OptimisticUpdate<M extends BaseMetadata> = CreateThreadOptimisticUpdate<M> | DeleteThreadOptimisticUpdate | EditThreadMetadataOptimisticUpdate<M> | CreateCommentOptimisticUpdate | EditCommentOptimisticUpdate | DeleteCommentOptimisticUpdate | AddReactionOptimisticUpdate | RemoveReactionOptimisticUpdate | MarkInboxNotificationAsReadOptimisticUpdate | MarkAllInboxNotificationsAsReadOptimisticUpdate | UpdateNotificationSettingsOptimisticUpdate;
2100
+ declare type OptimisticUpdate<M extends BaseMetadata> = CreateThreadOptimisticUpdate<M> | DeleteThreadOptimisticUpdate | EditThreadMetadataOptimisticUpdate<M> | MarkThreadAsResolvedOptimisticUpdate | MarkThreadAsUnresolvedOptimisticUpdate | CreateCommentOptimisticUpdate | EditCommentOptimisticUpdate | DeleteCommentOptimisticUpdate | AddReactionOptimisticUpdate | RemoveReactionOptimisticUpdate | MarkInboxNotificationAsReadOptimisticUpdate | MarkAllInboxNotificationsAsReadOptimisticUpdate | UpdateNotificationSettingsOptimisticUpdate;
2087
2101
  declare type CreateThreadOptimisticUpdate<M extends BaseMetadata> = {
2088
2102
  type: "create-thread";
2089
2103
  id: string;
@@ -2104,6 +2118,18 @@ declare type EditThreadMetadataOptimisticUpdate<M extends BaseMetadata> = {
2104
2118
  metadata: Resolve<Patchable<M>>;
2105
2119
  updatedAt: Date;
2106
2120
  };
2121
+ declare type MarkThreadAsResolvedOptimisticUpdate = {
2122
+ type: "mark-thread-as-resolved";
2123
+ id: string;
2124
+ threadId: string;
2125
+ updatedAt: Date;
2126
+ };
2127
+ declare type MarkThreadAsUnresolvedOptimisticUpdate = {
2128
+ type: "mark-thread-as-unresolved";
2129
+ id: string;
2130
+ threadId: string;
2131
+ updatedAt: Date;
2132
+ };
2107
2133
  declare type CreateCommentOptimisticUpdate = {
2108
2134
  type: "create-comment";
2109
2135
  id: string;
@@ -2671,12 +2697,22 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
2671
2697
  * Decode base64 string.
2672
2698
  */
2673
2699
  declare function b64decode(b64value: string): string;
2700
+ /**
2701
+ * Returns a promise that resolves after the given number of milliseconds.
2702
+ */
2703
+ declare function wait(millis: number): Promise<void>;
2674
2704
  /**
2675
2705
  * Returns whatever the given promise returns, but will be rejected with
2676
2706
  * a "Timed out" error if the given promise does not return or reject within
2677
2707
  * the given timeout period (in milliseconds).
2678
2708
  */
2679
2709
  declare function withTimeout<T>(promise: Promise<T>, millis: number, errmsg: string): Promise<T>;
2710
+ /**
2711
+ * Memoize a promise factory, so that each subsequent call will return the same
2712
+ * pending or success promise, but if the promise rejects, the next call to the
2713
+ * function will start a new promise.
2714
+ */
2715
+ declare function memoizeOnSuccess<T>(factoryFn: () => Promise<T>): () => Promise<T>;
2680
2716
 
2681
2717
  /**
2682
2718
  * Positions, aka the Pos type, are efficient encodings of "positions" in
@@ -2889,4 +2925,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
2889
2925
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
2890
2926
  };
2891
2927
 
2892
- 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, type KDAD, 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 };
2928
+ 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, type KDAD, 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, memoizeOnSuccess, nn, objectToQuery, patchLiveObjectKey, raise, removeReaction, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, upsertComment, wait, 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.1.1-test1";
9
+ var PKG_VERSION = "2.2.0";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -628,6 +628,9 @@ function compactObject(obj) {
628
628
  });
629
629
  return newObj;
630
630
  }
631
+ function wait(millis) {
632
+ return new Promise((res) => setTimeout(res, millis));
633
+ }
631
634
  async function withTimeout(promise, millis, errmsg) {
632
635
  let timerID;
633
636
  const timer$ = new Promise((_, reject) => {
@@ -637,13 +640,16 @@ async function withTimeout(promise, millis, errmsg) {
637
640
  });
638
641
  return Promise.race([promise, timer$]).finally(() => clearTimeout(timerID));
639
642
  }
640
- function memoize(factoryFn) {
643
+ function memoizeOnSuccess(factoryFn) {
641
644
  let cached = null;
642
645
  return () => {
643
646
  if (cached === null) {
644
- cached = { value: factoryFn() };
647
+ cached = factoryFn().catch((err) => {
648
+ cached = null;
649
+ throw err;
650
+ });
645
651
  }
646
- return cached.value;
652
+ return cached;
647
653
  };
648
654
  }
649
655
 
@@ -661,6 +667,7 @@ var ServerMsgCode = /* @__PURE__ */ ((ServerMsgCode2) => {
661
667
  ServerMsgCode2[ServerMsgCode2["THREAD_CREATED"] = 400] = "THREAD_CREATED";
662
668
  ServerMsgCode2[ServerMsgCode2["THREAD_DELETED"] = 407] = "THREAD_DELETED";
663
669
  ServerMsgCode2[ServerMsgCode2["THREAD_METADATA_UPDATED"] = 401] = "THREAD_METADATA_UPDATED";
670
+ ServerMsgCode2[ServerMsgCode2["THREAD_UPDATED"] = 408] = "THREAD_UPDATED";
664
671
  ServerMsgCode2[ServerMsgCode2["COMMENT_CREATED"] = 402] = "COMMENT_CREATED";
665
672
  ServerMsgCode2[ServerMsgCode2["COMMENT_EDITED"] = 403] = "COMMENT_EDITED";
666
673
  ServerMsgCode2[ServerMsgCode2["COMMENT_DELETED"] = 404] = "COMMENT_DELETED";
@@ -5244,6 +5251,22 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5244
5251
  }
5245
5252
  );
5246
5253
  }
5254
+ async function markThreadAsResolved({ threadId }) {
5255
+ await fetchJson(
5256
+ `/threads/${encodeURIComponent(threadId)}/mark-as-resolved`,
5257
+ {
5258
+ method: "POST"
5259
+ }
5260
+ );
5261
+ }
5262
+ async function markThreadAsUnresolved({ threadId }) {
5263
+ await fetchJson(
5264
+ `/threads/${encodeURIComponent(threadId)}/mark-as-unresolved`,
5265
+ {
5266
+ method: "POST"
5267
+ }
5268
+ );
5269
+ }
5247
5270
  async function createComment({
5248
5271
  threadId,
5249
5272
  commentId,
@@ -5337,6 +5360,8 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5337
5360
  createThread,
5338
5361
  deleteThread,
5339
5362
  editThreadMetadata,
5363
+ markThreadAsResolved,
5364
+ markThreadAsUnresolved,
5340
5365
  createComment,
5341
5366
  editComment,
5342
5367
  deleteComment: deleteComment2,
@@ -6141,6 +6166,7 @@ ${Array.from(traces).join("\n\n")}`
6141
6166
  case 400 /* THREAD_CREATED */:
6142
6167
  case 407 /* THREAD_DELETED */:
6143
6168
  case 401 /* THREAD_METADATA_UPDATED */:
6169
+ case 408 /* THREAD_UPDATED */:
6144
6170
  case 405 /* COMMENT_REACTION_ADDED */:
6145
6171
  case 406 /* COMMENT_REACTION_REMOVED */:
6146
6172
  case 402 /* COMMENT_CREATED */:
@@ -6615,8 +6641,8 @@ ${Array.from(traces).join("\n\n")}`
6615
6641
  getStorageStatus,
6616
6642
  isPresenceReady,
6617
6643
  isStorageReady,
6618
- waitUntilPresenceReady: memoize(waitUntilPresenceReady),
6619
- waitUntilStorageReady: memoize(waitUntilStorageReady),
6644
+ waitUntilPresenceReady: memoizeOnSuccess(waitUntilPresenceReady),
6645
+ waitUntilStorageReady: memoizeOnSuccess(waitUntilStorageReady),
6620
6646
  events,
6621
6647
  // Core
6622
6648
  getStatus: () => managedSocket.getStatus(),
@@ -6901,6 +6927,34 @@ function applyOptimisticUpdates(state) {
6901
6927
  };
6902
6928
  break;
6903
6929
  }
6930
+ case "mark-thread-as-resolved": {
6931
+ const thread = result.threads[optimisticUpdate.threadId];
6932
+ if (thread === void 0) {
6933
+ break;
6934
+ }
6935
+ if (thread.deletedAt !== void 0) {
6936
+ break;
6937
+ }
6938
+ result.threads[thread.id] = {
6939
+ ...thread,
6940
+ resolved: true
6941
+ };
6942
+ break;
6943
+ }
6944
+ case "mark-thread-as-unresolved": {
6945
+ const thread = result.threads[optimisticUpdate.threadId];
6946
+ if (thread === void 0) {
6947
+ break;
6948
+ }
6949
+ if (thread.deletedAt !== void 0) {
6950
+ break;
6951
+ }
6952
+ result.threads[thread.id] = {
6953
+ ...thread,
6954
+ resolved: false
6955
+ };
6956
+ break;
6957
+ }
6904
6958
  case "create-comment": {
6905
6959
  const thread = result.threads[optimisticUpdate.comment.threadId];
6906
6960
  if (thread === void 0) {
@@ -7477,7 +7531,7 @@ function isCommentBodyParagraph(element) {
7477
7531
  return "type" in element && element.type === "mention";
7478
7532
  }
7479
7533
  function isCommentBodyText(element) {
7480
- return "text" in element && typeof element.text === "string";
7534
+ return !("type" in element) && "text" in element && typeof element.text === "string";
7481
7535
  }
7482
7536
  function isCommentBodyMention(element) {
7483
7537
  return "type" in element && element.type === "mention";
@@ -7660,7 +7714,7 @@ function toAbsoluteUrl(url) {
7660
7714
  var stringifyCommentBodyPlainElements = {
7661
7715
  paragraph: ({ children }) => children,
7662
7716
  text: ({ element }) => element.text,
7663
- link: ({ element }) => element.url,
7717
+ link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
7664
7718
  mention: ({ element, user }) => {
7665
7719
  return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _181 => _181.name]), () => ( element.id))}`;
7666
7720
  }
@@ -7689,7 +7743,7 @@ var stringifyCommentBodyHtmlElements = {
7689
7743
  return children;
7690
7744
  },
7691
7745
  link: ({ element, href }) => {
7692
- return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.url}</a>`;
7746
+ return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
7693
7747
  },
7694
7748
  mention: ({ element, user }) => {
7695
7749
  return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _182 => _182.name]), () => ( element.id))}</span>`;
@@ -7719,7 +7773,7 @@ var stringifyCommentBodyMarkdownElements = {
7719
7773
  return children;
7720
7774
  },
7721
7775
  link: ({ element, href }) => {
7722
- return markdown`[${element.url}](${href})`;
7776
+ return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
7723
7777
  },
7724
7778
  mention: ({ element, user }) => {
7725
7779
  return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _183 => _183.name]), () => ( element.id))}`;
@@ -8333,5 +8387,7 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
8333
8387
 
8334
8388
 
8335
8389
 
8336
- exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.addReaction = addReaction; exports.applyOptimisticUpdates = applyOptimisticUpdates; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.deleteComment = deleteComment; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.removeReaction = removeReaction; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.upsertComment = upsertComment; exports.withTimeout = withTimeout;
8390
+
8391
+
8392
+ exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.addReaction = addReaction; exports.applyOptimisticUpdates = applyOptimisticUpdates; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.deleteComment = deleteComment; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.removeReaction = removeReaction; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.upsertComment = upsertComment; exports.wait = wait; exports.withTimeout = withTimeout;
8337
8393
  //# sourceMappingURL=index.js.map