@mauroandre/velojs 0.0.17 → 0.0.18

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.
@@ -1,6 +1,6 @@
1
1
  import { jsx as o, jsxs as p, Fragment as $ } from "preact/jsx-runtime";
2
- import { useRouter as v, Link as E } from "wouter-preact";
3
- import { __veloUpdatePending as y } from "./hooks.js";
2
+ import { useRouter as C, Link as S } from "wouter-preact";
3
+ import { __veloUpdatePending as E } from "./hooks.js";
4
4
  function O({ basePath: e, favicon: t = "/favicon.ico" } = {}) {
5
5
  const n = process.env.NODE_ENV !== "production";
6
6
  e = e || process.env.STATIC_BASE_URL || (process.env.VELO_STATIC ? "/client" : "");
@@ -11,10 +11,10 @@ function O({ basePath: e, favicon: t = "/favicon.ico" } = {}) {
11
11
  /* @__PURE__ */ o("script", { type: "module", src: "/@vite/client" }),
12
12
  /* @__PURE__ */ o("script", { type: "module", src: "/__velo_client.js" })
13
13
  ] });
14
- const r = typeof __VELO_CLIENT_JS__ < "u" ? __VELO_CLIENT_JS__ : "client.js";
14
+ const r = globalThis.__veloClientJs || (typeof __VELO_CLIENT_JS__ < "u" ? __VELO_CLIENT_JS__ : "client.js"), c = globalThis.__veloClientCss || (typeof __VELO_CLIENT_CSS__ < "u" ? __VELO_CLIENT_CSS__ : "client.css");
15
15
  return /* @__PURE__ */ p($, { children: [
16
16
  i,
17
- /* @__PURE__ */ o("link", { rel: "stylesheet", href: `${e}/${typeof __VELO_CLIENT_CSS__ < "u" ? __VELO_CLIENT_CSS__ : "client.css"}` }),
17
+ /* @__PURE__ */ o("link", { rel: "stylesheet", href: `${e}/${c}` }),
18
18
  /* @__PURE__ */ o("script", { type: "module", src: `${e}/${r}` })
19
19
  ] });
20
20
  }
@@ -25,29 +25,29 @@ function h(e, t) {
25
25
  return n;
26
26
  }
27
27
  function j({ to: e, params: t, search: n, absolute: i, ...r }) {
28
- const c = typeof e != "string", u = v(), _ = c ? (i ? e.metadata?.fullPath : e.metadata?.path) ?? "/" : e, l = t ? h(_, t) : _, L = c && i ? `~${l}` : l, a = n ? `?${new URLSearchParams(n).toString()}` : "", m = `${L}${a}`;
29
- if (typeof window < "u" && y.value) {
30
- let f;
28
+ const c = typeof e != "string", u = C(), f = c ? (i ? e.metadata?.fullPath : e.metadata?.path) ?? "/" : e, l = t ? h(f, t) : f, v = c && i ? `~${l}` : l, a = n ? `?${new URLSearchParams(n).toString()}` : "", L = `${v}${a}`;
29
+ if (typeof window < "u" && E.value) {
30
+ let _;
31
31
  if (c) {
32
- const s = e.metadata?.fullPath ?? _;
33
- f = `${t ? h(s, t) : s}${a}`;
32
+ const s = e.metadata?.fullPath ?? f;
33
+ _ = `${t ? h(s, t) : s}${a}`;
34
34
  } else {
35
35
  const s = l.replace(/^~/, "");
36
- f = `${!l.startsWith("~") && u.base ? u.base : ""}${s}${a}`;
36
+ _ = `${!l.startsWith("~") && u.base ? u.base : ""}${s}${a}`;
37
37
  }
38
- const { onClick: d, ...S } = r;
38
+ const { onClick: d, ...m } = r;
39
39
  return /* @__PURE__ */ o(
40
40
  "a",
41
41
  {
42
- href: f,
42
+ href: _,
43
43
  onClick: (s) => {
44
- d && d(s), s.defaultPrevented || (s.preventDefault(), window.location.href = f);
44
+ d && d(s), s.defaultPrevented || (s.preventDefault(), window.location.href = _);
45
45
  },
46
- ...S
46
+ ...m
47
47
  }
48
48
  );
49
49
  }
50
- return /* @__PURE__ */ o(E, { to: m, ...r });
50
+ return /* @__PURE__ */ o(S, { to: L, ...r });
51
51
  }
52
52
  export {
53
53
  j as Link,
package/dist/vite.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import d from "node:path";
2
- import _ from "node:fs";
3
- import C from "@preact/preset-vite";
2
+ import L from "node:fs";
3
+ import D from "@preact/preset-vite";
4
4
  import F from "@hono/vite-dev-server";
5
5
  import { parse as v } from "@babel/parser";
6
6
  import E from "@babel/traverse";
7
7
  import b from "@babel/generator";
8
8
  import * as e from "@babel/types";
9
9
  const m = typeof E == "function" ? E : E.default, S = typeof b == "function" ? b : b.default;
10
- function w(u, c, r, l) {
11
- const i = v(u, {
10
+ function w(u, l, r, c) {
11
+ const n = v(u, {
12
12
  sourceType: "module",
13
13
  plugins: ["typescript", "jsx"]
14
14
  });
15
15
  let t = !1;
16
- if (m(i, {
16
+ if (m(n, {
17
17
  // Procura: export const metadata = { ... }
18
18
  ExportNamedDeclaration(s) {
19
19
  const o = s.node.declaration;
@@ -21,23 +21,23 @@ function w(u, c, r, l) {
21
21
  const a = o.declarations[0];
22
22
  if (a && e.isIdentifier(a.id, { name: "metadata" }) && e.isObjectExpression(a.init)) {
23
23
  t = !0;
24
- const f = a.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 = a.init.properties.filter((y) => e.isObjectProperty(y) && e.isIdentifier(y.key) ? y.key.name !== "moduleId" && y.key.name !== "fullPath" && y.key.name !== "path" : !0), _ = [
25
25
  e.objectProperty(
26
26
  e.identifier("moduleId"),
27
- e.stringLiteral(c)
27
+ e.stringLiteral(l)
28
28
  )
29
29
  ];
30
- r !== void 0 && h.push(
30
+ r !== void 0 && _.push(
31
31
  e.objectProperty(
32
32
  e.identifier("fullPath"),
33
33
  e.stringLiteral(r)
34
34
  )
35
- ), l !== void 0 && h.push(
35
+ ), c !== void 0 && _.push(
36
36
  e.objectProperty(
37
37
  e.identifier("path"),
38
- e.stringLiteral(l)
38
+ e.stringLiteral(c)
39
39
  )
40
- ), a.init.properties = [...h, ...f];
40
+ ), a.init.properties = [..._, ...f];
41
41
  }
42
42
  }
43
43
  }
@@ -45,7 +45,7 @@ function w(u, c, r, l) {
45
45
  const s = [
46
46
  e.objectProperty(
47
47
  e.identifier("moduleId"),
48
- e.stringLiteral(c)
48
+ e.stringLiteral(l)
49
49
  )
50
50
  ];
51
51
  r !== void 0 && s.push(
@@ -53,10 +53,10 @@ function w(u, c, r, l) {
53
53
  e.identifier("fullPath"),
54
54
  e.stringLiteral(r)
55
55
  )
56
- ), l !== void 0 && s.push(
56
+ ), c !== void 0 && s.push(
57
57
  e.objectProperty(
58
58
  e.identifier("path"),
59
- e.stringLiteral(l)
59
+ e.stringLiteral(c)
60
60
  )
61
61
  );
62
62
  const o = e.exportNamedDeclaration(
@@ -67,50 +67,50 @@ function w(u, c, r, l) {
67
67
  )
68
68
  ])
69
69
  );
70
- i.program.body.unshift(o);
70
+ n.program.body.unshift(o);
71
71
  }
72
- return S(i, { retainLines: !0 }).code;
72
+ return S(n, { retainLines: !0 }).code;
73
73
  }
74
- function R(u, c) {
74
+ function V(u, l) {
75
75
  const r = v(u, {
76
76
  sourceType: "module",
77
77
  plugins: ["typescript", "jsx"]
78
78
  });
79
79
  return m(r, {
80
- CallExpression(i) {
81
- const t = i.node.callee, n = 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 (!n && !s) return;
83
- const o = i.node.arguments, a = e.stringLiteral(c), p = o[0];
84
- e.isStringLiteral(p) && p.value.includes("/") || (i.node.arguments = [a, ...o]);
80
+ CallExpression(n) {
81
+ const t = n.node.callee, i = 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 (!i && !s) return;
83
+ const o = n.node.arguments, a = e.stringLiteral(l), p = o[0];
84
+ e.isStringLiteral(p) && p.value.includes("/") || (n.node.arguments = [a, ...o]);
85
85
  }
86
86
  }), S(r, { retainLines: !0 }).code;
87
87
  }
88
- function V(u, c) {
88
+ function R(u, l) {
89
89
  const r = v(u, {
90
90
  sourceType: "module",
91
91
  plugins: ["typescript", "jsx"]
92
92
  });
93
93
  return m(r, {
94
- ExportNamedDeclaration(i) {
95
- const t = i.node.declaration;
94
+ ExportNamedDeclaration(n) {
95
+ const t = n.node.declaration;
96
96
  if (!e.isVariableDeclaration(t)) return;
97
- const n = t.declarations[0];
98
- if (!n || !e.isIdentifier(n.id)) return;
99
- const s = n.id.name;
97
+ const i = t.declarations[0];
98
+ if (!i || !e.isIdentifier(i.id)) return;
99
+ const s = i.id.name;
100
100
  if (!s.startsWith("action_")) return;
101
- const o = s.replace("action_", ""), a = n.init;
101
+ const o = s.replace("action_", ""), a = i.init;
102
102
  if (!e.isArrowFunctionExpression(a) || !a.async) return;
103
- const p = a.params, f = U(c, o, p);
103
+ const p = a.params, f = U(l, o, p);
104
104
  a.body = e.blockStatement([e.returnStatement(f)]), W(a, p);
105
105
  }
106
106
  }), S(r, { retainLines: !0 }).code;
107
107
  }
108
- function U(u, c, r) {
109
- const l = `/_action/${u}/${c}`;
108
+ function U(u, l, r) {
109
+ const c = `/_action/${u}/${l}`;
110
110
  return r.length === 0 ? e.callExpression(
111
111
  e.memberExpression(
112
112
  e.callExpression(e.identifier("fetch"), [
113
- e.stringLiteral(l),
113
+ e.stringLiteral(c),
114
114
  e.objectExpression([
115
115
  e.objectProperty(
116
116
  e.identifier("method"),
@@ -135,7 +135,7 @@ function U(u, c, r) {
135
135
  ) : e.callExpression(
136
136
  e.memberExpression(
137
137
  e.callExpression(e.identifier("fetch"), [
138
- e.stringLiteral(l),
138
+ e.stringLiteral(c),
139
139
  e.objectExpression([
140
140
  e.objectProperty(
141
141
  e.identifier("method"),
@@ -175,164 +175,166 @@ function U(u, c, r) {
175
175
  ]
176
176
  );
177
177
  }
178
- function W(u, c) {
179
- if (c.length === 0) return;
180
- const r = c[0];
178
+ function W(u, l) {
179
+ if (l.length === 0) return;
180
+ const r = l[0];
181
181
  if (e.isObjectPattern(r)) {
182
- let l = null;
182
+ let c = null;
183
183
  if (e.isTSTypeAnnotation(r.typeAnnotation) && e.isTSTypeReference(r.typeAnnotation.typeAnnotation)) {
184
- const n = r.typeAnnotation.typeAnnotation;
185
- e.isIdentifier(n.typeName, { name: "ActionArgs" }) && n.typeParameters?.params[0] && (l = n.typeParameters.params[0]);
184
+ const i = r.typeAnnotation.typeAnnotation;
185
+ e.isIdentifier(i.typeName, { name: "ActionArgs" }) && i.typeParameters?.params[0] && (c = i.typeParameters.params[0]);
186
186
  }
187
- const i = e.objectProperty(
187
+ const n = 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
- l && (t.typeAnnotation = e.tsTypeAnnotation(
193
+ ), t = e.objectPattern([n]);
194
+ c && (t.typeAnnotation = e.tsTypeAnnotation(
195
195
  e.tsTypeLiteral([
196
196
  e.tsPropertySignature(
197
197
  e.identifier("body"),
198
- e.tsTypeAnnotation(l)
198
+ e.tsTypeAnnotation(c)
199
199
  )
200
200
  ])
201
201
  )), u.params = [t];
202
202
  }
203
203
  }
204
204
  function $(u) {
205
- const c = v(u, {
205
+ const l = v(u, {
206
206
  sourceType: "module",
207
207
  plugins: ["typescript", "jsx"]
208
208
  });
209
- return m(c, {
210
- ExportNamedDeclaration(l) {
211
- const i = l.node.declaration;
212
- if (!e.isVariableDeclaration(i)) return;
213
- const t = i.declarations[0];
214
- !t || !e.isIdentifier(t.id) || t.id.name === "loader" && l.remove();
209
+ return m(l, {
210
+ ExportNamedDeclaration(c) {
211
+ const n = c.node.declaration;
212
+ if (!e.isVariableDeclaration(n)) return;
213
+ const t = n.declarations[0];
214
+ !t || !e.isIdentifier(t.id) || t.id.name === "loader" && c.remove();
215
215
  }
216
- }), S(c, { retainLines: !0 }).code;
216
+ }), S(l, { retainLines: !0 }).code;
217
217
  }
218
- function k(u) {
219
- const c = v(u, {
218
+ function J(u) {
219
+ const l = v(u, {
220
220
  sourceType: "module",
221
221
  plugins: ["typescript", "jsx"]
222
222
  }), r = /* @__PURE__ */ new Set();
223
- return m(c, {
224
- ObjectProperty(i) {
225
- if (e.isIdentifier(i.node.key, { name: "middlewares" }) && e.isArrayExpression(i.node.value)) {
226
- for (const t of i.node.value.elements)
223
+ return m(l, {
224
+ ObjectProperty(n) {
225
+ if (e.isIdentifier(n.node.key, { name: "middlewares" }) && e.isArrayExpression(n.node.value)) {
226
+ for (const t of n.node.value.elements)
227
227
  e.isIdentifier(t) && r.add(t.name);
228
- i.remove();
228
+ n.remove();
229
229
  }
230
230
  }
231
- }), r.size === 0 ? u : (m(c, {
232
- ImportDeclaration(i) {
233
- const t = i.node.specifiers, n = t.filter((s) => {
231
+ }), r.size === 0 ? u : (m(l, {
232
+ ImportDeclaration(n) {
233
+ const t = n.node.specifiers, i = t.filter((s) => {
234
234
  if (e.isImportSpecifier(s)) {
235
235
  const o = s.local.name;
236
236
  return !r.has(o);
237
237
  }
238
238
  return !0;
239
239
  });
240
- n.length === 0 ? i.remove() : n.length !== t.length && (i.node.specifiers = n);
240
+ i.length === 0 ? n.remove() : i.length !== t.length && (n.node.specifiers = i);
241
241
  }
242
- }), S(c, { retainLines: !0 }).code);
242
+ }), S(l, { retainLines: !0 }).code);
243
243
  }
244
244
  function j(u) {
245
- const c = v(u, {
245
+ const l = v(u, {
246
246
  sourceType: "module",
247
247
  plugins: ["typescript", "jsx"]
248
248
  }), r = /* @__PURE__ */ new Map();
249
- m(c, {
249
+ m(l, {
250
250
  ImportDeclaration(t) {
251
- const n = t.node.source.value;
251
+ const i = t.node.source.value;
252
252
  for (const s of t.node.specifiers)
253
- e.isImportNamespaceSpecifier(s) && r.set(s.local.name, n);
253
+ e.isImportNamespaceSpecifier(s) && r.set(s.local.name, i);
254
254
  }
255
255
  });
256
- const l = /* @__PURE__ */ new Map();
257
- m(c, {
256
+ const c = /* @__PURE__ */ new Map();
257
+ m(l, {
258
258
  ExportDefaultDeclaration(t) {
259
- const n = t.node.declaration;
259
+ const i = t.node.declaration;
260
260
  let s = null;
261
- e.isArrayExpression(n) ? s = n : e.isTSSatisfiesExpression(n) && e.isArrayExpression(n.expression) && (s = n.expression), s && A(s.elements, "", l);
261
+ e.isArrayExpression(i) ? s = i : e.isTSSatisfiesExpression(i) && e.isArrayExpression(i.expression) && (s = i.expression), s && P(s.elements, "", c);
262
262
  }
263
263
  });
264
- const i = /* @__PURE__ */ new Map();
265
- for (const [t, n] of l) {
264
+ const n = /* @__PURE__ */ new Map();
265
+ for (const [t, i] of c) {
266
266
  const s = r.get(t);
267
267
  if (s) {
268
268
  const o = s.replace(/^\.\//, "").replace(/\.(tsx?|jsx?|js)$/, "");
269
- i.set(o, n);
269
+ n.set(o, i);
270
270
  }
271
271
  }
272
- return i;
272
+ return n;
273
273
  }
274
- function A(u, c, r) {
275
- for (const l of u) {
276
- if (!e.isObjectExpression(l)) continue;
277
- let i = "", t = c, n = null, s = null;
278
- for (const o of l.properties) {
274
+ function P(u, l, r) {
275
+ for (const c of u) {
276
+ if (!e.isObjectExpression(c)) continue;
277
+ let n = "", t = l, i = null, s = null;
278
+ for (const o of c.properties) {
279
279
  if (!e.isObjectProperty(o)) continue;
280
280
  const a = o.key, p = e.isIdentifier(a) ? a.name : null;
281
- p === "path" && e.isStringLiteral(o.value) && (i = o.value.value, i && !i.startsWith("/") ? t = c + "/" + i : t = c + i), p === "module" && e.isIdentifier(o.value) && (n = o.value.name), p === "children" && e.isArrayExpression(o.value) && (s = o.value);
281
+ p === "path" && e.isStringLiteral(o.value) && (n = o.value.value, n && !n.startsWith("/") ? t = l + "/" + n : t = l + n), p === "module" && e.isIdentifier(o.value) && (i = o.value.name), p === "children" && e.isArrayExpression(o.value) && (s = o.value);
282
282
  }
283
- if (n) {
284
- const a = !s && i === "/" ? c || "/" : t;
285
- r.set(n, {
283
+ if (i) {
284
+ const a = !s && n === "/" ? l || "/" : t;
285
+ r.set(i, {
286
286
  fullPath: a,
287
- path: i
287
+ path: n
288
288
  });
289
289
  }
290
- s && A(s.elements, t, r);
290
+ s && P(s.elements, t, r);
291
291
  }
292
292
  }
293
- const g = "virtual:velo/server-entry", x = "virtual:velo/client-entry", T = "\0" + g, P = "\0" + x;
294
- function B(u, c) {
295
- let r = d.resolve(process.cwd(), c);
296
- const l = u.routesFile ?? "routes.tsx", i = /* @__PURE__ */ new Map();
293
+ const h = "virtual:velo/server-entry", g = "virtual:velo/client-entry", T = "\0" + h, N = "\0" + g;
294
+ function k(u, l) {
295
+ let r = d.resolve(process.cwd(), l);
296
+ const c = u.routesFile ?? "routes.tsx", n = /* @__PURE__ */ new Map();
297
297
  return {
298
298
  name: "velo:transform",
299
299
  enforce: "pre",
300
300
  configResolved(t) {
301
- r = d.resolve(t.root, c);
301
+ r = d.resolve(t.root, l);
302
302
  },
303
303
  buildStart() {
304
- const t = d.join(r, l);
305
- if (_.existsSync(t)) {
306
- const n = _.readFileSync(t, "utf-8"), s = j(n);
307
- i.clear();
304
+ const t = d.join(r, c);
305
+ if (L.existsSync(t)) {
306
+ const i = L.readFileSync(t, "utf-8"), s = j(i);
307
+ n.clear();
308
308
  for (const [o, a] of s)
309
- i.set(o, a);
309
+ n.set(o, a);
310
310
  }
311
311
  },
312
- handleHotUpdate({ file: t, server: n }) {
313
- const s = d.join(r, l);
312
+ handleHotUpdate({ file: t, server: i }) {
313
+ const s = d.join(r, c);
314
314
  if (t === s) {
315
- const o = _.readFileSync(s, "utf-8"), a = j(o);
316
- i.clear();
315
+ const o = L.readFileSync(s, "utf-8"), a = j(o);
316
+ n.clear();
317
317
  for (const [p, f] of a)
318
- i.set(p, f);
319
- return n.ws.send({ type: "full-reload" }), [];
318
+ n.set(p, f);
319
+ return i.ws.send({ type: "full-reload" }), [];
320
320
  }
321
321
  },
322
322
  resolveId(t) {
323
- return t === g || t.endsWith(g) ? T : t === x || t.endsWith(x) || t === "/__velo_client.js" ? P : null;
323
+ return t === h || t.endsWith(h) ? T : t === g || t.endsWith(g) || t === "/__velo_client.js" ? N : null;
324
324
  },
325
325
  load(t) {
326
- const n = u.routesFile ?? "routes.tsx", s = u.serverInit ?? "server.tsx", o = u.clientInit ?? "client.tsx", a = d.join(r, n).replace(/\.tsx?$/, ".js"), p = d.join(r, s).replace(/\.tsx?$/, ".js"), f = d.join(r, o).replace(/\.tsx?$/, ".js");
326
+ const i = u.routesFile ?? "routes.tsx", s = u.serverInit ?? "server.tsx", o = u.clientInit ?? "client.tsx", a = d.join(r, i).replace(/\.tsx?$/, ".js"), p = d.join(r, s).replace(/\.tsx?$/, ".js"), f = d.join(r, o).replace(/\.tsx?$/, ".js");
327
327
  return t === T ? `
328
328
  globalThis.__veloBuildHash = __VELO_BUILD_HASH__;
329
+ globalThis.__veloClientJs = __VELO_CLIENT_JS__;
330
+ globalThis.__veloClientCss = __VELO_CLIENT_CSS__;
329
331
  import "${p}";
330
332
  import routes from "${a}";
331
333
  import { startServer } from "@mauroandre/velojs/server";
332
334
 
333
335
  export { routes };
334
336
  export default await startServer({ routes });
335
- ` : t === P ? `
337
+ ` : t === N ? `
336
338
  import "${f}";
337
339
  import routes from "${a}";
338
340
  import { startClient } from "@mauroandre/velojs/client";
@@ -340,18 +342,18 @@ import { startClient } from "@mauroandre/velojs/client";
340
342
  startClient({ routes });
341
343
  ` : null;
342
344
  },
343
- transform(t, n, s) {
345
+ transform(t, i, s) {
344
346
  const o = s?.ssr === !0;
345
- if (n.startsWith("\0") || n.includes("/.velojs/") || !n.endsWith(".tsx") && !n.endsWith(".ts") || !n.startsWith(r)) return null;
347
+ if (i.startsWith("\0") || i.includes("/.velojs/") || !i.endsWith(".tsx") && !i.endsWith(".ts") || !i.startsWith(r)) return null;
346
348
  let a = t, p = !1;
347
- const f = /middlewares:\s*\[/.test(t), h = /export\s+(const|function)\s+Component/.test(
349
+ const f = /middlewares:\s*\[/.test(t), _ = /export\s+(const|function)\s+Component/.test(
348
350
  t
349
- ), y = /export\s+(const|function)\s+loader/.test(t), N = /export\s+const\s+action_\w+/.test(t), O = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), D = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t);
350
- if (!o && f && (a = k(a), p = !0), h || y || N || O || D) {
351
- const L = d.relative(r, n).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), I = i.get(L);
352
- a = w(a, L, I?.fullPath, I?.path), a = R(a, L), o || (a = V(
351
+ ), y = /export\s+(const|function)\s+loader/.test(t), A = /export\s+const\s+action_\w+/.test(t), O = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), C = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t);
352
+ if (!o && f && (a = J(a), p = !0), _ || y || A || O || C) {
353
+ const x = d.relative(r, i).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), I = n.get(x);
354
+ a = w(a, x, I?.fullPath, I?.path), a = V(a, x), o || (a = R(
353
355
  a,
354
- L
356
+ x
355
357
  )), o || (a = $(a)), p = !0;
356
358
  }
357
359
  return p ? {
@@ -361,26 +363,26 @@ startClient({ routes });
361
363
  }
362
364
  };
363
365
  }
364
- function J() {
366
+ function B() {
365
367
  return {
366
368
  name: "velo:config",
367
- config(u, { mode: c }) {
368
- const r = c === "server", l = c === "development", i = !!process.env.VELO_STATIC;
369
- let t = "client.js", n = "client.css";
369
+ config(u, { mode: l }) {
370
+ const r = l === "server", c = l === "development", n = !!process.env.VELO_STATIC;
371
+ let t = "client.js", i = "client.css";
370
372
  if (r)
371
373
  try {
372
- const o = d.resolve(process.cwd(), "dist/client/.vite/manifest.json"), p = JSON.parse(_.readFileSync(o, "utf-8"))[x];
373
- p && (t = p.file || t, p.css?.[0] && (n = p.css[0]));
374
+ const o = d.resolve(process.cwd(), "dist/client/.vite/manifest.json"), p = JSON.parse(L.readFileSync(o, "utf-8"))[g];
375
+ p && (t = p.file || t, p.css?.[0] && (i = p.css[0]));
374
376
  } catch {
375
377
  }
376
378
  const s = {
377
379
  define: {
378
- "process.env.NODE_ENV": JSON.stringify(l ? "development" : "production"),
379
- "process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (i ? "/client" : "")),
380
- __VELO_STATIC__: JSON.stringify(i),
380
+ "process.env.NODE_ENV": JSON.stringify(c ? "development" : "production"),
381
+ "process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (n ? "/client" : "")),
382
+ __VELO_STATIC__: JSON.stringify(n),
381
383
  __VELO_BUILD_HASH__: JSON.stringify(process.env.VELO_BUILD_HASH || Date.now().toString(36)),
382
384
  __VELO_CLIENT_JS__: JSON.stringify(t),
383
- __VELO_CLIENT_CSS__: JSON.stringify(n)
385
+ __VELO_CLIENT_CSS__: JSON.stringify(i)
384
386
  },
385
387
  resolve: {
386
388
  alias: {
@@ -390,7 +392,7 @@ function J() {
390
392
  }
391
393
  };
392
394
  return r ? s.build = {
393
- ssr: g,
395
+ ssr: h,
394
396
  outDir: "dist",
395
397
  emptyOutDir: !1,
396
398
  copyPublicDir: !1,
@@ -399,11 +401,11 @@ function J() {
399
401
  entryFileNames: "server.js"
400
402
  }
401
403
  }
402
- } : l || (s.build = {
404
+ } : c || (s.build = {
403
405
  manifest: !0,
404
406
  outDir: "dist/client",
405
407
  rollupOptions: {
406
- input: x,
408
+ input: g,
407
409
  output: {
408
410
  entryFileNames: "client.[hash].js",
409
411
  assetFileNames: (o) => o.names?.[0]?.endsWith(".css") ? "client.[hash].css" : "[name].[hash][extname]"
@@ -418,11 +420,11 @@ function M() {
418
420
  name: "velo:static-url",
419
421
  apply: "build",
420
422
  enforce: "post",
421
- generateBundle(u, c) {
423
+ generateBundle(u, l) {
422
424
  const r = process.env.STATIC_BASE_URL || "";
423
425
  if (r)
424
- for (const l of Object.values(c))
425
- l.type === "asset" && typeof l.source == "string" && l.fileName.endsWith(".css") && (l.source = l.source.replace(
426
+ for (const c of Object.values(l))
427
+ c.type === "asset" && typeof c.source == "string" && c.fileName.endsWith(".css") && (c.source = c.source.replace(
426
428
  /url\(\s*(['"]?)\/(?!\/)/g,
427
429
  `url($1${r}/`
428
430
  ));
@@ -430,14 +432,14 @@ function M() {
430
432
  };
431
433
  }
432
434
  function Z(u) {
433
- const c = u ?? {}, r = c.appDirectory ?? "./app";
435
+ const l = u ?? {}, r = l.appDirectory ?? "./app";
434
436
  return [
435
- J(),
436
- B(c, r),
437
+ B(),
438
+ k(l, r),
437
439
  M(),
438
- C(),
440
+ D(),
439
441
  F({
440
- entry: g
442
+ entry: h
441
443
  }),
442
444
  H()
443
445
  ];
@@ -452,11 +454,11 @@ function H() {
452
454
  }
453
455
  export {
454
456
  j as buildFullPathMap,
455
- A as collectFullPaths,
457
+ P as collectFullPaths,
456
458
  w as injectMetadata,
457
459
  $ as removeLoaders,
458
- k as removeMiddlewares,
459
- V as transformActionsForClient,
460
- R as transformLoaderFunctions,
460
+ J as removeMiddlewares,
461
+ R as transformActionsForClient,
462
+ V as transformLoaderFunctions,
461
463
  Z as veloPlugin
462
464
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "type": "module",
5
5
  "description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
6
6
  "keywords": [