@liveblocks/client 0.16.7 → 0.16.10

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/shared.mjs CHANGED
@@ -1,23 +1,31 @@
1
- var ServerMessageType, ClientMessageType, CrdtType, OpType, WebsocketCloseCodes;
1
+ var ServerMsgCode, ClientMsgCode, CrdtType, OpCode, WebsocketCloseCodes;
2
2
 
3
- !function(ServerMessageType) {
4
- ServerMessageType[ServerMessageType.UpdatePresence = 100] = "UpdatePresence", ServerMessageType[ServerMessageType.UserJoined = 101] = "UserJoined",
5
- ServerMessageType[ServerMessageType.UserLeft = 102] = "UserLeft", ServerMessageType[ServerMessageType.Event = 103] = "Event",
6
- ServerMessageType[ServerMessageType.RoomState = 104] = "RoomState", ServerMessageType[ServerMessageType.InitialStorageState = 200] = "InitialStorageState",
7
- ServerMessageType[ServerMessageType.UpdateStorage = 201] = "UpdateStorage";
8
- }(ServerMessageType || (ServerMessageType = {})), function(ClientMessageType) {
9
- ClientMessageType[ClientMessageType.UpdatePresence = 100] = "UpdatePresence", ClientMessageType[ClientMessageType.ClientEvent = 103] = "ClientEvent",
10
- ClientMessageType[ClientMessageType.FetchStorage = 200] = "FetchStorage", ClientMessageType[ClientMessageType.UpdateStorage = 201] = "UpdateStorage";
11
- }(ClientMessageType || (ClientMessageType = {})), function(CrdtType) {
12
- CrdtType[CrdtType.Object = 0] = "Object", CrdtType[CrdtType.List = 1] = "List",
13
- CrdtType[CrdtType.Map = 2] = "Map", CrdtType[CrdtType.Register = 3] = "Register";
14
- }(CrdtType || (CrdtType = {})), function(OpType) {
15
- OpType[OpType.Init = 0] = "Init", OpType[OpType.SetParentKey = 1] = "SetParentKey",
16
- OpType[OpType.CreateList = 2] = "CreateList", OpType[OpType.UpdateObject = 3] = "UpdateObject",
17
- OpType[OpType.CreateObject = 4] = "CreateObject", OpType[OpType.DeleteCrdt = 5] = "DeleteCrdt",
18
- OpType[OpType.DeleteObjectKey = 6] = "DeleteObjectKey", OpType[OpType.CreateMap = 7] = "CreateMap",
19
- OpType[OpType.CreateRegister = 8] = "CreateRegister";
20
- }(OpType || (OpType = {})), function(WebsocketCloseCodes) {
3
+ function isRootCrdt(crdt) {
4
+ return crdt.type === CrdtType.OBJECT && !isChildCrdt(crdt);
5
+ }
6
+
7
+ function isChildCrdt(crdt) {
8
+ return void 0 !== crdt.parentId && void 0 !== crdt.parentKey;
9
+ }
10
+
11
+ !function(ServerMsgCode) {
12
+ ServerMsgCode[ServerMsgCode.UPDATE_PRESENCE = 100] = "UPDATE_PRESENCE", ServerMsgCode[ServerMsgCode.USER_JOINED = 101] = "USER_JOINED",
13
+ ServerMsgCode[ServerMsgCode.USER_LEFT = 102] = "USER_LEFT", ServerMsgCode[ServerMsgCode.BROADCASTED_EVENT = 103] = "BROADCASTED_EVENT",
14
+ ServerMsgCode[ServerMsgCode.ROOM_STATE = 104] = "ROOM_STATE", ServerMsgCode[ServerMsgCode.INITIAL_STORAGE_STATE = 200] = "INITIAL_STORAGE_STATE",
15
+ ServerMsgCode[ServerMsgCode.UPDATE_STORAGE = 201] = "UPDATE_STORAGE";
16
+ }(ServerMsgCode || (ServerMsgCode = {})), function(ClientMsgCode) {
17
+ ClientMsgCode[ClientMsgCode.UPDATE_PRESENCE = 100] = "UPDATE_PRESENCE", ClientMsgCode[ClientMsgCode.BROADCAST_EVENT = 103] = "BROADCAST_EVENT",
18
+ ClientMsgCode[ClientMsgCode.FETCH_STORAGE = 200] = "FETCH_STORAGE", ClientMsgCode[ClientMsgCode.UPDATE_STORAGE = 201] = "UPDATE_STORAGE";
19
+ }(ClientMsgCode || (ClientMsgCode = {})), function(CrdtType) {
20
+ CrdtType[CrdtType.OBJECT = 0] = "OBJECT", CrdtType[CrdtType.LIST = 1] = "LIST",
21
+ CrdtType[CrdtType.MAP = 2] = "MAP", CrdtType[CrdtType.REGISTER = 3] = "REGISTER";
22
+ }(CrdtType || (CrdtType = {})), function(OpCode) {
23
+ OpCode[OpCode.INIT = 0] = "INIT", OpCode[OpCode.SET_PARENT_KEY = 1] = "SET_PARENT_KEY",
24
+ OpCode[OpCode.CREATE_LIST = 2] = "CREATE_LIST", OpCode[OpCode.UPDATE_OBJECT = 3] = "UPDATE_OBJECT",
25
+ OpCode[OpCode.CREATE_OBJECT = 4] = "CREATE_OBJECT", OpCode[OpCode.DELETE_CRDT = 5] = "DELETE_CRDT",
26
+ OpCode[OpCode.DELETE_OBJECT_KEY = 6] = "DELETE_OBJECT_KEY", OpCode[OpCode.CREATE_MAP = 7] = "CREATE_MAP",
27
+ OpCode[OpCode.CREATE_REGISTER = 8] = "CREATE_REGISTER";
28
+ }(OpCode || (OpCode = {})), function(WebsocketCloseCodes) {
21
29
  WebsocketCloseCodes[WebsocketCloseCodes.CLOSE_ABNORMAL = 1006] = "CLOSE_ABNORMAL",
22
30
  WebsocketCloseCodes[WebsocketCloseCodes.INVALID_MESSAGE_FORMAT = 4e3] = "INVALID_MESSAGE_FORMAT",
23
31
  WebsocketCloseCodes[WebsocketCloseCodes.NOT_ALLOWED = 4001] = "NOT_ALLOWED", WebsocketCloseCodes[WebsocketCloseCodes.MAX_NUMBER_OF_MESSAGES_PER_SECONDS = 4002] = "MAX_NUMBER_OF_MESSAGES_PER_SECONDS",
@@ -44,7 +52,7 @@ class AbstractCrdt {
44
52
  return this.__parentKey;
45
53
  }
46
54
  _apply(op, _isLocal) {
47
- return op.type === OpType.DeleteCrdt && null != this._parent && null != this._parentKey ? this._parent._detachChild(this) : {
55
+ return op.type === OpCode.DELETE_CRDT && null != this._parent && null != this._parentKey ? this._parent._detachChild(this) : {
48
56
  modified: !1
49
57
  };
50
58
  }
@@ -86,14 +94,13 @@ class LiveRegister extends AbstractCrdt {
86
94
  return this._data;
87
95
  }
88
96
  static _deserialize([id, item], _parentToChildren, doc) {
89
- if (item.type !== CrdtType.Register) throw new Error(`Tried to deserialize a map but item type is "${item.type}"`);
90
97
  const register = new LiveRegister(item.data);
91
98
  return register._attach(id, doc), register;
92
99
  }
93
100
  _serialize(parentId, parentKey, doc, intent) {
94
101
  if (null == this._id || null == parentId || null == parentKey) throw new Error("Cannot serialize register if parentId or parentKey is undefined");
95
102
  return [ {
96
- type: OpType.CreateRegister,
103
+ type: OpCode.CREATE_REGISTER,
97
104
  opId: null == doc ? void 0 : doc.generateOpId(),
98
105
  id: this._id,
99
106
  intent: intent,
@@ -105,7 +112,7 @@ class LiveRegister extends AbstractCrdt {
105
112
  _toSerializedCrdt() {
106
113
  var _a;
107
114
  return {
108
- type: CrdtType.Register,
115
+ type: CrdtType.REGISTER,
109
116
  parentId: null === (_a = this._parent) || void 0 === _a ? void 0 : _a._id,
110
117
  parentKey: this._parentKey,
111
118
  data: this.data
@@ -222,7 +229,7 @@ class LiveList extends AbstractCrdt {
222
229
  id: this._id,
223
230
  opId: null == doc ? void 0 : doc.generateOpId(),
224
231
  intent: intent,
225
- type: OpType.CreateList,
232
+ type: OpCode.CREATE_LIST,
226
233
  parentId: parentId,
227
234
  parentKey: parentKey
228
235
  };
@@ -278,7 +285,7 @@ class LiveList extends AbstractCrdt {
278
285
  const newIndex = this._items.findIndex((entry => entry[1] === newKey));
279
286
  return {
280
287
  reverse: [ {
281
- type: OpType.DeleteCrdt,
288
+ type: OpCode.DELETE_CRDT,
282
289
  id: id
283
290
  } ],
284
291
  modified: {
@@ -332,7 +339,7 @@ class LiveList extends AbstractCrdt {
332
339
  } ]
333
340
  },
334
341
  reverse: [ {
335
- type: OpType.SetParentKey,
342
+ type: OpCode.SET_PARENT_KEY,
336
343
  id: null == item ? void 0 : item[0]._id,
337
344
  parentKey: previousKey
338
345
  } ]
@@ -344,7 +351,7 @@ class LiveList extends AbstractCrdt {
344
351
  _toSerializedCrdt() {
345
352
  var _a;
346
353
  return {
347
- type: CrdtType.List,
354
+ type: CrdtType.LIST,
348
355
  parentId: null === (_a = this._parent) || void 0 === _a ? void 0 : _a._id,
349
356
  parentKey: this._parentKey
350
357
  };
@@ -373,7 +380,7 @@ class LiveList extends AbstractCrdt {
373
380
  type: "insert"
374
381
  } ]
375
382
  }), this._doc.dispatch(value._serialize(this._id, position, this._doc), [ {
376
- type: OpType.DeleteCrdt,
383
+ type: OpCode.DELETE_CRDT,
377
384
  id: id
378
385
  } ], storageUpdates);
379
386
  }
@@ -402,12 +409,12 @@ class LiveList extends AbstractCrdt {
402
409
  type: "move"
403
410
  } ]
404
411
  }), this._doc.dispatch([ {
405
- type: OpType.SetParentKey,
412
+ type: OpCode.SET_PARENT_KEY,
406
413
  id: item[0]._id,
407
414
  opId: this._doc.generateOpId(),
408
415
  parentKey: position
409
416
  } ], [ {
410
- type: OpType.SetParentKey,
417
+ type: OpCode.SET_PARENT_KEY,
411
418
  id: item[0]._id,
412
419
  parentKey: previousPosition
413
420
  } ], storageUpdates);
@@ -430,7 +437,7 @@ class LiveList extends AbstractCrdt {
430
437
  }), this._doc.dispatch([ {
431
438
  id: childRecordId,
432
439
  opId: this._doc.generateOpId(),
433
- type: OpType.DeleteCrdt
440
+ type: OpCode.DELETE_CRDT
434
441
  } ], item[0]._serialize(this._id, item[1]), storageUpdates);
435
442
  }
436
443
  }
@@ -444,7 +451,7 @@ class LiveList extends AbstractCrdt {
444
451
  const childId = item[0]._id;
445
452
  childId && (ops.push({
446
453
  id: childId,
447
- type: OpType.DeleteCrdt
454
+ type: OpCode.DELETE_CRDT
448
455
  }), reverseOps.push(...item[0]._serialize(this._id, item[1])), updateDelta.push({
449
456
  index: i,
450
457
  type: "delete"
@@ -578,7 +585,7 @@ class LiveMap extends AbstractCrdt {
578
585
  const ops = [], op = {
579
586
  id: this._id,
580
587
  opId: null == doc ? void 0 : doc.generateOpId(),
581
- type: OpType.CreateMap,
588
+ type: OpCode.CREATE_MAP,
582
589
  intent: intent,
583
590
  parentId: parentId,
584
591
  parentKey: parentKey
@@ -587,8 +594,7 @@ class LiveMap extends AbstractCrdt {
587
594
  for (const [key, value] of this._map) ops.push(...value._serialize(this._id, key, doc));
588
595
  return ops;
589
596
  }
590
- static _deserialize([id, item], parentToChildren, doc) {
591
- if (item.type !== CrdtType.Map) throw new Error(`Tried to deserialize a map but item type is "${item.type}"`);
597
+ static _deserialize([id, _item], parentToChildren, doc) {
592
598
  const map = new LiveMap;
593
599
  map._attach(id, doc);
594
600
  const children = parentToChildren.get(id);
@@ -614,7 +620,7 @@ class LiveMap extends AbstractCrdt {
614
620
  const previousValue = this._map.get(key);
615
621
  let reverse;
616
622
  return previousValue ? (reverse = previousValue._serialize(this._id, key), previousValue._detach()) : reverse = [ {
617
- type: OpType.DeleteCrdt,
623
+ type: OpCode.DELETE_CRDT,
618
624
  id: id
619
625
  } ], child._setParentLink(this, key), child._attach(id, this._doc), this._map.set(key, child),
620
626
  {
@@ -654,7 +660,7 @@ class LiveMap extends AbstractCrdt {
654
660
  _toSerializedCrdt() {
655
661
  var _a;
656
662
  return {
657
- type: CrdtType.Map,
663
+ type: CrdtType.MAP,
658
664
  parentId: null === (_a = this._parent) || void 0 === _a ? void 0 : _a._id,
659
665
  parentKey: this._parentKey
660
666
  };
@@ -680,7 +686,7 @@ class LiveMap extends AbstractCrdt {
680
686
  }
681
687
  }
682
688
  }), this._doc.dispatch(item._serialize(this._id, key, this._doc), oldValue ? oldValue._serialize(this._id, key) : [ {
683
- type: OpType.DeleteCrdt,
689
+ type: OpCode.DELETE_CRDT,
684
690
  id: id
685
691
  } ], storageUpdates);
686
692
  }
@@ -705,7 +711,7 @@ class LiveMap extends AbstractCrdt {
705
711
  }
706
712
  }
707
713
  }), this._doc.dispatch([ {
708
- type: OpType.DeleteCrdt,
714
+ type: OpCode.DELETE_CRDT,
709
715
  id: item._id,
710
716
  opId: this._doc.generateOpId()
711
717
  } ], item._serialize(this._id, key), storageUpdates);
@@ -758,6 +764,10 @@ class LiveMap extends AbstractCrdt {
758
764
  }
759
765
  }
760
766
 
767
+ function assertNever(_value, errmsg) {
768
+ throw new Error(errmsg);
769
+ }
770
+
761
771
  function remove(array, item) {
762
772
  for (let i = 0; i < array.length; i++) if (array[i] === item) {
763
773
  array.splice(i, 1);
@@ -771,16 +781,16 @@ function compact(items) {
771
781
 
772
782
  function creationOpToLiveStructure(op) {
773
783
  switch (op.type) {
774
- case OpType.CreateRegister:
784
+ case OpCode.CREATE_REGISTER:
775
785
  return new LiveRegister(op.data);
776
786
 
777
- case OpType.CreateObject:
787
+ case OpCode.CREATE_OBJECT:
778
788
  return new LiveObject(op.data);
779
789
 
780
- case OpType.CreateMap:
790
+ case OpCode.CREATE_MAP:
781
791
  return new LiveMap;
782
792
 
783
- case OpType.CreateList:
793
+ case OpCode.CREATE_LIST:
784
794
  return new LiveList;
785
795
  }
786
796
  }
@@ -789,19 +799,19 @@ function isSameNodeOrChildOf(node, parent) {
789
799
  return node === parent || !!node._parent && isSameNodeOrChildOf(node._parent, parent);
790
800
  }
791
801
 
792
- function deserialize(entry, parentToChildren, doc) {
793
- switch (entry[1].type) {
794
- case CrdtType.Object:
795
- return LiveObject._deserialize(entry, parentToChildren, doc);
802
+ function deserialize([id, crdt], parentToChildren, doc) {
803
+ switch (crdt.type) {
804
+ case CrdtType.OBJECT:
805
+ return LiveObject._deserialize([ id, crdt ], parentToChildren, doc);
796
806
 
797
- case CrdtType.List:
798
- return LiveList._deserialize(entry, parentToChildren, doc);
807
+ case CrdtType.LIST:
808
+ return LiveList._deserialize([ id, crdt ], parentToChildren, doc);
799
809
 
800
- case CrdtType.Map:
801
- return LiveMap._deserialize(entry, parentToChildren, doc);
810
+ case CrdtType.MAP:
811
+ return LiveMap._deserialize([ id, crdt ], parentToChildren, doc);
802
812
 
803
- case CrdtType.Register:
804
- return LiveRegister._deserialize(entry, parentToChildren, doc);
813
+ case CrdtType.REGISTER:
814
+ return LiveRegister._deserialize([ id, crdt ], parentToChildren, doc);
805
815
 
806
816
  default:
807
817
  throw new Error("Unexpected CRDT type");
@@ -826,23 +836,23 @@ function getTreesDiffOperations(currentItems, newItems) {
826
836
  const ops = [];
827
837
  return currentItems.forEach(((_, id) => {
828
838
  newItems.get(id) || ops.push({
829
- type: OpType.DeleteCrdt,
839
+ type: OpCode.DELETE_CRDT,
830
840
  id: id
831
841
  });
832
842
  })), newItems.forEach(((crdt, id) => {
833
843
  const currentCrdt = currentItems.get(id);
834
- if (currentCrdt) crdt.type === CrdtType.Object && JSON.stringify(crdt.data) !== JSON.stringify(currentCrdt.data) && ops.push({
835
- type: OpType.UpdateObject,
844
+ if (currentCrdt) crdt.type === CrdtType.OBJECT && (currentCrdt.type === CrdtType.OBJECT && JSON.stringify(crdt.data) === JSON.stringify(currentCrdt.data) || ops.push({
845
+ type: OpCode.UPDATE_OBJECT,
836
846
  id: id,
837
847
  data: crdt.data
838
- }), crdt.parentKey !== currentCrdt.parentKey && ops.push({
839
- type: OpType.SetParentKey,
848
+ })), crdt.parentKey !== currentCrdt.parentKey && ops.push({
849
+ type: OpCode.SET_PARENT_KEY,
840
850
  id: id,
841
851
  parentKey: crdt.parentKey
842
852
  }); else switch (crdt.type) {
843
- case CrdtType.Register:
853
+ case CrdtType.REGISTER:
844
854
  ops.push({
845
- type: OpType.CreateRegister,
855
+ type: OpCode.CREATE_REGISTER,
846
856
  id: id,
847
857
  parentId: crdt.parentId,
848
858
  parentKey: crdt.parentKey,
@@ -850,28 +860,32 @@ function getTreesDiffOperations(currentItems, newItems) {
850
860
  });
851
861
  break;
852
862
 
853
- case CrdtType.List:
863
+ case CrdtType.LIST:
854
864
  ops.push({
855
- type: OpType.CreateList,
865
+ type: OpCode.CREATE_LIST,
856
866
  id: id,
857
867
  parentId: crdt.parentId,
858
868
  parentKey: crdt.parentKey
859
869
  });
860
870
  break;
861
871
 
862
- case CrdtType.Object:
863
- ops.push({
864
- type: OpType.CreateObject,
872
+ case CrdtType.OBJECT:
873
+ ops.push(crdt.parentId ? {
874
+ type: OpCode.CREATE_OBJECT,
865
875
  id: id,
866
876
  parentId: crdt.parentId,
867
877
  parentKey: crdt.parentKey,
868
878
  data: crdt.data
879
+ } : {
880
+ type: OpCode.CREATE_OBJECT,
881
+ id: id,
882
+ data: crdt.data
869
883
  });
870
884
  break;
871
885
 
872
- case CrdtType.Map:
886
+ case CrdtType.MAP:
873
887
  ops.push({
874
- type: OpType.CreateMap,
888
+ type: OpCode.CREATE_MAP,
875
889
  id: id,
876
890
  parentId: crdt.parentId,
877
891
  parentKey: crdt.parentKey
@@ -956,21 +970,26 @@ class LiveObject extends AbstractCrdt {
956
970
  }
957
971
  _serialize(parentId, parentKey, doc, intent) {
958
972
  if (null == this._id) throw new Error("Cannot serialize item is not attached");
959
- const ops = [], op = {
973
+ const opId = null == doc ? void 0 : doc.generateOpId(), ops = [], op = void 0 !== parentId && void 0 !== parentKey ? {
974
+ type: OpCode.CREATE_OBJECT,
960
975
  id: this._id,
961
- opId: null == doc ? void 0 : doc.generateOpId(),
976
+ opId: opId,
962
977
  intent: intent,
963
- type: OpType.CreateObject,
964
978
  parentId: parentId,
965
979
  parentKey: parentKey,
966
980
  data: {}
981
+ } : {
982
+ type: OpCode.CREATE_OBJECT,
983
+ id: this._id,
984
+ opId: opId,
985
+ intent: intent,
986
+ data: {}
967
987
  };
968
988
  ops.push(op);
969
989
  for (const [key, value] of this._map) value instanceof AbstractCrdt ? ops.push(...value._serialize(this._id, key, doc)) : op.data[key] = value;
970
990
  return ops;
971
991
  }
972
992
  static _deserialize([id, item], parentToChildren, doc) {
973
- if (item.type !== CrdtType.Object) throw new Error(`Tried to deserialize a record but item type is "${item.type}"`);
974
993
  const liveObj = new LiveObject(item.data);
975
994
  return liveObj._attach(id, doc), this._deserializeChildren(liveObj, parentToChildren, doc);
976
995
  }
@@ -1006,11 +1025,11 @@ class LiveObject extends AbstractCrdt {
1006
1025
  let reverse;
1007
1026
  return isCrdt(previousValue) ? (reverse = previousValue._serialize(this._id, key),
1008
1027
  previousValue._detach()) : reverse = void 0 === previousValue ? [ {
1009
- type: OpType.DeleteObjectKey,
1028
+ type: OpCode.DELETE_OBJECT_KEY,
1010
1029
  id: this._id,
1011
1030
  key: key
1012
1031
  } ] : [ {
1013
- type: OpType.UpdateObject,
1032
+ type: OpCode.UPDATE_OBJECT,
1014
1033
  id: this._id,
1015
1034
  data: {
1016
1035
  [key]: previousValue
@@ -1059,23 +1078,26 @@ class LiveObject extends AbstractCrdt {
1059
1078
  for (const value of this._map.values()) isCrdt(value) && value._detach();
1060
1079
  }
1061
1080
  _apply(op, isLocal) {
1062
- return op.type === OpType.UpdateObject ? this._applyUpdate(op, isLocal) : op.type === OpType.DeleteObjectKey ? this._applyDeleteObjectKey(op) : super._apply(op, isLocal);
1081
+ return op.type === OpCode.UPDATE_OBJECT ? this._applyUpdate(op, isLocal) : op.type === OpCode.DELETE_OBJECT_KEY ? this._applyDeleteObjectKey(op) : super._apply(op, isLocal);
1063
1082
  }
1064
1083
  _toSerializedCrdt() {
1065
1084
  var _a;
1066
1085
  const data = {};
1067
1086
  for (const [key, value] of this._map) value instanceof AbstractCrdt == !1 && (data[key] = value);
1068
- return {
1069
- type: CrdtType.Object,
1070
- parentId: null === (_a = this._parent) || void 0 === _a ? void 0 : _a._id,
1087
+ return void 0 !== (null === (_a = this._parent) || void 0 === _a ? void 0 : _a._id) && void 0 !== this._parentKey ? {
1088
+ type: CrdtType.OBJECT,
1089
+ parentId: this._parent._id,
1071
1090
  parentKey: this._parentKey,
1072
1091
  data: data
1092
+ } : {
1093
+ type: CrdtType.OBJECT,
1094
+ data: data
1073
1095
  };
1074
1096
  }
1075
1097
  _applyUpdate(op, isLocal) {
1076
1098
  let isModified = !1;
1077
1099
  const reverse = [], reverseUpdate = {
1078
- type: OpType.UpdateObject,
1100
+ type: OpCode.UPDATE_OBJECT,
1079
1101
  id: this._id,
1080
1102
  data: {}
1081
1103
  };
@@ -1084,7 +1106,7 @@ class LiveObject extends AbstractCrdt {
1084
1106
  const oldValue = this._map.get(key);
1085
1107
  oldValue instanceof AbstractCrdt ? (reverse.push(...oldValue._serialize(this._id, key)),
1086
1108
  oldValue._detach()) : void 0 !== oldValue ? reverseUpdate.data[key] = oldValue : void 0 === oldValue && reverse.push({
1087
- type: OpType.DeleteObjectKey,
1109
+ type: OpCode.DELETE_OBJECT_KEY,
1088
1110
  id: this._id,
1089
1111
  key: key
1090
1112
  });
@@ -1129,7 +1151,7 @@ class LiveObject extends AbstractCrdt {
1129
1151
  const oldValue = this._map.get(key);
1130
1152
  let reverse = [];
1131
1153
  return isCrdt(oldValue) ? (reverse = oldValue._serialize(this._id, op.key), oldValue._detach()) : void 0 !== oldValue && (reverse = [ {
1132
- type: OpType.UpdateObject,
1154
+ type: OpCode.UPDATE_OBJECT,
1133
1155
  id: this._id,
1134
1156
  data: {
1135
1157
  [key]: oldValue
@@ -1169,7 +1191,7 @@ class LiveObject extends AbstractCrdt {
1169
1191
  void this._map.delete(keyAsString);
1170
1192
  let reverse;
1171
1193
  oldValue instanceof AbstractCrdt ? (oldValue._detach(), reverse = oldValue._serialize(this._id, keyAsString)) : reverse = [ {
1172
- type: OpType.UpdateObject,
1194
+ type: OpCode.UPDATE_OBJECT,
1173
1195
  data: {
1174
1196
  [keyAsString]: oldValue
1175
1197
  },
@@ -1185,7 +1207,7 @@ class LiveObject extends AbstractCrdt {
1185
1207
  }
1186
1208
  }
1187
1209
  }), this._doc.dispatch([ {
1188
- type: OpType.DeleteObjectKey,
1210
+ type: OpCode.DELETE_OBJECT_KEY,
1189
1211
  key: keyAsString,
1190
1212
  id: this._id,
1191
1213
  opId: this._doc.generateOpId()
@@ -1203,14 +1225,14 @@ class LiveObject extends AbstractCrdt {
1203
1225
  }
1204
1226
  const ops = [], reverseOps = [], opId = this._doc.generateOpId(), updatedProps = {}, reverseUpdateOp = {
1205
1227
  id: this._id,
1206
- type: OpType.UpdateObject,
1228
+ type: OpCode.UPDATE_OBJECT,
1207
1229
  data: {}
1208
1230
  }, updateDelta = {};
1209
1231
  for (const key in overrides) {
1210
1232
  const oldValue = this._map.get(key);
1211
1233
  oldValue instanceof AbstractCrdt ? (reverseOps.push(...oldValue._serialize(this._id, key)),
1212
1234
  oldValue._detach()) : void 0 === oldValue ? reverseOps.push({
1213
- type: OpType.DeleteObjectKey,
1235
+ type: OpCode.DELETE_OBJECT_KEY,
1214
1236
  id: this._id,
1215
1237
  key: key
1216
1238
  }) : reverseUpdateOp.data[key] = oldValue;
@@ -1228,7 +1250,7 @@ class LiveObject extends AbstractCrdt {
1228
1250
  0 !== Object.keys(updatedProps).length && ops.unshift({
1229
1251
  opId: opId,
1230
1252
  id: this._id,
1231
- type: OpType.UpdateObject,
1253
+ type: OpCode.UPDATE_OBJECT,
1232
1254
  data: updatedProps
1233
1255
  });
1234
1256
  const storageUpdates = new Map;
@@ -1240,4 +1262,4 @@ class LiveObject extends AbstractCrdt {
1240
1262
  }
1241
1263
  }
1242
1264
 
1243
- export { AbstractCrdt as A, ClientMessageType as C, LiveObject as L, OpType as O, ServerMessageType as S, WebsocketCloseCodes as W, isSameNodeOrChildOf as a, LiveList as b, isJsonArray as c, compact as d, isJsonObject as e, deprecateIf as f, getTreesDiffOperations as g, LiveMap as h, isTokenValid as i, LiveRegister as j, findNonSerializableValue as k, deprecate as l, mergeStorageUpdates as m, errorIf as n, CrdtType as o, parseJson as p, comparePosition as q, remove as r, makePosition as s, throwUsageError as t };
1265
+ export { AbstractCrdt as A, ClientMsgCode as C, LiveObject as L, OpCode as O, ServerMsgCode as S, WebsocketCloseCodes as W, isSameNodeOrChildOf as a, LiveList as b, isJsonArray as c, compact as d, isJsonObject as e, isRootCrdt as f, getTreesDiffOperations as g, deprecateIf as h, isTokenValid as i, LiveMap as j, LiveRegister as k, findNonSerializableValue as l, mergeStorageUpdates as m, deprecate as n, errorIf as o, parseJson as p, CrdtType as q, remove as r, comparePosition as s, throwUsageError as t, makePosition as u, isChildCrdt as v, assertNever as w };