@liveblocks/core 1.0.2-test5 → 1.0.6-test1
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.ts +47 -36
- package/dist/index.js +747 -421
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -460,28 +460,6 @@ declare type ToJson<T extends Lson | LsonObject> = T extends Json ? T : T extend
|
|
|
460
460
|
[K in KS]: ToJson<V>;
|
|
461
461
|
} : never;
|
|
462
462
|
|
|
463
|
-
/**
|
|
464
|
-
* This type is used by clients to define the metadata for a user.
|
|
465
|
-
*/
|
|
466
|
-
declare type BaseUserMeta = {
|
|
467
|
-
/**
|
|
468
|
-
* The id of the user that has been set in the authentication endpoint.
|
|
469
|
-
* Useful to get additional information about the connected user.
|
|
470
|
-
*/
|
|
471
|
-
id?: string;
|
|
472
|
-
/**
|
|
473
|
-
* Additional user information that has been set in the authentication endpoint.
|
|
474
|
-
*/
|
|
475
|
-
info?: Json;
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
declare type Callback<T> = (event: T) => void;
|
|
479
|
-
declare type UnsubscribeCallback = () => void;
|
|
480
|
-
declare type Observable<T> = {
|
|
481
|
-
subscribe(callback: Callback<T>): UnsubscribeCallback;
|
|
482
|
-
subscribeOnce(callback: Callback<T>): UnsubscribeCallback;
|
|
483
|
-
};
|
|
484
|
-
|
|
485
463
|
/**
|
|
486
464
|
* This helper type is effectively a no-op, but will force TypeScript to
|
|
487
465
|
* "evaluate" any named helper types in its definition. This can sometimes make
|
|
@@ -508,6 +486,28 @@ declare type Resolve<T> = T extends (...args: unknown[]) => unknown ? T : {
|
|
|
508
486
|
[K in keyof T]: T[K];
|
|
509
487
|
};
|
|
510
488
|
|
|
489
|
+
/**
|
|
490
|
+
* This type is used by clients to define the metadata for a user.
|
|
491
|
+
*/
|
|
492
|
+
declare type BaseUserMeta = {
|
|
493
|
+
/**
|
|
494
|
+
* The id of the user that has been set in the authentication endpoint.
|
|
495
|
+
* Useful to get additional information about the connected user.
|
|
496
|
+
*/
|
|
497
|
+
id?: string;
|
|
498
|
+
/**
|
|
499
|
+
* Additional user information that has been set in the authentication endpoint.
|
|
500
|
+
*/
|
|
501
|
+
info?: Json;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
declare type Callback<T> = (event: T) => void;
|
|
505
|
+
declare type UnsubscribeCallback = () => void;
|
|
506
|
+
declare type Observable<T> = {
|
|
507
|
+
subscribe(callback: Callback<T>): UnsubscribeCallback;
|
|
508
|
+
subscribeOnce(callback: Callback<T>): UnsubscribeCallback;
|
|
509
|
+
};
|
|
510
|
+
|
|
511
511
|
declare type AppOnlyAuthToken = {
|
|
512
512
|
appId: string;
|
|
513
513
|
roomId?: never;
|
|
@@ -685,27 +685,27 @@ declare type CustomEvent<TRoomEvent extends Json> = {
|
|
|
685
685
|
event: TRoomEvent;
|
|
686
686
|
};
|
|
687
687
|
declare type Connection = {
|
|
688
|
-
|
|
688
|
+
status: "closed";
|
|
689
689
|
} | {
|
|
690
|
-
|
|
690
|
+
status: "authenticating";
|
|
691
691
|
} | {
|
|
692
|
-
|
|
692
|
+
status: "connecting";
|
|
693
693
|
id: number;
|
|
694
694
|
userId?: string;
|
|
695
695
|
userInfo?: Json;
|
|
696
696
|
isReadOnly: boolean;
|
|
697
697
|
} | {
|
|
698
|
-
|
|
698
|
+
status: "open";
|
|
699
699
|
id: number;
|
|
700
700
|
userId?: string;
|
|
701
701
|
userInfo?: Json;
|
|
702
702
|
isReadOnly: boolean;
|
|
703
703
|
} | {
|
|
704
|
-
|
|
704
|
+
status: "unavailable";
|
|
705
705
|
} | {
|
|
706
|
-
|
|
706
|
+
status: "failed";
|
|
707
707
|
};
|
|
708
|
-
declare type
|
|
708
|
+
declare type ConnectionStatus = Connection["status"];
|
|
709
709
|
declare type StorageStatus = "not-loaded" | "loading" | "synchronizing" | "synchronized";
|
|
710
710
|
interface History {
|
|
711
711
|
/**
|
|
@@ -802,7 +802,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
802
802
|
* metadata and connection ID (from the auth server).
|
|
803
803
|
*/
|
|
804
804
|
isSelfAware(): boolean;
|
|
805
|
-
getConnectionState():
|
|
805
|
+
getConnectionState(): ConnectionStatus;
|
|
806
806
|
readonly subscribe: {
|
|
807
807
|
/**
|
|
808
808
|
* Subscribe to the current user presence updates.
|
|
@@ -858,7 +858,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
858
858
|
* @returns Unsubscribe function.
|
|
859
859
|
*
|
|
860
860
|
*/
|
|
861
|
-
(type: "connection", listener: Callback<
|
|
861
|
+
(type: "connection", listener: Callback<ConnectionStatus>): () => void;
|
|
862
862
|
/**
|
|
863
863
|
* Subscribes to changes made on a Live structure. Returns an unsubscribe function.
|
|
864
864
|
* In a future version, we will also expose what exactly changed in the Live structure.
|
|
@@ -1014,7 +1014,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1014
1014
|
event: OthersEvent<TPresence, TUserMeta>;
|
|
1015
1015
|
}>;
|
|
1016
1016
|
error: Observable<Error>;
|
|
1017
|
-
connection: Observable<
|
|
1017
|
+
connection: Observable<ConnectionStatus>;
|
|
1018
1018
|
storage: Observable<StorageUpdate[]>;
|
|
1019
1019
|
history: Observable<HistoryEvent>;
|
|
1020
1020
|
/**
|
|
@@ -1075,6 +1075,17 @@ declare type RoomInitializers<TPresence extends JsonObject, TStorage extends Lso
|
|
|
1075
1075
|
shouldInitiallyConnect?: boolean;
|
|
1076
1076
|
}>;
|
|
1077
1077
|
|
|
1078
|
+
declare type EnterOptions<TPresence extends JsonObject, TStorage extends LsonObject> = Resolve<RoomInitializers<TPresence, TStorage> & {
|
|
1079
|
+
/**
|
|
1080
|
+
* Only necessary when you’re using Liveblocks with React v17 or lower.
|
|
1081
|
+
*
|
|
1082
|
+
* If so, pass in a reference to `ReactDOM.unstable_batchedUpdates` here.
|
|
1083
|
+
* This will allow Liveblocks to circumvent the so-called "zombie child
|
|
1084
|
+
* problem". To learn more, see
|
|
1085
|
+
* https://liveblocks.io/docs/guides/troubleshooting#stale-props-zombie-child
|
|
1086
|
+
*/
|
|
1087
|
+
unstable_batchedUpdates?: (cb: () => void) => void;
|
|
1088
|
+
}>;
|
|
1078
1089
|
declare type Client = {
|
|
1079
1090
|
/**
|
|
1080
1091
|
* Gets a room. Returns null if {@link Client.enter} has not been called previously.
|
|
@@ -1087,7 +1098,7 @@ declare type Client = {
|
|
|
1087
1098
|
* @param roomId The id of the room
|
|
1088
1099
|
* @param options Optional. You can provide initializers for the Presence or Storage when entering the Room.
|
|
1089
1100
|
*/
|
|
1090
|
-
enter<TPresence extends JsonObject, TStorage extends LsonObject = LsonObject, TUserMeta extends BaseUserMeta = BaseUserMeta, TRoomEvent extends Json = never>(roomId: string, options:
|
|
1101
|
+
enter<TPresence extends JsonObject, TStorage extends LsonObject = LsonObject, TUserMeta extends BaseUserMeta = BaseUserMeta, TRoomEvent extends Json = never>(roomId: string, options: EnterOptions<TPresence, TStorage>): Room<TPresence, TStorage, TUserMeta, TRoomEvent>;
|
|
1091
1102
|
/**
|
|
1092
1103
|
* Leaves a room.
|
|
1093
1104
|
* @param roomId The id of the room
|
|
@@ -1600,7 +1611,7 @@ declare type ClientToPanelMessage =
|
|
|
1600
1611
|
| {
|
|
1601
1612
|
msg: "room::sync::full";
|
|
1602
1613
|
roomId: string;
|
|
1603
|
-
status:
|
|
1614
|
+
status: ConnectionStatus;
|
|
1604
1615
|
storage: readonly LsonTreeNode[] | null;
|
|
1605
1616
|
me: UserTreeNode | null;
|
|
1606
1617
|
others: readonly UserTreeNode[];
|
|
@@ -1611,7 +1622,7 @@ declare type ClientToPanelMessage =
|
|
|
1611
1622
|
| {
|
|
1612
1623
|
msg: "room::sync::partial";
|
|
1613
1624
|
roomId: string;
|
|
1614
|
-
status?:
|
|
1625
|
+
status?: ConnectionStatus;
|
|
1615
1626
|
storage?: readonly LsonTreeNode[];
|
|
1616
1627
|
me?: UserTreeNode;
|
|
1617
1628
|
others?: readonly UserTreeNode[];
|
|
@@ -1662,4 +1673,4 @@ declare type EnsureJson<T> = [
|
|
|
1662
1673
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
1663
1674
|
};
|
|
1664
1675
|
|
|
1665
|
-
export { AckOp, AppOnlyAuthToken, AuthToken, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode,
|
|
1676
|
+
export { AckOp, AppOnlyAuthToken, AuthToken, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, ConnectionStatus, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, FetchStorageClientMsg, History, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LiveList, LiveMap, LiveNode, LiveObject, LiveStructure, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomAuthToken, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, StorageStatus, StorageUpdate, ToImmutable, ToJson, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, asArrayWithLegacyMethods, assert, assertNever, b64decode, comparePosition, createClient, deprecate, deprecateIf, errorIf, freeze, isAppOnlyAuthToken, isAuthToken, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isPlainObject, isRoomAuthToken, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, tryParseJson };
|