@mauroandre/velojs 0.0.18 → 0.0.19

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