@liveblocks/core
Advanced tools
Comparing version
@@ -1463,2 +1463,59 @@ /** | ||
/** | ||
* "Plain LSON" is a JSON-based format that's used when serializing Live structures | ||
* to send them over HTTP (e.g. in the API endpoint to let users upload their initial | ||
* Room storage, in the API endpoint to fetch a Room's storage, ...). | ||
* | ||
* In the client, you would typically create LSON values using: | ||
* | ||
* new LiveObject({ x: 0, y: 0 }) | ||
* | ||
* But over HTTP, this has to be serialized somehow. The "Plain LSON" format | ||
* is what's used in the POST /init-storage-new endpoint, to allow users to | ||
* control which parts of their data structure should be considered "Live" | ||
* objects, and which parts are "normal" objects. | ||
* | ||
* So if they have a structure like: | ||
* | ||
* { x: 0, y: 0 } | ||
* | ||
* And want to make it a Live object, they can serialize it by wrapping it in | ||
* a special "annotation": | ||
* | ||
* { | ||
* "liveblocksType": "LiveObject", | ||
* "data": { x: 0, y: 0 }, | ||
* } | ||
* | ||
* This "Plain LSON" data format defines exactly those wrappings. | ||
* | ||
* To summarize: | ||
* | ||
* LSON value | Plain LSON equivalent | ||
* ----------------------+---------------------------------------------- | ||
* 42 | 42 | ||
* [1, 2, 3] | [1, 2, 3] | ||
* { x: 0, y: 0 } | { x: 0, y: 0 } | ||
* ----------------------+---------------------------------------------- | ||
* new LiveList(...) | { liveblocksType: "LiveList", data: ... } | ||
* new LiveMap(...) | { liveblocksType: "LiveMap", data: ... } | ||
* new LiveObject(...) | { liveblocksType: "LiveObject", data: ... } | ||
* | ||
*/ | ||
declare type PlainLsonFields = Record<string, PlainLson>; | ||
declare type PlainLsonObject = { | ||
liveblocksType: "LiveObject"; | ||
data: PlainLsonFields; | ||
}; | ||
declare type PlainLsonMap = { | ||
liveblocksType: "LiveMap"; | ||
data: PlainLsonFields; | ||
}; | ||
declare type PlainLsonList = { | ||
liveblocksType: "LiveList"; | ||
data: PlainLson[]; | ||
}; | ||
declare type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json; | ||
declare enum WebsocketCloseCodes { | ||
@@ -1609,2 +1666,2 @@ CLOSE_ABNORMAL = 1006, | ||
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 }; | ||
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 }; |
{ | ||
"name": "@liveblocks/core", | ||
"version": "1.0.2-test4", | ||
"version": "1.0.2-test5", | ||
"description": "Shared code and foundational internals for Liveblocks", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is too big to display
205045
1%6350
0.87%