@mauroandre/velojs 0.0.24 → 0.0.26

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