@mauroandre/velojs 0.0.38 → 0.0.40

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,116 +1,117 @@
1
- import y from "node:path";
2
- import b from "node:fs";
1
+ import d from "node:path";
2
+ import g from "node:fs";
3
3
  import R from "@preact/preset-vite";
4
4
  import $ from "@hono/vite-dev-server";
5
- import { parse as _ } from "@babel/parser";
5
+ import { parse as h } from "@babel/parser";
6
6
  import j from "@babel/traverse";
7
7
  import L from "@babel/generator";
8
8
  import * as e from "@babel/types";
9
- const d = typeof j == "function" ? j : j.default, h = typeof L == "function" ? L : L.default;
10
- function U(p, s, i, n) {
11
- const l = _(p, {
9
+ import { buildGraph as U } from "./graph.js";
10
+ const m = typeof j == "function" ? j : j.default, _ = typeof L == "function" ? L : L.default;
11
+ function W(p, o, n, i) {
12
+ const l = h(p, {
12
13
  sourceType: "module",
13
14
  plugins: ["typescript", "jsx"]
14
15
  });
15
16
  let t = !1;
16
- if (d(l, {
17
+ if (m(l, {
17
18
  // Procura: export const metadata = { ... }
18
- ExportNamedDeclaration(a) {
19
- const c = a.node.declaration;
19
+ ExportNamedDeclaration(s) {
20
+ const c = s.node.declaration;
20
21
  if (e.isVariableDeclaration(c) && c.declarations.length === 1) {
21
22
  const r = c.declarations[0];
22
23
  if (r && e.isIdentifier(r.id, { name: "metadata" }) && e.isObjectExpression(r.init)) {
23
24
  t = !0;
24
- const f = r.init.properties.filter((v) => e.isObjectProperty(v) && e.isIdentifier(v.key) ? v.key.name !== "moduleId" && v.key.name !== "fullPath" && v.key.name !== "path" : !0), m = [
25
+ const f = r.init.properties.filter((v) => e.isObjectProperty(v) && e.isIdentifier(v.key) ? v.key.name !== "moduleId" && v.key.name !== "fullPath" && v.key.name !== "path" : !0), y = [
25
26
  e.objectProperty(
26
27
  e.identifier("moduleId"),
27
- e.stringLiteral(s)
28
+ e.stringLiteral(o)
28
29
  )
29
30
  ];
30
- i !== void 0 && m.push(
31
+ n !== void 0 && y.push(
31
32
  e.objectProperty(
32
33
  e.identifier("fullPath"),
33
- e.stringLiteral(i)
34
+ e.stringLiteral(n)
34
35
  )
35
- ), n !== void 0 && m.push(
36
+ ), i !== void 0 && y.push(
36
37
  e.objectProperty(
37
38
  e.identifier("path"),
38
- e.stringLiteral(n)
39
+ e.stringLiteral(i)
39
40
  )
40
- ), r.init.properties = [...m, ...f];
41
+ ), r.init.properties = [...y, ...f];
41
42
  }
42
43
  }
43
44
  }
44
45
  }), !t) {
45
- const a = [
46
+ const s = [
46
47
  e.objectProperty(
47
48
  e.identifier("moduleId"),
48
- e.stringLiteral(s)
49
+ e.stringLiteral(o)
49
50
  )
50
51
  ];
51
- i !== void 0 && a.push(
52
+ n !== void 0 && s.push(
52
53
  e.objectProperty(
53
54
  e.identifier("fullPath"),
54
- e.stringLiteral(i)
55
+ e.stringLiteral(n)
55
56
  )
56
- ), n !== void 0 && a.push(
57
+ ), i !== void 0 && s.push(
57
58
  e.objectProperty(
58
59
  e.identifier("path"),
59
- e.stringLiteral(n)
60
+ e.stringLiteral(i)
60
61
  )
61
62
  );
62
63
  const c = e.exportNamedDeclaration(
63
64
  e.variableDeclaration("const", [
64
65
  e.variableDeclarator(
65
66
  e.identifier("metadata"),
66
- e.objectExpression(a)
67
+ e.objectExpression(s)
67
68
  )
68
69
  ])
69
70
  );
70
71
  l.program.body.unshift(c);
71
72
  }
72
- return h(l, { retainLines: !0 }).code;
73
+ return _(l, { retainLines: !0 }).code;
73
74
  }
74
- function W(p, s) {
75
- const i = _(p, {
75
+ function J(p, o) {
76
+ const n = h(p, {
76
77
  sourceType: "module",
77
78
  plugins: ["typescript", "jsx"]
78
79
  });
79
- return d(i, {
80
+ return m(n, {
80
81
  CallExpression(l) {
81
- const t = l.node.callee, o = e.isIdentifier(t, { name: "Loader" }) || e.isTSInstantiationExpression(t) && e.isIdentifier(t.expression, { name: "Loader" }), a = e.isIdentifier(t, { name: "useLoader" }) || e.isTSInstantiationExpression(t) && e.isIdentifier(t.expression, { name: "useLoader" });
82
- if (!o && !a) return;
83
- const c = l.node.arguments, r = e.stringLiteral(s), u = c[0];
82
+ const t = l.node.callee, a = e.isIdentifier(t, { name: "Loader" }) || e.isTSInstantiationExpression(t) && e.isIdentifier(t.expression, { name: "Loader" }), s = e.isIdentifier(t, { name: "useLoader" }) || e.isTSInstantiationExpression(t) && e.isIdentifier(t.expression, { name: "useLoader" });
83
+ if (!a && !s) return;
84
+ const c = l.node.arguments, r = e.stringLiteral(o), u = c[0];
84
85
  e.isStringLiteral(u) && u.value.includes("/") || (l.node.arguments = [r, ...c]);
85
86
  }
86
- }), h(i, { retainLines: !0 }).code;
87
+ }), _(n, { retainLines: !0 }).code;
87
88
  }
88
- function J(p, s) {
89
- const i = _(p, {
89
+ function B(p, o) {
90
+ const n = h(p, {
90
91
  sourceType: "module",
91
92
  plugins: ["typescript", "jsx"]
92
93
  });
93
- return d(i, {
94
+ return m(n, {
94
95
  ExportNamedDeclaration(l) {
95
96
  const t = l.node.declaration;
96
97
  if (!e.isVariableDeclaration(t)) return;
97
- const o = t.declarations[0];
98
- if (!o || !e.isIdentifier(o.id)) return;
99
- const a = o.id.name;
100
- if (!a.startsWith("action_")) return;
101
- const c = a.replace("action_", ""), r = o.init;
98
+ const a = t.declarations[0];
99
+ if (!a || !e.isIdentifier(a.id)) return;
100
+ const s = a.id.name;
101
+ if (!s.startsWith("action_")) return;
102
+ const c = s.replace("action_", ""), r = a.init;
102
103
  if (!e.isArrowFunctionExpression(r) || !r.async) return;
103
- const u = r.params, f = M(s, c, u);
104
- r.body = e.blockStatement([e.returnStatement(f)]), B(r, u);
104
+ const u = r.params, f = M(o, c, u);
105
+ r.body = e.blockStatement([e.returnStatement(f)]), H(r, u);
105
106
  }
106
- }), h(i, { retainLines: !0 }).code;
107
+ }), _(n, { retainLines: !0 }).code;
107
108
  }
108
- function M(p, s, i) {
109
- const n = `/_action/${p}/${s}`;
110
- return i.length === 0 ? e.callExpression(
109
+ function M(p, o, n) {
110
+ const i = `/_action/${p}/${o}`;
111
+ return n.length === 0 ? e.callExpression(
111
112
  e.memberExpression(
112
113
  e.callExpression(e.identifier("fetch"), [
113
- e.stringLiteral(n),
114
+ e.stringLiteral(i),
114
115
  e.objectExpression([
115
116
  e.objectProperty(
116
117
  e.identifier("method"),
@@ -135,7 +136,7 @@ function M(p, s, i) {
135
136
  ) : e.callExpression(
136
137
  e.memberExpression(
137
138
  e.callExpression(e.identifier("fetch"), [
138
- e.stringLiteral(n),
139
+ e.stringLiteral(i),
139
140
  e.objectExpression([
140
141
  e.objectProperty(
141
142
  e.identifier("method"),
@@ -175,14 +176,14 @@ function M(p, s, i) {
175
176
  ]
176
177
  );
177
178
  }
178
- function B(p, s) {
179
- if (s.length === 0) return;
180
- const i = s[0];
181
- if (e.isObjectPattern(i)) {
182
- let n = null;
183
- if (e.isTSTypeAnnotation(i.typeAnnotation) && e.isTSTypeReference(i.typeAnnotation.typeAnnotation)) {
184
- const o = i.typeAnnotation.typeAnnotation;
185
- e.isIdentifier(o.typeName, { name: "ActionArgs" }) && o.typeParameters?.params[0] && (n = o.typeParameters.params[0]);
179
+ function H(p, o) {
180
+ if (o.length === 0) return;
181
+ const n = o[0];
182
+ if (e.isObjectPattern(n)) {
183
+ let i = null;
184
+ if (e.isTSTypeAnnotation(n.typeAnnotation) && e.isTSTypeReference(n.typeAnnotation.typeAnnotation)) {
185
+ const a = n.typeAnnotation.typeAnnotation;
186
+ e.isIdentifier(a.typeName, { name: "ActionArgs" }) && a.typeParameters?.params[0] && (i = a.typeParameters.params[0]);
186
187
  }
187
188
  const l = e.objectProperty(
188
189
  e.identifier("body"),
@@ -191,31 +192,31 @@ function B(p, s) {
191
192
  !0
192
193
  // shorthand
193
194
  ), t = e.objectPattern([l]);
194
- n && (t.typeAnnotation = e.tsTypeAnnotation(
195
+ i && (t.typeAnnotation = e.tsTypeAnnotation(
195
196
  e.tsTypeLiteral([
196
197
  e.tsPropertySignature(
197
198
  e.identifier("body"),
198
- e.tsTypeAnnotation(n)
199
+ e.tsTypeAnnotation(i)
199
200
  )
200
201
  ])
201
202
  )), p.params = [t];
202
203
  }
203
204
  }
204
- function H(p, s) {
205
- const i = _(p, {
205
+ function G(p, o) {
206
+ const n = h(p, {
206
207
  sourceType: "module",
207
208
  plugins: ["typescript", "jsx"]
208
209
  });
209
- return d(i, {
210
+ return m(n, {
210
211
  ExportNamedDeclaration(l) {
211
212
  const t = l.node.declaration;
212
213
  if (!e.isVariableDeclaration(t)) return;
213
- const o = t.declarations[0];
214
- if (!o || !e.isIdentifier(o.id)) return;
215
- const a = o.id.name;
216
- if (!a.startsWith("stream_")) return;
217
- const c = a.replace("stream_", ""), r = `/_event/${s}/${c}`;
218
- o.init = e.objectExpression([
214
+ const a = t.declarations[0];
215
+ if (!a || !e.isIdentifier(a.id)) return;
216
+ const s = a.id.name;
217
+ if (!s.startsWith("stream_")) return;
218
+ const c = s.replace("stream_", ""), r = `/_event/${o}/${c}`;
219
+ a.init = e.objectExpression([
219
220
  e.objectProperty(
220
221
  e.identifier("__isVeloEventStream"),
221
222
  e.booleanLiteral(!0)
@@ -224,25 +225,25 @@ function H(p, s) {
224
225
  e.identifier("__path"),
225
226
  e.stringLiteral(r)
226
227
  )
227
- ]), o.id.typeAnnotation = null;
228
+ ]), a.id.typeAnnotation = null;
228
229
  }
229
- }), h(i, { retainLines: !0 }).code;
230
+ }), _(n, { retainLines: !0 }).code;
230
231
  }
231
- function z(p, s) {
232
- const i = _(p, {
232
+ function z(p, o) {
233
+ const n = h(p, {
233
234
  sourceType: "module",
234
235
  plugins: ["typescript", "jsx"]
235
236
  });
236
- return d(i, {
237
+ return m(n, {
237
238
  ExportNamedDeclaration(l) {
238
239
  const t = l.node.declaration;
239
240
  if (!e.isVariableDeclaration(t)) return;
240
- const o = t.declarations[0];
241
- if (!o || !e.isIdentifier(o.id)) return;
242
- const a = o.id.name;
243
- if (!a.startsWith("socket_")) return;
244
- const c = a.replace("socket_", ""), r = `/_socket/${s}/${c}`;
245
- o.init = e.objectExpression([
241
+ const a = t.declarations[0];
242
+ if (!a || !e.isIdentifier(a.id)) return;
243
+ const s = a.id.name;
244
+ if (!s.startsWith("socket_")) return;
245
+ const c = s.replace("socket_", ""), r = `/_socket/${o}/${c}`;
246
+ a.init = e.objectExpression([
246
247
  e.objectProperty(
247
248
  e.identifier("__isVeloSocket"),
248
249
  e.booleanLiteral(!0)
@@ -251,228 +252,228 @@ function z(p, s) {
251
252
  e.identifier("__path"),
252
253
  e.stringLiteral(r)
253
254
  )
254
- ]), o.id.typeAnnotation = null;
255
+ ]), a.id.typeAnnotation = null;
255
256
  }
256
- }), h(i, { retainLines: !0 }).code;
257
+ }), _(n, { retainLines: !0 }).code;
257
258
  }
258
- function G(p) {
259
- const s = _(p, {
259
+ function Y(p) {
260
+ const o = h(p, {
260
261
  sourceType: "module",
261
262
  plugins: ["typescript", "jsx"]
262
263
  });
263
- return d(s, {
264
- ExportNamedDeclaration(n) {
265
- const l = n.node.declaration;
264
+ return m(o, {
265
+ ExportNamedDeclaration(i) {
266
+ const l = i.node.declaration;
266
267
  if (!e.isVariableDeclaration(l)) return;
267
268
  const t = l.declarations[0];
268
- !t || !e.isIdentifier(t.id) || t.id.name === "loader" && n.remove();
269
+ !t || !e.isIdentifier(t.id) || t.id.name === "loader" && i.remove();
269
270
  }
270
- }), h(s, { retainLines: !0 }).code;
271
+ }), _(o, { retainLines: !0 }).code;
271
272
  }
272
- function Y(p) {
273
- const s = _(p, {
273
+ function X(p) {
274
+ const o = h(p, {
274
275
  sourceType: "module",
275
276
  plugins: ["typescript", "jsx"]
276
- }), i = /* @__PURE__ */ new Set();
277
- g(s.program, i);
278
- let n = !1;
279
- return d(s, {
277
+ }), n = /* @__PURE__ */ new Set();
278
+ x(o.program, n);
279
+ let i = !1;
280
+ return m(o, {
280
281
  ImportDeclaration(t) {
281
- const o = t.node.specifiers;
282
- if (o.length === 0) return;
283
- const a = o.filter((c) => i.has(c.local.name));
284
- a.length !== o.length && (n = !0, a.length === 0 ? t.remove() : t.node.specifiers = a);
282
+ const a = t.node.specifiers;
283
+ if (a.length === 0) return;
284
+ const s = a.filter((c) => n.has(c.local.name));
285
+ s.length !== a.length && (i = !0, s.length === 0 ? t.remove() : t.node.specifiers = s);
285
286
  }
286
- }), n ? h(s, { retainLines: !0 }).code : p;
287
+ }), i ? _(o, { retainLines: !0 }).code : p;
287
288
  }
288
- function X(p) {
289
- const s = _(p, {
289
+ function q(p) {
290
+ const o = h(p, {
290
291
  sourceType: "module",
291
292
  plugins: ["typescript", "jsx"]
292
- }), i = [];
293
- if (d(s, {
294
- ObjectProperty(a) {
295
- e.isIdentifier(a.node.key, { name: "middlewares" }) && (i.push(a.node.value), a.remove());
293
+ }), n = [];
294
+ if (m(o, {
295
+ ObjectProperty(s) {
296
+ e.isIdentifier(s.node.key, { name: "middlewares" }) && (n.push(s.node.value), s.remove());
296
297
  }
297
- }), i.length === 0) return p;
298
- const n = /* @__PURE__ */ new Set();
299
- for (const a of i)
300
- g(a, n);
298
+ }), n.length === 0) return p;
299
+ const i = /* @__PURE__ */ new Set();
300
+ for (const s of n)
301
+ x(s, i);
301
302
  const l = /* @__PURE__ */ new Set();
302
- g(s.program, l);
303
+ x(o.program, l);
303
304
  const t = /* @__PURE__ */ new Set();
304
- for (const a of n)
305
- l.has(a) || t.add(a);
306
- return t.size > 0 && d(s, {
307
- ImportDeclaration(a) {
308
- const c = a.node.specifiers, r = c.filter((u) => !t.has(u.local.name));
309
- r.length === 0 ? a.remove() : r.length !== c.length && (a.node.specifiers = r);
305
+ for (const s of i)
306
+ l.has(s) || t.add(s);
307
+ return t.size > 0 && m(o, {
308
+ ImportDeclaration(s) {
309
+ const c = s.node.specifiers, r = c.filter((u) => !t.has(u.local.name));
310
+ r.length === 0 ? s.remove() : r.length !== c.length && (s.node.specifiers = r);
310
311
  }
311
- }), h(s, { retainLines: !0 }).code;
312
+ }), _(o, { retainLines: !0 }).code;
312
313
  }
313
- function g(p, s) {
314
- const i = (n) => {
315
- if (!(!n || typeof n != "object")) {
316
- if (Array.isArray(n)) {
317
- for (const l of n) i(l);
314
+ function x(p, o) {
315
+ const n = (i) => {
316
+ if (!(!i || typeof i != "object")) {
317
+ if (Array.isArray(i)) {
318
+ for (const l of i) n(l);
318
319
  return;
319
320
  }
320
- if (n.type === "Identifier") {
321
- s.add(n.name), n.typeAnnotation && i(n.typeAnnotation);
321
+ if (i.type === "Identifier") {
322
+ o.add(i.name), i.typeAnnotation && n(i.typeAnnotation);
322
323
  return;
323
324
  }
324
- if (n.type === "JSXIdentifier") {
325
- s.add(n.name);
325
+ if (i.type === "JSXIdentifier") {
326
+ o.add(i.name);
326
327
  return;
327
328
  }
328
- if (n.type === "MemberExpression") {
329
- i(n.object), n.computed && i(n.property);
329
+ if (i.type === "MemberExpression") {
330
+ n(i.object), i.computed && n(i.property);
330
331
  return;
331
332
  }
332
- if ((n.type === "ObjectProperty" || n.type === "ObjectMethod") && !n.computed) {
333
- n.type === "ObjectProperty" ? i(n.value) : i(n.body);
333
+ if ((i.type === "ObjectProperty" || i.type === "ObjectMethod") && !i.computed) {
334
+ i.type === "ObjectProperty" ? n(i.value) : n(i.body);
334
335
  return;
335
336
  }
336
- if (!(n.type === "ImportSpecifier" || n.type === "ImportDefaultSpecifier" || n.type === "ImportNamespaceSpecifier"))
337
- for (const l of Object.keys(n))
338
- l === "loc" || l === "start" || l === "end" || l === "leadingComments" || l === "trailingComments" || l === "innerComments" || i(n[l]);
337
+ if (!(i.type === "ImportSpecifier" || i.type === "ImportDefaultSpecifier" || i.type === "ImportNamespaceSpecifier"))
338
+ for (const l of Object.keys(i))
339
+ l === "loc" || l === "start" || l === "end" || l === "leadingComments" || l === "trailingComments" || l === "innerComments" || n(i[l]);
339
340
  }
340
341
  };
341
- i(p);
342
+ n(p);
342
343
  }
343
- function q(p) {
344
- for (const s of p.properties)
345
- if (e.isObjectProperty(s) && e.isIdentifier(s.key) && s.key.name === "handler")
344
+ function K(p) {
345
+ for (const o of p.properties)
346
+ if (e.isObjectProperty(o) && e.isIdentifier(o.key) && o.key.name === "handler")
346
347
  return !0;
347
348
  return !1;
348
349
  }
349
- function K(p) {
350
- for (const s of p.properties)
351
- if (e.isObjectProperty(s) && e.isIdentifier(s.key) && s.key.name === "children" && e.isArrayExpression(s.value))
352
- return s.value;
350
+ function Q(p) {
351
+ for (const o of p.properties)
352
+ if (e.isObjectProperty(o) && e.isIdentifier(o.key) && o.key.name === "children" && e.isArrayExpression(o.value))
353
+ return o.value;
353
354
  return null;
354
355
  }
355
- function Q(p) {
356
- const s = _(p, {
356
+ function Z(p) {
357
+ const o = h(p, {
357
358
  sourceType: "module",
358
359
  plugins: ["typescript", "jsx"]
359
- }), i = [], n = (c) => {
360
+ }), n = [], i = (c) => {
360
361
  for (let r = c.elements.length - 1; r >= 0; r--) {
361
362
  const u = c.elements[r];
362
363
  if (!e.isObjectExpression(u)) continue;
363
- if (q(u)) {
364
- i.push(u), c.elements.splice(r, 1);
364
+ if (K(u)) {
365
+ n.push(u), c.elements.splice(r, 1);
365
366
  continue;
366
367
  }
367
- const f = K(u);
368
- f && n(f);
368
+ const f = Q(u);
369
+ f && i(f);
369
370
  }
370
371
  };
371
- if (d(s, {
372
+ if (m(o, {
372
373
  ExportDefaultDeclaration(c) {
373
374
  const r = c.node.declaration;
374
375
  let u = null;
375
- e.isArrayExpression(r) ? u = r : (e.isTSSatisfiesExpression(r) && e.isArrayExpression(r.expression) || e.isTSAsExpression(r) && e.isArrayExpression(r.expression)) && (u = r.expression), u && n(u);
376
+ e.isArrayExpression(r) ? u = r : (e.isTSSatisfiesExpression(r) && e.isArrayExpression(r.expression) || e.isTSAsExpression(r) && e.isArrayExpression(r.expression)) && (u = r.expression), u && i(u);
376
377
  }
377
- }), i.length === 0) return p;
378
+ }), n.length === 0) return p;
378
379
  const l = /* @__PURE__ */ new Set();
379
- for (const c of i)
380
- g(c, l);
380
+ for (const c of n)
381
+ x(c, l);
381
382
  const t = /* @__PURE__ */ new Set();
382
- g(s.program, t);
383
- const o = /* @__PURE__ */ new Set();
383
+ x(o.program, t);
384
+ const a = /* @__PURE__ */ new Set();
384
385
  for (const c of l)
385
- t.has(c) || o.add(c);
386
- return o.size > 0 && d(s, {
386
+ t.has(c) || a.add(c);
387
+ return a.size > 0 && m(o, {
387
388
  ImportDeclaration(c) {
388
- const r = c.node.specifiers, u = r.filter((f) => !o.has(f.local.name));
389
+ const r = c.node.specifiers, u = r.filter((f) => !a.has(f.local.name));
389
390
  u.length === 0 ? c.remove() : u.length !== r.length && (c.node.specifiers = u);
390
391
  }
391
- }), h(s, { retainLines: !0 }).code;
392
+ }), _(o, { retainLines: !0 }).code;
392
393
  }
393
394
  function A(p) {
394
- const s = _(p, {
395
+ const o = h(p, {
395
396
  sourceType: "module",
396
397
  plugins: ["typescript", "jsx"]
397
- }), i = /* @__PURE__ */ new Map();
398
- d(s, {
398
+ }), n = /* @__PURE__ */ new Map();
399
+ m(o, {
399
400
  ImportDeclaration(t) {
400
- const o = t.node.source.value;
401
- for (const a of t.node.specifiers)
402
- e.isImportNamespaceSpecifier(a) && i.set(a.local.name, o);
401
+ const a = t.node.source.value;
402
+ for (const s of t.node.specifiers)
403
+ e.isImportNamespaceSpecifier(s) && n.set(s.local.name, a);
403
404
  }
404
405
  });
405
- const n = /* @__PURE__ */ new Map();
406
- d(s, {
406
+ const i = /* @__PURE__ */ new Map();
407
+ m(o, {
407
408
  ExportDefaultDeclaration(t) {
408
- const o = t.node.declaration;
409
- let a = null;
410
- e.isArrayExpression(o) ? a = o : (e.isTSSatisfiesExpression(o) || e.isTSAsExpression(o)) && e.isArrayExpression(o.expression) && (a = o.expression), a && C(a.elements, "", n);
409
+ const a = t.node.declaration;
410
+ let s = null;
411
+ e.isArrayExpression(a) ? s = a : (e.isTSSatisfiesExpression(a) || e.isTSAsExpression(a)) && e.isArrayExpression(a.expression) && (s = a.expression), s && D(s.elements, "", i);
411
412
  }
412
413
  });
413
414
  const l = /* @__PURE__ */ new Map();
414
- for (const [t, o] of n) {
415
- const a = i.get(t);
416
- if (a) {
417
- const c = a.replace(/^\.\//, "").replace(/\.(tsx?|jsx?|js)$/, "");
418
- l.set(c, o);
415
+ for (const [t, a] of i) {
416
+ const s = n.get(t);
417
+ if (s) {
418
+ const c = s.replace(/^\.\//, "").replace(/\.(tsx?|jsx?|js)$/, "");
419
+ l.set(c, a);
419
420
  }
420
421
  }
421
422
  return l;
422
423
  }
423
- function C(p, s, i) {
424
- for (const n of p) {
425
- if (!e.isObjectExpression(n)) continue;
426
- let l = "", t = s, o = null, a = null;
427
- for (const c of n.properties) {
424
+ function D(p, o, n) {
425
+ for (const i of p) {
426
+ if (!e.isObjectExpression(i)) continue;
427
+ let l = "", t = o, a = null, s = null;
428
+ for (const c of i.properties) {
428
429
  if (!e.isObjectProperty(c)) continue;
429
430
  const r = c.key, u = e.isIdentifier(r) ? r.name : null;
430
- u === "path" && e.isStringLiteral(c.value) && (l = c.value.value, l && !l.startsWith("/") ? t = s + "/" + l : t = s + l), u === "module" && e.isIdentifier(c.value) && (o = c.value.name), u === "children" && e.isArrayExpression(c.value) && (a = c.value);
431
+ u === "path" && e.isStringLiteral(c.value) && (l = c.value.value, l && !l.startsWith("/") ? t = o + "/" + l : t = o + l), u === "module" && e.isIdentifier(c.value) && (a = c.value.name), u === "children" && e.isArrayExpression(c.value) && (s = c.value);
431
432
  }
432
- if (o) {
433
- const r = !a && l === "/" ? s || "/" : t;
434
- i.set(o, {
433
+ if (a) {
434
+ const r = !s && l === "/" ? o || "/" : t;
435
+ n.set(a, {
435
436
  fullPath: r,
436
437
  path: l
437
438
  });
438
439
  }
439
- a && C(a.elements, t, i);
440
+ s && D(s.elements, t, n);
440
441
  }
441
442
  }
442
- const S = "virtual:velo/server-entry", E = "virtual:velo/client-entry", P = "\0" + S, N = "\0" + E;
443
- function Z(p, s) {
444
- let i = y.resolve(process.cwd(), s);
445
- const n = p.routesFile ?? "routes.tsx", l = /* @__PURE__ */ new Map();
443
+ const b = "virtual:velo/server-entry", E = "virtual:velo/client-entry", P = "\0" + b, N = "\0" + E;
444
+ function ee(p, o) {
445
+ let n = d.resolve(process.cwd(), o);
446
+ const i = p.routesFile ?? "routes.tsx", l = /* @__PURE__ */ new Map();
446
447
  return {
447
448
  name: "velo:transform",
448
449
  enforce: "pre",
449
450
  configResolved(t) {
450
- i = y.resolve(t.root, s);
451
+ n = d.resolve(t.root, o);
451
452
  },
452
453
  buildStart() {
453
- const t = y.join(i, n);
454
- if (b.existsSync(t)) {
455
- const o = b.readFileSync(t, "utf-8"), a = A(o);
454
+ const t = d.join(n, i);
455
+ if (g.existsSync(t)) {
456
+ const a = g.readFileSync(t, "utf-8"), s = A(a);
456
457
  l.clear();
457
- for (const [c, r] of a)
458
+ for (const [c, r] of s)
458
459
  l.set(c, r);
459
460
  }
460
461
  },
461
- handleHotUpdate({ file: t, server: o }) {
462
- const a = y.join(i, n);
463
- if (t === a) {
464
- const c = b.readFileSync(a, "utf-8"), r = A(c);
462
+ handleHotUpdate({ file: t, server: a }) {
463
+ const s = d.join(n, i);
464
+ if (t === s) {
465
+ const c = g.readFileSync(s, "utf-8"), r = A(c);
465
466
  l.clear();
466
467
  for (const [u, f] of r)
467
468
  l.set(u, f);
468
- return o.ws.send({ type: "full-reload" }), [];
469
+ return a.ws.send({ type: "full-reload" }), [];
469
470
  }
470
471
  },
471
472
  resolveId(t) {
472
- return t === S || t.endsWith(S) ? P : t === E || t.endsWith(E) || t === "/__velo_client.js" ? N : null;
473
+ return t === b || t.endsWith(b) ? P : t === E || t.endsWith(E) || t === "/__velo_client.js" ? N : null;
473
474
  },
474
475
  load(t) {
475
- const o = p.routesFile ?? "routes.tsx", a = p.serverInit ?? "server.tsx", c = p.clientInit ?? "client.tsx", r = y.join(i, o).replace(/\.tsx?$/, ".js"), u = y.join(i, a).replace(/\.tsx?$/, ".js"), f = y.join(i, c).replace(/\.tsx?$/, ".js");
476
+ const a = p.routesFile ?? "routes.tsx", s = p.serverInit ?? "server.tsx", c = p.clientInit ?? "client.tsx", r = d.join(n, a).replace(/\.tsx?$/, ".js"), u = d.join(n, s).replace(/\.tsx?$/, ".js"), f = d.join(n, c).replace(/\.tsx?$/, ".js");
476
477
  return t === P ? `
477
478
  globalThis.__veloBuildHash = __VELO_BUILD_HASH__;
478
479
  globalThis.__veloClientJs = __VELO_CLIENT_JS__;
@@ -491,25 +492,25 @@ import { startClient } from "@mauroandre/velojs/client";
491
492
  startClient({ routes });
492
493
  ` : null;
493
494
  },
494
- transform(t, o, a) {
495
- const c = a?.ssr === !0;
496
- if (o.startsWith("\0") || o.includes("/.velojs/") || !o.endsWith(".tsx") && !o.endsWith(".ts") || !o.startsWith(i)) return null;
495
+ transform(t, a, s) {
496
+ const c = s?.ssr === !0;
497
+ if (a.startsWith("\0") || a.includes("/.velojs/") || !a.endsWith(".tsx") && !a.endsWith(".ts") || !a.startsWith(n)) return null;
497
498
  let r = t, u = !1;
498
- const f = /middlewares:\s*\[/.test(t), m = /export\s+(const|function)\s+Component/.test(
499
+ const f = /middlewares:\s*\[/.test(t), y = /export\s+(const|function)\s+Component/.test(
499
500
  t
500
- ), v = /export\s+(const|function)\s+loader/.test(t), D = /export\s+const\s+action_\w+/.test(t), I = /export\s+const\s+stream_\w+/.test(t), T = /export\s+const\s+socket_\w+/.test(t), w = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), k = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t), F = /\bhandler\s*:/.test(t), V = y.join(i, n);
501
- if (!c && f && (r = X(r), u = !0), !c && F && o === V && (r = Q(r), u = !0), m || v || D || I || T || w || k) {
502
- const x = y.relative(i, o).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), O = l.get(x);
503
- r = U(r, x, O?.fullPath, O?.path), r = W(r, x), c || (r = J(
501
+ ), v = /export\s+(const|function)\s+loader/.test(t), C = /export\s+const\s+action_\w+/.test(t), I = /export\s+const\s+stream_\w+/.test(t), T = /export\s+const\s+socket_\w+/.test(t), w = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), k = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t), F = /\bhandler\s*:/.test(t), V = d.join(n, i);
502
+ if (!c && f && (r = q(r), u = !0), !c && F && a === V && (r = Z(r), u = !0), y || v || C || I || T || w || k) {
503
+ const S = d.relative(n, a).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), O = l.get(S);
504
+ r = W(r, S, O?.fullPath, O?.path), r = J(r, S), c || (r = B(
504
505
  r,
505
- x
506
- )), !c && I && (r = H(
506
+ S
507
+ )), !c && I && (r = G(
507
508
  r,
508
- x
509
+ S
509
510
  )), !c && T && (r = z(
510
511
  r,
511
- x
512
- )), c || (r = G(r)), c || (r = Y(r)), u = !0;
512
+ S
513
+ )), c || (r = Y(r)), c || (r = X(r)), u = !0;
513
514
  }
514
515
  return u ? {
515
516
  code: r,
@@ -518,16 +519,16 @@ startClient({ routes });
518
519
  }
519
520
  };
520
521
  }
521
- function ee(p) {
522
+ function te(p) {
522
523
  return {
523
524
  name: "velo:config",
524
- config(s, { mode: i }) {
525
- const n = i === "server", l = i === "development", t = !!process.env.VELO_STATIC, o = s.server?.port ?? (Number(process.env.PORT) || p.port || 3e3);
526
- let a = "client.js", c = "client.css";
527
- if (n)
525
+ config(o, { mode: n }) {
526
+ const i = n === "server", l = n === "development", t = !!process.env.VELO_STATIC, a = o.server?.port ?? (Number(process.env.PORT) || p.port || 3e3);
527
+ let s = "client.js", c = "client.css";
528
+ if (i)
528
529
  try {
529
- const u = y.resolve(process.cwd(), "dist/client/.vite/manifest.json"), m = JSON.parse(b.readFileSync(u, "utf-8"))[E];
530
- m && (a = m.file || a, m.css?.[0] && (c = m.css[0]));
530
+ const u = d.resolve(process.cwd(), "dist/client/.vite/manifest.json"), y = JSON.parse(g.readFileSync(u, "utf-8"))[E];
531
+ y && (s = y.file || s, y.css?.[0] && (c = y.css[0]));
531
532
  } catch {
532
533
  }
533
534
  const r = {
@@ -536,7 +537,7 @@ function ee(p) {
536
537
  "process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (t ? "/client" : "")),
537
538
  __VELO_STATIC__: JSON.stringify(t),
538
539
  __VELO_BUILD_HASH__: JSON.stringify(process.env.VELO_BUILD_HASH || Date.now().toString(36)),
539
- __VELO_CLIENT_JS__: JSON.stringify(a),
540
+ __VELO_CLIENT_JS__: JSON.stringify(s),
540
541
  __VELO_CLIENT_CSS__: JSON.stringify(c),
541
542
  // Baked into the server bundle as startServer's port fallback.
542
543
  // null when unset → startServer falls back to PORT env / 3000.
@@ -549,11 +550,11 @@ function ee(p) {
549
550
  }
550
551
  },
551
552
  server: {
552
- port: o
553
+ port: a
553
554
  }
554
555
  };
555
- return n ? r.build = {
556
- ssr: S,
556
+ return i ? r.build = {
557
+ ssr: b,
557
558
  outDir: "dist",
558
559
  emptyOutDir: !1,
559
560
  copyPublicDir: !1,
@@ -576,36 +577,66 @@ function ee(p) {
576
577
  }
577
578
  };
578
579
  }
579
- function te() {
580
+ function re() {
580
581
  return {
581
582
  name: "velo:static-url",
582
583
  apply: "build",
583
584
  enforce: "post",
584
- generateBundle(p, s) {
585
- const i = process.env.STATIC_BASE_URL || "";
586
- if (i)
587
- for (const n of Object.values(s))
588
- n.type === "asset" && typeof n.source == "string" && n.fileName.endsWith(".css") && (n.source = n.source.replace(
585
+ generateBundle(p, o) {
586
+ const n = process.env.STATIC_BASE_URL || "";
587
+ if (n)
588
+ for (const i of Object.values(o))
589
+ i.type === "asset" && typeof i.source == "string" && i.fileName.endsWith(".css") && (i.source = i.source.replace(
589
590
  /url\(\s*(['"]?)\/(?!\/)/g,
590
- `url($1${i}/`
591
+ `url($1${n}/`
591
592
  ));
592
593
  }
593
594
  };
594
595
  }
595
- function pe(p) {
596
- const s = p ?? {}, i = s.appDirectory ?? "./app";
596
+ function ne(p, o) {
597
+ let n = "", i = "", l = !1, t = null;
598
+ function a() {
599
+ if (!n) return;
600
+ const s = d.resolve(n, o);
601
+ if (!g.existsSync(s)) return;
602
+ const c = U(s), r = d.join(n, ".velojs");
603
+ g.mkdirSync(r, { recursive: !0 }), g.writeFileSync(
604
+ d.join(r, "graph.json"),
605
+ JSON.stringify(c)
606
+ );
607
+ }
608
+ return {
609
+ name: "velo:graph",
610
+ configResolved(s) {
611
+ n = s.root, i = s.mode;
612
+ },
613
+ writeBundle() {
614
+ i !== "server" && a();
615
+ },
616
+ configureServer(s) {
617
+ a(), l = !0;
618
+ const c = d.resolve(n, o);
619
+ s.watcher.on("all", (r, u) => {
620
+ l && u.startsWith(c) && (t && clearTimeout(t), t = setTimeout(() => a(), 500));
621
+ });
622
+ }
623
+ };
624
+ }
625
+ function de(p) {
626
+ const o = p ?? {}, n = o.appDirectory ?? "./app";
597
627
  return [
598
- ee(s),
599
- Z(s, i),
600
- te(),
628
+ te(o),
629
+ ee(o, n),
630
+ re(),
631
+ ne(o, n),
601
632
  R(),
602
633
  $({
603
- entry: S
634
+ entry: b
604
635
  }),
605
- re()
636
+ ie()
606
637
  ];
607
638
  }
608
- function re() {
639
+ function ie() {
609
640
  return {
610
641
  name: "velo:ws-bridge",
611
642
  configureServer(p) {
@@ -615,15 +646,15 @@ function re() {
615
646
  }
616
647
  export {
617
648
  A as buildFullPathMap,
618
- C as collectFullPaths,
619
- U as injectMetadata,
620
- Y as pruneClientOnlyImports,
621
- Q as removeEndpointRoutes,
622
- G as removeLoaders,
623
- X as removeMiddlewares,
624
- J as transformActionsForClient,
625
- W as transformLoaderFunctions,
649
+ D as collectFullPaths,
650
+ W as injectMetadata,
651
+ X as pruneClientOnlyImports,
652
+ Z as removeEndpointRoutes,
653
+ Y as removeLoaders,
654
+ q as removeMiddlewares,
655
+ B as transformActionsForClient,
656
+ J as transformLoaderFunctions,
626
657
  z as transformSocketsForClient,
627
- H as transformStreamsForClient,
628
- pe as veloPlugin
658
+ G as transformStreamsForClient,
659
+ de as veloPlugin
629
660
  };