@liveblocks/core 3.20.0-exp1 → 3.20.0-exp3
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 +30 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -17
- package/dist/index.d.ts +14 -17
- package/dist/index.js +30 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -443,11 +443,9 @@ declare namespace OpCode {
|
|
|
443
443
|
type CREATE_TEXT = typeof OpCode.CREATE_TEXT;
|
|
444
444
|
type UPDATE_TEXT = typeof OpCode.UPDATE_TEXT;
|
|
445
445
|
}
|
|
446
|
-
type TextAttributes =
|
|
447
|
-
type
|
|
448
|
-
|
|
449
|
-
attributes?: TextAttributes;
|
|
450
|
-
}[];
|
|
446
|
+
type TextAttributes = JsonObject;
|
|
447
|
+
type LiveTextSegment = [text: string] | [text: string, attributes: TextAttributes];
|
|
448
|
+
type LiveTextData = LiveTextSegment[];
|
|
451
449
|
type TextOperation = {
|
|
452
450
|
type: "insert";
|
|
453
451
|
index: number;
|
|
@@ -461,7 +459,7 @@ type TextOperation = {
|
|
|
461
459
|
type: "format";
|
|
462
460
|
index: number;
|
|
463
461
|
length: number;
|
|
464
|
-
attributes:
|
|
462
|
+
attributes: JsonObject;
|
|
465
463
|
};
|
|
466
464
|
/**
|
|
467
465
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
@@ -521,7 +519,7 @@ type CreateTextOp = {
|
|
|
521
519
|
readonly type: OpCode.CREATE_TEXT;
|
|
522
520
|
readonly parentId: string;
|
|
523
521
|
readonly parentKey: string;
|
|
524
|
-
readonly data:
|
|
522
|
+
readonly data: LiveTextData;
|
|
525
523
|
readonly version: number;
|
|
526
524
|
};
|
|
527
525
|
type UpdateTextOp = {
|
|
@@ -704,7 +702,7 @@ type SerializedText = {
|
|
|
704
702
|
readonly type: CrdtType.TEXT;
|
|
705
703
|
readonly parentId: string;
|
|
706
704
|
readonly parentKey: string;
|
|
707
|
-
readonly data:
|
|
705
|
+
readonly data: LiveTextData;
|
|
708
706
|
readonly version: number;
|
|
709
707
|
};
|
|
710
708
|
type StorageNode = RootStorageNode | ChildStorageNode;
|
|
@@ -757,7 +755,7 @@ type CompactTextNode = readonly [
|
|
|
757
755
|
type: CrdtType.TEXT,
|
|
758
756
|
parentId: string,
|
|
759
757
|
parentKey: string,
|
|
760
|
-
data:
|
|
758
|
+
data: LiveTextData,
|
|
761
759
|
version: number
|
|
762
760
|
];
|
|
763
761
|
declare function compactNodesToNodeStream(compactNodes: CompactNode[]): NodeStream;
|
|
@@ -917,10 +915,10 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
917
915
|
clone(): LiveObject<O>;
|
|
918
916
|
}
|
|
919
917
|
|
|
920
|
-
declare function applyLiveTextOperations(
|
|
918
|
+
declare function applyLiveTextOperations(data: LiveTextData, ops: readonly TextOperation[]): LiveTextData;
|
|
921
919
|
|
|
922
920
|
type LiveTextAttributes = TextAttributes;
|
|
923
|
-
type LiveTextAttributesPatch =
|
|
921
|
+
type LiveTextAttributesPatch = JsonObject;
|
|
924
922
|
|
|
925
923
|
type LiveTextChange = {
|
|
926
924
|
readonly type: "insert";
|
|
@@ -947,7 +945,7 @@ type LiveTextUpdates = {
|
|
|
947
945
|
|
|
948
946
|
declare class LiveText extends AbstractCrdt {
|
|
949
947
|
#private;
|
|
950
|
-
constructor(
|
|
948
|
+
constructor(textOrData?: string | LiveTextData, version?: number);
|
|
951
949
|
get version(): number;
|
|
952
950
|
get length(): number;
|
|
953
951
|
insert(index: number, text: string, attributes?: TextAttributes): void;
|
|
@@ -955,8 +953,7 @@ declare class LiveText extends AbstractCrdt {
|
|
|
955
953
|
replace(index: number, length: number, text: string, attributes?: TextAttributes): void;
|
|
956
954
|
format(index: number, length: number, attributes: LiveTextAttributesPatch): void;
|
|
957
955
|
toString(): string;
|
|
958
|
-
|
|
959
|
-
toJSON(): LiveTextDelta;
|
|
956
|
+
toJSON(): LiveTextData;
|
|
960
957
|
clone(): LiveText;
|
|
961
958
|
}
|
|
962
959
|
|
|
@@ -1247,7 +1244,7 @@ type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Ls
|
|
|
1247
1244
|
readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
|
|
1248
1245
|
} : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
|
|
1249
1246
|
readonly [K in KS]: ToJson<V>;
|
|
1250
|
-
} : L extends LiveText ?
|
|
1247
|
+
} : L extends LiveText ? LiveTextData : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
|
|
1251
1248
|
readonly [K in keyof L]: ToJson<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
|
|
1252
1249
|
} : L extends Json ? L : never;
|
|
1253
1250
|
|
|
@@ -5098,7 +5095,7 @@ type PlainLsonList = {
|
|
|
5098
5095
|
};
|
|
5099
5096
|
type PlainLsonText = {
|
|
5100
5097
|
liveblocksType: "LiveText";
|
|
5101
|
-
data:
|
|
5098
|
+
data: LiveTextData;
|
|
5102
5099
|
version?: number;
|
|
5103
5100
|
};
|
|
5104
5101
|
type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | PlainLsonText | Json;
|
|
@@ -5816,4 +5813,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5816
5813
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5817
5814
|
};
|
|
5818
5815
|
|
|
5819
|
-
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 CompactTextNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CreateTextOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, 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 Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, 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, LiveText, type LiveTextAttributes, type LiveTextAttributesPatch, type LiveTextChange, type
|
|
5816
|
+
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 CompactTextNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CreateTextOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, 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 Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, 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, LiveText, type LiveTextAttributes, type LiveTextAttributesPatch, type LiveTextChange, type LiveTextData, type TextOperation as LiveTextOperation, type LiveTextSegment, type LiveTextUpdate, type LiveTextUpdates, 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 PlainLsonText, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, 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 SerializedText, 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 SyncConfig, type SyncMode, type SyncSource, type SyncStatus, type TextAttributes, TextEditorType, type TextOperation, type TextStorageNode, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateTextOp, 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, applyLiveTextOperations, 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, isTextStorageNode, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, nodeStreamToCompactNodes, objectToQuery, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -443,11 +443,9 @@ declare namespace OpCode {
|
|
|
443
443
|
type CREATE_TEXT = typeof OpCode.CREATE_TEXT;
|
|
444
444
|
type UPDATE_TEXT = typeof OpCode.UPDATE_TEXT;
|
|
445
445
|
}
|
|
446
|
-
type TextAttributes =
|
|
447
|
-
type
|
|
448
|
-
|
|
449
|
-
attributes?: TextAttributes;
|
|
450
|
-
}[];
|
|
446
|
+
type TextAttributes = JsonObject;
|
|
447
|
+
type LiveTextSegment = [text: string] | [text: string, attributes: TextAttributes];
|
|
448
|
+
type LiveTextData = LiveTextSegment[];
|
|
451
449
|
type TextOperation = {
|
|
452
450
|
type: "insert";
|
|
453
451
|
index: number;
|
|
@@ -461,7 +459,7 @@ type TextOperation = {
|
|
|
461
459
|
type: "format";
|
|
462
460
|
index: number;
|
|
463
461
|
length: number;
|
|
464
|
-
attributes:
|
|
462
|
+
attributes: JsonObject;
|
|
465
463
|
};
|
|
466
464
|
/**
|
|
467
465
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
@@ -521,7 +519,7 @@ type CreateTextOp = {
|
|
|
521
519
|
readonly type: OpCode.CREATE_TEXT;
|
|
522
520
|
readonly parentId: string;
|
|
523
521
|
readonly parentKey: string;
|
|
524
|
-
readonly data:
|
|
522
|
+
readonly data: LiveTextData;
|
|
525
523
|
readonly version: number;
|
|
526
524
|
};
|
|
527
525
|
type UpdateTextOp = {
|
|
@@ -704,7 +702,7 @@ type SerializedText = {
|
|
|
704
702
|
readonly type: CrdtType.TEXT;
|
|
705
703
|
readonly parentId: string;
|
|
706
704
|
readonly parentKey: string;
|
|
707
|
-
readonly data:
|
|
705
|
+
readonly data: LiveTextData;
|
|
708
706
|
readonly version: number;
|
|
709
707
|
};
|
|
710
708
|
type StorageNode = RootStorageNode | ChildStorageNode;
|
|
@@ -757,7 +755,7 @@ type CompactTextNode = readonly [
|
|
|
757
755
|
type: CrdtType.TEXT,
|
|
758
756
|
parentId: string,
|
|
759
757
|
parentKey: string,
|
|
760
|
-
data:
|
|
758
|
+
data: LiveTextData,
|
|
761
759
|
version: number
|
|
762
760
|
];
|
|
763
761
|
declare function compactNodesToNodeStream(compactNodes: CompactNode[]): NodeStream;
|
|
@@ -917,10 +915,10 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
917
915
|
clone(): LiveObject<O>;
|
|
918
916
|
}
|
|
919
917
|
|
|
920
|
-
declare function applyLiveTextOperations(
|
|
918
|
+
declare function applyLiveTextOperations(data: LiveTextData, ops: readonly TextOperation[]): LiveTextData;
|
|
921
919
|
|
|
922
920
|
type LiveTextAttributes = TextAttributes;
|
|
923
|
-
type LiveTextAttributesPatch =
|
|
921
|
+
type LiveTextAttributesPatch = JsonObject;
|
|
924
922
|
|
|
925
923
|
type LiveTextChange = {
|
|
926
924
|
readonly type: "insert";
|
|
@@ -947,7 +945,7 @@ type LiveTextUpdates = {
|
|
|
947
945
|
|
|
948
946
|
declare class LiveText extends AbstractCrdt {
|
|
949
947
|
#private;
|
|
950
|
-
constructor(
|
|
948
|
+
constructor(textOrData?: string | LiveTextData, version?: number);
|
|
951
949
|
get version(): number;
|
|
952
950
|
get length(): number;
|
|
953
951
|
insert(index: number, text: string, attributes?: TextAttributes): void;
|
|
@@ -955,8 +953,7 @@ declare class LiveText extends AbstractCrdt {
|
|
|
955
953
|
replace(index: number, length: number, text: string, attributes?: TextAttributes): void;
|
|
956
954
|
format(index: number, length: number, attributes: LiveTextAttributesPatch): void;
|
|
957
955
|
toString(): string;
|
|
958
|
-
|
|
959
|
-
toJSON(): LiveTextDelta;
|
|
956
|
+
toJSON(): LiveTextData;
|
|
960
957
|
clone(): LiveText;
|
|
961
958
|
}
|
|
962
959
|
|
|
@@ -1247,7 +1244,7 @@ type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Ls
|
|
|
1247
1244
|
readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
|
|
1248
1245
|
} : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
|
|
1249
1246
|
readonly [K in KS]: ToJson<V>;
|
|
1250
|
-
} : L extends LiveText ?
|
|
1247
|
+
} : L extends LiveText ? LiveTextData : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
|
|
1251
1248
|
readonly [K in keyof L]: ToJson<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
|
|
1252
1249
|
} : L extends Json ? L : never;
|
|
1253
1250
|
|
|
@@ -5098,7 +5095,7 @@ type PlainLsonList = {
|
|
|
5098
5095
|
};
|
|
5099
5096
|
type PlainLsonText = {
|
|
5100
5097
|
liveblocksType: "LiveText";
|
|
5101
|
-
data:
|
|
5098
|
+
data: LiveTextData;
|
|
5102
5099
|
version?: number;
|
|
5103
5100
|
};
|
|
5104
5101
|
type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | PlainLsonText | Json;
|
|
@@ -5816,4 +5813,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5816
5813
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5817
5814
|
};
|
|
5818
5815
|
|
|
5819
|
-
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 CompactTextNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CreateTextOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, 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 Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, 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, LiveText, type LiveTextAttributes, type LiveTextAttributesPatch, type LiveTextChange, type
|
|
5816
|
+
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 CompactTextNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CreateTextOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, 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 Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, 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, LiveText, type LiveTextAttributes, type LiveTextAttributesPatch, type LiveTextChange, type LiveTextData, type TextOperation as LiveTextOperation, type LiveTextSegment, type LiveTextUpdate, type LiveTextUpdates, 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 PlainLsonText, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, 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 SerializedText, 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 SyncConfig, type SyncMode, type SyncSource, type SyncStatus, type TextAttributes, TextEditorType, type TextOperation, type TextStorageNode, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateTextOp, 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, applyLiveTextOperations, 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, isTextStorageNode, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, nodeStreamToCompactNodes, objectToQuery, 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.20.0-
|
|
9
|
+
var PKG_VERSION = "3.20.0-exp3";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -8486,17 +8486,17 @@ function normalizeSegments(segments) {
|
|
|
8486
8486
|
}
|
|
8487
8487
|
return normalized;
|
|
8488
8488
|
}
|
|
8489
|
-
function
|
|
8489
|
+
function dataToSegments(data) {
|
|
8490
8490
|
return normalizeSegments(
|
|
8491
|
-
|
|
8492
|
-
text
|
|
8493
|
-
attributes
|
|
8491
|
+
data.map(([text, attributes]) => ({
|
|
8492
|
+
text,
|
|
8493
|
+
attributes
|
|
8494
8494
|
}))
|
|
8495
8495
|
);
|
|
8496
8496
|
}
|
|
8497
|
-
function
|
|
8497
|
+
function segmentsToData(segments) {
|
|
8498
8498
|
return segments.map(
|
|
8499
|
-
(segment) => segment.attributes === void 0 ?
|
|
8499
|
+
(segment) => segment.attributes === void 0 ? [segment.text] : [segment.text, { ...segment.attributes }]
|
|
8500
8500
|
);
|
|
8501
8501
|
}
|
|
8502
8502
|
function textLength(segments) {
|
|
@@ -8703,8 +8703,10 @@ function applyTextOperationsToSegments(segments, ops) {
|
|
|
8703
8703
|
}
|
|
8704
8704
|
return next;
|
|
8705
8705
|
}
|
|
8706
|
-
function applyLiveTextOperations(
|
|
8707
|
-
return
|
|
8706
|
+
function applyLiveTextOperations(data, ops) {
|
|
8707
|
+
return segmentsToData(
|
|
8708
|
+
applyTextOperationsToSegments(dataToSegments(data), ops)
|
|
8709
|
+
);
|
|
8708
8710
|
}
|
|
8709
8711
|
function invertTextOperations(segments, ops) {
|
|
8710
8712
|
let shadow = [...segments];
|
|
@@ -8757,9 +8759,9 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
8757
8759
|
#segments;
|
|
8758
8760
|
#version;
|
|
8759
8761
|
#pendingOps;
|
|
8760
|
-
constructor(
|
|
8762
|
+
constructor(textOrData = "", version = 0) {
|
|
8761
8763
|
super();
|
|
8762
|
-
this.#segments = typeof
|
|
8764
|
+
this.#segments = typeof textOrData === "string" ? textOrData.length === 0 ? [] : [{ text: textOrData }] : dataToSegments(textOrData);
|
|
8763
8765
|
this.#version = version;
|
|
8764
8766
|
this.#pendingOps = /* @__PURE__ */ new Map();
|
|
8765
8767
|
}
|
|
@@ -8786,7 +8788,7 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
8786
8788
|
id: this._id,
|
|
8787
8789
|
parentId,
|
|
8788
8790
|
parentKey,
|
|
8789
|
-
data: this.
|
|
8791
|
+
data: this.toJSON(),
|
|
8790
8792
|
version: this.#version
|
|
8791
8793
|
}
|
|
8792
8794
|
];
|
|
@@ -8800,7 +8802,7 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
8800
8802
|
type: CrdtType.TEXT,
|
|
8801
8803
|
parentId: nn(this.parent.node._id, "Parent node expected to have ID"),
|
|
8802
8804
|
parentKey: this.parent.key,
|
|
8803
|
-
data: this.
|
|
8805
|
+
data: this.toJSON(),
|
|
8804
8806
|
version: this.#version
|
|
8805
8807
|
};
|
|
8806
8808
|
}
|
|
@@ -8991,15 +8993,12 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
8991
8993
|
toString() {
|
|
8992
8994
|
return this.#segments.map((segment) => segment.text).join("");
|
|
8993
8995
|
}
|
|
8994
|
-
toDelta() {
|
|
8995
|
-
return segmentsToDelta(this.#segments);
|
|
8996
|
-
}
|
|
8997
8996
|
toJSON() {
|
|
8998
8997
|
return super.toJSON();
|
|
8999
8998
|
}
|
|
9000
8999
|
/** @internal */
|
|
9001
9000
|
_toJSON() {
|
|
9002
|
-
return this
|
|
9001
|
+
return segmentsToData(this.#segments);
|
|
9003
9002
|
}
|
|
9004
9003
|
/** @internal */
|
|
9005
9004
|
_toTreeNode(key) {
|
|
@@ -9018,7 +9017,7 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
9018
9017
|
};
|
|
9019
9018
|
}
|
|
9020
9019
|
clone() {
|
|
9021
|
-
return new _LiveText(this.
|
|
9020
|
+
return new _LiveText(this.toJSON(), this.#version);
|
|
9022
9021
|
}
|
|
9023
9022
|
};
|
|
9024
9023
|
|
|
@@ -9222,22 +9221,24 @@ function getTreesDiffOperations(currentItems, newItems) {
|
|
|
9222
9221
|
type: "delete",
|
|
9223
9222
|
index: 0,
|
|
9224
9223
|
length: currentCrdt.type === CrdtType.TEXT ? currentCrdt.data.reduce(
|
|
9225
|
-
(sum,
|
|
9224
|
+
(sum, segment) => sum + segment[0].length,
|
|
9226
9225
|
0
|
|
9227
9226
|
) : 0
|
|
9228
9227
|
},
|
|
9229
|
-
...crdt.data.map(
|
|
9230
|
-
|
|
9228
|
+
...crdt.data.map((segment, index, items) => {
|
|
9229
|
+
const [text, attributes] = segment;
|
|
9230
|
+
const insertIndex = items.slice(0, index).reduce((sum, item) => sum + item[0].length, 0);
|
|
9231
|
+
return attributes === void 0 ? {
|
|
9231
9232
|
type: "insert",
|
|
9232
|
-
index:
|
|
9233
|
-
text
|
|
9233
|
+
index: insertIndex,
|
|
9234
|
+
text
|
|
9234
9235
|
} : {
|
|
9235
9236
|
type: "insert",
|
|
9236
|
-
index:
|
|
9237
|
-
text
|
|
9238
|
-
attributes
|
|
9239
|
-
}
|
|
9240
|
-
)
|
|
9237
|
+
index: insertIndex,
|
|
9238
|
+
text,
|
|
9239
|
+
attributes
|
|
9240
|
+
};
|
|
9241
|
+
})
|
|
9241
9242
|
]
|
|
9242
9243
|
});
|
|
9243
9244
|
}
|
|
@@ -12846,7 +12847,7 @@ function toPlainLson(lson) {
|
|
|
12846
12847
|
} else if (lson instanceof LiveText) {
|
|
12847
12848
|
return {
|
|
12848
12849
|
liveblocksType: "LiveText",
|
|
12849
|
-
data: lson.
|
|
12850
|
+
data: lson.toJSON(),
|
|
12850
12851
|
version: lson.version
|
|
12851
12852
|
};
|
|
12852
12853
|
} else {
|