@mauroandre/velojs 0.0.9 → 0.0.10
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 +33 -29
- package/package.json +3 -1
package/dist/hooks.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { signal as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
function
|
|
1
|
+
import { signal as l, useSignal as d } from "@preact/signals";
|
|
2
|
+
import { useRef as h, useEffect as D } from "preact/hooks";
|
|
3
|
+
import { useLocation as v, useParams as p } from "wouter-preact";
|
|
4
|
+
function m(e) {
|
|
5
5
|
e.value !== null && typeof e.value == "object" && (e.value = { ...e.value });
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const a =
|
|
7
|
+
function P(e) {
|
|
8
|
+
const a = l(!1);
|
|
9
9
|
if (typeof window > "u")
|
|
10
10
|
return { data: {
|
|
11
11
|
get value() {
|
|
@@ -13,9 +13,9 @@ function A(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: l(n), loading: a };
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function T(e, a) {
|
|
19
19
|
let t, n;
|
|
20
20
|
Array.isArray(e) ? n = e : (t = e, n = a);
|
|
21
21
|
let r = null;
|
|
@@ -27,32 +27,36 @@ function m(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 = d(r), i = d(!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 w = 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
|
-
})(),
|
|
38
|
-
fetch(`${
|
|
37
|
+
})(), g = typeof __VELO_BUILD_HASH__ < "u" ? `?v=${__VELO_BUILD_HASH__}` : "";
|
|
38
|
+
fetch(`${w}${g}`).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
|
-
};
|
|
44
|
-
return
|
|
45
|
-
|
|
43
|
+
}, f = h(r !== null);
|
|
44
|
+
return D(() => {
|
|
45
|
+
if (f.current) {
|
|
46
|
+
f.current = !1;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
_();
|
|
46
50
|
}, n ?? []), { data: u, loading: i, refetch: _ };
|
|
47
51
|
}
|
|
48
|
-
function
|
|
49
|
-
const [, e] =
|
|
52
|
+
function L() {
|
|
53
|
+
const [, e] = v();
|
|
50
54
|
return e;
|
|
51
55
|
}
|
|
52
|
-
function
|
|
53
|
-
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} :
|
|
56
|
+
function E() {
|
|
57
|
+
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} : p();
|
|
54
58
|
}
|
|
55
|
-
function
|
|
59
|
+
function $() {
|
|
56
60
|
if (typeof window > "u")
|
|
57
61
|
return globalThis.__veloServerData?.getStore?.()?.__query ?? {};
|
|
58
62
|
const e = window.__PAGE_DATA__;
|
|
@@ -63,15 +67,15 @@ function L() {
|
|
|
63
67
|
t[r] = n;
|
|
64
68
|
}), t;
|
|
65
69
|
}
|
|
66
|
-
function
|
|
67
|
-
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (
|
|
70
|
+
function b() {
|
|
71
|
+
return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (v(), window.location.pathname);
|
|
68
72
|
}
|
|
69
73
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
P as Loader,
|
|
75
|
+
m as touch,
|
|
76
|
+
T as useLoader,
|
|
77
|
+
L as useNavigate,
|
|
78
|
+
E as useParams,
|
|
79
|
+
b as usePathname,
|
|
80
|
+
$ as useQuery
|
|
77
81
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mauroandre/velojs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
|
|
6
6
|
"keywords": [
|
|
@@ -86,9 +86,11 @@
|
|
|
86
86
|
"wouter-preact": "^3.9.0"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
+
"@testing-library/preact": "^3.2.4",
|
|
89
90
|
"@types/babel__generator": "^7.27.0",
|
|
90
91
|
"@types/babel__traverse": "^7.28.0",
|
|
91
92
|
"@types/node": "^25.5.2",
|
|
93
|
+
"jsdom": "^29.0.2",
|
|
92
94
|
"typescript": "^6.0.2",
|
|
93
95
|
"vitest": "^3.2.1"
|
|
94
96
|
}
|