@mauroandre/velojs 0.0.33 → 0.0.34

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/client.js CHANGED
@@ -1,53 +1,52 @@
1
- import { jsx as n } from "preact/jsx-runtime";
1
+ import { jsx as c } from "preact/jsx-runtime";
2
2
  import { hydrate as m } from "preact";
3
- import { Router as f, Route as l, Switch as s } from "wouter-preact";
4
- const p = (o, e) => o.reduceRight((r, i) => /* @__PURE__ */ n(i, { children: r }), e), h = (o, e = [], r = "") => {
3
+ import { Router as a, Route as y, Switch as R } from "wouter-preact";
4
+ const $ = (o, t) => o.reduceRight((e, l) => /* @__PURE__ */ c(l, { children: e }), t), d = (o, t, e) => t ? e && t === "/" ? o || "/" : t.startsWith("/") ? o + t : o + "/" + t : o, h = (o, t = [], e = "", l = "") => {
5
5
  const i = [];
6
6
  for (let u = 0; u < o.length; u++) {
7
- const t = o[u], c = `${r}${u}`;
8
- if (!t.module) {
9
- t.children && i.push(...h(t.children, e, `${c}-`));
7
+ const n = o[u], r = `${l}${u}`;
8
+ if (!n.module) {
9
+ if (n.children) {
10
+ const s = d(e, n.path, !1);
11
+ i.push(
12
+ ...h(n.children, t, s, `${r}-`)
13
+ );
14
+ }
10
15
  continue;
11
16
  }
12
- const d = t.module.Component;
13
- if (!t.children) {
17
+ const f = n.module.Component;
18
+ if (!n.children) {
19
+ const s = n.path === "*" ? "*" : d(e, n.path, !0);
14
20
  i.push(
15
- /* @__PURE__ */ n(l, { path: t.path || "", children: p(e, /* @__PURE__ */ n(d, {})) }, c)
21
+ /* @__PURE__ */ c(y, { path: s || "/", children: $(t, /* @__PURE__ */ c(f, {})) }, r)
16
22
  );
17
23
  continue;
18
24
  }
19
- if (t.isRoot) {
25
+ if (n.isRoot) {
20
26
  i.push(
21
- /* @__PURE__ */ n(s, { children: h(t.children, [], `${c}-`) }, c)
22
- );
23
- continue;
24
- }
25
- if (!t.path) {
26
- i.push(
27
- ...h(
28
- t.children,
29
- [...e, d],
30
- `${c}-`
31
- )
27
+ /* @__PURE__ */ c(R, { children: h(n.children, [], "", `${r}-`) }, r)
32
28
  );
33
29
  continue;
34
30
  }
31
+ const p = d(e, n.path, !1);
35
32
  i.push(
36
- /* @__PURE__ */ n(l, { path: t.path, nest: !0, children: p(
37
- e,
38
- /* @__PURE__ */ n(d, { children: /* @__PURE__ */ n(s, { children: h(t.children, [], `${c}-`) }) })
39
- ) }, c)
33
+ ...h(
34
+ n.children,
35
+ [...t, f],
36
+ p,
37
+ `${r}-`
38
+ )
40
39
  );
41
40
  }
42
41
  return i;
43
- }, a = ({ routes: o }) => {
44
- const e = h(o);
45
- return /* @__PURE__ */ n(f, { children: e });
46
- }, C = (o) => {
47
- const { routes: e } = o, r = document.querySelector("body");
48
- r && m(/* @__PURE__ */ n(a, { routes: e }), r);
42
+ }, C = ({ routes: o }) => {
43
+ const t = h(o);
44
+ return /* @__PURE__ */ c(a, { children: t });
45
+ }, S = (o) => {
46
+ const { routes: t } = o, e = document.querySelector("body");
47
+ e && m(/* @__PURE__ */ c(C, { routes: t }), e);
49
48
  };
50
49
  export {
51
- a as ClientRoutes,
52
- C as startClient
50
+ C as ClientRoutes,
51
+ S as startClient
53
52
  };
@@ -48,9 +48,8 @@ type LinkProps = Omit<WouterLinkProps, "to" | "href"> & {
48
48
  */
49
49
  search?: Record<string, string> | undefined;
50
50
  /**
51
- * When true, ignores current URL params and uses fullPath as-is
52
- * By default, params are extracted from current URL and substituted
53
- * @default false
51
+ * @deprecated No-op. Module refs always resolve to their fullPath now.
52
+ * Kept for backward compatibility.
54
53
  */
55
54
  absolute?: boolean;
56
55
  };
@@ -64,15 +63,12 @@ export declare function substituteParams(path: string, params: Record<string, st
64
63
  *
65
64
  * @example
66
65
  * ```tsx
67
- * // With string path
66
+ * // With string path (root-absolute; a leading "~/" is also accepted)
68
67
  * <Link to="/login">Login</Link>
69
68
  *
70
- * // With route module (relative - uses path, works with nest)
69
+ * // With route module (navigates to its fullPath)
71
70
  * <Link to={McpPage}>MCP</Link>
72
71
  *
73
- * // With route module (absolute - uses fullPath)
74
- * <Link to={LoginPage} absolute>Login</Link>
75
- *
76
72
  * // With explicit params
77
73
  * <Link to={UserPage} params={{ id: "123" }}>View User</Link>
78
74
  * ```
@@ -1,7 +1,7 @@
1
1
  import { jsx as o, jsxs as p, Fragment as h } from "preact/jsx-runtime";
2
- import { useRouter as L, Link as C } from "wouter-preact";
3
- import { __veloUpdatePending as S } from "./hooks.js";
4
- function O({ basePath: e, favicon: t = "/favicon.ico" } = {}) {
2
+ import { useRouter as v, Link as L } from "wouter-preact";
3
+ import { __veloUpdatePending as C } from "./hooks.js";
4
+ function k({ 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" : "");
7
7
  const r = t === !1 ? void 0 : t.endsWith(".svg") ? "image/svg+xml" : t.endsWith(".png") ? "image/png" : "image/x-icon", i = t !== !1 && /* @__PURE__ */ o("link", { rel: "icon", href: `${e}${t}`, type: r });
@@ -24,33 +24,33 @@ function $(e, t) {
24
24
  n = n.replace(`:${r}`, i);
25
25
  return n;
26
26
  }
27
- function j({ to: e, params: t, search: n, absolute: r, ...i }) {
28
- const l = typeof e != "string", c = L(), f = l ? (r ? e.metadata?.fullPath : e.metadata?.path) ?? "/" : e, _ = t ? $(f, t) : f, m = l && r ? `~${_}` : _, u = n ? `?${new URLSearchParams(n).toString()}` : "", g = `${m}${u}`;
29
- if (typeof window < "u" && S.value) {
30
- let a;
27
+ function O({ to: e, params: t, search: n, absolute: r, ...i }) {
28
+ const l = typeof e != "string", c = v(), f = l ? e.metadata?.fullPath ?? "/" : e, u = t ? $(f, t) : f, a = n ? `?${new URLSearchParams(n).toString()}` : "", g = `${u}${a}`;
29
+ if (typeof window < "u" && C.value) {
30
+ let _;
31
31
  if (l) {
32
32
  const s = e.metadata?.fullPath ?? f;
33
- a = `${t ? $(s, t) : s}${u}`;
33
+ _ = `${t ? $(s, t) : s}${a}`;
34
34
  } else {
35
- const s = _.replace(/^~/, "");
36
- a = `${!_.startsWith("~") && c.base ? c.base : ""}${s}${u}`;
35
+ const s = u.replace(/^~/, "");
36
+ _ = `${!u.startsWith("~") && c.base ? c.base : ""}${s}${a}`;
37
37
  }
38
- const { onClick: d, ...v } = i;
38
+ const { onClick: d, ...m } = i;
39
39
  return /* @__PURE__ */ o(
40
40
  "a",
41
41
  {
42
- href: a,
42
+ href: _,
43
43
  onClick: (s) => {
44
- d && d(s), s.defaultPrevented || (s.preventDefault(), window.location.href = a);
44
+ d && d(s), s.defaultPrevented || (s.preventDefault(), window.location.href = _);
45
45
  },
46
- ...v
46
+ ...m
47
47
  }
48
48
  );
49
49
  }
50
- return /* @__PURE__ */ o(C, { to: g, ...i });
50
+ return /* @__PURE__ */ o(L, { to: g, ...i });
51
51
  }
52
52
  export {
53
- j as Link,
54
- O as Scripts,
53
+ O as Link,
54
+ k as Scripts,
55
55
  $ as substituteParams
56
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "type": "module",
5
5
  "description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
6
6
  "keywords": [