soonjs 0.0.18 → 0.0.20
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/index.d.ts +1 -0
- package/dist/index.js +38 -22
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -54475,43 +54475,50 @@ function Aue({
|
|
|
54475
54475
|
pingTime: e = 0,
|
|
54476
54476
|
action: t
|
|
54477
54477
|
}) {
|
|
54478
|
-
|
|
54479
|
-
|
|
54480
|
-
|
|
54481
|
-
|
|
54478
|
+
let r = () => null;
|
|
54479
|
+
const n = new SE((i) => {
|
|
54480
|
+
let s;
|
|
54481
|
+
e > 0 && (s = setInterval(() => {
|
|
54482
|
+
o.closed ? clearInterval(s) : i.next({ event: "ping", message: `: ping
|
|
54482
54483
|
|
|
54483
54484
|
` });
|
|
54484
54485
|
}, e));
|
|
54485
|
-
const
|
|
54486
|
-
send(
|
|
54486
|
+
const a = [], o = {
|
|
54487
|
+
send(u) {
|
|
54487
54488
|
try {
|
|
54488
|
-
|
|
54489
|
-
...
|
|
54490
|
-
message: `${
|
|
54491
|
-
` : ""}data: ${typeof
|
|
54489
|
+
i.next({
|
|
54490
|
+
...u,
|
|
54491
|
+
message: `${u.event ? `event: ${u.event}
|
|
54492
|
+
` : ""}data: ${typeof u.data == "string" ? u.data : JSON.stringify(u.data)}
|
|
54492
54493
|
|
|
54493
54494
|
`
|
|
54494
54495
|
});
|
|
54495
|
-
} catch (
|
|
54496
|
-
|
|
54496
|
+
} catch (l) {
|
|
54497
|
+
o.error(l.message);
|
|
54497
54498
|
}
|
|
54498
54499
|
},
|
|
54499
|
-
error(
|
|
54500
|
-
|
|
54501
|
-
data: ${
|
|
54500
|
+
error(u) {
|
|
54501
|
+
i.next({ event: "error", data: u, message: `event: error
|
|
54502
|
+
data: ${u}
|
|
54502
54503
|
|
|
54503
|
-
` }),
|
|
54504
|
+
` }), i.complete(), o.closed = !0, a.forEach((l) => l == null ? void 0 : l());
|
|
54504
54505
|
},
|
|
54505
54506
|
close() {
|
|
54506
|
-
|
|
54507
|
+
i.next({ event: "close", message: `event: close
|
|
54507
54508
|
data:
|
|
54508
54509
|
|
|
54509
|
-
` }),
|
|
54510
|
+
` }), i.complete(), o.closed = !0, s && clearInterval(s), a.forEach((u) => u == null ? void 0 : u());
|
|
54510
54511
|
},
|
|
54511
|
-
closed: !1
|
|
54512
|
+
closed: !1,
|
|
54513
|
+
onClosed(u) {
|
|
54514
|
+
a.push(u);
|
|
54515
|
+
}
|
|
54512
54516
|
};
|
|
54513
|
-
|
|
54517
|
+
r = () => {
|
|
54518
|
+
o.closed || o.close();
|
|
54519
|
+
}, t(o);
|
|
54514
54520
|
});
|
|
54521
|
+
return n.streamClose = () => r == null ? void 0 : r(), n;
|
|
54515
54522
|
}
|
|
54516
54523
|
function $oe(e) {
|
|
54517
54524
|
return e instanceof SE;
|
|
@@ -54524,8 +54531,17 @@ function Cue(e) {
|
|
|
54524
54531
|
t.write(r.message);
|
|
54525
54532
|
},
|
|
54526
54533
|
complete() {
|
|
54527
|
-
t.end();
|
|
54528
|
-
}
|
|
54534
|
+
t.closed || t.end();
|
|
54535
|
+
}
|
|
54536
|
+
}), t.on("close", () => {
|
|
54537
|
+
var r;
|
|
54538
|
+
return (r = e == null ? void 0 : e.streamClose) == null ? void 0 : r.call(e);
|
|
54539
|
+
}), t.on("error", () => {
|
|
54540
|
+
var r;
|
|
54541
|
+
return (r = e == null ? void 0 : e.streamClose) == null ? void 0 : r.call(e);
|
|
54542
|
+
}), t.on("end", () => {
|
|
54543
|
+
var r;
|
|
54544
|
+
return (r = e == null ? void 0 : e.streamClose) == null ? void 0 : r.call(e);
|
|
54529
54545
|
}), t;
|
|
54530
54546
|
} else
|
|
54531
54547
|
throw new Error("Not a valid SSE body");
|