@yorkie-js/react 0.6.21 → 0.6.23
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 +317 -59
- package/dist/yorkie-js-react.es.js.map +1 -1
- package/dist/yorkie-js-react.js +317 -59
- package/dist/yorkie-js-react.js.map +1 -1
- package/package.json +4 -3
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.23";
|
|
11
11
|
const pkg$1 = {
|
|
12
12
|
name: name$1,
|
|
13
13
|
version: version$1
|
|
@@ -4692,7 +4692,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4692
4692
|
{ no: 3, name: "move", kind: "message", T: Operation_Move, oneof: "body" },
|
|
4693
4693
|
{ no: 4, name: "remove", kind: "message", T: Operation_Remove, oneof: "body" },
|
|
4694
4694
|
{ no: 5, name: "edit", kind: "message", T: Operation_Edit, oneof: "body" },
|
|
4695
|
-
{ no: 6, name: "select", kind: "message", T: Operation_Select, oneof: "body" },
|
|
4696
4695
|
{ no: 7, name: "style", kind: "message", T: Operation_Style, oneof: "body" },
|
|
4697
4696
|
{ no: 8, name: "increase", kind: "message", T: Operation_Increase, oneof: "body" },
|
|
4698
4697
|
{ no: 9, name: "tree_edit", kind: "message", T: Operation_TreeEdit, oneof: "body" },
|
|
@@ -4942,49 +4941,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4942
4941
|
} }
|
|
4943
4942
|
]));
|
|
4944
4943
|
let Operation_Edit = _Operation_Edit;
|
|
4945
|
-
const _Operation_Select = class _Operation_Select extends Message {
|
|
4946
|
-
constructor(data) {
|
|
4947
|
-
super();
|
|
4948
|
-
/**
|
|
4949
|
-
* @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;
|
|
4950
|
-
*/
|
|
4951
|
-
__publicField(this, "parentCreatedAt");
|
|
4952
|
-
/**
|
|
4953
|
-
* @generated from field: yorkie.v1.TextNodePos from = 2;
|
|
4954
|
-
*/
|
|
4955
|
-
__publicField(this, "from");
|
|
4956
|
-
/**
|
|
4957
|
-
* @generated from field: yorkie.v1.TextNodePos to = 3;
|
|
4958
|
-
*/
|
|
4959
|
-
__publicField(this, "to");
|
|
4960
|
-
/**
|
|
4961
|
-
* @generated from field: yorkie.v1.TimeTicket executed_at = 4;
|
|
4962
|
-
*/
|
|
4963
|
-
__publicField(this, "executedAt");
|
|
4964
|
-
proto3.util.initPartial(data, this);
|
|
4965
|
-
}
|
|
4966
|
-
static fromBinary(bytes, options) {
|
|
4967
|
-
return new _Operation_Select().fromBinary(bytes, options);
|
|
4968
|
-
}
|
|
4969
|
-
static fromJson(jsonValue, options) {
|
|
4970
|
-
return new _Operation_Select().fromJson(jsonValue, options);
|
|
4971
|
-
}
|
|
4972
|
-
static fromJsonString(jsonString, options) {
|
|
4973
|
-
return new _Operation_Select().fromJsonString(jsonString, options);
|
|
4974
|
-
}
|
|
4975
|
-
static equals(a, b) {
|
|
4976
|
-
return proto3.util.equals(_Operation_Select, a, b);
|
|
4977
|
-
}
|
|
4978
|
-
};
|
|
4979
|
-
__publicField(_Operation_Select, "runtime", proto3);
|
|
4980
|
-
__publicField(_Operation_Select, "typeName", "yorkie.v1.Operation.Select");
|
|
4981
|
-
__publicField(_Operation_Select, "fields", proto3.util.newFieldList(() => [
|
|
4982
|
-
{ no: 1, name: "parent_created_at", kind: "message", T: TimeTicket$1 },
|
|
4983
|
-
{ no: 2, name: "from", kind: "message", T: TextNodePos },
|
|
4984
|
-
{ no: 3, name: "to", kind: "message", T: TextNodePos },
|
|
4985
|
-
{ no: 4, name: "executed_at", kind: "message", T: TimeTicket$1 }
|
|
4986
|
-
]));
|
|
4987
|
-
let Operation_Select = _Operation_Select;
|
|
4988
4944
|
const _Operation_Style = class _Operation_Style extends Message {
|
|
4989
4945
|
constructor(data) {
|
|
4990
4946
|
super();
|
|
@@ -6447,9 +6403,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6447
6403
|
*/
|
|
6448
6404
|
__publicField(this, "key", "");
|
|
6449
6405
|
/**
|
|
6450
|
-
* @generated from field: string
|
|
6406
|
+
* @generated from field: string root = 3;
|
|
6451
6407
|
*/
|
|
6452
|
-
__publicField(this, "
|
|
6408
|
+
__publicField(this, "root", "");
|
|
6453
6409
|
/**
|
|
6454
6410
|
* @generated from field: int32 attached_clients = 7;
|
|
6455
6411
|
*/
|
|
@@ -6462,6 +6418,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6462
6418
|
* @generated from field: string schema_key = 9;
|
|
6463
6419
|
*/
|
|
6464
6420
|
__publicField(this, "schemaKey", "");
|
|
6421
|
+
/**
|
|
6422
|
+
* @generated from field: map<string, yorkie.v1.Presence> presences = 10;
|
|
6423
|
+
*/
|
|
6424
|
+
__publicField(this, "presences", {});
|
|
6465
6425
|
/**
|
|
6466
6426
|
* @generated from field: google.protobuf.Timestamp created_at = 4;
|
|
6467
6427
|
*/
|
|
@@ -6508,7 +6468,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6508
6468
|
},
|
|
6509
6469
|
{
|
|
6510
6470
|
no: 3,
|
|
6511
|
-
name: "
|
|
6471
|
+
name: "root",
|
|
6512
6472
|
kind: "scalar",
|
|
6513
6473
|
T: 9
|
|
6514
6474
|
/* ScalarType.STRING */
|
|
@@ -6528,6 +6488,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6528
6488
|
T: 9
|
|
6529
6489
|
/* ScalarType.STRING */
|
|
6530
6490
|
},
|
|
6491
|
+
{ no: 10, name: "presences", kind: "map", K: 9, V: { kind: "message", T: Presence$1 } },
|
|
6531
6492
|
{ no: 4, name: "created_at", kind: "message", T: Timestamp },
|
|
6532
6493
|
{ no: 5, name: "accessed_at", kind: "message", T: Timestamp },
|
|
6533
6494
|
{ no: 6, name: "updated_at", kind: "message", T: Timestamp }
|
|
@@ -8282,7 +8243,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8282
8243
|
* `remove` removes this element.
|
|
8283
8244
|
*/
|
|
8284
8245
|
remove(removedAt) {
|
|
8285
|
-
if (removedAt && removedAt.after(this.
|
|
8246
|
+
if (removedAt && removedAt.after(this.createdAt) && (!this.removedAt || removedAt.after(this.removedAt))) {
|
|
8286
8247
|
this.removedAt = removedAt;
|
|
8287
8248
|
return true;
|
|
8288
8249
|
}
|
|
@@ -10316,6 +10277,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10316
10277
|
super(value);
|
|
10317
10278
|
__publicField(this, "prev");
|
|
10318
10279
|
__publicField(this, "next");
|
|
10280
|
+
__publicField(this, "movedFrom");
|
|
10319
10281
|
this.value = value;
|
|
10320
10282
|
}
|
|
10321
10283
|
/**
|
|
@@ -10382,6 +10344,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10382
10344
|
getNext() {
|
|
10383
10345
|
return this.next;
|
|
10384
10346
|
}
|
|
10347
|
+
/**
|
|
10348
|
+
* `getMovedFrom` returns the previous element before the element moved.
|
|
10349
|
+
*/
|
|
10350
|
+
getMovedFrom() {
|
|
10351
|
+
return this.movedFrom;
|
|
10352
|
+
}
|
|
10353
|
+
/**
|
|
10354
|
+
* `setMovedFrom` sets the previous element before the element moved.
|
|
10355
|
+
*/
|
|
10356
|
+
setMovedFrom(movedFrom) {
|
|
10357
|
+
this.movedFrom = movedFrom;
|
|
10358
|
+
}
|
|
10385
10359
|
/**
|
|
10386
10360
|
* `getValue` returns a element value.
|
|
10387
10361
|
*/
|
|
@@ -10441,6 +10415,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10441
10415
|
`cant find the given node: ${createdAt.toIDString()}`
|
|
10442
10416
|
);
|
|
10443
10417
|
}
|
|
10418
|
+
while (node.getValue().getMovedAt() && node.getValue().getMovedAt().after(executedAt) && node.getMovedFrom()) {
|
|
10419
|
+
node = node.getMovedFrom();
|
|
10420
|
+
}
|
|
10444
10421
|
while (node.getNext() && node.getNext().getPositionedAt().after(executedAt)) {
|
|
10445
10422
|
node = node.getNext();
|
|
10446
10423
|
}
|
|
@@ -10465,30 +10442,51 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10465
10442
|
}
|
|
10466
10443
|
this.nodeMapByIndex.insertAfter(prevNode, newNode);
|
|
10467
10444
|
this.nodeMapByCreatedAt.set(newNode.getCreatedAt().toIDString(), newNode);
|
|
10445
|
+
return newNode;
|
|
10468
10446
|
}
|
|
10469
10447
|
/**
|
|
10470
10448
|
* `moveAfter` moves the given `createdAt` element
|
|
10471
10449
|
* after the `prevCreatedAt` element.
|
|
10472
10450
|
*/
|
|
10473
10451
|
moveAfter(prevCreatedAt, createdAt, executedAt) {
|
|
10474
|
-
|
|
10452
|
+
let prevNode = this.nodeMapByCreatedAt.get(prevCreatedAt.toIDString());
|
|
10475
10453
|
if (!prevNode) {
|
|
10476
10454
|
throw new YorkieError(
|
|
10477
10455
|
Code.ErrInvalidArgument,
|
|
10478
10456
|
`cant find the given node: ${prevCreatedAt.toIDString()}`
|
|
10479
10457
|
);
|
|
10480
10458
|
}
|
|
10481
|
-
|
|
10459
|
+
let node = this.nodeMapByCreatedAt.get(createdAt.toIDString());
|
|
10482
10460
|
if (!node) {
|
|
10483
10461
|
throw new YorkieError(
|
|
10484
10462
|
Code.ErrInvalidArgument,
|
|
10485
10463
|
`cant find the given node: ${createdAt.toIDString()}`
|
|
10486
10464
|
);
|
|
10487
10465
|
}
|
|
10488
|
-
if (prevNode !== node &&
|
|
10466
|
+
if (prevNode !== node && executedAt.after(node.getPositionedAt())) {
|
|
10467
|
+
const movedFrom = node.getPrev();
|
|
10468
|
+
let nextNode = node.getNext();
|
|
10489
10469
|
this.release(node);
|
|
10490
|
-
this.insertAfter(
|
|
10470
|
+
node = this.insertAfter(
|
|
10471
|
+
prevNode.getCreatedAt(),
|
|
10472
|
+
node.getValue(),
|
|
10473
|
+
executedAt
|
|
10474
|
+
);
|
|
10491
10475
|
node.getValue().setMovedAt(executedAt);
|
|
10476
|
+
node.setMovedFrom(movedFrom);
|
|
10477
|
+
while (nextNode && nextNode.getPositionedAt().after(executedAt)) {
|
|
10478
|
+
prevNode = node;
|
|
10479
|
+
node = nextNode;
|
|
10480
|
+
nextNode = node.getNext();
|
|
10481
|
+
this.release(node);
|
|
10482
|
+
node = this.insertAfter(
|
|
10483
|
+
prevNode.getCreatedAt(),
|
|
10484
|
+
node.getValue(),
|
|
10485
|
+
executedAt
|
|
10486
|
+
);
|
|
10487
|
+
node.getValue().setMovedAt(executedAt);
|
|
10488
|
+
node.setMovedFrom(movedFrom);
|
|
10489
|
+
}
|
|
10492
10490
|
}
|
|
10493
10491
|
}
|
|
10494
10492
|
/**
|
|
@@ -10567,6 +10565,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10567
10565
|
}
|
|
10568
10566
|
return node.getValue();
|
|
10569
10567
|
}
|
|
10568
|
+
/**
|
|
10569
|
+
* `set` sets the given element at the given creation time.
|
|
10570
|
+
*/
|
|
10571
|
+
set(createdAt, element, executedAt) {
|
|
10572
|
+
const node = this.nodeMapByCreatedAt.get(createdAt.toIDString());
|
|
10573
|
+
if (!node) {
|
|
10574
|
+
throw new YorkieError(
|
|
10575
|
+
Code.ErrInvalidArgument,
|
|
10576
|
+
`cant find the given node: ${createdAt.toIDString()}`
|
|
10577
|
+
);
|
|
10578
|
+
}
|
|
10579
|
+
this.insertAfter(node.getCreatedAt(), element, executedAt);
|
|
10580
|
+
return this.delete(createdAt, executedAt);
|
|
10581
|
+
}
|
|
10570
10582
|
/**
|
|
10571
10583
|
* `deleteByIndex` deletes the node of the given index.
|
|
10572
10584
|
*/
|
|
@@ -10710,6 +10722,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10710
10722
|
deleteByIndex(index, editedAt) {
|
|
10711
10723
|
return this.elements.deleteByIndex(index, editedAt);
|
|
10712
10724
|
}
|
|
10725
|
+
/**
|
|
10726
|
+
* `set` sets the given element at the given position of the creation time.
|
|
10727
|
+
*/
|
|
10728
|
+
set(createdAt, value, executedAt) {
|
|
10729
|
+
return this.elements.set(createdAt, value, executedAt);
|
|
10730
|
+
}
|
|
10713
10731
|
/**
|
|
10714
10732
|
* `getLastCreatedAt` get last created element.
|
|
10715
10733
|
*/
|
|
@@ -16126,6 +16144,77 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16126
16144
|
return this.attributesToRemove;
|
|
16127
16145
|
}
|
|
16128
16146
|
}
|
|
16147
|
+
class ArraySetOperation extends Operation {
|
|
16148
|
+
constructor(parentCreatedAt, createdAt, value, executedAt) {
|
|
16149
|
+
super(parentCreatedAt, executedAt);
|
|
16150
|
+
__publicField(this, "createdAt");
|
|
16151
|
+
__publicField(this, "value");
|
|
16152
|
+
this.createdAt = createdAt;
|
|
16153
|
+
this.value = value;
|
|
16154
|
+
}
|
|
16155
|
+
/**
|
|
16156
|
+
* `create` creates a new instance of ArraySetOperation.
|
|
16157
|
+
*/
|
|
16158
|
+
static create(parentCreatedAt, createdAt, value, executedAt) {
|
|
16159
|
+
return new ArraySetOperation(parentCreatedAt, createdAt, value, executedAt);
|
|
16160
|
+
}
|
|
16161
|
+
/**
|
|
16162
|
+
* `execute` executes this operation on the given `CRDTRoot`.
|
|
16163
|
+
*/
|
|
16164
|
+
execute(root) {
|
|
16165
|
+
const parentObject = root.findByCreatedAt(this.getParentCreatedAt());
|
|
16166
|
+
if (!parentObject) {
|
|
16167
|
+
throw new YorkieError(
|
|
16168
|
+
Code.ErrInvalidArgument,
|
|
16169
|
+
`fail to find ${this.getParentCreatedAt()}`
|
|
16170
|
+
);
|
|
16171
|
+
}
|
|
16172
|
+
if (!(parentObject instanceof CRDTArray)) {
|
|
16173
|
+
throw new YorkieError(
|
|
16174
|
+
Code.ErrInvalidArgument,
|
|
16175
|
+
`fail to execute, only array can execute set`
|
|
16176
|
+
);
|
|
16177
|
+
}
|
|
16178
|
+
const value = this.value.deepcopy();
|
|
16179
|
+
parentObject.insertAfter(this.createdAt, value, this.getExecutedAt());
|
|
16180
|
+
parentObject.delete(this.createdAt, this.getExecutedAt());
|
|
16181
|
+
root.registerElement(value);
|
|
16182
|
+
const reverseOp = void 0;
|
|
16183
|
+
return {
|
|
16184
|
+
opInfos: [
|
|
16185
|
+
{
|
|
16186
|
+
type: "array-set",
|
|
16187
|
+
path: root.createPath(this.getParentCreatedAt())
|
|
16188
|
+
}
|
|
16189
|
+
],
|
|
16190
|
+
reverseOp
|
|
16191
|
+
};
|
|
16192
|
+
}
|
|
16193
|
+
/**
|
|
16194
|
+
* `getEffectedCreatedAt` returns the creation time of the effected element.
|
|
16195
|
+
*/
|
|
16196
|
+
getEffectedCreatedAt() {
|
|
16197
|
+
return this.createdAt;
|
|
16198
|
+
}
|
|
16199
|
+
/**
|
|
16200
|
+
* `toTestString` returns a string containing the meta data.
|
|
16201
|
+
*/
|
|
16202
|
+
toTestString() {
|
|
16203
|
+
return `${this.getParentCreatedAt().toTestString()}.ARRAY_SET.${this.createdAt.toTestString()}=${this.value.toSortedJSON()}`;
|
|
16204
|
+
}
|
|
16205
|
+
/**
|
|
16206
|
+
* `getCreatedAt` returns the creation time of the target element.
|
|
16207
|
+
*/
|
|
16208
|
+
getCreatedAt() {
|
|
16209
|
+
return this.createdAt;
|
|
16210
|
+
}
|
|
16211
|
+
/**
|
|
16212
|
+
* `getValue` returns the value of this operation.
|
|
16213
|
+
*/
|
|
16214
|
+
getValue() {
|
|
16215
|
+
return this.value;
|
|
16216
|
+
}
|
|
16217
|
+
}
|
|
16129
16218
|
function toPresence(presence) {
|
|
16130
16219
|
const pbPresence = new Presence$1();
|
|
16131
16220
|
const pbDataMap = pbPresence.data;
|
|
@@ -16178,7 +16267,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16178
16267
|
}
|
|
16179
16268
|
const pbVector = new VersionVector$1();
|
|
16180
16269
|
for (const [actorID, lamport] of vector) {
|
|
16181
|
-
|
|
16270
|
+
const base64ActorID = uint8ArrayToBase64(toUint8Array(actorID));
|
|
16271
|
+
pbVector.vector[base64ActorID] = BigInt(lamport.toString());
|
|
16182
16272
|
}
|
|
16183
16273
|
return pbVector;
|
|
16184
16274
|
}
|
|
@@ -16422,6 +16512,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16422
16512
|
);
|
|
16423
16513
|
pbOperation.body.case = "treeStyle";
|
|
16424
16514
|
pbOperation.body.value = pbTreeStyleOperation;
|
|
16515
|
+
} else if (operation instanceof ArraySetOperation) {
|
|
16516
|
+
const arraySetOperation = operation;
|
|
16517
|
+
const pbArraySetOperation = new Operation_ArraySet();
|
|
16518
|
+
pbArraySetOperation.parentCreatedAt = toTimeTicket(
|
|
16519
|
+
arraySetOperation.getParentCreatedAt()
|
|
16520
|
+
);
|
|
16521
|
+
pbArraySetOperation.createdAt = toTimeTicket(
|
|
16522
|
+
arraySetOperation.getCreatedAt()
|
|
16523
|
+
);
|
|
16524
|
+
pbArraySetOperation.value = toElementSimple(arraySetOperation.getValue());
|
|
16525
|
+
pbArraySetOperation.executedAt = toTimeTicket(
|
|
16526
|
+
arraySetOperation.getExecutedAt()
|
|
16527
|
+
);
|
|
16528
|
+
pbOperation.body.case = "arraySet";
|
|
16529
|
+
pbOperation.body.value = pbArraySetOperation;
|
|
16425
16530
|
} else {
|
|
16426
16531
|
throw new YorkieError(Code.ErrUnimplemented, "unimplemented operation");
|
|
16427
16532
|
}
|
|
@@ -16676,7 +16781,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16676
16781
|
}
|
|
16677
16782
|
const vector = new VersionVector();
|
|
16678
16783
|
Object.entries(pbVersionVector.vector).forEach(([key, value]) => {
|
|
16679
|
-
|
|
16784
|
+
const hexKey = bytesToHex(base64ToUint8Array(key));
|
|
16785
|
+
vector.set(hexKey, BigInt(value.toString()));
|
|
16680
16786
|
});
|
|
16681
16787
|
return vector;
|
|
16682
16788
|
}
|
|
@@ -16960,8 +17066,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16960
17066
|
attributes,
|
|
16961
17067
|
fromTimeTicket(pbStyleOperation.executedAt)
|
|
16962
17068
|
);
|
|
16963
|
-
} else if (pbOperation.body.case === "select") {
|
|
16964
|
-
return;
|
|
16965
17069
|
} else if (pbOperation.body.case === "increase") {
|
|
16966
17070
|
const pbIncreaseOperation = pbOperation.body.value;
|
|
16967
17071
|
return IncreaseOperation.create(
|
|
@@ -17005,6 +17109,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17005
17109
|
fromTimeTicket(pbTreeStyleOperation.executedAt)
|
|
17006
17110
|
);
|
|
17007
17111
|
}
|
|
17112
|
+
} else if (pbOperation.body.case === "arraySet") {
|
|
17113
|
+
const pbArraySetOperation = pbOperation.body.value;
|
|
17114
|
+
return ArraySetOperation.create(
|
|
17115
|
+
fromTimeTicket(pbArraySetOperation.parentCreatedAt),
|
|
17116
|
+
fromTimeTicket(pbArraySetOperation.createdAt),
|
|
17117
|
+
fromElementSimple(pbArraySetOperation.value),
|
|
17118
|
+
fromTimeTicket(pbArraySetOperation.executedAt)
|
|
17119
|
+
);
|
|
17008
17120
|
} else {
|
|
17009
17121
|
throw new YorkieError(Code.ErrUnimplemented, `unimplemented operation`);
|
|
17010
17122
|
}
|
|
@@ -17204,9 +17316,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17204
17316
|
hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))
|
|
17205
17317
|
);
|
|
17206
17318
|
}
|
|
17319
|
+
function base64ToUint8Array(base64) {
|
|
17320
|
+
if (typeof window !== "undefined" && typeof window.atob === "function") {
|
|
17321
|
+
const binary = window.atob(base64);
|
|
17322
|
+
const len = binary.length;
|
|
17323
|
+
const bytes = new Uint8Array(len);
|
|
17324
|
+
for (let i = 0; i < len; i++) {
|
|
17325
|
+
bytes[i] = binary.charCodeAt(i);
|
|
17326
|
+
}
|
|
17327
|
+
return bytes;
|
|
17328
|
+
} else if (typeof globalThis !== "undefined" && typeof globalThis.Buffer !== "undefined") {
|
|
17329
|
+
const Buffer2 = globalThis.Buffer;
|
|
17330
|
+
return new Uint8Array(Buffer2.from(base64, "base64"));
|
|
17331
|
+
} else {
|
|
17332
|
+
throw new Error("No base64 decoder available");
|
|
17333
|
+
}
|
|
17334
|
+
}
|
|
17207
17335
|
function toUint8Array(hex) {
|
|
17208
17336
|
return hexToBytes(hex);
|
|
17209
17337
|
}
|
|
17338
|
+
function uint8ArrayToBase64(bytes) {
|
|
17339
|
+
if (typeof window !== "undefined" && typeof window.btoa === "function") {
|
|
17340
|
+
let binary = "";
|
|
17341
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
17342
|
+
binary += String.fromCharCode(bytes[i]);
|
|
17343
|
+
}
|
|
17344
|
+
return window.btoa(binary);
|
|
17345
|
+
} else if (typeof globalThis !== "undefined" && typeof globalThis.Buffer !== "undefined") {
|
|
17346
|
+
const Buffer2 = globalThis.Buffer;
|
|
17347
|
+
return Buffer2.from(bytes).toString("base64");
|
|
17348
|
+
} else {
|
|
17349
|
+
throw new Error("No base64 encoder available");
|
|
17350
|
+
}
|
|
17351
|
+
}
|
|
17210
17352
|
function bytesToChangeID(bytes) {
|
|
17211
17353
|
const pbChangeID = ChangeID$1.fromBinary(bytes);
|
|
17212
17354
|
return fromChangeID(pbChangeID);
|
|
@@ -18277,6 +18419,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18277
18419
|
return () => {
|
|
18278
18420
|
return toWrappedElement(context, target.getLast());
|
|
18279
18421
|
};
|
|
18422
|
+
} else if (method === "delete") {
|
|
18423
|
+
return (index) => {
|
|
18424
|
+
const deleted = ArrayProxy.deleteInternalByIndex(
|
|
18425
|
+
context,
|
|
18426
|
+
target,
|
|
18427
|
+
index
|
|
18428
|
+
);
|
|
18429
|
+
return toWrappedElement(context, deleted);
|
|
18430
|
+
};
|
|
18280
18431
|
} else if (method === "deleteByID") {
|
|
18281
18432
|
return (createdAt) => {
|
|
18282
18433
|
const deleted = ArrayProxy.deleteInternalByID(
|
|
@@ -18296,6 +18447,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18296
18447
|
);
|
|
18297
18448
|
return toWrappedElement(context, inserted);
|
|
18298
18449
|
};
|
|
18450
|
+
} else if (method === "insertIntegerAfter") {
|
|
18451
|
+
return (index, value) => {
|
|
18452
|
+
const array2 = ArrayProxy.insertIntegerAfterInternal(
|
|
18453
|
+
context,
|
|
18454
|
+
target,
|
|
18455
|
+
index,
|
|
18456
|
+
value
|
|
18457
|
+
);
|
|
18458
|
+
return toWrappedElement(context, array2);
|
|
18459
|
+
};
|
|
18299
18460
|
} else if (method === "insertBefore") {
|
|
18300
18461
|
return (nextID, value) => {
|
|
18301
18462
|
const inserted = ArrayProxy.insertBeforeInternal(
|
|
@@ -18306,6 +18467,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18306
18467
|
);
|
|
18307
18468
|
return toWrappedElement(context, inserted);
|
|
18308
18469
|
};
|
|
18470
|
+
} else if (method === "setInteger") {
|
|
18471
|
+
return (index, value) => {
|
|
18472
|
+
const array2 = ArrayProxy.setIntegerInternal(
|
|
18473
|
+
context,
|
|
18474
|
+
target,
|
|
18475
|
+
index,
|
|
18476
|
+
value
|
|
18477
|
+
);
|
|
18478
|
+
return toWrappedElement(context, array2);
|
|
18479
|
+
};
|
|
18309
18480
|
} else if (method === "moveBefore") {
|
|
18310
18481
|
return (nextID, id) => {
|
|
18311
18482
|
ArrayProxy.moveBeforeInternal(context, target, nextID, id);
|
|
@@ -18314,6 +18485,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18314
18485
|
return (prevID, id) => {
|
|
18315
18486
|
ArrayProxy.moveAfterInternal(context, target, prevID, id);
|
|
18316
18487
|
};
|
|
18488
|
+
} else if (method === "moveAfterByIndex") {
|
|
18489
|
+
return (prevIndex, targetIndex) => {
|
|
18490
|
+
ArrayProxy.moveAfterByIndexInternal(
|
|
18491
|
+
context,
|
|
18492
|
+
target,
|
|
18493
|
+
prevIndex,
|
|
18494
|
+
targetIndex
|
|
18495
|
+
);
|
|
18496
|
+
};
|
|
18317
18497
|
} else if (method === "moveFront") {
|
|
18318
18498
|
return (id) => {
|
|
18319
18499
|
ArrayProxy.moveFrontInternal(context, target, id);
|
|
@@ -18447,7 +18627,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18447
18627
|
*/
|
|
18448
18628
|
static moveAfterInternal(context, target, prevCreatedAt, createdAt) {
|
|
18449
18629
|
const ticket = context.issueTimeTicket();
|
|
18450
|
-
target.moveAfter(prevCreatedAt, createdAt, ticket);
|
|
18451
18630
|
context.push(
|
|
18452
18631
|
MoveOperation.create(
|
|
18453
18632
|
target.getCreatedAt(),
|
|
@@ -18456,6 +18635,33 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18456
18635
|
ticket
|
|
18457
18636
|
)
|
|
18458
18637
|
);
|
|
18638
|
+
target.moveAfter(prevCreatedAt, createdAt, ticket);
|
|
18639
|
+
}
|
|
18640
|
+
/**
|
|
18641
|
+
* `moveAfterByIndexInternal` moves the given element to its new position
|
|
18642
|
+
* after the given previous element.
|
|
18643
|
+
*/
|
|
18644
|
+
static moveAfterByIndexInternal(context, target, prevIndex, targetIndex) {
|
|
18645
|
+
const prevElem = target.get(prevIndex);
|
|
18646
|
+
if (!prevElem) {
|
|
18647
|
+
throw new YorkieError(
|
|
18648
|
+
Code.ErrInvalidArgument,
|
|
18649
|
+
`index out of bounds: ${prevIndex}`
|
|
18650
|
+
);
|
|
18651
|
+
}
|
|
18652
|
+
const targetElem = target.get(targetIndex);
|
|
18653
|
+
if (!targetElem) {
|
|
18654
|
+
throw new YorkieError(
|
|
18655
|
+
Code.ErrInvalidArgument,
|
|
18656
|
+
`index out of bounds: ${targetIndex}`
|
|
18657
|
+
);
|
|
18658
|
+
}
|
|
18659
|
+
ArrayProxy.moveAfterInternal(
|
|
18660
|
+
context,
|
|
18661
|
+
target,
|
|
18662
|
+
prevElem.getCreatedAt(),
|
|
18663
|
+
targetElem.getCreatedAt()
|
|
18664
|
+
);
|
|
18459
18665
|
}
|
|
18460
18666
|
/**
|
|
18461
18667
|
* `moveFrontInternal` moves the given `createdAt` element
|
|
@@ -18504,6 +18710,25 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18504
18710
|
);
|
|
18505
18711
|
return element;
|
|
18506
18712
|
}
|
|
18713
|
+
/**
|
|
18714
|
+
* `insertIntegerAfterInternal` inserts the given integer after the given previous element.
|
|
18715
|
+
*/
|
|
18716
|
+
static insertIntegerAfterInternal(context, target, index, value) {
|
|
18717
|
+
const prevElem = target.get(index);
|
|
18718
|
+
if (!prevElem) {
|
|
18719
|
+
throw new YorkieError(
|
|
18720
|
+
Code.ErrInvalidArgument,
|
|
18721
|
+
`index out of bounds: ${index}`
|
|
18722
|
+
);
|
|
18723
|
+
}
|
|
18724
|
+
ArrayProxy.insertAfterInternal(
|
|
18725
|
+
context,
|
|
18726
|
+
target,
|
|
18727
|
+
prevElem.getCreatedAt(),
|
|
18728
|
+
value
|
|
18729
|
+
);
|
|
18730
|
+
return target;
|
|
18731
|
+
}
|
|
18507
18732
|
/**
|
|
18508
18733
|
* `insertBeforeInternal` inserts the value before the previously created element.
|
|
18509
18734
|
*/
|
|
@@ -18515,6 +18740,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18515
18740
|
value
|
|
18516
18741
|
);
|
|
18517
18742
|
}
|
|
18743
|
+
/**
|
|
18744
|
+
* `setIntegerInternal` sets the given integer at the given index.
|
|
18745
|
+
*/
|
|
18746
|
+
static setIntegerInternal(context, target, index, value) {
|
|
18747
|
+
const prev = target.get(index);
|
|
18748
|
+
if (!prev) {
|
|
18749
|
+
throw new YorkieError(
|
|
18750
|
+
Code.ErrInvalidArgument,
|
|
18751
|
+
`index out of bounds: ${index}`
|
|
18752
|
+
);
|
|
18753
|
+
}
|
|
18754
|
+
ArrayProxy.setByIndexInternal(context, target, prev.getCreatedAt(), value);
|
|
18755
|
+
return target;
|
|
18756
|
+
}
|
|
18757
|
+
/**
|
|
18758
|
+
* `setByIndexInternal` sets the element of the given index.
|
|
18759
|
+
*/
|
|
18760
|
+
static setByIndexInternal(context, target, createdAt, value) {
|
|
18761
|
+
const ticket = context.issueTimeTicket();
|
|
18762
|
+
const element = buildCRDTElement(context, value, ticket);
|
|
18763
|
+
const copiedValue = element.deepcopy();
|
|
18764
|
+
context.push(
|
|
18765
|
+
ArraySetOperation.create(
|
|
18766
|
+
target.getCreatedAt(),
|
|
18767
|
+
createdAt,
|
|
18768
|
+
copiedValue,
|
|
18769
|
+
ticket
|
|
18770
|
+
)
|
|
18771
|
+
);
|
|
18772
|
+
target.set(createdAt, element, ticket);
|
|
18773
|
+
context.registerElement(element, target);
|
|
18774
|
+
return element;
|
|
18775
|
+
}
|
|
18518
18776
|
/**
|
|
18519
18777
|
* `deleteInternalByIndex` deletes target element of given index.
|
|
18520
18778
|
*/
|
|
@@ -21266,7 +21524,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
21266
21524
|
};
|
|
21267
21525
|
}
|
|
21268
21526
|
const name = "@yorkie-js/sdk";
|
|
21269
|
-
const version = "0.6.
|
|
21527
|
+
const version = "0.6.23";
|
|
21270
21528
|
const pkg = {
|
|
21271
21529
|
name,
|
|
21272
21530
|
version
|