@mauroandre/velojs 0.0.37 → 0.0.39
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 +19 -9
- package/agent/AGENTS.md +143 -0
- package/agent/skills/velojs-actions/SKILL.md +192 -0
- package/agent/skills/velojs-components/SKILL.md +99 -0
- package/agent/skills/velojs-endpoints/SKILL.md +187 -0
- package/agent/skills/velojs-event-streams/SKILL.md +705 -0
- package/agent/skills/velojs-getting-started/SKILL.md +191 -0
- package/agent/skills/velojs-hooks/SKILL.md +103 -0
- package/agent/skills/velojs-link-component/SKILL.md +67 -0
- package/agent/skills/velojs-loaders/SKILL.md +134 -0
- package/agent/skills/velojs-middlewares/SKILL.md +143 -0
- package/agent/skills/velojs-production-deploy/SKILL.md +96 -0
- package/agent/skills/velojs-project-graph/SKILL.md +97 -0
- package/agent/skills/velojs-routes/SKILL.md +209 -0
- package/agent/skills/velojs-scripts-component/SKILL.md +62 -0
- package/agent/skills/velojs-server-api/SKILL.md +155 -0
- package/agent/skills/velojs-sockets/SKILL.md +303 -0
- package/agent/skills/velojs-static-generation/SKILL.md +148 -0
- package/agent/skills/velojs-testing/SKILL.md +472 -0
- package/agent/skills/velojs-type-reference/SKILL.md +142 -0
- package/agent/skills/velojs-vite-plugin/SKILL.md +71 -0
- package/dist/cli.js +42 -31
- package/dist/graph.d.ts +37 -0
- package/dist/graph.js +202 -0
- package/dist/init.js +16 -7
- package/dist/vite.js +279 -248
- package/package.json +6 -2
package/dist/vite.js
CHANGED
|
@@ -1,116 +1,117 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import d from "node:path";
|
|
2
|
+
import g from "node:fs";
|
|
3
3
|
import R from "@preact/preset-vite";
|
|
4
4
|
import $ from "@hono/vite-dev-server";
|
|
5
|
-
import { parse as
|
|
5
|
+
import { parse as h } from "@babel/parser";
|
|
6
6
|
import j from "@babel/traverse";
|
|
7
7
|
import L from "@babel/generator";
|
|
8
8
|
import * as e from "@babel/types";
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
9
|
+
import { buildGraph as U } from "./graph.js";
|
|
10
|
+
const m = typeof j == "function" ? j : j.default, _ = typeof L == "function" ? L : L.default;
|
|
11
|
+
function W(p, o, n, i) {
|
|
12
|
+
const l = h(p, {
|
|
12
13
|
sourceType: "module",
|
|
13
14
|
plugins: ["typescript", "jsx"]
|
|
14
15
|
});
|
|
15
16
|
let t = !1;
|
|
16
|
-
if (
|
|
17
|
+
if (m(l, {
|
|
17
18
|
// Procura: export const metadata = { ... }
|
|
18
|
-
ExportNamedDeclaration(
|
|
19
|
-
const c =
|
|
19
|
+
ExportNamedDeclaration(s) {
|
|
20
|
+
const c = s.node.declaration;
|
|
20
21
|
if (e.isVariableDeclaration(c) && c.declarations.length === 1) {
|
|
21
22
|
const r = c.declarations[0];
|
|
22
23
|
if (r && e.isIdentifier(r.id, { name: "metadata" }) && e.isObjectExpression(r.init)) {
|
|
23
24
|
t = !0;
|
|
24
|
-
const f = r.init.properties.filter((v) => e.isObjectProperty(v) && e.isIdentifier(v.key) ? v.key.name !== "moduleId" && v.key.name !== "fullPath" && v.key.name !== "path" : !0),
|
|
25
|
+
const f = r.init.properties.filter((v) => e.isObjectProperty(v) && e.isIdentifier(v.key) ? v.key.name !== "moduleId" && v.key.name !== "fullPath" && v.key.name !== "path" : !0), y = [
|
|
25
26
|
e.objectProperty(
|
|
26
27
|
e.identifier("moduleId"),
|
|
27
|
-
e.stringLiteral(
|
|
28
|
+
e.stringLiteral(o)
|
|
28
29
|
)
|
|
29
30
|
];
|
|
30
|
-
|
|
31
|
+
n !== void 0 && y.push(
|
|
31
32
|
e.objectProperty(
|
|
32
33
|
e.identifier("fullPath"),
|
|
33
|
-
e.stringLiteral(
|
|
34
|
+
e.stringLiteral(n)
|
|
34
35
|
)
|
|
35
|
-
),
|
|
36
|
+
), i !== void 0 && y.push(
|
|
36
37
|
e.objectProperty(
|
|
37
38
|
e.identifier("path"),
|
|
38
|
-
e.stringLiteral(
|
|
39
|
+
e.stringLiteral(i)
|
|
39
40
|
)
|
|
40
|
-
), r.init.properties = [...
|
|
41
|
+
), r.init.properties = [...y, ...f];
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
}), !t) {
|
|
45
|
-
const
|
|
46
|
+
const s = [
|
|
46
47
|
e.objectProperty(
|
|
47
48
|
e.identifier("moduleId"),
|
|
48
|
-
e.stringLiteral(
|
|
49
|
+
e.stringLiteral(o)
|
|
49
50
|
)
|
|
50
51
|
];
|
|
51
|
-
|
|
52
|
+
n !== void 0 && s.push(
|
|
52
53
|
e.objectProperty(
|
|
53
54
|
e.identifier("fullPath"),
|
|
54
|
-
e.stringLiteral(
|
|
55
|
+
e.stringLiteral(n)
|
|
55
56
|
)
|
|
56
|
-
),
|
|
57
|
+
), i !== void 0 && s.push(
|
|
57
58
|
e.objectProperty(
|
|
58
59
|
e.identifier("path"),
|
|
59
|
-
e.stringLiteral(
|
|
60
|
+
e.stringLiteral(i)
|
|
60
61
|
)
|
|
61
62
|
);
|
|
62
63
|
const c = e.exportNamedDeclaration(
|
|
63
64
|
e.variableDeclaration("const", [
|
|
64
65
|
e.variableDeclarator(
|
|
65
66
|
e.identifier("metadata"),
|
|
66
|
-
e.objectExpression(
|
|
67
|
+
e.objectExpression(s)
|
|
67
68
|
)
|
|
68
69
|
])
|
|
69
70
|
);
|
|
70
71
|
l.program.body.unshift(c);
|
|
71
72
|
}
|
|
72
|
-
return
|
|
73
|
+
return _(l, { retainLines: !0 }).code;
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
-
const
|
|
75
|
+
function J(p, o) {
|
|
76
|
+
const n = h(p, {
|
|
76
77
|
sourceType: "module",
|
|
77
78
|
plugins: ["typescript", "jsx"]
|
|
78
79
|
});
|
|
79
|
-
return
|
|
80
|
+
return m(n, {
|
|
80
81
|
CallExpression(l) {
|
|
81
|
-
const t = l.node.callee,
|
|
82
|
-
if (!
|
|
83
|
-
const c = l.node.arguments, r = e.stringLiteral(
|
|
82
|
+
const t = l.node.callee, a = 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" });
|
|
83
|
+
if (!a && !s) return;
|
|
84
|
+
const c = l.node.arguments, r = e.stringLiteral(o), u = c[0];
|
|
84
85
|
e.isStringLiteral(u) && u.value.includes("/") || (l.node.arguments = [r, ...c]);
|
|
85
86
|
}
|
|
86
|
-
}),
|
|
87
|
+
}), _(n, { retainLines: !0 }).code;
|
|
87
88
|
}
|
|
88
|
-
function
|
|
89
|
-
const
|
|
89
|
+
function B(p, o) {
|
|
90
|
+
const n = h(p, {
|
|
90
91
|
sourceType: "module",
|
|
91
92
|
plugins: ["typescript", "jsx"]
|
|
92
93
|
});
|
|
93
|
-
return
|
|
94
|
+
return m(n, {
|
|
94
95
|
ExportNamedDeclaration(l) {
|
|
95
96
|
const t = l.node.declaration;
|
|
96
97
|
if (!e.isVariableDeclaration(t)) return;
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
99
|
-
const
|
|
100
|
-
if (!
|
|
101
|
-
const c =
|
|
98
|
+
const a = t.declarations[0];
|
|
99
|
+
if (!a || !e.isIdentifier(a.id)) return;
|
|
100
|
+
const s = a.id.name;
|
|
101
|
+
if (!s.startsWith("action_")) return;
|
|
102
|
+
const c = s.replace("action_", ""), r = a.init;
|
|
102
103
|
if (!e.isArrowFunctionExpression(r) || !r.async) return;
|
|
103
|
-
const u = r.params, f = M(
|
|
104
|
-
r.body = e.blockStatement([e.returnStatement(f)]),
|
|
104
|
+
const u = r.params, f = M(o, c, u);
|
|
105
|
+
r.body = e.blockStatement([e.returnStatement(f)]), H(r, u);
|
|
105
106
|
}
|
|
106
|
-
}),
|
|
107
|
+
}), _(n, { retainLines: !0 }).code;
|
|
107
108
|
}
|
|
108
|
-
function M(p,
|
|
109
|
-
const
|
|
110
|
-
return
|
|
109
|
+
function M(p, o, n) {
|
|
110
|
+
const i = `/_action/${p}/${o}`;
|
|
111
|
+
return n.length === 0 ? e.callExpression(
|
|
111
112
|
e.memberExpression(
|
|
112
113
|
e.callExpression(e.identifier("fetch"), [
|
|
113
|
-
e.stringLiteral(
|
|
114
|
+
e.stringLiteral(i),
|
|
114
115
|
e.objectExpression([
|
|
115
116
|
e.objectProperty(
|
|
116
117
|
e.identifier("method"),
|
|
@@ -135,7 +136,7 @@ function M(p, s, i) {
|
|
|
135
136
|
) : e.callExpression(
|
|
136
137
|
e.memberExpression(
|
|
137
138
|
e.callExpression(e.identifier("fetch"), [
|
|
138
|
-
e.stringLiteral(
|
|
139
|
+
e.stringLiteral(i),
|
|
139
140
|
e.objectExpression([
|
|
140
141
|
e.objectProperty(
|
|
141
142
|
e.identifier("method"),
|
|
@@ -175,14 +176,14 @@ function M(p, s, i) {
|
|
|
175
176
|
]
|
|
176
177
|
);
|
|
177
178
|
}
|
|
178
|
-
function
|
|
179
|
-
if (
|
|
180
|
-
const
|
|
181
|
-
if (e.isObjectPattern(
|
|
182
|
-
let
|
|
183
|
-
if (e.isTSTypeAnnotation(
|
|
184
|
-
const
|
|
185
|
-
e.isIdentifier(
|
|
179
|
+
function H(p, o) {
|
|
180
|
+
if (o.length === 0) return;
|
|
181
|
+
const n = o[0];
|
|
182
|
+
if (e.isObjectPattern(n)) {
|
|
183
|
+
let i = null;
|
|
184
|
+
if (e.isTSTypeAnnotation(n.typeAnnotation) && e.isTSTypeReference(n.typeAnnotation.typeAnnotation)) {
|
|
185
|
+
const a = n.typeAnnotation.typeAnnotation;
|
|
186
|
+
e.isIdentifier(a.typeName, { name: "ActionArgs" }) && a.typeParameters?.params[0] && (i = a.typeParameters.params[0]);
|
|
186
187
|
}
|
|
187
188
|
const l = e.objectProperty(
|
|
188
189
|
e.identifier("body"),
|
|
@@ -191,31 +192,31 @@ function B(p, s) {
|
|
|
191
192
|
!0
|
|
192
193
|
// shorthand
|
|
193
194
|
), t = e.objectPattern([l]);
|
|
194
|
-
|
|
195
|
+
i && (t.typeAnnotation = e.tsTypeAnnotation(
|
|
195
196
|
e.tsTypeLiteral([
|
|
196
197
|
e.tsPropertySignature(
|
|
197
198
|
e.identifier("body"),
|
|
198
|
-
e.tsTypeAnnotation(
|
|
199
|
+
e.tsTypeAnnotation(i)
|
|
199
200
|
)
|
|
200
201
|
])
|
|
201
202
|
)), p.params = [t];
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
|
-
function
|
|
205
|
-
const
|
|
205
|
+
function G(p, o) {
|
|
206
|
+
const n = h(p, {
|
|
206
207
|
sourceType: "module",
|
|
207
208
|
plugins: ["typescript", "jsx"]
|
|
208
209
|
});
|
|
209
|
-
return
|
|
210
|
+
return m(n, {
|
|
210
211
|
ExportNamedDeclaration(l) {
|
|
211
212
|
const t = l.node.declaration;
|
|
212
213
|
if (!e.isVariableDeclaration(t)) return;
|
|
213
|
-
const
|
|
214
|
-
if (!
|
|
215
|
-
const
|
|
216
|
-
if (!
|
|
217
|
-
const c =
|
|
218
|
-
|
|
214
|
+
const a = t.declarations[0];
|
|
215
|
+
if (!a || !e.isIdentifier(a.id)) return;
|
|
216
|
+
const s = a.id.name;
|
|
217
|
+
if (!s.startsWith("stream_")) return;
|
|
218
|
+
const c = s.replace("stream_", ""), r = `/_event/${o}/${c}`;
|
|
219
|
+
a.init = e.objectExpression([
|
|
219
220
|
e.objectProperty(
|
|
220
221
|
e.identifier("__isVeloEventStream"),
|
|
221
222
|
e.booleanLiteral(!0)
|
|
@@ -224,25 +225,25 @@ function H(p, s) {
|
|
|
224
225
|
e.identifier("__path"),
|
|
225
226
|
e.stringLiteral(r)
|
|
226
227
|
)
|
|
227
|
-
]),
|
|
228
|
+
]), a.id.typeAnnotation = null;
|
|
228
229
|
}
|
|
229
|
-
}),
|
|
230
|
+
}), _(n, { retainLines: !0 }).code;
|
|
230
231
|
}
|
|
231
|
-
function z(p,
|
|
232
|
-
const
|
|
232
|
+
function z(p, o) {
|
|
233
|
+
const n = h(p, {
|
|
233
234
|
sourceType: "module",
|
|
234
235
|
plugins: ["typescript", "jsx"]
|
|
235
236
|
});
|
|
236
|
-
return
|
|
237
|
+
return m(n, {
|
|
237
238
|
ExportNamedDeclaration(l) {
|
|
238
239
|
const t = l.node.declaration;
|
|
239
240
|
if (!e.isVariableDeclaration(t)) return;
|
|
240
|
-
const
|
|
241
|
-
if (!
|
|
242
|
-
const
|
|
243
|
-
if (!
|
|
244
|
-
const c =
|
|
245
|
-
|
|
241
|
+
const a = t.declarations[0];
|
|
242
|
+
if (!a || !e.isIdentifier(a.id)) return;
|
|
243
|
+
const s = a.id.name;
|
|
244
|
+
if (!s.startsWith("socket_")) return;
|
|
245
|
+
const c = s.replace("socket_", ""), r = `/_socket/${o}/${c}`;
|
|
246
|
+
a.init = e.objectExpression([
|
|
246
247
|
e.objectProperty(
|
|
247
248
|
e.identifier("__isVeloSocket"),
|
|
248
249
|
e.booleanLiteral(!0)
|
|
@@ -251,228 +252,228 @@ function z(p, s) {
|
|
|
251
252
|
e.identifier("__path"),
|
|
252
253
|
e.stringLiteral(r)
|
|
253
254
|
)
|
|
254
|
-
]),
|
|
255
|
+
]), a.id.typeAnnotation = null;
|
|
255
256
|
}
|
|
256
|
-
}),
|
|
257
|
+
}), _(n, { retainLines: !0 }).code;
|
|
257
258
|
}
|
|
258
|
-
function
|
|
259
|
-
const
|
|
259
|
+
function Y(p) {
|
|
260
|
+
const o = h(p, {
|
|
260
261
|
sourceType: "module",
|
|
261
262
|
plugins: ["typescript", "jsx"]
|
|
262
263
|
});
|
|
263
|
-
return
|
|
264
|
-
ExportNamedDeclaration(
|
|
265
|
-
const l =
|
|
264
|
+
return m(o, {
|
|
265
|
+
ExportNamedDeclaration(i) {
|
|
266
|
+
const l = i.node.declaration;
|
|
266
267
|
if (!e.isVariableDeclaration(l)) return;
|
|
267
268
|
const t = l.declarations[0];
|
|
268
|
-
!t || !e.isIdentifier(t.id) || t.id.name === "loader" &&
|
|
269
|
+
!t || !e.isIdentifier(t.id) || t.id.name === "loader" && i.remove();
|
|
269
270
|
}
|
|
270
|
-
}),
|
|
271
|
+
}), _(o, { retainLines: !0 }).code;
|
|
271
272
|
}
|
|
272
|
-
function
|
|
273
|
-
const
|
|
273
|
+
function X(p) {
|
|
274
|
+
const o = h(p, {
|
|
274
275
|
sourceType: "module",
|
|
275
276
|
plugins: ["typescript", "jsx"]
|
|
276
|
-
}),
|
|
277
|
-
|
|
278
|
-
let
|
|
279
|
-
return
|
|
277
|
+
}), n = /* @__PURE__ */ new Set();
|
|
278
|
+
x(o.program, n);
|
|
279
|
+
let i = !1;
|
|
280
|
+
return m(o, {
|
|
280
281
|
ImportDeclaration(t) {
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
284
|
-
|
|
282
|
+
const a = t.node.specifiers;
|
|
283
|
+
if (a.length === 0) return;
|
|
284
|
+
const s = a.filter((c) => n.has(c.local.name));
|
|
285
|
+
s.length !== a.length && (i = !0, s.length === 0 ? t.remove() : t.node.specifiers = s);
|
|
285
286
|
}
|
|
286
|
-
}),
|
|
287
|
+
}), i ? _(o, { retainLines: !0 }).code : p;
|
|
287
288
|
}
|
|
288
|
-
function
|
|
289
|
-
const
|
|
289
|
+
function q(p) {
|
|
290
|
+
const o = h(p, {
|
|
290
291
|
sourceType: "module",
|
|
291
292
|
plugins: ["typescript", "jsx"]
|
|
292
|
-
}),
|
|
293
|
-
if (
|
|
294
|
-
ObjectProperty(
|
|
295
|
-
e.isIdentifier(
|
|
293
|
+
}), n = [];
|
|
294
|
+
if (m(o, {
|
|
295
|
+
ObjectProperty(s) {
|
|
296
|
+
e.isIdentifier(s.node.key, { name: "middlewares" }) && (n.push(s.node.value), s.remove());
|
|
296
297
|
}
|
|
297
|
-
}),
|
|
298
|
-
const
|
|
299
|
-
for (const
|
|
300
|
-
|
|
298
|
+
}), n.length === 0) return p;
|
|
299
|
+
const i = /* @__PURE__ */ new Set();
|
|
300
|
+
for (const s of n)
|
|
301
|
+
x(s, i);
|
|
301
302
|
const l = /* @__PURE__ */ new Set();
|
|
302
|
-
|
|
303
|
+
x(o.program, l);
|
|
303
304
|
const t = /* @__PURE__ */ new Set();
|
|
304
|
-
for (const
|
|
305
|
-
l.has(
|
|
306
|
-
return t.size > 0 &&
|
|
307
|
-
ImportDeclaration(
|
|
308
|
-
const c =
|
|
309
|
-
r.length === 0 ?
|
|
305
|
+
for (const s of i)
|
|
306
|
+
l.has(s) || t.add(s);
|
|
307
|
+
return t.size > 0 && m(o, {
|
|
308
|
+
ImportDeclaration(s) {
|
|
309
|
+
const c = s.node.specifiers, r = c.filter((u) => !t.has(u.local.name));
|
|
310
|
+
r.length === 0 ? s.remove() : r.length !== c.length && (s.node.specifiers = r);
|
|
310
311
|
}
|
|
311
|
-
}),
|
|
312
|
+
}), _(o, { retainLines: !0 }).code;
|
|
312
313
|
}
|
|
313
|
-
function
|
|
314
|
-
const
|
|
315
|
-
if (!(!
|
|
316
|
-
if (Array.isArray(
|
|
317
|
-
for (const l of
|
|
314
|
+
function x(p, o) {
|
|
315
|
+
const n = (i) => {
|
|
316
|
+
if (!(!i || typeof i != "object")) {
|
|
317
|
+
if (Array.isArray(i)) {
|
|
318
|
+
for (const l of i) n(l);
|
|
318
319
|
return;
|
|
319
320
|
}
|
|
320
|
-
if (
|
|
321
|
-
|
|
321
|
+
if (i.type === "Identifier") {
|
|
322
|
+
o.add(i.name), i.typeAnnotation && n(i.typeAnnotation);
|
|
322
323
|
return;
|
|
323
324
|
}
|
|
324
|
-
if (
|
|
325
|
-
|
|
325
|
+
if (i.type === "JSXIdentifier") {
|
|
326
|
+
o.add(i.name);
|
|
326
327
|
return;
|
|
327
328
|
}
|
|
328
|
-
if (
|
|
329
|
-
i
|
|
329
|
+
if (i.type === "MemberExpression") {
|
|
330
|
+
n(i.object), i.computed && n(i.property);
|
|
330
331
|
return;
|
|
331
332
|
}
|
|
332
|
-
if ((
|
|
333
|
-
|
|
333
|
+
if ((i.type === "ObjectProperty" || i.type === "ObjectMethod") && !i.computed) {
|
|
334
|
+
i.type === "ObjectProperty" ? n(i.value) : n(i.body);
|
|
334
335
|
return;
|
|
335
336
|
}
|
|
336
|
-
if (!(
|
|
337
|
-
for (const l of Object.keys(
|
|
338
|
-
l === "loc" || l === "start" || l === "end" || l === "leadingComments" || l === "trailingComments" || l === "innerComments" || i
|
|
337
|
+
if (!(i.type === "ImportSpecifier" || i.type === "ImportDefaultSpecifier" || i.type === "ImportNamespaceSpecifier"))
|
|
338
|
+
for (const l of Object.keys(i))
|
|
339
|
+
l === "loc" || l === "start" || l === "end" || l === "leadingComments" || l === "trailingComments" || l === "innerComments" || n(i[l]);
|
|
339
340
|
}
|
|
340
341
|
};
|
|
341
|
-
|
|
342
|
+
n(p);
|
|
342
343
|
}
|
|
343
|
-
function
|
|
344
|
-
for (const
|
|
345
|
-
if (e.isObjectProperty(
|
|
344
|
+
function K(p) {
|
|
345
|
+
for (const o of p.properties)
|
|
346
|
+
if (e.isObjectProperty(o) && e.isIdentifier(o.key) && o.key.name === "handler")
|
|
346
347
|
return !0;
|
|
347
348
|
return !1;
|
|
348
349
|
}
|
|
349
|
-
function
|
|
350
|
-
for (const
|
|
351
|
-
if (e.isObjectProperty(
|
|
352
|
-
return
|
|
350
|
+
function Q(p) {
|
|
351
|
+
for (const o of p.properties)
|
|
352
|
+
if (e.isObjectProperty(o) && e.isIdentifier(o.key) && o.key.name === "children" && e.isArrayExpression(o.value))
|
|
353
|
+
return o.value;
|
|
353
354
|
return null;
|
|
354
355
|
}
|
|
355
|
-
function
|
|
356
|
-
const
|
|
356
|
+
function Z(p) {
|
|
357
|
+
const o = h(p, {
|
|
357
358
|
sourceType: "module",
|
|
358
359
|
plugins: ["typescript", "jsx"]
|
|
359
|
-
}),
|
|
360
|
+
}), n = [], i = (c) => {
|
|
360
361
|
for (let r = c.elements.length - 1; r >= 0; r--) {
|
|
361
362
|
const u = c.elements[r];
|
|
362
363
|
if (!e.isObjectExpression(u)) continue;
|
|
363
|
-
if (
|
|
364
|
-
|
|
364
|
+
if (K(u)) {
|
|
365
|
+
n.push(u), c.elements.splice(r, 1);
|
|
365
366
|
continue;
|
|
366
367
|
}
|
|
367
|
-
const f =
|
|
368
|
-
f &&
|
|
368
|
+
const f = Q(u);
|
|
369
|
+
f && i(f);
|
|
369
370
|
}
|
|
370
371
|
};
|
|
371
|
-
if (
|
|
372
|
+
if (m(o, {
|
|
372
373
|
ExportDefaultDeclaration(c) {
|
|
373
374
|
const r = c.node.declaration;
|
|
374
375
|
let u = null;
|
|
375
|
-
e.isArrayExpression(r) ? u = r : (e.isTSSatisfiesExpression(r) && e.isArrayExpression(r.expression) || e.isTSAsExpression(r) && e.isArrayExpression(r.expression)) && (u = r.expression), u &&
|
|
376
|
+
e.isArrayExpression(r) ? u = r : (e.isTSSatisfiesExpression(r) && e.isArrayExpression(r.expression) || e.isTSAsExpression(r) && e.isArrayExpression(r.expression)) && (u = r.expression), u && i(u);
|
|
376
377
|
}
|
|
377
|
-
}),
|
|
378
|
+
}), n.length === 0) return p;
|
|
378
379
|
const l = /* @__PURE__ */ new Set();
|
|
379
|
-
for (const c of
|
|
380
|
-
|
|
380
|
+
for (const c of n)
|
|
381
|
+
x(c, l);
|
|
381
382
|
const t = /* @__PURE__ */ new Set();
|
|
382
|
-
|
|
383
|
-
const
|
|
383
|
+
x(o.program, t);
|
|
384
|
+
const a = /* @__PURE__ */ new Set();
|
|
384
385
|
for (const c of l)
|
|
385
|
-
t.has(c) ||
|
|
386
|
-
return
|
|
386
|
+
t.has(c) || a.add(c);
|
|
387
|
+
return a.size > 0 && m(o, {
|
|
387
388
|
ImportDeclaration(c) {
|
|
388
|
-
const r = c.node.specifiers, u = r.filter((f) => !
|
|
389
|
+
const r = c.node.specifiers, u = r.filter((f) => !a.has(f.local.name));
|
|
389
390
|
u.length === 0 ? c.remove() : u.length !== r.length && (c.node.specifiers = u);
|
|
390
391
|
}
|
|
391
|
-
}),
|
|
392
|
+
}), _(o, { retainLines: !0 }).code;
|
|
392
393
|
}
|
|
393
394
|
function A(p) {
|
|
394
|
-
const
|
|
395
|
+
const o = h(p, {
|
|
395
396
|
sourceType: "module",
|
|
396
397
|
plugins: ["typescript", "jsx"]
|
|
397
|
-
}),
|
|
398
|
-
|
|
398
|
+
}), n = /* @__PURE__ */ new Map();
|
|
399
|
+
m(o, {
|
|
399
400
|
ImportDeclaration(t) {
|
|
400
|
-
const
|
|
401
|
-
for (const
|
|
402
|
-
e.isImportNamespaceSpecifier(
|
|
401
|
+
const a = t.node.source.value;
|
|
402
|
+
for (const s of t.node.specifiers)
|
|
403
|
+
e.isImportNamespaceSpecifier(s) && n.set(s.local.name, a);
|
|
403
404
|
}
|
|
404
405
|
});
|
|
405
|
-
const
|
|
406
|
-
|
|
406
|
+
const i = /* @__PURE__ */ new Map();
|
|
407
|
+
m(o, {
|
|
407
408
|
ExportDefaultDeclaration(t) {
|
|
408
|
-
const
|
|
409
|
-
let
|
|
410
|
-
e.isArrayExpression(
|
|
409
|
+
const a = t.node.declaration;
|
|
410
|
+
let s = null;
|
|
411
|
+
e.isArrayExpression(a) ? s = a : (e.isTSSatisfiesExpression(a) || e.isTSAsExpression(a)) && e.isArrayExpression(a.expression) && (s = a.expression), s && D(s.elements, "", i);
|
|
411
412
|
}
|
|
412
413
|
});
|
|
413
414
|
const l = /* @__PURE__ */ new Map();
|
|
414
|
-
for (const [t,
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
417
|
-
const c =
|
|
418
|
-
l.set(c,
|
|
415
|
+
for (const [t, a] of i) {
|
|
416
|
+
const s = n.get(t);
|
|
417
|
+
if (s) {
|
|
418
|
+
const c = s.replace(/^\.\//, "").replace(/\.(tsx?|jsx?|js)$/, "");
|
|
419
|
+
l.set(c, a);
|
|
419
420
|
}
|
|
420
421
|
}
|
|
421
422
|
return l;
|
|
422
423
|
}
|
|
423
|
-
function
|
|
424
|
-
for (const
|
|
425
|
-
if (!e.isObjectExpression(
|
|
426
|
-
let l = "", t =
|
|
427
|
-
for (const c of
|
|
424
|
+
function D(p, o, n) {
|
|
425
|
+
for (const i of p) {
|
|
426
|
+
if (!e.isObjectExpression(i)) continue;
|
|
427
|
+
let l = "", t = o, a = null, s = null;
|
|
428
|
+
for (const c of i.properties) {
|
|
428
429
|
if (!e.isObjectProperty(c)) continue;
|
|
429
430
|
const r = c.key, u = e.isIdentifier(r) ? r.name : null;
|
|
430
|
-
u === "path" && e.isStringLiteral(c.value) && (l = c.value.value, l && !l.startsWith("/") ? t =
|
|
431
|
+
u === "path" && e.isStringLiteral(c.value) && (l = c.value.value, l && !l.startsWith("/") ? t = o + "/" + l : t = o + l), u === "module" && e.isIdentifier(c.value) && (a = c.value.name), u === "children" && e.isArrayExpression(c.value) && (s = c.value);
|
|
431
432
|
}
|
|
432
|
-
if (
|
|
433
|
-
const r = !
|
|
434
|
-
|
|
433
|
+
if (a) {
|
|
434
|
+
const r = !s && l === "/" ? o || "/" : t;
|
|
435
|
+
n.set(a, {
|
|
435
436
|
fullPath: r,
|
|
436
437
|
path: l
|
|
437
438
|
});
|
|
438
439
|
}
|
|
439
|
-
|
|
440
|
+
s && D(s.elements, t, n);
|
|
440
441
|
}
|
|
441
442
|
}
|
|
442
|
-
const
|
|
443
|
-
function
|
|
444
|
-
let
|
|
445
|
-
const
|
|
443
|
+
const b = "virtual:velo/server-entry", E = "virtual:velo/client-entry", P = "\0" + b, N = "\0" + E;
|
|
444
|
+
function ee(p, o) {
|
|
445
|
+
let n = d.resolve(process.cwd(), o);
|
|
446
|
+
const i = p.routesFile ?? "routes.tsx", l = /* @__PURE__ */ new Map();
|
|
446
447
|
return {
|
|
447
448
|
name: "velo:transform",
|
|
448
449
|
enforce: "pre",
|
|
449
450
|
configResolved(t) {
|
|
450
|
-
|
|
451
|
+
n = d.resolve(t.root, o);
|
|
451
452
|
},
|
|
452
453
|
buildStart() {
|
|
453
|
-
const t =
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
454
|
+
const t = d.join(n, i);
|
|
455
|
+
if (g.existsSync(t)) {
|
|
456
|
+
const a = g.readFileSync(t, "utf-8"), s = A(a);
|
|
456
457
|
l.clear();
|
|
457
|
-
for (const [c, r] of
|
|
458
|
+
for (const [c, r] of s)
|
|
458
459
|
l.set(c, r);
|
|
459
460
|
}
|
|
460
461
|
},
|
|
461
|
-
handleHotUpdate({ file: t, server:
|
|
462
|
-
const
|
|
463
|
-
if (t ===
|
|
464
|
-
const c =
|
|
462
|
+
handleHotUpdate({ file: t, server: a }) {
|
|
463
|
+
const s = d.join(n, i);
|
|
464
|
+
if (t === s) {
|
|
465
|
+
const c = g.readFileSync(s, "utf-8"), r = A(c);
|
|
465
466
|
l.clear();
|
|
466
467
|
for (const [u, f] of r)
|
|
467
468
|
l.set(u, f);
|
|
468
|
-
return
|
|
469
|
+
return a.ws.send({ type: "full-reload" }), [];
|
|
469
470
|
}
|
|
470
471
|
},
|
|
471
472
|
resolveId(t) {
|
|
472
|
-
return t ===
|
|
473
|
+
return t === b || t.endsWith(b) ? P : t === E || t.endsWith(E) || t === "/__velo_client.js" ? N : null;
|
|
473
474
|
},
|
|
474
475
|
load(t) {
|
|
475
|
-
const
|
|
476
|
+
const a = p.routesFile ?? "routes.tsx", s = p.serverInit ?? "server.tsx", c = p.clientInit ?? "client.tsx", r = d.join(n, a).replace(/\.tsx?$/, ".js"), u = d.join(n, s).replace(/\.tsx?$/, ".js"), f = d.join(n, c).replace(/\.tsx?$/, ".js");
|
|
476
477
|
return t === P ? `
|
|
477
478
|
globalThis.__veloBuildHash = __VELO_BUILD_HASH__;
|
|
478
479
|
globalThis.__veloClientJs = __VELO_CLIENT_JS__;
|
|
@@ -491,25 +492,25 @@ import { startClient } from "@mauroandre/velojs/client";
|
|
|
491
492
|
startClient({ routes });
|
|
492
493
|
` : null;
|
|
493
494
|
},
|
|
494
|
-
transform(t,
|
|
495
|
-
const c =
|
|
496
|
-
if (
|
|
495
|
+
transform(t, a, s) {
|
|
496
|
+
const c = s?.ssr === !0;
|
|
497
|
+
if (a.startsWith("\0") || a.includes("/.velojs/") || !a.endsWith(".tsx") && !a.endsWith(".ts") || !a.startsWith(n)) return null;
|
|
497
498
|
let r = t, u = !1;
|
|
498
|
-
const f = /middlewares:\s*\[/.test(t),
|
|
499
|
+
const f = /middlewares:\s*\[/.test(t), y = /export\s+(const|function)\s+Component/.test(
|
|
499
500
|
t
|
|
500
|
-
), v = /export\s+(const|function)\s+loader/.test(t),
|
|
501
|
-
if (!c && f && (r =
|
|
502
|
-
const
|
|
503
|
-
r =
|
|
501
|
+
), v = /export\s+(const|function)\s+loader/.test(t), C = /export\s+const\s+action_\w+/.test(t), I = /export\s+const\s+stream_\w+/.test(t), T = /export\s+const\s+socket_\w+/.test(t), w = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), k = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t), F = /\bhandler\s*:/.test(t), V = d.join(n, i);
|
|
502
|
+
if (!c && f && (r = q(r), u = !0), !c && F && a === V && (r = Z(r), u = !0), y || v || C || I || T || w || k) {
|
|
503
|
+
const S = d.relative(n, a).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), O = l.get(S);
|
|
504
|
+
r = W(r, S, O?.fullPath, O?.path), r = J(r, S), c || (r = B(
|
|
504
505
|
r,
|
|
505
|
-
|
|
506
|
-
)), !c && I && (r =
|
|
506
|
+
S
|
|
507
|
+
)), !c && I && (r = G(
|
|
507
508
|
r,
|
|
508
|
-
|
|
509
|
+
S
|
|
509
510
|
)), !c && T && (r = z(
|
|
510
511
|
r,
|
|
511
|
-
|
|
512
|
-
)), c || (r =
|
|
512
|
+
S
|
|
513
|
+
)), c || (r = Y(r)), c || (r = X(r)), u = !0;
|
|
513
514
|
}
|
|
514
515
|
return u ? {
|
|
515
516
|
code: r,
|
|
@@ -518,16 +519,16 @@ startClient({ routes });
|
|
|
518
519
|
}
|
|
519
520
|
};
|
|
520
521
|
}
|
|
521
|
-
function
|
|
522
|
+
function te(p) {
|
|
522
523
|
return {
|
|
523
524
|
name: "velo:config",
|
|
524
|
-
config(
|
|
525
|
-
const
|
|
526
|
-
let
|
|
527
|
-
if (
|
|
525
|
+
config(o, { mode: n }) {
|
|
526
|
+
const i = n === "server", l = n === "development", t = !!process.env.VELO_STATIC, a = o.server?.port ?? (Number(process.env.PORT) || p.port || 3e3);
|
|
527
|
+
let s = "client.js", c = "client.css";
|
|
528
|
+
if (i)
|
|
528
529
|
try {
|
|
529
|
-
const u =
|
|
530
|
-
|
|
530
|
+
const u = d.resolve(process.cwd(), "dist/client/.vite/manifest.json"), y = JSON.parse(g.readFileSync(u, "utf-8"))[E];
|
|
531
|
+
y && (s = y.file || s, y.css?.[0] && (c = y.css[0]));
|
|
531
532
|
} catch {
|
|
532
533
|
}
|
|
533
534
|
const r = {
|
|
@@ -536,7 +537,7 @@ function ee(p) {
|
|
|
536
537
|
"process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (t ? "/client" : "")),
|
|
537
538
|
__VELO_STATIC__: JSON.stringify(t),
|
|
538
539
|
__VELO_BUILD_HASH__: JSON.stringify(process.env.VELO_BUILD_HASH || Date.now().toString(36)),
|
|
539
|
-
__VELO_CLIENT_JS__: JSON.stringify(
|
|
540
|
+
__VELO_CLIENT_JS__: JSON.stringify(s),
|
|
540
541
|
__VELO_CLIENT_CSS__: JSON.stringify(c),
|
|
541
542
|
// Baked into the server bundle as startServer's port fallback.
|
|
542
543
|
// null when unset → startServer falls back to PORT env / 3000.
|
|
@@ -549,11 +550,11 @@ function ee(p) {
|
|
|
549
550
|
}
|
|
550
551
|
},
|
|
551
552
|
server: {
|
|
552
|
-
port:
|
|
553
|
+
port: a
|
|
553
554
|
}
|
|
554
555
|
};
|
|
555
|
-
return
|
|
556
|
-
ssr:
|
|
556
|
+
return i ? r.build = {
|
|
557
|
+
ssr: b,
|
|
557
558
|
outDir: "dist",
|
|
558
559
|
emptyOutDir: !1,
|
|
559
560
|
copyPublicDir: !1,
|
|
@@ -576,36 +577,66 @@ function ee(p) {
|
|
|
576
577
|
}
|
|
577
578
|
};
|
|
578
579
|
}
|
|
579
|
-
function
|
|
580
|
+
function re() {
|
|
580
581
|
return {
|
|
581
582
|
name: "velo:static-url",
|
|
582
583
|
apply: "build",
|
|
583
584
|
enforce: "post",
|
|
584
|
-
generateBundle(p,
|
|
585
|
-
const
|
|
586
|
-
if (
|
|
587
|
-
for (const
|
|
588
|
-
|
|
585
|
+
generateBundle(p, o) {
|
|
586
|
+
const n = process.env.STATIC_BASE_URL || "";
|
|
587
|
+
if (n)
|
|
588
|
+
for (const i of Object.values(o))
|
|
589
|
+
i.type === "asset" && typeof i.source == "string" && i.fileName.endsWith(".css") && (i.source = i.source.replace(
|
|
589
590
|
/url\(\s*(['"]?)\/(?!\/)/g,
|
|
590
|
-
`url($1${
|
|
591
|
+
`url($1${n}/`
|
|
591
592
|
));
|
|
592
593
|
}
|
|
593
594
|
};
|
|
594
595
|
}
|
|
595
|
-
function
|
|
596
|
-
|
|
596
|
+
function ne(p, o) {
|
|
597
|
+
let n = "", i = "", l = !1, t = null;
|
|
598
|
+
function a() {
|
|
599
|
+
if (!n) return;
|
|
600
|
+
const s = d.resolve(n, o);
|
|
601
|
+
if (!g.existsSync(s)) return;
|
|
602
|
+
const c = U(s), r = d.join(n, ".velojs");
|
|
603
|
+
g.mkdirSync(r, { recursive: !0 }), g.writeFileSync(
|
|
604
|
+
d.join(r, "graph.json"),
|
|
605
|
+
JSON.stringify(c, null, 2)
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
name: "velo:graph",
|
|
610
|
+
configResolved(s) {
|
|
611
|
+
n = s.root, i = s.mode;
|
|
612
|
+
},
|
|
613
|
+
writeBundle() {
|
|
614
|
+
i !== "server" && a();
|
|
615
|
+
},
|
|
616
|
+
configureServer(s) {
|
|
617
|
+
a(), l = !0;
|
|
618
|
+
const c = d.resolve(n, o);
|
|
619
|
+
s.watcher.on("all", (r, u) => {
|
|
620
|
+
l && u.startsWith(c) && (t && clearTimeout(t), t = setTimeout(() => a(), 500));
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function de(p) {
|
|
626
|
+
const o = p ?? {}, n = o.appDirectory ?? "./app";
|
|
597
627
|
return [
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
628
|
+
te(o),
|
|
629
|
+
ee(o, n),
|
|
630
|
+
re(),
|
|
631
|
+
ne(o, n),
|
|
601
632
|
R(),
|
|
602
633
|
$({
|
|
603
|
-
entry:
|
|
634
|
+
entry: b
|
|
604
635
|
}),
|
|
605
|
-
|
|
636
|
+
ie()
|
|
606
637
|
];
|
|
607
638
|
}
|
|
608
|
-
function
|
|
639
|
+
function ie() {
|
|
609
640
|
return {
|
|
610
641
|
name: "velo:ws-bridge",
|
|
611
642
|
configureServer(p) {
|
|
@@ -615,15 +646,15 @@ function re() {
|
|
|
615
646
|
}
|
|
616
647
|
export {
|
|
617
648
|
A as buildFullPathMap,
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
649
|
+
D as collectFullPaths,
|
|
650
|
+
W as injectMetadata,
|
|
651
|
+
X as pruneClientOnlyImports,
|
|
652
|
+
Z as removeEndpointRoutes,
|
|
653
|
+
Y as removeLoaders,
|
|
654
|
+
q as removeMiddlewares,
|
|
655
|
+
B as transformActionsForClient,
|
|
656
|
+
J as transformLoaderFunctions,
|
|
626
657
|
z as transformSocketsForClient,
|
|
627
|
-
|
|
628
|
-
|
|
658
|
+
G as transformStreamsForClient,
|
|
659
|
+
de as veloPlugin
|
|
629
660
|
};
|