@mauroandre/velojs 0.0.23 → 0.0.25

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.
Files changed (3) hide show
  1. package/dist/events.js +110 -108
  2. package/dist/server.js +136 -137
  3. package/package.json +1 -1
package/dist/events.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { getAppContext as A } from "./app-context.js";
2
- const M = 2e4, R = 300 * 1e3, v = "";
2
+ const M = 2e4, R = 300 * 1e3, m = "";
3
3
  function x(t) {
4
- const o = A().pendingStreamRoutes.splice(0);
5
- for (const c of o) c(t);
4
+ const n = A().pendingStreamRoutes.splice(0);
5
+ for (const l of n) l(t);
6
6
  }
7
7
  const I = /* @__PURE__ */ new Set();
8
8
  function y() {
@@ -15,116 +15,116 @@ function L(t = {}) {
15
15
  throw new Error(
16
16
  "[velojs] createEventStream: `source` and `perChannelSource` are mutually exclusive. Use `source` for stream-wide producers or `perChannelSource` for per-channel resources, not both."
17
17
  );
18
- const a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Map();
19
- let l = null, w = 0;
18
+ const a = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
19
+ let c = null, w = 0;
20
20
  const i = /* @__PURE__ */ new Map(), b = () => {
21
- t.source && (l || (l = new AbortController(), Promise.resolve(
22
- t.source(p, { abortSignal: l.signal })
21
+ t.source && (c || (c = new AbortController(), Promise.resolve(
22
+ t.source(_, { abortSignal: c.signal })
23
23
  ).catch((e) => {
24
24
  console.error("[velojs] event stream source threw:", e);
25
25
  })));
26
- }, m = () => {
27
- w > 0 || l && (l.abort(), l = null);
28
- }, u = (e) => {
26
+ }, g = () => {
27
+ w > 0 || c && (c.abort(), c = null);
28
+ }, d = (e) => {
29
29
  if (!t.perChannelSource || i.has(e)) return;
30
- const n = new AbortController();
31
- i.set(e, n);
32
- const s = (r, S) => {
33
- h.emit(e, r, S);
30
+ const r = new AbortController();
31
+ i.set(e, r);
32
+ const o = (s, f) => {
33
+ p.emit(e, s, f);
34
34
  };
35
35
  Promise.resolve(
36
- t.perChannelSource(e, s, { abortSignal: n.signal })
37
- ).catch((r) => {
36
+ t.perChannelSource(e, o, { abortSignal: r.signal })
37
+ ).catch((s) => {
38
38
  console.error(
39
39
  `[velojs] perChannelSource threw for channel "${e}":`,
40
- r
40
+ s
41
41
  );
42
42
  });
43
- }, d = (e) => {
44
- const n = i.get(e);
45
- n && (n.abort(), i.delete(e));
43
+ }, S = (e) => {
44
+ const r = i.get(e);
45
+ r && (r.abort(), i.delete(e));
46
46
  };
47
- function p(e, n, s) {
48
- let r, S, E;
49
- if (!!t.broadcast ? (r = v, S = e, E = n) : (r = e, S = n, E = s), c.has(r)) {
47
+ function _(e, r, o) {
48
+ let s, f, u;
49
+ if (!!t.broadcast ? (s = m, f = e, u = r) : (s = e, f = r, u = o), l.has(s)) {
50
50
  console.warn(
51
- `[velojs] emit() called on closed channel "${r}" — ignored. Reopen the channel by emitting to a fresh ID, or remove the close() call.`
51
+ `[velojs] emit() called on closed channel "${s}" — ignored. Reopen the channel by emitting to a fresh ID, or remove the close() call.`
52
52
  );
53
53
  return;
54
54
  }
55
- if (E?.snapshot) {
56
- const _ = o.get(r) ?? [];
57
- _.push(S);
55
+ if (u?.snapshot) {
56
+ const v = n.get(s) ?? [];
57
+ v.push(f);
58
58
  const T = t.bufferSize ?? 1 / 0;
59
- _.length > T && _.splice(0, _.length - T), o.set(r, _);
59
+ v.length > T && v.splice(0, v.length - T), n.set(s, v);
60
60
  }
61
- const C = a.get(r);
62
- if (C)
63
- for (const _ of C) _(S);
61
+ const E = a.get(s);
62
+ if (E)
63
+ for (const v of E) v(f);
64
64
  }
65
- function g(e = v) {
66
- if (c.has(e)) return;
67
- c.add(e);
68
- const n = a.get(e);
69
- if (n)
70
- for (const S of n) S.close();
71
- const s = t.retainMs ?? R, r = f.get(e);
72
- r && clearTimeout(r), f.set(
65
+ function C(e = m) {
66
+ if (l.has(e)) return;
67
+ l.add(e);
68
+ const r = a.get(e);
69
+ if (r)
70
+ for (const f of r) f.close();
71
+ const o = t.retainMs ?? R, s = h.get(e);
72
+ s && clearTimeout(s), h.set(
73
73
  e,
74
74
  setTimeout(() => {
75
- o.delete(e), f.delete(e), c.delete(e);
76
- }, s)
75
+ n.delete(e), h.delete(e), l.delete(e);
76
+ }, o)
77
77
  );
78
78
  }
79
- const h = {
80
- emit: p,
81
- close: g,
79
+ const p = {
80
+ emit: _,
81
+ close: C,
82
82
  __isVeloEventStream: !0,
83
83
  __config: t,
84
84
  __listeners: a,
85
- __buffers: o,
85
+ __buffers: n,
86
86
  __path: t.path,
87
- __onConnect(e, n) {
88
- let s = a.get(e);
89
- const r = !s || s.size === 0;
90
- s || (s = /* @__PURE__ */ new Set(), a.set(e, s)), s.add(n), w++, b(), r && u(e);
87
+ __onConnect(e, r) {
88
+ let o = a.get(e);
89
+ const s = !o || o.size === 0;
90
+ o || (o = /* @__PURE__ */ new Set(), a.set(e, o)), o.add(r), w++, b(), s && d(e);
91
91
  },
92
- __onDisconnect(e, n) {
93
- const s = a.get(e);
94
- s && (s.delete(n), s.size === 0 && (a.delete(e), d(e)), w--, m());
92
+ __onDisconnect(e, r) {
93
+ const o = a.get(e);
94
+ o && (o.delete(r), o.size === 0 && (a.delete(e), S(e)), w--, g());
95
95
  },
96
96
  __reset() {
97
97
  for (const e of a.values())
98
- for (const n of e)
98
+ for (const r of e)
99
99
  try {
100
- n.close();
100
+ r.close();
101
101
  } catch {
102
102
  }
103
- a.clear(), o.clear(), c.clear();
104
- for (const e of f.values()) clearTimeout(e);
105
- f.clear(), l && (l.abort(), l = null);
103
+ a.clear(), n.clear(), l.clear();
104
+ for (const e of h.values()) clearTimeout(e);
105
+ h.clear(), c && (c.abort(), c = null);
106
106
  for (const e of i.values()) e.abort();
107
107
  i.clear(), w = 0;
108
108
  }
109
109
  };
110
110
  return t.path && A().pendingStreamRoutes.push((e) => {
111
- D(e, t.path, h, t.middlewares ?? []);
112
- }), I.add(h), h;
111
+ P(e, t.path, p, t.middlewares ?? []);
112
+ }), I.add(p), p;
113
113
  }
114
114
  function B(t) {
115
- return async (a, { abortSignal: o }) => {
116
- for (; !o.aborted; ) {
115
+ return async (a, { abortSignal: n }) => {
116
+ for (; !n.aborted; ) {
117
117
  try {
118
118
  await t.tick(a);
119
- } catch (c) {
120
- console.error("[velojs] poll tick threw:", c);
119
+ } catch (l) {
120
+ console.error("[velojs] poll tick threw:", l);
121
121
  }
122
- await new Promise((c) => {
123
- const f = setTimeout(c, t.intervalMs);
124
- o.addEventListener(
122
+ await new Promise((l) => {
123
+ const h = setTimeout(l, t.intervalMs);
124
+ n.addEventListener(
125
125
  "abort",
126
126
  () => {
127
- clearTimeout(f), c();
127
+ clearTimeout(h), l();
128
128
  },
129
129
  { once: !0 }
130
130
  );
@@ -133,67 +133,69 @@ function B(t) {
133
133
  };
134
134
  }
135
135
  function j(t) {
136
- return t.req.query("channel") ?? v;
136
+ return t.req.query("channel") ?? m;
137
137
  }
138
- function D(t, a, o, c = []) {
139
- const f = async (l) => {
138
+ function P(t, a, n, l = []) {
139
+ const h = async (c) => {
140
140
  const { streamSSE: w } = await import("hono/streaming");
141
141
  let i;
142
- if (o.__config.broadcast)
143
- i = v;
142
+ if (n.__config.broadcast)
143
+ i = m;
144
144
  else {
145
- const u = o.__config.channel ?? j;
146
- let d;
145
+ const d = n.__config.channel ?? j;
146
+ let S;
147
147
  try {
148
- d = await u(l);
149
- } catch (p) {
150
- return console.error("[velojs] channel resolver threw:", p), l.json({ error: "internal" }, 500);
148
+ S = await d(c);
149
+ } catch (_) {
150
+ return console.error("[velojs] channel resolver threw:", _), c.json({ error: "internal" }, 500);
151
151
  }
152
- if (d == null)
153
- return l.json({ error: "forbidden" }, 403);
154
- i = d;
152
+ if (S == null)
153
+ return c.json({ error: "forbidden" }, 403);
154
+ i = S;
155
155
  }
156
- const b = o.__config.heartbeatMs, m = b === !1 ? 0 : b ?? M;
157
- return w(l, async (u) => {
158
- const d = o.__buffers.get(i);
159
- if (d && d.length > 0 && await u.writeSSE({
156
+ const b = n.__config.heartbeatMs, g = b === !1 ? 0 : b ?? M;
157
+ return w(c, async (d) => {
158
+ const S = n.__buffers.get(i);
159
+ if (S && S.length > 0 && await d.writeSSE({
160
160
  event: "snapshot",
161
- data: JSON.stringify(d)
162
- }), o.__config.snapshot) {
163
- const r = await o.__config.snapshot(
164
- i === v ? void 0 : i
161
+ data: JSON.stringify(S)
162
+ }), n.__config.snapshot) {
163
+ const u = await n.__config.snapshot(
164
+ i === m ? void 0 : i
165
165
  );
166
- r !== void 0 && await u.writeSSE({
166
+ u !== void 0 && await d.writeSSE({
167
167
  event: "snapshot",
168
- data: JSON.stringify(r)
168
+ data: JSON.stringify(u)
169
169
  });
170
170
  }
171
- let p;
172
- const g = new Promise((r) => {
173
- p = r;
171
+ let _;
172
+ const C = new Promise((u) => {
173
+ _ = u;
174
174
  });
175
- let h = !1, e = null;
176
- const n = () => {
177
- h || (h = !0, e && clearInterval(e), o.__onDisconnect(i, s), p());
178
- }, s = ((r) => {
179
- h || (u.writeSSE({ data: JSON.stringify(r) }).catch(() => {
180
- }), o.__config.closeOn?.(r) && (u.close(), n()));
175
+ let p = !1, e = null, r = Promise.resolve();
176
+ const o = (u) => (r = r.then(() => d.writeSSE(u)).catch(() => {
177
+ }), r), s = () => {
178
+ p || (p = !0, e && clearInterval(e), n.__onDisconnect(i, f), _());
179
+ }, f = ((u) => {
180
+ p || (o({ data: JSON.stringify(u) }), n.__config.closeOn?.(u) && r.then(() => {
181
+ d.close(), s();
182
+ }));
181
183
  });
182
- s.close = () => {
183
- h || (u.writeSSE({ event: "close", data: "" }).catch(() => {
184
- }), u.close(), n());
185
- }, o.__onConnect(i, s), e = m > 0 ? setInterval(() => {
186
- h || u.writeSSE({ event: "heartbeat", data: "" }).catch(() => {
187
- });
188
- }, m) : null, u.onAbort(n), await g;
184
+ f.close = () => {
185
+ p || (o({ event: "close", data: "" }), r.then(() => {
186
+ d.close(), s();
187
+ }));
188
+ }, n.__onConnect(i, f), e = g > 0 ? setInterval(() => {
189
+ p || o({ event: "heartbeat", data: "" });
190
+ }, g) : null, d.onAbort(s), await C;
189
191
  });
190
192
  };
191
- c.length > 0 ? t.on(["GET"], [a], ...c, f) : t.on(["GET"], [a], f);
193
+ l.length > 0 ? t.on(["GET"], [a], ...l, h) : t.on(["GET"], [a], h);
192
194
  }
193
195
  export {
194
196
  L as createEventStream,
195
197
  x as flushPendingStreamRoutes,
196
198
  y as getRegisteredStreams,
197
199
  B as poll,
198
- D as registerStreamHandler
200
+ P as registerStreamHandler
199
201
  };
package/dist/server.js CHANGED
@@ -1,201 +1,200 @@
1
- import { jsx as _ } from "preact/jsx-runtime";
1
+ import { jsx as p } from "preact/jsx-runtime";
2
2
  import { Hono as b } from "hono";
3
3
  import { logger as q } from "hono/logger";
4
4
  import { trimTrailingSlash as T } from "hono/trailing-slash";
5
5
  import { render as A } from "preact-render-to-string";
6
6
  import { Router as R } from "wouter-preact";
7
7
  import { AsyncLocalStorage as C } from "node:async_hooks";
8
- import { getAppContext as v } from "./app-context.js";
9
- const y = new C();
10
- globalThis.__veloServerData = y;
11
- let g = null;
12
- function G(t) {
13
- if (g) {
14
- t(g);
8
+ import { getAppContext as g } from "./app-context.js";
9
+ import { flushPendingStreamRoutes as D, registerStreamHandler as I } from "./events.js";
10
+ const v = new C();
11
+ globalThis.__veloServerData = v;
12
+ let _ = null;
13
+ function W(e) {
14
+ if (_) {
15
+ e(_);
15
16
  return;
16
17
  }
17
- v().serverCallbacks.push(t);
18
+ g().serverCallbacks.push(e);
18
19
  }
19
- function w(t) {
20
- g = t;
21
- const e = v();
22
- for (const n of e.serverCallbacks) n(t);
23
- e.serverCallbacks.length = 0;
20
+ function y(e) {
21
+ _ = e;
22
+ const t = g();
23
+ for (const s of t.serverCallbacks) s(e);
24
+ t.serverCallbacks.length = 0;
24
25
  }
25
- function L(t) {
26
- v().pendingRoutes.push(t);
26
+ function J(e) {
27
+ g().pendingRoutes.push(e);
27
28
  }
28
- const D = (t, e, n) => {
29
- if (t.req.query("_data") === "1") {
30
- const c = globalThis.__veloBuildHash || void 0, o = n ? { ...n, __buildHash: c } : { __buildHash: c };
31
- return t.json(o);
29
+ const N = (e, t, s) => {
30
+ if (e.req.query("_data") === "1") {
31
+ const a = globalThis.__veloBuildHash || void 0, r = s ? { ...s, __buildHash: a } : { __buildHash: a };
32
+ return e.json(r);
32
33
  }
33
- const s = t.req.path, r = y.run(
34
- n ?? {},
35
- () => A(/* @__PURE__ */ _(R, { ssrPath: s, children: e }))
34
+ const n = e.req.path, o = v.run(
35
+ s ?? {},
36
+ () => A(/* @__PURE__ */ p(R, { ssrPath: n, children: t }))
36
37
  );
37
- if (t.header("Cache-Control", "no-cache"), !n)
38
- return t.html(r);
39
- const a = `<script>window.__PAGE_DATA__=${JSON.stringify(
40
- n
38
+ if (e.header("Cache-Control", "no-cache"), !s)
39
+ return e.html(o);
40
+ const c = `<script>window.__PAGE_DATA__=${JSON.stringify(
41
+ s
41
42
  )}<\/script>`;
42
- return t.html(r.replace("</head>", `${a}</head>`));
43
- }, I = async (t, e) => {
44
- const n = e.req.param(), s = e.req.query(), r = { params: n, query: s, c: e }, a = await Promise.all(
45
- t.map(async (o) => {
46
- if (!o.loader) return null;
47
- const l = await o.loader(r), i = o.metadata?.moduleId;
48
- return i ? { moduleId: i, loaderData: l } : null;
43
+ return e.html(o.replace("</head>", `${c}</head>`));
44
+ }, O = async (e, t) => {
45
+ const s = t.req.param(), n = t.req.query(), o = { params: s, query: n, c: t }, c = await Promise.all(
46
+ e.map(async (r) => {
47
+ if (!r.loader) return null;
48
+ const d = await r.loader(o), i = r.metadata?.moduleId;
49
+ return i ? { moduleId: i, loaderData: d } : null;
49
50
  })
50
- ), c = {
51
- __params: n,
52
- __query: s,
53
- __pathname: e.req.path
51
+ ), a = {
52
+ __params: s,
53
+ __query: n,
54
+ __pathname: t.req.path
54
55
  };
55
- for (const o of a)
56
- o && (c[o.moduleId] = o.loaderData);
56
+ for (const r of c)
57
+ r && (a[r.moduleId] = r.loaderData);
57
58
  return {
58
- components: t.map((o) => o.Component),
59
- data: c
59
+ components: e.map((r) => r.Component),
60
+ data: a
60
61
  };
61
- }, N = (t) => {
62
- if (t.length === 0) return null;
63
- const e = t.filter(Boolean);
62
+ }, j = (e) => {
64
63
  if (e.length === 0) return null;
65
- if (e.length === 1) {
66
- const r = e[0];
67
- return /* @__PURE__ */ _(r, {});
64
+ const t = e.filter(Boolean);
65
+ if (t.length === 0) return null;
66
+ if (t.length === 1) {
67
+ const o = t[0];
68
+ return /* @__PURE__ */ p(o, {});
68
69
  }
69
- const n = e[e.length - 1];
70
- return e.slice(0, -1).reduceRight((r, a) => /* @__PURE__ */ _(a, { children: r }), /* @__PURE__ */ _(n, {}));
71
- }, S = (t, e, n = [], s = []) => {
72
- for (const r of e) {
73
- const a = [...n, r.module], c = [
74
- ...s,
75
- ...r.middlewares || []
70
+ const s = t[t.length - 1];
71
+ return t.slice(0, -1).reduceRight((o, c) => /* @__PURE__ */ p(c, { children: o }), /* @__PURE__ */ p(s, {}));
72
+ }, w = (e, t, s = [], n = []) => {
73
+ for (const o of t) {
74
+ const c = [...s, o.module], a = [
75
+ ...n,
76
+ ...o.middlewares || []
76
77
  ];
77
- if (r.children)
78
- S(
79
- t,
80
- r.children,
81
- a,
82
- c
78
+ if (o.children)
79
+ w(
80
+ e,
81
+ o.children,
82
+ c,
83
+ a
83
84
  );
84
85
  else {
85
- const o = r.module.metadata?.fullPath;
86
- if (!o) {
86
+ const r = o.module.metadata?.fullPath;
87
+ if (!r) {
87
88
  console.warn(
88
- `Module ${r.module.metadata?.moduleId} has no fullPath`
89
+ `Module ${o.module.metadata?.moduleId} has no fullPath`
89
90
  );
90
91
  continue;
91
92
  }
92
- const l = async (i) => {
93
- const { components: m, data: u } = await I(a, i), d = N(m);
94
- return D(i, d, u);
93
+ const d = async (i) => {
94
+ const { components: u, data: m } = await O(c, i), l = j(u);
95
+ return N(i, l, m);
95
96
  };
96
- c.length > 0 ? t.on(["GET"], [o], ...c, l) : t.on(["GET"], [o], l);
97
+ a.length > 0 ? e.on(["GET"], [r], ...a, d) : e.on(["GET"], [r], d);
97
98
  }
98
99
  }
99
- }, P = (t, e, n = []) => {
100
- for (const s of e) {
101
- const r = s.module.metadata?.moduleId, a = [
102
- ...n,
103
- ...s.middlewares || []
100
+ }, S = (e, t, s = []) => {
101
+ for (const n of t) {
102
+ const o = n.module.metadata?.moduleId, c = [
103
+ ...s,
104
+ ...n.middlewares || []
104
105
  ];
105
- if (r) {
106
- const c = Object.keys(s.module).filter(
107
- (o) => o.startsWith("action_")
106
+ if (o) {
107
+ const a = Object.keys(n.module).filter(
108
+ (r) => r.startsWith("action_")
108
109
  );
109
- for (const o of c) {
110
- const l = o.replace("action_", ""), i = s.module[o];
110
+ for (const r of a) {
111
+ const d = r.replace("action_", ""), i = n.module[r];
111
112
  if (typeof i == "function") {
112
- const m = `/_action/${r}/${l}`, u = async (d) => {
113
+ const u = `/_action/${o}/${d}`, m = async (l) => {
113
114
  let f = {};
114
115
  try {
115
- f = await d.req.json();
116
+ f = await l.req.json();
116
117
  } catch {
117
118
  }
118
- const h = {
119
+ const P = {
119
120
  body: f,
120
- params: d.req.param(),
121
- query: d.req.query(),
122
- c: d
121
+ params: l.req.param(),
122
+ query: l.req.query(),
123
+ c: l
123
124
  };
124
125
  try {
125
- const p = await i(h);
126
- return d.json(p ?? { ok: !0 });
127
- } catch (p) {
128
- const E = p instanceof Error ? p.message : "Action failed";
129
- return d.json({ error: E }, 500);
126
+ const h = await i(P);
127
+ return l.json(h ?? { ok: !0 });
128
+ } catch (h) {
129
+ const E = h instanceof Error ? h.message : "Action failed";
130
+ return l.json({ error: E }, 500);
130
131
  }
131
132
  };
132
- a.length > 0 ? t.on(
133
+ c.length > 0 ? e.on(
133
134
  ["POST"],
134
- [m],
135
- ...a,
136
- u
137
- ) : t.on(["POST"], [m], u);
135
+ [u],
136
+ ...c,
137
+ m
138
+ ) : e.on(["POST"], [u], m);
138
139
  }
139
140
  }
140
141
  }
141
- s.children && P(t, s.children, a);
142
+ n.children && S(e, n.children, c);
142
143
  }
143
- }, O = async (t, e, n = []) => {
144
- const { registerStreamHandler: s } = await import("./events.js"), r = (a, c) => {
145
- for (const o of a) {
146
- const l = o.module.metadata?.moduleId, i = [
144
+ }, $ = async (e, t, s = []) => {
145
+ const n = (o, c) => {
146
+ for (const a of o) {
147
+ const r = a.module.metadata?.moduleId, d = [
147
148
  ...c,
148
- ...o.middlewares || []
149
+ ...a.middlewares || []
149
150
  ];
150
- if (l) {
151
- const m = Object.keys(o.module).filter(
151
+ if (r) {
152
+ const i = Object.keys(a.module).filter(
152
153
  (u) => u.startsWith("stream_")
153
154
  );
154
- for (const u of m) {
155
- const d = u.replace("stream_", ""), f = o.module[u];
156
- if (f?.__isVeloEventStream) {
157
- const h = `/_event/${l}/${d}`;
158
- f.__path = h, s(
159
- t,
160
- h,
155
+ for (const u of i) {
156
+ const m = u.replace("stream_", ""), l = a.module[u];
157
+ if (l?.__isVeloEventStream) {
158
+ const f = `/_event/${r}/${m}`;
159
+ l.__path = f, I(
160
+ e,
161
161
  f,
162
- i
162
+ l,
163
+ d
163
164
  );
164
165
  }
165
166
  }
166
167
  }
167
- o.children && r(o.children, i);
168
+ a.children && n(a.children, d);
168
169
  }
169
170
  };
170
- r(e, n);
171
- }, j = async (t) => {
172
- const e = new b();
173
- e.use(T()), process.env.NODE_ENV !== "production" && e.use("*", q());
174
- const s = v().pendingRoutes.splice(0);
175
- for (const a of s)
176
- await a(e);
177
- S(e, t), P(e, t), await O(e, t);
178
- const { flushPendingStreamRoutes: r } = await import("./events.js");
179
- if (r(e), process.env.NODE_ENV !== "production" && !g) {
180
- const a = globalThis.__veloDevServer;
181
- a && w(a);
171
+ n(t, s);
172
+ }, k = async (e) => {
173
+ const t = new b();
174
+ t.use(T()), process.env.NODE_ENV !== "production" && t.use("*", q());
175
+ const n = g().pendingRoutes.splice(0);
176
+ for (const o of n)
177
+ await o(t);
178
+ if (w(t, e), S(t, e), await $(t, e), D(t), process.env.NODE_ENV !== "production" && !_) {
179
+ const o = globalThis.__veloDevServer;
180
+ o && y(o);
182
181
  }
183
- return e;
184
- }, U = async (t) => {
185
- const { routes: e, port: n = Number(process.env.SERVER_PORT) || 3e3 } = t, s = await j(e);
182
+ return t;
183
+ }, z = async (e) => {
184
+ const { routes: t, port: s = Number(process.env.SERVER_PORT) || 3e3 } = e, n = await k(t);
186
185
  if (process.env.NODE_ENV === "production" && !process.env.VELO_STATIC) {
187
- const { serve: r } = await import("@hono/node-server"), { serveStatic: a } = await import("@hono/node-server/serve-static"), { join: c } = await import("node:path"), o = c(process.cwd(), "dist/client");
188
- (process.env.STATIC_BASE_URL || "").startsWith("http") || s.use("/*", a({ root: o })), console.log(`Server running on http://localhost:${n}`);
189
- const i = r({ fetch: s.fetch, port: n });
190
- w(i);
186
+ const { serve: o } = await import("@hono/node-server"), { serveStatic: c } = await import("@hono/node-server/serve-static"), { join: a } = await import("node:path"), r = a(process.cwd(), "dist/client");
187
+ (process.env.STATIC_BASE_URL || "").startsWith("http") || n.use("/*", c({ root: r })), console.log(`Server running on http://localhost:${s}`);
188
+ const i = o({ fetch: n.fetch, port: s });
189
+ y(i);
191
190
  }
192
- return s;
191
+ return n;
193
192
  };
194
193
  export {
195
- L as addRoutes,
196
- j as createApp,
197
- j as default,
198
- G as onServer,
199
- y as serverDataStorage,
200
- U as startServer
194
+ J as addRoutes,
195
+ k as createApp,
196
+ k as default,
197
+ W as onServer,
198
+ v as serverDataStorage,
199
+ z as startServer
201
200
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
6
6
  "keywords": [