@mauroandre/velojs 0.0.57 → 0.0.59
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 +91 -2
- package/agent/AGENTS.md +2 -0
- package/agent/skills/velojs-live-loader/SKILL.md +3 -1
- package/agent/skills/velojs-production-deploy/SKILL.md +7 -1
- package/agent/skills/velojs-telemetry/SKILL.md +182 -0
- package/dist/channels.d.ts +8 -1
- package/dist/channels.js +282 -227
- package/dist/cli.js +46 -32
- package/dist/events.d.ts +9 -1
- package/dist/events.js +161 -152
- package/dist/server.js +245 -198
- package/dist/sockets.d.ts +4 -1
- package/dist/sockets.js +115 -102
- package/dist/telemetry-cli.d.ts +67 -0
- package/dist/telemetry-cli.js +265 -0
- package/dist/telemetry-node.d.ts +38 -0
- package/dist/telemetry-node.js +93 -0
- package/dist/telemetry.d.ts +204 -0
- package/dist/telemetry.js +240 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1,310 +1,357 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Hono as
|
|
3
|
-
import { logger as
|
|
4
|
-
import { trimTrailingSlash as
|
|
5
|
-
import { render as
|
|
6
|
-
import { Router as
|
|
7
|
-
import { AsyncLocalStorage as
|
|
1
|
+
import { jsx as y } from "preact/jsx-runtime";
|
|
2
|
+
import { Hono as I } from "hono";
|
|
3
|
+
import { logger as O } from "hono/logger";
|
|
4
|
+
import { trimTrailingSlash as H } from "hono/trailing-slash";
|
|
5
|
+
import { render as V } from "preact-render-to-string";
|
|
6
|
+
import { Router as x } from "wouter-preact";
|
|
7
|
+
import { AsyncLocalStorage as G } from "node:async_hooks";
|
|
8
8
|
import { getAppContext as _ } from "./app-context.js";
|
|
9
|
-
import { flushPendingStreamRoutes as
|
|
10
|
-
import { registerSocketRoutes as
|
|
11
|
-
import { inspectChannels as
|
|
12
|
-
import { emit as
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
import { flushPendingStreamRoutes as L, registerStreamHandler as B } from "./events.js";
|
|
10
|
+
import { registerSocketRoutes as M, injectWebSocketServer as E } from "./sockets.js";
|
|
11
|
+
import { inspectChannels as W, registerChannelRoute as K } from "./channels.js";
|
|
12
|
+
import { emit as Se, registerChannels as Pe } from "./channels.js";
|
|
13
|
+
import { trace as P, jsonBytes as C, responseBytes as R, byteLength as F } from "./telemetry.js";
|
|
14
|
+
import { initNodeTelemetry as U } from "./telemetry-node.js";
|
|
15
|
+
const j = new G();
|
|
16
|
+
globalThis.__veloServerData = j;
|
|
17
|
+
let w = null;
|
|
18
|
+
function ve(e) {
|
|
19
|
+
if (w) {
|
|
20
|
+
e(w);
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
23
|
_().serverCallbacks.push(e);
|
|
22
24
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
+
function k(e) {
|
|
26
|
+
w = e;
|
|
25
27
|
const t = _();
|
|
26
|
-
for (const
|
|
28
|
+
for (const i of t.serverCallbacks) i(e);
|
|
27
29
|
t.serverCallbacks.length = 0;
|
|
28
30
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
+
function J(e) {
|
|
32
|
+
w === e && (w = null);
|
|
31
33
|
}
|
|
32
|
-
function
|
|
34
|
+
function we(e) {
|
|
33
35
|
_().pendingRoutes.push(e);
|
|
34
36
|
}
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
return e.json(
|
|
37
|
+
const z = (e) => JSON.stringify(e).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), Q = (e, t, i, s, o) => {
|
|
38
|
+
if (s && s !== 200 && e.status(s), e.req.query("_data") === "1") {
|
|
39
|
+
const r = globalThis.__veloBuildHash || void 0, a = i ? { ...i, __buildHash: r } : { __buildHash: r };
|
|
40
|
+
return { response: e.json(a), bytes: o.enabled ? C(a) : void 0 };
|
|
39
41
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
const n = o.span("render");
|
|
43
|
+
try {
|
|
44
|
+
const r = e.req.path;
|
|
45
|
+
let a = j.run(
|
|
46
|
+
i ?? {},
|
|
47
|
+
() => V(/* @__PURE__ */ y(x, { ssrPath: r, children: t }))
|
|
48
|
+
);
|
|
49
|
+
if (e.header("Cache-Control", "no-cache"), i) {
|
|
50
|
+
const l = `<script>window.__PAGE_DATA__=${z(i)}<\/script>`;
|
|
51
|
+
a = a.replace("</head>", () => `${l}</head>`);
|
|
52
|
+
}
|
|
53
|
+
return n.end("ok"), { response: e.html(a), bytes: o.enabled ? F(a) : void 0 };
|
|
54
|
+
} catch (r) {
|
|
55
|
+
throw n.end("error"), r;
|
|
56
|
+
}
|
|
57
|
+
}, X = async (e, t, i) => {
|
|
58
|
+
const s = t.req.param(), o = t.req.query(), n = { params: s, query: o, c: t }, r = await Promise.all(
|
|
59
|
+
e.map(async (c) => {
|
|
60
|
+
if (!c.loader) return null;
|
|
61
|
+
const h = c.metadata?.moduleId, u = i.span(`loader:${h ?? "anonymous"}`);
|
|
62
|
+
try {
|
|
63
|
+
const d = await c.loader(n);
|
|
64
|
+
return u.end("ok"), h ? { moduleId: h, loaderData: d } : null;
|
|
65
|
+
} catch (d) {
|
|
66
|
+
throw u.end("error"), d;
|
|
67
|
+
}
|
|
54
68
|
})
|
|
55
69
|
);
|
|
56
|
-
let
|
|
57
|
-
for (const
|
|
58
|
-
if (
|
|
59
|
-
|
|
70
|
+
let a;
|
|
71
|
+
for (const c of r)
|
|
72
|
+
if (c && c.loaderData instanceof Response) {
|
|
73
|
+
a = c.loaderData;
|
|
60
74
|
break;
|
|
61
75
|
}
|
|
62
|
-
const
|
|
63
|
-
__params:
|
|
64
|
-
__query:
|
|
76
|
+
const l = {
|
|
77
|
+
__params: s,
|
|
78
|
+
__query: o,
|
|
65
79
|
__pathname: t.req.path
|
|
66
80
|
};
|
|
67
|
-
for (const
|
|
68
|
-
|
|
81
|
+
for (const c of r)
|
|
82
|
+
c && !(c.loaderData instanceof Response) && (l[c.moduleId] = c.loaderData);
|
|
69
83
|
return {
|
|
70
|
-
components: e.map((
|
|
71
|
-
data:
|
|
72
|
-
shortCircuit:
|
|
84
|
+
components: e.map((c) => c.Component),
|
|
85
|
+
data: l,
|
|
86
|
+
shortCircuit: a
|
|
73
87
|
};
|
|
74
|
-
},
|
|
88
|
+
}, Y = (e) => {
|
|
75
89
|
if (e.length === 0) return null;
|
|
76
90
|
const t = e.filter(Boolean);
|
|
77
91
|
if (t.length === 0) return null;
|
|
78
92
|
if (t.length === 1) {
|
|
79
93
|
const o = t[0];
|
|
80
|
-
return /* @__PURE__ */
|
|
94
|
+
return /* @__PURE__ */ y(o, {});
|
|
81
95
|
}
|
|
82
|
-
const
|
|
83
|
-
return t.slice(0, -1).reduceRight((o, n) => /* @__PURE__ */
|
|
84
|
-
},
|
|
96
|
+
const i = t[t.length - 1];
|
|
97
|
+
return t.slice(0, -1).reduceRight((o, n) => /* @__PURE__ */ y(n, { children: o }), /* @__PURE__ */ y(i, {}));
|
|
98
|
+
}, S = (e, t, i = [], s = []) => {
|
|
85
99
|
for (const o of t) {
|
|
86
100
|
if (o.handler && !o.module) {
|
|
87
|
-
o.children &&
|
|
101
|
+
o.children && S(
|
|
88
102
|
e,
|
|
89
103
|
o.children,
|
|
90
|
-
|
|
91
|
-
[...
|
|
104
|
+
i,
|
|
105
|
+
[...s, ...o.middlewares || []]
|
|
92
106
|
);
|
|
93
107
|
continue;
|
|
94
108
|
}
|
|
95
|
-
const n = o.module ? [...
|
|
96
|
-
...
|
|
109
|
+
const n = o.module ? [...i, o.module] : i, r = [
|
|
110
|
+
...s,
|
|
97
111
|
...o.middlewares || []
|
|
98
112
|
];
|
|
99
113
|
if (o.children)
|
|
100
|
-
|
|
114
|
+
S(
|
|
101
115
|
e,
|
|
102
116
|
o.children,
|
|
103
117
|
n,
|
|
104
|
-
|
|
118
|
+
r
|
|
105
119
|
);
|
|
106
120
|
else if (o.module) {
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
121
|
+
const a = o.path === "*", l = o.statusCode ?? (a ? 404 : void 0), c = o.module.metadata?.fullPath;
|
|
122
|
+
if (!c && !a) {
|
|
109
123
|
console.warn(
|
|
110
124
|
`Module ${o.module.metadata?.moduleId} has no fullPath`
|
|
111
125
|
);
|
|
112
126
|
continue;
|
|
113
127
|
}
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
const h = async (u) => {
|
|
129
|
+
const d = u.req.query("_data") === "1", f = n[n.length - 1], m = P(d ? "data" : "page", {
|
|
130
|
+
route: c ?? f?.metadata?.fullPath,
|
|
131
|
+
module: f?.metadata?.moduleId
|
|
132
|
+
});
|
|
133
|
+
try {
|
|
134
|
+
const { components: v, data: p, shortCircuit: g } = await X(n, u, m);
|
|
135
|
+
if (g) {
|
|
136
|
+
const b = g.headers.get("Location");
|
|
137
|
+
return d && b && g.status >= 300 && g.status < 400 ? (m.end({
|
|
138
|
+
status: "ok",
|
|
139
|
+
bytes: m.enabled ? C({ __redirect: b }) : void 0
|
|
140
|
+
}), u.json({ __redirect: b })) : (m.end({
|
|
141
|
+
status: "ok",
|
|
142
|
+
bytes: m.enabled ? await R(g) : void 0
|
|
143
|
+
}), g);
|
|
144
|
+
}
|
|
145
|
+
const $ = Y(v), { response: D, bytes: N } = Q(u, $, p, l, m);
|
|
146
|
+
return m.end({ status: "ok", bytes: N }), D;
|
|
147
|
+
} catch (v) {
|
|
148
|
+
throw m.end({ status: "error" }), v;
|
|
119
149
|
}
|
|
120
|
-
const p = W(u);
|
|
121
|
-
return V(d, p, h, i);
|
|
122
150
|
};
|
|
123
|
-
|
|
151
|
+
a ? e.notFound(h) : r.length > 0 ? e.on(["GET"], [c], ...r, h) : e.on(["GET"], [c], h);
|
|
124
152
|
} else
|
|
125
153
|
continue;
|
|
126
154
|
}
|
|
127
|
-
},
|
|
128
|
-
for (const
|
|
129
|
-
const o =
|
|
130
|
-
...
|
|
131
|
-
...
|
|
155
|
+
}, T = (e, t, i = []) => {
|
|
156
|
+
for (const s of t) {
|
|
157
|
+
const o = s.module?.metadata?.moduleId, n = [
|
|
158
|
+
...i,
|
|
159
|
+
...s.middlewares || []
|
|
132
160
|
];
|
|
133
|
-
if (
|
|
134
|
-
const
|
|
135
|
-
(
|
|
161
|
+
if (s.module && o) {
|
|
162
|
+
const r = Object.keys(s.module).filter(
|
|
163
|
+
(a) => a.startsWith("action_")
|
|
136
164
|
);
|
|
137
|
-
for (const
|
|
138
|
-
const
|
|
139
|
-
if (typeof
|
|
140
|
-
const
|
|
141
|
-
|
|
165
|
+
for (const a of r) {
|
|
166
|
+
const l = a.replace("action_", ""), c = s.module[a];
|
|
167
|
+
if (typeof c == "function") {
|
|
168
|
+
const h = `/_action/${o}/${l}`, u = async (d) => {
|
|
169
|
+
const f = P("action", {
|
|
170
|
+
route: s.module?.metadata?.fullPath,
|
|
171
|
+
module: o,
|
|
172
|
+
name: l
|
|
173
|
+
});
|
|
174
|
+
let m = {};
|
|
142
175
|
try {
|
|
143
|
-
|
|
176
|
+
m = await d.req.json();
|
|
144
177
|
} catch {
|
|
145
178
|
}
|
|
146
|
-
const
|
|
147
|
-
body:
|
|
148
|
-
params:
|
|
149
|
-
query:
|
|
150
|
-
c:
|
|
179
|
+
const v = {
|
|
180
|
+
body: m,
|
|
181
|
+
params: d.req.param(),
|
|
182
|
+
query: d.req.query(),
|
|
183
|
+
c: d
|
|
151
184
|
};
|
|
152
185
|
try {
|
|
153
|
-
const
|
|
154
|
-
return
|
|
186
|
+
const g = await c(v) ?? { ok: !0 };
|
|
187
|
+
return f.end({ status: "ok", bytes: f.enabled ? C(g) : void 0 }), d.json(g);
|
|
155
188
|
} catch (p) {
|
|
156
|
-
const
|
|
157
|
-
return
|
|
189
|
+
const g = p instanceof Error ? p.message : "Action failed";
|
|
190
|
+
return f.end({ status: "error" }), d.json({ error: g }, 500);
|
|
158
191
|
}
|
|
159
192
|
};
|
|
160
193
|
n.length > 0 ? e.on(
|
|
161
194
|
["POST"],
|
|
162
|
-
[
|
|
195
|
+
[h],
|
|
163
196
|
...n,
|
|
164
|
-
|
|
165
|
-
) : e.on(["POST"], [
|
|
197
|
+
u
|
|
198
|
+
) : e.on(["POST"], [h], u);
|
|
166
199
|
}
|
|
167
200
|
}
|
|
168
201
|
}
|
|
169
|
-
|
|
202
|
+
s.children && T(e, s.children, n);
|
|
170
203
|
}
|
|
171
|
-
},
|
|
172
|
-
const
|
|
173
|
-
for (const
|
|
174
|
-
const
|
|
204
|
+
}, Z = async (e, t, i = []) => {
|
|
205
|
+
const s = (o, n) => {
|
|
206
|
+
for (const r of o) {
|
|
207
|
+
const a = r.module?.metadata?.moduleId, l = [
|
|
175
208
|
...n,
|
|
176
|
-
...
|
|
209
|
+
...r.middlewares || []
|
|
177
210
|
];
|
|
178
|
-
if (
|
|
179
|
-
const
|
|
180
|
-
(
|
|
211
|
+
if (r.module && a) {
|
|
212
|
+
const c = Object.keys(r.module).filter(
|
|
213
|
+
(h) => h.startsWith("stream_")
|
|
181
214
|
);
|
|
182
|
-
for (const
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
185
|
-
const
|
|
186
|
-
|
|
215
|
+
for (const h of c) {
|
|
216
|
+
const u = h.replace("stream_", ""), d = r.module[h];
|
|
217
|
+
if (d?.__isVeloEventStream) {
|
|
218
|
+
const f = `/_event/${a}/${u}`;
|
|
219
|
+
d.__path = f, B(
|
|
187
220
|
e,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
221
|
+
f,
|
|
222
|
+
d,
|
|
223
|
+
l,
|
|
224
|
+
{ moduleId: a, name: u }
|
|
191
225
|
);
|
|
192
226
|
}
|
|
193
227
|
}
|
|
194
228
|
}
|
|
195
|
-
|
|
229
|
+
r.children && s(r.children, l);
|
|
196
230
|
}
|
|
197
231
|
};
|
|
198
|
-
|
|
199
|
-
},
|
|
200
|
-
for (const
|
|
201
|
-
const o =
|
|
202
|
-
...
|
|
203
|
-
...
|
|
232
|
+
s(t, i);
|
|
233
|
+
}, q = (e, t, i = []) => {
|
|
234
|
+
for (const s of t) {
|
|
235
|
+
const o = s.module?.metadata?.moduleId, n = [
|
|
236
|
+
...i,
|
|
237
|
+
...s.middlewares || []
|
|
204
238
|
];
|
|
205
|
-
if (
|
|
206
|
-
const
|
|
207
|
-
if (Array.isArray(
|
|
208
|
-
for (const
|
|
209
|
-
|
|
239
|
+
if (s.module && o) {
|
|
240
|
+
const r = s.module.channels;
|
|
241
|
+
if (Array.isArray(r))
|
|
242
|
+
for (const a of r)
|
|
243
|
+
K(
|
|
210
244
|
e,
|
|
211
|
-
`/_channel/${o}/${
|
|
212
|
-
|
|
213
|
-
|
|
245
|
+
`/_channel/${o}/${a}`,
|
|
246
|
+
a,
|
|
247
|
+
s.module,
|
|
214
248
|
o,
|
|
215
249
|
n
|
|
216
250
|
);
|
|
217
251
|
}
|
|
218
|
-
|
|
252
|
+
s.children && q(e, s.children, n);
|
|
219
253
|
}
|
|
220
|
-
},
|
|
221
|
-
const t = /* @__PURE__ */ new Set(),
|
|
222
|
-
for (const o of
|
|
254
|
+
}, ee = (e, t) => t ? t.startsWith("/") ? e + t : e ? e + "/" + t : "/" + t : e || "", te = (e) => {
|
|
255
|
+
const t = /* @__PURE__ */ new Set(), i = (s) => {
|
|
256
|
+
for (const o of s) {
|
|
223
257
|
if (o.module && !o.children) {
|
|
224
258
|
const n = o.module.metadata?.fullPath;
|
|
225
259
|
n && t.add(n);
|
|
226
260
|
}
|
|
227
|
-
o.children &&
|
|
261
|
+
o.children && i(o.children);
|
|
228
262
|
}
|
|
229
263
|
};
|
|
230
|
-
return
|
|
231
|
-
},
|
|
264
|
+
return i(e), t;
|
|
265
|
+
}, A = (e, t, i, s = "", o = []) => {
|
|
232
266
|
for (const n of t) {
|
|
233
|
-
const
|
|
267
|
+
const r = ee(s, n.path), a = [
|
|
234
268
|
...o,
|
|
235
269
|
...n.middlewares || []
|
|
236
|
-
],
|
|
237
|
-
if (
|
|
238
|
-
`[velojs] invalid route at "${
|
|
239
|
-
) :
|
|
240
|
-
`[velojs] invalid route at "${
|
|
241
|
-
) :
|
|
242
|
-
`[velojs] ambiguous route at "${
|
|
243
|
-
) :
|
|
244
|
-
`[velojs] "isRoot" has no effect on endpoint at "${
|
|
245
|
-
),
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
`[velojs] path "${
|
|
270
|
+
], l = !!n.handler, c = !!n.method;
|
|
271
|
+
if (l && !c ? console.warn(
|
|
272
|
+
`[velojs] invalid route at "${r || "/"}" — "handler" set without "method"; endpoint skipped`
|
|
273
|
+
) : c && !l ? console.warn(
|
|
274
|
+
`[velojs] invalid route at "${r || "/"}" — "method" set without "handler"; endpoint skipped`
|
|
275
|
+
) : l && n.module ? console.warn(
|
|
276
|
+
`[velojs] ambiguous route at "${r || "/"}" — both "module" and "handler" set; endpoint ignored, page kept`
|
|
277
|
+
) : l && n.isRoot && console.warn(
|
|
278
|
+
`[velojs] "isRoot" has no effect on endpoint at "${r || "/"}"; ignored`
|
|
279
|
+
), l && c && !n.module) {
|
|
280
|
+
const u = n.method;
|
|
281
|
+
u === "GET" && i.has(r) && console.warn(
|
|
282
|
+
`[velojs] path "${r}" has both a page GET and an endpoint GET; the page wins and the endpoint is unreachable. Consider renaming one.`
|
|
249
283
|
);
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
284
|
+
const d = n.handler, f = async (m) => {
|
|
285
|
+
const v = P("endpoint", { route: r, method: u });
|
|
286
|
+
try {
|
|
287
|
+
const p = await d({
|
|
288
|
+
c: m,
|
|
289
|
+
params: m.req.param(),
|
|
290
|
+
query: m.req.query()
|
|
291
|
+
});
|
|
292
|
+
return v.end({
|
|
293
|
+
status: "ok",
|
|
294
|
+
bytes: v.enabled && p instanceof Response ? await R(p) : void 0
|
|
295
|
+
}), p;
|
|
296
|
+
} catch (p) {
|
|
297
|
+
throw v.end({ status: "error" }), p;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
a.length > 0 ? e.on([u], [r], ...a, f) : e.on([u], [r], f);
|
|
256
301
|
}
|
|
257
|
-
n.children &&
|
|
302
|
+
n.children && A(
|
|
258
303
|
e,
|
|
259
304
|
n.children,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
305
|
+
i,
|
|
306
|
+
r,
|
|
307
|
+
a
|
|
263
308
|
);
|
|
264
309
|
}
|
|
265
|
-
},
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
310
|
+
}, oe = async (e) => {
|
|
311
|
+
if (process.env.NODE_ENV !== "production" || process.env.VELO_STATIC || (process.env.STATIC_BASE_URL || "").startsWith("http")) return;
|
|
312
|
+
const { serveStatic: i } = await import("@hono/node-server/serve-static"), { join: s } = await import("node:path");
|
|
313
|
+
e.use("/*", i({ root: s(process.cwd(), "dist/client") }));
|
|
314
|
+
}, ne = async (e) => {
|
|
315
|
+
const t = new I();
|
|
316
|
+
await U(), t.use(H()), process.env.NODE_ENV !== "production" && t.use("*", O()), await oe(t);
|
|
317
|
+
const s = _().pendingRoutes.splice(0);
|
|
318
|
+
for (const n of s)
|
|
270
319
|
await n(t);
|
|
271
|
-
|
|
272
|
-
const o =
|
|
273
|
-
if (
|
|
320
|
+
S(t, e), T(t, e), await Z(t, e), q(t, e), process.env.NODE_ENV !== "production" && t.get("/_channel-inspect", (n) => n.json(W()));
|
|
321
|
+
const o = te(e);
|
|
322
|
+
if (A(t, e, o), await M(t, e), L(t), process.env.NODE_ENV !== "production" && !w) {
|
|
274
323
|
const n = globalThis.__veloDevServer;
|
|
275
|
-
n && (
|
|
324
|
+
n && (k(n), await E(t, n));
|
|
276
325
|
}
|
|
277
326
|
return t;
|
|
278
|
-
},
|
|
279
|
-
const { routes: t } = e,
|
|
327
|
+
}, ye = async (e) => {
|
|
328
|
+
const { routes: t } = e, i = Number(process.env.PORT) || e.port || 3e3, s = process.env.HOST || e.hostname || void 0, o = await ne(t);
|
|
280
329
|
if (process.env.NODE_ENV === "production" && !process.env.VELO_STATIC) {
|
|
281
|
-
const { serve: n } = await import("@hono/node-server"), {
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const h = d.address === "::" || d.address === "0.0.0.0" ? "0.0.0.0 (all interfaces)" : d.address;
|
|
288
|
-
console.log(`Server running on ${h}:${d.port}`);
|
|
330
|
+
const { serve: n } = await import("@hono/node-server"), r = n({ fetch: o.fetch, port: i, ...s ? { hostname: s } : {} });
|
|
331
|
+
r.listening || await new Promise((l) => r.once("listening", l));
|
|
332
|
+
const a = r.address();
|
|
333
|
+
if (a && typeof a == "object") {
|
|
334
|
+
const c = a.address === "::" || a.address === "0.0.0.0" ? "0.0.0.0 (all interfaces)" : a.address;
|
|
335
|
+
console.log(`Server running on ${c}:${a.port}`);
|
|
289
336
|
} else
|
|
290
|
-
console.log(`Server running on port ${
|
|
291
|
-
await
|
|
292
|
-
|
|
337
|
+
console.log(`Server running on port ${i}`);
|
|
338
|
+
await E(o, r), k(r), r.once("close", () => {
|
|
339
|
+
J(r);
|
|
293
340
|
});
|
|
294
341
|
}
|
|
295
342
|
return o;
|
|
296
343
|
};
|
|
297
344
|
export {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
345
|
+
we as addRoutes,
|
|
346
|
+
J as clearActiveServer,
|
|
347
|
+
ne as createApp,
|
|
348
|
+
ne as default,
|
|
349
|
+
Se as emit,
|
|
350
|
+
k as flushServerCallbacks,
|
|
351
|
+
W as inspectChannels,
|
|
352
|
+
z as jsonForScript,
|
|
353
|
+
ve as onServer,
|
|
354
|
+
Pe as registerChannels,
|
|
355
|
+
j as serverDataStorage,
|
|
356
|
+
ye as startServer
|
|
310
357
|
};
|
package/dist/sockets.d.ts
CHANGED
|
@@ -89,7 +89,10 @@ export declare function trackSocketSession(app: Hono, ctrl: AbortController): ()
|
|
|
89
89
|
export declare function abortAllSocketSessions(app: Hono): void;
|
|
90
90
|
/** @internal Returns registered sockets for `app` (used by the testing toolkit). */
|
|
91
91
|
export declare function getAppSockets(app: Hono): ReadonlyMap<string, RegisteredSocket>;
|
|
92
|
-
export declare function registerSocketHandler(app: Hono, path: string, handler: SocketHandler, middlewares?: MiddlewareHandler[]
|
|
92
|
+
export declare function registerSocketHandler(app: Hono, path: string, handler: SocketHandler, middlewares?: MiddlewareHandler[], info?: {
|
|
93
|
+
moduleId?: string | undefined;
|
|
94
|
+
name?: string | undefined;
|
|
95
|
+
}): Promise<void>;
|
|
93
96
|
/** Walks the route tree and registers every `socket_*` export. */
|
|
94
97
|
export declare function registerSocketRoutes(app: Hono, nodes: RouteNode[], parentMiddlewares?: MiddlewareHandler[]): Promise<void>;
|
|
95
98
|
/**
|