@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 +32 -33
- package/dist/components.d.ts +4 -8
- package/dist/components.js +17 -17
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1,53 +1,52 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as c } from "preact/jsx-runtime";
|
|
2
2
|
import { hydrate as m } from "preact";
|
|
3
|
-
import { Router as
|
|
4
|
-
const
|
|
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
|
|
8
|
-
if (!
|
|
9
|
-
|
|
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
|
|
13
|
-
if (!
|
|
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__ */
|
|
21
|
+
/* @__PURE__ */ c(y, { path: s || "/", children: $(t, /* @__PURE__ */ c(f, {})) }, r)
|
|
16
22
|
);
|
|
17
23
|
continue;
|
|
18
24
|
}
|
|
19
|
-
if (
|
|
25
|
+
if (n.isRoot) {
|
|
20
26
|
i.push(
|
|
21
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
...h(
|
|
34
|
+
n.children,
|
|
35
|
+
[...t, f],
|
|
36
|
+
p,
|
|
37
|
+
`${r}-`
|
|
38
|
+
)
|
|
40
39
|
);
|
|
41
40
|
}
|
|
42
41
|
return i;
|
|
43
|
-
},
|
|
44
|
-
const
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
},
|
|
47
|
-
const { routes:
|
|
48
|
-
|
|
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
|
-
|
|
52
|
-
|
|
50
|
+
C as ClientRoutes,
|
|
51
|
+
S as startClient
|
|
53
52
|
};
|
package/dist/components.d.ts
CHANGED
|
@@ -48,9 +48,8 @@ type LinkProps = Omit<WouterLinkProps, "to" | "href"> & {
|
|
|
48
48
|
*/
|
|
49
49
|
search?: Record<string, string> | undefined;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
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 (
|
|
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
|
* ```
|
package/dist/components.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as o, jsxs as p, Fragment as h } from "preact/jsx-runtime";
|
|
2
|
-
import { useRouter as
|
|
3
|
-
import { __veloUpdatePending as
|
|
4
|
-
function
|
|
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
|
|
28
|
-
const l = typeof e != "string", c =
|
|
29
|
-
if (typeof window < "u" &&
|
|
30
|
-
let
|
|
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
|
-
|
|
33
|
+
_ = `${t ? $(s, t) : s}${a}`;
|
|
34
34
|
} else {
|
|
35
|
-
const s =
|
|
36
|
-
|
|
35
|
+
const s = u.replace(/^~/, "");
|
|
36
|
+
_ = `${!u.startsWith("~") && c.base ? c.base : ""}${s}${a}`;
|
|
37
37
|
}
|
|
38
|
-
const { onClick: d, ...
|
|
38
|
+
const { onClick: d, ...m } = i;
|
|
39
39
|
return /* @__PURE__ */ o(
|
|
40
40
|
"a",
|
|
41
41
|
{
|
|
42
|
-
href:
|
|
42
|
+
href: _,
|
|
43
43
|
onClick: (s) => {
|
|
44
|
-
d && d(s), s.defaultPrevented || (s.preventDefault(), window.location.href =
|
|
44
|
+
d && d(s), s.defaultPrevented || (s.preventDefault(), window.location.href = _);
|
|
45
45
|
},
|
|
46
|
-
...
|
|
46
|
+
...m
|
|
47
47
|
}
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
return /* @__PURE__ */ o(
|
|
50
|
+
return /* @__PURE__ */ o(L, { to: g, ...i });
|
|
51
51
|
}
|
|
52
52
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
O as Link,
|
|
54
|
+
k as Scripts,
|
|
55
55
|
$ as substituteParams
|
|
56
56
|
};
|