@liveblocks/core 1.0.2-test4 → 1.0.2
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 +92 -24
- package/dist/index.js +2 -2
- package/package.json +1 -1
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;
|
|
@@ -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
|
|
@@ -1460,6 +1471,63 @@ SerializedCrdt>;
|
|
|
1460
1471
|
declare type ParentToChildNodeMap = Map<string, // Parent's node ID
|
|
1461
1472
|
IdTuple<SerializedChild>[]>;
|
|
1462
1473
|
|
|
1474
|
+
/**
|
|
1475
|
+
* "Plain LSON" is a JSON-based format that's used when serializing Live structures
|
|
1476
|
+
* to send them over HTTP (e.g. in the API endpoint to let users upload their initial
|
|
1477
|
+
* Room storage, in the API endpoint to fetch a Room's storage, ...).
|
|
1478
|
+
*
|
|
1479
|
+
* In the client, you would typically create LSON values using:
|
|
1480
|
+
*
|
|
1481
|
+
* new LiveObject({ x: 0, y: 0 })
|
|
1482
|
+
*
|
|
1483
|
+
* But over HTTP, this has to be serialized somehow. The "Plain LSON" format
|
|
1484
|
+
* is what's used in the POST /init-storage-new endpoint, to allow users to
|
|
1485
|
+
* control which parts of their data structure should be considered "Live"
|
|
1486
|
+
* objects, and which parts are "normal" objects.
|
|
1487
|
+
*
|
|
1488
|
+
* So if they have a structure like:
|
|
1489
|
+
*
|
|
1490
|
+
* { x: 0, y: 0 }
|
|
1491
|
+
*
|
|
1492
|
+
* And want to make it a Live object, they can serialize it by wrapping it in
|
|
1493
|
+
* a special "annotation":
|
|
1494
|
+
*
|
|
1495
|
+
* {
|
|
1496
|
+
* "liveblocksType": "LiveObject",
|
|
1497
|
+
* "data": { x: 0, y: 0 },
|
|
1498
|
+
* }
|
|
1499
|
+
*
|
|
1500
|
+
* This "Plain LSON" data format defines exactly those wrappings.
|
|
1501
|
+
*
|
|
1502
|
+
* To summarize:
|
|
1503
|
+
*
|
|
1504
|
+
* LSON value | Plain LSON equivalent
|
|
1505
|
+
* ----------------------+----------------------------------------------
|
|
1506
|
+
* 42 | 42
|
|
1507
|
+
* [1, 2, 3] | [1, 2, 3]
|
|
1508
|
+
* { x: 0, y: 0 } | { x: 0, y: 0 }
|
|
1509
|
+
* ----------------------+----------------------------------------------
|
|
1510
|
+
* new LiveList(...) | { liveblocksType: "LiveList", data: ... }
|
|
1511
|
+
* new LiveMap(...) | { liveblocksType: "LiveMap", data: ... }
|
|
1512
|
+
* new LiveObject(...) | { liveblocksType: "LiveObject", data: ... }
|
|
1513
|
+
*
|
|
1514
|
+
*/
|
|
1515
|
+
|
|
1516
|
+
declare type PlainLsonFields = Record<string, PlainLson>;
|
|
1517
|
+
declare type PlainLsonObject = {
|
|
1518
|
+
liveblocksType: "LiveObject";
|
|
1519
|
+
data: PlainLsonFields;
|
|
1520
|
+
};
|
|
1521
|
+
declare type PlainLsonMap = {
|
|
1522
|
+
liveblocksType: "LiveMap";
|
|
1523
|
+
data: PlainLsonFields;
|
|
1524
|
+
};
|
|
1525
|
+
declare type PlainLsonList = {
|
|
1526
|
+
liveblocksType: "LiveList";
|
|
1527
|
+
data: PlainLson[];
|
|
1528
|
+
};
|
|
1529
|
+
declare type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
|
|
1530
|
+
|
|
1463
1531
|
declare enum WebsocketCloseCodes {
|
|
1464
1532
|
CLOSE_ABNORMAL = 1006,
|
|
1465
1533
|
INVALID_MESSAGE_FORMAT = 4000,
|
|
@@ -1605,4 +1673,4 @@ declare type EnsureJson<T> = [
|
|
|
1605
1673
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
1606
1674
|
};
|
|
1607
1675
|
|
|
1608
|
-
export { AckOp, AppOnlyAuthToken, AuthToken, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, ConnectionState, 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, 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 };
|
|
1676
|
+
export { AckOp, AppOnlyAuthToken, AuthToken, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, ConnectionState, 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 };
|
package/dist/index.js
CHANGED
|
@@ -113,7 +113,7 @@ if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
|
113
113
|
var onMessageFromPanel = eventSource.observable;
|
|
114
114
|
|
|
115
115
|
// src/devtools/index.ts
|
|
116
|
-
var VERSION = true ? "1.0.2
|
|
116
|
+
var VERSION = true ? "1.0.2" : "dev";
|
|
117
117
|
var _devtoolsSetupHasRun = false;
|
|
118
118
|
function setupDevTools(getAllRooms) {
|
|
119
119
|
if (process.env.NODE_ENV === "production" || typeof window === "undefined") {
|
|
@@ -4178,7 +4178,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
|
|
|
4178
4178
|
const ws = WebSocketPolyfill || WebSocket;
|
|
4179
4179
|
return (token) => {
|
|
4180
4180
|
return new ws(
|
|
4181
|
-
`${liveblocksServer}/?token=${token}&version=${true ? "1.0.2
|
|
4181
|
+
`${liveblocksServer}/?token=${token}&version=${true ? "1.0.2" : "dev"}`
|
|
4182
4182
|
);
|
|
4183
4183
|
};
|
|
4184
4184
|
}
|