@liveblocks/client 0.16.10 → 0.16.13
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/index.d.ts +14 -2
- package/index.js +32 -45
- package/index.mjs +36 -48
- package/internal.d.ts +86 -182
- package/internal.js +19 -20
- package/internal.mjs +14 -16
- package/package.json +13 -9
- package/shared.d.ts +342 -186
- package/shared.js +608 -350
- package/shared.mjs +644 -314
package/shared.d.ts
CHANGED
|
@@ -1,105 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* - JsonScalar any legal JSON leaf value (no lists or objects)
|
|
7
|
-
* - JsonArray a JSON value whose outer type is an array
|
|
8
|
-
* - JsonObject a JSON value whose outer type is an object
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
declare type Json = JsonScalar | JsonArray | JsonObject;
|
|
12
|
-
declare type JsonScalar = string | number | boolean | null;
|
|
13
|
-
declare type JsonArray = Json[];
|
|
14
|
-
declare type JsonObject = {
|
|
15
|
-
[key: string]: Json | undefined;
|
|
1
|
+
declare type ApplyResult = {
|
|
2
|
+
reverse: Op[];
|
|
3
|
+
modified: StorageUpdate;
|
|
4
|
+
} | {
|
|
5
|
+
modified: false;
|
|
16
6
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* @param key The key of the element to return.
|
|
38
|
-
* @returns The element associated with the specified key, or undefined if the key can't be found in the LiveMap.
|
|
39
|
-
*/
|
|
40
|
-
get(key: TKey): TValue | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Adds or updates an element with a specified key and a value.
|
|
43
|
-
* @param key The key of the element to add. Should be a string.
|
|
44
|
-
* @param value The value of the element to add. Should be serializable to JSON.
|
|
45
|
-
*/
|
|
46
|
-
set(key: TKey, value: TValue): void;
|
|
47
|
-
/**
|
|
48
|
-
* Returns the number of elements in the LiveMap.
|
|
49
|
-
*/
|
|
50
|
-
get size(): number;
|
|
51
|
-
/**
|
|
52
|
-
* Returns a boolean indicating whether an element with the specified key exists or not.
|
|
53
|
-
* @param key The key of the element to test for presence.
|
|
54
|
-
*/
|
|
55
|
-
has(key: TKey): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Removes the specified element by key.
|
|
58
|
-
* @param key The key of the element to remove.
|
|
59
|
-
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
60
|
-
*/
|
|
61
|
-
delete(key: TKey): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Returns a new Iterator object that contains the [key, value] pairs for each element.
|
|
64
|
-
*/
|
|
65
|
-
entries(): IterableIterator<[TKey, TValue]>;
|
|
66
|
-
/**
|
|
67
|
-
* Same function object as the initial value of the entries method.
|
|
68
|
-
*/
|
|
69
|
-
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
70
|
-
/**
|
|
71
|
-
* Returns a new Iterator object that contains the keys for each element.
|
|
72
|
-
*/
|
|
73
|
-
keys(): IterableIterator<TKey>;
|
|
74
|
-
/**
|
|
75
|
-
* Returns a new Iterator object that contains the values for each element.
|
|
76
|
-
*/
|
|
77
|
-
values(): IterableIterator<TValue>;
|
|
78
|
-
/**
|
|
79
|
-
* Executes a provided function once per each key/value pair in the Map object, in insertion order.
|
|
80
|
-
* @param callback Function to execute for each entry in the map.
|
|
81
|
-
*/
|
|
82
|
-
forEach(callback: (value: TValue, key: TKey, map: LiveMap<TKey, TValue>) => void): void;
|
|
7
|
+
interface Doc {
|
|
8
|
+
roomId: string;
|
|
9
|
+
generateId: () => string;
|
|
10
|
+
generateOpId: () => string;
|
|
11
|
+
getItem: (id: string) => LiveNode | undefined;
|
|
12
|
+
addItem: (id: string, liveItem: LiveNode) => void;
|
|
13
|
+
deleteItem: (id: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Dispatching has three responsibilities:
|
|
16
|
+
* - Sends serialized ops to the WebSocket servers
|
|
17
|
+
* - Add reverse operations to the undo/redo stack
|
|
18
|
+
* - Notify room subscribers with updates (in-client, no networking)
|
|
19
|
+
*/
|
|
20
|
+
dispatch: (ops: Op[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
|
|
21
|
+
}
|
|
22
|
+
declare abstract class AbstractCrdt {
|
|
23
|
+
private __doc?;
|
|
24
|
+
private __id?;
|
|
25
|
+
private _parent;
|
|
26
|
+
get roomId(): string | null;
|
|
83
27
|
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Think of Lson as a sibling of the Json data tree, except that the nested
|
|
87
|
-
* data structure can contain a mix of Json values and LiveStructure instances.
|
|
88
|
-
*/
|
|
89
|
-
declare type Lson = Json | LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
|
|
90
|
-
/**
|
|
91
|
-
* A mapping of keys to Lson values. A Lson value is any valid JSON
|
|
92
|
-
* value or a Live storage data structure (LiveMap, LiveList, etc.)
|
|
93
|
-
*/
|
|
94
|
-
declare type LsonObject = {
|
|
95
|
-
[key: string]: Lson | undefined;
|
|
96
|
-
};
|
|
97
28
|
|
|
98
29
|
/**
|
|
99
30
|
* The LiveList class represents an ordered collection of items that is synchronized across clients.
|
|
100
31
|
*/
|
|
101
|
-
declare class LiveList<TItem extends Lson
|
|
32
|
+
declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
102
33
|
private _items;
|
|
34
|
+
private _implicitlyDeletedItems;
|
|
103
35
|
constructor(items?: TItem[]);
|
|
104
36
|
/**
|
|
105
37
|
* Returns the number of elements.
|
|
@@ -197,6 +129,303 @@ declare class LiveList<TItem extends Lson = Lson> extends AbstractCrdt {
|
|
|
197
129
|
[Symbol.iterator](): IterableIterator<TItem>;
|
|
198
130
|
}
|
|
199
131
|
|
|
132
|
+
/**
|
|
133
|
+
* The LiveMap class is similar to a JavaScript Map that is synchronized on all clients.
|
|
134
|
+
* Keys should be a string, and values should be serializable to JSON.
|
|
135
|
+
* If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
|
|
136
|
+
*/
|
|
137
|
+
declare class LiveMap<TKey extends string, TValue extends Lson> extends AbstractCrdt {
|
|
138
|
+
private _map;
|
|
139
|
+
constructor(entries?: readonly (readonly [TKey, TValue])[] | undefined);
|
|
140
|
+
/**
|
|
141
|
+
* @deprecated Please call as `new LiveMap()` or `new LiveMap([])` instead.
|
|
142
|
+
*/
|
|
143
|
+
constructor(entries: null);
|
|
144
|
+
/**
|
|
145
|
+
* Returns a specified element from the LiveMap.
|
|
146
|
+
* @param key The key of the element to return.
|
|
147
|
+
* @returns The element associated with the specified key, or undefined if the key can't be found in the LiveMap.
|
|
148
|
+
*/
|
|
149
|
+
get(key: TKey): TValue | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* Adds or updates an element with a specified key and a value.
|
|
152
|
+
* @param key The key of the element to add. Should be a string.
|
|
153
|
+
* @param value The value of the element to add. Should be serializable to JSON.
|
|
154
|
+
*/
|
|
155
|
+
set(key: TKey, value: TValue): void;
|
|
156
|
+
/**
|
|
157
|
+
* Returns the number of elements in the LiveMap.
|
|
158
|
+
*/
|
|
159
|
+
get size(): number;
|
|
160
|
+
/**
|
|
161
|
+
* Returns a boolean indicating whether an element with the specified key exists or not.
|
|
162
|
+
* @param key The key of the element to test for presence.
|
|
163
|
+
*/
|
|
164
|
+
has(key: TKey): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Removes the specified element by key.
|
|
167
|
+
* @param key The key of the element to remove.
|
|
168
|
+
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
169
|
+
*/
|
|
170
|
+
delete(key: TKey): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Returns a new Iterator object that contains the [key, value] pairs for each element.
|
|
173
|
+
*/
|
|
174
|
+
entries(): IterableIterator<[TKey, TValue]>;
|
|
175
|
+
/**
|
|
176
|
+
* Same function object as the initial value of the entries method.
|
|
177
|
+
*/
|
|
178
|
+
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
179
|
+
/**
|
|
180
|
+
* Returns a new Iterator object that contains the keys for each element.
|
|
181
|
+
*/
|
|
182
|
+
keys(): IterableIterator<TKey>;
|
|
183
|
+
/**
|
|
184
|
+
* Returns a new Iterator object that contains the values for each element.
|
|
185
|
+
*/
|
|
186
|
+
values(): IterableIterator<TValue>;
|
|
187
|
+
/**
|
|
188
|
+
* Executes a provided function once per each key/value pair in the Map object, in insertion order.
|
|
189
|
+
* @param callback Function to execute for each entry in the map.
|
|
190
|
+
*/
|
|
191
|
+
forEach(callback: (value: TValue, key: TKey, map: LiveMap<TKey, TValue>) => void): void;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The LiveObject class is similar to a JavaScript object that is synchronized on all clients.
|
|
196
|
+
* Keys should be a string, and values should be serializable to JSON.
|
|
197
|
+
* If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
|
|
198
|
+
*/
|
|
199
|
+
declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
200
|
+
private _map;
|
|
201
|
+
private _propToLastUpdate;
|
|
202
|
+
constructor(obj?: O);
|
|
203
|
+
private _applyUpdate;
|
|
204
|
+
private _applyDeleteObjectKey;
|
|
205
|
+
/**
|
|
206
|
+
* Transform the LiveObject into a javascript object
|
|
207
|
+
*/
|
|
208
|
+
toObject(): O;
|
|
209
|
+
/**
|
|
210
|
+
* Adds or updates a property with a specified key and a value.
|
|
211
|
+
* @param key The key of the property to add
|
|
212
|
+
* @param value The value of the property to add
|
|
213
|
+
*/
|
|
214
|
+
set<TKey extends keyof O>(key: TKey, value: O[TKey]): void;
|
|
215
|
+
/**
|
|
216
|
+
* Returns a specified property from the LiveObject.
|
|
217
|
+
* @param key The key of the property to get
|
|
218
|
+
*/
|
|
219
|
+
get<TKey extends keyof O>(key: TKey): O[TKey];
|
|
220
|
+
/**
|
|
221
|
+
* Deletes a key from the LiveObject
|
|
222
|
+
* @param key The key of the property to delete
|
|
223
|
+
*/
|
|
224
|
+
delete(key: keyof O): void;
|
|
225
|
+
/**
|
|
226
|
+
* Adds or updates multiple properties at once with an object.
|
|
227
|
+
* @param overrides The object used to overrides properties
|
|
228
|
+
*/
|
|
229
|
+
update(overrides: Partial<O>): void;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Represents an indefinitely deep arbitrary JSON data structure. There are
|
|
234
|
+
* four types that make up the Json family:
|
|
235
|
+
*
|
|
236
|
+
* - Json any legal JSON value
|
|
237
|
+
* - JsonScalar any legal JSON leaf value (no lists or objects)
|
|
238
|
+
* - JsonArray a JSON value whose outer type is an array
|
|
239
|
+
* - JsonObject a JSON value whose outer type is an object
|
|
240
|
+
*
|
|
241
|
+
*/
|
|
242
|
+
declare type Json = JsonScalar | JsonArray | JsonObject;
|
|
243
|
+
declare type JsonScalar = string | number | boolean | null;
|
|
244
|
+
declare type JsonArray = Json[];
|
|
245
|
+
declare type JsonObject = {
|
|
246
|
+
[key: string]: Json | undefined;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* INTERNAL
|
|
251
|
+
*/
|
|
252
|
+
declare class LiveRegister<TValue extends Json> extends AbstractCrdt {
|
|
253
|
+
_data: TValue;
|
|
254
|
+
constructor(data: TValue);
|
|
255
|
+
get data(): TValue;
|
|
256
|
+
/**
|
|
257
|
+
* INTERNAL
|
|
258
|
+
*/
|
|
259
|
+
static _deserialize([id, item]: IdTuple<SerializedRegister>, _parentToChildren: ParentToChildNodeMap, doc: Doc): LiveRegister<Json>;
|
|
260
|
+
/**
|
|
261
|
+
* INTERNAL
|
|
262
|
+
*/
|
|
263
|
+
_serialize(parentId: string, parentKey: string, doc?: Doc): Op[];
|
|
264
|
+
/**
|
|
265
|
+
* INTERNAL
|
|
266
|
+
*/
|
|
267
|
+
_toSerializedCrdt(): SerializedRegister;
|
|
268
|
+
_attachChild(_op: CreateChildOp): ApplyResult;
|
|
269
|
+
_detachChild(_crdt: LiveNode): ApplyResult;
|
|
270
|
+
_apply(op: Op, isLocal: boolean): ApplyResult;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
declare type LiveStructure = LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
|
|
274
|
+
/**
|
|
275
|
+
* Think of Lson as a sibling of the Json data tree, except that the nested
|
|
276
|
+
* data structure can contain a mix of Json values and LiveStructure instances.
|
|
277
|
+
*/
|
|
278
|
+
declare type Lson = Json | LiveStructure;
|
|
279
|
+
/**
|
|
280
|
+
* LiveNode is the internal tree for managing Live data structures. The key
|
|
281
|
+
* difference with Lson is that all the Json values get represented in
|
|
282
|
+
* a LiveRegister node.
|
|
283
|
+
*/
|
|
284
|
+
declare type LiveNode = LiveStructure | LiveRegister<Json>;
|
|
285
|
+
/**
|
|
286
|
+
* A mapping of keys to Lson values. A Lson value is any valid JSON
|
|
287
|
+
* value or a Live storage data structure (LiveMap, LiveList, etc.)
|
|
288
|
+
*/
|
|
289
|
+
declare type LsonObject = {
|
|
290
|
+
[key: string]: Lson | undefined;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
declare enum OpCode {
|
|
294
|
+
INIT = 0,
|
|
295
|
+
SET_PARENT_KEY = 1,
|
|
296
|
+
CREATE_LIST = 2,
|
|
297
|
+
UPDATE_OBJECT = 3,
|
|
298
|
+
CREATE_OBJECT = 4,
|
|
299
|
+
DELETE_CRDT = 5,
|
|
300
|
+
DELETE_OBJECT_KEY = 6,
|
|
301
|
+
CREATE_MAP = 7,
|
|
302
|
+
CREATE_REGISTER = 8
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
306
|
+
* only.
|
|
307
|
+
*/
|
|
308
|
+
declare type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
|
|
309
|
+
declare type CreateOp = CreateRootObjectOp | CreateChildOp;
|
|
310
|
+
declare type CreateChildOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
311
|
+
declare type UpdateObjectOp = {
|
|
312
|
+
opId?: string;
|
|
313
|
+
id: string;
|
|
314
|
+
type: OpCode.UPDATE_OBJECT;
|
|
315
|
+
data: Partial<JsonObject>;
|
|
316
|
+
};
|
|
317
|
+
declare type CreateObjectOp = {
|
|
318
|
+
opId?: string;
|
|
319
|
+
id: string;
|
|
320
|
+
intent?: "set";
|
|
321
|
+
deletedId?: string;
|
|
322
|
+
type: OpCode.CREATE_OBJECT;
|
|
323
|
+
parentId: string;
|
|
324
|
+
parentKey: string;
|
|
325
|
+
data: JsonObject;
|
|
326
|
+
};
|
|
327
|
+
declare type CreateRootObjectOp = Resolve<Omit<CreateObjectOp, "parentId" | "parentKey"> & {
|
|
328
|
+
parentId?: never;
|
|
329
|
+
parentKey?: never;
|
|
330
|
+
}>;
|
|
331
|
+
declare type CreateListOp = {
|
|
332
|
+
opId?: string;
|
|
333
|
+
id: string;
|
|
334
|
+
intent?: "set";
|
|
335
|
+
deletedId?: string;
|
|
336
|
+
type: OpCode.CREATE_LIST;
|
|
337
|
+
parentId: string;
|
|
338
|
+
parentKey: string;
|
|
339
|
+
};
|
|
340
|
+
declare type CreateMapOp = {
|
|
341
|
+
opId?: string;
|
|
342
|
+
id: string;
|
|
343
|
+
intent?: "set";
|
|
344
|
+
deletedId?: string;
|
|
345
|
+
type: OpCode.CREATE_MAP;
|
|
346
|
+
parentId: string;
|
|
347
|
+
parentKey: string;
|
|
348
|
+
};
|
|
349
|
+
declare type CreateRegisterOp = {
|
|
350
|
+
opId?: string;
|
|
351
|
+
id: string;
|
|
352
|
+
intent?: "set";
|
|
353
|
+
deletedId?: string;
|
|
354
|
+
type: OpCode.CREATE_REGISTER;
|
|
355
|
+
parentId: string;
|
|
356
|
+
parentKey: string;
|
|
357
|
+
data: Json;
|
|
358
|
+
};
|
|
359
|
+
declare type DeleteCrdtOp = {
|
|
360
|
+
opId?: string;
|
|
361
|
+
id: string;
|
|
362
|
+
type: OpCode.DELETE_CRDT;
|
|
363
|
+
};
|
|
364
|
+
declare type SetParentKeyOp = {
|
|
365
|
+
opId?: string;
|
|
366
|
+
id: string;
|
|
367
|
+
type: OpCode.SET_PARENT_KEY;
|
|
368
|
+
parentKey: string;
|
|
369
|
+
};
|
|
370
|
+
declare type DeleteObjectKeyOp = {
|
|
371
|
+
opId?: string;
|
|
372
|
+
id: string;
|
|
373
|
+
type: OpCode.DELETE_OBJECT_KEY;
|
|
374
|
+
key: string;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
declare type IdTuple<T> = [id: string, value: T];
|
|
378
|
+
declare enum CrdtType {
|
|
379
|
+
OBJECT = 0,
|
|
380
|
+
LIST = 1,
|
|
381
|
+
MAP = 2,
|
|
382
|
+
REGISTER = 3
|
|
383
|
+
}
|
|
384
|
+
declare type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
385
|
+
declare type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
386
|
+
declare type SerializedRootObject = {
|
|
387
|
+
type: CrdtType.OBJECT;
|
|
388
|
+
data: JsonObject;
|
|
389
|
+
parentId?: never;
|
|
390
|
+
parentKey?: never;
|
|
391
|
+
};
|
|
392
|
+
declare type SerializedObject = {
|
|
393
|
+
type: CrdtType.OBJECT;
|
|
394
|
+
parentId: string;
|
|
395
|
+
parentKey: string;
|
|
396
|
+
data: JsonObject;
|
|
397
|
+
};
|
|
398
|
+
declare type SerializedList = {
|
|
399
|
+
type: CrdtType.LIST;
|
|
400
|
+
parentId: string;
|
|
401
|
+
parentKey: string;
|
|
402
|
+
};
|
|
403
|
+
declare type SerializedMap = {
|
|
404
|
+
type: CrdtType.MAP;
|
|
405
|
+
parentId: string;
|
|
406
|
+
parentKey: string;
|
|
407
|
+
};
|
|
408
|
+
declare type SerializedRegister = {
|
|
409
|
+
type: CrdtType.REGISTER;
|
|
410
|
+
parentId: string;
|
|
411
|
+
parentKey: string;
|
|
412
|
+
data: Json;
|
|
413
|
+
};
|
|
414
|
+
declare function isRootCrdt(crdt: SerializedCrdt): crdt is SerializedRootObject;
|
|
415
|
+
declare function isChildCrdt(crdt: SerializedCrdt): crdt is SerializedChild;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Lookup table for nodes (= SerializedCrdt values) by their IDs.
|
|
419
|
+
*/
|
|
420
|
+
declare type NodeMap = Map<string, // Node ID
|
|
421
|
+
SerializedCrdt>;
|
|
422
|
+
/**
|
|
423
|
+
* Reverse lookup table for all child nodes (= list of SerializedCrdt values)
|
|
424
|
+
* by their parent node's IDs.
|
|
425
|
+
*/
|
|
426
|
+
declare type ParentToChildNodeMap = Map<string, // Parent's node ID
|
|
427
|
+
IdTuple<SerializedChild>[]>;
|
|
428
|
+
|
|
200
429
|
/**
|
|
201
430
|
* This helper type is effectively a no-op, but will force TypeScript to
|
|
202
431
|
* "evaluate" any named helper types in its definition. This can sometimes make
|
|
@@ -219,7 +448,7 @@ declare class LiveList<TItem extends Lson = Lson> extends AbstractCrdt {
|
|
|
219
448
|
* This trick comes from:
|
|
220
449
|
* https://effectivetypescript.com/2022/02/25/gentips-4-display/
|
|
221
450
|
*/
|
|
222
|
-
declare type Resolve<T> = T extends
|
|
451
|
+
declare type Resolve<T> = T extends (...args: any[]) => any ? T : {
|
|
223
452
|
[K in keyof T]: T[K];
|
|
224
453
|
};
|
|
225
454
|
declare type MyPresenceCallback<T extends Presence = Presence> = (me: T) => void;
|
|
@@ -431,10 +660,10 @@ interface History {
|
|
|
431
660
|
* It does not impact operations made by other clients.
|
|
432
661
|
*
|
|
433
662
|
* @example
|
|
434
|
-
* room.updatePresence({ selectedId: "
|
|
435
|
-
* room.updatePresence({ selectedId: "
|
|
663
|
+
* room.updatePresence({ selectedId: "xx" }, { addToHistory: true });
|
|
664
|
+
* room.updatePresence({ selectedId: "yy" }, { addToHistory: true });
|
|
436
665
|
* room.history.undo();
|
|
437
|
-
* // room.getPresence() equals { selectedId: "
|
|
666
|
+
* // room.getPresence() equals { selectedId: "xx" }
|
|
438
667
|
*/
|
|
439
668
|
undo: () => void;
|
|
440
669
|
/**
|
|
@@ -442,12 +671,12 @@ interface History {
|
|
|
442
671
|
* It does not impact operations made by other clients.
|
|
443
672
|
*
|
|
444
673
|
* @example
|
|
445
|
-
* room.updatePresence({ selectedId: "
|
|
446
|
-
* room.updatePresence({ selectedId: "
|
|
674
|
+
* room.updatePresence({ selectedId: "xx" }, { addToHistory: true });
|
|
675
|
+
* room.updatePresence({ selectedId: "yy" }, { addToHistory: true });
|
|
447
676
|
* room.history.undo();
|
|
448
|
-
* // room.getPresence() equals { selectedId: "
|
|
677
|
+
* // room.getPresence() equals { selectedId: "xx" }
|
|
449
678
|
* room.history.redo();
|
|
450
|
-
* // room.getPresence() equals { selectedId: "
|
|
679
|
+
* // room.getPresence() equals { selectedId: "yy" }
|
|
451
680
|
*/
|
|
452
681
|
redo: () => void;
|
|
453
682
|
/**
|
|
@@ -620,43 +849,6 @@ declare type Room = {
|
|
|
620
849
|
* Room's history contains functions that let you undo and redo operation made on by the current client on the presence and storage.
|
|
621
850
|
*/
|
|
622
851
|
history: History;
|
|
623
|
-
/**
|
|
624
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
625
|
-
* See v0.13 release notes for more information.
|
|
626
|
-
* Will be removed in a future version.
|
|
627
|
-
*/
|
|
628
|
-
unsubscribe: {
|
|
629
|
-
/**
|
|
630
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
631
|
-
* See v0.13 release notes for more information.
|
|
632
|
-
* Will be removed in a future version.
|
|
633
|
-
*/
|
|
634
|
-
<T extends Presence>(type: "my-presence", listener: MyPresenceCallback<T>): void;
|
|
635
|
-
/**
|
|
636
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
637
|
-
* See v0.13 release notes for more information.
|
|
638
|
-
* Will be removed in a future version.
|
|
639
|
-
*/
|
|
640
|
-
<T extends Presence>(type: "others", listener: OthersEventCallback<T>): void;
|
|
641
|
-
/**
|
|
642
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
643
|
-
* See v0.13 release notes for more information.
|
|
644
|
-
* Will be removed in a future version.
|
|
645
|
-
*/
|
|
646
|
-
(type: "event", listener: EventCallback): void;
|
|
647
|
-
/**
|
|
648
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
649
|
-
* See v0.13 release notes for more information.
|
|
650
|
-
* Will be removed in a future version.
|
|
651
|
-
*/
|
|
652
|
-
(type: "error", listener: ErrorCallback): void;
|
|
653
|
-
/**
|
|
654
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
655
|
-
* See v0.13 release notes for more information.
|
|
656
|
-
* Will be removed in a future version.
|
|
657
|
-
*/
|
|
658
|
-
(type: "connection", listener: ConnectionCallback): void;
|
|
659
|
-
};
|
|
660
852
|
/**
|
|
661
853
|
* Gets the current user.
|
|
662
854
|
* Returns null if not it is not yet connected to the room.
|
|
@@ -738,51 +930,15 @@ declare type Room = {
|
|
|
738
930
|
*/
|
|
739
931
|
batch: (fn: () => void) => void;
|
|
740
932
|
};
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
/**
|
|
751
|
-
* The LiveObject class is similar to a JavaScript object that is synchronized on all clients.
|
|
752
|
-
* Keys should be a string, and values should be serializable to JSON.
|
|
753
|
-
* If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
|
|
754
|
-
*/
|
|
755
|
-
declare class LiveObject<O extends LsonObject = LsonObject> extends AbstractCrdt {
|
|
756
|
-
private _map;
|
|
757
|
-
private _propToLastUpdate;
|
|
758
|
-
constructor(obj?: O);
|
|
759
|
-
private _applyUpdate;
|
|
760
|
-
private _applyDeleteObjectKey;
|
|
761
|
-
/**
|
|
762
|
-
* Transform the LiveObject into a javascript object
|
|
763
|
-
*/
|
|
764
|
-
toObject(): O;
|
|
765
|
-
/**
|
|
766
|
-
* Adds or updates a property with a specified key and a value.
|
|
767
|
-
* @param key The key of the property to add
|
|
768
|
-
* @param value The value of the property to add
|
|
769
|
-
*/
|
|
770
|
-
set<TKey extends keyof O>(key: TKey, value: O[TKey]): void;
|
|
771
|
-
/**
|
|
772
|
-
* Returns a specified property from the LiveObject.
|
|
773
|
-
* @param key The key of the property to get
|
|
774
|
-
*/
|
|
775
|
-
get<TKey extends keyof O>(key: TKey): O[TKey];
|
|
776
|
-
/**
|
|
777
|
-
* Deletes a key from the LiveObject
|
|
778
|
-
* @param key The key of the property to delete
|
|
779
|
-
*/
|
|
780
|
-
delete(key: keyof O): void;
|
|
781
|
-
/**
|
|
782
|
-
* Adds or updates multiple properties at once with an object.
|
|
783
|
-
* @param overrides The object used to overrides properties
|
|
784
|
-
*/
|
|
785
|
-
update(overrides: Partial<O>): void;
|
|
933
|
+
declare enum WebsocketCloseCodes {
|
|
934
|
+
CLOSE_ABNORMAL = 1006,
|
|
935
|
+
INVALID_MESSAGE_FORMAT = 4000,
|
|
936
|
+
NOT_ALLOWED = 4001,
|
|
937
|
+
MAX_NUMBER_OF_MESSAGES_PER_SECONDS = 4002,
|
|
938
|
+
MAX_NUMBER_OF_CONCURRENT_CONNECTIONS = 4003,
|
|
939
|
+
MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP = 4004,
|
|
940
|
+
MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM = 4005,
|
|
941
|
+
CLOSE_WITHOUT_RETRY = 4999
|
|
786
942
|
}
|
|
787
943
|
|
|
788
|
-
export {
|
|
944
|
+
export { SerializedRootObject as A, BroadcastOptions as B, ClientOptions as C, DeleteCrdtOp as D, SetParentKeyOp as E, UpdateObjectOp as F, CrdtType as G, History as H, IdTuple as I, Json as J, OpCode as K, LiveList as L, isChildCrdt as M, NodeMap as N, Others as O, Presence as P, isRootCrdt as Q, Room as R, StorageUpdate as S, User as U, WebsocketCloseCodes as W, Client as a, LiveMap as b, LiveObject as c, JsonObject as d, LiveStructure as e, Lson as f, LsonObject as g, Op as h, SerializedCrdt as i, CreateChildOp as j, CreateListOp as k, CreateMapOp as l, CreateObjectOp as m, CreateOp as n, CreateRegisterOp as o, CreateRootObjectOp as p, DeleteObjectKeyOp as q, LiveNode as r, ParentToChildNodeMap as s, Resolve as t, RoomInitializers as u, SerializedChild as v, SerializedList as w, SerializedMap as x, SerializedObject as y, SerializedRegister as z };
|