@liveblocks/core 1.0.8 → 1.1.0-fsm1
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 +66 -59
- package/dist/index.js +949 -362
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -129,6 +129,63 @@ declare type UpdateDelta = {
|
|
|
129
129
|
type: "delete";
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* "Plain LSON" is a JSON-based format that's used when serializing Live structures
|
|
134
|
+
* to send them over HTTP (e.g. in the API endpoint to let users upload their initial
|
|
135
|
+
* Room storage, in the API endpoint to fetch a Room's storage, ...).
|
|
136
|
+
*
|
|
137
|
+
* In the client, you would typically create LSON values using:
|
|
138
|
+
*
|
|
139
|
+
* new LiveObject({ x: 0, y: 0 })
|
|
140
|
+
*
|
|
141
|
+
* But over HTTP, this has to be serialized somehow. The "Plain LSON" format
|
|
142
|
+
* is what's used in the POST /init-storage-new endpoint, to allow users to
|
|
143
|
+
* control which parts of their data structure should be considered "Live"
|
|
144
|
+
* objects, and which parts are "normal" objects.
|
|
145
|
+
*
|
|
146
|
+
* So if they have a structure like:
|
|
147
|
+
*
|
|
148
|
+
* { x: 0, y: 0 }
|
|
149
|
+
*
|
|
150
|
+
* And want to make it a Live object, they can serialize it by wrapping it in
|
|
151
|
+
* a special "annotation":
|
|
152
|
+
*
|
|
153
|
+
* {
|
|
154
|
+
* "liveblocksType": "LiveObject",
|
|
155
|
+
* "data": { x: 0, y: 0 },
|
|
156
|
+
* }
|
|
157
|
+
*
|
|
158
|
+
* This "Plain LSON" data format defines exactly those wrappings.
|
|
159
|
+
*
|
|
160
|
+
* To summarize:
|
|
161
|
+
*
|
|
162
|
+
* LSON value | Plain LSON equivalent
|
|
163
|
+
* ----------------------+----------------------------------------------
|
|
164
|
+
* 42 | 42
|
|
165
|
+
* [1, 2, 3] | [1, 2, 3]
|
|
166
|
+
* { x: 0, y: 0 } | { x: 0, y: 0 }
|
|
167
|
+
* ----------------------+----------------------------------------------
|
|
168
|
+
* new LiveList(...) | { liveblocksType: "LiveList", data: ... }
|
|
169
|
+
* new LiveMap(...) | { liveblocksType: "LiveMap", data: ... }
|
|
170
|
+
* new LiveObject(...) | { liveblocksType: "LiveObject", data: ... }
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
declare type PlainLsonFields = Record<string, PlainLson>;
|
|
175
|
+
declare type PlainLsonObject = {
|
|
176
|
+
liveblocksType: "LiveObject";
|
|
177
|
+
data: PlainLsonFields;
|
|
178
|
+
};
|
|
179
|
+
declare type PlainLsonMap = {
|
|
180
|
+
liveblocksType: "LiveMap";
|
|
181
|
+
data: PlainLsonFields;
|
|
182
|
+
};
|
|
183
|
+
declare type PlainLsonList = {
|
|
184
|
+
liveblocksType: "LiveList";
|
|
185
|
+
data: PlainLson[];
|
|
186
|
+
};
|
|
187
|
+
declare type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
|
|
188
|
+
|
|
132
189
|
declare type LiveObjectUpdateDelta<O extends {
|
|
133
190
|
[key: string]: unknown;
|
|
134
191
|
}> = {
|
|
@@ -197,6 +254,10 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
197
254
|
declare type ToImmutable<L extends Lson | LsonObject> = L extends LiveList<infer I> ? readonly ToImmutable<I>[] : L extends LiveObject<infer O> ? ToImmutable<O> : L extends LiveMap<infer K, infer V> ? ReadonlyMap<K, ToImmutable<V>> : L extends LsonObject ? {
|
|
198
255
|
readonly [K in keyof L]: ToImmutable<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
|
|
199
256
|
} : L extends Json ? L : never;
|
|
257
|
+
/**
|
|
258
|
+
* Returns PlainLson for a given Json or LiveStructure, suitable for calling the storage init api
|
|
259
|
+
*/
|
|
260
|
+
declare function toPlainLson(lson: Lson): PlainLson;
|
|
200
261
|
|
|
201
262
|
/**
|
|
202
263
|
* A LiveMap notification that is sent in-client to any subscribers whenever
|
|
@@ -268,12 +329,15 @@ declare class LiveMap<TKey extends string, TValue extends Lson> extends Abstract
|
|
|
268
329
|
}
|
|
269
330
|
|
|
270
331
|
declare type StorageCallback = (updates: StorageUpdate[]) => void;
|
|
332
|
+
declare type LiveMapUpdate = LiveMapUpdates<string, Lson>;
|
|
333
|
+
declare type LiveObjectUpdate = LiveObjectUpdates<LsonObject>;
|
|
334
|
+
declare type LiveListUpdate = LiveListUpdates<Lson>;
|
|
271
335
|
/**
|
|
272
336
|
* The payload of notifications sent (in-client) when LiveStructures change.
|
|
273
337
|
* Messages of this kind are not originating from the network, but are 100%
|
|
274
338
|
* in-client.
|
|
275
339
|
*/
|
|
276
|
-
declare type StorageUpdate =
|
|
340
|
+
declare type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
|
|
277
341
|
|
|
278
342
|
declare abstract class AbstractCrdt {
|
|
279
343
|
get roomId(): string | null;
|
|
@@ -1546,63 +1610,6 @@ SerializedCrdt>;
|
|
|
1546
1610
|
declare type ParentToChildNodeMap = Map<string, // Parent's node ID
|
|
1547
1611
|
IdTuple<SerializedChild>[]>;
|
|
1548
1612
|
|
|
1549
|
-
/**
|
|
1550
|
-
* "Plain LSON" is a JSON-based format that's used when serializing Live structures
|
|
1551
|
-
* to send them over HTTP (e.g. in the API endpoint to let users upload their initial
|
|
1552
|
-
* Room storage, in the API endpoint to fetch a Room's storage, ...).
|
|
1553
|
-
*
|
|
1554
|
-
* In the client, you would typically create LSON values using:
|
|
1555
|
-
*
|
|
1556
|
-
* new LiveObject({ x: 0, y: 0 })
|
|
1557
|
-
*
|
|
1558
|
-
* But over HTTP, this has to be serialized somehow. The "Plain LSON" format
|
|
1559
|
-
* is what's used in the POST /init-storage-new endpoint, to allow users to
|
|
1560
|
-
* control which parts of their data structure should be considered "Live"
|
|
1561
|
-
* objects, and which parts are "normal" objects.
|
|
1562
|
-
*
|
|
1563
|
-
* So if they have a structure like:
|
|
1564
|
-
*
|
|
1565
|
-
* { x: 0, y: 0 }
|
|
1566
|
-
*
|
|
1567
|
-
* And want to make it a Live object, they can serialize it by wrapping it in
|
|
1568
|
-
* a special "annotation":
|
|
1569
|
-
*
|
|
1570
|
-
* {
|
|
1571
|
-
* "liveblocksType": "LiveObject",
|
|
1572
|
-
* "data": { x: 0, y: 0 },
|
|
1573
|
-
* }
|
|
1574
|
-
*
|
|
1575
|
-
* This "Plain LSON" data format defines exactly those wrappings.
|
|
1576
|
-
*
|
|
1577
|
-
* To summarize:
|
|
1578
|
-
*
|
|
1579
|
-
* LSON value | Plain LSON equivalent
|
|
1580
|
-
* ----------------------+----------------------------------------------
|
|
1581
|
-
* 42 | 42
|
|
1582
|
-
* [1, 2, 3] | [1, 2, 3]
|
|
1583
|
-
* { x: 0, y: 0 } | { x: 0, y: 0 }
|
|
1584
|
-
* ----------------------+----------------------------------------------
|
|
1585
|
-
* new LiveList(...) | { liveblocksType: "LiveList", data: ... }
|
|
1586
|
-
* new LiveMap(...) | { liveblocksType: "LiveMap", data: ... }
|
|
1587
|
-
* new LiveObject(...) | { liveblocksType: "LiveObject", data: ... }
|
|
1588
|
-
*
|
|
1589
|
-
*/
|
|
1590
|
-
|
|
1591
|
-
declare type PlainLsonFields = Record<string, PlainLson>;
|
|
1592
|
-
declare type PlainLsonObject = {
|
|
1593
|
-
liveblocksType: "LiveObject";
|
|
1594
|
-
data: PlainLsonFields;
|
|
1595
|
-
};
|
|
1596
|
-
declare type PlainLsonMap = {
|
|
1597
|
-
liveblocksType: "LiveMap";
|
|
1598
|
-
data: PlainLsonFields;
|
|
1599
|
-
};
|
|
1600
|
-
declare type PlainLsonList = {
|
|
1601
|
-
liveblocksType: "LiveList";
|
|
1602
|
-
data: PlainLson[];
|
|
1603
|
-
};
|
|
1604
|
-
declare type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
|
|
1605
|
-
|
|
1606
1613
|
declare type JsonTreeNode = {
|
|
1607
1614
|
readonly type: "Json";
|
|
1608
1615
|
readonly id: string;
|
|
@@ -1779,4 +1786,4 @@ declare type EnsureJson<T> = [
|
|
|
1779
1786
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
1780
1787
|
};
|
|
1781
1788
|
|
|
1782
|
-
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, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, 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, asPos, assert, assertNever, b64decode, createClient, deprecate, deprecateIf, errorIf, freeze, isAppOnlyAuthToken, isAuthToken, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isPlainObject, isRoomAuthToken, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, tryParseJson };
|
|
1789
|
+
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, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, 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, asPos, assert, assertNever, b64decode, createClient, deprecate, deprecateIf, errorIf, freeze, isAppOnlyAuthToken, isAuthToken, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isPlainObject, isRoomAuthToken, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, toPlainLson, tryParseJson };
|