@liveblocks/core 1.1.0 → 1.1.1-dual1
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 +1893 -0
- package/dist/index.d.ts +39 -33
- package/dist/index.js +5 -5968
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +19 -5
package/dist/index.d.ts
CHANGED
|
@@ -669,31 +669,6 @@ declare type Delegates<T extends BaseAuthResult> = {
|
|
|
669
669
|
createSocket: (token: T) => IWebSocketInstance;
|
|
670
670
|
};
|
|
671
671
|
|
|
672
|
-
declare type AppOnlyAuthToken = {
|
|
673
|
-
appId: string;
|
|
674
|
-
roomId?: never;
|
|
675
|
-
scopes: string[];
|
|
676
|
-
};
|
|
677
|
-
declare type RoomAuthToken = {
|
|
678
|
-
appId: string;
|
|
679
|
-
roomId: string;
|
|
680
|
-
scopes: string[];
|
|
681
|
-
actor: number;
|
|
682
|
-
maxConnectionsPerRoom?: number;
|
|
683
|
-
info?: Json;
|
|
684
|
-
groupIds?: string[];
|
|
685
|
-
} & ({
|
|
686
|
-
id: string;
|
|
687
|
-
anonymousId?: never;
|
|
688
|
-
} | {
|
|
689
|
-
id?: never;
|
|
690
|
-
anonymousId: string;
|
|
691
|
-
});
|
|
692
|
-
declare type AuthToken = AppOnlyAuthToken | RoomAuthToken;
|
|
693
|
-
declare function isAppOnlyAuthToken(data: JsonObject): data is AppOnlyAuthToken;
|
|
694
|
-
declare function isRoomAuthToken(data: JsonObject): data is RoomAuthToken;
|
|
695
|
-
declare function isAuthToken(data: JsonObject): data is AuthToken;
|
|
696
|
-
|
|
697
672
|
declare type ReadonlyArrayWithLegacyMethods<T> = readonly T[] & {
|
|
698
673
|
/**
|
|
699
674
|
* @deprecated Prefer the normal .length property on arrays.
|
|
@@ -711,11 +686,11 @@ declare function asArrayWithLegacyMethods<T>(arr: readonly T[]): ReadonlyArrayWi
|
|
|
711
686
|
*/
|
|
712
687
|
declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
|
|
713
688
|
/**
|
|
714
|
-
* The connection
|
|
689
|
+
* The connection ID of the User. It is unique and increment at every new connection.
|
|
715
690
|
*/
|
|
716
691
|
readonly connectionId: number;
|
|
717
692
|
/**
|
|
718
|
-
* The
|
|
693
|
+
* The ID of the User that has been set in the authentication endpoint.
|
|
719
694
|
* Useful to get additional information about the connected user.
|
|
720
695
|
*/
|
|
721
696
|
readonly id: TUserMeta["id"];
|
|
@@ -724,7 +699,7 @@ declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta>
|
|
|
724
699
|
*/
|
|
725
700
|
readonly info: TUserMeta["info"];
|
|
726
701
|
/**
|
|
727
|
-
* The user presence.
|
|
702
|
+
* The user’s presence data.
|
|
728
703
|
*/
|
|
729
704
|
readonly presence: TPresence;
|
|
730
705
|
/**
|
|
@@ -1077,6 +1052,17 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1077
1052
|
*/
|
|
1078
1053
|
addToHistory: boolean;
|
|
1079
1054
|
}): void;
|
|
1055
|
+
/**
|
|
1056
|
+
*
|
|
1057
|
+
* Sends Yjs document updates to liveblocks server
|
|
1058
|
+
*
|
|
1059
|
+
* @param {string} data the doc update to send to the server, base64 encoded uint8array
|
|
1060
|
+
*/
|
|
1061
|
+
updateYDoc(data: string): void;
|
|
1062
|
+
/**
|
|
1063
|
+
* Sends a request for the current document from liveblocks server
|
|
1064
|
+
*/
|
|
1065
|
+
fetchYDoc(stateVector: string): void;
|
|
1080
1066
|
/**
|
|
1081
1067
|
* Broadcasts an event to other users in the room. Event broadcasted to the room can be listened with {@link Room.subscribe}("event").
|
|
1082
1068
|
* @param {any} event the event to broadcast. Should be serializable to JSON
|
|
@@ -1134,6 +1120,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1134
1120
|
*/
|
|
1135
1121
|
readonly storageDidLoad: Observable<void>;
|
|
1136
1122
|
readonly storageStatus: Observable<StorageStatus>;
|
|
1123
|
+
readonly ydoc: Observable<string>;
|
|
1137
1124
|
};
|
|
1138
1125
|
/**
|
|
1139
1126
|
* Batches modifications made during the given function.
|
|
@@ -1456,12 +1443,14 @@ declare enum ClientMsgCode {
|
|
|
1456
1443
|
UPDATE_PRESENCE = 100,
|
|
1457
1444
|
BROADCAST_EVENT = 103,
|
|
1458
1445
|
FETCH_STORAGE = 200,
|
|
1459
|
-
UPDATE_STORAGE = 201
|
|
1446
|
+
UPDATE_STORAGE = 201,
|
|
1447
|
+
FETCH_YDOC = 300,
|
|
1448
|
+
UPDATE_YDOC = 301
|
|
1460
1449
|
}
|
|
1461
1450
|
/**
|
|
1462
1451
|
* Messages that can be sent from the client to the server.
|
|
1463
1452
|
*/
|
|
1464
|
-
declare type ClientMsg<TPresence extends JsonObject, TRoomEvent extends Json> = BroadcastEventClientMsg<TRoomEvent> | UpdatePresenceClientMsg<TPresence> | UpdateStorageClientMsg | FetchStorageClientMsg;
|
|
1453
|
+
declare type ClientMsg<TPresence extends JsonObject, TRoomEvent extends Json> = BroadcastEventClientMsg<TRoomEvent> | UpdatePresenceClientMsg<TPresence> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
|
|
1465
1454
|
declare type BroadcastEventClientMsg<TRoomEvent extends Json> = {
|
|
1466
1455
|
type: ClientMsgCode.BROADCAST_EVENT;
|
|
1467
1456
|
event: TRoomEvent;
|
|
@@ -1499,6 +1488,14 @@ declare type UpdateStorageClientMsg = {
|
|
|
1499
1488
|
declare type FetchStorageClientMsg = {
|
|
1500
1489
|
readonly type: ClientMsgCode.FETCH_STORAGE;
|
|
1501
1490
|
};
|
|
1491
|
+
declare type FetchYDocClientMsg = {
|
|
1492
|
+
readonly type: ClientMsgCode.FETCH_YDOC;
|
|
1493
|
+
readonly vector: string;
|
|
1494
|
+
};
|
|
1495
|
+
declare type UpdateYDocClientMsg = {
|
|
1496
|
+
readonly type: ClientMsgCode.UPDATE_YDOC;
|
|
1497
|
+
readonly update: string;
|
|
1498
|
+
};
|
|
1502
1499
|
|
|
1503
1500
|
declare type IdTuple<T> = [id: string, value: T];
|
|
1504
1501
|
declare enum CrdtType {
|
|
@@ -1548,12 +1545,13 @@ declare enum ServerMsgCode {
|
|
|
1548
1545
|
ROOM_STATE = 104,
|
|
1549
1546
|
INITIAL_STORAGE_STATE = 200,
|
|
1550
1547
|
UPDATE_STORAGE = 201,
|
|
1551
|
-
REJECT_STORAGE_OP = 299
|
|
1548
|
+
REJECT_STORAGE_OP = 299,
|
|
1549
|
+
UPDATE_YDOC = 300
|
|
1552
1550
|
}
|
|
1553
1551
|
/**
|
|
1554
1552
|
* Messages that can be sent from the server to the client.
|
|
1555
1553
|
*/
|
|
1556
|
-
declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg;
|
|
1554
|
+
declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdate;
|
|
1557
1555
|
/**
|
|
1558
1556
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
1559
1557
|
* a User updated their presence. For example, when a user moves their cursor.
|
|
@@ -1636,6 +1634,14 @@ declare type UserLeftServerMsg = {
|
|
|
1636
1634
|
readonly type: ServerMsgCode.USER_LEFT;
|
|
1637
1635
|
readonly actor: number;
|
|
1638
1636
|
};
|
|
1637
|
+
/**
|
|
1638
|
+
* Sent by the WebSocket server when the ydoc is updated or when requested based on stateVector passed.
|
|
1639
|
+
* Contains a base64 encoded update
|
|
1640
|
+
*/
|
|
1641
|
+
declare type YDocUpdate = {
|
|
1642
|
+
readonly type: ServerMsgCode.UPDATE_YDOC;
|
|
1643
|
+
readonly update: string;
|
|
1644
|
+
};
|
|
1639
1645
|
/**
|
|
1640
1646
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
1641
1647
|
* a User broadcasted an Event to everyone in the Room.
|
|
@@ -1884,4 +1890,4 @@ declare type EnsureJson<T> = [
|
|
|
1884
1890
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
1885
1891
|
};
|
|
1886
1892
|
|
|
1887
|
-
export { AckOp,
|
|
1893
|
+
export { AckOp, BaseAuthResult, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ToImmutable, ToJson, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, asArrayWithLegacyMethods, asPos, assert, assertNever, b64decode, createClient, deprecate, deprecateIf, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|