@mauroandre/velojs 0.0.48 → 0.0.50
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/agent/skills/velojs-vite-plugin/SKILL.md +20 -1
- package/dist/config.d.ts +7 -0
- package/dist/server.js +1 -1
- package/dist/static.js +1 -1
- package/dist/vite.d.ts +10 -0
- package/dist/vite.js +131 -122
- package/package.json +1 -1
|
@@ -7,17 +7,36 @@ description: "The `veloPlugin` build pipeline: the 9 AST transforms that inject
|
|
|
7
7
|
|
|
8
8
|
The `veloPlugin()` is the core of VeloJS. It's a single function that returns 6 Vite plugins working together to handle routing, SSR, code transforms, and more.
|
|
9
9
|
|
|
10
|
-
## The
|
|
10
|
+
## The 7 plugins
|
|
11
11
|
|
|
12
12
|
| Plugin | What it does |
|
|
13
13
|
|--------|-------------|
|
|
14
14
|
| `velo:config` | Sets up build config for client/server modes, Preact aliases, and environment defines |
|
|
15
15
|
| `velo:transform` | Performs AST transforms on your code (the most important plugin) |
|
|
16
16
|
| `velo:static-url` | Rewrites CSS `url(/path)` to use `STATIC_BASE_URL` in production builds |
|
|
17
|
+
| `velo:graph` | Generates `.velojs/graph.json` (route tree + dependency graph) on build and dev |
|
|
17
18
|
| `@preact/preset-vite` | Adds Preact JSX support |
|
|
18
19
|
| `@hono/vite-dev-server` | Runs the SSR dev server |
|
|
19
20
|
| `velo:ws-bridge` | Exposes Vite's HTTP server for WebSocket handlers during development |
|
|
20
21
|
|
|
22
|
+
## Dev server: what is served × intercepted
|
|
23
|
+
|
|
24
|
+
During `velojs dev`, every request that is **not** excluded falls through to the SSR app — if no route matches, it gets the app's 404/fallback HTML. Excluded (delegated to Vite, which serves and transforms them as modules): `.js`, `.mjs`, `.ts`, `.tsx`, `.jsx`, `.css`, `.md`, `.svelte`, `.vue`, `/@vite/*`, `/node_modules/*`, `/static/*`, and `?t=` cache-busted requests.
|
|
25
|
+
|
|
26
|
+
Project `.mjs` files are covered — relevant for build-time generators (Panda CSS, vanilla-extract) that emit ESM artifacts such as `styled-system/`.
|
|
27
|
+
|
|
28
|
+
Need more patterns? Declare them in the plugin config — they are **composed with** the defaults, not a replacement:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
plugins: [
|
|
33
|
+
veloPlugin({
|
|
34
|
+
devServerExclude: ["/generated/**"],
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
21
40
|
## AST Transformations
|
|
22
41
|
|
|
23
42
|
The `velo:transform` plugin uses Babel to modify your code at build time. It applies 9 transformations to `.ts`/`.tsx` files inside your `appDirectory` (a file elsewhere, or a `.js`/`.jsx` one, is not transformed at all):
|
package/dist/config.d.ts
CHANGED
|
@@ -25,5 +25,12 @@ export interface VeloConfig {
|
|
|
25
25
|
* @default 3000
|
|
26
26
|
*/
|
|
27
27
|
port?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Padrões adicionais de URL que o dev server deve delegar ao Vite em vez
|
|
30
|
+
* de interceptar como página (ex.: artefatos de geradores build-time como
|
|
31
|
+
* Panda CSS — "/styled-system/**"). Compostos com os defaults do
|
|
32
|
+
* @hono/vite-dev-server, não os substituem.
|
|
33
|
+
*/
|
|
34
|
+
devServerExclude?: (string | RegExp)[];
|
|
28
35
|
}
|
|
29
36
|
export declare function defineConfig(config: VeloConfig): VeloConfig;
|
package/dist/server.js
CHANGED
|
@@ -39,7 +39,7 @@ const N = (e) => JSON.stringify(e).replace(/</g, "\\u003c").replace(/>/g, "\\u00
|
|
|
39
39
|
if (e.header("Cache-Control", "no-cache"), !s)
|
|
40
40
|
return e.html(n);
|
|
41
41
|
const a = `<script>window.__PAGE_DATA__=${N(s)}<\/script>`;
|
|
42
|
-
return e.html(n.replace("</head>", `${a}</head>`));
|
|
42
|
+
return e.html(n.replace("</head>", () => `${a}</head>`));
|
|
43
43
|
}, G = async (e, t) => {
|
|
44
44
|
const s = t.req.param(), r = t.req.query(), o = { params: s, query: r, c: t }, n = await Promise.all(
|
|
45
45
|
e.map(async (i) => {
|
package/dist/static.js
CHANGED
package/dist/vite.d.ts
CHANGED
|
@@ -66,4 +66,14 @@ export declare function buildFullPathMap(code: string): Map<string, PathInfo>;
|
|
|
66
66
|
* Percorre recursivamente a árvore de rotas e coleta moduleName → { fullPath, path }
|
|
67
67
|
*/
|
|
68
68
|
export declare function collectFullPaths(elements: (t.Expression | t.SpreadElement | null)[], parentPath: string, result: Map<string, PathInfo>): void;
|
|
69
|
+
/**
|
|
70
|
+
* @hono/vite-dev-server treats `exclude` as all-or-nothing: passing one
|
|
71
|
+
* replaces the defaults entirely. We compose instead — the upstream defaults
|
|
72
|
+
* (imported, so they track the installed version) plus `.mjs`, which upstream
|
|
73
|
+
* misses: build-time generators (Panda CSS, vanilla-extract) emit ESM
|
|
74
|
+
* artifacts inside the project, and a project `.mjs` that falls through to
|
|
75
|
+
* the SSR app comes back as fallback HTML/404 — the browser's ESM import
|
|
76
|
+
* dies silently.
|
|
77
|
+
*/
|
|
78
|
+
export declare function devServerExcludeFor(veloConfig: VeloConfig): (string | RegExp)[];
|
|
69
79
|
export declare function veloPlugin(config?: VeloConfig): PluginOption[];
|
package/dist/vite.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import d from "node:path";
|
|
2
2
|
import g from "node:fs";
|
|
3
3
|
import R from "@preact/preset-vite";
|
|
4
|
-
import
|
|
4
|
+
import $, { defaultOptions as U } from "@hono/vite-dev-server";
|
|
5
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
|
-
import { buildGraph as
|
|
10
|
-
const m = typeof j == "function" ? j : j.default,
|
|
11
|
-
function
|
|
12
|
-
const l = h(
|
|
9
|
+
import { buildGraph as W } from "./graph.js";
|
|
10
|
+
const m = typeof j == "function" ? j : j.default, v = typeof L == "function" ? L : L.default;
|
|
11
|
+
function J(u, o, n, i) {
|
|
12
|
+
const l = h(u, {
|
|
13
13
|
sourceType: "module",
|
|
14
14
|
plugins: ["typescript", "jsx"]
|
|
15
15
|
});
|
|
@@ -22,7 +22,7 @@ function W(p, o, n, i) {
|
|
|
22
22
|
const r = c.declarations[0];
|
|
23
23
|
if (r && e.isIdentifier(r.id, { name: "metadata" }) && e.isObjectExpression(r.init)) {
|
|
24
24
|
t = !0;
|
|
25
|
-
const f = r.init.properties.filter((
|
|
25
|
+
const f = r.init.properties.filter((_) => e.isObjectProperty(_) && e.isIdentifier(_.key) ? _.key.name !== "moduleId" && _.key.name !== "fullPath" && _.key.name !== "path" : !0), y = [
|
|
26
26
|
e.objectProperty(
|
|
27
27
|
e.identifier("moduleId"),
|
|
28
28
|
e.stringLiteral(o)
|
|
@@ -70,10 +70,10 @@ function W(p, o, n, i) {
|
|
|
70
70
|
);
|
|
71
71
|
l.program.body.unshift(c);
|
|
72
72
|
}
|
|
73
|
-
return
|
|
73
|
+
return v(l, { retainLines: !0 }).code;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
const n = h(
|
|
75
|
+
function B(u, o) {
|
|
76
|
+
const n = h(u, {
|
|
77
77
|
sourceType: "module",
|
|
78
78
|
plugins: ["typescript", "jsx"]
|
|
79
79
|
});
|
|
@@ -81,13 +81,13 @@ function J(p, o) {
|
|
|
81
81
|
CallExpression(l) {
|
|
82
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
83
|
if (!a && !s) return;
|
|
84
|
-
const c = l.node.arguments, r = e.stringLiteral(o),
|
|
85
|
-
e.isStringLiteral(
|
|
84
|
+
const c = l.node.arguments, r = e.stringLiteral(o), p = c[0];
|
|
85
|
+
e.isStringLiteral(p) && p.value.includes("/") || (l.node.arguments = [r, ...c]);
|
|
86
86
|
}
|
|
87
|
-
}),
|
|
87
|
+
}), v(n, { retainLines: !0 }).code;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
const n = h(
|
|
89
|
+
function M(u, o) {
|
|
90
|
+
const n = h(u, {
|
|
91
91
|
sourceType: "module",
|
|
92
92
|
plugins: ["typescript", "jsx"]
|
|
93
93
|
});
|
|
@@ -101,13 +101,13 @@ function B(p, o) {
|
|
|
101
101
|
if (!s.startsWith("action_")) return;
|
|
102
102
|
const c = s.replace("action_", ""), r = a.init;
|
|
103
103
|
if (!e.isArrowFunctionExpression(r) || !r.async) return;
|
|
104
|
-
const
|
|
105
|
-
r.body = e.blockStatement([e.returnStatement(f)]),
|
|
104
|
+
const p = r.params, f = H(o, c, p);
|
|
105
|
+
r.body = e.blockStatement([e.returnStatement(f)]), G(r, p);
|
|
106
106
|
}
|
|
107
|
-
}),
|
|
107
|
+
}), v(n, { retainLines: !0 }).code;
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
const i = `/_action/${
|
|
109
|
+
function H(u, o, n) {
|
|
110
|
+
const i = `/_action/${u}/${o}`;
|
|
111
111
|
return n.length === 0 ? e.callExpression(
|
|
112
112
|
e.memberExpression(
|
|
113
113
|
e.callExpression(e.identifier("fetch"), [
|
|
@@ -176,7 +176,7 @@ function M(p, o, n) {
|
|
|
176
176
|
]
|
|
177
177
|
);
|
|
178
178
|
}
|
|
179
|
-
function
|
|
179
|
+
function G(u, o) {
|
|
180
180
|
if (o.length === 0) return;
|
|
181
181
|
const n = o[0];
|
|
182
182
|
if (e.isObjectPattern(n)) {
|
|
@@ -199,11 +199,11 @@ function H(p, o) {
|
|
|
199
199
|
e.tsTypeAnnotation(i)
|
|
200
200
|
)
|
|
201
201
|
])
|
|
202
|
-
)),
|
|
202
|
+
)), u.params = [t];
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
function
|
|
206
|
-
const n = h(
|
|
205
|
+
function z(u, o) {
|
|
206
|
+
const n = h(u, {
|
|
207
207
|
sourceType: "module",
|
|
208
208
|
plugins: ["typescript", "jsx"]
|
|
209
209
|
});
|
|
@@ -227,10 +227,10 @@ function G(p, o) {
|
|
|
227
227
|
)
|
|
228
228
|
]), a.id.typeAnnotation = null;
|
|
229
229
|
}
|
|
230
|
-
}),
|
|
230
|
+
}), v(n, { retainLines: !0 }).code;
|
|
231
231
|
}
|
|
232
|
-
function
|
|
233
|
-
const n = h(
|
|
232
|
+
function Y(u, o) {
|
|
233
|
+
const n = h(u, {
|
|
234
234
|
sourceType: "module",
|
|
235
235
|
plugins: ["typescript", "jsx"]
|
|
236
236
|
});
|
|
@@ -254,10 +254,10 @@ function z(p, o) {
|
|
|
254
254
|
)
|
|
255
255
|
]), a.id.typeAnnotation = null;
|
|
256
256
|
}
|
|
257
|
-
}),
|
|
257
|
+
}), v(n, { retainLines: !0 }).code;
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
const o = h(
|
|
259
|
+
function X(u) {
|
|
260
|
+
const o = h(u, {
|
|
261
261
|
sourceType: "module",
|
|
262
262
|
plugins: ["typescript", "jsx"]
|
|
263
263
|
});
|
|
@@ -268,14 +268,14 @@ function Y(p) {
|
|
|
268
268
|
const t = l.declarations[0];
|
|
269
269
|
!t || !e.isIdentifier(t.id) || t.id.name === "loader" && i.remove();
|
|
270
270
|
}
|
|
271
|
-
}),
|
|
271
|
+
}), v(o, { retainLines: !0 }).code;
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
const o = h(
|
|
273
|
+
function q(u) {
|
|
274
|
+
const o = h(u, {
|
|
275
275
|
sourceType: "module",
|
|
276
276
|
plugins: ["typescript", "jsx"]
|
|
277
277
|
}), n = /* @__PURE__ */ new Set();
|
|
278
|
-
|
|
278
|
+
S(o.program, n);
|
|
279
279
|
let i = !1;
|
|
280
280
|
return m(o, {
|
|
281
281
|
ImportDeclaration(t) {
|
|
@@ -284,10 +284,10 @@ function X(p) {
|
|
|
284
284
|
const s = a.filter((c) => n.has(c.local.name));
|
|
285
285
|
s.length !== a.length && (i = !0, s.length === 0 ? t.remove() : t.node.specifiers = s);
|
|
286
286
|
}
|
|
287
|
-
}), i ?
|
|
287
|
+
}), i ? v(o, { retainLines: !0 }).code : u;
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
const o = h(
|
|
289
|
+
function K(u) {
|
|
290
|
+
const o = h(u, {
|
|
291
291
|
sourceType: "module",
|
|
292
292
|
plugins: ["typescript", "jsx"]
|
|
293
293
|
}), n = [];
|
|
@@ -295,23 +295,23 @@ function q(p) {
|
|
|
295
295
|
ObjectProperty(s) {
|
|
296
296
|
e.isIdentifier(s.node.key, { name: "middlewares" }) && (n.push(s.node.value), s.remove());
|
|
297
297
|
}
|
|
298
|
-
}), n.length === 0) return
|
|
298
|
+
}), n.length === 0) return u;
|
|
299
299
|
const i = /* @__PURE__ */ new Set();
|
|
300
300
|
for (const s of n)
|
|
301
|
-
|
|
301
|
+
S(s, i);
|
|
302
302
|
const l = /* @__PURE__ */ new Set();
|
|
303
|
-
|
|
303
|
+
S(o.program, l);
|
|
304
304
|
const t = /* @__PURE__ */ new Set();
|
|
305
305
|
for (const s of i)
|
|
306
306
|
l.has(s) || t.add(s);
|
|
307
307
|
return t.size > 0 && m(o, {
|
|
308
308
|
ImportDeclaration(s) {
|
|
309
|
-
const c = s.node.specifiers, r = c.filter((
|
|
309
|
+
const c = s.node.specifiers, r = c.filter((p) => !t.has(p.local.name));
|
|
310
310
|
r.length === 0 ? s.remove() : r.length !== c.length && (s.node.specifiers = r);
|
|
311
311
|
}
|
|
312
|
-
}),
|
|
312
|
+
}), v(o, { retainLines: !0 }).code;
|
|
313
313
|
}
|
|
314
|
-
function
|
|
314
|
+
function S(u, o) {
|
|
315
315
|
const n = (i) => {
|
|
316
316
|
if (!(!i || typeof i != "object")) {
|
|
317
317
|
if (Array.isArray(i)) {
|
|
@@ -339,60 +339,60 @@ function x(p, o) {
|
|
|
339
339
|
l === "loc" || l === "start" || l === "end" || l === "leadingComments" || l === "trailingComments" || l === "innerComments" || n(i[l]);
|
|
340
340
|
}
|
|
341
341
|
};
|
|
342
|
-
n(
|
|
342
|
+
n(u);
|
|
343
343
|
}
|
|
344
|
-
function
|
|
345
|
-
for (const o of
|
|
344
|
+
function Q(u) {
|
|
345
|
+
for (const o of u.properties)
|
|
346
346
|
if (e.isObjectProperty(o) && e.isIdentifier(o.key) && o.key.name === "handler")
|
|
347
347
|
return !0;
|
|
348
348
|
return !1;
|
|
349
349
|
}
|
|
350
|
-
function
|
|
351
|
-
for (const o of
|
|
350
|
+
function Z(u) {
|
|
351
|
+
for (const o of u.properties)
|
|
352
352
|
if (e.isObjectProperty(o) && e.isIdentifier(o.key) && o.key.name === "children" && e.isArrayExpression(o.value))
|
|
353
353
|
return o.value;
|
|
354
354
|
return null;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
357
|
-
const o = h(
|
|
356
|
+
function ee(u) {
|
|
357
|
+
const o = h(u, {
|
|
358
358
|
sourceType: "module",
|
|
359
359
|
plugins: ["typescript", "jsx"]
|
|
360
360
|
}), n = [], i = (c) => {
|
|
361
361
|
for (let r = c.elements.length - 1; r >= 0; r--) {
|
|
362
|
-
const
|
|
363
|
-
if (!e.isObjectExpression(
|
|
364
|
-
if (
|
|
365
|
-
n.push(
|
|
362
|
+
const p = c.elements[r];
|
|
363
|
+
if (!e.isObjectExpression(p)) continue;
|
|
364
|
+
if (Q(p)) {
|
|
365
|
+
n.push(p), c.elements.splice(r, 1);
|
|
366
366
|
continue;
|
|
367
367
|
}
|
|
368
|
-
const f =
|
|
368
|
+
const f = Z(p);
|
|
369
369
|
f && i(f);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
372
|
if (m(o, {
|
|
373
373
|
ExportDefaultDeclaration(c) {
|
|
374
374
|
const r = c.node.declaration;
|
|
375
|
-
let
|
|
376
|
-
e.isArrayExpression(r) ?
|
|
375
|
+
let p = null;
|
|
376
|
+
e.isArrayExpression(r) ? p = r : (e.isTSSatisfiesExpression(r) && e.isArrayExpression(r.expression) || e.isTSAsExpression(r) && e.isArrayExpression(r.expression)) && (p = r.expression), p && i(p);
|
|
377
377
|
}
|
|
378
|
-
}), n.length === 0) return
|
|
378
|
+
}), n.length === 0) return u;
|
|
379
379
|
const l = /* @__PURE__ */ new Set();
|
|
380
380
|
for (const c of n)
|
|
381
|
-
|
|
381
|
+
S(c, l);
|
|
382
382
|
const t = /* @__PURE__ */ new Set();
|
|
383
|
-
|
|
383
|
+
S(o.program, t);
|
|
384
384
|
const a = /* @__PURE__ */ new Set();
|
|
385
385
|
for (const c of l)
|
|
386
386
|
t.has(c) || a.add(c);
|
|
387
387
|
return a.size > 0 && m(o, {
|
|
388
388
|
ImportDeclaration(c) {
|
|
389
|
-
const r = c.node.specifiers,
|
|
390
|
-
|
|
389
|
+
const r = c.node.specifiers, p = r.filter((f) => !a.has(f.local.name));
|
|
390
|
+
p.length === 0 ? c.remove() : p.length !== r.length && (c.node.specifiers = p);
|
|
391
391
|
}
|
|
392
|
-
}),
|
|
392
|
+
}), v(o, { retainLines: !0 }).code;
|
|
393
393
|
}
|
|
394
|
-
function A(
|
|
395
|
-
const o = h(
|
|
394
|
+
function A(u) {
|
|
395
|
+
const o = h(u, {
|
|
396
396
|
sourceType: "module",
|
|
397
397
|
plugins: ["typescript", "jsx"]
|
|
398
398
|
}), n = /* @__PURE__ */ new Map();
|
|
@@ -421,14 +421,14 @@ function A(p) {
|
|
|
421
421
|
}
|
|
422
422
|
return l;
|
|
423
423
|
}
|
|
424
|
-
function D(
|
|
425
|
-
for (const i of
|
|
424
|
+
function D(u, o, n) {
|
|
425
|
+
for (const i of u) {
|
|
426
426
|
if (!e.isObjectExpression(i)) continue;
|
|
427
427
|
let l = "", t = o, a = null, s = null;
|
|
428
428
|
for (const c of i.properties) {
|
|
429
429
|
if (!e.isObjectProperty(c)) continue;
|
|
430
|
-
const r = c.key,
|
|
431
|
-
|
|
430
|
+
const r = c.key, p = e.isIdentifier(r) ? r.name : null;
|
|
431
|
+
p === "path" && e.isStringLiteral(c.value) && (l = c.value.value, l && !l.startsWith("/") ? t = o + "/" + l : t = o + l), p === "module" && e.isIdentifier(c.value) && (a = c.value.name), p === "children" && e.isArrayExpression(c.value) && (s = c.value);
|
|
432
432
|
}
|
|
433
433
|
if (a) {
|
|
434
434
|
const r = !s && l === "/" ? o || "/" : t;
|
|
@@ -440,10 +440,10 @@ function D(p, o, n) {
|
|
|
440
440
|
s && D(s.elements, t, n);
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
const
|
|
444
|
-
function
|
|
443
|
+
const E = "virtual:velo/server-entry", b = "virtual:velo/client-entry", P = "\0" + E, N = "\0" + b;
|
|
444
|
+
function te(u, o) {
|
|
445
445
|
let n = d.resolve(process.cwd(), o);
|
|
446
|
-
const i =
|
|
446
|
+
const i = u.routesFile ?? "routes.tsx", l = /* @__PURE__ */ new Map();
|
|
447
447
|
return {
|
|
448
448
|
name: "velo:transform",
|
|
449
449
|
enforce: "pre",
|
|
@@ -464,21 +464,21 @@ function ee(p, o) {
|
|
|
464
464
|
if (t === s) {
|
|
465
465
|
const c = g.readFileSync(s, "utf-8"), r = A(c);
|
|
466
466
|
l.clear();
|
|
467
|
-
for (const [
|
|
468
|
-
l.set(
|
|
467
|
+
for (const [p, f] of r)
|
|
468
|
+
l.set(p, f);
|
|
469
469
|
return a.ws.send({ type: "full-reload" }), [];
|
|
470
470
|
}
|
|
471
471
|
},
|
|
472
472
|
resolveId(t) {
|
|
473
|
-
return t ===
|
|
473
|
+
return t === E || t.endsWith(E) ? P : t === b || t.endsWith(b) || t === "/__velo_client.js" ? N : null;
|
|
474
474
|
},
|
|
475
475
|
load(t) {
|
|
476
|
-
const a =
|
|
476
|
+
const a = u.routesFile ?? "routes.tsx", s = u.serverInit ?? "server.tsx", c = u.clientInit ?? "client.tsx", r = d.join(n, a).replace(/\.tsx?$/, ".js"), p = d.join(n, s).replace(/\.tsx?$/, ".js"), f = d.join(n, c).replace(/\.tsx?$/, ".js");
|
|
477
477
|
return t === P ? `
|
|
478
478
|
globalThis.__veloBuildHash = __VELO_BUILD_HASH__;
|
|
479
479
|
globalThis.__veloClientJs = __VELO_CLIENT_JS__;
|
|
480
480
|
globalThis.__veloClientCss = __VELO_CLIENT_CSS__;
|
|
481
|
-
import "${
|
|
481
|
+
import "${p}";
|
|
482
482
|
import routes from "${r}";
|
|
483
483
|
import { startServer } from "@mauroandre/velojs/server";
|
|
484
484
|
|
|
@@ -495,39 +495,39 @@ startClient({ routes });
|
|
|
495
495
|
transform(t, a, s) {
|
|
496
496
|
const c = s?.ssr === !0;
|
|
497
497
|
if (a.startsWith("\0") || a.includes("/.velojs/") || !a.endsWith(".tsx") && !a.endsWith(".ts") || !a.startsWith(n)) return null;
|
|
498
|
-
let r = t,
|
|
498
|
+
let r = t, p = !1;
|
|
499
499
|
const f = /middlewares:\s*\[/.test(t), y = /export\s+(const|function)\s+Component/.test(
|
|
500
500
|
t
|
|
501
|
-
),
|
|
502
|
-
if (!c && f && (r =
|
|
503
|
-
const
|
|
504
|
-
r =
|
|
501
|
+
), _ = /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 = K(r), p = !0), !c && F && a === V && (r = ee(r), p = !0), y || _ || C || I || T || w || k) {
|
|
503
|
+
const x = d.relative(n, a).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), O = l.get(x);
|
|
504
|
+
r = J(r, x, O?.fullPath, O?.path), r = B(r, x), c || (r = M(
|
|
505
505
|
r,
|
|
506
|
-
|
|
507
|
-
)), !c && I && (r =
|
|
506
|
+
x
|
|
507
|
+
)), !c && I && (r = z(
|
|
508
508
|
r,
|
|
509
|
-
|
|
510
|
-
)), !c && T && (r =
|
|
509
|
+
x
|
|
510
|
+
)), !c && T && (r = Y(
|
|
511
511
|
r,
|
|
512
|
-
|
|
513
|
-
)), c || (r =
|
|
512
|
+
x
|
|
513
|
+
)), c || (r = X(r)), c || (r = q(r)), p = !0;
|
|
514
514
|
}
|
|
515
|
-
return
|
|
515
|
+
return p ? {
|
|
516
516
|
code: r,
|
|
517
517
|
map: null
|
|
518
518
|
} : null;
|
|
519
519
|
}
|
|
520
520
|
};
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function re(u) {
|
|
523
523
|
return {
|
|
524
524
|
name: "velo:config",
|
|
525
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) ||
|
|
526
|
+
const i = n === "server", l = n === "development", t = !!process.env.VELO_STATIC, a = o.server?.port ?? (Number(process.env.PORT) || u.port || 3e3);
|
|
527
527
|
let s = "client.js", c = "client.css";
|
|
528
528
|
if (i)
|
|
529
529
|
try {
|
|
530
|
-
const
|
|
530
|
+
const p = d.resolve(process.cwd(), "dist/client/.vite/manifest.json"), y = JSON.parse(g.readFileSync(p, "utf-8"))[b];
|
|
531
531
|
y && (s = y.file || s, y.css?.[0] && (c = y.css[0]));
|
|
532
532
|
} catch {
|
|
533
533
|
}
|
|
@@ -541,7 +541,7 @@ function te(p) {
|
|
|
541
541
|
__VELO_CLIENT_CSS__: JSON.stringify(c),
|
|
542
542
|
// Baked into the server bundle as startServer's port fallback.
|
|
543
543
|
// null when unset → startServer falls back to PORT env / 3000.
|
|
544
|
-
__VELO_CONFIG_PORT__: JSON.stringify(
|
|
544
|
+
__VELO_CONFIG_PORT__: JSON.stringify(u.port ?? null)
|
|
545
545
|
},
|
|
546
546
|
resolve: {
|
|
547
547
|
alias: {
|
|
@@ -554,7 +554,7 @@ function te(p) {
|
|
|
554
554
|
}
|
|
555
555
|
};
|
|
556
556
|
return i ? r.build = {
|
|
557
|
-
ssr:
|
|
557
|
+
ssr: E,
|
|
558
558
|
outDir: "dist",
|
|
559
559
|
emptyOutDir: !1,
|
|
560
560
|
copyPublicDir: !1,
|
|
@@ -567,22 +567,22 @@ function te(p) {
|
|
|
567
567
|
manifest: !0,
|
|
568
568
|
outDir: "dist/client",
|
|
569
569
|
rollupOptions: {
|
|
570
|
-
input:
|
|
570
|
+
input: b,
|
|
571
571
|
output: {
|
|
572
572
|
entryFileNames: "client.[hash].js",
|
|
573
|
-
assetFileNames: (
|
|
573
|
+
assetFileNames: (p) => p.names?.[0]?.endsWith(".css") ? "client.[hash].css" : "[name].[hash][extname]"
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
576
|
}), r;
|
|
577
577
|
}
|
|
578
578
|
};
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function ne() {
|
|
581
581
|
return {
|
|
582
582
|
name: "velo:static-url",
|
|
583
583
|
apply: "build",
|
|
584
584
|
enforce: "post",
|
|
585
|
-
generateBundle(
|
|
585
|
+
generateBundle(u, o) {
|
|
586
586
|
const n = process.env.STATIC_BASE_URL || "";
|
|
587
587
|
if (n)
|
|
588
588
|
for (const i of Object.values(o))
|
|
@@ -593,13 +593,13 @@ function re() {
|
|
|
593
593
|
}
|
|
594
594
|
};
|
|
595
595
|
}
|
|
596
|
-
function
|
|
596
|
+
function ie(u, o) {
|
|
597
597
|
let n = "", i = "", l = !1, t = null;
|
|
598
598
|
function a() {
|
|
599
599
|
if (!n) return;
|
|
600
600
|
const s = d.resolve(n, o);
|
|
601
601
|
if (!g.existsSync(s)) return;
|
|
602
|
-
const c =
|
|
602
|
+
const c = W(s), r = d.join(n, ".velojs");
|
|
603
603
|
g.mkdirSync(r, { recursive: !0 }), g.writeFileSync(
|
|
604
604
|
d.join(r, "graph.json"),
|
|
605
605
|
JSON.stringify(c)
|
|
@@ -616,45 +616,54 @@ function ne(p, o) {
|
|
|
616
616
|
configureServer(s) {
|
|
617
617
|
a(), l = !0;
|
|
618
618
|
const c = d.resolve(n, o);
|
|
619
|
-
s.watcher.on("all", (r,
|
|
620
|
-
l &&
|
|
619
|
+
s.watcher.on("all", (r, p) => {
|
|
620
|
+
l && p.startsWith(c) && (t && clearTimeout(t), t = setTimeout(() => a(), 500));
|
|
621
621
|
});
|
|
622
622
|
}
|
|
623
623
|
};
|
|
624
624
|
}
|
|
625
|
-
function
|
|
626
|
-
const o = p ?? {}, n = o.appDirectory ?? "./app";
|
|
625
|
+
function se(u) {
|
|
627
626
|
return [
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
627
|
+
...U.exclude,
|
|
628
|
+
/.*\.mjs$/,
|
|
629
|
+
...u.devServerExclude ?? []
|
|
630
|
+
];
|
|
631
|
+
}
|
|
632
|
+
function ye(u) {
|
|
633
|
+
const o = u ?? {}, n = o.appDirectory ?? "./app";
|
|
634
|
+
return [
|
|
635
|
+
re(o),
|
|
636
|
+
te(o, n),
|
|
637
|
+
ne(),
|
|
638
|
+
ie(o, n),
|
|
632
639
|
R(),
|
|
633
640
|
$({
|
|
634
|
-
entry:
|
|
641
|
+
entry: E,
|
|
642
|
+
exclude: se(o)
|
|
635
643
|
}),
|
|
636
|
-
|
|
644
|
+
oe()
|
|
637
645
|
];
|
|
638
646
|
}
|
|
639
|
-
function
|
|
647
|
+
function oe() {
|
|
640
648
|
return {
|
|
641
649
|
name: "velo:ws-bridge",
|
|
642
|
-
configureServer(
|
|
643
|
-
globalThis.__veloDevServer =
|
|
650
|
+
configureServer(u) {
|
|
651
|
+
globalThis.__veloDevServer = u.httpServer;
|
|
644
652
|
}
|
|
645
653
|
};
|
|
646
654
|
}
|
|
647
655
|
export {
|
|
648
656
|
A as buildFullPathMap,
|
|
649
657
|
D as collectFullPaths,
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
658
|
+
se as devServerExcludeFor,
|
|
659
|
+
J as injectMetadata,
|
|
660
|
+
q as pruneClientOnlyImports,
|
|
661
|
+
ee as removeEndpointRoutes,
|
|
662
|
+
X as removeLoaders,
|
|
663
|
+
K as removeMiddlewares,
|
|
664
|
+
M as transformActionsForClient,
|
|
665
|
+
B as transformLoaderFunctions,
|
|
666
|
+
Y as transformSocketsForClient,
|
|
667
|
+
z as transformStreamsForClient,
|
|
668
|
+
ye as veloPlugin
|
|
660
669
|
};
|