@liveblocks/core 3.12.1-enums1 → 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 +57 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -22
- package/dist/index.d.ts +15 -22
- package/dist/index.js +56 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -342,6 +342,7 @@ declare const OpCode: Readonly<{
|
|
|
342
342
|
DELETE_OBJECT_KEY: 6;
|
|
343
343
|
CREATE_MAP: 7;
|
|
344
344
|
CREATE_REGISTER: 8;
|
|
345
|
+
ACK: 9;
|
|
345
346
|
}>;
|
|
346
347
|
declare namespace OpCode {
|
|
347
348
|
type INIT = typeof OpCode.INIT;
|
|
@@ -353,12 +354,13 @@ declare namespace OpCode {
|
|
|
353
354
|
type DELETE_OBJECT_KEY = typeof OpCode.DELETE_OBJECT_KEY;
|
|
354
355
|
type CREATE_MAP = typeof OpCode.CREATE_MAP;
|
|
355
356
|
type CREATE_REGISTER = typeof OpCode.CREATE_REGISTER;
|
|
357
|
+
type ACK = typeof OpCode.ACK;
|
|
356
358
|
}
|
|
357
359
|
/**
|
|
358
360
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
359
361
|
* only.
|
|
360
362
|
*/
|
|
361
|
-
type Op =
|
|
363
|
+
type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp | AckOp;
|
|
362
364
|
type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
363
365
|
type UpdateObjectOp = {
|
|
364
366
|
readonly opId?: string;
|
|
@@ -414,25 +416,6 @@ type AckOp = {
|
|
|
414
416
|
readonly id: "ACK";
|
|
415
417
|
readonly opId: string;
|
|
416
418
|
};
|
|
417
|
-
/**
|
|
418
|
-
* Create an Op that can be used as an acknowledgement for the given opId, to
|
|
419
|
-
* send back to the originating client in cases where the server decided to
|
|
420
|
-
* ignore the Op and not forward it.
|
|
421
|
-
*
|
|
422
|
-
* Why?
|
|
423
|
-
* It's important for the client to receive an acknowledgement for this, so
|
|
424
|
-
* that it can correctly update its own unacknowledged Ops administration.
|
|
425
|
-
* Otherwise it could get in "synchronizing" state indefinitely.
|
|
426
|
-
*
|
|
427
|
-
* CLEVER HACK
|
|
428
|
-
* Introducing a new Op type for this would not be backward-compatible as
|
|
429
|
-
* receiving such Op would crash old clients :(
|
|
430
|
-
* So the clever backward-compatible hack pulled here is that we codify the
|
|
431
|
-
* acknowledgement as a "deletion Op" for the non-existing node id "ACK". In
|
|
432
|
-
* old clients such Op is accepted, but will effectively be a no-op as that
|
|
433
|
-
* node does not exist, but as a side-effect the Op will get acknowledged.
|
|
434
|
-
*/
|
|
435
|
-
declare function ackOp(opId: string): AckOp;
|
|
436
419
|
type SetParentKeyOp = {
|
|
437
420
|
readonly opId?: string;
|
|
438
421
|
readonly id: string;
|
|
@@ -2505,6 +2488,7 @@ declare const ServerMsgCode: Readonly<{
|
|
|
2505
2488
|
ROOM_STATE: 104;
|
|
2506
2489
|
INITIAL_STORAGE_STATE: 200;
|
|
2507
2490
|
UPDATE_STORAGE: 201;
|
|
2491
|
+
STORAGE_ACK: 202;
|
|
2508
2492
|
UPDATE_YDOC: 300;
|
|
2509
2493
|
THREAD_CREATED: 400;
|
|
2510
2494
|
THREAD_DELETED: 407;
|
|
@@ -2525,6 +2509,7 @@ declare namespace ServerMsgCode {
|
|
|
2525
2509
|
type ROOM_STATE = typeof ServerMsgCode.ROOM_STATE;
|
|
2526
2510
|
type INITIAL_STORAGE_STATE = typeof ServerMsgCode.INITIAL_STORAGE_STATE;
|
|
2527
2511
|
type UPDATE_STORAGE = typeof ServerMsgCode.UPDATE_STORAGE;
|
|
2512
|
+
type STORAGE_ACK = typeof ServerMsgCode.STORAGE_ACK;
|
|
2528
2513
|
type UPDATE_YDOC = typeof ServerMsgCode.UPDATE_YDOC;
|
|
2529
2514
|
type THREAD_CREATED = typeof ServerMsgCode.THREAD_CREATED;
|
|
2530
2515
|
type THREAD_DELETED = typeof ServerMsgCode.THREAD_DELETED;
|
|
@@ -2540,7 +2525,7 @@ declare namespace ServerMsgCode {
|
|
|
2540
2525
|
/**
|
|
2541
2526
|
* Messages that can be sent from the server to the client.
|
|
2542
2527
|
*/
|
|
2543
|
-
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;
|
|
2544
2529
|
type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
|
|
2545
2530
|
type ThreadCreatedEvent = {
|
|
2546
2531
|
type: ServerMsgCode.THREAD_CREATED;
|
|
@@ -2749,6 +2734,14 @@ type UpdateStorageServerMsg = {
|
|
|
2749
2734
|
readonly type: ServerMsgCode.UPDATE_STORAGE;
|
|
2750
2735
|
readonly ops: Op[];
|
|
2751
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
|
+
};
|
|
2752
2745
|
/**
|
|
2753
2746
|
* Sent by the WebSocket server to the client to indicate that certain opIds
|
|
2754
2747
|
* have been rejected, possibly due to lack of permissions or exceeding
|
|
@@ -5193,4 +5186,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5193
5186
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5194
5187
|
};
|
|
5195
5188
|
|
|
5196
|
-
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 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,
|
|
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
|
@@ -342,6 +342,7 @@ declare const OpCode: Readonly<{
|
|
|
342
342
|
DELETE_OBJECT_KEY: 6;
|
|
343
343
|
CREATE_MAP: 7;
|
|
344
344
|
CREATE_REGISTER: 8;
|
|
345
|
+
ACK: 9;
|
|
345
346
|
}>;
|
|
346
347
|
declare namespace OpCode {
|
|
347
348
|
type INIT = typeof OpCode.INIT;
|
|
@@ -353,12 +354,13 @@ declare namespace OpCode {
|
|
|
353
354
|
type DELETE_OBJECT_KEY = typeof OpCode.DELETE_OBJECT_KEY;
|
|
354
355
|
type CREATE_MAP = typeof OpCode.CREATE_MAP;
|
|
355
356
|
type CREATE_REGISTER = typeof OpCode.CREATE_REGISTER;
|
|
357
|
+
type ACK = typeof OpCode.ACK;
|
|
356
358
|
}
|
|
357
359
|
/**
|
|
358
360
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
359
361
|
* only.
|
|
360
362
|
*/
|
|
361
|
-
type Op =
|
|
363
|
+
type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp | AckOp;
|
|
362
364
|
type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
363
365
|
type UpdateObjectOp = {
|
|
364
366
|
readonly opId?: string;
|
|
@@ -414,25 +416,6 @@ type AckOp = {
|
|
|
414
416
|
readonly id: "ACK";
|
|
415
417
|
readonly opId: string;
|
|
416
418
|
};
|
|
417
|
-
/**
|
|
418
|
-
* Create an Op that can be used as an acknowledgement for the given opId, to
|
|
419
|
-
* send back to the originating client in cases where the server decided to
|
|
420
|
-
* ignore the Op and not forward it.
|
|
421
|
-
*
|
|
422
|
-
* Why?
|
|
423
|
-
* It's important for the client to receive an acknowledgement for this, so
|
|
424
|
-
* that it can correctly update its own unacknowledged Ops administration.
|
|
425
|
-
* Otherwise it could get in "synchronizing" state indefinitely.
|
|
426
|
-
*
|
|
427
|
-
* CLEVER HACK
|
|
428
|
-
* Introducing a new Op type for this would not be backward-compatible as
|
|
429
|
-
* receiving such Op would crash old clients :(
|
|
430
|
-
* So the clever backward-compatible hack pulled here is that we codify the
|
|
431
|
-
* acknowledgement as a "deletion Op" for the non-existing node id "ACK". In
|
|
432
|
-
* old clients such Op is accepted, but will effectively be a no-op as that
|
|
433
|
-
* node does not exist, but as a side-effect the Op will get acknowledged.
|
|
434
|
-
*/
|
|
435
|
-
declare function ackOp(opId: string): AckOp;
|
|
436
419
|
type SetParentKeyOp = {
|
|
437
420
|
readonly opId?: string;
|
|
438
421
|
readonly id: string;
|
|
@@ -2505,6 +2488,7 @@ declare const ServerMsgCode: Readonly<{
|
|
|
2505
2488
|
ROOM_STATE: 104;
|
|
2506
2489
|
INITIAL_STORAGE_STATE: 200;
|
|
2507
2490
|
UPDATE_STORAGE: 201;
|
|
2491
|
+
STORAGE_ACK: 202;
|
|
2508
2492
|
UPDATE_YDOC: 300;
|
|
2509
2493
|
THREAD_CREATED: 400;
|
|
2510
2494
|
THREAD_DELETED: 407;
|
|
@@ -2525,6 +2509,7 @@ declare namespace ServerMsgCode {
|
|
|
2525
2509
|
type ROOM_STATE = typeof ServerMsgCode.ROOM_STATE;
|
|
2526
2510
|
type INITIAL_STORAGE_STATE = typeof ServerMsgCode.INITIAL_STORAGE_STATE;
|
|
2527
2511
|
type UPDATE_STORAGE = typeof ServerMsgCode.UPDATE_STORAGE;
|
|
2512
|
+
type STORAGE_ACK = typeof ServerMsgCode.STORAGE_ACK;
|
|
2528
2513
|
type UPDATE_YDOC = typeof ServerMsgCode.UPDATE_YDOC;
|
|
2529
2514
|
type THREAD_CREATED = typeof ServerMsgCode.THREAD_CREATED;
|
|
2530
2515
|
type THREAD_DELETED = typeof ServerMsgCode.THREAD_DELETED;
|
|
@@ -2540,7 +2525,7 @@ declare namespace ServerMsgCode {
|
|
|
2540
2525
|
/**
|
|
2541
2526
|
* Messages that can be sent from the server to the client.
|
|
2542
2527
|
*/
|
|
2543
|
-
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;
|
|
2544
2529
|
type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
|
|
2545
2530
|
type ThreadCreatedEvent = {
|
|
2546
2531
|
type: ServerMsgCode.THREAD_CREATED;
|
|
@@ -2749,6 +2734,14 @@ type UpdateStorageServerMsg = {
|
|
|
2749
2734
|
readonly type: ServerMsgCode.UPDATE_STORAGE;
|
|
2750
2735
|
readonly ops: Op[];
|
|
2751
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
|
+
};
|
|
2752
2745
|
/**
|
|
2753
2746
|
* Sent by the WebSocket server to the client to indicate that certain opIds
|
|
2754
2747
|
* have been rejected, possibly due to lack of permissions or exceeding
|
|
@@ -5193,4 +5186,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5193
5186
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5194
5187
|
};
|
|
5195
5188
|
|
|
5196
|
-
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 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,
|
|
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
|
|
@@ -5922,19 +5923,10 @@ var OpCode = Object.freeze({
|
|
|
5922
5923
|
DELETE_CRDT: 5,
|
|
5923
5924
|
DELETE_OBJECT_KEY: 6,
|
|
5924
5925
|
CREATE_MAP: 7,
|
|
5925
|
-
CREATE_REGISTER: 8
|
|
5926
|
+
CREATE_REGISTER: 8,
|
|
5927
|
+
ACK: 9
|
|
5928
|
+
// Will only appear in v8+
|
|
5926
5929
|
});
|
|
5927
|
-
function ackOp(opId) {
|
|
5928
|
-
return {
|
|
5929
|
-
type: OpCode.DELETE_CRDT,
|
|
5930
|
-
id: "ACK",
|
|
5931
|
-
// (H)ACK
|
|
5932
|
-
opId
|
|
5933
|
-
};
|
|
5934
|
-
}
|
|
5935
|
-
function isAckOp(op) {
|
|
5936
|
-
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5937
|
-
}
|
|
5938
5930
|
|
|
5939
5931
|
// src/crdts/AbstractCrdt.ts
|
|
5940
5932
|
function createManagedPool(roomId, options) {
|
|
@@ -6389,7 +6381,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6389
6381
|
};
|
|
6390
6382
|
}
|
|
6391
6383
|
}
|
|
6392
|
-
#
|
|
6384
|
+
#applySetFixop(op) {
|
|
6393
6385
|
if (this._pool === void 0) {
|
|
6394
6386
|
throw new Error("Can't attach child if managed pool is not present");
|
|
6395
6387
|
}
|
|
@@ -6499,7 +6491,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6499
6491
|
reverse: []
|
|
6500
6492
|
};
|
|
6501
6493
|
}
|
|
6502
|
-
#
|
|
6494
|
+
#applyInsertFixop(op) {
|
|
6503
6495
|
const existingItem = this.#items.find((item) => item._id === op.id);
|
|
6504
6496
|
const key = asPos(op.parentKey);
|
|
6505
6497
|
const itemIndexAtPosition = this._indexOfPosition(key);
|
|
@@ -6621,16 +6613,16 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6621
6613
|
if (op.intent === "set") {
|
|
6622
6614
|
if (source === 1 /* REMOTE */) {
|
|
6623
6615
|
result = this.#applySetRemote(op);
|
|
6624
|
-
} else if (source === 2 /*
|
|
6625
|
-
result = this.#
|
|
6616
|
+
} else if (source === 2 /* FIXOP */) {
|
|
6617
|
+
result = this.#applySetFixop(op);
|
|
6626
6618
|
} else {
|
|
6627
6619
|
result = this.#applySetUndoRedo(op);
|
|
6628
6620
|
}
|
|
6629
6621
|
} else {
|
|
6630
6622
|
if (source === 1 /* REMOTE */) {
|
|
6631
6623
|
result = this.#applyRemoteInsert(op);
|
|
6632
|
-
} else if (source === 2 /*
|
|
6633
|
-
result = this.#
|
|
6624
|
+
} else if (source === 2 /* FIXOP */) {
|
|
6625
|
+
result = this.#applyInsertFixop(op);
|
|
6634
6626
|
} else {
|
|
6635
6627
|
result = this.#applyInsertUndoRedo(op);
|
|
6636
6628
|
}
|
|
@@ -6713,7 +6705,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6713
6705
|
};
|
|
6714
6706
|
}
|
|
6715
6707
|
}
|
|
6716
|
-
#
|
|
6708
|
+
#applySetChildKeyFixop(newKey, child) {
|
|
6717
6709
|
const previousKey = nn(child._parentKey);
|
|
6718
6710
|
if (this.#implicitlyDeletedItems.has(child)) {
|
|
6719
6711
|
const existingItemIndex = this._indexOfPosition(newKey);
|
|
@@ -6794,8 +6786,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6794
6786
|
_setChildKey(newKey, child, source) {
|
|
6795
6787
|
if (source === 1 /* REMOTE */) {
|
|
6796
6788
|
return this.#applySetChildKeyRemote(newKey, child);
|
|
6797
|
-
} else if (source === 2 /*
|
|
6798
|
-
return this.#
|
|
6789
|
+
} else if (source === 2 /* FIXOP */) {
|
|
6790
|
+
return this.#applySetChildKeyFixop(newKey, child);
|
|
6799
6791
|
} else {
|
|
6800
6792
|
return this.#applySetChildKeyUndoRedo(newKey, child);
|
|
6801
6793
|
}
|
|
@@ -7308,7 +7300,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7308
7300
|
if (this._pool.getNode(id) !== void 0) {
|
|
7309
7301
|
return { modified: false };
|
|
7310
7302
|
}
|
|
7311
|
-
if (source === 2 /*
|
|
7303
|
+
if (source === 2 /* FIXOP */) {
|
|
7312
7304
|
const lastUpdateOpId = this.#unacknowledgedSet.get(key);
|
|
7313
7305
|
if (lastUpdateOpId === opId) {
|
|
7314
7306
|
this.#unacknowledgedSet.delete(key);
|
|
@@ -7709,7 +7701,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7709
7701
|
}
|
|
7710
7702
|
return { modified: false };
|
|
7711
7703
|
}
|
|
7712
|
-
if (source === 0 /*
|
|
7704
|
+
if (source === 0 /* LOCAL */) {
|
|
7713
7705
|
this.#propToLastUpdate.set(key, nn(opId));
|
|
7714
7706
|
} else if (this.#propToLastUpdate.get(key) === void 0) {
|
|
7715
7707
|
} else if (this.#propToLastUpdate.get(key) === opId) {
|
|
@@ -9115,7 +9107,11 @@ function createRoom(options, config) {
|
|
|
9115
9107
|
currentItems.set(id, node._serialize());
|
|
9116
9108
|
}
|
|
9117
9109
|
const ops = getTreesDiffOperations(currentItems, new Map(items));
|
|
9118
|
-
const result = applyOps(
|
|
9110
|
+
const result = applyOps(
|
|
9111
|
+
ops,
|
|
9112
|
+
/* isLocal */
|
|
9113
|
+
false
|
|
9114
|
+
);
|
|
9119
9115
|
notify(result.updates);
|
|
9120
9116
|
}
|
|
9121
9117
|
function _addToRealUndoStack(historyOps) {
|
|
@@ -9196,11 +9192,12 @@ function createRoom(options, config) {
|
|
|
9196
9192
|
} else {
|
|
9197
9193
|
let source;
|
|
9198
9194
|
if (isLocal) {
|
|
9199
|
-
source = 0 /*
|
|
9195
|
+
source = 0 /* LOCAL */;
|
|
9196
|
+
} else if (op.opId) {
|
|
9197
|
+
context.unacknowledgedOps.delete(op.opId);
|
|
9198
|
+
source = 2 /* FIXOP */;
|
|
9200
9199
|
} else {
|
|
9201
|
-
|
|
9202
|
-
const deleted = context.unacknowledgedOps.delete(opId);
|
|
9203
|
-
source = deleted ? 2 /* ACK */ : 1 /* REMOTE */;
|
|
9200
|
+
source = 1 /* REMOTE */;
|
|
9204
9201
|
}
|
|
9205
9202
|
const applyOpResult = applyOp(op, source);
|
|
9206
9203
|
if (applyOpResult.modified) {
|
|
@@ -9231,9 +9228,6 @@ function createRoom(options, config) {
|
|
|
9231
9228
|
};
|
|
9232
9229
|
}
|
|
9233
9230
|
function applyOp(op, source) {
|
|
9234
|
-
if (isAckOp(op)) {
|
|
9235
|
-
return { modified: false };
|
|
9236
|
-
}
|
|
9237
9231
|
switch (op.type) {
|
|
9238
9232
|
case OpCode.DELETE_OBJECT_KEY:
|
|
9239
9233
|
case OpCode.UPDATE_OBJECT:
|
|
@@ -9242,7 +9236,7 @@ function createRoom(options, config) {
|
|
|
9242
9236
|
if (node === void 0) {
|
|
9243
9237
|
return { modified: false };
|
|
9244
9238
|
}
|
|
9245
|
-
return node._apply(op, source === 0 /*
|
|
9239
|
+
return node._apply(op, source === 0 /* LOCAL */);
|
|
9246
9240
|
}
|
|
9247
9241
|
case OpCode.SET_PARENT_KEY: {
|
|
9248
9242
|
const node = context.pool.nodes.get(op.id);
|
|
@@ -9413,7 +9407,11 @@ function createRoom(options, config) {
|
|
|
9413
9407
|
}
|
|
9414
9408
|
const messages = [];
|
|
9415
9409
|
const inOps = Array.from(offlineOps.values());
|
|
9416
|
-
const result = applyOps(
|
|
9410
|
+
const result = applyOps(
|
|
9411
|
+
inOps,
|
|
9412
|
+
/* isLocal */
|
|
9413
|
+
true
|
|
9414
|
+
);
|
|
9417
9415
|
messages.push({
|
|
9418
9416
|
type: ClientMsgCode.UPDATE_STORAGE,
|
|
9419
9417
|
ops: result.ops
|
|
@@ -9477,9 +9475,12 @@ function createRoom(options, config) {
|
|
|
9477
9475
|
processInitialStorage(message);
|
|
9478
9476
|
break;
|
|
9479
9477
|
}
|
|
9480
|
-
// Write event
|
|
9481
9478
|
case ServerMsgCode.UPDATE_STORAGE: {
|
|
9482
|
-
const applyResult = applyOps(
|
|
9479
|
+
const applyResult = applyOps(
|
|
9480
|
+
message.ops,
|
|
9481
|
+
/* isLocal */
|
|
9482
|
+
false
|
|
9483
|
+
);
|
|
9483
9484
|
for (const [key, value] of applyResult.updates.storageUpdates) {
|
|
9484
9485
|
updates.storageUpdates.set(
|
|
9485
9486
|
key,
|
|
@@ -9488,6 +9489,14 @@ function createRoom(options, config) {
|
|
|
9488
9489
|
}
|
|
9489
9490
|
break;
|
|
9490
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
|
+
}
|
|
9491
9500
|
// Receiving a RejectedOps message in the client means that the server is no
|
|
9492
9501
|
// longer in sync with the client. Trying to synchronize the client again by
|
|
9493
9502
|
// rolling back particular Ops may be hard/impossible. It's fine to not try and
|
|
@@ -9693,7 +9702,11 @@ function createRoom(options, config) {
|
|
|
9693
9702
|
return;
|
|
9694
9703
|
}
|
|
9695
9704
|
context.pausedHistory = null;
|
|
9696
|
-
const result = applyOps(
|
|
9705
|
+
const result = applyOps(
|
|
9706
|
+
historyOps,
|
|
9707
|
+
/* isLocal */
|
|
9708
|
+
true
|
|
9709
|
+
);
|
|
9697
9710
|
notify(result.updates);
|
|
9698
9711
|
context.redoStack.push(result.reverse);
|
|
9699
9712
|
onHistoryChange();
|
|
@@ -9713,7 +9726,11 @@ function createRoom(options, config) {
|
|
|
9713
9726
|
return;
|
|
9714
9727
|
}
|
|
9715
9728
|
context.pausedHistory = null;
|
|
9716
|
-
const result = applyOps(
|
|
9729
|
+
const result = applyOps(
|
|
9730
|
+
historyOps,
|
|
9731
|
+
/* isLocal */
|
|
9732
|
+
true
|
|
9733
|
+
);
|
|
9717
9734
|
notify(result.updates);
|
|
9718
9735
|
context.undoStack.push(result.reverse);
|
|
9719
9736
|
onHistoryChange();
|
|
@@ -10217,7 +10234,7 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
10217
10234
|
}
|
|
10218
10235
|
const url2 = new URL(baseUrl);
|
|
10219
10236
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
10220
|
-
url2.pathname = "/
|
|
10237
|
+
url2.pathname = "/v8";
|
|
10221
10238
|
url2.searchParams.set("roomId", roomId);
|
|
10222
10239
|
if (authValue.type === "secret") {
|
|
10223
10240
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
@@ -11450,7 +11467,6 @@ export {
|
|
|
11450
11467
|
SortedList,
|
|
11451
11468
|
TextEditorType,
|
|
11452
11469
|
WebsocketCloseCodes,
|
|
11453
|
-
ackOp,
|
|
11454
11470
|
asPos,
|
|
11455
11471
|
assert,
|
|
11456
11472
|
assertNever,
|