@ceki/sdk 1.10.0 → 1.11.0
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/README.md +9 -9
- package/dist/cli.js +22 -24
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +12 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +12 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -623,7 +623,6 @@ function keymapForChar(char) {
|
|
|
623
623
|
var Browser = class _Browser {
|
|
624
624
|
sessionId;
|
|
625
625
|
browserId;
|
|
626
|
-
scheduleId;
|
|
627
626
|
chatTopicId;
|
|
628
627
|
browserInfo;
|
|
629
628
|
providerUserId;
|
|
@@ -669,8 +668,7 @@ var Browser = class _Browser {
|
|
|
669
668
|
constructor(client, match, humanizer) {
|
|
670
669
|
this._client = client;
|
|
671
670
|
this.sessionId = match.session_id;
|
|
672
|
-
this.browserId = match.
|
|
673
|
-
this.scheduleId = match.schedule_id;
|
|
671
|
+
this.browserId = match.browser_id;
|
|
674
672
|
this.chatTopicId = match.chat_topic_id ?? null;
|
|
675
673
|
this.browserInfo = match.browser_info ?? {};
|
|
676
674
|
this.providerUserId = match.provider_user_id ?? null;
|
|
@@ -685,7 +683,7 @@ var Browser = class _Browser {
|
|
|
685
683
|
saveSession(this.sessionId, {
|
|
686
684
|
session_id: this.sessionId,
|
|
687
685
|
chat_topic_id: this.chatTopicId,
|
|
688
|
-
|
|
686
|
+
browser_id: this.browserId,
|
|
689
687
|
last_seen_ts: this._lastSeenTs
|
|
690
688
|
});
|
|
691
689
|
}
|
|
@@ -1454,7 +1452,7 @@ var Client = class _Client {
|
|
|
1454
1452
|
_pongTimer = null;
|
|
1455
1453
|
_lastPongAt = 0;
|
|
1456
1454
|
_pendingRents = /* @__PURE__ */ new Map();
|
|
1457
|
-
// keyed by `rent:<
|
|
1455
|
+
// keyed by `rent:<browserId>` or eventId
|
|
1458
1456
|
_pendingResumes = /* @__PURE__ */ new Map();
|
|
1459
1457
|
// keyed by sessionId
|
|
1460
1458
|
_connectResolve = null;
|
|
@@ -1545,18 +1543,18 @@ var Client = class _Client {
|
|
|
1545
1543
|
const items = body.browsers ?? body.data ?? body;
|
|
1546
1544
|
return Array.isArray(items) ? items : [];
|
|
1547
1545
|
}
|
|
1548
|
-
async rent(
|
|
1549
|
-
const rentMsg = { type: "rent", browser_id:
|
|
1546
|
+
async rent(browserId, opts) {
|
|
1547
|
+
const rentMsg = { type: "rent", browser_id: browserId };
|
|
1550
1548
|
if (opts?.mode) rentMsg.mode = opts.mode;
|
|
1551
1549
|
this._wsSend(rentMsg);
|
|
1552
|
-
const key = `rent:${
|
|
1550
|
+
const key = `rent:${browserId}`;
|
|
1553
1551
|
return new Promise((resolve, reject) => {
|
|
1554
1552
|
const timer = setTimeout(() => {
|
|
1555
1553
|
this._pendingRents.delete(key);
|
|
1556
1554
|
reject(new TimeoutError("Rent timed out after 90s"));
|
|
1557
1555
|
}, 9e4);
|
|
1558
1556
|
this._pendingRents.set(key, {
|
|
1559
|
-
|
|
1557
|
+
browserId,
|
|
1560
1558
|
eventId: null,
|
|
1561
1559
|
opts,
|
|
1562
1560
|
resolve: (match) => {
|
|
@@ -1861,7 +1859,7 @@ var Client = class _Client {
|
|
|
1861
1859
|
}
|
|
1862
1860
|
_onMatch(msg) {
|
|
1863
1861
|
const eventId = String(msg.event_id ?? "");
|
|
1864
|
-
const
|
|
1862
|
+
const browserId = Number(msg.browser_id ?? 0);
|
|
1865
1863
|
const sessionId = String(msg.session_id ?? "");
|
|
1866
1864
|
if (msg.requires_ack) {
|
|
1867
1865
|
try {
|
|
@@ -1871,15 +1869,15 @@ var Client = class _Client {
|
|
|
1871
1869
|
}
|
|
1872
1870
|
let pending = this._pendingRents.get(`event:${eventId}`);
|
|
1873
1871
|
if (!pending) {
|
|
1874
|
-
pending = this._pendingRents.get(`rent:${
|
|
1872
|
+
pending = this._pendingRents.get(`rent:${browserId}`);
|
|
1875
1873
|
}
|
|
1876
1874
|
if (pending) {
|
|
1877
1875
|
clearTimeout(pending.timer);
|
|
1878
|
-
const key = pending.eventId ? `event:${pending.eventId}` : `rent:${pending.
|
|
1876
|
+
const key = pending.eventId ? `event:${pending.eventId}` : `rent:${pending.browserId}`;
|
|
1879
1877
|
this._pendingRents.delete(key);
|
|
1880
1878
|
const match = {
|
|
1881
1879
|
session_id: sessionId,
|
|
1882
|
-
|
|
1880
|
+
browser_id: browserId,
|
|
1883
1881
|
event_id: eventId || null,
|
|
1884
1882
|
chat_topic_id: msg.chat_topic_id ? String(msg.chat_topic_id) : null,
|
|
1885
1883
|
provider_user_id: msg.provider_user_id != null ? Number(msg.provider_user_id) : null,
|
|
@@ -1921,7 +1919,7 @@ var Client = class _Client {
|
|
|
1921
1919
|
const match = {
|
|
1922
1920
|
session_id: sessionId,
|
|
1923
1921
|
event_id: msg.event_id != null ? String(msg.event_id) : null,
|
|
1924
|
-
|
|
1922
|
+
browser_id: Number(msg.browser_id ?? 0),
|
|
1925
1923
|
chat_topic_id: msg.chat_topic_id ? String(msg.chat_topic_id) : null,
|
|
1926
1924
|
provider_user_id: msg.provider_user_id != null ? Number(msg.provider_user_id) : null,
|
|
1927
1925
|
started_at: Date.now(),
|