keits 0.0.3 → 0.0.4

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 (37) hide show
  1. package/dist/dev/api.js +270 -0
  2. package/dist/dev/forms.js +328 -0
  3. package/dist/dev/index.js +8 -299
  4. package/dist/dev/router.js +3 -1
  5. package/dist/dev/shared/computed-3UO-KiH1.js +40 -0
  6. package/dist/dev/shared/{element-C4DfKtZW.js → element-CQPqagu1.js} +5 -38
  7. package/dist/dev/shared/owner-Dmge21OW.js +62 -0
  8. package/dist/dev/shared/render-effect-kOGnLNbL.js +26 -0
  9. package/dist/dev/shared/resource-CbXVATvq.js +154 -0
  10. package/dist/dev/shared/signal-BOXkY-Iv.js +24 -0
  11. package/dist/dev/shared/store-BzUN1qE5.js +148 -0
  12. package/dist/dev/svg.js +1 -1
  13. package/dist/prod/api.js +210 -0
  14. package/dist/prod/forms.js +237 -0
  15. package/dist/prod/index.js +107 -316
  16. package/dist/prod/router.js +24 -22
  17. package/dist/prod/shared/computed-CAPpOLCY.js +33 -0
  18. package/dist/prod/shared/element-DGyQ01Vs.js +164 -0
  19. package/dist/prod/shared/owner-6BFHIPR9.js +59 -0
  20. package/dist/prod/shared/render-effect-DjaUT3Cn.js +23 -0
  21. package/dist/prod/shared/resource-CNC2DBO3.js +109 -0
  22. package/dist/prod/shared/signal-DGrl3r9T.js +16 -0
  23. package/dist/prod/shared/store-Dcscpk_h.js +109 -0
  24. package/dist/prod/svg.js +1 -1
  25. package/dist/types/api/cache.d.ts +16 -0
  26. package/dist/types/api/client.d.ts +42 -0
  27. package/dist/types/api/error.d.ts +16 -0
  28. package/dist/types/api/index.d.ts +3 -0
  29. package/dist/types/api/url.d.ts +5 -0
  30. package/dist/types/forms/form.d.ts +55 -0
  31. package/dist/types/forms/index.d.ts +2 -0
  32. package/dist/types/forms/paths.d.ts +6 -0
  33. package/dist/types/forms/types.d.ts +38 -0
  34. package/package.json +16 -2
  35. package/dist/dev/shared/owner-DlUsXKXE.js +0 -122
  36. package/dist/prod/shared/element-DUtXb3px.js +0 -187
  37. package/dist/prod/shared/owner-DgJNPM0P.js +0 -104
@@ -0,0 +1,38 @@
1
+ type Leaf = string | number | boolean | bigint | symbol | null | undefined | Date | Blob | ((...args: never[]) => unknown);
2
+ export type Path<T, Depth extends unknown[] = []> = Depth["length"] extends 8 ? never : T extends Leaf ? never : T extends readonly (infer Item)[] ? `${number}` | SubPath<`${number}`, Item, Depth> : {
3
+ [K in keyof T & string]: K | SubPath<K, T[K], Depth>;
4
+ }[keyof T & string];
5
+ type SubPath<K extends string, V, Depth extends unknown[]> = V extends Leaf ? never : `${K}.${Path<V, [...Depth, unknown]>}`;
6
+ export type PathValue<T, P extends string> = P extends `${infer Head}.${infer Rest}` ? PathValue<Step<T, Head>, Rest> : Step<T, P>;
7
+ type Step<T, K extends string> = T extends readonly (infer Item)[] ? (K extends `${number}` ? Item : never) : K extends keyof T ? T[K] : never;
8
+ export type ArrayPath<T> = {
9
+ [P in Path<T>]: PathValue<T, P> extends readonly unknown[] ? P : never;
10
+ }[Path<T>];
11
+ export type FormErrors<T> = {
12
+ [P in Path<T> | ""]?: string;
13
+ };
14
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
15
+ readonly "~standard": {
16
+ readonly version: 1;
17
+ readonly vendor: string;
18
+ readonly validate: (value: unknown) => StandardResult<Output> | Promise<StandardResult<Output>>;
19
+ readonly types?: {
20
+ readonly input: Input;
21
+ readonly output: Output;
22
+ } | undefined;
23
+ };
24
+ }
25
+ export type StandardResult<Output> = {
26
+ readonly value: Output;
27
+ readonly issues?: undefined;
28
+ } | {
29
+ readonly issues: readonly StandardIssue[];
30
+ };
31
+ export interface StandardIssue {
32
+ readonly message: string;
33
+ readonly path?: readonly (PropertyKey | {
34
+ readonly key: PropertyKey;
35
+ })[] | undefined;
36
+ }
37
+ export type CheckResult = string | null | undefined | false;
38
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keits",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Fine-grained reactive TypeScript framework. Real DOM, no virtual DOM, zero dependencies.",
5
5
  "keywords": [
6
6
  "reactive",
@@ -36,6 +36,18 @@
36
36
  "types": "./dist/types/router/index.d.ts",
37
37
  "development": "./dist/dev/router.js",
38
38
  "default": "./dist/prod/router.js"
39
+ },
40
+ "./api": {
41
+ "@keits/source": "./src/api/index.ts",
42
+ "types": "./dist/types/api/index.d.ts",
43
+ "development": "./dist/dev/api.js",
44
+ "default": "./dist/prod/api.js"
45
+ },
46
+ "./forms": {
47
+ "@keits/source": "./src/forms/index.ts",
48
+ "types": "./dist/types/forms/index.d.ts",
49
+ "development": "./dist/dev/forms.js",
50
+ "default": "./dist/prod/forms.js"
39
51
  }
40
52
  },
41
53
  "scripts": {
@@ -49,6 +61,8 @@
49
61
  "size/dom-basic.js": 3072,
50
62
  "size/svg-icon.js": 3328,
51
63
  "size/data-app.js": 5120,
52
- "size/router-app.js": 6144
64
+ "size/router-app.js": 6144,
65
+ "size/api-app.js": 6656,
66
+ "size/forms-app.js": 6656
53
67
  }
54
68
  }
@@ -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 };