@liveblocks/client 0.13.3 → 0.15.0-alpha.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.
Files changed (45) hide show
  1. package/lib/cjs/AbstractCrdt.d.ts +13 -7
  2. package/lib/cjs/AbstractCrdt.js +2 -5
  3. package/lib/cjs/LiveList.d.ts +16 -6
  4. package/lib/cjs/LiveList.js +148 -17
  5. package/lib/cjs/LiveMap.d.ts +12 -4
  6. package/lib/cjs/LiveMap.js +57 -7
  7. package/lib/cjs/LiveObject.d.ts +22 -8
  8. package/lib/cjs/LiveObject.js +109 -24
  9. package/lib/cjs/LiveRegister.d.ts +13 -5
  10. package/lib/cjs/LiveRegister.js +23 -4
  11. package/lib/cjs/immutable.d.ts +1 -0
  12. package/lib/cjs/immutable.js +64 -6
  13. package/lib/cjs/index.d.ts +1 -0
  14. package/lib/cjs/index.js +8 -1
  15. package/lib/cjs/live.d.ts +7 -0
  16. package/lib/cjs/room.d.ts +9 -1
  17. package/lib/cjs/room.js +131 -70
  18. package/lib/cjs/types.d.ts +25 -0
  19. package/lib/cjs/utils.d.ts +4 -1
  20. package/lib/cjs/utils.js +101 -1
  21. package/lib/esm/AbstractCrdt.d.ts +13 -7
  22. package/lib/esm/AbstractCrdt.js +2 -5
  23. package/lib/esm/LiveList.d.ts +16 -6
  24. package/lib/esm/LiveList.js +149 -18
  25. package/lib/esm/LiveMap.d.ts +12 -4
  26. package/lib/esm/LiveMap.js +57 -7
  27. package/lib/esm/LiveObject.d.ts +22 -8
  28. package/lib/esm/LiveObject.js +109 -24
  29. package/lib/esm/LiveRegister.d.ts +13 -5
  30. package/lib/esm/LiveRegister.js +24 -5
  31. package/lib/esm/immutable.d.ts +1 -0
  32. package/lib/esm/immutable.js +63 -6
  33. package/lib/esm/index.d.ts +1 -0
  34. package/lib/esm/index.js +1 -0
  35. package/lib/esm/live.d.ts +7 -0
  36. package/lib/esm/room.d.ts +9 -1
  37. package/lib/esm/room.js +132 -71
  38. package/lib/esm/types.d.ts +25 -0
  39. package/lib/esm/utils.d.ts +4 -1
  40. package/lib/esm/utils.js +99 -1
  41. package/package.json +2 -2
  42. package/lib/cjs/immutable/index.d.ts +0 -7
  43. package/lib/cjs/immutable/index.js +0 -214
  44. package/lib/esm/immutable/index.d.ts +0 -7
  45. package/lib/esm/immutable/index.js +0 -207
@@ -38,13 +38,14 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
38
38
  /**
39
39
  * INTERNAL
40
40
  */
41
- _serialize(parentId, parentKey) {
41
+ _serialize(parentId, parentKey, doc) {
42
42
  if (this._id == null) {
43
43
  throw new Error("Cannot serialize item is not attached");
44
44
  }
45
45
  const ops = [];
46
46
  const op = {
47
47
  id: this._id,
48
+ opId: doc === null || doc === void 0 ? void 0 : doc.generateOpId(),
48
49
  type: live_1.OpType.CreateObject,
49
50
  parentId,
50
51
  parentKey,
@@ -53,7 +54,7 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
53
54
  ops.push(op);
54
55
  for (const [key, value] of __classPrivateFieldGet(this, _LiveObject_map, "f")) {
55
56
  if (value instanceof AbstractCrdt_1.AbstractCrdt) {
56
- ops.push(...value._serialize(this._id, key));
57
+ ops.push(...value._serialize(this._id, key, doc));
57
58
  }
58
59
  else {
59
60
  op.data[key] = value;
@@ -70,7 +71,13 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
70
71
  }
71
72
  const object = new LiveObject(item.data);
72
73
  object._attach(id, doc);
73
- const children = parentToChildren.get(id);
74
+ return this._deserializeChildren(object, parentToChildren, doc);
75
+ }
76
+ /**
77
+ * INTERNAL
78
+ */
79
+ static _deserializeChildren(object, parentToChildren, doc) {
80
+ const children = parentToChildren.get(object._id);
74
81
  if (children == null) {
75
82
  return object;
76
83
  }
@@ -99,7 +106,7 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
99
106
  /**
100
107
  * INTERNAL
101
108
  */
102
- _attachChild(id, key, child) {
109
+ _attachChild(id, key, child, isLocal) {
103
110
  if (this._doc == null) {
104
111
  throw new Error("Can't attach child if doc is not present");
105
112
  }
@@ -126,19 +133,45 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
126
133
  __classPrivateFieldGet(this, _LiveObject_map, "f").set(key, child);
127
134
  child._setParentLink(this, key);
128
135
  child._attach(id, this._doc);
129
- return { reverse, modified: this };
136
+ return {
137
+ reverse,
138
+ modified: {
139
+ node: this,
140
+ type: "LiveObject",
141
+ updates: { [key]: { type: "update" } },
142
+ },
143
+ };
130
144
  }
131
145
  /**
132
146
  * INTERNAL
133
147
  */
134
148
  _detachChild(child) {
135
- for (const [key, value] of __classPrivateFieldGet(this, _LiveObject_map, "f")) {
136
- if (value === child) {
137
- __classPrivateFieldGet(this, _LiveObject_map, "f").delete(key);
138
- }
139
- }
140
149
  if (child) {
150
+ const reverse = child._serialize(this._id, child._parentKey, this._doc);
151
+ for (const [key, value] of __classPrivateFieldGet(this, _LiveObject_map, "f")) {
152
+ if (value === child) {
153
+ __classPrivateFieldGet(this, _LiveObject_map, "f").delete(key);
154
+ }
155
+ }
141
156
  child._detach();
157
+ const storageUpdate = {
158
+ node: this,
159
+ type: "LiveObject",
160
+ updates: {
161
+ [child._parentKey]: { type: "delete" },
162
+ },
163
+ };
164
+ return { modified: storageUpdate, reverse };
165
+ }
166
+ return { modified: false };
167
+ }
168
+ /**
169
+ * INTERNAL
170
+ */
171
+ _detachChildren() {
172
+ for (const [key, value] of __classPrivateFieldGet(this, _LiveObject_map, "f")) {
173
+ __classPrivateFieldGet(this, _LiveObject_map, "f").delete(key);
174
+ value._detach();
142
175
  }
143
176
  }
144
177
  /**
@@ -155,14 +188,32 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
155
188
  /**
156
189
  * INTERNAL
157
190
  */
158
- _apply(op) {
191
+ _apply(op, isLocal) {
159
192
  if (op.type === live_1.OpType.UpdateObject) {
160
- return __classPrivateFieldGet(this, _LiveObject_instances, "m", _LiveObject_applyUpdate).call(this, op);
193
+ return __classPrivateFieldGet(this, _LiveObject_instances, "m", _LiveObject_applyUpdate).call(this, op, isLocal);
161
194
  }
162
195
  else if (op.type === live_1.OpType.DeleteObjectKey) {
163
196
  return __classPrivateFieldGet(this, _LiveObject_instances, "m", _LiveObject_applyDeleteObjectKey).call(this, op);
164
197
  }
165
- return super._apply(op);
198
+ return super._apply(op, isLocal);
199
+ }
200
+ /**
201
+ * INTERNAL
202
+ */
203
+ _toSerializedCrdt() {
204
+ var _a;
205
+ return {
206
+ type: live_1.CrdtType.Object,
207
+ parentId: (_a = this._parent) === null || _a === void 0 ? void 0 : _a._id,
208
+ parentKey: this._parentKey,
209
+ data: this.toObject(),
210
+ };
211
+ }
212
+ /**
213
+ * INTERNAL
214
+ */
215
+ _getType() {
216
+ return "LiveObject";
166
217
  }
167
218
  /**
168
219
  * Transform the LiveObject into a javascript object
@@ -218,7 +269,20 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
218
269
  ];
219
270
  }
220
271
  __classPrivateFieldGet(this, _LiveObject_map, "f").delete(keyAsString);
221
- this._doc.dispatch([{ type: live_1.OpType.DeleteObjectKey, key: keyAsString, id: this._id }], reverse, [this]);
272
+ const storageUpdates = new Map();
273
+ storageUpdates.set(this._id, {
274
+ node: this,
275
+ type: "LiveObject",
276
+ updates: { [key]: { type: "delete" } },
277
+ });
278
+ this._doc.dispatch([
279
+ {
280
+ type: live_1.OpType.DeleteObjectKey,
281
+ key: keyAsString,
282
+ id: this._id,
283
+ opId: this._doc.generateOpId(),
284
+ },
285
+ ], reverse, storageUpdates);
222
286
  }
223
287
  /**
224
288
  * Adds or updates multiple properties at once with an object.
@@ -248,6 +312,7 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
248
312
  type: live_1.OpType.UpdateObject,
249
313
  data: {},
250
314
  };
315
+ const updateDelta = {};
251
316
  for (const key in overrides) {
252
317
  __classPrivateFieldGet(this, _LiveObject_propToLastUpdate, "f").set(key, opId);
253
318
  const oldValue = __classPrivateFieldGet(this, _LiveObject_map, "f").get(key);
@@ -265,12 +330,13 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
265
330
  if (newValue instanceof AbstractCrdt_1.AbstractCrdt) {
266
331
  newValue._setParentLink(this, key);
267
332
  newValue._attach(this._doc.generateId(), this._doc);
268
- ops.push(...newValue._serialize(this._id, key));
333
+ ops.push(...newValue._serialize(this._id, key, this._doc));
269
334
  }
270
335
  else {
271
336
  updatedProps[key] = newValue;
272
337
  }
273
338
  __classPrivateFieldGet(this, _LiveObject_map, "f").set(key, newValue);
339
+ updateDelta[key] = { type: "update" };
274
340
  }
275
341
  if (Object.keys(reverseUpdateOp.data).length !== 0) {
276
342
  reverseOps.unshift(reverseUpdateOp);
@@ -283,11 +349,17 @@ class LiveObject extends AbstractCrdt_1.AbstractCrdt {
283
349
  data: updatedProps,
284
350
  });
285
351
  }
286
- this._doc.dispatch(ops, reverseOps, [this]);
352
+ const storageUpdates = new Map();
353
+ storageUpdates.set(this._id, {
354
+ node: this,
355
+ type: "LiveObject",
356
+ updates: updateDelta,
357
+ });
358
+ this._doc.dispatch(ops, reverseOps, storageUpdates);
287
359
  }
288
360
  }
289
361
  exports.LiveObject = LiveObject;
290
- _LiveObject_map = new WeakMap(), _LiveObject_propToLastUpdate = new WeakMap(), _LiveObject_instances = new WeakSet(), _LiveObject_applyUpdate = function _LiveObject_applyUpdate(op) {
362
+ _LiveObject_map = new WeakMap(), _LiveObject_propToLastUpdate = new WeakMap(), _LiveObject_instances = new WeakSet(), _LiveObject_applyUpdate = function _LiveObject_applyUpdate(op, isLocal) {
291
363
  let isModified = false;
292
364
  const reverse = [];
293
365
  const reverseUpdate = {
@@ -309,11 +381,7 @@ _LiveObject_map = new WeakMap(), _LiveObject_propToLastUpdate = new WeakMap(), _
309
381
  reverse.push({ type: live_1.OpType.DeleteObjectKey, id: this._id, key });
310
382
  }
311
383
  }
312
- let isLocal = false;
313
- if (op.opId == null) {
314
- isLocal = true;
315
- op.opId = this._doc.generateOpId();
316
- }
384
+ let updateDelta = {};
317
385
  for (const key in op.data) {
318
386
  if (isLocal) {
319
387
  __classPrivateFieldGet(this, _LiveObject_propToLastUpdate, "f").set(key, op.opId);
@@ -336,12 +404,22 @@ _LiveObject_map = new WeakMap(), _LiveObject_propToLastUpdate = new WeakMap(), _
336
404
  oldValue._detach();
337
405
  }
338
406
  isModified = true;
407
+ updateDelta[key] = { type: "update" };
339
408
  __classPrivateFieldGet(this, _LiveObject_map, "f").set(key, op.data[key]);
340
409
  }
341
410
  if (Object.keys(reverseUpdate.data).length !== 0) {
342
411
  reverse.unshift(reverseUpdate);
343
412
  }
344
- return isModified ? { modified: this, reverse } : { modified: false };
413
+ return isModified
414
+ ? {
415
+ modified: {
416
+ node: this,
417
+ type: "LiveObject",
418
+ updates: updateDelta,
419
+ },
420
+ reverse,
421
+ }
422
+ : { modified: false };
345
423
  }, _LiveObject_applyDeleteObjectKey = function _LiveObject_applyDeleteObjectKey(op) {
346
424
  const key = op.key;
347
425
  // If property does not exist, exit without notifying
@@ -364,5 +442,12 @@ _LiveObject_map = new WeakMap(), _LiveObject_propToLastUpdate = new WeakMap(), _
364
442
  ];
365
443
  }
366
444
  __classPrivateFieldGet(this, _LiveObject_map, "f").delete(key);
367
- return { modified: this, reverse };
445
+ return {
446
+ modified: {
447
+ node: this,
448
+ type: "LiveObject",
449
+ updates: { [op.key]: { type: "delete" } },
450
+ },
451
+ reverse,
452
+ };
368
453
  };
@@ -1,5 +1,5 @@
1
1
  import { AbstractCrdt, Doc, ApplyResult } from "./AbstractCrdt";
2
- import { SerializedCrdtWithId, Op } from "./live";
2
+ import { SerializedCrdtWithId, Op, SerializedCrdt } from "./live";
3
3
  /**
4
4
  * INTERNAL
5
5
  */
@@ -14,8 +14,16 @@ export declare class LiveRegister<TValue = any> extends AbstractCrdt {
14
14
  /**
15
15
  * INTERNAL
16
16
  */
17
- _serialize(parentId: string, parentKey: string): Op[];
18
- _attachChild(id: string, key: string, crdt: AbstractCrdt): ApplyResult;
19
- _detachChild(crdt: AbstractCrdt): void;
20
- _apply(op: Op): ApplyResult;
17
+ _serialize(parentId: string, parentKey: string, doc?: Doc): Op[];
18
+ /**
19
+ * INTERNAL
20
+ */
21
+ _toSerializedCrdt(): SerializedCrdt;
22
+ _attachChild(id: string, key: string, crdt: AbstractCrdt, isLocal: boolean): ApplyResult;
23
+ _detachChild(crdt: AbstractCrdt): ApplyResult;
24
+ _apply(op: Op, isLocal: boolean): ApplyResult;
25
+ /**
26
+ * INTERNAL
27
+ */
28
+ _getType(): string;
21
29
  }
@@ -41,13 +41,14 @@ class LiveRegister extends AbstractCrdt_1.AbstractCrdt {
41
41
  /**
42
42
  * INTERNAL
43
43
  */
44
- _serialize(parentId, parentKey) {
44
+ _serialize(parentId, parentKey, doc) {
45
45
  if (this._id == null || parentId == null || parentKey == null) {
46
46
  throw new Error("Cannot serialize register if parentId or parentKey is undefined");
47
47
  }
48
48
  return [
49
49
  {
50
50
  type: live_1.OpType.CreateRegister,
51
+ opId: doc === null || doc === void 0 ? void 0 : doc.generateOpId(),
51
52
  id: this._id,
52
53
  parentId,
53
54
  parentKey,
@@ -55,14 +56,32 @@ class LiveRegister extends AbstractCrdt_1.AbstractCrdt {
55
56
  },
56
57
  ];
57
58
  }
58
- _attachChild(id, key, crdt) {
59
+ /**
60
+ * INTERNAL
61
+ */
62
+ _toSerializedCrdt() {
63
+ var _a;
64
+ return {
65
+ type: live_1.CrdtType.Register,
66
+ parentId: (_a = this._parent) === null || _a === void 0 ? void 0 : _a._id,
67
+ parentKey: this._parentKey,
68
+ data: this.data,
69
+ };
70
+ }
71
+ _attachChild(id, key, crdt, isLocal) {
59
72
  throw new Error("Method not implemented.");
60
73
  }
61
74
  _detachChild(crdt) {
62
75
  throw new Error("Method not implemented.");
63
76
  }
64
- _apply(op) {
65
- return super._apply(op);
77
+ _apply(op, isLocal) {
78
+ return super._apply(op, isLocal);
79
+ }
80
+ /**
81
+ * INTERNAL
82
+ */
83
+ _getType() {
84
+ return "LiveRegister";
66
85
  }
67
86
  }
68
87
  exports.LiveRegister = LiveRegister;
@@ -2,6 +2,7 @@ import { LiveList } from "./LiveList";
2
2
  import { LiveObject } from "./LiveObject";
3
3
  import { StorageUpdate } from "./types";
4
4
  export declare function liveObjectToJson(liveObject: LiveObject<any>): any;
5
+ export declare function liveNodeToJson(value: any): any;
5
6
  export declare function patchLiveList<T>(liveList: LiveList<T>, prev: Array<T>, next: Array<T>): void;
6
7
  export declare function patchLiveObjectKey<T>(liveObject: LiveObject<T>, key: keyof T, prev: any, next: any): void;
7
8
  export declare function patchLiveObject<T extends Record<string, any>>(root: LiveObject<T>, prev: T, next: T): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patchImmutableObject = exports.patchLiveObject = exports.patchLiveObjectKey = exports.patchLiveList = exports.liveObjectToJson = void 0;
3
+ exports.patchImmutableObject = exports.patchLiveObject = exports.patchLiveObjectKey = exports.patchLiveList = exports.liveNodeToJson = exports.liveObjectToJson = void 0;
4
4
  const LiveList_1 = require("./LiveList");
5
5
  const LiveMap_1 = require("./LiveMap");
6
6
  const LiveObject_1 = require("./LiveObject");
@@ -40,6 +40,7 @@ function liveNodeToJson(value) {
40
40
  }
41
41
  return value;
42
42
  }
43
+ exports.liveNodeToJson = liveNodeToJson;
43
44
  function isPlainObject(obj) {
44
45
  return Object.prototype.toString.call(obj) === "[object Object]";
45
46
  }
@@ -105,8 +106,10 @@ function patchLiveList(liveList, prev, next) {
105
106
  }
106
107
  }
107
108
  else if (i > nextEnd) {
108
- while (i <= prevEnd) {
109
- liveList.delete(i++);
109
+ let localI = i;
110
+ while (localI <= prevEnd) {
111
+ liveList.delete(i);
112
+ localI++;
110
113
  }
111
114
  }
112
115
  else {
@@ -199,6 +202,7 @@ function patchImmutableObjectWithUpdate(state, update) {
199
202
  return patchImmutableNode(state, path, update);
200
203
  }
201
204
  function patchImmutableNode(state, path, update) {
205
+ var _a, _b, _c, _d;
202
206
  const pathItem = path.pop();
203
207
  if (pathItem === undefined) {
204
208
  switch (update.type) {
@@ -206,19 +210,73 @@ function patchImmutableNode(state, path, update) {
206
210
  if (typeof state !== "object") {
207
211
  throw new Error("Internal: received update on LiveObject but state was not an object");
208
212
  }
209
- return liveObjectToJson(update.node);
213
+ let newState = Object.assign({}, state);
214
+ for (const key in update.updates) {
215
+ if (((_a = update.updates[key]) === null || _a === void 0 ? void 0 : _a.type) === "update") {
216
+ newState[key] = liveNodeToJson(update.node.get(key));
217
+ }
218
+ else if (((_b = update.updates[key]) === null || _b === void 0 ? void 0 : _b.type) === "delete") {
219
+ delete newState[key];
220
+ }
221
+ }
222
+ return newState;
210
223
  }
211
224
  case "LiveList": {
212
225
  if (Array.isArray(state) === false) {
213
226
  throw new Error("Internal: received update on LiveList but state was not an array");
214
227
  }
215
- return liveListToJson(update.node);
228
+ let newState = state.map((x) => x);
229
+ for (const listUpdate of update.updates) {
230
+ if (listUpdate.type === "insert") {
231
+ if (listUpdate.index === newState.length) {
232
+ newState.push(liveNodeToJson(listUpdate.item));
233
+ }
234
+ else {
235
+ newState = [
236
+ ...newState.slice(0, listUpdate.index),
237
+ liveNodeToJson(listUpdate.item),
238
+ ...newState.slice(listUpdate.index),
239
+ ];
240
+ }
241
+ }
242
+ else if (listUpdate.type === "delete") {
243
+ newState.splice(listUpdate.index, 1);
244
+ }
245
+ else if (listUpdate.type === "move") {
246
+ if (listUpdate.previousIndex > listUpdate.index) {
247
+ newState = [
248
+ ...newState.slice(0, listUpdate.index),
249
+ liveNodeToJson(listUpdate.item),
250
+ ...newState.slice(listUpdate.index, listUpdate.previousIndex),
251
+ ...newState.slice(listUpdate.previousIndex + 1),
252
+ ];
253
+ }
254
+ else {
255
+ newState = [
256
+ ...newState.slice(0, listUpdate.previousIndex),
257
+ ...newState.slice(listUpdate.previousIndex + 1, listUpdate.index + 1),
258
+ liveNodeToJson(listUpdate.item),
259
+ ...newState.slice(listUpdate.index + 1),
260
+ ];
261
+ }
262
+ }
263
+ }
264
+ return newState;
216
265
  }
217
266
  case "LiveMap": {
218
267
  if (typeof state !== "object") {
219
268
  throw new Error("Internal: received update on LiveMap but state was not an object");
220
269
  }
221
- return liveMapToJson(update.node);
270
+ let newState = Object.assign({}, state);
271
+ for (const key in update.updates) {
272
+ if (((_c = update.updates[key]) === null || _c === void 0 ? void 0 : _c.type) === "update") {
273
+ newState[key] = liveNodeToJson(update.node.get(key));
274
+ }
275
+ else if (((_d = update.updates[key]) === null || _d === void 0 ? void 0 : _d.type) === "delete") {
276
+ delete newState[key];
277
+ }
278
+ }
279
+ return newState;
222
280
  }
223
281
  }
224
282
  }
@@ -3,3 +3,4 @@ export { LiveMap } from "./LiveMap";
3
3
  export { LiveList } from "./LiveList";
4
4
  export type { Others, Presence, Room, Client, User, BroadcastOptions, } from "./types";
5
5
  export { createClient } from "./client";
6
+ export { liveObjectToJson, liveNodeToJson, patchLiveList, patchImmutableObject, patchLiveObject, patchLiveObjectKey, } from "./immutable";
package/lib/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createClient = exports.LiveList = exports.LiveMap = exports.LiveObject = void 0;
3
+ exports.patchLiveObjectKey = exports.patchLiveObject = exports.patchImmutableObject = exports.patchLiveList = exports.liveNodeToJson = exports.liveObjectToJson = exports.createClient = exports.LiveList = exports.LiveMap = exports.LiveObject = void 0;
4
4
  var LiveObject_1 = require("./LiveObject");
5
5
  Object.defineProperty(exports, "LiveObject", { enumerable: true, get: function () { return LiveObject_1.LiveObject; } });
6
6
  var LiveMap_1 = require("./LiveMap");
@@ -9,3 +9,10 @@ var LiveList_1 = require("./LiveList");
9
9
  Object.defineProperty(exports, "LiveList", { enumerable: true, get: function () { return LiveList_1.LiveList; } });
10
10
  var client_1 = require("./client");
11
11
  Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } });
12
+ var immutable_1 = require("./immutable");
13
+ Object.defineProperty(exports, "liveObjectToJson", { enumerable: true, get: function () { return immutable_1.liveObjectToJson; } });
14
+ Object.defineProperty(exports, "liveNodeToJson", { enumerable: true, get: function () { return immutable_1.liveNodeToJson; } });
15
+ Object.defineProperty(exports, "patchLiveList", { enumerable: true, get: function () { return immutable_1.patchLiveList; } });
16
+ Object.defineProperty(exports, "patchImmutableObject", { enumerable: true, get: function () { return immutable_1.patchImmutableObject; } });
17
+ Object.defineProperty(exports, "patchLiveObject", { enumerable: true, get: function () { return immutable_1.patchLiveObject; } });
18
+ Object.defineProperty(exports, "patchLiveObjectKey", { enumerable: true, get: function () { return immutable_1.patchLiveObjectKey; } });
package/lib/cjs/live.d.ts CHANGED
@@ -122,6 +122,7 @@ export declare type UpdateObjectOp = {
122
122
  };
123
123
  };
124
124
  export declare type CreateObjectOp = {
125
+ opId?: string;
125
126
  id: string;
126
127
  type: OpType.CreateObject;
127
128
  parentId?: string;
@@ -131,18 +132,21 @@ export declare type CreateObjectOp = {
131
132
  };
132
133
  };
133
134
  export declare type CreateListOp = {
135
+ opId?: string;
134
136
  id: string;
135
137
  type: OpType.CreateList;
136
138
  parentId: string;
137
139
  parentKey: string;
138
140
  };
139
141
  export declare type CreateMapOp = {
142
+ opId?: string;
140
143
  id: string;
141
144
  type: OpType.CreateMap;
142
145
  parentId: string;
143
146
  parentKey: string;
144
147
  };
145
148
  export declare type CreateRegisterOp = {
149
+ opId?: string;
146
150
  id: string;
147
151
  type: OpType.CreateRegister;
148
152
  parentId: string;
@@ -150,15 +154,18 @@ export declare type CreateRegisterOp = {
150
154
  data: any;
151
155
  };
152
156
  export declare type DeleteCrdtOp = {
157
+ opId?: string;
153
158
  id: string;
154
159
  type: OpType.DeleteCrdt;
155
160
  };
156
161
  export declare type SetParentKeyOp = {
162
+ opId?: string;
157
163
  id: string;
158
164
  type: OpType.SetParentKey;
159
165
  parentKey: string;
160
166
  };
161
167
  export declare type DeleteObjectKeyOp = {
168
+ opId?: string;
162
169
  id: string;
163
170
  type: OpType.DeleteObjectKey;
164
171
  key: string;
package/lib/cjs/room.d.ts CHANGED
@@ -11,6 +11,7 @@ declare type HistoryItem = Array<Op | {
11
11
  declare type IdFactory = () => string;
12
12
  export declare type State = {
13
13
  connection: Connection;
14
+ lastConnectionId: number | null;
14
15
  socket: WebSocket | null;
15
16
  lastFlushTime: number;
16
17
  buffer: {
@@ -59,9 +60,10 @@ export declare type State = {
59
60
  updates: {
60
61
  others: [];
61
62
  presence: boolean;
62
- nodes: Set<AbstractCrdt>;
63
+ storageUpdates: Map<string, StorageUpdate>;
63
64
  };
64
65
  };
66
+ offlineOperations: Map<string, Op>;
65
67
  };
66
68
  export declare type Effects = {
67
69
  authenticate(): void;
@@ -89,6 +91,12 @@ export declare function makeStateMachine(state: State, context: Context, mockedE
89
91
  authenticationSuccess: (token: AuthenticationToken, socket: WebSocket) => void;
90
92
  heartbeat: () => void;
91
93
  onNavigatorOnline: () => void;
94
+ simulateSocketClose: () => void;
95
+ simulateSendCloseEvent: (event: {
96
+ code: number;
97
+ wasClean: boolean;
98
+ reason: any;
99
+ }) => void;
92
100
  onVisibilityChange: (visibilityState: VisibilityState) => void;
93
101
  getUndoStack: () => HistoryItem[];
94
102
  getItemsCount: () => number;