@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.
- package/dist/yorkie-js-react.es.js +118 -10
- package/dist/yorkie-js-react.es.js.map +1 -1
- package/dist/yorkie-js-react.js +118 -10
- package/dist/yorkie-js-react.js.map +1 -1
- package/package.json +2 -2
|
@@ -5497,6 +5497,7 @@ var Code = /* @__PURE__ */ ((Code2) => {
|
|
|
5497
5497
|
Code2["ErrUnauthenticated"] = "ErrUnauthenticated";
|
|
5498
5498
|
Code2["ErrTooManySubscribers"] = "ErrTooManySubscribers";
|
|
5499
5499
|
Code2["ErrTooManyAttachments"] = "ErrTooManyAttachments";
|
|
5500
|
+
Code2["ErrEpochMismatch"] = "ErrEpochMismatch";
|
|
5500
5501
|
return Code2;
|
|
5501
5502
|
})(Code || {});
|
|
5502
5503
|
class YorkieError extends Error {
|
|
@@ -17219,22 +17220,49 @@ class Tree {
|
|
|
17219
17220
|
}
|
|
17220
17221
|
}
|
|
17221
17222
|
/**
|
|
17222
|
-
* `styleByPath` sets the attributes to the elements of the given
|
|
17223
|
+
* `styleByPath` sets the attributes to the elements of the given
|
|
17224
|
+
* path. When called with two paths, it styles the range between
|
|
17225
|
+
* them.
|
|
17223
17226
|
*/
|
|
17224
|
-
styleByPath(
|
|
17227
|
+
styleByPath(fromPathOrPath, toPathOrAttrs, maybeAttrs) {
|
|
17225
17228
|
if (!this.context || !this.tree) {
|
|
17226
17229
|
throw new YorkieError(
|
|
17227
17230
|
Code.ErrNotInitialized,
|
|
17228
17231
|
"Tree is not initialized yet"
|
|
17229
17232
|
);
|
|
17230
17233
|
}
|
|
17231
|
-
|
|
17232
|
-
|
|
17233
|
-
|
|
17234
|
-
|
|
17235
|
-
|
|
17234
|
+
let fromPos;
|
|
17235
|
+
let toPos;
|
|
17236
|
+
let attributes;
|
|
17237
|
+
if (Array.isArray(toPathOrAttrs)) {
|
|
17238
|
+
const fromPath = fromPathOrPath;
|
|
17239
|
+
const toPath = toPathOrAttrs;
|
|
17240
|
+
attributes = maybeAttrs;
|
|
17241
|
+
if (fromPath.length !== toPath.length) {
|
|
17242
|
+
throw new YorkieError(
|
|
17243
|
+
Code.ErrInvalidArgument,
|
|
17244
|
+
"path length should be equal"
|
|
17245
|
+
);
|
|
17246
|
+
}
|
|
17247
|
+
if (!fromPath.length || !toPath.length) {
|
|
17248
|
+
throw new YorkieError(
|
|
17249
|
+
Code.ErrInvalidArgument,
|
|
17250
|
+
"path should not be empty"
|
|
17251
|
+
);
|
|
17252
|
+
}
|
|
17253
|
+
fromPos = this.tree.pathToPos(fromPath);
|
|
17254
|
+
toPos = this.tree.pathToPos(toPath);
|
|
17255
|
+
} else {
|
|
17256
|
+
const path = fromPathOrPath;
|
|
17257
|
+
attributes = toPathOrAttrs;
|
|
17258
|
+
if (!path.length) {
|
|
17259
|
+
throw new YorkieError(
|
|
17260
|
+
Code.ErrInvalidArgument,
|
|
17261
|
+
"path should not be empty"
|
|
17262
|
+
);
|
|
17263
|
+
}
|
|
17264
|
+
[fromPos, toPos] = this.tree.pathToPosRange(path);
|
|
17236
17265
|
}
|
|
17237
|
-
const [fromPos, toPos] = this.tree.pathToPosRange(path);
|
|
17238
17266
|
const ticket = this.context.issueTimeTicket();
|
|
17239
17267
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
17240
17268
|
const [pairs, , diff] = this.tree.style([fromPos, toPos], attrs, ticket);
|
|
@@ -17325,6 +17353,51 @@ class Tree {
|
|
|
17325
17353
|
)
|
|
17326
17354
|
);
|
|
17327
17355
|
}
|
|
17356
|
+
/**
|
|
17357
|
+
* `removeStyleByPath` removes the attributes of the elements in
|
|
17358
|
+
* the given path range.
|
|
17359
|
+
*/
|
|
17360
|
+
removeStyleByPath(fromPath, toPath, attributesToRemove) {
|
|
17361
|
+
if (!this.context || !this.tree) {
|
|
17362
|
+
throw new YorkieError(
|
|
17363
|
+
Code.ErrNotInitialized,
|
|
17364
|
+
"Tree is not initialized yet"
|
|
17365
|
+
);
|
|
17366
|
+
}
|
|
17367
|
+
if (fromPath.length !== toPath.length) {
|
|
17368
|
+
throw new YorkieError(
|
|
17369
|
+
Code.ErrInvalidArgument,
|
|
17370
|
+
"path length should be equal"
|
|
17371
|
+
);
|
|
17372
|
+
}
|
|
17373
|
+
if (!fromPath.length || !toPath.length) {
|
|
17374
|
+
throw new YorkieError(
|
|
17375
|
+
Code.ErrInvalidArgument,
|
|
17376
|
+
"path should not be empty"
|
|
17377
|
+
);
|
|
17378
|
+
}
|
|
17379
|
+
const fromPos = this.tree.pathToPos(fromPath);
|
|
17380
|
+
const toPos = this.tree.pathToPos(toPath);
|
|
17381
|
+
const ticket = this.context.issueTimeTicket();
|
|
17382
|
+
const [pairs, , diff] = this.tree.removeStyle(
|
|
17383
|
+
[fromPos, toPos],
|
|
17384
|
+
attributesToRemove,
|
|
17385
|
+
ticket
|
|
17386
|
+
);
|
|
17387
|
+
this.context.acc(diff);
|
|
17388
|
+
for (const pair of pairs) {
|
|
17389
|
+
this.context.registerGCPair(pair);
|
|
17390
|
+
}
|
|
17391
|
+
this.context.push(
|
|
17392
|
+
TreeStyleOperation.createTreeRemoveStyleOperation(
|
|
17393
|
+
this.tree.getCreatedAt(),
|
|
17394
|
+
fromPos,
|
|
17395
|
+
toPos,
|
|
17396
|
+
attributesToRemove,
|
|
17397
|
+
ticket
|
|
17398
|
+
)
|
|
17399
|
+
);
|
|
17400
|
+
}
|
|
17328
17401
|
editInternal(fromPos, toPos, contents, splitLevel = 0) {
|
|
17329
17402
|
if (contents.length !== 0 && contents[0]) {
|
|
17330
17403
|
validateTreeNodes(contents);
|
|
@@ -18704,6 +18777,7 @@ var DocEventType = /* @__PURE__ */ ((DocEventType2) => {
|
|
|
18704
18777
|
DocEventType2["Unwatched"] = "unwatched";
|
|
18705
18778
|
DocEventType2["PresenceChanged"] = "presence-changed";
|
|
18706
18779
|
DocEventType2["AuthError"] = "auth-error";
|
|
18780
|
+
DocEventType2["EpochMismatch"] = "epoch-mismatch";
|
|
18707
18781
|
return DocEventType2;
|
|
18708
18782
|
})(DocEventType || {});
|
|
18709
18783
|
var StreamConnectionStatus = /* @__PURE__ */ ((StreamConnectionStatus2) => {
|
|
@@ -18993,6 +19067,17 @@ class Document {
|
|
|
18993
19067
|
}
|
|
18994
19068
|
}, arg3);
|
|
18995
19069
|
}
|
|
19070
|
+
if (arg1 === "epoch-mismatch") {
|
|
19071
|
+
const callback2 = arg2;
|
|
19072
|
+
return this.eventStream.subscribe((event) => {
|
|
19073
|
+
for (const docEvent of event) {
|
|
19074
|
+
if (docEvent.type !== "epoch-mismatch") {
|
|
19075
|
+
continue;
|
|
19076
|
+
}
|
|
19077
|
+
callback2(docEvent);
|
|
19078
|
+
}
|
|
19079
|
+
}, arg3);
|
|
19080
|
+
}
|
|
18996
19081
|
if (arg1 === "all") {
|
|
18997
19082
|
const callback2 = arg2;
|
|
18998
19083
|
return this.eventStream.subscribe(callback2, arg3, arg4);
|
|
@@ -19940,7 +20025,7 @@ function createAuthInterceptor(apiKey, token) {
|
|
|
19940
20025
|
};
|
|
19941
20026
|
}
|
|
19942
20027
|
const name$1 = "@yorkie-js/sdk";
|
|
19943
|
-
const version$1 = "0.7.3
|
|
20028
|
+
const version$1 = "0.7.3";
|
|
19944
20029
|
const pkg$1 = {
|
|
19945
20030
|
name: name$1,
|
|
19946
20031
|
version: version$1
|
|
@@ -20731,6 +20816,16 @@ class Client {
|
|
|
20731
20816
|
).catch(
|
|
20732
20817
|
async (err) => {
|
|
20733
20818
|
logger.error(`[SY] c:"${this.getKey()}" err :`, err);
|
|
20819
|
+
if (isErrorCode(err, Code.ErrEpochMismatch)) {
|
|
20820
|
+
attachment.resource.publish([
|
|
20821
|
+
{
|
|
20822
|
+
type: DocEventType.EpochMismatch,
|
|
20823
|
+
value: {
|
|
20824
|
+
method: "PushPull"
|
|
20825
|
+
}
|
|
20826
|
+
}
|
|
20827
|
+
]);
|
|
20828
|
+
}
|
|
20734
20829
|
await this.handleConnectError(err);
|
|
20735
20830
|
throw err;
|
|
20736
20831
|
}
|
|
@@ -21114,6 +21209,16 @@ class Client {
|
|
|
21114
21209
|
}
|
|
21115
21210
|
]);
|
|
21116
21211
|
}
|
|
21212
|
+
if (isErrorCode(e, Code.ErrEpochMismatch)) {
|
|
21213
|
+
attachment.resource.publish([
|
|
21214
|
+
{
|
|
21215
|
+
type: DocEventType.EpochMismatch,
|
|
21216
|
+
value: {
|
|
21217
|
+
method: "PushPull"
|
|
21218
|
+
}
|
|
21219
|
+
}
|
|
21220
|
+
]);
|
|
21221
|
+
}
|
|
21117
21222
|
throw e;
|
|
21118
21223
|
})
|
|
21119
21224
|
);
|
|
@@ -21543,6 +21648,9 @@ class Client {
|
|
|
21543
21648
|
if (errorCodeOf(err) === Code.ErrTooManyAttachments) {
|
|
21544
21649
|
return false;
|
|
21545
21650
|
}
|
|
21651
|
+
if (errorCodeOf(err) === Code.ErrEpochMismatch) {
|
|
21652
|
+
return false;
|
|
21653
|
+
}
|
|
21546
21654
|
if (errorCodeOf(err) === Code.ErrClientNotActivated || errorCodeOf(err) === Code.ErrClientNotFound) {
|
|
21547
21655
|
this.deactivateInternal();
|
|
21548
21656
|
}
|
|
@@ -21795,7 +21903,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
21795
21903
|
};
|
|
21796
21904
|
}
|
|
21797
21905
|
const name = "@yorkie-js/react";
|
|
21798
|
-
const version = "0.7.3
|
|
21906
|
+
const version = "0.7.3";
|
|
21799
21907
|
const pkg = {
|
|
21800
21908
|
name,
|
|
21801
21909
|
version
|