@mauroandre/velojs 0.0.34 → 0.0.36

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/client.js +61 -32
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -1,52 +1,81 @@
1
1
  import { jsx as c } from "preact/jsx-runtime";
2
- import { hydrate as m } from "preact";
3
- import { Router as a, Route as y, Switch as R } from "wouter-preact";
4
- const $ = (o, t) => o.reduceRight((e, l) => /* @__PURE__ */ c(l, { children: e }), t), d = (o, t, e) => t ? e && t === "/" ? o || "/" : t.startsWith("/") ? o + t : o + "/" + t : o, h = (o, t = [], e = "", l = "") => {
2
+ import { hydrate as j } from "preact";
3
+ import { Router as x, Route as p, Switch as $ } from "wouter-preact";
4
+ const l = (t, e, n) => e ? n && e === "/" ? t || "/" : e.startsWith("/") ? t + e : t + "/" + e : t, b = (t) => t === "" ? "*" : `${t}/*?`, w = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), S = (t) => {
5
+ let e = !1;
6
+ t.endsWith("/*?") && (t = t.slice(0, -3), e = !0);
7
+ const n = t.split("/").map((o) => o.startsWith(":") ? "[^/]+" : w(o)).join("/");
8
+ return e ? `${n}(?:/.*)?` : n;
9
+ }, a = (t, e) => {
10
+ if (t.path === "*") return [];
11
+ if (!t.module) {
12
+ const o = l(e, t.path, !1);
13
+ return (t.children ?? []).flatMap((i) => a(i, o));
14
+ }
15
+ if (!t.children)
16
+ return [l(e, t.path, !0) || "/"];
17
+ if (t.path)
18
+ return [`${l(e, t.path, !1)}/*?`];
19
+ const n = l(e, t.path, !1);
20
+ return (t.children ?? []).flatMap((o) => a(o, n));
21
+ }, W = (t, e) => {
22
+ const n = a(t, e);
23
+ return new RegExp(`^(?:${n.map(S).join("|")})$`);
24
+ }, y = (t) => {
25
+ for (const e of t) {
26
+ if (e.path === "*" && e.module) return e.module.Component;
27
+ if (e.children) {
28
+ const n = y(e.children);
29
+ if (n) return n;
30
+ }
31
+ }
32
+ return null;
33
+ }, R = (t, e) => e ? [...t, /* @__PURE__ */ c(p, { children: /* @__PURE__ */ c(e, {}) }, "__notfound")] : t, h = (t, e, n, o) => {
5
34
  const i = [];
6
- for (let u = 0; u < o.length; u++) {
7
- const n = o[u], r = `${l}${u}`;
8
- if (!n.module) {
9
- if (n.children) {
10
- const s = d(e, n.path, !1);
11
- i.push(
12
- ...h(n.children, t, s, `${r}-`)
13
- );
35
+ for (let u = 0; u < t.length; u++) {
36
+ const r = t[u], s = `${o}${u}`;
37
+ if (r.path === "*") continue;
38
+ if (!r.module) {
39
+ if (r.children) {
40
+ const f = l(e, r.path, !1);
41
+ i.push(...h(r.children, f, n, `${s}-`));
14
42
  }
15
43
  continue;
16
44
  }
17
- const f = n.module.Component;
18
- if (!n.children) {
19
- const s = n.path === "*" ? "*" : d(e, n.path, !0);
45
+ const d = r.module.Component;
46
+ if (!r.children) {
47
+ const f = l(e, r.path, !0) || "/";
20
48
  i.push(
21
- /* @__PURE__ */ c(y, { path: s || "/", children: $(t, /* @__PURE__ */ c(f, {})) }, r)
49
+ /* @__PURE__ */ c(p, { path: f, children: /* @__PURE__ */ c(d, {}) }, s)
22
50
  );
23
51
  continue;
24
52
  }
25
- if (n.isRoot) {
53
+ if (r.isRoot) {
26
54
  i.push(
27
- /* @__PURE__ */ c(R, { children: h(n.children, [], "", `${r}-`) }, r)
55
+ /* @__PURE__ */ c($, { children: R(
56
+ h(r.children, "", n, `${s}-`),
57
+ n
58
+ ) }, s)
28
59
  );
29
60
  continue;
30
61
  }
31
- const p = d(e, n.path, !1);
62
+ const m = l(e, r.path, !1), C = r.path ? b(m) : W(r, e);
32
63
  i.push(
33
- ...h(
34
- n.children,
35
- [...t, f],
36
- p,
37
- `${r}-`
38
- )
64
+ /* @__PURE__ */ c(p, { path: C, children: /* @__PURE__ */ c(d, { children: /* @__PURE__ */ c($, { children: R(
65
+ h(r.children, m, n, `${s}-`),
66
+ n
67
+ ) }) }) }, s)
39
68
  );
40
69
  }
41
70
  return i;
42
- }, C = ({ routes: o }) => {
43
- const t = h(o);
44
- return /* @__PURE__ */ c(a, { children: t });
45
- }, S = (o) => {
46
- const { routes: t } = o, e = document.querySelector("body");
47
- e && m(/* @__PURE__ */ c(C, { routes: t }), e);
71
+ }, v = ({ routes: t }) => {
72
+ const e = y(t), n = h(t, "", e, "");
73
+ return /* @__PURE__ */ c(x, { children: n });
74
+ }, q = (t) => {
75
+ const { routes: e } = t, n = document.querySelector("body");
76
+ n && j(/* @__PURE__ */ c(v, { routes: e }), n);
48
77
  };
49
78
  export {
50
- C as ClientRoutes,
51
- S as startClient
79
+ v as ClientRoutes,
80
+ q as startClient
52
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mauroandre/velojs",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "type": "module",
5
5
  "description": "Fullstack web framework built on Hono + Preact with Vite-powered AST transforms",
6
6
  "keywords": [