@mauroandre/velojs 0.0.11 → 0.0.13

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.
@@ -1,31 +1,31 @@
1
1
  import { jsx as i, jsxs as u, Fragment as p } from "preact/jsx-runtime";
2
2
  import { Link as m } from "wouter-preact";
3
- function v({ basePath: t, favicon: n = "/favicon.ico" } = {}) {
4
- const e = process.env.NODE_ENV !== "production";
5
- t = t || process.env.STATIC_BASE_URL || "";
6
- const r = n !== !1 && /* @__PURE__ */ i("link", { rel: "icon", href: `${t}${n}`, type: "image/x-icon" });
7
- return e ? /* @__PURE__ */ u(p, { children: [
3
+ function y({ basePath: e, favicon: n = "/favicon.ico" } = {}) {
4
+ const t = process.env.NODE_ENV !== "production";
5
+ e = e || process.env.STATIC_BASE_URL || (process.env.VELO_STATIC ? "/client" : "");
6
+ const r = n !== !1 && /* @__PURE__ */ i("link", { rel: "icon", href: `${e}${n}`, type: "image/x-icon" });
7
+ return t ? /* @__PURE__ */ u(p, { children: [
8
8
  r,
9
9
  /* @__PURE__ */ i("script", { type: "module", src: "/@vite/client" }),
10
10
  /* @__PURE__ */ i("script", { type: "module", src: "/__velo_client.js" })
11
11
  ] }) : /* @__PURE__ */ u(p, { children: [
12
12
  r,
13
- /* @__PURE__ */ i("link", { rel: "stylesheet", href: `${t}/client.css` }),
14
- /* @__PURE__ */ i("script", { type: "module", src: `${t}/client.js` })
13
+ /* @__PURE__ */ i("link", { rel: "stylesheet", href: `${e}/client.css` }),
14
+ /* @__PURE__ */ i("script", { type: "module", src: `${e}/client.js` })
15
15
  ] });
16
16
  }
17
- function $(t, n) {
18
- let e = t;
17
+ function $(e, n) {
18
+ let t = e;
19
19
  for (const [r, c] of Object.entries(n))
20
- e = e.replace(`:${r}`, c);
21
- return e;
20
+ t = t.replace(`:${r}`, c);
21
+ return t;
22
22
  }
23
- function g({ to: t, params: n, search: e, absolute: r, ...c }) {
24
- const s = typeof t != "string", o = s ? (r ? t.metadata?.fullPath : t.metadata?.path) ?? "/" : t, l = n ? $(o, n) : o, f = s && r ? `~${l}` : l, a = e ? `?${new URLSearchParams(e).toString()}` : "";
23
+ function S({ to: e, params: n, search: t, absolute: r, ...c }) {
24
+ const s = typeof e != "string", o = s ? (r ? e.metadata?.fullPath : e.metadata?.path) ?? "/" : e, l = n ? $(o, n) : o, f = s && r ? `~${l}` : l, a = t ? `?${new URLSearchParams(t).toString()}` : "";
25
25
  return /* @__PURE__ */ i(m, { to: `${f}${a}`, ...c });
26
26
  }
27
27
  export {
28
- g as Link,
29
- v as Scripts,
28
+ S as Link,
29
+ y as Scripts,
30
30
  $ as substituteParams
31
31
  };
package/dist/static.js CHANGED
@@ -1,62 +1,75 @@
1
- import f from "node:fs";
2
- import r from "node:path";
3
- async function h(a, n = "") {
4
- const o = [];
5
- for (const t of a) {
6
- const s = t.module.metadata?.fullPath ?? "";
1
+ import i from "node:fs";
2
+ import a from "node:path";
3
+ async function h(c, n = "") {
4
+ const e = [];
5
+ for (const t of c) {
6
+ const o = t.module.metadata?.fullPath ?? "";
7
7
  if (t.children) {
8
- const e = await h(t.children, s);
9
- o.push(...e);
8
+ const s = await h(t.children, o);
9
+ e.push(...s);
10
10
  } else {
11
- const e = t.module.metadata?.fullPath;
12
- if (!e) continue;
13
- const l = Object.keys(t.module).filter((c) => c.startsWith("action_"));
14
- if (l.length > 0 && console.warn(
15
- `⚠ Route ${e} has actions (${l.join(", ")}) — they won't work in static mode`
16
- ), e.includes(":")) {
17
- const c = t.module.staticPaths;
18
- if (typeof c == "function") {
19
- const i = await c();
20
- for (const d of i) {
21
- let u = e;
22
- for (const [m, p] of Object.entries(d))
23
- u = u.replace(`:${m}`, p);
24
- o.push({ fullPath: u, module: t.module });
11
+ const s = t.module.metadata?.fullPath;
12
+ if (!s) continue;
13
+ const r = Object.keys(t.module).filter((l) => l.startsWith("action_"));
14
+ if (r.length > 0 && console.warn(
15
+ `⚠ Route ${s} has actions (${r.join(", ")}) — they won't work in static mode`
16
+ ), s.includes(":")) {
17
+ const l = t.module.staticPaths;
18
+ if (typeof l == "function") {
19
+ const u = await l();
20
+ for (const d of u) {
21
+ let f = s;
22
+ for (const [p, m] of Object.entries(d))
23
+ f = f.replace(`:${p}`, m);
24
+ e.push({ fullPath: f, module: t.module });
25
25
  }
26
26
  } else
27
27
  console.warn(
28
- `Skipping ${e} — dynamic route without staticPaths export`
28
+ `Skipping ${s} — dynamic route without staticPaths export`
29
29
  );
30
30
  } else
31
- o.push({ fullPath: e, module: t.module });
31
+ e.push({ fullPath: s, module: t.module });
32
32
  }
33
33
  }
34
- return o;
34
+ return e;
35
35
  }
36
- async function w(a, n, o) {
37
- const t = "http://localhost", s = await a.fetch(new Request(`${t}${n}`));
38
- if (s.status !== 200) {
39
- console.warn(`Skipping ${n} — got status ${s.status}`);
36
+ async function y(c, n, e) {
37
+ const t = "http://localhost", o = await c.fetch(new Request(`${t}${n}`));
38
+ if (o.status !== 200) {
39
+ console.warn(`Skipping ${n} — got status ${o.status}`);
40
40
  return;
41
41
  }
42
- const e = await s.text(), c = await (await a.fetch(
42
+ const s = await o.text(), l = await (await c.fetch(
43
43
  new Request(`${t}${n}?_data=1`)
44
- )).text(), i = n === "/" ? o : r.join(o, n);
45
- f.mkdirSync(i, { recursive: !0 }), f.writeFileSync(r.join(i, "index.html"), e), f.writeFileSync(r.join(i, "index.json"), c);
44
+ )).text(), u = n === "/" ? e : a.join(e, n);
45
+ i.mkdirSync(u, { recursive: !0 }), i.writeFileSync(a.join(u, "index.html"), s), i.writeFileSync(a.join(u, "index.json"), l);
46
46
  }
47
- async function $(a, n) {
48
- const o = r.resolve(process.cwd(), "dist");
47
+ function w(c) {
48
+ const n = a.resolve(process.cwd(), "public");
49
+ if (!i.existsSync(n)) return;
50
+ const e = (t, o) => {
51
+ if (i.statSync(t).isDirectory()) {
52
+ i.mkdirSync(o, { recursive: !0 });
53
+ for (const r of i.readdirSync(t))
54
+ e(a.join(t, r), a.join(o, r));
55
+ } else
56
+ i.copyFileSync(t, o);
57
+ };
58
+ e(n, c);
59
+ }
60
+ async function j(c, n) {
61
+ const e = a.resolve(process.cwd(), "dist");
49
62
  console.log("Generating static pages...");
50
63
  const t = await h(n);
51
64
  if (t.length === 0) {
52
65
  console.warn("No routes found for static generation.");
53
66
  return;
54
67
  }
55
- for (const s of t)
56
- await w(a, s.fullPath, o), console.log(` ✓ ${s.fullPath}`);
57
- console.log(`
68
+ for (const o of t)
69
+ await y(c, o.fullPath, e), console.log(` ✓ ${o.fullPath}`);
70
+ w(e), console.log(`
58
71
  Generated ${t.length} static pages.`);
59
72
  }
60
73
  export {
61
- $ as generateStatic
74
+ j as generateStatic
62
75
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
6
6
  "keywords": [