@yorkie-js/react 0.6.7 → 0.6.8
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.js
CHANGED
|
@@ -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.
|
|
10
|
+
const version$1 = "0.6.8";
|
|
11
11
|
const pkg$1 = {
|
|
12
12
|
name: name$1,
|
|
13
13
|
version: version$1
|
|
@@ -7677,6 +7677,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7677
7677
|
}
|
|
7678
7678
|
}
|
|
7679
7679
|
const InitialActorID = "000000000000000000000000";
|
|
7680
|
+
const TimeTicketSize = 8 + 4 + 12;
|
|
7680
7681
|
class TimeTicket {
|
|
7681
7682
|
constructor(lamport, delimiter, actorID) {
|
|
7682
7683
|
__publicField(this, "lamport");
|
|
@@ -7895,6 +7896,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7895
7896
|
isRemoved() {
|
|
7896
7897
|
return !!this.removedAt;
|
|
7897
7898
|
}
|
|
7899
|
+
/**
|
|
7900
|
+
* `getMetaUsage` returns the meta usage of this element.
|
|
7901
|
+
*/
|
|
7902
|
+
getMetaUsage() {
|
|
7903
|
+
let meta = 0;
|
|
7904
|
+
if (this.getCreatedAt()) {
|
|
7905
|
+
meta += TimeTicketSize;
|
|
7906
|
+
}
|
|
7907
|
+
if (this.getMovedAt()) {
|
|
7908
|
+
meta += TimeTicketSize;
|
|
7909
|
+
}
|
|
7910
|
+
if (this.getRemovedAt()) {
|
|
7911
|
+
meta += TimeTicketSize;
|
|
7912
|
+
}
|
|
7913
|
+
return meta;
|
|
7914
|
+
}
|
|
7898
7915
|
}
|
|
7899
7916
|
class CRDTContainer extends CRDTElement {
|
|
7900
7917
|
constructor(createdAt) {
|
|
@@ -8127,6 +8144,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8127
8144
|
has(key) {
|
|
8128
8145
|
return this.memberNodes.has(key);
|
|
8129
8146
|
}
|
|
8147
|
+
/**
|
|
8148
|
+
* `getDataSize` returns the data usage of this element.
|
|
8149
|
+
*/
|
|
8150
|
+
getDataSize() {
|
|
8151
|
+
return {
|
|
8152
|
+
data: 0,
|
|
8153
|
+
meta: this.getMetaUsage()
|
|
8154
|
+
};
|
|
8155
|
+
}
|
|
8130
8156
|
/**
|
|
8131
8157
|
* `toJSON` returns the JSON encoding of this object.
|
|
8132
8158
|
*/
|
|
@@ -9694,6 +9720,44 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
9694
9720
|
);
|
|
9695
9721
|
}
|
|
9696
9722
|
}
|
|
9723
|
+
/**
|
|
9724
|
+
* `getValueSize` returns the size of the value. The size is similar to
|
|
9725
|
+
* the size of primitives in JavaScript.
|
|
9726
|
+
*/
|
|
9727
|
+
getValueSize() {
|
|
9728
|
+
switch (this.valueType) {
|
|
9729
|
+
case 0:
|
|
9730
|
+
return 8;
|
|
9731
|
+
case 1:
|
|
9732
|
+
return 4;
|
|
9733
|
+
case 2:
|
|
9734
|
+
return 4;
|
|
9735
|
+
case 3:
|
|
9736
|
+
return 8;
|
|
9737
|
+
case 4:
|
|
9738
|
+
return 8;
|
|
9739
|
+
case 5:
|
|
9740
|
+
return this.value.length * 2;
|
|
9741
|
+
case 6:
|
|
9742
|
+
return this.value.length;
|
|
9743
|
+
case 7:
|
|
9744
|
+
return 8;
|
|
9745
|
+
default:
|
|
9746
|
+
throw new YorkieError(
|
|
9747
|
+
Code.ErrUnimplemented,
|
|
9748
|
+
`unimplemented type: ${this.valueType}`
|
|
9749
|
+
);
|
|
9750
|
+
}
|
|
9751
|
+
}
|
|
9752
|
+
/**
|
|
9753
|
+
* `getDataSize` returns the data usage of this element.
|
|
9754
|
+
*/
|
|
9755
|
+
getDataSize() {
|
|
9756
|
+
return {
|
|
9757
|
+
data: this.getValueSize(),
|
|
9758
|
+
meta: this.getMetaUsage()
|
|
9759
|
+
};
|
|
9760
|
+
}
|
|
9697
9761
|
/**
|
|
9698
9762
|
* `toJSON` returns the JSON encoding of the value.
|
|
9699
9763
|
*/
|
|
@@ -10292,6 +10356,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10292
10356
|
}
|
|
10293
10357
|
}
|
|
10294
10358
|
}
|
|
10359
|
+
/**
|
|
10360
|
+
* `getDataSize` returns the data usage of this element.
|
|
10361
|
+
*/
|
|
10362
|
+
getDataSize() {
|
|
10363
|
+
return {
|
|
10364
|
+
data: 0,
|
|
10365
|
+
meta: this.getMetaUsage()
|
|
10366
|
+
};
|
|
10367
|
+
}
|
|
10295
10368
|
/**
|
|
10296
10369
|
* `toJSON` returns the JSON encoding of this array.
|
|
10297
10370
|
*/
|
|
@@ -10759,6 +10832,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10759
10832
|
}
|
|
10760
10833
|
return void 0;
|
|
10761
10834
|
}
|
|
10835
|
+
/**
|
|
10836
|
+
* `getDataSize` returns the size of this node.
|
|
10837
|
+
*/
|
|
10838
|
+
getDataSize() {
|
|
10839
|
+
return {
|
|
10840
|
+
data: (this.key.length + this.value.length) * 2,
|
|
10841
|
+
meta: TimeTicketSize
|
|
10842
|
+
};
|
|
10843
|
+
}
|
|
10762
10844
|
}
|
|
10763
10845
|
class RHT {
|
|
10764
10846
|
constructor() {
|
|
@@ -10970,6 +11052,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10970
11052
|
toString() {
|
|
10971
11053
|
return this.content;
|
|
10972
11054
|
}
|
|
11055
|
+
/**
|
|
11056
|
+
* `getDataSize` returns the data usage of this value.
|
|
11057
|
+
*/
|
|
11058
|
+
getDataSize() {
|
|
11059
|
+
const dataSize = { data: 0, meta: 0 };
|
|
11060
|
+
dataSize.data += this.content.length * 2;
|
|
11061
|
+
for (const node of this.attributes) {
|
|
11062
|
+
const size = node.getDataSize();
|
|
11063
|
+
dataSize.meta += size.meta;
|
|
11064
|
+
dataSize.data += size.data;
|
|
11065
|
+
}
|
|
11066
|
+
return dataSize;
|
|
11067
|
+
}
|
|
10973
11068
|
/**
|
|
10974
11069
|
* `toJSON` returns the JSON encoding of this value.
|
|
10975
11070
|
*/
|
|
@@ -11161,6 +11256,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11161
11256
|
getTreeByID() {
|
|
11162
11257
|
return this.rgaTreeSplit.getTreeByID();
|
|
11163
11258
|
}
|
|
11259
|
+
/**
|
|
11260
|
+
* `getDataSize` returns the data usage of this element.
|
|
11261
|
+
*/
|
|
11262
|
+
getDataSize() {
|
|
11263
|
+
const dataSize = { data: 0, meta: 0 };
|
|
11264
|
+
for (const node of this.rgaTreeSplit) {
|
|
11265
|
+
if (node.isRemoved()) {
|
|
11266
|
+
continue;
|
|
11267
|
+
}
|
|
11268
|
+
const size = node.getDataSize();
|
|
11269
|
+
dataSize.data += size.data;
|
|
11270
|
+
dataSize.meta += size.meta;
|
|
11271
|
+
}
|
|
11272
|
+
return {
|
|
11273
|
+
data: dataSize.data,
|
|
11274
|
+
meta: dataSize.meta + this.getMetaUsage()
|
|
11275
|
+
};
|
|
11276
|
+
}
|
|
11164
11277
|
/**
|
|
11165
11278
|
* `toJSON` returns the JSON encoding of this text.
|
|
11166
11279
|
*/
|
|
@@ -12775,6 +12888,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
12775
12888
|
this.attrs.purge(node);
|
|
12776
12889
|
}
|
|
12777
12890
|
}
|
|
12891
|
+
/**
|
|
12892
|
+
* `getDataSize` returns the data size of the node.
|
|
12893
|
+
*/
|
|
12894
|
+
getDataSize() {
|
|
12895
|
+
const dataSize = { data: 0, meta: 0 };
|
|
12896
|
+
if (this.isText) {
|
|
12897
|
+
dataSize.data += this.size * 2;
|
|
12898
|
+
}
|
|
12899
|
+
if (this.id) {
|
|
12900
|
+
dataSize.meta += TimeTicketSize;
|
|
12901
|
+
}
|
|
12902
|
+
if (this.removedAt) {
|
|
12903
|
+
dataSize.meta += TimeTicketSize;
|
|
12904
|
+
}
|
|
12905
|
+
if (this.attrs) {
|
|
12906
|
+
for (const node of this.attrs) {
|
|
12907
|
+
if (node.getRemovedAt()) {
|
|
12908
|
+
continue;
|
|
12909
|
+
}
|
|
12910
|
+
const size = node.getDataSize();
|
|
12911
|
+
dataSize.meta += size.meta;
|
|
12912
|
+
dataSize.data += size.data;
|
|
12913
|
+
}
|
|
12914
|
+
}
|
|
12915
|
+
return dataSize;
|
|
12916
|
+
}
|
|
12778
12917
|
/**
|
|
12779
12918
|
* `getGCPairs` returns the pairs of GC.
|
|
12780
12919
|
*/
|
|
@@ -13274,6 +13413,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13274
13413
|
toXML() {
|
|
13275
13414
|
return toXML(this.indexTree.getRoot());
|
|
13276
13415
|
}
|
|
13416
|
+
/**
|
|
13417
|
+
* `getDataSize` returns the data usage of this element.
|
|
13418
|
+
*/
|
|
13419
|
+
getDataSize() {
|
|
13420
|
+
const dataSize = { data: 0, meta: 0 };
|
|
13421
|
+
this.indexTree.traverse((node) => {
|
|
13422
|
+
if (node.getRemovedAt()) {
|
|
13423
|
+
return;
|
|
13424
|
+
}
|
|
13425
|
+
const size = node.getDataSize();
|
|
13426
|
+
dataSize.data += size.data;
|
|
13427
|
+
dataSize.meta += size.meta;
|
|
13428
|
+
});
|
|
13429
|
+
return {
|
|
13430
|
+
data: dataSize.data,
|
|
13431
|
+
meta: dataSize.meta + this.getMetaUsage()
|
|
13432
|
+
};
|
|
13433
|
+
}
|
|
13277
13434
|
/**
|
|
13278
13435
|
* `toJSON` returns the JSON encoding of this tree.
|
|
13279
13436
|
*/
|
|
@@ -14630,6 +14787,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14630
14787
|
RGATreeSplitPos.of(this.id, this.getLength())
|
|
14631
14788
|
];
|
|
14632
14789
|
}
|
|
14790
|
+
/**
|
|
14791
|
+
* `getData` returns the data of this node.
|
|
14792
|
+
*/
|
|
14793
|
+
getDataSize() {
|
|
14794
|
+
const dataSize = this.value.getDataSize();
|
|
14795
|
+
if (this.id) {
|
|
14796
|
+
dataSize.meta += TimeTicketSize;
|
|
14797
|
+
}
|
|
14798
|
+
if (this.removedAt) {
|
|
14799
|
+
dataSize.meta += TimeTicketSize;
|
|
14800
|
+
}
|
|
14801
|
+
return dataSize;
|
|
14802
|
+
}
|
|
14633
14803
|
/**
|
|
14634
14804
|
* `deepcopy` returns a new instance of this RGATreeSplitNode without structural info.
|
|
14635
14805
|
*/
|
|
@@ -15058,8 +15228,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15058
15228
|
}
|
|
15059
15229
|
const removeDecimal = (number) => number < 0 ? Math.ceil(number) : Math.floor(number);
|
|
15060
15230
|
var CounterType = /* @__PURE__ */ ((CounterType2) => {
|
|
15061
|
-
CounterType2[CounterType2["
|
|
15062
|
-
CounterType2[CounterType2["
|
|
15231
|
+
CounterType2[CounterType2["Int"] = 0] = "Int";
|
|
15232
|
+
CounterType2[CounterType2["Long"] = 1] = "Long";
|
|
15063
15233
|
return CounterType2;
|
|
15064
15234
|
})(CounterType || {});
|
|
15065
15235
|
class CRDTCounter extends CRDTElement {
|
|
@@ -15116,6 +15286,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15116
15286
|
);
|
|
15117
15287
|
}
|
|
15118
15288
|
}
|
|
15289
|
+
/**
|
|
15290
|
+
* `getDataSize` returns the data usage of this element.
|
|
15291
|
+
*/
|
|
15292
|
+
getDataSize() {
|
|
15293
|
+
const data = this.valueType === 0 ? 4 : 8;
|
|
15294
|
+
return {
|
|
15295
|
+
data,
|
|
15296
|
+
meta: this.getMetaUsage()
|
|
15297
|
+
};
|
|
15298
|
+
}
|
|
15119
15299
|
/**
|
|
15120
15300
|
* `toJSON` returns the JSON encoding of the value.
|
|
15121
15301
|
*/
|
|
@@ -15567,9 +15747,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15567
15747
|
}
|
|
15568
15748
|
function toCounterType(valueType) {
|
|
15569
15749
|
switch (valueType) {
|
|
15570
|
-
case CounterType.
|
|
15750
|
+
case CounterType.Int:
|
|
15571
15751
|
return ValueType.INTEGER_CNT;
|
|
15572
|
-
case CounterType.
|
|
15752
|
+
case CounterType.Long:
|
|
15573
15753
|
return ValueType.LONG_CNT;
|
|
15574
15754
|
default:
|
|
15575
15755
|
throw new YorkieError(
|
|
@@ -16122,9 +16302,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16122
16302
|
function fromCounterType(pbValueType) {
|
|
16123
16303
|
switch (pbValueType) {
|
|
16124
16304
|
case ValueType.INTEGER_CNT:
|
|
16125
|
-
return CounterType.
|
|
16305
|
+
return CounterType.Int;
|
|
16126
16306
|
case ValueType.LONG_CNT:
|
|
16127
|
-
return CounterType.
|
|
16307
|
+
return CounterType.Long;
|
|
16128
16308
|
}
|
|
16129
16309
|
throw new YorkieError(
|
|
16130
16310
|
Code.ErrUnimplemented,
|
|
@@ -17223,6 +17403,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17223
17403
|
getGarbageLen() {
|
|
17224
17404
|
return this.getGarbageElementSetSize() + this.gcPairMap.size;
|
|
17225
17405
|
}
|
|
17406
|
+
/**
|
|
17407
|
+
* `getDocSize` returns the size of the document.
|
|
17408
|
+
*/
|
|
17409
|
+
getDocSize() {
|
|
17410
|
+
const docSize = { live: { data: 0, meta: 0 }, gc: { data: 0, meta: 0 } };
|
|
17411
|
+
for (const [createdAt, value] of this.elementPairMapByCreatedAt) {
|
|
17412
|
+
if (this.gcElementSetByCreatedAt.has(createdAt)) {
|
|
17413
|
+
docSize.gc.data += value.element.getDataSize().data;
|
|
17414
|
+
docSize.gc.meta += value.element.getDataSize().meta;
|
|
17415
|
+
} else {
|
|
17416
|
+
docSize.live.data += value.element.getDataSize().data;
|
|
17417
|
+
docSize.live.meta += value.element.getDataSize().meta;
|
|
17418
|
+
}
|
|
17419
|
+
}
|
|
17420
|
+
for (const pair of this.gcPairMap.values()) {
|
|
17421
|
+
const size = pair.child.getDataSize();
|
|
17422
|
+
docSize.gc.data += size.data;
|
|
17423
|
+
docSize.gc.meta += size.meta;
|
|
17424
|
+
}
|
|
17425
|
+
return docSize;
|
|
17426
|
+
}
|
|
17226
17427
|
/**
|
|
17227
17428
|
* `deepcopy` copies itself deeply.
|
|
17228
17429
|
*/
|
|
@@ -18780,7 +18981,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18780
18981
|
} else if (elem instanceof CRDTText) {
|
|
18781
18982
|
return new Text(context, elem);
|
|
18782
18983
|
} else if (elem instanceof CRDTCounter) {
|
|
18783
|
-
const counter = new Counter(CounterType.
|
|
18984
|
+
const counter = new Counter(CounterType.Int, 0);
|
|
18784
18985
|
counter.initialize(context, elem);
|
|
18785
18986
|
return counter;
|
|
18786
18987
|
} else if (elem instanceof CRDTTree) {
|
|
@@ -19533,6 +19734,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19533
19734
|
);
|
|
19534
19735
|
return createJSON(context, this.clone.root.getObject());
|
|
19535
19736
|
}
|
|
19737
|
+
/**
|
|
19738
|
+
* `getDocSize` returns the size of this document.
|
|
19739
|
+
*/
|
|
19740
|
+
getDocSize() {
|
|
19741
|
+
return this.root.getDocSize();
|
|
19742
|
+
}
|
|
19536
19743
|
/**
|
|
19537
19744
|
* `garbageCollect` purges elements that were removed before the given time.
|
|
19538
19745
|
*
|
|
@@ -20242,7 +20449,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20242
20449
|
};
|
|
20243
20450
|
}
|
|
20244
20451
|
const name = "@yorkie-js/sdk";
|
|
20245
|
-
const version = "0.6.
|
|
20452
|
+
const version = "0.6.8";
|
|
20246
20453
|
const pkg = {
|
|
20247
20454
|
name,
|
|
20248
20455
|
version
|
|
@@ -21087,8 +21294,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
21087
21294
|
}
|
|
21088
21295
|
}
|
|
21089
21296
|
({
|
|
21090
|
-
IntType: CounterType.
|
|
21091
|
-
LongType: CounterType.
|
|
21297
|
+
IntType: CounterType.Int,
|
|
21298
|
+
LongType: CounterType.Long
|
|
21092
21299
|
});
|
|
21093
21300
|
if (typeof globalThis !== "undefined") {
|
|
21094
21301
|
globalThis.yorkie = {
|
|
@@ -21100,8 +21307,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
21100
21307
|
Tree,
|
|
21101
21308
|
LogLevel,
|
|
21102
21309
|
setLogLevel,
|
|
21103
|
-
IntType: CounterType.
|
|
21104
|
-
LongType: CounterType.
|
|
21310
|
+
IntType: CounterType.Int,
|
|
21311
|
+
LongType: CounterType.Long
|
|
21105
21312
|
};
|
|
21106
21313
|
}
|
|
21107
21314
|
const YorkieContext = react.createContext({
|
|
@@ -21259,7 +21466,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
21259
21466
|
error
|
|
21260
21467
|
};
|
|
21261
21468
|
}
|
|
21262
|
-
const DocumentContext = react.createContext(
|
|
21469
|
+
const DocumentContext = react.createContext(
|
|
21470
|
+
null
|
|
21471
|
+
);
|
|
21263
21472
|
const DocumentProvider = ({
|
|
21264
21473
|
docKey,
|
|
21265
21474
|
initialRoot = {},
|
|
@@ -21267,7 +21476,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
21267
21476
|
children
|
|
21268
21477
|
}) => {
|
|
21269
21478
|
const { client, loading: clientLoading, error: clientError } = useYorkie();
|
|
21270
|
-
const { root, presences, connection, update, loading, error } = useYorkieDocument(
|
|
21479
|
+
const { doc, root, presences, connection, update, loading, error } = useYorkieDocument(
|
|
21271
21480
|
client,
|
|
21272
21481
|
clientLoading,
|
|
21273
21482
|
clientError,
|
|
@@ -21278,7 +21487,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
21278
21487
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21279
21488
|
DocumentContext.Provider,
|
|
21280
21489
|
{
|
|
21281
|
-
value: {
|
|
21490
|
+
value: {
|
|
21491
|
+
doc,
|
|
21492
|
+
root,
|
|
21493
|
+
presences,
|
|
21494
|
+
connection,
|
|
21495
|
+
update,
|
|
21496
|
+
loading,
|
|
21497
|
+
error
|
|
21498
|
+
},
|
|
21282
21499
|
children
|
|
21283
21500
|
}
|
|
21284
21501
|
);
|
|
@@ -21289,6 +21506,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
21289
21506
|
throw new Error("useDocument must be used within a DocumentProvider");
|
|
21290
21507
|
}
|
|
21291
21508
|
return {
|
|
21509
|
+
doc: context.doc,
|
|
21292
21510
|
root: context.root,
|
|
21293
21511
|
presences: context.presences,
|
|
21294
21512
|
connection: context.connection,
|