soonjs 0.0.17 → 0.0.19
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.js +37 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5166,6 +5166,8 @@ const Yc = /* @__PURE__ */ dl(Du), eN = `declare module 'soonjs/auto/client' {
|
|
|
5166
5166
|
import type { Context, SoonFetchOptions, Meta } from '.soonjs/node_modules/soonjs';
|
|
5167
5167
|
import { z, ZodType } from 'zod';
|
|
5168
5168
|
|
|
5169
|
+
export { type SoonFetchOptions };
|
|
5170
|
+
|
|
5169
5171
|
type NonUndefined<A> = A extends undefined ? never : A;
|
|
5170
5172
|
type ReturnRealType<T extends (...args: any) => any | Promise<(...args: any) => any>, R = ReturnType<T>> = R extends Promise<infer U> ? U : R;
|
|
5171
5173
|
|
|
@@ -5175,6 +5177,7 @@ const Yc = /* @__PURE__ */ dl(Du), eN = `declare module 'soonjs/auto/client' {
|
|
|
5175
5177
|
* ============================================
|
|
5176
5178
|
*/
|
|
5177
5179
|
$$$apis$$$
|
|
5180
|
+
export { type apis as soonApis }
|
|
5178
5181
|
/**
|
|
5179
5182
|
* 调用服务端 api
|
|
5180
5183
|
*/
|
|
@@ -54472,43 +54475,47 @@ function Aue({
|
|
|
54472
54475
|
pingTime: e = 0,
|
|
54473
54476
|
action: t
|
|
54474
54477
|
}) {
|
|
54475
|
-
|
|
54476
|
-
|
|
54477
|
-
|
|
54478
|
-
|
|
54478
|
+
let r = () => null;
|
|
54479
|
+
const n = new SE((i) => {
|
|
54480
|
+
let s;
|
|
54481
|
+
e > 0 && (s = setInterval(() => {
|
|
54482
|
+
a.closed ? clearInterval(s) : i.next({ event: "ping", message: `: ping
|
|
54479
54483
|
|
|
54480
54484
|
` });
|
|
54481
54485
|
}, e));
|
|
54482
|
-
const
|
|
54483
|
-
send(
|
|
54486
|
+
const a = {
|
|
54487
|
+
send(o) {
|
|
54484
54488
|
try {
|
|
54485
|
-
|
|
54486
|
-
...
|
|
54487
|
-
message: `${
|
|
54488
|
-
` : ""}data: ${typeof
|
|
54489
|
+
i.next({
|
|
54490
|
+
...o,
|
|
54491
|
+
message: `${o.event ? `event: ${o.event}
|
|
54492
|
+
` : ""}data: ${typeof o.data == "string" ? o.data : JSON.stringify(o.data)}
|
|
54489
54493
|
|
|
54490
54494
|
`
|
|
54491
54495
|
});
|
|
54492
|
-
} catch (
|
|
54493
|
-
|
|
54496
|
+
} catch (u) {
|
|
54497
|
+
a.error(u.message);
|
|
54494
54498
|
}
|
|
54495
54499
|
},
|
|
54496
|
-
error(
|
|
54497
|
-
|
|
54498
|
-
data: ${
|
|
54500
|
+
error(o) {
|
|
54501
|
+
i.next({ event: "error", data: o, message: `event: error
|
|
54502
|
+
data: ${o}
|
|
54499
54503
|
|
|
54500
|
-
` }),
|
|
54504
|
+
` }), i.complete(), a.closed = !0;
|
|
54501
54505
|
},
|
|
54502
54506
|
close() {
|
|
54503
|
-
|
|
54507
|
+
i.next({ event: "close", message: `event: close
|
|
54504
54508
|
data:
|
|
54505
54509
|
|
|
54506
|
-
` }),
|
|
54510
|
+
` }), i.complete(), a.closed = !0, s && clearInterval(s);
|
|
54507
54511
|
},
|
|
54508
54512
|
closed: !1
|
|
54509
54513
|
};
|
|
54510
|
-
|
|
54514
|
+
r = () => {
|
|
54515
|
+
a.closed || a.close();
|
|
54516
|
+
}, t(a);
|
|
54511
54517
|
});
|
|
54518
|
+
return n.streamClose = () => r == null ? void 0 : r(), n;
|
|
54512
54519
|
}
|
|
54513
54520
|
function $oe(e) {
|
|
54514
54521
|
return e instanceof SE;
|
|
@@ -54521,8 +54528,17 @@ function Cue(e) {
|
|
|
54521
54528
|
t.write(r.message);
|
|
54522
54529
|
},
|
|
54523
54530
|
complete() {
|
|
54524
|
-
t.end();
|
|
54525
|
-
}
|
|
54531
|
+
t.closed || t.end();
|
|
54532
|
+
}
|
|
54533
|
+
}), t.on("close", () => {
|
|
54534
|
+
var r;
|
|
54535
|
+
return (r = e == null ? void 0 : e.streamClose) == null ? void 0 : r.call(e);
|
|
54536
|
+
}), t.on("error", () => {
|
|
54537
|
+
var r;
|
|
54538
|
+
return (r = e == null ? void 0 : e.streamClose) == null ? void 0 : r.call(e);
|
|
54539
|
+
}), t.on("end", () => {
|
|
54540
|
+
var r;
|
|
54541
|
+
return (r = e == null ? void 0 : e.streamClose) == null ? void 0 : r.call(e);
|
|
54526
54542
|
}), t;
|
|
54527
54543
|
} else
|
|
54528
54544
|
throw new Error("Not a valid SSE body");
|