@yorkie-js/sdk 0.6.27 → 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.
@@ -783,10 +783,10 @@ export declare class Client {
783
783
  * immediately using `fetch` with the `keepalive` option enabled. This is
784
784
  * useful for ensuring the deactivation request completes even if the page is
785
785
  * being unloaded, such as in `beforeunload` or `unload` event listeners.
786
+ * If synchronous is true, the server will wait for all pending operations to
787
+ * complete before deactivating.
786
788
  */
787
- deactivate(options?: {
788
- keepalive: boolean;
789
- }): Promise<void>;
789
+ deactivate(options?: DeactivateOptions): Promise<void>;
790
790
  /**
791
791
  * `hasDocument` checks if the given document is attached to this client.
792
792
  * @param docKey - the key of the document.
@@ -1896,6 +1896,25 @@ declare type DataSize = {
1896
1896
  meta: number;
1897
1897
  };
1898
1898
 
1899
+ /**
1900
+ * `DeactivateOptions` are user-settable options used when deactivating clients.
1901
+ */
1902
+ declare interface DeactivateOptions {
1903
+ /**
1904
+ * `keepalive` is used to enable the keepalive option when deactivating.
1905
+ * If true, the client will request deactivation immediately using `fetch`
1906
+ * with the `keepalive` option enabled. This is useful for ensuring the
1907
+ * deactivation request completes even if the page is being unloaded.
1908
+ */
1909
+ keepalive?: boolean;
1910
+ /**
1911
+ * `synchronous` is used to enable the synchronous option when deactivating.
1912
+ * If true, the server will wait for all pending operations to complete
1913
+ * before deactivating.
1914
+ */
1915
+ synchronous?: boolean;
1916
+ }
1917
+
1899
1918
  /**
1900
1919
  * `DecreasedDepthOf` represents the type of the decreased depth of the given depth.
1901
1920
  */
@@ -2569,11 +2588,17 @@ declare class Document_2<R, P extends Indexable = Indexable> {
2569
2588
  * `getMyPresence` returns the presence of the current client.
2570
2589
  */
2571
2590
  getMyPresence(): P;
2591
+ /**
2592
+ * `getOthersPresences` returns the presences of all other clients.
2593
+ */
2594
+ getOthersPresences(): Array<{
2595
+ clientID: ActorID;
2596
+ presence: P;
2597
+ }>;
2572
2598
  /**
2573
2599
  * `getPresence` returns the presence of the given clientID.
2574
2600
  */
2575
2601
  getPresence(clientID: ActorID): P | undefined;
2576
- /* Excluded from this release type: getPresenceForTest */
2577
2602
  /**
2578
2603
  * `getPresences` returns the presences of online clients.
2579
2604
  */
@@ -2581,6 +2606,7 @@ declare class Document_2<R, P extends Indexable = Indexable> {
2581
2606
  clientID: ActorID;
2582
2607
  presence: P;
2583
2608
  }>;
2609
+ /* Excluded from this release type: getPresenceForTest */
2584
2610
  /* Excluded from this release type: getSelfForTest */
2585
2611
  /* Excluded from this release type: getOthersForTest */
2586
2612
  /**
@@ -7059,6 +7059,10 @@ const _DeactivateClientRequest = class _DeactivateClientRequest extends Message
7059
7059
  * @generated from field: string client_id = 1;
7060
7060
  */
7061
7061
  __publicField(this, "clientId", "");
7062
+ /**
7063
+ * @generated from field: bool synchronous = 2;
7064
+ */
7065
+ __publicField(this, "synchronous", false);
7062
7066
  proto3.util.initPartial(data, this);
7063
7067
  }
7064
7068
  static fromBinary(bytes, options) {
@@ -7083,6 +7087,13 @@ __publicField(_DeactivateClientRequest, "fields", proto3.util.newFieldList(() =>
7083
7087
  kind: "scalar",
7084
7088
  T: 9
7085
7089
  /* ScalarType.STRING */
7090
+ },
7091
+ {
7092
+ no: 2,
7093
+ name: "synchronous",
7094
+ kind: "scalar",
7095
+ T: 8
7096
+ /* ScalarType.BOOL */
7086
7097
  }
7087
7098
  ]));
7088
7099
  let DeactivateClientRequest = _DeactivateClientRequest;
@@ -21350,6 +21361,22 @@ class Document {
21350
21361
  const p = this.presences.get(this.changeID.getActorID());
21351
21362
  return p ? deepcopy(p) : {};
21352
21363
  }
21364
+ /**
21365
+ * `getOthersPresences` returns the presences of all other clients.
21366
+ */
21367
+ getOthersPresences() {
21368
+ const others = [];
21369
+ const myClientID = this.changeID.getActorID();
21370
+ for (const clientID of this.onlineClients) {
21371
+ if (clientID !== myClientID && this.presences.has(clientID)) {
21372
+ others.push({
21373
+ clientID,
21374
+ presence: deepcopy(this.presences.get(clientID))
21375
+ });
21376
+ }
21377
+ }
21378
+ return others;
21379
+ }
21353
21380
  /**
21354
21381
  * `getPresence` returns the presence of the given clientID.
21355
21382
  */
@@ -21361,16 +21388,6 @@ class Document {
21361
21388
  const p = this.presences.get(clientID);
21362
21389
  return p ? deepcopy(p) : void 0;
21363
21390
  }
21364
- /**
21365
- * `getPresenceForTest` returns the presence of the given clientID
21366
- * regardless of whether the client is online or not.
21367
- *
21368
- * @internal
21369
- */
21370
- getPresenceForTest(clientID) {
21371
- const p = this.presences.get(clientID);
21372
- return p ? deepcopy(p) : void 0;
21373
- }
21374
21391
  /**
21375
21392
  * `getPresences` returns the presences of online clients.
21376
21393
  */
@@ -21390,6 +21407,16 @@ class Document {
21390
21407
  }
21391
21408
  return presences;
21392
21409
  }
21410
+ /**
21411
+ * `getPresenceForTest` returns the presence of the given clientID
21412
+ * regardless of whether the client is online or not.
21413
+ *
21414
+ * @internal
21415
+ */
21416
+ getPresenceForTest(clientID) {
21417
+ const p = this.presences.get(clientID);
21418
+ return p ? deepcopy(p) : void 0;
21419
+ }
21393
21420
  /**
21394
21421
  * `getSelfForTest` returns the client that has attached this document.
21395
21422
  *
@@ -21664,7 +21691,7 @@ function createAuthInterceptor(apiKey, token) {
21664
21691
  };
21665
21692
  }
21666
21693
  const name = "@yorkie-js/sdk";
21667
- const version = "0.6.27";
21694
+ const version = "0.6.28";
21668
21695
  const pkg = {
21669
21696
  name,
21670
21697
  version
@@ -21827,15 +21854,20 @@ class Client {
21827
21854
  * immediately using `fetch` with the `keepalive` option enabled. This is
21828
21855
  * useful for ensuring the deactivation request completes even if the page is
21829
21856
  * being unloaded, such as in `beforeunload` or `unload` event listeners.
21857
+ * If synchronous is true, the server will wait for all pending operations to
21858
+ * complete before deactivating.
21830
21859
  */
21831
- deactivate(options = { keepalive: false }) {
21860
+ deactivate(options = { keepalive: false, synchronous: false }) {
21832
21861
  if (this.status === "deactivated") {
21833
21862
  return Promise.resolve();
21834
21863
  }
21835
21864
  const task = async () => {
21836
21865
  try {
21837
21866
  await this.rpcClient.deactivateClient(
21838
- { clientId: this.id },
21867
+ {
21868
+ clientId: this.id,
21869
+ synchronous: options.synchronous
21870
+ },
21839
21871
  { headers: { "x-shard-key": `${this.apiKey}/${this.key}` } }
21840
21872
  );
21841
21873
  this.deactivateInternal();