@mauroandre/velojs 0.0.15 → 0.0.16
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/components.js +27 -19
- package/dist/hooks.js +37 -37
- package/package.json +1 -1
package/dist/components.js
CHANGED
|
@@ -1,48 +1,56 @@
|
|
|
1
|
-
import { jsx as o, jsxs as p, Fragment as
|
|
2
|
-
import {
|
|
3
|
-
import { __veloUpdatePending as
|
|
4
|
-
function
|
|
1
|
+
import { jsx as o, jsxs as p, Fragment as $ } from "preact/jsx-runtime";
|
|
2
|
+
import { useRouter as v, Link as E } from "wouter-preact";
|
|
3
|
+
import { __veloUpdatePending as y } from "./hooks.js";
|
|
4
|
+
function O({ 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 i = t !== !1 && /* @__PURE__ */ o("link", { rel: "icon", href: `${e}${t}`, type: "image/x-icon" });
|
|
8
8
|
if (n)
|
|
9
|
-
return /* @__PURE__ */ p(
|
|
9
|
+
return /* @__PURE__ */ p($, { children: [
|
|
10
10
|
i,
|
|
11
11
|
/* @__PURE__ */ o("script", { type: "module", src: "/@vite/client" }),
|
|
12
12
|
/* @__PURE__ */ o("script", { type: "module", src: "/__velo_client.js" })
|
|
13
13
|
] });
|
|
14
14
|
const r = typeof __VELO_CLIENT_JS__ < "u" ? __VELO_CLIENT_JS__ : "client.js";
|
|
15
|
-
return /* @__PURE__ */ p(
|
|
15
|
+
return /* @__PURE__ */ p($, { children: [
|
|
16
16
|
i,
|
|
17
17
|
/* @__PURE__ */ o("link", { rel: "stylesheet", href: `${e}/${typeof __VELO_CLIENT_CSS__ < "u" ? __VELO_CLIENT_CSS__ : "client.css"}` }),
|
|
18
18
|
/* @__PURE__ */ o("script", { type: "module", src: `${e}/${r}` })
|
|
19
19
|
] });
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function h(e, t) {
|
|
22
22
|
let n = e;
|
|
23
23
|
for (const [i, r] of Object.entries(t))
|
|
24
24
|
n = n.replace(`:${i}`, r);
|
|
25
25
|
return n;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const c = typeof e != "string",
|
|
29
|
-
if (typeof window < "u" &&
|
|
30
|
-
|
|
27
|
+
function j({ to: e, params: t, search: n, absolute: i, ...r }) {
|
|
28
|
+
const c = typeof e != "string", u = v(), _ = c ? (i ? e.metadata?.fullPath : e.metadata?.path) ?? "/" : e, l = t ? h(_, t) : _, L = c && i ? `~${l}` : l, a = n ? `?${new URLSearchParams(n).toString()}` : "", m = `${L}${a}`;
|
|
29
|
+
if (typeof window < "u" && y.value) {
|
|
30
|
+
let f;
|
|
31
|
+
if (c) {
|
|
32
|
+
const s = e.metadata?.fullPath ?? _;
|
|
33
|
+
f = `${t ? h(s, t) : s}${a}`;
|
|
34
|
+
} else {
|
|
35
|
+
const s = l.replace(/^~/, "");
|
|
36
|
+
f = `${!l.startsWith("~") && u.base ? u.base : ""}${s}${a}`;
|
|
37
|
+
}
|
|
38
|
+
const { onClick: d, ...S } = r;
|
|
31
39
|
return /* @__PURE__ */ o(
|
|
32
40
|
"a",
|
|
33
41
|
{
|
|
34
|
-
href:
|
|
35
|
-
onClick: (
|
|
36
|
-
d && d(
|
|
42
|
+
href: f,
|
|
43
|
+
onClick: (s) => {
|
|
44
|
+
d && d(s), s.defaultPrevented || (s.preventDefault(), window.location.href = f);
|
|
37
45
|
},
|
|
38
|
-
...
|
|
46
|
+
...S
|
|
39
47
|
}
|
|
40
48
|
);
|
|
41
49
|
}
|
|
42
|
-
return /* @__PURE__ */ o(
|
|
50
|
+
return /* @__PURE__ */ o(E, { to: m, ...r });
|
|
43
51
|
}
|
|
44
52
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
j as Link,
|
|
54
|
+
O as Scripts,
|
|
55
|
+
h as substituteParams
|
|
48
56
|
};
|
package/dist/hooks.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { signal as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
1
|
+
import { signal as _, useSignal as d } from "@preact/signals";
|
|
2
|
+
import { useRef as g, useEffect as h } from "preact/hooks";
|
|
3
|
+
import { useLocation as v, useParams as D } from "wouter-preact";
|
|
4
|
+
const p = _(!1);
|
|
5
|
+
function m(e) {
|
|
6
6
|
e.value !== null && typeof e.value == "object" && (e.value = { ...e.value });
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const a =
|
|
8
|
+
function P(e) {
|
|
9
|
+
const a = _(!1);
|
|
10
10
|
if (typeof window > "u")
|
|
11
11
|
return { data: {
|
|
12
12
|
get value() {
|
|
@@ -14,50 +14,50 @@ function T(e) {
|
|
|
14
14
|
}
|
|
15
15
|
}, loading: a };
|
|
16
16
|
const t = window.__PAGE_DATA__, n = e && t?.[e] ? t[e] : null;
|
|
17
|
-
return { data:
|
|
17
|
+
return { data: _(n), loading: a };
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function T(e, a) {
|
|
20
20
|
let t, n;
|
|
21
21
|
Array.isArray(e) ? n = e : (t = e, n = a);
|
|
22
22
|
let r = null;
|
|
23
23
|
if (typeof window > "u" && t) {
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const c = globalThis.__veloServerData?.getStore?.();
|
|
25
|
+
c?.[t] && (r = c[t]);
|
|
26
26
|
}
|
|
27
27
|
if (typeof window < "u" && t) {
|
|
28
28
|
const o = window.__PAGE_DATA__;
|
|
29
29
|
o?.[t] && (r = o[t], delete o[t]);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const u = d(r), i = d(!1), l = () => {
|
|
32
32
|
if (typeof window > "u" || !t) return;
|
|
33
33
|
const o = window.location.pathname;
|
|
34
34
|
i.value = !0;
|
|
35
|
-
const
|
|
35
|
+
const w = typeof __VELO_STATIC__ < "u" && __VELO_STATIC__ ? `${o === "/" ? "" : o}/index.json` : (() => {
|
|
36
36
|
const s = new URLSearchParams(window.location.search);
|
|
37
37
|
return s.set("_data", "1"), `${o}?${s.toString()}`;
|
|
38
|
-
})()
|
|
39
|
-
fetch(
|
|
40
|
-
typeof __VELO_BUILD_HASH__ < "u" && s.__buildHash && s.__buildHash !== __VELO_BUILD_HASH__ && (
|
|
38
|
+
})();
|
|
39
|
+
fetch(w, { cache: "no-cache" }).then((s) => s.json()).then((s) => {
|
|
40
|
+
typeof __VELO_BUILD_HASH__ < "u" && s.__buildHash && s.__buildHash !== __VELO_BUILD_HASH__ && (p.value = !0), u.value = s[t], i.value = !1;
|
|
41
41
|
}).catch(() => {
|
|
42
42
|
i.value = !1;
|
|
43
43
|
});
|
|
44
|
-
},
|
|
45
|
-
return
|
|
46
|
-
if (
|
|
47
|
-
|
|
44
|
+
}, f = g(r !== null);
|
|
45
|
+
return h(() => {
|
|
46
|
+
if (f.current) {
|
|
47
|
+
f.current = !1;
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
}, n ?? []), { data:
|
|
50
|
+
l();
|
|
51
|
+
}, n ?? []), { data: u, loading: i, refetch: l };
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
const [, e] =
|
|
53
|
+
function L() {
|
|
54
|
+
const [, e] = v();
|
|
55
55
|
return e;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} :
|
|
57
|
+
function E() {
|
|
58
|
+
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} : D();
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function b() {
|
|
61
61
|
if (typeof window > "u")
|
|
62
62
|
return globalThis.__veloServerData?.getStore?.()?.__query ?? {};
|
|
63
63
|
const e = window.__PAGE_DATA__;
|
|
@@ -68,16 +68,16 @@ function U() {
|
|
|
68
68
|
t[r] = n;
|
|
69
69
|
}), t;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (
|
|
71
|
+
function H() {
|
|
72
|
+
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (v(), window.location.pathname);
|
|
73
73
|
}
|
|
74
74
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
P as Loader,
|
|
76
|
+
p as __veloUpdatePending,
|
|
77
|
+
m as touch,
|
|
78
|
+
T as useLoader,
|
|
79
|
+
L as useNavigate,
|
|
80
|
+
E as useParams,
|
|
81
|
+
H as usePathname,
|
|
82
|
+
b as useQuery
|
|
83
83
|
};
|