@mauroandre/velojs 0.0.26 → 0.0.27

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