@mauroandre/velojs 0.0.8 → 0.0.9

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 (3) hide show
  1. package/dist/hooks.js +31 -31
  2. package/dist/vite.js +23 -22
  3. package/package.json +1 -1
package/dist/hooks.js CHANGED
@@ -1,10 +1,10 @@
1
- import { signal as f, useSignal as _ } from "@preact/signals";
2
- import { useEffect as w } from "preact/hooks";
3
- import { useLocation as d, useParams as g } from "wouter-preact";
4
- function S(e) {
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) {
5
5
  e.value !== null && typeof e.value == "object" && (e.value = { ...e.value });
6
6
  }
7
- function y(e) {
7
+ function A(e) {
8
8
  const a = f(!1);
9
9
  if (typeof window > "u")
10
10
  return { data: {
@@ -12,66 +12,66 @@ function y(e) {
12
12
  return e ? globalThis.__veloServerData?.getStore?.()?.[e] ?? null : null;
13
13
  }
14
14
  }, loading: a };
15
- const t = window.__PAGE_DATA__, r = e && t?.[e] ? t[e] : null;
16
- return { data: f(r), loading: a };
15
+ const t = window.__PAGE_DATA__, n = e && t?.[e] ? t[e] : null;
16
+ return { data: f(n), loading: a };
17
17
  }
18
18
  function m(e, a) {
19
- let t, r;
20
- Array.isArray(e) ? r = e : (t = e, r = a);
21
- let n = null;
19
+ let t, n;
20
+ Array.isArray(e) ? n = e : (t = e, n = a);
21
+ let r = null;
22
22
  if (typeof window > "u" && t) {
23
23
  const c = globalThis.__veloServerData?.getStore?.();
24
- c?.[t] && (n = c[t]);
24
+ c?.[t] && (r = c[t]);
25
25
  }
26
26
  if (typeof window < "u" && t) {
27
27
  const o = window.__PAGE_DATA__;
28
- o?.[t] && (n = o[t], delete o[t]);
28
+ o?.[t] && (r = o[t], delete o[t]);
29
29
  }
30
- const u = _(n), i = _(!1), l = () => {
30
+ const u = l(r), i = l(!1), _ = () => {
31
31
  if (typeof window > "u" || !t) return;
32
32
  const o = window.location.pathname;
33
33
  i.value = !0;
34
34
  const v = 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(v).then((s) => s.json()).then((s) => {
37
+ })(), w = typeof __VELO_BUILD_HASH__ < "u" ? `?v=${__VELO_BUILD_HASH__}` : "";
38
+ fetch(`${v}${w}`).then((s) => s.json()).then((s) => {
39
39
  u.value = s[t], i.value = !1;
40
- }).catch((s) => {
41
- console.error("Erro ao carregar dados:", s), i.value = !1;
40
+ }).catch(() => {
41
+ i.value = !1;
42
42
  });
43
43
  };
44
- return w(() => {
45
- n === null && l();
46
- }, r ?? []), { data: u, loading: i, refetch: l };
44
+ return g(() => {
45
+ r === null && _();
46
+ }, n ?? []), { data: u, loading: i, refetch: _ };
47
47
  }
48
- function A() {
48
+ function P() {
49
49
  const [, e] = d();
50
50
  return e;
51
51
  }
52
- function P() {
53
- return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} : g();
54
- }
55
52
  function T() {
53
+ return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__params ?? {} : h();
54
+ }
55
+ function L() {
56
56
  if (typeof window > "u")
57
57
  return globalThis.__veloServerData?.getStore?.()?.__query ?? {};
58
58
  const e = window.__PAGE_DATA__;
59
59
  if (e?.__query)
60
60
  return e.__query;
61
61
  const a = new URLSearchParams(window.location.search), t = {};
62
- return a.forEach((r, n) => {
63
- t[n] = r;
62
+ return a.forEach((n, r) => {
63
+ t[r] = n;
64
64
  }), t;
65
65
  }
66
66
  function E() {
67
67
  return typeof window > "u" ? globalThis.__veloServerData?.getStore?.()?.__pathname ?? "/" : (d(), window.location.pathname);
68
68
  }
69
69
  export {
70
- y as Loader,
71
- S as touch,
70
+ A as Loader,
71
+ y as touch,
72
72
  m as useLoader,
73
- A as useNavigate,
74
- P as useParams,
73
+ P as useNavigate,
74
+ T as useParams,
75
75
  E as usePathname,
76
- T as useQuery
76
+ L as useQuery
77
77
  };
package/dist/vite.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import d from "node:path";
2
- import j from "node:fs";
3
- import C from "@preact/preset-vite";
4
- import O from "@hono/vite-dev-server";
2
+ import S from "node:fs";
3
+ import F from "@preact/preset-vite";
4
+ import w from "@hono/vite-dev-server";
5
5
  import { parse as v } from "@babel/parser";
6
6
  import L from "@babel/traverse";
7
- import S from "@babel/generator";
7
+ import j from "@babel/generator";
8
8
  import * as e from "@babel/types";
9
- const m = typeof L == "function" ? L : L.default, h = typeof S == "function" ? S : S.default;
10
- function w(u, o, r, l) {
9
+ const m = typeof L == "function" ? L : L.default, h = typeof j == "function" ? j : j.default;
10
+ function C(u, o, r, l) {
11
11
  const i = v(u, {
12
12
  sourceType: "module",
13
13
  plugins: ["typescript", "jsx"]
@@ -290,7 +290,7 @@ function A(u, o, r) {
290
290
  s && A(s.elements, t, r);
291
291
  }
292
292
  }
293
- const g = "virtual:velo/server-entry", E = "virtual:velo/client-entry", P = "\0" + g, _ = "\0" + E;
293
+ const g = "virtual:velo/server-entry", E = "virtual:velo/client-entry", _ = "\0" + g, P = "\0" + E;
294
294
  function M(u, o) {
295
295
  let r = d.resolve(process.cwd(), o);
296
296
  const l = u.routesFile ?? "routes.tsx", i = /* @__PURE__ */ new Map();
@@ -302,8 +302,8 @@ function M(u, o) {
302
302
  },
303
303
  buildStart() {
304
304
  const t = d.join(r, l);
305
- if (j.existsSync(t)) {
306
- const n = j.readFileSync(t, "utf-8"), s = T(n);
305
+ if (S.existsSync(t)) {
306
+ const n = S.readFileSync(t, "utf-8"), s = T(n);
307
307
  i.clear();
308
308
  for (const [c, a] of s)
309
309
  i.set(c, a);
@@ -312,7 +312,7 @@ function M(u, o) {
312
312
  handleHotUpdate({ file: t, server: n }) {
313
313
  const s = d.join(r, l);
314
314
  if (t === s) {
315
- const c = j.readFileSync(s, "utf-8"), a = T(c);
315
+ const c = S.readFileSync(s, "utf-8"), a = T(c);
316
316
  i.clear();
317
317
  for (const [p, f] of a)
318
318
  i.set(p, f);
@@ -320,18 +320,18 @@ function M(u, o) {
320
320
  }
321
321
  },
322
322
  resolveId(t) {
323
- return t === g || t.endsWith(g) ? P : t === E || t.endsWith(E) || t === "/__velo_client.js" ? _ : null;
323
+ return t === g || t.endsWith(g) ? _ : t === E || t.endsWith(E) || t === "/__velo_client.js" ? P : null;
324
324
  },
325
325
  load(t) {
326
326
  const n = u.routesFile ?? "routes.tsx", s = u.serverInit ?? "server.tsx", c = u.clientInit ?? "client.tsx", a = d.join(r, n).replace(/\.tsx?$/, ".js"), p = d.join(r, s).replace(/\.tsx?$/, ".js"), f = d.join(r, c).replace(/\.tsx?$/, ".js");
327
- return t === P ? `
327
+ return t === _ ? `
328
328
  import "${p}";
329
329
  import routes from "${a}";
330
330
  import { startServer } from "@mauroandre/velojs/server";
331
331
 
332
332
  export { routes };
333
333
  export default await startServer({ routes });
334
- ` : t === _ ? `
334
+ ` : t === P ? `
335
335
  import "${f}";
336
336
  import routes from "${a}";
337
337
  import { startClient } from "@mauroandre/velojs/client";
@@ -345,10 +345,10 @@ startClient({ routes });
345
345
  let a = t, p = !1;
346
346
  const f = /middlewares:\s*\[/.test(t), x = /export\s+(const|function)\s+Component/.test(
347
347
  t
348
- ), y = /export\s+(const|function)\s+loader/.test(t), N = /export\s+const\s+action_\w+/.test(t), D = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), F = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t);
349
- if (!c && f && (a = k(a), p = !0), x || y || N || D || F) {
348
+ ), y = /export\s+(const|function)\s+loader/.test(t), N = /export\s+const\s+action_\w+/.test(t), D = /\bLoader\s*</.test(t) || /\bLoader\s*\(/.test(t), O = /\buseLoader\s*</.test(t) || /\buseLoader\s*\(/.test(t);
349
+ if (!c && f && (a = k(a), p = !0), x || y || N || D || O) {
350
350
  const b = d.relative(r, n).replace(/\.(tsx?|jsx?)$/, "").replace(/\\/g, "/"), I = i.get(b);
351
- a = w(a, b, I?.fullPath, I?.path), a = R(a, b), c || (a = V(
351
+ a = C(a, b, I?.fullPath, I?.path), a = R(a, b), c || (a = V(
352
352
  a,
353
353
  b
354
354
  )), c || (a = U(a)), p = !0;
@@ -368,7 +368,8 @@ function B() {
368
368
  define: {
369
369
  "process.env.NODE_ENV": JSON.stringify(l ? "development" : "production"),
370
370
  "process.env.STATIC_BASE_URL": JSON.stringify(process.env.STATIC_BASE_URL || (i ? "/client" : "")),
371
- __VELO_STATIC__: JSON.stringify(i)
371
+ __VELO_STATIC__: JSON.stringify(i),
372
+ __VELO_BUILD_HASH__: JSON.stringify(Date.now().toString(36))
372
373
  },
373
374
  resolve: {
374
375
  alias: {
@@ -423,14 +424,14 @@ function Z(u) {
423
424
  B(),
424
425
  M(o, r),
425
426
  J(),
426
- C(),
427
- O({
427
+ F(),
428
+ w({
428
429
  entry: g
429
430
  }),
430
- Y()
431
+ H()
431
432
  ];
432
433
  }
433
- function Y() {
434
+ function H() {
434
435
  return {
435
436
  name: "velo:ws-bridge",
436
437
  configureServer(u) {
@@ -441,7 +442,7 @@ function Y() {
441
442
  export {
442
443
  T as buildFullPathMap,
443
444
  A as collectFullPaths,
444
- w as injectMetadata,
445
+ C as injectMetadata,
445
446
  U as removeLoaders,
446
447
  k as removeMiddlewares,
447
448
  V as transformActionsForClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
6
6
  "keywords": [