@yorkie-js/react 0.6.8 → 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.
@@ -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";
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, maxCreatedAtMapByActor, versionVector) {
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, maxCreatedAtMap, pairs, valueChanges] = this.rgaTreeSplit.edit(
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 [maxCreatedAtMap, changes, pairs, [caretPos, caretPos]];
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, maxCreatedAtMapByActor, versionVector) {
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 maxCreatedAt;
11186
- let clientLamportAtChange = 0n;
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, maxCreatedAt, clientLamportAtChange)) {
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 [createdAtMapByActor, pairs, changes];
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, maxCreatedAtMapByActor, content, attributes, executedAt) {
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, maxCreatedAtMapByActor, content, attributes, executedAt) {
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 [, changes, pairs] = text.edit(
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, maxCreatedAtMapByActor, attributes, executedAt) {
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, maxCreatedAtMapByActor, attributes, executedAt) {
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 [, pairs, changes] = text.setStyle(
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";
@@ -11730,6 +11705,18 @@ class IndexTreeNode {
11730
11705
  hasTextChild() {
11731
11706
  return this.children.length > 0 && this.children.every((child) => child.isText);
11732
11707
  }
11708
+ /**
11709
+ * `getChildrenText` returns text value of all text type children.
11710
+ */
11711
+ getChildrenText() {
11712
+ if (this.isText) {
11713
+ return this.value;
11714
+ }
11715
+ if (this.hasTextChild()) {
11716
+ return this.children.map((child) => child.value).join("");
11717
+ }
11718
+ return "";
11719
+ }
11733
11720
  /**
11734
11721
  * `append` appends the given nodes to the children.
11735
11722
  */
@@ -12851,18 +12838,18 @@ class CRDTTreeNode extends IndexTreeNode {
12851
12838
  /**
12852
12839
  * `canDelete` checks if node is able to delete.
12853
12840
  */
12854
- canDelete(editedAt, maxCreatedAt, clientLamportAtChange) {
12855
- const nodeExisted = maxCreatedAt ? !this.getCreatedAt().after(maxCreatedAt) : this.getCreatedAt().getLamport() <= clientLamportAtChange;
12841
+ canDelete(editedAt, clientLamportAtChange) {
12842
+ const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
12856
12843
  return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));
12857
12844
  }
12858
12845
  /**
12859
12846
  * `canStyle` checks if node is able to style.
12860
12847
  */
12861
- canStyle(editedAt, maxCreatedAt, clientLamportAtChange) {
12848
+ canStyle(editedAt, clientLamportAtChange) {
12862
12849
  if (this.isText) {
12863
12850
  return false;
12864
12851
  }
12865
- const nodeExisted = maxCreatedAt ? !this.getCreatedAt().after(maxCreatedAt) : this.getCreatedAt().getLamport() <= clientLamportAtChange;
12852
+ const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
12866
12853
  return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));
12867
12854
  }
12868
12855
  /**
@@ -12928,7 +12915,7 @@ class CRDTTreeNode extends IndexTreeNode {
12928
12915
  return pairs;
12929
12916
  }
12930
12917
  }
12931
- function toTreeNode(node) {
12918
+ function toTreeNode$1(node) {
12932
12919
  var _a2;
12933
12920
  if (node.isText) {
12934
12921
  const currentNode = node;
@@ -12939,7 +12926,7 @@ function toTreeNode(node) {
12939
12926
  }
12940
12927
  const treeNode = {
12941
12928
  type: node.type,
12942
- children: node.children.map(toTreeNode)
12929
+ children: node.children.map(toTreeNode$1)
12943
12930
  };
12944
12931
  if (node.attrs) {
12945
12932
  treeNode.attributes = parseObjectValues((_a2 = node.attrs) == null ? void 0 : _a2.toObject());
@@ -13051,7 +13038,7 @@ class CRDTTree extends CRDTElement {
13051
13038
  /**
13052
13039
  * `style` applies the given attributes of the given range.
13053
13040
  */
13054
- style(range, attributes, editedAt, maxCreatedAtMapByActor, versionVector) {
13041
+ style(range, attributes, editedAt, versionVector) {
13055
13042
  const [fromParent, fromLeft] = this.findNodesAndSplitText(
13056
13043
  range[0],
13057
13044
  editedAt
@@ -13059,7 +13046,6 @@ class CRDTTree extends CRDTElement {
13059
13046
  const [toParent, toLeft] = this.findNodesAndSplitText(range[1], editedAt);
13060
13047
  const changes = [];
13061
13048
  const attrs = attributes ? parseObjectValues(attributes) : {};
13062
- const createdAtMapByActor = /* @__PURE__ */ new Map();
13063
13049
  const pairs = [];
13064
13050
  this.traverseInPosRange(
13065
13051
  fromParent,
@@ -13068,21 +13054,11 @@ class CRDTTree extends CRDTElement {
13068
13054
  toLeft,
13069
13055
  ([node]) => {
13070
13056
  const actorID = node.getCreatedAt().getActorID();
13071
- let maxCreatedAt;
13072
- let clientLamportAtChange = 0n;
13073
- if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
13074
- clientLamportAtChange = MaxLamport;
13075
- } else if (versionVector.size() > 0) {
13057
+ let clientLamportAtChange = MaxLamport;
13058
+ if (versionVector != void 0) {
13076
13059
  clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
13077
- } else {
13078
- maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
13079
13060
  }
13080
- if (node.canStyle(editedAt, maxCreatedAt, clientLamportAtChange) && attributes) {
13081
- const maxCreatedAt2 = createdAtMapByActor.get(actorID);
13082
- const createdAt = node.getCreatedAt();
13083
- if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
13084
- createdAtMapByActor.set(actorID, createdAt);
13085
- }
13061
+ if (node.canStyle(editedAt, clientLamportAtChange) && attributes) {
13086
13062
  const updatedAttrPairs = node.setAttrs(attributes, editedAt);
13087
13063
  const affectedAttrs = updatedAttrPairs.reduce(
13088
13064
  (acc, [, curr]) => {
@@ -13115,19 +13091,18 @@ class CRDTTree extends CRDTElement {
13115
13091
  }
13116
13092
  }
13117
13093
  );
13118
- return [createdAtMapByActor, pairs, changes];
13094
+ return [pairs, changes];
13119
13095
  }
13120
13096
  /**
13121
13097
  * `removeStyle` removes the given attributes of the given range.
13122
13098
  */
13123
- removeStyle(range, attributesToRemove, editedAt, maxCreatedAtMapByActor, versionVector) {
13099
+ removeStyle(range, attributesToRemove, editedAt, versionVector) {
13124
13100
  const [fromParent, fromLeft] = this.findNodesAndSplitText(
13125
13101
  range[0],
13126
13102
  editedAt
13127
13103
  );
13128
13104
  const [toParent, toLeft] = this.findNodesAndSplitText(range[1], editedAt);
13129
13105
  const changes = [];
13130
- const createdAtMapByActor = /* @__PURE__ */ new Map();
13131
13106
  const pairs = [];
13132
13107
  this.traverseInPosRange(
13133
13108
  fromParent,
@@ -13136,21 +13111,11 @@ class CRDTTree extends CRDTElement {
13136
13111
  toLeft,
13137
13112
  ([node]) => {
13138
13113
  const actorID = node.getCreatedAt().getActorID();
13139
- let maxCreatedAt;
13140
- let clientLamportAtChange = 0n;
13141
- if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
13142
- clientLamportAtChange = MaxLamport;
13143
- } else if (versionVector.size() > 0) {
13114
+ let clientLamportAtChange = MaxLamport;
13115
+ if (versionVector != void 0) {
13144
13116
  clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
13145
- } else {
13146
- maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
13147
13117
  }
13148
- if (node.canStyle(editedAt, maxCreatedAt, clientLamportAtChange) && attributesToRemove) {
13149
- const maxCreatedAt2 = createdAtMapByActor.get(actorID);
13150
- const createdAt = node.getCreatedAt();
13151
- if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
13152
- createdAtMapByActor.set(actorID, createdAt);
13153
- }
13118
+ if (node.canStyle(editedAt, clientLamportAtChange) && attributesToRemove) {
13154
13119
  if (!node.attrs) {
13155
13120
  node.attrs = new RHT();
13156
13121
  }
@@ -13174,13 +13139,13 @@ class CRDTTree extends CRDTElement {
13174
13139
  }
13175
13140
  }
13176
13141
  );
13177
- return [createdAtMapByActor, pairs, changes];
13142
+ return [pairs, changes];
13178
13143
  }
13179
13144
  /**
13180
13145
  * `edit` edits the tree with the given range and content.
13181
13146
  * If the content is undefined, the range will be removed.
13182
13147
  */
13183
- edit(range, contents, splitLevel, editedAt, issueTimeTicket, maxCreatedAtMapByActor, versionVector) {
13148
+ edit(range, contents, splitLevel, editedAt, issueTimeTicket, versionVector) {
13184
13149
  const [fromParent, fromLeft] = this.findNodesAndSplitText(
13185
13150
  range[0],
13186
13151
  editedAt
@@ -13191,7 +13156,6 @@ class CRDTTree extends CRDTElement {
13191
13156
  const nodesToBeRemoved = [];
13192
13157
  const tokensToBeRemoved = [];
13193
13158
  const toBeMovedToFromParents = [];
13194
- const maxCreatedAtMap = /* @__PURE__ */ new Map();
13195
13159
  this.traverseInPosRange(
13196
13160
  fromParent,
13197
13161
  fromLeft,
@@ -13204,21 +13168,11 @@ class CRDTTree extends CRDTElement {
13204
13168
  }
13205
13169
  }
13206
13170
  const actorID = node.getCreatedAt().getActorID();
13207
- let maxCreatedAt;
13208
- let clientLamportAtChange = 0n;
13209
- if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
13210
- clientLamportAtChange = MaxLamport;
13211
- } else if (versionVector.size() > 0) {
13171
+ let clientLamportAtChange = MaxLamport;
13172
+ if (versionVector != void 0) {
13212
13173
  clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
13213
- } else {
13214
- maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
13215
13174
  }
13216
- if (node.canDelete(editedAt, maxCreatedAt, clientLamportAtChange) || nodesToBeRemoved.includes(node.parent)) {
13217
- const maxCreatedAt2 = maxCreatedAtMap.get(actorID);
13218
- const createdAt = node.getCreatedAt();
13219
- if (!maxCreatedAt2 || createdAt.after(maxCreatedAt2)) {
13220
- maxCreatedAtMap.set(actorID, createdAt);
13221
- }
13175
+ if (node.canDelete(editedAt, clientLamportAtChange) || nodesToBeRemoved.includes(node.parent)) {
13222
13176
  if (tokenType === TokenType.Text || tokenType === TokenType.Start) {
13223
13177
  nodesToBeRemoved.push(node);
13224
13178
  }
@@ -13283,7 +13237,7 @@ class CRDTTree extends CRDTElement {
13283
13237
  }
13284
13238
  }
13285
13239
  if (aliveContents.length) {
13286
- const value = aliveContents.map((content) => toTreeNode(content));
13240
+ const value = aliveContents.map((content) => toTreeNode$1(content));
13287
13241
  if (changes.length && changes[changes.length - 1].from === fromIdx) {
13288
13242
  changes[changes.length - 1].value = value;
13289
13243
  } else {
@@ -13299,7 +13253,7 @@ class CRDTTree extends CRDTElement {
13299
13253
  }
13300
13254
  }
13301
13255
  }
13302
- return [changes, pairs, maxCreatedAtMap];
13256
+ return [changes, pairs];
13303
13257
  }
13304
13258
  /**
13305
13259
  * `editT` edits the given range with the given value.
@@ -13325,6 +13279,12 @@ class CRDTTree extends CRDTElement {
13325
13279
  `not implemented: ${target}, ${source}, ${ticket}`
13326
13280
  );
13327
13281
  }
13282
+ /**
13283
+ * `pathToTreePos` converts the given path of the node to the TreePos.
13284
+ */
13285
+ pathToTreePos(path) {
13286
+ return this.indexTree.pathToTreePos(path);
13287
+ }
13328
13288
  /**
13329
13289
  * `purge` physically purges the given node.
13330
13290
  */
@@ -13494,7 +13454,7 @@ class CRDTTree extends CRDTElement {
13494
13454
  * `getRootTreeNode` returns the converted value of this tree to TreeNode.
13495
13455
  */
13496
13456
  getRootTreeNode() {
13497
- return toTreeNode(this.indexTree.getRoot());
13457
+ return toTreeNode$1(this.indexTree.getRoot());
13498
13458
  }
13499
13459
  /**
13500
13460
  * `toTestTreeNode` returns the JSON of this tree for debugging.
@@ -13732,30 +13692,27 @@ class CRDTTree extends CRDTElement {
13732
13692
  }
13733
13693
  }
13734
13694
  class TreeEditOperation extends Operation {
13735
- constructor(parentCreatedAt, fromPos, toPos, contents, splitLevel, maxCreatedAtMapByActor, executedAt) {
13695
+ constructor(parentCreatedAt, fromPos, toPos, contents, splitLevel, executedAt) {
13736
13696
  super(parentCreatedAt, executedAt);
13737
13697
  __publicField(this, "fromPos");
13738
13698
  __publicField(this, "toPos");
13739
13699
  __publicField(this, "contents");
13740
13700
  __publicField(this, "splitLevel");
13741
- __publicField(this, "maxCreatedAtMapByActor");
13742
13701
  this.fromPos = fromPos;
13743
13702
  this.toPos = toPos;
13744
13703
  this.contents = contents;
13745
13704
  this.splitLevel = splitLevel;
13746
- this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
13747
13705
  }
13748
13706
  /**
13749
13707
  * `create` creates a new instance of EditOperation.
13750
13708
  */
13751
- static create(parentCreatedAt, fromPos, toPos, contents, splitLevel, maxCreatedAtMapByActor, executedAt) {
13709
+ static create(parentCreatedAt, fromPos, toPos, contents, splitLevel, executedAt) {
13752
13710
  return new TreeEditOperation(
13753
13711
  parentCreatedAt,
13754
13712
  fromPos,
13755
13713
  toPos,
13756
13714
  contents,
13757
13715
  splitLevel,
13758
- maxCreatedAtMapByActor,
13759
13716
  executedAt
13760
13717
  );
13761
13718
  }
@@ -13803,7 +13760,6 @@ class TreeEditOperation extends Operation {
13803
13760
  );
13804
13761
  return issueTimeTicket;
13805
13762
  })(),
13806
- this.maxCreatedAtMapByActor,
13807
13763
  versionVector
13808
13764
  );
13809
13765
  for (const pair of pairs) {
@@ -13866,13 +13822,6 @@ class TreeEditOperation extends Operation {
13866
13822
  getSplitLevel() {
13867
13823
  return this.splitLevel;
13868
13824
  }
13869
- /**
13870
- * `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
13871
- * by actor for the nodes included in the editing range.
13872
- */
13873
- getMaxCreatedAtMapByActor() {
13874
- return this.maxCreatedAtMapByActor;
13875
- }
13876
13825
  }
13877
13826
  class VersionVector {
13878
13827
  constructor(vector) {
@@ -14016,12 +13965,7 @@ class ChangeID {
14016
13965
  */
14017
13966
  syncClocks(other) {
14018
13967
  const lamport = other.lamport > this.lamport ? other.lamport + 1n : this.lamport + 1n;
14019
- let otherVV = other.versionVector;
14020
- if (otherVV.size() === 0) {
14021
- otherVV = otherVV.deepcopy();
14022
- otherVV.set(other.actor, other.lamport);
14023
- }
14024
- const maxVersionVector = this.versionVector.max(otherVV);
13968
+ const maxVersionVector = this.versionVector.max(other.versionVector);
14025
13969
  const newID = new ChangeID(
14026
13970
  this.clientSeq,
14027
13971
  lamport,
@@ -14267,7 +14211,7 @@ class Change {
14267
14211
  }
14268
14212
  }
14269
14213
  class ChangePack {
14270
- constructor(key, checkpoint, isRemoved, changes, versionVector, snapshot, minSyncedTicket) {
14214
+ constructor(key, checkpoint, isRemoved, changes, versionVector, snapshot) {
14271
14215
  /**
14272
14216
  * `documentKey` is the key of the document.
14273
14217
  */
@@ -14285,12 +14229,6 @@ class ChangePack {
14285
14229
  * `snapshot` is a byte array that encodes the document.
14286
14230
  */
14287
14231
  __publicField(this, "snapshot");
14288
- /**
14289
- * `minSyncedTicket` is the minimum logical time taken by clients who attach
14290
- * to the document. It is used to collect garbage on the replica on the
14291
- * client.
14292
- */
14293
- __publicField(this, "minSyncedTicket");
14294
14232
  /**
14295
14233
  * `versionVector` is the version vector current document
14296
14234
  */
@@ -14300,21 +14238,19 @@ class ChangePack {
14300
14238
  this.isRemoved = isRemoved;
14301
14239
  this.changes = changes;
14302
14240
  this.snapshot = snapshot;
14303
- this.minSyncedTicket = minSyncedTicket;
14304
14241
  this.versionVector = versionVector;
14305
14242
  }
14306
14243
  /**
14307
14244
  * `create` creates a new instance of ChangePack.
14308
14245
  */
14309
- static create(key, checkpoint, isRemoved, changes, versionVector, snapshot, minSyncedTicket) {
14246
+ static create(key, checkpoint, isRemoved, changes, versionVector, snapshot) {
14310
14247
  return new ChangePack(
14311
14248
  key,
14312
14249
  checkpoint,
14313
14250
  isRemoved,
14314
14251
  changes,
14315
14252
  versionVector,
14316
- snapshot,
14317
- minSyncedTicket
14253
+ snapshot
14318
14254
  );
14319
14255
  }
14320
14256
  /**
@@ -14365,12 +14301,6 @@ class ChangePack {
14365
14301
  getSnapshot() {
14366
14302
  return this.snapshot;
14367
14303
  }
14368
- /**
14369
- * `getMinSyncedTicket` returns the minimum synced ticket of this pack.
14370
- */
14371
- getMinSyncedTicket() {
14372
- return this.minSyncedTicket;
14373
- }
14374
14304
  /**
14375
14305
  * `getVersionVector` returns the document's version vector of this pack
14376
14306
  */
@@ -14755,9 +14685,9 @@ class RGATreeSplitNode extends SplayNode {
14755
14685
  /**
14756
14686
  * `canDelete` checks if node is able to delete.
14757
14687
  */
14758
- canDelete(editedAt, maxCreatedAt, clientLamportAtChange) {
14688
+ canDelete(editedAt, clientLamportAtChange) {
14759
14689
  const justRemoved = !this.removedAt;
14760
- const nodeExisted = maxCreatedAt ? !this.getCreatedAt().after(maxCreatedAt) : this.getCreatedAt().getLamport() <= clientLamportAtChange;
14690
+ const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
14761
14691
  if (nodeExisted && (!this.removedAt || editedAt.after(this.removedAt))) {
14762
14692
  return justRemoved;
14763
14693
  }
@@ -14766,8 +14696,8 @@ class RGATreeSplitNode extends SplayNode {
14766
14696
  /**
14767
14697
  * `canStyle` checks if node is able to set style.
14768
14698
  */
14769
- canStyle(editedAt, maxCreatedAt, clientLamportAtChange) {
14770
- const nodeExisted = maxCreatedAt ? !this.getCreatedAt().after(maxCreatedAt) : this.getCreatedAt().getLamport() <= clientLamportAtChange;
14699
+ canStyle(editedAt, clientLamportAtChange) {
14700
+ const nodeExisted = this.getCreatedAt().getLamport() <= clientLamportAtChange;
14771
14701
  return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));
14772
14702
  }
14773
14703
  /**
@@ -14849,17 +14779,15 @@ class RGATreeSplit {
14849
14779
  * @param range - range of RGATreeSplitNode
14850
14780
  * @param editedAt - edited time
14851
14781
  * @param value - value
14852
- * @param maxCreatedAtMapByActor - maxCreatedAtMapByActor
14853
- * @returns `[RGATreeSplitPos, Map<string, TimeTicket>, Array<GCPair>, Array<Change>]`
14782
+ * @returns `[RGATreeSplitPos, Array<GCPair>, Array<Change>]`
14854
14783
  */
14855
- edit(range, editedAt, value, maxCreatedAtMapByActor, versionVector) {
14784
+ edit(range, editedAt, value, versionVector) {
14856
14785
  const [toLeft, toRight] = this.findNodeWithSplit(range[1], editedAt);
14857
14786
  const [fromLeft, fromRight] = this.findNodeWithSplit(range[0], editedAt);
14858
14787
  const nodesToDelete = this.findBetween(fromRight, toRight);
14859
- const [changes, maxCreatedAtMap, removedNodes] = this.deleteNodes(
14788
+ const [changes, removedNodes] = this.deleteNodes(
14860
14789
  nodesToDelete,
14861
14790
  editedAt,
14862
- maxCreatedAtMapByActor,
14863
14791
  versionVector
14864
14792
  );
14865
14793
  const caretID = toRight ? toRight.getID() : toLeft.getID();
@@ -14889,7 +14817,7 @@ class RGATreeSplit {
14889
14817
  for (const [, removedNode] of removedNodes) {
14890
14818
  pairs.push({ parent: this, child: removedNode });
14891
14819
  }
14892
- return [caretPos, maxCreatedAtMap, pairs, changes];
14820
+ return [caretPos, pairs, changes];
14893
14821
  }
14894
14822
  /**
14895
14823
  * `indexToPos` finds RGATreeSplitPos of given offset.
@@ -15094,47 +15022,36 @@ class RGATreeSplit {
15094
15022
  splitNode.setInsPrev(node);
15095
15023
  return splitNode;
15096
15024
  }
15097
- deleteNodes(candidates, editedAt, maxCreatedAtMapByActor, versionVector) {
15025
+ deleteNodes(candidates, editedAt, versionVector) {
15098
15026
  if (!candidates.length) {
15099
- return [[], /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
15027
+ return [[], /* @__PURE__ */ new Map()];
15100
15028
  }
15101
15029
  const [nodesToDelete, nodesToKeep] = this.filterNodes(
15102
15030
  candidates,
15103
15031
  editedAt,
15104
- maxCreatedAtMapByActor,
15105
15032
  versionVector
15106
15033
  );
15107
- const createdAtMapByActor = /* @__PURE__ */ new Map();
15108
15034
  const removedNodes = /* @__PURE__ */ new Map();
15109
15035
  const changes = this.makeChanges(nodesToKeep, editedAt);
15110
15036
  for (const node of nodesToDelete) {
15111
- const actorID = node.getCreatedAt().getActorID();
15112
- if (!createdAtMapByActor.has(actorID) || node.getID().getCreatedAt().after(createdAtMapByActor.get(actorID))) {
15113
- createdAtMapByActor.set(actorID, node.getID().getCreatedAt());
15114
- }
15115
15037
  removedNodes.set(node.getID().toIDString(), node);
15116
15038
  node.remove(editedAt);
15117
15039
  }
15118
15040
  this.deleteIndexNodes(nodesToKeep);
15119
- return [changes, createdAtMapByActor, removedNodes];
15041
+ return [changes, removedNodes];
15120
15042
  }
15121
- filterNodes(candidates, editedAt, maxCreatedAtMapByActor, versionVector) {
15043
+ filterNodes(candidates, editedAt, versionVector) {
15122
15044
  const nodesToDelete = [];
15123
15045
  const nodesToKeep = [];
15124
15046
  const [leftEdge, rightEdge] = this.findEdgesOfCandidates(candidates);
15125
15047
  nodesToKeep.push(leftEdge);
15126
15048
  for (const node of candidates) {
15127
15049
  const actorID = node.getCreatedAt().getActorID();
15128
- let maxCreatedAt;
15129
- let clientLamportAtChange = 0n;
15130
- if (versionVector === void 0 && maxCreatedAtMapByActor === void 0) {
15131
- clientLamportAtChange = MaxLamport;
15132
- } else if (versionVector.size() > 0) {
15050
+ let clientLamportAtChange = MaxLamport;
15051
+ if (versionVector != void 0) {
15133
15052
  clientLamportAtChange = versionVector.get(actorID) ? versionVector.get(actorID) : 0n;
15134
- } else {
15135
- maxCreatedAt = maxCreatedAtMapByActor.has(actorID) ? maxCreatedAtMapByActor.get(actorID) : InitialTimeTicket;
15136
15053
  }
15137
- if (node.canDelete(editedAt, maxCreatedAt, clientLamportAtChange)) {
15054
+ if (node.canDelete(editedAt, clientLamportAtChange)) {
15138
15055
  nodesToDelete.push(node);
15139
15056
  } else {
15140
15057
  nodesToKeep.push(node);
@@ -15515,28 +15432,25 @@ class IncreaseOperation extends Operation {
15515
15432
  }
15516
15433
  }
15517
15434
  class TreeStyleOperation extends Operation {
15518
- constructor(parentCreatedAt, fromPos, toPos, maxCreatedAtMapByActor, attributes, attributesToRemove, executedAt) {
15435
+ constructor(parentCreatedAt, fromPos, toPos, attributes, attributesToRemove, executedAt) {
15519
15436
  super(parentCreatedAt, executedAt);
15520
15437
  __publicField(this, "fromPos");
15521
15438
  __publicField(this, "toPos");
15522
- __publicField(this, "maxCreatedAtMapByActor");
15523
15439
  __publicField(this, "attributes");
15524
15440
  __publicField(this, "attributesToRemove");
15525
15441
  this.fromPos = fromPos;
15526
15442
  this.toPos = toPos;
15527
- this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
15528
15443
  this.attributes = attributes;
15529
15444
  this.attributesToRemove = attributesToRemove;
15530
15445
  }
15531
15446
  /**
15532
15447
  * `create` creates a new instance of TreeStyleOperation.
15533
15448
  */
15534
- static create(parentCreatedAt, fromPos, toPos, maxCreatedAtMapByActor, attributes, executedAt) {
15449
+ static create(parentCreatedAt, fromPos, toPos, attributes, executedAt) {
15535
15450
  return new TreeStyleOperation(
15536
15451
  parentCreatedAt,
15537
15452
  fromPos,
15538
15453
  toPos,
15539
- maxCreatedAtMapByActor,
15540
15454
  attributes,
15541
15455
  [],
15542
15456
  executedAt
@@ -15545,12 +15459,11 @@ class TreeStyleOperation extends Operation {
15545
15459
  /**
15546
15460
  * `createTreeRemoveStyleOperation` creates a new instance of TreeStyleOperation for style deletion.
15547
15461
  */
15548
- static createTreeRemoveStyleOperation(parentCreatedAt, fromPos, toPos, maxCreatedAtMapByActor, attributesToRemove, executedAt) {
15462
+ static createTreeRemoveStyleOperation(parentCreatedAt, fromPos, toPos, attributesToRemove, executedAt) {
15549
15463
  return new TreeStyleOperation(
15550
15464
  parentCreatedAt,
15551
15465
  fromPos,
15552
15466
  toPos,
15553
- maxCreatedAtMapByActor,
15554
15467
  /* @__PURE__ */ new Map(),
15555
15468
  attributesToRemove,
15556
15469
  executedAt
@@ -15579,20 +15492,18 @@ class TreeStyleOperation extends Operation {
15579
15492
  if (this.attributes.size) {
15580
15493
  const attributes = {};
15581
15494
  [...this.attributes].forEach(([key, value]) => attributes[key] = value);
15582
- [, pairs, changes] = tree.style(
15495
+ [pairs, changes] = tree.style(
15583
15496
  [this.fromPos, this.toPos],
15584
15497
  attributes,
15585
15498
  this.getExecutedAt(),
15586
- this.maxCreatedAtMapByActor,
15587
15499
  versionVector
15588
15500
  );
15589
15501
  } else {
15590
15502
  const attributesToRemove = this.attributesToRemove;
15591
- [, pairs, changes] = tree.removeStyle(
15503
+ [pairs, changes] = tree.removeStyle(
15592
15504
  [this.fromPos, this.toPos],
15593
15505
  attributesToRemove,
15594
15506
  this.getExecutedAt(),
15595
- this.maxCreatedAtMapByActor,
15596
15507
  versionVector
15597
15508
  );
15598
15509
  }
@@ -15654,13 +15565,6 @@ class TreeStyleOperation extends Operation {
15654
15565
  getAttributesToRemove() {
15655
15566
  return this.attributesToRemove;
15656
15567
  }
15657
- /**
15658
- * `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
15659
- * by actor for the nodes included in the styling range.
15660
- */
15661
- getMaxCreatedAtMapByActor() {
15662
- return this.maxCreatedAtMapByActor;
15663
- }
15664
15568
  }
15665
15569
  function toPresence(presence) {
15666
15570
  const pbPresence = new Presence$1();
@@ -15884,10 +15788,6 @@ function toOperation(operation) {
15884
15788
  );
15885
15789
  pbEditOperation.from = toTextNodePos(editOperation.getFromPos());
15886
15790
  pbEditOperation.to = toTextNodePos(editOperation.getToPos());
15887
- const pbCreatedAtMapByActor = pbEditOperation.createdAtMapByActor;
15888
- for (const [key, value] of editOperation.getMaxCreatedAtMapByActor()) {
15889
- pbCreatedAtMapByActor[key] = toTimeTicket(value);
15890
- }
15891
15791
  pbEditOperation.content = editOperation.getContent();
15892
15792
  const pbAttributes = pbEditOperation.attributes;
15893
15793
  for (const [key, value] of editOperation.getAttributes()) {
@@ -15904,10 +15804,6 @@ function toOperation(operation) {
15904
15804
  );
15905
15805
  pbStyleOperation.from = toTextNodePos(styleOperation.getFromPos());
15906
15806
  pbStyleOperation.to = toTextNodePos(styleOperation.getToPos());
15907
- const pbCreatedAtMapByActor = pbStyleOperation.createdAtMapByActor;
15908
- for (const [key, value] of styleOperation.getMaxCreatedAtMapByActor()) {
15909
- pbCreatedAtMapByActor[key] = toTimeTicket(value);
15910
- }
15911
15807
  const pbAttributes = pbStyleOperation.attributes;
15912
15808
  for (const [key, value] of styleOperation.getAttributes()) {
15913
15809
  pbAttributes[key] = value;
@@ -15930,10 +15826,6 @@ function toOperation(operation) {
15930
15826
  } else if (operation instanceof TreeEditOperation) {
15931
15827
  const treeEditOperation = operation;
15932
15828
  const pbTreeEditOperation = new Operation_TreeEdit();
15933
- const pbCreatedAtMapByActor = pbTreeEditOperation.createdAtMapByActor;
15934
- for (const [key, value] of treeEditOperation.getMaxCreatedAtMapByActor()) {
15935
- pbCreatedAtMapByActor[key] = toTimeTicket(value);
15936
- }
15937
15829
  pbTreeEditOperation.parentCreatedAt = toTimeTicket(
15938
15830
  treeEditOperation.getParentCreatedAt()
15939
15831
  );
@@ -15956,10 +15848,6 @@ function toOperation(operation) {
15956
15848
  );
15957
15849
  pbTreeStyleOperation.from = toTreePos(treeStyleOperation.getFromPos());
15958
15850
  pbTreeStyleOperation.to = toTreePos(treeStyleOperation.getToPos());
15959
- const pbCreatedAtMapByActor = pbTreeStyleOperation.createdAtMapByActor;
15960
- for (const [key, value] of treeStyleOperation.getMaxCreatedAtMapByActor()) {
15961
- pbCreatedAtMapByActor[key] = toTimeTicket(value);
15962
- }
15963
15851
  const attributesToRemove = treeStyleOperation.getAttributesToRemove();
15964
15852
  if (attributesToRemove.length > 0) {
15965
15853
  pbTreeStyleOperation.attributesToRemove = attributesToRemove;
@@ -16197,8 +16085,7 @@ function toChangePack(pack) {
16197
16085
  isRemoved: pack.getIsRemoved(),
16198
16086
  changes: toChanges(pack.getChanges()),
16199
16087
  snapshot: pack.getSnapshot(),
16200
- versionVector: toVersionVector(pack.getVersionVector()),
16201
- minSyncedTicket: toTimeTicket(pack.getMinSyncedTicket())
16088
+ versionVector: toVersionVector(pack.getVersionVector())
16202
16089
  });
16203
16090
  }
16204
16091
  function errorMetadataOf(error) {
@@ -16488,12 +16375,6 @@ function fromOperation(pbOperation) {
16488
16375
  );
16489
16376
  } else if (pbOperation.body.case === "edit") {
16490
16377
  const pbEditOperation = pbOperation.body.value;
16491
- const createdAtMapByActor = /* @__PURE__ */ new Map();
16492
- Object.entries(pbEditOperation.createdAtMapByActor).forEach(
16493
- ([key, value]) => {
16494
- createdAtMapByActor.set(key, fromTimeTicket(value));
16495
- }
16496
- );
16497
16378
  const attributes = /* @__PURE__ */ new Map();
16498
16379
  Object.entries(pbEditOperation.attributes).forEach(([key, value]) => {
16499
16380
  attributes.set(key, value);
@@ -16502,19 +16383,12 @@ function fromOperation(pbOperation) {
16502
16383
  fromTimeTicket(pbEditOperation.parentCreatedAt),
16503
16384
  fromTextNodePos(pbEditOperation.from),
16504
16385
  fromTextNodePos(pbEditOperation.to),
16505
- createdAtMapByActor,
16506
16386
  pbEditOperation.content,
16507
16387
  attributes,
16508
16388
  fromTimeTicket(pbEditOperation.executedAt)
16509
16389
  );
16510
16390
  } else if (pbOperation.body.case === "style") {
16511
16391
  const pbStyleOperation = pbOperation.body.value;
16512
- const createdAtMapByActor = /* @__PURE__ */ new Map();
16513
- Object.entries(pbStyleOperation.createdAtMapByActor).forEach(
16514
- ([key, value]) => {
16515
- createdAtMapByActor.set(key, fromTimeTicket(value));
16516
- }
16517
- );
16518
16392
  const attributes = /* @__PURE__ */ new Map();
16519
16393
  Object.entries(pbStyleOperation.attributes).forEach(([key, value]) => {
16520
16394
  attributes.set(key, value);
@@ -16523,7 +16397,6 @@ function fromOperation(pbOperation) {
16523
16397
  fromTimeTicket(pbStyleOperation.parentCreatedAt),
16524
16398
  fromTextNodePos(pbStyleOperation.from),
16525
16399
  fromTextNodePos(pbStyleOperation.to),
16526
- createdAtMapByActor,
16527
16400
  attributes,
16528
16401
  fromTimeTicket(pbStyleOperation.executedAt)
16529
16402
  );
@@ -16538,39 +16411,23 @@ function fromOperation(pbOperation) {
16538
16411
  );
16539
16412
  } else if (pbOperation.body.case === "treeEdit") {
16540
16413
  const pbTreeEditOperation = pbOperation.body.value;
16541
- const createdAtMapByActor = /* @__PURE__ */ new Map();
16542
- Object.entries(pbTreeEditOperation.createdAtMapByActor).forEach(
16543
- ([key, value]) => {
16544
- createdAtMapByActor.set(key, fromTimeTicket(value));
16545
- }
16546
- );
16547
16414
  return TreeEditOperation.create(
16548
16415
  fromTimeTicket(pbTreeEditOperation.parentCreatedAt),
16549
16416
  fromTreePos(pbTreeEditOperation.from),
16550
16417
  fromTreePos(pbTreeEditOperation.to),
16551
16418
  fromTreeNodesWhenEdit(pbTreeEditOperation.contents),
16552
16419
  pbTreeEditOperation.splitLevel,
16553
- createdAtMapByActor,
16554
16420
  fromTimeTicket(pbTreeEditOperation.executedAt)
16555
16421
  );
16556
16422
  } else if (pbOperation.body.case === "treeStyle") {
16557
16423
  const pbTreeStyleOperation = pbOperation.body.value;
16558
16424
  const attributes = /* @__PURE__ */ new Map();
16559
16425
  const attributesToRemove = pbTreeStyleOperation.attributesToRemove;
16560
- const createdAtMapByActor = /* @__PURE__ */ new Map();
16561
- if (pbTreeStyleOperation == null ? void 0 : pbTreeStyleOperation.createdAtMapByActor) {
16562
- Object.entries(pbTreeStyleOperation.createdAtMapByActor).forEach(
16563
- ([key, value]) => {
16564
- createdAtMapByActor.set(key, fromTimeTicket(value));
16565
- }
16566
- );
16567
- }
16568
16426
  if ((attributesToRemove == null ? void 0 : attributesToRemove.length) > 0) {
16569
16427
  return TreeStyleOperation.createTreeRemoveStyleOperation(
16570
16428
  fromTimeTicket(pbTreeStyleOperation.parentCreatedAt),
16571
16429
  fromTreePos(pbTreeStyleOperation.from),
16572
16430
  fromTreePos(pbTreeStyleOperation.to),
16573
- createdAtMapByActor,
16574
16431
  attributesToRemove,
16575
16432
  fromTimeTicket(pbTreeStyleOperation.executedAt)
16576
16433
  );
@@ -16584,7 +16441,6 @@ function fromOperation(pbOperation) {
16584
16441
  fromTimeTicket(pbTreeStyleOperation.parentCreatedAt),
16585
16442
  fromTreePos(pbTreeStyleOperation.from),
16586
16443
  fromTreePos(pbTreeStyleOperation.to),
16587
- createdAtMapByActor,
16588
16444
  attributes,
16589
16445
  fromTimeTicket(pbTreeStyleOperation.executedAt)
16590
16446
  );
@@ -16627,8 +16483,7 @@ function fromChangePack(pbPack) {
16627
16483
  pbPack.isRemoved,
16628
16484
  fromChanges(pbPack.changes),
16629
16485
  fromVersionVector(pbPack.versionVector),
16630
- pbPack.snapshot,
16631
- fromTimeTicket(pbPack.minSyncedTicket)
16486
+ pbPack.snapshot
16632
16487
  );
16633
16488
  }
16634
16489
  function fromObject(pbObject) {
@@ -18091,7 +17946,7 @@ class Text {
18091
17946
  }
18092
17947
  const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
18093
17948
  const ticket = this.context.issueTimeTicket();
18094
- const [maxCreatedAtMapByActor, , pairs, rangeAfterEdit] = this.text.edit(
17949
+ const [, pairs, rangeAfterEdit] = this.text.edit(
18095
17950
  range,
18096
17951
  content,
18097
17952
  ticket,
@@ -18105,7 +17960,6 @@ class Text {
18105
17960
  this.text.getCreatedAt(),
18106
17961
  range[0],
18107
17962
  range[1],
18108
- maxCreatedAtMapByActor,
18109
17963
  content,
18110
17964
  attrs ? new Map(Object.entries(attrs)) : /* @__PURE__ */ new Map(),
18111
17965
  ticket
@@ -18151,11 +18005,7 @@ class Text {
18151
18005
  }
18152
18006
  const attrs = stringifyObjectValues(attributes);
18153
18007
  const ticket = this.context.issueTimeTicket();
18154
- const [maxCreatedAtMapByActor, pairs] = this.text.setStyle(
18155
- range,
18156
- attrs,
18157
- ticket
18158
- );
18008
+ const [pairs] = this.text.setStyle(range, attrs, ticket);
18159
18009
  for (const pair of pairs) {
18160
18010
  this.context.registerGCPair(pair);
18161
18011
  }
@@ -18164,7 +18014,6 @@ class Text {
18164
18014
  this.text.getCreatedAt(),
18165
18015
  range[0],
18166
18016
  range[1],
18167
- maxCreatedAtMapByActor,
18168
18017
  new Map(Object.entries(attrs)),
18169
18018
  ticket
18170
18019
  )
@@ -18369,6 +18218,81 @@ class Counter {
18369
18218
  return this.counter.toJSForTest();
18370
18219
  }
18371
18220
  }
18221
+ function toTreeNode(node) {
18222
+ if (node.isText) {
18223
+ return {
18224
+ type: node.type,
18225
+ value: node.value
18226
+ };
18227
+ }
18228
+ const newNode = {
18229
+ type: node.type,
18230
+ children: node.children.map((child) => toTreeNode(child))
18231
+ };
18232
+ if (node.attrs) {
18233
+ newNode.attributes = parseObjectValues(node.attrs.toObject());
18234
+ }
18235
+ return newNode;
18236
+ }
18237
+ function createSplitNode(node, offset) {
18238
+ const newNode = {
18239
+ type: node.isText ? node.parent.type : node.type,
18240
+ children: node.isText ? node.parent.getChildrenText().length === offset ? [] : [
18241
+ {
18242
+ type: DefaultTextType,
18243
+ value: node.parent.getChildrenText().slice(offset)
18244
+ }
18245
+ ] : node.children.slice(offset).map((child) => toTreeNode(child))
18246
+ };
18247
+ if (node.attrs) {
18248
+ newNode.attributes = parseObjectValues(node.attrs.toObject());
18249
+ } else if (node.isText && node.parent.attrs) {
18250
+ newNode.attributes = parseObjectValues(node.parent.attrs.toObject());
18251
+ }
18252
+ return newNode;
18253
+ }
18254
+ function separateSplit(treePos, path) {
18255
+ const { node } = treePos;
18256
+ const parentPath = [...path].slice(0, -1);
18257
+ const last = node.isText ? node.parent.getChildrenText().length : node.children.length;
18258
+ const toPath = [...parentPath, last];
18259
+ const insertPath = [...parentPath];
18260
+ const res = [];
18261
+ insertPath[insertPath.length - 1] += 1;
18262
+ if (!path.every((v, i) => v === toPath[i])) {
18263
+ res.push({ fromPath: [...path], toPath });
18264
+ }
18265
+ const newNode = createSplitNode(node, path[path.length - 1]);
18266
+ if (newNode) {
18267
+ res.push({ fromPath: insertPath, toPath: insertPath, content: newNode });
18268
+ }
18269
+ return res;
18270
+ }
18271
+ function separateMerge(treePos, path) {
18272
+ const { node: parentNode, offset } = treePos;
18273
+ const node = parentNode.children[offset];
18274
+ const leftSiblingNode = parentNode.children[offset - 1];
18275
+ const { children } = node;
18276
+ const parentPath = [...path].slice(0, -1);
18277
+ const res = [
18278
+ { fromPath: [...path], toPath: [...parentPath, offset + 1] }
18279
+ ];
18280
+ if (!node.children.length) {
18281
+ return res;
18282
+ }
18283
+ const insertPath = [
18284
+ ...parentPath,
18285
+ offset - 1,
18286
+ leftSiblingNode.hasTextChild() ? leftSiblingNode.getChildrenText().length : leftSiblingNode.children.length
18287
+ ];
18288
+ const nodes = children.map((child) => toTreeNode(child));
18289
+ res.push({
18290
+ fromPath: insertPath,
18291
+ toPath: insertPath,
18292
+ content: nodes
18293
+ });
18294
+ return res;
18295
+ }
18372
18296
  function buildDescendants(treeNode, parent, context) {
18373
18297
  const { type } = treeNode;
18374
18298
  const ticket = context.issueTimeTicket();
@@ -18549,6 +18473,62 @@ class Tree {
18549
18473
  }
18550
18474
  return this.tree.getIndexTree();
18551
18475
  }
18476
+ /**
18477
+ * `splitByPath` splits the tree by the given path.
18478
+ */
18479
+ splitByPath(path) {
18480
+ if (!this.context || !this.tree) {
18481
+ throw new YorkieError(
18482
+ Code.ErrNotInitialized,
18483
+ "Tree is not initialized yet"
18484
+ );
18485
+ }
18486
+ if (!path.length) {
18487
+ throw new YorkieError(
18488
+ Code.ErrInvalidArgument,
18489
+ "path should not be empty"
18490
+ );
18491
+ }
18492
+ const treePos = this.tree.pathToTreePos(path);
18493
+ const commands = separateSplit(treePos, path);
18494
+ for (const command of commands) {
18495
+ const { fromPath, toPath, content } = command;
18496
+ const fromPos = this.tree.pathToPos(fromPath);
18497
+ const toPos = this.tree.pathToPos(toPath);
18498
+ this.editInternal(fromPos, toPos, content ? [content] : [], 0);
18499
+ }
18500
+ }
18501
+ /**
18502
+ * `mergeByPath` merges the tree by the given path.
18503
+ */
18504
+ mergeByPath(path) {
18505
+ if (!this.context || !this.tree) {
18506
+ throw new YorkieError(
18507
+ Code.ErrNotInitialized,
18508
+ "Tree is not initialized yet"
18509
+ );
18510
+ }
18511
+ if (!path.length) {
18512
+ throw new YorkieError(
18513
+ Code.ErrInvalidArgument,
18514
+ "path should not be empty"
18515
+ );
18516
+ }
18517
+ const treePos = this.tree.pathToTreePos(path);
18518
+ if (treePos.node.isText) {
18519
+ throw new YorkieError(
18520
+ Code.ErrInvalidArgument,
18521
+ "text node cannot be merged"
18522
+ );
18523
+ }
18524
+ const commands = separateMerge(treePos, path);
18525
+ for (const command of commands) {
18526
+ const { fromPath, toPath, content } = command;
18527
+ const fromPos = this.tree.pathToPos(fromPath);
18528
+ const toPos = this.tree.pathToPos(toPath);
18529
+ this.editInternal(fromPos, toPos, content ?? [], 0);
18530
+ }
18531
+ }
18552
18532
  /**
18553
18533
  * `styleByPath` sets the attributes to the elements of the given path.
18554
18534
  */
@@ -18568,17 +18548,15 @@ class Tree {
18568
18548
  const [fromPos, toPos] = this.tree.pathToPosRange(path);
18569
18549
  const ticket = this.context.issueTimeTicket();
18570
18550
  const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
18571
- const [maxCreationMapByActor] = this.tree.style(
18572
- [fromPos, toPos],
18573
- attrs,
18574
- ticket
18575
- );
18551
+ const [pairs] = this.tree.style([fromPos, toPos], attrs, ticket);
18552
+ for (const pair of pairs) {
18553
+ this.context.registerGCPair(pair);
18554
+ }
18576
18555
  this.context.push(
18577
18556
  TreeStyleOperation.create(
18578
18557
  this.tree.getCreatedAt(),
18579
18558
  fromPos,
18580
18559
  toPos,
18581
- maxCreationMapByActor,
18582
18560
  attrs ? new Map(Object.entries(attrs)) : /* @__PURE__ */ new Map(),
18583
18561
  ticket
18584
18562
  )
@@ -18604,11 +18582,7 @@ class Tree {
18604
18582
  const toPos = this.tree.findPos(toIdx);
18605
18583
  const ticket = this.context.issueTimeTicket();
18606
18584
  const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
18607
- const [maxCreationMapByActor, pairs] = this.tree.style(
18608
- [fromPos, toPos],
18609
- attrs,
18610
- ticket
18611
- );
18585
+ const [pairs] = this.tree.style([fromPos, toPos], attrs, ticket);
18612
18586
  for (const pair of pairs) {
18613
18587
  this.context.registerGCPair(pair);
18614
18588
  }
@@ -18617,7 +18591,6 @@ class Tree {
18617
18591
  this.tree.getCreatedAt(),
18618
18592
  fromPos,
18619
18593
  toPos,
18620
- maxCreationMapByActor,
18621
18594
  attrs ? new Map(Object.entries(attrs)) : /* @__PURE__ */ new Map(),
18622
18595
  ticket
18623
18596
  )
@@ -18642,7 +18615,7 @@ class Tree {
18642
18615
  const fromPos = this.tree.findPos(fromIdx);
18643
18616
  const toPos = this.tree.findPos(toIdx);
18644
18617
  const ticket = this.context.issueTimeTicket();
18645
- const [maxCreationMapByActor, pairs] = this.tree.removeStyle(
18618
+ const [pairs] = this.tree.removeStyle(
18646
18619
  [fromPos, toPos],
18647
18620
  attributesToRemove,
18648
18621
  ticket
@@ -18655,7 +18628,6 @@ class Tree {
18655
18628
  this.tree.getCreatedAt(),
18656
18629
  fromPos,
18657
18630
  toPos,
18658
- maxCreationMapByActor,
18659
18631
  attributesToRemove,
18660
18632
  ticket
18661
18633
  )
@@ -18690,7 +18662,7 @@ class Tree {
18690
18662
  } else {
18691
18663
  crdtNodes = contents.map((content) => content && createCRDTTreeNode(this.context, content)).filter((a) => a);
18692
18664
  }
18693
- const [, pairs, maxCreatedAtMapByActor] = this.tree.edit(
18665
+ const [, pairs] = this.tree.edit(
18694
18666
  [fromPos, toPos],
18695
18667
  crdtNodes.length ? crdtNodes.map((crdtNode) => crdtNode == null ? void 0 : crdtNode.deepcopy()) : void 0,
18696
18668
  splitLevel,
@@ -18707,7 +18679,6 @@ class Tree {
18707
18679
  toPos,
18708
18680
  crdtNodes.length ? crdtNodes : void 0,
18709
18681
  splitLevel,
18710
- maxCreatedAtMapByActor,
18711
18682
  ticket
18712
18683
  )
18713
18684
  );
@@ -20447,7 +20418,7 @@ function createAuthInterceptor(apiKey, token) {
20447
20418
  };
20448
20419
  }
20449
20420
  const name = "@yorkie-js/sdk";
20450
- const version = "0.6.8";
20421
+ const version = "0.6.10";
20451
20422
  const pkg = {
20452
20423
  name,
20453
20424
  version