@yorkie-js/react 0.7.3-alpha → 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 {
@@ -17221,22 +17222,49 @@
17221
17222
  }
17222
17223
  }
17223
17224
  /**
17224
- * `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.
17225
17228
  */
17226
- styleByPath(path, attributes) {
17229
+ styleByPath(fromPathOrPath, toPathOrAttrs, maybeAttrs) {
17227
17230
  if (!this.context || !this.tree) {
17228
17231
  throw new YorkieError(
17229
17232
  Code.ErrNotInitialized,
17230
17233
  "Tree is not initialized yet"
17231
17234
  );
17232
17235
  }
17233
- if (!path.length) {
17234
- throw new YorkieError(
17235
- Code.ErrInvalidArgument,
17236
- "path should not be empty"
17237
- );
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);
17238
17267
  }
17239
- const [fromPos, toPos] = this.tree.pathToPosRange(path);
17240
17268
  const ticket = this.context.issueTimeTicket();
17241
17269
  const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
17242
17270
  const [pairs, , diff] = this.tree.style([fromPos, toPos], attrs, ticket);
@@ -17327,6 +17355,51 @@
17327
17355
  )
17328
17356
  );
17329
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
+ }
17330
17403
  editInternal(fromPos, toPos, contents, splitLevel = 0) {
17331
17404
  if (contents.length !== 0 && contents[0]) {
17332
17405
  validateTreeNodes(contents);
@@ -18706,6 +18779,7 @@
18706
18779
  DocEventType2["Unwatched"] = "unwatched";
18707
18780
  DocEventType2["PresenceChanged"] = "presence-changed";
18708
18781
  DocEventType2["AuthError"] = "auth-error";
18782
+ DocEventType2["EpochMismatch"] = "epoch-mismatch";
18709
18783
  return DocEventType2;
18710
18784
  })(DocEventType || {});
18711
18785
  var StreamConnectionStatus = /* @__PURE__ */ ((StreamConnectionStatus2) => {
@@ -18995,6 +19069,17 @@
18995
19069
  }
18996
19070
  }, arg3);
18997
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
+ }
18998
19083
  if (arg1 === "all") {
18999
19084
  const callback2 = arg2;
19000
19085
  return this.eventStream.subscribe(callback2, arg3, arg4);
@@ -19942,7 +20027,7 @@
19942
20027
  };
19943
20028
  }
19944
20029
  const name$1 = "@yorkie-js/sdk";
19945
- const version$1 = "0.7.3-alpha";
20030
+ const version$1 = "0.7.3";
19946
20031
  const pkg$1 = {
19947
20032
  name: name$1,
19948
20033
  version: version$1
@@ -20733,6 +20818,16 @@
20733
20818
  ).catch(
20734
20819
  async (err) => {
20735
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
+ }
20736
20831
  await this.handleConnectError(err);
20737
20832
  throw err;
20738
20833
  }
@@ -21116,6 +21211,16 @@
21116
21211
  }
21117
21212
  ]);
21118
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
+ }
21119
21224
  throw e;
21120
21225
  })
21121
21226
  );
@@ -21545,6 +21650,9 @@
21545
21650
  if (errorCodeOf(err) === Code.ErrTooManyAttachments) {
21546
21651
  return false;
21547
21652
  }
21653
+ if (errorCodeOf(err) === Code.ErrEpochMismatch) {
21654
+ return false;
21655
+ }
21548
21656
  if (errorCodeOf(err) === Code.ErrClientNotActivated || errorCodeOf(err) === Code.ErrClientNotFound) {
21549
21657
  this.deactivateInternal();
21550
21658
  }
@@ -21797,7 +21905,7 @@
21797
21905
  };
21798
21906
  }
21799
21907
  const name = "@yorkie-js/react";
21800
- const version = "0.7.3-alpha";
21908
+ const version = "0.7.3";
21801
21909
  const pkg = {
21802
21910
  name,
21803
21911
  version