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