@tuwaio/quasar-sdk 0.1.10 → 0.1.12
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/cli.cjs +14 -4
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -47,7 +47,7 @@ var path = __toESM(require("path"), 1);
|
|
|
47
47
|
// package.json
|
|
48
48
|
var package_default = {
|
|
49
49
|
name: "@tuwaio/quasar-sdk",
|
|
50
|
-
version: "0.1.
|
|
50
|
+
version: "0.1.12",
|
|
51
51
|
private: false,
|
|
52
52
|
author: "Oleksandr Tkach",
|
|
53
53
|
license: "Apache-2.0",
|
|
@@ -323,14 +323,14 @@ async function runListen(options) {
|
|
|
323
323
|
const reader = response.body.getReader();
|
|
324
324
|
const decoder = new TextDecoder("utf-8");
|
|
325
325
|
let buffer = "";
|
|
326
|
+
let currentEvent = "message";
|
|
327
|
+
let currentData = "";
|
|
326
328
|
while (!isShuttingDown) {
|
|
327
329
|
const { done, value } = await reader.read();
|
|
328
330
|
if (done) break;
|
|
329
331
|
buffer += decoder.decode(value, { stream: true });
|
|
330
332
|
const lines = buffer.split("\n");
|
|
331
333
|
buffer = lines.pop() || "";
|
|
332
|
-
let currentEvent = "message";
|
|
333
|
-
let currentData = "";
|
|
334
334
|
for (const line of lines) {
|
|
335
335
|
const trimmed = line.trim();
|
|
336
336
|
if (!trimmed) {
|
|
@@ -341,6 +341,9 @@ async function runListen(options) {
|
|
|
341
341
|
}
|
|
342
342
|
continue;
|
|
343
343
|
}
|
|
344
|
+
if (trimmed.startsWith(":")) {
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
344
347
|
if (trimmed.startsWith("event:")) {
|
|
345
348
|
currentEvent = trimmed.slice(6).trim();
|
|
346
349
|
} else if (trimmed.startsWith("data:")) {
|
|
@@ -350,6 +353,13 @@ ${dataLine}` : dataLine;
|
|
|
350
353
|
}
|
|
351
354
|
}
|
|
352
355
|
}
|
|
356
|
+
if (!isShuttingDown) {
|
|
357
|
+
console.warn(
|
|
358
|
+
`\x1B[33m[warn]\x1B[0m SSE stream closed by remote server. Reconnecting in ${reconnectDelay}ms...`
|
|
359
|
+
);
|
|
360
|
+
await new Promise((resolve) => setTimeout(resolve, reconnectDelay));
|
|
361
|
+
reconnectDelay = Math.min(reconnectDelay * 2, 15e3);
|
|
362
|
+
}
|
|
353
363
|
} catch (err) {
|
|
354
364
|
if (isShuttingDown) break;
|
|
355
365
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -365,7 +375,7 @@ async function handleSseMessage(event, rawData, forwardTo) {
|
|
|
365
375
|
}
|
|
366
376
|
try {
|
|
367
377
|
const payload = JSON.parse(rawData);
|
|
368
|
-
if (event === "connected") {
|
|
378
|
+
if (event === "connected" || event === "ready") {
|
|
369
379
|
return;
|
|
370
380
|
}
|
|
371
381
|
if (event === "payload" || event === "webhook" || event === "message") {
|