humn 1.4.0 → 1.5.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/dist/humn.js +265 -167
- package/dist/humn.js.map +1 -1
- package/dist/humn.umd.js +3 -3
- package/dist/humn.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/humn.js
CHANGED
|
@@ -1,219 +1,317 @@
|
|
|
1
|
-
let
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
},
|
|
5
|
-
|
|
1
|
+
let I = null, R = null;
|
|
2
|
+
const V = () => I, L = (t) => {
|
|
3
|
+
I = t;
|
|
4
|
+
}, J = () => R, O = (t) => {
|
|
5
|
+
R = t;
|
|
6
6
|
};
|
|
7
|
-
class
|
|
8
|
-
constructor({ memory: e, synapses:
|
|
9
|
-
const
|
|
7
|
+
class ee {
|
|
8
|
+
constructor({ memory: e, synapses: o }) {
|
|
9
|
+
const c = { ...e };
|
|
10
10
|
this._persistenceMap = /* @__PURE__ */ new Map();
|
|
11
|
-
for (const [
|
|
12
|
-
const
|
|
13
|
-
this._persistenceMap.set(
|
|
11
|
+
for (const [i, n] of Object.entries(e)) if (n && typeof n == "object" && n.__humn_persist) {
|
|
12
|
+
const s = n.config?.key || i;
|
|
13
|
+
this._persistenceMap.set(i, s);
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const r = localStorage.getItem(s);
|
|
16
|
+
c[i] = r !== null ? JSON.parse(r) : n.initial;
|
|
17
17
|
} catch {
|
|
18
|
-
|
|
18
|
+
c[i] = n.initial;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
this._memory =
|
|
22
|
-
let
|
|
23
|
-
if (typeof
|
|
24
|
-
const
|
|
25
|
-
l && typeof l == "object" ? (
|
|
26
|
-
} else
|
|
27
|
-
this._memory =
|
|
28
|
-
if (Array.from(
|
|
21
|
+
this._memory = c, this._listeners = /* @__PURE__ */ new Map(), this.synapses = o((i) => {
|
|
22
|
+
let n, s = /* @__PURE__ */ new Set();
|
|
23
|
+
if (typeof i == "function") {
|
|
24
|
+
const r = structuredClone(this._memory), l = i(this._createChangeTrackingProxy(r, s));
|
|
25
|
+
l && typeof l == "object" ? (n = { ...this._memory, ...l }, Object.keys(l).forEach((a) => s.add(a))) : n = r;
|
|
26
|
+
} else n = { ...this._memory, ...i }, s = new Set(Object.keys(i));
|
|
27
|
+
this._memory = n, this._persistenceMap.size > 0 && this._persistenceMap.forEach((r, l) => {
|
|
28
|
+
if (Array.from(s).some((a) => a === l || a.startsWith(l + "."))) try {
|
|
29
29
|
const a = this._memory[l];
|
|
30
|
-
localStorage.setItem(
|
|
30
|
+
localStorage.setItem(r, JSON.stringify(a));
|
|
31
31
|
} catch {
|
|
32
32
|
}
|
|
33
|
-
}), this._notifyRelevantListeners(
|
|
33
|
+
}), this._notifyRelevantListeners(s);
|
|
34
34
|
}, () => this._memory);
|
|
35
35
|
}
|
|
36
|
-
_createChangeTrackingProxy(e,
|
|
37
|
-
return new Proxy(e, { get: (
|
|
38
|
-
if (typeof
|
|
39
|
-
const
|
|
40
|
-
return typeof
|
|
41
|
-
}, set: (n, s
|
|
42
|
-
if (typeof
|
|
43
|
-
const
|
|
44
|
-
return
|
|
36
|
+
_createChangeTrackingProxy(e, o, c = "") {
|
|
37
|
+
return new Proxy(e, { get: (i, n) => {
|
|
38
|
+
if (typeof n == "symbol" || n === "__proto__") return i[n];
|
|
39
|
+
const s = i[n], r = c ? `${c}.${n}` : n;
|
|
40
|
+
return typeof s == "object" && s !== null ? this._createChangeTrackingProxy(s, o, r) : s;
|
|
41
|
+
}, set: (i, n, s) => {
|
|
42
|
+
if (typeof n == "symbol" || n === "__proto__") return i[n] = s, !0;
|
|
43
|
+
const r = c ? `${c}.${n}` : n;
|
|
44
|
+
return o.add(r), i[n] = s, !0;
|
|
45
45
|
} });
|
|
46
46
|
}
|
|
47
47
|
_notifyRelevantListeners(e) {
|
|
48
|
-
this._listeners.forEach((
|
|
49
|
-
Array.from(
|
|
48
|
+
this._listeners.forEach((o, c) => {
|
|
49
|
+
Array.from(o).some((i) => Array.from(e).some((n) => i === n || i.startsWith(n + ".") || n.startsWith(i + "."))) && c();
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
_createAccessTrackingProxy(e,
|
|
53
|
-
return typeof e != "object" || e === null ? e : new Proxy(e, { get: (
|
|
54
|
-
if (typeof
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
return typeof
|
|
52
|
+
_createAccessTrackingProxy(e, o, c = "") {
|
|
53
|
+
return typeof e != "object" || e === null ? e : new Proxy(e, { get: (i, n) => {
|
|
54
|
+
if (typeof n == "symbol" || n === "__proto__") return i[n];
|
|
55
|
+
const s = c ? `${c}.${n}` : n;
|
|
56
|
+
o.add(s);
|
|
57
|
+
const r = i[n];
|
|
58
|
+
return typeof r == "object" && r !== null ? this._createAccessTrackingProxy(r, o, s) : r;
|
|
59
59
|
} });
|
|
60
60
|
}
|
|
61
61
|
get memory() {
|
|
62
|
-
const e =
|
|
62
|
+
const e = V();
|
|
63
63
|
if (!e) return this._memory;
|
|
64
64
|
this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
|
|
65
|
-
const
|
|
66
|
-
return this._createAccessTrackingProxy(this._memory,
|
|
65
|
+
const o = this._listeners.get(e);
|
|
66
|
+
return this._createAccessTrackingProxy(this._memory, o);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
let
|
|
70
|
-
const
|
|
71
|
-
function
|
|
72
|
-
let
|
|
73
|
-
Array.isArray(t) && t.raw ?
|
|
74
|
-
let
|
|
75
|
-
return
|
|
76
|
-
})(
|
|
77
|
-
if (!
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
let l = 5381, a =
|
|
81
|
-
for (; a; ) l = 33 * l ^
|
|
69
|
+
let v = null;
|
|
70
|
+
const U = /* @__PURE__ */ new Set();
|
|
71
|
+
function te(t, ...e) {
|
|
72
|
+
let o = "", c = !1;
|
|
73
|
+
Array.isArray(t) && t.raw ? o = t.reduce((r, l, a) => r + l + (e[a] || ""), "") : (o = t, c = e[0] === !0);
|
|
74
|
+
let i = (function(r) {
|
|
75
|
+
return r.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").trim();
|
|
76
|
+
})(o);
|
|
77
|
+
if (!i) return "";
|
|
78
|
+
c && (i = i.replace(/(^|[{};,])(\s*)(?!from|to)((?:[.#]?[\w-]+|\[[^\]]+\]|:{1,2}[^:,{\s]+)+)(?=\s*\{)/gi, "$1$2$3&, $3"));
|
|
79
|
+
const n = (function(r) {
|
|
80
|
+
let l = 5381, a = r.length;
|
|
81
|
+
for (; a; ) l = 33 * l ^ r.charCodeAt(--a);
|
|
82
82
|
return (l >>> 0).toString(36);
|
|
83
|
-
})(
|
|
84
|
-
return
|
|
85
|
-
${
|
|
83
|
+
})(i), s = `humn-${n}`;
|
|
84
|
+
return U.has(n) || (v || (v = document.createElement("style"), v.id = "humn-styles", document.head.appendChild(v)), v.textContent += `.${s} {
|
|
85
|
+
${i}
|
|
86
86
|
}
|
|
87
|
-
`,
|
|
87
|
+
`, U.add(n)), s;
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
function
|
|
91
|
-
const e =
|
|
89
|
+
const ne = (t, e = {}, o = []) => ({ tag: t, props: e, children: (Array.isArray(o) ? o : [o]).flat().filter((c) => c != null && c !== !1 && c !== "") });
|
|
90
|
+
function oe(t) {
|
|
91
|
+
const e = J();
|
|
92
92
|
e && e.mounts.push(t);
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
const e =
|
|
94
|
+
function re(t) {
|
|
95
|
+
const e = J();
|
|
96
96
|
e && e.cleanups.push(t);
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
98
|
+
function j(t, e) {
|
|
99
|
+
try {
|
|
100
|
+
t();
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function z(t) {
|
|
105
|
+
const e = { mounts: [], cleanups: [] };
|
|
106
|
+
O(e);
|
|
107
|
+
const o = t.tag(t.props);
|
|
108
|
+
return O(null), t.hooks = e, o;
|
|
109
|
+
}
|
|
110
|
+
function N(t) {
|
|
111
|
+
t && (t.hooks?.cleanups && t.hooks.cleanups.forEach((e) => j(e)), t.child && N(t.child), t.children && t.children.forEach(N));
|
|
100
112
|
}
|
|
101
113
|
function E(t) {
|
|
102
|
-
|
|
114
|
+
t?.mounts?.length && setTimeout(() => t.mounts.forEach((e) => j(e)), 0);
|
|
103
115
|
}
|
|
104
|
-
const
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
116
|
+
const W = /* @__PURE__ */ new WeakMap();
|
|
117
|
+
function w(t) {
|
|
118
|
+
const e = W.get(t);
|
|
119
|
+
if (e) return e;
|
|
120
|
+
const o = { asyncPending: /* @__PURE__ */ new Map(), commitLocks: /* @__PURE__ */ new Map(), composition: /* @__PURE__ */ new Map(), debounceTimers: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Map() };
|
|
121
|
+
return W.set(t, o), o;
|
|
122
|
+
}
|
|
123
|
+
const q = /* @__PURE__ */ new Set(["prevent", "stop", "once", "capture", "passive"]);
|
|
124
|
+
function k({ element: t, eventName: e, listener: o, options: c = !1, propKey: i }) {
|
|
125
|
+
const { listeners: n } = w(t);
|
|
126
|
+
P(t, i), t.addEventListener(e, o, c), n.set(i, { eventName: e, listener: o, options: c });
|
|
127
|
+
}
|
|
128
|
+
function P(t, e) {
|
|
129
|
+
const { listeners: o } = w(t), c = o.get(e);
|
|
130
|
+
if (!c) return;
|
|
131
|
+
const { eventName: i, listener: n, options: s } = c;
|
|
132
|
+
t.removeEventListener(i, n, s), o.delete(e);
|
|
133
|
+
}
|
|
134
|
+
const G = /* @__PURE__ */ new Set(["onenter", "onescape", "onkeys", "oncommit"]), Q = ["__compositionstart", "__compositionend", "__keyhelper", "__oncommitblur"];
|
|
135
|
+
function D(t) {
|
|
136
|
+
const { debounceTimers: e } = w(t), o = e.get("oninputdebounced");
|
|
137
|
+
o && clearTimeout(o), e.delete("oninputdebounced"), P(t, "oninputdebounced");
|
|
138
|
+
}
|
|
139
|
+
function X(t, e) {
|
|
140
|
+
if (o = e, !(o.onenter || o.onescape || o.onkeys || o.oncommit)) return void (function(s) {
|
|
141
|
+
Q.forEach((r) => P(s, r));
|
|
142
|
+
})(t);
|
|
143
|
+
var o;
|
|
144
|
+
const c = w(t), i = (function({ element: s, newProps: r, runtime: l }) {
|
|
145
|
+
return (a) => {
|
|
146
|
+
if ((function(u, p) {
|
|
147
|
+
return u.isComposing || p === !0;
|
|
148
|
+
})(a, l.composition.get("active") === !0)) return;
|
|
149
|
+
const m = (function(u) {
|
|
150
|
+
const p = [];
|
|
151
|
+
return u.ctrlKey && p.push("ctrl"), u.metaKey && p.push("meta"), u.altKey && p.push("alt"), u.shiftKey && p.push("shift"), p.push(u.key.toLowerCase()), p.sort().join("+");
|
|
152
|
+
})(a);
|
|
153
|
+
a.key === "Enter" && r.onenter && r.onenter(a), a.key === "Escape" && r.onescape && r.onescape(a), r.onkeys && (function(u, p, d) {
|
|
154
|
+
Object.entries(d).forEach(([h, y]) => {
|
|
155
|
+
(function(_ = "") {
|
|
156
|
+
return _.split("+").map((f) => f.trim().toLowerCase()).filter(Boolean).map((f) => (function(g) {
|
|
157
|
+
return g !== "mod" ? g : navigator.platform.includes("Mac") ? "meta" : "ctrl";
|
|
158
|
+
})(f)).sort().join("+");
|
|
159
|
+
})(h) === p && y(u);
|
|
160
|
+
});
|
|
161
|
+
})(a, m, r.onkeys), a.key === "Enter" && r.oncommit && (l.commitLocks.set("enter", !0), r.oncommit(a), setTimeout(() => l.commitLocks.delete("enter"), 0));
|
|
162
|
+
};
|
|
163
|
+
})({ element: t, newProps: e, runtime: c }), n = (function({ newProps: s, runtime: r }) {
|
|
164
|
+
return (l) => {
|
|
165
|
+
s.oncommit && (r.commitLocks.get("enter") || s.oncommit(l));
|
|
166
|
+
};
|
|
167
|
+
})({ newProps: e, runtime: c });
|
|
168
|
+
k({ element: t, eventName: "compositionstart", listener: () => c.composition.set("active", !0), propKey: "__compositionstart" }), k({ element: t, eventName: "compositionend", listener: () => c.composition.set("active", !1), propKey: "__compositionend" }), k({ element: t, eventName: "keydown", listener: i, propKey: "__keyhelper" }), k({ element: t, eventName: "blur", listener: n, propKey: "__oncommitblur" });
|
|
169
|
+
}
|
|
170
|
+
function F(t, e = {}, o = {}) {
|
|
123
171
|
if (!t) return;
|
|
124
|
-
const
|
|
125
|
-
for (const
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
172
|
+
const c = { ...o, ...e };
|
|
173
|
+
for (const i in c) Y({ element: t, key: i, newProps: e, oldProps: o });
|
|
174
|
+
(function(i, n) {
|
|
175
|
+
if (!n.oninputdebounced) return void D(i);
|
|
176
|
+
const { debounceTimers: s } = w(i), r = Number(n.debounce), l = Number.isFinite(r) ? r : 250;
|
|
177
|
+
k({ element: i, eventName: "input", listener: (a) => {
|
|
178
|
+
const m = s.get("oninputdebounced");
|
|
179
|
+
m && clearTimeout(m);
|
|
180
|
+
const u = setTimeout(() => {
|
|
181
|
+
s.delete("oninputdebounced"), n.oninputdebounced({ ...a, currentTarget: i, target: i });
|
|
182
|
+
}, l);
|
|
183
|
+
s.set("oninputdebounced", u);
|
|
184
|
+
}, propKey: "oninputdebounced" });
|
|
185
|
+
})(t, e), X(t, e);
|
|
138
186
|
}
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
187
|
+
function Y({ element: t, key: e, newProps: o, oldProps: c }) {
|
|
188
|
+
const i = c[e], n = o[e];
|
|
189
|
+
n != null ? e !== "value" && e !== "checked" ? i === n && e !== "onclickasync" || (e.startsWith("on") ? (function({ element: s, handler: r, key: l, newProps: a }) {
|
|
190
|
+
const { eventKey: m, modifiers: u } = (function(d) {
|
|
191
|
+
const [h, ...y] = d.split("|");
|
|
192
|
+
return { eventKey: h, modifiers: y.filter((_) => q.has(_)) };
|
|
193
|
+
})(l), p = m.slice(2).toLowerCase();
|
|
194
|
+
if (!(function(d) {
|
|
195
|
+
return G.has(d);
|
|
196
|
+
})(m) && m !== "oninputdebounced") {
|
|
197
|
+
if (m === "onclickasync") return void (function({ element: d, handler: h, newProps: y, propKey: _ }) {
|
|
198
|
+
const { asyncPending: f } = w(d);
|
|
199
|
+
k({ element: d, eventName: "click", listener: async (g) => {
|
|
200
|
+
if (!y.disabledwhilepending || !f.get("click")) try {
|
|
201
|
+
f.set("click", !0), y.disabledwhilepending && (d.disabled = !0), await h(g);
|
|
202
|
+
} finally {
|
|
203
|
+
f.set("click", !1), y.disabledwhilepending && (d.disabled = !1);
|
|
204
|
+
}
|
|
205
|
+
}, propKey: _ });
|
|
206
|
+
})({ element: s, handler: r, newProps: a, propKey: l });
|
|
207
|
+
k({ element: s, eventName: p, listener: (d) => (u.includes("prevent") && d.preventDefault(), u.includes("stop") && d.stopPropagation(), r(d)), options: { capture: u.includes("capture"), once: u.includes("once"), passive: u.includes("passive") }, propKey: l });
|
|
208
|
+
}
|
|
209
|
+
})({ element: t, handler: n, key: e, newProps: o }) : e !== "debounce" && (e !== "disabled" ? t.setAttribute(e, n) : t.disabled = n === !0 || n === "true")) : (function({ element: s, key: r, value: l }) {
|
|
210
|
+
s[r] !== l && (s[r] = l);
|
|
211
|
+
})({ element: t, key: e, value: n }) : (function({ element: s, key: r }) {
|
|
212
|
+
r.startsWith("on") && P(s, r), r === "oninputdebounced" && D(s), s.removeAttribute(r);
|
|
213
|
+
})({ element: t, key: e });
|
|
214
|
+
}
|
|
215
|
+
const M = "http://www.w3.org/2000/svg", T = "http://www.w3.org/1998/Math/MathML";
|
|
216
|
+
function K(t) {
|
|
217
|
+
return t.namespaceURI === M && t.tagName !== "foreignObject" ? M : t.namespaceURI === T ? T : null;
|
|
218
|
+
}
|
|
219
|
+
function b(t, e) {
|
|
220
|
+
if (typeof t == "string" || typeof t == "number") return document.createTextNode(String(t));
|
|
221
|
+
if (typeof t.tag == "function") return (function(n, s) {
|
|
222
|
+
const r = z(n), l = b(r, s);
|
|
223
|
+
return n.child = r, n.el = l, E(n.hooks), l;
|
|
224
|
+
})(t, e);
|
|
225
|
+
const o = t.tag, c = /* @__PURE__ */ (function(n, s) {
|
|
226
|
+
return n === "svg" ? M : n === "math" ? T : s;
|
|
227
|
+
})(o, e), i = c ? document.createElementNS(c, o) : document.createElement(o);
|
|
228
|
+
return t.el = i, F(i, t.props), (function({ element: n, namespace: s, tag: r, vNode: l }) {
|
|
229
|
+
const a = r === "foreignObject" ? null : s;
|
|
230
|
+
l.children.forEach((m) => {
|
|
231
|
+
n.appendChild(b(m, a));
|
|
163
232
|
});
|
|
164
|
-
})(
|
|
233
|
+
})({ element: i, namespace: c, tag: o, vNode: t }), i;
|
|
165
234
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
235
|
+
function B(t) {
|
|
236
|
+
return t && t.some((e) => e?.props?.key != null);
|
|
237
|
+
}
|
|
238
|
+
function Z({ oldChildren: t, newChildren: e, parent: o, patchNode: c, runUnmount: i }) {
|
|
239
|
+
B(e) || B(t) ? (function({ oldChildren: n, newChildren: s, parent: r, patchNode: l, runUnmount: a }) {
|
|
240
|
+
const m = (function(u) {
|
|
241
|
+
const p = {};
|
|
242
|
+
return u.forEach((d, h) => {
|
|
243
|
+
const y = H(d, h);
|
|
244
|
+
p[y] = { index: h, vNode: d };
|
|
245
|
+
}), p;
|
|
246
|
+
})(n);
|
|
247
|
+
s.forEach((u, p) => {
|
|
248
|
+
const d = H(u, p), h = m[d];
|
|
249
|
+
if (h) return (function({ existingChild: y, index: _, newChild: f, parent: g, patchNode: C }) {
|
|
250
|
+
const A = y.vNode;
|
|
251
|
+
C(g, f, A, _);
|
|
252
|
+
const x = f.el || A.el, $ = g.childNodes[_];
|
|
253
|
+
x && $ !== x && g.insertBefore(x, $);
|
|
254
|
+
})({ existingChild: h, index: p, newChild: u, parent: r, patchNode: l }), void delete m[d];
|
|
255
|
+
(function({ index: y, newChild: _, parent: f }) {
|
|
256
|
+
const g = b(_, K(f)), C = f.childNodes[y];
|
|
257
|
+
if (C) return void f.insertBefore(g, C);
|
|
258
|
+
f.appendChild(g);
|
|
259
|
+
})({ index: p, newChild: u, parent: r });
|
|
260
|
+
}), (function({ keyedChildren: u, parent: p, runUnmount: d }) {
|
|
261
|
+
Object.values(u).forEach(({ vNode: h }) => {
|
|
262
|
+
h.el && h.el.parentNode === p && (d(h), p.removeChild(h.el));
|
|
263
|
+
});
|
|
264
|
+
})({ keyedChildren: m, parent: r, runUnmount: a });
|
|
265
|
+
})({ oldChildren: t, newChildren: e, parent: o, patchNode: c, runUnmount: i }) : (function({ oldChildren: n, newChildren: s, parent: r, patchNode: l }) {
|
|
266
|
+
const a = Math.max(s.length, n.length);
|
|
267
|
+
for (let m = 0; m < a; m++) l(r, s[m], n[m], m);
|
|
268
|
+
})({ oldChildren: t, newChildren: e, parent: o, patchNode: c });
|
|
171
269
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
270
|
+
function H(t, e) {
|
|
271
|
+
return t?.props?.key != null ? t.props.key : e;
|
|
174
272
|
}
|
|
175
|
-
function
|
|
273
|
+
function S(t, e, o, c = 0) {
|
|
176
274
|
if (e == null) {
|
|
177
|
-
const
|
|
178
|
-
return
|
|
275
|
+
const n = o.el || t.childNodes[c];
|
|
276
|
+
return N(o), void (n && t.removeChild(n));
|
|
179
277
|
}
|
|
180
278
|
if (typeof e.tag == "function") {
|
|
181
|
-
const
|
|
182
|
-
return e.child =
|
|
183
|
-
|
|
184
|
-
},
|
|
279
|
+
const n = !o, s = z(e);
|
|
280
|
+
return e.child = s, S(t, s, o ? o.child : void 0, c), e.el = s.el, n && E(e.hooks), void (n || (function({ newHooks: r, oldHooks: l }) {
|
|
281
|
+
l?.cleanups?.length && (l.cleanups.forEach((a) => j(a)), E(r));
|
|
282
|
+
})({ newHooks: e.hooks, oldHooks: o.hooks }));
|
|
185
283
|
}
|
|
186
|
-
if (
|
|
187
|
-
if (typeof e != typeof
|
|
188
|
-
const
|
|
189
|
-
return void (
|
|
284
|
+
if (o == null) return void t.appendChild(b(e, K(t)));
|
|
285
|
+
if (typeof e != typeof o || typeof e != "string" && e.tag !== o.tag) {
|
|
286
|
+
const n = o.el || t.childNodes[c];
|
|
287
|
+
return void (n && t.replaceChild(b(e, K(t)), n));
|
|
190
288
|
}
|
|
191
289
|
if (typeof e == "string" || typeof e == "number") {
|
|
192
|
-
if (e !==
|
|
193
|
-
const
|
|
194
|
-
|
|
290
|
+
if (e !== o) {
|
|
291
|
+
const n = t.childNodes[c];
|
|
292
|
+
n ? n.nodeValue = String(e) : t.appendChild(document.createTextNode(String(e)));
|
|
195
293
|
}
|
|
196
294
|
return;
|
|
197
295
|
}
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
const
|
|
202
|
-
let
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
296
|
+
const i = o.el || t.childNodes[c];
|
|
297
|
+
i && (e.el = i, F(i, e.props, o.props), Z({ oldChildren: o.children, newChildren: e.children, parent: i, patchNode: S, runUnmount: N }));
|
|
298
|
+
}
|
|
299
|
+
const ie = (t, e) => {
|
|
300
|
+
let o = null;
|
|
301
|
+
const c = () => {
|
|
302
|
+
L(c);
|
|
303
|
+
const i = { tag: e, props: {}, children: [] };
|
|
304
|
+
S(t, i, o), L(null), o = i;
|
|
207
305
|
};
|
|
208
|
-
|
|
209
|
-
},
|
|
306
|
+
c();
|
|
307
|
+
}, se = (t, e = {}) => ({ __humn_persist: !0, initial: t, config: e });
|
|
210
308
|
export {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
309
|
+
ee as Cortex,
|
|
310
|
+
te as css,
|
|
311
|
+
ne as h,
|
|
312
|
+
ie as mount,
|
|
313
|
+
re as onCleanup,
|
|
314
|
+
oe as onMount,
|
|
315
|
+
se as persist
|
|
218
316
|
};
|
|
219
317
|
//# sourceMappingURL=humn.js.map
|
package/dist/humn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"humn.js","sources":["../src/observer.js","../src/cortex.js","../src/css.js","../src/h.js","../src/lifecycle.js","../src/patch.js","../src/mount.js","../src/persist.js"],"sourcesContent":["/**\n * @file Observer module for tracking global state during rendering.\n * @module observer\n */\n\nlet currentObserver = null // For Cortex/State dependency\nlet currentInstance = null // For Lifecycle Hooks\n\n/**\n * Gets the current observer (render function).\n * @returns {function|null}\n */\nexport const getObserver = () => currentObserver\n\n/**\n * Sets the current observer.\n * @param {function|null} obs\n */\nexport const setObserver = (obs) => {\n currentObserver = obs\n}\n\n/**\n * Gets the current component instance (hook container).\n * @returns {object|null}\n */\nexport const getInstance = () => currentInstance\n\n/**\n * Sets the current component instance.\n * @param {object|null} inst\n */\nexport const setInstance = (inst) => {\n currentInstance = inst\n}\n","import { isDev } from './metrics.js'\nimport { getObserver } from './observer.js'\n\n/**\n * Mapped type for the Memory configuration object.\n * Allows each property to be the raw value OR a persisted wrapper.\n * @template T\n * @typedef { { [K in keyof T]: T[K] | import('./persist.js').Persisted<T[K]> } } MemoryInput\n */\n\n/**\n * Deeply unwraps persisted values from the memory shape.\n * @template {object} T\n * @typedef {{ [K in keyof T]: T[K] extends import('./persist.js').Persisted<infer I> ? I : T[K] }} UnwrappedMemory\n */\n\n/**\n * @template T\n * @callback Getter\n * @returns {T}\n */\n\n/**\n * @template T\n * @callback Setter\n * @param {Partial<T> | ((state: T) => void | Partial<T> | unknown)} updater\n * @returns {void}\n */\n\n/**\n * @template M, S\n * @callback SynapsesBuilder\n * @param {Setter<M>} set\n * @param {Getter<M>} get\n * @returns {S}\n */\n\n/**\n * @template M, S\n * @typedef {object} CortexConfig\n * @property {MemoryInput<M>} memory - The initial state configuration\n * @property {SynapsesBuilder<M, S>} synapses - The synapses builder function\n */\n\n/**\n * The Cortex class manages the state of the application.\n *\n * @template {object} MemoryType The shape of the application state\n * @template {object} SynapsesType The shape of the actions/methods\n */\nexport class Cortex {\n /**\n * Creates an instance of Cortex.\n * @param {CortexConfig<MemoryType, SynapsesType>} config\n */\n constructor({ memory, synapses }) {\n const liveMemory = { ...memory }\n this._persistenceMap = new Map()\n\n // Load in any existing values from local-storage\n for (const [key, value] of Object.entries(memory)) {\n if (value && typeof value === 'object' && value.__humn_persist) {\n const storageKey = value.config?.key || key\n this._persistenceMap.set(key, storageKey)\n\n try {\n const stored = localStorage.getItem(storageKey)\n if (stored !== null) {\n liveMemory[key] = JSON.parse(stored)\n } else {\n liveMemory[key] = value.initial\n }\n } catch (err) {\n if (isDev)\n console.warn(`Humn: Failed to load '${key}' from storage.`, err)\n liveMemory[key] = value.initial\n }\n }\n }\n\n /** @type {UnwrappedMemory<MemoryType>} */\n this._memory = liveMemory\n this._listeners = new Map()\n\n /** @type {Getter<UnwrappedMemory<MemoryType>>} */\n const get = () => this._memory\n\n /** @type {Setter<UnwrappedMemory<MemoryType>>} */\n const set = (updater) => {\n let nextState\n let changedPaths = new Set()\n\n if (typeof updater === 'function') {\n const clone = structuredClone(this._memory)\n const proxy = this._createChangeTrackingProxy(clone, changedPaths)\n const result = updater(proxy)\n\n if (result && typeof result === 'object') {\n nextState = { ...this._memory, ...result }\n Object.keys(result).forEach((key) => changedPaths.add(key))\n } else {\n nextState = clone\n }\n } else {\n nextState = { ...this._memory, ...updater }\n changedPaths = new Set(Object.keys(updater))\n }\n\n this._memory = nextState\n\n // Persistence logic\n if (this._persistenceMap.size > 0) {\n this._persistenceMap.forEach((storageKey, stateKey) => {\n const isDirty = Array.from(changedPaths).some(\n (path) => path === stateKey || path.startsWith(stateKey + '.'),\n )\n\n if (isDirty) {\n try {\n const value = this._memory[stateKey]\n localStorage.setItem(storageKey, JSON.stringify(value))\n } catch (err) {\n if (isDev)\n console.error(`Humn: Failed to save '${stateKey}'.`, err)\n }\n }\n })\n }\n\n this._notifyRelevantListeners(changedPaths)\n }\n\n /** @type {SynapsesType} */\n this.synapses = synapses(set, get)\n }\n\n /**\n * Creates a Proxy that tracks which properties are being mutated.\n * Includes a GET trap to recursively proxy nested objects for deep mutation tracking.\n *\n * WHY: We need to know exactly which paths were changed so we can notify ONLY\n * the components that care about those specific paths. If we just knew \"something changed\",\n * we'd have to re-render the whole app (like Redux) or rely on manual optimization.\n */\n _createChangeTrackingProxy(obj, changedPaths, path = '') {\n return new Proxy(obj, {\n get: (target, prop) => {\n if (typeof prop === 'symbol' || prop === '__proto__')\n return target[prop]\n\n const value = target[prop]\n const fullPath = path ? `${path}.${prop}` : prop\n\n // Recursively proxy nested objects so we can trap their sets too\n if (typeof value === 'object' && value !== null) {\n return this._createChangeTrackingProxy(value, changedPaths, fullPath)\n }\n return value\n },\n set: (target, prop, value) => {\n if (typeof prop === 'symbol' || prop === '__proto__') {\n target[prop] = value\n return true\n }\n\n const fullPath = path ? `${path}.${prop}` : prop\n changedPaths.add(fullPath)\n\n target[prop] = value\n return true\n },\n })\n }\n\n /**\n * Only notify listeners that read properties which changed\n */\n _notifyRelevantListeners(changedPaths) {\n this._listeners.forEach((accessedPaths, renderFn) => {\n const shouldNotify = Array.from(accessedPaths).some((accessedPath) => {\n return Array.from(changedPaths).some((changedPath) => {\n // Check for exact match or parent/child relationship\n return (\n accessedPath === changedPath ||\n accessedPath.startsWith(changedPath + '.') ||\n changedPath.startsWith(accessedPath + '.')\n )\n })\n })\n\n if (shouldNotify) renderFn()\n })\n }\n\n /**\n * Creates a Proxy that tracks which properties are accessed during render\n *\n * WHY: This is the other half of the magic. By tracking what a component READS\n * during its render, we build a precise dependency graph. If a component reads\n * `state.user.name`, it will only re-render when `state.user.name` changes,\n * not when `state.count` changes.\n */\n _createAccessTrackingProxy(obj, accessedPaths, path = '') {\n if (typeof obj !== 'object' || obj === null) return obj\n\n return new Proxy(obj, {\n get: (target, prop) => {\n // We don't care about prototype and symbol properties\n if (typeof prop === 'symbol' || prop === '__proto__')\n return target[prop]\n\n const fullPath = path ? `${path}.${prop}` : prop\n accessedPaths.add(fullPath)\n\n const value = target[prop]\n\n // Recursively wrap nested objects\n if (typeof value === 'object' && value !== null)\n return this._createAccessTrackingProxy(value, accessedPaths, fullPath)\n\n return value\n },\n })\n }\n\n /**\n * @returns {UnwrappedMemory<MemoryType>}\n */\n get memory() {\n const currentObserver = getObserver()\n\n if (!currentObserver) return this._memory\n\n if (!this._listeners.has(currentObserver))\n this._listeners.set(currentObserver, new Set())\n\n const accessedPaths = this._listeners.get(currentObserver)\n\n return this._createAccessTrackingProxy(this._memory, accessedPaths)\n }\n}\n","/**\n * @file Runtime Scoped CSS implementation using Native CSS Nesting.\n * @module css\n */\n\nlet styleSheet = null\nconst cache = new Set()\n\n/**\n * Simple DJB2 hashing function.\n */\nfunction hashString(str) {\n let hash = 5381\n let i = str.length\n while (i) {\n hash = (hash * 33) ^ str.charCodeAt(--i)\n }\n return (hash >>> 0).toString(36)\n}\n\n/**\n * Lightweight Runtime Minifier.\n * Removes comments and collapses whitespace.\n * We do not strip spaces around colons/brackets to ensure safety for calc().\n */\nfunction minify(css) {\n return css\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Remove comments\n .replace(/\\s+/g, ' ') // Collapse newlines/tabs to single space\n .trim() // Remove leading/trailing\n}\n\n/**\n * Scoped CSS Tag.\n * Wraps content in a unique class using Native CSS Nesting.\n * Supports two signatures:\n * 1. Tagged Template: css`...`\n * 2. Function: css(string, isSingleRoot)\n */\nexport function css(stringsOrStr, ...args) {\n let raw = ''\n let isSingleRoot = false\n\n // Detect usage of Tagged Template vs Function Call\n if (Array.isArray(stringsOrStr) && stringsOrStr.raw) {\n raw = stringsOrStr.reduce((acc, str, i) => {\n return acc + str + (args[i] || '')\n }, '')\n } else {\n raw = stringsOrStr\n // If called as function, the first arg is our boolean flag\n isSingleRoot = args[0] === true\n }\n let content = minify(raw)\n\n if (!content) return ''\n\n if (isSingleRoot) {\n // Transforms selectors to apply to BOTH the root (using &) AND descendants.\n // e.g. \"div\" -> \"div&, div\"\n\n // Regex Breakdown:\n // 1. (^|[{};,]) -> Hard Start (Line start, brace, semi, comma)\n // 2. (\\s*) -> Whitespace\n // 3. (?!from|to) -> Negative Lookahead: Ignore 'from'/'to' (keyframes)\n // 4. ( ... )+ -> Compound Selector:\n // (?:[.#]?[\\w-]+ ... ) -> Matches tags (div), classes (.class), ids (#id)\n // 5. (?=\\s*\\{) -> Lookahead: Must be followed by {\n\n content = content.replace(\n /(^|[{};,])(\\s*)(?!from|to)((?:[.#]?[\\w-]+|\\[[^\\]]+\\]|:{1,2}[^:,{\\s]+)+)(?=\\s*\\{)/gi,\n '$1$2$3&, $3',\n )\n }\n\n const hash = hashString(content)\n const hashedClassName = `humn-${hash}`\n\n if (cache.has(hash)) {\n return hashedClassName\n }\n\n if (!styleSheet) {\n styleSheet = document.createElement('style')\n styleSheet.id = 'humn-styles'\n document.head.appendChild(styleSheet)\n }\n\n styleSheet.textContent += `.${hashedClassName} { \n ${content} \n }\\n`\n cache.add(hash)\n\n return hashedClassName\n}\n","/**\n * @typedef {object} VNode\n * @property {string} tag\n * @property {object} props\n * @property {VNode[]} children\n */\n\n/**\n * Creates a virtual DOM node.\n * This is a hyperscript-like function.\n *\n * @param {string} tag - The tag name of the element.\n * @param {object} props - The properties of the element.\n * @param {VNode[]|VNode} children - The children of the element.\n * @returns {VNode} The virtual DOM node.\n */\nexport const h = (tag, props = {}, children = []) => {\n const childArray = Array.isArray(children) ? children : [children]\n\n // Filter out null/false so we don't have \"ghost\" nodes\n const cleanChildren = childArray\n .flat()\n .filter((c) => c !== null && c !== undefined && c !== false && c !== '')\n\n return {\n tag,\n props,\n children: cleanChildren,\n }\n}\n","/**\n * @file Lifecycle hooks for components.\n * @module lifecycle\n */\nimport { getInstance } from './observer.js'\n\n/**\n * Registers a callback to run after the component mounts.\n * @param {function} fn - The callback function.\n */\nexport function onMount(fn) {\n const instance = getInstance()\n if (instance) {\n instance.mounts.push(fn)\n }\n}\n\n/**\n * Registers a callback to run when the component unmounts.\n * @param {function} fn - The callback function.\n */\nexport function onCleanup(fn) {\n const instance = getInstance()\n if (instance) {\n instance.cleanups.push(fn)\n }\n}\n","/**\n * @file This file contains the diffing and patching algorithm for the virtual DOM,\n * including support for Keyed Diffing.\n * @module patch\n */\nimport { track } from './metrics.js'\nimport { setInstance } from './observer.js'\n\nfunction getNamespace(parent) {\n if (parent.namespaceURI === SVG_NS && parent.tagName !== 'foreignObject') {\n return SVG_NS\n }\n if (parent.namespaceURI === MATH_NS) {\n return MATH_NS\n }\n return null\n}\n\n/**\n * Checks if a list of children contains keys.\n * @param {Array<import(\"./h.js\").VNode>} children - The list of VNodes.\n * @returns {boolean} True if keys are present.\n */\nexport function hasKeys(children) {\n return children && children.some((c) => c && c.props && c.props.key != null)\n}\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\nconst MATH_NS = 'http://www.w3.org/1998/Math/MathML'\n/**\n * Creates a real DOM element from a virtual node.\n * @param {import(\"./h.js\").VNode | string | number} vNode\n * @param {string} [namespace] - The current namespace URI (if any).\n * @returns {Text | HTMLElement | SVGElement}\n */\nfunction createElement(vNode, namespace) {\n if (typeof vNode === 'string' || typeof vNode === 'number') {\n return document.createTextNode(String(vNode))\n }\n\n if (typeof vNode.tag === 'function') {\n const childVNode = renderComponent(vNode)\n vNode.child = childVNode\n\n const el = createElement(childVNode, namespace)\n\n vNode.el = el\n if (vNode.hooks?.mounts.length > 0) {\n setTimeout(() => vNode.hooks.mounts.forEach((fn) => fn()), 0)\n }\n return el\n }\n\n track('elementsCreated')\n\n const tag = vNode.tag\n\n // We prioritize specific tag declarations over the inherited namespace.\n if (tag === 'svg') namespace = SVG_NS\n else if (tag === 'math') namespace = MATH_NS\n // NOTE: If we are inside 'foreignObject', we must NOT use the SVG NS.\n // We handle this by resetting 'ns' in the recursion step below,\n // so 'ns' entering here is already null for the foreignObject's children.\n\n // createElementNS is slower than createElement, so only use it if we have a namespace.\n const element = namespace\n ? document.createElementNS(namespace, tag)\n : document.createElement(tag)\n\n vNode.el = element\n patchProps(element, vNode.props)\n\n // If we are currently at a 'foreignObject', children must exit the SVG namespace.\n const childNS = tag === 'foreignObject' ? null : namespace\n\n vNode.children.forEach((child) => {\n element.appendChild(createElement(child, childNS))\n })\n\n return element\n}\n\n/**\n * Updates the properties (attributes/events) of a DOM element.\n * @param {HTMLElement} element - The DOM element to update.\n * @param {object} [newProps={}] - The new properties.\n * @param {object} [oldProps={}] - The old properties.\n *\n * WHY: We check against the LIVE DOM value for inputs (value/checked) to prevent\n * the \"cursor jumping\" bug. If we just blindly set the attribute, the browser\n * might reset the cursor position to the end of the input.\n */\nfunction patchProps(element, newProps = {}, oldProps = {}) {\n if (!element) return\n\n const allProps = { ...oldProps, ...newProps }\n\n for (const key in allProps) {\n const oldValue = oldProps[key]\n const newValue = newProps[key]\n\n // Handle removed props\n if (newValue === undefined || newValue === null) {\n element.removeAttribute(key)\n track('patches')\n continue\n }\n\n // We check against the LIVE DOM value to prevent cursor jumping\n if (key === 'value' || key === 'checked') {\n if (element[key] !== newValue) {\n element[key] = newValue\n track('patches')\n }\n continue\n }\n\n // If prop hasn't changed, skip\n if (oldValue === newValue) continue\n\n track('patches')\n\n // Handle Events\n if (key.startsWith('on')) {\n const eventName = key.slice(2).toLowerCase()\n if (oldValue) element.removeEventListener(eventName, oldValue)\n element.addEventListener(eventName, newValue)\n }\n // Handle the disabled attribute\n if (key === 'disabled') {\n element.disabled = newValue === true || newValue === 'true'\n }\n // Handle standard attributes\n else {\n element.setAttribute(key, newValue)\n }\n }\n}\n\n/**\n * Reconciles the children of a node, handling both simple lists and keyed reordering.\n * @param {HTMLElement} parent - The parent DOM element.\n * @param {Array<import(\"./h.js\").VNode>} newChildren - The new list of children.\n * @param {Array<import(\"./h.js\").VNode>} oldChildren - The old list of children.\n *\n * WHY: This is the most complex part of the VDOM. We need to efficiently update\n * a list of items. Without keys, we just update index-by-index, which is fast\n * but causes issues if items are reordered (state gets mixed up).\n * With keys, we can track items as they move around, preserving their state\n * and minimizing DOM operations.\n */\nfunction reconcileChildren(parent, newChildren, oldChildren) {\n const isKeyed = hasKeys(newChildren) || hasKeys(oldChildren)\n\n // If no keys are used, use the fast index-based simple loop.\n // This is faster for static lists or simple text replacements.\n if (!isKeyed) {\n const maxLen = Math.max(newChildren.length, oldChildren.length)\n for (let i = 0; i < maxLen; i++) {\n patch(parent, newChildren[i], oldChildren[i], i)\n }\n return\n }\n\n reconcileKeyedChildren(parent, newChildren, oldChildren)\n}\n\n/**\n * Handles the complex logic of reconciling keyed children.\n *\n * WHY: When keys are present, we can't just iterate by index. We need to map\n * existing children by their key so we can find them even if they've moved.\n * This allows us to re-use DOM nodes (preserving focus/state) instead of\n * destroying and re-creating them.\n */\nfunction reconcileKeyedChildren(parent, newChildren, oldChildren) {\n // Map existing children by Key for O(1) lookup\n const keyed = {}\n oldChildren.forEach((child, i) => {\n const key = (child.props && child.props.key) != null ? child.props.key : i\n keyed[key] = { vNode: child, index: i }\n })\n\n newChildren.forEach((newChild, i) => {\n const key =\n (newChild.props && newChild.props.key) != null ? newChild.props.key : i\n const existingChildMatch = keyed[key]\n\n if (existingChildMatch) {\n // A. MATCH FOUND - The item existed before\n const oldVNode = existingChildMatch.vNode\n\n // Update the node's content recursively\n patch(parent, newChild, oldVNode, i)\n\n // If the DOM node isn't in the right spot, move it.\n // We use oldVNode.el because patch transfers the ref, but just to be safe:\n const element = newChild.el || oldVNode.el\n\n // Get the node currently at this index in the real DOM\n const domChildAtIndex = parent.childNodes[i]\n\n // If the element exists but is in the wrong place, move it\n if (element && domChildAtIndex !== element) {\n parent.insertBefore(element, domChildAtIndex)\n track('patches')\n }\n\n // Remove from map so we know it was re-used\n delete keyed[key]\n } else {\n // B. NO MATCH - This is a new item\n const newElement = createElement(newChild, getNamespace(parent))\n const domChildAtIndex = parent.childNodes[i]\n\n if (domChildAtIndex) {\n parent.insertBefore(newElement, domChildAtIndex)\n } else {\n parent.appendChild(newElement)\n }\n }\n })\n\n // Remove any old keys that weren't used in the new list\n Object.values(keyed).forEach(({ vNode }) => {\n if (vNode.el && vNode.el.parentNode === parent) {\n runUnmount(vNode) // Clean up hooks\n parent.removeChild(vNode.el)\n track('elementsRemoved')\n }\n })\n}\n\n/**\n * Executes a Functional Component, tracks hooks, and returns the VNode.\n * @param {import(\"./h.js\").VNode} vNode - The component vNode.\n * @returns {import(\"./h.js\").VNode} The rendered child vNode.\n */\nfunction renderComponent(vNode) {\n track('componentsRendered')\n\n // 1. Prepare Hook Container\n const hooks = {\n mounts: [],\n cleanups: [],\n }\n\n // 2. Set Global Scope\n setInstance(hooks)\n\n // 3. Run the User's Component Function\n // We pass props as the first argument\n const renderedVNode = vNode.tag(vNode.props)\n\n // 4. Clear Global Scope\n setInstance(null)\n\n // 5. Attach hooks to the VNode so we can run them later\n vNode.hooks = hooks\n\n return renderedVNode\n}\n\n/**\n * Helper to recursively run cleanup hooks when a tree is removed.\n * @param {import(\"./h.js\").VNode} vNode - The vNode to unmount.\n */\nfunction runUnmount(vNode) {\n if (!vNode) return\n\n // 1. Run hooks for this node\n if (vNode.hooks && vNode.hooks.cleanups) {\n vNode.hooks.cleanups.forEach((fn) => fn())\n }\n\n // 2. Recurse into child (if component)\n if (vNode.child) {\n runUnmount(vNode.child)\n }\n\n // 3. Recurse into children (if element)\n if (vNode.children) {\n vNode.children.forEach(runUnmount)\n }\n}\n\n/**\n * The main diffing function. Compares V-DOM trees and updates the real DOM.\n * @param {HTMLElement} parent - The parent DOM element.\n * @param {import(\"./h.js\").VNode | string | number} newVNode - The new virtual node.\n * @param {import(\"./h.js\").VNode | string | number} oldVNode - The old virtual node.\n * @param {number} [index=0] - The index of the child node (used for simple diffing).\n */\nexport function patch(parent, newVNode, oldVNode, index = 0) {\n track('diffs')\n\n // Case 1: Removal - The new node is null/undefined, so we remove the old one.\n if (newVNode === undefined || newVNode === null) {\n const el = oldVNode.el || parent.childNodes[index]\n\n // Recursive Cleanup\n runUnmount(oldVNode)\n\n if (el) {\n parent.removeChild(el)\n track('elementsRemoved')\n }\n return\n }\n\n // Case 2: Component - If it's a function, we delegate to the component logic.\n if (typeof newVNode.tag === 'function') {\n const isNew = !oldVNode\n\n const childVNode = renderComponent(newVNode)\n newVNode.child = childVNode\n\n const oldChild = oldVNode ? oldVNode.child : undefined\n patch(parent, childVNode, oldChild, index)\n\n newVNode.el = childVNode.el\n\n // Run mount hooks on the next tick\n if (isNew && newVNode.hooks && newVNode.hooks.mounts.length > 0) {\n setTimeout(() => {\n newVNode.hooks.mounts.forEach((fn) => fn())\n }, 0)\n }\n // TODO: Handle updates (running old cleanups if necessary) for Phase 2\n return\n }\n\n // Case 3: Creation - No old node exists, so we create a new one.\n if (oldVNode === undefined || oldVNode === null) {\n parent.appendChild(createElement(newVNode, getNamespace(parent)))\n return\n }\n\n // Case 4: Replacement - The node type changed (e.g. div -> span), so we replace it entirely.\n if (\n typeof newVNode !== typeof oldVNode ||\n (typeof newVNode !== 'string' && newVNode.tag !== oldVNode.tag)\n ) {\n const el = oldVNode.el || parent.childNodes[index]\n if (el) {\n parent.replaceChild(createElement(newVNode, getNamespace(parent)), el)\n track('patches')\n }\n return\n }\n\n // Case 5: Text Update - It's a text node, so we just update the text content.\n if (typeof newVNode === 'string' || typeof newVNode === 'number') {\n if (newVNode !== oldVNode) {\n const el = parent.childNodes[index]\n if (el) {\n el.nodeValue = String(newVNode)\n track('patches')\n } else {\n // Self healing: if text node missing, append it\n parent.appendChild(document.createTextNode(String(newVNode)))\n }\n }\n return\n }\n\n // Case 6: Update - Same tag, so we update props and recurse into children.\n const el = oldVNode.el || parent.childNodes[index]\n\n if (!el) return\n\n // Transfer DOM reference to the new VNode\n newVNode.el = el\n\n patchProps(el, newVNode.props, oldVNode.props)\n\n reconcileChildren(el, newVNode.children, oldVNode.children)\n}\n","/**\n * @file Mounts the application to the DOM.\n * @module mount\n */\nimport { setObserver } from './observer.js'\nimport { patch } from './patch.js'\n\n/**\n * Mounts a component to a target DOM element.\n * @param {HTMLElement} target - The DOM element to mount to.\n * @param {function} Component - The root component function.\n */\nexport const mount = (target, Component) => {\n let prevVNode = null\n\n const lifecycle = () => {\n setObserver(lifecycle)\n\n const nextVNode = {\n tag: Component,\n props: {},\n children: [],\n }\n\n patch(target, nextVNode, prevVNode)\n setObserver(null)\n prevVNode = nextVNode\n }\n\n lifecycle()\n}\n","/**\n * Represents a value wrapped by the persist() function.\n * @template T\n * @typedef {object} Persisted\n * @property {T} initial\n * @property {boolean} __humn_persist\n * @property {PersistConfig} [config]\n */\n\n/**\n * @typedef {object} PersistConfig\n * @property {string} key\n */\n\n/**\n * Marks a section of the state for persistence in localStorage.\n * @template T\n * @param {T} initial\n * @param {PersistConfig} [config]\n * @returns {Persisted<T>}\n */\nexport const persist = (initial, config = {}) => ({\n __humn_persist: true,\n initial,\n config,\n})\n"],"names":["currentObserver","currentInstance","getObserver","setObserver","obs","getInstance","setInstance","inst","Cortex","memory","synapses","liveMemory","this","_persistenceMap","Map","key","value","Object","entries","__humn_persist","storageKey","config","set","stored","localStorage","getItem","JSON","parse","initial","err","_memory","_listeners","updater","nextState","changedPaths","Set","clone","structuredClone","result","_createChangeTrackingProxy","keys","forEach","add","size","stateKey","Array","from","some","path","startsWith","setItem","stringify","_notifyRelevantListeners","obj","Proxy","get","target","prop","fullPath","accessedPaths","renderFn","accessedPath","changedPath","_createAccessTrackingProxy","has","styleSheet","cache","css","stringsOrStr","args","raw","isSingleRoot","isArray","reduce","acc","str","i","content","replace","trim","hash","length","charCodeAt","toString","hashedClassName","document","createElement","id","head","appendChild","textContent","h","tag","props","children","flat","filter","c","onMount","fn","instance","mounts","push","onCleanup","cleanups","getNamespace","parent","namespaceURI","SVG_NS","tagName","MATH_NS","hasKeys","vNode","namespace","createTextNode","String","childVNode","renderComponent","child","el","hooks","setTimeout","element","createElementNS","patchProps","childNS","newProps","oldProps","allProps","oldValue","newValue","eventName","slice","toLowerCase","removeEventListener","addEventListener","disabled","setAttribute","removeAttribute","reconcileChildren","newChildren","oldChildren","maxLen","Math","max","patch","keyed","index","newChild","existingChildMatch","oldVNode","domChildAtIndex","childNodes","insertBefore","newElement","values","parentNode","runUnmount","removeChild","renderedVNode","newVNode","isNew","replaceChild","nodeValue","mount","Component","prevVNode","lifecycle","nextVNode","persist"],"mappings":"AAKA,IAAIA,IAAkB,MAClBC,IAAkB;AAMf,MAAMC,IAAc,MAAMF,GAMpBG,IAAeC,OAAAA;AAC1BJ,EAAAA,IAAkBI;AAAAA,GAOPC,IAAc,MAAMJ,GAMpBK,IAAeC,CAAAA,MAAAA;AAC1BN,EAAAA,IAAkBM;AAAAA;ACiBb,MAAMC,EAAAA;AAAAA,EAKX,cAAYC,QAAEA,GAAMC,UAAEA,EAAAA,GAAAA;AACpB,UAAMC,IAAa,EAAA,GAAKF,EAAAA;AACxBG,SAAKC,kBAAkB,oBAAIC;AAG3B,eAAK,CAAOC,GAAKC,CAAAA,KAAUC,OAAOC,QAAQT,GACxC,KAAIO,KAA0B,OAAVA,KAAU,YAA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AA,IACFA,EAAG4C,YAAYhD,OAAO6C,KAItBtD,EAAOjB,YAAYJ,SAAS6B,eAAeC,OAAO6C,CAAAA,CAAAA,CAAAA;AAAAA,IAEtD;AACA;AAAA,EACF;AAGA,QAAMzC,IAAK+B,EAAS/B,MAAMb,EAAO8C,WAAWL,CAAAA;AAEvC5B,EAAAA,MAGLyC,EAASzC,KAAKA,GAEdK,EAAWL,GAAIyC,EAASnE,OAAOyD,EAASzD,KAAAA,GAExC8C,EAAkBpB,GAAIyC,EAASlE,UAAUwD,EAASxD,QAAAA;AACpD;AC7WY,MAACsE,IAAQ,CAAC5G,GAAQ6G;AAC5B,MAAIC,IAAY;AAEhB,QAAMC,IAAY,MAAA;AAChBpK,IAAAA,EAAYoK,CAAAA;AAEZ,UAAMC,IAAY,EAChB5E,KAAKyE,GACLxE,OAAO,CAAA,GACPC,UAAU,CAAA,EAAA;AAGZmD,IAAAA,EAAMzF,GAAQgH,GAAWF,CAAAA,GACzBnK,EAAY,OACZmK,IAAYE;AAAAA,EAAAA;AAGdD,EAAAA,EAAAA;AAAAA,GCRWE,IAAU,CAAC7I,GAASP,IAAS,QAAE,EAC1CF,gBAAAA,IACAS,SAAAA,GACAP;"}
|
|
1
|
+
{"version":3,"file":"humn.js","sources":["../src/observer.js","../src/cortex.js","../src/css.js","../src/h.js","../src/lifecycle.js","../src/runtime/component-lifecycle.js","../src/runtime/element-runtime.js","../src/runtime/event-listeners.js","../src/runtime/interaction-helpers.js","../src/runtime/patch-props.js","../src/runtime/create-element.js","../src/runtime/reconcile-children.js","../src/runtime/patch.js","../src/mount.js","../src/persist.js"],"sourcesContent":["/**\n * @file Observer module for tracking global state during rendering.\n * @module observer\n */\n\nlet currentObserver = null // For Cortex/State dependency\nlet currentInstance = null // For Lifecycle Hooks\n\n/**\n * Gets the current observer (render function).\n * @returns {function|null}\n */\nexport const getObserver = () => currentObserver\n\n/**\n * Sets the current observer.\n * @param {function|null} obs\n */\nexport const setObserver = (obs) => {\n currentObserver = obs\n}\n\n/**\n * Gets the current component instance (hook container).\n * @returns {object|null}\n */\nexport const getInstance = () => currentInstance\n\n/**\n * Sets the current component instance.\n * @param {object|null} inst\n */\nexport const setInstance = (inst) => {\n currentInstance = inst\n}\n","import { isDev } from './metrics.js'\nimport { getObserver } from './observer.js'\n\n/**\n * Mapped type for the Memory configuration object.\n * Allows each property to be the raw value OR a persisted wrapper.\n * @template T\n * @typedef { { [K in keyof T]: T[K] | import('./persist.js').Persisted<T[K]> } } MemoryInput\n */\n\n/**\n * Deeply unwraps persisted values from the memory shape.\n * @template {object} T\n * @typedef {{ [K in keyof T]: T[K] extends import('./persist.js').Persisted<infer I> ? I : T[K] }} UnwrappedMemory\n */\n\n/**\n * @template T\n * @callback Getter\n * @returns {T}\n */\n\n/**\n * @template T\n * @callback Setter\n * @param {Partial<T> | ((state: T) => void | Partial<T> | unknown)} updater\n * @returns {void}\n */\n\n/**\n * @template M, S\n * @callback SynapsesBuilder\n * @param {Setter<M>} set\n * @param {Getter<M>} get\n * @returns {S}\n */\n\n/**\n * @template M, S\n * @typedef {object} CortexConfig\n * @property {MemoryInput<M>} memory - The initial state configuration\n * @property {SynapsesBuilder<M, S>} synapses - The synapses builder function\n */\n\n/**\n * The Cortex class manages the state of the application.\n *\n * @template {object} MemoryType The shape of the application state\n * @template {object} SynapsesType The shape of the actions/methods\n */\nexport class Cortex {\n /**\n * Creates an instance of Cortex.\n * @param {CortexConfig<MemoryType, SynapsesType>} config\n */\n constructor({ memory, synapses }) {\n const liveMemory = { ...memory }\n this._persistenceMap = new Map()\n\n // Load in any existing values from local-storage\n for (const [key, value] of Object.entries(memory)) {\n if (value && typeof value === 'object' && value.__humn_persist) {\n const storageKey = value.config?.key || key\n this._persistenceMap.set(key, storageKey)\n\n try {\n const stored = localStorage.getItem(storageKey)\n if (stored !== null) {\n liveMemory[key] = JSON.parse(stored)\n } else {\n liveMemory[key] = value.initial\n }\n } catch (err) {\n if (isDev)\n console.warn(`Humn: Failed to load '${key}' from storage.`, err)\n liveMemory[key] = value.initial\n }\n }\n }\n\n /** @type {UnwrappedMemory<MemoryType>} */\n this._memory = liveMemory\n this._listeners = new Map()\n\n /** @type {Getter<UnwrappedMemory<MemoryType>>} */\n const get = () => this._memory\n\n /** @type {Setter<UnwrappedMemory<MemoryType>>} */\n const set = (updater) => {\n let nextState\n let changedPaths = new Set()\n\n if (typeof updater === 'function') {\n const clone = structuredClone(this._memory)\n const proxy = this._createChangeTrackingProxy(clone, changedPaths)\n const result = updater(proxy)\n\n if (result && typeof result === 'object') {\n nextState = { ...this._memory, ...result }\n Object.keys(result).forEach((key) => changedPaths.add(key))\n } else {\n nextState = clone\n }\n } else {\n nextState = { ...this._memory, ...updater }\n changedPaths = new Set(Object.keys(updater))\n }\n\n this._memory = nextState\n\n // Persistence logic\n if (this._persistenceMap.size > 0) {\n this._persistenceMap.forEach((storageKey, stateKey) => {\n const isDirty = Array.from(changedPaths).some(\n (path) => path === stateKey || path.startsWith(stateKey + '.'),\n )\n\n if (isDirty) {\n try {\n const value = this._memory[stateKey]\n localStorage.setItem(storageKey, JSON.stringify(value))\n } catch (err) {\n if (isDev)\n console.error(`Humn: Failed to save '${stateKey}'.`, err)\n }\n }\n })\n }\n\n this._notifyRelevantListeners(changedPaths)\n }\n\n /** @type {SynapsesType} */\n this.synapses = synapses(set, get)\n }\n\n /**\n * Creates a Proxy that tracks which properties are being mutated.\n * Includes a GET trap to recursively proxy nested objects for deep mutation tracking.\n *\n * WHY: We need to know exactly which paths were changed so we can notify ONLY\n * the components that care about those specific paths. If we just knew \"something changed\",\n * we'd have to re-render the whole app (like Redux) or rely on manual optimization.\n */\n _createChangeTrackingProxy(obj, changedPaths, path = '') {\n return new Proxy(obj, {\n get: (target, prop) => {\n if (typeof prop === 'symbol' || prop === '__proto__')\n return target[prop]\n\n const value = target[prop]\n const fullPath = path ? `${path}.${prop}` : prop\n\n // Recursively proxy nested objects so we can trap their sets too\n if (typeof value === 'object' && value !== null) {\n return this._createChangeTrackingProxy(value, changedPaths, fullPath)\n }\n return value\n },\n set: (target, prop, value) => {\n if (typeof prop === 'symbol' || prop === '__proto__') {\n target[prop] = value\n return true\n }\n\n const fullPath = path ? `${path}.${prop}` : prop\n changedPaths.add(fullPath)\n\n target[prop] = value\n return true\n },\n })\n }\n\n /**\n * Only notify listeners that read properties which changed\n */\n _notifyRelevantListeners(changedPaths) {\n this._listeners.forEach((accessedPaths, renderFn) => {\n const shouldNotify = Array.from(accessedPaths).some((accessedPath) => {\n return Array.from(changedPaths).some((changedPath) => {\n // Check for exact match or parent/child relationship\n return (\n accessedPath === changedPath ||\n accessedPath.startsWith(changedPath + '.') ||\n changedPath.startsWith(accessedPath + '.')\n )\n })\n })\n\n if (shouldNotify) renderFn()\n })\n }\n\n /**\n * Creates a Proxy that tracks which properties are accessed during render\n *\n * WHY: This is the other half of the magic. By tracking what a component READS\n * during its render, we build a precise dependency graph. If a component reads\n * `state.user.name`, it will only re-render when `state.user.name` changes,\n * not when `state.count` changes.\n */\n _createAccessTrackingProxy(obj, accessedPaths, path = '') {\n if (typeof obj !== 'object' || obj === null) return obj\n\n return new Proxy(obj, {\n get: (target, prop) => {\n // We don't care about prototype and symbol properties\n if (typeof prop === 'symbol' || prop === '__proto__')\n return target[prop]\n\n const fullPath = path ? `${path}.${prop}` : prop\n accessedPaths.add(fullPath)\n\n const value = target[prop]\n\n // Recursively wrap nested objects\n if (typeof value === 'object' && value !== null)\n return this._createAccessTrackingProxy(value, accessedPaths, fullPath)\n\n return value\n },\n })\n }\n\n /**\n * @returns {UnwrappedMemory<MemoryType>}\n */\n get memory() {\n const currentObserver = getObserver()\n\n if (!currentObserver) return this._memory\n\n if (!this._listeners.has(currentObserver))\n this._listeners.set(currentObserver, new Set())\n\n const accessedPaths = this._listeners.get(currentObserver)\n\n return this._createAccessTrackingProxy(this._memory, accessedPaths)\n }\n}\n","/**\n * @file Runtime Scoped CSS implementation using Native CSS Nesting.\n * @module css\n */\n\nlet styleSheet = null\nconst cache = new Set()\n\n/**\n * Simple DJB2 hashing function.\n */\nfunction hashString(str) {\n let hash = 5381\n let i = str.length\n while (i) {\n hash = (hash * 33) ^ str.charCodeAt(--i)\n }\n return (hash >>> 0).toString(36)\n}\n\n/**\n * Lightweight Runtime Minifier.\n * Removes comments and collapses whitespace.\n * We do not strip spaces around colons/brackets to ensure safety for calc().\n */\nfunction minify(css) {\n return css\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Remove comments\n .replace(/\\s+/g, ' ') // Collapse newlines/tabs to single space\n .trim() // Remove leading/trailing\n}\n\n/**\n * Scoped CSS Tag.\n * Wraps content in a unique class using Native CSS Nesting.\n * Supports two signatures:\n * 1. Tagged Template: css`...`\n * 2. Function: css(string, isSingleRoot)\n */\nexport function css(stringsOrStr, ...args) {\n let raw = ''\n let isSingleRoot = false\n\n // Detect usage of Tagged Template vs Function Call\n if (Array.isArray(stringsOrStr) && stringsOrStr.raw) {\n raw = stringsOrStr.reduce((acc, str, i) => {\n return acc + str + (args[i] || '')\n }, '')\n } else {\n raw = stringsOrStr\n // If called as function, the first arg is our boolean flag\n isSingleRoot = args[0] === true\n }\n let content = minify(raw)\n\n if (!content) return ''\n\n if (isSingleRoot) {\n // Transforms selectors to apply to BOTH the root (using &) AND descendants.\n // e.g. \"div\" -> \"div&, div\"\n\n // Regex Breakdown:\n // 1. (^|[{};,]) -> Hard Start (Line start, brace, semi, comma)\n // 2. (\\s*) -> Whitespace\n // 3. (?!from|to) -> Negative Lookahead: Ignore 'from'/'to' (keyframes)\n // 4. ( ... )+ -> Compound Selector:\n // (?:[.#]?[\\w-]+ ... ) -> Matches tags (div), classes (.class), ids (#id)\n // 5. (?=\\s*\\{) -> Lookahead: Must be followed by {\n\n content = content.replace(\n /(^|[{};,])(\\s*)(?!from|to)((?:[.#]?[\\w-]+|\\[[^\\]]+\\]|:{1,2}[^:,{\\s]+)+)(?=\\s*\\{)/gi,\n '$1$2$3&, $3',\n )\n }\n\n const hash = hashString(content)\n const hashedClassName = `humn-${hash}`\n\n if (cache.has(hash)) {\n return hashedClassName\n }\n\n if (!styleSheet) {\n styleSheet = document.createElement('style')\n styleSheet.id = 'humn-styles'\n document.head.appendChild(styleSheet)\n }\n\n styleSheet.textContent += `.${hashedClassName} { \n ${content} \n }\\n`\n cache.add(hash)\n\n return hashedClassName\n}\n","/**\n * @typedef {object} VNode\n * @property {string} tag\n * @property {object} props\n * @property {VNode[]} children\n */\n\n/**\n * Creates a virtual DOM node.\n * This is a hyperscript-like function.\n *\n * @param {string} tag - The tag name of the element.\n * @param {object} props - The properties of the element.\n * @param {VNode[]|VNode} children - The children of the element.\n * @returns {VNode} The virtual DOM node.\n */\nexport const h = (tag, props = {}, children = []) => {\n const childArray = Array.isArray(children) ? children : [children]\n\n // Filter out null/false so we don't have \"ghost\" nodes\n const cleanChildren = childArray\n .flat()\n .filter((c) => c !== null && c !== undefined && c !== false && c !== '')\n\n return {\n tag,\n props,\n children: cleanChildren,\n }\n}\n","/**\n * @file Lifecycle hooks for components.\n * @module lifecycle\n */\nimport { getInstance } from './observer.js'\n\n/**\n * Registers a callback to run after the component mounts.\n * @param {function} fn - The callback function.\n */\nexport function onMount(fn) {\n const instance = getInstance()\n if (instance) {\n instance.mounts.push(fn)\n }\n}\n\n/**\n * Registers a callback to run when the component unmounts.\n * @param {function} fn - The callback function.\n */\nexport function onCleanup(fn) {\n const instance = getInstance()\n if (instance) {\n instance.cleanups.push(fn)\n }\n}\n","import { track } from '../metrics.js'\nimport { setInstance } from '../observer.js'\n\nexport function invokeHookSafely(fn, errorMessage) {\n try {\n fn()\n } catch (error) {\n console.error(errorMessage, error)\n }\n}\n\nexport function renderComponent(vNode) {\n track('componentsRendered')\n const hooks = { mounts: [], cleanups: [] }\n setInstance(hooks)\n\n const renderedVNode = vNode.tag(vNode.props)\n\n setInstance(null)\n vNode.hooks = hooks\n return renderedVNode\n}\n\nexport function runUnmount(vNode) {\n if (!vNode) return\n\n if (vNode.hooks?.cleanups)\n vNode.hooks.cleanups.forEach((fn) =>\n invokeHookSafely(fn, 'Error in cleanup hook:'),\n )\n if (vNode.child) runUnmount(vNode.child)\n if (vNode.children) vNode.children.forEach(runUnmount)\n}\n\nexport function scheduleMountHooks(hooks) {\n if (!hooks?.mounts?.length) return\n\n setTimeout(\n () =>\n hooks.mounts.forEach((fn) =>\n invokeHookSafely(fn, 'Error in mount hook:'),\n ),\n 0,\n )\n}\n\nexport function runComponentUpdateHooks({ newHooks, oldHooks }) {\n if (!oldHooks?.cleanups?.length) return\n\n oldHooks.cleanups.forEach((fn) =>\n invokeHookSafely(fn, 'Error in cleanup hook:'),\n )\n scheduleMountHooks(newHooks)\n}\n","const elementRuntime = new WeakMap()\n\nexport function getElementRuntime(element) {\n const existing = elementRuntime.get(element)\n if (existing) return existing\n\n const runtime = {\n asyncPending: new Map(),\n commitLocks: new Map(),\n composition: new Map(),\n debounceTimers: new Map(),\n listeners: new Map(),\n }\n\n elementRuntime.set(element, runtime)\n return runtime\n}\n","import { getElementRuntime } from './element-runtime.js'\n\nconst MODIFIER_FLAGS = new Set([\n 'prevent',\n 'stop',\n 'once',\n 'capture',\n 'passive',\n])\n\nexport function parseEventKey(key) {\n const [eventKey, ...modifierParts] = key.split('|')\n const modifiers = modifierParts.filter((modifier) =>\n MODIFIER_FLAGS.has(modifier),\n )\n\n return { eventKey, modifiers }\n}\n\nexport function addManagedListener({\n element,\n eventName,\n listener,\n options = false,\n propKey,\n}) {\n const { listeners } = getElementRuntime(element)\n\n removeManagedListener(element, propKey)\n element.addEventListener(eventName, listener, options)\n listeners.set(propKey, { eventName, listener, options })\n}\n\nexport function removeManagedListener(element, propKey) {\n const { listeners } = getElementRuntime(element)\n const previous = listeners.get(propKey)\n if (!previous) return\n\n const { eventName, listener, options } = previous\n element.removeEventListener(eventName, listener, options)\n listeners.delete(propKey)\n}\n","import { getElementRuntime } from './element-runtime.js'\nimport { addManagedListener, removeManagedListener } from './event-listeners.js'\n\nconst HELPER_EVENTS = new Set(['onenter', 'onescape', 'onkeys', 'oncommit'])\nconst INTERACTION_LISTENER_KEYS = [\n '__compositionstart',\n '__compositionend',\n '__keyhelper',\n '__oncommitblur',\n]\n\nexport function isInteractionHelperProp(eventKey) {\n return HELPER_EVENTS.has(eventKey)\n}\n\nexport function clearDebouncedInput(element) {\n const { debounceTimers } = getElementRuntime(element)\n const timer = debounceTimers.get('oninputdebounced')\n if (timer) clearTimeout(timer)\n\n debounceTimers.delete('oninputdebounced')\n removeManagedListener(element, 'oninputdebounced')\n}\n\nexport function patchDebouncedInput(element, newProps) {\n if (!newProps.oninputdebounced) {\n clearDebouncedInput(element)\n return\n }\n\n const { debounceTimers } = getElementRuntime(element)\n const debounceMs = Number(newProps.debounce)\n const delay = Number.isFinite(debounceMs) ? debounceMs : 250\n\n const debouncedHandler = (event) => {\n const previous = debounceTimers.get('oninputdebounced')\n if (previous) clearTimeout(previous)\n\n const timer = setTimeout(() => {\n debounceTimers.delete('oninputdebounced')\n newProps.oninputdebounced({\n ...event,\n currentTarget: element,\n target: element,\n })\n }, delay)\n\n debounceTimers.set('oninputdebounced', timer)\n }\n\n addManagedListener({\n element,\n eventName: 'input',\n listener: debouncedHandler,\n propKey: 'oninputdebounced',\n })\n}\n\nexport function patchInteractionHelpers(element, newProps) {\n if (!hasInteractionHelpers(newProps)) {\n removeInteractionHelpers(element)\n return\n }\n\n const runtime = getElementRuntime(element)\n const keyHandler = getKeyHandler({ element, newProps, runtime })\n const blurHandler = getBlurHandler({ newProps, runtime })\n const startComposition = () => runtime.composition.set('active', true)\n const endComposition = () => runtime.composition.set('active', false)\n\n addManagedListener({\n element,\n eventName: 'compositionstart',\n listener: startComposition,\n propKey: '__compositionstart',\n })\n addManagedListener({\n element,\n eventName: 'compositionend',\n listener: endComposition,\n propKey: '__compositionend',\n })\n addManagedListener({\n element,\n eventName: 'keydown',\n listener: keyHandler,\n propKey: '__keyhelper',\n })\n addManagedListener({\n element,\n eventName: 'blur',\n listener: blurHandler,\n propKey: '__oncommitblur',\n })\n}\n\nexport function patchAsyncClick({ element, handler, newProps, propKey }) {\n const { asyncPending } = getElementRuntime(element)\n const wrapped = async (event) => {\n if (newProps.disabledwhilepending && asyncPending.get('click')) return\n\n try {\n asyncPending.set('click', true)\n if (newProps.disabledwhilepending) element.disabled = true\n await handler(event)\n } finally {\n asyncPending.set('click', false)\n if (newProps.disabledwhilepending) element.disabled = false\n }\n }\n\n addManagedListener({\n element,\n eventName: 'click',\n listener: wrapped,\n propKey,\n })\n}\n\nfunction removeInteractionHelpers(element) {\n INTERACTION_LISTENER_KEYS.forEach((key) =>\n removeManagedListener(element, key),\n )\n}\n\nfunction hasInteractionHelpers(props) {\n return Boolean(\n props.onenter || props.onescape || props.onkeys || props.oncommit,\n )\n}\n\nfunction getKeyHandler({ element, newProps, runtime }) {\n return (event) => {\n const composing = runtime.composition.get('active') === true\n if (shouldIgnoreKeyboardEvent(event, composing)) return\n\n const combo = getEventCombo(event)\n\n if (event.key === 'Enter' && newProps.onenter) newProps.onenter(event)\n if (event.key === 'Escape' && newProps.onescape) newProps.onescape(event)\n if (newProps.onkeys) runMatchingKeyHandlers(event, combo, newProps.onkeys)\n\n if (event.key !== 'Enter' || !newProps.oncommit) return\n\n runtime.commitLocks.set('enter', true)\n newProps.oncommit(event)\n setTimeout(() => runtime.commitLocks.delete('enter'), 0)\n }\n}\n\nfunction getBlurHandler({ newProps, runtime }) {\n return (event) => {\n if (!newProps.oncommit) return\n if (runtime.commitLocks.get('enter')) return\n\n newProps.oncommit(event)\n }\n}\n\nfunction runMatchingKeyHandlers(event, combo, handlers) {\n Object.entries(handlers).forEach(([keyCombo, handler]) => {\n if (normalizeKeyCombo(keyCombo) === combo) handler(event)\n })\n}\n\nfunction getEventCombo(event) {\n const comboParts = []\n if (event.ctrlKey) comboParts.push('ctrl')\n if (event.metaKey) comboParts.push('meta')\n if (event.altKey) comboParts.push('alt')\n if (event.shiftKey) comboParts.push('shift')\n\n comboParts.push(event.key.toLowerCase())\n return comboParts.sort().join('+')\n}\n\nfunction normalizeKeyCombo(combo = '') {\n return combo\n .split('+')\n .map((part) => part.trim().toLowerCase())\n .filter(Boolean)\n .map((part) => getNormalizedModifier(part))\n .sort()\n .join('+')\n}\n\nfunction getNormalizedModifier(part) {\n if (part !== 'mod') return part\n\n return navigator.platform.includes('Mac') ? 'meta' : 'ctrl'\n}\n\nfunction shouldIgnoreKeyboardEvent(event, compositionState) {\n return event.isComposing || compositionState === true\n}\n","import { track } from '../metrics.js'\nimport {\n addManagedListener,\n parseEventKey,\n removeManagedListener,\n} from './event-listeners.js'\nimport {\n clearDebouncedInput,\n isInteractionHelperProp,\n patchAsyncClick,\n patchDebouncedInput,\n patchInteractionHelpers,\n} from './interaction-helpers.js'\n\nexport function patchProps(element, newProps = {}, oldProps = {}) {\n if (!element) return\n\n const allProps = { ...oldProps, ...newProps }\n for (const key in allProps) {\n patchProp({ element, key, newProps, oldProps })\n }\n\n patchDebouncedInput(element, newProps)\n patchInteractionHelpers(element, newProps)\n}\n\nfunction patchProp({ element, key, newProps, oldProps }) {\n const oldValue = oldProps[key]\n const newValue = newProps[key]\n\n if (newValue === undefined || newValue === null) {\n removeProp({ element, key })\n return\n }\n\n // Avoid resetting browser-managed input state, such as cursor position.\n if (key === 'value' || key === 'checked') {\n patchLiveDomProp({ element, key, value: newValue })\n return\n }\n\n if (oldValue === newValue && key !== 'onclickasync') return\n\n track('patches')\n if (key.startsWith('on')) {\n patchEventProp({ element, handler: newValue, key, newProps })\n return\n }\n\n if (key === 'debounce') return\n if (key === 'disabled') {\n element.disabled = newValue === true || newValue === 'true'\n return\n }\n\n element.setAttribute(key, newValue)\n}\n\nfunction removeProp({ element, key }) {\n if (key.startsWith('on')) removeManagedListener(element, key)\n if (key === 'oninputdebounced') clearDebouncedInput(element)\n\n element.removeAttribute(key)\n track('patches')\n}\n\nfunction patchLiveDomProp({ element, key, value }) {\n if (element[key] === value) return\n\n element[key] = value\n track('patches')\n}\n\nfunction patchEventProp({ element, handler, key, newProps }) {\n const { eventKey, modifiers } = parseEventKey(key)\n const eventName = eventKey.slice(2).toLowerCase()\n\n if (isInteractionHelperProp(eventKey)) return\n if (eventKey === 'oninputdebounced') return\n\n if (eventKey === 'onclickasync') {\n patchAsyncClick({ element, handler, newProps, propKey: key })\n return\n }\n\n const listener = (event) => {\n if (modifiers.includes('prevent')) event.preventDefault()\n if (modifiers.includes('stop')) event.stopPropagation()\n return handler(event)\n }\n\n addManagedListener({\n element,\n eventName,\n listener,\n options: {\n capture: modifiers.includes('capture'),\n once: modifiers.includes('once'),\n passive: modifiers.includes('passive'),\n },\n propKey: key,\n })\n}\n","import { track } from '../metrics.js'\nimport { patchProps } from './patch-props.js'\nimport { renderComponent, scheduleMountHooks } from './component-lifecycle.js'\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\nconst MATH_NS = 'http://www.w3.org/1998/Math/MathML'\n\nexport function getNamespace(parent) {\n if (parent.namespaceURI === SVG_NS && parent.tagName !== 'foreignObject') {\n return SVG_NS\n }\n if (parent.namespaceURI === MATH_NS) {\n return MATH_NS\n }\n return null\n}\n\nexport function createElement(vNode, namespace) {\n if (typeof vNode === 'string' || typeof vNode === 'number') {\n return document.createTextNode(String(vNode))\n }\n\n if (typeof vNode.tag === 'function')\n return createComponentElement(vNode, namespace)\n\n track('elementsCreated')\n const tag = vNode.tag\n const elementNamespace = getElementNamespace(tag, namespace)\n const element = elementNamespace\n ? document.createElementNS(elementNamespace, tag)\n : document.createElement(tag)\n\n vNode.el = element\n patchProps(element, vNode.props)\n appendChildren({ element, namespace: elementNamespace, tag, vNode })\n return element\n}\n\nfunction createComponentElement(vNode, namespace) {\n const childVNode = renderComponent(vNode)\n const element = createElement(childVNode, namespace)\n\n vNode.child = childVNode\n vNode.el = element\n scheduleMountHooks(vNode.hooks)\n\n return element\n}\n\nfunction appendChildren({ element, namespace, tag, vNode }) {\n // Children of SVG foreignObject must return to the HTML namespace.\n const childNamespace = tag === 'foreignObject' ? null : namespace\n\n vNode.children.forEach((child) => {\n element.appendChild(createElement(child, childNamespace))\n })\n}\n\nfunction getElementNamespace(tag, namespace) {\n // A nested <svg> or <math> starts a fresh namespace regardless of its parent.\n if (tag === 'svg') return SVG_NS\n if (tag === 'math') return MATH_NS\n\n // createElementNS is slower than createElement, so only use it when needed.\n return namespace\n}\n","import { createElement, getNamespace } from './create-element.js'\nimport { track } from '../metrics.js'\n\nexport function hasKeys(children) {\n return children && children.some((child) => child?.props?.key != null)\n}\n\nexport function reconcileChildren({\n oldChildren,\n newChildren,\n parent,\n patchNode,\n runUnmount,\n}) {\n // Unkeyed children are cheap to patch by index; keyed children preserve DOM\n // identity across reorders so state and focus do not move to the wrong item.\n const isKeyed = hasKeys(newChildren) || hasKeys(oldChildren)\n if (isKeyed) {\n reconcileKeyedChildren({\n oldChildren,\n newChildren,\n parent,\n patchNode,\n runUnmount,\n })\n return\n }\n\n reconcileUnkeyedChildren({ oldChildren, newChildren, parent, patchNode })\n}\n\nfunction reconcileUnkeyedChildren({\n oldChildren,\n newChildren,\n parent,\n patchNode,\n}) {\n const maxLength = Math.max(newChildren.length, oldChildren.length)\n for (let index = 0; index < maxLength; index++) {\n patchNode(parent, newChildren[index], oldChildren[index], index)\n }\n}\n\nfunction reconcileKeyedChildren({\n oldChildren,\n newChildren,\n parent,\n patchNode,\n runUnmount,\n}) {\n const keyedChildren = getKeyedChildren(oldChildren)\n\n newChildren.forEach((newChild, index) => {\n const key = getChildKey(newChild, index)\n const existingChild = keyedChildren[key]\n\n if (existingChild) {\n patchExistingKeyedChild({\n existingChild,\n index,\n newChild,\n parent,\n patchNode,\n })\n delete keyedChildren[key]\n return\n }\n\n insertNewKeyedChild({ index, newChild, parent })\n })\n\n removeStaleKeyedChildren({ keyedChildren, parent, runUnmount })\n}\n\nfunction getKeyedChildren(children) {\n const keyedChildren = {}\n\n children.forEach((child, index) => {\n const key = getChildKey(child, index)\n keyedChildren[key] = { index, vNode: child }\n })\n\n return keyedChildren\n}\n\nfunction getChildKey(child, fallback) {\n return child?.props?.key != null ? child.props.key : fallback\n}\n\nfunction patchExistingKeyedChild({\n existingChild,\n index,\n newChild,\n parent,\n patchNode,\n}) {\n const oldVNode = existingChild.vNode\n patchNode(parent, newChild, oldVNode, index)\n\n const element = newChild.el || oldVNode.el\n const domChildAtIndex = parent.childNodes[index]\n if (element && domChildAtIndex !== element) {\n parent.insertBefore(element, domChildAtIndex)\n track('patches')\n }\n}\n\nfunction insertNewKeyedChild({ index, newChild, parent }) {\n const newElement = createElement(newChild, getNamespace(parent))\n const domChildAtIndex = parent.childNodes[index]\n\n if (domChildAtIndex) {\n parent.insertBefore(newElement, domChildAtIndex)\n return\n }\n\n parent.appendChild(newElement)\n}\n\nfunction removeStaleKeyedChildren({ keyedChildren, parent, runUnmount }) {\n Object.values(keyedChildren).forEach(({ vNode }) => {\n if (!vNode.el || vNode.el.parentNode !== parent) return\n\n runUnmount(vNode)\n parent.removeChild(vNode.el)\n track('elementsRemoved')\n })\n}\n","import {\n renderComponent,\n runComponentUpdateHooks,\n runUnmount,\n scheduleMountHooks,\n} from './component-lifecycle.js'\nimport { createElement, getNamespace } from './create-element.js'\nimport { track } from '../metrics.js'\nimport { patchProps } from './patch-props.js'\nimport { hasKeys, reconcileChildren } from './reconcile-children.js'\n\nexport { hasKeys }\n\nexport function patch(parent, newVNode, oldVNode, index = 0) {\n track('diffs')\n\n // Removal must clean up recursively so component hooks cannot leak.\n if (newVNode === undefined || newVNode === null) {\n const el = oldVNode.el || parent.childNodes[index]\n runUnmount(oldVNode)\n if (el) {\n parent.removeChild(el)\n track('elementsRemoved')\n }\n return\n }\n\n if (typeof newVNode.tag === 'function') {\n const isNew = !oldVNode\n const childVNode = renderComponent(newVNode)\n newVNode.child = childVNode\n const oldChild = oldVNode ? oldVNode.child : undefined\n patch(parent, childVNode, oldChild, index)\n newVNode.el = childVNode.el\n if (isNew) scheduleMountHooks(newVNode.hooks)\n if (!isNew)\n runComponentUpdateHooks({\n newHooks: newVNode.hooks,\n oldHooks: oldVNode.hooks,\n })\n return\n }\n\n if (oldVNode === undefined || oldVNode === null) {\n parent.appendChild(createElement(newVNode, getNamespace(parent)))\n return\n }\n\n // Different node types cannot be safely patched in place.\n if (\n typeof newVNode !== typeof oldVNode ||\n (typeof newVNode !== 'string' && newVNode.tag !== oldVNode.tag)\n ) {\n const el = oldVNode.el || parent.childNodes[index]\n if (el) {\n parent.replaceChild(createElement(newVNode, getNamespace(parent)), el)\n track('patches')\n }\n return\n }\n\n if (typeof newVNode === 'string' || typeof newVNode === 'number') {\n if (newVNode !== oldVNode) {\n const el = parent.childNodes[index]\n if (el) {\n el.nodeValue = String(newVNode)\n track('patches')\n } else parent.appendChild(document.createTextNode(String(newVNode)))\n }\n return\n }\n\n const el = oldVNode.el || parent.childNodes[index]\n if (!el) return\n newVNode.el = el\n patchProps(el, newVNode.props, oldVNode.props)\n reconcileChildren({\n oldChildren: oldVNode.children,\n newChildren: newVNode.children,\n parent: el,\n patchNode: patch,\n runUnmount,\n })\n}\n","/**\n * @file Mounts the application to the DOM.\n * @module mount\n */\nimport { setObserver } from './observer.js'\nimport { patch } from './runtime/patch.js'\n\n/**\n * Mounts a component to a target DOM element.\n * @param {HTMLElement} target - The DOM element to mount to.\n * @param {function} Component - The root component function.\n */\nexport const mount = (target, Component) => {\n let prevVNode = null\n\n const lifecycle = () => {\n setObserver(lifecycle)\n\n const nextVNode = {\n tag: Component,\n props: {},\n children: [],\n }\n\n patch(target, nextVNode, prevVNode)\n setObserver(null)\n prevVNode = nextVNode\n }\n\n lifecycle()\n}\n","/**\n * Represents a value wrapped by the persist() function.\n * @template T\n * @typedef {object} Persisted\n * @property {T} initial\n * @property {boolean} __humn_persist\n * @property {PersistConfig} [config]\n */\n\n/**\n * @typedef {object} PersistConfig\n * @property {string} key\n */\n\n/**\n * Marks a section of the state for persistence in localStorage.\n * @template T\n * @param {T} initial\n * @param {PersistConfig} [config]\n * @returns {Persisted<T>}\n */\nexport const persist = (initial, config = {}) => ({\n __humn_persist: true,\n initial,\n config,\n})\n"],"names":["currentObserver","currentInstance","getObserver","setObserver","obs","getInstance","setInstance","inst","Cortex","constructor","memory","synapses","liveMemory","this","_persistenceMap","Map","key","value","Object","entries","__humn_persist","storageKey","config","set","stored","localStorage","getItem","JSON","parse","initial","err","_memory","_listeners","updater","nextState","changedPaths","Set","clone","structuredClone","result","_createChangeTrackingProxy","keys","forEach","add","size","stateKey","Array","from","some","path","startsWith","setItem","stringify","_notifyRelevantListeners","obj","Proxy","get","target","prop","fullPath","accessedPaths","renderFn","accessedPath","changedPath","_createAccessTrackingProxy","has","styleSheet","cache","css","stringsOrStr","args","raw","isSingleRoot","isArray","reduce","acc","str","i","content","replace","trim","hash","length","charCodeAt","toString","hashedClassName","document","createElement","id","head","appendChild","textContent","h","tag","props","children","flat","filter","c","onMount","fn","instance","mounts","push","onCleanup","cleanups","invokeHookSafely","errorMessage","error","renderComponent","vNode","hooks","renderedVNode","runUnmount","child","scheduleMountHooks","setTimeout","elementRuntime","WeakMap","getElementRuntime","element","existing","runtime","asyncPending","commitLocks","composition","debounceTimers","listeners","MODIFIER_FLAGS","addManagedListener","eventName","listener","options","propKey","removeManagedListener","addEventListener","previous","removeEventListener","delete","HELPER_EVENTS","INTERACTION_LISTENER_KEYS","clearDebouncedInput","timer","clearTimeout","patchInteractionHelpers","newProps","onenter","onescape","onkeys","oncommit","keyHandler","event","compositionState","isComposing","combo","comboParts","ctrlKey","metaKey","altKey","shiftKey","toLowerCase","sort","join","handlers","keyCombo","handler","split","map","part","Boolean","navigator","platform","includes","blurHandler","patchProps","oldProps","allProps","patchProp","oninputdebounced","debounceMs","Number","debounce","delay","isFinite","currentTarget","oldValue","newValue","eventKey","modifiers","modifierParts","modifier","slice","async","disabledwhilepending","disabled","preventDefault","stopPropagation","capture","once","passive","setAttribute","removeAttribute","SVG_NS","MATH_NS","getNamespace","parent","namespaceURI","tagName","namespace","createTextNode","String","childVNode","el","elementNamespace","createElementNS","childNamespace","hasKeys","reconcileChildren","oldChildren","newChildren","patchNode","keyedChildren","index","getChildKey","newChild","existingChild","oldVNode","domChildAtIndex","childNodes","insertBefore","newElement","values","parentNode","removeChild","maxLength","Math","max","fallback","patch","newVNode","isNew","newHooks","oldHooks","replaceChild","nodeValue","mount","Component","prevVNode","lifecycle","nextVNode","persist"],"mappings":"AAKA,IAAIA,IAAkB,MAClBC,IAAkB;AAMf,MAAMC,IAAc,MAAMF,GAMpBG,IAAeC,CAAAA,MAAAA;AAC1BJ,EAAAA,IAAkBI;AAAAA,GAOPC,IAAc,MAAMJ,GAMpBK,IAAeC,CAAAA,MAAAA;AAC1BN,EAAAA,IAAkBM;AAAAA;ACiBb,MAAMC,GAAAA;AAAAA,EAKX,YAAAC,EAAYC,QAAEA,GAAMC,UAAEA,EAAAA,GAAAA;AACpB,UAAMC,IAAa,EAAA,GAAKF,EAAAA;AACxBG,SAAKC,kBAAkB,oBAAIC;AAG3B,eAAK,CAAOC,GAAKC,CAAAA,KAAUC,OAAOC,QAAQT,CAAAA,EACxC,KAAIO,KAA0B,OAAVA,KAAU,YAAYA,EAAMG,gBAAgB;AAC9D,YAAMC,IAAaJ,EAAMK,QAAQN,OAAOA;AACxCH,WAAKC,gBAAgBS,IAAIP,GAAKK,CAAAA;AAE9B,UAAA;AACE,cAAMG,IAASC,aAAaC,QAAQL,CAAAA;AAElCT,QAAAA,EAAWI,CAAAA,IADTQ,MAAW,OACKG,KAAKC,MAAMJ,CAAAA,IAEXP,EAAMY;AAAAA,MAE5B,QAASC;AAGPlB,QAAAA,EAAWI,CAAAA,IAAOC,EAAMY;AAAAA,MAC1B;AAAA,IACF;AAIFhB,SAAKkB,UAAUnB,GACfC,KAAKmB,aAAa,oBAAIjB,OAmDtBF,KAAKF,WAAWA,EA7CHsB,CAAAA,MAAAA;AACX,UAAIC,GACAC,IAAe,oBAAIC;AAEvB,UAAuB,OAAZH,KAAY,YAAY;AACjC,cAAMI,IAAQC,gBAAgBzB,KAAKkB,OAAAA,GAE7BQ,IA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ACoI,KAAQ,CAAC5L,GAAQ6L,MAAAA;AAC5B,MAAIC,IAAY;AAEhB,QAAMC,IAAY,MAAA;AAChBrP,IAAAA,EAAYqP,CAAAA;AAEZ,UAAMC,IAAY,EAChB5J,KAAKyJ,GACLxJ,OAAO,CAAA,GACPC,UAAU,CAAA,EAAA;AAGZ+I,IAAAA,EAAMrL,GAAQgM,GAAWF,CAAAA,GACzBpP,EAAY,IAAA,GACZoP,IAAYE;AAAAA,EAAAA;AAGdD,EAAAA,EAAAA;AAAAA,GCRWE,KAAU,CAAC7N,GAASP,IAAS,QAAE,EAC1CF,gBAAAA,IACAS,SAAAA,GACAP,QAAAA,EAAAA;"}
|
package/dist/humn.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(a,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):h((a=typeof globalThis<"u"?globalThis:a||self).Humn={})})(this,function(a){"use strict";let h=null,v=null;const $=()=>h,w=t=>{h=t},x=()=>v,C=t=>{v=t};let p=null;const E=new Set;function _(t){return t.namespaceURI===b&&t.tagName!=="foreignObject"?b:t.namespaceURI===k?k:null}function N(t){return t&&t.some(e=>e&&e.props&&e.props.key!=null)}const b="http://www.w3.org/2000/svg",k="http://www.w3.org/1998/Math/MathML";function d(t,e){if(typeof t=="string"||typeof t=="number")return document.createTextNode(String(t));if(typeof t.tag=="function"){const r=j(t);t.child=r;const i=d(r,e);return t.el=i,t.hooks?.mounts.length>0&&setTimeout(()=>t.hooks.mounts.forEach(c=>c()),0),i}const s=t.tag;s==="svg"?e=b:s==="math"&&(e=k);const o=e?document.createElementNS(e,s):document.createElement(s);t.el=o,S(o,t.props);const n=s==="foreignObject"?null:e;return t.children.forEach(r=>{o.appendChild(d(r,n))}),o}function S(t,e={},s={}){if(!t)return;const o={...s,...e};for(const n in o){const r=s[n],i=e[n];if(i!=null)if(n!=="value"&&n!=="checked"){if(r!==i){if(n.startsWith("on")){const c=n.slice(2).toLowerCase();r&&t.removeEventListener(c,r),t.addEventListener(c,i)}n==="disabled"?t.disabled=i===!0||i==="true":t.setAttribute(n,i)}}else t[n]!==i&&(t[n]=i);else t.removeAttribute(n)}}function M(t,e,s){if(!(N(e)||N(s))){const o=Math.max(e.length,s.length);for(let n=0;n<o;n++)g(t,e[n],s[n],n);return}(function(o,n,r){const i={};r.forEach((c,l)=>{const u=(c.props&&c.props.key)!=null?c.props.key:l;i[u]={vNode:c,index:l}}),n.forEach((c,l)=>{const u=(c.props&&c.props.key)!=null?c.props.key:l,A=i[u];if(A){const m=A.vNode;g(o,c,m,l);const f=c.el||m.el,T=o.childNodes[l];f&&T!==f&&o.insertBefore(f,T),delete i[u]}else{const m=d(c,_(o)),f=o.childNodes[l];f?o.insertBefore(m,f):o.appendChild(m)}}),Object.values(i).forEach(({vNode:c})=>{c.el&&c.el.parentNode===o&&(y(c),o.removeChild(c.el))})})(t,e,s)}function j(t){const e={mounts:[],cleanups:[]};C(e);const s=t.tag(t.props);return C(null),t.hooks=e,s}function y(t){t&&(t.hooks&&t.hooks.cleanups&&t.hooks.cleanups.forEach(e=>e()),t.child&&y(t.child),t.children&&t.children.forEach(y))}function g(t,e,s,o=0){if(e==null){const r=s.el||t.childNodes[o];return y(s),void(r&&t.removeChild(r))}if(typeof e.tag=="function"){const r=!s,i=j(e);return e.child=i,g(t,i,s?s.child:void 0,o),e.el=i.el,void(r&&e.hooks&&e.hooks.mounts.length>0&&setTimeout(()=>{e.hooks.mounts.forEach(c=>c())},0))}if(s==null)return void t.appendChild(d(e,_(t)));if(typeof e!=typeof s||typeof e!="string"&&e.tag!==s.tag){const r=s.el||t.childNodes[o];return void(r&&t.replaceChild(d(e,_(t)),r))}if(typeof e=="string"||typeof e=="number"){if(e!==s){const r=t.childNodes[o];r?r.nodeValue=String(e):t.appendChild(document.createTextNode(String(e)))}return}const n=s.el||t.childNodes[o];n&&(e.el=n,S(n,e.props,s.props),M(n,e.children,s.children))}a.Cortex=class{constructor({memory:t,synapses:e}){const s={...t};this._persistenceMap=new Map;for(const[o,n]of Object.entries(t))if(n&&typeof n=="object"&&n.__humn_persist){const r=n.config?.key||o;this._persistenceMap.set(o,r);try{const i=localStorage.getItem(r);s[o]=i!==null?JSON.parse(i):n.initial}catch{s[o]=n.initial}}this._memory=s,this._listeners=new Map,this.synapses=e(o=>{let n,r=new Set;if(typeof o=="function"){const i=structuredClone(this._memory),c=o(this._createChangeTrackingProxy(i,r));c&&typeof c=="object"?(n={...this._memory,...c},Object.keys(c).forEach(l=>r.add(l))):n=i}else n={...this._memory,...o},r=new Set(Object.keys(o));this._memory=n,this._persistenceMap.size>0&&this._persistenceMap.forEach((i,c)=>{if(Array.from(r).some(l=>l===c||l.startsWith(c+".")))try{const l=this._memory[c];localStorage.setItem(i,JSON.stringify(l))}catch{}}),this._notifyRelevantListeners(r)},()=>this._memory)}_createChangeTrackingProxy(t,e,s=""){return new Proxy(t,{get:(o,n)=>{if(typeof n=="symbol"||n==="__proto__")return o[n];const r=o[n],i=s?`${s}.${n}`:n;return typeof r=="object"&&r!==null?this._createChangeTrackingProxy(r,e,i):r},set:(o,n,r)=>{if(typeof n=="symbol"||n==="__proto__")return o[n]=r,!0;const i=s?`${s}.${n}`:n;return e.add(i),o[n]=r,!0}})}_notifyRelevantListeners(t){this._listeners.forEach((e,s)=>{Array.from(e).some(o=>Array.from(t).some(n=>o===n||o.startsWith(n+".")||n.startsWith(o+".")))&&s()})}_createAccessTrackingProxy(t,e,s=""){return typeof t!="object"||t===null?t:new Proxy(t,{get:(o,n)=>{if(typeof n=="symbol"||n==="__proto__")return o[n];const r=s?`${s}.${n}`:n;e.add(r);const i=o[n];return typeof i=="object"&&i!==null?this._createAccessTrackingProxy(i,e,r):i}})}get memory(){const t=$();if(!t)return this._memory;this._listeners.has(t)||this._listeners.set(t,new Set);const e=this._listeners.get(t);return this._createAccessTrackingProxy(this._memory,e)}},a.css=function(t,...e){let s="",o=!1;Array.isArray(t)&&t.raw?s=t.reduce((c,l,u)=>c+l+(e[u]||""),""):(s=t,o=e[0]===!0);let n=(function(c){return c.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").trim()})(s);if(!n)return"";o&&(n=n.replace(/(^|[{};,])(\s*)(?!from|to)((?:[.#]?[\w-]+|\[[^\]]+\]|:{1,2}[^:,{\s]+)+)(?=\s*\{)/gi,"$1$2$3&, $3"));const r=(function(c){let l=5381,u=c.length;for(;u;)l=33*l^c.charCodeAt(--u);return(l>>>0).toString(36)})(n),i=`humn-${r}`;return E.has(r)||(p||(p=document.createElement("style"),p.id="humn-styles",document.head.appendChild(p)),p.textContent+=`.${i} {
|
|
2
|
-
${
|
|
1
|
+
(function(g,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):v((g=typeof globalThis<"u"?globalThis:g||self).Humn={})})(this,function(g){"use strict";let v=null,L=null;const q=()=>v,O=e=>{v=e},U=()=>L,W=e=>{L=e};let C=null;const H=new Set;function T(e,t){try{e()}catch{}}function B(e){const t={mounts:[],cleanups:[]};W(t);const n=e.tag(e.props);return W(null),e.hooks=t,n}function P(e){e&&(e.hooks?.cleanups&&e.hooks.cleanups.forEach(t=>T(t)),e.child&&P(e.child),e.children&&e.children.forEach(P))}function M(e){e?.mounts?.length&&setTimeout(()=>e.mounts.forEach(t=>T(t)),0)}const I=new WeakMap;function b(e){const t=I.get(e);if(t)return t;const n={asyncPending:new Map,commitLocks:new Map,composition:new Map,debounceTimers:new Map,listeners:new Map};return I.set(e,n),n}const G=new Set(["prevent","stop","once","capture","passive"]);function w({element:e,eventName:t,listener:n,options:i=!1,propKey:o}){const{listeners:r}=b(e);x(e,o),e.addEventListener(t,n,i),r.set(o,{eventName:t,listener:n,options:i})}function x(e,t){const{listeners:n}=b(e),i=n.get(t);if(!i)return;const{eventName:o,listener:r,options:s}=i;e.removeEventListener(o,r,s),n.delete(t)}const Q=new Set(["onenter","onescape","onkeys","oncommit"]),X=["__compositionstart","__compositionend","__keyhelper","__oncommitblur"];function R(e){const{debounceTimers:t}=b(e),n=t.get("oninputdebounced");n&&clearTimeout(n),t.delete("oninputdebounced"),x(e,"oninputdebounced")}function Y(e,t){if(n=t,!(n.onenter||n.onescape||n.onkeys||n.oncommit))return void(function(s){X.forEach(c=>x(s,c))})(e);var n;const i=b(e),o=(function({element:s,newProps:c,runtime:l}){return u=>{if((function(a,p){return a.isComposing||p===!0})(u,l.composition.get("active")===!0))return;const m=(function(a){const p=[];return a.ctrlKey&&p.push("ctrl"),a.metaKey&&p.push("meta"),a.altKey&&p.push("alt"),a.shiftKey&&p.push("shift"),p.push(a.key.toLowerCase()),p.sort().join("+")})(u);u.key==="Enter"&&c.onenter&&c.onenter(u),u.key==="Escape"&&c.onescape&&c.onescape(u),c.onkeys&&(function(a,p,d){Object.entries(d).forEach(([f,y])=>{(function(k=""){return k.split("+").map(h=>h.trim().toLowerCase()).filter(Boolean).map(h=>(function(_){return _!=="mod"?_:navigator.platform.includes("Mac")?"meta":"ctrl"})(h)).sort().join("+")})(f)===p&&y(a)})})(u,m,c.onkeys),u.key==="Enter"&&c.oncommit&&(l.commitLocks.set("enter",!0),c.oncommit(u),setTimeout(()=>l.commitLocks.delete("enter"),0))}})({element:e,newProps:t,runtime:i}),r=(function({newProps:s,runtime:c}){return l=>{s.oncommit&&(c.commitLocks.get("enter")||s.oncommit(l))}})({newProps:t,runtime:i});w({element:e,eventName:"compositionstart",listener:()=>i.composition.set("active",!0),propKey:"__compositionstart"}),w({element:e,eventName:"compositionend",listener:()=>i.composition.set("active",!1),propKey:"__compositionend"}),w({element:e,eventName:"keydown",listener:o,propKey:"__keyhelper"}),w({element:e,eventName:"blur",listener:r,propKey:"__oncommitblur"})}function J(e,t={},n={}){if(!e)return;const i={...n,...t};for(const o in i)Z({element:e,key:o,newProps:t,oldProps:n});(function(o,r){if(!r.oninputdebounced)return void R(o);const{debounceTimers:s}=b(o),c=Number(r.debounce),l=Number.isFinite(c)?c:250;w({element:o,eventName:"input",listener:u=>{const m=s.get("oninputdebounced");m&&clearTimeout(m);const a=setTimeout(()=>{s.delete("oninputdebounced"),r.oninputdebounced({...u,currentTarget:o,target:o})},l);s.set("oninputdebounced",a)},propKey:"oninputdebounced"})})(e,t),Y(e,t)}function Z({element:e,key:t,newProps:n,oldProps:i}){const o=i[t],r=n[t];r!=null?t!=="value"&&t!=="checked"?o===r&&t!=="onclickasync"||(t.startsWith("on")?(function({element:s,handler:c,key:l,newProps:u}){const{eventKey:m,modifiers:a}=(function(d){const[f,...y]=d.split("|");return{eventKey:f,modifiers:y.filter(k=>G.has(k))}})(l),p=m.slice(2).toLowerCase();if(!(function(d){return Q.has(d)})(m)&&m!=="oninputdebounced"){if(m==="onclickasync")return void(function({element:d,handler:f,newProps:y,propKey:k}){const{asyncPending:h}=b(d);w({element:d,eventName:"click",listener:async _=>{if(!y.disabledwhilepending||!h.get("click"))try{h.set("click",!0),y.disabledwhilepending&&(d.disabled=!0),await f(_)}finally{h.set("click",!1),y.disabledwhilepending&&(d.disabled=!1)}},propKey:k})})({element:s,handler:c,newProps:u,propKey:l});w({element:s,eventName:p,listener:d=>(a.includes("prevent")&&d.preventDefault(),a.includes("stop")&&d.stopPropagation(),c(d)),options:{capture:a.includes("capture"),once:a.includes("once"),passive:a.includes("passive")},propKey:l})}})({element:e,handler:r,key:t,newProps:n}):t!=="debounce"&&(t!=="disabled"?e.setAttribute(t,r):e.disabled=r===!0||r==="true")):(function({element:s,key:c,value:l}){s[c]!==l&&(s[c]=l)})({element:e,key:t,value:r}):(function({element:s,key:c}){c.startsWith("on")&&x(s,c),c==="oninputdebounced"&&R(s),s.removeAttribute(c)})({element:e,key:t})}const S="http://www.w3.org/2000/svg",j="http://www.w3.org/1998/Math/MathML";function K(e){return e.namespaceURI===S&&e.tagName!=="foreignObject"?S:e.namespaceURI===j?j:null}function N(e,t){if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(typeof e.tag=="function")return(function(r,s){const c=B(r),l=N(c,s);return r.child=c,r.el=l,M(r.hooks),l})(e,t);const n=e.tag,i=(function(r,s){return r==="svg"?S:r==="math"?j:s})(n,t),o=i?document.createElementNS(i,n):document.createElement(n);return e.el=o,J(o,e.props),(function({element:r,namespace:s,tag:c,vNode:l}){const u=c==="foreignObject"?null:s;l.children.forEach(m=>{r.appendChild(N(m,u))})})({element:o,namespace:i,tag:n,vNode:e}),o}function z(e){return e&&e.some(t=>t?.props?.key!=null)}function ee({oldChildren:e,newChildren:t,parent:n,patchNode:i,runUnmount:o}){z(t)||z(e)?(function({oldChildren:r,newChildren:s,parent:c,patchNode:l,runUnmount:u}){const m=(function(a){const p={};return a.forEach((d,f)=>{const y=D(d,f);p[y]={index:f,vNode:d}}),p})(r);s.forEach((a,p)=>{const d=D(a,p),f=m[d];if(f)return(function({existingChild:y,index:k,newChild:h,parent:_,patchNode:E}){const F=y.vNode;E(_,h,F,k);const $=h.el||F.el,V=_.childNodes[k];$&&V!==$&&_.insertBefore($,V)})({existingChild:f,index:p,newChild:a,parent:c,patchNode:l}),void delete m[d];(function({index:y,newChild:k,parent:h}){const _=N(k,K(h)),E=h.childNodes[y];if(E)return void h.insertBefore(_,E);h.appendChild(_)})({index:p,newChild:a,parent:c})}),(function({keyedChildren:a,parent:p,runUnmount:d}){Object.values(a).forEach(({vNode:f})=>{f.el&&f.el.parentNode===p&&(d(f),p.removeChild(f.el))})})({keyedChildren:m,parent:c,runUnmount:u})})({oldChildren:e,newChildren:t,parent:n,patchNode:i,runUnmount:o}):(function({oldChildren:r,newChildren:s,parent:c,patchNode:l}){const u=Math.max(s.length,r.length);for(let m=0;m<u;m++)l(c,s[m],r[m],m)})({oldChildren:e,newChildren:t,parent:n,patchNode:i})}function D(e,t){return e?.props?.key!=null?e.props.key:t}function A(e,t,n,i=0){if(t==null){const r=n.el||e.childNodes[i];return P(n),void(r&&e.removeChild(r))}if(typeof t.tag=="function"){const r=!n,s=B(t);return t.child=s,A(e,s,n?n.child:void 0,i),t.el=s.el,r&&M(t.hooks),void(r||(function({newHooks:c,oldHooks:l}){l?.cleanups?.length&&(l.cleanups.forEach(u=>T(u)),M(c))})({newHooks:t.hooks,oldHooks:n.hooks}))}if(n==null)return void e.appendChild(N(t,K(e)));if(typeof t!=typeof n||typeof t!="string"&&t.tag!==n.tag){const r=n.el||e.childNodes[i];return void(r&&e.replaceChild(N(t,K(e)),r))}if(typeof t=="string"||typeof t=="number"){if(t!==n){const r=e.childNodes[i];r?r.nodeValue=String(t):e.appendChild(document.createTextNode(String(t)))}return}const o=n.el||e.childNodes[i];o&&(t.el=o,J(o,t.props,n.props),ee({oldChildren:n.children,newChildren:t.children,parent:o,patchNode:A,runUnmount:P}))}g.Cortex=class{constructor({memory:e,synapses:t}){const n={...e};this._persistenceMap=new Map;for(const[i,o]of Object.entries(e))if(o&&typeof o=="object"&&o.__humn_persist){const r=o.config?.key||i;this._persistenceMap.set(i,r);try{const s=localStorage.getItem(r);n[i]=s!==null?JSON.parse(s):o.initial}catch{n[i]=o.initial}}this._memory=n,this._listeners=new Map,this.synapses=t(i=>{let o,r=new Set;if(typeof i=="function"){const s=structuredClone(this._memory),c=i(this._createChangeTrackingProxy(s,r));c&&typeof c=="object"?(o={...this._memory,...c},Object.keys(c).forEach(l=>r.add(l))):o=s}else o={...this._memory,...i},r=new Set(Object.keys(i));this._memory=o,this._persistenceMap.size>0&&this._persistenceMap.forEach((s,c)=>{if(Array.from(r).some(l=>l===c||l.startsWith(c+".")))try{const l=this._memory[c];localStorage.setItem(s,JSON.stringify(l))}catch{}}),this._notifyRelevantListeners(r)},()=>this._memory)}_createChangeTrackingProxy(e,t,n=""){return new Proxy(e,{get:(i,o)=>{if(typeof o=="symbol"||o==="__proto__")return i[o];const r=i[o],s=n?`${n}.${o}`:o;return typeof r=="object"&&r!==null?this._createChangeTrackingProxy(r,t,s):r},set:(i,o,r)=>{if(typeof o=="symbol"||o==="__proto__")return i[o]=r,!0;const s=n?`${n}.${o}`:o;return t.add(s),i[o]=r,!0}})}_notifyRelevantListeners(e){this._listeners.forEach((t,n)=>{Array.from(t).some(i=>Array.from(e).some(o=>i===o||i.startsWith(o+".")||o.startsWith(i+".")))&&n()})}_createAccessTrackingProxy(e,t,n=""){return typeof e!="object"||e===null?e:new Proxy(e,{get:(i,o)=>{if(typeof o=="symbol"||o==="__proto__")return i[o];const r=n?`${n}.${o}`:o;t.add(r);const s=i[o];return typeof s=="object"&&s!==null?this._createAccessTrackingProxy(s,t,r):s}})}get memory(){const e=q();if(!e)return this._memory;this._listeners.has(e)||this._listeners.set(e,new Set);const t=this._listeners.get(e);return this._createAccessTrackingProxy(this._memory,t)}},g.css=function(e,...t){let n="",i=!1;Array.isArray(e)&&e.raw?n=e.reduce((c,l,u)=>c+l+(t[u]||""),""):(n=e,i=t[0]===!0);let o=(function(c){return c.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").trim()})(n);if(!o)return"";i&&(o=o.replace(/(^|[{};,])(\s*)(?!from|to)((?:[.#]?[\w-]+|\[[^\]]+\]|:{1,2}[^:,{\s]+)+)(?=\s*\{)/gi,"$1$2$3&, $3"));const r=(function(c){let l=5381,u=c.length;for(;u;)l=33*l^c.charCodeAt(--u);return(l>>>0).toString(36)})(o),s=`humn-${r}`;return H.has(r)||(C||(C=document.createElement("style"),C.id="humn-styles",document.head.appendChild(C)),C.textContent+=`.${s} {
|
|
2
|
+
${o}
|
|
3
3
|
}
|
|
4
|
-
`,
|
|
4
|
+
`,H.add(r)),s},g.h=(e,t={},n=[])=>({tag:e,props:t,children:(Array.isArray(n)?n:[n]).flat().filter(i=>i!=null&&i!==!1&&i!=="")}),g.mount=(e,t)=>{let n=null;const i=()=>{O(i);const o={tag:t,props:{},children:[]};A(e,o,n),O(null),n=o};i()},g.onCleanup=function(e){const t=U();t&&t.cleanups.push(e)},g.onMount=function(e){const t=U();t&&t.mounts.push(e)},g.persist=(e,t={})=>({__humn_persist:!0,initial:e,config:t}),Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
5
5
|
//# sourceMappingURL=humn.umd.js.map
|
package/dist/humn.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"humn.umd.js","sources":["../src/observer.js","../src/css.js","../src/patch.js","../src/persist.js","../src/cortex.js","../src/h.js","../src/mount.js","../src/lifecycle.js"],"sourcesContent":["/**\n * @file Observer module for tracking global state during rendering.\n * @module observer\n */\n\nlet currentObserver = null // For Cortex/State dependency\nlet currentInstance = null // For Lifecycle Hooks\n\n/**\n * Gets the current observer (render function).\n * @returns {function|null}\n */\nexport const getObserver = () => currentObserver\n\n/**\n * Sets the current observer.\n * @param {function|null} obs\n */\nexport const setObserver = (obs) => {\n currentObserver = obs\n}\n\n/**\n * Gets the current component instance (hook container).\n * @returns {object|null}\n */\nexport const getInstance = () => currentInstance\n\n/**\n * Sets the current component instance.\n * @param {object|null} inst\n */\nexport const setInstance = (inst) => {\n currentInstance = inst\n}\n","/**\n * @file Runtime Scoped CSS implementation using Native CSS Nesting.\n * @module css\n */\n\nlet styleSheet = null\nconst cache = new Set()\n\n/**\n * Simple DJB2 hashing function.\n */\nfunction hashString(str) {\n let hash = 5381\n let i = str.length\n while (i) {\n hash = (hash * 33) ^ str.charCodeAt(--i)\n }\n return (hash >>> 0).toString(36)\n}\n\n/**\n * Lightweight Runtime Minifier.\n * Removes comments and collapses whitespace.\n * We do not strip spaces around colons/brackets to ensure safety for calc().\n */\nfunction minify(css) {\n return css\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Remove comments\n .replace(/\\s+/g, ' ') // Collapse newlines/tabs to single space\n .trim() // Remove leading/trailing\n}\n\n/**\n * Scoped CSS Tag.\n * Wraps content in a unique class using Native CSS Nesting.\n * Supports two signatures:\n * 1. Tagged Template: css`...`\n * 2. Function: css(string, isSingleRoot)\n */\nexport function css(stringsOrStr, ...args) {\n let raw = ''\n let isSingleRoot = false\n\n // Detect usage of Tagged Template vs Function Call\n if (Array.isArray(stringsOrStr) && stringsOrStr.raw) {\n raw = stringsOrStr.reduce((acc, str, i) => {\n return acc + str + (args[i] || '')\n }, '')\n } else {\n raw = stringsOrStr\n // If called as function, the first arg is our boolean flag\n isSingleRoot = args[0] === true\n }\n let content = minify(raw)\n\n if (!content) return ''\n\n if (isSingleRoot) {\n // Transforms selectors to apply to BOTH the root (using &) AND descendants.\n // e.g. \"div\" -> \"div&, div\"\n\n // Regex Breakdown:\n // 1. (^|[{};,]) -> Hard Start (Line start, brace, semi, comma)\n // 2. (\\s*) -> Whitespace\n // 3. (?!from|to) -> Negative Lookahead: Ignore 'from'/'to' (keyframes)\n // 4. ( ... )+ -> Compound Selector:\n // (?:[.#]?[\\w-]+ ... ) -> Matches tags (div), classes (.class), ids (#id)\n // 5. (?=\\s*\\{) -> Lookahead: Must be followed by {\n\n content = content.replace(\n /(^|[{};,])(\\s*)(?!from|to)((?:[.#]?[\\w-]+|\\[[^\\]]+\\]|:{1,2}[^:,{\\s]+)+)(?=\\s*\\{)/gi,\n '$1$2$3&, $3',\n )\n }\n\n const hash = hashString(content)\n const hashedClassName = `humn-${hash}`\n\n if (cache.has(hash)) {\n return hashedClassName\n }\n\n if (!styleSheet) {\n styleSheet = document.createElement('style')\n styleSheet.id = 'humn-styles'\n document.head.appendChild(styleSheet)\n }\n\n styleSheet.textContent += `.${hashedClassName} { \n ${content} \n }\\n`\n cache.add(hash)\n\n return hashedClassName\n}\n","/**\n * @file This file contains the diffing and patching algorithm for the virtual DOM,\n * including support for Keyed Diffing.\n * @module patch\n */\nimport { track } from './metrics.js'\nimport { setInstance } from './observer.js'\n\nfunction getNamespace(parent) {\n if (parent.namespaceURI === SVG_NS && parent.tagName !== 'foreignObject') {\n return SVG_NS\n }\n if (parent.namespaceURI === MATH_NS) {\n return MATH_NS\n }\n return null\n}\n\n/**\n * Checks if a list of children contains keys.\n * @param {Array<import(\"./h.js\").VNode>} children - The list of VNodes.\n * @returns {boolean} True if keys are present.\n */\nexport function hasKeys(children) {\n return children && children.some((c) => c && c.props && c.props.key != null)\n}\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\nconst MATH_NS = 'http://www.w3.org/1998/Math/MathML'\n/**\n * Creates a real DOM element from a virtual node.\n * @param {import(\"./h.js\").VNode | string | number} vNode\n * @param {string} [namespace] - The current namespace URI (if any).\n * @returns {Text | HTMLElement | SVGElement}\n */\nfunction createElement(vNode, namespace) {\n if (typeof vNode === 'string' || typeof vNode === 'number') {\n return document.createTextNode(String(vNode))\n }\n\n if (typeof vNode.tag === 'function') {\n const childVNode = renderComponent(vNode)\n vNode.child = childVNode\n\n const el = createElement(childVNode, namespace)\n\n vNode.el = el\n if (vNode.hooks?.mounts.length > 0) {\n setTimeout(() => vNode.hooks.mounts.forEach((fn) => fn()), 0)\n }\n return el\n }\n\n track('elementsCreated')\n\n const tag = vNode.tag\n\n // We prioritize specific tag declarations over the inherited namespace.\n if (tag === 'svg') namespace = SVG_NS\n else if (tag === 'math') namespace = MATH_NS\n // NOTE: If we are inside 'foreignObject', we must NOT use the SVG NS.\n // We handle this by resetting 'ns' in the recursion step below,\n // so 'ns' entering here is already null for the foreignObject's children.\n\n // createElementNS is slower than createElement, so only use it if we have a namespace.\n const element = namespace\n ? document.createElementNS(namespace, tag)\n : document.createElement(tag)\n\n vNode.el = element\n patchProps(element, vNode.props)\n\n // If we are currently at a 'foreignObject', children must exit the SVG namespace.\n const childNS = tag === 'foreignObject' ? null : namespace\n\n vNode.children.forEach((child) => {\n element.appendChild(createElement(child, childNS))\n })\n\n return element\n}\n\n/**\n * Updates the properties (attributes/events) of a DOM element.\n * @param {HTMLElement} element - The DOM element to update.\n * @param {object} [newProps={}] - The new properties.\n * @param {object} [oldProps={}] - The old properties.\n *\n * WHY: We check against the LIVE DOM value for inputs (value/checked) to prevent\n * the \"cursor jumping\" bug. If we just blindly set the attribute, the browser\n * might reset the cursor position to the end of the input.\n */\nfunction patchProps(element, newProps = {}, oldProps = {}) {\n if (!element) return\n\n const allProps = { ...oldProps, ...newProps }\n\n for (const key in allProps) {\n const oldValue = oldProps[key]\n const newValue = newProps[key]\n\n // Handle removed props\n if (newValue === undefined || newValue === null) {\n element.removeAttribute(key)\n track('patches')\n continue\n }\n\n // We check against the LIVE DOM value to prevent cursor jumping\n if (key === 'value' || key === 'checked') {\n if (element[key] !== newValue) {\n element[key] = newValue\n track('patches')\n }\n continue\n }\n\n // If prop hasn't changed, skip\n if (oldValue === newValue) continue\n\n track('patches')\n\n // Handle Events\n if (key.startsWith('on')) {\n const eventName = key.slice(2).toLowerCase()\n if (oldValue) element.removeEventListener(eventName, oldValue)\n element.addEventListener(eventName, newValue)\n }\n // Handle the disabled attribute\n if (key === 'disabled') {\n element.disabled = newValue === true || newValue === 'true'\n }\n // Handle standard attributes\n else {\n element.setAttribute(key, newValue)\n }\n }\n}\n\n/**\n * Reconciles the children of a node, handling both simple lists and keyed reordering.\n * @param {HTMLElement} parent - The parent DOM element.\n * @param {Array<import(\"./h.js\").VNode>} newChildren - The new list of children.\n * @param {Array<import(\"./h.js\").VNode>} oldChildren - The old list of children.\n *\n * WHY: This is the most complex part of the VDOM. We need to efficiently update\n * a list of items. Without keys, we just update index-by-index, which is fast\n * but causes issues if items are reordered (state gets mixed up).\n * With keys, we can track items as they move around, preserving their state\n * and minimizing DOM operations.\n */\nfunction reconcileChildren(parent, newChildren, oldChildren) {\n const isKeyed = hasKeys(newChildren) || hasKeys(oldChildren)\n\n // If no keys are used, use the fast index-based simple loop.\n // This is faster for static lists or simple text replacements.\n if (!isKeyed) {\n const maxLen = Math.max(newChildren.length, oldChildren.length)\n for (let i = 0; i < maxLen; i++) {\n patch(parent, newChildren[i], oldChildren[i], i)\n }\n return\n }\n\n reconcileKeyedChildren(parent, newChildren, oldChildren)\n}\n\n/**\n * Handles the complex logic of reconciling keyed children.\n *\n * WHY: When keys are present, we can't just iterate by index. We need to map\n * existing children by their key so we can find them even if they've moved.\n * This allows us to re-use DOM nodes (preserving focus/state) instead of\n * destroying and re-creating them.\n */\nfunction reconcileKeyedChildren(parent, newChildren, oldChildren) {\n // Map existing children by Key for O(1) lookup\n const keyed = {}\n oldChildren.forEach((child, i) => {\n const key = (child.props && child.props.key) != null ? child.props.key : i\n keyed[key] = { vNode: child, index: i }\n })\n\n newChildren.forEach((newChild, i) => {\n const key =\n (newChild.props && newChild.props.key) != null ? newChild.props.key : i\n const existingChildMatch = keyed[key]\n\n if (existingChildMatch) {\n // A. MATCH FOUND - The item existed before\n const oldVNode = existingChildMatch.vNode\n\n // Update the node's content recursively\n patch(parent, newChild, oldVNode, i)\n\n // If the DOM node isn't in the right spot, move it.\n // We use oldVNode.el because patch transfers the ref, but just to be safe:\n const element = newChild.el || oldVNode.el\n\n // Get the node currently at this index in the real DOM\n const domChildAtIndex = parent.childNodes[i]\n\n // If the element exists but is in the wrong place, move it\n if (element && domChildAtIndex !== element) {\n parent.insertBefore(element, domChildAtIndex)\n track('patches')\n }\n\n // Remove from map so we know it was re-used\n delete keyed[key]\n } else {\n // B. NO MATCH - This is a new item\n const newElement = createElement(newChild, getNamespace(parent))\n const domChildAtIndex = parent.childNodes[i]\n\n if (domChildAtIndex) {\n parent.insertBefore(newElement, domChildAtIndex)\n } else {\n parent.appendChild(newElement)\n }\n }\n })\n\n // Remove any old keys that weren't used in the new list\n Object.values(keyed).forEach(({ vNode }) => {\n if (vNode.el && vNode.el.parentNode === parent) {\n runUnmount(vNode) // Clean up hooks\n parent.removeChild(vNode.el)\n track('elementsRemoved')\n }\n })\n}\n\n/**\n * Executes a Functional Component, tracks hooks, and returns the VNode.\n * @param {import(\"./h.js\").VNode} vNode - The component vNode.\n * @returns {import(\"./h.js\").VNode} The rendered child vNode.\n */\nfunction renderComponent(vNode) {\n track('componentsRendered')\n\n // 1. Prepare Hook Container\n const hooks = {\n mounts: [],\n cleanups: [],\n }\n\n // 2. Set Global Scope\n setInstance(hooks)\n\n // 3. Run the User's Component Function\n // We pass props as the first argument\n const renderedVNode = vNode.tag(vNode.props)\n\n // 4. Clear Global Scope\n setInstance(null)\n\n // 5. Attach hooks to the VNode so we can run them later\n vNode.hooks = hooks\n\n return renderedVNode\n}\n\n/**\n * Helper to recursively run cleanup hooks when a tree is removed.\n * @param {import(\"./h.js\").VNode} vNode - The vNode to unmount.\n */\nfunction runUnmount(vNode) {\n if (!vNode) return\n\n // 1. Run hooks for this node\n if (vNode.hooks && vNode.hooks.cleanups) {\n vNode.hooks.cleanups.forEach((fn) => fn())\n }\n\n // 2. Recurse into child (if component)\n if (vNode.child) {\n runUnmount(vNode.child)\n }\n\n // 3. Recurse into children (if element)\n if (vNode.children) {\n vNode.children.forEach(runUnmount)\n }\n}\n\n/**\n * The main diffing function. Compares V-DOM trees and updates the real DOM.\n * @param {HTMLElement} parent - The parent DOM element.\n * @param {import(\"./h.js\").VNode | string | number} newVNode - The new virtual node.\n * @param {import(\"./h.js\").VNode | string | number} oldVNode - The old virtual node.\n * @param {number} [index=0] - The index of the child node (used for simple diffing).\n */\nexport function patch(parent, newVNode, oldVNode, index = 0) {\n track('diffs')\n\n // Case 1: Removal - The new node is null/undefined, so we remove the old one.\n if (newVNode === undefined || newVNode === null) {\n const el = oldVNode.el || parent.childNodes[index]\n\n // Recursive Cleanup\n runUnmount(oldVNode)\n\n if (el) {\n parent.removeChild(el)\n track('elementsRemoved')\n }\n return\n }\n\n // Case 2: Component - If it's a function, we delegate to the component logic.\n if (typeof newVNode.tag === 'function') {\n const isNew = !oldVNode\n\n const childVNode = renderComponent(newVNode)\n newVNode.child = childVNode\n\n const oldChild = oldVNode ? oldVNode.child : undefined\n patch(parent, childVNode, oldChild, index)\n\n newVNode.el = childVNode.el\n\n // Run mount hooks on the next tick\n if (isNew && newVNode.hooks && newVNode.hooks.mounts.length > 0) {\n setTimeout(() => {\n newVNode.hooks.mounts.forEach((fn) => fn())\n }, 0)\n }\n // TODO: Handle updates (running old cleanups if necessary) for Phase 2\n return\n }\n\n // Case 3: Creation - No old node exists, so we create a new one.\n if (oldVNode === undefined || oldVNode === null) {\n parent.appendChild(createElement(newVNode, getNamespace(parent)))\n return\n }\n\n // Case 4: Replacement - The node type changed (e.g. div -> span), so we replace it entirely.\n if (\n typeof newVNode !== typeof oldVNode ||\n (typeof newVNode !== 'string' && newVNode.tag !== oldVNode.tag)\n ) {\n const el = oldVNode.el || parent.childNodes[index]\n if (el) {\n parent.replaceChild(createElement(newVNode, getNamespace(parent)), el)\n track('patches')\n }\n return\n }\n\n // Case 5: Text Update - It's a text node, so we just update the text content.\n if (typeof newVNode === 'string' || typeof newVNode === 'number') {\n if (newVNode !== oldVNode) {\n const el = parent.childNodes[index]\n if (el) {\n el.nodeValue = String(newVNode)\n track('patches')\n } else {\n // Self healing: if text node missing, append it\n parent.appendChild(document.createTextNode(String(newVNode)))\n }\n }\n return\n }\n\n // Case 6: Update - Same tag, so we update props and recurse into children.\n const el = oldVNode.el || parent.childNodes[index]\n\n if (!el) return\n\n // Transfer DOM reference to the new VNode\n newVNode.el = el\n\n patchProps(el, newVNode.props, oldVNode.props)\n\n reconcileChildren(el, newVNode.children, oldVNode.children)\n}\n","/**\n * Represents a value wrapped by the persist() function.\n * @template T\n * @typedef {object} Persisted\n * @property {T} initial\n * @property {boolean} __humn_persist\n * @property {PersistConfig} [config]\n */\n\n/**\n * @typedef {object} PersistConfig\n * @property {string} key\n */\n\n/**\n * Marks a section of the state for persistence in localStorage.\n * @template T\n * @param {T} initial\n * @param {PersistConfig} [config]\n * @returns {Persisted<T>}\n */\nexport const persist = (initial, config = {}) => ({\n __humn_persist: true,\n initial,\n config,\n})\n","import { isDev } from './metrics.js'\nimport { getObserver } from './observer.js'\n\n/**\n * Mapped type for the Memory configuration object.\n * Allows each property to be the raw value OR a persisted wrapper.\n * @template T\n * @typedef { { [K in keyof T]: T[K] | import('./persist.js').Persisted<T[K]> } } MemoryInput\n */\n\n/**\n * Deeply unwraps persisted values from the memory shape.\n * @template {object} T\n * @typedef {{ [K in keyof T]: T[K] extends import('./persist.js').Persisted<infer I> ? I : T[K] }} UnwrappedMemory\n */\n\n/**\n * @template T\n * @callback Getter\n * @returns {T}\n */\n\n/**\n * @template T\n * @callback Setter\n * @param {Partial<T> | ((state: T) => void | Partial<T> | unknown)} updater\n * @returns {void}\n */\n\n/**\n * @template M, S\n * @callback SynapsesBuilder\n * @param {Setter<M>} set\n * @param {Getter<M>} get\n * @returns {S}\n */\n\n/**\n * @template M, S\n * @typedef {object} CortexConfig\n * @property {MemoryInput<M>} memory - The initial state configuration\n * @property {SynapsesBuilder<M, S>} synapses - The synapses builder function\n */\n\n/**\n * The Cortex class manages the state of the application.\n *\n * @template {object} MemoryType The shape of the application state\n * @template {object} SynapsesType The shape of the actions/methods\n */\nexport class Cortex {\n /**\n * Creates an instance of Cortex.\n * @param {CortexConfig<MemoryType, SynapsesType>} config\n */\n constructor({ memory, synapses }) {\n const liveMemory = { ...memory }\n this._persistenceMap = new Map()\n\n // Load in any existing values from local-storage\n for (const [key, value] of Object.entries(memory)) {\n if (value && typeof value === 'object' && value.__humn_persist) {\n const storageKey = value.config?.key || key\n this._persistenceMap.set(key, storageKey)\n\n try {\n const stored = localStorage.getItem(storageKey)\n if (stored !== null) {\n liveMemory[key] = JSON.parse(stored)\n } else {\n liveMemory[key] = value.initial\n }\n } catch (err) {\n if (isDev)\n console.warn(`Humn: Failed to load '${key}' from storage.`, err)\n liveMemory[key] = value.initial\n }\n }\n }\n\n /** @type {UnwrappedMemory<MemoryType>} */\n this._memory = liveMemory\n this._listeners = new Map()\n\n /** @type {Getter<UnwrappedMemory<MemoryType>>} */\n const get = () => this._memory\n\n /** @type {Setter<UnwrappedMemory<MemoryType>>} */\n const set = (updater) => {\n let nextState\n let changedPaths = new Set()\n\n if (typeof updater === 'function') {\n const clone = structuredClone(this._memory)\n const proxy = this._createChangeTrackingProxy(clone, changedPaths)\n const result = updater(proxy)\n\n if (result && typeof result === 'object') {\n nextState = { ...this._memory, ...result }\n Object.keys(result).forEach((key) => changedPaths.add(key))\n } else {\n nextState = clone\n }\n } else {\n nextState = { ...this._memory, ...updater }\n changedPaths = new Set(Object.keys(updater))\n }\n\n this._memory = nextState\n\n // Persistence logic\n if (this._persistenceMap.size > 0) {\n this._persistenceMap.forEach((storageKey, stateKey) => {\n const isDirty = Array.from(changedPaths).some(\n (path) => path === stateKey || path.startsWith(stateKey + '.'),\n )\n\n if (isDirty) {\n try {\n const value = this._memory[stateKey]\n localStorage.setItem(storageKey, JSON.stringify(value))\n } catch (err) {\n if (isDev)\n console.error(`Humn: Failed to save '${stateKey}'.`, err)\n }\n }\n })\n }\n\n this._notifyRelevantListeners(changedPaths)\n }\n\n /** @type {SynapsesType} */\n this.synapses = synapses(set, get)\n }\n\n /**\n * Creates a Proxy that tracks which properties are being mutated.\n * Includes a GET trap to recursively proxy nested objects for deep mutation tracking.\n *\n * WHY: We need to know exactly which paths were changed so we can notify ONLY\n * the components that care about those specific paths. If we just knew \"something changed\",\n * we'd have to re-render the whole app (like Redux) or rely on manual optimization.\n */\n _createChangeTrackingProxy(obj, changedPaths, path = '') {\n return new Proxy(obj, {\n get: (target, prop) => {\n if (typeof prop === 'symbol' || prop === '__proto__')\n return target[prop]\n\n const value = target[prop]\n const fullPath = path ? `${path}.${prop}` : prop\n\n // Recursively proxy nested objects so we can trap their sets too\n if (typeof value === 'object' && value !== null) {\n return this._createChangeTrackingProxy(value, changedPaths, fullPath)\n }\n return value\n },\n set: (target, prop, value) => {\n if (typeof prop === 'symbol' || prop === '__proto__') {\n target[prop] = value\n return true\n }\n\n const fullPath = path ? `${path}.${prop}` : prop\n changedPaths.add(fullPath)\n\n target[prop] = value\n return true\n },\n })\n }\n\n /**\n * Only notify listeners that read properties which changed\n */\n _notifyRelevantListeners(changedPaths) {\n this._listeners.forEach((accessedPaths, renderFn) => {\n const shouldNotify = Array.from(accessedPaths).some((accessedPath) => {\n return Array.from(changedPaths).some((changedPath) => {\n // Check for exact match or parent/child relationship\n return (\n accessedPath === changedPath ||\n accessedPath.startsWith(changedPath + '.') ||\n changedPath.startsWith(accessedPath + '.')\n )\n })\n })\n\n if (shouldNotify) renderFn()\n })\n }\n\n /**\n * Creates a Proxy that tracks which properties are accessed during render\n *\n * WHY: This is the other half of the magic. By tracking what a component READS\n * during its render, we build a precise dependency graph. If a component reads\n * `state.user.name`, it will only re-render when `state.user.name` changes,\n * not when `state.count` changes.\n */\n _createAccessTrackingProxy(obj, accessedPaths, path = '') {\n if (typeof obj !== 'object' || obj === null) return obj\n\n return new Proxy(obj, {\n get: (target, prop) => {\n // We don't care about prototype and symbol properties\n if (typeof prop === 'symbol' || prop === '__proto__')\n return target[prop]\n\n const fullPath = path ? `${path}.${prop}` : prop\n accessedPaths.add(fullPath)\n\n const value = target[prop]\n\n // Recursively wrap nested objects\n if (typeof value === 'object' && value !== null)\n return this._createAccessTrackingProxy(value, accessedPaths, fullPath)\n\n return value\n },\n })\n }\n\n /**\n * @returns {UnwrappedMemory<MemoryType>}\n */\n get memory() {\n const currentObserver = getObserver()\n\n if (!currentObserver) return this._memory\n\n if (!this._listeners.has(currentObserver))\n this._listeners.set(currentObserver, new Set())\n\n const accessedPaths = this._listeners.get(currentObserver)\n\n return this._createAccessTrackingProxy(this._memory, accessedPaths)\n }\n}\n","/**\n * @typedef {object} VNode\n * @property {string} tag\n * @property {object} props\n * @property {VNode[]} children\n */\n\n/**\n * Creates a virtual DOM node.\n * This is a hyperscript-like function.\n *\n * @param {string} tag - The tag name of the element.\n * @param {object} props - The properties of the element.\n * @param {VNode[]|VNode} children - The children of the element.\n * @returns {VNode} The virtual DOM node.\n */\nexport const h = (tag, props = {}, children = []) => {\n const childArray = Array.isArray(children) ? children : [children]\n\n // Filter out null/false so we don't have \"ghost\" nodes\n const cleanChildren = childArray\n .flat()\n .filter((c) => c !== null && c !== undefined && c !== false && c !== '')\n\n return {\n tag,\n props,\n children: cleanChildren,\n }\n}\n","/**\n * @file Mounts the application to the DOM.\n * @module mount\n */\nimport { setObserver } from './observer.js'\nimport { patch } from './patch.js'\n\n/**\n * Mounts a component to a target DOM element.\n * @param {HTMLElement} target - The DOM element to mount to.\n * @param {function} Component - The root component function.\n */\nexport const mount = (target, Component) => {\n let prevVNode = null\n\n const lifecycle = () => {\n setObserver(lifecycle)\n\n const nextVNode = {\n tag: Component,\n props: {},\n children: [],\n }\n\n patch(target, nextVNode, prevVNode)\n setObserver(null)\n prevVNode = nextVNode\n }\n\n lifecycle()\n}\n","/**\n * @file Lifecycle hooks for components.\n * @module lifecycle\n */\nimport { getInstance } from './observer.js'\n\n/**\n * Registers a callback to run after the component mounts.\n * @param {function} fn - The callback function.\n */\nexport function onMount(fn) {\n const instance = getInstance()\n if (instance) {\n instance.mounts.push(fn)\n }\n}\n\n/**\n * Registers a callback to run when the component unmounts.\n * @param {function} fn - The callback function.\n */\nexport function onCleanup(fn) {\n const instance = getInstance()\n if (instance) {\n instance.cleanups.push(fn)\n }\n}\n"],"names":["g","f","exports","module","define","amd","globalThis","self","Humn","this","currentObserver","currentInstance","getObserver","setObserver","obs","getInstance","setInstance","inst","styleSheet","cache","Set","getNamespace","parent","namespaceURI","SVG_NS","tagName","MATH_NS","hasKeys","children","some","c","props","key","createElement","vNode","namespace","document","createTextNode","String","tag","childVNode","renderComponent","child","el","hooks","mounts","length","setTimeout","forEach","fn","element","createElementNS","patchProps","childNS","appendChild","newProps","oldProps","allProps","oldValue","newValue","startsWith","eventName","slice","toLowerCase","removeEventListener","addEventListener","disabled","setAttribute","removeAttribute","reconcileChildren","newChildren","oldChildren","maxLen","Math","max","i","patch","keyed","index","newChild","existingChildMatch","oldVNode","domChildAtIndex","childNodes","insertBefore","newElement","Object","values","parentNode","runUnmount","removeChild","cleanups","renderedVNode","newVNode","isNew","replaceChild","nodeValue","Cortex","constructor","memory","synapses","liveMemory","_persistenceMap","Map","value","entries","__humn_persist","storageKey","config","set","stored","localStorage","getItem","JSON","parse","initial","_memory","_listeners","updater","nextState","changedPaths","clone","structuredClone","result","_createChangeTrackingProxy","keys","add","size","stateKey","Array","from","path","setItem","stringify","_notifyRelevantListeners","obj","Proxy","get","target","prop","fullPath","accessedPaths","renderFn","accessedPath","changedPath","_createAccessTrackingProxy","has","css","stringsOrStr","args","raw","isSingleRoot","isArray","reduce","acc","str","content","replace","trim","hash","charCodeAt","toString","hashedClassName","id","head","textContent","h","flat","filter","mount","Component","prevVNode","lifecycle","nextVNode","onCleanup","instance","push","onMount","persist","defineProperty","Symbol","toStringTag"],"mappings":"CAAA,SAAAA,EAAAC,EAAAA,CAAA,OAAAC,SAAA,iBAAAC,OAAA,IAAAF,EAAAC,OAAAA,EAAA,OAAAE,QAAA,YAAAA,OAAAC,IAAAD,OAAA,CAAA,WAAAH,CAAAA,EAAAA,GAAAD,EAAA,OAAAM,WAAA,IAAAA,WAAAN,GAAAO,MAAAC,KAAA,CAAA,CAAA,CAAA,GAAAC,KAAA,SAAAP,EAAAA,CAAA,aAKA,IAAIQ,EAAkB,KAClBC,EAAkB,KAMf,MAAMC,EAAc,IAAMF,EAMpBG,EAAeC,IAC1BJ,EAAkBI,CAAAA,EAOPC,EAAc,IAAMJ,EAMpBK,EAAeC,GAAAA,CAC1BN,EAAkBM,CAAAA,EC5BpB,IAAIC,EAAa,KACjB,MAAMC,EAAQ,IAAIC,ICElB,SAASC,EAAaC,EAAAA,CACpB,OAAIA,EAAOC,eAAiBC,GAAUF,EAAOG,UAAY,gBAChDD,EAELF,EAAOC,eAAiBG,EACnBA,EAEF,IACT,CAOO,SAASC,EAAQC,EAAAA,CACtB,OAAOA,GAAYA,EAASC,KAAMC,GAAMA,GAAKA,EAAEC,OAASD,EAAEC,MAAMC,KAAO,IAAPA,CAClE,CAEA,MAAMR,EAAS,6BACTE,EAAU,qCAOhB,SAASO,EAAcC,EAAOC,EAAAA,CAC5B,GAAqB,OAAVD,GAAU,UAA6B,OAAVA,GAAU,SAChD,OAAOE,SAASC,eAAeC,OAAOJ,CAAAA,CAAAA,EAGxC,GAAyB,OAAdA,EAAMK,KAAQ,WAAY,CACnC,MAAMC,EAAaC,EAAgBP,CAAAA,EACnCA,EAAMQ,MAA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src/observer.js","../src/css.js","../src/runtime/component-lifecycle.js","../src/runtime/element-runtime.js","../src/runtime/event-listeners.js","../src/runtime/interaction-helpers.js","../src/runtime/patch-props.js","../src/runtime/create-element.js","../src/runtime/reconcile-children.js","../src/runtime/patch.js","../src/persist.js","../src/cortex.js","../src/h.js","../src/mount.js","../src/lifecycle.js"],"sourcesContent":["/**\n * @file Observer module for tracking global state during rendering.\n * @module observer\n */\n\nlet currentObserver = null // For Cortex/State dependency\nlet currentInstance = null // For Lifecycle Hooks\n\n/**\n * Gets the current observer (render function).\n * @returns {function|null}\n */\nexport const getObserver = () => currentObserver\n\n/**\n * Sets the current observer.\n * @param {function|null} obs\n */\nexport const setObserver = (obs) => {\n currentObserver = obs\n}\n\n/**\n * Gets the current component instance (hook container).\n * @returns {object|null}\n */\nexport const getInstance = () => currentInstance\n\n/**\n * Sets the current component instance.\n * @param {object|null} inst\n */\nexport const setInstance = (inst) => {\n currentInstance = inst\n}\n","/**\n * @file Runtime Scoped CSS implementation using Native CSS Nesting.\n * @module css\n */\n\nlet styleSheet = null\nconst cache = new Set()\n\n/**\n * Simple DJB2 hashing function.\n */\nfunction hashString(str) {\n let hash = 5381\n let i = str.length\n while (i) {\n hash = (hash * 33) ^ str.charCodeAt(--i)\n }\n return (hash >>> 0).toString(36)\n}\n\n/**\n * Lightweight Runtime Minifier.\n * Removes comments and collapses whitespace.\n * We do not strip spaces around colons/brackets to ensure safety for calc().\n */\nfunction minify(css) {\n return css\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Remove comments\n .replace(/\\s+/g, ' ') // Collapse newlines/tabs to single space\n .trim() // Remove leading/trailing\n}\n\n/**\n * Scoped CSS Tag.\n * Wraps content in a unique class using Native CSS Nesting.\n * Supports two signatures:\n * 1. Tagged Template: css`...`\n * 2. Function: css(string, isSingleRoot)\n */\nexport function css(stringsOrStr, ...args) {\n let raw = ''\n let isSingleRoot = false\n\n // Detect usage of Tagged Template vs Function Call\n if (Array.isArray(stringsOrStr) && stringsOrStr.raw) {\n raw = stringsOrStr.reduce((acc, str, i) => {\n return acc + str + (args[i] || '')\n }, '')\n } else {\n raw = stringsOrStr\n // If called as function, the first arg is our boolean flag\n isSingleRoot = args[0] === true\n }\n let content = minify(raw)\n\n if (!content) return ''\n\n if (isSingleRoot) {\n // Transforms selectors to apply to BOTH the root (using &) AND descendants.\n // e.g. \"div\" -> \"div&, div\"\n\n // Regex Breakdown:\n // 1. (^|[{};,]) -> Hard Start (Line start, brace, semi, comma)\n // 2. (\\s*) -> Whitespace\n // 3. (?!from|to) -> Negative Lookahead: Ignore 'from'/'to' (keyframes)\n // 4. ( ... )+ -> Compound Selector:\n // (?:[.#]?[\\w-]+ ... ) -> Matches tags (div), classes (.class), ids (#id)\n // 5. (?=\\s*\\{) -> Lookahead: Must be followed by {\n\n content = content.replace(\n /(^|[{};,])(\\s*)(?!from|to)((?:[.#]?[\\w-]+|\\[[^\\]]+\\]|:{1,2}[^:,{\\s]+)+)(?=\\s*\\{)/gi,\n '$1$2$3&, $3',\n )\n }\n\n const hash = hashString(content)\n const hashedClassName = `humn-${hash}`\n\n if (cache.has(hash)) {\n return hashedClassName\n }\n\n if (!styleSheet) {\n styleSheet = document.createElement('style')\n styleSheet.id = 'humn-styles'\n document.head.appendChild(styleSheet)\n }\n\n styleSheet.textContent += `.${hashedClassName} { \n ${content} \n }\\n`\n cache.add(hash)\n\n return hashedClassName\n}\n","import { track } from '../metrics.js'\nimport { setInstance } from '../observer.js'\n\nexport function invokeHookSafely(fn, errorMessage) {\n try {\n fn()\n } catch (error) {\n console.error(errorMessage, error)\n }\n}\n\nexport function renderComponent(vNode) {\n track('componentsRendered')\n const hooks = { mounts: [], cleanups: [] }\n setInstance(hooks)\n\n const renderedVNode = vNode.tag(vNode.props)\n\n setInstance(null)\n vNode.hooks = hooks\n return renderedVNode\n}\n\nexport function runUnmount(vNode) {\n if (!vNode) return\n\n if (vNode.hooks?.cleanups)\n vNode.hooks.cleanups.forEach((fn) =>\n invokeHookSafely(fn, 'Error in cleanup hook:'),\n )\n if (vNode.child) runUnmount(vNode.child)\n if (vNode.children) vNode.children.forEach(runUnmount)\n}\n\nexport function scheduleMountHooks(hooks) {\n if (!hooks?.mounts?.length) return\n\n setTimeout(\n () =>\n hooks.mounts.forEach((fn) =>\n invokeHookSafely(fn, 'Error in mount hook:'),\n ),\n 0,\n )\n}\n\nexport function runComponentUpdateHooks({ newHooks, oldHooks }) {\n if (!oldHooks?.cleanups?.length) return\n\n oldHooks.cleanups.forEach((fn) =>\n invokeHookSafely(fn, 'Error in cleanup hook:'),\n )\n scheduleMountHooks(newHooks)\n}\n","const elementRuntime = new WeakMap()\n\nexport function getElementRuntime(element) {\n const existing = elementRuntime.get(element)\n if (existing) return existing\n\n const runtime = {\n asyncPending: new Map(),\n commitLocks: new Map(),\n composition: new Map(),\n debounceTimers: new Map(),\n listeners: new Map(),\n }\n\n elementRuntime.set(element, runtime)\n return runtime\n}\n","import { getElementRuntime } from './element-runtime.js'\n\nconst MODIFIER_FLAGS = new Set([\n 'prevent',\n 'stop',\n 'once',\n 'capture',\n 'passive',\n])\n\nexport function parseEventKey(key) {\n const [eventKey, ...modifierParts] = key.split('|')\n const modifiers = modifierParts.filter((modifier) =>\n MODIFIER_FLAGS.has(modifier),\n )\n\n return { eventKey, modifiers }\n}\n\nexport function addManagedListener({\n element,\n eventName,\n listener,\n options = false,\n propKey,\n}) {\n const { listeners } = getElementRuntime(element)\n\n removeManagedListener(element, propKey)\n element.addEventListener(eventName, listener, options)\n listeners.set(propKey, { eventName, listener, options })\n}\n\nexport function removeManagedListener(element, propKey) {\n const { listeners } = getElementRuntime(element)\n const previous = listeners.get(propKey)\n if (!previous) return\n\n const { eventName, listener, options } = previous\n element.removeEventListener(eventName, listener, options)\n listeners.delete(propKey)\n}\n","import { getElementRuntime } from './element-runtime.js'\nimport { addManagedListener, removeManagedListener } from './event-listeners.js'\n\nconst HELPER_EVENTS = new Set(['onenter', 'onescape', 'onkeys', 'oncommit'])\nconst INTERACTION_LISTENER_KEYS = [\n '__compositionstart',\n '__compositionend',\n '__keyhelper',\n '__oncommitblur',\n]\n\nexport function isInteractionHelperProp(eventKey) {\n return HELPER_EVENTS.has(eventKey)\n}\n\nexport function clearDebouncedInput(element) {\n const { debounceTimers } = getElementRuntime(element)\n const timer = debounceTimers.get('oninputdebounced')\n if (timer) clearTimeout(timer)\n\n debounceTimers.delete('oninputdebounced')\n removeManagedListener(element, 'oninputdebounced')\n}\n\nexport function patchDebouncedInput(element, newProps) {\n if (!newProps.oninputdebounced) {\n clearDebouncedInput(element)\n return\n }\n\n const { debounceTimers } = getElementRuntime(element)\n const debounceMs = Number(newProps.debounce)\n const delay = Number.isFinite(debounceMs) ? debounceMs : 250\n\n const debouncedHandler = (event) => {\n const previous = debounceTimers.get('oninputdebounced')\n if (previous) clearTimeout(previous)\n\n const timer = setTimeout(() => {\n debounceTimers.delete('oninputdebounced')\n newProps.oninputdebounced({\n ...event,\n currentTarget: element,\n target: element,\n })\n }, delay)\n\n debounceTimers.set('oninputdebounced', timer)\n }\n\n addManagedListener({\n element,\n eventName: 'input',\n listener: debouncedHandler,\n propKey: 'oninputdebounced',\n })\n}\n\nexport function patchInteractionHelpers(element, newProps) {\n if (!hasInteractionHelpers(newProps)) {\n removeInteractionHelpers(element)\n return\n }\n\n const runtime = getElementRuntime(element)\n const keyHandler = getKeyHandler({ element, newProps, runtime })\n const blurHandler = getBlurHandler({ newProps, runtime })\n const startComposition = () => runtime.composition.set('active', true)\n const endComposition = () => runtime.composition.set('active', false)\n\n addManagedListener({\n element,\n eventName: 'compositionstart',\n listener: startComposition,\n propKey: '__compositionstart',\n })\n addManagedListener({\n element,\n eventName: 'compositionend',\n listener: endComposition,\n propKey: '__compositionend',\n })\n addManagedListener({\n element,\n eventName: 'keydown',\n listener: keyHandler,\n propKey: '__keyhelper',\n })\n addManagedListener({\n element,\n eventName: 'blur',\n listener: blurHandler,\n propKey: '__oncommitblur',\n })\n}\n\nexport function patchAsyncClick({ element, handler, newProps, propKey }) {\n const { asyncPending } = getElementRuntime(element)\n const wrapped = async (event) => {\n if (newProps.disabledwhilepending && asyncPending.get('click')) return\n\n try {\n asyncPending.set('click', true)\n if (newProps.disabledwhilepending) element.disabled = true\n await handler(event)\n } finally {\n asyncPending.set('click', false)\n if (newProps.disabledwhilepending) element.disabled = false\n }\n }\n\n addManagedListener({\n element,\n eventName: 'click',\n listener: wrapped,\n propKey,\n })\n}\n\nfunction removeInteractionHelpers(element) {\n INTERACTION_LISTENER_KEYS.forEach((key) =>\n removeManagedListener(element, key),\n )\n}\n\nfunction hasInteractionHelpers(props) {\n return Boolean(\n props.onenter || props.onescape || props.onkeys || props.oncommit,\n )\n}\n\nfunction getKeyHandler({ element, newProps, runtime }) {\n return (event) => {\n const composing = runtime.composition.get('active') === true\n if (shouldIgnoreKeyboardEvent(event, composing)) return\n\n const combo = getEventCombo(event)\n\n if (event.key === 'Enter' && newProps.onenter) newProps.onenter(event)\n if (event.key === 'Escape' && newProps.onescape) newProps.onescape(event)\n if (newProps.onkeys) runMatchingKeyHandlers(event, combo, newProps.onkeys)\n\n if (event.key !== 'Enter' || !newProps.oncommit) return\n\n runtime.commitLocks.set('enter', true)\n newProps.oncommit(event)\n setTimeout(() => runtime.commitLocks.delete('enter'), 0)\n }\n}\n\nfunction getBlurHandler({ newProps, runtime }) {\n return (event) => {\n if (!newProps.oncommit) return\n if (runtime.commitLocks.get('enter')) return\n\n newProps.oncommit(event)\n }\n}\n\nfunction runMatchingKeyHandlers(event, combo, handlers) {\n Object.entries(handlers).forEach(([keyCombo, handler]) => {\n if (normalizeKeyCombo(keyCombo) === combo) handler(event)\n })\n}\n\nfunction getEventCombo(event) {\n const comboParts = []\n if (event.ctrlKey) comboParts.push('ctrl')\n if (event.metaKey) comboParts.push('meta')\n if (event.altKey) comboParts.push('alt')\n if (event.shiftKey) comboParts.push('shift')\n\n comboParts.push(event.key.toLowerCase())\n return comboParts.sort().join('+')\n}\n\nfunction normalizeKeyCombo(combo = '') {\n return combo\n .split('+')\n .map((part) => part.trim().toLowerCase())\n .filter(Boolean)\n .map((part) => getNormalizedModifier(part))\n .sort()\n .join('+')\n}\n\nfunction getNormalizedModifier(part) {\n if (part !== 'mod') return part\n\n return navigator.platform.includes('Mac') ? 'meta' : 'ctrl'\n}\n\nfunction shouldIgnoreKeyboardEvent(event, compositionState) {\n return event.isComposing || compositionState === true\n}\n","import { track } from '../metrics.js'\nimport {\n addManagedListener,\n parseEventKey,\n removeManagedListener,\n} from './event-listeners.js'\nimport {\n clearDebouncedInput,\n isInteractionHelperProp,\n patchAsyncClick,\n patchDebouncedInput,\n patchInteractionHelpers,\n} from './interaction-helpers.js'\n\nexport function patchProps(element, newProps = {}, oldProps = {}) {\n if (!element) return\n\n const allProps = { ...oldProps, ...newProps }\n for (const key in allProps) {\n patchProp({ element, key, newProps, oldProps })\n }\n\n patchDebouncedInput(element, newProps)\n patchInteractionHelpers(element, newProps)\n}\n\nfunction patchProp({ element, key, newProps, oldProps }) {\n const oldValue = oldProps[key]\n const newValue = newProps[key]\n\n if (newValue === undefined || newValue === null) {\n removeProp({ element, key })\n return\n }\n\n // Avoid resetting browser-managed input state, such as cursor position.\n if (key === 'value' || key === 'checked') {\n patchLiveDomProp({ element, key, value: newValue })\n return\n }\n\n if (oldValue === newValue && key !== 'onclickasync') return\n\n track('patches')\n if (key.startsWith('on')) {\n patchEventProp({ element, handler: newValue, key, newProps })\n return\n }\n\n if (key === 'debounce') return\n if (key === 'disabled') {\n element.disabled = newValue === true || newValue === 'true'\n return\n }\n\n element.setAttribute(key, newValue)\n}\n\nfunction removeProp({ element, key }) {\n if (key.startsWith('on')) removeManagedListener(element, key)\n if (key === 'oninputdebounced') clearDebouncedInput(element)\n\n element.removeAttribute(key)\n track('patches')\n}\n\nfunction patchLiveDomProp({ element, key, value }) {\n if (element[key] === value) return\n\n element[key] = value\n track('patches')\n}\n\nfunction patchEventProp({ element, handler, key, newProps }) {\n const { eventKey, modifiers } = parseEventKey(key)\n const eventName = eventKey.slice(2).toLowerCase()\n\n if (isInteractionHelperProp(eventKey)) return\n if (eventKey === 'oninputdebounced') return\n\n if (eventKey === 'onclickasync') {\n patchAsyncClick({ element, handler, newProps, propKey: key })\n return\n }\n\n const listener = (event) => {\n if (modifiers.includes('prevent')) event.preventDefault()\n if (modifiers.includes('stop')) event.stopPropagation()\n return handler(event)\n }\n\n addManagedListener({\n element,\n eventName,\n listener,\n options: {\n capture: modifiers.includes('capture'),\n once: modifiers.includes('once'),\n passive: modifiers.includes('passive'),\n },\n propKey: key,\n })\n}\n","import { track } from '../metrics.js'\nimport { patchProps } from './patch-props.js'\nimport { renderComponent, scheduleMountHooks } from './component-lifecycle.js'\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\nconst MATH_NS = 'http://www.w3.org/1998/Math/MathML'\n\nexport function getNamespace(parent) {\n if (parent.namespaceURI === SVG_NS && parent.tagName !== 'foreignObject') {\n return SVG_NS\n }\n if (parent.namespaceURI === MATH_NS) {\n return MATH_NS\n }\n return null\n}\n\nexport function createElement(vNode, namespace) {\n if (typeof vNode === 'string' || typeof vNode === 'number') {\n return document.createTextNode(String(vNode))\n }\n\n if (typeof vNode.tag === 'function')\n return createComponentElement(vNode, namespace)\n\n track('elementsCreated')\n const tag = vNode.tag\n const elementNamespace = getElementNamespace(tag, namespace)\n const element = elementNamespace\n ? document.createElementNS(elementNamespace, tag)\n : document.createElement(tag)\n\n vNode.el = element\n patchProps(element, vNode.props)\n appendChildren({ element, namespace: elementNamespace, tag, vNode })\n return element\n}\n\nfunction createComponentElement(vNode, namespace) {\n const childVNode = renderComponent(vNode)\n const element = createElement(childVNode, namespace)\n\n vNode.child = childVNode\n vNode.el = element\n scheduleMountHooks(vNode.hooks)\n\n return element\n}\n\nfunction appendChildren({ element, namespace, tag, vNode }) {\n // Children of SVG foreignObject must return to the HTML namespace.\n const childNamespace = tag === 'foreignObject' ? null : namespace\n\n vNode.children.forEach((child) => {\n element.appendChild(createElement(child, childNamespace))\n })\n}\n\nfunction getElementNamespace(tag, namespace) {\n // A nested <svg> or <math> starts a fresh namespace regardless of its parent.\n if (tag === 'svg') return SVG_NS\n if (tag === 'math') return MATH_NS\n\n // createElementNS is slower than createElement, so only use it when needed.\n return namespace\n}\n","import { createElement, getNamespace } from './create-element.js'\nimport { track } from '../metrics.js'\n\nexport function hasKeys(children) {\n return children && children.some((child) => child?.props?.key != null)\n}\n\nexport function reconcileChildren({\n oldChildren,\n newChildren,\n parent,\n patchNode,\n runUnmount,\n}) {\n // Unkeyed children are cheap to patch by index; keyed children preserve DOM\n // identity across reorders so state and focus do not move to the wrong item.\n const isKeyed = hasKeys(newChildren) || hasKeys(oldChildren)\n if (isKeyed) {\n reconcileKeyedChildren({\n oldChildren,\n newChildren,\n parent,\n patchNode,\n runUnmount,\n })\n return\n }\n\n reconcileUnkeyedChildren({ oldChildren, newChildren, parent, patchNode })\n}\n\nfunction reconcileUnkeyedChildren({\n oldChildren,\n newChildren,\n parent,\n patchNode,\n}) {\n const maxLength = Math.max(newChildren.length, oldChildren.length)\n for (let index = 0; index < maxLength; index++) {\n patchNode(parent, newChildren[index], oldChildren[index], index)\n }\n}\n\nfunction reconcileKeyedChildren({\n oldChildren,\n newChildren,\n parent,\n patchNode,\n runUnmount,\n}) {\n const keyedChildren = getKeyedChildren(oldChildren)\n\n newChildren.forEach((newChild, index) => {\n const key = getChildKey(newChild, index)\n const existingChild = keyedChildren[key]\n\n if (existingChild) {\n patchExistingKeyedChild({\n existingChild,\n index,\n newChild,\n parent,\n patchNode,\n })\n delete keyedChildren[key]\n return\n }\n\n insertNewKeyedChild({ index, newChild, parent })\n })\n\n removeStaleKeyedChildren({ keyedChildren, parent, runUnmount })\n}\n\nfunction getKeyedChildren(children) {\n const keyedChildren = {}\n\n children.forEach((child, index) => {\n const key = getChildKey(child, index)\n keyedChildren[key] = { index, vNode: child }\n })\n\n return keyedChildren\n}\n\nfunction getChildKey(child, fallback) {\n return child?.props?.key != null ? child.props.key : fallback\n}\n\nfunction patchExistingKeyedChild({\n existingChild,\n index,\n newChild,\n parent,\n patchNode,\n}) {\n const oldVNode = existingChild.vNode\n patchNode(parent, newChild, oldVNode, index)\n\n const element = newChild.el || oldVNode.el\n const domChildAtIndex = parent.childNodes[index]\n if (element && domChildAtIndex !== element) {\n parent.insertBefore(element, domChildAtIndex)\n track('patches')\n }\n}\n\nfunction insertNewKeyedChild({ index, newChild, parent }) {\n const newElement = createElement(newChild, getNamespace(parent))\n const domChildAtIndex = parent.childNodes[index]\n\n if (domChildAtIndex) {\n parent.insertBefore(newElement, domChildAtIndex)\n return\n }\n\n parent.appendChild(newElement)\n}\n\nfunction removeStaleKeyedChildren({ keyedChildren, parent, runUnmount }) {\n Object.values(keyedChildren).forEach(({ vNode }) => {\n if (!vNode.el || vNode.el.parentNode !== parent) return\n\n runUnmount(vNode)\n parent.removeChild(vNode.el)\n track('elementsRemoved')\n })\n}\n","import {\n renderComponent,\n runComponentUpdateHooks,\n runUnmount,\n scheduleMountHooks,\n} from './component-lifecycle.js'\nimport { createElement, getNamespace } from './create-element.js'\nimport { track } from '../metrics.js'\nimport { patchProps } from './patch-props.js'\nimport { hasKeys, reconcileChildren } from './reconcile-children.js'\n\nexport { hasKeys }\n\nexport function patch(parent, newVNode, oldVNode, index = 0) {\n track('diffs')\n\n // Removal must clean up recursively so component hooks cannot leak.\n if (newVNode === undefined || newVNode === null) {\n const el = oldVNode.el || parent.childNodes[index]\n runUnmount(oldVNode)\n if (el) {\n parent.removeChild(el)\n track('elementsRemoved')\n }\n return\n }\n\n if (typeof newVNode.tag === 'function') {\n const isNew = !oldVNode\n const childVNode = renderComponent(newVNode)\n newVNode.child = childVNode\n const oldChild = oldVNode ? oldVNode.child : undefined\n patch(parent, childVNode, oldChild, index)\n newVNode.el = childVNode.el\n if (isNew) scheduleMountHooks(newVNode.hooks)\n if (!isNew)\n runComponentUpdateHooks({\n newHooks: newVNode.hooks,\n oldHooks: oldVNode.hooks,\n })\n return\n }\n\n if (oldVNode === undefined || oldVNode === null) {\n parent.appendChild(createElement(newVNode, getNamespace(parent)))\n return\n }\n\n // Different node types cannot be safely patched in place.\n if (\n typeof newVNode !== typeof oldVNode ||\n (typeof newVNode !== 'string' && newVNode.tag !== oldVNode.tag)\n ) {\n const el = oldVNode.el || parent.childNodes[index]\n if (el) {\n parent.replaceChild(createElement(newVNode, getNamespace(parent)), el)\n track('patches')\n }\n return\n }\n\n if (typeof newVNode === 'string' || typeof newVNode === 'number') {\n if (newVNode !== oldVNode) {\n const el = parent.childNodes[index]\n if (el) {\n el.nodeValue = String(newVNode)\n track('patches')\n } else parent.appendChild(document.createTextNode(String(newVNode)))\n }\n return\n }\n\n const el = oldVNode.el || parent.childNodes[index]\n if (!el) return\n newVNode.el = el\n patchProps(el, newVNode.props, oldVNode.props)\n reconcileChildren({\n oldChildren: oldVNode.children,\n newChildren: newVNode.children,\n parent: el,\n patchNode: patch,\n runUnmount,\n })\n}\n","/**\n * Represents a value wrapped by the persist() function.\n * @template T\n * @typedef {object} Persisted\n * @property {T} initial\n * @property {boolean} __humn_persist\n * @property {PersistConfig} [config]\n */\n\n/**\n * @typedef {object} PersistConfig\n * @property {string} key\n */\n\n/**\n * Marks a section of the state for persistence in localStorage.\n * @template T\n * @param {T} initial\n * @param {PersistConfig} [config]\n * @returns {Persisted<T>}\n */\nexport const persist = (initial, config = {}) => ({\n __humn_persist: true,\n initial,\n config,\n})\n","import { isDev } from './metrics.js'\nimport { getObserver } from './observer.js'\n\n/**\n * Mapped type for the Memory configuration object.\n * Allows each property to be the raw value OR a persisted wrapper.\n * @template T\n * @typedef { { [K in keyof T]: T[K] | import('./persist.js').Persisted<T[K]> } } MemoryInput\n */\n\n/**\n * Deeply unwraps persisted values from the memory shape.\n * @template {object} T\n * @typedef {{ [K in keyof T]: T[K] extends import('./persist.js').Persisted<infer I> ? I : T[K] }} UnwrappedMemory\n */\n\n/**\n * @template T\n * @callback Getter\n * @returns {T}\n */\n\n/**\n * @template T\n * @callback Setter\n * @param {Partial<T> | ((state: T) => void | Partial<T> | unknown)} updater\n * @returns {void}\n */\n\n/**\n * @template M, S\n * @callback SynapsesBuilder\n * @param {Setter<M>} set\n * @param {Getter<M>} get\n * @returns {S}\n */\n\n/**\n * @template M, S\n * @typedef {object} CortexConfig\n * @property {MemoryInput<M>} memory - The initial state configuration\n * @property {SynapsesBuilder<M, S>} synapses - The synapses builder function\n */\n\n/**\n * The Cortex class manages the state of the application.\n *\n * @template {object} MemoryType The shape of the application state\n * @template {object} SynapsesType The shape of the actions/methods\n */\nexport class Cortex {\n /**\n * Creates an instance of Cortex.\n * @param {CortexConfig<MemoryType, SynapsesType>} config\n */\n constructor({ memory, synapses }) {\n const liveMemory = { ...memory }\n this._persistenceMap = new Map()\n\n // Load in any existing values from local-storage\n for (const [key, value] of Object.entries(memory)) {\n if (value && typeof value === 'object' && value.__humn_persist) {\n const storageKey = value.config?.key || key\n this._persistenceMap.set(key, storageKey)\n\n try {\n const stored = localStorage.getItem(storageKey)\n if (stored !== null) {\n liveMemory[key] = JSON.parse(stored)\n } else {\n liveMemory[key] = value.initial\n }\n } catch (err) {\n if (isDev)\n console.warn(`Humn: Failed to load '${key}' from storage.`, err)\n liveMemory[key] = value.initial\n }\n }\n }\n\n /** @type {UnwrappedMemory<MemoryType>} */\n this._memory = liveMemory\n this._listeners = new Map()\n\n /** @type {Getter<UnwrappedMemory<MemoryType>>} */\n const get = () => this._memory\n\n /** @type {Setter<UnwrappedMemory<MemoryType>>} */\n const set = (updater) => {\n let nextState\n let changedPaths = new Set()\n\n if (typeof updater === 'function') {\n const clone = structuredClone(this._memory)\n const proxy = this._createChangeTrackingProxy(clone, changedPaths)\n const result = updater(proxy)\n\n if (result && typeof result === 'object') {\n nextState = { ...this._memory, ...result }\n Object.keys(result).forEach((key) => changedPaths.add(key))\n } else {\n nextState = clone\n }\n } else {\n nextState = { ...this._memory, ...updater }\n changedPaths = new Set(Object.keys(updater))\n }\n\n this._memory = nextState\n\n // Persistence logic\n if (this._persistenceMap.size > 0) {\n this._persistenceMap.forEach((storageKey, stateKey) => {\n const isDirty = Array.from(changedPaths).some(\n (path) => path === stateKey || path.startsWith(stateKey + '.'),\n )\n\n if (isDirty) {\n try {\n const value = this._memory[stateKey]\n localStorage.setItem(storageKey, JSON.stringify(value))\n } catch (err) {\n if (isDev)\n console.error(`Humn: Failed to save '${stateKey}'.`, err)\n }\n }\n })\n }\n\n this._notifyRelevantListeners(changedPaths)\n }\n\n /** @type {SynapsesType} */\n this.synapses = synapses(set, get)\n }\n\n /**\n * Creates a Proxy that tracks which properties are being mutated.\n * Includes a GET trap to recursively proxy nested objects for deep mutation tracking.\n *\n * WHY: We need to know exactly which paths were changed so we can notify ONLY\n * the components that care about those specific paths. If we just knew \"something changed\",\n * we'd have to re-render the whole app (like Redux) or rely on manual optimization.\n */\n _createChangeTrackingProxy(obj, changedPaths, path = '') {\n return new Proxy(obj, {\n get: (target, prop) => {\n if (typeof prop === 'symbol' || prop === '__proto__')\n return target[prop]\n\n const value = target[prop]\n const fullPath = path ? `${path}.${prop}` : prop\n\n // Recursively proxy nested objects so we can trap their sets too\n if (typeof value === 'object' && value !== null) {\n return this._createChangeTrackingProxy(value, changedPaths, fullPath)\n }\n return value\n },\n set: (target, prop, value) => {\n if (typeof prop === 'symbol' || prop === '__proto__') {\n target[prop] = value\n return true\n }\n\n const fullPath = path ? `${path}.${prop}` : prop\n changedPaths.add(fullPath)\n\n target[prop] = value\n return true\n },\n })\n }\n\n /**\n * Only notify listeners that read properties which changed\n */\n _notifyRelevantListeners(changedPaths) {\n this._listeners.forEach((accessedPaths, renderFn) => {\n const shouldNotify = Array.from(accessedPaths).some((accessedPath) => {\n return Array.from(changedPaths).some((changedPath) => {\n // Check for exact match or parent/child relationship\n return (\n accessedPath === changedPath ||\n accessedPath.startsWith(changedPath + '.') ||\n changedPath.startsWith(accessedPath + '.')\n )\n })\n })\n\n if (shouldNotify) renderFn()\n })\n }\n\n /**\n * Creates a Proxy that tracks which properties are accessed during render\n *\n * WHY: This is the other half of the magic. By tracking what a component READS\n * during its render, we build a precise dependency graph. If a component reads\n * `state.user.name`, it will only re-render when `state.user.name` changes,\n * not when `state.count` changes.\n */\n _createAccessTrackingProxy(obj, accessedPaths, path = '') {\n if (typeof obj !== 'object' || obj === null) return obj\n\n return new Proxy(obj, {\n get: (target, prop) => {\n // We don't care about prototype and symbol properties\n if (typeof prop === 'symbol' || prop === '__proto__')\n return target[prop]\n\n const fullPath = path ? `${path}.${prop}` : prop\n accessedPaths.add(fullPath)\n\n const value = target[prop]\n\n // Recursively wrap nested objects\n if (typeof value === 'object' && value !== null)\n return this._createAccessTrackingProxy(value, accessedPaths, fullPath)\n\n return value\n },\n })\n }\n\n /**\n * @returns {UnwrappedMemory<MemoryType>}\n */\n get memory() {\n const currentObserver = getObserver()\n\n if (!currentObserver) return this._memory\n\n if (!this._listeners.has(currentObserver))\n this._listeners.set(currentObserver, new Set())\n\n const accessedPaths = this._listeners.get(currentObserver)\n\n return this._createAccessTrackingProxy(this._memory, accessedPaths)\n }\n}\n","/**\n * @typedef {object} VNode\n * @property {string} tag\n * @property {object} props\n * @property {VNode[]} children\n */\n\n/**\n * Creates a virtual DOM node.\n * This is a hyperscript-like function.\n *\n * @param {string} tag - The tag name of the element.\n * @param {object} props - The properties of the element.\n * @param {VNode[]|VNode} children - The children of the element.\n * @returns {VNode} The virtual DOM node.\n */\nexport const h = (tag, props = {}, children = []) => {\n const childArray = Array.isArray(children) ? children : [children]\n\n // Filter out null/false so we don't have \"ghost\" nodes\n const cleanChildren = childArray\n .flat()\n .filter((c) => c !== null && c !== undefined && c !== false && c !== '')\n\n return {\n tag,\n props,\n children: cleanChildren,\n }\n}\n","/**\n * @file Mounts the application to the DOM.\n * @module mount\n */\nimport { setObserver } from './observer.js'\nimport { patch } from './runtime/patch.js'\n\n/**\n * Mounts a component to a target DOM element.\n * @param {HTMLElement} target - The DOM element to mount to.\n * @param {function} Component - The root component function.\n */\nexport const mount = (target, Component) => {\n let prevVNode = null\n\n const lifecycle = () => {\n setObserver(lifecycle)\n\n const nextVNode = {\n tag: Component,\n props: {},\n children: [],\n }\n\n patch(target, nextVNode, prevVNode)\n setObserver(null)\n prevVNode = nextVNode\n }\n\n lifecycle()\n}\n","/**\n * @file Lifecycle hooks for components.\n * @module lifecycle\n */\nimport { getInstance } from './observer.js'\n\n/**\n * Registers a callback to run after the component mounts.\n * @param {function} fn - The callback function.\n */\nexport function onMount(fn) {\n const instance = getInstance()\n if (instance) {\n instance.mounts.push(fn)\n }\n}\n\n/**\n * Registers a callback to run when the component unmounts.\n * @param {function} fn - The callback function.\n */\nexport function onCleanup(fn) {\n const instance = getInstance()\n if (instance) {\n instance.cleanups.push(fn)\n }\n}\n"],"names":["g","f","exports","module","define","amd","globalThis","self","Humn","this","currentObserver","currentInstance","getObserver","setObserver","obs","getInstance","setInstance","inst","styleSheet","cache","Set","invokeHookSafely","fn","errorMessage","error","renderComponent","vNode","hooks","mounts","cleanups","renderedVNode","tag","props","runUnmount","forEach","child","children","scheduleMountHooks","length","setTimeout","elementRuntime","WeakMap","getElementRuntime","element","existing","get","runtime","asyncPending","Map","commitLocks","composition","debounceTimers","listeners","set","MODIFIER_FLAGS","addManagedListener","eventName","listener","options","propKey","removeManagedListener","addEventListener","previous","removeEventListener","delete","HELPER_EVENTS","INTERACTION_LISTENER_KEYS","clearDebouncedInput","timer","clearTimeout","patchInteractionHelpers","newProps","onenter","onescape","onkeys","oncommit","key","keyHandler","event","compositionState","isComposing","combo","comboParts","ctrlKey","push","metaKey","altKey","shiftKey","toLowerCase","sort","join","handlers","Object","entries","keyCombo","handler","split","map","part","trim","filter","Boolean","navigator","platform","includes","blurHandler","patchProps","oldProps","allProps","patchProp","oninputdebounced","debounceMs","Number","debounce","delay","isFinite","currentTarget","target","oldValue","newValue","startsWith","eventKey","modifiers","modifierParts","modifier","has","slice","async","disabledwhilepending","disabled","preventDefault","stopPropagation","capture","once","passive","setAttribute","value","removeAttribute","SVG_NS","MATH_NS","getNamespace","parent","namespaceURI","tagName","createElement","namespace","document","createTextNode","String","childVNode","el","elementNamespace","createElementNS","childNamespace","appendChild","hasKeys","some","reconcileChildren","oldChildren","newChildren","patchNode","keyedChildren","index","getChildKey","newChild","existingChild","oldVNode","domChildAtIndex","childNodes","insertBefore","newElement","values","parentNode","removeChild","maxLength","Math","max","fallback","patch","newVNode","isNew","newHooks","oldHooks","replaceChild","nodeValue","Cortex","constructor","memory","synapses","liveMemory","_persistenceMap","__humn_persist","storageKey","config","stored","localStorage","getItem","JSON","parse","initial","err","_memory","_listeners","updater","nextState","changedPaths","clone","structuredClone","result","_createChangeTrackingProxy","keys","add","size","stateKey","Array","from","path","setItem","stringify","_notifyRelevantListeners","obj","Proxy","prop","fullPath","accessedPaths","renderFn","accessedPath","changedPath","_createAccessTrackingProxy","css","stringsOrStr","args","raw","isSingleRoot","isArray","reduce","acc","str","i","content","replace","hash","charCodeAt","toString","hashedClassName","id","head","textContent","h","flat","c","mount","Component","prevVNode","lifecycle","nextVNode","onCleanup","instance","onMount","persist","defineProperty","Symbol","toStringTag"],"mappings":"CAAA,SAAAA,EAAAC,EAAAA,CAAA,OAAAC,SAAA,UAAA,OAAAC,OAAA,IAAAF,EAAAC,OAAAA,EAAA,OAAAE,QAAA,YAAAA,OAAAC,IAAAD,OAAA,CAAA,SAAA,EAAAH,CAAAA,EAAAA,GAAAD,EAAA,OAAAM,WAAA,IAAAA,WAAAN,GAAAO,MAAAC,KAAA,CAAA,CAAA,CAAA,GAAAC,KAAA,SAAAP,EAAAA,CAAA,aAKA,IAAIQ,EAAkB,KAClBC,EAAkB,KAMf,MAAMC,EAAc,IAAMF,EAMpBG,EAAeC,GAAAA,CAC1BJ,EAAkBI,CAAAA,EAOPC,EAAc,IAAMJ,EAMpBK,EAAeC,GAAAA,CAC1BN,EAAkBM,CAAAA,EC5BpB,IAAIC,EAAa,KACjB,MAAMC,EAAQ,IAAIC,ICHX,SAASC,EAAiBC,EAA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