@liveblocks/client 0.15.10 → 0.16.0

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/lib/index.d.ts CHANGED
@@ -1,9 +1,97 @@
1
1
  /**
2
- * The LiveList class represents an ordered collection of items that is synchorinized across clients.
2
+ * Represents an indefinitely deep arbitrary JSON data structure. There are
3
+ * four types that make up the Json family:
4
+ *
5
+ * - Json any legal JSON value
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;
16
+ };
17
+
18
+ /**
19
+ * The LiveMap class is similar to a JavaScript Map that is synchronized on all clients.
20
+ * Keys should be a string, and values should be serializable to JSON.
21
+ * If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
22
+ */
23
+ declare class LiveMap<TKey extends string = string, TValue extends Lson = Lson> extends AbstractCrdt {
24
+ private _map;
25
+ constructor(entries?: readonly (readonly [TKey, TValue])[] | null | undefined);
26
+ /**
27
+ * Returns a specified element from the LiveMap.
28
+ * @param key The key of the element to return.
29
+ * @returns The element associated with the specified key, or undefined if the key can't be found in the LiveMap.
30
+ */
31
+ get(key: TKey): TValue | undefined;
32
+ /**
33
+ * Adds or updates an element with a specified key and a value.
34
+ * @param key The key of the element to add. Should be a string.
35
+ * @param value The value of the element to add. Should be serializable to JSON.
36
+ */
37
+ set(key: TKey, value: TValue): void;
38
+ /**
39
+ * Returns the number of elements in the LiveMap.
40
+ */
41
+ get size(): number;
42
+ /**
43
+ * Returns a boolean indicating whether an element with the specified key exists or not.
44
+ * @param key The key of the element to test for presence.
45
+ */
46
+ has(key: TKey): boolean;
47
+ /**
48
+ * Removes the specified element by key.
49
+ * @param key The key of the element to remove.
50
+ * @returns true if an element existed and has been removed, or false if the element does not exist.
51
+ */
52
+ delete(key: TKey): boolean;
53
+ /**
54
+ * Returns a new Iterator object that contains the [key, value] pairs for each element.
55
+ */
56
+ entries(): IterableIterator<[TKey, TValue]>;
57
+ /**
58
+ * Same function object as the initial value of the entries method.
59
+ */
60
+ [Symbol.iterator](): IterableIterator<[TKey, TValue]>;
61
+ /**
62
+ * Returns a new Iterator object that contains the keys for each element.
63
+ */
64
+ keys(): IterableIterator<TKey>;
65
+ /**
66
+ * Returns a new Iterator object that contains the values for each element.
67
+ */
68
+ values(): IterableIterator<TValue>;
69
+ /**
70
+ * Executes a provided function once per each key/value pair in the Map object, in insertion order.
71
+ * @param callback Function to execute for each entry in the map.
72
+ */
73
+ forEach(callback: (value: TValue, key: TKey, map: LiveMap<TKey, TValue>) => void): void;
74
+ }
75
+
76
+ /**
77
+ * Think of Lson as a sibling of the Json data tree, except that the nested
78
+ * data structure can contain a mix of Json values and LiveStructure instances.
3
79
  */
4
- declare class LiveList<T> extends AbstractCrdt {
5
- #private;
6
- constructor(items?: T[]);
80
+ declare type Lson = Json | LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
81
+ /**
82
+ * A mapping of keys to Lson values. A Lson value is any valid JSON
83
+ * value or a Live storage data structure (LiveMap, LiveList, etc.)
84
+ */
85
+ declare type LsonObject = {
86
+ [key: string]: Lson;
87
+ };
88
+
89
+ /**
90
+ * The LiveList class represents an ordered collection of items that is synchronized across clients.
91
+ */
92
+ declare class LiveList<TItem extends Lson = Lson> extends AbstractCrdt {
93
+ private _items;
94
+ constructor(items?: TItem[]);
7
95
  /**
8
96
  * Returns the number of elements.
9
97
  */
@@ -12,13 +100,13 @@ declare class LiveList<T> extends AbstractCrdt {
12
100
  * Adds one element to the end of the LiveList.
13
101
  * @param element The element to add to the end of the LiveList.
14
102
  */
15
- push(element: T): void;
103
+ push(element: TItem): void;
16
104
  /**
17
105
  * Inserts one element at a specified index.
18
106
  * @param element The element to insert.
19
107
  * @param index The index at which you want to insert the element.
20
108
  */
21
- insert(element: T, index: number): void;
109
+ insert(element: TItem, index: number): void;
22
110
  /**
23
111
  * Move one element from one index to another.
24
112
  * @param index The index of the element to move
@@ -31,137 +119,80 @@ declare class LiveList<T> extends AbstractCrdt {
31
119
  */
32
120
  delete(index: number): void;
33
121
  clear(): void;
122
+ set(index: number, item: TItem): void;
34
123
  /**
35
124
  * Returns an Array of all the elements in the LiveList.
36
125
  */
37
- toArray(): T[];
126
+ toArray(): TItem[];
38
127
  /**
39
128
  * Tests whether all elements pass the test implemented by the provided function.
40
129
  * @param predicate Function to test for each element, taking two arguments (the element and its index).
41
130
  * @returns true if the predicate function returns a truthy value for every element. Otherwise, false.
42
131
  */
43
- every(predicate: (value: T, index: number) => unknown): boolean;
132
+ every(predicate: (value: TItem, index: number) => unknown): boolean;
44
133
  /**
45
134
  * Creates an array with all elements that pass the test implemented by the provided function.
46
135
  * @param predicate Function to test each element of the LiveList. Return a value that coerces to true to keep the element, or to false otherwise.
47
136
  * @returns An array with the elements that pass the test.
48
137
  */
49
- filter(predicate: (value: T, index: number) => unknown): T[];
138
+ filter(predicate: (value: TItem, index: number) => unknown): TItem[];
50
139
  /**
51
140
  * Returns the first element that satisfies the provided testing function.
52
141
  * @param predicate Function to execute on each value.
53
142
  * @returns The value of the first element in the LiveList that satisfies the provided testing function. Otherwise, undefined is returned.
54
143
  */
55
- find(predicate: (value: T, index: number) => unknown): T | undefined;
144
+ find(predicate: (value: TItem, index: number) => unknown): TItem | undefined;
56
145
  /**
57
146
  * Returns the index of the first element in the LiveList that satisfies the provided testing function.
58
147
  * @param predicate Function to execute on each value until the function returns true, indicating that the satisfying element was found.
59
148
  * @returns The index of the first element in the LiveList that passes the test. Otherwise, -1.
60
149
  */
61
- findIndex(predicate: (value: T, index: number) => unknown): number;
150
+ findIndex(predicate: (value: TItem, index: number) => unknown): number;
62
151
  /**
63
152
  * Executes a provided function once for each element.
64
153
  * @param callbackfn Function to execute on each element.
65
154
  */
66
- forEach(callbackfn: (value: T, index: number) => void): void;
155
+ forEach(callbackfn: (value: TItem, index: number) => void): void;
67
156
  /**
68
157
  * Get the element at the specified index.
69
158
  * @param index The index on the element to get.
70
159
  * @returns The element at the specified index or undefined.
71
160
  */
72
- get(index: number): T | undefined;
161
+ get(index: number): TItem | undefined;
73
162
  /**
74
163
  * Returns the first index at which a given element can be found in the LiveList, or -1 if it is not present.
75
164
  * @param searchElement Element to locate.
76
165
  * @param fromIndex The index to start the search at.
77
166
  * @returns The first index of the element in the LiveList; -1 if not found.
78
167
  */
79
- indexOf(searchElement: T, fromIndex?: number): number;
168
+ indexOf(searchElement: TItem, fromIndex?: number): number;
80
169
  /**
81
170
  * Returns the last index at which a given element can be found in the LiveList, or -1 if it is not present. The LiveLsit is searched backwards, starting at fromIndex.
82
171
  * @param searchElement Element to locate.
83
172
  * @param fromIndex The index at which to start searching backwards.
84
173
  * @returns
85
174
  */
86
- lastIndexOf(searchElement: T, fromIndex?: number): number;
175
+ lastIndexOf(searchElement: TItem, fromIndex?: number): number;
87
176
  /**
88
177
  * Creates an array populated with the results of calling a provided function on every element.
89
178
  * @param callback Function that is called for every element.
90
179
  * @returns An array with each element being the result of the callback function.
91
180
  */
92
- map<U>(callback: (value: T, index: number) => U): U[];
181
+ map<U>(callback: (value: TItem, index: number) => U): U[];
93
182
  /**
94
183
  * Tests whether at least one element in the LiveList passes the test implemented by the provided function.
95
184
  * @param predicate Function to test for each element.
96
185
  * @returns true if the callback function returns a truthy value for at least one element. Otherwise, false.
97
186
  */
98
- some(predicate: (value: T, index: number) => unknown): boolean;
99
- [Symbol.iterator](): IterableIterator<T>;
100
- }
101
-
102
- /**
103
- * The LiveMap class is similar to a JavaScript Map that is synchronized on all clients.
104
- * Keys should be a string, and values should be serializable to JSON.
105
- * If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
106
- */
107
- declare class LiveMap<TKey extends string, TValue> extends AbstractCrdt {
108
- #private;
109
- constructor(entries?: readonly (readonly [TKey, TValue])[] | null | undefined);
110
- /**
111
- * Returns a specified element from the LiveMap.
112
- * @param key The key of the element to return.
113
- * @returns The element associated with the specified key, or undefined if the key can't be found in the LiveMap.
114
- */
115
- get(key: TKey): TValue | undefined;
116
- /**
117
- * Adds or updates an element with a specified key and a value.
118
- * @param key The key of the element to add. Should be a string.
119
- * @param value The value of the element to add. Should be serializable to JSON.
120
- */
121
- set(key: TKey, value: TValue): void;
122
- /**
123
- * Returns the number of elements in the LiveMap.
124
- */
125
- get size(): number;
126
- /**
127
- * Returns a boolean indicating whether an element with the specified key exists or not.
128
- * @param key The key of the element to test for presence.
129
- */
130
- has(key: TKey): boolean;
131
- /**
132
- * Removes the specified element by key.
133
- * @param key The key of the element to remove.
134
- * @returns true if an element existed and has been removed, or false if the element does not exist.
135
- */
136
- delete(key: TKey): boolean;
137
- /**
138
- * Returns a new Iterator object that contains the [key, value] pairs for each element.
139
- */
140
- entries(): IterableIterator<[string, TValue]>;
141
- /**
142
- * Same function object as the initial value of the entries method.
143
- */
144
- [Symbol.iterator](): IterableIterator<[string, TValue]>;
145
- /**
146
- * Returns a new Iterator object that contains the keys for each element.
147
- */
148
- keys(): IterableIterator<TKey>;
149
- /**
150
- * Returns a new Iterator object that contains the values for each element.
151
- */
152
- values(): IterableIterator<TValue>;
153
- /**
154
- * Executes a provided function once per each key/value pair in the Map object, in insertion order.
155
- * @param callback Function to execute for each entry in the map.
156
- */
157
- forEach(callback: (value: TValue, key: TKey, map: LiveMap<TKey, TValue>) => void): void;
187
+ some(predicate: (value: TItem, index: number) => unknown): boolean;
188
+ [Symbol.iterator](): IterableIterator<TItem>;
158
189
  }
159
190
 
160
191
  declare type MyPresenceCallback<T extends Presence = Presence> = (me: T) => void;
161
192
  declare type OthersEventCallback<T extends Presence = Presence> = (others: Others<T>, event: OthersEvent<T>) => void;
162
193
  declare type EventCallback = ({ connectionId, event, }: {
163
194
  connectionId: number;
164
- event: any;
195
+ event: Json;
165
196
  }) => void;
166
197
  declare type ErrorCallback = (error: Error) => void;
167
198
  declare type ConnectionCallback = (state: ConnectionState) => void;
@@ -170,22 +201,26 @@ declare type UpdateDelta = {
170
201
  } | {
171
202
  type: "delete";
172
203
  };
173
- declare type LiveMapUpdates<TKey extends string = string, TValue = any> = {
204
+ declare type LiveMapUpdates<TKey extends string, TValue extends Lson> = {
174
205
  type: "LiveMap";
175
206
  node: LiveMap<TKey, TValue>;
176
- updates: Record<TKey, UpdateDelta>;
207
+ updates: {
208
+ [key: string]: UpdateDelta;
209
+ };
177
210
  };
178
- declare type LiveObjectUpdateDelta<T> = Partial<{
179
- [Property in keyof T]: UpdateDelta;
180
- }>;
181
- declare type LiveObjectUpdates<TData = any> = {
211
+ declare type LiveObjectUpdateDelta<O extends {
212
+ [key: string]: unknown;
213
+ }> = {
214
+ [K in keyof O]?: UpdateDelta | undefined;
215
+ };
216
+ declare type LiveObjectUpdates<TData extends LsonObject> = {
182
217
  type: "LiveObject";
183
218
  node: LiveObject<TData>;
184
219
  updates: LiveObjectUpdateDelta<TData>;
185
220
  };
186
221
  declare type LiveListUpdateDelta = {
187
222
  index: number;
188
- item: AbstractCrdt;
223
+ item: any;
189
224
  type: "insert";
190
225
  } | {
191
226
  index: number;
@@ -193,10 +228,14 @@ declare type LiveListUpdateDelta = {
193
228
  } | {
194
229
  index: number;
195
230
  previousIndex: number;
196
- item: AbstractCrdt;
231
+ item: any;
197
232
  type: "move";
233
+ } | {
234
+ index: number;
235
+ item: any;
236
+ type: "set";
198
237
  };
199
- declare type LiveListUpdates<TItem = any> = {
238
+ declare type LiveListUpdates<TItem extends Lson> = {
200
239
  type: "LiveList";
201
240
  node: LiveList<TItem>;
202
241
  updates: LiveListUpdateDelta[];
@@ -209,7 +248,7 @@ declare type BroadcastOptions = {
209
248
  */
210
249
  shouldQueueEventIfNotReady: boolean;
211
250
  };
212
- declare type StorageUpdate = LiveMapUpdates | LiveObjectUpdates | LiveListUpdates;
251
+ declare type StorageUpdate = LiveMapUpdates<string, Lson> | LiveObjectUpdates<LsonObject> | LiveListUpdates<Lson>;
213
252
  declare type Client = {
214
253
  /**
215
254
  * Gets a room. Returns null if {@link Client.enter} has not been called previously.
@@ -275,9 +314,7 @@ declare type User<TPresence extends Presence = Presence> = {
275
314
  */
276
315
  readonly presence?: TPresence;
277
316
  };
278
- declare type Presence = {
279
- [key: string]: any;
280
- };
317
+ declare type Presence = Record<string, unknown>;
281
318
  declare type AuthEndpointCallback = (room: string) => Promise<{
282
319
  token: string;
283
320
  }>;
@@ -311,6 +348,58 @@ declare type OthersEvent<T extends Presence = Presence> = {
311
348
  } | {
312
349
  type: "reset";
313
350
  };
351
+ interface History {
352
+ /**
353
+ * Undoes the last operation executed by the current client.
354
+ * It does not impact operations made by other clients.
355
+ *
356
+ * @example
357
+ * room.updatePresence({ selectedId: "xxx" }, { addToHistory: true });
358
+ * room.updatePresence({ selectedId: "yyy" }, { addToHistory: true });
359
+ * room.history.undo();
360
+ * // room.getPresence() equals { selectedId: "xxx" }
361
+ */
362
+ undo: () => void;
363
+ /**
364
+ * Redoes the last operation executed by the current client.
365
+ * It does not impact operations made by other clients.
366
+ *
367
+ * @example
368
+ * room.updatePresence({ selectedId: "xxx" }, { addToHistory: true });
369
+ * room.updatePresence({ selectedId: "yyy" }, { addToHistory: true });
370
+ * room.history.undo();
371
+ * // room.getPresence() equals { selectedId: "xxx" }
372
+ * room.history.redo();
373
+ * // room.getPresence() equals { selectedId: "yyy" }
374
+ */
375
+ redo: () => void;
376
+ /**
377
+ * All future modifications made on the Room will be merged together to create a single history item until resume is called.
378
+ *
379
+ * @example
380
+ * room.updatePresence({ cursor: { x: 0, y: 0 } }, { addToHistory: true });
381
+ * room.history.pause();
382
+ * room.updatePresence({ cursor: { x: 1, y: 1 } }, { addToHistory: true });
383
+ * room.updatePresence({ cursor: { x: 2, y: 2 } }, { addToHistory: true });
384
+ * room.history.resume();
385
+ * room.history.undo();
386
+ * // room.getPresence() equals { cursor: { x: 0, y: 0 } }
387
+ */
388
+ pause: () => void;
389
+ /**
390
+ * Resumes history. Modifications made on the Room are not merged into a single history item anymore.
391
+ *
392
+ * @example
393
+ * room.updatePresence({ cursor: { x: 0, y: 0 } }, { addToHistory: true });
394
+ * room.history.pause();
395
+ * room.updatePresence({ cursor: { x: 1, y: 1 } }, { addToHistory: true });
396
+ * room.updatePresence({ cursor: { x: 2, y: 2 } }, { addToHistory: true });
397
+ * room.history.resume();
398
+ * room.history.undo();
399
+ * // room.getPresence() equals { cursor: { x: 0, y: 0 } }
400
+ */
401
+ resume: () => void;
402
+ }
314
403
  declare type Room = {
315
404
  /**
316
405
  * The id of the room.
@@ -372,7 +461,7 @@ declare type Room = {
372
461
  * const unsubscribe = room.subscribe(liveMap, (liveMap) => { });
373
462
  * unsubscribe();
374
463
  */
375
- <TKey extends string, TValue>(liveMap: LiveMap<TKey, TValue>, listener: (liveMap: LiveMap<TKey, TValue>) => void): () => void;
464
+ <TKey extends string, TValue extends Lson>(liveMap: LiveMap<TKey, TValue>, listener: (liveMap: LiveMap<TKey, TValue>) => void): () => void;
376
465
  /**
377
466
  * Subscribes to changes made on a {@link LiveObject}. Returns an unsubscribe function.
378
467
  * In a future version, we will also expose what exactly changed in the {@link LiveObject}.
@@ -386,7 +475,7 @@ declare type Room = {
386
475
  * const unsubscribe = room.subscribe(liveObject, (liveObject) => { });
387
476
  * unsubscribe();
388
477
  */
389
- <TData>(liveObject: LiveObject<TData>, callback: (liveObject: LiveObject<TData>) => void): () => void;
478
+ <TData extends JsonObject>(liveObject: LiveObject<TData>, callback: (liveObject: LiveObject<TData>) => void): () => void;
390
479
  /**
391
480
  * Subscribes to changes made on a {@link LiveList}. Returns an unsubscribe function.
392
481
  * In a future version, we will also expose what exactly changed in the {@link LiveList}.
@@ -400,7 +489,7 @@ declare type Room = {
400
489
  * const unsubscribe = room.subscribe(liveList, (liveList) => { });
401
490
  * unsubscribe();
402
491
  */
403
- <TItem>(liveList: LiveList<TItem>, callback: (liveList: LiveList<TItem>) => void): () => void;
492
+ <TItem extends Lson>(liveList: LiveList<TItem>, callback: (liveList: LiveList<TItem>) => void): () => void;
404
493
  /**
405
494
  * Subscribes to changes made on a {@link LiveMap} and all the nested data structures. Returns an unsubscribe function.
406
495
  * In a future version, we will also expose what exactly changed in the {@link LiveMap}.
@@ -414,7 +503,7 @@ declare type Room = {
414
503
  * const unsubscribe = room.subscribe(liveMap, (liveMap) => { }, { isDeep: true });
415
504
  * unsubscribe();
416
505
  */
417
- <TKey extends string, TValue>(liveMap: LiveMap<TKey, TValue>, callback: (updates: StorageUpdate[]) => void, options: {
506
+ <TKey extends string, TValue extends Lson>(liveMap: LiveMap<TKey, TValue>, callback: (updates: LiveMapUpdates<TKey, TValue>[]) => void, options: {
418
507
  isDeep: true;
419
508
  }): () => void;
420
509
  /**
@@ -430,7 +519,7 @@ declare type Room = {
430
519
  * const unsubscribe = room.subscribe(liveObject, (liveObject) => { }, { isDeep: true });
431
520
  * unsubscribe();
432
521
  */
433
- <TData>(liveObject: LiveObject<TData>, callback: (updates: StorageUpdate[]) => void, options: {
522
+ <TData extends LsonObject>(liveObject: LiveObject<TData>, callback: (updates: LiveObjectUpdates<TData>[]) => void, options: {
434
523
  isDeep: true;
435
524
  }): () => void;
436
525
  /**
@@ -446,65 +535,14 @@ declare type Room = {
446
535
  * const unsubscribe = room.subscribe(liveList, (liveList) => { }, { isDeep: true });
447
536
  * unsubscribe();
448
537
  */
449
- <TItem>(liveList: LiveList<TItem>, callback: (updates: StorageUpdate[]) => void, options: {
538
+ <TItem extends Lson>(liveList: LiveList<TItem>, callback: (updates: LiveListUpdates<TItem>[]) => void, options: {
450
539
  isDeep: true;
451
540
  }): () => void;
452
541
  };
453
542
  /**
454
543
  * Room's history contains functions that let you undo and redo operation made on by the current client on the presence and storage.
455
544
  */
456
- history: {
457
- /**
458
- * Undoes the last operation executed by the current client.
459
- * It does not impact operations made by other clients.
460
- *
461
- * @example
462
- * room.updatePresence({ selectedId: "xxx" }, { addToHistory: true });
463
- * room.updatePresence({ selectedId: "yyy" }, { addToHistory: true });
464
- * room.history.undo();
465
- * // room.getPresence() equals { selectedId: "xxx" }
466
- */
467
- undo: () => void;
468
- /**
469
- * Redoes the last operation executed by the current client.
470
- * It does not impact operations made by other clients.
471
- *
472
- * @example
473
- * room.updatePresence({ selectedId: "xxx" }, { addToHistory: true });
474
- * room.updatePresence({ selectedId: "yyy" }, { addToHistory: true });
475
- * room.history.undo();
476
- * // room.getPresence() equals { selectedId: "xxx" }
477
- * room.history.redo();
478
- * // room.getPresence() equals { selectedId: "yyy" }
479
- */
480
- redo: () => void;
481
- /**
482
- * All future modifications made on the Room will be merged together to create a single history item until resume is called.
483
- *
484
- * @example
485
- * room.updatePresence({ cursor: { x: 0, y: 0 } }, { addToHistory: true });
486
- * room.history.pause();
487
- * room.updatePresence({ cursor: { x: 1, y: 1 } }, { addToHistory: true });
488
- * room.updatePresence({ cursor: { x: 2, y: 2 } }, { addToHistory: true });
489
- * room.history.resume();
490
- * room.history.undo();
491
- * // room.getPresence() equals { cursor: { x: 0, y: 0 } }
492
- */
493
- pause: () => void;
494
- /**
495
- * Resumes history. Modifications made on the Room are not merged into a single history item anymore.
496
- *
497
- * @example
498
- * room.updatePresence({ cursor: { x: 0, y: 0 } }, { addToHistory: true });
499
- * room.history.pause();
500
- * room.updatePresence({ cursor: { x: 1, y: 1 } }, { addToHistory: true });
501
- * room.updatePresence({ cursor: { x: 2, y: 2 } }, { addToHistory: true });
502
- * room.history.resume();
503
- * room.history.undo();
504
- * // room.getPresence() equals { cursor: { x: 0, y: 0 } }
505
- */
506
- resume: () => void;
507
- };
545
+ history: History;
508
546
  /**
509
547
  * @deprecated use the callback returned by subscribe instead.
510
548
  * See v0.13 release notes for more information.
@@ -597,7 +635,7 @@ declare type Room = {
597
635
  * }
598
636
  * });
599
637
  */
600
- broadcastEvent: (event: any, options?: BroadcastOptions) => void;
638
+ broadcastEvent: (event: JsonObject, options?: BroadcastOptions) => void;
601
639
  /**
602
640
  * Get the room's storage asynchronously.
603
641
  * The storage's root is a {@link LiveObject}.
@@ -605,7 +643,7 @@ declare type Room = {
605
643
  * @example
606
644
  * const { root } = await room.getStorage();
607
645
  */
608
- getStorage: <TRoot>() => Promise<{
646
+ getStorage: <TRoot extends LsonObject>() => Promise<{
609
647
  root: LiveObject<TRoot>;
610
648
  }>;
611
649
  /**
@@ -625,7 +663,10 @@ declare type Room = {
625
663
  };
626
664
 
627
665
  declare abstract class AbstractCrdt {
628
- #private;
666
+ private __parent?;
667
+ private __doc?;
668
+ private __id?;
669
+ private __parentKey?;
629
670
  get roomId(): string | null;
630
671
  }
631
672
 
@@ -634,34 +675,37 @@ declare abstract class AbstractCrdt {
634
675
  * Keys should be a string, and values should be serializable to JSON.
635
676
  * If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
636
677
  */
637
- declare class LiveObject<T extends Record<string, any> = Record<string, any>> extends AbstractCrdt {
638
- #private;
639
- constructor(object?: T);
678
+ declare class LiveObject<O extends LsonObject = LsonObject> extends AbstractCrdt {
679
+ private _map;
680
+ private _propToLastUpdate;
681
+ constructor(object?: O);
682
+ private _applyUpdate;
683
+ private _applyDeleteObjectKey;
640
684
  /**
641
685
  * Transform the LiveObject into a javascript object
642
686
  */
643
- toObject(): T;
687
+ toObject(): O;
644
688
  /**
645
689
  * Adds or updates a property with a specified key and a value.
646
690
  * @param key The key of the property to add
647
691
  * @param value The value of the property to add
648
692
  */
649
- set<TKey extends keyof T>(key: TKey, value: T[TKey]): void;
693
+ set<TKey extends keyof O>(key: TKey, value: O[TKey]): void;
650
694
  /**
651
695
  * Returns a specified property from the LiveObject.
652
696
  * @param key The key of the property to get
653
697
  */
654
- get<TKey extends keyof T>(key: TKey): T[TKey];
698
+ get<TKey extends keyof O>(key: TKey): O[TKey];
655
699
  /**
656
700
  * Deletes a key from the LiveObject
657
701
  * @param key The key of the property to delete
658
702
  */
659
- delete(key: keyof T): void;
703
+ delete(key: keyof O): void;
660
704
  /**
661
705
  * Adds or updates multiple properties at once with an object.
662
706
  * @param overrides The object used to overrides properties
663
707
  */
664
- update(overrides: Partial<T>): void;
708
+ update(overrides: Partial<O>): void;
665
709
  }
666
710
 
667
711
  /**
@@ -691,4 +735,4 @@ declare class LiveObject<T extends Record<string, any> = Record<string, any>> ex
691
735
  */
692
736
  declare function createClient(options: ClientOptions): Client;
693
737
 
694
- export { BroadcastOptions, Client, LiveList, LiveMap, LiveObject, Others, Presence, Room, StorageUpdate, User, createClient };
738
+ export { BroadcastOptions, Client, History, Json, JsonObject, LiveList, LiveMap, LiveObject, Lson, LsonObject, Others, Presence, Room, StorageUpdate, User, createClient };