@liveblocks/client 0.16.12 → 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 +1 -1
- package/index.js +31 -44
- package/index.mjs +35 -47
- package/internal.d.ts +77 -199
- package/internal.js +13 -15
- package/internal.mjs +14 -16
- package/package.json +13 -9
- package/shared.d.ts +342 -181
- package/shared.js +590 -341
- package/shared.mjs +625 -306
package/shared.d.ts
CHANGED
|
@@ -1,100 +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
|
-
* Adds or updates an element with a specified key and a value.
|
|
38
|
-
* @param key The key of the element to add. Should be a string.
|
|
39
|
-
* @param value The value of the element to add. Should be serializable to JSON.
|
|
40
|
-
*/
|
|
41
|
-
set(key: TKey, value: TValue): void;
|
|
42
|
-
/**
|
|
43
|
-
* Returns the number of elements in the LiveMap.
|
|
44
|
-
*/
|
|
45
|
-
get size(): number;
|
|
46
|
-
/**
|
|
47
|
-
* Returns a boolean indicating whether an element with the specified key exists or not.
|
|
48
|
-
* @param key The key of the element to test for presence.
|
|
49
|
-
*/
|
|
50
|
-
has(key: TKey): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Removes the specified element by key.
|
|
53
|
-
* @param key The key of the element to remove.
|
|
54
|
-
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
55
|
-
*/
|
|
56
|
-
delete(key: TKey): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Returns a new Iterator object that contains the [key, value] pairs for each element.
|
|
59
|
-
*/
|
|
60
|
-
entries(): IterableIterator<[TKey, TValue]>;
|
|
61
|
-
/**
|
|
62
|
-
* Same function object as the initial value of the entries method.
|
|
63
|
-
*/
|
|
64
|
-
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
65
|
-
/**
|
|
66
|
-
* Returns a new Iterator object that contains the keys for each element.
|
|
67
|
-
*/
|
|
68
|
-
keys(): IterableIterator<TKey>;
|
|
69
|
-
/**
|
|
70
|
-
* Returns a new Iterator object that contains the values for each element.
|
|
71
|
-
*/
|
|
72
|
-
values(): IterableIterator<TValue>;
|
|
73
|
-
/**
|
|
74
|
-
* Executes a provided function once per each key/value pair in the Map object, in insertion order.
|
|
75
|
-
* @param callback Function to execute for each entry in the map.
|
|
76
|
-
*/
|
|
77
|
-
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;
|
|
78
27
|
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Think of Lson as a sibling of the Json data tree, except that the nested
|
|
82
|
-
* data structure can contain a mix of Json values and LiveStructure instances.
|
|
83
|
-
*/
|
|
84
|
-
declare type Lson = Json | LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
|
|
85
|
-
/**
|
|
86
|
-
* A mapping of keys to Lson values. A Lson value is any valid JSON
|
|
87
|
-
* value or a Live storage data structure (LiveMap, LiveList, etc.)
|
|
88
|
-
*/
|
|
89
|
-
declare type LsonObject = {
|
|
90
|
-
[key: string]: Lson | undefined;
|
|
91
|
-
};
|
|
92
28
|
|
|
93
29
|
/**
|
|
94
30
|
* The LiveList class represents an ordered collection of items that is synchronized across clients.
|
|
95
31
|
*/
|
|
96
|
-
declare class LiveList<TItem extends Lson
|
|
32
|
+
declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
97
33
|
private _items;
|
|
34
|
+
private _implicitlyDeletedItems;
|
|
98
35
|
constructor(items?: TItem[]);
|
|
99
36
|
/**
|
|
100
37
|
* Returns the number of elements.
|
|
@@ -192,6 +129,303 @@ declare class LiveList<TItem extends Lson = Lson> extends AbstractCrdt {
|
|
|
192
129
|
[Symbol.iterator](): IterableIterator<TItem>;
|
|
193
130
|
}
|
|
194
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
|
+
|
|
195
429
|
/**
|
|
196
430
|
* This helper type is effectively a no-op, but will force TypeScript to
|
|
197
431
|
* "evaluate" any named helper types in its definition. This can sometimes make
|
|
@@ -214,7 +448,7 @@ declare class LiveList<TItem extends Lson = Lson> extends AbstractCrdt {
|
|
|
214
448
|
* This trick comes from:
|
|
215
449
|
* https://effectivetypescript.com/2022/02/25/gentips-4-display/
|
|
216
450
|
*/
|
|
217
|
-
declare type Resolve<T> = T extends
|
|
451
|
+
declare type Resolve<T> = T extends (...args: any[]) => any ? T : {
|
|
218
452
|
[K in keyof T]: T[K];
|
|
219
453
|
};
|
|
220
454
|
declare type MyPresenceCallback<T extends Presence = Presence> = (me: T) => void;
|
|
@@ -426,10 +660,10 @@ interface History {
|
|
|
426
660
|
* It does not impact operations made by other clients.
|
|
427
661
|
*
|
|
428
662
|
* @example
|
|
429
|
-
* room.updatePresence({ selectedId: "
|
|
430
|
-
* room.updatePresence({ selectedId: "
|
|
663
|
+
* room.updatePresence({ selectedId: "xx" }, { addToHistory: true });
|
|
664
|
+
* room.updatePresence({ selectedId: "yy" }, { addToHistory: true });
|
|
431
665
|
* room.history.undo();
|
|
432
|
-
* // room.getPresence() equals { selectedId: "
|
|
666
|
+
* // room.getPresence() equals { selectedId: "xx" }
|
|
433
667
|
*/
|
|
434
668
|
undo: () => void;
|
|
435
669
|
/**
|
|
@@ -437,12 +671,12 @@ interface History {
|
|
|
437
671
|
* It does not impact operations made by other clients.
|
|
438
672
|
*
|
|
439
673
|
* @example
|
|
440
|
-
* room.updatePresence({ selectedId: "
|
|
441
|
-
* room.updatePresence({ selectedId: "
|
|
674
|
+
* room.updatePresence({ selectedId: "xx" }, { addToHistory: true });
|
|
675
|
+
* room.updatePresence({ selectedId: "yy" }, { addToHistory: true });
|
|
442
676
|
* room.history.undo();
|
|
443
|
-
* // room.getPresence() equals { selectedId: "
|
|
677
|
+
* // room.getPresence() equals { selectedId: "xx" }
|
|
444
678
|
* room.history.redo();
|
|
445
|
-
* // room.getPresence() equals { selectedId: "
|
|
679
|
+
* // room.getPresence() equals { selectedId: "yy" }
|
|
446
680
|
*/
|
|
447
681
|
redo: () => void;
|
|
448
682
|
/**
|
|
@@ -615,43 +849,6 @@ declare type Room = {
|
|
|
615
849
|
* Room's history contains functions that let you undo and redo operation made on by the current client on the presence and storage.
|
|
616
850
|
*/
|
|
617
851
|
history: History;
|
|
618
|
-
/**
|
|
619
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
620
|
-
* See v0.13 release notes for more information.
|
|
621
|
-
* Will be removed in a future version.
|
|
622
|
-
*/
|
|
623
|
-
unsubscribe: {
|
|
624
|
-
/**
|
|
625
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
626
|
-
* See v0.13 release notes for more information.
|
|
627
|
-
* Will be removed in a future version.
|
|
628
|
-
*/
|
|
629
|
-
<T extends Presence>(type: "my-presence", listener: MyPresenceCallback<T>): void;
|
|
630
|
-
/**
|
|
631
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
632
|
-
* See v0.13 release notes for more information.
|
|
633
|
-
* Will be removed in a future version.
|
|
634
|
-
*/
|
|
635
|
-
<T extends Presence>(type: "others", listener: OthersEventCallback<T>): void;
|
|
636
|
-
/**
|
|
637
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
638
|
-
* See v0.13 release notes for more information.
|
|
639
|
-
* Will be removed in a future version.
|
|
640
|
-
*/
|
|
641
|
-
(type: "event", listener: EventCallback): void;
|
|
642
|
-
/**
|
|
643
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
644
|
-
* See v0.13 release notes for more information.
|
|
645
|
-
* Will be removed in a future version.
|
|
646
|
-
*/
|
|
647
|
-
(type: "error", listener: ErrorCallback): void;
|
|
648
|
-
/**
|
|
649
|
-
* @deprecated use the callback returned by subscribe instead.
|
|
650
|
-
* See v0.13 release notes for more information.
|
|
651
|
-
* Will be removed in a future version.
|
|
652
|
-
*/
|
|
653
|
-
(type: "connection", listener: ConnectionCallback): void;
|
|
654
|
-
};
|
|
655
852
|
/**
|
|
656
853
|
* Gets the current user.
|
|
657
854
|
* Returns null if not it is not yet connected to the room.
|
|
@@ -733,51 +930,15 @@ declare type Room = {
|
|
|
733
930
|
*/
|
|
734
931
|
batch: (fn: () => void) => void;
|
|
735
932
|
};
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
/**
|
|
746
|
-
* The LiveObject class is similar to a JavaScript object that is synchronized on all clients.
|
|
747
|
-
* Keys should be a string, and values should be serializable to JSON.
|
|
748
|
-
* If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
|
|
749
|
-
*/
|
|
750
|
-
declare class LiveObject<O extends LsonObject = LsonObject> extends AbstractCrdt {
|
|
751
|
-
private _map;
|
|
752
|
-
private _propToLastUpdate;
|
|
753
|
-
constructor(obj?: O);
|
|
754
|
-
private _applyUpdate;
|
|
755
|
-
private _applyDeleteObjectKey;
|
|
756
|
-
/**
|
|
757
|
-
* Transform the LiveObject into a javascript object
|
|
758
|
-
*/
|
|
759
|
-
toObject(): O;
|
|
760
|
-
/**
|
|
761
|
-
* Adds or updates a property with a specified key and a value.
|
|
762
|
-
* @param key The key of the property to add
|
|
763
|
-
* @param value The value of the property to add
|
|
764
|
-
*/
|
|
765
|
-
set<TKey extends keyof O>(key: TKey, value: O[TKey]): void;
|
|
766
|
-
/**
|
|
767
|
-
* Returns a specified property from the LiveObject.
|
|
768
|
-
* @param key The key of the property to get
|
|
769
|
-
*/
|
|
770
|
-
get<TKey extends keyof O>(key: TKey): O[TKey];
|
|
771
|
-
/**
|
|
772
|
-
* Deletes a key from the LiveObject
|
|
773
|
-
* @param key The key of the property to delete
|
|
774
|
-
*/
|
|
775
|
-
delete(key: keyof O): void;
|
|
776
|
-
/**
|
|
777
|
-
* Adds or updates multiple properties at once with an object.
|
|
778
|
-
* @param overrides The object used to overrides properties
|
|
779
|
-
*/
|
|
780
|
-
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
|
|
781
942
|
}
|
|
782
943
|
|
|
783
|
-
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 };
|