@yorkie-js/react 0.6.26 → 0.6.27

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.
@@ -8259,6 +8259,12 @@ class CRDTElement {
8259
8259
  }
8260
8260
  return this.movedAt;
8261
8261
  }
8262
+ /**
8263
+ * `setCreatedAt` sets the creation time of this element manually.
8264
+ */
8265
+ setCreatedAt(createdAt) {
8266
+ this.createdAt = createdAt;
8267
+ }
8262
8268
  /**
8263
8269
  * `setMovedAt` sets the move time of this element.
8264
8270
  */
@@ -10957,6 +10963,12 @@ class AddOperation extends Operation {
10957
10963
  getValue() {
10958
10964
  return this.value;
10959
10965
  }
10966
+ /**
10967
+ * `setPrevCreatedAt` sets the creation time of the previous element.
10968
+ */
10969
+ setPrevCreatedAt(createdAt) {
10970
+ this.prevCreatedAt = createdAt;
10971
+ }
10960
10972
  }
10961
10973
  class RemoveOperation extends Operation {
10962
10974
  constructor(parentCreatedAt, createdAt, executedAt) {
@@ -11067,6 +11079,12 @@ class RemoveOperation extends Operation {
11067
11079
  getCreatedAt() {
11068
11080
  return this.createdAt;
11069
11081
  }
11082
+ /**
11083
+ * `setCreatedAt` sets the creation time of the target element.
11084
+ */
11085
+ setCreatedAt(createdAt) {
11086
+ this.createdAt = createdAt;
11087
+ }
11070
11088
  }
11071
11089
  class SetOperation extends Operation {
11072
11090
  constructor(key, value, parentCreatedAt, executedAt) {
@@ -11258,6 +11276,18 @@ class MoveOperation extends Operation {
11258
11276
  getCreatedAt() {
11259
11277
  return this.createdAt;
11260
11278
  }
11279
+ /**
11280
+ * `setPrevCreatedAt` sets the creation time of the previous element.
11281
+ */
11282
+ setPrevCreatedAt(createdAt) {
11283
+ this.prevCreatedAt = createdAt;
11284
+ }
11285
+ /**
11286
+ * `setCreatedAt` sets the creation time of the target element.
11287
+ */
11288
+ setCreatedAt(createdAt) {
11289
+ this.createdAt = createdAt;
11290
+ }
11261
11291
  }
11262
11292
  class RHTNode {
11263
11293
  constructor(key, value, updatedAt, isRemoved) {
@@ -16222,11 +16252,12 @@ class ArraySetOperation extends Operation {
16222
16252
  `fail to execute, only array can execute set`
16223
16253
  );
16224
16254
  }
16255
+ const previousValue = parentObject.getByID(this.createdAt).deepcopy();
16256
+ const reverseOp = this.toReverseOperation(this.value, previousValue);
16225
16257
  const value = this.value.deepcopy();
16226
16258
  parentObject.insertAfter(this.createdAt, value, this.getExecutedAt());
16227
16259
  parentObject.delete(this.createdAt, this.getExecutedAt());
16228
16260
  root.registerElement(value);
16229
- const reverseOp = void 0;
16230
16261
  return {
16231
16262
  opInfos: [
16232
16263
  {
@@ -16237,6 +16268,17 @@ class ArraySetOperation extends Operation {
16237
16268
  reverseOp
16238
16269
  };
16239
16270
  }
16271
+ /**
16272
+ * `toReverseOperation` returns the reverse operation of this operation.
16273
+ */
16274
+ toReverseOperation(newValue, prevValue) {
16275
+ const reverseOp = ArraySetOperation.create(
16276
+ this.getParentCreatedAt(),
16277
+ newValue.getCreatedAt(),
16278
+ prevValue
16279
+ );
16280
+ return reverseOp;
16281
+ }
16240
16282
  /**
16241
16283
  * `getEffectedCreatedAt` returns the creation time of the effected element.
16242
16284
  */
@@ -16261,6 +16303,12 @@ class ArraySetOperation extends Operation {
16261
16303
  getValue() {
16262
16304
  return this.value;
16263
16305
  }
16306
+ /**
16307
+ * `setCreatedAt` sets the creation time of the target element.
16308
+ */
16309
+ setCreatedAt(createdAt) {
16310
+ this.createdAt = createdAt;
16311
+ }
16264
16312
  }
16265
16313
  function toPresence(presence) {
16266
16314
  const pbPresence = new Presence$1();
@@ -17510,7 +17558,7 @@ function uuid() {
17510
17558
  });
17511
17559
  }
17512
17560
  class Attachment {
17513
- constructor(reconnectStreamDelay, doc, docID, syncMode, unsubscribeBroacastEvent) {
17561
+ constructor(reconnectStreamDelay, doc, docID, syncMode, unsubscribeBroadcastEvent) {
17514
17562
  // TODO(hackerwins): Consider to changing the modifiers of the following properties to private.
17515
17563
  __publicField(this, "reconnectStreamDelay");
17516
17564
  __publicField(this, "doc");
@@ -17528,7 +17576,7 @@ class Attachment {
17528
17576
  this.syncMode = syncMode;
17529
17577
  this.remoteChangeEventReceived = false;
17530
17578
  this.cancelled = false;
17531
- this.unsubscribeBroadcastEvent = unsubscribeBroacastEvent;
17579
+ this.unsubscribeBroadcastEvent = unsubscribeBroadcastEvent;
17532
17580
  }
17533
17581
  /**
17534
17582
  * `changeSyncMode` changes the sync mode of the document.
@@ -20184,6 +20232,32 @@ class History {
20184
20232
  getRedoStackForTest() {
20185
20233
  return this.redoStack;
20186
20234
  }
20235
+ /**
20236
+ * `reconcileCreatedAt` updates the createdAt and prevCreatedAt fields.
20237
+ *
20238
+ * When an element is replaced(e.g., UndoRemove as Add, or Set),
20239
+ * it receives a new createdAt(executedAt). However, existing history
20240
+ * operations may still reference the old createdAt or prevCreatedAt.
20241
+ *
20242
+ * This method scans both undo/redo stacks and replaces any matching
20243
+ * createdAt/prevCreatedAt with the new one, ensuring consistency.
20244
+ */
20245
+ reconcileCreatedAt(prevCreatedAt, currCreatedAt) {
20246
+ const replace = (stack) => {
20247
+ for (const ops of stack) {
20248
+ for (const op of ops) {
20249
+ if ((op instanceof ArraySetOperation || op instanceof RemoveOperation || op instanceof MoveOperation) && op.getCreatedAt() === prevCreatedAt) {
20250
+ op.setCreatedAt(currCreatedAt);
20251
+ }
20252
+ if ((op instanceof AddOperation || op instanceof MoveOperation) && op.getPrevCreatedAt() === prevCreatedAt) {
20253
+ op.setPrevCreatedAt(currCreatedAt);
20254
+ }
20255
+ }
20256
+ }
20257
+ };
20258
+ replace(this.undoStack);
20259
+ replace(this.redoStack);
20260
+ }
20187
20261
  }
20188
20262
  const EventSourceDevPanel = "yorkie-devtools-panel";
20189
20263
  const EventSourceSDK = "yorkie-devtools-sdk";
@@ -20441,6 +20515,14 @@ class Document {
20441
20515
  this.presences,
20442
20516
  OpSource.Local
20443
20517
  );
20518
+ for (const op of change.getOperations()) {
20519
+ if (op instanceof ArraySetOperation) {
20520
+ this.internalHistory.reconcileCreatedAt(
20521
+ op.getCreatedAt(),
20522
+ op.getValue().getCreatedAt()
20523
+ );
20524
+ }
20525
+ }
20444
20526
  const reversePresence = context.getReversePresence();
20445
20527
  if (reversePresence) {
20446
20528
  reverseOps.push({
@@ -21397,6 +21479,15 @@ class Document {
21397
21479
  }
21398
21480
  const ticket = context.issueTimeTicket();
21399
21481
  undoOp.setExecutedAt(ticket);
21482
+ if (undoOp instanceof ArraySetOperation) {
21483
+ const prev = undoOp.getCreatedAt();
21484
+ undoOp.getValue().setCreatedAt(ticket);
21485
+ this.internalHistory.reconcileCreatedAt(prev, ticket);
21486
+ } else if (undoOp instanceof AddOperation) {
21487
+ const prev = undoOp.getValue().getCreatedAt();
21488
+ undoOp.getValue().setCreatedAt(ticket);
21489
+ this.internalHistory.reconcileCreatedAt(prev, ticket);
21490
+ }
21400
21491
  context.push(undoOp);
21401
21492
  }
21402
21493
  const change = context.toChange();
@@ -21484,6 +21575,15 @@ class Document {
21484
21575
  }
21485
21576
  const ticket = context.issueTimeTicket();
21486
21577
  redoOp.setExecutedAt(ticket);
21578
+ if (redoOp instanceof ArraySetOperation) {
21579
+ const prev = redoOp.getCreatedAt();
21580
+ redoOp.getValue().setCreatedAt(ticket);
21581
+ this.internalHistory.reconcileCreatedAt(prev, ticket);
21582
+ } else if (redoOp instanceof AddOperation) {
21583
+ const prev = redoOp.getValue().getCreatedAt();
21584
+ redoOp.getValue().setCreatedAt(ticket);
21585
+ this.internalHistory.reconcileCreatedAt(prev, ticket);
21586
+ }
21487
21587
  context.push(redoOp);
21488
21588
  }
21489
21589
  const change = context.toChange();
@@ -21586,7 +21686,7 @@ function createAuthInterceptor(apiKey, token) {
21586
21686
  };
21587
21687
  }
21588
21688
  const name$1 = "@yorkie-js/sdk";
21589
- const version$1 = "0.6.26";
21689
+ const version$1 = "0.6.27";
21590
21690
  const pkg$1 = {
21591
21691
  name: name$1,
21592
21692
  version: version$1
@@ -22477,7 +22577,7 @@ if (typeof globalThis !== "undefined") {
22477
22577
  };
22478
22578
  }
22479
22579
  const name = "@yorkie-js/react";
22480
- const version = "0.6.26";
22580
+ const version = "0.6.27";
22481
22581
  const pkg = {
22482
22582
  name,
22483
22583
  version