@liveblocks/core 2.11.0 → 2.12.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.d.mts +79 -14
- package/dist/index.d.ts +79 -14
- package/dist/index.js +189 -118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -89
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2258,12 +2258,31 @@ declare type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extend
|
|
|
2258
2258
|
*/
|
|
2259
2259
|
markInboxNotificationAsRead(notificationId: string): Promise<void>;
|
|
2260
2260
|
};
|
|
2261
|
-
declare type
|
|
2261
|
+
declare type YjsSyncStatus = "loading" | "synchronizing" | "synchronized";
|
|
2262
|
+
/**
|
|
2263
|
+
* Interface that @liveblocks/yjs must respect.
|
|
2264
|
+
* This interface type is declare in @liveblocks/core, so we don't have to
|
|
2265
|
+
* depend on `yjs`. It's only used to determine the API contract between
|
|
2266
|
+
* @liveblocks/core and @liveblocks/yjs.
|
|
2267
|
+
*/
|
|
2268
|
+
interface IYjsProvider {
|
|
2262
2269
|
synced: boolean;
|
|
2263
|
-
getStatus: () =>
|
|
2264
|
-
on(event: "sync"
|
|
2265
|
-
|
|
2266
|
-
|
|
2270
|
+
getStatus: () => YjsSyncStatus;
|
|
2271
|
+
on(event: "sync", listener: (synced: boolean) => void): void;
|
|
2272
|
+
on(event: "status", listener: (status: YjsSyncStatus) => void): void;
|
|
2273
|
+
off(event: "sync", listener: (synced: boolean) => void): void;
|
|
2274
|
+
off(event: "status", listener: (status: YjsSyncStatus) => void): void;
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* A "Sync Source" can be a Storage document, a Yjs document, Comments,
|
|
2278
|
+
* Notifications, etc.
|
|
2279
|
+
* The Client keeps a registry of all active sync sources, and will use it to
|
|
2280
|
+
* determine the global "sync status" for Liveblocks.
|
|
2281
|
+
*/
|
|
2282
|
+
interface SyncSource {
|
|
2283
|
+
setSyncStatus(status: InternalSyncStatus): void;
|
|
2284
|
+
destroy(): void;
|
|
2285
|
+
}
|
|
2267
2286
|
/**
|
|
2268
2287
|
* @private
|
|
2269
2288
|
*
|
|
@@ -2276,9 +2295,9 @@ declare type PrivateRoomApi = {
|
|
|
2276
2295
|
presenceBuffer: Json | undefined;
|
|
2277
2296
|
undoStack: readonly (readonly Readonly<HistoryOp<JsonObject>>[])[];
|
|
2278
2297
|
nodeCount: number;
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2298
|
+
getYjsProvider(): IYjsProvider | undefined;
|
|
2299
|
+
setYjsProvider(provider: IYjsProvider | undefined): void;
|
|
2300
|
+
yjsProviderDidChange: Observable<void>;
|
|
2282
2301
|
getSelf_forDevTools(): UserTreeNode | null;
|
|
2283
2302
|
getOthers_forDevTools(): readonly UserTreeNode[];
|
|
2284
2303
|
reportTextEditor(editor: TextEditorType, rootKey: string): Promise<void>;
|
|
@@ -2405,6 +2424,15 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
|
|
|
2405
2424
|
*/
|
|
2406
2425
|
initialStorage: S | ((roomId: string) => S);
|
|
2407
2426
|
}>>;
|
|
2427
|
+
declare type SyncStatus = "synchronizing" | "synchronized";
|
|
2428
|
+
/**
|
|
2429
|
+
* "synchronizing" - Liveblocks is in the process of writing changes
|
|
2430
|
+
* "synchronized" - Liveblocks has persisted all pending changes
|
|
2431
|
+
* "has-local-changes" - There is local pending state inputted by the user, but
|
|
2432
|
+
* we're not yet "synchronizing" it until a user
|
|
2433
|
+
* interaction, like the draft text in a comment box.
|
|
2434
|
+
*/
|
|
2435
|
+
declare type InternalSyncStatus = SyncStatus | "has-local-changes";
|
|
2408
2436
|
/**
|
|
2409
2437
|
* @private
|
|
2410
2438
|
*
|
|
@@ -2437,6 +2465,7 @@ declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> =
|
|
|
2437
2465
|
requestedAt: Date;
|
|
2438
2466
|
}>;
|
|
2439
2467
|
as<M2 extends BaseMetadata>(): Client<U, M2>;
|
|
2468
|
+
createSyncSource(): SyncSource;
|
|
2440
2469
|
};
|
|
2441
2470
|
declare type NotificationsApi<M extends BaseMetadata> = {
|
|
2442
2471
|
/**
|
|
@@ -2606,6 +2635,31 @@ declare type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> =
|
|
|
2606
2635
|
* will probably happen if you do.
|
|
2607
2636
|
*/
|
|
2608
2637
|
readonly [kInternal]: PrivateClientApi<U, M>;
|
|
2638
|
+
/**
|
|
2639
|
+
* Returns the current global sync status of the Liveblocks client. If any
|
|
2640
|
+
* part of Liveblocks has any local pending changes that haven't been
|
|
2641
|
+
* confirmed by or persisted by the server yet, this will be "synchronizing",
|
|
2642
|
+
* otherwise "synchronized".
|
|
2643
|
+
*
|
|
2644
|
+
* This is a combined status for all of the below parts of Liveblocks:
|
|
2645
|
+
* - Storage (realtime APIs)
|
|
2646
|
+
* - Text Editors
|
|
2647
|
+
* - Comments
|
|
2648
|
+
* - Notifications
|
|
2649
|
+
*
|
|
2650
|
+
* @example
|
|
2651
|
+
* const status = client.getSyncStatus(); // "synchronizing" | "synchronized"
|
|
2652
|
+
*/
|
|
2653
|
+
getSyncStatus(): SyncStatus;
|
|
2654
|
+
/**
|
|
2655
|
+
* All possible client events, subscribable from a single place.
|
|
2656
|
+
*
|
|
2657
|
+
* @private These event sources are private for now, but will become public
|
|
2658
|
+
* once they're stable.
|
|
2659
|
+
*/
|
|
2660
|
+
readonly events: {
|
|
2661
|
+
readonly syncStatus: Observable<void>;
|
|
2662
|
+
};
|
|
2609
2663
|
} & NotificationsApi<M>;
|
|
2610
2664
|
declare type AuthEndpoint = string | ((room?: string) => Promise<CustomAuthenticationResult>);
|
|
2611
2665
|
/**
|
|
@@ -2631,6 +2685,12 @@ declare type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
2631
2685
|
* A function that returns room info from room IDs.
|
|
2632
2686
|
*/
|
|
2633
2687
|
resolveRoomsInfo?: (args: ResolveRoomsInfoArgs) => OptionalPromise<(DRI | undefined)[] | undefined>;
|
|
2688
|
+
/**
|
|
2689
|
+
* Prevent the current browser tab from being closed if there are any locally
|
|
2690
|
+
* pending Liveblocks changes that haven't been submitted to or confirmed by
|
|
2691
|
+
* the server yet.
|
|
2692
|
+
*/
|
|
2693
|
+
preventUnsavedChanges?: boolean;
|
|
2634
2694
|
} & ({
|
|
2635
2695
|
publicApiKey: string;
|
|
2636
2696
|
authEndpoint?: never;
|
|
@@ -3167,15 +3227,20 @@ declare function asPos(str: string): Pos;
|
|
|
3167
3227
|
declare function shallow(a: unknown, b: unknown): boolean;
|
|
3168
3228
|
|
|
3169
3229
|
/**
|
|
3170
|
-
* A datastructure to keep elements in ascending order, defined by
|
|
3171
|
-
* function
|
|
3230
|
+
* A datastructure to keep elements in ascending order, as defined by the "less
|
|
3231
|
+
* than" function you provide. The elements will be ordered according to
|
|
3232
|
+
* whatever you define as the "less than" for this element type, so that every
|
|
3233
|
+
* element is less than its successor in the list.
|
|
3172
3234
|
*
|
|
3173
|
-
* const sorted = SortedList.from(
|
|
3235
|
+
* const sorted = SortedList.from(
|
|
3236
|
+
* [{ id: 4 }, { id: 1 }, { id: 9 }, { id: 4 }],
|
|
3237
|
+
* (a, b) => a.id < b.id)
|
|
3238
|
+
* )
|
|
3174
3239
|
* sorted.add({ id: 5 })
|
|
3175
|
-
* sorted.remove({ id: 4 })
|
|
3240
|
+
* sorted.remove({ id: 4 }) // Assuming it's the same obj ref!
|
|
3176
3241
|
*
|
|
3177
3242
|
* Array.from(sorted)
|
|
3178
|
-
* [{ id: 1 }, { id: 4 }, { id:
|
|
3243
|
+
* [{ id: 1 }, { id: 4 }, { id: 5 }, { id: 9 }])
|
|
3179
3244
|
*/
|
|
3180
3245
|
declare class SortedList<T> {
|
|
3181
3246
|
private _data;
|
|
@@ -3362,4 +3427,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
3362
3427
|
/** @deprecated Use HttpError instead. */
|
|
3363
3428
|
declare const NotificationsApiError: typeof HttpError;
|
|
3364
3429
|
|
|
3365
|
-
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, 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, 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, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GetUserThreadsOptions, type History, type HistoryVersion, HttpError, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, 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, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, 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 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, SortedList, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, 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, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, autoRetry, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
|
3430
|
+
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, 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, 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, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GetUserThreadsOptions, type History, type HistoryVersion, HttpError, 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, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, 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 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, SortedList, type Status, type StorageStatus, type StorageUpdate, type Store, 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, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -2258,12 +2258,31 @@ declare type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extend
|
|
|
2258
2258
|
*/
|
|
2259
2259
|
markInboxNotificationAsRead(notificationId: string): Promise<void>;
|
|
2260
2260
|
};
|
|
2261
|
-
declare type
|
|
2261
|
+
declare type YjsSyncStatus = "loading" | "synchronizing" | "synchronized";
|
|
2262
|
+
/**
|
|
2263
|
+
* Interface that @liveblocks/yjs must respect.
|
|
2264
|
+
* This interface type is declare in @liveblocks/core, so we don't have to
|
|
2265
|
+
* depend on `yjs`. It's only used to determine the API contract between
|
|
2266
|
+
* @liveblocks/core and @liveblocks/yjs.
|
|
2267
|
+
*/
|
|
2268
|
+
interface IYjsProvider {
|
|
2262
2269
|
synced: boolean;
|
|
2263
|
-
getStatus: () =>
|
|
2264
|
-
on(event: "sync"
|
|
2265
|
-
|
|
2266
|
-
|
|
2270
|
+
getStatus: () => YjsSyncStatus;
|
|
2271
|
+
on(event: "sync", listener: (synced: boolean) => void): void;
|
|
2272
|
+
on(event: "status", listener: (status: YjsSyncStatus) => void): void;
|
|
2273
|
+
off(event: "sync", listener: (synced: boolean) => void): void;
|
|
2274
|
+
off(event: "status", listener: (status: YjsSyncStatus) => void): void;
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* A "Sync Source" can be a Storage document, a Yjs document, Comments,
|
|
2278
|
+
* Notifications, etc.
|
|
2279
|
+
* The Client keeps a registry of all active sync sources, and will use it to
|
|
2280
|
+
* determine the global "sync status" for Liveblocks.
|
|
2281
|
+
*/
|
|
2282
|
+
interface SyncSource {
|
|
2283
|
+
setSyncStatus(status: InternalSyncStatus): void;
|
|
2284
|
+
destroy(): void;
|
|
2285
|
+
}
|
|
2267
2286
|
/**
|
|
2268
2287
|
* @private
|
|
2269
2288
|
*
|
|
@@ -2276,9 +2295,9 @@ declare type PrivateRoomApi = {
|
|
|
2276
2295
|
presenceBuffer: Json | undefined;
|
|
2277
2296
|
undoStack: readonly (readonly Readonly<HistoryOp<JsonObject>>[])[];
|
|
2278
2297
|
nodeCount: number;
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2298
|
+
getYjsProvider(): IYjsProvider | undefined;
|
|
2299
|
+
setYjsProvider(provider: IYjsProvider | undefined): void;
|
|
2300
|
+
yjsProviderDidChange: Observable<void>;
|
|
2282
2301
|
getSelf_forDevTools(): UserTreeNode | null;
|
|
2283
2302
|
getOthers_forDevTools(): readonly UserTreeNode[];
|
|
2284
2303
|
reportTextEditor(editor: TextEditorType, rootKey: string): Promise<void>;
|
|
@@ -2405,6 +2424,15 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
|
|
|
2405
2424
|
*/
|
|
2406
2425
|
initialStorage: S | ((roomId: string) => S);
|
|
2407
2426
|
}>>;
|
|
2427
|
+
declare type SyncStatus = "synchronizing" | "synchronized";
|
|
2428
|
+
/**
|
|
2429
|
+
* "synchronizing" - Liveblocks is in the process of writing changes
|
|
2430
|
+
* "synchronized" - Liveblocks has persisted all pending changes
|
|
2431
|
+
* "has-local-changes" - There is local pending state inputted by the user, but
|
|
2432
|
+
* we're not yet "synchronizing" it until a user
|
|
2433
|
+
* interaction, like the draft text in a comment box.
|
|
2434
|
+
*/
|
|
2435
|
+
declare type InternalSyncStatus = SyncStatus | "has-local-changes";
|
|
2408
2436
|
/**
|
|
2409
2437
|
* @private
|
|
2410
2438
|
*
|
|
@@ -2437,6 +2465,7 @@ declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> =
|
|
|
2437
2465
|
requestedAt: Date;
|
|
2438
2466
|
}>;
|
|
2439
2467
|
as<M2 extends BaseMetadata>(): Client<U, M2>;
|
|
2468
|
+
createSyncSource(): SyncSource;
|
|
2440
2469
|
};
|
|
2441
2470
|
declare type NotificationsApi<M extends BaseMetadata> = {
|
|
2442
2471
|
/**
|
|
@@ -2606,6 +2635,31 @@ declare type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> =
|
|
|
2606
2635
|
* will probably happen if you do.
|
|
2607
2636
|
*/
|
|
2608
2637
|
readonly [kInternal]: PrivateClientApi<U, M>;
|
|
2638
|
+
/**
|
|
2639
|
+
* Returns the current global sync status of the Liveblocks client. If any
|
|
2640
|
+
* part of Liveblocks has any local pending changes that haven't been
|
|
2641
|
+
* confirmed by or persisted by the server yet, this will be "synchronizing",
|
|
2642
|
+
* otherwise "synchronized".
|
|
2643
|
+
*
|
|
2644
|
+
* This is a combined status for all of the below parts of Liveblocks:
|
|
2645
|
+
* - Storage (realtime APIs)
|
|
2646
|
+
* - Text Editors
|
|
2647
|
+
* - Comments
|
|
2648
|
+
* - Notifications
|
|
2649
|
+
*
|
|
2650
|
+
* @example
|
|
2651
|
+
* const status = client.getSyncStatus(); // "synchronizing" | "synchronized"
|
|
2652
|
+
*/
|
|
2653
|
+
getSyncStatus(): SyncStatus;
|
|
2654
|
+
/**
|
|
2655
|
+
* All possible client events, subscribable from a single place.
|
|
2656
|
+
*
|
|
2657
|
+
* @private These event sources are private for now, but will become public
|
|
2658
|
+
* once they're stable.
|
|
2659
|
+
*/
|
|
2660
|
+
readonly events: {
|
|
2661
|
+
readonly syncStatus: Observable<void>;
|
|
2662
|
+
};
|
|
2609
2663
|
} & NotificationsApi<M>;
|
|
2610
2664
|
declare type AuthEndpoint = string | ((room?: string) => Promise<CustomAuthenticationResult>);
|
|
2611
2665
|
/**
|
|
@@ -2631,6 +2685,12 @@ declare type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
2631
2685
|
* A function that returns room info from room IDs.
|
|
2632
2686
|
*/
|
|
2633
2687
|
resolveRoomsInfo?: (args: ResolveRoomsInfoArgs) => OptionalPromise<(DRI | undefined)[] | undefined>;
|
|
2688
|
+
/**
|
|
2689
|
+
* Prevent the current browser tab from being closed if there are any locally
|
|
2690
|
+
* pending Liveblocks changes that haven't been submitted to or confirmed by
|
|
2691
|
+
* the server yet.
|
|
2692
|
+
*/
|
|
2693
|
+
preventUnsavedChanges?: boolean;
|
|
2634
2694
|
} & ({
|
|
2635
2695
|
publicApiKey: string;
|
|
2636
2696
|
authEndpoint?: never;
|
|
@@ -3167,15 +3227,20 @@ declare function asPos(str: string): Pos;
|
|
|
3167
3227
|
declare function shallow(a: unknown, b: unknown): boolean;
|
|
3168
3228
|
|
|
3169
3229
|
/**
|
|
3170
|
-
* A datastructure to keep elements in ascending order, defined by
|
|
3171
|
-
* function
|
|
3230
|
+
* A datastructure to keep elements in ascending order, as defined by the "less
|
|
3231
|
+
* than" function you provide. The elements will be ordered according to
|
|
3232
|
+
* whatever you define as the "less than" for this element type, so that every
|
|
3233
|
+
* element is less than its successor in the list.
|
|
3172
3234
|
*
|
|
3173
|
-
* const sorted = SortedList.from(
|
|
3235
|
+
* const sorted = SortedList.from(
|
|
3236
|
+
* [{ id: 4 }, { id: 1 }, { id: 9 }, { id: 4 }],
|
|
3237
|
+
* (a, b) => a.id < b.id)
|
|
3238
|
+
* )
|
|
3174
3239
|
* sorted.add({ id: 5 })
|
|
3175
|
-
* sorted.remove({ id: 4 })
|
|
3240
|
+
* sorted.remove({ id: 4 }) // Assuming it's the same obj ref!
|
|
3176
3241
|
*
|
|
3177
3242
|
* Array.from(sorted)
|
|
3178
|
-
* [{ id: 1 }, { id: 4 }, { id:
|
|
3243
|
+
* [{ id: 1 }, { id: 4 }, { id: 5 }, { id: 9 }])
|
|
3179
3244
|
*/
|
|
3180
3245
|
declare class SortedList<T> {
|
|
3181
3246
|
private _data;
|
|
@@ -3362,4 +3427,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
3362
3427
|
/** @deprecated Use HttpError instead. */
|
|
3363
3428
|
declare const NotificationsApiError: typeof HttpError;
|
|
3364
3429
|
|
|
3365
|
-
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, 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, 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, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GetUserThreadsOptions, type History, type HistoryVersion, HttpError, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, 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, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, 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 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, SortedList, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, 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, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, autoRetry, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
|
3430
|
+
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, 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, 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, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GetUserThreadsOptions, type History, type HistoryVersion, HttpError, 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, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, 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 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, SortedList, type Status, type StorageStatus, type StorageUpdate, type Store, 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, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|