@mauroandre/velojs 0.0.50 → 0.0.52

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,15 +1,15 @@
1
1
  import d from "node:path";
2
2
  import g from "node:fs";
3
3
  import R from "@preact/preset-vite";
4
- import $, { defaultOptions as U } from "@hono/vite-dev-server";
5
- import { parse as h } from "@babel/parser";
4
+ import $, { defaultOptions as J } from "@hono/vite-dev-server";
5
+ import { parse as _ } from "@babel/parser";
6
6
  import j from "@babel/traverse";
7
7
  import L from "@babel/generator";
8
8
  import * as e from "@babel/types";
9
- import { buildGraph as W } from "./graph.js";
10
- const m = typeof j == "function" ? j : j.default, v = typeof L == "function" ? L : L.default;
11
- function J(u, o, n, i) {
12
- const l = h(u, {
9
+ import { buildGraph as U } from "./graph.js";
10
+ const m = typeof j == "function" ? j : j.default, h = typeof L == "function" ? L : L.default;
11
+ function W(u, o, n, i) {
12
+ const l = _(u, {
13
13
  sourceType: "module",
14
14
  plugins: ["typescript", "jsx"]
15
15
  });
@@ -22,7 +22,7 @@ function J(u, o, n, i) {
22
22
  const r = c.declarations[0];
23
23
  if (r && e.isIdentifier(r.id, { name: "metadata" }) && e.isObjectExpression(r.init)) {
24
24
  t = !0;
25
- const f = r.init.properties.filter((_) => e.isObjectProperty(_) && e.isIdentifier(_.key) ? _.key.name !== "moduleId" && _.key.name !== "fullPath" && _.key.name !== "path" : !0), y = [
25
+ const f = r.init.properties.filter((v) => e.isObjectProperty(v) && e.isIdentifier(v.key) ? v.key.name !== "moduleId" && v.key.name !== "fullPath" && v.key.name !== "path" : !0), y = [
26
26
  e.objectProperty(
27
27
  e.identifier("moduleId"),
28
28
  e.stringLiteral(o)
@@ -70,10 +70,10 @@ function J(u, o, n, i) {
70
70
  );
71
71
  l.program.body.unshift(c);
72
72
  }
73
- return v(l, { retainLines: !0 }).code;
73
+ return h(l, { retainLines: !0 }).code;
74
74
  }
75
- function B(u, o) {
76
- const n = h(u, {
75
+ function M(u, o) {
76
+ const n = _(u, {
77
77
  sourceType: "module",
78
78
  plugins: ["typescript", "jsx"]
79
79
  });
@@ -84,10 +84,10 @@ function B(u, o) {
84
84
  const c = l.node.arguments, r = e.stringLiteral(o), p = c[0];
85
85
  e.isStringLiteral(p) && p.value.includes("/") || (l.node.arguments = [r, ...c]);
86
86
  }
87
- }), v(n, { retainLines: !0 }).code;
87
+ }), h(n, { retainLines: !0 }).code;
88
88
  }
89
- function M(u, o) {
90
- const n = h(u, {
89
+ function B(u, o) {
90
+ const n = _(u, {
91
91
  sourceType: "module",
92
92
  plugins: ["typescript", "jsx"]
93
93
  });
@@ -104,7 +104,7 @@ function M(u, o) {
104
104
  const p = r.params, f = H(o, c, p);
105
105
  r.body = e.blockStatement([e.returnStatement(f)]), G(r, p);
106
106
  }
107
- }), v(n, { retainLines: !0 }).code;
107
+ }), h(n, { retainLines: !0 }).code;
108
108
  }
109
109
  function H(u, o, n) {
110
110
  const i = `/_action/${u}/${o}`;
@@ -203,7 +203,7 @@ function G(u, o) {
203
203
  }
204
204
  }
205
205
  function z(u, o) {
206
- const n = h(u, {
206
+ const n = _(u, {
207
207
  sourceType: "module",
208
208
  plugins: ["typescript", "jsx"]
209
209
  });
@@ -227,10 +227,10 @@ function z(u, o) {
227
227
  )
228
228
  ]), a.id.typeAnnotation = null;
229
229
  }
230
- }), v(n, { retainLines: !0 }).code;
230
+ }), h(n, { retainLines: !0 }).code;
231
231
  }
232
232
  function Y(u, o) {
233
- const n = h(u, {
233
+ const n = _(u, {
234
234
  sourceType: "module",
235
235
  plugins: ["typescript", "jsx"]
236
236
  });
@@ -254,10 +254,10 @@ function Y(u, o) {
254
254
  )
255
255
  ]), a.id.typeAnnotation = null;
256
256
  }
257
- }), v(n, { retainLines: !0 }).code;
257
+ }), h(n, { retainLines: !0 }).code;
258
258
  }
259
259
  function X(u) {
260
- const o = h(u, {
260
+ const o = _(u, {
261
261
  sourceType: "module",
262
262
  plugins: ["typescript", "jsx"]
263
263
  });
@@ -268,14 +268,14 @@ function X(u) {
268
268
  const t = l.declarations[0];
269
269
  !t || !e.isIdentifier(t.id) || t.id.name === "loader" && i.remove();
270
270
  }
271
- }), v(o, { retainLines: !0 }).code;
271
+ }), h(o, { retainLines: !0 }).code;
272
272
  }
273
273
  function q(u) {
274
- const o = h(u, {
274
+ const o = _(u, {
275
275
  sourceType: "module",
276
276
  plugins: ["typescript", "jsx"]
277
277
  }), n = /* @__PURE__ */ new Set();
278
- S(o.program, n);
278
+ x(o.program, n);
279
279
  let i = !1;
280
280
  return m(o, {
281
281
  ImportDeclaration(t) {
@@ -284,10 +284,10 @@ function q(u) {
284
284
  const s = a.filter((c) => n.has(c.local.name));
285
285
  s.length !== a.length && (i = !0, s.length === 0 ? t.remove() : t.node.specifiers = s);
286
286
  }
287
- }), i ? v(o, { retainLines: !0 }).code : u;
287
+ }), i ? h(o, { retainLines: !0 }).code : u;
288
288
  }
289
289
  function K(u) {
290
- const o = h(u, {
290
+ const o = _(u, {
291
291
  sourceType: "module",
292
292
  plugins: ["typescript", "jsx"]
293
293
  }), n = [];
@@ -298,9 +298,9 @@ function K(u) {
298
298
  }), n.length === 0) return u;
299
299
  const i = /* @__PURE__ */ new Set();
300
300
  for (const s of n)
301
- S(s, i);
301
+ x(s, i);
302
302
  const l = /* @__PURE__ */ new Set();
303
- S(o.program, l);
303
+ x(o.program, l);
304
304
  const t = /* @__PURE__ */ new Set();
305
305
  for (const s of i)
306
306
  l.has(s) || t.add(s);
@@ -309,9 +309,9 @@ function K(u) {
309
309
  const c = s.node.specifiers, r = c.filter((p) => !t.has(p.local.name));
310
310
  r.length === 0 ? s.remove() : r.length !== c.length && (s.node.specifiers = r);
311
311
  }
312
- }), v(o, { retainLines: !0 }).code;
312
+ }), h(o, { retainLines: !0 }).code;
313
313
  }
314
- function S(u, o) {
314
+ function x(u, o) {
315
315
  const n = (i) => {
316
316
  if (!(!i || typeof i != "object")) {
317
317
  if (Array.isArray(i)) {
@@ -354,7 +354,7 @@ function Z(u) {
354
354
  return null;
355
355
  }
356
356
  function ee(u) {
357
- const o = h(u, {
357
+ const o = _(u, {
358
358
  sourceType: "module",
359
359
  plugins: ["typescript", "jsx"]
360
360
  }), n = [], i = (c) => {
@@ -378,9 +378,9 @@ function ee(u) {
378
378
  }), n.length === 0) return u;
379
379
  const l = /* @__PURE__ */ new Set();
380
380
  for (const c of n)
381
- S(c, l);
381
+ x(c, l);
382
382
  const t = /* @__PURE__ */ new Set();
383
- S(o.program, t);
383
+ x(o.program, t);
384
384
  const a = /* @__PURE__ */ new Set();
385
385
  for (const c of l)
386
386
  t.has(c) || a.add(c);
@@ -389,10 +389,10 @@ function ee(u) {
389
389
  const r = c.node.specifiers, p = r.filter((f) => !a.has(f.local.name));
390
390
  p.length === 0 ? c.remove() : p.length !== r.length && (c.node.specifiers = p);
391
391
  }
392
- }), v(o, { retainLines: !0 }).code;
392
+ }), h(o, { retainLines: !0 }).code;
393
393
  }
394
394
  function A(u) {
395
- const o = h(u, {
395
+ const o = _(u, {
396
396
  sourceType: "module",
397
397
  plugins: ["typescript", "jsx"]
398
398
  }), n = /* @__PURE__ */ new Map();
@@ -408,7 +408,7 @@ function A(u) {
408
408
  ExportDefaultDeclaration(t) {
409
409
  const a = t.node.declaration;
410
410
  let s = null;
411
- e.isArrayExpression(a) ? s = a : (e.isTSSatisfiesExpression(a) || e.isTSAsExpression(a)) && e.isArrayExpression(a.expression) && (s = a.expression), s && D(s.elements, "", i);
411
+ e.isArrayExpression(a) ? s = a : (e.isTSSatisfiesExpression(a) || e.isTSAsExpression(a)) && e.isArrayExpression(a.expression) && (s = a.expression), s && C(s.elements, "", i);
412
412
  }
413
413
  });
414
414
  const l = /* @__PURE__ */ new Map();
@@ -421,7 +421,7 @@ function A(u) {
421
421
  }
422
422
  return l;
423
423
  }
424
- function D(u, o, n) {
424
+ function C(u, o, n) {
425
425
  for (const i of u) {
426
426
  if (!e.isObjectExpression(i)) continue;
427
427
  let l = "", t = o, a = null, s = null;
@@ -437,10 +437,10 @@ function D(u, o, n) {
437
437
  path: l
438
438
  });
439
439
  }
440
- s && D(s.elements, t, n);
440
+ s && C(s.elements, t, n);
441
441
  }
442
442
  }
443
- const E = "virtual:velo/server-entry", b = "virtual:velo/client-entry", P = "\0" + E, N = "\0" + b;
443
+ const E = "virtual:velo/server-entry", b = "virtual:velo/client-entry", N = "\0" + E, P = "\0" + b;
444
444
  function te(u, o) {
445
445
  let n = d.resolve(process.cwd(), o);
446
446
  const i = u.routesFile ?? "routes.tsx", l = /* @__PURE__ */ new Map();
@@ -470,11 +470,11 @@ function te(u, o) {
470
470
  }
471
471
  },
472
472
  resolveId(t) {
473
- return t === E || t.endsWith(E) ? P : t === b || t.endsWith(b) || t === "/__velo_client.js" ? N : null;
473
+ return t === E || t.endsWith(E) ? N : t === b || t.endsWith(b) || t === "/__velo_client.js" ? P : null;
474
474
  },
475
475
  load(t) {
476
476
  const a = u.routesFile ?? "routes.tsx", s = u.serverInit ?? "server.tsx", c = u.clientInit ?? "client.tsx", r = d.join(n, a).replace(/\.tsx?$/, ".js"), p = d.join(n, s).replace(/\.tsx?$/, ".js"), f = d.join(n, c).replace(/\.tsx?$/, ".js");
477
- return t === P ? `
477
+ return t === N ? `
478
478
  globalThis.__veloBuildHash = __VELO_BUILD_HASH__;
479
479
  globalThis.__veloClientJs = __VELO_CLIENT_JS__;
480
480
  globalThis.__veloClientCss = __VELO_CLIENT_CSS__;
@@ -483,8 +483,8 @@ import routes from "${r}";
483
483
  import { startServer } from "@mauroandre/velojs/server";
484
484
 
485
485
  export { routes };
486
- export default await startServer({ routes, port: __VELO_CONFIG_PORT__ });
487
- ` : t === N ? `
486
+ export default await startServer({ routes, port: __VELO_CONFIG_PORT__, hostname: __VELO_CONFIG_HOSTNAME__ });
487
+ ` : t === P ? `
488
488
  import "${f}";
489
489
  import routes from "${r}";
490
490
  import { startClient } from "@mauroandre/velojs/client";
@@ -498,18 +498,18 @@ startClient({ routes });
498
498
  let r = t, p = !1;
499
499
  const f = /middlewares:\s*\[/.test(t), y = /export\s+(const|function)\s+Component/.test(
500
500
  t
501
- ), _ = /export\s+(const|function)\s+loader/.test(t), C = /export\s+const\s+action_\w+/.test(t), I = /export\s+const\s+stream_\w+/.test(t), T = /export\s+const\s+socket_\w+/.test(t), w = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), k = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t), F = /\bhandler\s*:/.test(t), V = d.join(n, i);
502
- if (!c && f && (r = K(r), p = !0), !c && F && a === V && (r = ee(r), p = !0), y || _ || C || I || T || w || k) {
503
- const x = d.relative(n, a).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), O = l.get(x);
504
- r = J(r, x, O?.fullPath, O?.path), r = B(r, x), c || (r = M(
501
+ ), v = /export\s+(const|function)\s+loader/.test(t), D = /export\s+const\s+action_\w+/.test(t), I = /export\s+const\s+stream_\w+/.test(t), T = /export\s+const\s+socket_\w+/.test(t), w = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), F = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t), k = /\bhandler\s*:/.test(t), V = d.join(n, i);
502
+ if (!c && f && (r = K(r), p = !0), !c && k && a === V && (r = ee(r), p = !0), y || v || D || I || T || w || F) {
503
+ const S = d.relative(n, a).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), O = l.get(S);
504
+ r = W(r, S, O?.fullPath, O?.path), r = M(r, S), c || (r = B(
505
505
  r,
506
- x
506
+ S
507
507
  )), !c && I && (r = z(
508
508
  r,
509
- x
509
+ S
510
510
  )), !c && T && (r = Y(
511
511
  r,
512
- x
512
+ S
513
513
  )), c || (r = X(r)), c || (r = q(r)), p = !0;
514
514
  }
515
515
  return p ? {
@@ -541,7 +541,9 @@ function re(u) {
541
541
  __VELO_CLIENT_CSS__: JSON.stringify(c),
542
542
  // Baked into the server bundle as startServer's port fallback.
543
543
  // null when unset → startServer falls back to PORT env / 3000.
544
- __VELO_CONFIG_PORT__: JSON.stringify(u.port ?? null)
544
+ __VELO_CONFIG_PORT__: JSON.stringify(u.port ?? null),
545
+ // Same for the bind interface: null → HOST env / Node default.
546
+ __VELO_CONFIG_HOSTNAME__: JSON.stringify(u.hostname ?? null)
545
547
  },
546
548
  resolve: {
547
549
  alias: {
@@ -599,7 +601,7 @@ function ie(u, o) {
599
601
  if (!n) return;
600
602
  const s = d.resolve(n, o);
601
603
  if (!g.existsSync(s)) return;
602
- const c = W(s), r = d.join(n, ".velojs");
604
+ const c = U(s), r = d.join(n, ".velojs");
603
605
  g.mkdirSync(r, { recursive: !0 }), g.writeFileSync(
604
606
  d.join(r, "graph.json"),
605
607
  JSON.stringify(c)
@@ -624,7 +626,7 @@ function ie(u, o) {
624
626
  }
625
627
  function se(u) {
626
628
  return [
627
- ...U.exclude,
629
+ ...J.exclude,
628
630
  /.*\.mjs$/,
629
631
  ...u.devServerExclude ?? []
630
632
  ];
@@ -654,15 +656,15 @@ function oe() {
654
656
  }
655
657
  export {
656
658
  A as buildFullPathMap,
657
- D as collectFullPaths,
659
+ C as collectFullPaths,
658
660
  se as devServerExcludeFor,
659
- J as injectMetadata,
661
+ W as injectMetadata,
660
662
  q as pruneClientOnlyImports,
661
663
  ee as removeEndpointRoutes,
662
664
  X as removeLoaders,
663
665
  K as removeMiddlewares,
664
- M as transformActionsForClient,
665
- B as transformLoaderFunctions,
666
+ B as transformActionsForClient,
667
+ M as transformLoaderFunctions,
666
668
  Y as transformSocketsForClient,
667
669
  z as transformStreamsForClient,
668
670
  ye as veloPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "type": "module",
5
5
  "description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
6
6
  "keywords": [