@yorkie-js/sdk 0.7.10 → 0.7.11-rc

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.
@@ -495,6 +495,18 @@ declare class ChangeID {
495
495
  * doesn't have logical clocks, this ID is returned.
496
496
  */
497
497
  syncClocks(other: ChangeID): ChangeID;
498
+ /**
499
+ * `syncLamport` advances the lamport clock against the given ID without
500
+ * merging its version vector into the receiver's. It is the counterpart
501
+ * of `syncClocks` for attachments that have opted out of GC participation
502
+ * (see docs/design/disable-gc-on-attach.md in the server repo): the
503
+ * receiver does not need other actors' entries in its VV because it
504
+ * never produces or consumes tombstones, and dropping them keeps each
505
+ * subsequent local Change's VV at O(1) instead of O(num_actors).
506
+ * Lamport must still advance so that TimeTickets produced locally
507
+ * remain ordered against remote operations.
508
+ */
509
+ syncLamport(other: ChangeID): ChangeID;
498
510
  /**
499
511
  * `setClocks` sets the given clocks to this ID. This is used when the snapshot
500
512
  * is given from the server.
@@ -2925,6 +2937,7 @@ declare class Document_2<R, P extends Indexable = Indexable> implements Attachab
2925
2937
  private onlineClients;
2926
2938
  private eventStream;
2927
2939
  private eventStreamObserver;
2940
+ private disableGC;
2928
2941
  /**
2929
2942
  * `history` is exposed to the user to manage undo/redo operations.
2930
2943
  */
@@ -3033,6 +3046,12 @@ declare class Document_2<R, P extends Indexable = Indexable> implements Attachab
3033
3046
  * changes the document has.
3034
3047
  */
3035
3048
  setActor(actorID: ActorID): void;
3049
+ /**
3050
+ * `setDisableGC` records whether this document participates in GC. The
3051
+ * client calls this on attach so subsequent applyChange runs use the
3052
+ * lamport-only sync path.
3053
+ */
3054
+ setDisableGC(disableGC: boolean): void;
3036
3055
  /**
3037
3056
  * `isEnableDevtools` returns whether devtools is enabled or not.
3038
3057
  */
@@ -13766,6 +13766,26 @@ class ChangeID {
13766
13766
  newID.versionVector.set(this.actor, lamport);
13767
13767
  return newID;
13768
13768
  }
13769
+ /**
13770
+ * `syncLamport` advances the lamport clock against the given ID without
13771
+ * merging its version vector into the receiver's. It is the counterpart
13772
+ * of `syncClocks` for attachments that have opted out of GC participation
13773
+ * (see docs/design/disable-gc-on-attach.md in the server repo): the
13774
+ * receiver does not need other actors' entries in its VV because it
13775
+ * never produces or consumes tombstones, and dropping them keeps each
13776
+ * subsequent local Change's VV at O(1) instead of O(num_actors).
13777
+ * Lamport must still advance so that TimeTickets produced locally
13778
+ * remain ordered against remote operations.
13779
+ */
13780
+ syncLamport(other) {
13781
+ if (!other.hasClocks()) {
13782
+ return this;
13783
+ }
13784
+ const lamport = other.lamport > this.lamport ? other.lamport + 1n : this.lamport + 1n;
13785
+ const vector = this.versionVector.deepcopy();
13786
+ vector.set(this.actor, lamport);
13787
+ return new ChangeID(this.clientSeq, lamport, this.actor, vector);
13788
+ }
13769
13789
  /**
13770
13790
  * `setClocks` sets the given clocks to this ID. This is used when the snapshot
13771
13791
  * is given from the server.
@@ -19642,6 +19662,12 @@ class Document {
19642
19662
  onlineClients;
19643
19663
  eventStream;
19644
19664
  eventStreamObserver;
19665
+ // `disableGC`, when true, declares that this document does not produce or
19666
+ // consume tombstones (see disable-gc-on-attach in the server repo). It is
19667
+ // set by the client on Attach and consumed by applyChange to skip merging
19668
+ // remote actors' version vectors into changeID, keeping each subsequent
19669
+ // local Change's VV at O(1) for high-fan-out Counter workloads.
19670
+ disableGC;
19645
19671
  /**
19646
19672
  * `history` is exposed to the user to manage undo/redo operations.
19647
19673
  */
@@ -19655,6 +19681,7 @@ class Document {
19655
19681
  this.changeID = InitialChangeID;
19656
19682
  this.checkpoint = InitialCheckpoint;
19657
19683
  this.localChanges = [];
19684
+ this.disableGC = false;
19658
19685
  this.root = CRDTRoot.create();
19659
19686
  this.presences = /* @__PURE__ */ new Map();
19660
19687
  this.onlineClients = /* @__PURE__ */ new Set();
@@ -20063,6 +20090,14 @@ class Document {
20063
20090
  }
20064
20091
  this.changeID = this.changeID.setActor(actorID);
20065
20092
  }
20093
+ /**
20094
+ * `setDisableGC` records whether this document participates in GC. The
20095
+ * client calls this on attach so subsequent applyChange runs use the
20096
+ * lamport-only sync path.
20097
+ */
20098
+ setDisableGC(disableGC) {
20099
+ this.disableGC = disableGC;
20100
+ }
20066
20101
  /**
20067
20102
  * `isEnableDevtools` returns whether devtools is enabled or not.
20068
20103
  */
@@ -20301,7 +20336,7 @@ class Document {
20301
20336
  );
20302
20337
  }
20303
20338
  }
20304
- this.changeID = this.changeID.syncClocks(change.getID());
20339
+ this.changeID = this.disableGC ? this.changeID.syncLamport(change.getID()) : this.changeID.syncClocks(change.getID());
20305
20340
  if (opInfos.length) {
20306
20341
  const rawChange = this.isEnableDevtools() ? change.toStruct() : void 0;
20307
20342
  events.push(
@@ -20984,7 +21019,7 @@ function createAuthInterceptor(apiKey, token) {
20984
21019
  };
20985
21020
  }
20986
21021
  const name = "@yorkie-js/sdk";
20987
- const version = "0.7.10";
21022
+ const version = "0.7.11-rc";
20988
21023
  const pkg = {
20989
21024
  name,
20990
21025
  version
@@ -21545,6 +21580,7 @@ class Client {
21545
21580
  doc.setSchemaRules(converter.fromSchemaRules(res.schemaRules));
21546
21581
  }
21547
21582
  const pack = converter.fromChangePack(res.changePack);
21583
+ doc.setDisableGC(opts.disableGC ?? false);
21548
21584
  doc.applyChangePack(pack);
21549
21585
  if (doc.getStatus() === DocStatus.Removed) {
21550
21586
  return doc;