@mauroandre/velojs 0.0.5 → 0.0.7

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.
@@ -1,10 +1,15 @@
1
- import { jsx as i, jsxs as u, Fragment as m } from "preact/jsx-runtime";
2
- import { Link as p } from "wouter-preact";
3
- function y({ basePath: t, favicon: n = "/favicon.ico" } = {}) {
1
+ import { jsx as i, jsxs as u, Fragment as p } from "preact/jsx-runtime";
2
+ import { Link as m } from "wouter-preact";
3
+ function v({ basePath: t, favicon: n = "/favicon.ico" } = {}) {
4
+ const e = process.env.NODE_ENV !== "production";
4
5
  t = t || process.env.STATIC_BASE_URL || "";
5
- const e = n !== !1 && /* @__PURE__ */ i("link", { rel: "icon", href: `${t}${n}`, type: "image/x-icon" });
6
- return /* @__PURE__ */ u(m, { children: [
7
- e,
6
+ const r = n !== !1 && /* @__PURE__ */ i("link", { rel: "icon", href: `${t}${n}`, type: "image/x-icon" });
7
+ return e ? /* @__PURE__ */ u(p, { children: [
8
+ r,
9
+ /* @__PURE__ */ i("script", { type: "module", src: "/@vite/client" }),
10
+ /* @__PURE__ */ i("script", { type: "module", src: "/__velo_client.js" })
11
+ ] }) : /* @__PURE__ */ u(p, { children: [
12
+ r,
8
13
  /* @__PURE__ */ i("link", { rel: "stylesheet", href: `${t}/client.css` }),
9
14
  /* @__PURE__ */ i("script", { type: "module", src: `${t}/client.js` })
10
15
  ] });
@@ -15,12 +20,12 @@ function $(t, n) {
15
20
  e = e.replace(`:${r}`, c);
16
21
  return e;
17
22
  }
18
- function S({ to: t, params: n, search: e, absolute: r, ...c }) {
19
- const o = typeof t != "string", s = o ? (r ? t.metadata?.fullPath : t.metadata?.path) ?? "/" : t, l = n ? $(s, n) : s, a = o && r ? `~${l}` : l, f = e ? `?${new URLSearchParams(e).toString()}` : "";
20
- return /* @__PURE__ */ i(p, { to: `${a}${f}`, ...c });
23
+ function g({ to: t, params: n, search: e, absolute: r, ...c }) {
24
+ const s = typeof t != "string", o = s ? (r ? t.metadata?.fullPath : t.metadata?.path) ?? "/" : t, l = n ? $(o, n) : o, f = s && r ? `~${l}` : l, a = e ? `?${new URLSearchParams(e).toString()}` : "";
25
+ return /* @__PURE__ */ i(m, { to: `${f}${a}`, ...c });
21
26
  }
22
27
  export {
23
- S as Link,
24
- y as Scripts,
28
+ g as Link,
29
+ v as Scripts,
25
30
  $ as substituteParams
26
31
  };
package/dist/server.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { jsx as h } from "preact/jsx-runtime";
2
- import { Hono as T } from "hono";
3
- import { logger as A } from "hono/logger";
4
- import { trimTrailingSlash as R } from "hono/trailing-slash";
5
- import { render as D } from "preact-render-to-string";
2
+ import { Hono as A } from "hono";
3
+ import { logger as T } from "hono/logger";
4
+ import { trimTrailingSlash as D } from "hono/trailing-slash";
5
+ import { render as R } from "preact-render-to-string";
6
6
  import { Router as N } from "wouter-preact";
7
7
  import { AsyncLocalStorage as O } from "node:async_hooks";
8
8
  const v = new O();
9
9
  globalThis.__veloServerData = v;
10
10
  const g = [];
11
11
  let p = null;
12
- function x(t) {
12
+ function B(t) {
13
13
  if (p) {
14
14
  t(p);
15
15
  return;
@@ -22,7 +22,7 @@ function y(t) {
22
22
  g.length = 0;
23
23
  }
24
24
  const w = [];
25
- function B(t) {
25
+ function K(t) {
26
26
  w.push(t);
27
27
  }
28
28
  const b = (t, e, o) => {
@@ -30,7 +30,7 @@ const b = (t, e, o) => {
30
30
  return t.json(o ?? null);
31
31
  const s = t.req.path, r = v.run(
32
32
  o ?? {},
33
- () => D(/* @__PURE__ */ h(N, { ssrPath: s, children: e }))
33
+ () => R(/* @__PURE__ */ h(N, { ssrPath: s, children: e }))
34
34
  );
35
35
  if (!o)
36
36
  return t.html(r);
@@ -94,7 +94,7 @@ const b = (t, e, o) => {
94
94
  c.length > 0 ? t.on(["GET"], [n], ...c, u) : t.on(["GET"], [n], u);
95
95
  }
96
96
  }
97
- }, P = (t, e, o = []) => {
97
+ }, q = (t, e, o = []) => {
98
98
  for (const s of e) {
99
99
  const r = s.module.metadata?.moduleId, a = [
100
100
  ...o,
@@ -113,14 +113,14 @@ const b = (t, e, o) => {
113
113
  _ = await l.req.json();
114
114
  } catch {
115
115
  }
116
- const q = {
116
+ const P = {
117
117
  body: _,
118
118
  params: l.req.param(),
119
119
  query: l.req.query(),
120
120
  c: l
121
121
  };
122
122
  try {
123
- const m = await i(q);
123
+ const m = await i(P);
124
124
  return l.json(m ?? { ok: !0 });
125
125
  } catch (m) {
126
126
  const E = m instanceof Error ? m.message : "Action failed";
@@ -136,33 +136,33 @@ const b = (t, e, o) => {
136
136
  }
137
137
  }
138
138
  }
139
- s.children && P(t, s.children, a);
139
+ s.children && q(t, s.children, a);
140
140
  }
141
141
  }, C = async (t) => {
142
- const e = new T();
143
- e.use(R()), process.env.NODE_ENV !== "production" && e.use("*", A());
142
+ const e = new A();
143
+ e.use(D()), process.env.NODE_ENV !== "production" && e.use("*", T());
144
144
  for (const o of w)
145
145
  await o(e);
146
- if (S(e, t), P(e, t), process.env.NODE_ENV !== "production" && !p) {
146
+ if (S(e, t), q(e, t), process.env.NODE_ENV !== "production" && !p) {
147
147
  const o = globalThis.__veloDevServer;
148
148
  o && y(o);
149
149
  }
150
150
  return e;
151
- }, K = async (t) => {
151
+ }, L = async (t) => {
152
152
  const { routes: e, port: o = Number(process.env.SERVER_PORT) || 3e3 } = t, s = await C(e);
153
153
  if (process.env.NODE_ENV === "production") {
154
- const { serve: r } = await import("@hono/node-server"), { serveStatic: a } = await import("@hono/node-server/serve-static"), { dirname: c, join: n } = await import("node:path"), { fileURLToPath: u } = await import("node:url"), i = c(u(import.meta.url)), d = n(i, "client");
155
- (process.env.STATIC_BASE_URL || "").startsWith("http") || s.use("/*", a({ root: d })), console.log(`Server running on http://localhost:${o}`);
156
- const l = r({ fetch: s.fetch, port: o });
157
- y(l);
154
+ const { serve: r } = await import("@hono/node-server"), { serveStatic: a } = await import("@hono/node-server/serve-static"), { join: c } = await import("node:path"), n = c(process.cwd(), "dist/client");
155
+ (process.env.STATIC_BASE_URL || "").startsWith("http") || s.use("/*", a({ root: n })), console.log(`Server running on http://localhost:${o}`);
156
+ const i = r({ fetch: s.fetch, port: o });
157
+ y(i);
158
158
  }
159
159
  return s;
160
160
  };
161
161
  export {
162
- B as addRoutes,
162
+ K as addRoutes,
163
163
  C as createApp,
164
164
  C as default,
165
- x as onServer,
165
+ B as onServer,
166
166
  v as serverDataStorage,
167
- K as startServer
167
+ L as startServer
168
168
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
6
6
  "keywords": [