@yorkie-js/react 0.7.6 → 0.7.7

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.
@@ -11134,6 +11134,32 @@
11134
11134
  }
11135
11135
  actualRight.push(child);
11136
11136
  }
11137
+ if (versionVector) {
11138
+ const movedToLeft = [];
11139
+ const remaining = [];
11140
+ let boundaryReached = false;
11141
+ for (const child of actualRight) {
11142
+ if (!boundaryReached) {
11143
+ if (child.insPrevID !== void 0 && !child.isText) {
11144
+ remaining.push(child);
11145
+ continue;
11146
+ }
11147
+ const actorID = child.id.getCreatedAt().getActorID();
11148
+ const knownLamport = versionVector.get(actorID);
11149
+ if (knownLamport === void 0 || knownLamport < child.id.getCreatedAt().getLamport()) {
11150
+ movedToLeft.push(child);
11151
+ continue;
11152
+ }
11153
+ }
11154
+ boundaryReached = true;
11155
+ remaining.push(child);
11156
+ }
11157
+ if (movedToLeft.length > 0) {
11158
+ left.push(...movedToLeft);
11159
+ actualRight.length = 0;
11160
+ actualRight.push(...remaining);
11161
+ }
11162
+ }
11137
11163
  this._children = left;
11138
11164
  clone._children = actualRight;
11139
11165
  this.visibleSize = this._children.reduce(
@@ -11910,8 +11936,14 @@
11910
11936
  split.insPrevID = this.id;
11911
11937
  if (this.insNextID) {
11912
11938
  const insNext = tree.findFloorNode(this.insNextID);
11913
- insNext.insPrevID = split.id;
11914
11939
  split.insNextID = this.insNextID;
11940
+ if (insNext) {
11941
+ insNext.insPrevID = split.id;
11942
+ if (!this.isText && insNext.parent && !insNext.isRemoved && insNext.parent !== split.parent && split.allChildren.length === 0) {
11943
+ split.parent.detachChild(split);
11944
+ insNext.parent.insertBefore(split, insNext);
11945
+ }
11946
+ }
11915
11947
  }
11916
11948
  this.insNextID = split.id;
11917
11949
  tree.registerNode(split);
@@ -12135,7 +12167,7 @@
12135
12167
  * given node, advancing past element-type split siblings that the editing
12136
12168
  * client did not know about (not in versionVector).
12137
12169
  */
12138
- advancePastUnknownSplitSiblings(node, versionVector) {
12170
+ advancePastUnknownSplitSiblings(node, versionVector, relaxParentCheck = false, skipActorID) {
12139
12171
  if (!versionVector || !node) {
12140
12172
  return node;
12141
12173
  }
@@ -12145,10 +12177,13 @@
12145
12177
  if (!next || next.isText) {
12146
12178
  break;
12147
12179
  }
12148
- if (next.parent !== current.parent) {
12180
+ if (!relaxParentCheck && next.parent !== current.parent) {
12149
12181
  break;
12150
12182
  }
12151
12183
  const actorID = next.id.getCreatedAt().getActorID();
12184
+ if (skipActorID !== void 0 && actorID === skipActorID) {
12185
+ break;
12186
+ }
12152
12187
  const knownLamport = versionVector.get(actorID);
12153
12188
  if (knownLamport !== void 0 && knownLamport >= next.id.getCreatedAt().getLamport()) {
12154
12189
  break;
@@ -12489,6 +12524,23 @@
12489
12524
  addDataSizes(diff, diffTo, diffFrom);
12490
12525
  const fromLeft = fromLeftRaw !== fromParent ? this.advancePastUnknownSplitSiblings(fromLeftRaw, versionVector) : fromLeftRaw;
12491
12526
  const toLeft = toLeftRaw !== toParent ? this.advancePastUnknownSplitSiblings(toLeftRaw, versionVector) : toLeftRaw;
12527
+ let collectFromParent = fromParent;
12528
+ let collectFromLeft = fromLeft;
12529
+ if (fromLeft !== fromParent && fromParent !== toParent) {
12530
+ let current = fromLeft;
12531
+ while (current.insNextID) {
12532
+ const next = this.findFloorNode(current.insNextID);
12533
+ if (!next || next.isText) {
12534
+ break;
12535
+ }
12536
+ if (next.parent && next.parent === toParent) {
12537
+ collectFromLeft = next;
12538
+ collectFromParent = toParent;
12539
+ break;
12540
+ }
12541
+ current = next;
12542
+ }
12543
+ }
12492
12544
  const fromIdx = this.toIndex(fromParent, fromLeft);
12493
12545
  const fromPath = this.toPath(fromParent, fromLeft);
12494
12546
  const nodesToBeRemoved = [];
@@ -12497,8 +12549,8 @@
12497
12549
  const toBeMergedNodes = [];
12498
12550
  const preTombstoned = /* @__PURE__ */ new Set();
12499
12551
  this.traverseInPosRange(
12500
- fromParent,
12501
- fromLeft,
12552
+ collectFromParent,
12553
+ collectFromLeft,
12502
12554
  toParent,
12503
12555
  toLeft,
12504
12556
  ([node, tokenType], ended) => {
@@ -12602,9 +12654,20 @@
12602
12654
  let parent = fromParent;
12603
12655
  let left = fromLeft;
12604
12656
  while (splitCount < splitLevel) {
12657
+ if (left !== parent) {
12658
+ left = this.advancePastUnknownSplitSiblings(
12659
+ left,
12660
+ versionVector,
12661
+ true,
12662
+ editedAt.getActorID()
12663
+ );
12664
+ if (left.parent && left.parent !== parent) {
12665
+ parent = left.parent;
12666
+ }
12667
+ }
12605
12668
  parent.split(
12606
12669
  this,
12607
- parent.findOffset(left, true) + 1,
12670
+ left !== parent ? parent.findOffset(left, true) + 1 : 0,
12608
12671
  issueTimeTicket,
12609
12672
  versionVector
12610
12673
  );
@@ -13211,10 +13274,10 @@
13211
13274
  );
13212
13275
  this.lastToIdx = preEditFromIdx + removedSize;
13213
13276
  let reverseOp;
13214
- const isPureL1Split = this.splitLevel === 1 && !this.contents?.length && removedNodes.length === 0;
13277
+ const isPureSplit = this.splitLevel > 0 && !this.contents?.length && removedNodes.length === 0;
13215
13278
  if (this.splitLevel === 0) {
13216
13279
  reverseOp = this.toReverseOperation(tree, removedNodes, preEditFromIdx);
13217
- } else if (isPureL1Split) {
13280
+ } else if (isPureSplit) {
13218
13281
  reverseOp = this.toSplitReverseOperation(tree, preEditFromIdx);
13219
13282
  }
13220
13283
  root.acc(diff);
@@ -20810,7 +20873,7 @@
20810
20873
  };
20811
20874
  }
20812
20875
  const name$1 = "@yorkie-js/sdk";
20813
- const version$1 = "0.7.6";
20876
+ const version$1 = "0.7.7";
20814
20877
  const pkg$1 = {
20815
20878
  name: name$1,
20816
20879
  version: version$1
@@ -22516,8 +22579,11 @@
22516
22579
  function isCounter(value) {
22517
22580
  return typeof value === "object" && value !== null && value.type === "Counter" && typeof value.value === "object";
22518
22581
  }
22582
+ function isDedupCounter(value) {
22583
+ return typeof value === "object" && value !== null && value.type === "DedupCounter" && typeof value.value === "object" && typeof value.registers === "string";
22584
+ }
22519
22585
  function isObject(value) {
22520
- return typeof value === "object" && value !== null && !Array.isArray(value) && !isText(value) && !isTree(value) && !isInt(value) && !isLong(value) && !isDate(value) && !isBinData(value) && !isCounter(value);
22586
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !isText(value) && !isTree(value) && !isInt(value) && !isLong(value) && !isDate(value) && !isBinData(value) && !isCounter(value) && !isDedupCounter(value);
22521
22587
  }
22522
22588
  function parse(yson) {
22523
22589
  try {
@@ -22533,6 +22599,12 @@
22533
22599
  }
22534
22600
  function preprocessYSON(yson) {
22535
22601
  let result = yson;
22602
+ result = result.replace(
22603
+ /DedupCounter\(Int\((-?\d+)\),"([^"]+)"\)/g,
22604
+ (_, value, registers) => {
22605
+ return `{"__yson_type":"DedupCounter","__yson_data":{"__yson_type":"Int","__yson_data":${value}},"__yson_registers":"${registers}"}`;
22606
+ }
22607
+ );
22536
22608
  result = result.replace(
22537
22609
  /Counter\((Int|Long)\((-?\d+)\)\)/g,
22538
22610
  (_, type, value) => {
@@ -22593,6 +22665,20 @@
22593
22665
  value: value.__yson_data
22594
22666
  };
22595
22667
  }
22668
+ if (value.__yson_type === "DedupCounter" && typeof value.__yson_data === "object" && typeof value.__yson_registers === "string") {
22669
+ const counterValue = postprocessValue(value.__yson_data);
22670
+ if (typeof counterValue === "object" && counterValue !== null && "type" in counterValue && counterValue.type === "Int") {
22671
+ return {
22672
+ type: "DedupCounter",
22673
+ value: counterValue,
22674
+ registers: value.__yson_registers
22675
+ };
22676
+ }
22677
+ throw new YorkieError(
22678
+ Code.ErrInvalidArgument,
22679
+ "DedupCounter must contain Int"
22680
+ );
22681
+ }
22596
22682
  if (value.__yson_type === "Counter" && typeof value.__yson_data === "object") {
22597
22683
  const counterValue = postprocessValue(value.__yson_data);
22598
22684
  if (typeof counterValue === "object" && counterValue !== null && "type" in counterValue && (counterValue.type === "Int" || counterValue.type === "Long")) {
@@ -22681,6 +22767,7 @@
22681
22767
  isBinData,
22682
22768
  isCounter,
22683
22769
  isDate,
22770
+ isDedupCounter,
22684
22771
  isInt,
22685
22772
  isLong,
22686
22773
  isObject,
@@ -22707,7 +22794,7 @@
22707
22794
  };
22708
22795
  }
22709
22796
  const name = "@yorkie-js/react";
22710
- const version = "0.7.6";
22797
+ const version = "0.7.7";
22711
22798
  const pkg = {
22712
22799
  name,
22713
22800
  version