@liveblocks/client 0.15.11 → 0.16.2

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.
@@ -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 | undefined;
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.)
3
84
  */
4
- declare class LiveList<T> extends AbstractCrdt {
85
+ declare type LsonObject = {
86
+ [key: string]: Lson | undefined;
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 {
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,34 @@ declare type UpdateDelta = {
170
201
  } | {
171
202
  type: "delete";
172
203
  };
173
- declare type LiveMapUpdates<TKey extends string = string, TValue = any> = {
204
+ /**
205
+ * A LiveMap notification that is sent in-client to any subscribers whenever
206
+ * one or more of the values inside the LiveMap instance have changed.
207
+ */
208
+ declare type LiveMapUpdates<TKey extends string, TValue extends Lson> = {
174
209
  type: "LiveMap";
175
210
  node: LiveMap<TKey, TValue>;
176
- updates: Record<TKey, UpdateDelta>;
211
+ updates: {
212
+ [key: string]: UpdateDelta;
213
+ };
177
214
  };
178
- declare type LiveObjectUpdateDelta<T> = Partial<{
179
- [Property in keyof T]: UpdateDelta;
180
- }>;
181
- declare type LiveObjectUpdates<TData = any> = {
215
+ declare type LiveObjectUpdateDelta<O extends {
216
+ [key: string]: unknown;
217
+ }> = {
218
+ [K in keyof O]?: UpdateDelta | undefined;
219
+ };
220
+ /**
221
+ * A LiveObject notification that is sent in-client to any subscribers whenever
222
+ * one or more of the entries inside the LiveObject instance have changed.
223
+ */
224
+ declare type LiveObjectUpdates<TData extends LsonObject> = {
182
225
  type: "LiveObject";
183
226
  node: LiveObject<TData>;
184
227
  updates: LiveObjectUpdateDelta<TData>;
185
228
  };
186
229
  declare type LiveListUpdateDelta = {
187
230
  index: number;
188
- item: AbstractCrdt;
231
+ item: any;
189
232
  type: "insert";
190
233
  } | {
191
234
  index: number;
@@ -193,10 +236,18 @@ declare type LiveListUpdateDelta = {
193
236
  } | {
194
237
  index: number;
195
238
  previousIndex: number;
196
- item: AbstractCrdt;
239
+ item: any;
197
240
  type: "move";
241
+ } | {
242
+ index: number;
243
+ item: any;
244
+ type: "set";
198
245
  };
199
- declare type LiveListUpdates<TItem = any> = {
246
+ /**
247
+ * A LiveList notification that is sent in-client to any subscribers whenever
248
+ * one or more of the items inside the LiveList instance have changed.
249
+ */
250
+ declare type LiveListUpdates<TItem extends Lson> = {
200
251
  type: "LiveList";
201
252
  node: LiveList<TItem>;
202
253
  updates: LiveListUpdateDelta[];
@@ -209,7 +260,12 @@ declare type BroadcastOptions = {
209
260
  */
210
261
  shouldQueueEventIfNotReady: boolean;
211
262
  };
212
- declare type StorageUpdate = LiveMapUpdates | LiveObjectUpdates | LiveListUpdates;
263
+ /**
264
+ * The payload of notifications sent (in-client) when LiveStructures change.
265
+ * Messages of this kind are not originating from the network, but are 100%
266
+ * in-client.
267
+ */
268
+ declare type StorageUpdate = LiveMapUpdates<string, Lson> | LiveObjectUpdates<LsonObject> | LiveListUpdates<Lson>;
213
269
  declare type Client = {
214
270
  /**
215
271
  * Gets a room. Returns null if {@link Client.enter} has not been called previously.
@@ -309,6 +365,58 @@ declare type OthersEvent<T extends Presence = Presence> = {
309
365
  } | {
310
366
  type: "reset";
311
367
  };
368
+ interface History {
369
+ /**
370
+ * Undoes the last operation executed by the current client.
371
+ * It does not impact operations made by other clients.
372
+ *
373
+ * @example
374
+ * room.updatePresence({ selectedId: "xxx" }, { addToHistory: true });
375
+ * room.updatePresence({ selectedId: "yyy" }, { addToHistory: true });
376
+ * room.history.undo();
377
+ * // room.getPresence() equals { selectedId: "xxx" }
378
+ */
379
+ undo: () => void;
380
+ /**
381
+ * Redoes the last operation executed by the current client.
382
+ * It does not impact operations made by other clients.
383
+ *
384
+ * @example
385
+ * room.updatePresence({ selectedId: "xxx" }, { addToHistory: true });
386
+ * room.updatePresence({ selectedId: "yyy" }, { addToHistory: true });
387
+ * room.history.undo();
388
+ * // room.getPresence() equals { selectedId: "xxx" }
389
+ * room.history.redo();
390
+ * // room.getPresence() equals { selectedId: "yyy" }
391
+ */
392
+ redo: () => void;
393
+ /**
394
+ * All future modifications made on the Room will be merged together to create a single history item until resume is called.
395
+ *
396
+ * @example
397
+ * room.updatePresence({ cursor: { x: 0, y: 0 } }, { addToHistory: true });
398
+ * room.history.pause();
399
+ * room.updatePresence({ cursor: { x: 1, y: 1 } }, { addToHistory: true });
400
+ * room.updatePresence({ cursor: { x: 2, y: 2 } }, { addToHistory: true });
401
+ * room.history.resume();
402
+ * room.history.undo();
403
+ * // room.getPresence() equals { cursor: { x: 0, y: 0 } }
404
+ */
405
+ pause: () => void;
406
+ /**
407
+ * Resumes history. Modifications made on the Room are not merged into a single history item anymore.
408
+ *
409
+ * @example
410
+ * room.updatePresence({ cursor: { x: 0, y: 0 } }, { addToHistory: true });
411
+ * room.history.pause();
412
+ * room.updatePresence({ cursor: { x: 1, y: 1 } }, { addToHistory: true });
413
+ * room.updatePresence({ cursor: { x: 2, y: 2 } }, { addToHistory: true });
414
+ * room.history.resume();
415
+ * room.history.undo();
416
+ * // room.getPresence() equals { cursor: { x: 0, y: 0 } }
417
+ */
418
+ resume: () => void;
419
+ }
312
420
  declare type Room = {
313
421
  /**
314
422
  * The id of the room.
@@ -370,7 +478,7 @@ declare type Room = {
370
478
  * const unsubscribe = room.subscribe(liveMap, (liveMap) => { });
371
479
  * unsubscribe();
372
480
  */
373
- <TKey extends string, TValue>(liveMap: LiveMap<TKey, TValue>, listener: (liveMap: LiveMap<TKey, TValue>) => void): () => void;
481
+ <TKey extends string, TValue extends Lson>(liveMap: LiveMap<TKey, TValue>, listener: (liveMap: LiveMap<TKey, TValue>) => void): () => void;
374
482
  /**
375
483
  * Subscribes to changes made on a {@link LiveObject}. Returns an unsubscribe function.
376
484
  * In a future version, we will also expose what exactly changed in the {@link LiveObject}.
@@ -384,7 +492,7 @@ declare type Room = {
384
492
  * const unsubscribe = room.subscribe(liveObject, (liveObject) => { });
385
493
  * unsubscribe();
386
494
  */
387
- <TData>(liveObject: LiveObject<TData>, callback: (liveObject: LiveObject<TData>) => void): () => void;
495
+ <TData extends JsonObject>(liveObject: LiveObject<TData>, callback: (liveObject: LiveObject<TData>) => void): () => void;
388
496
  /**
389
497
  * Subscribes to changes made on a {@link LiveList}. Returns an unsubscribe function.
390
498
  * In a future version, we will also expose what exactly changed in the {@link LiveList}.
@@ -398,7 +506,7 @@ declare type Room = {
398
506
  * const unsubscribe = room.subscribe(liveList, (liveList) => { });
399
507
  * unsubscribe();
400
508
  */
401
- <TItem>(liveList: LiveList<TItem>, callback: (liveList: LiveList<TItem>) => void): () => void;
509
+ <TItem extends Lson>(liveList: LiveList<TItem>, callback: (liveList: LiveList<TItem>) => void): () => void;
402
510
  /**
403
511
  * Subscribes to changes made on a {@link LiveMap} and all the nested data structures. Returns an unsubscribe function.
404
512
  * In a future version, we will also expose what exactly changed in the {@link LiveMap}.
@@ -412,7 +520,7 @@ declare type Room = {
412
520
  * const unsubscribe = room.subscribe(liveMap, (liveMap) => { }, { isDeep: true });
413
521
  * unsubscribe();
414
522
  */
415
- <TKey extends string, TValue>(liveMap: LiveMap<TKey, TValue>, callback: (updates: StorageUpdate[]) => void, options: {
523
+ <TKey extends string, TValue extends Lson>(liveMap: LiveMap<TKey, TValue>, callback: (updates: LiveMapUpdates<TKey, TValue>[]) => void, options: {
416
524
  isDeep: true;
417
525
  }): () => void;
418
526
  /**
@@ -428,7 +536,7 @@ declare type Room = {
428
536
  * const unsubscribe = room.subscribe(liveObject, (liveObject) => { }, { isDeep: true });
429
537
  * unsubscribe();
430
538
  */
431
- <TData>(liveObject: LiveObject<TData>, callback: (updates: StorageUpdate[]) => void, options: {
539
+ <TData extends LsonObject>(liveObject: LiveObject<TData>, callback: (updates: LiveObjectUpdates<TData>[]) => void, options: {
432
540
  isDeep: true;
433
541
  }): () => void;
434
542
  /**
@@ -444,65 +552,14 @@ declare type Room = {
444
552
  * const unsubscribe = room.subscribe(liveList, (liveList) => { }, { isDeep: true });
445
553
  * unsubscribe();
446
554
  */
447
- <TItem>(liveList: LiveList<TItem>, callback: (updates: StorageUpdate[]) => void, options: {
555
+ <TItem extends Lson>(liveList: LiveList<TItem>, callback: (updates: LiveListUpdates<TItem>[]) => void, options: {
448
556
  isDeep: true;
449
557
  }): () => void;
450
558
  };
451
559
  /**
452
560
  * Room's history contains functions that let you undo and redo operation made on by the current client on the presence and storage.
453
561
  */
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
- };
562
+ history: History;
506
563
  /**
507
564
  * @deprecated use the callback returned by subscribe instead.
508
565
  * See v0.13 release notes for more information.
@@ -595,7 +652,7 @@ declare type Room = {
595
652
  * }
596
653
  * });
597
654
  */
598
- broadcastEvent: (event: any, options?: BroadcastOptions) => void;
655
+ broadcastEvent: (event: JsonObject, options?: BroadcastOptions) => void;
599
656
  /**
600
657
  * Get the room's storage asynchronously.
601
658
  * The storage's root is a {@link LiveObject}.
@@ -603,7 +660,7 @@ declare type Room = {
603
660
  * @example
604
661
  * const { root } = await room.getStorage();
605
662
  */
606
- getStorage: <TRoot>() => Promise<{
663
+ getStorage: <TRoot extends LsonObject>() => Promise<{
607
664
  root: LiveObject<TRoot>;
608
665
  }>;
609
666
  /**
@@ -635,37 +692,37 @@ declare abstract class AbstractCrdt {
635
692
  * Keys should be a string, and values should be serializable to JSON.
636
693
  * If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
637
694
  */
638
- declare class LiveObject<T extends Record<string, any> = Record<string, any>> extends AbstractCrdt {
695
+ declare class LiveObject<O extends LsonObject = LsonObject> extends AbstractCrdt {
639
696
  private _map;
640
697
  private _propToLastUpdate;
641
- constructor(object?: T);
698
+ constructor(object?: O);
642
699
  private _applyUpdate;
643
700
  private _applyDeleteObjectKey;
644
701
  /**
645
702
  * Transform the LiveObject into a javascript object
646
703
  */
647
- toObject(): T;
704
+ toObject(): O;
648
705
  /**
649
706
  * Adds or updates a property with a specified key and a value.
650
707
  * @param key The key of the property to add
651
708
  * @param value The value of the property to add
652
709
  */
653
- set<TKey extends keyof T>(key: TKey, value: T[TKey]): void;
710
+ set<TKey extends keyof O>(key: TKey, value: O[TKey]): void;
654
711
  /**
655
712
  * Returns a specified property from the LiveObject.
656
713
  * @param key The key of the property to get
657
714
  */
658
- get<TKey extends keyof T>(key: TKey): T[TKey];
715
+ get<TKey extends keyof O>(key: TKey): O[TKey];
659
716
  /**
660
717
  * Deletes a key from the LiveObject
661
718
  * @param key The key of the property to delete
662
719
  */
663
- delete(key: keyof T): void;
720
+ delete(key: keyof O): void;
664
721
  /**
665
722
  * Adds or updates multiple properties at once with an object.
666
723
  * @param overrides The object used to overrides properties
667
724
  */
668
- update(overrides: Partial<T>): void;
725
+ update(overrides: Partial<O>): void;
669
726
  }
670
727
 
671
728
  /**
@@ -695,4 +752,4 @@ declare class LiveObject<T extends Record<string, any> = Record<string, any>> ex
695
752
  */
696
753
  declare function createClient(options: ClientOptions): Client;
697
754
 
698
- export { BroadcastOptions, Client, LiveList, LiveMap, LiveObject, Others, Presence, Room, StorageUpdate, User, createClient };
755
+ export { BroadcastOptions, Client, History, Json, JsonObject, LiveList, LiveMap, LiveObject, Lson, LsonObject, Others, Presence, Room, StorageUpdate, User, createClient };