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