@mauroandre/velojs 0.0.35 → 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.
- package/dist/client.js +62 -53
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1,72 +1,81 @@
|
|
|
1
1
|
import { jsx as c } from "preact/jsx-runtime";
|
|
2
|
-
import { hydrate as
|
|
3
|
-
import { Router as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
10
30
|
}
|
|
11
31
|
}
|
|
12
32
|
return null;
|
|
13
|
-
},
|
|
14
|
-
const
|
|
15
|
-
for (let u = 0; u <
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
if (!
|
|
19
|
-
if (
|
|
20
|
-
const f =
|
|
21
|
-
|
|
22
|
-
...h(o.children, t, f, i, `${r}-`)
|
|
23
|
-
);
|
|
33
|
+
}, R = (t, e) => e ? [...t, /* @__PURE__ */ c(p, { children: /* @__PURE__ */ c(e, {}) }, "__notfound")] : t, h = (t, e, n, o) => {
|
|
34
|
+
const i = [];
|
|
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}-`));
|
|
24
42
|
}
|
|
25
43
|
continue;
|
|
26
44
|
}
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
29
|
-
const f =
|
|
30
|
-
|
|
31
|
-
/* @__PURE__ */ c(
|
|
32
|
-
);
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (o.isRoot) {
|
|
36
|
-
l.push(
|
|
37
|
-
/* @__PURE__ */ c(a, { children: y(
|
|
38
|
-
h(o.children, [], "", i, `${r}-`),
|
|
39
|
-
i
|
|
40
|
-
) }, r)
|
|
45
|
+
const d = r.module.Component;
|
|
46
|
+
if (!r.children) {
|
|
47
|
+
const f = l(e, r.path, !0) || "/";
|
|
48
|
+
i.push(
|
|
49
|
+
/* @__PURE__ */ c(p, { path: f, children: /* @__PURE__ */ c(d, {}) }, s)
|
|
41
50
|
);
|
|
42
51
|
continue;
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
if (r.isRoot) {
|
|
54
|
+
i.push(
|
|
55
|
+
/* @__PURE__ */ c($, { children: R(
|
|
56
|
+
h(r.children, "", n, `${s}-`),
|
|
57
|
+
n
|
|
58
|
+
) }, s)
|
|
48
59
|
);
|
|
49
60
|
continue;
|
|
50
61
|
}
|
|
51
|
-
l.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
) }) })
|
|
58
|
-
) }, r)
|
|
62
|
+
const m = l(e, r.path, !1), C = r.path ? b(m) : W(r, e);
|
|
63
|
+
i.push(
|
|
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)
|
|
59
68
|
);
|
|
60
69
|
}
|
|
61
|
-
return
|
|
62
|
-
},
|
|
63
|
-
const
|
|
64
|
-
return /* @__PURE__ */ c(
|
|
65
|
-
}, q = (
|
|
66
|
-
const { routes:
|
|
67
|
-
|
|
70
|
+
return i;
|
|
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);
|
|
68
77
|
};
|
|
69
78
|
export {
|
|
70
|
-
|
|
79
|
+
v as ClientRoutes,
|
|
71
80
|
q as startClient
|
|
72
81
|
};
|