@mauroandre/velojs 0.0.35 → 0.0.37

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