@mauroandre/velojs 0.0.4 → 0.0.6
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 +36 -37
- package/bin/velojs.js +1 -14
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +59 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.js +19 -0
- package/dist/components.d.ts +81 -0
- package/dist/components.js +31 -0
- package/{src/config.ts → dist/config.d.ts} +1 -7
- package/dist/config.js +6 -0
- package/dist/cookie.d.ts +1 -0
- package/dist/cookie.js +8 -0
- package/dist/factory.js +5 -0
- package/dist/hooks.d.ts +119 -0
- package/dist/hooks.js +72 -0
- package/{src/index.ts → dist/index.d.ts} +1 -15
- package/dist/index.js +7 -0
- package/dist/init.d.ts +1 -0
- package/dist/init.js +149 -0
- package/dist/server.d.ts +14 -0
- package/dist/server.js +168 -0
- package/{src/types.ts → dist/types.d.ts} +0 -6
- package/dist/types.js +1 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +448 -0
- package/package.json +21 -46
- package/src/cli.ts +0 -84
- package/src/client.tsx +0 -79
- package/src/components.tsx +0 -155
- package/src/cookie.ts +0 -7
- package/src/hooks.tsx +0 -266
- package/src/init.ts +0 -188
- package/src/server.tsx +0 -347
- package/src/vite.ts +0 -937
- /package/{src/factory.ts → dist/factory.d.ts} +0 -0
package/dist/vite.js
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import d from "node:path";
|
|
2
|
+
import E from "node:fs";
|
|
3
|
+
import w from "@preact/preset-vite";
|
|
4
|
+
import C from "@hono/vite-dev-server";
|
|
5
|
+
import { parse as v } from "@babel/parser";
|
|
6
|
+
import L from "@babel/traverse";
|
|
7
|
+
import I from "@babel/generator";
|
|
8
|
+
import * as e from "@babel/types";
|
|
9
|
+
const m = typeof L == "function" ? L : L.default, h = typeof I == "function" ? I : I.default;
|
|
10
|
+
function R(u, o, r, l) {
|
|
11
|
+
const n = v(u, {
|
|
12
|
+
sourceType: "module",
|
|
13
|
+
plugins: ["typescript", "jsx"]
|
|
14
|
+
});
|
|
15
|
+
let t = !1;
|
|
16
|
+
if (m(n, {
|
|
17
|
+
// Procura: export const metadata = { ... }
|
|
18
|
+
ExportNamedDeclaration(s) {
|
|
19
|
+
const c = s.node.declaration;
|
|
20
|
+
if (e.isVariableDeclaration(c) && c.declarations.length === 1) {
|
|
21
|
+
const a = c.declarations[0];
|
|
22
|
+
if (a && e.isIdentifier(a.id, { name: "metadata" }) && e.isObjectExpression(a.init)) {
|
|
23
|
+
t = !0;
|
|
24
|
+
const f = a.init.properties.filter((y) => e.isObjectProperty(y) && e.isIdentifier(y.key) ? y.key.name !== "moduleId" && y.key.name !== "fullPath" && y.key.name !== "path" : !0), x = [
|
|
25
|
+
e.objectProperty(
|
|
26
|
+
e.identifier("moduleId"),
|
|
27
|
+
e.stringLiteral(o)
|
|
28
|
+
)
|
|
29
|
+
];
|
|
30
|
+
r !== void 0 && x.push(
|
|
31
|
+
e.objectProperty(
|
|
32
|
+
e.identifier("fullPath"),
|
|
33
|
+
e.stringLiteral(r)
|
|
34
|
+
)
|
|
35
|
+
), l !== void 0 && x.push(
|
|
36
|
+
e.objectProperty(
|
|
37
|
+
e.identifier("path"),
|
|
38
|
+
e.stringLiteral(l)
|
|
39
|
+
)
|
|
40
|
+
), a.init.properties = [...x, ...f];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}), !t) {
|
|
45
|
+
const s = [
|
|
46
|
+
e.objectProperty(
|
|
47
|
+
e.identifier("moduleId"),
|
|
48
|
+
e.stringLiteral(o)
|
|
49
|
+
)
|
|
50
|
+
];
|
|
51
|
+
r !== void 0 && s.push(
|
|
52
|
+
e.objectProperty(
|
|
53
|
+
e.identifier("fullPath"),
|
|
54
|
+
e.stringLiteral(r)
|
|
55
|
+
)
|
|
56
|
+
), l !== void 0 && s.push(
|
|
57
|
+
e.objectProperty(
|
|
58
|
+
e.identifier("path"),
|
|
59
|
+
e.stringLiteral(l)
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
const c = e.exportNamedDeclaration(
|
|
63
|
+
e.variableDeclaration("const", [
|
|
64
|
+
e.variableDeclarator(
|
|
65
|
+
e.identifier("metadata"),
|
|
66
|
+
e.objectExpression(s)
|
|
67
|
+
)
|
|
68
|
+
])
|
|
69
|
+
);
|
|
70
|
+
n.program.body.unshift(c);
|
|
71
|
+
}
|
|
72
|
+
return h(n, { retainLines: !0 }).code;
|
|
73
|
+
}
|
|
74
|
+
function O(u, o) {
|
|
75
|
+
const r = v(u, {
|
|
76
|
+
sourceType: "module",
|
|
77
|
+
plugins: ["typescript", "jsx"]
|
|
78
|
+
});
|
|
79
|
+
return m(r, {
|
|
80
|
+
CallExpression(n) {
|
|
81
|
+
const t = n.node.callee, i = e.isIdentifier(t, { name: "Loader" }) || e.isTSInstantiationExpression(t) && e.isIdentifier(t.expression, { name: "Loader" }), s = e.isIdentifier(t, { name: "useLoader" }) || e.isTSInstantiationExpression(t) && e.isIdentifier(t.expression, { name: "useLoader" });
|
|
82
|
+
if (!i && !s) return;
|
|
83
|
+
const c = n.node.arguments, a = e.stringLiteral(o), p = c[0];
|
|
84
|
+
e.isStringLiteral(p) && p.value.includes("/") || (n.node.arguments = [a, ...c]);
|
|
85
|
+
}
|
|
86
|
+
}), h(r, { retainLines: !0 }).code;
|
|
87
|
+
}
|
|
88
|
+
function W(u, o) {
|
|
89
|
+
const r = v(u, {
|
|
90
|
+
sourceType: "module",
|
|
91
|
+
plugins: ["typescript", "jsx"]
|
|
92
|
+
});
|
|
93
|
+
return m(r, {
|
|
94
|
+
ExportNamedDeclaration(n) {
|
|
95
|
+
const t = n.node.declaration;
|
|
96
|
+
if (!e.isVariableDeclaration(t)) return;
|
|
97
|
+
const i = t.declarations[0];
|
|
98
|
+
if (!i || !e.isIdentifier(i.id)) return;
|
|
99
|
+
const s = i.id.name;
|
|
100
|
+
if (!s.startsWith("action_")) return;
|
|
101
|
+
const c = s.replace("action_", ""), a = i.init;
|
|
102
|
+
if (!e.isArrowFunctionExpression(a) || !a.async) return;
|
|
103
|
+
const p = a.params, f = $(o, c, p);
|
|
104
|
+
a.body = e.blockStatement([e.returnStatement(f)]), V(a, p);
|
|
105
|
+
}
|
|
106
|
+
}), h(r, { retainLines: !0 }).code;
|
|
107
|
+
}
|
|
108
|
+
function $(u, o, r) {
|
|
109
|
+
const l = `/_action/${u}/${o}`;
|
|
110
|
+
return r.length === 0 ? e.callExpression(
|
|
111
|
+
e.memberExpression(
|
|
112
|
+
e.callExpression(e.identifier("fetch"), [
|
|
113
|
+
e.stringLiteral(l),
|
|
114
|
+
e.objectExpression([
|
|
115
|
+
e.objectProperty(
|
|
116
|
+
e.identifier("method"),
|
|
117
|
+
e.stringLiteral("POST")
|
|
118
|
+
)
|
|
119
|
+
])
|
|
120
|
+
]),
|
|
121
|
+
e.identifier("then")
|
|
122
|
+
),
|
|
123
|
+
[
|
|
124
|
+
e.arrowFunctionExpression(
|
|
125
|
+
[e.identifier("r")],
|
|
126
|
+
e.callExpression(
|
|
127
|
+
e.memberExpression(
|
|
128
|
+
e.identifier("r"),
|
|
129
|
+
e.identifier("json")
|
|
130
|
+
),
|
|
131
|
+
[]
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
]
|
|
135
|
+
) : e.callExpression(
|
|
136
|
+
e.memberExpression(
|
|
137
|
+
e.callExpression(e.identifier("fetch"), [
|
|
138
|
+
e.stringLiteral(l),
|
|
139
|
+
e.objectExpression([
|
|
140
|
+
e.objectProperty(
|
|
141
|
+
e.identifier("method"),
|
|
142
|
+
e.stringLiteral("POST")
|
|
143
|
+
),
|
|
144
|
+
e.objectProperty(
|
|
145
|
+
e.identifier("headers"),
|
|
146
|
+
e.objectExpression([
|
|
147
|
+
e.objectProperty(
|
|
148
|
+
e.stringLiteral("Content-Type"),
|
|
149
|
+
e.stringLiteral("application/json")
|
|
150
|
+
)
|
|
151
|
+
])
|
|
152
|
+
),
|
|
153
|
+
e.objectProperty(
|
|
154
|
+
e.identifier("body"),
|
|
155
|
+
e.callExpression(
|
|
156
|
+
e.memberExpression(
|
|
157
|
+
e.identifier("JSON"),
|
|
158
|
+
e.identifier("stringify")
|
|
159
|
+
),
|
|
160
|
+
[e.identifier("body")]
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
])
|
|
164
|
+
]),
|
|
165
|
+
e.identifier("then")
|
|
166
|
+
),
|
|
167
|
+
[
|
|
168
|
+
e.arrowFunctionExpression(
|
|
169
|
+
[e.identifier("r")],
|
|
170
|
+
e.callExpression(
|
|
171
|
+
e.memberExpression(e.identifier("r"), e.identifier("json")),
|
|
172
|
+
[]
|
|
173
|
+
)
|
|
174
|
+
)
|
|
175
|
+
]
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
function V(u, o) {
|
|
179
|
+
if (o.length === 0) return;
|
|
180
|
+
const r = o[0];
|
|
181
|
+
if (e.isObjectPattern(r)) {
|
|
182
|
+
let l = null;
|
|
183
|
+
if (e.isTSTypeAnnotation(r.typeAnnotation) && e.isTSTypeReference(r.typeAnnotation.typeAnnotation)) {
|
|
184
|
+
const i = r.typeAnnotation.typeAnnotation;
|
|
185
|
+
e.isIdentifier(i.typeName, { name: "ActionArgs" }) && i.typeParameters?.params[0] && (l = i.typeParameters.params[0]);
|
|
186
|
+
}
|
|
187
|
+
const n = e.objectProperty(
|
|
188
|
+
e.identifier("body"),
|
|
189
|
+
e.identifier("body"),
|
|
190
|
+
!1,
|
|
191
|
+
!0
|
|
192
|
+
// shorthand
|
|
193
|
+
), t = e.objectPattern([n]);
|
|
194
|
+
l && (t.typeAnnotation = e.tsTypeAnnotation(
|
|
195
|
+
e.tsTypeLiteral([
|
|
196
|
+
e.tsPropertySignature(
|
|
197
|
+
e.identifier("body"),
|
|
198
|
+
e.tsTypeAnnotation(l)
|
|
199
|
+
)
|
|
200
|
+
])
|
|
201
|
+
)), u.params = [t];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function U(u) {
|
|
205
|
+
const o = v(u, {
|
|
206
|
+
sourceType: "module",
|
|
207
|
+
plugins: ["typescript", "jsx"]
|
|
208
|
+
});
|
|
209
|
+
return m(o, {
|
|
210
|
+
ExportNamedDeclaration(l) {
|
|
211
|
+
const n = l.node.declaration;
|
|
212
|
+
if (!e.isVariableDeclaration(n)) return;
|
|
213
|
+
const t = n.declarations[0];
|
|
214
|
+
!t || !e.isIdentifier(t.id) || t.id.name === "loader" && l.remove();
|
|
215
|
+
}
|
|
216
|
+
}), h(o, { retainLines: !0 }).code;
|
|
217
|
+
}
|
|
218
|
+
function k(u) {
|
|
219
|
+
const o = v(u, {
|
|
220
|
+
sourceType: "module",
|
|
221
|
+
plugins: ["typescript", "jsx"]
|
|
222
|
+
}), r = /* @__PURE__ */ new Set();
|
|
223
|
+
return m(o, {
|
|
224
|
+
ObjectProperty(n) {
|
|
225
|
+
if (e.isIdentifier(n.node.key, { name: "middlewares" }) && e.isArrayExpression(n.node.value)) {
|
|
226
|
+
for (const t of n.node.value.elements)
|
|
227
|
+
e.isIdentifier(t) && r.add(t.name);
|
|
228
|
+
n.remove();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}), r.size === 0 ? u : (m(o, {
|
|
232
|
+
ImportDeclaration(n) {
|
|
233
|
+
const t = n.node.specifiers, i = t.filter((s) => {
|
|
234
|
+
if (e.isImportSpecifier(s)) {
|
|
235
|
+
const c = s.local.name;
|
|
236
|
+
return !r.has(c);
|
|
237
|
+
}
|
|
238
|
+
return !0;
|
|
239
|
+
});
|
|
240
|
+
i.length === 0 ? n.remove() : i.length !== t.length && (n.node.specifiers = i);
|
|
241
|
+
}
|
|
242
|
+
}), h(o, { retainLines: !0 }).code);
|
|
243
|
+
}
|
|
244
|
+
function T(u) {
|
|
245
|
+
const o = v(u, {
|
|
246
|
+
sourceType: "module",
|
|
247
|
+
plugins: ["typescript", "jsx"]
|
|
248
|
+
}), r = /* @__PURE__ */ new Map();
|
|
249
|
+
m(o, {
|
|
250
|
+
ImportDeclaration(t) {
|
|
251
|
+
const i = t.node.source.value;
|
|
252
|
+
for (const s of t.node.specifiers)
|
|
253
|
+
e.isImportNamespaceSpecifier(s) && r.set(s.local.name, i);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
const l = /* @__PURE__ */ new Map();
|
|
257
|
+
m(o, {
|
|
258
|
+
ExportDefaultDeclaration(t) {
|
|
259
|
+
const i = t.node.declaration;
|
|
260
|
+
let s = null;
|
|
261
|
+
e.isArrayExpression(i) ? s = i : e.isTSSatisfiesExpression(i) && e.isArrayExpression(i.expression) && (s = i.expression), s && N(s.elements, "", l);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
const n = /* @__PURE__ */ new Map();
|
|
265
|
+
for (const [t, i] of l) {
|
|
266
|
+
const s = r.get(t);
|
|
267
|
+
if (s) {
|
|
268
|
+
const c = s.replace(/^\.\//, "").replace(/\.(tsx?|jsx?|js)$/, "");
|
|
269
|
+
n.set(c, i);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return n;
|
|
273
|
+
}
|
|
274
|
+
function N(u, o, r) {
|
|
275
|
+
for (const l of u) {
|
|
276
|
+
if (!e.isObjectExpression(l)) continue;
|
|
277
|
+
let n = "", t = o, i = null, s = null;
|
|
278
|
+
for (const c of l.properties) {
|
|
279
|
+
if (!e.isObjectProperty(c)) continue;
|
|
280
|
+
const a = c.key, p = e.isIdentifier(a) ? a.name : null;
|
|
281
|
+
p === "path" && e.isStringLiteral(c.value) && (n = c.value.value, n && !n.startsWith("/") ? t = o + "/" + n : t = o + n), p === "module" && e.isIdentifier(c.value) && (i = c.value.name), p === "children" && e.isArrayExpression(c.value) && (s = c.value);
|
|
282
|
+
}
|
|
283
|
+
if (i) {
|
|
284
|
+
const a = !s && n === "/" ? o || "/" : t;
|
|
285
|
+
r.set(i, {
|
|
286
|
+
fullPath: a,
|
|
287
|
+
path: n
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
s && N(s.elements, t, r);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const g = "virtual:velo/server-entry", j = "virtual:velo/client-entry", P = "\0" + g, A = "\0" + j;
|
|
294
|
+
function M(u, o) {
|
|
295
|
+
let r = d.resolve(process.cwd(), o);
|
|
296
|
+
const l = u.routesFile ?? "routes.tsx", n = /* @__PURE__ */ new Map();
|
|
297
|
+
return {
|
|
298
|
+
name: "velo:transform",
|
|
299
|
+
enforce: "pre",
|
|
300
|
+
configResolved(t) {
|
|
301
|
+
r = d.resolve(t.root, o);
|
|
302
|
+
},
|
|
303
|
+
buildStart() {
|
|
304
|
+
const t = d.join(r, l);
|
|
305
|
+
if (E.existsSync(t)) {
|
|
306
|
+
const i = E.readFileSync(t, "utf-8"), s = T(i);
|
|
307
|
+
n.clear();
|
|
308
|
+
for (const [c, a] of s)
|
|
309
|
+
n.set(c, a);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
handleHotUpdate({ file: t, server: i }) {
|
|
313
|
+
const s = d.join(r, l);
|
|
314
|
+
if (t === s) {
|
|
315
|
+
const c = E.readFileSync(s, "utf-8"), a = T(c);
|
|
316
|
+
n.clear();
|
|
317
|
+
for (const [p, f] of a)
|
|
318
|
+
n.set(p, f);
|
|
319
|
+
return i.ws.send({ type: "full-reload" }), [];
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
resolveId(t) {
|
|
323
|
+
return t === g || t.endsWith(g) ? P : t === j || t.endsWith(j) || t === "/__velo_client.js" ? A : null;
|
|
324
|
+
},
|
|
325
|
+
load(t) {
|
|
326
|
+
const i = u.routesFile ?? "routes.tsx", s = u.serverInit ?? "server.tsx", c = u.clientInit ?? "client.tsx", a = d.join(r, i).replace(/\.tsx?$/, ".js"), p = d.join(r, s).replace(/\.tsx?$/, ".js"), f = d.join(r, c).replace(/\.tsx?$/, ".js");
|
|
327
|
+
return t === P ? `
|
|
328
|
+
import "${p}";
|
|
329
|
+
import routes from "${a}";
|
|
330
|
+
import { startServer } from "@mauroandre/velojs/server";
|
|
331
|
+
|
|
332
|
+
export default await startServer({ routes });
|
|
333
|
+
` : t === A ? `
|
|
334
|
+
import "${f}";
|
|
335
|
+
import routes from "${a}";
|
|
336
|
+
import { startClient } from "@mauroandre/velojs/client";
|
|
337
|
+
|
|
338
|
+
startClient({ routes });
|
|
339
|
+
` : null;
|
|
340
|
+
},
|
|
341
|
+
transform(t, i, s) {
|
|
342
|
+
const c = s?.ssr === !0;
|
|
343
|
+
if (i.startsWith("\0") || i.includes("/.velojs/") || !i.endsWith(".tsx") && !i.endsWith(".ts") || !i.startsWith(r)) return null;
|
|
344
|
+
let a = t, p = !1;
|
|
345
|
+
const f = /middlewares:\s*\[/.test(t), x = /export\s+(const|function)\s+Component/.test(
|
|
346
|
+
t
|
|
347
|
+
), y = /export\s+(const|function)\s+loader/.test(t), _ = /export\s+const\s+action_\w+/.test(t), D = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), F = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t);
|
|
348
|
+
if (!c && f && (a = k(a), p = !0), x || y || _ || D || F) {
|
|
349
|
+
const b = d.relative(r, i).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), S = n.get(b);
|
|
350
|
+
a = R(a, b, S?.fullPath, S?.path), a = O(a, b), c || (a = W(
|
|
351
|
+
a,
|
|
352
|
+
b
|
|
353
|
+
)), c || (a = U(a)), p = !0;
|
|
354
|
+
}
|
|
355
|
+
return p ? {
|
|
356
|
+
code: a,
|
|
357
|
+
map: null
|
|
358
|
+
} : null;
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function B() {
|
|
363
|
+
return {
|
|
364
|
+
name: "velo:config",
|
|
365
|
+
config(u, { mode: o }) {
|
|
366
|
+
const r = o === "server", l = o === "development", n = {
|
|
367
|
+
define: {
|
|
368
|
+
"process.env.NODE_ENV": JSON.stringify(l ? "development" : "production"),
|
|
369
|
+
"process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || "")
|
|
370
|
+
},
|
|
371
|
+
resolve: {
|
|
372
|
+
alias: {
|
|
373
|
+
react: "preact/compat",
|
|
374
|
+
"react-dom": "preact/compat"
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
return r ? n.build = {
|
|
379
|
+
ssr: g,
|
|
380
|
+
outDir: "dist",
|
|
381
|
+
emptyOutDir: !1,
|
|
382
|
+
copyPublicDir: !1,
|
|
383
|
+
rollupOptions: {
|
|
384
|
+
output: {
|
|
385
|
+
entryFileNames: "server.js"
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
} : l || (n.build = {
|
|
389
|
+
manifest: !0,
|
|
390
|
+
outDir: "dist/client",
|
|
391
|
+
rollupOptions: {
|
|
392
|
+
input: j,
|
|
393
|
+
output: {
|
|
394
|
+
entryFileNames: "client.js",
|
|
395
|
+
assetFileNames: (t) => t.names?.[0]?.endsWith(".css") ? "client.css" : "[name][extname]"
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}), n;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
function J() {
|
|
403
|
+
return {
|
|
404
|
+
name: "velo:static-url",
|
|
405
|
+
apply: "build",
|
|
406
|
+
enforce: "post",
|
|
407
|
+
generateBundle(u, o) {
|
|
408
|
+
const r = process.env.STATIC_BASE_URL || "";
|
|
409
|
+
if (r)
|
|
410
|
+
for (const l of Object.values(o))
|
|
411
|
+
l.type === "asset" && typeof l.source == "string" && l.fileName.endsWith(".css") && (l.source = l.source.replace(
|
|
412
|
+
/url\(\s*(['"]?)\/(?!\/)/g,
|
|
413
|
+
`url($1${r}/`
|
|
414
|
+
));
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function Z(u) {
|
|
419
|
+
const o = u ?? {}, r = o.appDirectory ?? "./app";
|
|
420
|
+
return [
|
|
421
|
+
B(),
|
|
422
|
+
M(o, r),
|
|
423
|
+
J(),
|
|
424
|
+
w(),
|
|
425
|
+
C({
|
|
426
|
+
entry: g
|
|
427
|
+
}),
|
|
428
|
+
Y()
|
|
429
|
+
];
|
|
430
|
+
}
|
|
431
|
+
function Y() {
|
|
432
|
+
return {
|
|
433
|
+
name: "velo:ws-bridge",
|
|
434
|
+
configureServer(u) {
|
|
435
|
+
globalThis.__veloDevServer = u.httpServer;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
export {
|
|
440
|
+
T as buildFullPathMap,
|
|
441
|
+
N as collectFullPaths,
|
|
442
|
+
R as injectMetadata,
|
|
443
|
+
U as removeLoaders,
|
|
444
|
+
k as removeMiddlewares,
|
|
445
|
+
W as transformActionsForClient,
|
|
446
|
+
O as transformLoaderFunctions,
|
|
447
|
+
Z as veloPlugin
|
|
448
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mauroandre/velojs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
|
|
6
6
|
"keywords": [
|
|
@@ -23,75 +23,51 @@
|
|
|
23
23
|
"velojs": "bin/velojs.js"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
|
-
"
|
|
26
|
+
"dist/",
|
|
27
27
|
"bin/",
|
|
28
28
|
"README.md",
|
|
29
29
|
"LICENSE"
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
|
+
"build": "vite build --config vite.build.config.ts && tsc --declaration --emitDeclarationOnly --outDir dist --noEmit false --rootDir src",
|
|
32
33
|
"typecheck": "tsc --noEmit",
|
|
33
34
|
"test": "vitest run",
|
|
34
35
|
"test:watch": "vitest"
|
|
35
36
|
},
|
|
36
|
-
"main": "./
|
|
37
|
-
"types": "./
|
|
37
|
+
"main": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
38
39
|
"exports": {
|
|
39
40
|
".": {
|
|
40
|
-
"types": "./
|
|
41
|
-
"import": "./
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"import": "./dist/index.js"
|
|
42
43
|
},
|
|
43
44
|
"./server": {
|
|
44
|
-
"types": "./
|
|
45
|
-
"import": "./
|
|
45
|
+
"types": "./dist/server.d.ts",
|
|
46
|
+
"import": "./dist/server.js"
|
|
46
47
|
},
|
|
47
48
|
"./client": {
|
|
48
|
-
"types": "./
|
|
49
|
-
"import": "./
|
|
49
|
+
"types": "./dist/client.d.ts",
|
|
50
|
+
"import": "./dist/client.js"
|
|
50
51
|
},
|
|
51
52
|
"./hooks": {
|
|
52
|
-
"types": "./
|
|
53
|
-
"import": "./
|
|
53
|
+
"types": "./dist/hooks.d.ts",
|
|
54
|
+
"import": "./dist/hooks.js"
|
|
54
55
|
},
|
|
55
56
|
"./cookie": {
|
|
56
|
-
"types": "./
|
|
57
|
-
"import": "./
|
|
57
|
+
"types": "./dist/cookie.d.ts",
|
|
58
|
+
"import": "./dist/cookie.js"
|
|
58
59
|
},
|
|
59
60
|
"./factory": {
|
|
60
|
-
"types": "./
|
|
61
|
-
"import": "./
|
|
61
|
+
"types": "./dist/factory.d.ts",
|
|
62
|
+
"import": "./dist/factory.js"
|
|
62
63
|
},
|
|
63
64
|
"./vite": {
|
|
64
|
-
"types": "./
|
|
65
|
-
"import": "./
|
|
65
|
+
"types": "./dist/vite.d.ts",
|
|
66
|
+
"import": "./dist/vite.js"
|
|
66
67
|
},
|
|
67
68
|
"./config": {
|
|
68
|
-
"types": "./
|
|
69
|
-
"import": "./
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
"typesVersions": {
|
|
73
|
-
"*": {
|
|
74
|
-
"server": [
|
|
75
|
-
"./src/server.tsx"
|
|
76
|
-
],
|
|
77
|
-
"client": [
|
|
78
|
-
"./src/client.tsx"
|
|
79
|
-
],
|
|
80
|
-
"hooks": [
|
|
81
|
-
"./src/hooks.tsx"
|
|
82
|
-
],
|
|
83
|
-
"cookie": [
|
|
84
|
-
"./src/cookie.ts"
|
|
85
|
-
],
|
|
86
|
-
"factory": [
|
|
87
|
-
"./src/factory.ts"
|
|
88
|
-
],
|
|
89
|
-
"vite": [
|
|
90
|
-
"./src/vite.ts"
|
|
91
|
-
],
|
|
92
|
-
"config": [
|
|
93
|
-
"./src/config.ts"
|
|
94
|
-
]
|
|
69
|
+
"types": "./dist/config.d.ts",
|
|
70
|
+
"import": "./dist/config.js"
|
|
95
71
|
}
|
|
96
72
|
},
|
|
97
73
|
"dependencies": {
|
|
@@ -106,7 +82,6 @@
|
|
|
106
82
|
"hono": "^4.12.0",
|
|
107
83
|
"preact": "^10.29.0",
|
|
108
84
|
"preact-render-to-string": "^6.6.0",
|
|
109
|
-
"tsx": "^4.19.0",
|
|
110
85
|
"vite": "^7.3.0",
|
|
111
86
|
"wouter-preact": "^3.9.0"
|
|
112
87
|
},
|
package/src/cli.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env npx tsx
|
|
2
|
-
|
|
3
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
-
import { resolve } from "node:path";
|
|
5
|
-
|
|
6
|
-
const args = process.argv.slice(2);
|
|
7
|
-
const command = args[0];
|
|
8
|
-
|
|
9
|
-
const runCommand = (cmd: string, cmdArgs: string[] = []) => {
|
|
10
|
-
const result = spawnSync(cmd, cmdArgs, {
|
|
11
|
-
stdio: "inherit",
|
|
12
|
-
cwd: process.cwd(),
|
|
13
|
-
});
|
|
14
|
-
process.exit(result.status ?? 0);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const runVite = () => {
|
|
18
|
-
runCommand("npx", ["vite", ...args.slice(1)]);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const runBuild = () => {
|
|
22
|
-
console.log("Building client...");
|
|
23
|
-
spawnSync("npx", ["vite", "build"], { stdio: "inherit", cwd: process.cwd() });
|
|
24
|
-
|
|
25
|
-
console.log("Building server...");
|
|
26
|
-
spawnSync("npx", ["vite", "build", "--mode", "server"], { stdio: "inherit", cwd: process.cwd() });
|
|
27
|
-
|
|
28
|
-
console.log("Build complete!");
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const runStart = () => {
|
|
32
|
-
process.env.NODE_ENV = "production";
|
|
33
|
-
const serverPath = resolve(process.cwd(), "dist/server.js");
|
|
34
|
-
runCommand("node", [serverPath]);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const showHelp = () => {
|
|
38
|
-
console.log(`
|
|
39
|
-
VeloJS CLI
|
|
40
|
-
|
|
41
|
-
Usage:
|
|
42
|
-
velojs <command>
|
|
43
|
-
|
|
44
|
-
Commands:
|
|
45
|
-
init Create a new VeloJS project
|
|
46
|
-
dev Start development server
|
|
47
|
-
build Build for production (client + server)
|
|
48
|
-
start Start production server
|
|
49
|
-
|
|
50
|
-
Examples:
|
|
51
|
-
velojs init my-app
|
|
52
|
-
velojs dev
|
|
53
|
-
velojs build
|
|
54
|
-
velojs start
|
|
55
|
-
`);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
switch (command) {
|
|
59
|
-
case "init": {
|
|
60
|
-
const { runInit } = await import("./init.js");
|
|
61
|
-
await runInit(args[1]);
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
case "dev":
|
|
65
|
-
runVite();
|
|
66
|
-
break;
|
|
67
|
-
case "build":
|
|
68
|
-
runBuild();
|
|
69
|
-
break;
|
|
70
|
-
case "start":
|
|
71
|
-
runStart();
|
|
72
|
-
break;
|
|
73
|
-
case "help":
|
|
74
|
-
case "--help":
|
|
75
|
-
case "-h":
|
|
76
|
-
showHelp();
|
|
77
|
-
break;
|
|
78
|
-
default:
|
|
79
|
-
if (command) {
|
|
80
|
-
console.error(`Unknown command: ${command}`);
|
|
81
|
-
}
|
|
82
|
-
showHelp();
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|