@liveblocks/client 0.17.11-debug2 → 0.18.0-beta1
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/.built-by-link-script +1 -1
- package/{chunk-QLMVHHAZ.js → chunk-ZNCSOBAX.js} +321 -170
- package/{index-0007883d.d.ts → index-f955942f.d.ts} +259 -182
- package/index.d.ts +14 -3
- package/index.js +691 -496
- package/index.mjs +7 -1363
- package/internal.d.ts +35 -8
- package/internal.js +49 -47
- package/internal.mjs +32 -363
- package/package.json +1 -1
- package/chunk-ATVOU6HF.mjs +0 -2314
|
@@ -537,15 +537,15 @@ var AbstractCrdt = /*#__PURE__*/ function() {
|
|
|
537
537
|
}
|
|
538
538
|
},
|
|
539
539
|
{
|
|
540
|
-
key: "
|
|
540
|
+
key: "_pool",
|
|
541
541
|
get: function get() {
|
|
542
|
-
return this.
|
|
542
|
+
return this.__pool;
|
|
543
543
|
}
|
|
544
544
|
},
|
|
545
545
|
{
|
|
546
546
|
key: "roomId",
|
|
547
547
|
get: function get() {
|
|
548
|
-
return this.
|
|
548
|
+
return this.__pool ? this.__pool.roomId : null;
|
|
549
549
|
}
|
|
550
550
|
},
|
|
551
551
|
{
|
|
@@ -615,7 +615,7 @@ var AbstractCrdt = /*#__PURE__*/ function() {
|
|
|
615
615
|
switch(this.parent.type){
|
|
616
616
|
case "HasParent":
|
|
617
617
|
if (this.parent.node !== newParentNode) {
|
|
618
|
-
throw new Error("Cannot
|
|
618
|
+
throw new Error("Cannot set parent: node already has a parent");
|
|
619
619
|
} else {
|
|
620
620
|
this._parent = HasParent(newParentNode, newParentKey);
|
|
621
621
|
return;
|
|
@@ -633,20 +633,20 @@ var AbstractCrdt = /*#__PURE__*/ function() {
|
|
|
633
633
|
},
|
|
634
634
|
{
|
|
635
635
|
key: "_attach",
|
|
636
|
-
value: function _attach(id,
|
|
637
|
-
if (this.__id || this.
|
|
638
|
-
throw new Error("Cannot attach
|
|
636
|
+
value: function _attach(id, pool) {
|
|
637
|
+
if (this.__id || this.__pool) {
|
|
638
|
+
throw new Error("Cannot attach node: already attached");
|
|
639
639
|
}
|
|
640
|
-
|
|
640
|
+
pool.addNode(id, crdtAsLiveNode(this));
|
|
641
641
|
this.__id = id;
|
|
642
|
-
this.
|
|
642
|
+
this.__pool = pool;
|
|
643
643
|
}
|
|
644
644
|
},
|
|
645
645
|
{
|
|
646
646
|
key: "_detach",
|
|
647
647
|
value: function _detach() {
|
|
648
|
-
if (this.
|
|
649
|
-
this.
|
|
648
|
+
if (this.__pool && this.__id) {
|
|
649
|
+
this.__pool.deleteNode(this.__id);
|
|
650
650
|
}
|
|
651
651
|
switch(this.parent.type){
|
|
652
652
|
case "HasParent":
|
|
@@ -667,7 +667,27 @@ var AbstractCrdt = /*#__PURE__*/ function() {
|
|
|
667
667
|
default:
|
|
668
668
|
assertNever(this.parent, "Unknown state");
|
|
669
669
|
}
|
|
670
|
-
this.
|
|
670
|
+
this.__pool = void 0;
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
key: "invalidate",
|
|
675
|
+
value: function invalidate() {
|
|
676
|
+
if (this._cachedImmutable !== void 0) {
|
|
677
|
+
this._cachedImmutable = void 0;
|
|
678
|
+
if (this.parent.type === "HasParent") {
|
|
679
|
+
this.parent.node.invalidate();
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
key: "toImmutable",
|
|
686
|
+
value: function toImmutable() {
|
|
687
|
+
if (this._cachedImmutable === void 0) {
|
|
688
|
+
this._cachedImmutable = this._toImmutable();
|
|
689
|
+
}
|
|
690
|
+
return this._cachedImmutable;
|
|
671
691
|
}
|
|
672
692
|
}
|
|
673
693
|
]);
|
|
@@ -692,8 +712,8 @@ var LiveRegister = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
692
712
|
}
|
|
693
713
|
},
|
|
694
714
|
{
|
|
695
|
-
key: "
|
|
696
|
-
value: function
|
|
715
|
+
key: "_toOps",
|
|
716
|
+
value: function _toOps(parentId, parentKey, pool) {
|
|
697
717
|
if (this._id == null || parentId == null || parentKey == null) {
|
|
698
718
|
throw new Error("Cannot serialize register if parentId or parentKey is undefined");
|
|
699
719
|
}
|
|
@@ -701,7 +721,7 @@ var LiveRegister = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
701
721
|
{
|
|
702
722
|
type: 8 /* CREATE_REGISTER */ ,
|
|
703
723
|
opId: _optionalChain([
|
|
704
|
-
|
|
724
|
+
pool,
|
|
705
725
|
"optionalAccess",
|
|
706
726
|
function(_2) {
|
|
707
727
|
return _2.generateOpId;
|
|
@@ -720,8 +740,8 @@ var LiveRegister = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
720
740
|
}
|
|
721
741
|
},
|
|
722
742
|
{
|
|
723
|
-
key: "
|
|
724
|
-
value: function
|
|
743
|
+
key: "_serialize",
|
|
744
|
+
value: function _serialize() {
|
|
725
745
|
if (this.parent.type !== "HasParent") {
|
|
726
746
|
throw new Error("Cannot serialize LiveRegister if parent is missing");
|
|
727
747
|
}
|
|
@@ -750,14 +770,20 @@ var LiveRegister = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
750
770
|
value: function _apply(op, isLocal) {
|
|
751
771
|
return _get(_getPrototypeOf(LiveRegister.prototype), "_apply", this).call(this, op, isLocal);
|
|
752
772
|
}
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
key: "_toImmutable",
|
|
776
|
+
value: function _toImmutable() {
|
|
777
|
+
return this._data;
|
|
778
|
+
}
|
|
753
779
|
}
|
|
754
780
|
], [
|
|
755
781
|
{
|
|
756
782
|
key: "_deserialize",
|
|
757
|
-
value: function _deserialize(param, _parentToChildren,
|
|
783
|
+
value: function _deserialize(param, _parentToChildren, pool) {
|
|
758
784
|
var _param = _slicedToArray(param, 2), id = _param[0], item = _param[1];
|
|
759
785
|
var register = new LiveRegister(item.data);
|
|
760
|
-
register._attach(id,
|
|
786
|
+
register._attach(id, pool);
|
|
761
787
|
return register;
|
|
762
788
|
}
|
|
763
789
|
}
|
|
@@ -772,7 +798,6 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
772
798
|
_classCallCheck(this, LiveMap);
|
|
773
799
|
var _this;
|
|
774
800
|
_this = _super.call(this);
|
|
775
|
-
errorIf(entries2 === null, "Support for calling `new LiveMap(null)` will be removed in @liveblocks/client 0.18. Please call as `new LiveMap()`, or `new LiveMap([])`.");
|
|
776
801
|
_this.unacknowledgedSet = /* @__PURE__ */ new Map();
|
|
777
802
|
if (entries2) {
|
|
778
803
|
var mappedEntries = [];
|
|
@@ -809,8 +834,8 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
809
834
|
}
|
|
810
835
|
_createClass(LiveMap, [
|
|
811
836
|
{
|
|
812
|
-
key: "
|
|
813
|
-
value: function
|
|
837
|
+
key: "_toOps",
|
|
838
|
+
value: function _toOps(parentId, parentKey, pool) {
|
|
814
839
|
if (this._id == null) {
|
|
815
840
|
throw new Error("Cannot serialize item is not attached");
|
|
816
841
|
}
|
|
@@ -818,7 +843,7 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
818
843
|
var op = {
|
|
819
844
|
id: this._id,
|
|
820
845
|
opId: _optionalChain([
|
|
821
|
-
|
|
846
|
+
pool,
|
|
822
847
|
"optionalAccess",
|
|
823
848
|
function(_4) {
|
|
824
849
|
return _4.generateOpId;
|
|
@@ -838,7 +863,7 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
838
863
|
for(var _iterator = this._map[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
839
864
|
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
840
865
|
var _ops;
|
|
841
|
-
(_ops = ops).push.apply(_ops, _toConsumableArray(value.
|
|
866
|
+
(_ops = ops).push.apply(_ops, _toConsumableArray(value._toOps(this._id, key, pool)));
|
|
842
867
|
}
|
|
843
868
|
} catch (err) {
|
|
844
869
|
_didIteratorError = true;
|
|
@@ -859,14 +884,14 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
859
884
|
},
|
|
860
885
|
{
|
|
861
886
|
key: "_attach",
|
|
862
|
-
value: function _attach(id,
|
|
863
|
-
_get(_getPrototypeOf(LiveMap.prototype), "_attach", this).call(this, id,
|
|
887
|
+
value: function _attach(id, pool) {
|
|
888
|
+
_get(_getPrototypeOf(LiveMap.prototype), "_attach", this).call(this, id, pool);
|
|
864
889
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
865
890
|
try {
|
|
866
891
|
for(var _iterator = this._map[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
867
892
|
var _value = _slicedToArray(_step.value, 2), _key = _value[0], value = _value[1];
|
|
868
893
|
if (isLiveNode(value)) {
|
|
869
|
-
value._attach(
|
|
894
|
+
value._attach(pool.generateId(), pool);
|
|
870
895
|
}
|
|
871
896
|
}
|
|
872
897
|
} catch (err) {
|
|
@@ -888,13 +913,13 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
888
913
|
{
|
|
889
914
|
key: "_attachChild",
|
|
890
915
|
value: function _attachChild(op, source) {
|
|
891
|
-
if (this.
|
|
892
|
-
throw new Error("Can't attach child if
|
|
916
|
+
if (this._pool == null) {
|
|
917
|
+
throw new Error("Can't attach child if managed pool is not present");
|
|
893
918
|
}
|
|
894
919
|
var id = op.id, parentKey = op.parentKey, opId = op.opId;
|
|
895
920
|
var key = parentKey;
|
|
896
921
|
var child = creationOpToLiveNode(op);
|
|
897
|
-
if (this.
|
|
922
|
+
if (this._pool.getNode(id) !== void 0) {
|
|
898
923
|
return {
|
|
899
924
|
modified: false
|
|
900
925
|
};
|
|
@@ -918,7 +943,7 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
918
943
|
var reverse;
|
|
919
944
|
if (previousValue) {
|
|
920
945
|
var thisId = nn(this._id);
|
|
921
|
-
reverse = previousValue.
|
|
946
|
+
reverse = previousValue._toOps(thisId, key);
|
|
922
947
|
previousValue._detach();
|
|
923
948
|
} else {
|
|
924
949
|
reverse = [
|
|
@@ -929,8 +954,9 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
929
954
|
];
|
|
930
955
|
}
|
|
931
956
|
child._setParentLink(this, key);
|
|
932
|
-
child._attach(id, this.
|
|
957
|
+
child._attach(id, this._pool);
|
|
933
958
|
this._map.set(key, child);
|
|
959
|
+
this.invalidate();
|
|
934
960
|
return {
|
|
935
961
|
modified: {
|
|
936
962
|
node: this,
|
|
@@ -974,13 +1000,14 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
974
1000
|
value: function _detachChild(child) {
|
|
975
1001
|
var id = nn(this._id);
|
|
976
1002
|
var parentKey = nn(child._parentKey);
|
|
977
|
-
var reverse = child.
|
|
1003
|
+
var reverse = child._toOps(id, parentKey, this._pool);
|
|
978
1004
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
979
1005
|
try {
|
|
980
1006
|
for(var _iterator = this._map[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
981
1007
|
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
982
1008
|
if (value === child) {
|
|
983
1009
|
this._map.delete(key);
|
|
1010
|
+
this.invalidate();
|
|
984
1011
|
}
|
|
985
1012
|
}
|
|
986
1013
|
} catch (err) {
|
|
@@ -1012,8 +1039,8 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1012
1039
|
}
|
|
1013
1040
|
},
|
|
1014
1041
|
{
|
|
1015
|
-
key: "
|
|
1016
|
-
value: function
|
|
1042
|
+
key: "_serialize",
|
|
1043
|
+
value: function _serialize() {
|
|
1017
1044
|
if (this.parent.type !== "HasParent") {
|
|
1018
1045
|
throw new Error("Cannot serialize LiveMap if parent is missing");
|
|
1019
1046
|
}
|
|
@@ -1044,9 +1071,10 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1044
1071
|
var item = lsonToLiveNode(value);
|
|
1045
1072
|
item._setParentLink(this, key);
|
|
1046
1073
|
this._map.set(key, item);
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1074
|
+
this.invalidate();
|
|
1075
|
+
if (this._pool && this._id) {
|
|
1076
|
+
var id = this._pool.generateId();
|
|
1077
|
+
item._attach(id, this._pool);
|
|
1050
1078
|
var storageUpdates = /* @__PURE__ */ new Map();
|
|
1051
1079
|
storageUpdates.set(this._id, {
|
|
1052
1080
|
node: this,
|
|
@@ -1055,9 +1083,9 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1055
1083
|
type: "update"
|
|
1056
1084
|
})
|
|
1057
1085
|
});
|
|
1058
|
-
var ops = item.
|
|
1086
|
+
var ops = item._toOps(this._id, key, this._pool);
|
|
1059
1087
|
this.unacknowledgedSet.set(key, nn(ops[0].opId));
|
|
1060
|
-
this.
|
|
1088
|
+
this._pool.dispatch(item._toOps(this._id, key, this._pool), oldValue ? oldValue._toOps(this._id, key) : [
|
|
1061
1089
|
{
|
|
1062
1090
|
type: 5 /* DELETE_CRDT */ ,
|
|
1063
1091
|
id: id
|
|
@@ -1087,7 +1115,8 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1087
1115
|
}
|
|
1088
1116
|
item._detach();
|
|
1089
1117
|
this._map.delete(key);
|
|
1090
|
-
|
|
1118
|
+
this.invalidate();
|
|
1119
|
+
if (this._pool && item._id) {
|
|
1091
1120
|
var thisId = nn(this._id);
|
|
1092
1121
|
var storageUpdates = /* @__PURE__ */ new Map();
|
|
1093
1122
|
storageUpdates.set(thisId, {
|
|
@@ -1097,13 +1126,13 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1097
1126
|
type: "delete"
|
|
1098
1127
|
})
|
|
1099
1128
|
});
|
|
1100
|
-
this.
|
|
1129
|
+
this._pool.dispatch([
|
|
1101
1130
|
{
|
|
1102
1131
|
type: 5 /* DELETE_CRDT */ ,
|
|
1103
1132
|
id: item._id,
|
|
1104
|
-
opId: this.
|
|
1133
|
+
opId: this._pool.generateOpId()
|
|
1105
1134
|
}
|
|
1106
|
-
], item.
|
|
1135
|
+
], item._toOps(thisId, key), storageUpdates);
|
|
1107
1136
|
}
|
|
1108
1137
|
return true;
|
|
1109
1138
|
}
|
|
@@ -1193,14 +1222,47 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1193
1222
|
}
|
|
1194
1223
|
}
|
|
1195
1224
|
}
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
key: "toImmutable",
|
|
1228
|
+
value: function toImmutable() {
|
|
1229
|
+
return _get(_getPrototypeOf(LiveMap.prototype), "toImmutable", this).call(this);
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
key: "_toImmutable",
|
|
1234
|
+
value: function _toImmutable() {
|
|
1235
|
+
var result = /* @__PURE__ */ new Map();
|
|
1236
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1237
|
+
try {
|
|
1238
|
+
for(var _iterator = this._map[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1239
|
+
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
1240
|
+
result.set(key, value.toImmutable());
|
|
1241
|
+
}
|
|
1242
|
+
} catch (err) {
|
|
1243
|
+
_didIteratorError = true;
|
|
1244
|
+
_iteratorError = err;
|
|
1245
|
+
} finally{
|
|
1246
|
+
try {
|
|
1247
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1248
|
+
_iterator.return();
|
|
1249
|
+
}
|
|
1250
|
+
} finally{
|
|
1251
|
+
if (_didIteratorError) {
|
|
1252
|
+
throw _iteratorError;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
return freeze(result);
|
|
1257
|
+
}
|
|
1196
1258
|
}
|
|
1197
1259
|
], [
|
|
1198
1260
|
{
|
|
1199
1261
|
key: "_deserialize",
|
|
1200
|
-
value: function _deserialize(param, parentToChildren,
|
|
1262
|
+
value: function _deserialize(param, parentToChildren, pool) {
|
|
1201
1263
|
var _param = _slicedToArray(param, 2), id = _param[0], _item = _param[1];
|
|
1202
1264
|
var map = new LiveMap();
|
|
1203
|
-
map._attach(id,
|
|
1265
|
+
map._attach(id, pool);
|
|
1204
1266
|
var children = parentToChildren.get(id);
|
|
1205
1267
|
if (children == null) {
|
|
1206
1268
|
return map;
|
|
@@ -1212,9 +1274,10 @@ var LiveMap = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1212
1274
|
var child = deserialize([
|
|
1213
1275
|
id2,
|
|
1214
1276
|
crdt
|
|
1215
|
-
], parentToChildren,
|
|
1277
|
+
], parentToChildren, pool);
|
|
1216
1278
|
child._setParentLink(map, crdt.parentKey);
|
|
1217
1279
|
map._map.set(crdt.parentKey, child);
|
|
1280
|
+
map.invalidate();
|
|
1218
1281
|
}
|
|
1219
1282
|
} catch (err) {
|
|
1220
1283
|
_didIteratorError = true;
|
|
@@ -1259,13 +1322,13 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1259
1322
|
}
|
|
1260
1323
|
_createClass(LiveObject, [
|
|
1261
1324
|
{
|
|
1262
|
-
key: "
|
|
1263
|
-
value: function
|
|
1325
|
+
key: "_toOps",
|
|
1326
|
+
value: function _toOps(parentId, parentKey, pool) {
|
|
1264
1327
|
if (this._id == null) {
|
|
1265
1328
|
throw new Error("Cannot serialize item is not attached");
|
|
1266
1329
|
}
|
|
1267
1330
|
var opId = _optionalChain([
|
|
1268
|
-
|
|
1331
|
+
pool,
|
|
1269
1332
|
"optionalAccess",
|
|
1270
1333
|
function(_6) {
|
|
1271
1334
|
return _6.generateOpId;
|
|
@@ -1296,7 +1359,7 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1296
1359
|
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
1297
1360
|
if (isLiveNode(value)) {
|
|
1298
1361
|
var _ops;
|
|
1299
|
-
(_ops = ops).push.apply(_ops, _toConsumableArray(value.
|
|
1362
|
+
(_ops = ops).push.apply(_ops, _toConsumableArray(value._toOps(this._id, key, pool)));
|
|
1300
1363
|
} else {
|
|
1301
1364
|
op.data[key] = value;
|
|
1302
1365
|
}
|
|
@@ -1320,14 +1383,14 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1320
1383
|
},
|
|
1321
1384
|
{
|
|
1322
1385
|
key: "_attach",
|
|
1323
|
-
value: function _attach(id,
|
|
1324
|
-
_get(_getPrototypeOf(LiveObject.prototype), "_attach", this).call(this, id,
|
|
1386
|
+
value: function _attach(id, pool) {
|
|
1387
|
+
_get(_getPrototypeOf(LiveObject.prototype), "_attach", this).call(this, id, pool);
|
|
1325
1388
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1326
1389
|
try {
|
|
1327
1390
|
for(var _iterator = this._map[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1328
1391
|
var _value = _slicedToArray(_step.value, 2), _key = _value[0], value = _value[1];
|
|
1329
1392
|
if (isLiveNode(value)) {
|
|
1330
|
-
value._attach(
|
|
1393
|
+
value._attach(pool.generateId(), pool);
|
|
1331
1394
|
}
|
|
1332
1395
|
}
|
|
1333
1396
|
} catch (err) {
|
|
@@ -1349,12 +1412,12 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1349
1412
|
{
|
|
1350
1413
|
key: "_attachChild",
|
|
1351
1414
|
value: function _attachChild(op, source) {
|
|
1352
|
-
if (this.
|
|
1353
|
-
throw new Error("Can't attach child if
|
|
1415
|
+
if (this._pool == null) {
|
|
1416
|
+
throw new Error("Can't attach child if managed pool is not present");
|
|
1354
1417
|
}
|
|
1355
1418
|
var id = op.id, opId = op.opId, key = op.parentKey;
|
|
1356
1419
|
var child = creationOpToLson(op);
|
|
1357
|
-
if (this.
|
|
1420
|
+
if (this._pool.getNode(id) !== void 0) {
|
|
1358
1421
|
if (this._propToLastUpdate.get(key) === opId) {
|
|
1359
1422
|
this._propToLastUpdate.delete(key);
|
|
1360
1423
|
}
|
|
@@ -1378,7 +1441,7 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1378
1441
|
var previousValue = this._map.get(key);
|
|
1379
1442
|
var reverse;
|
|
1380
1443
|
if (isLiveNode(previousValue)) {
|
|
1381
|
-
reverse = previousValue.
|
|
1444
|
+
reverse = previousValue._toOps(thisId, key);
|
|
1382
1445
|
previousValue._detach();
|
|
1383
1446
|
} else if (previousValue === void 0) {
|
|
1384
1447
|
reverse = [
|
|
@@ -1398,9 +1461,10 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1398
1461
|
];
|
|
1399
1462
|
}
|
|
1400
1463
|
this._map.set(key, child);
|
|
1464
|
+
this.invalidate();
|
|
1401
1465
|
if (isLiveStructure(child)) {
|
|
1402
1466
|
child._setParentLink(this, key);
|
|
1403
|
-
child._attach(id, this.
|
|
1467
|
+
child._attach(id, this._pool);
|
|
1404
1468
|
}
|
|
1405
1469
|
return {
|
|
1406
1470
|
reverse: reverse,
|
|
@@ -1420,13 +1484,14 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1420
1484
|
if (child) {
|
|
1421
1485
|
var id = nn(this._id);
|
|
1422
1486
|
var parentKey = nn(child._parentKey);
|
|
1423
|
-
var reverse = child.
|
|
1487
|
+
var reverse = child._toOps(id, parentKey, this._pool);
|
|
1424
1488
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1425
1489
|
try {
|
|
1426
1490
|
for(var _iterator = this._map[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1427
1491
|
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
1428
1492
|
if (value === child) {
|
|
1429
1493
|
this._map.delete(key);
|
|
1494
|
+
this.invalidate();
|
|
1430
1495
|
}
|
|
1431
1496
|
}
|
|
1432
1497
|
} catch (err) {
|
|
@@ -1501,8 +1566,8 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1501
1566
|
}
|
|
1502
1567
|
},
|
|
1503
1568
|
{
|
|
1504
|
-
key: "
|
|
1505
|
-
value: function
|
|
1569
|
+
key: "_serialize",
|
|
1570
|
+
value: function _serialize() {
|
|
1506
1571
|
var data = {};
|
|
1507
1572
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1508
1573
|
try {
|
|
@@ -1557,7 +1622,7 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1557
1622
|
var oldValue = this._map.get(key);
|
|
1558
1623
|
if (isLiveNode(oldValue)) {
|
|
1559
1624
|
var _reverse;
|
|
1560
|
-
(_reverse = reverse).push.apply(_reverse, _toConsumableArray(oldValue.
|
|
1625
|
+
(_reverse = reverse).push.apply(_reverse, _toConsumableArray(oldValue._toOps(id, key)));
|
|
1561
1626
|
oldValue._detach();
|
|
1562
1627
|
} else if (oldValue !== void 0) {
|
|
1563
1628
|
reverseUpdate.data[key] = oldValue;
|
|
@@ -1594,6 +1659,7 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1594
1659
|
type: "update"
|
|
1595
1660
|
};
|
|
1596
1661
|
this._map.set(key1, value);
|
|
1662
|
+
this.invalidate();
|
|
1597
1663
|
}
|
|
1598
1664
|
if (Object.keys(reverseUpdate.data).length !== 0) {
|
|
1599
1665
|
reverse.unshift(reverseUpdate);
|
|
@@ -1628,7 +1694,7 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1628
1694
|
var id = nn(this._id);
|
|
1629
1695
|
var reverse = [];
|
|
1630
1696
|
if (isLiveNode(oldValue)) {
|
|
1631
|
-
reverse = oldValue.
|
|
1697
|
+
reverse = oldValue._toOps(id, op.key);
|
|
1632
1698
|
oldValue._detach();
|
|
1633
1699
|
} else if (oldValue !== void 0) {
|
|
1634
1700
|
reverse = [
|
|
@@ -1640,6 +1706,7 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1640
1706
|
];
|
|
1641
1707
|
}
|
|
1642
1708
|
this._map.delete(key);
|
|
1709
|
+
this.invalidate();
|
|
1643
1710
|
return {
|
|
1644
1711
|
modified: {
|
|
1645
1712
|
node: this,
|
|
@@ -1678,17 +1745,18 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1678
1745
|
if (oldValue === void 0) {
|
|
1679
1746
|
return;
|
|
1680
1747
|
}
|
|
1681
|
-
if (this.
|
|
1748
|
+
if (this._pool == null || this._id == null) {
|
|
1682
1749
|
if (isLiveNode(oldValue)) {
|
|
1683
1750
|
oldValue._detach();
|
|
1684
1751
|
}
|
|
1685
1752
|
this._map.delete(keyAsString);
|
|
1753
|
+
this.invalidate();
|
|
1686
1754
|
return;
|
|
1687
1755
|
}
|
|
1688
1756
|
var reverse;
|
|
1689
1757
|
if (isLiveNode(oldValue)) {
|
|
1690
1758
|
oldValue._detach();
|
|
1691
|
-
reverse = oldValue.
|
|
1759
|
+
reverse = oldValue._toOps(this._id, keyAsString);
|
|
1692
1760
|
} else {
|
|
1693
1761
|
reverse = [
|
|
1694
1762
|
{
|
|
@@ -1699,6 +1767,7 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1699
1767
|
];
|
|
1700
1768
|
}
|
|
1701
1769
|
this._map.delete(keyAsString);
|
|
1770
|
+
this.invalidate();
|
|
1702
1771
|
var storageUpdates = /* @__PURE__ */ new Map();
|
|
1703
1772
|
storageUpdates.set(this._id, {
|
|
1704
1773
|
node: this,
|
|
@@ -1707,23 +1776,23 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1707
1776
|
type: "delete"
|
|
1708
1777
|
})
|
|
1709
1778
|
});
|
|
1710
|
-
this.
|
|
1779
|
+
this._pool.dispatch([
|
|
1711
1780
|
{
|
|
1712
1781
|
type: 6 /* DELETE_OBJECT_KEY */ ,
|
|
1713
1782
|
key: keyAsString,
|
|
1714
1783
|
id: this._id,
|
|
1715
|
-
opId: this.
|
|
1784
|
+
opId: this._pool.generateOpId()
|
|
1716
1785
|
}
|
|
1717
1786
|
], reverse, storageUpdates);
|
|
1718
1787
|
}
|
|
1719
1788
|
},
|
|
1720
1789
|
{
|
|
1721
1790
|
key: "update",
|
|
1722
|
-
value: function update(
|
|
1791
|
+
value: function update(patch) {
|
|
1723
1792
|
var _this = this;
|
|
1724
|
-
if (this.
|
|
1725
|
-
for(var key in
|
|
1726
|
-
var newValue =
|
|
1793
|
+
if (this._pool == null || this._id == null) {
|
|
1794
|
+
for(var key in patch){
|
|
1795
|
+
var newValue = patch[key];
|
|
1727
1796
|
if (newValue === void 0) {
|
|
1728
1797
|
continue;
|
|
1729
1798
|
}
|
|
@@ -1735,12 +1804,13 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1735
1804
|
newValue._setParentLink(this, key);
|
|
1736
1805
|
}
|
|
1737
1806
|
this._map.set(key, newValue);
|
|
1807
|
+
this.invalidate();
|
|
1738
1808
|
}
|
|
1739
1809
|
return;
|
|
1740
1810
|
}
|
|
1741
1811
|
var ops = [];
|
|
1742
1812
|
var reverseOps = [];
|
|
1743
|
-
var opId = this.
|
|
1813
|
+
var opId = this._pool.generateOpId();
|
|
1744
1814
|
var updatedProps = {};
|
|
1745
1815
|
var reverseUpdateOp = {
|
|
1746
1816
|
id: this._id,
|
|
@@ -1748,15 +1818,15 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1748
1818
|
data: {}
|
|
1749
1819
|
};
|
|
1750
1820
|
var updateDelta = {};
|
|
1751
|
-
for(var key1 in
|
|
1752
|
-
var newValue1 =
|
|
1821
|
+
for(var key1 in patch){
|
|
1822
|
+
var newValue1 = patch[key1];
|
|
1753
1823
|
if (newValue1 === void 0) {
|
|
1754
1824
|
continue;
|
|
1755
1825
|
}
|
|
1756
1826
|
var oldValue1 = this._map.get(key1);
|
|
1757
1827
|
if (isLiveNode(oldValue1)) {
|
|
1758
1828
|
var _reverseOps;
|
|
1759
|
-
(_reverseOps = reverseOps).push.apply(_reverseOps, _toConsumableArray(oldValue1.
|
|
1829
|
+
(_reverseOps = reverseOps).push.apply(_reverseOps, _toConsumableArray(oldValue1._toOps(this._id, key1)));
|
|
1760
1830
|
oldValue1._detach();
|
|
1761
1831
|
} else if (oldValue1 === void 0) {
|
|
1762
1832
|
reverseOps.push({
|
|
@@ -1770,8 +1840,8 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1770
1840
|
if (isLiveNode(newValue1)) {
|
|
1771
1841
|
var _ops;
|
|
1772
1842
|
newValue1._setParentLink(this, key1);
|
|
1773
|
-
newValue1._attach(this.
|
|
1774
|
-
var newAttachChildOps = newValue1.
|
|
1843
|
+
newValue1._attach(this._pool.generateId(), this._pool);
|
|
1844
|
+
var newAttachChildOps = newValue1._toOps(this._id, key1, this._pool);
|
|
1775
1845
|
var createCrdtOp = newAttachChildOps.find(function(op) {
|
|
1776
1846
|
return op.parentId === _this._id;
|
|
1777
1847
|
});
|
|
@@ -1784,6 +1854,7 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1784
1854
|
this._propToLastUpdate.set(key1, opId);
|
|
1785
1855
|
}
|
|
1786
1856
|
this._map.set(key1, newValue1);
|
|
1857
|
+
this.invalidate();
|
|
1787
1858
|
updateDelta[key1] = {
|
|
1788
1859
|
type: "update"
|
|
1789
1860
|
};
|
|
@@ -1805,22 +1876,55 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1805
1876
|
type: "LiveObject",
|
|
1806
1877
|
updates: updateDelta
|
|
1807
1878
|
});
|
|
1808
|
-
this.
|
|
1879
|
+
this._pool.dispatch(ops, reverseOps, storageUpdates);
|
|
1880
|
+
}
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
key: "toImmutable",
|
|
1884
|
+
value: function toImmutable() {
|
|
1885
|
+
return _get(_getPrototypeOf(LiveObject.prototype), "toImmutable", this).call(this);
|
|
1886
|
+
}
|
|
1887
|
+
},
|
|
1888
|
+
{
|
|
1889
|
+
key: "_toImmutable",
|
|
1890
|
+
value: function _toImmutable() {
|
|
1891
|
+
var result = {};
|
|
1892
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1893
|
+
try {
|
|
1894
|
+
for(var _iterator = this._map[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1895
|
+
var _value = _slicedToArray(_step.value, 2), key = _value[0], val = _value[1];
|
|
1896
|
+
result[key] = isLiveStructure(val) ? val.toImmutable() : val;
|
|
1897
|
+
}
|
|
1898
|
+
} catch (err) {
|
|
1899
|
+
_didIteratorError = true;
|
|
1900
|
+
_iteratorError = err;
|
|
1901
|
+
} finally{
|
|
1902
|
+
try {
|
|
1903
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1904
|
+
_iterator.return();
|
|
1905
|
+
}
|
|
1906
|
+
} finally{
|
|
1907
|
+
if (_didIteratorError) {
|
|
1908
|
+
throw _iteratorError;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
return process.env.NODE_ENV === "production" ? result : Object.freeze(result);
|
|
1809
1913
|
}
|
|
1810
1914
|
}
|
|
1811
1915
|
], [
|
|
1812
1916
|
{
|
|
1813
1917
|
key: "_deserialize",
|
|
1814
|
-
value: function _deserialize(param, parentToChildren,
|
|
1918
|
+
value: function _deserialize(param, parentToChildren, pool) {
|
|
1815
1919
|
var _param = _slicedToArray(param, 2), id = _param[0], item = _param[1];
|
|
1816
1920
|
var liveObj = new LiveObject(item.data);
|
|
1817
|
-
liveObj._attach(id,
|
|
1818
|
-
return this._deserializeChildren(liveObj, parentToChildren,
|
|
1921
|
+
liveObj._attach(id, pool);
|
|
1922
|
+
return this._deserializeChildren(liveObj, parentToChildren, pool);
|
|
1819
1923
|
}
|
|
1820
1924
|
},
|
|
1821
1925
|
{
|
|
1822
1926
|
key: "_deserializeChildren",
|
|
1823
|
-
value: function _deserializeChildren(liveObj, parentToChildren,
|
|
1927
|
+
value: function _deserializeChildren(liveObj, parentToChildren, pool) {
|
|
1824
1928
|
var children = parentToChildren.get(nn(liveObj._id));
|
|
1825
1929
|
if (children == null) {
|
|
1826
1930
|
return liveObj;
|
|
@@ -1832,11 +1936,12 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1832
1936
|
var child = deserializeToLson([
|
|
1833
1937
|
id,
|
|
1834
1938
|
crdt
|
|
1835
|
-
], parentToChildren,
|
|
1939
|
+
], parentToChildren, pool);
|
|
1836
1940
|
if (isLiveStructure(child)) {
|
|
1837
1941
|
child._setParentLink(liveObj, crdt.parentKey);
|
|
1838
1942
|
}
|
|
1839
1943
|
liveObj._map.set(crdt.parentKey, child);
|
|
1944
|
+
liveObj.invalidate();
|
|
1840
1945
|
}
|
|
1841
1946
|
} catch (err) {
|
|
1842
1947
|
_didIteratorError = true;
|
|
@@ -1859,19 +1964,24 @@ var LiveObject = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
1859
1964
|
return LiveObject;
|
|
1860
1965
|
}(AbstractCrdt);
|
|
1861
1966
|
// src/utils.ts
|
|
1862
|
-
function
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
array.splice(i, 1);
|
|
1866
|
-
break;
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1967
|
+
var freeze = process.env.NODE_ENV === "production" ? function(x) {
|
|
1968
|
+
return x;
|
|
1969
|
+
} : Object.freeze;
|
|
1870
1970
|
function compact(items) {
|
|
1871
1971
|
return items.filter(function(item) {
|
|
1872
1972
|
return item != null;
|
|
1873
1973
|
});
|
|
1874
1974
|
}
|
|
1975
|
+
function compactObject(obj) {
|
|
1976
|
+
var newObj = _objectSpread({}, obj);
|
|
1977
|
+
Object.keys(obj).forEach(function(k) {
|
|
1978
|
+
var key = k;
|
|
1979
|
+
if (newObj[key] === void 0) {
|
|
1980
|
+
delete newObj[key];
|
|
1981
|
+
}
|
|
1982
|
+
});
|
|
1983
|
+
return newObj;
|
|
1984
|
+
}
|
|
1875
1985
|
function creationOpToLiveNode(op) {
|
|
1876
1986
|
return lsonToLiveNode(creationOpToLson(op));
|
|
1877
1987
|
}
|
|
@@ -1898,7 +2008,7 @@ function isSameNodeOrChildOf(node, parent) {
|
|
|
1898
2008
|
}
|
|
1899
2009
|
return false;
|
|
1900
2010
|
}
|
|
1901
|
-
function deserialize(param, parentToChildren,
|
|
2011
|
+
function deserialize(param, parentToChildren, pool) {
|
|
1902
2012
|
var _param = _slicedToArray(param, 2), id = _param[0], crdt = _param[1];
|
|
1903
2013
|
switch(crdt.type){
|
|
1904
2014
|
case 0 /* OBJECT */ :
|
|
@@ -1906,28 +2016,28 @@ function deserialize(param, parentToChildren, doc) {
|
|
|
1906
2016
|
return LiveObject._deserialize([
|
|
1907
2017
|
id,
|
|
1908
2018
|
crdt
|
|
1909
|
-
], parentToChildren,
|
|
2019
|
+
], parentToChildren, pool);
|
|
1910
2020
|
}
|
|
1911
2021
|
case 1 /* LIST */ :
|
|
1912
2022
|
{
|
|
1913
2023
|
return LiveList._deserialize([
|
|
1914
2024
|
id,
|
|
1915
2025
|
crdt
|
|
1916
|
-
], parentToChildren,
|
|
2026
|
+
], parentToChildren, pool);
|
|
1917
2027
|
}
|
|
1918
2028
|
case 2 /* MAP */ :
|
|
1919
2029
|
{
|
|
1920
2030
|
return LiveMap._deserialize([
|
|
1921
2031
|
id,
|
|
1922
2032
|
crdt
|
|
1923
|
-
], parentToChildren,
|
|
2033
|
+
], parentToChildren, pool);
|
|
1924
2034
|
}
|
|
1925
2035
|
case 3 /* REGISTER */ :
|
|
1926
2036
|
{
|
|
1927
2037
|
return LiveRegister._deserialize([
|
|
1928
2038
|
id,
|
|
1929
2039
|
crdt
|
|
1930
|
-
], parentToChildren,
|
|
2040
|
+
], parentToChildren, pool);
|
|
1931
2041
|
}
|
|
1932
2042
|
default:
|
|
1933
2043
|
{
|
|
@@ -1935,7 +2045,7 @@ function deserialize(param, parentToChildren, doc) {
|
|
|
1935
2045
|
}
|
|
1936
2046
|
}
|
|
1937
2047
|
}
|
|
1938
|
-
function deserializeToLson(param, parentToChildren,
|
|
2048
|
+
function deserializeToLson(param, parentToChildren, pool) {
|
|
1939
2049
|
var _param = _slicedToArray(param, 2), id = _param[0], crdt = _param[1];
|
|
1940
2050
|
switch(crdt.type){
|
|
1941
2051
|
case 0 /* OBJECT */ :
|
|
@@ -1943,21 +2053,21 @@ function deserializeToLson(param, parentToChildren, doc) {
|
|
|
1943
2053
|
return LiveObject._deserialize([
|
|
1944
2054
|
id,
|
|
1945
2055
|
crdt
|
|
1946
|
-
], parentToChildren,
|
|
2056
|
+
], parentToChildren, pool);
|
|
1947
2057
|
}
|
|
1948
2058
|
case 1 /* LIST */ :
|
|
1949
2059
|
{
|
|
1950
2060
|
return LiveList._deserialize([
|
|
1951
2061
|
id,
|
|
1952
2062
|
crdt
|
|
1953
|
-
], parentToChildren,
|
|
2063
|
+
], parentToChildren, pool);
|
|
1954
2064
|
}
|
|
1955
2065
|
case 2 /* MAP */ :
|
|
1956
2066
|
{
|
|
1957
2067
|
return LiveMap._deserialize([
|
|
1958
2068
|
id,
|
|
1959
2069
|
crdt
|
|
1960
|
-
], parentToChildren,
|
|
2070
|
+
], parentToChildren, pool);
|
|
1961
2071
|
}
|
|
1962
2072
|
case 3 /* REGISTER */ :
|
|
1963
2073
|
{
|
|
@@ -2258,7 +2368,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2258
2368
|
var _this;
|
|
2259
2369
|
_this = _super.call(this);
|
|
2260
2370
|
_this._items = [];
|
|
2261
|
-
_this._implicitlyDeletedItems = /* @__PURE__ */ new
|
|
2371
|
+
_this._implicitlyDeletedItems = /* @__PURE__ */ new WeakSet();
|
|
2262
2372
|
_this._unacknowledgedSets = /* @__PURE__ */ new Map();
|
|
2263
2373
|
var position = void 0;
|
|
2264
2374
|
for(var i = 0; i < items.length; i++){
|
|
@@ -2272,8 +2382,8 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2272
2382
|
}
|
|
2273
2383
|
_createClass(LiveList, [
|
|
2274
2384
|
{
|
|
2275
|
-
key: "
|
|
2276
|
-
value: function
|
|
2385
|
+
key: "_toOps",
|
|
2386
|
+
value: function _toOps(parentId, parentKey, pool) {
|
|
2277
2387
|
if (this._id == null) {
|
|
2278
2388
|
throw new Error("Cannot serialize item is not attached");
|
|
2279
2389
|
}
|
|
@@ -2281,7 +2391,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2281
2391
|
var op = {
|
|
2282
2392
|
id: this._id,
|
|
2283
2393
|
opId: _optionalChain([
|
|
2284
|
-
|
|
2394
|
+
pool,
|
|
2285
2395
|
"optionalAccess",
|
|
2286
2396
|
function(_8) {
|
|
2287
2397
|
return _8.generateOpId;
|
|
@@ -2301,7 +2411,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2301
2411
|
for(var _iterator = this._items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2302
2412
|
var item = _step.value;
|
|
2303
2413
|
var _ops;
|
|
2304
|
-
(_ops = ops).push.apply(_ops, _toConsumableArray(item.
|
|
2414
|
+
(_ops = ops).push.apply(_ops, _toConsumableArray(item._toOps(this._id, item._getParentKeyOrThrow(), pool)));
|
|
2305
2415
|
}
|
|
2306
2416
|
} catch (err) {
|
|
2307
2417
|
_didIteratorError = true;
|
|
@@ -2331,6 +2441,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2331
2441
|
key: "_sortItems",
|
|
2332
2442
|
value: function _sortItems() {
|
|
2333
2443
|
this._items.sort(compareNodePosition);
|
|
2444
|
+
this.invalidate();
|
|
2334
2445
|
}
|
|
2335
2446
|
},
|
|
2336
2447
|
{
|
|
@@ -2343,13 +2454,13 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2343
2454
|
},
|
|
2344
2455
|
{
|
|
2345
2456
|
key: "_attach",
|
|
2346
|
-
value: function _attach(id,
|
|
2347
|
-
_get(_getPrototypeOf(LiveList.prototype), "_attach", this).call(this, id,
|
|
2457
|
+
value: function _attach(id, pool) {
|
|
2458
|
+
_get(_getPrototypeOf(LiveList.prototype), "_attach", this).call(this, id, pool);
|
|
2348
2459
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2349
2460
|
try {
|
|
2350
2461
|
for(var _iterator = this._items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2351
2462
|
var item = _step.value;
|
|
2352
|
-
item._attach(
|
|
2463
|
+
item._attach(pool.generateId(), pool);
|
|
2353
2464
|
}
|
|
2354
2465
|
} catch (err) {
|
|
2355
2466
|
_didIteratorError = true;
|
|
@@ -2396,12 +2507,12 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2396
2507
|
{
|
|
2397
2508
|
key: "_applySetRemote",
|
|
2398
2509
|
value: function _applySetRemote(op) {
|
|
2399
|
-
if (this.
|
|
2400
|
-
throw new Error("Can't attach child if
|
|
2510
|
+
if (this._pool == null) {
|
|
2511
|
+
throw new Error("Can't attach child if managed pool is not present");
|
|
2401
2512
|
}
|
|
2402
2513
|
var id = op.id, key = op.parentKey;
|
|
2403
2514
|
var child = creationOpToLiveNode(op);
|
|
2404
|
-
child._attach(id, this.
|
|
2515
|
+
child._attach(id, this._pool);
|
|
2405
2516
|
child._setParentLink(this, key);
|
|
2406
2517
|
var deletedId = op.deletedId;
|
|
2407
2518
|
var indexOfItemWithSamePosition = this._indexOfPosition(key);
|
|
@@ -2449,8 +2560,8 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2449
2560
|
{
|
|
2450
2561
|
key: "_applySetAck",
|
|
2451
2562
|
value: function _applySetAck(op) {
|
|
2452
|
-
if (this.
|
|
2453
|
-
throw new Error("Can't attach child if
|
|
2563
|
+
if (this._pool == null) {
|
|
2564
|
+
throw new Error("Can't attach child if managed pool is not present");
|
|
2454
2565
|
}
|
|
2455
2566
|
var delta = [];
|
|
2456
2567
|
var deletedDelta = this._detachItemAssociatedToSetOperation(op.deletedId);
|
|
@@ -2498,7 +2609,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2498
2609
|
reverse: []
|
|
2499
2610
|
};
|
|
2500
2611
|
} else {
|
|
2501
|
-
var orphan = this.
|
|
2612
|
+
var orphan = this._pool.getNode(op.id);
|
|
2502
2613
|
if (orphan && this._implicitlyDeletedItems.has(orphan)) {
|
|
2503
2614
|
orphan._setParentLink(this, op.parentKey);
|
|
2504
2615
|
this._implicitlyDeletedItems.delete(orphan);
|
|
@@ -2528,10 +2639,10 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2528
2639
|
{
|
|
2529
2640
|
key: "_detachItemAssociatedToSetOperation",
|
|
2530
2641
|
value: function _detachItemAssociatedToSetOperation(deletedId) {
|
|
2531
|
-
if (deletedId == null || this.
|
|
2642
|
+
if (deletedId == null || this._pool == null) {
|
|
2532
2643
|
return null;
|
|
2533
2644
|
}
|
|
2534
|
-
var deletedItem = this.
|
|
2645
|
+
var deletedItem = this._pool.getNode(deletedId);
|
|
2535
2646
|
if (deletedItem == null) {
|
|
2536
2647
|
return null;
|
|
2537
2648
|
}
|
|
@@ -2545,8 +2656,8 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2545
2656
|
{
|
|
2546
2657
|
key: "_applyRemoteInsert",
|
|
2547
2658
|
value: function _applyRemoteInsert(op) {
|
|
2548
|
-
if (this.
|
|
2549
|
-
throw new Error("Can't attach child if
|
|
2659
|
+
if (this._pool == null) {
|
|
2660
|
+
throw new Error("Can't attach child if managed pool is not present");
|
|
2550
2661
|
}
|
|
2551
2662
|
var key = op.parentKey;
|
|
2552
2663
|
var existingItemIndex = this._indexOfPosition(key);
|
|
@@ -2596,7 +2707,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2596
2707
|
};
|
|
2597
2708
|
}
|
|
2598
2709
|
} else {
|
|
2599
|
-
var orphan = nn(this.
|
|
2710
|
+
var orphan = nn(this._pool).getNode(op.id);
|
|
2600
2711
|
if (orphan && this._implicitlyDeletedItems.has(orphan)) {
|
|
2601
2712
|
orphan._setParentLink(this, key);
|
|
2602
2713
|
this._implicitlyDeletedItems.delete(orphan);
|
|
@@ -2632,11 +2743,11 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2632
2743
|
this,
|
|
2633
2744
|
"access",
|
|
2634
2745
|
function(_10) {
|
|
2635
|
-
return _10.
|
|
2746
|
+
return _10._pool;
|
|
2636
2747
|
},
|
|
2637
2748
|
"optionalAccess",
|
|
2638
2749
|
function(_11) {
|
|
2639
|
-
return _11.
|
|
2750
|
+
return _11.getNode;
|
|
2640
2751
|
},
|
|
2641
2752
|
"call",
|
|
2642
2753
|
function(_12) {
|
|
@@ -2647,7 +2758,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2647
2758
|
modified: false
|
|
2648
2759
|
};
|
|
2649
2760
|
}
|
|
2650
|
-
child._attach(id, nn(this.
|
|
2761
|
+
child._attach(id, nn(this._pool));
|
|
2651
2762
|
child._setParentLink(this, key);
|
|
2652
2763
|
var existingItemIndex = this._indexOfPosition(key);
|
|
2653
2764
|
var newKey = key;
|
|
@@ -2681,11 +2792,11 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2681
2792
|
this,
|
|
2682
2793
|
"access",
|
|
2683
2794
|
function(_13) {
|
|
2684
|
-
return _13.
|
|
2795
|
+
return _13._pool;
|
|
2685
2796
|
},
|
|
2686
2797
|
"optionalAccess",
|
|
2687
2798
|
function(_14) {
|
|
2688
|
-
return _14.
|
|
2799
|
+
return _14.getNode;
|
|
2689
2800
|
},
|
|
2690
2801
|
"call",
|
|
2691
2802
|
function(_15) {
|
|
@@ -2698,14 +2809,14 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2698
2809
|
}
|
|
2699
2810
|
this._unacknowledgedSets.set(key, nn(op.opId));
|
|
2700
2811
|
var indexOfItemWithSameKey = this._indexOfPosition(key);
|
|
2701
|
-
child._attach(id, nn(this.
|
|
2812
|
+
child._attach(id, nn(this._pool));
|
|
2702
2813
|
child._setParentLink(this, key);
|
|
2703
2814
|
var newKey = key;
|
|
2704
2815
|
if (indexOfItemWithSameKey !== -1) {
|
|
2705
2816
|
var existingItem = this._items[indexOfItemWithSameKey];
|
|
2706
2817
|
existingItem._detach();
|
|
2707
2818
|
this._items[indexOfItemWithSameKey] = child;
|
|
2708
|
-
var reverse = existingItem.
|
|
2819
|
+
var reverse = existingItem._toOps(nn(this._id), key, this._pool);
|
|
2709
2820
|
addIntentAndDeletedIdToOperation(reverse, op.id);
|
|
2710
2821
|
var delta = [
|
|
2711
2822
|
setDelta(indexOfItemWithSameKey, child)
|
|
@@ -2739,27 +2850,31 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2739
2850
|
{
|
|
2740
2851
|
key: "_attachChild",
|
|
2741
2852
|
value: function _attachChild(op, source) {
|
|
2742
|
-
if (this.
|
|
2743
|
-
throw new Error("Can't attach child if
|
|
2853
|
+
if (this._pool == null) {
|
|
2854
|
+
throw new Error("Can't attach child if managed pool is not present");
|
|
2744
2855
|
}
|
|
2856
|
+
var result;
|
|
2745
2857
|
if (op.intent === "set") {
|
|
2746
2858
|
if (source === 1 /* REMOTE */ ) {
|
|
2747
|
-
|
|
2748
|
-
}
|
|
2749
|
-
|
|
2750
|
-
|
|
2859
|
+
result = this._applySetRemote(op);
|
|
2860
|
+
} else if (source === 2 /* ACK */ ) {
|
|
2861
|
+
result = this._applySetAck(op);
|
|
2862
|
+
} else {
|
|
2863
|
+
result = this._applySetUndoRedo(op);
|
|
2751
2864
|
}
|
|
2752
|
-
|
|
2753
|
-
|
|
2865
|
+
} else {
|
|
2866
|
+
if (source === 1 /* REMOTE */ ) {
|
|
2867
|
+
result = this._applyRemoteInsert(op);
|
|
2868
|
+
} else if (source === 2 /* ACK */ ) {
|
|
2869
|
+
result = this._applyInsertAck(op);
|
|
2870
|
+
} else {
|
|
2871
|
+
result = this._applyInsertUndoRedo(op);
|
|
2754
2872
|
}
|
|
2755
2873
|
}
|
|
2756
|
-
if (
|
|
2757
|
-
|
|
2758
|
-
} else if (source === 2 /* ACK */ ) {
|
|
2759
|
-
return this._applyInsertAck(op);
|
|
2760
|
-
} else {
|
|
2761
|
-
return this._applyInsertUndoRedo(op);
|
|
2874
|
+
if (result.modified !== false) {
|
|
2875
|
+
this.invalidate();
|
|
2762
2876
|
}
|
|
2877
|
+
return result;
|
|
2763
2878
|
}
|
|
2764
2879
|
},
|
|
2765
2880
|
{
|
|
@@ -2767,7 +2882,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2767
2882
|
value: function _detachChild(child) {
|
|
2768
2883
|
if (child) {
|
|
2769
2884
|
var parentKey = nn(child._parentKey);
|
|
2770
|
-
var reverse = child.
|
|
2885
|
+
var reverse = child._toOps(nn(this._id), parentKey, this._pool);
|
|
2771
2886
|
var indexToDelete = this._items.indexOf(child);
|
|
2772
2887
|
if (indexToDelete === -1) {
|
|
2773
2888
|
return {
|
|
@@ -2775,6 +2890,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
2775
2890
|
};
|
|
2776
2891
|
}
|
|
2777
2892
|
this._items.splice(indexToDelete, 1);
|
|
2893
|
+
this.invalidate();
|
|
2778
2894
|
child._detach();
|
|
2779
2895
|
return {
|
|
2780
2896
|
modified: makeUpdate(this, [
|
|
@@ -3012,8 +3128,8 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3012
3128
|
}
|
|
3013
3129
|
},
|
|
3014
3130
|
{
|
|
3015
|
-
key: "
|
|
3016
|
-
value: function
|
|
3131
|
+
key: "_serialize",
|
|
3132
|
+
value: function _serialize() {
|
|
3017
3133
|
if (this.parent.type !== "HasParent") {
|
|
3018
3134
|
throw new Error("Cannot serialize LiveList if parent is missing");
|
|
3019
3135
|
}
|
|
@@ -3048,10 +3164,10 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3048
3164
|
var value = lsonToLiveNode(element);
|
|
3049
3165
|
value._setParentLink(this, position);
|
|
3050
3166
|
this._insertAndSort(value);
|
|
3051
|
-
if (this.
|
|
3052
|
-
var id = this.
|
|
3053
|
-
value._attach(id, this.
|
|
3054
|
-
this.
|
|
3167
|
+
if (this._pool && this._id) {
|
|
3168
|
+
var id = this._pool.generateId();
|
|
3169
|
+
value._attach(id, this._pool);
|
|
3170
|
+
this._pool.dispatch(value._toOps(this._id, position, this._pool), [
|
|
3055
3171
|
{
|
|
3056
3172
|
type: 5 /* DELETE_CRDT */ ,
|
|
3057
3173
|
id: id
|
|
@@ -3096,7 +3212,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3096
3212
|
var previousPosition = item._getParentKeyOrThrow();
|
|
3097
3213
|
item._setParentLink(this, position);
|
|
3098
3214
|
this._sortItems();
|
|
3099
|
-
if (this.
|
|
3215
|
+
if (this._pool && this._id) {
|
|
3100
3216
|
var storageUpdates = /* @__PURE__ */ new Map([
|
|
3101
3217
|
[
|
|
3102
3218
|
this._id,
|
|
@@ -3105,11 +3221,11 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3105
3221
|
])
|
|
3106
3222
|
]
|
|
3107
3223
|
]);
|
|
3108
|
-
this.
|
|
3224
|
+
this._pool.dispatch([
|
|
3109
3225
|
{
|
|
3110
3226
|
type: 1 /* SET_PARENT_KEY */ ,
|
|
3111
3227
|
id: nn(item._id),
|
|
3112
|
-
opId: this.
|
|
3228
|
+
opId: this._pool.generateOpId(),
|
|
3113
3229
|
parentKey: position
|
|
3114
3230
|
}
|
|
3115
3231
|
], [
|
|
@@ -3131,20 +3247,21 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3131
3247
|
var item = this._items[index];
|
|
3132
3248
|
item._detach();
|
|
3133
3249
|
this._items.splice(index, 1);
|
|
3134
|
-
|
|
3250
|
+
this.invalidate();
|
|
3251
|
+
if (this._pool) {
|
|
3135
3252
|
var childRecordId = item._id;
|
|
3136
3253
|
if (childRecordId) {
|
|
3137
3254
|
var storageUpdates = /* @__PURE__ */ new Map();
|
|
3138
3255
|
storageUpdates.set(nn(this._id), makeUpdate(this, [
|
|
3139
3256
|
deleteDelta(index)
|
|
3140
3257
|
]));
|
|
3141
|
-
this.
|
|
3258
|
+
this._pool.dispatch([
|
|
3142
3259
|
{
|
|
3143
3260
|
id: childRecordId,
|
|
3144
|
-
opId: this.
|
|
3261
|
+
opId: this._pool.generateOpId(),
|
|
3145
3262
|
type: 5 /* DELETE_CRDT */
|
|
3146
3263
|
}
|
|
3147
|
-
], item.
|
|
3264
|
+
], item._toOps(nn(this._id), item._getParentKeyOrThrow()), storageUpdates);
|
|
3148
3265
|
}
|
|
3149
3266
|
}
|
|
3150
3267
|
}
|
|
@@ -3152,7 +3269,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3152
3269
|
{
|
|
3153
3270
|
key: "clear",
|
|
3154
3271
|
value: function clear() {
|
|
3155
|
-
if (this.
|
|
3272
|
+
if (this._pool) {
|
|
3156
3273
|
var ops = [];
|
|
3157
3274
|
var reverseOps = [];
|
|
3158
3275
|
var updateDelta = [];
|
|
@@ -3167,9 +3284,9 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3167
3284
|
ops.push({
|
|
3168
3285
|
type: 5 /* DELETE_CRDT */ ,
|
|
3169
3286
|
id: childId,
|
|
3170
|
-
opId: this.
|
|
3287
|
+
opId: this._pool.generateOpId()
|
|
3171
3288
|
});
|
|
3172
|
-
(_reverseOps = reverseOps).push.apply(_reverseOps, _toConsumableArray(item.
|
|
3289
|
+
(_reverseOps = reverseOps).push.apply(_reverseOps, _toConsumableArray(item._toOps(nn(this._id), item._getParentKeyOrThrow())));
|
|
3173
3290
|
updateDelta.push(deleteDelta(0));
|
|
3174
3291
|
}
|
|
3175
3292
|
}
|
|
@@ -3188,9 +3305,10 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3188
3305
|
}
|
|
3189
3306
|
}
|
|
3190
3307
|
this._items = [];
|
|
3308
|
+
this.invalidate();
|
|
3191
3309
|
var storageUpdates = /* @__PURE__ */ new Map();
|
|
3192
3310
|
storageUpdates.set(nn(this._id), makeUpdate(this, updateDelta));
|
|
3193
|
-
this.
|
|
3311
|
+
this._pool.dispatch(ops, reverseOps, storageUpdates);
|
|
3194
3312
|
} else {
|
|
3195
3313
|
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3196
3314
|
try {
|
|
@@ -3213,6 +3331,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3213
3331
|
}
|
|
3214
3332
|
}
|
|
3215
3333
|
this._items = [];
|
|
3334
|
+
this.invalidate();
|
|
3216
3335
|
}
|
|
3217
3336
|
}
|
|
3218
3337
|
},
|
|
@@ -3229,19 +3348,20 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3229
3348
|
var value = lsonToLiveNode(item);
|
|
3230
3349
|
value._setParentLink(this, position);
|
|
3231
3350
|
this._items[index] = value;
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3351
|
+
this.invalidate();
|
|
3352
|
+
if (this._pool && this._id) {
|
|
3353
|
+
var id = this._pool.generateId();
|
|
3354
|
+
value._attach(id, this._pool);
|
|
3235
3355
|
var storageUpdates = /* @__PURE__ */ new Map();
|
|
3236
3356
|
storageUpdates.set(this._id, makeUpdate(this, [
|
|
3237
3357
|
setDelta(index, value)
|
|
3238
3358
|
]));
|
|
3239
|
-
var ops = value.
|
|
3359
|
+
var ops = value._toOps(this._id, position, this._pool);
|
|
3240
3360
|
addIntentAndDeletedIdToOperation(ops, existingId);
|
|
3241
3361
|
this._unacknowledgedSets.set(position, nn(ops[0].opId));
|
|
3242
|
-
var reverseOps = existingItem.
|
|
3362
|
+
var reverseOps = existingItem._toOps(this._id, position, void 0);
|
|
3243
3363
|
addIntentAndDeletedIdToOperation(reverseOps, id);
|
|
3244
|
-
this.
|
|
3364
|
+
this._pool.dispatch(ops, reverseOps, storageUpdates);
|
|
3245
3365
|
}
|
|
3246
3366
|
}
|
|
3247
3367
|
},
|
|
@@ -3328,7 +3448,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3328
3448
|
key: "_createAttachItemAndSort",
|
|
3329
3449
|
value: function _createAttachItemAndSort(op, key) {
|
|
3330
3450
|
var newItem = creationOpToLiveNode(op);
|
|
3331
|
-
newItem._attach(op.id, nn(this.
|
|
3451
|
+
newItem._attach(op.id, nn(this._pool));
|
|
3332
3452
|
newItem._setParentLink(this, key);
|
|
3333
3453
|
this._insertAndSort(newItem);
|
|
3334
3454
|
var newIndex = this._indexOfPosition(key);
|
|
@@ -3362,14 +3482,29 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3362
3482
|
]) : void 0);
|
|
3363
3483
|
this._items[index]._setParentLink(this, shiftedPosition);
|
|
3364
3484
|
}
|
|
3485
|
+
},
|
|
3486
|
+
{
|
|
3487
|
+
key: "toImmutable",
|
|
3488
|
+
value: function toImmutable() {
|
|
3489
|
+
return _get(_getPrototypeOf(LiveList.prototype), "toImmutable", this).call(this);
|
|
3490
|
+
}
|
|
3491
|
+
},
|
|
3492
|
+
{
|
|
3493
|
+
key: "_toImmutable",
|
|
3494
|
+
value: function _toImmutable() {
|
|
3495
|
+
var result = this._items.map(function(node) {
|
|
3496
|
+
return node.toImmutable();
|
|
3497
|
+
});
|
|
3498
|
+
return process.env.NODE_ENV === "production" ? result : Object.freeze(result);
|
|
3499
|
+
}
|
|
3365
3500
|
}
|
|
3366
3501
|
], [
|
|
3367
3502
|
{
|
|
3368
3503
|
key: "_deserialize",
|
|
3369
|
-
value: function _deserialize(param, parentToChildren,
|
|
3504
|
+
value: function _deserialize(param, parentToChildren, pool) {
|
|
3370
3505
|
var _param = _slicedToArray(param, 1), id = _param[0];
|
|
3371
3506
|
var list = new LiveList();
|
|
3372
|
-
list._attach(id,
|
|
3507
|
+
list._attach(id, pool);
|
|
3373
3508
|
var children = parentToChildren.get(id);
|
|
3374
3509
|
if (children == null) {
|
|
3375
3510
|
return list;
|
|
@@ -3381,7 +3516,7 @@ var LiveList = /*#__PURE__*/ function(AbstractCrdt) {
|
|
|
3381
3516
|
var child = deserialize([
|
|
3382
3517
|
id2,
|
|
3383
3518
|
crdt
|
|
3384
|
-
], parentToChildren,
|
|
3519
|
+
], parentToChildren, pool);
|
|
3385
3520
|
child._setParentLink(list, crdt.parentKey);
|
|
3386
3521
|
list._insertAndSort(child);
|
|
3387
3522
|
}
|
|
@@ -3539,6 +3674,20 @@ function parseRoomAuthToken(tokenString) {
|
|
|
3539
3674
|
throw new Error("Authentication error: we expected a room token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback");
|
|
3540
3675
|
}
|
|
3541
3676
|
}
|
|
3677
|
+
// src/LegacyArray.ts
|
|
3678
|
+
function asArrayWithLegacyMethods(arr) {
|
|
3679
|
+
Object.defineProperty(arr, "count", {
|
|
3680
|
+
value: arr.length,
|
|
3681
|
+
enumerable: false
|
|
3682
|
+
});
|
|
3683
|
+
Object.defineProperty(arr, "toArray", {
|
|
3684
|
+
value: function() {
|
|
3685
|
+
return arr;
|
|
3686
|
+
},
|
|
3687
|
+
enumerable: false
|
|
3688
|
+
});
|
|
3689
|
+
return freeze(arr);
|
|
3690
|
+
}
|
|
3542
3691
|
// src/types/Json.ts
|
|
3543
3692
|
function isJsonScalar(data) {
|
|
3544
3693
|
return data === null || typeof data === "string" || typeof data === "number" || typeof data === "boolean";
|
|
@@ -3569,8 +3718,9 @@ exports.comparePosition = comparePosition;
|
|
|
3569
3718
|
exports.LiveList = LiveList;
|
|
3570
3719
|
exports.LiveMap = LiveMap;
|
|
3571
3720
|
exports.LiveObject = LiveObject;
|
|
3572
|
-
exports.
|
|
3721
|
+
exports.freeze = freeze;
|
|
3573
3722
|
exports.compact = compact;
|
|
3723
|
+
exports.compactObject = compactObject;
|
|
3574
3724
|
exports.isSameNodeOrChildOf = isSameNodeOrChildOf;
|
|
3575
3725
|
exports.isLiveNode = isLiveNode;
|
|
3576
3726
|
exports.isLiveList = isLiveList;
|
|
@@ -3587,6 +3737,7 @@ exports.isAppOnlyAuthToken = isAppOnlyAuthToken;
|
|
|
3587
3737
|
exports.isRoomAuthToken = isRoomAuthToken;
|
|
3588
3738
|
exports.isAuthToken = isAuthToken;
|
|
3589
3739
|
exports.parseRoomAuthToken = parseRoomAuthToken;
|
|
3740
|
+
exports.asArrayWithLegacyMethods = asArrayWithLegacyMethods;
|
|
3590
3741
|
exports.isJsonScalar = isJsonScalar;
|
|
3591
3742
|
exports.isJsonArray = isJsonArray;
|
|
3592
3743
|
exports.isJsonObject = isJsonObject;
|