@liveblocks/core 2.21.0-emails3 → 2.22.0
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 +159 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +116 -41
- package/dist/index.d.ts +116 -41
- package/dist/index.js +88 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -592,6 +592,58 @@ type LiveListUpdate = LiveListUpdates<Lson>;
|
|
|
592
592
|
*/
|
|
593
593
|
type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
|
|
594
594
|
|
|
595
|
+
/**
|
|
596
|
+
* The managed pool is a namespace registry (i.e. a context) that "owns" all
|
|
597
|
+
* the individual live nodes, ensuring each one has a unique ID, and holding on
|
|
598
|
+
* to live nodes before and after they are inter-connected.
|
|
599
|
+
*/
|
|
600
|
+
interface ManagedPool {
|
|
601
|
+
readonly roomId: string;
|
|
602
|
+
readonly nodes: ReadonlyMap<string, LiveNode>;
|
|
603
|
+
readonly generateId: () => string;
|
|
604
|
+
readonly generateOpId: () => string;
|
|
605
|
+
readonly getNode: (id: string) => LiveNode | undefined;
|
|
606
|
+
readonly addNode: (id: string, node: LiveNode) => void;
|
|
607
|
+
readonly deleteNode: (id: string) => void;
|
|
608
|
+
/**
|
|
609
|
+
* Dispatching has three responsibilities:
|
|
610
|
+
* - Sends serialized ops to the WebSocket servers
|
|
611
|
+
* - Add reverse operations to the undo/redo stack
|
|
612
|
+
* - Notify room subscribers with updates (in-client, no networking)
|
|
613
|
+
*/
|
|
614
|
+
dispatch: (ops: Op[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
|
|
615
|
+
/**
|
|
616
|
+
* Ensures storage can be written to else throws an error.
|
|
617
|
+
* This is used to prevent writing to storage when the user does not have
|
|
618
|
+
* permission to do so.
|
|
619
|
+
* @throws {Error} if storage is not writable
|
|
620
|
+
* @returns {void}
|
|
621
|
+
*/
|
|
622
|
+
assertStorageIsWritable: () => void;
|
|
623
|
+
}
|
|
624
|
+
type CreateManagedPoolOptions = {
|
|
625
|
+
/**
|
|
626
|
+
* Returns the current connection ID. This is used to generate unique
|
|
627
|
+
* prefixes for nodes created by this client. This number is allowed to
|
|
628
|
+
* change over time (for example, when the client reconnects).
|
|
629
|
+
*/
|
|
630
|
+
getCurrentConnectionId(): number;
|
|
631
|
+
/**
|
|
632
|
+
* Will get invoked when any Live structure calls .dispatch() on the pool.
|
|
633
|
+
*/
|
|
634
|
+
onDispatch?: (ops: Op[], reverse: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
|
|
635
|
+
/**
|
|
636
|
+
* Will get invoked when any Live structure calls .assertStorageIsWritable()
|
|
637
|
+
* on the pool. Defaults to true when not provided. Return false if you want
|
|
638
|
+
* to prevent writes to the pool locally early, because you know they won't
|
|
639
|
+
* have an effect upstream.
|
|
640
|
+
*/
|
|
641
|
+
isStorageWritable?: () => boolean;
|
|
642
|
+
};
|
|
643
|
+
/**
|
|
644
|
+
* @private Private API, never use this API directly.
|
|
645
|
+
*/
|
|
646
|
+
declare function createManagedPool(roomId: string, options: CreateManagedPoolOptions): ManagedPool;
|
|
595
647
|
declare abstract class AbstractCrdt {
|
|
596
648
|
#private;
|
|
597
649
|
get roomId(): string | null;
|
|
@@ -788,6 +840,46 @@ type ToJson<T extends Lson | LsonObject> = T extends Json ? T : T extends LsonOb
|
|
|
788
840
|
[K in KS]: ToJson<V>;
|
|
789
841
|
} : never;
|
|
790
842
|
|
|
843
|
+
type IdTuple<T> = [id: string, value: T];
|
|
844
|
+
declare enum CrdtType {
|
|
845
|
+
OBJECT = 0,
|
|
846
|
+
LIST = 1,
|
|
847
|
+
MAP = 2,
|
|
848
|
+
REGISTER = 3
|
|
849
|
+
}
|
|
850
|
+
type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
851
|
+
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
852
|
+
type SerializedRootObject = {
|
|
853
|
+
readonly type: CrdtType.OBJECT;
|
|
854
|
+
readonly data: JsonObject;
|
|
855
|
+
readonly parentId?: never;
|
|
856
|
+
readonly parentKey?: never;
|
|
857
|
+
};
|
|
858
|
+
type SerializedObject = {
|
|
859
|
+
readonly type: CrdtType.OBJECT;
|
|
860
|
+
readonly parentId: string;
|
|
861
|
+
readonly parentKey: string;
|
|
862
|
+
readonly data: JsonObject;
|
|
863
|
+
};
|
|
864
|
+
type SerializedList = {
|
|
865
|
+
readonly type: CrdtType.LIST;
|
|
866
|
+
readonly parentId: string;
|
|
867
|
+
readonly parentKey: string;
|
|
868
|
+
};
|
|
869
|
+
type SerializedMap = {
|
|
870
|
+
readonly type: CrdtType.MAP;
|
|
871
|
+
readonly parentId: string;
|
|
872
|
+
readonly parentKey: string;
|
|
873
|
+
};
|
|
874
|
+
type SerializedRegister = {
|
|
875
|
+
readonly type: CrdtType.REGISTER;
|
|
876
|
+
readonly parentId: string;
|
|
877
|
+
readonly parentKey: string;
|
|
878
|
+
readonly data: Json;
|
|
879
|
+
};
|
|
880
|
+
declare function isRootCrdt(crdt: SerializedCrdt): crdt is SerializedRootObject;
|
|
881
|
+
declare function isChildCrdt(crdt: SerializedCrdt): crdt is SerializedChild;
|
|
882
|
+
|
|
791
883
|
type LiveObjectUpdateDelta<O extends {
|
|
792
884
|
[key: string]: unknown;
|
|
793
885
|
}> = {
|
|
@@ -809,6 +901,8 @@ type LiveObjectUpdates<TData extends LsonObject> = {
|
|
|
809
901
|
*/
|
|
810
902
|
declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
811
903
|
#private;
|
|
904
|
+
/** @private Do not use this API directly */
|
|
905
|
+
static _fromItems<O extends LsonObject>(items: IdTuple<SerializedCrdt>[], pool: ManagedPool): LiveObject<O>;
|
|
812
906
|
constructor(obj?: O);
|
|
813
907
|
/**
|
|
814
908
|
* Transform the LiveObject into a javascript object
|
|
@@ -1205,46 +1299,6 @@ type UpdateYDocClientMsg = {
|
|
|
1205
1299
|
readonly v2?: boolean;
|
|
1206
1300
|
};
|
|
1207
1301
|
|
|
1208
|
-
type IdTuple<T> = [id: string, value: T];
|
|
1209
|
-
declare enum CrdtType {
|
|
1210
|
-
OBJECT = 0,
|
|
1211
|
-
LIST = 1,
|
|
1212
|
-
MAP = 2,
|
|
1213
|
-
REGISTER = 3
|
|
1214
|
-
}
|
|
1215
|
-
type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
1216
|
-
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
1217
|
-
type SerializedRootObject = {
|
|
1218
|
-
readonly type: CrdtType.OBJECT;
|
|
1219
|
-
readonly data: JsonObject;
|
|
1220
|
-
readonly parentId?: never;
|
|
1221
|
-
readonly parentKey?: never;
|
|
1222
|
-
};
|
|
1223
|
-
type SerializedObject = {
|
|
1224
|
-
readonly type: CrdtType.OBJECT;
|
|
1225
|
-
readonly parentId: string;
|
|
1226
|
-
readonly parentKey: string;
|
|
1227
|
-
readonly data: JsonObject;
|
|
1228
|
-
};
|
|
1229
|
-
type SerializedList = {
|
|
1230
|
-
readonly type: CrdtType.LIST;
|
|
1231
|
-
readonly parentId: string;
|
|
1232
|
-
readonly parentKey: string;
|
|
1233
|
-
};
|
|
1234
|
-
type SerializedMap = {
|
|
1235
|
-
readonly type: CrdtType.MAP;
|
|
1236
|
-
readonly parentId: string;
|
|
1237
|
-
readonly parentKey: string;
|
|
1238
|
-
};
|
|
1239
|
-
type SerializedRegister = {
|
|
1240
|
-
readonly type: CrdtType.REGISTER;
|
|
1241
|
-
readonly parentId: string;
|
|
1242
|
-
readonly parentKey: string;
|
|
1243
|
-
readonly data: Json;
|
|
1244
|
-
};
|
|
1245
|
-
declare function isRootCrdt(crdt: SerializedCrdt): crdt is SerializedRootObject;
|
|
1246
|
-
declare function isChildCrdt(crdt: SerializedCrdt): crdt is SerializedChild;
|
|
1247
|
-
|
|
1248
1302
|
declare enum ServerMsgCode {
|
|
1249
1303
|
UPDATE_PRESENCE = 100,
|
|
1250
1304
|
USER_JOINED = 101,
|
|
@@ -3261,6 +3315,10 @@ type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
3261
3315
|
* });
|
|
3262
3316
|
*/
|
|
3263
3317
|
declare function createClient<U extends BaseUserMeta = DU>(options: ClientOptions<U>): Client<U>;
|
|
3318
|
+
/**
|
|
3319
|
+
* @private Private API, don't use this directly.
|
|
3320
|
+
*/
|
|
3321
|
+
declare function checkBounds(option: string, value: unknown, min: number, max?: number, recommendedMin?: number): number;
|
|
3264
3322
|
|
|
3265
3323
|
type CommentBodyParagraphElementArgs = {
|
|
3266
3324
|
/**
|
|
@@ -3421,6 +3479,23 @@ declare function lsonToJson(value: Lson): Json;
|
|
|
3421
3479
|
declare function patchLiveObjectKey<O extends LsonObject, K extends keyof O, V extends Json>(liveObject: LiveObject<O>, key: K, prev?: V, next?: V): void;
|
|
3422
3480
|
declare function legacy_patchImmutableObject<TState extends JsonObject>(state: TState, updates: StorageUpdate[]): TState;
|
|
3423
3481
|
|
|
3482
|
+
/**
|
|
3483
|
+
* Like `new AbortController()`, but where the result can be unpacked
|
|
3484
|
+
* safely, i.e. `const { signal, abort } = makeAbortController()`.
|
|
3485
|
+
*
|
|
3486
|
+
* This unpacking is unsafe to do with a regular `AbortController` because
|
|
3487
|
+
* the `abort` method is not bound to the controller instance.
|
|
3488
|
+
*
|
|
3489
|
+
* In addition to this, you can also pass an optional (external)
|
|
3490
|
+
* AbortSignal to "wrap", in which case the returned signal will be in
|
|
3491
|
+
* aborted state when either the signal is aborted externally or
|
|
3492
|
+
* internally.
|
|
3493
|
+
*/
|
|
3494
|
+
declare function makeAbortController(externalSignal?: AbortSignal): {
|
|
3495
|
+
signal: AbortSignal;
|
|
3496
|
+
abort: (reason?: unknown) => void;
|
|
3497
|
+
};
|
|
3498
|
+
|
|
3424
3499
|
/**
|
|
3425
3500
|
* Helper function that can be used to implement exhaustive switch statements
|
|
3426
3501
|
* with TypeScript. Example usage:
|
|
@@ -4013,4 +4088,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
4013
4088
|
/** @deprecated Use HttpError instead. */
|
|
4014
4089
|
declare const NotificationsApiError: typeof HttpError;
|
|
4015
4090
|
|
|
4016
|
-
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, type UserNotificationSettingsPlain, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, createUserNotificationSettings, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchUserNotificationSettings, raise, resolveUsersInCommentBody, shallow, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
|
4091
|
+
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, type ManagedPool, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, type UserNotificationSettingsPlain, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createThreadId, createUserNotificationSettings, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchUserNotificationSettings, raise, resolveUsersInCommentBody, shallow, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -592,6 +592,58 @@ type LiveListUpdate = LiveListUpdates<Lson>;
|
|
|
592
592
|
*/
|
|
593
593
|
type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
|
|
594
594
|
|
|
595
|
+
/**
|
|
596
|
+
* The managed pool is a namespace registry (i.e. a context) that "owns" all
|
|
597
|
+
* the individual live nodes, ensuring each one has a unique ID, and holding on
|
|
598
|
+
* to live nodes before and after they are inter-connected.
|
|
599
|
+
*/
|
|
600
|
+
interface ManagedPool {
|
|
601
|
+
readonly roomId: string;
|
|
602
|
+
readonly nodes: ReadonlyMap<string, LiveNode>;
|
|
603
|
+
readonly generateId: () => string;
|
|
604
|
+
readonly generateOpId: () => string;
|
|
605
|
+
readonly getNode: (id: string) => LiveNode | undefined;
|
|
606
|
+
readonly addNode: (id: string, node: LiveNode) => void;
|
|
607
|
+
readonly deleteNode: (id: string) => void;
|
|
608
|
+
/**
|
|
609
|
+
* Dispatching has three responsibilities:
|
|
610
|
+
* - Sends serialized ops to the WebSocket servers
|
|
611
|
+
* - Add reverse operations to the undo/redo stack
|
|
612
|
+
* - Notify room subscribers with updates (in-client, no networking)
|
|
613
|
+
*/
|
|
614
|
+
dispatch: (ops: Op[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
|
|
615
|
+
/**
|
|
616
|
+
* Ensures storage can be written to else throws an error.
|
|
617
|
+
* This is used to prevent writing to storage when the user does not have
|
|
618
|
+
* permission to do so.
|
|
619
|
+
* @throws {Error} if storage is not writable
|
|
620
|
+
* @returns {void}
|
|
621
|
+
*/
|
|
622
|
+
assertStorageIsWritable: () => void;
|
|
623
|
+
}
|
|
624
|
+
type CreateManagedPoolOptions = {
|
|
625
|
+
/**
|
|
626
|
+
* Returns the current connection ID. This is used to generate unique
|
|
627
|
+
* prefixes for nodes created by this client. This number is allowed to
|
|
628
|
+
* change over time (for example, when the client reconnects).
|
|
629
|
+
*/
|
|
630
|
+
getCurrentConnectionId(): number;
|
|
631
|
+
/**
|
|
632
|
+
* Will get invoked when any Live structure calls .dispatch() on the pool.
|
|
633
|
+
*/
|
|
634
|
+
onDispatch?: (ops: Op[], reverse: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
|
|
635
|
+
/**
|
|
636
|
+
* Will get invoked when any Live structure calls .assertStorageIsWritable()
|
|
637
|
+
* on the pool. Defaults to true when not provided. Return false if you want
|
|
638
|
+
* to prevent writes to the pool locally early, because you know they won't
|
|
639
|
+
* have an effect upstream.
|
|
640
|
+
*/
|
|
641
|
+
isStorageWritable?: () => boolean;
|
|
642
|
+
};
|
|
643
|
+
/**
|
|
644
|
+
* @private Private API, never use this API directly.
|
|
645
|
+
*/
|
|
646
|
+
declare function createManagedPool(roomId: string, options: CreateManagedPoolOptions): ManagedPool;
|
|
595
647
|
declare abstract class AbstractCrdt {
|
|
596
648
|
#private;
|
|
597
649
|
get roomId(): string | null;
|
|
@@ -788,6 +840,46 @@ type ToJson<T extends Lson | LsonObject> = T extends Json ? T : T extends LsonOb
|
|
|
788
840
|
[K in KS]: ToJson<V>;
|
|
789
841
|
} : never;
|
|
790
842
|
|
|
843
|
+
type IdTuple<T> = [id: string, value: T];
|
|
844
|
+
declare enum CrdtType {
|
|
845
|
+
OBJECT = 0,
|
|
846
|
+
LIST = 1,
|
|
847
|
+
MAP = 2,
|
|
848
|
+
REGISTER = 3
|
|
849
|
+
}
|
|
850
|
+
type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
851
|
+
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
852
|
+
type SerializedRootObject = {
|
|
853
|
+
readonly type: CrdtType.OBJECT;
|
|
854
|
+
readonly data: JsonObject;
|
|
855
|
+
readonly parentId?: never;
|
|
856
|
+
readonly parentKey?: never;
|
|
857
|
+
};
|
|
858
|
+
type SerializedObject = {
|
|
859
|
+
readonly type: CrdtType.OBJECT;
|
|
860
|
+
readonly parentId: string;
|
|
861
|
+
readonly parentKey: string;
|
|
862
|
+
readonly data: JsonObject;
|
|
863
|
+
};
|
|
864
|
+
type SerializedList = {
|
|
865
|
+
readonly type: CrdtType.LIST;
|
|
866
|
+
readonly parentId: string;
|
|
867
|
+
readonly parentKey: string;
|
|
868
|
+
};
|
|
869
|
+
type SerializedMap = {
|
|
870
|
+
readonly type: CrdtType.MAP;
|
|
871
|
+
readonly parentId: string;
|
|
872
|
+
readonly parentKey: string;
|
|
873
|
+
};
|
|
874
|
+
type SerializedRegister = {
|
|
875
|
+
readonly type: CrdtType.REGISTER;
|
|
876
|
+
readonly parentId: string;
|
|
877
|
+
readonly parentKey: string;
|
|
878
|
+
readonly data: Json;
|
|
879
|
+
};
|
|
880
|
+
declare function isRootCrdt(crdt: SerializedCrdt): crdt is SerializedRootObject;
|
|
881
|
+
declare function isChildCrdt(crdt: SerializedCrdt): crdt is SerializedChild;
|
|
882
|
+
|
|
791
883
|
type LiveObjectUpdateDelta<O extends {
|
|
792
884
|
[key: string]: unknown;
|
|
793
885
|
}> = {
|
|
@@ -809,6 +901,8 @@ type LiveObjectUpdates<TData extends LsonObject> = {
|
|
|
809
901
|
*/
|
|
810
902
|
declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
811
903
|
#private;
|
|
904
|
+
/** @private Do not use this API directly */
|
|
905
|
+
static _fromItems<O extends LsonObject>(items: IdTuple<SerializedCrdt>[], pool: ManagedPool): LiveObject<O>;
|
|
812
906
|
constructor(obj?: O);
|
|
813
907
|
/**
|
|
814
908
|
* Transform the LiveObject into a javascript object
|
|
@@ -1205,46 +1299,6 @@ type UpdateYDocClientMsg = {
|
|
|
1205
1299
|
readonly v2?: boolean;
|
|
1206
1300
|
};
|
|
1207
1301
|
|
|
1208
|
-
type IdTuple<T> = [id: string, value: T];
|
|
1209
|
-
declare enum CrdtType {
|
|
1210
|
-
OBJECT = 0,
|
|
1211
|
-
LIST = 1,
|
|
1212
|
-
MAP = 2,
|
|
1213
|
-
REGISTER = 3
|
|
1214
|
-
}
|
|
1215
|
-
type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
1216
|
-
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
1217
|
-
type SerializedRootObject = {
|
|
1218
|
-
readonly type: CrdtType.OBJECT;
|
|
1219
|
-
readonly data: JsonObject;
|
|
1220
|
-
readonly parentId?: never;
|
|
1221
|
-
readonly parentKey?: never;
|
|
1222
|
-
};
|
|
1223
|
-
type SerializedObject = {
|
|
1224
|
-
readonly type: CrdtType.OBJECT;
|
|
1225
|
-
readonly parentId: string;
|
|
1226
|
-
readonly parentKey: string;
|
|
1227
|
-
readonly data: JsonObject;
|
|
1228
|
-
};
|
|
1229
|
-
type SerializedList = {
|
|
1230
|
-
readonly type: CrdtType.LIST;
|
|
1231
|
-
readonly parentId: string;
|
|
1232
|
-
readonly parentKey: string;
|
|
1233
|
-
};
|
|
1234
|
-
type SerializedMap = {
|
|
1235
|
-
readonly type: CrdtType.MAP;
|
|
1236
|
-
readonly parentId: string;
|
|
1237
|
-
readonly parentKey: string;
|
|
1238
|
-
};
|
|
1239
|
-
type SerializedRegister = {
|
|
1240
|
-
readonly type: CrdtType.REGISTER;
|
|
1241
|
-
readonly parentId: string;
|
|
1242
|
-
readonly parentKey: string;
|
|
1243
|
-
readonly data: Json;
|
|
1244
|
-
};
|
|
1245
|
-
declare function isRootCrdt(crdt: SerializedCrdt): crdt is SerializedRootObject;
|
|
1246
|
-
declare function isChildCrdt(crdt: SerializedCrdt): crdt is SerializedChild;
|
|
1247
|
-
|
|
1248
1302
|
declare enum ServerMsgCode {
|
|
1249
1303
|
UPDATE_PRESENCE = 100,
|
|
1250
1304
|
USER_JOINED = 101,
|
|
@@ -3261,6 +3315,10 @@ type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
3261
3315
|
* });
|
|
3262
3316
|
*/
|
|
3263
3317
|
declare function createClient<U extends BaseUserMeta = DU>(options: ClientOptions<U>): Client<U>;
|
|
3318
|
+
/**
|
|
3319
|
+
* @private Private API, don't use this directly.
|
|
3320
|
+
*/
|
|
3321
|
+
declare function checkBounds(option: string, value: unknown, min: number, max?: number, recommendedMin?: number): number;
|
|
3264
3322
|
|
|
3265
3323
|
type CommentBodyParagraphElementArgs = {
|
|
3266
3324
|
/**
|
|
@@ -3421,6 +3479,23 @@ declare function lsonToJson(value: Lson): Json;
|
|
|
3421
3479
|
declare function patchLiveObjectKey<O extends LsonObject, K extends keyof O, V extends Json>(liveObject: LiveObject<O>, key: K, prev?: V, next?: V): void;
|
|
3422
3480
|
declare function legacy_patchImmutableObject<TState extends JsonObject>(state: TState, updates: StorageUpdate[]): TState;
|
|
3423
3481
|
|
|
3482
|
+
/**
|
|
3483
|
+
* Like `new AbortController()`, but where the result can be unpacked
|
|
3484
|
+
* safely, i.e. `const { signal, abort } = makeAbortController()`.
|
|
3485
|
+
*
|
|
3486
|
+
* This unpacking is unsafe to do with a regular `AbortController` because
|
|
3487
|
+
* the `abort` method is not bound to the controller instance.
|
|
3488
|
+
*
|
|
3489
|
+
* In addition to this, you can also pass an optional (external)
|
|
3490
|
+
* AbortSignal to "wrap", in which case the returned signal will be in
|
|
3491
|
+
* aborted state when either the signal is aborted externally or
|
|
3492
|
+
* internally.
|
|
3493
|
+
*/
|
|
3494
|
+
declare function makeAbortController(externalSignal?: AbortSignal): {
|
|
3495
|
+
signal: AbortSignal;
|
|
3496
|
+
abort: (reason?: unknown) => void;
|
|
3497
|
+
};
|
|
3498
|
+
|
|
3424
3499
|
/**
|
|
3425
3500
|
* Helper function that can be used to implement exhaustive switch statements
|
|
3426
3501
|
* with TypeScript. Example usage:
|
|
@@ -4013,4 +4088,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
4013
4088
|
/** @deprecated Use HttpError instead. */
|
|
4014
4089
|
declare const NotificationsApiError: typeof HttpError;
|
|
4015
4090
|
|
|
4016
|
-
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, type UserNotificationSettingsPlain, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, createUserNotificationSettings, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchUserNotificationSettings, raise, resolveUsersInCommentBody, shallow, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
|
4091
|
+
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, type ManagedPool, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, type UserNotificationSettingsPlain, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createThreadId, createUserNotificationSettings, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchUserNotificationSettings, raise, resolveUsersInCommentBody, shallow, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|