@yorkie-js/react 0.6.36 → 0.6.38

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.
@@ -13527,7 +13527,6 @@ class LLRBNode {
13527
13527
  constructor(key, value, isRed) {
13528
13528
  __publicField(this, "key");
13529
13529
  __publicField(this, "value");
13530
- __publicField(this, "parent");
13531
13530
  __publicField(this, "left");
13532
13531
  __publicField(this, "right");
13533
13532
  __publicField(this, "isRed");
@@ -13612,33 +13611,19 @@ class LLRBTree {
13612
13611
  */
13613
13612
  floorEntry(key) {
13614
13613
  let node = this.root;
13614
+ let result = void 0;
13615
13615
  while (node) {
13616
13616
  const compare2 = this.comparator(key, node.key);
13617
- if (compare2 > 0) {
13618
- if (node.right) {
13619
- node.right.parent = node;
13620
- node = node.right;
13621
- } else {
13622
- return node;
13623
- }
13617
+ if (compare2 === 0) {
13618
+ return node;
13624
13619
  } else if (compare2 < 0) {
13625
- if (node.left) {
13626
- node.left.parent = node;
13627
- node = node.left;
13628
- } else {
13629
- let parent = node.parent;
13630
- let childNode = node;
13631
- while (parent && childNode === parent.left) {
13632
- childNode = parent;
13633
- parent = parent.parent;
13634
- }
13635
- return parent;
13636
- }
13620
+ node = node.left;
13637
13621
  } else {
13638
- return node;
13622
+ result = node;
13623
+ node = node.right;
13639
13624
  }
13640
13625
  }
13641
- return;
13626
+ return result;
13642
13627
  }
13643
13628
  /**
13644
13629
  * `lastEntry` returns last entry of LLRBTree.
@@ -22309,7 +22294,7 @@ function createAuthInterceptor(apiKey, token) {
22309
22294
  };
22310
22295
  }
22311
22296
  const name$1 = "@yorkie-js/sdk";
22312
- const version$1 = "0.6.36";
22297
+ const version$1 = "0.6.38";
22313
22298
  const pkg$1 = {
22314
22299
  name: name$1,
22315
22300
  version: version$1
@@ -22349,6 +22334,7 @@ var ChannelEventType = /* @__PURE__ */ ((ChannelEventType2) => {
22349
22334
  ChannelEventType2["AuthError"] = "auth-error";
22350
22335
  return ChannelEventType2;
22351
22336
  })(ChannelEventType || {});
22337
+ const KeyPathSeparator = ".";
22352
22338
  class Channel2 {
22353
22339
  /**
22354
22340
  * @param key - the key of the channel.
@@ -22362,6 +22348,7 @@ class Channel2 {
22362
22348
  __publicField(this, "seq");
22363
22349
  __publicField(this, "eventStream");
22364
22350
  __publicField(this, "eventStreamObserver");
22351
+ this.validateChannelKey(key);
22365
22352
  this.key = key;
22366
22353
  this.status = "detached";
22367
22354
  this.count = 0;
@@ -22376,6 +22363,12 @@ class Channel2 {
22376
22363
  getKey() {
22377
22364
  return this.key;
22378
22365
  }
22366
+ /**
22367
+ * `getFirstKeyPath` returns the first key path to the presence count.
22368
+ */
22369
+ getFirstKeyPath() {
22370
+ return this.key.split(KeyPathSeparator)[0];
22371
+ }
22379
22372
  /**
22380
22373
  * `getStatus` returns the status of this channel.
22381
22374
  */
@@ -22521,6 +22514,23 @@ class Channel2 {
22521
22514
  options
22522
22515
  });
22523
22516
  }
22517
+ validateChannelKey(key) {
22518
+ if (key === "") {
22519
+ throw new Error("channel key must not be empty");
22520
+ }
22521
+ if (key.includes(" ")) {
22522
+ throw new Error("channel key must not contain a whitespace");
22523
+ }
22524
+ if (key.startsWith(KeyPathSeparator)) {
22525
+ throw new Error("channel key must not start with a period");
22526
+ }
22527
+ if (key.endsWith(KeyPathSeparator)) {
22528
+ throw new Error("channel key must not end with a period");
22529
+ }
22530
+ if (key.includes(`${KeyPathSeparator}${KeyPathSeparator}`)) {
22531
+ throw new Error("channel key path must not empty");
22532
+ }
22533
+ }
22524
22534
  }
22525
22535
  var SyncMode = /* @__PURE__ */ ((SyncMode2) => {
22526
22536
  SyncMode2["Manual"] = "manual";
@@ -22869,7 +22879,11 @@ class Client {
22869
22879
  clientId: this.id,
22870
22880
  channelKey: channel.getKey()
22871
22881
  },
22872
- { headers: { "x-shard-key": `${this.apiKey}/${channel.getKey()}` } }
22882
+ {
22883
+ headers: {
22884
+ "x-shard-key": `${this.apiKey}/${channel.getFirstKeyPath()}`
22885
+ }
22886
+ }
22873
22887
  );
22874
22888
  channel.setSessionID(res.sessionId);
22875
22889
  channel.updateCount(Number(res.count), 0);
@@ -22933,7 +22947,11 @@ class Client {
22933
22947
  channelKey: channel.getKey(),
22934
22948
  sessionId: channel.getSessionID()
22935
22949
  },
22936
- { headers: { "x-shard-key": `${this.apiKey}/${channel.getKey()}` } }
22950
+ {
22951
+ headers: {
22952
+ "x-shard-key": `${this.apiKey}/${channel.getFirstKeyPath()}`
22953
+ }
22954
+ }
22937
22955
  );
22938
22956
  channel.updateCount(Number(res.count), 0);
22939
22957
  channel.applyStatus(ChannelStatus.Detached);
@@ -23144,6 +23162,7 @@ class Client {
23144
23162
  "payload is not serializable"
23145
23163
  );
23146
23164
  }
23165
+ const ch = attachment.resource;
23147
23166
  const maxRetries = (options == null ? void 0 : options.maxRetries) ?? DefaultBroadcastOptions.maxRetries;
23148
23167
  const maxBackoff = DefaultBroadcastOptions.maxBackoff;
23149
23168
  let retryCount = 0;
@@ -23164,7 +23183,11 @@ class Client {
23164
23183
  topic,
23165
23184
  payload: new TextEncoder().encode(JSON.stringify(payload))
23166
23185
  },
23167
- { headers: { "x-shard-key": `${this.apiKey}/${key}` } }
23186
+ {
23187
+ headers: {
23188
+ "x-shard-key": `${this.apiKey}/${ch.getFirstKeyPath()}`
23189
+ }
23190
+ }
23168
23191
  );
23169
23192
  logger.info(
23170
23193
  `[BC] c:"${this.getKey()}" broadcasts p:"${key}" t:"${topic}"`
@@ -23425,7 +23448,9 @@ class Client {
23425
23448
  channelKey: key
23426
23449
  },
23427
23450
  {
23428
- headers: { "x-shard-key": `${this.apiKey}/${key}` },
23451
+ headers: {
23452
+ "x-shard-key": `${this.apiKey}/${attachment.resource.getFirstKeyPath()}`
23453
+ },
23429
23454
  signal: ac.signal
23430
23455
  }
23431
23456
  );
@@ -23549,7 +23574,7 @@ class Client {
23549
23574
  },
23550
23575
  {
23551
23576
  headers: {
23552
- "x-shard-key": `${this.apiKey}/${resource.getKey()}`
23577
+ "x-shard-key": `${this.apiKey}/${resource.getFirstKeyPath()}`
23553
23578
  }
23554
23579
  }
23555
23580
  );
@@ -23690,7 +23715,7 @@ if (typeof globalThis !== "undefined") {
23690
23715
  };
23691
23716
  }
23692
23717
  const name = "@yorkie-js/react";
23693
- const version = "0.6.36";
23718
+ const version = "0.6.38";
23694
23719
  const pkg = {
23695
23720
  name,
23696
23721
  version