@yorkie-js/react 0.6.18 → 0.6.21

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.
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7
7
 
8
8
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
9
9
  const name$1 = "@yorkie-js/react";
10
- const version$1 = "0.6.18";
10
+ const version$1 = "0.6.21";
11
11
  const pkg$1 = {
12
12
  name: name$1,
13
13
  version: version$1
@@ -10657,8 +10657,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
10657
10657
  /**
10658
10658
  * `insertAfter` adds a new node after the the given node.
10659
10659
  */
10660
- insertAfter(prevCreatedAt, value) {
10661
- this.elements.insertAfter(prevCreatedAt, value);
10660
+ insertAfter(prevCreatedAt, value, executedAt) {
10661
+ this.elements.insertAfter(prevCreatedAt, value, executedAt);
10662
10662
  }
10663
10663
  /**
10664
10664
  * `moveAfter` moves the given `createdAt` element after the `prevCreatedAt`.
@@ -10826,6 +10826,84 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
10826
10826
  return clone;
10827
10827
  }
10828
10828
  }
10829
+ class AddOperation extends Operation {
10830
+ constructor(parentCreatedAt, prevCreatedAt, value, executedAt) {
10831
+ super(parentCreatedAt, executedAt);
10832
+ __publicField(this, "prevCreatedAt");
10833
+ __publicField(this, "value");
10834
+ this.prevCreatedAt = prevCreatedAt;
10835
+ this.value = value;
10836
+ }
10837
+ /**
10838
+ * `create` creates a new instance of AddOperation.
10839
+ */
10840
+ static create(parentCreatedAt, prevCreatedAt, value, executedAt) {
10841
+ return new AddOperation(parentCreatedAt, prevCreatedAt, value, executedAt);
10842
+ }
10843
+ /**
10844
+ * `execute` executes this operation on the given `CRDTRoot`.
10845
+ */
10846
+ execute(root) {
10847
+ const parentObject = root.findByCreatedAt(this.getParentCreatedAt());
10848
+ if (!parentObject) {
10849
+ throw new YorkieError(
10850
+ Code.ErrInvalidArgument,
10851
+ `fail to find ${this.getParentCreatedAt()}`
10852
+ );
10853
+ }
10854
+ if (!(parentObject instanceof CRDTArray)) {
10855
+ throw new YorkieError(
10856
+ Code.ErrInvalidArgument,
10857
+ `fail to execute, only array can execute add`
10858
+ );
10859
+ }
10860
+ const array = parentObject;
10861
+ const value = this.value.deepcopy();
10862
+ array.insertAfter(this.prevCreatedAt, value, this.getExecutedAt());
10863
+ root.registerElement(value, array);
10864
+ return {
10865
+ opInfos: [
10866
+ {
10867
+ type: "add",
10868
+ path: root.createPath(this.getParentCreatedAt()),
10869
+ index: Number(array.subPathOf(this.getEffectedCreatedAt()))
10870
+ }
10871
+ ],
10872
+ reverseOp: this.toReverseOperation()
10873
+ };
10874
+ }
10875
+ toReverseOperation() {
10876
+ const reverseOp = RemoveOperation.create(
10877
+ this.getParentCreatedAt(),
10878
+ this.value.getCreatedAt()
10879
+ );
10880
+ return reverseOp;
10881
+ }
10882
+ /**
10883
+ * `getEffectedCreatedAt` returns the creation time of the effected element.
10884
+ */
10885
+ getEffectedCreatedAt() {
10886
+ return this.value.getCreatedAt();
10887
+ }
10888
+ /**
10889
+ * `toTestString` returns a string containing the meta data.
10890
+ */
10891
+ toTestString() {
10892
+ return `${this.getParentCreatedAt().toTestString()}.ADD.${this.value.toJSON()}`;
10893
+ }
10894
+ /**
10895
+ * `getPrevCreatedAt` returns the creation time of previous element.
10896
+ */
10897
+ getPrevCreatedAt() {
10898
+ return this.prevCreatedAt;
10899
+ }
10900
+ /**
10901
+ * `getValue` returns the value of this operation.
10902
+ */
10903
+ getValue() {
10904
+ return this.value;
10905
+ }
10906
+ }
10829
10907
  class RemoveOperation extends Operation {
10830
10908
  constructor(parentCreatedAt, createdAt, executedAt) {
10831
10909
  super(parentCreatedAt, executedAt);
@@ -10890,6 +10968,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
10890
10968
  * `toReverseOperation` returns the reverse operation of this operation.
10891
10969
  */
10892
10970
  toReverseOperation(parentObject) {
10971
+ if (parentObject instanceof CRDTArray) {
10972
+ const value = parentObject.getByID(this.createdAt);
10973
+ if (value !== void 0) {
10974
+ const prevCreatedAt = parentObject.getPrevCreatedAt(
10975
+ this.createdAt
10976
+ );
10977
+ return AddOperation.create(
10978
+ this.getParentCreatedAt(),
10979
+ prevCreatedAt,
10980
+ value.deepcopy()
10981
+ );
10982
+ }
10983
+ }
10893
10984
  if (parentObject instanceof CRDTObject) {
10894
10985
  const key = parentObject.subPathOf(this.createdAt);
10895
10986
  if (key !== void 0) {
@@ -11028,76 +11119,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
11028
11119
  return this.value;
11029
11120
  }
11030
11121
  }
11031
- class AddOperation extends Operation {
11032
- constructor(parentCreatedAt, prevCreatedAt, value, executedAt) {
11033
- super(parentCreatedAt, executedAt);
11034
- __publicField(this, "prevCreatedAt");
11035
- __publicField(this, "value");
11036
- this.prevCreatedAt = prevCreatedAt;
11037
- this.value = value;
11038
- }
11039
- /**
11040
- * `create` creates a new instance of AddOperation.
11041
- */
11042
- static create(parentCreatedAt, prevCreatedAt, value, executedAt) {
11043
- return new AddOperation(parentCreatedAt, prevCreatedAt, value, executedAt);
11044
- }
11045
- /**
11046
- * `execute` executes this operation on the given `CRDTRoot`.
11047
- */
11048
- execute(root) {
11049
- const parentObject = root.findByCreatedAt(this.getParentCreatedAt());
11050
- if (!parentObject) {
11051
- throw new YorkieError(
11052
- Code.ErrInvalidArgument,
11053
- `fail to find ${this.getParentCreatedAt()}`
11054
- );
11055
- }
11056
- if (!(parentObject instanceof CRDTArray)) {
11057
- throw new YorkieError(
11058
- Code.ErrInvalidArgument,
11059
- `fail to execute, only array can execute add`
11060
- );
11061
- }
11062
- const array = parentObject;
11063
- const value = this.value.deepcopy();
11064
- array.insertAfter(this.prevCreatedAt, value);
11065
- root.registerElement(value, array);
11066
- return {
11067
- opInfos: [
11068
- {
11069
- type: "add",
11070
- path: root.createPath(this.getParentCreatedAt()),
11071
- index: Number(array.subPathOf(this.getEffectedCreatedAt()))
11072
- }
11073
- ]
11074
- };
11075
- }
11076
- /**
11077
- * `getEffectedCreatedAt` returns the creation time of the effected element.
11078
- */
11079
- getEffectedCreatedAt() {
11080
- return this.value.getCreatedAt();
11081
- }
11082
- /**
11083
- * `toTestString` returns a string containing the meta data.
11084
- */
11085
- toTestString() {
11086
- return `${this.getParentCreatedAt().toTestString()}.ADD.${this.value.toJSON()}`;
11087
- }
11088
- /**
11089
- * `getPrevCreatedAt` returns the creation time of previous element.
11090
- */
11091
- getPrevCreatedAt() {
11092
- return this.prevCreatedAt;
11093
- }
11094
- /**
11095
- * `getValue` returns the value of this operation.
11096
- */
11097
- getValue() {
11098
- return this.value;
11099
- }
11100
- }
11101
11122
  class MoveOperation extends Operation {
11102
11123
  constructor(parentCreatedAt, prevCreatedAt, createdAt, executedAt) {
11103
11124
  super(parentCreatedAt, executedAt);
@@ -11135,6 +11156,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
11135
11156
  );
11136
11157
  }
11137
11158
  const array = parentObject;
11159
+ const reverseOp = this.toReverseOperation(array);
11138
11160
  const previousIndex = Number(array.subPathOf(this.createdAt));
11139
11161
  array.moveAfter(this.prevCreatedAt, this.createdAt, this.getExecutedAt());
11140
11162
  const index = Number(array.subPathOf(this.createdAt));
@@ -11146,9 +11168,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
11146
11168
  index,
11147
11169
  previousIndex
11148
11170
  }
11149
- ]
11171
+ ],
11172
+ reverseOp
11150
11173
  };
11151
11174
  }
11175
+ toReverseOperation(array) {
11176
+ const preservePrevCreatedAt = array.getPrevCreatedAt(this.createdAt);
11177
+ return MoveOperation.create(
11178
+ this.getParentCreatedAt(),
11179
+ preservePrevCreatedAt,
11180
+ this.createdAt
11181
+ );
11182
+ }
11152
11183
  /**
11153
11184
  * `getEffectedCreatedAt` returns the creation time of the effected element.
11154
11185
  */
@@ -21235,7 +21266,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
21235
21266
  };
21236
21267
  }
21237
21268
  const name = "@yorkie-js/sdk";
21238
- const version = "0.6.18";
21269
+ const version = "0.6.21";
21239
21270
  const pkg = {
21240
21271
  name,
21241
21272
  version