@mauroandre/velojs 0.0.59 → 0.0.61
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 +182 -1
- package/agent/AGENTS.md +84 -0
- package/agent/skills/velojs-actions/SKILL.md +32 -0
- package/agent/skills/velojs-hooks/SKILL.md +26 -0
- package/agent/skills/velojs-live-actions/SKILL.md +211 -0
- package/agent/skills/velojs-telemetry/SKILL.md +6 -1
- package/agent/skills/velojs-type-reference/SKILL.md +1 -0
- package/agent/skills/velojs-vite-plugin/SKILL.md +51 -2
- package/dist/channels.d.ts +117 -11
- package/dist/channels.js +459 -284
- package/dist/config.d.ts +8 -0
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.js +34 -32
- package/dist/leak-diagnostic.d.ts +77 -0
- package/dist/leak-diagnostic.js +14 -0
- package/dist/live-action.d.ts +86 -0
- package/dist/live-action.js +52 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +165 -143
- package/dist/telemetry-cli.d.ts +1 -0
- package/dist/telemetry-cli.js +116 -113
- package/dist/telemetry.d.ts +3 -3
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +500 -453
- package/dist/testing/subscription.d.ts +7 -0
- package/dist/testing/types.d.ts +43 -2
- package/dist/types.d.ts +12 -0
- package/dist/vite.d.ts +47 -1
- package/dist/vite.js +869 -401
- package/package.json +1 -1
package/dist/vite.js
CHANGED
|
@@ -1,115 +1,128 @@
|
|
|
1
|
-
import
|
|
1
|
+
import b from "node:fs";
|
|
2
2
|
import m from "node:path";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { parse as v } from "@babel/parser";
|
|
7
|
-
import P from "@babel/traverse";
|
|
8
|
-
import D from "@babel/generator";
|
|
3
|
+
import { builtinModules as se } from "node:module";
|
|
4
|
+
import { parse as O } from "@babel/parser";
|
|
5
|
+
import N from "@babel/traverse";
|
|
9
6
|
import * as e from "@babel/types";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
import { loadEnv as ie } from "vite";
|
|
8
|
+
import oe from "@preact/preset-vite";
|
|
9
|
+
import ae, { defaultOptions as ce } from "@hono/vite-dev-server";
|
|
10
|
+
import R from "@babel/generator";
|
|
11
|
+
import { buildGraph as le } from "./graph.js";
|
|
12
|
+
const w = typeof N == "function" ? N : N.default, A = typeof R == "function" ? R : R.default;
|
|
13
|
+
function ue(r, n, t, s) {
|
|
14
|
+
const o = O(r, {
|
|
14
15
|
sourceType: "module",
|
|
15
16
|
plugins: ["typescript", "jsx"]
|
|
16
17
|
});
|
|
17
|
-
let
|
|
18
|
-
if (
|
|
18
|
+
let c = !1;
|
|
19
|
+
if (w(o, {
|
|
19
20
|
// Procura: export const metadata = { ... }
|
|
20
|
-
ExportNamedDeclaration(
|
|
21
|
-
const
|
|
22
|
-
if (e.isVariableDeclaration(
|
|
23
|
-
const l =
|
|
21
|
+
ExportNamedDeclaration(a) {
|
|
22
|
+
const u = a.node.declaration;
|
|
23
|
+
if (e.isVariableDeclaration(u) && u.declarations.length === 1) {
|
|
24
|
+
const l = u.declarations[0];
|
|
24
25
|
if (l && e.isIdentifier(l.id, { name: "metadata" }) && e.isObjectExpression(l.init)) {
|
|
25
|
-
|
|
26
|
-
const d = l.init.properties.filter((
|
|
26
|
+
c = !0;
|
|
27
|
+
const d = l.init.properties.filter((h) => e.isObjectProperty(h) && e.isIdentifier(h.key) ? h.key.name !== "moduleId" && h.key.name !== "fullPath" && h.key.name !== "path" : !0), y = [
|
|
27
28
|
e.objectProperty(
|
|
28
29
|
e.identifier("moduleId"),
|
|
29
30
|
e.stringLiteral(n)
|
|
30
31
|
)
|
|
31
32
|
];
|
|
32
|
-
|
|
33
|
+
t !== void 0 && y.push(
|
|
33
34
|
e.objectProperty(
|
|
34
35
|
e.identifier("fullPath"),
|
|
35
|
-
e.stringLiteral(
|
|
36
|
+
e.stringLiteral(t)
|
|
36
37
|
)
|
|
37
|
-
), s !== void 0 &&
|
|
38
|
+
), s !== void 0 && y.push(
|
|
38
39
|
e.objectProperty(
|
|
39
40
|
e.identifier("path"),
|
|
40
41
|
e.stringLiteral(s)
|
|
41
42
|
)
|
|
42
|
-
), l.init.properties = [...
|
|
43
|
+
), l.init.properties = [...y, ...d];
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
}), !
|
|
47
|
-
const
|
|
47
|
+
}), !c) {
|
|
48
|
+
const a = [
|
|
48
49
|
e.objectProperty(
|
|
49
50
|
e.identifier("moduleId"),
|
|
50
51
|
e.stringLiteral(n)
|
|
51
52
|
)
|
|
52
53
|
];
|
|
53
|
-
|
|
54
|
+
t !== void 0 && a.push(
|
|
54
55
|
e.objectProperty(
|
|
55
56
|
e.identifier("fullPath"),
|
|
56
|
-
e.stringLiteral(
|
|
57
|
+
e.stringLiteral(t)
|
|
57
58
|
)
|
|
58
|
-
), s !== void 0 &&
|
|
59
|
+
), s !== void 0 && a.push(
|
|
59
60
|
e.objectProperty(
|
|
60
61
|
e.identifier("path"),
|
|
61
62
|
e.stringLiteral(s)
|
|
62
63
|
)
|
|
63
64
|
);
|
|
64
|
-
const
|
|
65
|
+
const u = e.exportNamedDeclaration(
|
|
65
66
|
e.variableDeclaration("const", [
|
|
66
67
|
e.variableDeclarator(
|
|
67
68
|
e.identifier("metadata"),
|
|
68
|
-
e.objectExpression(
|
|
69
|
+
e.objectExpression(a)
|
|
69
70
|
)
|
|
70
71
|
])
|
|
71
72
|
);
|
|
72
|
-
|
|
73
|
+
o.program.body.unshift(u);
|
|
73
74
|
}
|
|
74
|
-
return
|
|
75
|
+
return A(o, { retainLines: !0 }).code;
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
77
|
+
function pe(r, n) {
|
|
78
|
+
const t = O(r, {
|
|
78
79
|
sourceType: "module",
|
|
79
80
|
plugins: ["typescript", "jsx"]
|
|
80
81
|
});
|
|
81
|
-
return
|
|
82
|
-
CallExpression(
|
|
83
|
-
const
|
|
84
|
-
if (!
|
|
85
|
-
const
|
|
86
|
-
e.isStringLiteral(
|
|
82
|
+
return w(t, {
|
|
83
|
+
CallExpression(o) {
|
|
84
|
+
const c = o.node.callee, i = e.isIdentifier(c, { name: "Loader" }) || e.isTSInstantiationExpression(c) && e.isIdentifier(c.expression, { name: "Loader" }), a = e.isIdentifier(c, { name: "useLoader" }) || e.isTSInstantiationExpression(c) && e.isIdentifier(c.expression, { name: "useLoader" });
|
|
85
|
+
if (!i && !a) return;
|
|
86
|
+
const u = o.node.arguments, l = e.stringLiteral(n), p = u[0];
|
|
87
|
+
e.isStringLiteral(p) && p.value.includes("/") || (o.node.arguments = [l, ...u]);
|
|
87
88
|
}
|
|
88
|
-
}),
|
|
89
|
+
}), A(t, { retainLines: !0 }).code;
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
-
const
|
|
91
|
+
function fe(r, n, t) {
|
|
92
|
+
const s = O(r, {
|
|
92
93
|
sourceType: "module",
|
|
93
94
|
plugins: ["typescript", "jsx"]
|
|
94
95
|
});
|
|
95
|
-
return
|
|
96
|
+
return w(s, {
|
|
96
97
|
ExportNamedDeclaration(c) {
|
|
97
|
-
const
|
|
98
|
-
if (!e.isVariableDeclaration(
|
|
99
|
-
const
|
|
100
|
-
if (!
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
103
|
-
const
|
|
104
|
-
if (!e.isArrowFunctionExpression(
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
98
|
+
const i = c.node.declaration;
|
|
99
|
+
if (!e.isVariableDeclaration(i)) return;
|
|
100
|
+
const a = i.declarations[0];
|
|
101
|
+
if (!a || !e.isIdentifier(a.id)) return;
|
|
102
|
+
const u = a.id.name;
|
|
103
|
+
if (!u.startsWith("action_")) return;
|
|
104
|
+
const l = u.replace("action_", ""), p = a.init;
|
|
105
|
+
if (!e.isArrowFunctionExpression(p) || !p.async) return;
|
|
106
|
+
const d = p.params, y = de(n, l, d);
|
|
107
|
+
p.body = e.blockStatement([e.returnStatement(y)]), me(p, d), t?.has(l) && (a.init = e.callExpression(e.identifier("Object.assign"), [
|
|
108
|
+
p,
|
|
109
|
+
e.objectExpression([
|
|
110
|
+
e.objectProperty(
|
|
111
|
+
e.identifier("__isVeloLiveAction"),
|
|
112
|
+
e.booleanLiteral(!0)
|
|
113
|
+
),
|
|
114
|
+
e.objectProperty(
|
|
115
|
+
e.identifier("__path"),
|
|
116
|
+
e.stringLiteral(`/_live/${n}/${l}`)
|
|
117
|
+
)
|
|
118
|
+
])
|
|
119
|
+
]), a.id.typeAnnotation = null);
|
|
120
|
+
}
|
|
121
|
+
}), A(s, { retainLines: !0 }).code;
|
|
122
|
+
}
|
|
123
|
+
function de(r, n, t) {
|
|
124
|
+
const s = `/_action/${r}/${n}`;
|
|
125
|
+
return t.length === 0 ? e.callExpression(
|
|
113
126
|
e.memberExpression(
|
|
114
127
|
e.callExpression(e.identifier("fetch"), [
|
|
115
128
|
e.stringLiteral(s),
|
|
@@ -177,47 +190,47 @@ function ee(p, n, r) {
|
|
|
177
190
|
]
|
|
178
191
|
);
|
|
179
192
|
}
|
|
180
|
-
function
|
|
193
|
+
function me(r, n) {
|
|
181
194
|
if (n.length === 0) return;
|
|
182
|
-
const
|
|
183
|
-
if (e.isObjectPattern(
|
|
195
|
+
const t = n[0];
|
|
196
|
+
if (e.isObjectPattern(t)) {
|
|
184
197
|
let s = null;
|
|
185
|
-
if (e.isTSTypeAnnotation(
|
|
186
|
-
const
|
|
187
|
-
e.isIdentifier(
|
|
198
|
+
if (e.isTSTypeAnnotation(t.typeAnnotation) && e.isTSTypeReference(t.typeAnnotation.typeAnnotation)) {
|
|
199
|
+
const i = t.typeAnnotation.typeAnnotation;
|
|
200
|
+
e.isIdentifier(i.typeName, { name: "ActionArgs" }) && i.typeParameters?.params[0] && (s = i.typeParameters.params[0]);
|
|
188
201
|
}
|
|
189
|
-
const
|
|
202
|
+
const o = e.objectProperty(
|
|
190
203
|
e.identifier("body"),
|
|
191
204
|
e.identifier("body"),
|
|
192
205
|
!1,
|
|
193
206
|
!0
|
|
194
207
|
// shorthand
|
|
195
|
-
),
|
|
196
|
-
s && (
|
|
208
|
+
), c = e.objectPattern([o]);
|
|
209
|
+
s && (c.typeAnnotation = e.tsTypeAnnotation(
|
|
197
210
|
e.tsTypeLiteral([
|
|
198
211
|
e.tsPropertySignature(
|
|
199
212
|
e.identifier("body"),
|
|
200
213
|
e.tsTypeAnnotation(s)
|
|
201
214
|
)
|
|
202
215
|
])
|
|
203
|
-
)),
|
|
216
|
+
)), r.params = [c];
|
|
204
217
|
}
|
|
205
218
|
}
|
|
206
|
-
function
|
|
207
|
-
const
|
|
219
|
+
function he(r, n) {
|
|
220
|
+
const t = O(r, {
|
|
208
221
|
sourceType: "module",
|
|
209
222
|
plugins: ["typescript", "jsx"]
|
|
210
223
|
});
|
|
211
|
-
return
|
|
212
|
-
ExportNamedDeclaration(
|
|
213
|
-
const
|
|
214
|
-
if (!e.isVariableDeclaration(
|
|
215
|
-
const
|
|
216
|
-
if (!
|
|
217
|
-
const
|
|
218
|
-
if (!
|
|
219
|
-
const
|
|
220
|
-
|
|
224
|
+
return w(t, {
|
|
225
|
+
ExportNamedDeclaration(o) {
|
|
226
|
+
const c = o.node.declaration;
|
|
227
|
+
if (!e.isVariableDeclaration(c)) return;
|
|
228
|
+
const i = c.declarations[0];
|
|
229
|
+
if (!i || !e.isIdentifier(i.id)) return;
|
|
230
|
+
const a = i.id.name;
|
|
231
|
+
if (!a.startsWith("stream_")) return;
|
|
232
|
+
const u = a.replace("stream_", ""), l = `/_event/${n}/${u}`;
|
|
233
|
+
i.init = e.objectExpression([
|
|
221
234
|
e.objectProperty(
|
|
222
235
|
e.identifier("__isVeloEventStream"),
|
|
223
236
|
e.booleanLiteral(!0)
|
|
@@ -226,25 +239,25 @@ function re(p, n) {
|
|
|
226
239
|
e.identifier("__path"),
|
|
227
240
|
e.stringLiteral(l)
|
|
228
241
|
)
|
|
229
|
-
]),
|
|
242
|
+
]), i.id.typeAnnotation = null;
|
|
230
243
|
}
|
|
231
|
-
}),
|
|
244
|
+
}), A(t, { retainLines: !0 }).code;
|
|
232
245
|
}
|
|
233
|
-
function
|
|
234
|
-
const
|
|
246
|
+
function ye(r, n) {
|
|
247
|
+
const t = O(r, {
|
|
235
248
|
sourceType: "module",
|
|
236
249
|
plugins: ["typescript", "jsx"]
|
|
237
250
|
});
|
|
238
|
-
return
|
|
239
|
-
ExportNamedDeclaration(
|
|
240
|
-
const
|
|
241
|
-
if (!e.isVariableDeclaration(
|
|
242
|
-
const
|
|
243
|
-
if (!
|
|
244
|
-
const
|
|
245
|
-
if (!
|
|
246
|
-
const
|
|
247
|
-
|
|
251
|
+
return w(t, {
|
|
252
|
+
ExportNamedDeclaration(o) {
|
|
253
|
+
const c = o.node.declaration;
|
|
254
|
+
if (!e.isVariableDeclaration(c)) return;
|
|
255
|
+
const i = c.declarations[0];
|
|
256
|
+
if (!i || !e.isIdentifier(i.id)) return;
|
|
257
|
+
const a = i.id.name;
|
|
258
|
+
if (!a.startsWith("socket_")) return;
|
|
259
|
+
const u = a.replace("socket_", ""), l = `/_socket/${n}/${u}`;
|
|
260
|
+
i.init = e.objectExpression([
|
|
248
261
|
e.objectProperty(
|
|
249
262
|
e.identifier("__isVeloSocket"),
|
|
250
263
|
e.booleanLiteral(!0)
|
|
@@ -253,74 +266,74 @@ function ne(p, n) {
|
|
|
253
266
|
e.identifier("__path"),
|
|
254
267
|
e.stringLiteral(l)
|
|
255
268
|
)
|
|
256
|
-
]),
|
|
269
|
+
]), i.id.typeAnnotation = null;
|
|
257
270
|
}
|
|
258
|
-
}),
|
|
271
|
+
}), A(t, { retainLines: !0 }).code;
|
|
259
272
|
}
|
|
260
|
-
function
|
|
261
|
-
const n =
|
|
273
|
+
function ge(r) {
|
|
274
|
+
const n = O(r, {
|
|
262
275
|
sourceType: "module",
|
|
263
276
|
plugins: ["typescript", "jsx"]
|
|
264
277
|
});
|
|
265
|
-
return
|
|
278
|
+
return w(n, {
|
|
266
279
|
ExportNamedDeclaration(s) {
|
|
267
|
-
const
|
|
268
|
-
if (!e.isVariableDeclaration(
|
|
269
|
-
const
|
|
270
|
-
!
|
|
280
|
+
const o = s.node.declaration;
|
|
281
|
+
if (!e.isVariableDeclaration(o)) return;
|
|
282
|
+
const c = o.declarations[0];
|
|
283
|
+
!c || !e.isIdentifier(c.id) || c.id.name === "loader" && s.remove();
|
|
271
284
|
}
|
|
272
|
-
}),
|
|
285
|
+
}), A(n, { retainLines: !0 }).code;
|
|
273
286
|
}
|
|
274
|
-
function
|
|
275
|
-
const n =
|
|
287
|
+
function ve(r) {
|
|
288
|
+
const n = O(r, {
|
|
276
289
|
sourceType: "module",
|
|
277
290
|
plugins: ["typescript", "jsx"]
|
|
278
|
-
}),
|
|
279
|
-
|
|
291
|
+
}), t = /* @__PURE__ */ new Set();
|
|
292
|
+
D(n.program, t);
|
|
280
293
|
let s = !1;
|
|
281
|
-
return
|
|
282
|
-
ImportDeclaration(
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
285
|
-
const
|
|
286
|
-
|
|
294
|
+
return w(n, {
|
|
295
|
+
ImportDeclaration(c) {
|
|
296
|
+
const i = c.node.specifiers;
|
|
297
|
+
if (i.length === 0) return;
|
|
298
|
+
const a = i.filter((u) => t.has(u.local.name));
|
|
299
|
+
a.length !== i.length && (s = !0, a.length === 0 ? c.remove() : c.node.specifiers = a);
|
|
287
300
|
}
|
|
288
|
-
}), s ?
|
|
301
|
+
}), s ? A(n, { retainLines: !0 }).code : r;
|
|
289
302
|
}
|
|
290
|
-
function
|
|
291
|
-
const n =
|
|
303
|
+
function xe(r) {
|
|
304
|
+
const n = O(r, {
|
|
292
305
|
sourceType: "module",
|
|
293
306
|
plugins: ["typescript", "jsx"]
|
|
294
|
-
}),
|
|
295
|
-
if (
|
|
296
|
-
ObjectProperty(
|
|
297
|
-
e.isIdentifier(
|
|
307
|
+
}), t = [];
|
|
308
|
+
if (w(n, {
|
|
309
|
+
ObjectProperty(a) {
|
|
310
|
+
e.isIdentifier(a.node.key, { name: "middlewares" }) && (t.push(a.node.value), a.remove());
|
|
298
311
|
}
|
|
299
|
-
}),
|
|
312
|
+
}), t.length === 0) return r;
|
|
300
313
|
const s = /* @__PURE__ */ new Set();
|
|
301
|
-
for (const
|
|
302
|
-
|
|
314
|
+
for (const a of t)
|
|
315
|
+
D(a, s);
|
|
316
|
+
const o = /* @__PURE__ */ new Set();
|
|
317
|
+
D(n.program, o);
|
|
303
318
|
const c = /* @__PURE__ */ new Set();
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
function T(p, n) {
|
|
316
|
-
const r = (s) => {
|
|
319
|
+
for (const a of s)
|
|
320
|
+
o.has(a) || c.add(a);
|
|
321
|
+
return c.size > 0 && w(n, {
|
|
322
|
+
ImportDeclaration(a) {
|
|
323
|
+
const u = a.node.specifiers, l = u.filter((p) => !c.has(p.local.name));
|
|
324
|
+
l.length === 0 ? a.remove() : l.length !== u.length && (a.node.specifiers = l);
|
|
325
|
+
}
|
|
326
|
+
}), A(n, { retainLines: !0 }).code;
|
|
327
|
+
}
|
|
328
|
+
function D(r, n) {
|
|
329
|
+
const t = (s) => {
|
|
317
330
|
if (!(!s || typeof s != "object")) {
|
|
318
331
|
if (Array.isArray(s)) {
|
|
319
|
-
for (const
|
|
332
|
+
for (const o of s) t(o);
|
|
320
333
|
return;
|
|
321
334
|
}
|
|
322
335
|
if (s.type === "Identifier") {
|
|
323
|
-
n.add(s.name), s.typeAnnotation &&
|
|
336
|
+
n.add(s.name), s.typeAnnotation && t(s.typeAnnotation);
|
|
324
337
|
return;
|
|
325
338
|
}
|
|
326
339
|
if (s.type === "JSXIdentifier") {
|
|
@@ -328,315 +341,389 @@ function T(p, n) {
|
|
|
328
341
|
return;
|
|
329
342
|
}
|
|
330
343
|
if (s.type === "MemberExpression") {
|
|
331
|
-
|
|
344
|
+
t(s.object), s.computed && t(s.property);
|
|
332
345
|
return;
|
|
333
346
|
}
|
|
334
347
|
if ((s.type === "ObjectProperty" || s.type === "ObjectMethod") && !s.computed) {
|
|
335
|
-
s.type === "ObjectProperty" ?
|
|
348
|
+
s.type === "ObjectProperty" ? t(s.value) : t(s.body);
|
|
336
349
|
return;
|
|
337
350
|
}
|
|
338
351
|
if (!(s.type === "ImportSpecifier" || s.type === "ImportDefaultSpecifier" || s.type === "ImportNamespaceSpecifier"))
|
|
339
|
-
for (const
|
|
340
|
-
|
|
352
|
+
for (const o of Object.keys(s))
|
|
353
|
+
o === "loc" || o === "start" || o === "end" || o === "leadingComments" || o === "trailingComments" || o === "innerComments" || t(s[o]);
|
|
341
354
|
}
|
|
342
355
|
};
|
|
343
|
-
r
|
|
356
|
+
t(r);
|
|
344
357
|
}
|
|
345
|
-
function
|
|
346
|
-
for (const n of
|
|
358
|
+
function Se(r) {
|
|
359
|
+
for (const n of r.properties)
|
|
347
360
|
if (e.isObjectProperty(n) && e.isIdentifier(n.key) && n.key.name === "handler")
|
|
348
361
|
return !0;
|
|
349
362
|
return !1;
|
|
350
363
|
}
|
|
351
|
-
function
|
|
352
|
-
for (const n of
|
|
364
|
+
function _e(r) {
|
|
365
|
+
for (const n of r.properties)
|
|
353
366
|
if (e.isObjectProperty(n) && e.isIdentifier(n.key) && n.key.name === "children" && e.isArrayExpression(n.value))
|
|
354
367
|
return n.value;
|
|
355
368
|
return null;
|
|
356
369
|
}
|
|
357
|
-
function
|
|
358
|
-
const n =
|
|
370
|
+
function je(r) {
|
|
371
|
+
const n = O(r, {
|
|
359
372
|
sourceType: "module",
|
|
360
373
|
plugins: ["typescript", "jsx"]
|
|
361
|
-
}),
|
|
362
|
-
for (let l =
|
|
363
|
-
const
|
|
364
|
-
if (!e.isObjectExpression(
|
|
365
|
-
if (
|
|
366
|
-
|
|
374
|
+
}), t = [], s = (u) => {
|
|
375
|
+
for (let l = u.elements.length - 1; l >= 0; l--) {
|
|
376
|
+
const p = u.elements[l];
|
|
377
|
+
if (!e.isObjectExpression(p)) continue;
|
|
378
|
+
if (Se(p)) {
|
|
379
|
+
t.push(p), u.elements.splice(l, 1);
|
|
367
380
|
continue;
|
|
368
381
|
}
|
|
369
|
-
const d =
|
|
382
|
+
const d = _e(p);
|
|
370
383
|
d && s(d);
|
|
371
384
|
}
|
|
372
385
|
};
|
|
373
|
-
if (
|
|
374
|
-
ExportDefaultDeclaration(
|
|
375
|
-
const l =
|
|
376
|
-
let
|
|
377
|
-
e.isArrayExpression(l) ?
|
|
386
|
+
if (w(n, {
|
|
387
|
+
ExportDefaultDeclaration(u) {
|
|
388
|
+
const l = u.node.declaration;
|
|
389
|
+
let p = null;
|
|
390
|
+
e.isArrayExpression(l) ? p = l : (e.isTSSatisfiesExpression(l) && e.isArrayExpression(l.expression) || e.isTSAsExpression(l) && e.isArrayExpression(l.expression)) && (p = l.expression), p && s(p);
|
|
378
391
|
}
|
|
379
|
-
}),
|
|
380
|
-
const c = /* @__PURE__ */ new Set();
|
|
381
|
-
for (const t of r)
|
|
382
|
-
T(t, c);
|
|
383
|
-
const a = /* @__PURE__ */ new Set();
|
|
384
|
-
T(n.program, a);
|
|
392
|
+
}), t.length === 0) return r;
|
|
385
393
|
const o = /* @__PURE__ */ new Set();
|
|
386
|
-
for (const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
394
|
+
for (const u of t)
|
|
395
|
+
D(u, o);
|
|
396
|
+
const c = /* @__PURE__ */ new Set();
|
|
397
|
+
D(n.program, c);
|
|
398
|
+
const i = /* @__PURE__ */ new Set();
|
|
399
|
+
for (const u of o)
|
|
400
|
+
c.has(u) || i.add(u);
|
|
401
|
+
return i.size > 0 && w(n, {
|
|
402
|
+
ImportDeclaration(u) {
|
|
403
|
+
const l = u.node.specifiers, p = l.filter((d) => !i.has(d.local.name));
|
|
404
|
+
p.length === 0 ? u.remove() : p.length !== l.length && (u.node.specifiers = p);
|
|
392
405
|
}
|
|
393
|
-
}),
|
|
406
|
+
}), A(n, { retainLines: !0 }).code;
|
|
394
407
|
}
|
|
395
|
-
function
|
|
396
|
-
const n =
|
|
408
|
+
function B(r) {
|
|
409
|
+
const n = O(r, {
|
|
397
410
|
sourceType: "module",
|
|
398
411
|
plugins: ["typescript", "jsx"]
|
|
399
|
-
}),
|
|
400
|
-
|
|
401
|
-
ImportDeclaration(
|
|
402
|
-
const
|
|
403
|
-
for (const
|
|
404
|
-
e.isImportNamespaceSpecifier(
|
|
412
|
+
}), t = /* @__PURE__ */ new Map();
|
|
413
|
+
w(n, {
|
|
414
|
+
ImportDeclaration(c) {
|
|
415
|
+
const i = c.node.source.value;
|
|
416
|
+
for (const a of c.node.specifiers)
|
|
417
|
+
e.isImportNamespaceSpecifier(a) && t.set(a.local.name, i);
|
|
405
418
|
}
|
|
406
419
|
});
|
|
407
420
|
const s = /* @__PURE__ */ new Map();
|
|
408
|
-
|
|
409
|
-
ExportDefaultDeclaration(
|
|
410
|
-
const
|
|
411
|
-
let
|
|
412
|
-
e.isArrayExpression(
|
|
421
|
+
w(n, {
|
|
422
|
+
ExportDefaultDeclaration(c) {
|
|
423
|
+
const i = c.node.declaration;
|
|
424
|
+
let a = null;
|
|
425
|
+
e.isArrayExpression(i) ? a = i : (e.isTSSatisfiesExpression(i) || e.isTSAsExpression(i)) && e.isArrayExpression(i.expression) && (a = i.expression), a && X(a.elements, "", s);
|
|
413
426
|
}
|
|
414
427
|
});
|
|
415
|
-
const
|
|
416
|
-
for (const [
|
|
417
|
-
const
|
|
418
|
-
if (
|
|
419
|
-
const
|
|
420
|
-
|
|
428
|
+
const o = /* @__PURE__ */ new Map();
|
|
429
|
+
for (const [c, i] of s) {
|
|
430
|
+
const a = t.get(c);
|
|
431
|
+
if (a) {
|
|
432
|
+
const u = a.replace(/^\.\//, "").replace(/\.(tsx?|jsx?|js)$/, "");
|
|
433
|
+
o.set(u, i);
|
|
421
434
|
}
|
|
422
435
|
}
|
|
423
|
-
return
|
|
436
|
+
return o;
|
|
424
437
|
}
|
|
425
|
-
function
|
|
426
|
-
for (const s of
|
|
438
|
+
function X(r, n, t) {
|
|
439
|
+
for (const s of r) {
|
|
427
440
|
if (!e.isObjectExpression(s)) continue;
|
|
428
|
-
let
|
|
429
|
-
for (const
|
|
430
|
-
if (!e.isObjectProperty(
|
|
431
|
-
const l =
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
if (
|
|
435
|
-
const l = !
|
|
436
|
-
|
|
441
|
+
let o = "", c = n, i = null, a = null;
|
|
442
|
+
for (const u of s.properties) {
|
|
443
|
+
if (!e.isObjectProperty(u)) continue;
|
|
444
|
+
const l = u.key, p = e.isIdentifier(l) ? l.name : null;
|
|
445
|
+
p === "path" && e.isStringLiteral(u.value) && (o = u.value.value, o && !o.startsWith("/") ? c = n + "/" + o : c = n + o), p === "module" && e.isIdentifier(u.value) && (i = u.value.name), p === "children" && e.isArrayExpression(u.value) && (a = u.value);
|
|
446
|
+
}
|
|
447
|
+
if (i) {
|
|
448
|
+
const l = !a && o === "/" ? n || "/" : c;
|
|
449
|
+
t.set(i, {
|
|
437
450
|
fullPath: l,
|
|
438
|
-
path:
|
|
451
|
+
path: o
|
|
439
452
|
});
|
|
440
453
|
}
|
|
441
|
-
|
|
454
|
+
a && X(a.elements, c, t);
|
|
442
455
|
}
|
|
443
456
|
}
|
|
444
|
-
function
|
|
445
|
-
const n =
|
|
457
|
+
function Ee(r) {
|
|
458
|
+
const n = O(r, {
|
|
446
459
|
sourceType: "module",
|
|
447
460
|
plugins: ["typescript", "jsx"]
|
|
448
461
|
});
|
|
449
|
-
let
|
|
450
|
-
return
|
|
462
|
+
let t = null;
|
|
463
|
+
return w(n, {
|
|
451
464
|
ExportNamedDeclaration(s) {
|
|
452
|
-
if (
|
|
453
|
-
const
|
|
454
|
-
if (e.isVariableDeclaration(
|
|
455
|
-
for (const
|
|
456
|
-
if (!e.isIdentifier(
|
|
457
|
-
let
|
|
458
|
-
if (
|
|
459
|
-
const
|
|
460
|
-
for (const
|
|
461
|
-
e.isStringLiteral(
|
|
462
|
-
|
|
465
|
+
if (t) return;
|
|
466
|
+
const o = s.node.declaration;
|
|
467
|
+
if (e.isVariableDeclaration(o))
|
|
468
|
+
for (const c of o.declarations) {
|
|
469
|
+
if (!e.isIdentifier(c.id, { name: "channels" })) continue;
|
|
470
|
+
let i = c.init;
|
|
471
|
+
if (i && (e.isTSSatisfiesExpression(i) || e.isTSAsExpression(i)) && (i = i.expression), !e.isArrayExpression(i)) continue;
|
|
472
|
+
const a = [];
|
|
473
|
+
for (const u of i.elements)
|
|
474
|
+
e.isStringLiteral(u) && a.push(u.value);
|
|
475
|
+
t = a;
|
|
463
476
|
}
|
|
464
477
|
}
|
|
465
|
-
}),
|
|
478
|
+
}), t;
|
|
466
479
|
}
|
|
467
|
-
function
|
|
480
|
+
function be(r) {
|
|
468
481
|
const n = /* @__PURE__ */ new Set();
|
|
469
|
-
if (!
|
|
470
|
-
let
|
|
482
|
+
if (!b.existsSync(r)) return n;
|
|
483
|
+
let t;
|
|
471
484
|
try {
|
|
472
|
-
|
|
485
|
+
t = O(b.readFileSync(r, "utf-8"), {
|
|
473
486
|
sourceType: "module",
|
|
474
487
|
plugins: ["typescript", "jsx"]
|
|
475
488
|
});
|
|
476
489
|
} catch {
|
|
477
490
|
return n;
|
|
478
491
|
}
|
|
479
|
-
return
|
|
492
|
+
return w(t, {
|
|
480
493
|
ExportNamedDeclaration(s) {
|
|
481
|
-
const
|
|
482
|
-
if (e.isVariableDeclaration(
|
|
483
|
-
for (const
|
|
484
|
-
if (!e.isIdentifier(
|
|
485
|
-
let
|
|
486
|
-
if (
|
|
487
|
-
for (const
|
|
488
|
-
e.isObjectProperty(
|
|
494
|
+
const o = s.node.declaration;
|
|
495
|
+
if (e.isVariableDeclaration(o))
|
|
496
|
+
for (const c of o.declarations) {
|
|
497
|
+
if (!e.isIdentifier(c.id, { name: "channels" })) continue;
|
|
498
|
+
let i = c.init;
|
|
499
|
+
if (i && (e.isTSSatisfiesExpression(i) || e.isTSAsExpression(i)) && (i = i.expression), !!e.isObjectExpression(i))
|
|
500
|
+
for (const a of i.properties)
|
|
501
|
+
e.isObjectProperty(a) && (e.isIdentifier(a.key) ? n.add(a.key.name) : e.isStringLiteral(a.key) && n.add(a.key.value));
|
|
489
502
|
}
|
|
490
503
|
}
|
|
491
504
|
}), n;
|
|
492
505
|
}
|
|
493
|
-
function
|
|
494
|
-
return [m.join(
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
506
|
+
function M(r) {
|
|
507
|
+
return [m.join(r, "channels.ts"), m.join(r, "channels.tsx")];
|
|
508
|
+
}
|
|
509
|
+
function Y(r) {
|
|
510
|
+
const n = O(r, {
|
|
511
|
+
sourceType: "module",
|
|
512
|
+
plugins: ["typescript", "jsx"]
|
|
513
|
+
});
|
|
514
|
+
let t = null;
|
|
515
|
+
return w(n, {
|
|
516
|
+
ExportNamedDeclaration(s) {
|
|
517
|
+
if (t) return;
|
|
518
|
+
const o = s.node.declaration;
|
|
519
|
+
if (e.isVariableDeclaration(o))
|
|
520
|
+
for (const c of o.declarations) {
|
|
521
|
+
if (!e.isIdentifier(c.id, { name: "liveActions" })) continue;
|
|
522
|
+
let i = c.init;
|
|
523
|
+
if (i && (e.isTSSatisfiesExpression(i) || e.isTSAsExpression(i)) && (i = i.expression), !e.isObjectExpression(i)) continue;
|
|
524
|
+
const a = {};
|
|
525
|
+
for (const u of i.properties) {
|
|
526
|
+
if (!e.isObjectProperty(u) || u.computed) continue;
|
|
527
|
+
const l = e.isIdentifier(u.key) ? u.key.name : e.isStringLiteral(u.key) ? u.key.value : null;
|
|
528
|
+
if (l === null) continue;
|
|
529
|
+
let p = u.value;
|
|
530
|
+
if (p && (e.isTSSatisfiesExpression(p) || e.isTSAsExpression(p)) && (p = p.expression), !e.isArrayExpression(p)) continue;
|
|
531
|
+
const d = [];
|
|
532
|
+
for (const y of p.elements)
|
|
533
|
+
e.isStringLiteral(y) && d.push(y.value);
|
|
534
|
+
a[l] = d;
|
|
535
|
+
}
|
|
536
|
+
t = a;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}), t;
|
|
540
|
+
}
|
|
541
|
+
const P = "virtual:velo/server-entry", F = "virtual:velo/client-entry", H = "\0" + P, G = "\0" + F, Ie = "@mauroandre/velojs/client";
|
|
542
|
+
function Q(r, n) {
|
|
543
|
+
return m.relative(r, n).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/");
|
|
544
|
+
}
|
|
545
|
+
function Z(r, n) {
|
|
546
|
+
const { id: t, appDir: s, isSSR: o } = n, c = n.routesFile ?? "routes.tsx";
|
|
547
|
+
if (t.startsWith("\0") || t.includes("/.velojs/") || !t.endsWith(".tsx") && !t.endsWith(".ts") || !t.startsWith(s)) return null;
|
|
548
|
+
let i = r, a = !1;
|
|
549
|
+
const u = /middlewares:\s*\[/.test(r), l = /export\s+(const|function)\s+Component/.test(
|
|
550
|
+
r
|
|
551
|
+
), p = /export\s+(const|function)\s+loader/.test(r), d = /export\s+const\s+action_\w+/.test(r), y = /export\s+const\s+stream_\w+/.test(r), h = /export\s+const\s+socket_\w+/.test(r), _ = /\bLoader\s*</.test(r) || /\bLoader\s*\(/.test(r), v = /\buseLoader\s*</.test(r) || /\buseLoader\s*\(/.test(r), T = /\bhandler\s*:/.test(r), S = Q(s, t), I = n.pathInfo, j = /export\s+(const|let|var)\s+liveActions\b/.test(r) ? Y(r) : null, E = j ? new Set(Object.keys(j)) : void 0, k = m.join(s, c);
|
|
552
|
+
return !o && u && (i = xe(i), a = !0), !o && T && t === k && (i = je(i), a = !0), (l || p || d || y || h || _ || v) && (i = ue(i, S, I?.fullPath, I?.path), i = pe(i, S), o || (i = fe(
|
|
553
|
+
i,
|
|
554
|
+
S,
|
|
555
|
+
E
|
|
556
|
+
)), !o && y && (i = he(
|
|
557
|
+
i,
|
|
558
|
+
S
|
|
559
|
+
)), !o && h && (i = ye(
|
|
560
|
+
i,
|
|
561
|
+
S
|
|
562
|
+
)), o || (i = ge(i)), o || (i = ve(i)), a = !0), a ? { code: i, moduleId: S } : null;
|
|
563
|
+
}
|
|
564
|
+
function ee(r, n) {
|
|
565
|
+
const t = n.routesFile ?? "routes.tsx", s = n.clientInit ?? "client.tsx";
|
|
566
|
+
return {
|
|
567
|
+
clientInit: m.join(r, s).replace(/\.tsx?$/, ".js"),
|
|
568
|
+
routes: m.join(r, t).replace(/\.tsx?$/, ".js"),
|
|
569
|
+
framework: Ie
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function Le(r, n) {
|
|
573
|
+
let t = m.resolve(process.cwd(), n);
|
|
574
|
+
const s = r.routesFile ?? "routes.tsx", o = /* @__PURE__ */ new Map();
|
|
575
|
+
let c = null;
|
|
576
|
+
const i = () => {
|
|
577
|
+
if (!c) {
|
|
578
|
+
const l = M(t).find((p) => b.existsSync(p));
|
|
579
|
+
c = l ? be(l) : /* @__PURE__ */ new Set();
|
|
580
|
+
}
|
|
581
|
+
return c;
|
|
582
|
+
}, a = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
|
|
508
583
|
return {
|
|
509
584
|
name: "velo:transform",
|
|
510
585
|
enforce: "pre",
|
|
511
|
-
configResolved(
|
|
512
|
-
|
|
586
|
+
configResolved(l) {
|
|
587
|
+
t = m.resolve(l.root, n), c = null;
|
|
513
588
|
},
|
|
514
589
|
buildStart() {
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
if (
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
for (const [
|
|
521
|
-
|
|
590
|
+
c = null;
|
|
591
|
+
const l = m.join(t, s);
|
|
592
|
+
if (b.existsSync(l)) {
|
|
593
|
+
const p = b.readFileSync(l, "utf-8"), d = B(p);
|
|
594
|
+
o.clear();
|
|
595
|
+
for (const [y, h] of d)
|
|
596
|
+
o.set(y, h);
|
|
522
597
|
}
|
|
523
598
|
},
|
|
524
|
-
handleHotUpdate({ file:
|
|
525
|
-
if (
|
|
526
|
-
return
|
|
527
|
-
const
|
|
528
|
-
if (
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
for (const [
|
|
532
|
-
|
|
533
|
-
return
|
|
599
|
+
handleHotUpdate({ file: l, server: p }) {
|
|
600
|
+
if (M(t).includes(l))
|
|
601
|
+
return c = null, p.ws.send({ type: "full-reload" }), [];
|
|
602
|
+
const d = m.join(t, s);
|
|
603
|
+
if (l === d) {
|
|
604
|
+
const y = b.readFileSync(d, "utf-8"), h = B(y);
|
|
605
|
+
o.clear();
|
|
606
|
+
for (const [_, v] of h)
|
|
607
|
+
o.set(_, v);
|
|
608
|
+
return p.ws.send({ type: "full-reload" }), [];
|
|
534
609
|
}
|
|
535
610
|
},
|
|
536
|
-
resolveId(
|
|
537
|
-
return
|
|
611
|
+
resolveId(l) {
|
|
612
|
+
return l === P || l.endsWith(P) ? H : l === F || l.endsWith(F) || l === "/__velo_client.js" ? G : null;
|
|
538
613
|
},
|
|
539
|
-
load(
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
542
|
-
const
|
|
614
|
+
load(l) {
|
|
615
|
+
const p = r.routesFile ?? "routes.tsx", d = r.serverInit ?? "server.tsx", y = m.join(t, p).replace(/\.tsx?$/, ".js"), h = m.join(t, d).replace(/\.tsx?$/, ".js");
|
|
616
|
+
if (l === H) {
|
|
617
|
+
const _ = M(t).find((T) => b.existsSync(T)), v = _ ? _.replace(/\.tsx?$/, ".js") : null;
|
|
543
618
|
return `
|
|
544
619
|
globalThis.__veloBuildHash = __VELO_BUILD_HASH__;
|
|
545
620
|
globalThis.__veloClientJs = __VELO_CLIENT_JS__;
|
|
546
621
|
globalThis.__veloClientCss = __VELO_CLIENT_CSS__;
|
|
547
|
-
import "${
|
|
548
|
-
import routes from "${
|
|
549
|
-
import { startServer${
|
|
550
|
-
${
|
|
551
|
-
${
|
|
622
|
+
import "${h}";
|
|
623
|
+
import routes from "${y}";
|
|
624
|
+
import { startServer${v ? ", registerChannels" : ""} } from "@mauroandre/velojs/server";
|
|
625
|
+
${v ? `import { channels as __veloChannelMap } from "${v}";` : ""}
|
|
626
|
+
${v ? "registerChannels(__veloChannelMap);" : ""}
|
|
552
627
|
|
|
553
628
|
export { routes };
|
|
554
629
|
export default await startServer({ routes, port: __VELO_CONFIG_PORT__, hostname: __VELO_CONFIG_HOSTNAME__ });
|
|
555
630
|
`;
|
|
556
631
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
import {
|
|
632
|
+
if (l === G) {
|
|
633
|
+
const _ = ee(t, r);
|
|
634
|
+
return `
|
|
635
|
+
import "${_.clientInit}";
|
|
636
|
+
import routes from "${_.routes}";
|
|
637
|
+
import { startClient } from "${_.framework}";
|
|
561
638
|
|
|
562
639
|
startClient({ routes });
|
|
563
|
-
|
|
640
|
+
`;
|
|
641
|
+
}
|
|
642
|
+
return null;
|
|
564
643
|
},
|
|
565
|
-
transform(
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
const I = pe(t);
|
|
574
|
-
if (I) {
|
|
575
|
-
if (!_)
|
|
644
|
+
transform(l, p, d) {
|
|
645
|
+
const y = d?.ssr === !0;
|
|
646
|
+
if (p.startsWith("\0") || p.includes("/.velojs/") || !p.endsWith(".tsx") && !p.endsWith(".ts") || !p.startsWith(t)) return null;
|
|
647
|
+
const h = /export\s+(const|function)\s+loader/.test(l), _ = /export\s+(const|let|var)\s+channels\b/.test(l), v = Q(t, p);
|
|
648
|
+
if (_) {
|
|
649
|
+
const S = Ee(l);
|
|
650
|
+
if (S) {
|
|
651
|
+
if (!h)
|
|
576
652
|
throw new Error(
|
|
577
|
-
`[velojs] "${
|
|
653
|
+
`[velojs] "${v}" declares \`channels\` without a \`loader\` — there is nothing to synchronize. Add a loader or remove the export.`
|
|
578
654
|
);
|
|
579
|
-
const
|
|
580
|
-
if (
|
|
655
|
+
const I = i(), j = S.filter((E) => !I.has(E));
|
|
656
|
+
if (j.length > 0)
|
|
581
657
|
throw new Error(
|
|
582
|
-
`[velojs] "${
|
|
658
|
+
`[velojs] "${v}" declares channel(s) ${j.map((E) => `"${E}"`).join(", ")} with no entry in app/channels.ts — add the partition resolver for each name (a typo or a rename would otherwise be a silent no-op).`
|
|
583
659
|
);
|
|
584
|
-
process.env.VELO_STATIC && !
|
|
585
|
-
`[velojs] "${
|
|
660
|
+
process.env.VELO_STATIC && !a.has(v) && (a.add(v), console.warn(
|
|
661
|
+
`[velojs] "${v}" declares channels (${S.join(
|
|
586
662
|
", "
|
|
587
663
|
)}) — inert in a static build: there is no SSE server, so no connection is opened and freshness stays "live".`
|
|
588
664
|
));
|
|
589
665
|
}
|
|
590
666
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
667
|
+
if (/export\s+(const|let|var)\s+liveActions\b/.test(l)) {
|
|
668
|
+
const S = Y(l);
|
|
669
|
+
if (S)
|
|
670
|
+
for (const [I, j] of Object.entries(S)) {
|
|
671
|
+
if (!new RegExp(`export\\s+const\\s+action_${I}\\b`).test(l))
|
|
672
|
+
throw new Error(
|
|
673
|
+
`[velojs] "${v}" declares liveActions.${I} but the module has no \`export const action_${I}\` — there is nothing to synchronize. Add the action or remove the entry.`
|
|
674
|
+
);
|
|
675
|
+
const E = i(), k = j.filter(($) => !E.has($));
|
|
676
|
+
if (k.length > 0)
|
|
677
|
+
throw new Error(
|
|
678
|
+
`[velojs] "${v}" liveActions.${I} declares channel(s) ${k.map(($) => `"${$}"`).join(", ")} with no entry in app/channels.ts — add the partition resolver for each name (a typo or a rename would otherwise be a silent no-op).`
|
|
679
|
+
);
|
|
680
|
+
if (process.env.VELO_STATIC) {
|
|
681
|
+
const $ = `${v}#${I}`;
|
|
682
|
+
u.has($) || (u.add($), console.warn(
|
|
683
|
+
`[velojs] "${v}" liveActions.${I} (channels: ${j.join(", ")}) — inert in a static build: there is no SSE server, the hook opens no connection and returns data undefined with freshness "error" (the load really failed — the contrast with a channel, which stays "live", is deliberate).`
|
|
684
|
+
));
|
|
685
|
+
}
|
|
686
|
+
}
|
|
604
687
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
688
|
+
const T = Z(l, {
|
|
689
|
+
id: p,
|
|
690
|
+
appDir: t,
|
|
691
|
+
isSSR: y,
|
|
692
|
+
routesFile: s,
|
|
693
|
+
pathInfo: o.get(v)
|
|
694
|
+
});
|
|
695
|
+
return T ? { code: T.code, map: null } : null;
|
|
609
696
|
}
|
|
610
697
|
};
|
|
611
698
|
}
|
|
612
|
-
function
|
|
699
|
+
function Te(r) {
|
|
613
700
|
return {
|
|
614
701
|
name: "velo:config",
|
|
615
|
-
config(n, { mode:
|
|
616
|
-
const s =
|
|
702
|
+
config(n, { mode: t }) {
|
|
703
|
+
const s = t === "server", o = t === "development", c = !!process.env.VELO_STATIC, i = n.server?.port ?? (Number(process.env.PORT) || r.port || 3e3), a = m.resolve(
|
|
617
704
|
process.cwd(),
|
|
618
705
|
n.root ?? "."
|
|
619
|
-
),
|
|
620
|
-
let
|
|
706
|
+
), u = n.envDir ? m.resolve(a, n.envDir) : a, l = ie(t, u, ""), p = process.env.HOST?.trim() || l.HOST?.trim() || void 0, d = n.server?.host ?? p ?? r.hostname, y = d === !0 || d === "0.0.0.0" || d === "::", h = n.server?.allowedHosts ?? (y ? !0 : void 0);
|
|
707
|
+
let _ = "client.js", v = "client.css";
|
|
621
708
|
if (s)
|
|
622
709
|
try {
|
|
623
|
-
const
|
|
624
|
-
|
|
710
|
+
const S = m.resolve(process.cwd(), "dist/client/.vite/manifest.json"), j = JSON.parse(b.readFileSync(S, "utf-8"))[F];
|
|
711
|
+
j && (_ = j.file || _, j.css?.[0] && (v = j.css[0]));
|
|
625
712
|
} catch {
|
|
626
713
|
}
|
|
627
|
-
const
|
|
714
|
+
const T = {
|
|
628
715
|
define: {
|
|
629
|
-
"process.env.NODE_ENV": JSON.stringify(
|
|
630
|
-
"process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (
|
|
631
|
-
__VELO_STATIC__: JSON.stringify(
|
|
716
|
+
"process.env.NODE_ENV": JSON.stringify(o ? "development" : "production"),
|
|
717
|
+
"process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (c ? "/client" : "")),
|
|
718
|
+
__VELO_STATIC__: JSON.stringify(c),
|
|
632
719
|
__VELO_BUILD_HASH__: JSON.stringify(process.env.VELO_BUILD_HASH || Date.now().toString(36)),
|
|
633
|
-
__VELO_CLIENT_JS__: JSON.stringify(
|
|
634
|
-
__VELO_CLIENT_CSS__: JSON.stringify(
|
|
720
|
+
__VELO_CLIENT_JS__: JSON.stringify(_),
|
|
721
|
+
__VELO_CLIENT_CSS__: JSON.stringify(v),
|
|
635
722
|
// Baked into the server bundle as startServer's port fallback.
|
|
636
723
|
// null when unset → startServer falls back to PORT env / 3000.
|
|
637
|
-
__VELO_CONFIG_PORT__: JSON.stringify(
|
|
724
|
+
__VELO_CONFIG_PORT__: JSON.stringify(r.port ?? null),
|
|
638
725
|
// Same for the bind interface: null → HOST env / Node default.
|
|
639
|
-
__VELO_CONFIG_HOSTNAME__: JSON.stringify(
|
|
726
|
+
__VELO_CONFIG_HOSTNAME__: JSON.stringify(r.hostname ?? null)
|
|
640
727
|
},
|
|
641
728
|
resolve: {
|
|
642
729
|
alias: {
|
|
@@ -645,15 +732,15 @@ function de(p) {
|
|
|
645
732
|
}
|
|
646
733
|
},
|
|
647
734
|
server: {
|
|
648
|
-
port:
|
|
735
|
+
port: i,
|
|
649
736
|
// Host and allowedHosts only shape the dev server; in build
|
|
650
737
|
// they are inert, so we keep them out of the build config.
|
|
651
|
-
...
|
|
652
|
-
...
|
|
738
|
+
...o && d !== void 0 ? { host: d } : {},
|
|
739
|
+
...o && h !== void 0 ? { allowedHosts: h } : {}
|
|
653
740
|
}
|
|
654
741
|
};
|
|
655
|
-
return s ?
|
|
656
|
-
ssr:
|
|
742
|
+
return s ? T.build = {
|
|
743
|
+
ssr: P,
|
|
657
744
|
outDir: "dist",
|
|
658
745
|
emptyOutDir: !1,
|
|
659
746
|
copyPublicDir: !1,
|
|
@@ -662,109 +749,490 @@ function de(p) {
|
|
|
662
749
|
entryFileNames: "server.js"
|
|
663
750
|
}
|
|
664
751
|
}
|
|
665
|
-
} :
|
|
752
|
+
} : o || (T.build = {
|
|
666
753
|
manifest: !0,
|
|
667
754
|
outDir: "dist/client",
|
|
668
755
|
rollupOptions: {
|
|
669
|
-
input:
|
|
756
|
+
input: F,
|
|
670
757
|
output: {
|
|
671
758
|
entryFileNames: "client.[hash].js",
|
|
672
|
-
assetFileNames: (
|
|
759
|
+
assetFileNames: (S) => S.names?.[0]?.endsWith(".css") ? "client.[hash].css" : "[name].[hash][extname]"
|
|
673
760
|
}
|
|
674
761
|
}
|
|
675
|
-
}),
|
|
762
|
+
}), T;
|
|
676
763
|
}
|
|
677
764
|
};
|
|
678
765
|
}
|
|
679
|
-
function
|
|
766
|
+
function we() {
|
|
680
767
|
return {
|
|
681
768
|
name: "velo:static-url",
|
|
682
769
|
apply: "build",
|
|
683
770
|
enforce: "post",
|
|
684
|
-
generateBundle(
|
|
685
|
-
const
|
|
686
|
-
if (
|
|
771
|
+
generateBundle(r, n) {
|
|
772
|
+
const t = process.env.STATIC_BASE_URL || "";
|
|
773
|
+
if (t)
|
|
687
774
|
for (const s of Object.values(n))
|
|
688
775
|
s.type === "asset" && typeof s.source == "string" && s.fileName.endsWith(".css") && (s.source = s.source.replace(
|
|
689
776
|
/url\(\s*(['"]?)\/(?!\/)/g,
|
|
690
|
-
`url($1${
|
|
777
|
+
`url($1${t}/`
|
|
691
778
|
));
|
|
692
779
|
}
|
|
693
780
|
};
|
|
694
781
|
}
|
|
695
|
-
function
|
|
696
|
-
let
|
|
697
|
-
function
|
|
698
|
-
if (!
|
|
699
|
-
const
|
|
700
|
-
if (!
|
|
701
|
-
const
|
|
702
|
-
|
|
782
|
+
function Oe(r, n) {
|
|
783
|
+
let t = "", s = "", o = !1, c = null;
|
|
784
|
+
function i() {
|
|
785
|
+
if (!t) return;
|
|
786
|
+
const a = m.resolve(t, n);
|
|
787
|
+
if (!b.existsSync(a)) return;
|
|
788
|
+
const u = le(a), l = m.join(t, ".velojs");
|
|
789
|
+
b.mkdirSync(l, { recursive: !0 }), b.writeFileSync(
|
|
703
790
|
m.join(l, "graph.json"),
|
|
704
|
-
JSON.stringify(
|
|
791
|
+
JSON.stringify(u)
|
|
705
792
|
);
|
|
706
793
|
}
|
|
707
794
|
return {
|
|
708
795
|
name: "velo:graph",
|
|
709
|
-
configResolved(
|
|
710
|
-
|
|
796
|
+
configResolved(a) {
|
|
797
|
+
t = a.root, s = a.mode;
|
|
711
798
|
},
|
|
712
799
|
writeBundle() {
|
|
713
|
-
s !== "server" &&
|
|
800
|
+
s !== "server" && i();
|
|
714
801
|
},
|
|
715
|
-
configureServer(
|
|
716
|
-
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
802
|
+
configureServer(a) {
|
|
803
|
+
i(), o = !0;
|
|
804
|
+
const u = m.resolve(t, n);
|
|
805
|
+
a.watcher.on("all", (l, p) => {
|
|
806
|
+
o && p.startsWith(u) && (c && clearTimeout(c), c = setTimeout(() => i(), 500));
|
|
720
807
|
});
|
|
721
808
|
}
|
|
722
809
|
};
|
|
723
810
|
}
|
|
724
|
-
function
|
|
811
|
+
function $e(r) {
|
|
725
812
|
return [
|
|
726
|
-
...
|
|
813
|
+
...ce.exclude,
|
|
727
814
|
/.*\.mjs$/,
|
|
728
|
-
...
|
|
815
|
+
...r.devServerExclude ?? []
|
|
729
816
|
];
|
|
730
817
|
}
|
|
731
|
-
function
|
|
732
|
-
|
|
818
|
+
function Ae(r, n) {
|
|
819
|
+
let t = "", s = "", o = "", c = null, i = null;
|
|
820
|
+
const a = /* @__PURE__ */ new Map();
|
|
821
|
+
function u() {
|
|
822
|
+
const l = ee(o, r);
|
|
823
|
+
return Ue({
|
|
824
|
+
rootDir: t,
|
|
825
|
+
appDir: o,
|
|
826
|
+
routesFile: r.routesFile,
|
|
827
|
+
entrySpecs: [l.clientInit, l.routes, l.framework],
|
|
828
|
+
serverOnly: r.serverOnly,
|
|
829
|
+
cache: a
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
return {
|
|
833
|
+
name: "velo:leak-diagnostic",
|
|
834
|
+
configResolved(l) {
|
|
835
|
+
t = l.root, s = l.mode, o = m.resolve(t, n);
|
|
836
|
+
},
|
|
837
|
+
closeBundle() {
|
|
838
|
+
s !== "server" && console.log(W(u()));
|
|
839
|
+
},
|
|
840
|
+
configureServer(l) {
|
|
841
|
+
const p = u();
|
|
842
|
+
c = p.signature, console.log(W(p)), l.watcher.on("all", (d, y) => {
|
|
843
|
+
i && clearTimeout(i), i = setTimeout(() => {
|
|
844
|
+
const h = u();
|
|
845
|
+
h.signature !== c && (c = h.signature, console.log(W(h)));
|
|
846
|
+
}, 500);
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function tt(r) {
|
|
852
|
+
const n = r ?? {}, t = n.appDirectory ?? "./app";
|
|
733
853
|
return [
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
854
|
+
Te(n),
|
|
855
|
+
Le(n, t),
|
|
856
|
+
we(),
|
|
857
|
+
Oe(n, t),
|
|
858
|
+
Ae(n, t),
|
|
859
|
+
oe(),
|
|
860
|
+
ae({
|
|
861
|
+
entry: P,
|
|
862
|
+
exclude: $e(n)
|
|
742
863
|
}),
|
|
743
|
-
|
|
864
|
+
ke()
|
|
744
865
|
];
|
|
745
866
|
}
|
|
746
|
-
function
|
|
867
|
+
function ke() {
|
|
747
868
|
return {
|
|
748
869
|
name: "velo:ws-bridge",
|
|
749
|
-
configureServer(
|
|
750
|
-
globalThis.__veloDevServer =
|
|
870
|
+
configureServer(r) {
|
|
871
|
+
globalThis.__veloDevServer = r.httpServer;
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
const Ne = typeof N == "function" ? N : N.default, K = new Set(se);
|
|
876
|
+
function te(r) {
|
|
877
|
+
if (r.startsWith("node:") || K.has(r)) return !0;
|
|
878
|
+
const n = r.indexOf("/");
|
|
879
|
+
return !!(n > 0 && K.has(r.slice(0, n)));
|
|
880
|
+
}
|
|
881
|
+
function De(r) {
|
|
882
|
+
let n = "";
|
|
883
|
+
for (let t = 0; t < r.length; t++) {
|
|
884
|
+
const s = r[t];
|
|
885
|
+
s === "*" ? r[t + 1] === "*" ? (n += ".*", t++) : n += "[^/]*" : s === "?" ? n += "[^/]" : n += s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
886
|
+
}
|
|
887
|
+
return new RegExp(`^${n}$`);
|
|
888
|
+
}
|
|
889
|
+
const Pe = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs"]);
|
|
890
|
+
function V(r) {
|
|
891
|
+
const n = [
|
|
892
|
+
r,
|
|
893
|
+
`${r}.ts`,
|
|
894
|
+
`${r}.tsx`,
|
|
895
|
+
`${r}.js`,
|
|
896
|
+
`${r}.jsx`,
|
|
897
|
+
`${r}.mjs`,
|
|
898
|
+
// TS-style extension completion: "./x.js" can stand for "./x.ts".
|
|
899
|
+
r.replace(/\.js$/, ".ts"),
|
|
900
|
+
r.replace(/\.js$/, ".tsx"),
|
|
901
|
+
r.replace(/\.jsx$/, ".tsx"),
|
|
902
|
+
...["index.ts", "index.tsx", "index.js", "index.jsx", "index.mjs"].map(
|
|
903
|
+
(t) => m.join(r, t)
|
|
904
|
+
)
|
|
905
|
+
];
|
|
906
|
+
for (const t of n)
|
|
907
|
+
if (!t.endsWith(".d.ts"))
|
|
908
|
+
try {
|
|
909
|
+
if (b.existsSync(t) && b.statSync(t).isFile())
|
|
910
|
+
return t;
|
|
911
|
+
} catch {
|
|
912
|
+
}
|
|
913
|
+
return null;
|
|
914
|
+
}
|
|
915
|
+
function Fe(r, n) {
|
|
916
|
+
let t = {};
|
|
917
|
+
try {
|
|
918
|
+
t = JSON.parse(b.readFileSync(m.join(r, "package.json"), "utf-8"));
|
|
919
|
+
} catch {
|
|
920
|
+
t = {};
|
|
921
|
+
}
|
|
922
|
+
const s = (c) => {
|
|
923
|
+
if (typeof c == "string") return c;
|
|
924
|
+
if (c && typeof c == "object") {
|
|
925
|
+
const i = c;
|
|
926
|
+
for (const a of ["browser", "import", "module", "default", "require", "node"]) {
|
|
927
|
+
const u = s(i[a]);
|
|
928
|
+
if (u) return u;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
return null;
|
|
932
|
+
}, o = t.exports;
|
|
933
|
+
if (typeof o == "string") {
|
|
934
|
+
if (n === ".") return o;
|
|
935
|
+
} else if (o && typeof o == "object") {
|
|
936
|
+
const c = o;
|
|
937
|
+
if (Object.prototype.hasOwnProperty.call(c, n))
|
|
938
|
+
return s(c[n]);
|
|
939
|
+
for (const i of Object.keys(c)) {
|
|
940
|
+
const a = i.indexOf("*");
|
|
941
|
+
if (a < 0) continue;
|
|
942
|
+
const u = i.slice(0, a), l = i.slice(a + 1);
|
|
943
|
+
if (n.startsWith(u) && n.endsWith(l)) {
|
|
944
|
+
const p = n.slice(u.length, n.length - l.length), d = s(c[i]);
|
|
945
|
+
if (d) return d.replace("*", p);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
return null;
|
|
949
|
+
}
|
|
950
|
+
if (n === ".")
|
|
951
|
+
for (const c of ["module", "main"]) {
|
|
952
|
+
const i = t[c];
|
|
953
|
+
if (typeof i == "string") return i;
|
|
954
|
+
}
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
function Ce(r, n) {
|
|
958
|
+
const t = r.split("?")[0];
|
|
959
|
+
if (!t || t.startsWith("\0") || t.startsWith("virtual:") || t.startsWith("data:") || t.startsWith("http:") || t.startsWith("https:"))
|
|
960
|
+
return null;
|
|
961
|
+
if (t.startsWith(".") || m.isAbsolute(t))
|
|
962
|
+
return V(m.resolve(m.dirname(n), t));
|
|
963
|
+
const o = (t.startsWith("@") ? t.split("/").slice(0, 2) : t.split("/").slice(0, 1)).join("/"), c = t.length > o.length ? `.${t.slice(o.length)}` : ".";
|
|
964
|
+
let i = m.dirname(n);
|
|
965
|
+
for (; ; ) {
|
|
966
|
+
const a = m.join(i, "node_modules", o);
|
|
967
|
+
if (b.existsSync(m.join(a, "package.json"))) {
|
|
968
|
+
const l = Fe(a, c);
|
|
969
|
+
if (l) {
|
|
970
|
+
const p = V(m.resolve(a, l));
|
|
971
|
+
if (p) return p;
|
|
972
|
+
}
|
|
973
|
+
return V(
|
|
974
|
+
m.resolve(a, c === "." ? "index" : c.slice(2))
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
const u = m.dirname(i);
|
|
978
|
+
if (u === i) return null;
|
|
979
|
+
i = u;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
function z(r) {
|
|
983
|
+
return O(r, {
|
|
984
|
+
sourceType: "module",
|
|
985
|
+
plugins: ["typescript", "jsx"]
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
function q(r) {
|
|
989
|
+
const n = [], t = (s, o, c, i) => {
|
|
990
|
+
const a = [];
|
|
991
|
+
for (const u of i)
|
|
992
|
+
(e.isImportSpecifier(u) || e.isImportDefaultSpecifier(u) || e.isImportNamespaceSpecifier(u) || e.isExportSpecifier(u)) && a.push(u.local.name);
|
|
993
|
+
n.push({
|
|
994
|
+
spec: s,
|
|
995
|
+
line: o.loc?.start.line ?? 0,
|
|
996
|
+
kind: c,
|
|
997
|
+
locals: a
|
|
998
|
+
});
|
|
999
|
+
};
|
|
1000
|
+
return Ne(r, {
|
|
1001
|
+
ImportDeclaration(s) {
|
|
1002
|
+
s.node.importKind !== "type" && t(s.node.source.value, s.node, "static", s.node.specifiers);
|
|
1003
|
+
},
|
|
1004
|
+
ExportNamedDeclaration(s) {
|
|
1005
|
+
s.node.source && s.node.exportKind !== "type" && t(s.node.source.value, s.node, "static", s.node.specifiers);
|
|
1006
|
+
},
|
|
1007
|
+
ExportAllDeclaration(s) {
|
|
1008
|
+
s.node.exportKind !== "type" && t(s.node.source.value, s.node, "static", []);
|
|
1009
|
+
},
|
|
1010
|
+
CallExpression(s) {
|
|
1011
|
+
if (!e.isImport(s.node.callee)) return;
|
|
1012
|
+
const o = s.node.arguments[0];
|
|
1013
|
+
e.isStringLiteral(o) && t(o.value, s.node, "dynamic", []);
|
|
1014
|
+
},
|
|
1015
|
+
ImportExpression(s) {
|
|
1016
|
+
const o = s.node.source;
|
|
1017
|
+
e.isStringLiteral(o) && t(o.value, s.node, "dynamic", []);
|
|
1018
|
+
}
|
|
1019
|
+
}), n;
|
|
1020
|
+
}
|
|
1021
|
+
function Re(r, n) {
|
|
1022
|
+
const t = /* @__PURE__ */ new Set(), s = [];
|
|
1023
|
+
for (const o of r) {
|
|
1024
|
+
let c = -1;
|
|
1025
|
+
for (let i = 0; i < n.length; i++) {
|
|
1026
|
+
if (t.has(i)) continue;
|
|
1027
|
+
const a = n[i];
|
|
1028
|
+
if (a.spec === o.spec && a.kind === o.kind && !(o.locals.length > 0 && a.locals.length > 0 && !o.locals.some((l) => a.locals.includes(l)))) {
|
|
1029
|
+
c = i;
|
|
1030
|
+
break;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
s.push(c >= 0 ? n[c] : o), c >= 0 && t.add(c);
|
|
1034
|
+
}
|
|
1035
|
+
return s.sort((o, c) => o.line - c.line);
|
|
1036
|
+
}
|
|
1037
|
+
function Me(r, n) {
|
|
1038
|
+
return m.relative(r, n).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/");
|
|
1039
|
+
}
|
|
1040
|
+
function Ve(r, n, t, s, o) {
|
|
1041
|
+
const { rootDir: c, appDir: i } = n, a = m.relative(c, r).split(m.sep).join("/") || r;
|
|
1042
|
+
let u = 0;
|
|
1043
|
+
try {
|
|
1044
|
+
u = b.statSync(r).mtimeMs;
|
|
1045
|
+
} catch {
|
|
1046
|
+
}
|
|
1047
|
+
const l = o.get(r);
|
|
1048
|
+
if (l && l.info && l.mtimeMs === u) return l.info;
|
|
1049
|
+
const p = s.filter((E) => E.regex.test(a)).map((E) => E.glob), d = m.extname(r);
|
|
1050
|
+
if (!Pe.has(d)) {
|
|
1051
|
+
const E = { file: r, display: a, edges: [], builtins: [], patterns: p };
|
|
1052
|
+
return o.set(r, { mtimeMs: u, info: E }), E;
|
|
1053
|
+
}
|
|
1054
|
+
let y = "";
|
|
1055
|
+
try {
|
|
1056
|
+
y = b.readFileSync(r, "utf-8");
|
|
1057
|
+
} catch {
|
|
1058
|
+
y = "";
|
|
1059
|
+
}
|
|
1060
|
+
let h = [];
|
|
1061
|
+
try {
|
|
1062
|
+
h = q(z(y));
|
|
1063
|
+
} catch {
|
|
1064
|
+
h = [];
|
|
1065
|
+
}
|
|
1066
|
+
const _ = Z(y, {
|
|
1067
|
+
id: r,
|
|
1068
|
+
appDir: i,
|
|
1069
|
+
isSSR: !1,
|
|
1070
|
+
routesFile: n.routesFile,
|
|
1071
|
+
pathInfo: t.get(Me(i, r))
|
|
1072
|
+
}), v = _ ? _.code : y;
|
|
1073
|
+
let T;
|
|
1074
|
+
try {
|
|
1075
|
+
T = q(z(v));
|
|
1076
|
+
} catch {
|
|
1077
|
+
T = h;
|
|
1078
|
+
}
|
|
1079
|
+
const S = Re(T, h), I = [
|
|
1080
|
+
...new Set(S.filter((E) => te(E.spec)).map((E) => E.spec))
|
|
1081
|
+
].sort(), j = { file: r, display: a, edges: S, builtins: I, patterns: p };
|
|
1082
|
+
return o.set(r, { mtimeMs: u, info: j }), j;
|
|
1083
|
+
}
|
|
1084
|
+
const We = 8, Be = 100, Je = 2e4;
|
|
1085
|
+
function Ue(r) {
|
|
1086
|
+
const { rootDir: n, entrySpecs: t } = r, s = r.resolve ?? Ce, o = r.cache ?? /* @__PURE__ */ new Map(), c = (r.serverOnly ?? []).map((f) => ({
|
|
1087
|
+
glob: f,
|
|
1088
|
+
regex: De(f)
|
|
1089
|
+
})), i = /* @__PURE__ */ new Map(), a = m.join(r.appDir, r.routesFile ?? "routes.tsx");
|
|
1090
|
+
try {
|
|
1091
|
+
const f = b.readFileSync(a, "utf-8");
|
|
1092
|
+
for (const [g, x] of B(f))
|
|
1093
|
+
i.set(g, x);
|
|
1094
|
+
} catch {
|
|
1095
|
+
}
|
|
1096
|
+
const u = /* @__PURE__ */ new Map(), l = "virtual:velo/client-entry", p = m.join(r.appDir, "__velo_client_entry__.js"), d = (f, g) => {
|
|
1097
|
+
if (te(f)) return `builtin:${f}`;
|
|
1098
|
+
try {
|
|
1099
|
+
return s(f, g);
|
|
1100
|
+
} catch {
|
|
1101
|
+
return null;
|
|
1102
|
+
}
|
|
1103
|
+
}, y = (f) => {
|
|
1104
|
+
const g = u.get(f);
|
|
1105
|
+
if (g) return g;
|
|
1106
|
+
const x = Ve(f, r, i, c, o), L = {
|
|
1107
|
+
file: f,
|
|
1108
|
+
display: x.display,
|
|
1109
|
+
edges: [],
|
|
1110
|
+
builtins: x.builtins,
|
|
1111
|
+
patterns: x.patterns
|
|
1112
|
+
};
|
|
1113
|
+
u.set(f, L);
|
|
1114
|
+
for (const U of x.edges)
|
|
1115
|
+
L.edges.push({ ...U, target: d(U.spec, f) });
|
|
1116
|
+
return L;
|
|
1117
|
+
}, h = {
|
|
1118
|
+
file: null,
|
|
1119
|
+
display: l,
|
|
1120
|
+
edges: []
|
|
1121
|
+
};
|
|
1122
|
+
for (const f of t)
|
|
1123
|
+
h.edges.push({
|
|
1124
|
+
spec: f,
|
|
1125
|
+
line: 0,
|
|
1126
|
+
kind: "static",
|
|
1127
|
+
locals: [],
|
|
1128
|
+
target: d(f, p)
|
|
1129
|
+
});
|
|
1130
|
+
const _ = (f) => f.builtins.length > 0 || f.patterns.length > 0, v = (f) => {
|
|
1131
|
+
const g = [];
|
|
1132
|
+
if (f.builtins.length > 0) {
|
|
1133
|
+
const x = f.builtins.map((L) => `"${L}"`).join(", ");
|
|
1134
|
+
g.push(
|
|
1135
|
+
f.builtins.length === 1 ? `imports Node builtin ${x}` : `imports Node builtins ${x}`
|
|
1136
|
+
);
|
|
1137
|
+
}
|
|
1138
|
+
if (f.patterns.length > 0) {
|
|
1139
|
+
const x = f.patterns.map((L) => `"${L}"`).join(", ");
|
|
1140
|
+
g.push(
|
|
1141
|
+
f.patterns.length === 1 ? `matches serverOnly pattern ${x}` : `matches serverOnly patterns ${x}`
|
|
1142
|
+
);
|
|
1143
|
+
}
|
|
1144
|
+
return g;
|
|
1145
|
+
}, T = (f, g) => {
|
|
1146
|
+
let x = g.findIndex((L) => L.server);
|
|
1147
|
+
return x < 0 && (x = g.length - 1), {
|
|
1148
|
+
target: f.display,
|
|
1149
|
+
qualifiers: v(f),
|
|
1150
|
+
chain: g.map((L) => ({ from: L.from, line: L.line, to: L.to })),
|
|
1151
|
+
entryIndex: x
|
|
1152
|
+
};
|
|
1153
|
+
}, S = [], I = /* @__PURE__ */ new Map();
|
|
1154
|
+
let j = !1, E = Je;
|
|
1155
|
+
const k = [], $ = /* @__PURE__ */ new Set(), ne = (f, g) => {
|
|
1156
|
+
const x = I.get(f.display) ?? 0;
|
|
1157
|
+
if (x >= We || S.length >= Be) {
|
|
1158
|
+
j = !0;
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
I.set(f.display, x + 1), S.push(T(f, g));
|
|
1162
|
+
}, J = (f) => {
|
|
1163
|
+
for (const g of f.edges) {
|
|
1164
|
+
if (E-- <= 0) {
|
|
1165
|
+
j = !0;
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
if (!g.target || g.target.startsWith("builtin:")) continue;
|
|
1169
|
+
const x = y(g.target), L = {
|
|
1170
|
+
from: f.display,
|
|
1171
|
+
line: f.file === null ? null : g.line,
|
|
1172
|
+
to: x.display,
|
|
1173
|
+
server: _(x),
|
|
1174
|
+
targetNode: x
|
|
1175
|
+
};
|
|
1176
|
+
L.server && ne(x, [...k, L]), $.has(g.target) || ($.add(g.target), k.push(L), J(x), k.pop(), $.delete(g.target));
|
|
751
1177
|
}
|
|
752
1178
|
};
|
|
1179
|
+
J(h);
|
|
1180
|
+
const C = [];
|
|
1181
|
+
for (const f of u.values())
|
|
1182
|
+
for (const g of f.edges)
|
|
1183
|
+
C.push(
|
|
1184
|
+
`${f.display}|${g.line}|${g.kind}|${g.spec}|${g.target ?? ""}`
|
|
1185
|
+
);
|
|
1186
|
+
C.sort();
|
|
1187
|
+
const re = JSON.stringify({
|
|
1188
|
+
modules: [...u.values()].map((f) => f.display).sort(),
|
|
1189
|
+
edges: C
|
|
1190
|
+
});
|
|
1191
|
+
return {
|
|
1192
|
+
leaks: S,
|
|
1193
|
+
truncated: j,
|
|
1194
|
+
signature: re,
|
|
1195
|
+
moduleCount: u.size + 1
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
function W(r) {
|
|
1199
|
+
const n = [];
|
|
1200
|
+
return r.leaks.length === 0 ? (n.push(
|
|
1201
|
+
"[velojs] server->client leak analysis: 0 leaks — what ships to the client is clean."
|
|
1202
|
+
), n.join(`
|
|
1203
|
+
`)) : (n.push(
|
|
1204
|
+
`[velojs] server->client leak analysis: ${r.leaks.length} leak(s) in what ships to the client.`
|
|
1205
|
+
), r.leaks.forEach((t, s) => {
|
|
1206
|
+
n.push(""), n.push(`${s + 1}) ${t.target}`), n.push(` server because: ${t.qualifiers.join("; ")}`), n.push(" import chain from the client entry:"), t.chain.forEach((o, c) => {
|
|
1207
|
+
const i = o.line === null ? `${o.from} (generated)` : `${o.from}:${o.line}`, a = c === t.entryIndex ? " <- entry point (cut here)" : "";
|
|
1208
|
+
n.push(` ${i} -> ${o.to}${a}`);
|
|
1209
|
+
});
|
|
1210
|
+
}), r.truncated && (n.push(""), n.push("... report truncated at its safety budget — more paths exist.")), n.push(""), n.push("The report is read-only: nothing is blocked or rewritten; the cut is yours."), n.join(`
|
|
1211
|
+
`));
|
|
753
1212
|
}
|
|
754
1213
|
export {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
1214
|
+
Ue as a,
|
|
1215
|
+
B as buildFullPathMap,
|
|
1216
|
+
ee as clientEntryModulePaths,
|
|
1217
|
+
X as collectFullPaths,
|
|
1218
|
+
Ce as d,
|
|
1219
|
+
Ee as declaredChannelNames,
|
|
1220
|
+
Y as declaredLiveActions,
|
|
1221
|
+
$e as devServerExcludeFor,
|
|
1222
|
+
W as f,
|
|
1223
|
+
De as g,
|
|
1224
|
+
te as i,
|
|
1225
|
+
ue as injectMetadata,
|
|
1226
|
+
Q as moduleIdFor,
|
|
1227
|
+
ve as pruneClientOnlyImports,
|
|
1228
|
+
be as readChannelMapNames,
|
|
1229
|
+
je as removeEndpointRoutes,
|
|
1230
|
+
ge as removeLoaders,
|
|
1231
|
+
xe as removeMiddlewares,
|
|
1232
|
+
fe as transformActionsForClient,
|
|
1233
|
+
pe as transformLoaderFunctions,
|
|
1234
|
+
Z as transformModuleCode,
|
|
1235
|
+
ye as transformSocketsForClient,
|
|
1236
|
+
he as transformStreamsForClient,
|
|
1237
|
+
tt as veloPlugin
|
|
770
1238
|
};
|