@liveblocks/core 1.9.7 → 1.9.8
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 +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -941,12 +941,15 @@ interface IWebSocket {
|
|
|
941
941
|
/**
|
|
942
942
|
* The following ranges will be respected by the client:
|
|
943
943
|
*
|
|
944
|
+
* 10xx: client will reauthorize (just like 41xx)
|
|
944
945
|
* 40xx: client will disconnect
|
|
945
946
|
* 41xx: client will reauthorize
|
|
946
947
|
* 42xx: client will retry without reauthorizing (currently not used)
|
|
947
948
|
*
|
|
948
949
|
*/
|
|
949
950
|
declare enum WebsocketCloseCodes {
|
|
951
|
+
/** Normal close of connection, the connection fulfilled its purpose. */
|
|
952
|
+
CLOSE_NORMAL = 1000,
|
|
950
953
|
/** Unexpected error happened with the network/infra level. In spirit akin to HTTP 503 */
|
|
951
954
|
CLOSE_ABNORMAL = 1006,
|
|
952
955
|
/** Unexpected error happened. In spirit akin to HTTP 500 */
|
|
@@ -965,6 +968,8 @@ declare enum WebsocketCloseCodes {
|
|
|
965
968
|
MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP = 4004,
|
|
966
969
|
/** Room is full, disconnect */
|
|
967
970
|
MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM = 4005,
|
|
971
|
+
/** The server kicked the connection from the room. */
|
|
972
|
+
KICKED = 4100,
|
|
968
973
|
/** The auth token is expired, reauthorize to get a fresh one. In spirit akin to HTTP 401 */
|
|
969
974
|
TOKEN_EXPIRED = 4109,
|
|
970
975
|
/** Disconnect immediately */
|
|
@@ -999,6 +1004,9 @@ declare type LostConnectionEvent = "lost" | "restored" | "failed";
|
|
|
999
1004
|
* any value (except null).
|
|
1000
1005
|
*/
|
|
1001
1006
|
declare type BaseAuthResult = NonNullable<Json>;
|
|
1007
|
+
declare class LiveblocksError extends Error {
|
|
1008
|
+
code: number;
|
|
1009
|
+
}
|
|
1002
1010
|
declare type Delegates<T extends BaseAuthResult> = {
|
|
1003
1011
|
authenticate: () => Promise<T>;
|
|
1004
1012
|
createSocket: (authValue: T) => IWebSocketInstance;
|
|
@@ -1386,6 +1394,7 @@ declare type InternalOthersEvent<TPresence extends JsonObject, TUserMeta extends
|
|
|
1386
1394
|
updates: Partial<TPresence>;
|
|
1387
1395
|
} | {
|
|
1388
1396
|
type: "reset";
|
|
1397
|
+
user?: never;
|
|
1389
1398
|
};
|
|
1390
1399
|
declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = Resolve<InternalOthersEvent<TPresence, TUserMeta> & {
|
|
1391
1400
|
others: readonly User<TPresence, TUserMeta>[];
|
|
@@ -1558,7 +1567,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
|
|
|
1558
1567
|
* @returns Unsubscribe function.
|
|
1559
1568
|
*
|
|
1560
1569
|
*/
|
|
1561
|
-
(type: "error", listener:
|
|
1570
|
+
(type: "error", listener: Callback<LiveblocksError>): () => void;
|
|
1562
1571
|
/**
|
|
1563
1572
|
* @deprecated This API will be removed in a future version of Liveblocks.
|
|
1564
1573
|
* Prefer using the newer `.subscribe('status')` API.
|
|
@@ -1792,7 +1801,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1792
1801
|
readonly self: Observable<User<TPresence, TUserMeta>>;
|
|
1793
1802
|
readonly myPresence: Observable<TPresence>;
|
|
1794
1803
|
readonly others: Observable<OthersEvent<TPresence, TUserMeta>>;
|
|
1795
|
-
readonly error: Observable<
|
|
1804
|
+
readonly error: Observable<LiveblocksError>;
|
|
1796
1805
|
readonly storage: Observable<StorageUpdate[]>;
|
|
1797
1806
|
readonly history: Observable<HistoryEvent>;
|
|
1798
1807
|
/**
|
|
@@ -2588,4 +2597,4 @@ declare type EnsureJson<T> = [
|
|
|
2588
2597
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
2589
2598
|
};
|
|
2590
2599
|
|
|
2591
|
-
export { type AckOp, type AsyncCache, type AsyncState, type AsyncStateError, type AsyncStateInitial, type AsyncStateLoading, type AsyncStateResolved, type AsyncStateSuccess, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyResolveUsersArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsApi, CommentsApiError, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, type Op, OpCode, type Others, type OthersEvent, type ParentToChildNodeMap, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type RejectedStorageOpServerMsg, type Resolve, type Room, type RoomEventMessage, type RoomInitializers, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToThreadData, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|
|
2600
|
+
export { type AckOp, type AsyncCache, type AsyncState, type AsyncStateError, type AsyncStateInitial, type AsyncStateLoading, type AsyncStateResolved, type AsyncStateSuccess, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyResolveUsersArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsApi, CommentsApiError, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, type Op, OpCode, type Others, type OthersEvent, type ParentToChildNodeMap, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type RejectedStorageOpServerMsg, type Resolve, type Room, type RoomEventMessage, type RoomInitializers, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToThreadData, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -941,12 +941,15 @@ interface IWebSocket {
|
|
|
941
941
|
/**
|
|
942
942
|
* The following ranges will be respected by the client:
|
|
943
943
|
*
|
|
944
|
+
* 10xx: client will reauthorize (just like 41xx)
|
|
944
945
|
* 40xx: client will disconnect
|
|
945
946
|
* 41xx: client will reauthorize
|
|
946
947
|
* 42xx: client will retry without reauthorizing (currently not used)
|
|
947
948
|
*
|
|
948
949
|
*/
|
|
949
950
|
declare enum WebsocketCloseCodes {
|
|
951
|
+
/** Normal close of connection, the connection fulfilled its purpose. */
|
|
952
|
+
CLOSE_NORMAL = 1000,
|
|
950
953
|
/** Unexpected error happened with the network/infra level. In spirit akin to HTTP 503 */
|
|
951
954
|
CLOSE_ABNORMAL = 1006,
|
|
952
955
|
/** Unexpected error happened. In spirit akin to HTTP 500 */
|
|
@@ -965,6 +968,8 @@ declare enum WebsocketCloseCodes {
|
|
|
965
968
|
MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP = 4004,
|
|
966
969
|
/** Room is full, disconnect */
|
|
967
970
|
MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM = 4005,
|
|
971
|
+
/** The server kicked the connection from the room. */
|
|
972
|
+
KICKED = 4100,
|
|
968
973
|
/** The auth token is expired, reauthorize to get a fresh one. In spirit akin to HTTP 401 */
|
|
969
974
|
TOKEN_EXPIRED = 4109,
|
|
970
975
|
/** Disconnect immediately */
|
|
@@ -999,6 +1004,9 @@ declare type LostConnectionEvent = "lost" | "restored" | "failed";
|
|
|
999
1004
|
* any value (except null).
|
|
1000
1005
|
*/
|
|
1001
1006
|
declare type BaseAuthResult = NonNullable<Json>;
|
|
1007
|
+
declare class LiveblocksError extends Error {
|
|
1008
|
+
code: number;
|
|
1009
|
+
}
|
|
1002
1010
|
declare type Delegates<T extends BaseAuthResult> = {
|
|
1003
1011
|
authenticate: () => Promise<T>;
|
|
1004
1012
|
createSocket: (authValue: T) => IWebSocketInstance;
|
|
@@ -1386,6 +1394,7 @@ declare type InternalOthersEvent<TPresence extends JsonObject, TUserMeta extends
|
|
|
1386
1394
|
updates: Partial<TPresence>;
|
|
1387
1395
|
} | {
|
|
1388
1396
|
type: "reset";
|
|
1397
|
+
user?: never;
|
|
1389
1398
|
};
|
|
1390
1399
|
declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = Resolve<InternalOthersEvent<TPresence, TUserMeta> & {
|
|
1391
1400
|
others: readonly User<TPresence, TUserMeta>[];
|
|
@@ -1558,7 +1567,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
|
|
|
1558
1567
|
* @returns Unsubscribe function.
|
|
1559
1568
|
*
|
|
1560
1569
|
*/
|
|
1561
|
-
(type: "error", listener:
|
|
1570
|
+
(type: "error", listener: Callback<LiveblocksError>): () => void;
|
|
1562
1571
|
/**
|
|
1563
1572
|
* @deprecated This API will be removed in a future version of Liveblocks.
|
|
1564
1573
|
* Prefer using the newer `.subscribe('status')` API.
|
|
@@ -1792,7 +1801,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1792
1801
|
readonly self: Observable<User<TPresence, TUserMeta>>;
|
|
1793
1802
|
readonly myPresence: Observable<TPresence>;
|
|
1794
1803
|
readonly others: Observable<OthersEvent<TPresence, TUserMeta>>;
|
|
1795
|
-
readonly error: Observable<
|
|
1804
|
+
readonly error: Observable<LiveblocksError>;
|
|
1796
1805
|
readonly storage: Observable<StorageUpdate[]>;
|
|
1797
1806
|
readonly history: Observable<HistoryEvent>;
|
|
1798
1807
|
/**
|
|
@@ -2588,4 +2597,4 @@ declare type EnsureJson<T> = [
|
|
|
2588
2597
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
2589
2598
|
};
|
|
2590
2599
|
|
|
2591
|
-
export { type AckOp, type AsyncCache, type AsyncState, type AsyncStateError, type AsyncStateInitial, type AsyncStateLoading, type AsyncStateResolved, type AsyncStateSuccess, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyResolveUsersArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsApi, CommentsApiError, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, type Op, OpCode, type Others, type OthersEvent, type ParentToChildNodeMap, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type RejectedStorageOpServerMsg, type Resolve, type Room, type RoomEventMessage, type RoomInitializers, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToThreadData, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|
|
2600
|
+
export { type AckOp, type AsyncCache, type AsyncState, type AsyncStateError, type AsyncStateInitial, type AsyncStateLoading, type AsyncStateResolved, type AsyncStateSuccess, type BaseAuthResult, type BaseMetadata, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyResolveUsersArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsApi, CommentsApiError, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type LegacyConnectionStatus, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NodeMap, type Op, OpCode, type Others, type OthersEvent, type ParentToChildNodeMap, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type RejectedStorageOpServerMsg, type Resolve, type Room, type RoomEventMessage, type RoomInitializers, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToThreadData, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, 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 = "1.9.
|
|
9
|
+
var PKG_VERSION = "1.9.8";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -362,23 +362,29 @@ var FSM = class {
|
|
|
362
362
|
}
|
|
363
363
|
onEnterAsync(nameOrPattern, promiseFn, onOK, onError) {
|
|
364
364
|
return this.onEnter(nameOrPattern, () => {
|
|
365
|
-
|
|
366
|
-
|
|
365
|
+
const abortController = new AbortController();
|
|
366
|
+
const signal = abortController.signal;
|
|
367
|
+
let done = false;
|
|
368
|
+
void promiseFn(this.currentContext.current, signal).then(
|
|
367
369
|
// On OK
|
|
368
370
|
(data) => {
|
|
369
|
-
if (!
|
|
371
|
+
if (!signal.aborted) {
|
|
372
|
+
done = true;
|
|
370
373
|
this.transition({ type: "ASYNC_OK", data }, onOK);
|
|
371
374
|
}
|
|
372
375
|
},
|
|
373
376
|
// On Error
|
|
374
377
|
(reason) => {
|
|
375
|
-
if (!
|
|
378
|
+
if (!signal.aborted) {
|
|
379
|
+
done = true;
|
|
376
380
|
this.transition({ type: "ASYNC_ERROR", reason }, onError);
|
|
377
381
|
}
|
|
378
382
|
}
|
|
379
383
|
);
|
|
380
384
|
return () => {
|
|
381
|
-
|
|
385
|
+
if (!done) {
|
|
386
|
+
abortController.abort();
|
|
387
|
+
}
|
|
382
388
|
};
|
|
383
389
|
});
|
|
384
390
|
}
|
|
@@ -652,6 +658,7 @@ var ServerMsgCode = /* @__PURE__ */ ((ServerMsgCode2) => {
|
|
|
652
658
|
|
|
653
659
|
// src/types/IWebSocket.ts
|
|
654
660
|
var WebsocketCloseCodes = /* @__PURE__ */ ((WebsocketCloseCodes2) => {
|
|
661
|
+
WebsocketCloseCodes2[WebsocketCloseCodes2["CLOSE_NORMAL"] = 1e3] = "CLOSE_NORMAL";
|
|
655
662
|
WebsocketCloseCodes2[WebsocketCloseCodes2["CLOSE_ABNORMAL"] = 1006] = "CLOSE_ABNORMAL";
|
|
656
663
|
WebsocketCloseCodes2[WebsocketCloseCodes2["UNEXPECTED_CONDITION"] = 1011] = "UNEXPECTED_CONDITION";
|
|
657
664
|
WebsocketCloseCodes2[WebsocketCloseCodes2["TRY_AGAIN_LATER"] = 1013] = "TRY_AGAIN_LATER";
|
|
@@ -661,6 +668,7 @@ var WebsocketCloseCodes = /* @__PURE__ */ ((WebsocketCloseCodes2) => {
|
|
|
661
668
|
WebsocketCloseCodes2[WebsocketCloseCodes2["MAX_NUMBER_OF_CONCURRENT_CONNECTIONS"] = 4003] = "MAX_NUMBER_OF_CONCURRENT_CONNECTIONS";
|
|
662
669
|
WebsocketCloseCodes2[WebsocketCloseCodes2["MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP"] = 4004] = "MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP";
|
|
663
670
|
WebsocketCloseCodes2[WebsocketCloseCodes2["MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM"] = 4005] = "MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM";
|
|
671
|
+
WebsocketCloseCodes2[WebsocketCloseCodes2["KICKED"] = 4100] = "KICKED";
|
|
664
672
|
WebsocketCloseCodes2[WebsocketCloseCodes2["TOKEN_EXPIRED"] = 4109] = "TOKEN_EXPIRED";
|
|
665
673
|
WebsocketCloseCodes2[WebsocketCloseCodes2["CLOSE_WITHOUT_RETRY"] = 4999] = "CLOSE_WITHOUT_RETRY";
|
|
666
674
|
return WebsocketCloseCodes2;
|
|
@@ -728,6 +736,7 @@ var StopRetrying = class extends Error {
|
|
|
728
736
|
}
|
|
729
737
|
};
|
|
730
738
|
var LiveblocksError = class extends Error {
|
|
739
|
+
/** @internal */
|
|
731
740
|
constructor(message, code) {
|
|
732
741
|
super(message);
|
|
733
742
|
this.code = code;
|
|
@@ -942,14 +951,16 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
942
951
|
// When the "open" event happens, we're ready to transition to the
|
|
943
952
|
// OK state. This is done by resolving the Promise.
|
|
944
953
|
//
|
|
945
|
-
async (ctx) => {
|
|
954
|
+
async (ctx, signal) => {
|
|
946
955
|
let capturedPrematureEvent = null;
|
|
956
|
+
let unconfirmedSocket = null;
|
|
947
957
|
const connect$ = new Promise(
|
|
948
958
|
(resolve, rej) => {
|
|
949
959
|
if (ctx.authValue === null) {
|
|
950
960
|
throw new Error("No auth authValue");
|
|
951
961
|
}
|
|
952
962
|
const socket = delegates.createSocket(ctx.authValue);
|
|
963
|
+
unconfirmedSocket = socket;
|
|
953
964
|
function reject(event) {
|
|
954
965
|
capturedPrematureEvent = event;
|
|
955
966
|
socket.removeEventListener("message", onSocketMessage);
|
|
@@ -1005,12 +1016,18 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
1005
1016
|
//
|
|
1006
1017
|
([socket, unsub]) => {
|
|
1007
1018
|
unsub();
|
|
1019
|
+
if (signal.aborted) {
|
|
1020
|
+
throw new Error("Aborted");
|
|
1021
|
+
}
|
|
1008
1022
|
if (capturedPrematureEvent) {
|
|
1009
1023
|
throw capturedPrematureEvent;
|
|
1010
1024
|
}
|
|
1011
1025
|
return socket;
|
|
1012
1026
|
}
|
|
1013
|
-
)
|
|
1027
|
+
).catch((e) => {
|
|
1028
|
+
teardownSocket(unconfirmedSocket);
|
|
1029
|
+
throw e;
|
|
1030
|
+
});
|
|
1014
1031
|
},
|
|
1015
1032
|
// Only transition to OK state after a successfully opened WebSocket connection
|
|
1016
1033
|
(okEvent) => ({
|