keits 0.0.3 → 0.1.0
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/README.md +93 -79
- package/dist/dev/api.js +275 -0
- package/dist/dev/forms.js +330 -0
- package/dist/dev/index.js +26 -326
- package/dist/dev/router.js +24 -5
- package/dist/dev/shared/computed-DrF8O8b4.js +40 -0
- package/dist/dev/shared/{element-C4DfKtZW.js → element-DXwmUAnz.js} +32 -111
- package/dist/dev/shared/{graph-D6-x_CWC.js → graph-SIvYLXSv.js} +62 -3
- package/dist/dev/shared/hydrate-C8cOsDDH.js +588 -0
- package/dist/dev/shared/mount-CDB2HgN5.js +23 -0
- package/dist/dev/shared/namespaces-Cz82B0Pr.js +84 -0
- package/dist/dev/shared/owner-BuwIoI4j.js +72 -0
- package/dist/dev/shared/render-context-k2uu_dM_.js +34 -0
- package/dist/dev/shared/render-effect-Uk9dDmuU.js +32 -0
- package/dist/dev/shared/resource-DlgzdtcG.js +145 -0
- package/dist/dev/shared/signal-B3xOKbVm.js +24 -0
- package/dist/dev/shared/store-0vEg2bQV.js +152 -0
- package/dist/dev/shared/unsafe-keys-CB1P22No.js +8 -0
- package/dist/dev/static.js +76 -0
- package/dist/dev/svg.js +2 -1
- package/dist/dev/testing.js +216 -0
- package/dist/dev/vite.js +141 -0
- package/dist/prod/api.js +215 -0
- package/dist/prod/forms.js +240 -0
- package/dist/prod/index.js +110 -327
- package/dist/prod/router.js +83 -68
- package/dist/prod/shared/computed-BjqJ6Pps.js +33 -0
- package/dist/prod/shared/element-DCit4-3e.js +129 -0
- package/dist/prod/shared/{graph-C_aA46c6.js → graph-CR2WKbwr.js} +107 -63
- package/dist/prod/shared/hydrate-kKnJbkV7.js +480 -0
- package/dist/prod/shared/mount-DbeKIoyD.js +18 -0
- package/dist/prod/shared/namespaces-BSRrBJIU.js +71 -0
- package/dist/prod/shared/owner-DBi3odT4.js +67 -0
- package/dist/prod/shared/render-context-DF8lr1uu.js +30 -0
- package/dist/prod/shared/render-effect-UFDi2Pfh.js +25 -0
- package/dist/prod/shared/resource-Ch5tVseZ.js +91 -0
- package/dist/prod/shared/signal-BDMlfa0Z.js +16 -0
- package/dist/prod/shared/store-CvW0DbmK.js +110 -0
- package/dist/prod/shared/unsafe-keys-C5PMlerl.js +7 -0
- package/dist/prod/static.js +48 -0
- package/dist/prod/svg.js +3 -2
- package/dist/prod/testing.js +144 -0
- package/dist/prod/vite.js +106 -0
- package/dist/types/api/cache.d.ts +16 -0
- package/dist/types/api/client.d.ts +42 -0
- package/dist/types/api/error.d.ts +16 -0
- package/dist/types/api/index.d.ts +3 -0
- package/dist/types/api/url.d.ts +5 -0
- package/dist/types/async/render-context.d.ts +10 -0
- package/dist/types/core/effect.d.ts +1 -0
- package/dist/types/core/graph.d.ts +11 -0
- package/dist/types/core/owner.d.ts +1 -0
- package/dist/types/core/unsafe-keys.d.ts +2 -0
- package/dist/types/dom/hooks.d.ts +4 -0
- package/dist/types/dom/types.d.ts +5 -0
- package/dist/types/forms/form.d.ts +55 -0
- package/dist/types/forms/index.d.ts +2 -0
- package/dist/types/forms/paths.d.ts +6 -0
- package/dist/types/forms/types.d.ts +38 -0
- package/dist/types/router/index.d.ts +1 -0
- package/dist/types/router/match.d.ts +1 -0
- package/dist/types/router/types.d.ts +1 -0
- package/dist/types/static/head.d.ts +36 -0
- package/dist/types/static/hydrate.d.ts +3 -0
- package/dist/types/static/index.d.ts +4 -0
- package/dist/types/static/island.d.ts +14 -0
- package/dist/types/static/json.d.ts +1 -0
- package/dist/types/static/render.d.ts +11 -0
- package/dist/types/static/server-dom.d.ts +100 -0
- package/dist/types/testing/index.d.ts +62 -0
- package/dist/types/vite/index.d.ts +24 -0
- package/package.json +46 -5
- package/dist/dev/shared/owner-DlUsXKXE.js +0 -122
- package/dist/prod/shared/element-DUtXb3px.js +0 -187
- package/dist/prod/shared/owner-DgJNPM0P.js +0 -104
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { i as e, n as t, o as n, t as r } from "./render-context-DF8lr1uu.js";
|
|
2
|
+
import { i, l as a, p as o, s, t as c, x as l } from "./graph-CR2WKbwr.js";
|
|
3
|
+
import { t as u } from "./signal-BDMlfa0Z.js";
|
|
4
|
+
import { t as d } from "./render-effect-UFDi2Pfh.js";
|
|
5
|
+
// src/async/suspense-context.ts
|
|
6
|
+
var f = e(null);
|
|
7
|
+
// src/async/resource.ts
|
|
8
|
+
function p(e, p, h) {
|
|
9
|
+
let g = typeof p == "function", _ = g ? e : () => !0, v = g ? p : (t, n) => e(n), y = g ? h : p, b = s(), x = o(), S = n(r), C = x !== null && S === null ? t?.(x) : void 0, w = C !== void 0 || y !== void 0 && "initialValue" in y, T = u(C === void 0 ? y?.initialValue : C.value), E = u(w ? "ready" : "unresolved"), D = u(null), O = null, k = 0, A = [], j = null, M = () => {
|
|
10
|
+
let e = A;
|
|
11
|
+
A = [];
|
|
12
|
+
for (let t of e) t();
|
|
13
|
+
};
|
|
14
|
+
function N(e, t) {
|
|
15
|
+
O?.abort(), O = null;
|
|
16
|
+
let n = ++k;
|
|
17
|
+
if (e == null || e === !1) return j = null, E.set(l(T) === void 0 ? "unresolved" : "ready"), M(), Promise.resolve();
|
|
18
|
+
j = e;
|
|
19
|
+
let r = new AbortController();
|
|
20
|
+
O = r;
|
|
21
|
+
let i;
|
|
22
|
+
try {
|
|
23
|
+
i = v(e, {
|
|
24
|
+
signal: r.signal,
|
|
25
|
+
refetching: t,
|
|
26
|
+
value: l(T)
|
|
27
|
+
});
|
|
28
|
+
} catch (e) {
|
|
29
|
+
return F(e), Promise.resolve();
|
|
30
|
+
}
|
|
31
|
+
if (!m(i)) return P(i), Promise.resolve();
|
|
32
|
+
E.set(l(T) === void 0 && l(E) !== "ready" ? "pending" : "refreshing");
|
|
33
|
+
let a = Promise.resolve(i).then((e) => {
|
|
34
|
+
n === k && P(e);
|
|
35
|
+
}, (e) => {
|
|
36
|
+
n === k && F(e);
|
|
37
|
+
});
|
|
38
|
+
return S?.wait(a), a;
|
|
39
|
+
}
|
|
40
|
+
function P(e) {
|
|
41
|
+
O = null, x !== null && S?.store(x, e, b), i(() => {
|
|
42
|
+
T.set(() => e), D.set(null), E.set("ready");
|
|
43
|
+
}), M();
|
|
44
|
+
}
|
|
45
|
+
function F(e) {
|
|
46
|
+
O = null, i(() => {
|
|
47
|
+
D.set({ error: e }), E.set("errored");
|
|
48
|
+
}), M();
|
|
49
|
+
}
|
|
50
|
+
let I = C !== void 0;
|
|
51
|
+
d(() => {
|
|
52
|
+
let e = _();
|
|
53
|
+
I ? I = !1 : l(() => N(e, !1));
|
|
54
|
+
}), c(() => {
|
|
55
|
+
k++, O?.abort(), O = null;
|
|
56
|
+
});
|
|
57
|
+
let L = Object.assign(() => {
|
|
58
|
+
let e = E();
|
|
59
|
+
if (e === "errored") throw D().error;
|
|
60
|
+
if (e === "pending") {
|
|
61
|
+
let e = n(f);
|
|
62
|
+
e !== null && e.wait(L, (e) => A.push(e));
|
|
63
|
+
}
|
|
64
|
+
return T();
|
|
65
|
+
}, {
|
|
66
|
+
state: () => E(),
|
|
67
|
+
loading: () => {
|
|
68
|
+
let e = E();
|
|
69
|
+
return e === "pending" || e === "refreshing";
|
|
70
|
+
},
|
|
71
|
+
error: () => D()?.error,
|
|
72
|
+
refetch: () => l(() => N(j ?? _(), !0)),
|
|
73
|
+
mutate: (e) => i(() => {
|
|
74
|
+
T.set(() => e), D.set(null), E.set(e === void 0 ? "unresolved" : "ready");
|
|
75
|
+
}),
|
|
76
|
+
optimistic: async (e, t) => {
|
|
77
|
+
let n = l(T), r = e(n);
|
|
78
|
+
T.set(() => r);
|
|
79
|
+
try {
|
|
80
|
+
return await t(), !0;
|
|
81
|
+
} catch (e) {
|
|
82
|
+
return l(T) === r && T.set(() => n), i(() => a(e, b)), !1;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return L;
|
|
87
|
+
}
|
|
88
|
+
function m(e) {
|
|
89
|
+
return typeof e?.then == "function";
|
|
90
|
+
}
|
|
91
|
+
export { f as n, p as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { b as e, m as t } from "./graph-CR2WKbwr.js";
|
|
2
|
+
// src/core/signal.ts
|
|
3
|
+
function n(n, r) {
|
|
4
|
+
let i = {
|
|
5
|
+
kind: 0,
|
|
6
|
+
value: n,
|
|
7
|
+
equals: r?.equals ?? Object.is,
|
|
8
|
+
observers: [],
|
|
9
|
+
seenBy: 0
|
|
10
|
+
};
|
|
11
|
+
return Object.assign(() => (e(i), i.value), { set: (e) => {
|
|
12
|
+
let n = typeof e == "function" ? e(i.value) : e;
|
|
13
|
+
i.equals !== !1 && i.equals(i.value, n) || (i.value = n, t(i));
|
|
14
|
+
} });
|
|
15
|
+
}
|
|
16
|
+
export { n as t };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { t as e } from "./unsafe-keys-C5PMlerl.js";
|
|
2
|
+
import { b as t, f as n, i as r, m as i, x as a } from "./graph-CR2WKbwr.js";
|
|
3
|
+
// src/core/store.ts
|
|
4
|
+
var o = Symbol("raw"), s = Symbol("shape"), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), u = 0;
|
|
5
|
+
function d(e, t) {
|
|
6
|
+
let n = m(e);
|
|
7
|
+
return [n, (e) => {
|
|
8
|
+
u++;
|
|
9
|
+
try {
|
|
10
|
+
a(() => r(() => e(n)));
|
|
11
|
+
} finally {
|
|
12
|
+
u--;
|
|
13
|
+
}
|
|
14
|
+
}];
|
|
15
|
+
}
|
|
16
|
+
function f(e) {
|
|
17
|
+
if (typeof e == "object" && e) {
|
|
18
|
+
let t = e[o];
|
|
19
|
+
if (t !== void 0) return t;
|
|
20
|
+
}
|
|
21
|
+
return e;
|
|
22
|
+
}
|
|
23
|
+
function p(e) {
|
|
24
|
+
if (typeof e != "object" || !e || e === Object.prototype) return !1;
|
|
25
|
+
if (Array.isArray(e)) return !0;
|
|
26
|
+
let t = Object.getPrototypeOf(e);
|
|
27
|
+
return t === Object.prototype || t === null;
|
|
28
|
+
}
|
|
29
|
+
function m(e) {
|
|
30
|
+
if (!p(e)) return e;
|
|
31
|
+
let t = c.get(e);
|
|
32
|
+
return t === void 0 && (t = new Proxy(e, v), c.set(e, t)), t;
|
|
33
|
+
}
|
|
34
|
+
function h(e, t) {
|
|
35
|
+
let n = l.get(e);
|
|
36
|
+
n === void 0 && l.set(e, n = /* @__PURE__ */ new Map());
|
|
37
|
+
let r = n.get(t);
|
|
38
|
+
return r === void 0 && n.set(t, r = {
|
|
39
|
+
kind: 0,
|
|
40
|
+
observers: [],
|
|
41
|
+
seenBy: 0
|
|
42
|
+
}), r;
|
|
43
|
+
}
|
|
44
|
+
function g(e, t) {
|
|
45
|
+
let n = l.get(e)?.get(t);
|
|
46
|
+
n !== void 0 && i(n);
|
|
47
|
+
}
|
|
48
|
+
function _(e) {
|
|
49
|
+
return !1;
|
|
50
|
+
}
|
|
51
|
+
var v = {
|
|
52
|
+
get(e, r) {
|
|
53
|
+
if (r === o) return e;
|
|
54
|
+
let i = e[r];
|
|
55
|
+
return n() && (Object.hasOwn(e, r) || !(r in e)) && t(h(e, r)), m(i);
|
|
56
|
+
},
|
|
57
|
+
has(e, r) {
|
|
58
|
+
return n() && t(h(e, r)), r in e;
|
|
59
|
+
},
|
|
60
|
+
ownKeys(e) {
|
|
61
|
+
return n() && t(h(e, s)), Reflect.ownKeys(e);
|
|
62
|
+
},
|
|
63
|
+
set(e, t, n) {
|
|
64
|
+
if (u === 0) {
|
|
65
|
+
let t = _(e);
|
|
66
|
+
if (t) throw t;
|
|
67
|
+
return !1;
|
|
68
|
+
}
|
|
69
|
+
let r = e, i = f(n), a = Object.hasOwn(e, t), o = r[t], c = Array.isArray(e), l = c ? e.length : 0;
|
|
70
|
+
if (a && Object.is(o, i)) return !0;
|
|
71
|
+
if (r[t] = i, g(e, t), a || g(e, s), c) {
|
|
72
|
+
let n = e.length;
|
|
73
|
+
if (n !== l) {
|
|
74
|
+
t !== "length" && g(e, "length"), g(e, s);
|
|
75
|
+
for (let t = n; t < l; t++) g(e, String(t));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return !0;
|
|
79
|
+
},
|
|
80
|
+
deleteProperty(e, t) {
|
|
81
|
+
if (u === 0) {
|
|
82
|
+
let t = _(e);
|
|
83
|
+
if (t) throw t;
|
|
84
|
+
return !1;
|
|
85
|
+
}
|
|
86
|
+
return Object.hasOwn(e, t) && (delete e[t], g(e, t), g(e, s)), !0;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
function y(e, t, n = {}) {
|
|
90
|
+
b(m(f(e)), f(t), n.key);
|
|
91
|
+
}
|
|
92
|
+
function b(t, n, r) {
|
|
93
|
+
let i = f(t), a = t;
|
|
94
|
+
if (Array.isArray(i) && Array.isArray(n)) {
|
|
95
|
+
let e = /* @__PURE__ */ new Map();
|
|
96
|
+
if (r !== void 0) for (let t of i) p(t) && e.set(t[r], t);
|
|
97
|
+
for (let t = 0; t < n.length; t++) {
|
|
98
|
+
let o = n[t], s = r !== void 0 && p(o) ? e.get(o[r]) : i[t];
|
|
99
|
+
a[t] = x(s, o, r);
|
|
100
|
+
}
|
|
101
|
+
i.length !== n.length && (a.length = n.length);
|
|
102
|
+
} else {
|
|
103
|
+
for (let t of Object.keys(n)) e.has(t) || (a[t] = x(i[t], n[t], r));
|
|
104
|
+
for (let e of Object.keys(i)) Object.hasOwn(n, e) || delete a[e];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function x(e, t, n) {
|
|
108
|
+
return p(e) && p(t) && Array.isArray(e) === Array.isArray(t) ? (b(m(e), t, n), e) : t;
|
|
109
|
+
}
|
|
110
|
+
export { d as n, f as r, y as t };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { i as e, r as t, t as n } from "./shared/hydrate-kKnJbkV7.js";
|
|
2
|
+
import { d as r, s as i } from "./shared/graph-CR2WKbwr.js";
|
|
3
|
+
import { a, n as o } from "./shared/owner-DBi3odT4.js";
|
|
4
|
+
import { a as s, n as c } from "./shared/namespaces-BSRrBJIU.js";
|
|
5
|
+
// src/static/island.ts
|
|
6
|
+
function l(e, t, n = {}) {
|
|
7
|
+
return Object.assign((l) => {
|
|
8
|
+
let d = s.element("keits-island", null);
|
|
9
|
+
d.setAttribute("data-island", e), d.setAttribute("style", "display: contents"), n.when !== void 0 && n.when !== "load" && d.setAttribute("data-when", n.when);
|
|
10
|
+
let f = o((n) => {
|
|
11
|
+
let a = i();
|
|
12
|
+
return r() && (a.hydratable = !0, a.key !== void 0 && d.setAttribute("data-key", a.key), d.setAttribute("data-props", u(e, l))), c(d, t(l)), n;
|
|
13
|
+
});
|
|
14
|
+
return a(f), d;
|
|
15
|
+
}, {
|
|
16
|
+
island: e,
|
|
17
|
+
component: t
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function u(e, t) {
|
|
21
|
+
return JSON.stringify(t ?? {});
|
|
22
|
+
}
|
|
23
|
+
function d(e, t = document) {
|
|
24
|
+
for (let n of t.querySelectorAll("keits-island[data-key]")) {
|
|
25
|
+
if (n.parentElement?.closest("keits-island") != null) continue;
|
|
26
|
+
let t = n.getAttribute("data-island") ?? "", r = Object.hasOwn(e, t) ? e[t] : void 0;
|
|
27
|
+
r !== void 0 && p(n, n.getAttribute("data-when") ?? "load", () => {
|
|
28
|
+
if ("island" in r) return f(n, r);
|
|
29
|
+
Promise.resolve(r()).then((e) => f(n, "island" in e ? e : e.default), (e) => setTimeout(() => {
|
|
30
|
+
throw e;
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function f(e, t) {
|
|
36
|
+
let r = e.getAttribute("data-key"), i = JSON.parse(e.getAttribute("data-props") ?? "{}");
|
|
37
|
+
e.removeAttribute("data-key"), e.removeAttribute("data-props"), n(() => t.component(i), e, r);
|
|
38
|
+
}
|
|
39
|
+
function p(e, t, n) {
|
|
40
|
+
if (t === "visible" && typeof IntersectionObserver == "function") {
|
|
41
|
+
let t = new IntersectionObserver((e) => {
|
|
42
|
+
e.some((e) => e.isIntersecting) && (t.disconnect(), n());
|
|
43
|
+
});
|
|
44
|
+
for (let n of e.children) t.observe(n);
|
|
45
|
+
e.children.length === 0 && n();
|
|
46
|
+
} else t === "idle" && typeof requestIdleCallback == "function" ? requestIdleCallback(() => n()) : t === "idle" ? setTimeout(n, 1) : n();
|
|
47
|
+
}
|
|
48
|
+
export { e as head, n as hydrate, d as hydrateIslands, l as island, t as renderToString };
|
package/dist/prod/svg.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as e } from "./shared/element-DCit4-3e.js";
|
|
2
|
+
import { t } from "./shared/namespaces-BSRrBJIU.js";
|
|
2
3
|
// src/svg/element.ts
|
|
3
4
|
function n(n) {
|
|
4
|
-
return
|
|
5
|
+
return e(n, t);
|
|
5
6
|
}
|
|
6
7
|
// src/svg/tags.ts
|
|
7
8
|
var r = /* @__PURE__ */ n("a"), i = /* @__PURE__ */ n("animate"), a = /* @__PURE__ */ n("animateMotion"), o = /* @__PURE__ */ n("animateTransform"), s = /* @__PURE__ */ n("circle"), c = /* @__PURE__ */ n("clipPath"), l = /* @__PURE__ */ n("defs"), u = /* @__PURE__ */ n("desc"), d = /* @__PURE__ */ n("ellipse"), f = /* @__PURE__ */ n("feBlend"), p = /* @__PURE__ */ n("feColorMatrix"), m = /* @__PURE__ */ n("feComponentTransfer"), h = /* @__PURE__ */ n("feComposite"), g = /* @__PURE__ */ n("feConvolveMatrix"), _ = /* @__PURE__ */ n("feDiffuseLighting"), v = /* @__PURE__ */ n("feDisplacementMap"), y = /* @__PURE__ */ n("feDistantLight"), b = /* @__PURE__ */ n("feDropShadow"), x = /* @__PURE__ */ n("feFlood"), S = /* @__PURE__ */ n("feFuncA"), C = /* @__PURE__ */ n("feFuncB"), w = /* @__PURE__ */ n("feFuncG"), T = /* @__PURE__ */ n("feFuncR"), E = /* @__PURE__ */ n("feGaussianBlur"), D = /* @__PURE__ */ n("feImage"), O = /* @__PURE__ */ n("feMerge"), k = /* @__PURE__ */ n("feMergeNode"), A = /* @__PURE__ */ n("feMorphology"), j = /* @__PURE__ */ n("feOffset"), M = /* @__PURE__ */ n("fePointLight"), N = /* @__PURE__ */ n("feSpecularLighting"), P = /* @__PURE__ */ n("feSpotLight"), F = /* @__PURE__ */ n("feTile"), I = /* @__PURE__ */ n("feTurbulence"), L = /* @__PURE__ */ n("filter"), ee = /* @__PURE__ */ n("foreignObject"), R = /* @__PURE__ */ n("g"), z = /* @__PURE__ */ n("image"), B = /* @__PURE__ */ n("line"), V = /* @__PURE__ */ n("linearGradient"), H = /* @__PURE__ */ n("marker"), U = /* @__PURE__ */ n("mask"), W = /* @__PURE__ */ n("metadata"), G = /* @__PURE__ */ n("mpath"), K = /* @__PURE__ */ n("path"), q = /* @__PURE__ */ n("pattern"), J = /* @__PURE__ */ n("polygon"), Y = /* @__PURE__ */ n("polyline"), X = /* @__PURE__ */ n("radialGradient"), Z = /* @__PURE__ */ n("rect"), Q = /* @__PURE__ */ n("script"), $ = /* @__PURE__ */ n("set"), te = /* @__PURE__ */ n("stop"), ne = /* @__PURE__ */ n("style"), re = /* @__PURE__ */ n("svg"), ie = /* @__PURE__ */ n("switch"), ae = /* @__PURE__ */ n("symbol"), oe = /* @__PURE__ */ n("text"), se = /* @__PURE__ */ n("textPath"), ce = /* @__PURE__ */ n("title"), le = /* @__PURE__ */ n("tspan"), ue = /* @__PURE__ */ n("use"), de = /* @__PURE__ */ n("view");
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { t as e } from "./shared/mount-DbeKIoyD.js";
|
|
2
|
+
import { n as t, r as n, t as r } from "./shared/hydrate-kKnJbkV7.js";
|
|
3
|
+
// src/testing/index.ts
|
|
4
|
+
var i = /* @__PURE__ */ new Set();
|
|
5
|
+
function a(t) {
|
|
6
|
+
let n = document.body.appendChild(document.createElement("div"));
|
|
7
|
+
return s(n, e(t, n));
|
|
8
|
+
}
|
|
9
|
+
async function o(e) {
|
|
10
|
+
let a = await n(e, { hydrate: !0 }), o = document.body.appendChild(document.createElement("div"));
|
|
11
|
+
return o.innerHTML = a.html, document.getElementById("keits-data")?.remove(), a.data !== "" && document.body.insertAdjacentHTML("beforeend", a.data), t(), i.add(() => o.remove()), {
|
|
12
|
+
container: o,
|
|
13
|
+
html: a.html,
|
|
14
|
+
head: a.head,
|
|
15
|
+
hydrate: () => s(o, r(e, o))
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function s(e, t) {
|
|
19
|
+
let n = () => {
|
|
20
|
+
i.delete(n) && (t(), e.remove());
|
|
21
|
+
};
|
|
22
|
+
return i.add(n), {
|
|
23
|
+
container: e,
|
|
24
|
+
unmount: n,
|
|
25
|
+
...f(e)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function c() {
|
|
29
|
+
for (let e of [...i]) e();
|
|
30
|
+
i.clear(), document.getElementById("keits-data")?.remove();
|
|
31
|
+
}
|
|
32
|
+
async function l() {
|
|
33
|
+
for (let e = 0; e < 3; e++) await new Promise((e) => setTimeout(e, 0));
|
|
34
|
+
}
|
|
35
|
+
var u = {
|
|
36
|
+
click(e) {
|
|
37
|
+
e.dispatchEvent(new MouseEvent("click", {
|
|
38
|
+
bubbles: !0,
|
|
39
|
+
cancelable: !0,
|
|
40
|
+
button: 0
|
|
41
|
+
}));
|
|
42
|
+
},
|
|
43
|
+
type(e, t) {
|
|
44
|
+
let n = d(e, "type into");
|
|
45
|
+
n.focus();
|
|
46
|
+
for (let e of t) n.value += e, n.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
47
|
+
},
|
|
48
|
+
clear(e) {
|
|
49
|
+
let t = d(e, "clear");
|
|
50
|
+
t.value = "", t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
51
|
+
},
|
|
52
|
+
select(e, t) {
|
|
53
|
+
if (!(e instanceof HTMLSelectElement)) throw Error(`[keits/testing] user.select() needs a <select>, got <${e.localName}>.`);
|
|
54
|
+
e.value = t, e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
55
|
+
},
|
|
56
|
+
check(e) {
|
|
57
|
+
if (!(e instanceof HTMLInputElement) || e.type !== "checkbox" && e.type !== "radio") throw Error(`[keits/testing] user.check() needs a checkbox or radio, got ${h(e)}.`);
|
|
58
|
+
e.checked = e.type === "radio" || !e.checked, e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
59
|
+
},
|
|
60
|
+
blur(e) {
|
|
61
|
+
e.dispatchEvent(new FocusEvent("blur")), e.dispatchEvent(new FocusEvent("focusout", { bubbles: !0 }));
|
|
62
|
+
},
|
|
63
|
+
submit(e) {
|
|
64
|
+
let t = e instanceof HTMLFormElement ? e : e.closest("form");
|
|
65
|
+
if (t === null) throw Error(`[keits/testing] user.submit(): ${h(e)} is not in a <form>.`);
|
|
66
|
+
t.dispatchEvent(new Event("submit", {
|
|
67
|
+
bubbles: !0,
|
|
68
|
+
cancelable: !0
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
function d(e, t) {
|
|
73
|
+
if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement) return e;
|
|
74
|
+
throw Error(`[keits/testing] Can't ${t} ${h(e)}: it isn't an <input> or <textarea>.`);
|
|
75
|
+
}
|
|
76
|
+
function f(e) {
|
|
77
|
+
let t = () => [...e.querySelectorAll("*")], n = (e) => {
|
|
78
|
+
let n = t().filter((t) => m(p(t.textContent ?? ""), e));
|
|
79
|
+
return n.filter((e) => !n.some((t) => t !== e && e.contains(t)));
|
|
80
|
+
}, r = (e, n = {}) => t().filter((t) => v(t) === e && (n.name === void 0 || m(y(t), n.name))), i = (t, n) => {
|
|
81
|
+
if (t.length === 1) return t[0];
|
|
82
|
+
let r = p(e.textContent ?? "").slice(0, 200);
|
|
83
|
+
throw t.length === 0 ? Error(`[keits/testing] Found no element ${n}. The page says: "${r}"`) : Error(`[keits/testing] Found ${t.length} elements ${n}: ${t.map(h).join(", ")}. Make the query more specific.`);
|
|
84
|
+
}, a = (e, t) => `with role "${e}"${t?.name === void 0 ? "" : ` named ${String(t.name)}`}`;
|
|
85
|
+
return {
|
|
86
|
+
getByText: (e) => i(n(e), `with the text ${String(e)}`),
|
|
87
|
+
queryByText: (e) => n(e)[0] ?? null,
|
|
88
|
+
getAllByText: (e) => {
|
|
89
|
+
let t = n(e);
|
|
90
|
+
return t.length === 0 && i(t, `with the text ${String(e)}`), t;
|
|
91
|
+
},
|
|
92
|
+
getByRole: (e, t) => i(r(e, t), a(e, t)),
|
|
93
|
+
queryByRole: (e, t) => r(e, t)[0] ?? null,
|
|
94
|
+
getAllByRole: (e, t) => {
|
|
95
|
+
let n = r(e, t);
|
|
96
|
+
return n.length === 0 && i(n, a(e, t)), n;
|
|
97
|
+
},
|
|
98
|
+
getByLabelText: (e) => i(t().filter((t) => g(t) && _(t).some((t) => m(t, e))), `labelled ${String(e)}`),
|
|
99
|
+
getByTestId: (e) => i(t().filter((t) => t.getAttribute("data-testid") === e), `with data-testid "${e}"`)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
var p = (e) => e.replace(/\s+/g, " ").trim(), m = (e, t) => typeof t == "string" ? e === t : t.test(e), h = (e) => `<${e.localName}${e.id ? `#${e.id}` : ""}>`, g = (e) => [
|
|
103
|
+
"input",
|
|
104
|
+
"select",
|
|
105
|
+
"textarea",
|
|
106
|
+
"button"
|
|
107
|
+
].includes(e.localName);
|
|
108
|
+
function _(e) {
|
|
109
|
+
let t = [], n = e.getAttribute("aria-label");
|
|
110
|
+
n !== null && t.push(p(n));
|
|
111
|
+
let r = e.getAttribute("aria-labelledby");
|
|
112
|
+
if (r !== null && t.push(p(r.split(/\s+/).map((t) => e.ownerDocument.getElementById(t)?.textContent ?? "").join(" "))), e.id !== "") for (let n of e.ownerDocument.querySelectorAll(`label[for="${e.id}"]`)) t.push(p(n.textContent ?? ""));
|
|
113
|
+
let i = e.closest("label");
|
|
114
|
+
return i !== null && t.push(p(i.textContent ?? "")), t;
|
|
115
|
+
}
|
|
116
|
+
function v(e) {
|
|
117
|
+
let t = e.getAttribute("role");
|
|
118
|
+
if (t !== null) return t.split(/\s+/)[0];
|
|
119
|
+
let n = e.localName;
|
|
120
|
+
if (n === "input") {
|
|
121
|
+
let t = (e.getAttribute("type") ?? "text").toLowerCase();
|
|
122
|
+
return t === "checkbox" || t === "radio" ? t : t === "button" || t === "submit" || t === "reset" ? "button" : t === "range" ? "slider" : t === "number" ? "spinbutton" : t === "search" ? "searchbox" : t === "hidden" ? null : "textbox";
|
|
123
|
+
}
|
|
124
|
+
return /^h[1-6]$/.test(n) ? "heading" : n === "a" ? e.hasAttribute("href") ? "link" : null : n === "img" ? e.getAttribute("alt") === "" ? "presentation" : "img" : {
|
|
125
|
+
button: "button",
|
|
126
|
+
textarea: "textbox",
|
|
127
|
+
select: "combobox",
|
|
128
|
+
ul: "list",
|
|
129
|
+
ol: "list",
|
|
130
|
+
li: "listitem",
|
|
131
|
+
nav: "navigation",
|
|
132
|
+
main: "main",
|
|
133
|
+
form: "form",
|
|
134
|
+
dialog: "dialog",
|
|
135
|
+
table: "table",
|
|
136
|
+
tr: "row",
|
|
137
|
+
option: "option"
|
|
138
|
+
}[n] ?? null;
|
|
139
|
+
}
|
|
140
|
+
function y(e) {
|
|
141
|
+
let t = e.getAttribute("aria-label");
|
|
142
|
+
return t === null ? g(e) && e.localName !== "button" ? _(e)[0] ?? p(e.getAttribute("placeholder") ?? "") : e.localName === "img" ? p(e.getAttribute("alt") ?? "") : p(e.textContent ?? "") : p(t);
|
|
143
|
+
}
|
|
144
|
+
export { c as cleanup, l as flush, a as render, o as renderOnServer, u as user, f as within };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createHash as e } from "node:crypto";
|
|
2
|
+
import { existsSync as t } from "node:fs";
|
|
3
|
+
import { mkdir as n, readFile as r, rm as i, writeFile as a } from "node:fs/promises";
|
|
4
|
+
import { dirname as o, join as s, resolve as c } from "node:path";
|
|
5
|
+
import { pathToFileURL as l } from "node:url";
|
|
6
|
+
// src/vite/index.ts
|
|
7
|
+
var u = "<!--app-head-->", d = "<!--app-html-->";
|
|
8
|
+
function f(e) {
|
|
9
|
+
let t = {}, n;
|
|
10
|
+
return {
|
|
11
|
+
name: "keits",
|
|
12
|
+
apply: "build",
|
|
13
|
+
config(e) {
|
|
14
|
+
t = e;
|
|
15
|
+
},
|
|
16
|
+
configResolved(e) {
|
|
17
|
+
n = e;
|
|
18
|
+
},
|
|
19
|
+
async closeBundle() {
|
|
20
|
+
if (n.build.ssr) return;
|
|
21
|
+
let r = await p(t, n, e);
|
|
22
|
+
n.logger.info(`keits: ${r.rendered + r.reused} pages (${r.rendered} rendered, ${r.reused} reused) · ${r.changed.length} changed, ${r.removed.length} removed`);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function p(e, n, a) {
|
|
27
|
+
let o = n.root, f = c(o, n.build.outDir), p = c(o, a.cacheDir ?? "node_modules/.keits"), v = s(p, "server"), { build: y, mergeConfig: b } = await import("vite"), { environments: x, ...S } = e;
|
|
28
|
+
await y(b(S, {
|
|
29
|
+
configFile: !1,
|
|
30
|
+
root: o,
|
|
31
|
+
mode: n.mode,
|
|
32
|
+
logLevel: "warn",
|
|
33
|
+
ssr: { noExternal: !0 },
|
|
34
|
+
build: {
|
|
35
|
+
ssr: c(o, a.entry),
|
|
36
|
+
outDir: v,
|
|
37
|
+
emptyOutDir: !0,
|
|
38
|
+
copyPublicDir: !1,
|
|
39
|
+
rollupOptions: { output: {
|
|
40
|
+
entryFileNames: "entry.mjs",
|
|
41
|
+
format: "es"
|
|
42
|
+
} }
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
let C = s(v, "entry.mjs"), w = await import(`${l(C).href}?t=${Date.now()}`);
|
|
46
|
+
if (typeof w.pages != "function" || typeof w.render != "function") throw Error(`[keits/vite] ${a.entry} must export pages() and render(url).`);
|
|
47
|
+
let T = await r(s(f, "index.html"), "utf8");
|
|
48
|
+
if (!T.includes(d) || !T.includes(u)) throw Error(`[keits/vite] index.html needs ${d} where the page goes (e.g. <div id="app">${d}</div>), and ${u} in <head>.`);
|
|
49
|
+
let E = g(T + await r(C, "utf8")), D = s(p, "pages.json"), O = t(D) ? JSON.parse(await r(D, "utf8")) : {
|
|
50
|
+
code: "",
|
|
51
|
+
pages: {}
|
|
52
|
+
}, k = {
|
|
53
|
+
code: E,
|
|
54
|
+
pages: {}
|
|
55
|
+
}, A = {
|
|
56
|
+
changed: [],
|
|
57
|
+
removed: [],
|
|
58
|
+
rendered: 0,
|
|
59
|
+
reused: 0
|
|
60
|
+
}, j = [...await w.pages()].map((e) => typeof e == "string" ? { url: e } : e), M = [], N = async (e, t) => {
|
|
61
|
+
let n = g(t);
|
|
62
|
+
O.files?.[e] !== n && A.changed.push(e), (k.files ??= {})[e] = n, await h(s(f, e), t);
|
|
63
|
+
};
|
|
64
|
+
for (let e of j) {
|
|
65
|
+
let n = m(e.url), i = O.pages[e.url], a = s(p, "pages", n), o;
|
|
66
|
+
try {
|
|
67
|
+
if (e.version !== void 0 && O.code === E && i?.version === e.version && t(a)) o = await r(a, "utf8"), A.reused++;
|
|
68
|
+
else {
|
|
69
|
+
let t = await w.render(e.url);
|
|
70
|
+
o = T.replace(u, () => t.head).replace(d, () => t.html + t.data), A.rendered++, await h(a, o);
|
|
71
|
+
}
|
|
72
|
+
} catch (t) {
|
|
73
|
+
M.push(` ${e.url}: ${t instanceof Error ? t.message : String(t)}`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
await h(s(f, n), o);
|
|
77
|
+
let c = g(o);
|
|
78
|
+
(i?.hash !== c || i.file !== n) && A.changed.push(n), k.pages[e.url] = {
|
|
79
|
+
hash: c,
|
|
80
|
+
file: n,
|
|
81
|
+
...e.version === void 0 ? {} : { version: e.version }
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (M.length > 0) throw Error(`[keits/vite] ${M.length} page(s) could not be rendered:\n${M.join("\n")}`);
|
|
85
|
+
for (let [e, t] of Object.entries(O.pages)) e in k.pages || (A.removed.push(t.file), await i(s(p, "pages", t.file), { force: !0 }));
|
|
86
|
+
if (a.site !== void 0) {
|
|
87
|
+
let e = a.site.replace(/\/+$/, "");
|
|
88
|
+
await N("sitemap.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n" + j.filter((e) => e.sitemap !== !1 && m(e.url) !== "404.html").map((t) => ` <url><loc>${_(e + t.url)}</loc></url>\n`).join("") + "</urlset>\n"), t(s(f, "robots.txt")) || await N("robots.txt", `User-agent: *\nAllow: /\n\nSitemap: ${e}/sitemap.xml\n`);
|
|
89
|
+
}
|
|
90
|
+
return await h(D, JSON.stringify(k, null, 2)), await h(s(p, "changes.json"), JSON.stringify(A, null, 2)), A;
|
|
91
|
+
}
|
|
92
|
+
function m(e) {
|
|
93
|
+
if (!e.startsWith("/") || e.split("/").some((e) => e === ".." || e === ".")) throw Error(`[keits/vite] "${e}" is not a page URL: it must start with "/" and can't contain "." or ".." parts.`);
|
|
94
|
+
let t = e.split(/[?#]/)[0].replace(/\/+$/, "");
|
|
95
|
+
return t === "" ? "index.html" : t === "/404" ? "404.html" : t.endsWith(".html") ? t.slice(1) : `${t.slice(1)}/index.html`;
|
|
96
|
+
}
|
|
97
|
+
async function h(e, t) {
|
|
98
|
+
await n(o(e), { recursive: !0 }), await a(e, t);
|
|
99
|
+
}
|
|
100
|
+
function g(t) {
|
|
101
|
+
return e("sha256").update(t).digest("hex").slice(0, 16);
|
|
102
|
+
}
|
|
103
|
+
function _(e) {
|
|
104
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
105
|
+
}
|
|
106
|
+
export { m as fileFor, f as keits };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Watcher {
|
|
2
|
+
readonly url: string | null;
|
|
3
|
+
push(data: unknown): void;
|
|
4
|
+
refetch(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export interface QueryCache {
|
|
7
|
+
peek(url: string): {
|
|
8
|
+
data: unknown;
|
|
9
|
+
stale: boolean;
|
|
10
|
+
} | null;
|
|
11
|
+
fetch(url: string): Promise<unknown>;
|
|
12
|
+
watch(watcher: Watcher): () => void;
|
|
13
|
+
invalidate(prefix: string): Promise<void>;
|
|
14
|
+
clear(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare function createQueryCache(load: (url: string) => Promise<unknown>, staleTime: number, maxEntries?: number): QueryCache;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Resource } from "../async/resource";
|
|
2
|
+
import { type PathParams, type QueryParams } from "./url";
|
|
3
|
+
export interface ApiConfig {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
headers?: HeadersInit | (() => HeadersInit | PromiseLike<HeadersInit>);
|
|
6
|
+
timeout?: number;
|
|
7
|
+
refresh?: () => boolean | PromiseLike<boolean>;
|
|
8
|
+
staleTime?: number;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
credentials?: RequestCredentials;
|
|
11
|
+
}
|
|
12
|
+
export interface RequestOptions<T> {
|
|
13
|
+
params?: PathParams;
|
|
14
|
+
query?: QueryParams;
|
|
15
|
+
body?: unknown;
|
|
16
|
+
headers?: HeadersInit;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
parse?: (data: unknown) => T;
|
|
20
|
+
invalidate?: string | readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export interface QueryOptions<T> {
|
|
23
|
+
params?: PathParams | (() => PathParams | null | undefined | false);
|
|
24
|
+
query?: QueryParams | (() => QueryParams | null | undefined | false);
|
|
25
|
+
parse?: (data: unknown) => T;
|
|
26
|
+
}
|
|
27
|
+
export interface Api {
|
|
28
|
+
get<T = unknown>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
29
|
+
post<T = unknown>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
30
|
+
put<T = unknown>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
31
|
+
patch<T = unknown>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
32
|
+
delete<T = unknown>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
33
|
+
request<T = unknown>(method: string, path: string, options?: RequestOptions<T>): Promise<T>;
|
|
34
|
+
query<T = unknown>(path: string, options?: QueryOptions<T>): Resource<T>;
|
|
35
|
+
prefetch(path: string, options?: {
|
|
36
|
+
params?: PathParams;
|
|
37
|
+
query?: QueryParams;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
invalidate(prefix?: string): Promise<void>;
|
|
40
|
+
clear(): void;
|
|
41
|
+
}
|
|
42
|
+
export declare function createApi(config?: ApiConfig): Api;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class ApiError extends Error {
|
|
2
|
+
readonly name = "ApiError";
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly body: unknown;
|
|
5
|
+
readonly method: string;
|
|
6
|
+
readonly url: string;
|
|
7
|
+
constructor(init: {
|
|
8
|
+
status: number;
|
|
9
|
+
body: unknown;
|
|
10
|
+
method: string;
|
|
11
|
+
url: string;
|
|
12
|
+
message: string;
|
|
13
|
+
cause?: unknown;
|
|
14
|
+
});
|
|
15
|
+
get timedOut(): boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type QueryValue = string | number | boolean | null | undefined | readonly (string | number | boolean)[];
|
|
2
|
+
export type QueryParams = Readonly<Record<string, QueryValue>>;
|
|
3
|
+
export type PathParams = Readonly<Record<string, string | number>>;
|
|
4
|
+
export declare function buildPath(path: string, params?: PathParams, query?: QueryParams): string;
|
|
5
|
+
export declare function underPrefix(url: string, prefix: string): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Owner } from "../core/graph";
|
|
2
|
+
export interface RenderTracker {
|
|
3
|
+
wait(loading: Promise<unknown>): void;
|
|
4
|
+
store(key: string, value: unknown, owner: Owner | null): void;
|
|
5
|
+
}
|
|
6
|
+
export declare const RenderContext: import("..").Context<RenderTracker | null>;
|
|
7
|
+
export declare let hydratedValue: ((key: string) => {
|
|
8
|
+
value: unknown;
|
|
9
|
+
} | undefined) | null;
|
|
10
|
+
export declare function setHydratedValue(lookup: typeof hydratedValue): void;
|