@liveblocks/core 3.14.0-pre6 → 3.14.0-rc1
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 +86 -153
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -79
- package/dist/index.d.ts +72 -79
- package/dist/index.js +44 -111
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -519,77 +519,6 @@ type TheirOp = DistributiveOmit<Op, "opId"> & {
|
|
|
519
519
|
opId?: undefined;
|
|
520
520
|
};
|
|
521
521
|
|
|
522
|
-
type ClientMsgCode = (typeof ClientMsgCode)[keyof typeof ClientMsgCode];
|
|
523
|
-
declare const ClientMsgCode: Readonly<{
|
|
524
|
-
UPDATE_PRESENCE: 100;
|
|
525
|
-
BROADCAST_EVENT: 103;
|
|
526
|
-
FETCH_STORAGE: 200;
|
|
527
|
-
UPDATE_STORAGE: 201;
|
|
528
|
-
FETCH_YDOC: 300;
|
|
529
|
-
UPDATE_YDOC: 301;
|
|
530
|
-
}>;
|
|
531
|
-
declare namespace ClientMsgCode {
|
|
532
|
-
type UPDATE_PRESENCE = typeof ClientMsgCode.UPDATE_PRESENCE;
|
|
533
|
-
type BROADCAST_EVENT = typeof ClientMsgCode.BROADCAST_EVENT;
|
|
534
|
-
type FETCH_STORAGE = typeof ClientMsgCode.FETCH_STORAGE;
|
|
535
|
-
type UPDATE_STORAGE = typeof ClientMsgCode.UPDATE_STORAGE;
|
|
536
|
-
type FETCH_YDOC = typeof ClientMsgCode.FETCH_YDOC;
|
|
537
|
-
type UPDATE_YDOC = typeof ClientMsgCode.UPDATE_YDOC;
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Messages that can be sent from the client to the server.
|
|
541
|
-
*/
|
|
542
|
-
type ClientMsg<P extends JsonObject, E extends Json> = BroadcastEventClientMsg<E> | UpdatePresenceClientMsg<P> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
|
|
543
|
-
type BroadcastEventClientMsg<E extends Json> = {
|
|
544
|
-
type: ClientMsgCode.BROADCAST_EVENT;
|
|
545
|
-
event: E;
|
|
546
|
-
};
|
|
547
|
-
type UpdatePresenceClientMsg<P extends JsonObject> = {
|
|
548
|
-
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
549
|
-
/**
|
|
550
|
-
* Set this to any number to signify that this is a Full Presence™
|
|
551
|
-
* update, not a patch.
|
|
552
|
-
*
|
|
553
|
-
* The numeric value itself no longer has specific meaning. Historically,
|
|
554
|
-
* this field was intended so that clients could ignore these broadcasted
|
|
555
|
-
* full presence messages, but it turned out that getting a full presence
|
|
556
|
-
* "keyframe" from time to time was useful.
|
|
557
|
-
*
|
|
558
|
-
* So nowadays, the presence (pun intended) of this `targetActor` field
|
|
559
|
-
* is a backward-compatible way of expressing that the `data` contains
|
|
560
|
-
* all presence fields, and isn't a partial "patch".
|
|
561
|
-
*/
|
|
562
|
-
readonly targetActor: number;
|
|
563
|
-
readonly data: P;
|
|
564
|
-
} | {
|
|
565
|
-
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
566
|
-
/**
|
|
567
|
-
* Absence of the `targetActor` field signifies that this is a Partial
|
|
568
|
-
* Presence™ "patch".
|
|
569
|
-
*/
|
|
570
|
-
readonly targetActor?: undefined;
|
|
571
|
-
readonly data: Partial<P>;
|
|
572
|
-
};
|
|
573
|
-
type UpdateStorageClientMsg = {
|
|
574
|
-
readonly type: ClientMsgCode.UPDATE_STORAGE;
|
|
575
|
-
readonly ops: ClientWireOp[];
|
|
576
|
-
};
|
|
577
|
-
type FetchStorageClientMsg = {
|
|
578
|
-
readonly type: ClientMsgCode.FETCH_STORAGE;
|
|
579
|
-
};
|
|
580
|
-
type FetchYDocClientMsg = {
|
|
581
|
-
readonly type: ClientMsgCode.FETCH_YDOC;
|
|
582
|
-
readonly vector: string;
|
|
583
|
-
readonly guid?: string;
|
|
584
|
-
readonly v2?: boolean;
|
|
585
|
-
};
|
|
586
|
-
type UpdateYDocClientMsg = {
|
|
587
|
-
readonly type: ClientMsgCode.UPDATE_YDOC;
|
|
588
|
-
readonly update: string;
|
|
589
|
-
readonly guid?: string;
|
|
590
|
-
readonly v2?: boolean;
|
|
591
|
-
};
|
|
592
|
-
|
|
593
522
|
/**
|
|
594
523
|
* Represents an indefinitely deep arbitrary immutable data
|
|
595
524
|
* structure, as returned by the .toImmutable().
|
|
@@ -1900,11 +1829,6 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1900
1829
|
streamStorage(options: {
|
|
1901
1830
|
roomId: string;
|
|
1902
1831
|
}): Promise<StorageNode[]>;
|
|
1903
|
-
sendMessagesOverHTTP<P extends JsonObject, E extends Json>(options: {
|
|
1904
|
-
roomId: string;
|
|
1905
|
-
nonce: string | undefined;
|
|
1906
|
-
messages: ClientMsg<P, E>[];
|
|
1907
|
-
}): Promise<Response>;
|
|
1908
1832
|
executeContextualPrompt({ roomId, prompt, context, signal, }: {
|
|
1909
1833
|
roomId: string;
|
|
1910
1834
|
prompt: string;
|
|
@@ -2469,7 +2393,6 @@ type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
2469
2393
|
lostConnectionTimeout?: number;
|
|
2470
2394
|
backgroundKeepAliveTimeout?: number;
|
|
2471
2395
|
polyfills?: Polyfills;
|
|
2472
|
-
largeMessageStrategy?: LargeMessageStrategy;
|
|
2473
2396
|
/**
|
|
2474
2397
|
* @deprecated For new rooms, use `engine: 2` instead. Engine v2 rooms have
|
|
2475
2398
|
* native support for streaming. This flag will be removed in a future
|
|
@@ -2652,6 +2575,77 @@ type Delegates<T extends BaseAuthResult> = {
|
|
|
2652
2575
|
canZombie: () => boolean;
|
|
2653
2576
|
};
|
|
2654
2577
|
|
|
2578
|
+
type ClientMsgCode = (typeof ClientMsgCode)[keyof typeof ClientMsgCode];
|
|
2579
|
+
declare const ClientMsgCode: Readonly<{
|
|
2580
|
+
UPDATE_PRESENCE: 100;
|
|
2581
|
+
BROADCAST_EVENT: 103;
|
|
2582
|
+
FETCH_STORAGE: 200;
|
|
2583
|
+
UPDATE_STORAGE: 201;
|
|
2584
|
+
FETCH_YDOC: 300;
|
|
2585
|
+
UPDATE_YDOC: 301;
|
|
2586
|
+
}>;
|
|
2587
|
+
declare namespace ClientMsgCode {
|
|
2588
|
+
type UPDATE_PRESENCE = typeof ClientMsgCode.UPDATE_PRESENCE;
|
|
2589
|
+
type BROADCAST_EVENT = typeof ClientMsgCode.BROADCAST_EVENT;
|
|
2590
|
+
type FETCH_STORAGE = typeof ClientMsgCode.FETCH_STORAGE;
|
|
2591
|
+
type UPDATE_STORAGE = typeof ClientMsgCode.UPDATE_STORAGE;
|
|
2592
|
+
type FETCH_YDOC = typeof ClientMsgCode.FETCH_YDOC;
|
|
2593
|
+
type UPDATE_YDOC = typeof ClientMsgCode.UPDATE_YDOC;
|
|
2594
|
+
}
|
|
2595
|
+
/**
|
|
2596
|
+
* Messages that can be sent from the client to the server.
|
|
2597
|
+
*/
|
|
2598
|
+
type ClientMsg<P extends JsonObject, E extends Json> = BroadcastEventClientMsg<E> | UpdatePresenceClientMsg<P> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
|
|
2599
|
+
type BroadcastEventClientMsg<E extends Json> = {
|
|
2600
|
+
type: ClientMsgCode.BROADCAST_EVENT;
|
|
2601
|
+
event: E;
|
|
2602
|
+
};
|
|
2603
|
+
type UpdatePresenceClientMsg<P extends JsonObject> = {
|
|
2604
|
+
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
2605
|
+
/**
|
|
2606
|
+
* Set this to any number to signify that this is a Full Presence™
|
|
2607
|
+
* update, not a patch.
|
|
2608
|
+
*
|
|
2609
|
+
* The numeric value itself no longer has specific meaning. Historically,
|
|
2610
|
+
* this field was intended so that clients could ignore these broadcasted
|
|
2611
|
+
* full presence messages, but it turned out that getting a full presence
|
|
2612
|
+
* "keyframe" from time to time was useful.
|
|
2613
|
+
*
|
|
2614
|
+
* So nowadays, the presence (pun intended) of this `targetActor` field
|
|
2615
|
+
* is a backward-compatible way of expressing that the `data` contains
|
|
2616
|
+
* all presence fields, and isn't a partial "patch".
|
|
2617
|
+
*/
|
|
2618
|
+
readonly targetActor: number;
|
|
2619
|
+
readonly data: P;
|
|
2620
|
+
} | {
|
|
2621
|
+
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
2622
|
+
/**
|
|
2623
|
+
* Absence of the `targetActor` field signifies that this is a Partial
|
|
2624
|
+
* Presence™ "patch".
|
|
2625
|
+
*/
|
|
2626
|
+
readonly targetActor?: undefined;
|
|
2627
|
+
readonly data: Partial<P>;
|
|
2628
|
+
};
|
|
2629
|
+
type UpdateStorageClientMsg = {
|
|
2630
|
+
readonly type: ClientMsgCode.UPDATE_STORAGE;
|
|
2631
|
+
readonly ops: ClientWireOp[];
|
|
2632
|
+
};
|
|
2633
|
+
type FetchStorageClientMsg = {
|
|
2634
|
+
readonly type: ClientMsgCode.FETCH_STORAGE;
|
|
2635
|
+
};
|
|
2636
|
+
type FetchYDocClientMsg = {
|
|
2637
|
+
readonly type: ClientMsgCode.FETCH_YDOC;
|
|
2638
|
+
readonly vector: string;
|
|
2639
|
+
readonly guid?: string;
|
|
2640
|
+
readonly v2?: boolean;
|
|
2641
|
+
};
|
|
2642
|
+
type UpdateYDocClientMsg = {
|
|
2643
|
+
readonly type: ClientMsgCode.UPDATE_YDOC;
|
|
2644
|
+
readonly update: string;
|
|
2645
|
+
readonly guid?: string;
|
|
2646
|
+
readonly v2?: boolean;
|
|
2647
|
+
};
|
|
2648
|
+
|
|
2655
2649
|
type ServerMsgCode = (typeof ServerMsgCode)[keyof typeof ServerMsgCode];
|
|
2656
2650
|
declare const ServerMsgCode: Readonly<{
|
|
2657
2651
|
UPDATE_PRESENCE: 100;
|
|
@@ -3832,7 +3826,6 @@ type PartialUnless<C, T> = Record<string, never> extends C ? Partial<T> : [
|
|
|
3832
3826
|
type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ? OptionalTuple<T> : [
|
|
3833
3827
|
C
|
|
3834
3828
|
] extends [never] ? OptionalTuple<T> : T;
|
|
3835
|
-
type LargeMessageStrategy = "default" | "split" | "experimental-fallback-to-http";
|
|
3836
3829
|
|
|
3837
3830
|
type Cursor = Brand<string, "Cursor">;
|
|
3838
3831
|
type ChatId = string;
|
|
@@ -5327,4 +5320,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5327
5320
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5328
5321
|
};
|
|
5329
5322
|
|
|
5330
|
-
export { 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 ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, 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 DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, 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 HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, 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
|
|
5323
|
+
export { 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 ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, 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 DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, 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 HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, 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 LayerKey, type ListStorageNode, 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 MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, 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 RegisterStorageNode, 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 RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, 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, compactNodesToNodeStream, 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, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, 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
|
@@ -519,77 +519,6 @@ type TheirOp = DistributiveOmit<Op, "opId"> & {
|
|
|
519
519
|
opId?: undefined;
|
|
520
520
|
};
|
|
521
521
|
|
|
522
|
-
type ClientMsgCode = (typeof ClientMsgCode)[keyof typeof ClientMsgCode];
|
|
523
|
-
declare const ClientMsgCode: Readonly<{
|
|
524
|
-
UPDATE_PRESENCE: 100;
|
|
525
|
-
BROADCAST_EVENT: 103;
|
|
526
|
-
FETCH_STORAGE: 200;
|
|
527
|
-
UPDATE_STORAGE: 201;
|
|
528
|
-
FETCH_YDOC: 300;
|
|
529
|
-
UPDATE_YDOC: 301;
|
|
530
|
-
}>;
|
|
531
|
-
declare namespace ClientMsgCode {
|
|
532
|
-
type UPDATE_PRESENCE = typeof ClientMsgCode.UPDATE_PRESENCE;
|
|
533
|
-
type BROADCAST_EVENT = typeof ClientMsgCode.BROADCAST_EVENT;
|
|
534
|
-
type FETCH_STORAGE = typeof ClientMsgCode.FETCH_STORAGE;
|
|
535
|
-
type UPDATE_STORAGE = typeof ClientMsgCode.UPDATE_STORAGE;
|
|
536
|
-
type FETCH_YDOC = typeof ClientMsgCode.FETCH_YDOC;
|
|
537
|
-
type UPDATE_YDOC = typeof ClientMsgCode.UPDATE_YDOC;
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Messages that can be sent from the client to the server.
|
|
541
|
-
*/
|
|
542
|
-
type ClientMsg<P extends JsonObject, E extends Json> = BroadcastEventClientMsg<E> | UpdatePresenceClientMsg<P> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
|
|
543
|
-
type BroadcastEventClientMsg<E extends Json> = {
|
|
544
|
-
type: ClientMsgCode.BROADCAST_EVENT;
|
|
545
|
-
event: E;
|
|
546
|
-
};
|
|
547
|
-
type UpdatePresenceClientMsg<P extends JsonObject> = {
|
|
548
|
-
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
549
|
-
/**
|
|
550
|
-
* Set this to any number to signify that this is a Full Presence™
|
|
551
|
-
* update, not a patch.
|
|
552
|
-
*
|
|
553
|
-
* The numeric value itself no longer has specific meaning. Historically,
|
|
554
|
-
* this field was intended so that clients could ignore these broadcasted
|
|
555
|
-
* full presence messages, but it turned out that getting a full presence
|
|
556
|
-
* "keyframe" from time to time was useful.
|
|
557
|
-
*
|
|
558
|
-
* So nowadays, the presence (pun intended) of this `targetActor` field
|
|
559
|
-
* is a backward-compatible way of expressing that the `data` contains
|
|
560
|
-
* all presence fields, and isn't a partial "patch".
|
|
561
|
-
*/
|
|
562
|
-
readonly targetActor: number;
|
|
563
|
-
readonly data: P;
|
|
564
|
-
} | {
|
|
565
|
-
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
566
|
-
/**
|
|
567
|
-
* Absence of the `targetActor` field signifies that this is a Partial
|
|
568
|
-
* Presence™ "patch".
|
|
569
|
-
*/
|
|
570
|
-
readonly targetActor?: undefined;
|
|
571
|
-
readonly data: Partial<P>;
|
|
572
|
-
};
|
|
573
|
-
type UpdateStorageClientMsg = {
|
|
574
|
-
readonly type: ClientMsgCode.UPDATE_STORAGE;
|
|
575
|
-
readonly ops: ClientWireOp[];
|
|
576
|
-
};
|
|
577
|
-
type FetchStorageClientMsg = {
|
|
578
|
-
readonly type: ClientMsgCode.FETCH_STORAGE;
|
|
579
|
-
};
|
|
580
|
-
type FetchYDocClientMsg = {
|
|
581
|
-
readonly type: ClientMsgCode.FETCH_YDOC;
|
|
582
|
-
readonly vector: string;
|
|
583
|
-
readonly guid?: string;
|
|
584
|
-
readonly v2?: boolean;
|
|
585
|
-
};
|
|
586
|
-
type UpdateYDocClientMsg = {
|
|
587
|
-
readonly type: ClientMsgCode.UPDATE_YDOC;
|
|
588
|
-
readonly update: string;
|
|
589
|
-
readonly guid?: string;
|
|
590
|
-
readonly v2?: boolean;
|
|
591
|
-
};
|
|
592
|
-
|
|
593
522
|
/**
|
|
594
523
|
* Represents an indefinitely deep arbitrary immutable data
|
|
595
524
|
* structure, as returned by the .toImmutable().
|
|
@@ -1900,11 +1829,6 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1900
1829
|
streamStorage(options: {
|
|
1901
1830
|
roomId: string;
|
|
1902
1831
|
}): Promise<StorageNode[]>;
|
|
1903
|
-
sendMessagesOverHTTP<P extends JsonObject, E extends Json>(options: {
|
|
1904
|
-
roomId: string;
|
|
1905
|
-
nonce: string | undefined;
|
|
1906
|
-
messages: ClientMsg<P, E>[];
|
|
1907
|
-
}): Promise<Response>;
|
|
1908
1832
|
executeContextualPrompt({ roomId, prompt, context, signal, }: {
|
|
1909
1833
|
roomId: string;
|
|
1910
1834
|
prompt: string;
|
|
@@ -2469,7 +2393,6 @@ type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
2469
2393
|
lostConnectionTimeout?: number;
|
|
2470
2394
|
backgroundKeepAliveTimeout?: number;
|
|
2471
2395
|
polyfills?: Polyfills;
|
|
2472
|
-
largeMessageStrategy?: LargeMessageStrategy;
|
|
2473
2396
|
/**
|
|
2474
2397
|
* @deprecated For new rooms, use `engine: 2` instead. Engine v2 rooms have
|
|
2475
2398
|
* native support for streaming. This flag will be removed in a future
|
|
@@ -2652,6 +2575,77 @@ type Delegates<T extends BaseAuthResult> = {
|
|
|
2652
2575
|
canZombie: () => boolean;
|
|
2653
2576
|
};
|
|
2654
2577
|
|
|
2578
|
+
type ClientMsgCode = (typeof ClientMsgCode)[keyof typeof ClientMsgCode];
|
|
2579
|
+
declare const ClientMsgCode: Readonly<{
|
|
2580
|
+
UPDATE_PRESENCE: 100;
|
|
2581
|
+
BROADCAST_EVENT: 103;
|
|
2582
|
+
FETCH_STORAGE: 200;
|
|
2583
|
+
UPDATE_STORAGE: 201;
|
|
2584
|
+
FETCH_YDOC: 300;
|
|
2585
|
+
UPDATE_YDOC: 301;
|
|
2586
|
+
}>;
|
|
2587
|
+
declare namespace ClientMsgCode {
|
|
2588
|
+
type UPDATE_PRESENCE = typeof ClientMsgCode.UPDATE_PRESENCE;
|
|
2589
|
+
type BROADCAST_EVENT = typeof ClientMsgCode.BROADCAST_EVENT;
|
|
2590
|
+
type FETCH_STORAGE = typeof ClientMsgCode.FETCH_STORAGE;
|
|
2591
|
+
type UPDATE_STORAGE = typeof ClientMsgCode.UPDATE_STORAGE;
|
|
2592
|
+
type FETCH_YDOC = typeof ClientMsgCode.FETCH_YDOC;
|
|
2593
|
+
type UPDATE_YDOC = typeof ClientMsgCode.UPDATE_YDOC;
|
|
2594
|
+
}
|
|
2595
|
+
/**
|
|
2596
|
+
* Messages that can be sent from the client to the server.
|
|
2597
|
+
*/
|
|
2598
|
+
type ClientMsg<P extends JsonObject, E extends Json> = BroadcastEventClientMsg<E> | UpdatePresenceClientMsg<P> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
|
|
2599
|
+
type BroadcastEventClientMsg<E extends Json> = {
|
|
2600
|
+
type: ClientMsgCode.BROADCAST_EVENT;
|
|
2601
|
+
event: E;
|
|
2602
|
+
};
|
|
2603
|
+
type UpdatePresenceClientMsg<P extends JsonObject> = {
|
|
2604
|
+
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
2605
|
+
/**
|
|
2606
|
+
* Set this to any number to signify that this is a Full Presence™
|
|
2607
|
+
* update, not a patch.
|
|
2608
|
+
*
|
|
2609
|
+
* The numeric value itself no longer has specific meaning. Historically,
|
|
2610
|
+
* this field was intended so that clients could ignore these broadcasted
|
|
2611
|
+
* full presence messages, but it turned out that getting a full presence
|
|
2612
|
+
* "keyframe" from time to time was useful.
|
|
2613
|
+
*
|
|
2614
|
+
* So nowadays, the presence (pun intended) of this `targetActor` field
|
|
2615
|
+
* is a backward-compatible way of expressing that the `data` contains
|
|
2616
|
+
* all presence fields, and isn't a partial "patch".
|
|
2617
|
+
*/
|
|
2618
|
+
readonly targetActor: number;
|
|
2619
|
+
readonly data: P;
|
|
2620
|
+
} | {
|
|
2621
|
+
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
2622
|
+
/**
|
|
2623
|
+
* Absence of the `targetActor` field signifies that this is a Partial
|
|
2624
|
+
* Presence™ "patch".
|
|
2625
|
+
*/
|
|
2626
|
+
readonly targetActor?: undefined;
|
|
2627
|
+
readonly data: Partial<P>;
|
|
2628
|
+
};
|
|
2629
|
+
type UpdateStorageClientMsg = {
|
|
2630
|
+
readonly type: ClientMsgCode.UPDATE_STORAGE;
|
|
2631
|
+
readonly ops: ClientWireOp[];
|
|
2632
|
+
};
|
|
2633
|
+
type FetchStorageClientMsg = {
|
|
2634
|
+
readonly type: ClientMsgCode.FETCH_STORAGE;
|
|
2635
|
+
};
|
|
2636
|
+
type FetchYDocClientMsg = {
|
|
2637
|
+
readonly type: ClientMsgCode.FETCH_YDOC;
|
|
2638
|
+
readonly vector: string;
|
|
2639
|
+
readonly guid?: string;
|
|
2640
|
+
readonly v2?: boolean;
|
|
2641
|
+
};
|
|
2642
|
+
type UpdateYDocClientMsg = {
|
|
2643
|
+
readonly type: ClientMsgCode.UPDATE_YDOC;
|
|
2644
|
+
readonly update: string;
|
|
2645
|
+
readonly guid?: string;
|
|
2646
|
+
readonly v2?: boolean;
|
|
2647
|
+
};
|
|
2648
|
+
|
|
2655
2649
|
type ServerMsgCode = (typeof ServerMsgCode)[keyof typeof ServerMsgCode];
|
|
2656
2650
|
declare const ServerMsgCode: Readonly<{
|
|
2657
2651
|
UPDATE_PRESENCE: 100;
|
|
@@ -3832,7 +3826,6 @@ type PartialUnless<C, T> = Record<string, never> extends C ? Partial<T> : [
|
|
|
3832
3826
|
type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ? OptionalTuple<T> : [
|
|
3833
3827
|
C
|
|
3834
3828
|
] extends [never] ? OptionalTuple<T> : T;
|
|
3835
|
-
type LargeMessageStrategy = "default" | "split" | "experimental-fallback-to-http";
|
|
3836
3829
|
|
|
3837
3830
|
type Cursor = Brand<string, "Cursor">;
|
|
3838
3831
|
type ChatId = string;
|
|
@@ -5327,4 +5320,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5327
5320
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5328
5321
|
};
|
|
5329
5322
|
|
|
5330
|
-
export { 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 ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, 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 DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, 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 HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, 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
|
|
5323
|
+
export { 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 ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, 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 DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, 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 HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, 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 LayerKey, type ListStorageNode, 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 MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, 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 RegisterStorageNode, 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 RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, 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, compactNodesToNodeStream, 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, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, 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.14.0-
|
|
9
|
+
var PKG_VERSION = "3.14.0-rc1";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -2280,19 +2280,6 @@ function createApiClient({
|
|
|
2280
2280
|
);
|
|
2281
2281
|
return await result.json();
|
|
2282
2282
|
}
|
|
2283
|
-
async function sendMessagesOverHTTP(options) {
|
|
2284
|
-
return httpClient.rawPost(
|
|
2285
|
-
url`/v2/c/rooms/${options.roomId}/send-message`,
|
|
2286
|
-
await authManager.getAuthValue({
|
|
2287
|
-
requestedScope: "room:read",
|
|
2288
|
-
roomId: options.roomId
|
|
2289
|
-
}),
|
|
2290
|
-
{
|
|
2291
|
-
nonce: options.nonce,
|
|
2292
|
-
messages: options.messages
|
|
2293
|
-
}
|
|
2294
|
-
);
|
|
2295
|
-
}
|
|
2296
2283
|
async function getInboxNotifications(options) {
|
|
2297
2284
|
const PAGE_SIZE = 50;
|
|
2298
2285
|
let query;
|
|
@@ -2541,7 +2528,6 @@ function createApiClient({
|
|
|
2541
2528
|
getChatAttachmentUrl,
|
|
2542
2529
|
// Room storage
|
|
2543
2530
|
streamStorage,
|
|
2544
|
-
sendMessagesOverHTTP,
|
|
2545
2531
|
// Notifications
|
|
2546
2532
|
getInboxNotifications,
|
|
2547
2533
|
getInboxNotificationsSince,
|
|
@@ -8744,6 +8730,29 @@ function isJsonObject(data) {
|
|
|
8744
8730
|
return !isJsonScalar(data) && !isJsonArray(data);
|
|
8745
8731
|
}
|
|
8746
8732
|
|
|
8733
|
+
// src/lib/stopwatch.ts
|
|
8734
|
+
function makeStopWatch() {
|
|
8735
|
+
let startTime = 0;
|
|
8736
|
+
let lastLapTime = 0;
|
|
8737
|
+
let laps;
|
|
8738
|
+
function start() {
|
|
8739
|
+
laps = [];
|
|
8740
|
+
startTime = performance.now();
|
|
8741
|
+
lastLapTime = startTime;
|
|
8742
|
+
}
|
|
8743
|
+
function lap(now2 = performance.now()) {
|
|
8744
|
+
laps.push(now2 - lastLapTime);
|
|
8745
|
+
lastLapTime = now2;
|
|
8746
|
+
}
|
|
8747
|
+
function stop() {
|
|
8748
|
+
const endTime = performance.now();
|
|
8749
|
+
lap(endTime);
|
|
8750
|
+
const total = endTime - startTime;
|
|
8751
|
+
return { total, laps };
|
|
8752
|
+
}
|
|
8753
|
+
return { start, lap, stop };
|
|
8754
|
+
}
|
|
8755
|
+
|
|
8747
8756
|
// src/protocol/ClientMsg.ts
|
|
8748
8757
|
var ClientMsgCode = Object.freeze({
|
|
8749
8758
|
// For Presence
|
|
@@ -8996,7 +9005,6 @@ function defaultMessageFromContext(context) {
|
|
|
8996
9005
|
}
|
|
8997
9006
|
|
|
8998
9007
|
// src/room.ts
|
|
8999
|
-
var MAX_SOCKET_MESSAGE_SIZE = 1024 * 1024 - 512;
|
|
9000
9008
|
function makeIdFactory(connectionId) {
|
|
9001
9009
|
let count = 0;
|
|
9002
9010
|
return () => `${connectionId}:${count++}`;
|
|
@@ -9109,6 +9117,7 @@ function createRoom(options, config) {
|
|
|
9109
9117
|
unacknowledgedOps: /* @__PURE__ */ new Map()
|
|
9110
9118
|
};
|
|
9111
9119
|
const nodeMapBuffer = makeNodeMapBuffer();
|
|
9120
|
+
const stopwatch = config.enableDebugLogging ? makeStopWatch() : void 0;
|
|
9112
9121
|
let lastTokenKey;
|
|
9113
9122
|
function onStatusDidChange(newStatus) {
|
|
9114
9123
|
const authValue = managedSocket.authValue;
|
|
@@ -9263,100 +9272,8 @@ function createRoom(options, config) {
|
|
|
9263
9272
|
...options2
|
|
9264
9273
|
});
|
|
9265
9274
|
}
|
|
9266
|
-
function* chunkOps(msg) {
|
|
9267
|
-
const { ops, ...rest } = msg;
|
|
9268
|
-
if (ops.length < 2) {
|
|
9269
|
-
throw new Error("Cannot split ops into smaller chunks");
|
|
9270
|
-
}
|
|
9271
|
-
const mid = Math.floor(ops.length / 2);
|
|
9272
|
-
const firstHalf = ops.slice(0, mid);
|
|
9273
|
-
const secondHalf = ops.slice(mid);
|
|
9274
|
-
for (const halfOps of [firstHalf, secondHalf]) {
|
|
9275
|
-
const half = { ops: halfOps, ...rest };
|
|
9276
|
-
const text = stringifyOrLog([half]);
|
|
9277
|
-
if (!isTooBigForWebSocket(text)) {
|
|
9278
|
-
yield text;
|
|
9279
|
-
} else {
|
|
9280
|
-
yield* chunkOps(half);
|
|
9281
|
-
}
|
|
9282
|
-
}
|
|
9283
|
-
}
|
|
9284
|
-
function* chunkMessages(messages) {
|
|
9285
|
-
if (messages.length < 2) {
|
|
9286
|
-
if (messages[0].type === ClientMsgCode.UPDATE_STORAGE) {
|
|
9287
|
-
yield* chunkOps(messages[0]);
|
|
9288
|
-
return;
|
|
9289
|
-
} else {
|
|
9290
|
-
throw new Error(
|
|
9291
|
-
"Cannot split into chunks smaller than the allowed message size"
|
|
9292
|
-
);
|
|
9293
|
-
}
|
|
9294
|
-
}
|
|
9295
|
-
const mid = Math.floor(messages.length / 2);
|
|
9296
|
-
const firstHalf = messages.slice(0, mid);
|
|
9297
|
-
const secondHalf = messages.slice(mid);
|
|
9298
|
-
for (const half of [firstHalf, secondHalf]) {
|
|
9299
|
-
const text = stringifyOrLog(half);
|
|
9300
|
-
if (!isTooBigForWebSocket(text)) {
|
|
9301
|
-
yield text;
|
|
9302
|
-
} else {
|
|
9303
|
-
yield* chunkMessages(half);
|
|
9304
|
-
}
|
|
9305
|
-
}
|
|
9306
|
-
}
|
|
9307
|
-
function isTooBigForWebSocket(text) {
|
|
9308
|
-
if (text.length * 4 < MAX_SOCKET_MESSAGE_SIZE) {
|
|
9309
|
-
return false;
|
|
9310
|
-
}
|
|
9311
|
-
return new TextEncoder().encode(text).length >= MAX_SOCKET_MESSAGE_SIZE;
|
|
9312
|
-
}
|
|
9313
9275
|
function sendMessages(messages) {
|
|
9314
|
-
|
|
9315
|
-
const text = stringifyOrLog(messages);
|
|
9316
|
-
if (!isTooBigForWebSocket(text)) {
|
|
9317
|
-
return managedSocket.send(text);
|
|
9318
|
-
}
|
|
9319
|
-
switch (strategy) {
|
|
9320
|
-
case "default": {
|
|
9321
|
-
const type = "LARGE_MESSAGE_ERROR";
|
|
9322
|
-
const err = new LiveblocksError("Message is too large for websockets", {
|
|
9323
|
-
type
|
|
9324
|
-
});
|
|
9325
|
-
const didNotify = config.errorEventSource.notify(err);
|
|
9326
|
-
if (!didNotify) {
|
|
9327
|
-
error2(
|
|
9328
|
-
"Message is too large for websockets. Configure largeMessageStrategy option or useErrorListener to handle this."
|
|
9329
|
-
);
|
|
9330
|
-
}
|
|
9331
|
-
return;
|
|
9332
|
-
}
|
|
9333
|
-
case "split": {
|
|
9334
|
-
warn("Message is too large for websockets, splitting into smaller chunks");
|
|
9335
|
-
for (const chunk2 of chunkMessages(messages)) {
|
|
9336
|
-
managedSocket.send(chunk2);
|
|
9337
|
-
}
|
|
9338
|
-
return;
|
|
9339
|
-
}
|
|
9340
|
-
// NOTE: This strategy is experimental as it will not work in all situations.
|
|
9341
|
-
// It should only be used for broadcasting, presence updates, but isn't suitable
|
|
9342
|
-
// for Storage or Yjs updates yet (because through this channel the server does
|
|
9343
|
-
// not respond with acks or rejections, causing the client's reported status to
|
|
9344
|
-
// be stuck in "synchronizing" forever).
|
|
9345
|
-
case "experimental-fallback-to-http": {
|
|
9346
|
-
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
9347
|
-
const nonce = context.dynamicSessionInfoSig.get()?.nonce ?? raise("Session is not authorized to send message over HTTP");
|
|
9348
|
-
void httpClient.sendMessagesOverHTTP({ roomId, nonce, messages }).then((resp) => {
|
|
9349
|
-
if (!resp.ok && resp.status === 403) {
|
|
9350
|
-
managedSocket.reconnect();
|
|
9351
|
-
}
|
|
9352
|
-
}).catch((err) => {
|
|
9353
|
-
error2(
|
|
9354
|
-
`Failed to deliver message over HTTP: ${String(err)}`
|
|
9355
|
-
);
|
|
9356
|
-
});
|
|
9357
|
-
return;
|
|
9358
|
-
}
|
|
9359
|
-
}
|
|
9276
|
+
managedSocket.send(stringifyOrLog(messages));
|
|
9360
9277
|
}
|
|
9361
9278
|
const self = DerivedSignal.from(
|
|
9362
9279
|
context.staticSessionInfoSig,
|
|
@@ -9795,11 +9712,27 @@ function createRoom(options, config) {
|
|
|
9795
9712
|
break;
|
|
9796
9713
|
}
|
|
9797
9714
|
case ServerMsgCode.STORAGE_CHUNK:
|
|
9715
|
+
stopwatch?.lap();
|
|
9798
9716
|
nodeMapBuffer.append(compactNodesToNodeStream(message.nodes));
|
|
9799
9717
|
break;
|
|
9800
|
-
case ServerMsgCode.STORAGE_STREAM_END:
|
|
9718
|
+
case ServerMsgCode.STORAGE_STREAM_END: {
|
|
9719
|
+
const timing = stopwatch?.stop();
|
|
9720
|
+
if (timing) {
|
|
9721
|
+
const ms = (v) => `${v.toFixed(1)}ms`;
|
|
9722
|
+
const rest = timing.laps.slice(1);
|
|
9723
|
+
warn(
|
|
9724
|
+
`Storage chunk arrival: ${[
|
|
9725
|
+
`total=${ms(timing.total)}`,
|
|
9726
|
+
`first=${ms(timing.laps[0])}`,
|
|
9727
|
+
`rest.n=${rest.length}`,
|
|
9728
|
+
`rest.avg=${ms(rest.reduce((a, b) => a + b, 0) / rest.length)}`,
|
|
9729
|
+
`rest.max=${ms(rest.reduce((a, b) => Math.max(a, b), 0))}`
|
|
9730
|
+
].join(", ")}`
|
|
9731
|
+
);
|
|
9732
|
+
}
|
|
9801
9733
|
processInitialStorage(nodeMapBuffer.take());
|
|
9802
9734
|
break;
|
|
9735
|
+
}
|
|
9803
9736
|
case ServerMsgCode.UPDATE_STORAGE: {
|
|
9804
9737
|
const applyResult = applyRemoteOps(message.ops);
|
|
9805
9738
|
for (const [key, value] of applyResult.updates.storageUpdates) {
|
|
@@ -9964,6 +9897,7 @@ function createRoom(options, config) {
|
|
|
9964
9897
|
} else if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
9965
9898
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
9966
9899
|
nodeMapBuffer.take();
|
|
9900
|
+
stopwatch?.start();
|
|
9967
9901
|
}
|
|
9968
9902
|
if (options2.flush) {
|
|
9969
9903
|
flushNowOrSoon();
|
|
@@ -10694,7 +10628,6 @@ function createClient(options) {
|
|
|
10694
10628
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
10695
10629
|
baseUrl,
|
|
10696
10630
|
errorEventSource: liveblocksErrorSource,
|
|
10697
|
-
largeMessageStrategy: clientOptions.largeMessageStrategy,
|
|
10698
10631
|
unstable_streamData: !!clientOptions.unstable_streamData,
|
|
10699
10632
|
roomHttpClient: httpClient,
|
|
10700
10633
|
createSyncSource,
|