@yorkie-js/react 0.6.9 → 0.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/yorkie-js-react.es.js +82 -260
- package/dist/yorkie-js-react.es.js.map +1 -1
- package/dist/yorkie-js-react.js +82 -260
- package/dist/yorkie-js-react.js.map +1 -1
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { createContext, useMemo, useState, useEffect, useContext, useCallback } from "react";
|
|
7
7
|
const name$1 = "@yorkie-js/react";
|
|
8
|
-
const version$1 = "0.6.
|
|
8
|
+
const version$1 = "0.6.10";
|
|
9
9
|
const pkg$1 = {
|
|
10
10
|
name: name$1,
|
|
11
11
|
version: version$1
|
|
@@ -4468,6 +4468,8 @@ let ChangePack$1 = (_a = class extends Message {
|
|
|
4468
4468
|
*/
|
|
4469
4469
|
__publicField(this, "changes", []);
|
|
4470
4470
|
/**
|
|
4471
|
+
* deprecated
|
|
4472
|
+
*
|
|
4471
4473
|
* @generated from field: yorkie.v1.TimeTicket min_synced_ticket = 5;
|
|
4472
4474
|
*/
|
|
4473
4475
|
__publicField(this, "minSyncedTicket");
|
|
@@ -4884,6 +4886,8 @@ const _Operation_Edit = class _Operation_Edit extends Message {
|
|
|
4884
4886
|
*/
|
|
4885
4887
|
__publicField(this, "to");
|
|
4886
4888
|
/**
|
|
4889
|
+
* deprecated
|
|
4890
|
+
*
|
|
4887
4891
|
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 4;
|
|
4888
4892
|
*/
|
|
4889
4893
|
__publicField(this, "createdAtMapByActor", {});
|
|
@@ -5003,6 +5007,8 @@ const _Operation_Style = class _Operation_Style extends Message {
|
|
|
5003
5007
|
*/
|
|
5004
5008
|
__publicField(this, "executedAt");
|
|
5005
5009
|
/**
|
|
5010
|
+
* deprecated
|
|
5011
|
+
*
|
|
5006
5012
|
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 6;
|
|
5007
5013
|
*/
|
|
5008
5014
|
__publicField(this, "createdAtMapByActor", {});
|
|
@@ -5090,6 +5096,8 @@ const _Operation_TreeEdit = class _Operation_TreeEdit extends Message {
|
|
|
5090
5096
|
*/
|
|
5091
5097
|
__publicField(this, "to");
|
|
5092
5098
|
/**
|
|
5099
|
+
* deprecated
|
|
5100
|
+
*
|
|
5093
5101
|
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 4;
|
|
5094
5102
|
*/
|
|
5095
5103
|
__publicField(this, "createdAtMapByActor", {});
|
|
@@ -5166,6 +5174,8 @@ const _Operation_TreeStyle = class _Operation_TreeStyle extends Message {
|
|
|
5166
5174
|
*/
|
|
5167
5175
|
__publicField(this, "attributesToRemove", []);
|
|
5168
5176
|
/**
|
|
5177
|
+
* deprecated
|
|
5178
|
+
*
|
|
5169
5179
|
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 7;
|
|
5170
5180
|
*/
|
|
5171
5181
|
__publicField(this, "createdAtMapByActor", {});
|
|
@@ -11131,18 +11141,17 @@ class CRDTText extends CRDTElement {
|
|
|
11131
11141
|
*
|
|
11132
11142
|
* @internal
|
|
11133
11143
|
*/
|
|
11134
|
-
edit(range, content, editedAt, attributes,
|
|
11144
|
+
edit(range, content, editedAt, attributes, versionVector) {
|
|
11135
11145
|
const crdtTextValue = content ? CRDTTextValue.create(content) : void 0;
|
|
11136
11146
|
if (crdtTextValue && attributes) {
|
|
11137
11147
|
for (const [k, v] of Object.entries(attributes)) {
|
|
11138
11148
|
crdtTextValue.setAttr(k, v, editedAt);
|
|
11139
11149
|
}
|
|
11140
11150
|
}
|
|
11141
|
-
const [caretPos,
|
|
11151
|
+
const [caretPos, pairs, valueChanges] = this.rgaTreeSplit.edit(
|
|
11142
11152
|
range,
|
|
11143
11153
|
editedAt,
|
|
11144
11154
|
crdtTextValue,
|
|
11145
|
-
maxCreatedAtMapByActor,
|
|
11146
11155
|
versionVector
|
|
11147
11156
|
);
|
|
11148
11157
|
const changes = valueChanges.map((change) => ({
|
|
@@ -11157,7 +11166,7 @@ class CRDTText extends CRDTElement {
|
|
|
11157
11166
|
type: "content"
|
|
11158
11167
|
/* Content */
|
|
11159
11168
|
}));
|
|
11160
|
-
return [
|
|
11169
|
+
return [changes, pairs, [caretPos, caretPos]];
|
|
11161
11170
|
}
|
|
11162
11171
|
/**
|
|
11163
11172
|
* `setStyle` applies the style of the given range.
|
|
@@ -11167,10 +11176,9 @@ class CRDTText extends CRDTElement {
|
|
|
11167
11176
|
* @param range - range of RGATreeSplitNode
|
|
11168
11177
|
* @param attributes - style attributes
|
|
11169
11178
|
* @param editedAt - edited time
|
|
11170
|
-
* @param maxCreatedAtMapByActor - maxCreatedAtMapByActor
|
|
11171
11179
|
* @internal
|
|
11172
11180
|
*/
|
|
11173
|
-
setStyle(range, attributes, editedAt,
|
|
11181
|
+
setStyle(range, attributes, editedAt, versionVector) {
|
|
11174
11182
|
const [, toRight] = this.rgaTreeSplit.findNodeWithSplit(range[1], editedAt);
|
|
11175
11183
|
const [, fromRight] = this.rgaTreeSplit.findNodeWithSplit(
|
|
11176
11184
|
range[0],
|
|
@@ -11178,25 +11186,14 @@ class CRDTText extends CRDTElement {
|
|
|
11178
11186
|
);
|
|
11179
11187
|
const changes = [];
|
|
11180
11188
|
const nodes = this.rgaTreeSplit.findBetween(fromRight, toRight);
|
|
11181
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
11182
11189
|
const toBeStyleds = [];
|
|
11183
11190
|
for (const node of nodes) {
|
|
11184
11191
|
const actorID = node.getCreatedAt().getActorID();
|
|
11185
|
-
let
|
|
11186
|
-
|
|
11187
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
11188
|
-
clientLamportAtChange = MaxLamport;
|
|
11189
|
-
} else if (versionVector.size() > 0) {
|
|
11192
|
+
let clientLamportAtChange = MaxLamport;
|
|
11193
|
+
if (versionVector != void 0) {
|
|
11190
11194
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
11191
|
-
} else {
|
|
11192
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
11193
11195
|
}
|
|
11194
|
-
if (node.canStyle(editedAt,
|
|
11195
|
-
const maxCreatedAt2 = createdAtMapByActor.get(actorID);
|
|
11196
|
-
const createdAt = node.getCreatedAt();
|
|
11197
|
-
if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
|
|
11198
|
-
createdAtMapByActor.set(actorID, createdAt);
|
|
11199
|
-
}
|
|
11196
|
+
if (node.canStyle(editedAt, clientLamportAtChange)) {
|
|
11200
11197
|
toBeStyleds.push(node);
|
|
11201
11198
|
}
|
|
11202
11199
|
}
|
|
@@ -11224,7 +11221,7 @@ class CRDTText extends CRDTElement {
|
|
|
11224
11221
|
}
|
|
11225
11222
|
}
|
|
11226
11223
|
}
|
|
11227
|
-
return [
|
|
11224
|
+
return [pairs, changes];
|
|
11228
11225
|
}
|
|
11229
11226
|
/**
|
|
11230
11227
|
* `indexRangeToPosRange` returns the position range of the given index range.
|
|
@@ -11371,28 +11368,25 @@ class CRDTText extends CRDTElement {
|
|
|
11371
11368
|
}
|
|
11372
11369
|
}
|
|
11373
11370
|
class EditOperation extends Operation {
|
|
11374
|
-
constructor(parentCreatedAt, fromPos, toPos,
|
|
11371
|
+
constructor(parentCreatedAt, fromPos, toPos, content, attributes, executedAt) {
|
|
11375
11372
|
super(parentCreatedAt, executedAt);
|
|
11376
11373
|
__publicField(this, "fromPos");
|
|
11377
11374
|
__publicField(this, "toPos");
|
|
11378
|
-
__publicField(this, "maxCreatedAtMapByActor");
|
|
11379
11375
|
__publicField(this, "content");
|
|
11380
11376
|
__publicField(this, "attributes");
|
|
11381
11377
|
this.fromPos = fromPos;
|
|
11382
11378
|
this.toPos = toPos;
|
|
11383
|
-
this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
|
|
11384
11379
|
this.content = content;
|
|
11385
11380
|
this.attributes = attributes;
|
|
11386
11381
|
}
|
|
11387
11382
|
/**
|
|
11388
11383
|
* `create` creates a new instance of EditOperation.
|
|
11389
11384
|
*/
|
|
11390
|
-
static create(parentCreatedAt, fromPos, toPos,
|
|
11385
|
+
static create(parentCreatedAt, fromPos, toPos, content, attributes, executedAt) {
|
|
11391
11386
|
return new EditOperation(
|
|
11392
11387
|
parentCreatedAt,
|
|
11393
11388
|
fromPos,
|
|
11394
11389
|
toPos,
|
|
11395
|
-
maxCreatedAtMapByActor,
|
|
11396
11390
|
content,
|
|
11397
11391
|
attributes,
|
|
11398
11392
|
executedAt
|
|
@@ -11416,12 +11410,11 @@ class EditOperation extends Operation {
|
|
|
11416
11410
|
);
|
|
11417
11411
|
}
|
|
11418
11412
|
const text = parentObject;
|
|
11419
|
-
const [
|
|
11413
|
+
const [changes, pairs] = text.edit(
|
|
11420
11414
|
[this.fromPos, this.toPos],
|
|
11421
11415
|
this.content,
|
|
11422
11416
|
this.getExecutedAt(),
|
|
11423
11417
|
Object.fromEntries(this.attributes),
|
|
11424
|
-
this.maxCreatedAtMapByActor,
|
|
11425
11418
|
versionVector
|
|
11426
11419
|
);
|
|
11427
11420
|
for (const pair of pairs) {
|
|
@@ -11479,35 +11472,25 @@ class EditOperation extends Operation {
|
|
|
11479
11472
|
getAttributes() {
|
|
11480
11473
|
return this.attributes || /* @__PURE__ */ new Map();
|
|
11481
11474
|
}
|
|
11482
|
-
/**
|
|
11483
|
-
* `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
|
|
11484
|
-
* by actor for the nodes included in the editing range.
|
|
11485
|
-
*/
|
|
11486
|
-
getMaxCreatedAtMapByActor() {
|
|
11487
|
-
return this.maxCreatedAtMapByActor;
|
|
11488
|
-
}
|
|
11489
11475
|
}
|
|
11490
11476
|
class StyleOperation extends Operation {
|
|
11491
|
-
constructor(parentCreatedAt, fromPos, toPos,
|
|
11477
|
+
constructor(parentCreatedAt, fromPos, toPos, attributes, executedAt) {
|
|
11492
11478
|
super(parentCreatedAt, executedAt);
|
|
11493
11479
|
__publicField(this, "fromPos");
|
|
11494
11480
|
__publicField(this, "toPos");
|
|
11495
|
-
__publicField(this, "maxCreatedAtMapByActor");
|
|
11496
11481
|
__publicField(this, "attributes");
|
|
11497
11482
|
this.fromPos = fromPos;
|
|
11498
11483
|
this.toPos = toPos;
|
|
11499
|
-
this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
|
|
11500
11484
|
this.attributes = attributes;
|
|
11501
11485
|
}
|
|
11502
11486
|
/**
|
|
11503
11487
|
* `create` creates a new instance of StyleOperation.
|
|
11504
11488
|
*/
|
|
11505
|
-
static create(parentCreatedAt, fromPos, toPos,
|
|
11489
|
+
static create(parentCreatedAt, fromPos, toPos, attributes, executedAt) {
|
|
11506
11490
|
return new StyleOperation(
|
|
11507
11491
|
parentCreatedAt,
|
|
11508
11492
|
fromPos,
|
|
11509
11493
|
toPos,
|
|
11510
|
-
maxCreatedAtMapByActor,
|
|
11511
11494
|
attributes,
|
|
11512
11495
|
executedAt
|
|
11513
11496
|
);
|
|
@@ -11530,11 +11513,10 @@ class StyleOperation extends Operation {
|
|
|
11530
11513
|
);
|
|
11531
11514
|
}
|
|
11532
11515
|
const text = parentObject;
|
|
11533
|
-
const [
|
|
11516
|
+
const [pairs, changes] = text.setStyle(
|
|
11534
11517
|
[this.fromPos, this.toPos],
|
|
11535
11518
|
this.attributes ? Object.fromEntries(this.attributes) : {},
|
|
11536
11519
|
this.getExecutedAt(),
|
|
11537
|
-
this.maxCreatedAtMapByActor,
|
|
11538
11520
|
versionVector
|
|
11539
11521
|
);
|
|
11540
11522
|
for (const pair of pairs) {
|
|
@@ -11586,13 +11568,6 @@ class StyleOperation extends Operation {
|
|
|
11586
11568
|
getAttributes() {
|
|
11587
11569
|
return this.attributes;
|
|
11588
11570
|
}
|
|
11589
|
-
/**
|
|
11590
|
-
* `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
|
|
11591
|
-
* by actor for the nodes included in the editing range.
|
|
11592
|
-
*/
|
|
11593
|
-
getMaxCreatedAtMapByActor() {
|
|
11594
|
-
return this.maxCreatedAtMapByActor;
|
|
11595
|
-
}
|
|
11596
11571
|
}
|
|
11597
11572
|
const ElementPaddingSize = 2;
|
|
11598
11573
|
const DefaultRootType = "root";
|
|
@@ -12863,18 +12838,18 @@ class CRDTTreeNode extends IndexTreeNode {
|
|
|
12863
12838
|
/**
|
|
12864
12839
|
* `canDelete` checks if node is able to delete.
|
|
12865
12840
|
*/
|
|
12866
|
-
canDelete(editedAt,
|
|
12867
|
-
const nodeExisted =
|
|
12841
|
+
canDelete(editedAt, clientLamportAtChange) {
|
|
12842
|
+
const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
|
|
12868
12843
|
return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));
|
|
12869
12844
|
}
|
|
12870
12845
|
/**
|
|
12871
12846
|
* `canStyle` checks if node is able to style.
|
|
12872
12847
|
*/
|
|
12873
|
-
canStyle(editedAt,
|
|
12848
|
+
canStyle(editedAt, clientLamportAtChange) {
|
|
12874
12849
|
if (this.isText) {
|
|
12875
12850
|
return false;
|
|
12876
12851
|
}
|
|
12877
|
-
const nodeExisted =
|
|
12852
|
+
const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
|
|
12878
12853
|
return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));
|
|
12879
12854
|
}
|
|
12880
12855
|
/**
|
|
@@ -13063,7 +13038,7 @@ class CRDTTree extends CRDTElement {
|
|
|
13063
13038
|
/**
|
|
13064
13039
|
* `style` applies the given attributes of the given range.
|
|
13065
13040
|
*/
|
|
13066
|
-
style(range, attributes, editedAt,
|
|
13041
|
+
style(range, attributes, editedAt, versionVector) {
|
|
13067
13042
|
const [fromParent, fromLeft] = this.findNodesAndSplitText(
|
|
13068
13043
|
range[0],
|
|
13069
13044
|
editedAt
|
|
@@ -13071,7 +13046,6 @@ class CRDTTree extends CRDTElement {
|
|
|
13071
13046
|
const [toParent, toLeft] = this.findNodesAndSplitText(range[1], editedAt);
|
|
13072
13047
|
const changes = [];
|
|
13073
13048
|
const attrs = attributes ? parseObjectValues(attributes) : {};
|
|
13074
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
13075
13049
|
const pairs = [];
|
|
13076
13050
|
this.traverseInPosRange(
|
|
13077
13051
|
fromParent,
|
|
@@ -13080,21 +13054,11 @@ class CRDTTree extends CRDTElement {
|
|
|
13080
13054
|
toLeft,
|
|
13081
13055
|
([node]) => {
|
|
13082
13056
|
const actorID = node.getCreatedAt().getActorID();
|
|
13083
|
-
let
|
|
13084
|
-
|
|
13085
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
13086
|
-
clientLamportAtChange = MaxLamport;
|
|
13087
|
-
} else if (versionVector.size() > 0) {
|
|
13057
|
+
let clientLamportAtChange = MaxLamport;
|
|
13058
|
+
if (versionVector != void 0) {
|
|
13088
13059
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
13089
|
-
} else {
|
|
13090
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
13091
13060
|
}
|
|
13092
|
-
if (node.canStyle(editedAt,
|
|
13093
|
-
const maxCreatedAt2 = createdAtMapByActor.get(actorID);
|
|
13094
|
-
const createdAt = node.getCreatedAt();
|
|
13095
|
-
if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
|
|
13096
|
-
createdAtMapByActor.set(actorID, createdAt);
|
|
13097
|
-
}
|
|
13061
|
+
if (node.canStyle(editedAt, clientLamportAtChange) && attributes) {
|
|
13098
13062
|
const updatedAttrPairs = node.setAttrs(attributes, editedAt);
|
|
13099
13063
|
const affectedAttrs = updatedAttrPairs.reduce(
|
|
13100
13064
|
(acc, [, curr]) => {
|
|
@@ -13127,19 +13091,18 @@ class CRDTTree extends CRDTElement {
|
|
|
13127
13091
|
}
|
|
13128
13092
|
}
|
|
13129
13093
|
);
|
|
13130
|
-
return [
|
|
13094
|
+
return [pairs, changes];
|
|
13131
13095
|
}
|
|
13132
13096
|
/**
|
|
13133
13097
|
* `removeStyle` removes the given attributes of the given range.
|
|
13134
13098
|
*/
|
|
13135
|
-
removeStyle(range, attributesToRemove, editedAt,
|
|
13099
|
+
removeStyle(range, attributesToRemove, editedAt, versionVector) {
|
|
13136
13100
|
const [fromParent, fromLeft] = this.findNodesAndSplitText(
|
|
13137
13101
|
range[0],
|
|
13138
13102
|
editedAt
|
|
13139
13103
|
);
|
|
13140
13104
|
const [toParent, toLeft] = this.findNodesAndSplitText(range[1], editedAt);
|
|
13141
13105
|
const changes = [];
|
|
13142
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
13143
13106
|
const pairs = [];
|
|
13144
13107
|
this.traverseInPosRange(
|
|
13145
13108
|
fromParent,
|
|
@@ -13148,21 +13111,11 @@ class CRDTTree extends CRDTElement {
|
|
|
13148
13111
|
toLeft,
|
|
13149
13112
|
([node]) => {
|
|
13150
13113
|
const actorID = node.getCreatedAt().getActorID();
|
|
13151
|
-
let
|
|
13152
|
-
|
|
13153
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
13154
|
-
clientLamportAtChange = MaxLamport;
|
|
13155
|
-
} else if (versionVector.size() > 0) {
|
|
13114
|
+
let clientLamportAtChange = MaxLamport;
|
|
13115
|
+
if (versionVector != void 0) {
|
|
13156
13116
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
13157
|
-
} else {
|
|
13158
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
13159
13117
|
}
|
|
13160
|
-
if (node.canStyle(editedAt,
|
|
13161
|
-
const maxCreatedAt2 = createdAtMapByActor.get(actorID);
|
|
13162
|
-
const createdAt = node.getCreatedAt();
|
|
13163
|
-
if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
|
|
13164
|
-
createdAtMapByActor.set(actorID, createdAt);
|
|
13165
|
-
}
|
|
13118
|
+
if (node.canStyle(editedAt, clientLamportAtChange) && attributesToRemove) {
|
|
13166
13119
|
if (!node.attrs) {
|
|
13167
13120
|
node.attrs = new RHT();
|
|
13168
13121
|
}
|
|
@@ -13186,13 +13139,13 @@ class CRDTTree extends CRDTElement {
|
|
|
13186
13139
|
}
|
|
13187
13140
|
}
|
|
13188
13141
|
);
|
|
13189
|
-
return [
|
|
13142
|
+
return [pairs, changes];
|
|
13190
13143
|
}
|
|
13191
13144
|
/**
|
|
13192
13145
|
* `edit` edits the tree with the given range and content.
|
|
13193
13146
|
* If the content is undefined, the range will be removed.
|
|
13194
13147
|
*/
|
|
13195
|
-
edit(range, contents, splitLevel, editedAt, issueTimeTicket,
|
|
13148
|
+
edit(range, contents, splitLevel, editedAt, issueTimeTicket, versionVector) {
|
|
13196
13149
|
const [fromParent, fromLeft] = this.findNodesAndSplitText(
|
|
13197
13150
|
range[0],
|
|
13198
13151
|
editedAt
|
|
@@ -13203,7 +13156,6 @@ class CRDTTree extends CRDTElement {
|
|
|
13203
13156
|
const nodesToBeRemoved = [];
|
|
13204
13157
|
const tokensToBeRemoved = [];
|
|
13205
13158
|
const toBeMovedToFromParents = [];
|
|
13206
|
-
const maxCreatedAtMap = /* @__PURE__ */ new Map();
|
|
13207
13159
|
this.traverseInPosRange(
|
|
13208
13160
|
fromParent,
|
|
13209
13161
|
fromLeft,
|
|
@@ -13216,21 +13168,11 @@ class CRDTTree extends CRDTElement {
|
|
|
13216
13168
|
}
|
|
13217
13169
|
}
|
|
13218
13170
|
const actorID = node.getCreatedAt().getActorID();
|
|
13219
|
-
let
|
|
13220
|
-
|
|
13221
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
13222
|
-
clientLamportAtChange = MaxLamport;
|
|
13223
|
-
} else if (versionVector.size() > 0) {
|
|
13171
|
+
let clientLamportAtChange = MaxLamport;
|
|
13172
|
+
if (versionVector != void 0) {
|
|
13224
13173
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
13225
|
-
} else {
|
|
13226
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
13227
13174
|
}
|
|
13228
|
-
if (node.canDelete(editedAt,
|
|
13229
|
-
const maxCreatedAt2 = maxCreatedAtMap.get(actorID);
|
|
13230
|
-
const createdAt = node.getCreatedAt();
|
|
13231
|
-
if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
|
|
13232
|
-
maxCreatedAtMap.set(actorID, createdAt);
|
|
13233
|
-
}
|
|
13175
|
+
if (node.canDelete(editedAt, clientLamportAtChange) || nodesToBeRemoved.includes(node.parent)) {
|
|
13234
13176
|
if (tokenType === TokenType.Text || tokenType === TokenType.Start) {
|
|
13235
13177
|
nodesToBeRemoved.push(node);
|
|
13236
13178
|
}
|
|
@@ -13311,7 +13253,7 @@ class CRDTTree extends CRDTElement {
|
|
|
13311
13253
|
}
|
|
13312
13254
|
}
|
|
13313
13255
|
}
|
|
13314
|
-
return [changes, pairs
|
|
13256
|
+
return [changes, pairs];
|
|
13315
13257
|
}
|
|
13316
13258
|
/**
|
|
13317
13259
|
* `editT` edits the given range with the given value.
|
|
@@ -13750,30 +13692,27 @@ class CRDTTree extends CRDTElement {
|
|
|
13750
13692
|
}
|
|
13751
13693
|
}
|
|
13752
13694
|
class TreeEditOperation extends Operation {
|
|
13753
|
-
constructor(parentCreatedAt, fromPos, toPos, contents, splitLevel,
|
|
13695
|
+
constructor(parentCreatedAt, fromPos, toPos, contents, splitLevel, executedAt) {
|
|
13754
13696
|
super(parentCreatedAt, executedAt);
|
|
13755
13697
|
__publicField(this, "fromPos");
|
|
13756
13698
|
__publicField(this, "toPos");
|
|
13757
13699
|
__publicField(this, "contents");
|
|
13758
13700
|
__publicField(this, "splitLevel");
|
|
13759
|
-
__publicField(this, "maxCreatedAtMapByActor");
|
|
13760
13701
|
this.fromPos = fromPos;
|
|
13761
13702
|
this.toPos = toPos;
|
|
13762
13703
|
this.contents = contents;
|
|
13763
13704
|
this.splitLevel = splitLevel;
|
|
13764
|
-
this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
|
|
13765
13705
|
}
|
|
13766
13706
|
/**
|
|
13767
13707
|
* `create` creates a new instance of EditOperation.
|
|
13768
13708
|
*/
|
|
13769
|
-
static create(parentCreatedAt, fromPos, toPos, contents, splitLevel,
|
|
13709
|
+
static create(parentCreatedAt, fromPos, toPos, contents, splitLevel, executedAt) {
|
|
13770
13710
|
return new TreeEditOperation(
|
|
13771
13711
|
parentCreatedAt,
|
|
13772
13712
|
fromPos,
|
|
13773
13713
|
toPos,
|
|
13774
13714
|
contents,
|
|
13775
13715
|
splitLevel,
|
|
13776
|
-
maxCreatedAtMapByActor,
|
|
13777
13716
|
executedAt
|
|
13778
13717
|
);
|
|
13779
13718
|
}
|
|
@@ -13821,7 +13760,6 @@ class TreeEditOperation extends Operation {
|
|
|
13821
13760
|
);
|
|
13822
13761
|
return issueTimeTicket;
|
|
13823
13762
|
})(),
|
|
13824
|
-
this.maxCreatedAtMapByActor,
|
|
13825
13763
|
versionVector
|
|
13826
13764
|
);
|
|
13827
13765
|
for (const pair of pairs) {
|
|
@@ -13884,13 +13822,6 @@ class TreeEditOperation extends Operation {
|
|
|
13884
13822
|
getSplitLevel() {
|
|
13885
13823
|
return this.splitLevel;
|
|
13886
13824
|
}
|
|
13887
|
-
/**
|
|
13888
|
-
* `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
|
|
13889
|
-
* by actor for the nodes included in the editing range.
|
|
13890
|
-
*/
|
|
13891
|
-
getMaxCreatedAtMapByActor() {
|
|
13892
|
-
return this.maxCreatedAtMapByActor;
|
|
13893
|
-
}
|
|
13894
13825
|
}
|
|
13895
13826
|
class VersionVector {
|
|
13896
13827
|
constructor(vector) {
|
|
@@ -14034,12 +13965,7 @@ class ChangeID {
|
|
|
14034
13965
|
*/
|
|
14035
13966
|
syncClocks(other) {
|
|
14036
13967
|
const lamport = other.lamport > this.lamport ? other.lamport + 1n : this.lamport + 1n;
|
|
14037
|
-
|
|
14038
|
-
if (otherVV.size() === 0) {
|
|
14039
|
-
otherVV = otherVV.deepcopy();
|
|
14040
|
-
otherVV.set(other.actor, other.lamport);
|
|
14041
|
-
}
|
|
14042
|
-
const maxVersionVector = this.versionVector.max(otherVV);
|
|
13968
|
+
const maxVersionVector = this.versionVector.max(other.versionVector);
|
|
14043
13969
|
const newID = new ChangeID(
|
|
14044
13970
|
this.clientSeq,
|
|
14045
13971
|
lamport,
|
|
@@ -14285,7 +14211,7 @@ class Change {
|
|
|
14285
14211
|
}
|
|
14286
14212
|
}
|
|
14287
14213
|
class ChangePack {
|
|
14288
|
-
constructor(key, checkpoint, isRemoved, changes, versionVector, snapshot
|
|
14214
|
+
constructor(key, checkpoint, isRemoved, changes, versionVector, snapshot) {
|
|
14289
14215
|
/**
|
|
14290
14216
|
* `documentKey` is the key of the document.
|
|
14291
14217
|
*/
|
|
@@ -14303,12 +14229,6 @@ class ChangePack {
|
|
|
14303
14229
|
* `snapshot` is a byte array that encodes the document.
|
|
14304
14230
|
*/
|
|
14305
14231
|
__publicField(this, "snapshot");
|
|
14306
|
-
/**
|
|
14307
|
-
* `minSyncedTicket` is the minimum logical time taken by clients who attach
|
|
14308
|
-
* to the document. It is used to collect garbage on the replica on the
|
|
14309
|
-
* client.
|
|
14310
|
-
*/
|
|
14311
|
-
__publicField(this, "minSyncedTicket");
|
|
14312
14232
|
/**
|
|
14313
14233
|
* `versionVector` is the version vector current document
|
|
14314
14234
|
*/
|
|
@@ -14318,21 +14238,19 @@ class ChangePack {
|
|
|
14318
14238
|
this.isRemoved = isRemoved;
|
|
14319
14239
|
this.changes = changes;
|
|
14320
14240
|
this.snapshot = snapshot;
|
|
14321
|
-
this.minSyncedTicket = minSyncedTicket;
|
|
14322
14241
|
this.versionVector = versionVector;
|
|
14323
14242
|
}
|
|
14324
14243
|
/**
|
|
14325
14244
|
* `create` creates a new instance of ChangePack.
|
|
14326
14245
|
*/
|
|
14327
|
-
static create(key, checkpoint, isRemoved, changes, versionVector, snapshot
|
|
14246
|
+
static create(key, checkpoint, isRemoved, changes, versionVector, snapshot) {
|
|
14328
14247
|
return new ChangePack(
|
|
14329
14248
|
key,
|
|
14330
14249
|
checkpoint,
|
|
14331
14250
|
isRemoved,
|
|
14332
14251
|
changes,
|
|
14333
14252
|
versionVector,
|
|
14334
|
-
snapshot
|
|
14335
|
-
minSyncedTicket
|
|
14253
|
+
snapshot
|
|
14336
14254
|
);
|
|
14337
14255
|
}
|
|
14338
14256
|
/**
|
|
@@ -14383,12 +14301,6 @@ class ChangePack {
|
|
|
14383
14301
|
getSnapshot() {
|
|
14384
14302
|
return this.snapshot;
|
|
14385
14303
|
}
|
|
14386
|
-
/**
|
|
14387
|
-
* `getMinSyncedTicket` returns the minimum synced ticket of this pack.
|
|
14388
|
-
*/
|
|
14389
|
-
getMinSyncedTicket() {
|
|
14390
|
-
return this.minSyncedTicket;
|
|
14391
|
-
}
|
|
14392
14304
|
/**
|
|
14393
14305
|
* `getVersionVector` returns the document's version vector of this pack
|
|
14394
14306
|
*/
|
|
@@ -14773,9 +14685,9 @@ class RGATreeSplitNode extends SplayNode {
|
|
|
14773
14685
|
/**
|
|
14774
14686
|
* `canDelete` checks if node is able to delete.
|
|
14775
14687
|
*/
|
|
14776
|
-
canDelete(editedAt,
|
|
14688
|
+
canDelete(editedAt, clientLamportAtChange) {
|
|
14777
14689
|
const justRemoved = !this.removedAt;
|
|
14778
|
-
const nodeExisted =
|
|
14690
|
+
const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
|
|
14779
14691
|
if (nodeExisted && (!this.removedAt || editedAt.after(this.removedAt))) {
|
|
14780
14692
|
return justRemoved;
|
|
14781
14693
|
}
|
|
@@ -14784,8 +14696,8 @@ class RGATreeSplitNode extends SplayNode {
|
|
|
14784
14696
|
/**
|
|
14785
14697
|
* `canStyle` checks if node is able to set style.
|
|
14786
14698
|
*/
|
|
14787
|
-
canStyle(editedAt,
|
|
14788
|
-
const nodeExisted =
|
|
14699
|
+
canStyle(editedAt, clientLamportAtChange) {
|
|
14700
|
+
const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
|
|
14789
14701
|
return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));
|
|
14790
14702
|
}
|
|
14791
14703
|
/**
|
|
@@ -14867,17 +14779,15 @@ class RGATreeSplit {
|
|
|
14867
14779
|
* @param range - range of RGATreeSplitNode
|
|
14868
14780
|
* @param editedAt - edited time
|
|
14869
14781
|
* @param value - value
|
|
14870
|
-
* @
|
|
14871
|
-
* @returns `[RGATreeSplitPos, Map<string, TimeTicket>, Array<GCPair>, Array<Change>]`
|
|
14782
|
+
* @returns `[RGATreeSplitPos, Array<GCPair>, Array<Change>]`
|
|
14872
14783
|
*/
|
|
14873
|
-
edit(range, editedAt, value,
|
|
14784
|
+
edit(range, editedAt, value, versionVector) {
|
|
14874
14785
|
const [toLeft, toRight] = this.findNodeWithSplit(range[1], editedAt);
|
|
14875
14786
|
const [fromLeft, fromRight] = this.findNodeWithSplit(range[0], editedAt);
|
|
14876
14787
|
const nodesToDelete = this.findBetween(fromRight, toRight);
|
|
14877
|
-
const [changes,
|
|
14788
|
+
const [changes, removedNodes] = this.deleteNodes(
|
|
14878
14789
|
nodesToDelete,
|
|
14879
14790
|
editedAt,
|
|
14880
|
-
maxCreatedAtMapByActor,
|
|
14881
14791
|
versionVector
|
|
14882
14792
|
);
|
|
14883
14793
|
const caretID = toRight ? toRight.getID() : toLeft.getID();
|
|
@@ -14907,7 +14817,7 @@ class RGATreeSplit {
|
|
|
14907
14817
|
for (const [, removedNode] of removedNodes) {
|
|
14908
14818
|
pairs.push({ parent: this, child: removedNode });
|
|
14909
14819
|
}
|
|
14910
|
-
return [caretPos,
|
|
14820
|
+
return [caretPos, pairs, changes];
|
|
14911
14821
|
}
|
|
14912
14822
|
/**
|
|
14913
14823
|
* `indexToPos` finds RGATreeSplitPos of given offset.
|
|
@@ -15112,47 +15022,36 @@ class RGATreeSplit {
|
|
|
15112
15022
|
splitNode.setInsPrev(node);
|
|
15113
15023
|
return splitNode;
|
|
15114
15024
|
}
|
|
15115
|
-
deleteNodes(candidates, editedAt,
|
|
15025
|
+
deleteNodes(candidates, editedAt, versionVector) {
|
|
15116
15026
|
if (!candidates.length) {
|
|
15117
|
-
return [[], /* @__PURE__ */ new Map()
|
|
15027
|
+
return [[], /* @__PURE__ */ new Map()];
|
|
15118
15028
|
}
|
|
15119
15029
|
const [nodesToDelete, nodesToKeep] = this.filterNodes(
|
|
15120
15030
|
candidates,
|
|
15121
15031
|
editedAt,
|
|
15122
|
-
maxCreatedAtMapByActor,
|
|
15123
15032
|
versionVector
|
|
15124
15033
|
);
|
|
15125
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
15126
15034
|
const removedNodes = /* @__PURE__ */ new Map();
|
|
15127
15035
|
const changes = this.makeChanges(nodesToKeep, editedAt);
|
|
15128
15036
|
for (const node of nodesToDelete) {
|
|
15129
|
-
const actorID = node.getCreatedAt().getActorID();
|
|
15130
|
-
if (!createdAtMapByActor.has(actorID) || node.getID().getCreatedAt().after(createdAtMapByActor.get(actorID))) {
|
|
15131
|
-
createdAtMapByActor.set(actorID, node.getID().getCreatedAt());
|
|
15132
|
-
}
|
|
15133
15037
|
removedNodes.set(node.getID().toIDString(), node);
|
|
15134
15038
|
node.remove(editedAt);
|
|
15135
15039
|
}
|
|
15136
15040
|
this.deleteIndexNodes(nodesToKeep);
|
|
15137
|
-
return [changes,
|
|
15041
|
+
return [changes, removedNodes];
|
|
15138
15042
|
}
|
|
15139
|
-
filterNodes(candidates, editedAt,
|
|
15043
|
+
filterNodes(candidates, editedAt, versionVector) {
|
|
15140
15044
|
const nodesToDelete = [];
|
|
15141
15045
|
const nodesToKeep = [];
|
|
15142
15046
|
const [leftEdge, rightEdge] = this.findEdgesOfCandidates(candidates);
|
|
15143
15047
|
nodesToKeep.push(leftEdge);
|
|
15144
15048
|
for (const node of candidates) {
|
|
15145
15049
|
const actorID = node.getCreatedAt().getActorID();
|
|
15146
|
-
let
|
|
15147
|
-
|
|
15148
|
-
if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
|
|
15149
|
-
clientLamportAtChange = MaxLamport;
|
|
15150
|
-
} else if (versionVector.size() > 0) {
|
|
15050
|
+
let clientLamportAtChange = MaxLamport;
|
|
15051
|
+
if (versionVector != void 0) {
|
|
15151
15052
|
clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
|
|
15152
|
-
} else {
|
|
15153
|
-
maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
|
|
15154
15053
|
}
|
|
15155
|
-
if (node.canDelete(editedAt,
|
|
15054
|
+
if (node.canDelete(editedAt, clientLamportAtChange)) {
|
|
15156
15055
|
nodesToDelete.push(node);
|
|
15157
15056
|
} else {
|
|
15158
15057
|
nodesToKeep.push(node);
|
|
@@ -15533,28 +15432,25 @@ class IncreaseOperation extends Operation {
|
|
|
15533
15432
|
}
|
|
15534
15433
|
}
|
|
15535
15434
|
class TreeStyleOperation extends Operation {
|
|
15536
|
-
constructor(parentCreatedAt, fromPos, toPos,
|
|
15435
|
+
constructor(parentCreatedAt, fromPos, toPos, attributes, attributesToRemove, executedAt) {
|
|
15537
15436
|
super(parentCreatedAt, executedAt);
|
|
15538
15437
|
__publicField(this, "fromPos");
|
|
15539
15438
|
__publicField(this, "toPos");
|
|
15540
|
-
__publicField(this, "maxCreatedAtMapByActor");
|
|
15541
15439
|
__publicField(this, "attributes");
|
|
15542
15440
|
__publicField(this, "attributesToRemove");
|
|
15543
15441
|
this.fromPos = fromPos;
|
|
15544
15442
|
this.toPos = toPos;
|
|
15545
|
-
this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
|
|
15546
15443
|
this.attributes = attributes;
|
|
15547
15444
|
this.attributesToRemove = attributesToRemove;
|
|
15548
15445
|
}
|
|
15549
15446
|
/**
|
|
15550
15447
|
* `create` creates a new instance of TreeStyleOperation.
|
|
15551
15448
|
*/
|
|
15552
|
-
static create(parentCreatedAt, fromPos, toPos,
|
|
15449
|
+
static create(parentCreatedAt, fromPos, toPos, attributes, executedAt) {
|
|
15553
15450
|
return new TreeStyleOperation(
|
|
15554
15451
|
parentCreatedAt,
|
|
15555
15452
|
fromPos,
|
|
15556
15453
|
toPos,
|
|
15557
|
-
maxCreatedAtMapByActor,
|
|
15558
15454
|
attributes,
|
|
15559
15455
|
[],
|
|
15560
15456
|
executedAt
|
|
@@ -15563,12 +15459,11 @@ class TreeStyleOperation extends Operation {
|
|
|
15563
15459
|
/**
|
|
15564
15460
|
* `createTreeRemoveStyleOperation` creates a new instance of TreeStyleOperation for style deletion.
|
|
15565
15461
|
*/
|
|
15566
|
-
static createTreeRemoveStyleOperation(parentCreatedAt, fromPos, toPos,
|
|
15462
|
+
static createTreeRemoveStyleOperation(parentCreatedAt, fromPos, toPos, attributesToRemove, executedAt) {
|
|
15567
15463
|
return new TreeStyleOperation(
|
|
15568
15464
|
parentCreatedAt,
|
|
15569
15465
|
fromPos,
|
|
15570
15466
|
toPos,
|
|
15571
|
-
maxCreatedAtMapByActor,
|
|
15572
15467
|
/* @__PURE__ */ new Map(),
|
|
15573
15468
|
attributesToRemove,
|
|
15574
15469
|
executedAt
|
|
@@ -15597,20 +15492,18 @@ class TreeStyleOperation extends Operation {
|
|
|
15597
15492
|
if (this.attributes.size) {
|
|
15598
15493
|
const attributes = {};
|
|
15599
15494
|
[...this.attributes].forEach(([key, value]) => attributes[key] = value);
|
|
15600
|
-
[
|
|
15495
|
+
[pairs, changes] = tree.style(
|
|
15601
15496
|
[this.fromPos, this.toPos],
|
|
15602
15497
|
attributes,
|
|
15603
15498
|
this.getExecutedAt(),
|
|
15604
|
-
this.maxCreatedAtMapByActor,
|
|
15605
15499
|
versionVector
|
|
15606
15500
|
);
|
|
15607
15501
|
} else {
|
|
15608
15502
|
const attributesToRemove = this.attributesToRemove;
|
|
15609
|
-
[
|
|
15503
|
+
[pairs, changes] = tree.removeStyle(
|
|
15610
15504
|
[this.fromPos, this.toPos],
|
|
15611
15505
|
attributesToRemove,
|
|
15612
15506
|
this.getExecutedAt(),
|
|
15613
|
-
this.maxCreatedAtMapByActor,
|
|
15614
15507
|
versionVector
|
|
15615
15508
|
);
|
|
15616
15509
|
}
|
|
@@ -15672,13 +15565,6 @@ class TreeStyleOperation extends Operation {
|
|
|
15672
15565
|
getAttributesToRemove() {
|
|
15673
15566
|
return this.attributesToRemove;
|
|
15674
15567
|
}
|
|
15675
|
-
/**
|
|
15676
|
-
* `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
|
|
15677
|
-
* by actor for the nodes included in the styling range.
|
|
15678
|
-
*/
|
|
15679
|
-
getMaxCreatedAtMapByActor() {
|
|
15680
|
-
return this.maxCreatedAtMapByActor;
|
|
15681
|
-
}
|
|
15682
15568
|
}
|
|
15683
15569
|
function toPresence(presence) {
|
|
15684
15570
|
const pbPresence = new Presence$1();
|
|
@@ -15902,10 +15788,6 @@ function toOperation(operation) {
|
|
|
15902
15788
|
);
|
|
15903
15789
|
pbEditOperation.from = toTextNodePos(editOperation.getFromPos());
|
|
15904
15790
|
pbEditOperation.to = toTextNodePos(editOperation.getToPos());
|
|
15905
|
-
const pbCreatedAtMapByActor = pbEditOperation.createdAtMapByActor;
|
|
15906
|
-
for (const [key, value] of editOperation.getMaxCreatedAtMapByActor()) {
|
|
15907
|
-
pbCreatedAtMapByActor[key] = toTimeTicket(value);
|
|
15908
|
-
}
|
|
15909
15791
|
pbEditOperation.content = editOperation.getContent();
|
|
15910
15792
|
const pbAttributes = pbEditOperation.attributes;
|
|
15911
15793
|
for (const [key, value] of editOperation.getAttributes()) {
|
|
@@ -15922,10 +15804,6 @@ function toOperation(operation) {
|
|
|
15922
15804
|
);
|
|
15923
15805
|
pbStyleOperation.from = toTextNodePos(styleOperation.getFromPos());
|
|
15924
15806
|
pbStyleOperation.to = toTextNodePos(styleOperation.getToPos());
|
|
15925
|
-
const pbCreatedAtMapByActor = pbStyleOperation.createdAtMapByActor;
|
|
15926
|
-
for (const [key, value] of styleOperation.getMaxCreatedAtMapByActor()) {
|
|
15927
|
-
pbCreatedAtMapByActor[key] = toTimeTicket(value);
|
|
15928
|
-
}
|
|
15929
15807
|
const pbAttributes = pbStyleOperation.attributes;
|
|
15930
15808
|
for (const [key, value] of styleOperation.getAttributes()) {
|
|
15931
15809
|
pbAttributes[key] = value;
|
|
@@ -15948,10 +15826,6 @@ function toOperation(operation) {
|
|
|
15948
15826
|
} else if (operation instanceof TreeEditOperation) {
|
|
15949
15827
|
const treeEditOperation = operation;
|
|
15950
15828
|
const pbTreeEditOperation = new Operation_TreeEdit();
|
|
15951
|
-
const pbCreatedAtMapByActor = pbTreeEditOperation.createdAtMapByActor;
|
|
15952
|
-
for (const [key, value] of treeEditOperation.getMaxCreatedAtMapByActor()) {
|
|
15953
|
-
pbCreatedAtMapByActor[key] = toTimeTicket(value);
|
|
15954
|
-
}
|
|
15955
15829
|
pbTreeEditOperation.parentCreatedAt = toTimeTicket(
|
|
15956
15830
|
treeEditOperation.getParentCreatedAt()
|
|
15957
15831
|
);
|
|
@@ -15974,10 +15848,6 @@ function toOperation(operation) {
|
|
|
15974
15848
|
);
|
|
15975
15849
|
pbTreeStyleOperation.from = toTreePos(treeStyleOperation.getFromPos());
|
|
15976
15850
|
pbTreeStyleOperation.to = toTreePos(treeStyleOperation.getToPos());
|
|
15977
|
-
const pbCreatedAtMapByActor = pbTreeStyleOperation.createdAtMapByActor;
|
|
15978
|
-
for (const [key, value] of treeStyleOperation.getMaxCreatedAtMapByActor()) {
|
|
15979
|
-
pbCreatedAtMapByActor[key] = toTimeTicket(value);
|
|
15980
|
-
}
|
|
15981
15851
|
const attributesToRemove = treeStyleOperation.getAttributesToRemove();
|
|
15982
15852
|
if (attributesToRemove.length > 0) {
|
|
15983
15853
|
pbTreeStyleOperation.attributesToRemove = attributesToRemove;
|
|
@@ -16215,8 +16085,7 @@ function toChangePack(pack) {
|
|
|
16215
16085
|
isRemoved: pack.getIsRemoved(),
|
|
16216
16086
|
changes: toChanges(pack.getChanges()),
|
|
16217
16087
|
snapshot: pack.getSnapshot(),
|
|
16218
|
-
versionVector: toVersionVector(pack.getVersionVector())
|
|
16219
|
-
minSyncedTicket: toTimeTicket(pack.getMinSyncedTicket())
|
|
16088
|
+
versionVector: toVersionVector(pack.getVersionVector())
|
|
16220
16089
|
});
|
|
16221
16090
|
}
|
|
16222
16091
|
function errorMetadataOf(error) {
|
|
@@ -16506,12 +16375,6 @@ function fromOperation(pbOperation) {
|
|
|
16506
16375
|
);
|
|
16507
16376
|
} else if (pbOperation.body.case === "edit") {
|
|
16508
16377
|
const pbEditOperation = pbOperation.body.value;
|
|
16509
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
16510
|
-
Object.entries(pbEditOperation.createdAtMapByActor).forEach(
|
|
16511
|
-
([key, value]) => {
|
|
16512
|
-
createdAtMapByActor.set(key, fromTimeTicket(value));
|
|
16513
|
-
}
|
|
16514
|
-
);
|
|
16515
16378
|
const attributes = /* @__PURE__ */ new Map();
|
|
16516
16379
|
Object.entries(pbEditOperation.attributes).forEach(([key, value]) => {
|
|
16517
16380
|
attributes.set(key, value);
|
|
@@ -16520,19 +16383,12 @@ function fromOperation(pbOperation) {
|
|
|
16520
16383
|
fromTimeTicket(pbEditOperation.parentCreatedAt),
|
|
16521
16384
|
fromTextNodePos(pbEditOperation.from),
|
|
16522
16385
|
fromTextNodePos(pbEditOperation.to),
|
|
16523
|
-
createdAtMapByActor,
|
|
16524
16386
|
pbEditOperation.content,
|
|
16525
16387
|
attributes,
|
|
16526
16388
|
fromTimeTicket(pbEditOperation.executedAt)
|
|
16527
16389
|
);
|
|
16528
16390
|
} else if (pbOperation.body.case === "style") {
|
|
16529
16391
|
const pbStyleOperation = pbOperation.body.value;
|
|
16530
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
16531
|
-
Object.entries(pbStyleOperation.createdAtMapByActor).forEach(
|
|
16532
|
-
([key, value]) => {
|
|
16533
|
-
createdAtMapByActor.set(key, fromTimeTicket(value));
|
|
16534
|
-
}
|
|
16535
|
-
);
|
|
16536
16392
|
const attributes = /* @__PURE__ */ new Map();
|
|
16537
16393
|
Object.entries(pbStyleOperation.attributes).forEach(([key, value]) => {
|
|
16538
16394
|
attributes.set(key, value);
|
|
@@ -16541,7 +16397,6 @@ function fromOperation(pbOperation) {
|
|
|
16541
16397
|
fromTimeTicket(pbStyleOperation.parentCreatedAt),
|
|
16542
16398
|
fromTextNodePos(pbStyleOperation.from),
|
|
16543
16399
|
fromTextNodePos(pbStyleOperation.to),
|
|
16544
|
-
createdAtMapByActor,
|
|
16545
16400
|
attributes,
|
|
16546
16401
|
fromTimeTicket(pbStyleOperation.executedAt)
|
|
16547
16402
|
);
|
|
@@ -16556,39 +16411,23 @@ function fromOperation(pbOperation) {
|
|
|
16556
16411
|
);
|
|
16557
16412
|
} else if (pbOperation.body.case === "treeEdit") {
|
|
16558
16413
|
const pbTreeEditOperation = pbOperation.body.value;
|
|
16559
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
16560
|
-
Object.entries(pbTreeEditOperation.createdAtMapByActor).forEach(
|
|
16561
|
-
([key, value]) => {
|
|
16562
|
-
createdAtMapByActor.set(key, fromTimeTicket(value));
|
|
16563
|
-
}
|
|
16564
|
-
);
|
|
16565
16414
|
return TreeEditOperation.create(
|
|
16566
16415
|
fromTimeTicket(pbTreeEditOperation.parentCreatedAt),
|
|
16567
16416
|
fromTreePos(pbTreeEditOperation.from),
|
|
16568
16417
|
fromTreePos(pbTreeEditOperation.to),
|
|
16569
16418
|
fromTreeNodesWhenEdit(pbTreeEditOperation.contents),
|
|
16570
16419
|
pbTreeEditOperation.splitLevel,
|
|
16571
|
-
createdAtMapByActor,
|
|
16572
16420
|
fromTimeTicket(pbTreeEditOperation.executedAt)
|
|
16573
16421
|
);
|
|
16574
16422
|
} else if (pbOperation.body.case === "treeStyle") {
|
|
16575
16423
|
const pbTreeStyleOperation = pbOperation.body.value;
|
|
16576
16424
|
const attributes = /* @__PURE__ */ new Map();
|
|
16577
16425
|
const attributesToRemove = pbTreeStyleOperation.attributesToRemove;
|
|
16578
|
-
const createdAtMapByActor = /* @__PURE__ */ new Map();
|
|
16579
|
-
if (pbTreeStyleOperation == null ? void 0 : pbTreeStyleOperation.createdAtMapByActor) {
|
|
16580
|
-
Object.entries(pbTreeStyleOperation.createdAtMapByActor).forEach(
|
|
16581
|
-
([key, value]) => {
|
|
16582
|
-
createdAtMapByActor.set(key, fromTimeTicket(value));
|
|
16583
|
-
}
|
|
16584
|
-
);
|
|
16585
|
-
}
|
|
16586
16426
|
if ((attributesToRemove == null ? void 0 : attributesToRemove.length) > 0) {
|
|
16587
16427
|
return TreeStyleOperation.createTreeRemoveStyleOperation(
|
|
16588
16428
|
fromTimeTicket(pbTreeStyleOperation.parentCreatedAt),
|
|
16589
16429
|
fromTreePos(pbTreeStyleOperation.from),
|
|
16590
16430
|
fromTreePos(pbTreeStyleOperation.to),
|
|
16591
|
-
createdAtMapByActor,
|
|
16592
16431
|
attributesToRemove,
|
|
16593
16432
|
fromTimeTicket(pbTreeStyleOperation.executedAt)
|
|
16594
16433
|
);
|
|
@@ -16602,7 +16441,6 @@ function fromOperation(pbOperation) {
|
|
|
16602
16441
|
fromTimeTicket(pbTreeStyleOperation.parentCreatedAt),
|
|
16603
16442
|
fromTreePos(pbTreeStyleOperation.from),
|
|
16604
16443
|
fromTreePos(pbTreeStyleOperation.to),
|
|
16605
|
-
createdAtMapByActor,
|
|
16606
16444
|
attributes,
|
|
16607
16445
|
fromTimeTicket(pbTreeStyleOperation.executedAt)
|
|
16608
16446
|
);
|
|
@@ -16645,8 +16483,7 @@ function fromChangePack(pbPack) {
|
|
|
16645
16483
|
pbPack.isRemoved,
|
|
16646
16484
|
fromChanges(pbPack.changes),
|
|
16647
16485
|
fromVersionVector(pbPack.versionVector),
|
|
16648
|
-
pbPack.snapshot
|
|
16649
|
-
fromTimeTicket(pbPack.minSyncedTicket)
|
|
16486
|
+
pbPack.snapshot
|
|
16650
16487
|
);
|
|
16651
16488
|
}
|
|
16652
16489
|
function fromObject(pbObject) {
|
|
@@ -18109,7 +17946,7 @@ class Text {
|
|
|
18109
17946
|
}
|
|
18110
17947
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18111
17948
|
const ticket = this.context.issueTimeTicket();
|
|
18112
|
-
const [
|
|
17949
|
+
const [, pairs, rangeAfterEdit] = this.text.edit(
|
|
18113
17950
|
range,
|
|
18114
17951
|
content,
|
|
18115
17952
|
ticket,
|
|
@@ -18123,7 +17960,6 @@ class Text {
|
|
|
18123
17960
|
this.text.getCreatedAt(),
|
|
18124
17961
|
range[0],
|
|
18125
17962
|
range[1],
|
|
18126
|
-
maxCreatedAtMapByActor,
|
|
18127
17963
|
content,
|
|
18128
17964
|
attrs ? new Map(Object.entries(attrs)) : /* @__PURE__ */ new Map(),
|
|
18129
17965
|
ticket
|
|
@@ -18169,11 +18005,7 @@ class Text {
|
|
|
18169
18005
|
}
|
|
18170
18006
|
const attrs = stringifyObjectValues(attributes);
|
|
18171
18007
|
const ticket = this.context.issueTimeTicket();
|
|
18172
|
-
const [
|
|
18173
|
-
range,
|
|
18174
|
-
attrs,
|
|
18175
|
-
ticket
|
|
18176
|
-
);
|
|
18008
|
+
const [pairs] = this.text.setStyle(range, attrs, ticket);
|
|
18177
18009
|
for (const pair of pairs) {
|
|
18178
18010
|
this.context.registerGCPair(pair);
|
|
18179
18011
|
}
|
|
@@ -18182,7 +18014,6 @@ class Text {
|
|
|
18182
18014
|
this.text.getCreatedAt(),
|
|
18183
18015
|
range[0],
|
|
18184
18016
|
range[1],
|
|
18185
|
-
maxCreatedAtMapByActor,
|
|
18186
18017
|
new Map(Object.entries(attrs)),
|
|
18187
18018
|
ticket
|
|
18188
18019
|
)
|
|
@@ -18717,17 +18548,15 @@ class Tree {
|
|
|
18717
18548
|
const [fromPos, toPos] = this.tree.pathToPosRange(path);
|
|
18718
18549
|
const ticket = this.context.issueTimeTicket();
|
|
18719
18550
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18720
|
-
const [
|
|
18721
|
-
|
|
18722
|
-
|
|
18723
|
-
|
|
18724
|
-
);
|
|
18551
|
+
const [pairs] = this.tree.style([fromPos, toPos], attrs, ticket);
|
|
18552
|
+
for (const pair of pairs) {
|
|
18553
|
+
this.context.registerGCPair(pair);
|
|
18554
|
+
}
|
|
18725
18555
|
this.context.push(
|
|
18726
18556
|
TreeStyleOperation.create(
|
|
18727
18557
|
this.tree.getCreatedAt(),
|
|
18728
18558
|
fromPos,
|
|
18729
18559
|
toPos,
|
|
18730
|
-
maxCreationMapByActor,
|
|
18731
18560
|
attrs ? new Map(Object.entries(attrs)) : /* @__PURE__ */ new Map(),
|
|
18732
18561
|
ticket
|
|
18733
18562
|
)
|
|
@@ -18753,11 +18582,7 @@ class Tree {
|
|
|
18753
18582
|
const toPos = this.tree.findPos(toIdx);
|
|
18754
18583
|
const ticket = this.context.issueTimeTicket();
|
|
18755
18584
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18756
|
-
const [
|
|
18757
|
-
[fromPos, toPos],
|
|
18758
|
-
attrs,
|
|
18759
|
-
ticket
|
|
18760
|
-
);
|
|
18585
|
+
const [pairs] = this.tree.style([fromPos, toPos], attrs, ticket);
|
|
18761
18586
|
for (const pair of pairs) {
|
|
18762
18587
|
this.context.registerGCPair(pair);
|
|
18763
18588
|
}
|
|
@@ -18766,7 +18591,6 @@ class Tree {
|
|
|
18766
18591
|
this.tree.getCreatedAt(),
|
|
18767
18592
|
fromPos,
|
|
18768
18593
|
toPos,
|
|
18769
|
-
maxCreationMapByActor,
|
|
18770
18594
|
attrs ? new Map(Object.entries(attrs)) : /* @__PURE__ */ new Map(),
|
|
18771
18595
|
ticket
|
|
18772
18596
|
)
|
|
@@ -18791,7 +18615,7 @@ class Tree {
|
|
|
18791
18615
|
const fromPos = this.tree.findPos(fromIdx);
|
|
18792
18616
|
const toPos = this.tree.findPos(toIdx);
|
|
18793
18617
|
const ticket = this.context.issueTimeTicket();
|
|
18794
|
-
const [
|
|
18618
|
+
const [pairs] = this.tree.removeStyle(
|
|
18795
18619
|
[fromPos, toPos],
|
|
18796
18620
|
attributesToRemove,
|
|
18797
18621
|
ticket
|
|
@@ -18804,7 +18628,6 @@ class Tree {
|
|
|
18804
18628
|
this.tree.getCreatedAt(),
|
|
18805
18629
|
fromPos,
|
|
18806
18630
|
toPos,
|
|
18807
|
-
maxCreationMapByActor,
|
|
18808
18631
|
attributesToRemove,
|
|
18809
18632
|
ticket
|
|
18810
18633
|
)
|
|
@@ -18839,7 +18662,7 @@ class Tree {
|
|
|
18839
18662
|
} else {
|
|
18840
18663
|
crdtNodes = contents.map((content) => content && createCRDTTreeNode(this.context, content)).filter((a) => a);
|
|
18841
18664
|
}
|
|
18842
|
-
const [, pairs
|
|
18665
|
+
const [, pairs] = this.tree.edit(
|
|
18843
18666
|
[fromPos, toPos],
|
|
18844
18667
|
crdtNodes.length ? crdtNodes.map((crdtNode) => crdtNode == null ? void 0 : crdtNode.deepcopy()) : void 0,
|
|
18845
18668
|
splitLevel,
|
|
@@ -18856,7 +18679,6 @@ class Tree {
|
|
|
18856
18679
|
toPos,
|
|
18857
18680
|
crdtNodes.length ? crdtNodes : void 0,
|
|
18858
18681
|
splitLevel,
|
|
18859
|
-
maxCreatedAtMapByActor,
|
|
18860
18682
|
ticket
|
|
18861
18683
|
)
|
|
18862
18684
|
);
|
|
@@ -20596,7 +20418,7 @@ function createAuthInterceptor(apiKey, token) {
|
|
|
20596
20418
|
};
|
|
20597
20419
|
}
|
|
20598
20420
|
const name = "@yorkie-js/sdk";
|
|
20599
|
-
const version = "0.6.
|
|
20421
|
+
const version = "0.6.10";
|
|
20600
20422
|
const pkg = {
|
|
20601
20423
|
name,
|
|
20602
20424
|
version
|