@liveblocks/client 0.15.11 → 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.
79
+ */
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.
3
91
  */
4
- declare class LiveList<T> extends AbstractCrdt {
92
+ declare class LiveList<TItem extends Lson = Lson> extends AbstractCrdt {
5
93
  private _items;
6
- constructor(items?: T[]);
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 _map;
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.
@@ -309,6 +348,58 @@ declare type OthersEvent<T extends Presence = Presence> = {
309
348
  } | {
310
349
  type: "reset";
311
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
+ }
312
403
  declare type Room = {
313
404
  /**
314
405
  * The id of the room.
@@ -370,7 +461,7 @@ declare type Room = {
370
461
  * const unsubscribe = room.subscribe(liveMap, (liveMap) => { });
371
462
  * unsubscribe();
372
463
  */
373
- <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;
374
465
  /**
375
466
  * Subscribes to changes made on a {@link LiveObject}. Returns an unsubscribe function.
376
467
  * In a future version, we will also expose what exactly changed in the {@link LiveObject}.
@@ -384,7 +475,7 @@ declare type Room = {
384
475
  * const unsubscribe = room.subscribe(liveObject, (liveObject) => { });
385
476
  * unsubscribe();
386
477
  */
387
- <TData>(liveObject: LiveObject<TData>, callback: (liveObject: LiveObject<TData>) => void): () => void;
478
+ <TData extends JsonObject>(liveObject: LiveObject<TData>, callback: (liveObject: LiveObject<TData>) => void): () => void;
388
479
  /**
389
480
  * Subscribes to changes made on a {@link LiveList}. Returns an unsubscribe function.
390
481
  * In a future version, we will also expose what exactly changed in the {@link LiveList}.
@@ -398,7 +489,7 @@ declare type Room = {
398
489
  * const unsubscribe = room.subscribe(liveList, (liveList) => { });
399
490
  * unsubscribe();
400
491
  */
401
- <TItem>(liveList: LiveList<TItem>, callback: (liveList: LiveList<TItem>) => void): () => void;
492
+ <TItem extends Lson>(liveList: LiveList<TItem>, callback: (liveList: LiveList<TItem>) => void): () => void;
402
493
  /**
403
494
  * Subscribes to changes made on a {@link LiveMap} and all the nested data structures. Returns an unsubscribe function.
404
495
  * In a future version, we will also expose what exactly changed in the {@link LiveMap}.
@@ -412,7 +503,7 @@ declare type Room = {
412
503
  * const unsubscribe = room.subscribe(liveMap, (liveMap) => { }, { isDeep: true });
413
504
  * unsubscribe();
414
505
  */
415
- <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: {
416
507
  isDeep: true;
417
508
  }): () => void;
418
509
  /**
@@ -428,7 +519,7 @@ declare type Room = {
428
519
  * const unsubscribe = room.subscribe(liveObject, (liveObject) => { }, { isDeep: true });
429
520
  * unsubscribe();
430
521
  */
431
- <TData>(liveObject: LiveObject<TData>, callback: (updates: StorageUpdate[]) => void, options: {
522
+ <TData extends LsonObject>(liveObject: LiveObject<TData>, callback: (updates: LiveObjectUpdates<TData>[]) => void, options: {
432
523
  isDeep: true;
433
524
  }): () => void;
434
525
  /**
@@ -444,65 +535,14 @@ declare type Room = {
444
535
  * const unsubscribe = room.subscribe(liveList, (liveList) => { }, { isDeep: true });
445
536
  * unsubscribe();
446
537
  */
447
- <TItem>(liveList: LiveList<TItem>, callback: (updates: StorageUpdate[]) => void, options: {
538
+ <TItem extends Lson>(liveList: LiveList<TItem>, callback: (updates: LiveListUpdates<TItem>[]) => void, options: {
448
539
  isDeep: true;
449
540
  }): () => void;
450
541
  };
451
542
  /**
452
543
  * Room's history contains functions that let you undo and redo operation made on by the current client on the presence and storage.
453
544
  */
454
- history: {
455
- /**
456
- * Undoes the last operation executed by the current client.
457
- * It does not impact operations made by other clients.
458
- *
459
- * @example
460
- * room.updatePresence({ selectedId: "xxx" }, { addToHistory: true });
461
- * room.updatePresence({ selectedId: "yyy" }, { addToHistory: true });
462
- * room.history.undo();
463
- * // room.getPresence() equals { selectedId: "xxx" }
464
- */
465
- undo: () => void;
466
- /**
467
- * Redoes the last operation executed by the current client.
468
- * It does not impact operations made by other clients.
469
- *
470
- * @example
471
- * room.updatePresence({ selectedId: "xxx" }, { addToHistory: true });
472
- * room.updatePresence({ selectedId: "yyy" }, { addToHistory: true });
473
- * room.history.undo();
474
- * // room.getPresence() equals { selectedId: "xxx" }
475
- * room.history.redo();
476
- * // room.getPresence() equals { selectedId: "yyy" }
477
- */
478
- redo: () => void;
479
- /**
480
- * All future modifications made on the Room will be merged together to create a single history item until resume is called.
481
- *
482
- * @example
483
- * room.updatePresence({ cursor: { x: 0, y: 0 } }, { addToHistory: true });
484
- * room.history.pause();
485
- * room.updatePresence({ cursor: { x: 1, y: 1 } }, { addToHistory: true });
486
- * room.updatePresence({ cursor: { x: 2, y: 2 } }, { addToHistory: true });
487
- * room.history.resume();
488
- * room.history.undo();
489
- * // room.getPresence() equals { cursor: { x: 0, y: 0 } }
490
- */
491
- pause: () => void;
492
- /**
493
- * Resumes history. Modifications made on the Room are not merged into a single history item anymore.
494
- *
495
- * @example
496
- * room.updatePresence({ cursor: { x: 0, y: 0 } }, { addToHistory: true });
497
- * room.history.pause();
498
- * room.updatePresence({ cursor: { x: 1, y: 1 } }, { addToHistory: true });
499
- * room.updatePresence({ cursor: { x: 2, y: 2 } }, { addToHistory: true });
500
- * room.history.resume();
501
- * room.history.undo();
502
- * // room.getPresence() equals { cursor: { x: 0, y: 0 } }
503
- */
504
- resume: () => void;
505
- };
545
+ history: History;
506
546
  /**
507
547
  * @deprecated use the callback returned by subscribe instead.
508
548
  * See v0.13 release notes for more information.
@@ -595,7 +635,7 @@ declare type Room = {
595
635
  * }
596
636
  * });
597
637
  */
598
- broadcastEvent: (event: any, options?: BroadcastOptions) => void;
638
+ broadcastEvent: (event: JsonObject, options?: BroadcastOptions) => void;
599
639
  /**
600
640
  * Get the room's storage asynchronously.
601
641
  * The storage's root is a {@link LiveObject}.
@@ -603,7 +643,7 @@ declare type Room = {
603
643
  * @example
604
644
  * const { root } = await room.getStorage();
605
645
  */
606
- getStorage: <TRoot>() => Promise<{
646
+ getStorage: <TRoot extends LsonObject>() => Promise<{
607
647
  root: LiveObject<TRoot>;
608
648
  }>;
609
649
  /**
@@ -635,37 +675,37 @@ declare abstract class AbstractCrdt {
635
675
  * Keys should be a string, and values should be serializable to JSON.
636
676
  * If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
637
677
  */
638
- declare class LiveObject<T extends Record<string, any> = Record<string, any>> extends AbstractCrdt {
678
+ declare class LiveObject<O extends LsonObject = LsonObject> extends AbstractCrdt {
639
679
  private _map;
640
680
  private _propToLastUpdate;
641
- constructor(object?: T);
681
+ constructor(object?: O);
642
682
  private _applyUpdate;
643
683
  private _applyDeleteObjectKey;
644
684
  /**
645
685
  * Transform the LiveObject into a javascript object
646
686
  */
647
- toObject(): T;
687
+ toObject(): O;
648
688
  /**
649
689
  * Adds or updates a property with a specified key and a value.
650
690
  * @param key The key of the property to add
651
691
  * @param value The value of the property to add
652
692
  */
653
- set<TKey extends keyof T>(key: TKey, value: T[TKey]): void;
693
+ set<TKey extends keyof O>(key: TKey, value: O[TKey]): void;
654
694
  /**
655
695
  * Returns a specified property from the LiveObject.
656
696
  * @param key The key of the property to get
657
697
  */
658
- get<TKey extends keyof T>(key: TKey): T[TKey];
698
+ get<TKey extends keyof O>(key: TKey): O[TKey];
659
699
  /**
660
700
  * Deletes a key from the LiveObject
661
701
  * @param key The key of the property to delete
662
702
  */
663
- delete(key: keyof T): void;
703
+ delete(key: keyof O): void;
664
704
  /**
665
705
  * Adds or updates multiple properties at once with an object.
666
706
  * @param overrides The object used to overrides properties
667
707
  */
668
- update(overrides: Partial<T>): void;
708
+ update(overrides: Partial<O>): void;
669
709
  }
670
710
 
671
711
  /**
@@ -695,4 +735,4 @@ declare class LiveObject<T extends Record<string, any> = Record<string, any>> ex
695
735
  */
696
736
  declare function createClient(options: ClientOptions): Client;
697
737
 
698
- 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 };