@mauroandre/velojs 0.0.10 → 0.0.11
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/hooks.js +28 -28
- package/package.json +1 -1
package/dist/hooks.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { signal as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
function
|
|
1
|
+
import { signal as d, useSignal as v } from "@preact/signals";
|
|
2
|
+
import { useRef as D, useEffect as p } from "preact/hooks";
|
|
3
|
+
import { useLocation as w, useParams as S } from "wouter-preact";
|
|
4
|
+
function P(e) {
|
|
5
5
|
e.value !== null && typeof e.value == "object" && (e.value = { ...e.value });
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const a =
|
|
7
|
+
function T(e) {
|
|
8
|
+
const a = d(!1);
|
|
9
9
|
if (typeof window > "u")
|
|
10
10
|
return { data: {
|
|
11
11
|
get value() {
|
|
@@ -13,9 +13,9 @@ function P(e) {
|
|
|
13
13
|
}
|
|
14
14
|
}, loading: a };
|
|
15
15
|
const t = window.__PAGE_DATA__, n = e && t?.[e] ? t[e] : null;
|
|
16
|
-
return { data:
|
|
16
|
+
return { data: d(n), loading: a };
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function L(e, a) {
|
|
19
19
|
let t, n;
|
|
20
20
|
Array.isArray(e) ? n = e : (t = e, n = a);
|
|
21
21
|
let r = null;
|
|
@@ -27,21 +27,21 @@ function T(e, a) {
|
|
|
27
27
|
const o = window.__PAGE_DATA__;
|
|
28
28
|
o?.[t] && (r = o[t], delete o[t]);
|
|
29
29
|
}
|
|
30
|
-
const u =
|
|
30
|
+
const u = v(r), i = v(!1), _ = () => {
|
|
31
31
|
if (typeof window > "u" || !t) return;
|
|
32
32
|
const o = window.location.pathname;
|
|
33
33
|
i.value = !0;
|
|
34
|
-
const
|
|
34
|
+
const l = typeof __VELO_STATIC__ < "u" && __VELO_STATIC__ ? `${o === "/" ? "" : o}/index.json` : (() => {
|
|
35
35
|
const s = new URLSearchParams(window.location.search);
|
|
36
36
|
return s.set("_data", "1"), `${o}?${s.toString()}`;
|
|
37
|
-
})(), g = typeof __VELO_BUILD_HASH__ < "u" ?
|
|
38
|
-
fetch(`${
|
|
37
|
+
})(), g = l.includes("?") ? "&" : "?", h = typeof __VELO_BUILD_HASH__ < "u" ? `${g}v=${__VELO_BUILD_HASH__}` : "";
|
|
38
|
+
fetch(`${l}${h}`).then((s) => s.json()).then((s) => {
|
|
39
39
|
u.value = s[t], i.value = !1;
|
|
40
40
|
}).catch(() => {
|
|
41
41
|
i.value = !1;
|
|
42
42
|
});
|
|
43
|
-
}, f =
|
|
44
|
-
return
|
|
43
|
+
}, f = D(r !== null);
|
|
44
|
+
return p(() => {
|
|
45
45
|
if (f.current) {
|
|
46
46
|
f.current = !1;
|
|
47
47
|
return;
|
|
@@ -49,14 +49,14 @@ function T(e, a) {
|
|
|
49
49
|
_();
|
|
50
50
|
}, n ?? []), { data: u, loading: i, refetch: _ };
|
|
51
51
|
}
|
|
52
|
-
function L() {
|
|
53
|
-
const [, e] = v();
|
|
54
|
-
return e;
|
|
55
|
-
}
|
|
56
52
|
function E() {
|
|
57
|
-
|
|
53
|
+
const [, e] = w();
|
|
54
|
+
return e;
|
|
58
55
|
}
|
|
59
56
|
function $() {
|
|
57
|
+
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} : S();
|
|
58
|
+
}
|
|
59
|
+
function b() {
|
|
60
60
|
if (typeof window > "u")
|
|
61
61
|
return globalThis.__veloServerData?.getStore?.()?.__query ?? {};
|
|
62
62
|
const e = window.__PAGE_DATA__;
|
|
@@ -67,15 +67,15 @@ function $() {
|
|
|
67
67
|
t[r] = n;
|
|
68
68
|
}), t;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (
|
|
70
|
+
function H() {
|
|
71
|
+
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (w(), window.location.pathname);
|
|
72
72
|
}
|
|
73
73
|
export {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
T as Loader,
|
|
75
|
+
P as touch,
|
|
76
|
+
L as useLoader,
|
|
77
|
+
E as useNavigate,
|
|
78
|
+
$ as useParams,
|
|
79
|
+
H as usePathname,
|
|
80
|
+
b as useQuery
|
|
81
81
|
};
|