@yorkie-js/react 0.7.1 → 0.7.3

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.
@@ -5499,6 +5499,7 @@
5499
5499
  Code2["ErrUnauthenticated"] = "ErrUnauthenticated";
5500
5500
  Code2["ErrTooManySubscribers"] = "ErrTooManySubscribers";
5501
5501
  Code2["ErrTooManyAttachments"] = "ErrTooManyAttachments";
5502
+ Code2["ErrEpochMismatch"] = "ErrEpochMismatch";
5502
5503
  return Code2;
5503
5504
  })(Code || {});
5504
5505
  class YorkieError extends Error {
@@ -5830,6 +5831,8 @@
5830
5831
  if (!node || executedAt.after(node.getValue().getPositionedAt())) {
5831
5832
  this.nodeMapByKey.set(key, newNode);
5832
5833
  value.setMovedAt(executedAt);
5834
+ } else if (!node.isRemoved()) {
5835
+ value.remove(node.getValue().getPositionedAt());
5833
5836
  }
5834
5837
  return removed;
5835
5838
  }
@@ -17219,22 +17222,49 @@
17219
17222
  }
17220
17223
  }
17221
17224
  /**
17222
- * `styleByPath` sets the attributes to the elements of the given path.
17225
+ * `styleByPath` sets the attributes to the elements of the given
17226
+ * path. When called with two paths, it styles the range between
17227
+ * them.
17223
17228
  */
17224
- styleByPath(path, attributes) {
17229
+ styleByPath(fromPathOrPath, toPathOrAttrs, maybeAttrs) {
17225
17230
  if (!this.context || !this.tree) {
17226
17231
  throw new YorkieError(
17227
17232
  Code.ErrNotInitialized,
17228
17233
  "Tree is not initialized yet"
17229
17234
  );
17230
17235
  }
17231
- if (!path.length) {
17232
- throw new YorkieError(
17233
- Code.ErrInvalidArgument,
17234
- "path should not be empty"
17235
- );
17236
+ let fromPos;
17237
+ let toPos;
17238
+ let attributes;
17239
+ if (Array.isArray(toPathOrAttrs)) {
17240
+ const fromPath = fromPathOrPath;
17241
+ const toPath = toPathOrAttrs;
17242
+ attributes = maybeAttrs;
17243
+ if (fromPath.length !== toPath.length) {
17244
+ throw new YorkieError(
17245
+ Code.ErrInvalidArgument,
17246
+ "path length should be equal"
17247
+ );
17248
+ }
17249
+ if (!fromPath.length || !toPath.length) {
17250
+ throw new YorkieError(
17251
+ Code.ErrInvalidArgument,
17252
+ "path should not be empty"
17253
+ );
17254
+ }
17255
+ fromPos = this.tree.pathToPos(fromPath);
17256
+ toPos = this.tree.pathToPos(toPath);
17257
+ } else {
17258
+ const path = fromPathOrPath;
17259
+ attributes = toPathOrAttrs;
17260
+ if (!path.length) {
17261
+ throw new YorkieError(
17262
+ Code.ErrInvalidArgument,
17263
+ "path should not be empty"
17264
+ );
17265
+ }
17266
+ [fromPos, toPos] = this.tree.pathToPosRange(path);
17236
17267
  }
17237
- const [fromPos, toPos] = this.tree.pathToPosRange(path);
17238
17268
  const ticket = this.context.issueTimeTicket();
17239
17269
  const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
17240
17270
  const [pairs, , diff] = this.tree.style([fromPos, toPos], attrs, ticket);
@@ -17325,6 +17355,51 @@
17325
17355
  )
17326
17356
  );
17327
17357
  }
17358
+ /**
17359
+ * `removeStyleByPath` removes the attributes of the elements in
17360
+ * the given path range.
17361
+ */
17362
+ removeStyleByPath(fromPath, toPath, attributesToRemove) {
17363
+ if (!this.context || !this.tree) {
17364
+ throw new YorkieError(
17365
+ Code.ErrNotInitialized,
17366
+ "Tree is not initialized yet"
17367
+ );
17368
+ }
17369
+ if (fromPath.length !== toPath.length) {
17370
+ throw new YorkieError(
17371
+ Code.ErrInvalidArgument,
17372
+ "path length should be equal"
17373
+ );
17374
+ }
17375
+ if (!fromPath.length || !toPath.length) {
17376
+ throw new YorkieError(
17377
+ Code.ErrInvalidArgument,
17378
+ "path should not be empty"
17379
+ );
17380
+ }
17381
+ const fromPos = this.tree.pathToPos(fromPath);
17382
+ const toPos = this.tree.pathToPos(toPath);
17383
+ const ticket = this.context.issueTimeTicket();
17384
+ const [pairs, , diff] = this.tree.removeStyle(
17385
+ [fromPos, toPos],
17386
+ attributesToRemove,
17387
+ ticket
17388
+ );
17389
+ this.context.acc(diff);
17390
+ for (const pair of pairs) {
17391
+ this.context.registerGCPair(pair);
17392
+ }
17393
+ this.context.push(
17394
+ TreeStyleOperation.createTreeRemoveStyleOperation(
17395
+ this.tree.getCreatedAt(),
17396
+ fromPos,
17397
+ toPos,
17398
+ attributesToRemove,
17399
+ ticket
17400
+ )
17401
+ );
17402
+ }
17328
17403
  editInternal(fromPos, toPos, contents, splitLevel = 0) {
17329
17404
  if (contents.length !== 0 && contents[0]) {
17330
17405
  validateTreeNodes(contents);
@@ -18704,6 +18779,7 @@
18704
18779
  DocEventType2["Unwatched"] = "unwatched";
18705
18780
  DocEventType2["PresenceChanged"] = "presence-changed";
18706
18781
  DocEventType2["AuthError"] = "auth-error";
18782
+ DocEventType2["EpochMismatch"] = "epoch-mismatch";
18707
18783
  return DocEventType2;
18708
18784
  })(DocEventType || {});
18709
18785
  var StreamConnectionStatus = /* @__PURE__ */ ((StreamConnectionStatus2) => {
@@ -18993,6 +19069,17 @@
18993
19069
  }
18994
19070
  }, arg3);
18995
19071
  }
19072
+ if (arg1 === "epoch-mismatch") {
19073
+ const callback2 = arg2;
19074
+ return this.eventStream.subscribe((event) => {
19075
+ for (const docEvent of event) {
19076
+ if (docEvent.type !== "epoch-mismatch") {
19077
+ continue;
19078
+ }
19079
+ callback2(docEvent);
19080
+ }
19081
+ }, arg3);
19082
+ }
18996
19083
  if (arg1 === "all") {
18997
19084
  const callback2 = arg2;
18998
19085
  return this.eventStream.subscribe(callback2, arg3, arg4);
@@ -19940,7 +20027,7 @@
19940
20027
  };
19941
20028
  }
19942
20029
  const name$1 = "@yorkie-js/sdk";
19943
- const version$1 = "0.7.1";
20030
+ const version$1 = "0.7.3";
19944
20031
  const pkg$1 = {
19945
20032
  name: name$1,
19946
20033
  version: version$1
@@ -20731,6 +20818,16 @@
20731
20818
  ).catch(
20732
20819
  async (err) => {
20733
20820
  logger.error(`[SY] c:"${this.getKey()}" err :`, err);
20821
+ if (isErrorCode(err, Code.ErrEpochMismatch)) {
20822
+ attachment.resource.publish([
20823
+ {
20824
+ type: DocEventType.EpochMismatch,
20825
+ value: {
20826
+ method: "PushPull"
20827
+ }
20828
+ }
20829
+ ]);
20830
+ }
20734
20831
  await this.handleConnectError(err);
20735
20832
  throw err;
20736
20833
  }
@@ -21114,6 +21211,16 @@
21114
21211
  }
21115
21212
  ]);
21116
21213
  }
21214
+ if (isErrorCode(e, Code.ErrEpochMismatch)) {
21215
+ attachment.resource.publish([
21216
+ {
21217
+ type: DocEventType.EpochMismatch,
21218
+ value: {
21219
+ method: "PushPull"
21220
+ }
21221
+ }
21222
+ ]);
21223
+ }
21117
21224
  throw e;
21118
21225
  })
21119
21226
  );
@@ -21543,6 +21650,9 @@
21543
21650
  if (errorCodeOf(err) === Code.ErrTooManyAttachments) {
21544
21651
  return false;
21545
21652
  }
21653
+ if (errorCodeOf(err) === Code.ErrEpochMismatch) {
21654
+ return false;
21655
+ }
21546
21656
  if (errorCodeOf(err) === Code.ErrClientNotActivated || errorCodeOf(err) === Code.ErrClientNotFound) {
21547
21657
  this.deactivateInternal();
21548
21658
  }
@@ -21795,7 +21905,7 @@
21795
21905
  };
21796
21906
  }
21797
21907
  const name = "@yorkie-js/react";
21798
- const version = "0.7.1";
21908
+ const version = "0.7.3";
21799
21909
  const pkg = {
21800
21910
  name,
21801
21911
  version
@@ -22367,7 +22477,10 @@
22367
22477
  return useSelector(channelStore, (state) => state.sessionCount);
22368
22478
  };
22369
22479
  exports2.ChannelProvider = ChannelProvider;
22480
+ exports2.Counter = Counter;
22370
22481
  exports2.DocumentProvider = DocumentProvider;
22482
+ exports2.Text = Text;
22483
+ exports2.Tree = Tree;
22371
22484
  exports2.YorkieProvider = YorkieProvider;
22372
22485
  exports2.createDocumentSelector = createDocumentSelector;
22373
22486
  exports2.shallowEqual = shallowEqual;