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