@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.
@@ -13529,7 +13529,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
13529
13529
  constructor(key, value, isRed) {
13530
13530
  __publicField(this, "key");
13531
13531
  __publicField(this, "value");
13532
- __publicField(this, "parent");
13533
13532
  __publicField(this, "left");
13534
13533
  __publicField(this, "right");
13535
13534
  __publicField(this, "isRed");
@@ -13614,33 +13613,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
13614
13613
  */
13615
13614
  floorEntry(key) {
13616
13615
  let node = this.root;
13616
+ let result = void 0;
13617
13617
  while (node) {
13618
13618
  const compare = this.comparator(key, node.key);
13619
- if (compare > 0) {
13620
- if (node.right) {
13621
- node.right.parent = node;
13622
- node = node.right;
13623
- } else {
13624
- return node;
13625
- }
13619
+ if (compare === 0) {
13620
+ return node;
13626
13621
  } else if (compare < 0) {
13627
- if (node.left) {
13628
- node.left.parent = node;
13629
- node = node.left;
13630
- } else {
13631
- let parent = node.parent;
13632
- let childNode = node;
13633
- while (parent && childNode === parent.left) {
13634
- childNode = parent;
13635
- parent = parent.parent;
13636
- }
13637
- return parent;
13638
- }
13622
+ node = node.left;
13639
13623
  } else {
13640
- return node;
13624
+ result = node;
13625
+ node = node.right;
13641
13626
  }
13642
13627
  }
13643
- return;
13628
+ return result;
13644
13629
  }
13645
13630
  /**
13646
13631
  * `lastEntry` returns last entry of LLRBTree.
@@ -22311,7 +22296,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22311
22296
  };
22312
22297
  }
22313
22298
  const name$1 = "@yorkie-js/sdk";
22314
- const version$1 = "0.6.36";
22299
+ const version$1 = "0.6.38";
22315
22300
  const pkg$1 = {
22316
22301
  name: name$1,
22317
22302
  version: version$1
@@ -22351,6 +22336,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22351
22336
  ChannelEventType2["AuthError"] = "auth-error";
22352
22337
  return ChannelEventType2;
22353
22338
  })(ChannelEventType || {});
22339
+ const KeyPathSeparator = ".";
22354
22340
  class Channel {
22355
22341
  /**
22356
22342
  * @param key - the key of the channel.
@@ -22364,6 +22350,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22364
22350
  __publicField(this, "seq");
22365
22351
  __publicField(this, "eventStream");
22366
22352
  __publicField(this, "eventStreamObserver");
22353
+ this.validateChannelKey(key);
22367
22354
  this.key = key;
22368
22355
  this.status = "detached";
22369
22356
  this.count = 0;
@@ -22378,6 +22365,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22378
22365
  getKey() {
22379
22366
  return this.key;
22380
22367
  }
22368
+ /**
22369
+ * `getFirstKeyPath` returns the first key path to the presence count.
22370
+ */
22371
+ getFirstKeyPath() {
22372
+ return this.key.split(KeyPathSeparator)[0];
22373
+ }
22381
22374
  /**
22382
22375
  * `getStatus` returns the status of this channel.
22383
22376
  */
@@ -22523,6 +22516,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22523
22516
  options
22524
22517
  });
22525
22518
  }
22519
+ validateChannelKey(key) {
22520
+ if (key === "") {
22521
+ throw new Error("channel key must not be empty");
22522
+ }
22523
+ if (key.includes(" ")) {
22524
+ throw new Error("channel key must not contain a whitespace");
22525
+ }
22526
+ if (key.startsWith(KeyPathSeparator)) {
22527
+ throw new Error("channel key must not start with a period");
22528
+ }
22529
+ if (key.endsWith(KeyPathSeparator)) {
22530
+ throw new Error("channel key must not end with a period");
22531
+ }
22532
+ if (key.includes(`${KeyPathSeparator}${KeyPathSeparator}`)) {
22533
+ throw new Error("channel key path must not empty");
22534
+ }
22535
+ }
22526
22536
  }
22527
22537
  var SyncMode = /* @__PURE__ */ ((SyncMode2) => {
22528
22538
  SyncMode2["Manual"] = "manual";
@@ -22871,7 +22881,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22871
22881
  clientId: this.id,
22872
22882
  channelKey: channel.getKey()
22873
22883
  },
22874
- { headers: { "x-shard-key": `${this.apiKey}/${channel.getKey()}` } }
22884
+ {
22885
+ headers: {
22886
+ "x-shard-key": `${this.apiKey}/${channel.getFirstKeyPath()}`
22887
+ }
22888
+ }
22875
22889
  );
22876
22890
  channel.setSessionID(res.sessionId);
22877
22891
  channel.updateCount(Number(res.count), 0);
@@ -22935,7 +22949,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22935
22949
  channelKey: channel.getKey(),
22936
22950
  sessionId: channel.getSessionID()
22937
22951
  },
22938
- { headers: { "x-shard-key": `${this.apiKey}/${channel.getKey()}` } }
22952
+ {
22953
+ headers: {
22954
+ "x-shard-key": `${this.apiKey}/${channel.getFirstKeyPath()}`
22955
+ }
22956
+ }
22939
22957
  );
22940
22958
  channel.updateCount(Number(res.count), 0);
22941
22959
  channel.applyStatus(ChannelStatus.Detached);
@@ -23146,6 +23164,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23146
23164
  "payload is not serializable"
23147
23165
  );
23148
23166
  }
23167
+ const ch = attachment.resource;
23149
23168
  const maxRetries = (options == null ? void 0 : options.maxRetries) ?? DefaultBroadcastOptions.maxRetries;
23150
23169
  const maxBackoff = DefaultBroadcastOptions.maxBackoff;
23151
23170
  let retryCount = 0;
@@ -23166,7 +23185,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23166
23185
  topic,
23167
23186
  payload: new TextEncoder().encode(JSON.stringify(payload))
23168
23187
  },
23169
- { headers: { "x-shard-key": `${this.apiKey}/${key}` } }
23188
+ {
23189
+ headers: {
23190
+ "x-shard-key": `${this.apiKey}/${ch.getFirstKeyPath()}`
23191
+ }
23192
+ }
23170
23193
  );
23171
23194
  logger.info(
23172
23195
  `[BC] c:"${this.getKey()}" broadcasts p:"${key}" t:"${topic}"`
@@ -23427,7 +23450,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23427
23450
  channelKey: key
23428
23451
  },
23429
23452
  {
23430
- headers: { "x-shard-key": `${this.apiKey}/${key}` },
23453
+ headers: {
23454
+ "x-shard-key": `${this.apiKey}/${attachment.resource.getFirstKeyPath()}`
23455
+ },
23431
23456
  signal: ac.signal
23432
23457
  }
23433
23458
  );
@@ -23551,7 +23576,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23551
23576
  },
23552
23577
  {
23553
23578
  headers: {
23554
- "x-shard-key": `${this.apiKey}/${resource.getKey()}`
23579
+ "x-shard-key": `${this.apiKey}/${resource.getFirstKeyPath()}`
23555
23580
  }
23556
23581
  }
23557
23582
  );
@@ -23692,7 +23717,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23692
23717
  };
23693
23718
  }
23694
23719
  const name = "@yorkie-js/react";
23695
- const version = "0.6.36";
23720
+ const version = "0.6.38";
23696
23721
  const pkg = {
23697
23722
  name,
23698
23723
  version