@yorkie-js/react 0.6.26 → 0.6.28
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 +149 -17
- package/dist/yorkie-js-react.es.js.map +1 -1
- package/dist/yorkie-js-react.js +149 -17
- package/dist/yorkie-js-react.js.map +1 -1
- package/package.json +2 -2
|
@@ -7086,6 +7086,10 @@ const _DeactivateClientRequest = class _DeactivateClientRequest extends Message
|
|
|
7086
7086
|
* @generated from field: string client_id = 1;
|
|
7087
7087
|
*/
|
|
7088
7088
|
__publicField(this, "clientId", "");
|
|
7089
|
+
/**
|
|
7090
|
+
* @generated from field: bool synchronous = 2;
|
|
7091
|
+
*/
|
|
7092
|
+
__publicField(this, "synchronous", false);
|
|
7089
7093
|
proto3.util.initPartial(data, this);
|
|
7090
7094
|
}
|
|
7091
7095
|
static fromBinary(bytes, options) {
|
|
@@ -7110,6 +7114,13 @@ __publicField(_DeactivateClientRequest, "fields", proto3.util.newFieldList(() =>
|
|
|
7110
7114
|
kind: "scalar",
|
|
7111
7115
|
T: 9
|
|
7112
7116
|
/* ScalarType.STRING */
|
|
7117
|
+
},
|
|
7118
|
+
{
|
|
7119
|
+
no: 2,
|
|
7120
|
+
name: "synchronous",
|
|
7121
|
+
kind: "scalar",
|
|
7122
|
+
T: 8
|
|
7123
|
+
/* ScalarType.BOOL */
|
|
7113
7124
|
}
|
|
7114
7125
|
]));
|
|
7115
7126
|
let DeactivateClientRequest = _DeactivateClientRequest;
|
|
@@ -8259,6 +8270,12 @@ class CRDTElement {
|
|
|
8259
8270
|
}
|
|
8260
8271
|
return this.movedAt;
|
|
8261
8272
|
}
|
|
8273
|
+
/**
|
|
8274
|
+
* `setCreatedAt` sets the creation time of this element manually.
|
|
8275
|
+
*/
|
|
8276
|
+
setCreatedAt(createdAt) {
|
|
8277
|
+
this.createdAt = createdAt;
|
|
8278
|
+
}
|
|
8262
8279
|
/**
|
|
8263
8280
|
* `setMovedAt` sets the move time of this element.
|
|
8264
8281
|
*/
|
|
@@ -10957,6 +10974,12 @@ class AddOperation extends Operation {
|
|
|
10957
10974
|
getValue() {
|
|
10958
10975
|
return this.value;
|
|
10959
10976
|
}
|
|
10977
|
+
/**
|
|
10978
|
+
* `setPrevCreatedAt` sets the creation time of the previous element.
|
|
10979
|
+
*/
|
|
10980
|
+
setPrevCreatedAt(createdAt) {
|
|
10981
|
+
this.prevCreatedAt = createdAt;
|
|
10982
|
+
}
|
|
10960
10983
|
}
|
|
10961
10984
|
class RemoveOperation extends Operation {
|
|
10962
10985
|
constructor(parentCreatedAt, createdAt, executedAt) {
|
|
@@ -11067,6 +11090,12 @@ class RemoveOperation extends Operation {
|
|
|
11067
11090
|
getCreatedAt() {
|
|
11068
11091
|
return this.createdAt;
|
|
11069
11092
|
}
|
|
11093
|
+
/**
|
|
11094
|
+
* `setCreatedAt` sets the creation time of the target element.
|
|
11095
|
+
*/
|
|
11096
|
+
setCreatedAt(createdAt) {
|
|
11097
|
+
this.createdAt = createdAt;
|
|
11098
|
+
}
|
|
11070
11099
|
}
|
|
11071
11100
|
class SetOperation extends Operation {
|
|
11072
11101
|
constructor(key, value, parentCreatedAt, executedAt) {
|
|
@@ -11258,6 +11287,18 @@ class MoveOperation extends Operation {
|
|
|
11258
11287
|
getCreatedAt() {
|
|
11259
11288
|
return this.createdAt;
|
|
11260
11289
|
}
|
|
11290
|
+
/**
|
|
11291
|
+
* `setPrevCreatedAt` sets the creation time of the previous element.
|
|
11292
|
+
*/
|
|
11293
|
+
setPrevCreatedAt(createdAt) {
|
|
11294
|
+
this.prevCreatedAt = createdAt;
|
|
11295
|
+
}
|
|
11296
|
+
/**
|
|
11297
|
+
* `setCreatedAt` sets the creation time of the target element.
|
|
11298
|
+
*/
|
|
11299
|
+
setCreatedAt(createdAt) {
|
|
11300
|
+
this.createdAt = createdAt;
|
|
11301
|
+
}
|
|
11261
11302
|
}
|
|
11262
11303
|
class RHTNode {
|
|
11263
11304
|
constructor(key, value, updatedAt, isRemoved) {
|
|
@@ -16222,11 +16263,12 @@ class ArraySetOperation extends Operation {
|
|
|
16222
16263
|
`fail to execute, only array can execute set`
|
|
16223
16264
|
);
|
|
16224
16265
|
}
|
|
16266
|
+
const previousValue = parentObject.getByID(this.createdAt).deepcopy();
|
|
16267
|
+
const reverseOp = this.toReverseOperation(this.value, previousValue);
|
|
16225
16268
|
const value = this.value.deepcopy();
|
|
16226
16269
|
parentObject.insertAfter(this.createdAt, value, this.getExecutedAt());
|
|
16227
16270
|
parentObject.delete(this.createdAt, this.getExecutedAt());
|
|
16228
16271
|
root.registerElement(value);
|
|
16229
|
-
const reverseOp = void 0;
|
|
16230
16272
|
return {
|
|
16231
16273
|
opInfos: [
|
|
16232
16274
|
{
|
|
@@ -16237,6 +16279,17 @@ class ArraySetOperation extends Operation {
|
|
|
16237
16279
|
reverseOp
|
|
16238
16280
|
};
|
|
16239
16281
|
}
|
|
16282
|
+
/**
|
|
16283
|
+
* `toReverseOperation` returns the reverse operation of this operation.
|
|
16284
|
+
*/
|
|
16285
|
+
toReverseOperation(newValue, prevValue) {
|
|
16286
|
+
const reverseOp = ArraySetOperation.create(
|
|
16287
|
+
this.getParentCreatedAt(),
|
|
16288
|
+
newValue.getCreatedAt(),
|
|
16289
|
+
prevValue
|
|
16290
|
+
);
|
|
16291
|
+
return reverseOp;
|
|
16292
|
+
}
|
|
16240
16293
|
/**
|
|
16241
16294
|
* `getEffectedCreatedAt` returns the creation time of the effected element.
|
|
16242
16295
|
*/
|
|
@@ -16261,6 +16314,12 @@ class ArraySetOperation extends Operation {
|
|
|
16261
16314
|
getValue() {
|
|
16262
16315
|
return this.value;
|
|
16263
16316
|
}
|
|
16317
|
+
/**
|
|
16318
|
+
* `setCreatedAt` sets the creation time of the target element.
|
|
16319
|
+
*/
|
|
16320
|
+
setCreatedAt(createdAt) {
|
|
16321
|
+
this.createdAt = createdAt;
|
|
16322
|
+
}
|
|
16264
16323
|
}
|
|
16265
16324
|
function toPresence(presence) {
|
|
16266
16325
|
const pbPresence = new Presence$1();
|
|
@@ -17510,7 +17569,7 @@ function uuid() {
|
|
|
17510
17569
|
});
|
|
17511
17570
|
}
|
|
17512
17571
|
class Attachment {
|
|
17513
|
-
constructor(reconnectStreamDelay, doc, docID, syncMode,
|
|
17572
|
+
constructor(reconnectStreamDelay, doc, docID, syncMode, unsubscribeBroadcastEvent) {
|
|
17514
17573
|
// TODO(hackerwins): Consider to changing the modifiers of the following properties to private.
|
|
17515
17574
|
__publicField(this, "reconnectStreamDelay");
|
|
17516
17575
|
__publicField(this, "doc");
|
|
@@ -17528,7 +17587,7 @@ class Attachment {
|
|
|
17528
17587
|
this.syncMode = syncMode;
|
|
17529
17588
|
this.remoteChangeEventReceived = false;
|
|
17530
17589
|
this.cancelled = false;
|
|
17531
|
-
this.unsubscribeBroadcastEvent =
|
|
17590
|
+
this.unsubscribeBroadcastEvent = unsubscribeBroadcastEvent;
|
|
17532
17591
|
}
|
|
17533
17592
|
/**
|
|
17534
17593
|
* `changeSyncMode` changes the sync mode of the document.
|
|
@@ -20184,6 +20243,32 @@ class History {
|
|
|
20184
20243
|
getRedoStackForTest() {
|
|
20185
20244
|
return this.redoStack;
|
|
20186
20245
|
}
|
|
20246
|
+
/**
|
|
20247
|
+
* `reconcileCreatedAt` updates the createdAt and prevCreatedAt fields.
|
|
20248
|
+
*
|
|
20249
|
+
* When an element is replaced(e.g., UndoRemove as Add, or Set),
|
|
20250
|
+
* it receives a new createdAt(executedAt). However, existing history
|
|
20251
|
+
* operations may still reference the old createdAt or prevCreatedAt.
|
|
20252
|
+
*
|
|
20253
|
+
* This method scans both undo/redo stacks and replaces any matching
|
|
20254
|
+
* createdAt/prevCreatedAt with the new one, ensuring consistency.
|
|
20255
|
+
*/
|
|
20256
|
+
reconcileCreatedAt(prevCreatedAt, currCreatedAt) {
|
|
20257
|
+
const replace = (stack) => {
|
|
20258
|
+
for (const ops of stack) {
|
|
20259
|
+
for (const op of ops) {
|
|
20260
|
+
if ((op instanceof ArraySetOperation || op instanceof RemoveOperation || op instanceof MoveOperation) && op.getCreatedAt() === prevCreatedAt) {
|
|
20261
|
+
op.setCreatedAt(currCreatedAt);
|
|
20262
|
+
}
|
|
20263
|
+
if ((op instanceof AddOperation || op instanceof MoveOperation) && op.getPrevCreatedAt() === prevCreatedAt) {
|
|
20264
|
+
op.setPrevCreatedAt(currCreatedAt);
|
|
20265
|
+
}
|
|
20266
|
+
}
|
|
20267
|
+
}
|
|
20268
|
+
};
|
|
20269
|
+
replace(this.undoStack);
|
|
20270
|
+
replace(this.redoStack);
|
|
20271
|
+
}
|
|
20187
20272
|
}
|
|
20188
20273
|
const EventSourceDevPanel = "yorkie-devtools-panel";
|
|
20189
20274
|
const EventSourceSDK = "yorkie-devtools-sdk";
|
|
@@ -20441,6 +20526,14 @@ class Document {
|
|
|
20441
20526
|
this.presences,
|
|
20442
20527
|
OpSource.Local
|
|
20443
20528
|
);
|
|
20529
|
+
for (const op of change.getOperations()) {
|
|
20530
|
+
if (op instanceof ArraySetOperation) {
|
|
20531
|
+
this.internalHistory.reconcileCreatedAt(
|
|
20532
|
+
op.getCreatedAt(),
|
|
20533
|
+
op.getValue().getCreatedAt()
|
|
20534
|
+
);
|
|
20535
|
+
}
|
|
20536
|
+
}
|
|
20444
20537
|
const reversePresence = context.getReversePresence();
|
|
20445
20538
|
if (reversePresence) {
|
|
20446
20539
|
reverseOps.push({
|
|
@@ -21290,6 +21383,22 @@ class Document {
|
|
|
21290
21383
|
const p = this.presences.get(this.changeID.getActorID());
|
|
21291
21384
|
return p ? deepcopy(p) : {};
|
|
21292
21385
|
}
|
|
21386
|
+
/**
|
|
21387
|
+
* `getOthersPresences` returns the presences of all other clients.
|
|
21388
|
+
*/
|
|
21389
|
+
getOthersPresences() {
|
|
21390
|
+
const others = [];
|
|
21391
|
+
const myClientID = this.changeID.getActorID();
|
|
21392
|
+
for (const clientID of this.onlineClients) {
|
|
21393
|
+
if (clientID !== myClientID && this.presences.has(clientID)) {
|
|
21394
|
+
others.push({
|
|
21395
|
+
clientID,
|
|
21396
|
+
presence: deepcopy(this.presences.get(clientID))
|
|
21397
|
+
});
|
|
21398
|
+
}
|
|
21399
|
+
}
|
|
21400
|
+
return others;
|
|
21401
|
+
}
|
|
21293
21402
|
/**
|
|
21294
21403
|
* `getPresence` returns the presence of the given clientID.
|
|
21295
21404
|
*/
|
|
@@ -21301,16 +21410,6 @@ class Document {
|
|
|
21301
21410
|
const p = this.presences.get(clientID);
|
|
21302
21411
|
return p ? deepcopy(p) : void 0;
|
|
21303
21412
|
}
|
|
21304
|
-
/**
|
|
21305
|
-
* `getPresenceForTest` returns the presence of the given clientID
|
|
21306
|
-
* regardless of whether the client is online or not.
|
|
21307
|
-
*
|
|
21308
|
-
* @internal
|
|
21309
|
-
*/
|
|
21310
|
-
getPresenceForTest(clientID) {
|
|
21311
|
-
const p = this.presences.get(clientID);
|
|
21312
|
-
return p ? deepcopy(p) : void 0;
|
|
21313
|
-
}
|
|
21314
21413
|
/**
|
|
21315
21414
|
* `getPresences` returns the presences of online clients.
|
|
21316
21415
|
*/
|
|
@@ -21330,6 +21429,16 @@ class Document {
|
|
|
21330
21429
|
}
|
|
21331
21430
|
return presences;
|
|
21332
21431
|
}
|
|
21432
|
+
/**
|
|
21433
|
+
* `getPresenceForTest` returns the presence of the given clientID
|
|
21434
|
+
* regardless of whether the client is online or not.
|
|
21435
|
+
*
|
|
21436
|
+
* @internal
|
|
21437
|
+
*/
|
|
21438
|
+
getPresenceForTest(clientID) {
|
|
21439
|
+
const p = this.presences.get(clientID);
|
|
21440
|
+
return p ? deepcopy(p) : void 0;
|
|
21441
|
+
}
|
|
21333
21442
|
/**
|
|
21334
21443
|
* `getSelfForTest` returns the client that has attached this document.
|
|
21335
21444
|
*
|
|
@@ -21397,6 +21506,15 @@ class Document {
|
|
|
21397
21506
|
}
|
|
21398
21507
|
const ticket = context.issueTimeTicket();
|
|
21399
21508
|
undoOp.setExecutedAt(ticket);
|
|
21509
|
+
if (undoOp instanceof ArraySetOperation) {
|
|
21510
|
+
const prev = undoOp.getCreatedAt();
|
|
21511
|
+
undoOp.getValue().setCreatedAt(ticket);
|
|
21512
|
+
this.internalHistory.reconcileCreatedAt(prev, ticket);
|
|
21513
|
+
} else if (undoOp instanceof AddOperation) {
|
|
21514
|
+
const prev = undoOp.getValue().getCreatedAt();
|
|
21515
|
+
undoOp.getValue().setCreatedAt(ticket);
|
|
21516
|
+
this.internalHistory.reconcileCreatedAt(prev, ticket);
|
|
21517
|
+
}
|
|
21400
21518
|
context.push(undoOp);
|
|
21401
21519
|
}
|
|
21402
21520
|
const change = context.toChange();
|
|
@@ -21484,6 +21602,15 @@ class Document {
|
|
|
21484
21602
|
}
|
|
21485
21603
|
const ticket = context.issueTimeTicket();
|
|
21486
21604
|
redoOp.setExecutedAt(ticket);
|
|
21605
|
+
if (redoOp instanceof ArraySetOperation) {
|
|
21606
|
+
const prev = redoOp.getCreatedAt();
|
|
21607
|
+
redoOp.getValue().setCreatedAt(ticket);
|
|
21608
|
+
this.internalHistory.reconcileCreatedAt(prev, ticket);
|
|
21609
|
+
} else if (redoOp instanceof AddOperation) {
|
|
21610
|
+
const prev = redoOp.getValue().getCreatedAt();
|
|
21611
|
+
redoOp.getValue().setCreatedAt(ticket);
|
|
21612
|
+
this.internalHistory.reconcileCreatedAt(prev, ticket);
|
|
21613
|
+
}
|
|
21487
21614
|
context.push(redoOp);
|
|
21488
21615
|
}
|
|
21489
21616
|
const change = context.toChange();
|
|
@@ -21586,7 +21713,7 @@ function createAuthInterceptor(apiKey, token) {
|
|
|
21586
21713
|
};
|
|
21587
21714
|
}
|
|
21588
21715
|
const name$1 = "@yorkie-js/sdk";
|
|
21589
|
-
const version$1 = "0.6.
|
|
21716
|
+
const version$1 = "0.6.28";
|
|
21590
21717
|
const pkg$1 = {
|
|
21591
21718
|
name: name$1,
|
|
21592
21719
|
version: version$1
|
|
@@ -21739,15 +21866,20 @@ class Client {
|
|
|
21739
21866
|
* immediately using `fetch` with the `keepalive` option enabled. This is
|
|
21740
21867
|
* useful for ensuring the deactivation request completes even if the page is
|
|
21741
21868
|
* being unloaded, such as in `beforeunload` or `unload` event listeners.
|
|
21869
|
+
* If synchronous is true, the server will wait for all pending operations to
|
|
21870
|
+
* complete before deactivating.
|
|
21742
21871
|
*/
|
|
21743
|
-
deactivate(options = { keepalive: false }) {
|
|
21872
|
+
deactivate(options = { keepalive: false, synchronous: false }) {
|
|
21744
21873
|
if (this.status === "deactivated") {
|
|
21745
21874
|
return Promise.resolve();
|
|
21746
21875
|
}
|
|
21747
21876
|
const task = async () => {
|
|
21748
21877
|
try {
|
|
21749
21878
|
await this.rpcClient.deactivateClient(
|
|
21750
|
-
{
|
|
21879
|
+
{
|
|
21880
|
+
clientId: this.id,
|
|
21881
|
+
synchronous: options.synchronous
|
|
21882
|
+
},
|
|
21751
21883
|
{ headers: { "x-shard-key": `${this.apiKey}/${this.key}` } }
|
|
21752
21884
|
);
|
|
21753
21885
|
this.deactivateInternal();
|
|
@@ -22477,7 +22609,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
22477
22609
|
};
|
|
22478
22610
|
}
|
|
22479
22611
|
const name = "@yorkie-js/react";
|
|
22480
|
-
const version = "0.6.
|
|
22612
|
+
const version = "0.6.28";
|
|
22481
22613
|
const pkg = {
|
|
22482
22614
|
name,
|
|
22483
22615
|
version
|