@mauroandre/velojs 0.0.17 → 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,14 +1,14 @@
1
1
  import d from "node:path";
2
- import _ from "node:fs";
3
- import C from "@preact/preset-vite";
4
- import F from "@hono/vite-dev-server";
5
- import { parse as v } from "@babel/parser";
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
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, c, r, l) {
11
- const i = 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
  });
@@ -16,28 +16,28 @@ function w(u, c, r, l) {
16
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), h = [
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
- e.stringLiteral(c)
27
+ e.stringLiteral(l)
28
28
  )
29
29
  ];
30
- r !== void 0 && h.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
- ), l !== void 0 && h.push(
35
+ ), c !== void 0 && h.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
+ ), o.init.properties = [...h, ...f];
41
41
  }
42
42
  }
43
43
  }
@@ -45,21 +45,21 @@ 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
- 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
- ), 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
- 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 w(u, c, r, l) {
67
67
  )
68
68
  ])
69
69
  );
70
- i.program.body.unshift(o);
70
+ i.program.body.unshift(a);
71
71
  }
72
- return S(i, { retainLines: !0 }).code;
72
+ return v(i, { retainLines: !0 }).code;
73
73
  }
74
- function R(u, c) {
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, {
79
+ return m(n, {
80
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]);
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 V(u, c) {
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, {
93
+ return m(n, {
94
94
  ExportNamedDeclaration(i) {
95
95
  const t = i.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 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 = n.init;
102
- if (!e.isArrowFunctionExpression(a) || !a.async) return;
103
- const p = a.params, f = U(c, 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, c, r) {
109
- const l = `/_action/${u}/${c}`;
110
- return r.length === 0 ? e.callExpression(
108
+ function U(u, l, n) {
109
+ const c = `/_action/${u}/${l}`;
110
+ return n.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,14 +175,14 @@ 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];
181
- if (e.isObjectPattern(r)) {
182
- let l = null;
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]);
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]);
186
186
  }
187
187
  const i = e.objectProperty(
188
188
  e.identifier("body"),
@@ -191,196 +191,228 @@ function W(u, c) {
191
191
  !0
192
192
  // shorthand
193
193
  ), t = e.objectPattern([i]);
194
- l && (t.typeAnnotation = e.tsTypeAnnotation(
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
- function $(u) {
205
- const c = v(u, {
204
+ function J(u, l) {
205
+ const n = _(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;
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, {
233
+ sourceType: "module",
234
+ plugins: ["typescript", "jsx"]
235
+ });
236
+ return m(l, {
237
+ ExportNamedDeclaration(c) {
238
+ const i = c.node.declaration;
212
239
  if (!e.isVariableDeclaration(i)) return;
213
240
  const t = i.declarations[0];
214
- !t || !e.isIdentifier(t.id) || t.id.name === "loader" && l.remove();
241
+ !t || !e.isIdentifier(t.id) || t.id.name === "loader" && c.remove();
215
242
  }
216
- }), S(c, { retainLines: !0 }).code;
243
+ }), v(l, { retainLines: !0 }).code;
217
244
  }
218
- function k(u) {
219
- const c = v(u, {
245
+ function B(u) {
246
+ const l = _(u, {
220
247
  sourceType: "module",
221
248
  plugins: ["typescript", "jsx"]
222
- }), r = /* @__PURE__ */ new Set();
223
- return m(c, {
249
+ }), n = /* @__PURE__ */ new Set();
250
+ return m(l, {
224
251
  ObjectProperty(i) {
225
252
  if (e.isIdentifier(i.node.key, { name: "middlewares" }) && e.isArrayExpression(i.node.value)) {
226
253
  for (const t of i.node.value.elements)
227
- e.isIdentifier(t) && r.add(t.name);
254
+ e.isIdentifier(t) && n.add(t.name);
228
255
  i.remove();
229
256
  }
230
257
  }
231
- }), r.size === 0 ? u : (m(c, {
258
+ }), n.size === 0 ? u : (m(l, {
232
259
  ImportDeclaration(i) {
233
- const t = i.node.specifiers, n = t.filter((s) => {
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
- n.length === 0 ? i.remove() : n.length !== t.length && (i.node.specifiers = n);
267
+ r.length === 0 ? i.remove() : r.length !== t.length && (i.node.specifiers = r);
241
268
  }
242
- }), S(c, { retainLines: !0 }).code);
269
+ }), v(l, { retainLines: !0 }).code);
243
270
  }
244
- function j(u) {
245
- const c = v(u, {
271
+ function T(u) {
272
+ const l = _(u, {
246
273
  sourceType: "module",
247
274
  plugins: ["typescript", "jsx"]
248
- }), r = /* @__PURE__ */ new Map();
249
- m(c, {
275
+ }), n = /* @__PURE__ */ new Map();
276
+ m(l, {
250
277
  ImportDeclaration(t) {
251
- const n = 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, n);
280
+ e.isImportNamespaceSpecifier(s) && n.set(s.local.name, r);
254
281
  }
255
282
  });
256
- const l = /* @__PURE__ */ new Map();
257
- m(c, {
283
+ const c = /* @__PURE__ */ new Map();
284
+ m(l, {
258
285
  ExportDefaultDeclaration(t) {
259
- const n = t.node.declaration;
286
+ const r = t.node.declaration;
260
287
  let s = null;
261
- e.isArrayExpression(n) ? s = n : e.isTSSatisfiesExpression(n) && e.isArrayExpression(n.expression) && (s = n.expression), s && A(s.elements, "", l);
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
291
  const i = /* @__PURE__ */ new Map();
265
- for (const [t, n] of l) {
266
- const s = r.get(t);
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
- i.set(o, n);
295
+ const a = s.replace(/^\.\//, "").replace(/\.(tsx?|jsx?|js)$/, "");
296
+ i.set(a, r);
270
297
  }
271
298
  }
272
299
  return i;
273
300
  }
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) {
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) && (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);
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);
282
309
  }
283
- if (n) {
284
- const a = !s && i === "/" ? c || "/" : t;
285
- r.set(n, {
286
- fullPath: a,
310
+ if (r) {
311
+ const o = !s && i === "/" ? l || "/" : t;
312
+ n.set(r, {
313
+ fullPath: o,
287
314
  path: i
288
315
  });
289
316
  }
290
- s && A(s.elements, t, r);
317
+ s && A(s.elements, t, n);
291
318
  }
292
319
  }
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();
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, c);
328
+ n = d.resolve(t.root, l);
302
329
  },
303
330
  buildStart() {
304
- const t = d.join(r, l);
305
- if (_.existsSync(t)) {
306
- const n = _.readFileSync(t, "utf-8"), s = j(n);
331
+ const t = d.join(n, c);
332
+ if (L.existsSync(t)) {
333
+ const r = L.readFileSync(t, "utf-8"), s = T(r);
307
334
  i.clear();
308
- for (const [o, a] of s)
309
- i.set(o, a);
335
+ for (const [a, o] of s)
336
+ i.set(a, o);
310
337
  }
311
338
  },
312
- handleHotUpdate({ file: t, server: n }) {
313
- const s = d.join(r, l);
339
+ handleHotUpdate({ file: t, server: r }) {
340
+ const s = d.join(n, c);
314
341
  if (t === s) {
315
- const o = _.readFileSync(s, "utf-8"), a = j(o);
342
+ const a = L.readFileSync(s, "utf-8"), o = T(a);
316
343
  i.clear();
317
- for (const [p, f] of a)
344
+ for (const [p, f] of o)
318
345
  i.set(p, f);
319
- return n.ws.send({ type: "full-reload" }), [];
346
+ return r.ws.send({ type: "full-reload" }), [];
320
347
  }
321
348
  },
322
349
  resolveId(t) {
323
- return t === g || t.endsWith(g) ? T : t === x || t.endsWith(x) || t === "/__velo_client.js" ? P : 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 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");
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__;
356
+ globalThis.__veloClientJs = __VELO_CLIENT_JS__;
357
+ globalThis.__veloClientCss = __VELO_CLIENT_CSS__;
329
358
  import "${p}";
330
- import routes from "${a}";
359
+ import routes from "${o}";
331
360
  import { startServer } from "@mauroandre/velojs/server";
332
361
 
333
362
  export { routes };
334
363
  export default await startServer({ routes });
335
364
  ` : t === P ? `
336
365
  import "${f}";
337
- import routes from "${a}";
366
+ import routes from "${o}";
338
367
  import { startClient } from "@mauroandre/velojs/client";
339
368
 
340
369
  startClient({ routes });
341
370
  ` : null;
342
371
  },
343
- transform(t, n, s) {
344
- const o = s?.ssr === !0;
345
- if (n.startsWith("\0") || n.includes("/.velojs/") || !n.endsWith(".tsx") && !n.endsWith(".ts") || !n.startsWith(r)) return null;
346
- let a = t, p = !1;
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;
347
376
  const f = /middlewares:\s*\[/.test(t), h = /export\s+(const|function)\s+Component/.test(
348
377
  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(
353
- a,
354
- L
355
- )), 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;
356
388
  }
357
389
  return p ? {
358
- code: a,
390
+ code: o,
359
391
  map: null
360
392
  } : null;
361
393
  }
362
394
  };
363
395
  }
364
- function J() {
396
+ function H() {
365
397
  return {
366
398
  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";
370
- if (r)
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)
371
403
  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]));
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]));
374
406
  } catch {
375
407
  }
376
408
  const s = {
377
409
  define: {
378
- "process.env.NODE_ENV": JSON.stringify(l ? "development" : "production"),
410
+ "process.env.NODE_ENV": JSON.stringify(c ? "development" : "production"),
379
411
  "process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (i ? "/client" : "")),
380
412
  __VELO_STATIC__: JSON.stringify(i),
381
413
  __VELO_BUILD_HASH__: JSON.stringify(process.env.VELO_BUILD_HASH || Date.now().toString(36)),
382
414
  __VELO_CLIENT_JS__: JSON.stringify(t),
383
- __VELO_CLIENT_CSS__: JSON.stringify(n)
415
+ __VELO_CLIENT_CSS__: JSON.stringify(r)
384
416
  },
385
417
  resolve: {
386
418
  alias: {
@@ -389,8 +421,8 @@ function J() {
389
421
  }
390
422
  }
391
423
  };
392
- return r ? s.build = {
393
- ssr: g,
424
+ return n ? s.build = {
425
+ ssr: x,
394
426
  outDir: "dist",
395
427
  emptyOutDir: !1,
396
428
  copyPublicDir: !1,
@@ -399,50 +431,50 @@ function J() {
399
431
  entryFileNames: "server.js"
400
432
  }
401
433
  }
402
- } : l || (s.build = {
434
+ } : c || (s.build = {
403
435
  manifest: !0,
404
436
  outDir: "dist/client",
405
437
  rollupOptions: {
406
- input: x,
438
+ input: S,
407
439
  output: {
408
440
  entryFileNames: "client.[hash].js",
409
- 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]"
410
442
  }
411
443
  }
412
444
  }), s;
413
445
  }
414
446
  };
415
447
  }
416
- function M() {
448
+ function Y() {
417
449
  return {
418
450
  name: "velo:static-url",
419
451
  apply: "build",
420
452
  enforce: "post",
421
- generateBundle(u, c) {
422
- const r = process.env.STATIC_BASE_URL || "";
423
- 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(
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(
426
458
  /url\(\s*(['"]?)\/(?!\/)/g,
427
- `url($1${r}/`
459
+ `url($1${n}/`
428
460
  ));
429
461
  }
430
462
  };
431
463
  }
432
- function Z(u) {
433
- const c = u ?? {}, r = c.appDirectory ?? "./app";
464
+ function te(u) {
465
+ const l = u ?? {}, n = l.appDirectory ?? "./app";
434
466
  return [
435
- J(),
436
- B(c, r),
437
- M(),
438
- C(),
439
- F({
440
- entry: g
467
+ H(),
468
+ M(l, n),
469
+ Y(),
470
+ F(),
471
+ w({
472
+ entry: x
441
473
  }),
442
- H()
474
+ z()
443
475
  ];
444
476
  }
445
- function H() {
477
+ function z() {
446
478
  return {
447
479
  name: "velo:ws-bridge",
448
480
  configureServer(u) {
@@ -451,12 +483,13 @@ function H() {
451
483
  };
452
484
  }
453
485
  export {
454
- j as buildFullPathMap,
486
+ T as buildFullPathMap,
455
487
  A as collectFullPaths,
456
- w as injectMetadata,
457
- $ as removeLoaders,
458
- k as removeMiddlewares,
459
- V as transformActionsForClient,
488
+ V as injectMetadata,
489
+ k as removeLoaders,
490
+ B as removeMiddlewares,
491
+ $ as transformActionsForClient,
460
492
  R as transformLoaderFunctions,
461
- Z as veloPlugin
493
+ J as transformStreamsForClient,
494
+ te as veloPlugin
462
495
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.17",
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"