humn 1.3.2 → 1.3.3

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 CHANGED
@@ -1,211 +1,219 @@
1
- let C = null, x = null;
2
- const S = () => C, g = (e) => {
3
- C = e;
4
- }, E = () => x, k = (e) => {
5
- x = e;
1
+ let N = null, x = null;
2
+ const M = () => N, b = (t) => {
3
+ N = t;
4
+ }, S = () => x, w = (t) => {
5
+ x = t;
6
6
  };
7
- class w {
8
- constructor({ memory: t, synapses: o }) {
9
- const i = { ...t };
7
+ class T {
8
+ constructor({ memory: e, synapses: n }) {
9
+ const o = { ...e };
10
10
  this._persistenceMap = /* @__PURE__ */ new Map();
11
- for (const [s, r] of Object.entries(t)) if (r && r.__humn_persist) {
12
- const c = r.config.key || s;
13
- this._persistenceMap.set(s, c);
11
+ for (const [r, s] of Object.entries(e)) if (s && s.__humn_persist) {
12
+ const c = s.config.key || r;
13
+ this._persistenceMap.set(r, c);
14
14
  try {
15
- const n = localStorage.getItem(c);
16
- i[s] = n !== null ? JSON.parse(n) : r.initial;
15
+ const i = localStorage.getItem(c);
16
+ o[r] = i !== null ? JSON.parse(i) : s.initial;
17
17
  } catch {
18
- i[s] = r.initial;
18
+ o[r] = s.initial;
19
19
  }
20
20
  }
21
- this._memory = i, this._listeners = /* @__PURE__ */ new Map(), this.synapses = o((s) => {
22
- let r, c = /* @__PURE__ */ new Set();
23
- if (typeof s == "function") {
24
- const n = structuredClone(this._memory), l = s(this._createChangeTrackingProxy(n, c));
25
- l && typeof l == "object" ? (r = { ...this._memory, ...l }, Object.keys(l).forEach((a) => c.add(a))) : r = n;
26
- } else r = { ...this._memory, ...s }, c = new Set(Object.keys(s));
27
- this._memory = r, this._persistenceMap.size > 0 && this._persistenceMap.forEach((n, l) => {
21
+ this._memory = o, this._listeners = /* @__PURE__ */ new Map(), this.synapses = n((r) => {
22
+ let s, c = /* @__PURE__ */ new Set();
23
+ if (typeof r == "function") {
24
+ const i = structuredClone(this._memory), l = r(this._createChangeTrackingProxy(i, c));
25
+ l && typeof l == "object" ? (s = { ...this._memory, ...l }, Object.keys(l).forEach((a) => c.add(a))) : s = i;
26
+ } else s = { ...this._memory, ...r }, c = new Set(Object.keys(r));
27
+ this._memory = s, this._persistenceMap.size > 0 && this._persistenceMap.forEach((i, l) => {
28
28
  if (Array.from(c).some((a) => a === l || a.startsWith(l + "."))) try {
29
29
  const a = this._memory[l];
30
- localStorage.setItem(n, JSON.stringify(a));
30
+ localStorage.setItem(i, JSON.stringify(a));
31
31
  } catch {
32
32
  }
33
33
  }), this._notifyRelevantListeners(c);
34
34
  }, () => this._memory);
35
35
  }
36
- _createChangeTrackingProxy(t, o, i = "") {
37
- return new Proxy(t, { get: (s, r) => {
38
- if (typeof r == "symbol" || r === "__proto__") return s[r];
39
- const c = s[r], n = i ? `${i}.${r}` : r;
40
- return typeof c == "object" && c !== null ? this._createChangeTrackingProxy(c, o, n) : c;
41
- }, set: (s, r, c) => {
42
- if (typeof r == "symbol" || r === "__proto__") return s[r] = c, !0;
43
- const n = i ? `${i}.${r}` : r;
44
- return o.add(n), s[r] = c, !0;
36
+ _createChangeTrackingProxy(e, n, o = "") {
37
+ return new Proxy(e, { get: (r, s) => {
38
+ if (typeof s == "symbol" || s === "__proto__") return r[s];
39
+ const c = r[s], i = o ? `${o}.${s}` : s;
40
+ return typeof c == "object" && c !== null ? this._createChangeTrackingProxy(c, n, i) : c;
41
+ }, set: (r, s, c) => {
42
+ if (typeof s == "symbol" || s === "__proto__") return r[s] = c, !0;
43
+ const i = o ? `${o}.${s}` : s;
44
+ return n.add(i), r[s] = c, !0;
45
45
  } });
46
46
  }
47
- _notifyRelevantListeners(t) {
48
- this._listeners.forEach((o, i) => {
49
- Array.from(o).some((s) => Array.from(t).some((r) => s === r || s.startsWith(r + ".") || r.startsWith(s + "."))) && i();
47
+ _notifyRelevantListeners(e) {
48
+ this._listeners.forEach((n, o) => {
49
+ Array.from(n).some((r) => Array.from(e).some((s) => r === s || r.startsWith(s + ".") || s.startsWith(r + "."))) && o();
50
50
  });
51
51
  }
52
- _createAccessTrackingProxy(t, o, i = "") {
53
- return typeof t != "object" || t === null ? t : new Proxy(t, { get: (s, r) => {
54
- if (typeof r == "symbol" || r === "__proto__") return s[r];
55
- const c = i ? `${i}.${r}` : r;
56
- o.add(c);
57
- const n = s[r];
58
- return typeof n == "object" && n !== null ? this._createAccessTrackingProxy(n, o, c) : n;
52
+ _createAccessTrackingProxy(e, n, o = "") {
53
+ return typeof e != "object" || e === null ? e : new Proxy(e, { get: (r, s) => {
54
+ if (typeof s == "symbol" || s === "__proto__") return r[s];
55
+ const c = o ? `${o}.${s}` : s;
56
+ n.add(c);
57
+ const i = r[s];
58
+ return typeof i == "object" && i !== null ? this._createAccessTrackingProxy(i, n, c) : i;
59
59
  } });
60
60
  }
61
61
  get memory() {
62
- const t = S();
63
- if (!t) return this._memory;
64
- this._listeners.has(t) || this._listeners.set(t, /* @__PURE__ */ new Set());
65
- const o = this._listeners.get(t);
66
- return o.clear(), this._createAccessTrackingProxy(this._memory, o);
62
+ const e = M();
63
+ if (!e) return this._memory;
64
+ this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
65
+ const n = this._listeners.get(e);
66
+ return n.clear(), this._createAccessTrackingProxy(this._memory, n);
67
67
  }
68
68
  }
69
69
  let p = null;
70
- const v = /* @__PURE__ */ new Set();
71
- function T(e, ...t) {
72
- let o = "", i = !1;
73
- Array.isArray(e) && e.raw ? o = e.reduce((n, l, a) => n + l + (t[a] || ""), "") : (o = e, i = t[0] === !0);
74
- let s = (function(n) {
75
- return n.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").trim();
76
- })(o);
77
- if (!s) return "";
78
- i && (s = s.replace(/(^|[{};,])(\s*)(?!from|to)((?:[.#]?[\w-]+|\[[^\]]+\]|:{1,2}[^:,{\s]+)+)(?=\s*\{)/gi, "$1$2$3&, $3"));
79
- const r = (function(n) {
80
- let l = 5381, a = n.length;
81
- for (; a; ) l = 33 * l ^ n.charCodeAt(--a);
70
+ const C = /* @__PURE__ */ new Set();
71
+ function O(t, ...e) {
72
+ let n = "", o = !1;
73
+ Array.isArray(t) && t.raw ? n = t.reduce((i, l, a) => i + l + (e[a] || ""), "") : (n = t, o = e[0] === !0);
74
+ let r = (function(i) {
75
+ return i.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").trim();
76
+ })(n);
77
+ if (!r) return "";
78
+ o && (r = r.replace(/(^|[{};,])(\s*)(?!from|to)((?:[.#]?[\w-]+|\[[^\]]+\]|:{1,2}[^:,{\s]+)+)(?=\s*\{)/gi, "$1$2$3&, $3"));
79
+ const s = (function(i) {
80
+ let l = 5381, a = i.length;
81
+ for (; a; ) l = 33 * l ^ i.charCodeAt(--a);
82
82
  return (l >>> 0).toString(36);
83
- })(s), c = `humn-${r}`;
84
- return v.has(r) || (p || (p = document.createElement("style"), p.id = "humn-styles", document.head.appendChild(p)), p.textContent += `.${c} {
85
- ${s}
83
+ })(r), c = `humn-${s}`;
84
+ return C.has(s) || (p || (p = document.createElement("style"), p.id = "humn-styles", document.head.appendChild(p)), p.textContent += `.${c} {
85
+ ${r}
86
86
  }
87
- `, v.add(r)), c;
87
+ `, C.add(s)), c;
88
88
  }
89
- const j = (e, t = {}, o = []) => ({ tag: e, props: t, children: (Array.isArray(o) ? o : [o]).flat().filter((i) => i != null && i !== !1 && i !== "") });
90
- function M(e) {
91
- const t = E();
92
- t && t.mounts.push(e);
89
+ const P = (t, e = {}, n = []) => ({ tag: t, props: e, children: (Array.isArray(n) ? n : [n]).flat().filter((o) => o != null && o !== !1 && o !== "") });
90
+ function L(t) {
91
+ const e = S();
92
+ e && e.mounts.push(t);
93
93
  }
94
- function P(e) {
95
- const t = E();
96
- t && t.cleanups.push(e);
94
+ function I(t) {
95
+ const e = S();
96
+ e && e.cleanups.push(t);
97
97
  }
98
- function b(e) {
99
- return e && e.some((t) => t && t.props && t.props.key != null);
98
+ function y(t) {
99
+ return t.namespaceURI === g && t.tagName !== "foreignObject" ? g : t.namespaceURI === _ ? _ : null;
100
100
  }
101
- function f(e) {
102
- if (typeof e == "string" || typeof e == "number") return document.createTextNode(String(e));
103
- if (typeof e.tag == "function") {
104
- const o = A(e);
105
- e.child = o;
106
- const i = f(o);
107
- return e.el = i, e.hooks && e.hooks.mounts.length > 0 && setTimeout(() => e.hooks.mounts.forEach((s) => s()), 0), i;
101
+ function E(t) {
102
+ return t && t.some((e) => e && e.props && e.props.key != null);
103
+ }
104
+ const g = "http://www.w3.org/2000/svg", _ = "http://www.w3.org/1998/Math/MathML";
105
+ function f(t, e) {
106
+ if (typeof t == "string" || typeof t == "number") return document.createTextNode(String(t));
107
+ if (typeof t.tag == "function") {
108
+ const s = $(t);
109
+ t.child = s;
110
+ const c = f(s, e);
111
+ return t.el = c, t.hooks?.mounts.length > 0 && setTimeout(() => t.hooks.mounts.forEach((i) => i()), 0), c;
108
112
  }
109
- const t = document.createElement(e.tag);
110
- return e.el = t, N(t, e.props), e.children.forEach((o) => {
111
- t.appendChild(f(o));
112
- }), t;
113
+ const n = t.tag;
114
+ n === "svg" ? e = g : n === "math" && (e = _);
115
+ const o = e ? document.createElementNS(e, n) : document.createElement(n);
116
+ t.el = o, A(o, t.props);
117
+ const r = n === "foreignObject" ? null : e;
118
+ return t.children.forEach((s) => {
119
+ o.appendChild(f(s, r));
120
+ }), o;
113
121
  }
114
- function N(e, t = {}, o = {}) {
115
- if (!e) return;
116
- const i = { ...o, ...t };
117
- for (const s in i) {
118
- const r = o[s], c = t[s];
119
- if (c != null) if (s !== "value" && s !== "checked") {
120
- if (r !== c) {
121
- if (s.startsWith("on")) {
122
- const n = s.slice(2).toLowerCase();
123
- r && e.removeEventListener(n, r), e.addEventListener(n, c);
122
+ function A(t, e = {}, n = {}) {
123
+ if (!t) return;
124
+ const o = { ...n, ...e };
125
+ for (const r in o) {
126
+ const s = n[r], c = e[r];
127
+ if (c != null) if (r !== "value" && r !== "checked") {
128
+ if (s !== c) {
129
+ if (r.startsWith("on")) {
130
+ const i = r.slice(2).toLowerCase();
131
+ s && t.removeEventListener(i, s), t.addEventListener(i, c);
124
132
  }
125
- s === "disabled" ? e.disabled = c === !0 || c === "true" : e.setAttribute(s, c);
133
+ r === "disabled" ? t.disabled = c === !0 || c === "true" : t.setAttribute(r, c);
126
134
  }
127
- } else e[s] !== c && (e[s] = c);
128
- else e.removeAttribute(s);
135
+ } else t[r] !== c && (t[r] = c);
136
+ else t.removeAttribute(r);
129
137
  }
130
138
  }
131
- function $(e, t, o) {
132
- if (!(b(t) || b(o))) {
133
- const i = Math.max(t.length, o.length);
134
- for (let s = 0; s < i; s++) m(e, t[s], o[s], s);
139
+ function j(t, e, n) {
140
+ if (!(E(e) || E(n))) {
141
+ const o = Math.max(e.length, n.length);
142
+ for (let r = 0; r < o; r++) m(t, e[r], n[r], r);
135
143
  return;
136
144
  }
137
- (function(i, s, r) {
145
+ (function(o, r, s) {
138
146
  const c = {};
139
- r.forEach((n, l) => {
140
- const a = (n.props && n.props.key) != null ? n.props.key : l;
141
- c[a] = { vNode: n, index: l };
142
- }), s.forEach((n, l) => {
143
- const a = (n.props && n.props.key) != null ? n.props.key : l, y = c[a];
144
- if (y) {
145
- const u = y.vNode;
146
- m(i, n, u, l);
147
- const h = n.el || u.el, _ = i.childNodes[l];
148
- h && _ !== h && i.insertBefore(h, _), delete c[a];
147
+ s.forEach((i, l) => {
148
+ const a = (i.props && i.props.key) != null ? i.props.key : l;
149
+ c[a] = { vNode: i, index: l };
150
+ }), r.forEach((i, l) => {
151
+ const a = (i.props && i.props.key) != null ? i.props.key : l, k = c[a];
152
+ if (k) {
153
+ const h = k.vNode;
154
+ m(o, i, h, l);
155
+ const u = i.el || h.el, v = o.childNodes[l];
156
+ u && v !== u && o.insertBefore(u, v), delete c[a];
149
157
  } else {
150
- const u = f(n), h = i.childNodes[l];
151
- h ? i.insertBefore(u, h) : i.appendChild(u);
158
+ const h = f(i, y(o)), u = o.childNodes[l];
159
+ u ? o.insertBefore(h, u) : o.appendChild(h);
152
160
  }
153
- }), Object.values(c).forEach(({ vNode: n }) => {
154
- n.el && n.el.parentNode === i && (d(n), i.removeChild(n.el));
161
+ }), Object.values(c).forEach(({ vNode: i }) => {
162
+ i.el && i.el.parentNode === o && (d(i), o.removeChild(i.el));
155
163
  });
156
- })(e, t, o);
164
+ })(t, e, n);
157
165
  }
158
- function A(e) {
159
- const t = { mounts: [], cleanups: [] };
160
- k(t);
161
- const o = e.tag(e.props);
162
- return k(null), e.hooks = t, o;
166
+ function $(t) {
167
+ const e = { mounts: [], cleanups: [] };
168
+ w(e);
169
+ const n = t.tag(t.props);
170
+ return w(null), t.hooks = e, n;
163
171
  }
164
- function d(e) {
165
- e && (e.hooks && e.hooks.cleanups && e.hooks.cleanups.forEach((t) => t()), e.child && d(e.child), e.children && e.children.forEach(d));
172
+ function d(t) {
173
+ t && (t.hooks && t.hooks.cleanups && t.hooks.cleanups.forEach((e) => e()), t.child && d(t.child), t.children && t.children.forEach(d));
166
174
  }
167
- function m(e, t, o, i = 0) {
168
- if (t == null) {
169
- const r = o.el || e.childNodes[i];
170
- return d(o), void (r && e.removeChild(r));
175
+ function m(t, e, n, o = 0) {
176
+ if (e == null) {
177
+ const s = n.el || t.childNodes[o];
178
+ return d(n), void (s && t.removeChild(s));
171
179
  }
172
- if (typeof t.tag == "function") {
173
- const r = !o, c = A(t);
174
- return t.child = c, m(e, c, o ? o.child : void 0, i), t.el = c.el, void (r && t.hooks && t.hooks.mounts.length > 0 && setTimeout(() => {
175
- t.hooks.mounts.forEach((n) => n());
180
+ if (typeof e.tag == "function") {
181
+ const s = !n, c = $(e);
182
+ return e.child = c, m(t, c, n ? n.child : void 0, o), e.el = c.el, void (s && e.hooks && e.hooks.mounts.length > 0 && setTimeout(() => {
183
+ e.hooks.mounts.forEach((i) => i());
176
184
  }, 0));
177
185
  }
178
- if (o == null) return void e.appendChild(f(t));
179
- if (typeof t != typeof o || typeof t != "string" && t.tag !== o.tag) {
180
- const r = o.el || e.childNodes[i];
181
- return void (r && e.replaceChild(f(t), r));
186
+ if (n == null) return void t.appendChild(f(e, y(t)));
187
+ if (typeof e != typeof n || typeof e != "string" && e.tag !== n.tag) {
188
+ const s = n.el || t.childNodes[o];
189
+ return void (s && t.replaceChild(f(e, y(t)), s));
182
190
  }
183
- if (typeof t == "string" || typeof t == "number") {
184
- if (t !== o) {
185
- const r = e.childNodes[i];
186
- r ? r.nodeValue = String(t) : e.appendChild(document.createTextNode(String(t)));
191
+ if (typeof e == "string" || typeof e == "number") {
192
+ if (e !== n) {
193
+ const s = t.childNodes[o];
194
+ s ? s.nodeValue = String(e) : t.appendChild(document.createTextNode(String(e)));
187
195
  }
188
196
  return;
189
197
  }
190
- const s = o.el || e.childNodes[i];
191
- s && (t.el = s, N(s, t.props, o.props), $(s, t.children, o.children));
198
+ const r = n.el || t.childNodes[o];
199
+ r && (e.el = r, A(r, e.props, n.props), j(r, e.children, n.children));
192
200
  }
193
- const O = (e, t) => {
194
- let o = null;
195
- const i = () => {
196
- g(i);
197
- const s = { tag: t, props: {}, children: [] };
198
- m(e, s, o), g(null), o = s;
201
+ const R = (t, e) => {
202
+ let n = null;
203
+ const o = () => {
204
+ b(o);
205
+ const r = { tag: e, props: {}, children: [] };
206
+ m(t, r, n), b(null), n = r;
199
207
  };
200
- i();
201
- }, L = (e, t = {}) => ({ __humn_persist: !0, initial: e, config: t });
208
+ o();
209
+ }, W = (t, e = {}) => ({ __humn_persist: !0, initial: t, config: e });
202
210
  export {
203
- w as Cortex,
204
- T as css,
205
- j as h,
206
- O as mount,
207
- P as onCleanup,
208
- M as onMount,
209
- L as persist
211
+ T as Cortex,
212
+ O as css,
213
+ P as h,
214
+ R as mount,
215
+ I as onCleanup,
216
+ L as onMount,
217
+ W as persist
210
218
  };
211
219
  //# 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 { getObserver } from './observer.js'\nimport { isDev } from './metrics.js'\n\n/**\n * @typedef {object} Synapses\n * @property {function} set - Function to update the memory\n * @property {function} get - Function to get the memory\n */\n\n/**\n * @typedef {object} CortexParams\n * @property {object} memory - The initial state\n * @property {function(function, function): object} synapses - The synapses function\n */\n\n/**\n * The Cortex class manages the state of the application.\n * This uses a Proxy for fine-grained reactivity, ensuring only those components\n * which use the updated value get re-rendered.\n *\n * WHY: We use Proxies instead of simple getters/setters because it allows us to\n * detect access to nested properties dynamically without needing to declare\n * dependencies upfront. This \"magic\" auto-subscription is what makes Humn's\n * DX so clean.\n */\nexport class Cortex {\n /**\n * Creates an instance of Cortex.\n * @param {CortexParams} CortexParams - The parameters for the Cortex.\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 && 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 this._memory = liveMemory\n this._listeners = new Map()\n\n const get = () => this._memory\n\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 // If we need to persist any of the values\n // we save them to localStorage here\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 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 memory wrapped in a tracking Proxy\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 // This gives us fresh tracking each render\n accessedPaths.clear()\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\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\n/**\n * Creates a real DOM element from a virtual node.\n * @param {import(\"./h.js\").VNode | string | number} vNode - The virtual node.\n * @returns {Text | HTMLElement} The created DOM element.\n */\nfunction createElement(vNode) {\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 // Recursively create the DOM for the child\n const el = createElement(childVNode)\n vNode.el = el\n\n // Queue Mount Hooks\n if (vNode.hooks && 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 el = document.createElement(vNode.tag)\n vNode.el = el\n patchProps(el, vNode.props)\n\n vNode.children.forEach((child) => {\n el.appendChild(createElement(child))\n })\n\n return el\n}\n\n/**\n * Updates the properties (attributes/events) of a DOM element.\n * @param {HTMLElement} el - 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(el, newProps = {}, oldProps = {}) {\n if (!el) 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 el.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 (el[key] !== newValue) {\n el[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) el.removeEventListener(eventName, oldValue)\n el.addEventListener(eventName, newValue)\n }\n // Handle the disabled attribute\n if (key === 'disabled') {\n el.disabled = newValue === true || newValue === 'true'\n }\n // Handle standard attributes\n else {\n el.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 el = 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 (el && domChildAtIndex !== el) {\n parent.insertBefore(el, 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 newEl = createElement(newChild)\n const domChildAtIndex = parent.childNodes[i]\n\n if (domChildAtIndex) {\n parent.insertBefore(newEl, domChildAtIndex)\n } else {\n parent.appendChild(newEl)\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))\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), 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 * @typedef {object} HumnPersist\n * @property {boolean} __humn_persist\n * @property {any} initial\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 *\n * @param {any} initial - The initial value of the state.\n * @param {PersistConfig} config - The configuration for persistence.\n * @returns {HumnPersist}\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","clear","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","hasKeys","vNode","createTextNode","String","childVNode","renderComponent","child","el","hooks","setTimeout","patchProps","newProps","oldProps","allProps","oldValue","newValue","eventName","slice","toLowerCase","removeEventListener","addEventListener","disabled","setAttribute","removeAttribute","reconcileChildren","parent","newChildren","oldChildren","maxLen","Math","max","patch","keyed","index","newChild","existingChildMatch","oldVNode","domChildAtIndex","childNodes","insertBefore","newEl","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,CAAAA,MAAAA;AAC1BJ,EAAAA,IAAkBI;AAAAA,GAOPC,IAAc,MAAMJ,GAMpBK,IAAeC,OAAAA;AAC1BN,EAAAA,IAAkBM;AAAAA;ACRb,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,CAAAA,EACxC,KAAIO,KAASA,EAAMG,gBAAgB;AACjC,YAAMC,IAAaJ,EAAMK,OAAON,OAAOA;AACvCH,WAAKC,gBAAgBS,IAAIP,GAAKK,CAAAA;AAE9B;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;AAGFhB,SAAKkB,UAAUnB,GACfC,KAAKmB,aAAa,oBAAIjB,OAiDtBF,KAAKF,WAAWA,EA7CHsB,CAAAA,MAAAA;AACX,UAAIC,GACAC,IAAe,oBAAIC;AAEvB,UAAuB,OAAZH,KAAY,YAAY;AACjC,cAAMI,IAAQC,gBAAgBzB,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AA,OAAoBV,KACN,OAAbU,KAAa,YAAYA,EAAS3D,QAAQiD,EAASjD,KAC3D;AACA,UAAMoB,IAAK6B,EAAS7B,MAAMkB,EAAOa,WAAWL;AAK5C,WAAA,MAJI1B,KACFkB,EAAOuB,aAAanE,EAAciE,CAAAA,GAAWvC,CAAAA;AAAAA,EAIjD;AAGA,MAAwB,OAAbuC,KAAa,YAAgC,OAAbA,KAAa,UAAU;AAChE,QAAIA,MAAaV,GAAU;AACzB,YAAM7B,IAAKkB,EAAOa,WAAWL,CAAAA;AACzB1B,MAAAA,IACFA,EAAG0C,YAAY9C,OAAO2C,CAAAA,IAItBrB,EAAOzC,YAAYJ,SAASsB,eAAeC,OAAO2C,CAAAA,CAAAA,CAAAA;AAAAA,IAEtD;AACA;AAAA,EACF;AAGA,QAAMvC,IAAK6B,EAAS7B,MAAMkB,EAAOa,WAAWL,CAAAA;AAEvC1B,EAAAA,MAGLuC,EAASvC,KAAKA,GAEdG,EAAWH,GAAIuC,EAAS1D,OAAOgD,EAAShD,QAExCoC,EAAkBjB,GAAIuC,EAASzD,UAAU+C,EAAS/C,QAAAA;AACpD;AClVY,MAAC6D,IAAQ,CAACpG,GAAQqG,MAAAA;AAC5B,MAAIC,IAAY;AAEhB,QAAMC,IAAY;AAChB5J,IAAAA,EAAY4J,CAAAA;AAEZ,UAAMC,IAAY,EAChBnE,KAAKgE,GACL/D,OAAO,CAAA,GACPC,UAAU,CAAA,EAAA;AAGZ0C,IAAAA,EAAMjF,GAAQwG,GAAWF,CAAAA,GACzB3J,EAAY,OACZ2J,IAAYE;AAAAA,EAAAA;AAGdD,EAAAA,EAAAA;AAAAA,GCVWE,IAAU,CAACrI,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/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 { getObserver } from './observer.js'\nimport { isDev } from './metrics.js'\n\n/**\n * @typedef {object} Synapses\n * @property {function} set - Function to update the memory\n * @property {function} get - Function to get the memory\n */\n\n/**\n * @typedef {object} CortexParams\n * @property {object} memory - The initial state\n * @property {function(function, function): object} synapses - The synapses function\n */\n\n/**\n * The Cortex class manages the state of the application.\n * This uses a Proxy for fine-grained reactivity, ensuring only those components\n * which use the updated value get re-rendered.\n *\n * WHY: We use Proxies instead of simple getters/setters because it allows us to\n * detect access to nested properties dynamically without needing to declare\n * dependencies upfront. This \"magic\" auto-subscription is what makes Humn's\n * DX so clean.\n */\nexport class Cortex {\n /**\n * Creates an instance of Cortex.\n * @param {CortexParams} CortexParams - The parameters for the Cortex.\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 && 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 this._memory = liveMemory\n this._listeners = new Map()\n\n const get = () => this._memory\n\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 // If we need to persist any of the values\n // we save them to localStorage here\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 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 memory wrapped in a tracking Proxy\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 // This gives us fresh tracking each render\n accessedPaths.clear()\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 * @typedef {object} HumnPersist\n * @property {boolean} __humn_persist\n * @property {any} initial\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 *\n * @param {any} initial - The initial value of the state.\n * @param {PersistConfig} config - The configuration for persistence.\n * @returns {HumnPersist}\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","clear","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;ACRb,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,KAASA,EAAMG,gBAAgB;AACjC,YAAMC,IAAa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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,QAGLyC,EAASzC,KAAKA,GAEdK,EAAWL,GAAIyC,EAASnE,OAAOyD,EAASzD,KAAAA,GAExC8C,EAAkBpB,GAAIyC,EAASlE,UAAUwD,EAASxD,QAAAA;AACpD;AC7WY,MAACsE,IAAQ,CAAC7G,GAAQ8G;AAC5B,MAAIC,IAAY;AAEhB,QAAMC,IAAY,MAAA;AAChBrK,IAAAA,EAAYqK,CAAAA;AAEZ,UAAMC,IAAY,EAChB5E,KAAKyE,GACLxE,OAAO,CAAA,GACPC,UAAU,CAAA,EAAA;AAGZmD,IAAAA,EAAM1F,GAAQiH,GAAWF,CAAAA,GACzBpK,EAAY,OACZoK,IAAYE;AAAAA,EAAAA;AAGdD,EAAAA,EAAAA;AAAAA,GCVWE,IAAU,CAAC9I,GAASP,IAAS,QAAE,EAC1CF,gBAAAA,IACAS,SAAAA,GACAP;"}
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,_=null;const T=()=>h,k=t=>{h=t},b=()=>_,v=t=>{_=t};let p=null;const x=new Set;function C(t){return t&&t.some(e=>e&&e.props&&e.props.key!=null)}function d(t){if(typeof t=="string"||typeof t=="number")return document.createTextNode(String(t));if(typeof t.tag=="function"){const n=S(t);t.child=n;const s=d(n);return t.el=s,t.hooks&&t.hooks.mounts.length>0&&setTimeout(()=>t.hooks.mounts.forEach(o=>o()),0),s}const e=document.createElement(t.tag);return t.el=e,E(e,t.props),t.children.forEach(n=>{e.appendChild(d(n))}),e}function E(t,e={},n={}){if(!t)return;const s={...n,...e};for(const o in s){const r=n[o],i=e[o];if(i!=null)if(o!=="value"&&o!=="checked"){if(r!==i){if(o.startsWith("on")){const c=o.slice(2).toLowerCase();r&&t.removeEventListener(c,r),t.addEventListener(c,i)}o==="disabled"?t.disabled=i===!0||i==="true":t.setAttribute(o,i)}}else t[o]!==i&&(t[o]=i);else t.removeAttribute(o)}}function $(t,e,n){if(!(C(e)||C(n))){const s=Math.max(e.length,n.length);for(let o=0;o<s;o++)g(t,e[o],n[o],o);return}(function(s,o,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}}),o.forEach((c,l)=>{const u=(c.props&&c.props.key)!=null?c.props.key:l,N=i[u];if(N){const y=N.vNode;g(s,c,y,l);const f=c.el||y.el,A=s.childNodes[l];f&&A!==f&&s.insertBefore(f,A),delete i[u]}else{const y=d(c),f=s.childNodes[l];f?s.insertBefore(y,f):s.appendChild(y)}}),Object.values(i).forEach(({vNode:c})=>{c.el&&c.el.parentNode===s&&(m(c),s.removeChild(c.el))})})(t,e,n)}function S(t){const e={mounts:[],cleanups:[]};v(e);const n=t.tag(t.props);return v(null),t.hooks=e,n}function m(t){t&&(t.hooks&&t.hooks.cleanups&&t.hooks.cleanups.forEach(e=>e()),t.child&&m(t.child),t.children&&t.children.forEach(m))}function g(t,e,n,s=0){if(e==null){const r=n.el||t.childNodes[s];return m(n),void(r&&t.removeChild(r))}if(typeof e.tag=="function"){const r=!n,i=S(e);return e.child=i,g(t,i,n?n.child:void 0,s),e.el=i.el,void(r&&e.hooks&&e.hooks.mounts.length>0&&setTimeout(()=>{e.hooks.mounts.forEach(c=>c())},0))}if(n==null)return void t.appendChild(d(e));if(typeof e!=typeof n||typeof e!="string"&&e.tag!==n.tag){const r=n.el||t.childNodes[s];return void(r&&t.replaceChild(d(e),r))}if(typeof e=="string"||typeof e=="number"){if(e!==n){const r=t.childNodes[s];r?r.nodeValue=String(e):t.appendChild(document.createTextNode(String(e)))}return}const o=n.el||t.childNodes[s];o&&(e.el=o,E(o,e.props,n.props),$(o,e.children,n.children))}a.Cortex=class{constructor({memory:t,synapses:e}){const n={...t};this._persistenceMap=new Map;for(const[s,o]of Object.entries(t))if(o&&o.__humn_persist){const r=o.config.key||s;this._persistenceMap.set(s,r);try{const i=localStorage.getItem(r);n[s]=i!==null?JSON.parse(i):o.initial}catch{n[s]=o.initial}}this._memory=n,this._listeners=new Map,this.synapses=e(s=>{let o,r=new Set;if(typeof s=="function"){const i=structuredClone(this._memory),c=s(this._createChangeTrackingProxy(i,r));c&&typeof c=="object"?(o={...this._memory,...c},Object.keys(c).forEach(l=>r.add(l))):o=i}else o={...this._memory,...s},r=new Set(Object.keys(s));this._memory=o,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,n=""){return new Proxy(t,{get:(s,o)=>{if(typeof o=="symbol"||o==="__proto__")return s[o];const r=s[o],i=n?`${n}.${o}`:o;return typeof r=="object"&&r!==null?this._createChangeTrackingProxy(r,e,i):r},set:(s,o,r)=>{if(typeof o=="symbol"||o==="__proto__")return s[o]=r,!0;const i=n?`${n}.${o}`:o;return e.add(i),s[o]=r,!0}})}_notifyRelevantListeners(t){this._listeners.forEach((e,n)=>{Array.from(e).some(s=>Array.from(t).some(o=>s===o||s.startsWith(o+".")||o.startsWith(s+".")))&&n()})}_createAccessTrackingProxy(t,e,n=""){return typeof t!="object"||t===null?t:new Proxy(t,{get:(s,o)=>{if(typeof o=="symbol"||o==="__proto__")return s[o];const r=n?`${n}.${o}`:o;e.add(r);const i=s[o];return typeof i=="object"&&i!==null?this._createAccessTrackingProxy(i,e,r):i}})}get memory(){const t=T();if(!t)return this._memory;this._listeners.has(t)||this._listeners.set(t,new Set);const e=this._listeners.get(t);return e.clear(),this._createAccessTrackingProxy(this._memory,e)}},a.css=function(t,...e){let n="",s=!1;Array.isArray(t)&&t.raw?n=t.reduce((c,l,u)=>c+l+(e[u]||""),""):(n=t,s=e[0]===!0);let o=(function(c){return c.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").trim()})(n);if(!o)return"";s&&(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),i=`humn-${r}`;return x.has(r)||(p||(p=document.createElement("style"),p.id="humn-styles",document.head.appendChild(p)),p.textContent+=`.${i} {
2
- ${o}
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 j=()=>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=A(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,T=i[u];if(T){const m=T.vNode;g(o,c,m,l);const f=c.el||m.el,$=o.childNodes[l];f&&$!==f&&o.insertBefore(f,$),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 A(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=A(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&&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=j();if(!t)return this._memory;this._listeners.has(t)||this._listeners.set(t,new Set);const e=this._listeners.get(t);return e.clear(),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
+ ${n}
3
3
  }
4
- `,x.add(r)),i},a.h=(t,e={},n=[])=>({tag:t,props:e,children:(Array.isArray(n)?n:[n]).flat().filter(s=>s!=null&&s!==!1&&s!=="")}),a.mount=(t,e)=>{let n=null;const s=()=>{k(s);const o={tag:e,props:{},children:[]};g(t,o,n),k(null),n=o};s()},a.onCleanup=function(t){const e=b();e&&e.cleanups.push(t)},a.onMount=function(t){const e=b();e&&e.mounts.push(t)},a.persist=(t,e={})=>({__humn_persist:!0,initial:t,config:e}),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
4
+ `,E.add(r)),i},a.h=(t,e={},s=[])=>({tag:t,props:e,children:(Array.isArray(s)?s:[s]).flat().filter(o=>o!=null&&o!==!1&&o!=="")}),a.mount=(t,e)=>{let s=null;const o=()=>{w(o);const n={tag:e,props:{},children:[]};g(t,n,s),w(null),s=n};o()},a.onCleanup=function(t){const e=x();e&&e.cleanups.push(t)},a.onMount=function(t){const e=x();e&&e.mounts.push(t)},a.persist=(t,e={})=>({__humn_persist:!0,initial:t,config:e}),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
5
5
  //# sourceMappingURL=humn.umd.js.map
@@ -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\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\n/**\n * Creates a real DOM element from a virtual node.\n * @param {import(\"./h.js\").VNode | string | number} vNode - The virtual node.\n * @returns {Text | HTMLElement} The created DOM element.\n */\nfunction createElement(vNode) {\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 // Recursively create the DOM for the child\n const el = createElement(childVNode)\n vNode.el = el\n\n // Queue Mount Hooks\n if (vNode.hooks && 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 el = document.createElement(vNode.tag)\n vNode.el = el\n patchProps(el, vNode.props)\n\n vNode.children.forEach((child) => {\n el.appendChild(createElement(child))\n })\n\n return el\n}\n\n/**\n * Updates the properties (attributes/events) of a DOM element.\n * @param {HTMLElement} el - 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(el, newProps = {}, oldProps = {}) {\n if (!el) 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 el.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 (el[key] !== newValue) {\n el[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) el.removeEventListener(eventName, oldValue)\n el.addEventListener(eventName, newValue)\n }\n // Handle the disabled attribute\n if (key === 'disabled') {\n el.disabled = newValue === true || newValue === 'true'\n }\n // Handle standard attributes\n else {\n el.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 el = 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 (el && domChildAtIndex !== el) {\n parent.insertBefore(el, 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 newEl = createElement(newChild)\n const domChildAtIndex = parent.childNodes[i]\n\n if (domChildAtIndex) {\n parent.insertBefore(newEl, domChildAtIndex)\n } else {\n parent.appendChild(newEl)\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))\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), 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 * @typedef {object} HumnPersist\n * @property {boolean} __humn_persist\n * @property {any} initial\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 *\n * @param {any} initial - The initial value of the state.\n * @param {PersistConfig} config - The configuration for persistence.\n * @returns {HumnPersist}\n */\nexport const persist = (initial, config = {}) => ({\n __humn_persist: true,\n initial,\n config,\n})\n","import { getObserver } from './observer.js'\nimport { isDev } from './metrics.js'\n\n/**\n * @typedef {object} Synapses\n * @property {function} set - Function to update the memory\n * @property {function} get - Function to get the memory\n */\n\n/**\n * @typedef {object} CortexParams\n * @property {object} memory - The initial state\n * @property {function(function, function): object} synapses - The synapses function\n */\n\n/**\n * The Cortex class manages the state of the application.\n * This uses a Proxy for fine-grained reactivity, ensuring only those components\n * which use the updated value get re-rendered.\n *\n * WHY: We use Proxies instead of simple getters/setters because it allows us to\n * detect access to nested properties dynamically without needing to declare\n * dependencies upfront. This \"magic\" auto-subscription is what makes Humn's\n * DX so clean.\n */\nexport class Cortex {\n /**\n * Creates an instance of Cortex.\n * @param {CortexParams} CortexParams - The parameters for the Cortex.\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 && 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 this._memory = liveMemory\n this._listeners = new Map()\n\n const get = () => this._memory\n\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 // If we need to persist any of the values\n // we save them to localStorage here\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 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 memory wrapped in a tracking Proxy\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 // This gives us fresh tracking each render\n accessedPaths.clear()\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","hasKeys","children","some","c","props","key","createElement","vNode","document","createTextNode","String","tag","childVNode","renderComponent","child","el","hooks","mounts","length","setTimeout","forEach","fn","patchProps","appendChild","newProps","oldProps","allProps","oldValue","newValue","startsWith","eventName","slice","toLowerCase","removeEventListener","addEventListener","disabled","setAttribute","removeAttribute","reconcileChildren","parent","newChildren","oldChildren","maxLen","Math","max","i","patch","keyed","index","newChild","existingChildMatch","oldVNode","domChildAtIndex","childNodes","insertBefore","newEl","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","clear","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,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,ICOX,SAASC,EAAQC,EAAAA,CACtB,OAAOA,GAAYA,EAASC,KAAMC,GAAMA,GAAKA,EAAEC,OAASD,EAAEC,MAAMC,KAAO,IAAPA,CAClE,CAOA,SAASC,EAAcC,EAAAA,CACrB,GAAqB,OAAVA,GAAU,UAA6B,OAAVA,GAAU,SAChD,OAAOC,SAASC,eAAeC,OAAOH,IAGxC,GAAyB,OAAdA,EAAMI,KAAQ,WAAY,CACnC,MAAMC,EAAaC,EAAgBN,GACnCA,EAAMO,MAAQF,EAGd,MAAMG,EAAKT,EAAcM,CAAAA,EAOzB,OANAL,EAAMQ,GAAKA,EAGPR,EAAMS,OAAST,EAAMS,MAAMC,OAAOC,OAAS,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EAAW,CAAA,KAQrC,CACLU,IAAAA,EACAP,MAAAA,EACAH,UAViBkG,MAAMwB,QAAQ1H,CAAAA,EAAYA,EAAW,CAACA,IAItDyI,KAAAA,EACAC,OAAQxI,GAAMA,GAAAA,MAAiCA,IAAjCA,IAAgDA,IAAM,EAANA,CAAAA,GFClEtB,EAAA+J,MGXoB,CAAChC,EAAQiC,IAAAA,CAC5B,IAAIC,EAAY,KAEhB,MAAMC,EAAY,KAChBvJ,EAAYuJ,CAAAA,EAEZ,MAAMC,EAAY,CAChBrI,IAAKkI,EACLzI,MAAO,CAAA,EACPH,SAAU,CAAA,CAAA,EAGZ6C,EAAM8D,EAAQoC,EAAWF,CAAAA,EACzBtJ,EAAY,MACZsJ,EAAYE,CAAAA,EAGdD,EAAAA,CAAAA,EHNDlK,EAAAoK,UIFM,SAAmB5H,EAAAA,CACxB,MAAM6H,EAAWxJ,IACbwJ,GACFA,EAASrF,SAASsF,KAAK9H,CAAAA,CAE3B,EJHCxC,EAAAuK,QIbM,SAAiB/H,EAAAA,CACtB,MAAM6H,EAAWxJ,EAAAA,EACbwJ,GACFA,EAASjI,OAAOkI,KAAK9H,CAAAA,CAEzB,EJQCxC,EAAAwK,QAJsB,CAAChE,EAASP,EAAS,MAAE,CAC1CF,kBACAS,QAAAA,EACAP,OAAAA,CAAAA,GACDtB,OAAA8F,eAAAzK,EAAA0K,OAAAC,YAAA,CAAA9E,MAAA,QAAA,CAAA,CAAA,CAAA"}
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 * @typedef {object} HumnPersist\n * @property {boolean} __humn_persist\n * @property {any} initial\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 *\n * @param {any} initial - The initial value of the state.\n * @param {PersistConfig} config - The configuration for persistence.\n * @returns {HumnPersist}\n */\nexport const persist = (initial, config = {}) => ({\n __humn_persist: true,\n initial,\n config,\n})\n","import { getObserver } from './observer.js'\nimport { isDev } from './metrics.js'\n\n/**\n * @typedef {object} Synapses\n * @property {function} set - Function to update the memory\n * @property {function} get - Function to get the memory\n */\n\n/**\n * @typedef {object} CortexParams\n * @property {object} memory - The initial state\n * @property {function(function, function): object} synapses - The synapses function\n */\n\n/**\n * The Cortex class manages the state of the application.\n * This uses a Proxy for fine-grained reactivity, ensuring only those components\n * which use the updated value get re-rendered.\n *\n * WHY: We use Proxies instead of simple getters/setters because it allows us to\n * detect access to nested properties dynamically without needing to declare\n * dependencies upfront. This \"magic\" auto-subscription is what makes Humn's\n * DX so clean.\n */\nexport class Cortex {\n /**\n * Creates an instance of Cortex.\n * @param {CortexParams} CortexParams - The parameters for the Cortex.\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 && 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 this._memory = liveMemory\n this._listeners = new Map()\n\n const get = () => this._memory\n\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 // If we need to persist any of the values\n // we save them to localStorage here\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 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 memory wrapped in a tracking Proxy\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 // This gives us fresh tracking each render\n accessedPaths.clear()\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","err","_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","clear","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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EAAAA,CACxB,MAAMgI,EAAWlK,EAAAA,EACbkK,GACFA,EAAStF,SAASuF,KAAKjI,CAAAA,CAE3B,EJHC/C,EAAAiL,QIbM,SAAiBlI,EAAAA,CACtB,MAAMgI,EAAWlK,IACbkK,GACFA,EAASpI,OAAOqI,KAAKjI,EAEzB,EJQC/C,EAAAkL,QAJsB,CAACjE,EAASP,EAAS,MAAE,CAC1CF,kBACAS,QAAAA,EACAP,OAAAA,CAAAA,GACDtB,OAAA+F,eAAAnL,EAAAoL,OAAAC,YAAA,CAAA/E,MAAA,QAAA,CAAA,CAAA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humn",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "A minimal, human-centric reactive UI library with built in state management.",
5
5
  "keywords": [
6
6
  "reactive",