@liveblocks/core 3.13.0-rc2 → 3.13.0-vincent2
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 +101 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -27
- package/dist/index.d.ts +65 -27
- package/dist/index.js +100 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -342,7 +342,6 @@ declare const OpCode: Readonly<{
|
|
|
342
342
|
DELETE_OBJECT_KEY: 6;
|
|
343
343
|
CREATE_MAP: 7;
|
|
344
344
|
CREATE_REGISTER: 8;
|
|
345
|
-
ACK: 9;
|
|
346
345
|
}>;
|
|
347
346
|
declare namespace OpCode {
|
|
348
347
|
type INIT = typeof OpCode.INIT;
|
|
@@ -354,7 +353,6 @@ declare namespace OpCode {
|
|
|
354
353
|
type DELETE_OBJECT_KEY = typeof OpCode.DELETE_OBJECT_KEY;
|
|
355
354
|
type CREATE_MAP = typeof OpCode.CREATE_MAP;
|
|
356
355
|
type CREATE_REGISTER = typeof OpCode.CREATE_REGISTER;
|
|
357
|
-
type ACK = typeof OpCode.ACK;
|
|
358
356
|
}
|
|
359
357
|
/**
|
|
360
358
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
@@ -592,6 +590,7 @@ declare namespace CrdtType {
|
|
|
592
590
|
}
|
|
593
591
|
type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
594
592
|
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
593
|
+
type NodeStream = Iterable<IdTuple<SerializedCrdt>>;
|
|
595
594
|
type SerializedRootObject = {
|
|
596
595
|
readonly type: CrdtType.OBJECT;
|
|
597
596
|
readonly data: JsonObject;
|
|
@@ -620,6 +619,36 @@ type SerializedRegister = {
|
|
|
620
619
|
readonly parentKey: string;
|
|
621
620
|
readonly data: Json;
|
|
622
621
|
};
|
|
622
|
+
type CompactNode = CompactRootNode | CompactChildNode;
|
|
623
|
+
type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode;
|
|
624
|
+
type CompactRootNode = readonly [id: "root", data: JsonObject];
|
|
625
|
+
type CompactObjectNode = readonly [
|
|
626
|
+
id: string,
|
|
627
|
+
type: CrdtType.OBJECT,
|
|
628
|
+
parentId: string,
|
|
629
|
+
parentKey: string,
|
|
630
|
+
data: JsonObject
|
|
631
|
+
];
|
|
632
|
+
type CompactListNode = readonly [
|
|
633
|
+
id: string,
|
|
634
|
+
type: CrdtType.LIST,
|
|
635
|
+
parentId: string,
|
|
636
|
+
parentKey: string
|
|
637
|
+
];
|
|
638
|
+
type CompactMapNode = readonly [
|
|
639
|
+
id: string,
|
|
640
|
+
type: CrdtType.MAP,
|
|
641
|
+
parentId: string,
|
|
642
|
+
parentKey: string
|
|
643
|
+
];
|
|
644
|
+
type CompactRegisterNode = readonly [
|
|
645
|
+
id: string,
|
|
646
|
+
type: CrdtType.REGISTER,
|
|
647
|
+
parentId: string,
|
|
648
|
+
parentKey: string,
|
|
649
|
+
data: Json
|
|
650
|
+
];
|
|
651
|
+
declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
|
|
623
652
|
|
|
624
653
|
type LiveObjectUpdateDelta<O extends {
|
|
625
654
|
[key: string]: unknown;
|
|
@@ -653,7 +682,7 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
653
682
|
*/
|
|
654
683
|
static detectLargeObjects: boolean;
|
|
655
684
|
/** @private Do not use this API directly */
|
|
656
|
-
static _fromItems<O extends LsonObject>(
|
|
685
|
+
static _fromItems<O extends LsonObject>(nodes: NodeStream, pool: ManagedPool): LiveObject<O>;
|
|
657
686
|
constructor(obj?: O);
|
|
658
687
|
/**
|
|
659
688
|
* Transform the LiveObject into a javascript object
|
|
@@ -2492,7 +2521,8 @@ declare const ServerMsgCode: Readonly<{
|
|
|
2492
2521
|
USER_LEFT: 102;
|
|
2493
2522
|
BROADCASTED_EVENT: 103;
|
|
2494
2523
|
ROOM_STATE: 104;
|
|
2495
|
-
|
|
2524
|
+
STORAGE_STATE_V7: 200;
|
|
2525
|
+
STORAGE_CHUNK: 210;
|
|
2496
2526
|
UPDATE_STORAGE: 201;
|
|
2497
2527
|
UPDATE_YDOC: 300;
|
|
2498
2528
|
THREAD_CREATED: 400;
|
|
@@ -2512,7 +2542,8 @@ declare namespace ServerMsgCode {
|
|
|
2512
2542
|
type USER_LEFT = typeof ServerMsgCode.USER_LEFT;
|
|
2513
2543
|
type BROADCASTED_EVENT = typeof ServerMsgCode.BROADCASTED_EVENT;
|
|
2514
2544
|
type ROOM_STATE = typeof ServerMsgCode.ROOM_STATE;
|
|
2515
|
-
type
|
|
2545
|
+
type STORAGE_STATE_V7 = typeof ServerMsgCode.STORAGE_STATE_V7;
|
|
2546
|
+
type STORAGE_CHUNK = typeof ServerMsgCode.STORAGE_CHUNK;
|
|
2516
2547
|
type UPDATE_STORAGE = typeof ServerMsgCode.UPDATE_STORAGE;
|
|
2517
2548
|
type UPDATE_YDOC = typeof ServerMsgCode.UPDATE_YDOC;
|
|
2518
2549
|
type THREAD_CREATED = typeof ServerMsgCode.THREAD_CREATED;
|
|
@@ -2529,7 +2560,7 @@ declare namespace ServerMsgCode {
|
|
|
2529
2560
|
/**
|
|
2530
2561
|
* Messages that can be sent from the server to the client.
|
|
2531
2562
|
*/
|
|
2532
|
-
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> |
|
|
2563
|
+
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | StorageStateServerMsg_V7 | StorageChunkServerMsg | UpdateStorageServerMsg | YDocUpdateServerMsg | RejectedStorageOpServerMsg | CommentsEventServerMsg;
|
|
2533
2564
|
type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
|
|
2534
2565
|
type ThreadCreatedEvent = {
|
|
2535
2566
|
type: ServerMsgCode.THREAD_CREATED;
|
|
@@ -2693,40 +2724,47 @@ type BroadcastedEventServerMsg<E extends Json> = {
|
|
|
2693
2724
|
*/
|
|
2694
2725
|
type RoomStateServerMsg<U extends BaseUserMeta> = {
|
|
2695
2726
|
readonly type: ServerMsgCode.ROOM_STATE;
|
|
2696
|
-
/**
|
|
2697
|
-
* Informs the client what their actor ID is going to be.
|
|
2698
|
-
* @since v1.2 (WS API v7)
|
|
2699
|
-
*/
|
|
2727
|
+
/** Informs the client what their actor ID is going to be. */
|
|
2700
2728
|
readonly actor: number;
|
|
2701
|
-
/**
|
|
2702
|
-
* Secure nonce for the current session.
|
|
2703
|
-
* @since v1.2 (WS API v7)
|
|
2704
|
-
*/
|
|
2729
|
+
/** Secure nonce for the current session. */
|
|
2705
2730
|
readonly nonce: string;
|
|
2706
|
-
/**
|
|
2707
|
-
* Informs the client what permissions the current User (self) has.
|
|
2708
|
-
* @since v1.2 (WS API v7)
|
|
2709
|
-
*/
|
|
2731
|
+
/** Informs the client what permissions the current User (self) has. */
|
|
2710
2732
|
readonly scopes: string[];
|
|
2711
2733
|
readonly users: {
|
|
2712
2734
|
readonly [otherActor: number]: U & {
|
|
2713
2735
|
scopes: string[];
|
|
2714
2736
|
};
|
|
2715
2737
|
};
|
|
2716
|
-
/**
|
|
2717
|
-
* Metadata sent from the server to the client.
|
|
2718
|
-
*/
|
|
2738
|
+
/** Metadata sent from the server to the client. */
|
|
2719
2739
|
readonly meta: JsonObject;
|
|
2720
2740
|
};
|
|
2721
2741
|
/**
|
|
2722
|
-
*
|
|
2723
|
-
* joining the Room, to provide the initial Storage state of the Room. The
|
|
2724
|
-
* payload includes the entire Storage document.
|
|
2742
|
+
* No longer used as of WS API v8.
|
|
2725
2743
|
*/
|
|
2726
|
-
type
|
|
2727
|
-
readonly type: ServerMsgCode.
|
|
2744
|
+
type StorageStateServerMsg_V7 = {
|
|
2745
|
+
readonly type: ServerMsgCode.STORAGE_STATE_V7;
|
|
2728
2746
|
readonly items: IdTuple<SerializedCrdt>[];
|
|
2729
2747
|
};
|
|
2748
|
+
/**
|
|
2749
|
+
* Sent by the WebSocket server to a single client in response to the client
|
|
2750
|
+
* sending a FetchStorageClientMsg message, to provide the initial Storage
|
|
2751
|
+
* state of the Room.
|
|
2752
|
+
*
|
|
2753
|
+
* The server will respond with 0+ STORAGE_CHUNK messages with
|
|
2754
|
+
* done=false, followed by exactly one STORAGE_CHUNK message with
|
|
2755
|
+
* done=true.
|
|
2756
|
+
*
|
|
2757
|
+
* If the room is using the new storage engine that supports streaming, then
|
|
2758
|
+
* potentially multiple chunks might get sent.
|
|
2759
|
+
*
|
|
2760
|
+
* If the room is using the old storage engine, then all nodes will be sent in
|
|
2761
|
+
* a single/large chunk (non-streaming).
|
|
2762
|
+
*/
|
|
2763
|
+
type StorageChunkServerMsg = {
|
|
2764
|
+
readonly type: ServerMsgCode.STORAGE_CHUNK;
|
|
2765
|
+
readonly done: boolean;
|
|
2766
|
+
readonly nodes: CompactNode[];
|
|
2767
|
+
};
|
|
2730
2768
|
/**
|
|
2731
2769
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
2732
2770
|
* a change occurred in the Storage document.
|
|
@@ -5182,4 +5220,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5182
5220
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5183
5221
|
};
|
|
5184
5222
|
|
|
5185
|
-
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
|
|
5223
|
+
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 CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, 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 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 StorageChunkServerMsg, 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, nodeStreamToCompactNodes, 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,7 +342,6 @@ declare const OpCode: Readonly<{
|
|
|
342
342
|
DELETE_OBJECT_KEY: 6;
|
|
343
343
|
CREATE_MAP: 7;
|
|
344
344
|
CREATE_REGISTER: 8;
|
|
345
|
-
ACK: 9;
|
|
346
345
|
}>;
|
|
347
346
|
declare namespace OpCode {
|
|
348
347
|
type INIT = typeof OpCode.INIT;
|
|
@@ -354,7 +353,6 @@ declare namespace OpCode {
|
|
|
354
353
|
type DELETE_OBJECT_KEY = typeof OpCode.DELETE_OBJECT_KEY;
|
|
355
354
|
type CREATE_MAP = typeof OpCode.CREATE_MAP;
|
|
356
355
|
type CREATE_REGISTER = typeof OpCode.CREATE_REGISTER;
|
|
357
|
-
type ACK = typeof OpCode.ACK;
|
|
358
356
|
}
|
|
359
357
|
/**
|
|
360
358
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
@@ -592,6 +590,7 @@ declare namespace CrdtType {
|
|
|
592
590
|
}
|
|
593
591
|
type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
594
592
|
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
593
|
+
type NodeStream = Iterable<IdTuple<SerializedCrdt>>;
|
|
595
594
|
type SerializedRootObject = {
|
|
596
595
|
readonly type: CrdtType.OBJECT;
|
|
597
596
|
readonly data: JsonObject;
|
|
@@ -620,6 +619,36 @@ type SerializedRegister = {
|
|
|
620
619
|
readonly parentKey: string;
|
|
621
620
|
readonly data: Json;
|
|
622
621
|
};
|
|
622
|
+
type CompactNode = CompactRootNode | CompactChildNode;
|
|
623
|
+
type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode;
|
|
624
|
+
type CompactRootNode = readonly [id: "root", data: JsonObject];
|
|
625
|
+
type CompactObjectNode = readonly [
|
|
626
|
+
id: string,
|
|
627
|
+
type: CrdtType.OBJECT,
|
|
628
|
+
parentId: string,
|
|
629
|
+
parentKey: string,
|
|
630
|
+
data: JsonObject
|
|
631
|
+
];
|
|
632
|
+
type CompactListNode = readonly [
|
|
633
|
+
id: string,
|
|
634
|
+
type: CrdtType.LIST,
|
|
635
|
+
parentId: string,
|
|
636
|
+
parentKey: string
|
|
637
|
+
];
|
|
638
|
+
type CompactMapNode = readonly [
|
|
639
|
+
id: string,
|
|
640
|
+
type: CrdtType.MAP,
|
|
641
|
+
parentId: string,
|
|
642
|
+
parentKey: string
|
|
643
|
+
];
|
|
644
|
+
type CompactRegisterNode = readonly [
|
|
645
|
+
id: string,
|
|
646
|
+
type: CrdtType.REGISTER,
|
|
647
|
+
parentId: string,
|
|
648
|
+
parentKey: string,
|
|
649
|
+
data: Json
|
|
650
|
+
];
|
|
651
|
+
declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
|
|
623
652
|
|
|
624
653
|
type LiveObjectUpdateDelta<O extends {
|
|
625
654
|
[key: string]: unknown;
|
|
@@ -653,7 +682,7 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
653
682
|
*/
|
|
654
683
|
static detectLargeObjects: boolean;
|
|
655
684
|
/** @private Do not use this API directly */
|
|
656
|
-
static _fromItems<O extends LsonObject>(
|
|
685
|
+
static _fromItems<O extends LsonObject>(nodes: NodeStream, pool: ManagedPool): LiveObject<O>;
|
|
657
686
|
constructor(obj?: O);
|
|
658
687
|
/**
|
|
659
688
|
* Transform the LiveObject into a javascript object
|
|
@@ -2492,7 +2521,8 @@ declare const ServerMsgCode: Readonly<{
|
|
|
2492
2521
|
USER_LEFT: 102;
|
|
2493
2522
|
BROADCASTED_EVENT: 103;
|
|
2494
2523
|
ROOM_STATE: 104;
|
|
2495
|
-
|
|
2524
|
+
STORAGE_STATE_V7: 200;
|
|
2525
|
+
STORAGE_CHUNK: 210;
|
|
2496
2526
|
UPDATE_STORAGE: 201;
|
|
2497
2527
|
UPDATE_YDOC: 300;
|
|
2498
2528
|
THREAD_CREATED: 400;
|
|
@@ -2512,7 +2542,8 @@ declare namespace ServerMsgCode {
|
|
|
2512
2542
|
type USER_LEFT = typeof ServerMsgCode.USER_LEFT;
|
|
2513
2543
|
type BROADCASTED_EVENT = typeof ServerMsgCode.BROADCASTED_EVENT;
|
|
2514
2544
|
type ROOM_STATE = typeof ServerMsgCode.ROOM_STATE;
|
|
2515
|
-
type
|
|
2545
|
+
type STORAGE_STATE_V7 = typeof ServerMsgCode.STORAGE_STATE_V7;
|
|
2546
|
+
type STORAGE_CHUNK = typeof ServerMsgCode.STORAGE_CHUNK;
|
|
2516
2547
|
type UPDATE_STORAGE = typeof ServerMsgCode.UPDATE_STORAGE;
|
|
2517
2548
|
type UPDATE_YDOC = typeof ServerMsgCode.UPDATE_YDOC;
|
|
2518
2549
|
type THREAD_CREATED = typeof ServerMsgCode.THREAD_CREATED;
|
|
@@ -2529,7 +2560,7 @@ declare namespace ServerMsgCode {
|
|
|
2529
2560
|
/**
|
|
2530
2561
|
* Messages that can be sent from the server to the client.
|
|
2531
2562
|
*/
|
|
2532
|
-
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> |
|
|
2563
|
+
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | StorageStateServerMsg_V7 | StorageChunkServerMsg | UpdateStorageServerMsg | YDocUpdateServerMsg | RejectedStorageOpServerMsg | CommentsEventServerMsg;
|
|
2533
2564
|
type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
|
|
2534
2565
|
type ThreadCreatedEvent = {
|
|
2535
2566
|
type: ServerMsgCode.THREAD_CREATED;
|
|
@@ -2693,40 +2724,47 @@ type BroadcastedEventServerMsg<E extends Json> = {
|
|
|
2693
2724
|
*/
|
|
2694
2725
|
type RoomStateServerMsg<U extends BaseUserMeta> = {
|
|
2695
2726
|
readonly type: ServerMsgCode.ROOM_STATE;
|
|
2696
|
-
/**
|
|
2697
|
-
* Informs the client what their actor ID is going to be.
|
|
2698
|
-
* @since v1.2 (WS API v7)
|
|
2699
|
-
*/
|
|
2727
|
+
/** Informs the client what their actor ID is going to be. */
|
|
2700
2728
|
readonly actor: number;
|
|
2701
|
-
/**
|
|
2702
|
-
* Secure nonce for the current session.
|
|
2703
|
-
* @since v1.2 (WS API v7)
|
|
2704
|
-
*/
|
|
2729
|
+
/** Secure nonce for the current session. */
|
|
2705
2730
|
readonly nonce: string;
|
|
2706
|
-
/**
|
|
2707
|
-
* Informs the client what permissions the current User (self) has.
|
|
2708
|
-
* @since v1.2 (WS API v7)
|
|
2709
|
-
*/
|
|
2731
|
+
/** Informs the client what permissions the current User (self) has. */
|
|
2710
2732
|
readonly scopes: string[];
|
|
2711
2733
|
readonly users: {
|
|
2712
2734
|
readonly [otherActor: number]: U & {
|
|
2713
2735
|
scopes: string[];
|
|
2714
2736
|
};
|
|
2715
2737
|
};
|
|
2716
|
-
/**
|
|
2717
|
-
* Metadata sent from the server to the client.
|
|
2718
|
-
*/
|
|
2738
|
+
/** Metadata sent from the server to the client. */
|
|
2719
2739
|
readonly meta: JsonObject;
|
|
2720
2740
|
};
|
|
2721
2741
|
/**
|
|
2722
|
-
*
|
|
2723
|
-
* joining the Room, to provide the initial Storage state of the Room. The
|
|
2724
|
-
* payload includes the entire Storage document.
|
|
2742
|
+
* No longer used as of WS API v8.
|
|
2725
2743
|
*/
|
|
2726
|
-
type
|
|
2727
|
-
readonly type: ServerMsgCode.
|
|
2744
|
+
type StorageStateServerMsg_V7 = {
|
|
2745
|
+
readonly type: ServerMsgCode.STORAGE_STATE_V7;
|
|
2728
2746
|
readonly items: IdTuple<SerializedCrdt>[];
|
|
2729
2747
|
};
|
|
2748
|
+
/**
|
|
2749
|
+
* Sent by the WebSocket server to a single client in response to the client
|
|
2750
|
+
* sending a FetchStorageClientMsg message, to provide the initial Storage
|
|
2751
|
+
* state of the Room.
|
|
2752
|
+
*
|
|
2753
|
+
* The server will respond with 0+ STORAGE_CHUNK messages with
|
|
2754
|
+
* done=false, followed by exactly one STORAGE_CHUNK message with
|
|
2755
|
+
* done=true.
|
|
2756
|
+
*
|
|
2757
|
+
* If the room is using the new storage engine that supports streaming, then
|
|
2758
|
+
* potentially multiple chunks might get sent.
|
|
2759
|
+
*
|
|
2760
|
+
* If the room is using the old storage engine, then all nodes will be sent in
|
|
2761
|
+
* a single/large chunk (non-streaming).
|
|
2762
|
+
*/
|
|
2763
|
+
type StorageChunkServerMsg = {
|
|
2764
|
+
readonly type: ServerMsgCode.STORAGE_CHUNK;
|
|
2765
|
+
readonly done: boolean;
|
|
2766
|
+
readonly nodes: CompactNode[];
|
|
2767
|
+
};
|
|
2730
2768
|
/**
|
|
2731
2769
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
2732
2770
|
* a change occurred in the Storage document.
|
|
@@ -5182,4 +5220,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5182
5220
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5183
5221
|
};
|
|
5184
5222
|
|
|
5185
|
-
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
|
|
5223
|
+
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 CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, 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 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 StorageChunkServerMsg, 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, nodeStreamToCompactNodes, 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.13.0-
|
|
9
|
+
var PKG_VERSION = "3.13.0-vincent2";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3090,7 +3090,10 @@ var ServerMsgCode = Object.freeze({
|
|
|
3090
3090
|
BROADCASTED_EVENT: 103,
|
|
3091
3091
|
ROOM_STATE: 104,
|
|
3092
3092
|
// For Storage
|
|
3093
|
-
|
|
3093
|
+
STORAGE_STATE_V7: 200,
|
|
3094
|
+
// Only sent in V7
|
|
3095
|
+
STORAGE_CHUNK: 210,
|
|
3096
|
+
// Used in V8+
|
|
3094
3097
|
UPDATE_STORAGE: 201,
|
|
3095
3098
|
// For Yjs Docs
|
|
3096
3099
|
UPDATE_YDOC: 300,
|
|
@@ -5922,9 +5925,7 @@ var OpCode = Object.freeze({
|
|
|
5922
5925
|
DELETE_CRDT: 5,
|
|
5923
5926
|
DELETE_OBJECT_KEY: 6,
|
|
5924
5927
|
CREATE_MAP: 7,
|
|
5925
|
-
CREATE_REGISTER: 8
|
|
5926
|
-
ACK: 9
|
|
5927
|
-
// Will only appear in v8+
|
|
5928
|
+
CREATE_REGISTER: 8
|
|
5928
5929
|
});
|
|
5929
5930
|
function isAckOp(op) {
|
|
5930
5931
|
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
@@ -6142,6 +6143,57 @@ var CrdtType = Object.freeze({
|
|
|
6142
6143
|
MAP: 2,
|
|
6143
6144
|
REGISTER: 3
|
|
6144
6145
|
});
|
|
6146
|
+
function isRootNode(node) {
|
|
6147
|
+
return node[0] === "root";
|
|
6148
|
+
}
|
|
6149
|
+
function isRootCrdt(id, _) {
|
|
6150
|
+
return id === "root";
|
|
6151
|
+
}
|
|
6152
|
+
function* compactNodesToNodeStream(nodes) {
|
|
6153
|
+
for (const node of nodes) {
|
|
6154
|
+
const id = node[0];
|
|
6155
|
+
if (isRootNode(node)) {
|
|
6156
|
+
yield [id, { type: CrdtType.OBJECT, data: node[1] }];
|
|
6157
|
+
continue;
|
|
6158
|
+
}
|
|
6159
|
+
switch (node[1]) {
|
|
6160
|
+
case CrdtType.OBJECT:
|
|
6161
|
+
yield [id, { type: CrdtType.OBJECT, parentId: node[2], parentKey: node[3], data: node[4] }];
|
|
6162
|
+
break;
|
|
6163
|
+
case CrdtType.LIST:
|
|
6164
|
+
yield [id, { type: CrdtType.LIST, parentId: node[2], parentKey: node[3] }];
|
|
6165
|
+
break;
|
|
6166
|
+
case CrdtType.MAP:
|
|
6167
|
+
yield [id, { type: CrdtType.MAP, parentId: node[2], parentKey: node[3] }];
|
|
6168
|
+
break;
|
|
6169
|
+
case CrdtType.REGISTER:
|
|
6170
|
+
yield [id, { type: CrdtType.REGISTER, parentId: node[2], parentKey: node[3], data: node[4] }];
|
|
6171
|
+
break;
|
|
6172
|
+
}
|
|
6173
|
+
}
|
|
6174
|
+
}
|
|
6175
|
+
function* nodeStreamToCompactNodes(nodes) {
|
|
6176
|
+
for (const [id, node] of nodes) {
|
|
6177
|
+
switch (node.type) {
|
|
6178
|
+
case CrdtType.OBJECT:
|
|
6179
|
+
if (isRootCrdt(id, node)) {
|
|
6180
|
+
yield [id, node.data];
|
|
6181
|
+
} else {
|
|
6182
|
+
yield [id, CrdtType.OBJECT, node.parentId, node.parentKey, node.data];
|
|
6183
|
+
}
|
|
6184
|
+
break;
|
|
6185
|
+
case CrdtType.LIST:
|
|
6186
|
+
yield [id, CrdtType.LIST, node.parentId, node.parentKey];
|
|
6187
|
+
break;
|
|
6188
|
+
case CrdtType.MAP:
|
|
6189
|
+
yield [id, CrdtType.MAP, node.parentId, node.parentKey];
|
|
6190
|
+
break;
|
|
6191
|
+
case CrdtType.REGISTER:
|
|
6192
|
+
yield [id, CrdtType.REGISTER, node.parentId, node.parentKey, node.data];
|
|
6193
|
+
break;
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
}
|
|
6145
6197
|
|
|
6146
6198
|
// src/crdts/LiveRegister.ts
|
|
6147
6199
|
var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
@@ -7576,7 +7628,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7576
7628
|
|
|
7577
7629
|
// src/crdts/LiveObject.ts
|
|
7578
7630
|
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
7579
|
-
function
|
|
7631
|
+
function isRootCrdt2(id, _) {
|
|
7580
7632
|
return id === "root";
|
|
7581
7633
|
}
|
|
7582
7634
|
var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
@@ -7596,7 +7648,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7596
7648
|
const parentToChildren = /* @__PURE__ */ new Map();
|
|
7597
7649
|
let root = null;
|
|
7598
7650
|
for (const [id, crdt] of items) {
|
|
7599
|
-
if (
|
|
7651
|
+
if (isRootCrdt2(id, crdt)) {
|
|
7600
7652
|
root = crdt;
|
|
7601
7653
|
} else {
|
|
7602
7654
|
const tuple = [id, crdt];
|
|
@@ -7614,8 +7666,8 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7614
7666
|
return [root, parentToChildren];
|
|
7615
7667
|
}
|
|
7616
7668
|
/** @private Do not use this API directly */
|
|
7617
|
-
static _fromItems(
|
|
7618
|
-
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(
|
|
7669
|
+
static _fromItems(nodes, pool) {
|
|
7670
|
+
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(nodes);
|
|
7619
7671
|
return _LiveObject._deserialize(
|
|
7620
7672
|
["root", root],
|
|
7621
7673
|
parentToChildren,
|
|
@@ -8234,10 +8286,7 @@ function getTreesDiffOperations(currentItems, newItems) {
|
|
|
8234
8286
|
const ops = [];
|
|
8235
8287
|
currentItems.forEach((_, id) => {
|
|
8236
8288
|
if (!newItems.get(id)) {
|
|
8237
|
-
ops.push({
|
|
8238
|
-
type: OpCode.DELETE_CRDT,
|
|
8239
|
-
id
|
|
8240
|
-
});
|
|
8289
|
+
ops.push({ type: OpCode.DELETE_CRDT, id });
|
|
8241
8290
|
}
|
|
8242
8291
|
});
|
|
8243
8292
|
newItems.forEach((crdt, id) => {
|
|
@@ -8735,6 +8784,21 @@ function installBackgroundTabSpy() {
|
|
|
8735
8784
|
};
|
|
8736
8785
|
return [inBackgroundSince, unsub];
|
|
8737
8786
|
}
|
|
8787
|
+
function makePartialNodeMap() {
|
|
8788
|
+
let map = /* @__PURE__ */ new Map();
|
|
8789
|
+
return {
|
|
8790
|
+
append(chunk2) {
|
|
8791
|
+
for (const [id, node] of chunk2) {
|
|
8792
|
+
map.set(id, node);
|
|
8793
|
+
}
|
|
8794
|
+
},
|
|
8795
|
+
clear() {
|
|
8796
|
+
const result = map;
|
|
8797
|
+
map = /* @__PURE__ */ new Map();
|
|
8798
|
+
return result;
|
|
8799
|
+
}
|
|
8800
|
+
};
|
|
8801
|
+
}
|
|
8738
8802
|
function createRoom(options, config) {
|
|
8739
8803
|
const roomId = config.roomId;
|
|
8740
8804
|
const initialPresence = options.initialPresence;
|
|
@@ -8795,6 +8859,7 @@ function createRoom(options, config) {
|
|
|
8795
8859
|
activeBatch: null,
|
|
8796
8860
|
unacknowledgedOps: /* @__PURE__ */ new Map()
|
|
8797
8861
|
};
|
|
8862
|
+
const partialNodes = makePartialNodeMap();
|
|
8798
8863
|
let lastTokenKey;
|
|
8799
8864
|
function onStatusDidChange(newStatus) {
|
|
8800
8865
|
const authValue = managedSocket.authValue;
|
|
@@ -9076,14 +9141,11 @@ function createRoom(options, config) {
|
|
|
9076
9141
|
self,
|
|
9077
9142
|
(me) => me !== null ? userToTreeNode("Me", me) : null
|
|
9078
9143
|
);
|
|
9079
|
-
function createOrUpdateRootFromMessage(
|
|
9080
|
-
if (message.items.length === 0) {
|
|
9081
|
-
throw new Error("Internal error: cannot load storage without items");
|
|
9082
|
-
}
|
|
9144
|
+
function createOrUpdateRootFromMessage(nodes) {
|
|
9083
9145
|
if (context.root !== void 0) {
|
|
9084
|
-
updateRoot(
|
|
9146
|
+
updateRoot(new Map(nodes));
|
|
9085
9147
|
} else {
|
|
9086
|
-
context.root = LiveObject._fromItems(
|
|
9148
|
+
context.root = LiveObject._fromItems(nodes, context.pool);
|
|
9087
9149
|
}
|
|
9088
9150
|
const canWrite = self.get()?.canWrite ?? true;
|
|
9089
9151
|
const stackSizeBefore = context.undoStack.length;
|
|
@@ -9100,7 +9162,10 @@ function createRoom(options, config) {
|
|
|
9100
9162
|
}
|
|
9101
9163
|
context.undoStack.length = stackSizeBefore;
|
|
9102
9164
|
}
|
|
9103
|
-
function updateRoot(
|
|
9165
|
+
function updateRoot(nodes) {
|
|
9166
|
+
if (nodes.size === 0) {
|
|
9167
|
+
throw new Error("Internal error: cannot load storage without items");
|
|
9168
|
+
}
|
|
9104
9169
|
if (context.root === void 0) {
|
|
9105
9170
|
return;
|
|
9106
9171
|
}
|
|
@@ -9108,7 +9173,7 @@ function createRoom(options, config) {
|
|
|
9108
9173
|
for (const [id, node] of context.pool.nodes) {
|
|
9109
9174
|
currentItems.set(id, node._serialize());
|
|
9110
9175
|
}
|
|
9111
|
-
const ops = getTreesDiffOperations(currentItems,
|
|
9176
|
+
const ops = getTreesDiffOperations(currentItems, nodes);
|
|
9112
9177
|
const result = applyOps(
|
|
9113
9178
|
ops,
|
|
9114
9179
|
/* isLocal */
|
|
@@ -9475,8 +9540,11 @@ function createRoom(options, config) {
|
|
|
9475
9540
|
updates.others.push(onRoomStateMessage(message));
|
|
9476
9541
|
break;
|
|
9477
9542
|
}
|
|
9478
|
-
case ServerMsgCode.
|
|
9479
|
-
|
|
9543
|
+
case ServerMsgCode.STORAGE_CHUNK: {
|
|
9544
|
+
partialNodes.append(compactNodesToNodeStream(message.nodes));
|
|
9545
|
+
if (message.done) {
|
|
9546
|
+
processInitialStorage(partialNodes.clear());
|
|
9547
|
+
}
|
|
9480
9548
|
break;
|
|
9481
9549
|
}
|
|
9482
9550
|
case ServerMsgCode.UPDATE_STORAGE: {
|
|
@@ -9521,6 +9589,8 @@ function createRoom(options, config) {
|
|
|
9521
9589
|
eventHub.comments.notify(message);
|
|
9522
9590
|
break;
|
|
9523
9591
|
}
|
|
9592
|
+
case ServerMsgCode.STORAGE_STATE_V7:
|
|
9593
|
+
// No longer used in V8
|
|
9524
9594
|
default:
|
|
9525
9595
|
break;
|
|
9526
9596
|
}
|
|
@@ -9622,9 +9692,9 @@ function createRoom(options, config) {
|
|
|
9622
9692
|
}
|
|
9623
9693
|
let _getStorage$ = null;
|
|
9624
9694
|
let _resolveStoragePromise = null;
|
|
9625
|
-
function processInitialStorage(
|
|
9695
|
+
function processInitialStorage(nodes) {
|
|
9626
9696
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
9627
|
-
createOrUpdateRootFromMessage(
|
|
9697
|
+
createOrUpdateRootFromMessage(nodes);
|
|
9628
9698
|
applyAndSendOps(unacknowledgedOps);
|
|
9629
9699
|
_resolveStoragePromise?.();
|
|
9630
9700
|
notifyStorageStatus();
|
|
@@ -9632,8 +9702,8 @@ function createRoom(options, config) {
|
|
|
9632
9702
|
}
|
|
9633
9703
|
async function streamStorage() {
|
|
9634
9704
|
if (!managedSocket.authValue) return;
|
|
9635
|
-
const
|
|
9636
|
-
processInitialStorage(
|
|
9705
|
+
const nodes = new Map(await httpClient.streamStorage({ roomId }));
|
|
9706
|
+
processInitialStorage(nodes);
|
|
9637
9707
|
}
|
|
9638
9708
|
function refreshStorage(options2) {
|
|
9639
9709
|
const messages = context.buffer.messages;
|
|
@@ -9641,6 +9711,7 @@ function createRoom(options, config) {
|
|
|
9641
9711
|
void streamStorage();
|
|
9642
9712
|
} else if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
9643
9713
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
9714
|
+
partialNodes.clear();
|
|
9644
9715
|
}
|
|
9645
9716
|
if (options2.flush) {
|
|
9646
9717
|
flushNowOrSoon();
|
|
@@ -10230,7 +10301,7 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill, eng
|
|
|
10230
10301
|
}
|
|
10231
10302
|
const url2 = new URL(baseUrl);
|
|
10232
10303
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
10233
|
-
url2.pathname = "/
|
|
10304
|
+
url2.pathname = "/v8";
|
|
10234
10305
|
url2.searchParams.set("roomId", roomId);
|
|
10235
10306
|
if (authValue.type === "secret") {
|
|
10236
10307
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
@@ -11529,6 +11600,7 @@ export {
|
|
|
11529
11600
|
memoizeOnSuccess,
|
|
11530
11601
|
nanoid,
|
|
11531
11602
|
nn,
|
|
11603
|
+
nodeStreamToCompactNodes,
|
|
11532
11604
|
objectToQuery,
|
|
11533
11605
|
patchLiveObjectKey,
|
|
11534
11606
|
patchNotificationSettings,
|