@mauroandre/velojs 0.0.46 → 0.0.48

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.
@@ -106,6 +106,23 @@ refetch(); // e.g. aggregate counters
106
106
 
107
107
  > **Never mirror loader data into a module-level `export let`.** On the server, a module binding is per-process, not per-request — a value stored there belongs to whichever request wrote it last. `Loader`'s server value is an AsyncLocalStorage getter, so it is per-request by construction. That's the whole reason the handle is safe to export.
108
108
 
109
+ ## Redirecting from a loader
110
+
111
+ A loader may return a `Response` to short-circuit rendering — the common case is an auth gate that redirects instead of rendering the page:
112
+
113
+ ```typescript
114
+ export const loader = async ({ c }: LoaderArgs) => {
115
+ const user = c.get("user");
116
+ if (!user) return c.redirect("/login"); // no page render, no __PAGE_DATA__
117
+ return { projects: await listProjects(user) };
118
+ };
119
+ ```
120
+
121
+ - **Direct load / refresh:** the browser receives the `302` and navigates normally.
122
+ - **SPA navigation:** the `?_data=1` endpoint answers `{ __redirect: "/login" }` and the client does a full navigation (server state — session, cookies — may have changed, so it is not an SPA transition).
123
+
124
+ Any `Response` short-circuits, not only redirects (a `404` JSON, for example). If several loaders return one, the first in route order (layout → leaf) wins.
125
+
109
126
  ## When to use which
110
127
 
111
128
  | Scenario | Use |
@@ -141,3 +141,20 @@ export const action_save = async ({ body, c }: ActionArgs<{ name: string }>) =>
141
141
  ```
142
142
 
143
143
  This is the recommended pattern for passing authentication data (current user, permissions, etc) from middleware to your page code.
144
+
145
+ ### Typing `c.get()` — ContextVariableMap
146
+
147
+ `c.get("user")` does not compile out of the box: Hono's `Context` only accepts keys declared in `ContextVariableMap`. Augment it once in your app (e.g. in `app/types.d.ts`) and every `c.get`/`c.set` becomes typed — no casts, no helper functions:
148
+
149
+ ```typescript
150
+ import type { Usuario } from "./modules/auth/auth.types.js";
151
+
152
+ declare module "hono" {
153
+ interface ContextVariableMap {
154
+ user: Usuario;
155
+ }
156
+ }
157
+ ```
158
+
159
+ After this, `c.get("user")` returns `Usuario` in middlewares, loaders, and actions, and `c.get("anythingElse")` fails at compile time.
160
+
@@ -1,16 +1,16 @@
1
- import { signal as d } from "@preact/signals";
2
- const S = d(!1), c = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Map();
3
- let u = /* @__PURE__ */ new Set();
4
- const l = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new WeakSet();
1
+ import { signal as u } from "@preact/signals";
2
+ const S = u(!1), c = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Map();
3
+ let d = /* @__PURE__ */ new Set();
4
+ const l = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new WeakSet();
5
5
  let w = !1;
6
6
  function E(t) {
7
7
  v();
8
8
  let e = c.get(t);
9
- return e || (e = d(null), c.set(t, e)), e;
9
+ return e || (e = u(null), c.set(t, e)), e;
10
10
  }
11
- function g(t) {
12
- let e = _.get(t);
13
- return e || (e = d(!1), _.set(t, e)), e;
11
+ function y(t) {
12
+ let e = h.get(t);
13
+ return e || (e = u(!1), h.set(t, e)), e;
14
14
  }
15
15
  function v() {
16
16
  if (w || typeof window > "u") return;
@@ -20,22 +20,22 @@ function v() {
20
20
  for (const e of Object.keys(t)) {
21
21
  if (e.startsWith("__")) continue;
22
22
  let n = c.get(e);
23
- n || (n = d(null), c.set(e, n)), n.value = t[e];
23
+ n || (n = u(null), c.set(e, n)), n.value = t[e];
24
24
  }
25
25
  }
26
26
  function x(t) {
27
- if (y.has(t)) return;
28
- y.add(t);
27
+ if (g.has(t)) return;
28
+ g.add(t);
29
29
  const e = (n) => {
30
30
  for (const o of n) {
31
31
  const i = o.module?.metadata;
32
- i?.moduleId && i.fullPath !== void 0 && (f.set(i.moduleId, i.fullPath), (!o.children || o.children.length === 0) && h.add(i.moduleId)), o.children && e(o.children);
32
+ i?.moduleId && i.fullPath !== void 0 && (f.set(i.moduleId, i.fullPath), (!o.children || o.children.length === 0) && _.add(i.moduleId)), o.children && e(o.children);
33
33
  }
34
34
  };
35
35
  if (e(t), typeof window < "u") {
36
36
  v();
37
37
  for (const n of c.keys()) M(n, window.location.pathname);
38
- u = L(window.location.pathname);
38
+ d = L(window.location.pathname);
39
39
  }
40
40
  }
41
41
  const P = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -51,7 +51,7 @@ function m(t, e, n = !1) {
51
51
  }
52
52
  function O(t, e) {
53
53
  const n = f.get(t);
54
- return n === void 0 ? !1 : m(n, e, h.has(t)) !== null;
54
+ return n === void 0 ? !1 : m(n, e, _.has(t)) !== null;
55
55
  }
56
56
  function L(t) {
57
57
  const e = /* @__PURE__ */ new Set();
@@ -62,7 +62,7 @@ function L(t) {
62
62
  function k(t, e) {
63
63
  const n = f.get(t);
64
64
  if (n === void 0) return null;
65
- const o = m(n, e, h.has(t));
65
+ const o = m(n, e, _.has(t));
66
66
  return o === null ? null : JSON.stringify(o);
67
67
  }
68
68
  function M(t, e) {
@@ -77,18 +77,22 @@ function H(t) {
77
77
  async function $(t, e, n) {
78
78
  if (typeof window > "u" || t.length === 0) return;
79
79
  const o = H(e);
80
- for (const a of t) g(a).value = !0;
80
+ for (const a of t) y(a).value = !0;
81
81
  let i = n ? l.get(o) : void 0;
82
82
  i || (i = fetch(o, { cache: "no-cache" }).then((a) => a.json()), n && (l.set(o, i), i.catch(() => {
83
83
  }).then(() => l.delete(o))));
84
84
  try {
85
85
  const a = await i;
86
+ if (a.__redirect) {
87
+ window.location.href = String(a.__redirect);
88
+ return;
89
+ }
86
90
  typeof __VELO_BUILD_HASH__ < "u" && a.__buildHash && a.__buildHash !== __VELO_BUILD_HASH__ && (S.value = !0);
87
91
  for (const r of t)
88
92
  r in a && (E(r).value = a[r], M(r, e));
89
93
  } catch {
90
94
  } finally {
91
- for (const a of t) g(a).value = !1;
95
+ for (const a of t) y(a).value = !1;
92
96
  }
93
97
  }
94
98
  function T(t) {
@@ -97,22 +101,22 @@ function T(t) {
97
101
  for (const o of c.keys()) {
98
102
  if (!n.has(o)) continue;
99
103
  const i = k(o, t);
100
- p.get(o) === i && u.has(o) || e.push(o);
104
+ p.get(o) === i && d.has(o) || e.push(o);
101
105
  }
102
- u = n, $(e, t, !0);
106
+ d = n, $(e, t, !0);
103
107
  }
104
108
  function U(t) {
105
109
  typeof window > "u" || $([t], window.location.pathname, !1);
106
110
  }
107
111
  function D() {
108
- c.clear(), _.clear(), f.clear(), h.clear(), p.clear(), u = /* @__PURE__ */ new Set(), l.clear(), w = !1, S.value = !1;
112
+ c.clear(), h.clear(), f.clear(), _.clear(), p.clear(), d = /* @__PURE__ */ new Set(), l.clear(), w = !1, S.value = !1;
109
113
  }
110
114
  export {
111
115
  D as __resetLoaderStore,
112
116
  S as __veloUpdatePending,
113
117
  m as extractParams,
114
118
  E as loaderEntry,
115
- g as loaderLoading,
119
+ y as loaderLoading,
116
120
  U as refetchModule,
117
121
  x as registerRoutePatterns,
118
122
  T as syncLocation
package/dist/server.d.ts CHANGED
@@ -9,6 +9,16 @@ export interface StartServerOptions {
9
9
  port?: number;
10
10
  }
11
11
  export declare function addRoutes(fn: (app: Hono) => void | Promise<void>): void;
12
+ /**
13
+ * Serializa dados para injeção num <script> inline. JSON não escapa `<`, então
14
+ * uma string com `</script>` nos dados fecharia a tag no meio — o resto do
15
+ * payload transborda pro documento como HTML e a hidratação quebra (observado
16
+ * em produção com conteúdo de modelo contendo pseudo-tags). `<` é escape
17
+ * JSON/JS válido e decodifica transparente no cliente. Também escapa `>`
18
+ * (defesa para `<!--`) e U+2028/U+2029 (válidos em JSON, quebras de linha em
19
+ * JS antigo).
20
+ */
21
+ export declare const jsonForScript: (value: unknown) => string;
12
22
  export declare const createApp: (routes: AppRoutes) => Promise<Hono>;
13
23
  export declare const startServer: (options: StartServerOptions) => Promise<Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">>;
14
24
  export default createApp;
package/dist/server.js CHANGED
@@ -1,79 +1,85 @@
1
- import { jsx as g } from "preact/jsx-runtime";
2
- import { Hono as R } from "hono";
3
- import { logger as T } from "hono/logger";
4
- import { trimTrailingSlash as j } from "hono/trailing-slash";
5
- import { render as A } from "preact-render-to-string";
6
- import { Router as C } from "wouter-preact";
7
- import { AsyncLocalStorage as k } from "node:async_hooks";
1
+ import { jsx as _ } from "preact/jsx-runtime";
2
+ import { Hono as j } from "hono";
3
+ import { logger as E } from "hono/logger";
4
+ import { trimTrailingSlash as T } from "hono/trailing-slash";
5
+ import { render as C } from "preact-render-to-string";
6
+ import { Router as k } from "wouter-preact";
7
+ import { AsyncLocalStorage as A } from "node:async_hooks";
8
8
  import { getAppContext as w } from "./app-context.js";
9
- import { flushPendingStreamRoutes as $, registerStreamHandler as D } from "./events.js";
10
- import { registerSocketRoutes as I, injectWebSocketServer as y } from "./sockets.js";
11
- const S = new k();
12
- globalThis.__veloServerData = S;
9
+ import { flushPendingStreamRoutes as D, registerStreamHandler as $ } from "./events.js";
10
+ import { registerSocketRoutes as I, injectWebSocketServer as S } from "./sockets.js";
11
+ const P = new A();
12
+ globalThis.__veloServerData = P;
13
13
  let v = null;
14
- function Y(e) {
14
+ function Z(e) {
15
15
  if (v) {
16
16
  e(v);
17
17
  return;
18
18
  }
19
19
  w().serverCallbacks.push(e);
20
20
  }
21
- function P(e) {
21
+ function b(e) {
22
22
  v = e;
23
23
  const t = w();
24
24
  for (const s of t.serverCallbacks) s(e);
25
25
  t.serverCallbacks.length = 0;
26
26
  }
27
- function Z(e) {
27
+ function ee(e) {
28
28
  w().pendingRoutes.push(e);
29
29
  }
30
- const N = (e, t, s, r) => {
30
+ const N = (e) => JSON.stringify(e).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), O = (e, t, s, r) => {
31
31
  if (r && r !== 200 && e.status(r), e.req.query("_data") === "1") {
32
- const i = globalThis.__veloBuildHash || void 0, l = s ? { ...s, __buildHash: i } : { __buildHash: i };
33
- return e.json(l);
32
+ const c = globalThis.__veloBuildHash || void 0, i = s ? { ...s, __buildHash: c } : { __buildHash: c };
33
+ return e.json(i);
34
34
  }
35
- const o = e.req.path, n = S.run(
35
+ const o = e.req.path, n = P.run(
36
36
  s ?? {},
37
- () => A(/* @__PURE__ */ g(C, { ssrPath: o, children: t }))
37
+ () => C(/* @__PURE__ */ _(k, { ssrPath: o, children: t }))
38
38
  );
39
39
  if (e.header("Cache-Control", "no-cache"), !s)
40
40
  return e.html(n);
41
- const a = `<script>window.__PAGE_DATA__=${JSON.stringify(
42
- s
43
- )}<\/script>`;
41
+ const a = `<script>window.__PAGE_DATA__=${N(s)}<\/script>`;
44
42
  return e.html(n.replace("</head>", `${a}</head>`));
45
- }, O = async (e, t) => {
43
+ }, G = async (e, t) => {
46
44
  const s = t.req.param(), r = t.req.query(), o = { params: s, query: r, c: t }, n = await Promise.all(
47
45
  e.map(async (i) => {
48
46
  if (!i.loader) return null;
49
- const l = await i.loader(o), c = i.metadata?.moduleId;
50
- return c ? { moduleId: c, loaderData: l } : null;
47
+ const l = await i.loader(o), d = i.metadata?.moduleId;
48
+ return d ? { moduleId: d, loaderData: l } : null;
51
49
  })
52
- ), a = {
50
+ );
51
+ let a;
52
+ for (const i of n)
53
+ if (i && i.loaderData instanceof Response) {
54
+ a = i.loaderData;
55
+ break;
56
+ }
57
+ const c = {
53
58
  __params: s,
54
59
  __query: r,
55
60
  __pathname: t.req.path
56
61
  };
57
62
  for (const i of n)
58
- i && (a[i.moduleId] = i.loaderData);
63
+ i && !(i.loaderData instanceof Response) && (c[i.moduleId] = i.loaderData);
59
64
  return {
60
65
  components: e.map((i) => i.Component),
61
- data: a
66
+ data: c,
67
+ shortCircuit: a
62
68
  };
63
- }, G = (e) => {
69
+ }, H = (e) => {
64
70
  if (e.length === 0) return null;
65
71
  const t = e.filter(Boolean);
66
72
  if (t.length === 0) return null;
67
73
  if (t.length === 1) {
68
74
  const o = t[0];
69
- return /* @__PURE__ */ g(o, {});
75
+ return /* @__PURE__ */ _(o, {});
70
76
  }
71
77
  const s = t[t.length - 1];
72
- return t.slice(0, -1).reduceRight((o, n) => /* @__PURE__ */ g(n, { children: o }), /* @__PURE__ */ g(s, {}));
73
- }, _ = (e, t, s = [], r = []) => {
78
+ return t.slice(0, -1).reduceRight((o, n) => /* @__PURE__ */ _(n, { children: o }), /* @__PURE__ */ _(s, {}));
79
+ }, y = (e, t, s = [], r = []) => {
74
80
  for (const o of t) {
75
81
  if (o.handler && !o.module) {
76
- o.children && _(
82
+ o.children && y(
77
83
  e,
78
84
  o.children,
79
85
  s,
@@ -86,29 +92,34 @@ const N = (e, t, s, r) => {
86
92
  ...o.middlewares || []
87
93
  ];
88
94
  if (o.children)
89
- _(
95
+ y(
90
96
  e,
91
97
  o.children,
92
98
  n,
93
99
  a
94
100
  );
95
101
  else if (o.module) {
96
- const i = o.path === "*", l = o.statusCode ?? (i ? 404 : void 0), c = o.module.metadata?.fullPath;
97
- if (!c && !i) {
102
+ const c = o.path === "*", i = o.statusCode ?? (c ? 404 : void 0), l = o.module.metadata?.fullPath;
103
+ if (!l && !c) {
98
104
  console.warn(
99
105
  `Module ${o.module.metadata?.moduleId} has no fullPath`
100
106
  );
101
107
  continue;
102
108
  }
103
- const u = async (h) => {
104
- const { components: d, data: m } = await O(n, h), f = G(d);
105
- return N(h, f, m, l);
109
+ const d = async (h) => {
110
+ const { components: u, data: m, shortCircuit: f } = await G(n, h);
111
+ if (f) {
112
+ const g = f.headers.get("Location");
113
+ return h.req.query("_data") === "1" && g && f.status >= 300 && f.status < 400 ? h.json({ __redirect: g }) : f;
114
+ }
115
+ const p = H(u);
116
+ return O(h, p, m, i);
106
117
  };
107
- i ? e.notFound(u) : a.length > 0 ? e.on(["GET"], [c], ...a, u) : e.on(["GET"], [c], u);
118
+ c ? e.notFound(d) : a.length > 0 ? e.on(["GET"], [l], ...a, d) : e.on(["GET"], [l], d);
108
119
  } else
109
120
  continue;
110
121
  }
111
- }, b = (e, t, s = []) => {
122
+ }, q = (e, t, s = []) => {
112
123
  for (const r of t) {
113
124
  const o = r.module?.metadata?.moduleId, n = [
114
125
  ...s,
@@ -116,71 +127,71 @@ const N = (e, t, s, r) => {
116
127
  ];
117
128
  if (r.module && o) {
118
129
  const a = Object.keys(r.module).filter(
119
- (i) => i.startsWith("action_")
130
+ (c) => c.startsWith("action_")
120
131
  );
121
- for (const i of a) {
122
- const l = i.replace("action_", ""), c = r.module[i];
123
- if (typeof c == "function") {
124
- const u = `/_action/${o}/${l}`, h = async (d) => {
132
+ for (const c of a) {
133
+ const i = c.replace("action_", ""), l = r.module[c];
134
+ if (typeof l == "function") {
135
+ const d = `/_action/${o}/${i}`, h = async (u) => {
125
136
  let m = {};
126
137
  try {
127
- m = await d.req.json();
138
+ m = await u.req.json();
128
139
  } catch {
129
140
  }
130
141
  const f = {
131
142
  body: m,
132
- params: d.req.param(),
133
- query: d.req.query(),
134
- c: d
143
+ params: u.req.param(),
144
+ query: u.req.query(),
145
+ c: u
135
146
  };
136
147
  try {
137
- const p = await c(f);
138
- return d.json(p ?? { ok: !0 });
148
+ const p = await l(f);
149
+ return u.json(p ?? { ok: !0 });
139
150
  } catch (p) {
140
- const E = p instanceof Error ? p.message : "Action failed";
141
- return d.json({ error: E }, 500);
151
+ const g = p instanceof Error ? p.message : "Action failed";
152
+ return u.json({ error: g }, 500);
142
153
  }
143
154
  };
144
155
  n.length > 0 ? e.on(
145
156
  ["POST"],
146
- [u],
157
+ [d],
147
158
  ...n,
148
159
  h
149
- ) : e.on(["POST"], [u], h);
160
+ ) : e.on(["POST"], [d], h);
150
161
  }
151
162
  }
152
163
  }
153
- r.children && b(e, r.children, n);
164
+ r.children && q(e, r.children, n);
154
165
  }
155
- }, H = async (e, t, s = []) => {
166
+ }, x = async (e, t, s = []) => {
156
167
  const r = (o, n) => {
157
168
  for (const a of o) {
158
- const i = a.module?.metadata?.moduleId, l = [
169
+ const c = a.module?.metadata?.moduleId, i = [
159
170
  ...n,
160
171
  ...a.middlewares || []
161
172
  ];
162
- if (a.module && i) {
163
- const c = Object.keys(a.module).filter(
164
- (u) => u.startsWith("stream_")
173
+ if (a.module && c) {
174
+ const l = Object.keys(a.module).filter(
175
+ (d) => d.startsWith("stream_")
165
176
  );
166
- for (const u of c) {
167
- const h = u.replace("stream_", ""), d = a.module[u];
168
- if (d?.__isVeloEventStream) {
169
- const m = `/_event/${i}/${h}`;
170
- d.__path = m, D(
177
+ for (const d of l) {
178
+ const h = d.replace("stream_", ""), u = a.module[d];
179
+ if (u?.__isVeloEventStream) {
180
+ const m = `/_event/${c}/${h}`;
181
+ u.__path = m, $(
171
182
  e,
172
183
  m,
173
- d,
174
- l
184
+ u,
185
+ i
175
186
  );
176
187
  }
177
188
  }
178
189
  }
179
- a.children && r(a.children, l);
190
+ a.children && r(a.children, i);
180
191
  }
181
192
  };
182
193
  r(t, s);
183
- }, x = (e, t) => t ? t.startsWith("/") ? e + t : e ? e + "/" + t : "/" + t : e || "", V = (e) => {
194
+ }, V = (e, t) => t ? t.startsWith("/") ? e + t : e ? e + "/" + t : "/" + t : e || "", W = (e) => {
184
195
  const t = /* @__PURE__ */ new Set(), s = (r) => {
185
196
  for (const o of r) {
186
197
  if (o.module && !o.children) {
@@ -191,68 +202,69 @@ const N = (e, t, s, r) => {
191
202
  }
192
203
  };
193
204
  return s(e), t;
194
- }, q = (e, t, s, r = "", o = []) => {
205
+ }, R = (e, t, s, r = "", o = []) => {
195
206
  for (const n of t) {
196
- const a = x(r, n.path), i = [
207
+ const a = V(r, n.path), c = [
197
208
  ...o,
198
209
  ...n.middlewares || []
199
- ], l = !!n.handler, c = !!n.method;
200
- if (l && !c ? console.warn(
210
+ ], i = !!n.handler, l = !!n.method;
211
+ if (i && !l ? console.warn(
201
212
  `[velojs] invalid route at "${a || "/"}" — "handler" set without "method"; endpoint skipped`
202
- ) : c && !l ? console.warn(
213
+ ) : l && !i ? console.warn(
203
214
  `[velojs] invalid route at "${a || "/"}" — "method" set without "handler"; endpoint skipped`
204
- ) : l && n.module ? console.warn(
215
+ ) : i && n.module ? console.warn(
205
216
  `[velojs] ambiguous route at "${a || "/"}" — both "module" and "handler" set; endpoint ignored, page kept`
206
- ) : l && n.isRoot && console.warn(
217
+ ) : i && n.isRoot && console.warn(
207
218
  `[velojs] "isRoot" has no effect on endpoint at "${a || "/"}"; ignored`
208
- ), l && c && !n.module) {
219
+ ), i && l && !n.module) {
209
220
  const h = n.method;
210
221
  h === "GET" && s.has(a) && console.warn(
211
222
  `[velojs] path "${a}" has both a page GET and an endpoint GET; the page wins and the endpoint is unreachable. Consider renaming one.`
212
223
  );
213
- const d = n.handler, m = async (f) => await d({
224
+ const u = n.handler, m = async (f) => await u({
214
225
  c: f,
215
226
  params: f.req.param(),
216
227
  query: f.req.query()
217
228
  });
218
- i.length > 0 ? e.on([h], [a], ...i, m) : e.on([h], [a], m);
229
+ c.length > 0 ? e.on([h], [a], ...c, m) : e.on([h], [a], m);
219
230
  }
220
- n.children && q(
231
+ n.children && R(
221
232
  e,
222
233
  n.children,
223
234
  s,
224
235
  a,
225
- i
236
+ c
226
237
  );
227
238
  }
228
- }, W = async (e) => {
229
- const t = new R();
230
- t.use(j()), process.env.NODE_ENV !== "production" && t.use("*", T());
239
+ }, K = async (e) => {
240
+ const t = new j();
241
+ t.use(T()), process.env.NODE_ENV !== "production" && t.use("*", E());
231
242
  const r = w().pendingRoutes.splice(0);
232
243
  for (const n of r)
233
244
  await n(t);
234
- _(t, e), b(t, e), await H(t, e);
235
- const o = V(e);
236
- if (q(t, e, o), await I(t, e), $(t), process.env.NODE_ENV !== "production" && !v) {
245
+ y(t, e), q(t, e), await x(t, e);
246
+ const o = W(e);
247
+ if (R(t, e, o), await I(t, e), D(t), process.env.NODE_ENV !== "production" && !v) {
237
248
  const n = globalThis.__veloDevServer;
238
- n && (P(n), await y(t, n));
249
+ n && (b(n), await S(t, n));
239
250
  }
240
251
  return t;
241
- }, ee = async (e) => {
242
- const { routes: t } = e, s = Number(process.env.PORT) || e.port || 3e3, r = await W(t);
252
+ }, te = async (e) => {
253
+ const { routes: t } = e, s = Number(process.env.PORT) || e.port || 3e3, r = await K(t);
243
254
  if (process.env.NODE_ENV === "production" && !process.env.VELO_STATIC) {
244
- const { serve: o } = await import("@hono/node-server"), { serveStatic: n } = await import("@hono/node-server/serve-static"), { join: a } = await import("node:path"), i = a(process.cwd(), "dist/client");
245
- (process.env.STATIC_BASE_URL || "").startsWith("http") || r.use("/*", n({ root: i })), console.log(`Server running on http://localhost:${s}`);
246
- const c = o({ fetch: r.fetch, port: s });
247
- await y(r, c), P(c);
255
+ const { serve: o } = await import("@hono/node-server"), { serveStatic: n } = await import("@hono/node-server/serve-static"), { join: a } = await import("node:path"), c = a(process.cwd(), "dist/client");
256
+ (process.env.STATIC_BASE_URL || "").startsWith("http") || r.use("/*", n({ root: c })), console.log(`Server running on http://localhost:${s}`);
257
+ const l = o({ fetch: r.fetch, port: s });
258
+ await S(r, l), b(l);
248
259
  }
249
260
  return r;
250
261
  };
251
262
  export {
252
- Z as addRoutes,
253
- W as createApp,
254
- W as default,
255
- Y as onServer,
256
- S as serverDataStorage,
257
- ee as startServer
263
+ ee as addRoutes,
264
+ K as createApp,
265
+ K as default,
266
+ N as jsonForScript,
267
+ Z as onServer,
268
+ P as serverDataStorage,
269
+ te as startServer
258
270
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "type": "module",
5
5
  "description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
6
6
  "keywords": [