@liveblocks/core 3.12.1 → 3.13.0-ack1
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.cjs +53 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +53 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -360,7 +360,7 @@ declare namespace OpCode {
|
|
|
360
360
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
361
361
|
* only.
|
|
362
362
|
*/
|
|
363
|
-
type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp |
|
|
363
|
+
type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp | AckOp;
|
|
364
364
|
type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
365
365
|
type UpdateObjectOp = {
|
|
366
366
|
readonly opId?: string;
|
|
@@ -411,15 +411,11 @@ type DeleteCrdtOp = {
|
|
|
411
411
|
readonly id: string;
|
|
412
412
|
readonly type: OpCode.DELETE_CRDT;
|
|
413
413
|
};
|
|
414
|
-
type
|
|
414
|
+
type AckOp = {
|
|
415
415
|
readonly type: OpCode.DELETE_CRDT;
|
|
416
416
|
readonly id: "ACK";
|
|
417
417
|
readonly opId: string;
|
|
418
418
|
};
|
|
419
|
-
type AckOpV8 = {
|
|
420
|
-
readonly type: OpCode.ACK;
|
|
421
|
-
readonly opId: string;
|
|
422
|
-
};
|
|
423
419
|
type SetParentKeyOp = {
|
|
424
420
|
readonly opId?: string;
|
|
425
421
|
readonly id: string;
|
|
@@ -2492,6 +2488,7 @@ declare const ServerMsgCode: Readonly<{
|
|
|
2492
2488
|
ROOM_STATE: 104;
|
|
2493
2489
|
INITIAL_STORAGE_STATE: 200;
|
|
2494
2490
|
UPDATE_STORAGE: 201;
|
|
2491
|
+
STORAGE_ACK: 202;
|
|
2495
2492
|
UPDATE_YDOC: 300;
|
|
2496
2493
|
THREAD_CREATED: 400;
|
|
2497
2494
|
THREAD_DELETED: 407;
|
|
@@ -2512,6 +2509,7 @@ declare namespace ServerMsgCode {
|
|
|
2512
2509
|
type ROOM_STATE = typeof ServerMsgCode.ROOM_STATE;
|
|
2513
2510
|
type INITIAL_STORAGE_STATE = typeof ServerMsgCode.INITIAL_STORAGE_STATE;
|
|
2514
2511
|
type UPDATE_STORAGE = typeof ServerMsgCode.UPDATE_STORAGE;
|
|
2512
|
+
type STORAGE_ACK = typeof ServerMsgCode.STORAGE_ACK;
|
|
2515
2513
|
type UPDATE_YDOC = typeof ServerMsgCode.UPDATE_YDOC;
|
|
2516
2514
|
type THREAD_CREATED = typeof ServerMsgCode.THREAD_CREATED;
|
|
2517
2515
|
type THREAD_DELETED = typeof ServerMsgCode.THREAD_DELETED;
|
|
@@ -2527,7 +2525,7 @@ declare namespace ServerMsgCode {
|
|
|
2527
2525
|
/**
|
|
2528
2526
|
* Messages that can be sent from the server to the client.
|
|
2529
2527
|
*/
|
|
2530
|
-
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | YDocUpdateServerMsg | RejectedStorageOpServerMsg | CommentsEventServerMsg;
|
|
2528
|
+
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | StorageAckServerMsg | YDocUpdateServerMsg | RejectedStorageOpServerMsg | CommentsEventServerMsg;
|
|
2531
2529
|
type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
|
|
2532
2530
|
type ThreadCreatedEvent = {
|
|
2533
2531
|
type: ServerMsgCode.THREAD_CREATED;
|
|
@@ -2736,6 +2734,14 @@ type UpdateStorageServerMsg = {
|
|
|
2736
2734
|
readonly type: ServerMsgCode.UPDATE_STORAGE;
|
|
2737
2735
|
readonly ops: Op[];
|
|
2738
2736
|
};
|
|
2737
|
+
/**
|
|
2738
|
+
* Sent back to client that initiated a storage mutation, to acknowledge which
|
|
2739
|
+
* mutations have been persisted.
|
|
2740
|
+
*/
|
|
2741
|
+
type StorageAckServerMsg = {
|
|
2742
|
+
readonly type: ServerMsgCode.STORAGE_ACK;
|
|
2743
|
+
readonly opIds: string[];
|
|
2744
|
+
};
|
|
2739
2745
|
/**
|
|
2740
2746
|
* Sent by the WebSocket server to the client to indicate that certain opIds
|
|
2741
2747
|
* have been rejected, possibly due to lack of permissions or exceeding
|
|
@@ -5180,4 +5186,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5180
5186
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5181
5187
|
};
|
|
5182
5188
|
|
|
5183
|
-
export { type
|
|
5189
|
+
export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, 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 CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DE, type DGI, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, type LayerKey, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageAckServerMsg, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isNumberOperator, isPlainObject, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -360,7 +360,7 @@ declare namespace OpCode {
|
|
|
360
360
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
361
361
|
* only.
|
|
362
362
|
*/
|
|
363
|
-
type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp |
|
|
363
|
+
type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp | AckOp;
|
|
364
364
|
type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
365
365
|
type UpdateObjectOp = {
|
|
366
366
|
readonly opId?: string;
|
|
@@ -411,15 +411,11 @@ type DeleteCrdtOp = {
|
|
|
411
411
|
readonly id: string;
|
|
412
412
|
readonly type: OpCode.DELETE_CRDT;
|
|
413
413
|
};
|
|
414
|
-
type
|
|
414
|
+
type AckOp = {
|
|
415
415
|
readonly type: OpCode.DELETE_CRDT;
|
|
416
416
|
readonly id: "ACK";
|
|
417
417
|
readonly opId: string;
|
|
418
418
|
};
|
|
419
|
-
type AckOpV8 = {
|
|
420
|
-
readonly type: OpCode.ACK;
|
|
421
|
-
readonly opId: string;
|
|
422
|
-
};
|
|
423
419
|
type SetParentKeyOp = {
|
|
424
420
|
readonly opId?: string;
|
|
425
421
|
readonly id: string;
|
|
@@ -2492,6 +2488,7 @@ declare const ServerMsgCode: Readonly<{
|
|
|
2492
2488
|
ROOM_STATE: 104;
|
|
2493
2489
|
INITIAL_STORAGE_STATE: 200;
|
|
2494
2490
|
UPDATE_STORAGE: 201;
|
|
2491
|
+
STORAGE_ACK: 202;
|
|
2495
2492
|
UPDATE_YDOC: 300;
|
|
2496
2493
|
THREAD_CREATED: 400;
|
|
2497
2494
|
THREAD_DELETED: 407;
|
|
@@ -2512,6 +2509,7 @@ declare namespace ServerMsgCode {
|
|
|
2512
2509
|
type ROOM_STATE = typeof ServerMsgCode.ROOM_STATE;
|
|
2513
2510
|
type INITIAL_STORAGE_STATE = typeof ServerMsgCode.INITIAL_STORAGE_STATE;
|
|
2514
2511
|
type UPDATE_STORAGE = typeof ServerMsgCode.UPDATE_STORAGE;
|
|
2512
|
+
type STORAGE_ACK = typeof ServerMsgCode.STORAGE_ACK;
|
|
2515
2513
|
type UPDATE_YDOC = typeof ServerMsgCode.UPDATE_YDOC;
|
|
2516
2514
|
type THREAD_CREATED = typeof ServerMsgCode.THREAD_CREATED;
|
|
2517
2515
|
type THREAD_DELETED = typeof ServerMsgCode.THREAD_DELETED;
|
|
@@ -2527,7 +2525,7 @@ declare namespace ServerMsgCode {
|
|
|
2527
2525
|
/**
|
|
2528
2526
|
* Messages that can be sent from the server to the client.
|
|
2529
2527
|
*/
|
|
2530
|
-
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | YDocUpdateServerMsg | RejectedStorageOpServerMsg | CommentsEventServerMsg;
|
|
2528
|
+
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | StorageAckServerMsg | YDocUpdateServerMsg | RejectedStorageOpServerMsg | CommentsEventServerMsg;
|
|
2531
2529
|
type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
|
|
2532
2530
|
type ThreadCreatedEvent = {
|
|
2533
2531
|
type: ServerMsgCode.THREAD_CREATED;
|
|
@@ -2736,6 +2734,14 @@ type UpdateStorageServerMsg = {
|
|
|
2736
2734
|
readonly type: ServerMsgCode.UPDATE_STORAGE;
|
|
2737
2735
|
readonly ops: Op[];
|
|
2738
2736
|
};
|
|
2737
|
+
/**
|
|
2738
|
+
* Sent back to client that initiated a storage mutation, to acknowledge which
|
|
2739
|
+
* mutations have been persisted.
|
|
2740
|
+
*/
|
|
2741
|
+
type StorageAckServerMsg = {
|
|
2742
|
+
readonly type: ServerMsgCode.STORAGE_ACK;
|
|
2743
|
+
readonly opIds: string[];
|
|
2744
|
+
};
|
|
2739
2745
|
/**
|
|
2740
2746
|
* Sent by the WebSocket server to the client to indicate that certain opIds
|
|
2741
2747
|
* have been rejected, possibly due to lack of permissions or exceeding
|
|
@@ -5180,4 +5186,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5180
5186
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5181
5187
|
};
|
|
5182
5188
|
|
|
5183
|
-
export { type
|
|
5189
|
+
export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, 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 CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DE, type DGI, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, type LayerKey, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageAckServerMsg, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isNumberOperator, isPlainObject, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, 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 = "3.
|
|
9
|
+
var PKG_VERSION = "3.13.0-ack1";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3092,6 +3092,7 @@ var ServerMsgCode = Object.freeze({
|
|
|
3092
3092
|
// For Storage
|
|
3093
3093
|
INITIAL_STORAGE_STATE: 200,
|
|
3094
3094
|
UPDATE_STORAGE: 201,
|
|
3095
|
+
STORAGE_ACK: 202,
|
|
3095
3096
|
// For Yjs Docs
|
|
3096
3097
|
UPDATE_YDOC: 300,
|
|
3097
3098
|
// For Comments
|
|
@@ -5926,10 +5927,6 @@ var OpCode = Object.freeze({
|
|
|
5926
5927
|
ACK: 9
|
|
5927
5928
|
// Will only appear in v8+
|
|
5928
5929
|
});
|
|
5929
|
-
function isAck(op) {
|
|
5930
|
-
return op.type === OpCode.ACK || // >= v8
|
|
5931
|
-
op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5932
|
-
}
|
|
5933
5930
|
|
|
5934
5931
|
// src/crdts/AbstractCrdt.ts
|
|
5935
5932
|
function createManagedPool(roomId, options) {
|
|
@@ -6384,7 +6381,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6384
6381
|
};
|
|
6385
6382
|
}
|
|
6386
6383
|
}
|
|
6387
|
-
#
|
|
6384
|
+
#applySetFixop(op) {
|
|
6388
6385
|
if (this._pool === void 0) {
|
|
6389
6386
|
throw new Error("Can't attach child if managed pool is not present");
|
|
6390
6387
|
}
|
|
@@ -6494,7 +6491,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6494
6491
|
reverse: []
|
|
6495
6492
|
};
|
|
6496
6493
|
}
|
|
6497
|
-
#
|
|
6494
|
+
#applyInsertFixop(op) {
|
|
6498
6495
|
const existingItem = this.#items.find((item) => item._id === op.id);
|
|
6499
6496
|
const key = asPos(op.parentKey);
|
|
6500
6497
|
const itemIndexAtPosition = this._indexOfPosition(key);
|
|
@@ -6616,16 +6613,16 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6616
6613
|
if (op.intent === "set") {
|
|
6617
6614
|
if (source === 1 /* REMOTE */) {
|
|
6618
6615
|
result = this.#applySetRemote(op);
|
|
6619
|
-
} else if (source === 2 /*
|
|
6620
|
-
result = this.#
|
|
6616
|
+
} else if (source === 2 /* FIXOP */) {
|
|
6617
|
+
result = this.#applySetFixop(op);
|
|
6621
6618
|
} else {
|
|
6622
6619
|
result = this.#applySetUndoRedo(op);
|
|
6623
6620
|
}
|
|
6624
6621
|
} else {
|
|
6625
6622
|
if (source === 1 /* REMOTE */) {
|
|
6626
6623
|
result = this.#applyRemoteInsert(op);
|
|
6627
|
-
} else if (source === 2 /*
|
|
6628
|
-
result = this.#
|
|
6624
|
+
} else if (source === 2 /* FIXOP */) {
|
|
6625
|
+
result = this.#applyInsertFixop(op);
|
|
6629
6626
|
} else {
|
|
6630
6627
|
result = this.#applyInsertUndoRedo(op);
|
|
6631
6628
|
}
|
|
@@ -6708,7 +6705,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6708
6705
|
};
|
|
6709
6706
|
}
|
|
6710
6707
|
}
|
|
6711
|
-
#
|
|
6708
|
+
#applySetChildKeyFixop(newKey, child) {
|
|
6712
6709
|
const previousKey = nn(child._parentKey);
|
|
6713
6710
|
if (this.#implicitlyDeletedItems.has(child)) {
|
|
6714
6711
|
const existingItemIndex = this._indexOfPosition(newKey);
|
|
@@ -6789,8 +6786,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6789
6786
|
_setChildKey(newKey, child, source) {
|
|
6790
6787
|
if (source === 1 /* REMOTE */) {
|
|
6791
6788
|
return this.#applySetChildKeyRemote(newKey, child);
|
|
6792
|
-
} else if (source === 2 /*
|
|
6793
|
-
return this.#
|
|
6789
|
+
} else if (source === 2 /* FIXOP */) {
|
|
6790
|
+
return this.#applySetChildKeyFixop(newKey, child);
|
|
6794
6791
|
} else {
|
|
6795
6792
|
return this.#applySetChildKeyUndoRedo(newKey, child);
|
|
6796
6793
|
}
|
|
@@ -7303,7 +7300,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7303
7300
|
if (this._pool.getNode(id) !== void 0) {
|
|
7304
7301
|
return { modified: false };
|
|
7305
7302
|
}
|
|
7306
|
-
if (source === 2 /*
|
|
7303
|
+
if (source === 2 /* FIXOP */) {
|
|
7307
7304
|
const lastUpdateOpId = this.#unacknowledgedSet.get(key);
|
|
7308
7305
|
if (lastUpdateOpId === opId) {
|
|
7309
7306
|
this.#unacknowledgedSet.delete(key);
|
|
@@ -7704,7 +7701,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7704
7701
|
}
|
|
7705
7702
|
return { modified: false };
|
|
7706
7703
|
}
|
|
7707
|
-
if (source === 0 /*
|
|
7704
|
+
if (source === 0 /* LOCAL */) {
|
|
7708
7705
|
this.#propToLastUpdate.set(key, nn(opId));
|
|
7709
7706
|
} else if (this.#propToLastUpdate.get(key) === void 0) {
|
|
7710
7707
|
} else if (this.#propToLastUpdate.get(key) === opId) {
|
|
@@ -9110,7 +9107,11 @@ function createRoom(options, config) {
|
|
|
9110
9107
|
currentItems.set(id, node._serialize());
|
|
9111
9108
|
}
|
|
9112
9109
|
const ops = getTreesDiffOperations(currentItems, new Map(items));
|
|
9113
|
-
const result = applyOps(
|
|
9110
|
+
const result = applyOps(
|
|
9111
|
+
ops,
|
|
9112
|
+
/* isLocal */
|
|
9113
|
+
false
|
|
9114
|
+
);
|
|
9114
9115
|
notify(result.updates);
|
|
9115
9116
|
}
|
|
9116
9117
|
function _addToRealUndoStack(historyOps) {
|
|
@@ -9191,11 +9192,12 @@ function createRoom(options, config) {
|
|
|
9191
9192
|
} else {
|
|
9192
9193
|
let source;
|
|
9193
9194
|
if (isLocal) {
|
|
9194
|
-
source = 0 /*
|
|
9195
|
+
source = 0 /* LOCAL */;
|
|
9196
|
+
} else if (op.opId) {
|
|
9197
|
+
context.unacknowledgedOps.delete(op.opId);
|
|
9198
|
+
source = 2 /* FIXOP */;
|
|
9195
9199
|
} else {
|
|
9196
|
-
|
|
9197
|
-
const deleted = context.unacknowledgedOps.delete(opId);
|
|
9198
|
-
source = deleted ? 2 /* ACK */ : 1 /* REMOTE */;
|
|
9200
|
+
source = 1 /* REMOTE */;
|
|
9199
9201
|
}
|
|
9200
9202
|
const applyOpResult = applyOp(op, source);
|
|
9201
9203
|
if (applyOpResult.modified) {
|
|
@@ -9226,9 +9228,6 @@ function createRoom(options, config) {
|
|
|
9226
9228
|
};
|
|
9227
9229
|
}
|
|
9228
9230
|
function applyOp(op, source) {
|
|
9229
|
-
if (isAck(op)) {
|
|
9230
|
-
return { modified: false };
|
|
9231
|
-
}
|
|
9232
9231
|
switch (op.type) {
|
|
9233
9232
|
case OpCode.DELETE_OBJECT_KEY:
|
|
9234
9233
|
case OpCode.UPDATE_OBJECT:
|
|
@@ -9237,7 +9236,7 @@ function createRoom(options, config) {
|
|
|
9237
9236
|
if (node === void 0) {
|
|
9238
9237
|
return { modified: false };
|
|
9239
9238
|
}
|
|
9240
|
-
return node._apply(op, source === 0 /*
|
|
9239
|
+
return node._apply(op, source === 0 /* LOCAL */);
|
|
9241
9240
|
}
|
|
9242
9241
|
case OpCode.SET_PARENT_KEY: {
|
|
9243
9242
|
const node = context.pool.nodes.get(op.id);
|
|
@@ -9408,7 +9407,11 @@ function createRoom(options, config) {
|
|
|
9408
9407
|
}
|
|
9409
9408
|
const messages = [];
|
|
9410
9409
|
const inOps = Array.from(offlineOps.values());
|
|
9411
|
-
const result = applyOps(
|
|
9410
|
+
const result = applyOps(
|
|
9411
|
+
inOps,
|
|
9412
|
+
/* isLocal */
|
|
9413
|
+
true
|
|
9414
|
+
);
|
|
9412
9415
|
messages.push({
|
|
9413
9416
|
type: ClientMsgCode.UPDATE_STORAGE,
|
|
9414
9417
|
ops: result.ops
|
|
@@ -9472,9 +9475,12 @@ function createRoom(options, config) {
|
|
|
9472
9475
|
processInitialStorage(message);
|
|
9473
9476
|
break;
|
|
9474
9477
|
}
|
|
9475
|
-
// Write event
|
|
9476
9478
|
case ServerMsgCode.UPDATE_STORAGE: {
|
|
9477
|
-
const applyResult = applyOps(
|
|
9479
|
+
const applyResult = applyOps(
|
|
9480
|
+
message.ops,
|
|
9481
|
+
/* isLocal */
|
|
9482
|
+
false
|
|
9483
|
+
);
|
|
9478
9484
|
for (const [key, value] of applyResult.updates.storageUpdates) {
|
|
9479
9485
|
updates.storageUpdates.set(
|
|
9480
9486
|
key,
|
|
@@ -9483,6 +9489,14 @@ function createRoom(options, config) {
|
|
|
9483
9489
|
}
|
|
9484
9490
|
break;
|
|
9485
9491
|
}
|
|
9492
|
+
// Since V8. On V7, acks were sent disguised as an Ops in UPDATE_STORAGE messages.
|
|
9493
|
+
case ServerMsgCode.STORAGE_ACK: {
|
|
9494
|
+
for (const opId of message.opIds) {
|
|
9495
|
+
context.unacknowledgedOps.delete(opId);
|
|
9496
|
+
}
|
|
9497
|
+
notifyStorageStatus();
|
|
9498
|
+
break;
|
|
9499
|
+
}
|
|
9486
9500
|
// Receiving a RejectedOps message in the client means that the server is no
|
|
9487
9501
|
// longer in sync with the client. Trying to synchronize the client again by
|
|
9488
9502
|
// rolling back particular Ops may be hard/impossible. It's fine to not try and
|
|
@@ -9688,7 +9702,11 @@ function createRoom(options, config) {
|
|
|
9688
9702
|
return;
|
|
9689
9703
|
}
|
|
9690
9704
|
context.pausedHistory = null;
|
|
9691
|
-
const result = applyOps(
|
|
9705
|
+
const result = applyOps(
|
|
9706
|
+
historyOps,
|
|
9707
|
+
/* isLocal */
|
|
9708
|
+
true
|
|
9709
|
+
);
|
|
9692
9710
|
notify(result.updates);
|
|
9693
9711
|
context.redoStack.push(result.reverse);
|
|
9694
9712
|
onHistoryChange();
|
|
@@ -9708,7 +9726,11 @@ function createRoom(options, config) {
|
|
|
9708
9726
|
return;
|
|
9709
9727
|
}
|
|
9710
9728
|
context.pausedHistory = null;
|
|
9711
|
-
const result = applyOps(
|
|
9729
|
+
const result = applyOps(
|
|
9730
|
+
historyOps,
|
|
9731
|
+
/* isLocal */
|
|
9732
|
+
true
|
|
9733
|
+
);
|
|
9712
9734
|
notify(result.updates);
|
|
9713
9735
|
context.undoStack.push(result.reverse);
|
|
9714
9736
|
onHistoryChange();
|
|
@@ -10212,7 +10234,7 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
10212
10234
|
}
|
|
10213
10235
|
const url2 = new URL(baseUrl);
|
|
10214
10236
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
10215
|
-
url2.pathname = "/
|
|
10237
|
+
url2.pathname = "/v8";
|
|
10216
10238
|
url2.searchParams.set("roomId", roomId);
|
|
10217
10239
|
if (authValue.type === "secret") {
|
|
10218
10240
|
url2.searchParams.set("tok", authValue.token.raw);
|