@yorkie-js/sdk 0.6.9 → 0.6.11-rc
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/dist/yorkie-js-sdk.d.ts +22 -29
- package/dist/yorkie-js-sdk.es.js +89 -273
- package/dist/yorkie-js-sdk.es.js.map +1 -1
- package/dist/yorkie-js-sdk.js +89 -273
- package/dist/yorkie-js-sdk.js.map +1 -1
- package/package.json +1 -1
package/dist/yorkie-js-sdk.es.js
CHANGED
|
@@ -4435,6 +4435,8 @@ let ChangePack$1 = (_a = class extends Message {
|
|
|
4435
4435
|
*/
|
|
4436
4436
|
__publicField(this, "changes", []);
|
|
4437
4437
|
/**
|
|
4438
|
+
* deprecated
|
|
4439
|
+
*
|
|
4438
4440
|
* @generated from field: yorkie.v1.TimeTicket min_synced_ticket = 5;
|
|
4439
4441
|
*/
|
|
4440
4442
|
__publicField(this, "minSyncedTicket");
|
|
@@ -4851,6 +4853,8 @@ const _Operation_Edit = class _Operation_Edit extends Message {
|
|
|
4851
4853
|
*/
|
|
4852
4854
|
__publicField(this, "to");
|
|
4853
4855
|
/**
|
|
4856
|
+
* deprecated
|
|
4857
|
+
*
|
|
4854
4858
|
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 4;
|
|
4855
4859
|
*/
|
|
4856
4860
|
__publicField(this, "createdAtMapByActor", {});
|
|
@@ -4970,6 +4974,8 @@ const _Operation_Style = class _Operation_Style extends Message {
|
|
|
4970
4974
|
*/
|
|
4971
4975
|
__publicField(this, "executedAt");
|
|
4972
4976
|
/**
|
|
4977
|
+
* deprecated
|
|
4978
|
+
*
|
|
4973
4979
|
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 6;
|
|
4974
4980
|
*/
|
|
4975
4981
|
__publicField(this, "createdAtMapByActor", {});
|
|
@@ -5057,6 +5063,8 @@ const _Operation_TreeEdit = class _Operation_TreeEdit extends Message {
|
|
|
5057
5063
|
*/
|
|
5058
5064
|
__publicField(this, "to");
|
|
5059
5065
|
/**
|
|
5066
|
+
* deprecated
|
|
5067
|
+
*
|
|
5060
5068
|
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 4;
|
|
5061
5069
|
*/
|
|
5062
5070
|
__publicField(this, "createdAtMapByActor", {});
|
|
@@ -5133,6 +5141,8 @@ const _Operation_TreeStyle = class _Operation_TreeStyle extends Message {
|
|
|
5133
5141
|
*/
|
|
5134
5142
|
__publicField(this, "attributesToRemove", []);
|
|
5135
5143
|
/**
|
|
5144
|
+
* deprecated
|
|
5145
|
+
*
|
|
5136
5146
|
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 7;
|
|
5137
5147
|
*/
|
|
5138
5148
|
__publicField(this, "createdAtMapByActor", {});
|
|
@@ -11098,18 +11108,17 @@ class CRDTText extends CRDTElement {
|
|
|
11098
11108
|
*
|
|
11099
11109
|
* @internal
|
|
11100
11110
|
*/
|
|
11101
|
-
edit(range, content, editedAt, attributes,
|
|
11111
|
+
edit(range, content, editedAt, attributes, versionVector) {
|
|
11102
11112
|
const crdtTextValue = content ? CRDTTextValue.create(content) : void 0;
|
|
11103
11113
|
if (crdtTextValue && attributes) {
|
|
11104
11114
|
for (const [k, v] of Object.entries(attributes)) {
|
|
11105
11115
|
crdtTextValue.setAttr(k, v, editedAt);
|
|
11106
11116
|
}
|
|
11107
11117
|
}
|
|
11108
|
-
const [caretPos,
|
|
11118
|
+
const [caretPos, pairs, valueChanges] = this.rgaTreeSplit.edit(
|
|
11109
11119
|
range,
|
|
11110
11120
|
editedAt,
|
|
11111
11121
|
crdtTextValue,
|
|
11112
|
-
maxCreatedAtMapByActor,
|
|
11113
11122
|
versionVector
|
|
11114
11123
|
);
|
|
11115
11124
|
const changes = valueChanges.map((change) => ({
|
|
@@ -11124,7 +11133,7 @@ class CRDTText extends CRDTElement {
|
|
|
11124
11133
|
type: "content"
|
|
11125
11134
|
/* Content */
|
|
11126
11135
|
}));
|
|
11127
|
-
return [
|
|
11136
|
+
return [changes, pairs, [caretPos, caretPos]];
|
|
11128
11137
|
}
|
|
11129
11138
|
/**
|
|
11130
11139
|
* `setStyle` applies the style of the given range.
|
|
@@ -11134,10 +11143,9 @@ class CRDTText extends CRDTElement {
|
|
|
11134
11143
|
* @param range - range of RGATreeSplitNode
|
|
11135
11144
|
* @param attributes - style attributes
|
|
11136
11145
|
* @param editedAt - edited time
|
|
11137
|
-
* @param maxCreatedAtMapByActor - maxCreatedAtMapByActor
|
|
11138
11146
|
* @internal
|
|
11139
11147
|
*/
|
|
11140
|
-
setStyle(range, attributes, editedAt,
|
|
11148
|
+
setStyle(range, attributes, editedAt, versionVector) {
|
|
11141
11149
|
const [, toRight] = this.rgaTreeSplit.findNodeWithSplit(range[1], editedAt);
|
|
11142
11150
|
const [, fromRight] = this.rgaTreeSplit.findNodeWithSplit(
|
|
11143
11151
|
range[0],
|
|
@@ -11145,25 +11153,14 @@ class CRDTText extends CRDTElement {
|
|
|
11145
11153
|
);
|
|
11146
11154
|
const changes = [];
|
|
11147
11155
|
const nodes = this.rgaTreeSplit.findBetween(fromRight, toRight);
|
|
11148
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
11149
11156
|
const toBeStyleds = [];
|
|
11150
11157
|
for (const node of nodes) {
|
|
11151
11158
|
const actorID = node.getCreatedAt().getActorID();
|
|
11152
|
-
let
|
|
11153
|
-
|
|
11154
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
11155
|
-
clientLamportAtChange = MaxLamport;
|
|
11156
|
-
} else if (versionVector.size() > 0) {
|
|
11159
|
+
let clientLamportAtChange = MaxLamport;
|
|
11160
|
+
if (versionVector != void 0) {
|
|
11157
11161
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
11158
|
-
} else {
|
|
11159
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
11160
11162
|
}
|
|
11161
|
-
if (node.canStyle(editedAt,
|
|
11162
|
-
const maxCreatedAt2 = createdAtMapByActor.get(actorID);
|
|
11163
|
-
const createdAt = node.getCreatedAt();
|
|
11164
|
-
if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
|
|
11165
|
-
createdAtMapByActor.set(actorID, createdAt);
|
|
11166
|
-
}
|
|
11163
|
+
if (node.canStyle(editedAt, clientLamportAtChange)) {
|
|
11167
11164
|
toBeStyleds.push(node);
|
|
11168
11165
|
}
|
|
11169
11166
|
}
|
|
@@ -11191,7 +11188,7 @@ class CRDTText extends CRDTElement {
|
|
|
11191
11188
|
}
|
|
11192
11189
|
}
|
|
11193
11190
|
}
|
|
11194
|
-
return [
|
|
11191
|
+
return [pairs, changes];
|
|
11195
11192
|
}
|
|
11196
11193
|
/**
|
|
11197
11194
|
* `indexRangeToPosRange` returns the position range of the given index range.
|
|
@@ -11338,28 +11335,25 @@ class CRDTText extends CRDTElement {
|
|
|
11338
11335
|
}
|
|
11339
11336
|
}
|
|
11340
11337
|
class EditOperation extends Operation {
|
|
11341
|
-
constructor(parentCreatedAt, fromPos, toPos,
|
|
11338
|
+
constructor(parentCreatedAt, fromPos, toPos, content, attributes, executedAt) {
|
|
11342
11339
|
super(parentCreatedAt, executedAt);
|
|
11343
11340
|
__publicField(this, "fromPos");
|
|
11344
11341
|
__publicField(this, "toPos");
|
|
11345
|
-
__publicField(this, "maxCreatedAtMapByActor");
|
|
11346
11342
|
__publicField(this, "content");
|
|
11347
11343
|
__publicField(this, "attributes");
|
|
11348
11344
|
this.fromPos = fromPos;
|
|
11349
11345
|
this.toPos = toPos;
|
|
11350
|
-
this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
|
|
11351
11346
|
this.content = content;
|
|
11352
11347
|
this.attributes = attributes;
|
|
11353
11348
|
}
|
|
11354
11349
|
/**
|
|
11355
11350
|
* `create` creates a new instance of EditOperation.
|
|
11356
11351
|
*/
|
|
11357
|
-
static create(parentCreatedAt, fromPos, toPos,
|
|
11352
|
+
static create(parentCreatedAt, fromPos, toPos, content, attributes, executedAt) {
|
|
11358
11353
|
return new EditOperation(
|
|
11359
11354
|
parentCreatedAt,
|
|
11360
11355
|
fromPos,
|
|
11361
11356
|
toPos,
|
|
11362
|
-
maxCreatedAtMapByActor,
|
|
11363
11357
|
content,
|
|
11364
11358
|
attributes,
|
|
11365
11359
|
executedAt
|
|
@@ -11383,12 +11377,11 @@ class EditOperation extends Operation {
|
|
|
11383
11377
|
);
|
|
11384
11378
|
}
|
|
11385
11379
|
const text = parentObject;
|
|
11386
|
-
const [
|
|
11380
|
+
const [changes, pairs] = text.edit(
|
|
11387
11381
|
[this.fromPos, this.toPos],
|
|
11388
11382
|
this.content,
|
|
11389
11383
|
this.getExecutedAt(),
|
|
11390
11384
|
Object.fromEntries(this.attributes),
|
|
11391
|
-
this.maxCreatedAtMapByActor,
|
|
11392
11385
|
versionVector
|
|
11393
11386
|
);
|
|
11394
11387
|
for (const pair of pairs) {
|
|
@@ -11446,35 +11439,25 @@ class EditOperation extends Operation {
|
|
|
11446
11439
|
getAttributes() {
|
|
11447
11440
|
return this.attributes || /* @__PURE__ */ new Map();
|
|
11448
11441
|
}
|
|
11449
|
-
/**
|
|
11450
|
-
* `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
|
|
11451
|
-
* by actor for the nodes included in the editing range.
|
|
11452
|
-
*/
|
|
11453
|
-
getMaxCreatedAtMapByActor() {
|
|
11454
|
-
return this.maxCreatedAtMapByActor;
|
|
11455
|
-
}
|
|
11456
11442
|
}
|
|
11457
11443
|
class StyleOperation extends Operation {
|
|
11458
|
-
constructor(parentCreatedAt, fromPos, toPos,
|
|
11444
|
+
constructor(parentCreatedAt, fromPos, toPos, attributes, executedAt) {
|
|
11459
11445
|
super(parentCreatedAt, executedAt);
|
|
11460
11446
|
__publicField(this, "fromPos");
|
|
11461
11447
|
__publicField(this, "toPos");
|
|
11462
|
-
__publicField(this, "maxCreatedAtMapByActor");
|
|
11463
11448
|
__publicField(this, "attributes");
|
|
11464
11449
|
this.fromPos = fromPos;
|
|
11465
11450
|
this.toPos = toPos;
|
|
11466
|
-
this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
|
|
11467
11451
|
this.attributes = attributes;
|
|
11468
11452
|
}
|
|
11469
11453
|
/**
|
|
11470
11454
|
* `create` creates a new instance of StyleOperation.
|
|
11471
11455
|
*/
|
|
11472
|
-
static create(parentCreatedAt, fromPos, toPos,
|
|
11456
|
+
static create(parentCreatedAt, fromPos, toPos, attributes, executedAt) {
|
|
11473
11457
|
return new StyleOperation(
|
|
11474
11458
|
parentCreatedAt,
|
|
11475
11459
|
fromPos,
|
|
11476
11460
|
toPos,
|
|
11477
|
-
maxCreatedAtMapByActor,
|
|
11478
11461
|
attributes,
|
|
11479
11462
|
executedAt
|
|
11480
11463
|
);
|
|
@@ -11497,11 +11480,10 @@ class StyleOperation extends Operation {
|
|
|
11497
11480
|
);
|
|
11498
11481
|
}
|
|
11499
11482
|
const text = parentObject;
|
|
11500
|
-
const [
|
|
11483
|
+
const [pairs, changes] = text.setStyle(
|
|
11501
11484
|
[this.fromPos, this.toPos],
|
|
11502
11485
|
this.attributes ? Object.fromEntries(this.attributes) : {},
|
|
11503
11486
|
this.getExecutedAt(),
|
|
11504
|
-
this.maxCreatedAtMapByActor,
|
|
11505
11487
|
versionVector
|
|
11506
11488
|
);
|
|
11507
11489
|
for (const pair of pairs) {
|
|
@@ -11553,13 +11535,6 @@ class StyleOperation extends Operation {
|
|
|
11553
11535
|
getAttributes() {
|
|
11554
11536
|
return this.attributes;
|
|
11555
11537
|
}
|
|
11556
|
-
/**
|
|
11557
|
-
* `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
|
|
11558
|
-
* by actor for the nodes included in the editing range.
|
|
11559
|
-
*/
|
|
11560
|
-
getMaxCreatedAtMapByActor() {
|
|
11561
|
-
return this.maxCreatedAtMapByActor;
|
|
11562
|
-
}
|
|
11563
11538
|
}
|
|
11564
11539
|
const ElementPaddingSize = 2;
|
|
11565
11540
|
const DefaultRootType = "root";
|
|
@@ -12830,18 +12805,18 @@ class CRDTTreeNode extends IndexTreeNode {
|
|
|
12830
12805
|
/**
|
|
12831
12806
|
* `canDelete` checks if node is able to delete.
|
|
12832
12807
|
*/
|
|
12833
|
-
canDelete(editedAt,
|
|
12834
|
-
const nodeExisted =
|
|
12808
|
+
canDelete(editedAt, clientLamportAtChange) {
|
|
12809
|
+
const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
|
|
12835
12810
|
return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));
|
|
12836
12811
|
}
|
|
12837
12812
|
/**
|
|
12838
12813
|
* `canStyle` checks if node is able to style.
|
|
12839
12814
|
*/
|
|
12840
|
-
canStyle(editedAt,
|
|
12815
|
+
canStyle(editedAt, clientLamportAtChange) {
|
|
12841
12816
|
if (this.isText) {
|
|
12842
12817
|
return false;
|
|
12843
12818
|
}
|
|
12844
|
-
const nodeExisted =
|
|
12819
|
+
const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
|
|
12845
12820
|
return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));
|
|
12846
12821
|
}
|
|
12847
12822
|
/**
|
|
@@ -13030,7 +13005,7 @@ class CRDTTree extends CRDTElement {
|
|
|
13030
13005
|
/**
|
|
13031
13006
|
* `style` applies the given attributes of the given range.
|
|
13032
13007
|
*/
|
|
13033
|
-
style(range, attributes, editedAt,
|
|
13008
|
+
style(range, attributes, editedAt, versionVector) {
|
|
13034
13009
|
const [fromParent, fromLeft] = this.findNodesAndSplitText(
|
|
13035
13010
|
range[0],
|
|
13036
13011
|
editedAt
|
|
@@ -13038,7 +13013,6 @@ class CRDTTree extends CRDTElement {
|
|
|
13038
13013
|
const [toParent, toLeft] = this.findNodesAndSplitText(range[1], editedAt);
|
|
13039
13014
|
const changes = [];
|
|
13040
13015
|
const attrs = attributes ? parseObjectValues(attributes) : {};
|
|
13041
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
13042
13016
|
const pairs = [];
|
|
13043
13017
|
this.traverseInPosRange(
|
|
13044
13018
|
fromParent,
|
|
@@ -13047,21 +13021,11 @@ class CRDTTree extends CRDTElement {
|
|
|
13047
13021
|
toLeft,
|
|
13048
13022
|
([node]) => {
|
|
13049
13023
|
const actorID = node.getCreatedAt().getActorID();
|
|
13050
|
-
let
|
|
13051
|
-
|
|
13052
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
13053
|
-
clientLamportAtChange = MaxLamport;
|
|
13054
|
-
} else if (versionVector.size() > 0) {
|
|
13024
|
+
let clientLamportAtChange = MaxLamport;
|
|
13025
|
+
if (versionVector != void 0) {
|
|
13055
13026
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
13056
|
-
} else {
|
|
13057
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
13058
13027
|
}
|
|
13059
|
-
if (node.canStyle(editedAt,
|
|
13060
|
-
const maxCreatedAt2 = createdAtMapByActor.get(actorID);
|
|
13061
|
-
const createdAt = node.getCreatedAt();
|
|
13062
|
-
if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
|
|
13063
|
-
createdAtMapByActor.set(actorID, createdAt);
|
|
13064
|
-
}
|
|
13028
|
+
if (node.canStyle(editedAt, clientLamportAtChange) && attributes) {
|
|
13065
13029
|
const updatedAttrPairs = node.setAttrs(attributes, editedAt);
|
|
13066
13030
|
const affectedAttrs = updatedAttrPairs.reduce(
|
|
13067
13031
|
(acc, [, curr]) => {
|
|
@@ -13094,19 +13058,18 @@ class CRDTTree extends CRDTElement {
|
|
|
13094
13058
|
}
|
|
13095
13059
|
}
|
|
13096
13060
|
);
|
|
13097
|
-
return [
|
|
13061
|
+
return [pairs, changes];
|
|
13098
13062
|
}
|
|
13099
13063
|
/**
|
|
13100
13064
|
* `removeStyle` removes the given attributes of the given range.
|
|
13101
13065
|
*/
|
|
13102
|
-
removeStyle(range, attributesToRemove, editedAt,
|
|
13066
|
+
removeStyle(range, attributesToRemove, editedAt, versionVector) {
|
|
13103
13067
|
const [fromParent, fromLeft] = this.findNodesAndSplitText(
|
|
13104
13068
|
range[0],
|
|
13105
13069
|
editedAt
|
|
13106
13070
|
);
|
|
13107
13071
|
const [toParent, toLeft] = this.findNodesAndSplitText(range[1], editedAt);
|
|
13108
13072
|
const changes = [];
|
|
13109
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
13110
13073
|
const pairs = [];
|
|
13111
13074
|
this.traverseInPosRange(
|
|
13112
13075
|
fromParent,
|
|
@@ -13115,21 +13078,11 @@ class CRDTTree extends CRDTElement {
|
|
|
13115
13078
|
toLeft,
|
|
13116
13079
|
([node]) => {
|
|
13117
13080
|
const actorID = node.getCreatedAt().getActorID();
|
|
13118
|
-
let
|
|
13119
|
-
|
|
13120
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
13121
|
-
clientLamportAtChange = MaxLamport;
|
|
13122
|
-
} else if (versionVector.size() > 0) {
|
|
13081
|
+
let clientLamportAtChange = MaxLamport;
|
|
13082
|
+
if (versionVector != void 0) {
|
|
13123
13083
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
13124
|
-
} else {
|
|
13125
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
13126
13084
|
}
|
|
13127
|
-
if (node.canStyle(editedAt,
|
|
13128
|
-
const maxCreatedAt2 = createdAtMapByActor.get(actorID);
|
|
13129
|
-
const createdAt = node.getCreatedAt();
|
|
13130
|
-
if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
|
|
13131
|
-
createdAtMapByActor.set(actorID, createdAt);
|
|
13132
|
-
}
|
|
13085
|
+
if (node.canStyle(editedAt, clientLamportAtChange) && attributesToRemove) {
|
|
13133
13086
|
if (!node.attrs) {
|
|
13134
13087
|
node.attrs = new RHT();
|
|
13135
13088
|
}
|
|
@@ -13153,13 +13106,13 @@ class CRDTTree extends CRDTElement {
|
|
|
13153
13106
|
}
|
|
13154
13107
|
}
|
|
13155
13108
|
);
|
|
13156
|
-
return [
|
|
13109
|
+
return [pairs, changes];
|
|
13157
13110
|
}
|
|
13158
13111
|
/**
|
|
13159
13112
|
* `edit` edits the tree with the given range and content.
|
|
13160
13113
|
* If the content is undefined, the range will be removed.
|
|
13161
13114
|
*/
|
|
13162
|
-
edit(range, contents, splitLevel, editedAt, issueTimeTicket,
|
|
13115
|
+
edit(range, contents, splitLevel, editedAt, issueTimeTicket, versionVector) {
|
|
13163
13116
|
const [fromParent, fromLeft] = this.findNodesAndSplitText(
|
|
13164
13117
|
range[0],
|
|
13165
13118
|
editedAt
|
|
@@ -13170,7 +13123,6 @@ class CRDTTree extends CRDTElement {
|
|
|
13170
13123
|
const nodesToBeRemoved = [];
|
|
13171
13124
|
const tokensToBeRemoved = [];
|
|
13172
13125
|
const toBeMovedToFromParents = [];
|
|
13173
|
-
const maxCreatedAtMap = /* @__PURE__ */ new Map();
|
|
13174
13126
|
this.traverseInPosRange(
|
|
13175
13127
|
fromParent,
|
|
13176
13128
|
fromLeft,
|
|
@@ -13183,21 +13135,11 @@ class CRDTTree extends CRDTElement {
|
|
|
13183
13135
|
}
|
|
13184
13136
|
}
|
|
13185
13137
|
const actorID = node.getCreatedAt().getActorID();
|
|
13186
|
-
let
|
|
13187
|
-
|
|
13188
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
13189
|
-
clientLamportAtChange = MaxLamport;
|
|
13190
|
-
} else if (versionVector.size() > 0) {
|
|
13138
|
+
let clientLamportAtChange = MaxLamport;
|
|
13139
|
+
if (versionVector != void 0) {
|
|
13191
13140
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
13192
|
-
} else {
|
|
13193
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
13194
13141
|
}
|
|
13195
|
-
if (node.canDelete(editedAt,
|
|
13196
|
-
const maxCreatedAt2 = maxCreatedAtMap.get(actorID);
|
|
13197
|
-
const createdAt = node.getCreatedAt();
|
|
13198
|
-
if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
|
|
13199
|
-
maxCreatedAtMap.set(actorID, createdAt);
|
|
13200
|
-
}
|
|
13142
|
+
if (node.canDelete(editedAt, clientLamportAtChange) || nodesToBeRemoved.includes(node.parent)) {
|
|
13201
13143
|
if (tokenType === TokenType.Text || tokenType === TokenType.Start) {
|
|
13202
13144
|
nodesToBeRemoved.push(node);
|
|
13203
13145
|
}
|
|
@@ -13278,7 +13220,7 @@ class CRDTTree extends CRDTElement {
|
|
|
13278
13220
|
}
|
|
13279
13221
|
}
|
|
13280
13222
|
}
|
|
13281
|
-
return [changes, pairs
|
|
13223
|
+
return [changes, pairs];
|
|
13282
13224
|
}
|
|
13283
13225
|
/**
|
|
13284
13226
|
* `editT` edits the given range with the given value.
|
|
@@ -13717,30 +13659,27 @@ class CRDTTree extends CRDTElement {
|
|
|
13717
13659
|
}
|
|
13718
13660
|
}
|
|
13719
13661
|
class TreeEditOperation extends Operation {
|
|
13720
|
-
constructor(parentCreatedAt, fromPos, toPos, contents, splitLevel,
|
|
13662
|
+
constructor(parentCreatedAt, fromPos, toPos, contents, splitLevel, executedAt) {
|
|
13721
13663
|
super(parentCreatedAt, executedAt);
|
|
13722
13664
|
__publicField(this, "fromPos");
|
|
13723
13665
|
__publicField(this, "toPos");
|
|
13724
13666
|
__publicField(this, "contents");
|
|
13725
13667
|
__publicField(this, "splitLevel");
|
|
13726
|
-
__publicField(this, "maxCreatedAtMapByActor");
|
|
13727
13668
|
this.fromPos = fromPos;
|
|
13728
13669
|
this.toPos = toPos;
|
|
13729
13670
|
this.contents = contents;
|
|
13730
13671
|
this.splitLevel = splitLevel;
|
|
13731
|
-
this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
|
|
13732
13672
|
}
|
|
13733
13673
|
/**
|
|
13734
13674
|
* `create` creates a new instance of EditOperation.
|
|
13735
13675
|
*/
|
|
13736
|
-
static create(parentCreatedAt, fromPos, toPos, contents, splitLevel,
|
|
13676
|
+
static create(parentCreatedAt, fromPos, toPos, contents, splitLevel, executedAt) {
|
|
13737
13677
|
return new TreeEditOperation(
|
|
13738
13678
|
parentCreatedAt,
|
|
13739
13679
|
fromPos,
|
|
13740
13680
|
toPos,
|
|
13741
13681
|
contents,
|
|
13742
13682
|
splitLevel,
|
|
13743
|
-
maxCreatedAtMapByActor,
|
|
13744
13683
|
executedAt
|
|
13745
13684
|
);
|
|
13746
13685
|
}
|
|
@@ -13788,7 +13727,6 @@ class TreeEditOperation extends Operation {
|
|
|
13788
13727
|
);
|
|
13789
13728
|
return issueTimeTicket;
|
|
13790
13729
|
})(),
|
|
13791
|
-
this.maxCreatedAtMapByActor,
|
|
13792
13730
|
versionVector
|
|
13793
13731
|
);
|
|
13794
13732
|
for (const pair of pairs) {
|
|
@@ -13851,13 +13789,6 @@ class TreeEditOperation extends Operation {
|
|
|
13851
13789
|
getSplitLevel() {
|
|
13852
13790
|
return this.splitLevel;
|
|
13853
13791
|
}
|
|
13854
|
-
/**
|
|
13855
|
-
* `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
|
|
13856
|
-
* by actor for the nodes included in the editing range.
|
|
13857
|
-
*/
|
|
13858
|
-
getMaxCreatedAtMapByActor() {
|
|
13859
|
-
return this.maxCreatedAtMapByActor;
|
|
13860
|
-
}
|
|
13861
13792
|
}
|
|
13862
13793
|
class VersionVector {
|
|
13863
13794
|
constructor(vector) {
|
|
@@ -14001,12 +13932,7 @@ class ChangeID {
|
|
|
14001
13932
|
*/
|
|
14002
13933
|
syncClocks(other) {
|
|
14003
13934
|
const lamport = other.lamport > this.lamport ? other.lamport + 1n : this.lamport + 1n;
|
|
14004
|
-
|
|
14005
|
-
if (otherVV.size() === 0) {
|
|
14006
|
-
otherVV = otherVV.deepcopy();
|
|
14007
|
-
otherVV.set(other.actor, other.lamport);
|
|
14008
|
-
}
|
|
14009
|
-
const maxVersionVector = this.versionVector.max(otherVV);
|
|
13935
|
+
const maxVersionVector = this.versionVector.max(other.versionVector);
|
|
14010
13936
|
const newID = new ChangeID(
|
|
14011
13937
|
this.clientSeq,
|
|
14012
13938
|
lamport,
|
|
@@ -14252,7 +14178,7 @@ class Change {
|
|
|
14252
14178
|
}
|
|
14253
14179
|
}
|
|
14254
14180
|
class ChangePack {
|
|
14255
|
-
constructor(key, checkpoint, isRemoved, changes, versionVector, snapshot
|
|
14181
|
+
constructor(key, checkpoint, isRemoved, changes, versionVector, snapshot) {
|
|
14256
14182
|
/**
|
|
14257
14183
|
* `documentKey` is the key of the document.
|
|
14258
14184
|
*/
|
|
@@ -14270,12 +14196,6 @@ class ChangePack {
|
|
|
14270
14196
|
* `snapshot` is a byte array that encodes the document.
|
|
14271
14197
|
*/
|
|
14272
14198
|
__publicField(this, "snapshot");
|
|
14273
|
-
/**
|
|
14274
|
-
* `minSyncedTicket` is the minimum logical time taken by clients who attach
|
|
14275
|
-
* to the document. It is used to collect garbage on the replica on the
|
|
14276
|
-
* client.
|
|
14277
|
-
*/
|
|
14278
|
-
__publicField(this, "minSyncedTicket");
|
|
14279
14199
|
/**
|
|
14280
14200
|
* `versionVector` is the version vector current document
|
|
14281
14201
|
*/
|
|
@@ -14285,21 +14205,19 @@ class ChangePack {
|
|
|
14285
14205
|
this.isRemoved = isRemoved;
|
|
14286
14206
|
this.changes = changes;
|
|
14287
14207
|
this.snapshot = snapshot;
|
|
14288
|
-
this.minSyncedTicket = minSyncedTicket;
|
|
14289
14208
|
this.versionVector = versionVector;
|
|
14290
14209
|
}
|
|
14291
14210
|
/**
|
|
14292
14211
|
* `create` creates a new instance of ChangePack.
|
|
14293
14212
|
*/
|
|
14294
|
-
static create(key, checkpoint, isRemoved, changes, versionVector, snapshot
|
|
14213
|
+
static create(key, checkpoint, isRemoved, changes, versionVector, snapshot) {
|
|
14295
14214
|
return new ChangePack(
|
|
14296
14215
|
key,
|
|
14297
14216
|
checkpoint,
|
|
14298
14217
|
isRemoved,
|
|
14299
14218
|
changes,
|
|
14300
14219
|
versionVector,
|
|
14301
|
-
snapshot
|
|
14302
|
-
minSyncedTicket
|
|
14220
|
+
snapshot
|
|
14303
14221
|
);
|
|
14304
14222
|
}
|
|
14305
14223
|
/**
|
|
@@ -14350,12 +14268,6 @@ class ChangePack {
|
|
|
14350
14268
|
getSnapshot() {
|
|
14351
14269
|
return this.snapshot;
|
|
14352
14270
|
}
|
|
14353
|
-
/**
|
|
14354
|
-
* `getMinSyncedTicket` returns the minimum synced ticket of this pack.
|
|
14355
|
-
*/
|
|
14356
|
-
getMinSyncedTicket() {
|
|
14357
|
-
return this.minSyncedTicket;
|
|
14358
|
-
}
|
|
14359
14271
|
/**
|
|
14360
14272
|
* `getVersionVector` returns the document's version vector of this pack
|
|
14361
14273
|
*/
|
|
@@ -14740,9 +14652,9 @@ class RGATreeSplitNode extends SplayNode {
|
|
|
14740
14652
|
/**
|
|
14741
14653
|
* `canDelete` checks if node is able to delete.
|
|
14742
14654
|
*/
|
|
14743
|
-
canDelete(editedAt,
|
|
14655
|
+
canDelete(editedAt, clientLamportAtChange) {
|
|
14744
14656
|
const justRemoved = !this.removedAt;
|
|
14745
|
-
const nodeExisted =
|
|
14657
|
+
const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
|
|
14746
14658
|
if (nodeExisted && (!this.removedAt || editedAt.after(this.removedAt))) {
|
|
14747
14659
|
return justRemoved;
|
|
14748
14660
|
}
|
|
@@ -14751,8 +14663,8 @@ class RGATreeSplitNode extends SplayNode {
|
|
|
14751
14663
|
/**
|
|
14752
14664
|
* `canStyle` checks if node is able to set style.
|
|
14753
14665
|
*/
|
|
14754
|
-
canStyle(editedAt,
|
|
14755
|
-
const nodeExisted =
|
|
14666
|
+
canStyle(editedAt, clientLamportAtChange) {
|
|
14667
|
+
const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
|
|
14756
14668
|
return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));
|
|
14757
14669
|
}
|
|
14758
14670
|
/**
|
|
@@ -14834,17 +14746,15 @@ class RGATreeSplit {
|
|
|
14834
14746
|
* @param range - range of RGATreeSplitNode
|
|
14835
14747
|
* @param editedAt - edited time
|
|
14836
14748
|
* @param value - value
|
|
14837
|
-
* @
|
|
14838
|
-
* @returns `[RGATreeSplitPos, Map<string, TimeTicket>, Array<GCPair>, Array<Change>]`
|
|
14749
|
+
* @returns `[RGATreeSplitPos, Array<GCPair>, Array<Change>]`
|
|
14839
14750
|
*/
|
|
14840
|
-
edit(range, editedAt, value,
|
|
14751
|
+
edit(range, editedAt, value, versionVector) {
|
|
14841
14752
|
const [toLeft, toRight] = this.findNodeWithSplit(range[1], editedAt);
|
|
14842
14753
|
const [fromLeft, fromRight] = this.findNodeWithSplit(range[0], editedAt);
|
|
14843
14754
|
const nodesToDelete = this.findBetween(fromRight, toRight);
|
|
14844
|
-
const [changes,
|
|
14755
|
+
const [changes, removedNodes] = this.deleteNodes(
|
|
14845
14756
|
nodesToDelete,
|
|
14846
14757
|
editedAt,
|
|
14847
|
-
maxCreatedAtMapByActor,
|
|
14848
14758
|
versionVector
|
|
14849
14759
|
);
|
|
14850
14760
|
const caretID = toRight ? toRight.getID() : toLeft.getID();
|
|
@@ -14874,7 +14784,7 @@ class RGATreeSplit {
|
|
|
14874
14784
|
for (const [, removedNode] of removedNodes) {
|
|
14875
14785
|
pairs.push({ parent: this, child: removedNode });
|
|
14876
14786
|
}
|
|
14877
|
-
return [caretPos,
|
|
14787
|
+
return [caretPos, pairs, changes];
|
|
14878
14788
|
}
|
|
14879
14789
|
/**
|
|
14880
14790
|
* `indexToPos` finds RGATreeSplitPos of given offset.
|
|
@@ -15079,47 +14989,36 @@ class RGATreeSplit {
|
|
|
15079
14989
|
splitNode.setInsPrev(node);
|
|
15080
14990
|
return splitNode;
|
|
15081
14991
|
}
|
|
15082
|
-
deleteNodes(candidates, editedAt,
|
|
14992
|
+
deleteNodes(candidates, editedAt, versionVector) {
|
|
15083
14993
|
if (!candidates.length) {
|
|
15084
|
-
return [[], /* @__PURE__ */ new Map()
|
|
14994
|
+
return [[], /* @__PURE__ */ new Map()];
|
|
15085
14995
|
}
|
|
15086
14996
|
const [nodesToDelete, nodesToKeep] = this.filterNodes(
|
|
15087
14997
|
candidates,
|
|
15088
14998
|
editedAt,
|
|
15089
|
-
maxCreatedAtMapByActor,
|
|
15090
14999
|
versionVector
|
|
15091
15000
|
);
|
|
15092
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
15093
15001
|
const removedNodes = /* @__PURE__ */ new Map();
|
|
15094
15002
|
const changes = this.makeChanges(nodesToKeep, editedAt);
|
|
15095
15003
|
for (const node of nodesToDelete) {
|
|
15096
|
-
const actorID = node.getCreatedAt().getActorID();
|
|
15097
|
-
if (!createdAtMapByActor.has(actorID) || node.getID().getCreatedAt().after(createdAtMapByActor.get(actorID))) {
|
|
15098
|
-
createdAtMapByActor.set(actorID, node.getID().getCreatedAt());
|
|
15099
|
-
}
|
|
15100
15004
|
removedNodes.set(node.getID().toIDString(), node);
|
|
15101
15005
|
node.remove(editedAt);
|
|
15102
15006
|
}
|
|
15103
15007
|
this.deleteIndexNodes(nodesToKeep);
|
|
15104
|
-
return [changes,
|
|
15008
|
+
return [changes, removedNodes];
|
|
15105
15009
|
}
|
|
15106
|
-
filterNodes(candidates, editedAt,
|
|
15010
|
+
filterNodes(candidates, editedAt, versionVector) {
|
|
15107
15011
|
const nodesToDelete = [];
|
|
15108
15012
|
const nodesToKeep = [];
|
|
15109
15013
|
const [leftEdge, rightEdge] = this.findEdgesOfCandidates(candidates);
|
|
15110
15014
|
nodesToKeep.push(leftEdge);
|
|
15111
15015
|
for (const node of candidates) {
|
|
15112
15016
|
const actorID = node.getCreatedAt().getActorID();
|
|
15113
|
-
let
|
|
15114
|
-
|
|
15115
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
15116
|
-
clientLamportAtChange = MaxLamport;
|
|
15117
|
-
} else if (versionVector.size() > 0) {
|
|
15017
|
+
let clientLamportAtChange = MaxLamport;
|
|
15018
|
+
if (versionVector != void 0) {
|
|
15118
15019
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
15119
|
-
} else {
|
|
15120
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
15121
15020
|
}
|
|
15122
|
-
if (node.canDelete(editedAt,
|
|
15021
|
+
if (node.canDelete(editedAt, clientLamportAtChange)) {
|
|
15123
15022
|
nodesToDelete.push(node);
|
|
15124
15023
|
} else {
|
|
15125
15024
|
nodesToKeep.push(node);
|
|
@@ -15500,28 +15399,25 @@ class IncreaseOperation extends Operation {
|
|
|
15500
15399
|
}
|
|
15501
15400
|
}
|
|
15502
15401
|
class TreeStyleOperation extends Operation {
|
|
15503
|
-
constructor(parentCreatedAt, fromPos, toPos,
|
|
15402
|
+
constructor(parentCreatedAt, fromPos, toPos, attributes, attributesToRemove, executedAt) {
|
|
15504
15403
|
super(parentCreatedAt, executedAt);
|
|
15505
15404
|
__publicField(this, "fromPos");
|
|
15506
15405
|
__publicField(this, "toPos");
|
|
15507
|
-
__publicField(this, "maxCreatedAtMapByActor");
|
|
15508
15406
|
__publicField(this, "attributes");
|
|
15509
15407
|
__publicField(this, "attributesToRemove");
|
|
15510
15408
|
this.fromPos = fromPos;
|
|
15511
15409
|
this.toPos = toPos;
|
|
15512
|
-
this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
|
|
15513
15410
|
this.attributes = attributes;
|
|
15514
15411
|
this.attributesToRemove = attributesToRemove;
|
|
15515
15412
|
}
|
|
15516
15413
|
/**
|
|
15517
15414
|
* `create` creates a new instance of TreeStyleOperation.
|
|
15518
15415
|
*/
|
|
15519
|
-
static create(parentCreatedAt, fromPos, toPos,
|
|
15416
|
+
static create(parentCreatedAt, fromPos, toPos, attributes, executedAt) {
|
|
15520
15417
|
return new TreeStyleOperation(
|
|
15521
15418
|
parentCreatedAt,
|
|
15522
15419
|
fromPos,
|
|
15523
15420
|
toPos,
|
|
15524
|
-
maxCreatedAtMapByActor,
|
|
15525
15421
|
attributes,
|
|
15526
15422
|
[],
|
|
15527
15423
|
executedAt
|
|
@@ -15530,12 +15426,11 @@ class TreeStyleOperation extends Operation {
|
|
|
15530
15426
|
/**
|
|
15531
15427
|
* `createTreeRemoveStyleOperation` creates a new instance of TreeStyleOperation for style deletion.
|
|
15532
15428
|
*/
|
|
15533
|
-
static createTreeRemoveStyleOperation(parentCreatedAt, fromPos, toPos,
|
|
15429
|
+
static createTreeRemoveStyleOperation(parentCreatedAt, fromPos, toPos, attributesToRemove, executedAt) {
|
|
15534
15430
|
return new TreeStyleOperation(
|
|
15535
15431
|
parentCreatedAt,
|
|
15536
15432
|
fromPos,
|
|
15537
15433
|
toPos,
|
|
15538
|
-
maxCreatedAtMapByActor,
|
|
15539
15434
|
/* @__PURE__ */ new Map(),
|
|
15540
15435
|
attributesToRemove,
|
|
15541
15436
|
executedAt
|
|
@@ -15564,20 +15459,18 @@ class TreeStyleOperation extends Operation {
|
|
|
15564
15459
|
if (this.attributes.size) {
|
|
15565
15460
|
const attributes = {};
|
|
15566
15461
|
[...this.attributes].forEach(([key, value]) => attributes[key] = value);
|
|
15567
|
-
[
|
|
15462
|
+
[pairs, changes] = tree.style(
|
|
15568
15463
|
[this.fromPos, this.toPos],
|
|
15569
15464
|
attributes,
|
|
15570
15465
|
this.getExecutedAt(),
|
|
15571
|
-
this.maxCreatedAtMapByActor,
|
|
15572
15466
|
versionVector
|
|
15573
15467
|
);
|
|
15574
15468
|
} else {
|
|
15575
15469
|
const attributesToRemove = this.attributesToRemove;
|
|
15576
|
-
[
|
|
15470
|
+
[pairs, changes] = tree.removeStyle(
|
|
15577
15471
|
[this.fromPos, this.toPos],
|
|
15578
15472
|
attributesToRemove,
|
|
15579
15473
|
this.getExecutedAt(),
|
|
15580
|
-
this.maxCreatedAtMapByActor,
|
|
15581
15474
|
versionVector
|
|
15582
15475
|
);
|
|
15583
15476
|
}
|
|
@@ -15639,13 +15532,6 @@ class TreeStyleOperation extends Operation {
|
|
|
15639
15532
|
getAttributesToRemove() {
|
|
15640
15533
|
return this.attributesToRemove;
|
|
15641
15534
|
}
|
|
15642
|
-
/**
|
|
15643
|
-
* `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
|
|
15644
|
-
* by actor for the nodes included in the styling range.
|
|
15645
|
-
*/
|
|
15646
|
-
getMaxCreatedAtMapByActor() {
|
|
15647
|
-
return this.maxCreatedAtMapByActor;
|
|
15648
|
-
}
|
|
15649
15535
|
}
|
|
15650
15536
|
function toPresence(presence) {
|
|
15651
15537
|
const pbPresence = new Presence$1();
|
|
@@ -15869,10 +15755,6 @@ function toOperation(operation) {
|
|
|
15869
15755
|
);
|
|
15870
15756
|
pbEditOperation.from = toTextNodePos(editOperation.getFromPos());
|
|
15871
15757
|
pbEditOperation.to = toTextNodePos(editOperation.getToPos());
|
|
15872
|
-
const pbCreatedAtMapByActor = pbEditOperation.createdAtMapByActor;
|
|
15873
|
-
for (const [key, value] of editOperation.getMaxCreatedAtMapByActor()) {
|
|
15874
|
-
pbCreatedAtMapByActor[key] = toTimeTicket(value);
|
|
15875
|
-
}
|
|
15876
15758
|
pbEditOperation.content = editOperation.getContent();
|
|
15877
15759
|
const pbAttributes = pbEditOperation.attributes;
|
|
15878
15760
|
for (const [key, value] of editOperation.getAttributes()) {
|
|
@@ -15889,10 +15771,6 @@ function toOperation(operation) {
|
|
|
15889
15771
|
);
|
|
15890
15772
|
pbStyleOperation.from = toTextNodePos(styleOperation.getFromPos());
|
|
15891
15773
|
pbStyleOperation.to = toTextNodePos(styleOperation.getToPos());
|
|
15892
|
-
const pbCreatedAtMapByActor = pbStyleOperation.createdAtMapByActor;
|
|
15893
|
-
for (const [key, value] of styleOperation.getMaxCreatedAtMapByActor()) {
|
|
15894
|
-
pbCreatedAtMapByActor[key] = toTimeTicket(value);
|
|
15895
|
-
}
|
|
15896
15774
|
const pbAttributes = pbStyleOperation.attributes;
|
|
15897
15775
|
for (const [key, value] of styleOperation.getAttributes()) {
|
|
15898
15776
|
pbAttributes[key] = value;
|
|
@@ -15915,10 +15793,6 @@ function toOperation(operation) {
|
|
|
15915
15793
|
} else if (operation instanceof TreeEditOperation) {
|
|
15916
15794
|
const treeEditOperation = operation;
|
|
15917
15795
|
const pbTreeEditOperation = new Operation_TreeEdit();
|
|
15918
|
-
const pbCreatedAtMapByActor = pbTreeEditOperation.createdAtMapByActor;
|
|
15919
|
-
for (const [key, value] of treeEditOperation.getMaxCreatedAtMapByActor()) {
|
|
15920
|
-
pbCreatedAtMapByActor[key] = toTimeTicket(value);
|
|
15921
|
-
}
|
|
15922
15796
|
pbTreeEditOperation.parentCreatedAt = toTimeTicket(
|
|
15923
15797
|
treeEditOperation.getParentCreatedAt()
|
|
15924
15798
|
);
|
|
@@ -15941,10 +15815,6 @@ function toOperation(operation) {
|
|
|
15941
15815
|
);
|
|
15942
15816
|
pbTreeStyleOperation.from = toTreePos(treeStyleOperation.getFromPos());
|
|
15943
15817
|
pbTreeStyleOperation.to = toTreePos(treeStyleOperation.getToPos());
|
|
15944
|
-
const pbCreatedAtMapByActor = pbTreeStyleOperation.createdAtMapByActor;
|
|
15945
|
-
for (const [key, value] of treeStyleOperation.getMaxCreatedAtMapByActor()) {
|
|
15946
|
-
pbCreatedAtMapByActor[key] = toTimeTicket(value);
|
|
15947
|
-
}
|
|
15948
15818
|
const attributesToRemove = treeStyleOperation.getAttributesToRemove();
|
|
15949
15819
|
if (attributesToRemove.length > 0) {
|
|
15950
15820
|
pbTreeStyleOperation.attributesToRemove = attributesToRemove;
|
|
@@ -16182,8 +16052,7 @@ function toChangePack(pack) {
|
|
|
16182
16052
|
isRemoved: pack.getIsRemoved(),
|
|
16183
16053
|
changes: toChanges(pack.getChanges()),
|
|
16184
16054
|
snapshot: pack.getSnapshot(),
|
|
16185
|
-
versionVector: toVersionVector(pack.getVersionVector())
|
|
16186
|
-
minSyncedTicket: toTimeTicket(pack.getMinSyncedTicket())
|
|
16055
|
+
versionVector: toVersionVector(pack.getVersionVector())
|
|
16187
16056
|
});
|
|
16188
16057
|
}
|
|
16189
16058
|
function errorMetadataOf(error) {
|
|
@@ -16473,12 +16342,6 @@ function fromOperation(pbOperation) {
|
|
|
16473
16342
|
);
|
|
16474
16343
|
} else if (pbOperation.body.case === "edit") {
|
|
16475
16344
|
const pbEditOperation = pbOperation.body.value;
|
|
16476
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
16477
|
-
Object.entries(pbEditOperation.createdAtMapByActor).forEach(
|
|
16478
|
-
([key, value]) => {
|
|
16479
|
-
createdAtMapByActor.set(key, fromTimeTicket(value));
|
|
16480
|
-
}
|
|
16481
|
-
);
|
|
16482
16345
|
const attributes = /* @__PURE__ */ new Map();
|
|
16483
16346
|
Object.entries(pbEditOperation.attributes).forEach(([key, value]) => {
|
|
16484
16347
|
attributes.set(key, value);
|
|
@@ -16487,19 +16350,12 @@ function fromOperation(pbOperation) {
|
|
|
16487
16350
|
fromTimeTicket(pbEditOperation.parentCreatedAt),
|
|
16488
16351
|
fromTextNodePos(pbEditOperation.from),
|
|
16489
16352
|
fromTextNodePos(pbEditOperation.to),
|
|
16490
|
-
createdAtMapByActor,
|
|
16491
16353
|
pbEditOperation.content,
|
|
16492
16354
|
attributes,
|
|
16493
16355
|
fromTimeTicket(pbEditOperation.executedAt)
|
|
16494
16356
|
);
|
|
16495
16357
|
} else if (pbOperation.body.case === "style") {
|
|
16496
16358
|
const pbStyleOperation = pbOperation.body.value;
|
|
16497
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
16498
|
-
Object.entries(pbStyleOperation.createdAtMapByActor).forEach(
|
|
16499
|
-
([key, value]) => {
|
|
16500
|
-
createdAtMapByActor.set(key, fromTimeTicket(value));
|
|
16501
|
-
}
|
|
16502
|
-
);
|
|
16503
16359
|
const attributes = /* @__PURE__ */ new Map();
|
|
16504
16360
|
Object.entries(pbStyleOperation.attributes).forEach(([key, value]) => {
|
|
16505
16361
|
attributes.set(key, value);
|
|
@@ -16508,7 +16364,6 @@ function fromOperation(pbOperation) {
|
|
|
16508
16364
|
fromTimeTicket(pbStyleOperation.parentCreatedAt),
|
|
16509
16365
|
fromTextNodePos(pbStyleOperation.from),
|
|
16510
16366
|
fromTextNodePos(pbStyleOperation.to),
|
|
16511
|
-
createdAtMapByActor,
|
|
16512
16367
|
attributes,
|
|
16513
16368
|
fromTimeTicket(pbStyleOperation.executedAt)
|
|
16514
16369
|
);
|
|
@@ -16523,39 +16378,23 @@ function fromOperation(pbOperation) {
|
|
|
16523
16378
|
);
|
|
16524
16379
|
} else if (pbOperation.body.case === "treeEdit") {
|
|
16525
16380
|
const pbTreeEditOperation = pbOperation.body.value;
|
|
16526
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
16527
|
-
Object.entries(pbTreeEditOperation.createdAtMapByActor).forEach(
|
|
16528
|
-
([key, value]) => {
|
|
16529
|
-
createdAtMapByActor.set(key, fromTimeTicket(value));
|
|
16530
|
-
}
|
|
16531
|
-
);
|
|
16532
16381
|
return TreeEditOperation.create(
|
|
16533
16382
|
fromTimeTicket(pbTreeEditOperation.parentCreatedAt),
|
|
16534
16383
|
fromTreePos(pbTreeEditOperation.from),
|
|
16535
16384
|
fromTreePos(pbTreeEditOperation.to),
|
|
16536
16385
|
fromTreeNodesWhenEdit(pbTreeEditOperation.contents),
|
|
16537
16386
|
pbTreeEditOperation.splitLevel,
|
|
16538
|
-
createdAtMapByActor,
|
|
16539
16387
|
fromTimeTicket(pbTreeEditOperation.executedAt)
|
|
16540
16388
|
);
|
|
16541
16389
|
} else if (pbOperation.body.case === "treeStyle") {
|
|
16542
16390
|
const pbTreeStyleOperation = pbOperation.body.value;
|
|
16543
16391
|
const attributes = /* @__PURE__ */ new Map();
|
|
16544
16392
|
const attributesToRemove = pbTreeStyleOperation.attributesToRemove;
|
|
16545
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
16546
|
-
if (pbTreeStyleOperation == null ? void 0 : pbTreeStyleOperation.createdAtMapByActor) {
|
|
16547
|
-
Object.entries(pbTreeStyleOperation.createdAtMapByActor).forEach(
|
|
16548
|
-
([key, value]) => {
|
|
16549
|
-
createdAtMapByActor.set(key, fromTimeTicket(value));
|
|
16550
|
-
}
|
|
16551
|
-
);
|
|
16552
|
-
}
|
|
16553
16393
|
if ((attributesToRemove == null ? void 0 : attributesToRemove.length) > 0) {
|
|
16554
16394
|
return TreeStyleOperation.createTreeRemoveStyleOperation(
|
|
16555
16395
|
fromTimeTicket(pbTreeStyleOperation.parentCreatedAt),
|
|
16556
16396
|
fromTreePos(pbTreeStyleOperation.from),
|
|
16557
16397
|
fromTreePos(pbTreeStyleOperation.to),
|
|
16558
|
-
createdAtMapByActor,
|
|
16559
16398
|
attributesToRemove,
|
|
16560
16399
|
fromTimeTicket(pbTreeStyleOperation.executedAt)
|
|
16561
16400
|
);
|
|
@@ -16569,7 +16408,6 @@ function fromOperation(pbOperation) {
|
|
|
16569
16408
|
fromTimeTicket(pbTreeStyleOperation.parentCreatedAt),
|
|
16570
16409
|
fromTreePos(pbTreeStyleOperation.from),
|
|
16571
16410
|
fromTreePos(pbTreeStyleOperation.to),
|
|
16572
|
-
createdAtMapByActor,
|
|
16573
16411
|
attributes,
|
|
16574
16412
|
fromTimeTicket(pbTreeStyleOperation.executedAt)
|
|
16575
16413
|
);
|
|
@@ -16612,8 +16450,7 @@ function fromChangePack(pbPack) {
|
|
|
16612
16450
|
pbPack.isRemoved,
|
|
16613
16451
|
fromChanges(pbPack.changes),
|
|
16614
16452
|
fromVersionVector(pbPack.versionVector),
|
|
16615
|
-
pbPack.snapshot
|
|
16616
|
-
fromTimeTicket(pbPack.minSyncedTicket)
|
|
16453
|
+
pbPack.snapshot
|
|
16617
16454
|
);
|
|
16618
16455
|
}
|
|
16619
16456
|
function fromObject(pbObject) {
|
|
@@ -18076,7 +17913,7 @@ class Text {
|
|
|
18076
17913
|
}
|
|
18077
17914
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18078
17915
|
const ticket = this.context.issueTimeTicket();
|
|
18079
|
-
const [
|
|
17916
|
+
const [, pairs, rangeAfterEdit] = this.text.edit(
|
|
18080
17917
|
range,
|
|
18081
17918
|
content,
|
|
18082
17919
|
ticket,
|
|
@@ -18090,7 +17927,6 @@ class Text {
|
|
|
18090
17927
|
this.text.getCreatedAt(),
|
|
18091
17928
|
range[0],
|
|
18092
17929
|
range[1],
|
|
18093
|
-
maxCreatedAtMapByActor,
|
|
18094
17930
|
content,
|
|
18095
17931
|
attrs ? new Map(Object.entries(attrs)) : /* @__PURE__ */ new Map(),
|
|
18096
17932
|
ticket
|
|
@@ -18136,11 +17972,7 @@ class Text {
|
|
|
18136
17972
|
}
|
|
18137
17973
|
const attrs = stringifyObjectValues(attributes);
|
|
18138
17974
|
const ticket = this.context.issueTimeTicket();
|
|
18139
|
-
const [
|
|
18140
|
-
range,
|
|
18141
|
-
attrs,
|
|
18142
|
-
ticket
|
|
18143
|
-
);
|
|
17975
|
+
const [pairs] = this.text.setStyle(range, attrs, ticket);
|
|
18144
17976
|
for (const pair of pairs) {
|
|
18145
17977
|
this.context.registerGCPair(pair);
|
|
18146
17978
|
}
|
|
@@ -18149,7 +17981,6 @@ class Text {
|
|
|
18149
17981
|
this.text.getCreatedAt(),
|
|
18150
17982
|
range[0],
|
|
18151
17983
|
range[1],
|
|
18152
|
-
maxCreatedAtMapByActor,
|
|
18153
17984
|
new Map(Object.entries(attrs)),
|
|
18154
17985
|
ticket
|
|
18155
17986
|
)
|
|
@@ -18684,17 +18515,15 @@ class Tree {
|
|
|
18684
18515
|
const [fromPos, toPos] = this.tree.pathToPosRange(path);
|
|
18685
18516
|
const ticket = this.context.issueTimeTicket();
|
|
18686
18517
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18687
|
-
const [
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
);
|
|
18518
|
+
const [pairs] = this.tree.style([fromPos, toPos], attrs, ticket);
|
|
18519
|
+
for (const pair of pairs) {
|
|
18520
|
+
this.context.registerGCPair(pair);
|
|
18521
|
+
}
|
|
18692
18522
|
this.context.push(
|
|
18693
18523
|
TreeStyleOperation.create(
|
|
18694
18524
|
this.tree.getCreatedAt(),
|
|
18695
18525
|
fromPos,
|
|
18696
18526
|
toPos,
|
|
18697
|
-
maxCreationMapByActor,
|
|
18698
18527
|
attrs ? new Map(Object.entries(attrs)) : /* @__PURE__ */ new Map(),
|
|
18699
18528
|
ticket
|
|
18700
18529
|
)
|
|
@@ -18720,11 +18549,7 @@ class Tree {
|
|
|
18720
18549
|
const toPos = this.tree.findPos(toIdx);
|
|
18721
18550
|
const ticket = this.context.issueTimeTicket();
|
|
18722
18551
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18723
|
-
const [
|
|
18724
|
-
[fromPos, toPos],
|
|
18725
|
-
attrs,
|
|
18726
|
-
ticket
|
|
18727
|
-
);
|
|
18552
|
+
const [pairs] = this.tree.style([fromPos, toPos], attrs, ticket);
|
|
18728
18553
|
for (const pair of pairs) {
|
|
18729
18554
|
this.context.registerGCPair(pair);
|
|
18730
18555
|
}
|
|
@@ -18733,7 +18558,6 @@ class Tree {
|
|
|
18733
18558
|
this.tree.getCreatedAt(),
|
|
18734
18559
|
fromPos,
|
|
18735
18560
|
toPos,
|
|
18736
|
-
maxCreationMapByActor,
|
|
18737
18561
|
attrs ? new Map(Object.entries(attrs)) : /* @__PURE__ */ new Map(),
|
|
18738
18562
|
ticket
|
|
18739
18563
|
)
|
|
@@ -18758,7 +18582,7 @@ class Tree {
|
|
|
18758
18582
|
const fromPos = this.tree.findPos(fromIdx);
|
|
18759
18583
|
const toPos = this.tree.findPos(toIdx);
|
|
18760
18584
|
const ticket = this.context.issueTimeTicket();
|
|
18761
|
-
const [
|
|
18585
|
+
const [pairs] = this.tree.removeStyle(
|
|
18762
18586
|
[fromPos, toPos],
|
|
18763
18587
|
attributesToRemove,
|
|
18764
18588
|
ticket
|
|
@@ -18771,7 +18595,6 @@ class Tree {
|
|
|
18771
18595
|
this.tree.getCreatedAt(),
|
|
18772
18596
|
fromPos,
|
|
18773
18597
|
toPos,
|
|
18774
|
-
maxCreationMapByActor,
|
|
18775
18598
|
attributesToRemove,
|
|
18776
18599
|
ticket
|
|
18777
18600
|
)
|
|
@@ -18806,7 +18629,7 @@ class Tree {
|
|
|
18806
18629
|
} else {
|
|
18807
18630
|
crdtNodes = contents.map((content) => content && createCRDTTreeNode(this.context, content)).filter((a) => a);
|
|
18808
18631
|
}
|
|
18809
|
-
const [, pairs
|
|
18632
|
+
const [, pairs] = this.tree.edit(
|
|
18810
18633
|
[fromPos, toPos],
|
|
18811
18634
|
crdtNodes.length ? crdtNodes.map((crdtNode) => crdtNode == null ? void 0 : crdtNode.deepcopy()) : void 0,
|
|
18812
18635
|
splitLevel,
|
|
@@ -18823,7 +18646,6 @@ class Tree {
|
|
|
18823
18646
|
toPos,
|
|
18824
18647
|
crdtNodes.length ? crdtNodes : void 0,
|
|
18825
18648
|
splitLevel,
|
|
18826
|
-
maxCreatedAtMapByActor,
|
|
18827
18649
|
ticket
|
|
18828
18650
|
)
|
|
18829
18651
|
);
|
|
@@ -20568,7 +20390,7 @@ function createAuthInterceptor(apiKey, token) {
|
|
|
20568
20390
|
};
|
|
20569
20391
|
}
|
|
20570
20392
|
const name = "@yorkie-js/sdk";
|
|
20571
|
-
const version = "0.6.
|
|
20393
|
+
const version = "0.6.11-rc";
|
|
20572
20394
|
const pkg = {
|
|
20573
20395
|
name,
|
|
20574
20396
|
version
|
|
@@ -20736,15 +20558,16 @@ class Client {
|
|
|
20736
20558
|
if (this.status === "deactivated") {
|
|
20737
20559
|
return Promise.resolve();
|
|
20738
20560
|
}
|
|
20561
|
+
this.deactivateInternal();
|
|
20739
20562
|
const task = async () => {
|
|
20740
20563
|
try {
|
|
20741
20564
|
await this.rpcClient.deactivateClient(
|
|
20742
20565
|
{ clientId: this.id },
|
|
20743
20566
|
{ headers: { "x-shard-key": this.apiKey } }
|
|
20744
20567
|
);
|
|
20745
|
-
this.deactivateInternal();
|
|
20746
20568
|
logger.info(`[DC] c"${this.getKey()}" deactivated`);
|
|
20747
20569
|
} catch (err) {
|
|
20570
|
+
this.status = "activated";
|
|
20748
20571
|
logger.error(`[DC] c:"${this.getKey()}" err :`, err);
|
|
20749
20572
|
await this.handleConnectError(err);
|
|
20750
20573
|
throw err;
|
|
@@ -20828,12 +20651,12 @@ class Client {
|
|
|
20828
20651
|
await this.runWatchLoop(doc.getKey());
|
|
20829
20652
|
}
|
|
20830
20653
|
logger.info(`[AD] c:"${this.getKey()}" attaches d:"${doc.getKey()}"`);
|
|
20831
|
-
const
|
|
20654
|
+
const crdtRoot = doc.getRootObject();
|
|
20832
20655
|
if (opts.initialRoot) {
|
|
20833
20656
|
const initialRoot = opts.initialRoot;
|
|
20834
20657
|
doc.update((root) => {
|
|
20835
20658
|
for (const [k, v] of Object.entries(initialRoot)) {
|
|
20836
|
-
if (!
|
|
20659
|
+
if (!crdtRoot.has(k)) {
|
|
20837
20660
|
const key = k;
|
|
20838
20661
|
root[key] = v;
|
|
20839
20662
|
}
|
|
@@ -20856,7 +20679,7 @@ class Client {
|
|
|
20856
20679
|
* the changes should be applied to other replicas before GC time. For this,
|
|
20857
20680
|
* if the document is no longer used by this client, it should be detached.
|
|
20858
20681
|
*/
|
|
20859
|
-
detach(doc, opts = {
|
|
20682
|
+
detach(doc, opts = { removeIfNotAttached: false }) {
|
|
20860
20683
|
if (!this.isActive()) {
|
|
20861
20684
|
throw new YorkieError(
|
|
20862
20685
|
Code.ErrClientNotActivated,
|
|
@@ -20871,14 +20694,14 @@ class Client {
|
|
|
20871
20694
|
);
|
|
20872
20695
|
}
|
|
20873
20696
|
doc.update((_, p) => p.clear());
|
|
20874
|
-
|
|
20697
|
+
return this.enqueueTask(async () => {
|
|
20875
20698
|
try {
|
|
20876
20699
|
const res = await this.rpcClient.detachDocument(
|
|
20877
20700
|
{
|
|
20878
20701
|
clientId: this.id,
|
|
20879
20702
|
documentId: attachment.docID,
|
|
20880
20703
|
changePack: converter.toChangePack(doc.createChangePack()),
|
|
20881
|
-
removeIfNotAttached: opts.removeIfNotAttached
|
|
20704
|
+
removeIfNotAttached: opts.removeIfNotAttached
|
|
20882
20705
|
},
|
|
20883
20706
|
{ headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
|
|
20884
20707
|
);
|
|
@@ -20895,14 +20718,7 @@ class Client {
|
|
|
20895
20718
|
await this.handleConnectError(err);
|
|
20896
20719
|
throw err;
|
|
20897
20720
|
}
|
|
20898
|
-
};
|
|
20899
|
-
if (opts.keepalive) {
|
|
20900
|
-
this.keepalive = true;
|
|
20901
|
-
const resp = task();
|
|
20902
|
-
this.keepalive = false;
|
|
20903
|
-
return resp;
|
|
20904
|
-
}
|
|
20905
|
-
return this.enqueueTask(task);
|
|
20721
|
+
});
|
|
20906
20722
|
}
|
|
20907
20723
|
/**
|
|
20908
20724
|
* `changeRealtimeSync` changes the synchronization mode of the given document.
|