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