@mauroandre/velojs 0.0.6 → 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.
- package/dist/server.js +22 -22
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as h } from "preact/jsx-runtime";
|
|
2
|
-
import { Hono as
|
|
3
|
-
import { logger as
|
|
4
|
-
import { trimTrailingSlash as
|
|
5
|
-
import { render as
|
|
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
|
|
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
|
|
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
|
-
() =>
|
|
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
|
-
},
|
|
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
|
|
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(
|
|
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 &&
|
|
139
|
+
s.children && q(t, s.children, a);
|
|
140
140
|
}
|
|
141
141
|
}, C = async (t) => {
|
|
142
|
-
const e = new
|
|
143
|
-
e.use(
|
|
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),
|
|
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
|
-
},
|
|
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"), {
|
|
155
|
-
(process.env.STATIC_BASE_URL || "").startsWith("http") || s.use("/*", a({ root:
|
|
156
|
-
const
|
|
157
|
-
y(
|
|
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
|
-
|
|
162
|
+
K as addRoutes,
|
|
163
163
|
C as createApp,
|
|
164
164
|
C as default,
|
|
165
|
-
|
|
165
|
+
B as onServer,
|
|
166
166
|
v as serverDataStorage,
|
|
167
|
-
|
|
167
|
+
L as startServer
|
|
168
168
|
};
|