@mauroandre/velojs 0.0.9 → 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.
Files changed (2) hide show
  1. package/dist/hooks.js +33 -29
  2. package/package.json +3 -1
package/dist/hooks.js CHANGED
@@ -1,11 +1,11 @@
1
- import { signal as f, useSignal as l } from "@preact/signals";
2
- import { useEffect as g } from "preact/hooks";
3
- import { useLocation as d, useParams as h } from "wouter-preact";
4
- function y(e) {
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 A(e) {
8
- const a = f(!1);
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 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: f(n), loading: a };
16
+ return { data: d(n), loading: a };
17
17
  }
18
- function m(e, a) {
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,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 = l(r), i = l(!1), _ = () => {
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 v = typeof __VELO_STATIC__ < "u" && __VELO_STATIC__ ? `${o === "/" ? "" : o}/index.json` : (() => {
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
- })(), w = typeof __VELO_BUILD_HASH__ < "u" ? `?v=${__VELO_BUILD_HASH__}` : "";
38
- fetch(`${v}${w}`).then((s) => s.json()).then((s) => {
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
- };
44
- return g(() => {
45
- r === null && _();
43
+ }, f = D(r !== null);
44
+ return p(() => {
45
+ if (f.current) {
46
+ f.current = !1;
47
+ return;
48
+ }
49
+ _();
46
50
  }, n ?? []), { data: u, loading: i, refetch: _ };
47
51
  }
48
- function P() {
49
- const [, e] = d();
52
+ function E() {
53
+ const [, e] = w();
50
54
  return e;
51
55
  }
52
- function T() {
53
- return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} : h();
56
+ function $() {
57
+ return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} : S();
54
58
  }
55
- function L() {
59
+ function b() {
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 E() {
67
- return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (d(), window.location.pathname);
70
+ function H() {
71
+ return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (w(), window.location.pathname);
68
72
  }
69
73
  export {
70
- A as Loader,
71
- y as touch,
72
- m as useLoader,
73
- P as useNavigate,
74
- T as useParams,
75
- E as usePathname,
76
- L as useQuery
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
77
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
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
  }