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