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.
Files changed (75) hide show
  1. package/README.md +93 -79
  2. package/dist/dev/api.js +275 -0
  3. package/dist/dev/forms.js +330 -0
  4. package/dist/dev/index.js +26 -326
  5. package/dist/dev/router.js +24 -5
  6. package/dist/dev/shared/computed-DrF8O8b4.js +40 -0
  7. package/dist/dev/shared/{element-C4DfKtZW.js → element-DXwmUAnz.js} +32 -111
  8. package/dist/dev/shared/{graph-D6-x_CWC.js → graph-SIvYLXSv.js} +62 -3
  9. package/dist/dev/shared/hydrate-C8cOsDDH.js +588 -0
  10. package/dist/dev/shared/mount-CDB2HgN5.js +23 -0
  11. package/dist/dev/shared/namespaces-Cz82B0Pr.js +84 -0
  12. package/dist/dev/shared/owner-BuwIoI4j.js +72 -0
  13. package/dist/dev/shared/render-context-k2uu_dM_.js +34 -0
  14. package/dist/dev/shared/render-effect-Uk9dDmuU.js +32 -0
  15. package/dist/dev/shared/resource-DlgzdtcG.js +145 -0
  16. package/dist/dev/shared/signal-B3xOKbVm.js +24 -0
  17. package/dist/dev/shared/store-0vEg2bQV.js +152 -0
  18. package/dist/dev/shared/unsafe-keys-CB1P22No.js +8 -0
  19. package/dist/dev/static.js +76 -0
  20. package/dist/dev/svg.js +2 -1
  21. package/dist/dev/testing.js +216 -0
  22. package/dist/dev/vite.js +141 -0
  23. package/dist/prod/api.js +215 -0
  24. package/dist/prod/forms.js +240 -0
  25. package/dist/prod/index.js +110 -327
  26. package/dist/prod/router.js +83 -68
  27. package/dist/prod/shared/computed-BjqJ6Pps.js +33 -0
  28. package/dist/prod/shared/element-DCit4-3e.js +129 -0
  29. package/dist/prod/shared/{graph-C_aA46c6.js → graph-CR2WKbwr.js} +107 -63
  30. package/dist/prod/shared/hydrate-kKnJbkV7.js +480 -0
  31. package/dist/prod/shared/mount-DbeKIoyD.js +18 -0
  32. package/dist/prod/shared/namespaces-BSRrBJIU.js +71 -0
  33. package/dist/prod/shared/owner-DBi3odT4.js +67 -0
  34. package/dist/prod/shared/render-context-DF8lr1uu.js +30 -0
  35. package/dist/prod/shared/render-effect-UFDi2Pfh.js +25 -0
  36. package/dist/prod/shared/resource-Ch5tVseZ.js +91 -0
  37. package/dist/prod/shared/signal-BDMlfa0Z.js +16 -0
  38. package/dist/prod/shared/store-CvW0DbmK.js +110 -0
  39. package/dist/prod/shared/unsafe-keys-C5PMlerl.js +7 -0
  40. package/dist/prod/static.js +48 -0
  41. package/dist/prod/svg.js +3 -2
  42. package/dist/prod/testing.js +144 -0
  43. package/dist/prod/vite.js +106 -0
  44. package/dist/types/api/cache.d.ts +16 -0
  45. package/dist/types/api/client.d.ts +42 -0
  46. package/dist/types/api/error.d.ts +16 -0
  47. package/dist/types/api/index.d.ts +3 -0
  48. package/dist/types/api/url.d.ts +5 -0
  49. package/dist/types/async/render-context.d.ts +10 -0
  50. package/dist/types/core/effect.d.ts +1 -0
  51. package/dist/types/core/graph.d.ts +11 -0
  52. package/dist/types/core/owner.d.ts +1 -0
  53. package/dist/types/core/unsafe-keys.d.ts +2 -0
  54. package/dist/types/dom/hooks.d.ts +4 -0
  55. package/dist/types/dom/types.d.ts +5 -0
  56. package/dist/types/forms/form.d.ts +55 -0
  57. package/dist/types/forms/index.d.ts +2 -0
  58. package/dist/types/forms/paths.d.ts +6 -0
  59. package/dist/types/forms/types.d.ts +38 -0
  60. package/dist/types/router/index.d.ts +1 -0
  61. package/dist/types/router/match.d.ts +1 -0
  62. package/dist/types/router/types.d.ts +1 -0
  63. package/dist/types/static/head.d.ts +36 -0
  64. package/dist/types/static/hydrate.d.ts +3 -0
  65. package/dist/types/static/index.d.ts +4 -0
  66. package/dist/types/static/island.d.ts +14 -0
  67. package/dist/types/static/json.d.ts +1 -0
  68. package/dist/types/static/render.d.ts +11 -0
  69. package/dist/types/static/server-dom.d.ts +100 -0
  70. package/dist/types/testing/index.d.ts +62 -0
  71. package/dist/types/vite/index.d.ts +24 -0
  72. package/package.json +46 -5
  73. package/dist/dev/shared/owner-DlUsXKXE.js +0 -122
  74. package/dist/prod/shared/element-DUtXb3px.js +0 -187
  75. package/dist/prod/shared/owner-DgJNPM0P.js +0 -104
@@ -1,122 +0,0 @@
1
- import { _ as withStaticRender, c as handleError, d as notify, g as updateIfNeeded, i as batch, m as track, n as addMount, o as dispose, p as runWithOwner$1, r as adopt, s as getOwner$1, t as addCleanup } from "./graph-D6-x_CWC.js";
2
- // src/core/signal.ts
3
- function signal(value, options) {
4
- const node = {
5
- kind: 0,
6
- value,
7
- equals: options?.equals ?? Object.is,
8
- observers: [],
9
- seenBy: 0
10
- };
11
- if (options?.name !== void 0) node.name = options.name;
12
- const read = () => {
13
- track(node);
14
- return node.value;
15
- };
16
- const set = (next) => {
17
- const value = typeof next === "function" ? next(node.value) : next;
18
- if (node.equals !== false && node.equals(node.value, value)) return;
19
- node.value = value;
20
- notify(node);
21
- };
22
- return Object.assign(read, { set });
23
- }
24
- // src/core/computed.ts
25
- function computed(fn, options) {
26
- const node = {
27
- kind: 2,
28
- fn,
29
- value: void 0,
30
- equals: options?.equals ?? Object.is,
31
- hasValue: false,
32
- hasError: false,
33
- error: void 0,
34
- computing: false,
35
- state: 2,
36
- sources: [],
37
- observers: [],
38
- seenBy: 0,
39
- flushId: 0,
40
- flushRuns: 0,
41
- owner: null,
42
- children: null,
43
- cleanups: null,
44
- disposed: false
45
- };
46
- if (options?.name !== void 0) node.name = options.name;
47
- adopt(node);
48
- return () => {
49
- if (node.computing) throw cycleError(node);
50
- if (node.state !== 0) updateIfNeeded(node);
51
- track(node);
52
- if (node.hasError) throw node.error;
53
- return node.value;
54
- };
55
- }
56
- function cycleError(node) {
57
- {
58
- const who = node.name ? `"${node.name}"` : "a computed";
59
- return /* @__PURE__ */ new Error(`[keits] Cycle detected: ${who} reads itself (directly or through other computeds).`);
60
- }
61
- }
62
- // src/core/owner.ts
63
- function getOwner() {
64
- return getOwner$1();
65
- }
66
- function runWithOwner(owner, fn) {
67
- return runWithOwner$1(owner, fn);
68
- }
69
- function createRoot(fn) {
70
- const root = {
71
- kind: 3,
72
- owner: getOwner$1(),
73
- children: null,
74
- cleanups: null,
75
- disposed: false,
76
- handler: null
77
- };
78
- const disposeRoot = () => batch(() => dispose(root));
79
- return batch(() => {
80
- try {
81
- return runWithOwner$1(root, () => fn(disposeRoot));
82
- } catch (error) {
83
- dispose(root);
84
- throw error;
85
- }
86
- });
87
- }
88
- function onCleanup(fn) {
89
- if (!addCleanup(fn) && true) console.warn("[keits] onCleanup was called outside an owner, so it will never run.");
90
- }
91
- function onMount(fn) {
92
- addMount(fn);
93
- }
94
- function catchError(fn, handler) {
95
- const boundary = {
96
- kind: 3,
97
- owner: null,
98
- children: null,
99
- cleanups: null,
100
- disposed: false,
101
- handler
102
- };
103
- adopt(boundary);
104
- return batch(() => {
105
- try {
106
- return runWithOwner$1(boundary, fn);
107
- } catch (error) {
108
- handleError(error, boundary);
109
- return;
110
- }
111
- });
112
- }
113
- function renderStatic(fn) {
114
- return withStaticRender(() => createRoot((dispose) => {
115
- try {
116
- return fn();
117
- } finally {
118
- dispose();
119
- }
120
- }));
121
- }
122
- export { onMount as a, computed as c, onCleanup as i, signal as l, createRoot as n, renderStatic as o, getOwner as r, runWithOwner as s, catchError as t };
@@ -1,187 +0,0 @@
1
- import { c as e, f as t, i as n, l as r, p as i, r as a, s as o } from "./graph-C_aA46c6.js";
2
- // src/core/effect.ts
3
- function s(e, i) {
4
- if (r()) return;
5
- let o = {
6
- kind: 1,
7
- fn: e,
8
- state: 0,
9
- sources: [],
10
- flushId: 0,
11
- flushRuns: 0,
12
- owner: null,
13
- children: null,
14
- cleanups: null,
15
- disposed: !1
16
- };
17
- a(o), n(() => t(o));
18
- }
19
- var c = {
20
- element: (e, t) => t === null ? document.createElement(e) : document.createElementNS(t, e),
21
- text: (e) => document.createTextNode(e),
22
- marker: () => document.createComment("")
23
- };
24
- // src/dom/render-effect.ts
25
- function l(e) {
26
- r() ? e() : s(e);
27
- }
28
- // src/dom/insert.ts
29
- function u(e, t, n = null) {
30
- if (t != null && typeof t != "boolean") {
31
- if (typeof t == "function") return m(e, t, n);
32
- if (d(t)) for (let r of t) u(e, r, n);
33
- else typeof t == "object" ? e.insertBefore(t, n) : e.insertBefore(c.text(String(t)), n);
34
- }
35
- }
36
- function d(e) {
37
- return Array.isArray(e);
38
- }
39
- function f(e) {
40
- return e === null || typeof e != "object" && typeof e != "function";
41
- }
42
- function p(e) {
43
- return e == null || typeof e == "boolean" ? "" : String(e);
44
- }
45
- function m(e, t, n) {
46
- let r = c.text("");
47
- e.insertBefore(r, n);
48
- let i = null, a = null;
49
- l(() => {
50
- let e = t();
51
- if (i === null || a === null) {
52
- if (f(e)) {
53
- let t = p(e);
54
- r.data !== t && (r.data = t);
55
- return;
56
- }
57
- i = c.marker(), a = c.marker(), r.before(i), r.after(a), r.remove();
58
- }
59
- h(i, a), u(a.parentNode, e, a);
60
- });
61
- }
62
- function h(e, t) {
63
- let n = e.nextSibling;
64
- for (; n !== null && n !== t;) {
65
- let e = n.nextSibling;
66
- n.remove(), n = e;
67
- }
68
- }
69
- // src/dom/events.ts
70
- function g(e, t, n) {
71
- let i = n, a;
72
- if (Array.isArray(n) && ([i, a] = n), typeof i != "function") throw Error("[keits] bad handler");
73
- r() || _(e, t.slice(2), i, a);
74
- }
75
- function _(t, r, a, s) {
76
- let c = o();
77
- t.addEventListener(r, (t) => {
78
- n(() => {
79
- try {
80
- let r = i(c, () => a(t));
81
- v(r) && r.then(void 0, (t) => n(() => e(t, c)));
82
- } catch (t) {
83
- e(t, c);
84
- }
85
- });
86
- }, s);
87
- }
88
- function v(e) {
89
- return typeof e?.then == "function";
90
- }
91
- // src/dom/namespaces.ts
92
- var y = "http://www.w3.org/2000/svg", b = /* @__PURE__ */ new Set([
93
- "innerHTML",
94
- "outerHTML",
95
- "srcdoc"
96
- ]), x = /* @__PURE__ */ new Set([
97
- "href",
98
- "src",
99
- "action",
100
- "formAction",
101
- "formaction",
102
- "poster",
103
- "cite",
104
- "data",
105
- "xlink:href"
106
- ]), S = "about:invalid#keits-blocked";
107
- function C(e, t) {
108
- for (let n in t) {
109
- let r = t[n];
110
- n !== "ref" && (n === "class" ? D(e, r) : n === "style" ? j(e, r) : n.startsWith("on") ? g(e, n, r) : typeof r == "function" ? l(() => w(e, n, r())) : w(e, n, r));
111
- }
112
- }
113
- function w(e, t, n) {
114
- if (b.has(t)) throw Error("[keits] unsafe prop");
115
- x.has(t) && typeof n == "string" && T(n) && (n = S), t in e && e.namespaceURI !== "http://www.w3.org/2000/svg" ? (e[t] = n, r() && E(e, t, n)) : n == null || n === !1 ? e.removeAttribute(t) : e.setAttribute(t, n === !0 ? "" : String(n));
116
- }
117
- function T(e) {
118
- return e.replace(/[\u0000-\u0020]/g, "").toLowerCase().startsWith("javascript");
119
- }
120
- function E(e, t, n) {
121
- t === "value" ? e.localName === "textarea" ? e.textContent = n == null ? "" : String(n) : n == null ? e.removeAttribute("value") : e.setAttribute("value", String(n)) : (t === "checked" || t === "selected") && e.toggleAttribute(t, n === !0);
122
- }
123
- function D(e, t) {
124
- if (typeof t == "function") {
125
- l(() => O(e, A(t())));
126
- return;
127
- }
128
- let n = [];
129
- k(t, n, (t, n) => {
130
- l(() => e.classList.toggle(t, n()));
131
- }), n.length > 0 && e.classList.add(...n);
132
- }
133
- function O(e, t) {
134
- t === "" ? e.removeAttribute("class") : e.setAttribute("class", t);
135
- }
136
- function k(e, t, n) {
137
- if (e) {
138
- if (typeof e == "string") for (let n of e.split(/\s+/)) n && t.push(n);
139
- else if (Array.isArray(e)) for (let r of e) k(r, t, n);
140
- else for (let [r, i] of Object.entries(e)) typeof i == "function" ? n ? n(r, i) : i() && t.push(r) : i && t.push(r);
141
- }
142
- }
143
- function A(e) {
144
- let t = [];
145
- return k(e, t), t.join(" ");
146
- }
147
- function j(e, t) {
148
- let n = e.style;
149
- if (typeof t == "function") {
150
- let e = [];
151
- l(() => {
152
- let r = t();
153
- if (typeof r == "string" || r == null) {
154
- n.cssText = r ?? "", e = [];
155
- return;
156
- }
157
- let i = Object.keys(r);
158
- for (let t of e) t in r || n.removeProperty(t);
159
- for (let e of i) N(n, e, M(r[e]));
160
- e = i;
161
- });
162
- } else if (typeof t == "string") n.cssText = t;
163
- else if (t != null) for (let [e, r] of Object.entries(t)) typeof r == "function" ? l(() => N(n, e, r())) : N(n, e, r);
164
- }
165
- function M(e) {
166
- return typeof e == "function" ? e() : e;
167
- }
168
- function N(e, t, n) {
169
- n == null || n === "" ? e.removeProperty(t) : e.setProperty(t, String(n));
170
- }
171
- // src/dom/element.ts
172
- function P(e) {
173
- return (t, n) => {
174
- let r = c.element(e, null);
175
- return I(t) ? (C(r, t), u(r, n), typeof t.ref == "function" && t.ref(r)) : t == null ? u(r, n) : u(r, t), r;
176
- };
177
- }
178
- function F(e, t) {
179
- return (n, r) => {
180
- let i = c.element(e, t);
181
- return I(n) ? (C(i, n), u(i, r), typeof n.ref == "function" && n.ref(i)) : n == null ? u(i, r) : u(i, n), i;
182
- };
183
- }
184
- function I(e) {
185
- return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.nodeType != "number";
186
- }
187
- export { l as a, u as i, P as n, c as o, y as r, s, F as t };
@@ -1,104 +0,0 @@
1
- import { _ as e, c as t, d as n, g as r, i, m as a, n as o, o as s, p as c, r as l, s as u, t as d } from "./graph-C_aA46c6.js";
2
- // src/core/signal.ts
3
- function f(e, t) {
4
- let r = {
5
- kind: 0,
6
- value: e,
7
- equals: t?.equals ?? Object.is,
8
- observers: [],
9
- seenBy: 0
10
- };
11
- return Object.assign(() => (a(r), r.value), { set: (e) => {
12
- let t = typeof e == "function" ? e(r.value) : e;
13
- r.equals !== !1 && r.equals(r.value, t) || (r.value = t, n(r));
14
- } });
15
- }
16
- // src/core/computed.ts
17
- function p(e, t) {
18
- let n = {
19
- kind: 2,
20
- fn: e,
21
- value: void 0,
22
- equals: t?.equals ?? Object.is,
23
- hasValue: !1,
24
- hasError: !1,
25
- error: void 0,
26
- computing: !1,
27
- state: 2,
28
- sources: [],
29
- observers: [],
30
- seenBy: 0,
31
- flushId: 0,
32
- flushRuns: 0,
33
- owner: null,
34
- children: null,
35
- cleanups: null,
36
- disposed: !1
37
- };
38
- return l(n), () => {
39
- if (n.computing) throw m(n);
40
- if (n.state !== 0 && r(n), a(n), n.hasError) throw n.error;
41
- return n.value;
42
- };
43
- }
44
- function m(e) {
45
- return /* @__PURE__ */ Error("[keits] cycle detected");
46
- }
47
- // src/core/owner.ts
48
- function h() {
49
- return u();
50
- }
51
- function g(e, t) {
52
- return c(e, t);
53
- }
54
- function _(e) {
55
- let t = {
56
- kind: 3,
57
- owner: u(),
58
- children: null,
59
- cleanups: null,
60
- disposed: !1,
61
- handler: null
62
- }, n = () => i(() => s(t));
63
- return i(() => {
64
- try {
65
- return c(t, () => e(n));
66
- } catch (e) {
67
- throw s(t), e;
68
- }
69
- });
70
- }
71
- function v(e) {
72
- d(e);
73
- }
74
- function y(e) {
75
- o(e);
76
- }
77
- function b(e, n) {
78
- let r = {
79
- kind: 3,
80
- owner: null,
81
- children: null,
82
- cleanups: null,
83
- disposed: !1,
84
- handler: n
85
- };
86
- return l(r), i(() => {
87
- try {
88
- return c(r, e);
89
- } catch (e) {
90
- t(e, r);
91
- return;
92
- }
93
- });
94
- }
95
- function x(t) {
96
- return e(() => _((e) => {
97
- try {
98
- return t();
99
- } finally {
100
- e();
101
- }
102
- }));
103
- }
104
- export { y as a, p as c, v as i, f as l, _ as n, x as o, h as r, g as s, b as t };