@yorkie-js/react 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.
@@ -98,7 +98,7 @@ declare type DocumentContextType<R, P extends Indexable = Indexable> = {
98
98
  * This component must be under a `YorkieProvider` component to initialize the
99
99
  * Yorkie client properly.
100
100
  */
101
- export declare const DocumentProvider: <R, P extends Indexable = Indexable>({ docKey, initialRoot, initialPresence, enableDevtools, syncMode, documentPollInterval, children, }: {
101
+ export declare const DocumentProvider: <R, P extends Indexable = Indexable>({ docKey, initialRoot, initialPresence, enableDevtools, syncMode, documentPollInterval, disableGC, children, }: {
102
102
  docKey: string;
103
103
  initialRoot?: R;
104
104
  initialPresence?: P;
@@ -113,6 +113,13 @@ export declare const DocumentProvider: <R, P extends Indexable = Indexable>({ do
113
113
  * Default: 3000. Applied at attach time.
114
114
  */
115
115
  documentPollInterval?: number;
116
+ /**
117
+ * `disableGC` declares that this attachment will not produce or consume
118
+ * tombstones. Use only with Counter or primitive workloads; misuse on a
119
+ * document that uses Tree, Text, or Array deletions leads to undefined
120
+ * GC behavior on this client.
121
+ */
122
+ disableGC?: boolean;
116
123
  children?: default_2.ReactNode;
117
124
  }) => JSX.Element;
118
125
 
@@ -317,6 +324,13 @@ export declare function useYorkieDoc<R, P extends Indexable = Indexable>(apiKey:
317
324
  enableDevtools?: boolean;
318
325
  syncMode?: SyncMode;
319
326
  documentPollInterval?: number;
327
+ /**
328
+ * `disableGC` declares that this attachment will not produce or consume
329
+ * tombstones. Use only with Counter or primitive workloads; misuse on a
330
+ * document that uses Tree, Text, or Array deletions leads to undefined
331
+ * GC behavior on this client.
332
+ */
333
+ disableGC?: boolean;
320
334
  }): {
321
335
  root: R;
322
336
  presences: Array<{
@@ -13768,6 +13768,26 @@ class ChangeID {
13768
13768
  newID.versionVector.set(this.actor, lamport);
13769
13769
  return newID;
13770
13770
  }
13771
+ /**
13772
+ * `syncLamport` advances the lamport clock against the given ID without
13773
+ * merging its version vector into the receiver's. It is the counterpart
13774
+ * of `syncClocks` for attachments that have opted out of GC participation
13775
+ * (see docs/design/disable-gc-on-attach.md in the server repo): the
13776
+ * receiver does not need other actors' entries in its VV because it
13777
+ * never produces or consumes tombstones, and dropping them keeps each
13778
+ * subsequent local Change's VV at O(1) instead of O(num_actors).
13779
+ * Lamport must still advance so that TimeTickets produced locally
13780
+ * remain ordered against remote operations.
13781
+ */
13782
+ syncLamport(other) {
13783
+ if (!other.hasClocks()) {
13784
+ return this;
13785
+ }
13786
+ const lamport = other.lamport > this.lamport ? other.lamport + 1n : this.lamport + 1n;
13787
+ const vector = this.versionVector.deepcopy();
13788
+ vector.set(this.actor, lamport);
13789
+ return new ChangeID(this.clientSeq, lamport, this.actor, vector);
13790
+ }
13771
13791
  /**
13772
13792
  * `setClocks` sets the given clocks to this ID. This is used when the snapshot
13773
13793
  * is given from the server.
@@ -19639,6 +19659,12 @@ class Document {
19639
19659
  onlineClients;
19640
19660
  eventStream;
19641
19661
  eventStreamObserver;
19662
+ // `disableGC`, when true, declares that this document does not produce or
19663
+ // consume tombstones (see disable-gc-on-attach in the server repo). It is
19664
+ // set by the client on Attach and consumed by applyChange to skip merging
19665
+ // remote actors' version vectors into changeID, keeping each subsequent
19666
+ // local Change's VV at O(1) for high-fan-out Counter workloads.
19667
+ disableGC;
19642
19668
  /**
19643
19669
  * `history` is exposed to the user to manage undo/redo operations.
19644
19670
  */
@@ -19652,6 +19678,7 @@ class Document {
19652
19678
  this.changeID = InitialChangeID;
19653
19679
  this.checkpoint = InitialCheckpoint;
19654
19680
  this.localChanges = [];
19681
+ this.disableGC = false;
19655
19682
  this.root = CRDTRoot.create();
19656
19683
  this.presences = /* @__PURE__ */ new Map();
19657
19684
  this.onlineClients = /* @__PURE__ */ new Set();
@@ -20060,6 +20087,14 @@ class Document {
20060
20087
  }
20061
20088
  this.changeID = this.changeID.setActor(actorID);
20062
20089
  }
20090
+ /**
20091
+ * `setDisableGC` records whether this document participates in GC. The
20092
+ * client calls this on attach so subsequent applyChange runs use the
20093
+ * lamport-only sync path.
20094
+ */
20095
+ setDisableGC(disableGC) {
20096
+ this.disableGC = disableGC;
20097
+ }
20063
20098
  /**
20064
20099
  * `isEnableDevtools` returns whether devtools is enabled or not.
20065
20100
  */
@@ -20298,7 +20333,7 @@ class Document {
20298
20333
  );
20299
20334
  }
20300
20335
  }
20301
- this.changeID = this.changeID.syncClocks(change.getID());
20336
+ this.changeID = this.disableGC ? this.changeID.syncLamport(change.getID()) : this.changeID.syncClocks(change.getID());
20302
20337
  if (opInfos.length) {
20303
20338
  const rawChange = this.isEnableDevtools() ? change.toStruct() : void 0;
20304
20339
  events.push(
@@ -20981,7 +21016,7 @@ function createAuthInterceptor(apiKey, token) {
20981
21016
  };
20982
21017
  }
20983
21018
  const name$1 = "@yorkie-js/sdk";
20984
- const version$1 = "0.7.10";
21019
+ const version$1 = "0.7.11-rc";
20985
21020
  const pkg$1 = {
20986
21021
  name: name$1,
20987
21022
  version: version$1
@@ -21532,6 +21567,7 @@ class Client {
21532
21567
  doc.setSchemaRules(converter.fromSchemaRules(res.schemaRules));
21533
21568
  }
21534
21569
  const pack = converter.fromChangePack(res.changePack);
21570
+ doc.setDisableGC(opts.disableGC ?? false);
21535
21571
  doc.applyChangePack(pack);
21536
21572
  if (doc.getStatus() === DocStatus.Removed) {
21537
21573
  return doc;
@@ -23064,7 +23100,7 @@ if (typeof globalThis !== "undefined") {
23064
23100
  };
23065
23101
  }
23066
23102
  const name = "@yorkie-js/react";
23067
- const version = "0.7.10";
23103
+ const version = "0.7.11-rc";
23068
23104
  const pkg = {
23069
23105
  name,
23070
23106
  version
@@ -23253,7 +23289,7 @@ function shallowEqual(valueA, valueB) {
23253
23289
  valueB
23254
23290
  );
23255
23291
  }
23256
- function useYorkieDocument(client, clientLoading, clientError, docKey, initialRoot, initialPresence, enableDevtools, syncMode, documentPollInterval, docStore) {
23292
+ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRoot, initialPresence, enableDevtools, syncMode, documentPollInterval, disableGC, docStore) {
23257
23293
  const initialRootRef = useRef(initialRoot);
23258
23294
  const initialPresenceRef = useRef(initialPresence);
23259
23295
  const [didMount, setDidMount] = useState(false);
@@ -23313,7 +23349,8 @@ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRo
23313
23349
  initialRoot: initialRootRef.current,
23314
23350
  initialPresence: initialPresenceRef.current,
23315
23351
  syncMode,
23316
- documentPollInterval
23352
+ documentPollInterval,
23353
+ disableGC
23317
23354
  });
23318
23355
  const update = (callback) => {
23319
23356
  try {
@@ -23361,7 +23398,8 @@ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRo
23361
23398
  docStore,
23362
23399
  didMount,
23363
23400
  syncMode,
23364
- documentPollInterval
23401
+ documentPollInterval,
23402
+ disableGC
23365
23403
  ]);
23366
23404
  }
23367
23405
  const DocumentContext = createContext(void 0);
@@ -23372,6 +23410,7 @@ const DocumentProvider = ({
23372
23410
  enableDevtools = false,
23373
23411
  syncMode,
23374
23412
  documentPollInterval,
23413
+ disableGC,
23375
23414
  children
23376
23415
  }) => {
23377
23416
  const { client, loading: clientLoading, error: clientError } = useYorkie();
@@ -23399,6 +23438,7 @@ const DocumentProvider = ({
23399
23438
  enableDevtools,
23400
23439
  syncMode,
23401
23440
  documentPollInterval,
23441
+ disableGC,
23402
23442
  documentStore
23403
23443
  );
23404
23444
  return /* @__PURE__ */ jsx(DocumentContext.Provider, { value: documentStore, children });
@@ -23518,6 +23558,7 @@ function useYorkieDoc(apiKey, docKey, opts) {
23518
23558
  opts?.enableDevtools ?? false,
23519
23559
  opts?.syncMode,
23520
23560
  opts?.documentPollInterval,
23561
+ opts?.disableGC,
23521
23562
  documentStore
23522
23563
  );
23523
23564
  const documentState = useSelector(documentStore);