@yorkie-js/sdk 0.6.36 → 0.6.37
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.
package/dist/yorkie-js-sdk.d.ts
CHANGED
|
@@ -724,6 +724,10 @@ export declare class Channel implements Observable_2<ChannelEvent>, Attachable {
|
|
|
724
724
|
* `getKey` returns the key of this channel.
|
|
725
725
|
*/
|
|
726
726
|
getKey(): string;
|
|
727
|
+
/**
|
|
728
|
+
* `getFirstKeyPath` returns the first key path to the presence count.
|
|
729
|
+
*/
|
|
730
|
+
getFirstKeyPath(): string;
|
|
727
731
|
/**
|
|
728
732
|
* `getStatus` returns the status of this channel.
|
|
729
733
|
*/
|
|
@@ -808,6 +812,7 @@ export declare class Channel implements Observable_2<ChannelEvent>, Attachable {
|
|
|
808
812
|
* `broadcast` sends a message to all clients watching this channel.
|
|
809
813
|
*/
|
|
810
814
|
broadcast(topic: string, payload: any, options?: BroadcastOptions): void;
|
|
815
|
+
private validateChannelKey;
|
|
811
816
|
}
|
|
812
817
|
|
|
813
818
|
/**
|
|
@@ -3762,7 +3767,6 @@ declare type LeafElement = PrimitiveValue | Primitive | Text_2 | Counter | Tree;
|
|
|
3762
3767
|
declare class LLRBNode<K, V> {
|
|
3763
3768
|
key: K;
|
|
3764
3769
|
value: V;
|
|
3765
|
-
parent?: LLRBNode<K, V>;
|
|
3766
3770
|
left?: LLRBNode<K, V>;
|
|
3767
3771
|
right?: LLRBNode<K, V>;
|
|
3768
3772
|
isRed: boolean;
|
package/dist/yorkie-js-sdk.es.js
CHANGED
|
@@ -13500,7 +13500,6 @@ class LLRBNode {
|
|
|
13500
13500
|
constructor(key, value, isRed) {
|
|
13501
13501
|
__publicField(this, "key");
|
|
13502
13502
|
__publicField(this, "value");
|
|
13503
|
-
__publicField(this, "parent");
|
|
13504
13503
|
__publicField(this, "left");
|
|
13505
13504
|
__publicField(this, "right");
|
|
13506
13505
|
__publicField(this, "isRed");
|
|
@@ -13585,33 +13584,19 @@ class LLRBTree {
|
|
|
13585
13584
|
*/
|
|
13586
13585
|
floorEntry(key) {
|
|
13587
13586
|
let node = this.root;
|
|
13587
|
+
let result = void 0;
|
|
13588
13588
|
while (node) {
|
|
13589
13589
|
const compare2 = this.comparator(key, node.key);
|
|
13590
|
-
if (compare2
|
|
13591
|
-
|
|
13592
|
-
node.right.parent = node;
|
|
13593
|
-
node = node.right;
|
|
13594
|
-
} else {
|
|
13595
|
-
return node;
|
|
13596
|
-
}
|
|
13590
|
+
if (compare2 === 0) {
|
|
13591
|
+
return node;
|
|
13597
13592
|
} else if (compare2 < 0) {
|
|
13598
|
-
|
|
13599
|
-
node.left.parent = node;
|
|
13600
|
-
node = node.left;
|
|
13601
|
-
} else {
|
|
13602
|
-
let parent = node.parent;
|
|
13603
|
-
let childNode = node;
|
|
13604
|
-
while (parent && childNode === parent.left) {
|
|
13605
|
-
childNode = parent;
|
|
13606
|
-
parent = parent.parent;
|
|
13607
|
-
}
|
|
13608
|
-
return parent;
|
|
13609
|
-
}
|
|
13593
|
+
node = node.left;
|
|
13610
13594
|
} else {
|
|
13611
|
-
|
|
13595
|
+
result = node;
|
|
13596
|
+
node = node.right;
|
|
13612
13597
|
}
|
|
13613
13598
|
}
|
|
13614
|
-
return;
|
|
13599
|
+
return result;
|
|
13615
13600
|
}
|
|
13616
13601
|
/**
|
|
13617
13602
|
* `lastEntry` returns last entry of LLRBTree.
|
|
@@ -22287,7 +22272,7 @@ function createAuthInterceptor(apiKey, token) {
|
|
|
22287
22272
|
};
|
|
22288
22273
|
}
|
|
22289
22274
|
const name = "@yorkie-js/sdk";
|
|
22290
|
-
const version = "0.6.
|
|
22275
|
+
const version = "0.6.37";
|
|
22291
22276
|
const pkg = {
|
|
22292
22277
|
name,
|
|
22293
22278
|
version
|
|
@@ -22327,6 +22312,7 @@ var ChannelEventType = /* @__PURE__ */ ((ChannelEventType2) => {
|
|
|
22327
22312
|
ChannelEventType2["AuthError"] = "auth-error";
|
|
22328
22313
|
return ChannelEventType2;
|
|
22329
22314
|
})(ChannelEventType || {});
|
|
22315
|
+
const KeyPathSeparator = ".";
|
|
22330
22316
|
class Channel2 {
|
|
22331
22317
|
/**
|
|
22332
22318
|
* @param key - the key of the channel.
|
|
@@ -22340,6 +22326,7 @@ class Channel2 {
|
|
|
22340
22326
|
__publicField(this, "seq");
|
|
22341
22327
|
__publicField(this, "eventStream");
|
|
22342
22328
|
__publicField(this, "eventStreamObserver");
|
|
22329
|
+
this.validateChannelKey(key);
|
|
22343
22330
|
this.key = key;
|
|
22344
22331
|
this.status = "detached";
|
|
22345
22332
|
this.count = 0;
|
|
@@ -22354,6 +22341,12 @@ class Channel2 {
|
|
|
22354
22341
|
getKey() {
|
|
22355
22342
|
return this.key;
|
|
22356
22343
|
}
|
|
22344
|
+
/**
|
|
22345
|
+
* `getFirstKeyPath` returns the first key path to the presence count.
|
|
22346
|
+
*/
|
|
22347
|
+
getFirstKeyPath() {
|
|
22348
|
+
return this.key.split(KeyPathSeparator)[0];
|
|
22349
|
+
}
|
|
22357
22350
|
/**
|
|
22358
22351
|
* `getStatus` returns the status of this channel.
|
|
22359
22352
|
*/
|
|
@@ -22499,6 +22492,23 @@ class Channel2 {
|
|
|
22499
22492
|
options
|
|
22500
22493
|
});
|
|
22501
22494
|
}
|
|
22495
|
+
validateChannelKey(key) {
|
|
22496
|
+
if (key === "") {
|
|
22497
|
+
throw new Error("channel key must not be empty");
|
|
22498
|
+
}
|
|
22499
|
+
if (key.includes(" ")) {
|
|
22500
|
+
throw new Error("channel key must not contain a whitespace");
|
|
22501
|
+
}
|
|
22502
|
+
if (key.startsWith(KeyPathSeparator)) {
|
|
22503
|
+
throw new Error("channel key must not start with a period");
|
|
22504
|
+
}
|
|
22505
|
+
if (key.endsWith(KeyPathSeparator)) {
|
|
22506
|
+
throw new Error("channel key must not end with a period");
|
|
22507
|
+
}
|
|
22508
|
+
if (key.includes(`${KeyPathSeparator}${KeyPathSeparator}`)) {
|
|
22509
|
+
throw new Error("channel key path must not empty");
|
|
22510
|
+
}
|
|
22511
|
+
}
|
|
22502
22512
|
}
|
|
22503
22513
|
var SyncMode = /* @__PURE__ */ ((SyncMode2) => {
|
|
22504
22514
|
SyncMode2["Manual"] = "manual";
|
|
@@ -22857,7 +22867,11 @@ class Client {
|
|
|
22857
22867
|
clientId: this.id,
|
|
22858
22868
|
channelKey: channel.getKey()
|
|
22859
22869
|
},
|
|
22860
|
-
{
|
|
22870
|
+
{
|
|
22871
|
+
headers: {
|
|
22872
|
+
"x-shard-key": `${this.apiKey}/${channel.getFirstKeyPath()}`
|
|
22873
|
+
}
|
|
22874
|
+
}
|
|
22861
22875
|
);
|
|
22862
22876
|
channel.setSessionID(res.sessionId);
|
|
22863
22877
|
channel.updateCount(Number(res.count), 0);
|
|
@@ -22921,7 +22935,11 @@ class Client {
|
|
|
22921
22935
|
channelKey: channel.getKey(),
|
|
22922
22936
|
sessionId: channel.getSessionID()
|
|
22923
22937
|
},
|
|
22924
|
-
{
|
|
22938
|
+
{
|
|
22939
|
+
headers: {
|
|
22940
|
+
"x-shard-key": `${this.apiKey}/${channel.getFirstKeyPath()}`
|
|
22941
|
+
}
|
|
22942
|
+
}
|
|
22925
22943
|
);
|
|
22926
22944
|
channel.updateCount(Number(res.count), 0);
|
|
22927
22945
|
channel.applyStatus(ChannelStatus.Detached);
|
|
@@ -23132,6 +23150,7 @@ class Client {
|
|
|
23132
23150
|
"payload is not serializable"
|
|
23133
23151
|
);
|
|
23134
23152
|
}
|
|
23153
|
+
const ch = attachment.resource;
|
|
23135
23154
|
const maxRetries = (options == null ? void 0 : options.maxRetries) ?? DefaultBroadcastOptions.maxRetries;
|
|
23136
23155
|
const maxBackoff = DefaultBroadcastOptions.maxBackoff;
|
|
23137
23156
|
let retryCount = 0;
|
|
@@ -23152,7 +23171,11 @@ class Client {
|
|
|
23152
23171
|
topic,
|
|
23153
23172
|
payload: new TextEncoder().encode(JSON.stringify(payload))
|
|
23154
23173
|
},
|
|
23155
|
-
{
|
|
23174
|
+
{
|
|
23175
|
+
headers: {
|
|
23176
|
+
"x-shard-key": `${this.apiKey}/${ch.getFirstKeyPath()}`
|
|
23177
|
+
}
|
|
23178
|
+
}
|
|
23156
23179
|
);
|
|
23157
23180
|
logger.info(
|
|
23158
23181
|
`[BC] c:"${this.getKey()}" broadcasts p:"${key}" t:"${topic}"`
|
|
@@ -23413,7 +23436,9 @@ class Client {
|
|
|
23413
23436
|
channelKey: key
|
|
23414
23437
|
},
|
|
23415
23438
|
{
|
|
23416
|
-
headers: {
|
|
23439
|
+
headers: {
|
|
23440
|
+
"x-shard-key": `${this.apiKey}/${attachment.resource.getFirstKeyPath()}`
|
|
23441
|
+
},
|
|
23417
23442
|
signal: ac.signal
|
|
23418
23443
|
}
|
|
23419
23444
|
);
|
|
@@ -23537,7 +23562,7 @@ class Client {
|
|
|
23537
23562
|
},
|
|
23538
23563
|
{
|
|
23539
23564
|
headers: {
|
|
23540
|
-
"x-shard-key": `${this.apiKey}/${resource.
|
|
23565
|
+
"x-shard-key": `${this.apiKey}/${resource.getFirstKeyPath()}`
|
|
23541
23566
|
}
|
|
23542
23567
|
}
|
|
23543
23568
|
);
|