humn 1.6.0 → 1.6.1
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 +286 -269
- package/dist/humn.js.map +1 -1
- package/dist/humn.umd.js +3 -3
- package/dist/humn.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/humn.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
let
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
let O = null, j = null;
|
|
2
|
+
const D = () => O;
|
|
3
|
+
function F(e) {
|
|
4
4
|
const t = e?.__humnCortexes;
|
|
5
5
|
t && (t.forEach((n) => n._listeners.delete(e)), t.clear());
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
$ = e;
|
|
9
|
-
}, K = () => O, H = (e) => {
|
|
7
|
+
const I = (e) => {
|
|
10
8
|
O = e;
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
}, x = () => j, v = (e) => {
|
|
10
|
+
j = e;
|
|
11
|
+
}, C = /* @__PURE__ */ new Set();
|
|
12
|
+
let k = !1;
|
|
13
|
+
function J(e) {
|
|
14
|
+
C.add(e), W();
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
16
|
+
function W() {
|
|
17
|
+
k || (k = !0, queueMicrotask(Q));
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
const e = Array.from(
|
|
22
|
-
|
|
19
|
+
function Q() {
|
|
20
|
+
k = !1;
|
|
21
|
+
const e = Array.from(C);
|
|
22
|
+
C.clear(), e.forEach((t) => t()), C.size > 0 && W();
|
|
23
23
|
}
|
|
24
|
-
class
|
|
24
|
+
class Te {
|
|
25
25
|
/**
|
|
26
26
|
* Creates an instance of Cortex.
|
|
27
27
|
* @param {CortexConfig<MemoryType, SynapsesType>} config
|
|
28
28
|
*/
|
|
29
29
|
constructor({ memory: t, synapses: n }) {
|
|
30
|
-
const
|
|
30
|
+
const i = { ...t };
|
|
31
31
|
this._persistenceMap = /* @__PURE__ */ new Map();
|
|
32
32
|
for (const [s, c] of Object.entries(t))
|
|
33
33
|
if (c && typeof c == "object" && c.__humn_persist) {
|
|
@@ -35,13 +35,13 @@ class He {
|
|
|
35
35
|
this._persistenceMap.set(s, u);
|
|
36
36
|
try {
|
|
37
37
|
const a = localStorage.getItem(u);
|
|
38
|
-
a !== null ?
|
|
38
|
+
a !== null ? i[s] = JSON.parse(a) : i[s] = c.initial;
|
|
39
39
|
} catch {
|
|
40
|
-
|
|
40
|
+
i[s] = c.initial;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
this._memory =
|
|
44
|
-
const
|
|
43
|
+
this._memory = i, this._listeners = /* @__PURE__ */ new Map();
|
|
44
|
+
const o = () => this._memory, r = (s) => {
|
|
45
45
|
let c, u = /* @__PURE__ */ new Set();
|
|
46
46
|
if (typeof s == "function") {
|
|
47
47
|
const a = this._createMutationDraft(this._memory, u), f = s(a.memory);
|
|
@@ -59,50 +59,50 @@ class He {
|
|
|
59
59
|
}
|
|
60
60
|
}), this._notifyRelevantListeners(u);
|
|
61
61
|
};
|
|
62
|
-
this.synapses = n(
|
|
62
|
+
this.synapses = n(r, o);
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Creates a copy-on-write mutation draft that tracks changed paths without
|
|
66
66
|
* cloning the whole store before every mutative update.
|
|
67
67
|
*/
|
|
68
68
|
_createMutationDraft(t, n) {
|
|
69
|
-
const
|
|
70
|
-
const a =
|
|
69
|
+
const i = /* @__PURE__ */ new WeakMap(), o = ({ parent: s, parentProp: c, target: u }) => {
|
|
70
|
+
const a = i.get(u);
|
|
71
71
|
if (a) return a;
|
|
72
72
|
const f = Array.isArray(u) ? u.slice() : { ...u };
|
|
73
|
-
return
|
|
74
|
-
},
|
|
73
|
+
return i.set(u, f), s && (o(s)[c] = f), f;
|
|
74
|
+
}, r = (s, c = "", u = null, a = null) => new Proxy(s, {
|
|
75
75
|
deleteProperty: (d, l) => {
|
|
76
|
-
const
|
|
77
|
-
return delete
|
|
76
|
+
const b = o({ parent: u, parentProp: a, target: d });
|
|
77
|
+
return delete b[l], typeof l != "symbol" && n.add(c ? `${c}.${l}` : String(l)), !0;
|
|
78
78
|
},
|
|
79
79
|
get: (d, l) => {
|
|
80
|
-
const h = (
|
|
80
|
+
const h = (i.get(d) || d)[l];
|
|
81
81
|
if (typeof l == "symbol" || l === "__proto__" || typeof h != "object" || h === null) return h;
|
|
82
|
-
const
|
|
83
|
-
return
|
|
82
|
+
const G = c ? `${c}.${l}` : String(l);
|
|
83
|
+
return r(
|
|
84
84
|
h,
|
|
85
|
-
|
|
85
|
+
G,
|
|
86
86
|
{ parent: u, parentProp: a, target: d },
|
|
87
87
|
l
|
|
88
88
|
);
|
|
89
89
|
},
|
|
90
|
-
set: (d, l,
|
|
91
|
-
const h =
|
|
92
|
-
return h[l] =
|
|
90
|
+
set: (d, l, b) => {
|
|
91
|
+
const h = o({ parent: u, parentProp: a, target: d });
|
|
92
|
+
return h[l] = b, typeof l != "symbol" && n.add(c ? `${c}.${l}` : String(l)), !0;
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
return {
|
|
96
|
-
getNextState: () =>
|
|
97
|
-
memory:
|
|
96
|
+
getNextState: () => i.get(t) || t,
|
|
97
|
+
memory: r(t)
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Only notify listeners that read properties which changed
|
|
102
102
|
*/
|
|
103
103
|
_notifyRelevantListeners(t) {
|
|
104
|
-
Array.from(this._listeners.entries()).forEach(([
|
|
105
|
-
Array.from(
|
|
104
|
+
Array.from(this._listeners.entries()).forEach(([i, o]) => {
|
|
105
|
+
Array.from(o).some((s) => Array.from(t).some((c) => s === c || s.startsWith(c + ".") || c.startsWith(s + "."))) && J(i);
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
@@ -113,14 +113,14 @@ class He {
|
|
|
113
113
|
* `state.user.name`, it will only re-render when `state.user.name` changes,
|
|
114
114
|
* not when `state.count` changes.
|
|
115
115
|
*/
|
|
116
|
-
_createAccessTrackingProxy(t, n,
|
|
116
|
+
_createAccessTrackingProxy(t, n, i = "") {
|
|
117
117
|
return typeof t != "object" || t === null ? t : new Proxy(t, {
|
|
118
|
-
get: (
|
|
119
|
-
if (typeof
|
|
120
|
-
return r
|
|
121
|
-
const s =
|
|
118
|
+
get: (o, r) => {
|
|
119
|
+
if (typeof r == "symbol" || r === "__proto__")
|
|
120
|
+
return o[r];
|
|
121
|
+
const s = i ? `${i}.${r}` : r;
|
|
122
122
|
n.add(s);
|
|
123
|
-
const c = r
|
|
123
|
+
const c = o[r];
|
|
124
124
|
return typeof c == "object" && c !== null ? this._createAccessTrackingProxy(c, n, s) : c;
|
|
125
125
|
}
|
|
126
126
|
});
|
|
@@ -129,7 +129,7 @@ class He {
|
|
|
129
129
|
* @returns {UnwrappedMemory<MemoryType>}
|
|
130
130
|
*/
|
|
131
131
|
get memory() {
|
|
132
|
-
const t =
|
|
132
|
+
const t = D();
|
|
133
133
|
if (!t) return this._memory;
|
|
134
134
|
this._listeners.has(t) || this._listeners.set(t, /* @__PURE__ */ new Set()), t.__humnCortexes || (t.__humnCortexes = /* @__PURE__ */ new Set()), t.__humnCortexes.add(this);
|
|
135
135
|
const n = this._listeners.get(t);
|
|
@@ -137,91 +137,91 @@ class He {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
let y = null;
|
|
140
|
-
const
|
|
141
|
-
function
|
|
140
|
+
const H = /* @__PURE__ */ new Set();
|
|
141
|
+
function Y(e) {
|
|
142
142
|
let t = 5381, n = e.length;
|
|
143
143
|
for (; n; )
|
|
144
144
|
t = t * 33 ^ e.charCodeAt(--n);
|
|
145
145
|
return (t >>> 0).toString(36);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function X(e) {
|
|
148
148
|
return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").trim();
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
let n = "",
|
|
152
|
-
Array.isArray(e) && e.raw ? n = e.reduce((c, u, a) => c + u + (t[a] || ""), "") : (n = e,
|
|
153
|
-
let
|
|
154
|
-
if (!
|
|
155
|
-
|
|
150
|
+
function Re(e, ...t) {
|
|
151
|
+
let n = "", i = !1;
|
|
152
|
+
Array.isArray(e) && e.raw ? n = e.reduce((c, u, a) => c + u + (t[a] || ""), "") : (n = e, i = t[0] === !0);
|
|
153
|
+
let o = X(n);
|
|
154
|
+
if (!o) return "";
|
|
155
|
+
i && (o = o.replace(
|
|
156
156
|
/(^|[{};,])(\s*)(?!from|to)((?:[.#]?[\w-]+|\[[^\]]+\]|:{1,2}[^:,{\s]+)+)(?=\s*\{)/gi,
|
|
157
157
|
"$1$2$3&, $3"
|
|
158
158
|
));
|
|
159
|
-
const
|
|
160
|
-
return
|
|
161
|
-
${
|
|
159
|
+
const r = Y(o), s = `humn-${r}`;
|
|
160
|
+
return H.has(r) || (y || (y = document.createElement("style"), y.id = "humn-styles", document.head.appendChild(y)), y.textContent += `.${s} {
|
|
161
|
+
${o}
|
|
162
162
|
}
|
|
163
|
-
`,
|
|
163
|
+
`, H.add(r)), s;
|
|
164
164
|
}
|
|
165
|
-
const
|
|
166
|
-
const
|
|
165
|
+
const $e = (e, t = {}, n = []) => {
|
|
166
|
+
const o = (Array.isArray(n) ? n : [n]).flat().filter((r) => r != null && r !== !1 && r !== "");
|
|
167
167
|
return {
|
|
168
168
|
tag: e,
|
|
169
169
|
props: t,
|
|
170
|
-
children:
|
|
170
|
+
children: o
|
|
171
171
|
};
|
|
172
172
|
};
|
|
173
|
-
function
|
|
173
|
+
function Z(e) {
|
|
174
174
|
if (typeof e != "object" || e === null) return e;
|
|
175
175
|
const t = Array.isArray(e.children) ? e.children : [];
|
|
176
176
|
return {
|
|
177
177
|
tag: e.tag,
|
|
178
178
|
props: { ...e.props },
|
|
179
|
-
children: t.map(
|
|
179
|
+
children: t.map(Z)
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
const t =
|
|
182
|
+
function Oe(e) {
|
|
183
|
+
const t = x();
|
|
184
184
|
t && t.mounts.push(e);
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
const t =
|
|
186
|
+
function je(e) {
|
|
187
|
+
const t = x();
|
|
188
188
|
t && t.cleanups.push(e);
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function B(e, t) {
|
|
191
191
|
try {
|
|
192
192
|
e();
|
|
193
193
|
} catch (n) {
|
|
194
194
|
console.error(t, n);
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
const n = { mounts: [], cleanups: [] },
|
|
199
|
-
|
|
197
|
+
function w(e, t) {
|
|
198
|
+
const n = { mounts: [], cleanups: [] }, i = x(), o = D();
|
|
199
|
+
F(t), I(t), v(n);
|
|
200
200
|
try {
|
|
201
|
-
const
|
|
202
|
-
return e.hooks = n,
|
|
201
|
+
const r = e.tag(e.props);
|
|
202
|
+
return e.hooks = n, r;
|
|
203
203
|
} finally {
|
|
204
|
-
|
|
204
|
+
v(i), I(o);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
e && (
|
|
209
|
-
(t) =>
|
|
210
|
-
), e.child &&
|
|
207
|
+
function g(e) {
|
|
208
|
+
e && (F(e.instance?.update), e.instance && (e.instance.isMounted = !1, e.instance.parent = null, e.instance.vNode = null), e.hooks?.cleanups && e.hooks.cleanups.forEach(
|
|
209
|
+
(t) => B(t, "Error in cleanup hook:")
|
|
210
|
+
), e.child && g(e.child), e.children && e.children.forEach(g));
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function P(e) {
|
|
213
213
|
e?.mounts?.length && setTimeout(
|
|
214
214
|
() => e.mounts.forEach(
|
|
215
|
-
(t) =>
|
|
215
|
+
(t) => B(t, "Error in mount hook:")
|
|
216
216
|
),
|
|
217
217
|
0
|
|
218
218
|
);
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function N({ newHooks: e, oldHooks: t }) {
|
|
221
221
|
}
|
|
222
|
-
const
|
|
222
|
+
const L = /* @__PURE__ */ new WeakMap();
|
|
223
223
|
function p(e) {
|
|
224
|
-
const t =
|
|
224
|
+
const t = L.get(e);
|
|
225
225
|
if (t) return t;
|
|
226
226
|
const n = {
|
|
227
227
|
asyncPending: /* @__PURE__ */ new Map(),
|
|
@@ -230,56 +230,56 @@ function p(e) {
|
|
|
230
230
|
debounceTimers: /* @__PURE__ */ new Map(),
|
|
231
231
|
listeners: /* @__PURE__ */ new Map()
|
|
232
232
|
};
|
|
233
|
-
return
|
|
233
|
+
return L.set(e, n), n;
|
|
234
234
|
}
|
|
235
|
-
const
|
|
235
|
+
const V = /* @__PURE__ */ new Set([
|
|
236
236
|
"prevent",
|
|
237
237
|
"stop",
|
|
238
238
|
"once",
|
|
239
239
|
"capture",
|
|
240
240
|
"passive"
|
|
241
241
|
]);
|
|
242
|
-
function
|
|
243
|
-
const [t, ...n] = e.split("|"),
|
|
244
|
-
(
|
|
242
|
+
function ee(e) {
|
|
243
|
+
const [t, ...n] = e.split("|"), i = n.filter(
|
|
244
|
+
(o) => V.has(o)
|
|
245
245
|
);
|
|
246
|
-
return { eventKey: t, modifiers:
|
|
246
|
+
return { eventKey: t, modifiers: i };
|
|
247
247
|
}
|
|
248
248
|
function m({
|
|
249
249
|
element: e,
|
|
250
250
|
eventName: t,
|
|
251
251
|
listener: n,
|
|
252
|
-
options:
|
|
253
|
-
propKey:
|
|
252
|
+
options: i = !1,
|
|
253
|
+
propKey: o
|
|
254
254
|
}) {
|
|
255
|
-
const { listeners:
|
|
256
|
-
|
|
255
|
+
const { listeners: r } = p(e);
|
|
256
|
+
E(e, o), e.addEventListener(t, n, i), r.set(o, { eventName: t, listener: n, options: i });
|
|
257
257
|
}
|
|
258
|
-
function
|
|
259
|
-
const { listeners: n } = p(e),
|
|
260
|
-
if (!
|
|
261
|
-
const { eventName:
|
|
262
|
-
e.removeEventListener(
|
|
258
|
+
function E(e, t) {
|
|
259
|
+
const { listeners: n } = p(e), i = n.get(t);
|
|
260
|
+
if (!i) return;
|
|
261
|
+
const { eventName: o, listener: r, options: s } = i;
|
|
262
|
+
e.removeEventListener(o, r, s), n.delete(t);
|
|
263
263
|
}
|
|
264
|
-
const
|
|
264
|
+
const te = /* @__PURE__ */ new Set(["onenter", "onescape", "onkeys", "oncommit"]), ne = [
|
|
265
265
|
"__compositionstart",
|
|
266
266
|
"__compositionend",
|
|
267
267
|
"__keyhelper",
|
|
268
268
|
"__oncommitblur"
|
|
269
269
|
];
|
|
270
|
-
function
|
|
271
|
-
return
|
|
270
|
+
function ie(e) {
|
|
271
|
+
return te.has(e);
|
|
272
272
|
}
|
|
273
|
-
function
|
|
273
|
+
function U(e) {
|
|
274
274
|
const { debounceTimers: t } = p(e), n = t.get("oninputdebounced");
|
|
275
|
-
n && clearTimeout(n), t.delete("oninputdebounced"),
|
|
275
|
+
n && clearTimeout(n), t.delete("oninputdebounced"), E(e, "oninputdebounced");
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function re(e, t) {
|
|
278
278
|
if (!t.oninputdebounced) {
|
|
279
|
-
|
|
279
|
+
U(e);
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
282
|
-
const { debounceTimers: n } = p(e),
|
|
282
|
+
const { debounceTimers: n } = p(e), i = Number(t.debounce), o = Number.isFinite(i) ? i : 250;
|
|
283
283
|
m({
|
|
284
284
|
element: e,
|
|
285
285
|
eventName: "input",
|
|
@@ -292,22 +292,22 @@ function oe(e, t) {
|
|
|
292
292
|
currentTarget: e,
|
|
293
293
|
target: e
|
|
294
294
|
});
|
|
295
|
-
},
|
|
295
|
+
}, o);
|
|
296
296
|
n.set("oninputdebounced", u);
|
|
297
297
|
},
|
|
298
298
|
propKey: "oninputdebounced"
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
|
-
function
|
|
302
|
-
if (!
|
|
303
|
-
|
|
301
|
+
function oe(e, t) {
|
|
302
|
+
if (!ue(t)) {
|
|
303
|
+
ce(e);
|
|
304
304
|
return;
|
|
305
305
|
}
|
|
306
|
-
const n = p(e),
|
|
306
|
+
const n = p(e), i = le({ element: e, newProps: t, runtime: n }), o = ae({ newProps: t, runtime: n }), r = () => n.composition.set("active", !0), s = () => n.composition.set("active", !1);
|
|
307
307
|
m({
|
|
308
308
|
element: e,
|
|
309
309
|
eventName: "compositionstart",
|
|
310
|
-
listener:
|
|
310
|
+
listener: r,
|
|
311
311
|
propKey: "__compositionstart"
|
|
312
312
|
}), m({
|
|
313
313
|
element: e,
|
|
@@ -317,155 +317,155 @@ function re(e, t) {
|
|
|
317
317
|
}), m({
|
|
318
318
|
element: e,
|
|
319
319
|
eventName: "keydown",
|
|
320
|
-
listener:
|
|
320
|
+
listener: i,
|
|
321
321
|
propKey: "__keyhelper"
|
|
322
322
|
}), m({
|
|
323
323
|
element: e,
|
|
324
324
|
eventName: "blur",
|
|
325
|
-
listener:
|
|
325
|
+
listener: o,
|
|
326
326
|
propKey: "__oncommitblur"
|
|
327
327
|
});
|
|
328
328
|
}
|
|
329
|
-
function
|
|
330
|
-
const { asyncPending:
|
|
329
|
+
function se({ element: e, handler: t, newProps: n, propKey: i }) {
|
|
330
|
+
const { asyncPending: o } = p(e);
|
|
331
331
|
m({
|
|
332
332
|
element: e,
|
|
333
333
|
eventName: "click",
|
|
334
334
|
listener: async (s) => {
|
|
335
|
-
if (!(n.disabledwhilepending &&
|
|
335
|
+
if (!(n.disabledwhilepending && o.get("click")))
|
|
336
336
|
try {
|
|
337
|
-
|
|
337
|
+
o.set("click", !0), n.disabledwhilepending && (e.disabled = !0), await t(s);
|
|
338
338
|
} finally {
|
|
339
|
-
|
|
339
|
+
o.set("click", !1), n.disabledwhilepending && (e.disabled = !1);
|
|
340
340
|
}
|
|
341
341
|
},
|
|
342
|
-
propKey:
|
|
342
|
+
propKey: i
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
|
-
function
|
|
346
|
-
|
|
347
|
-
(t) =>
|
|
345
|
+
function ce(e) {
|
|
346
|
+
ne.forEach(
|
|
347
|
+
(t) => E(e, t)
|
|
348
348
|
);
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function ue(e) {
|
|
351
351
|
return !!(e.onenter || e.onescape || e.onkeys || e.oncommit);
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
return (
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
357
|
-
const
|
|
358
|
-
|
|
353
|
+
function le({ element: e, newProps: t, runtime: n }) {
|
|
354
|
+
return (i) => {
|
|
355
|
+
const o = n.composition.get("active") === !0;
|
|
356
|
+
if (pe(i, o)) return;
|
|
357
|
+
const r = de(i);
|
|
358
|
+
i.key === "Enter" && t.onenter && t.onenter(i), i.key === "Escape" && t.onescape && t.onescape(i), t.onkeys && fe(i, r, t.onkeys), !(i.key !== "Enter" || !t.oncommit) && (n.commitLocks.set("enter", !0), t.oncommit(i), setTimeout(() => n.commitLocks.delete("enter"), 0));
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function ae({ newProps: e, runtime: t }) {
|
|
362
362
|
return (n) => {
|
|
363
363
|
e.oncommit && (t.commitLocks.get("enter") || e.oncommit(n));
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
Object.entries(n).forEach(([
|
|
368
|
-
|
|
366
|
+
function fe(e, t, n) {
|
|
367
|
+
Object.entries(n).forEach(([i, o]) => {
|
|
368
|
+
he(i) === t && o(e);
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
|
-
function
|
|
371
|
+
function de(e) {
|
|
372
372
|
const t = [];
|
|
373
373
|
return e.ctrlKey && t.push("ctrl"), e.metaKey && t.push("meta"), e.altKey && t.push("alt"), e.shiftKey && t.push("shift"), t.push(e.key.toLowerCase()), t.sort().join("+");
|
|
374
374
|
}
|
|
375
|
-
function
|
|
376
|
-
return e.split("+").map((t) => t.trim().toLowerCase()).filter(Boolean).map((t) =>
|
|
375
|
+
function he(e = "") {
|
|
376
|
+
return e.split("+").map((t) => t.trim().toLowerCase()).filter(Boolean).map((t) => me(t)).sort().join("+");
|
|
377
377
|
}
|
|
378
|
-
function
|
|
378
|
+
function me(e) {
|
|
379
379
|
return e !== "mod" ? e : navigator.platform.includes("Mac") ? "meta" : "ctrl";
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function pe(e, t) {
|
|
382
382
|
return e.isComposing || t === !0;
|
|
383
383
|
}
|
|
384
|
-
function
|
|
384
|
+
function z(e, t = {}, n = {}) {
|
|
385
385
|
if (!e) return;
|
|
386
|
-
const
|
|
387
|
-
for (const
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
function
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
|
|
386
|
+
const i = { ...n, ...t };
|
|
387
|
+
for (const o in i)
|
|
388
|
+
ye({ element: e, key: o, newProps: t, oldProps: n });
|
|
389
|
+
re(e, t), oe(e, t);
|
|
390
|
+
}
|
|
391
|
+
function ye({ element: e, key: t, newProps: n, oldProps: i }) {
|
|
392
|
+
const o = i[t], r = n[t];
|
|
393
|
+
if (r == null) {
|
|
394
|
+
ge({ element: e, key: t });
|
|
395
395
|
return;
|
|
396
396
|
}
|
|
397
397
|
if (t === "value" || t === "checked") {
|
|
398
|
-
|
|
398
|
+
_e({ element: e, key: t, value: r });
|
|
399
399
|
return;
|
|
400
400
|
}
|
|
401
|
-
if (!(
|
|
401
|
+
if (!(o === r && t !== "onclickasync")) {
|
|
402
402
|
if (t.startsWith("on")) {
|
|
403
|
-
|
|
403
|
+
be({ element: e, handler: r, key: t, newProps: n });
|
|
404
404
|
return;
|
|
405
405
|
}
|
|
406
406
|
if (t !== "debounce") {
|
|
407
407
|
if (t === "disabled") {
|
|
408
|
-
e.disabled =
|
|
408
|
+
e.disabled = r === !0 || r === "true";
|
|
409
409
|
return;
|
|
410
410
|
}
|
|
411
|
-
e.setAttribute(t,
|
|
411
|
+
e.setAttribute(t, r);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
|
-
function
|
|
416
|
-
t.startsWith("on") &&
|
|
415
|
+
function ge({ element: e, key: t }) {
|
|
416
|
+
t.startsWith("on") && E(e, t), t === "oninputdebounced" && U(e), e.removeAttribute(t);
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function _e({ element: e, key: t, value: n }) {
|
|
419
419
|
e[t] !== n && (e[t] = n);
|
|
420
420
|
}
|
|
421
|
-
function
|
|
422
|
-
const { eventKey:
|
|
423
|
-
if (
|
|
424
|
-
if (
|
|
425
|
-
|
|
421
|
+
function be({ element: e, handler: t, key: n, newProps: i }) {
|
|
422
|
+
const { eventKey: o, modifiers: r } = ee(n), s = o.slice(2).toLowerCase();
|
|
423
|
+
if (ie(o) || o === "oninputdebounced") return;
|
|
424
|
+
if (o === "onclickasync") {
|
|
425
|
+
se({ element: e, handler: t, newProps: i, propKey: n });
|
|
426
426
|
return;
|
|
427
427
|
}
|
|
428
428
|
m({
|
|
429
429
|
element: e,
|
|
430
430
|
eventName: s,
|
|
431
|
-
listener: (u) => (
|
|
431
|
+
listener: (u) => (r.includes("prevent") && u.preventDefault(), r.includes("stop") && u.stopPropagation(), t(u)),
|
|
432
432
|
options: {
|
|
433
|
-
capture:
|
|
434
|
-
once:
|
|
435
|
-
passive:
|
|
433
|
+
capture: r.includes("capture"),
|
|
434
|
+
once: r.includes("once"),
|
|
435
|
+
passive: r.includes("passive")
|
|
436
436
|
},
|
|
437
437
|
propKey: n
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
|
-
const
|
|
441
|
-
function
|
|
442
|
-
return e.namespaceURI ===
|
|
440
|
+
const M = "http://www.w3.org/2000/svg", S = "http://www.w3.org/1998/Math/MathML";
|
|
441
|
+
function T(e) {
|
|
442
|
+
return e.namespaceURI === M && e.tagName !== "foreignObject" ? M : e.namespaceURI === S ? S : null;
|
|
443
443
|
}
|
|
444
|
-
function
|
|
444
|
+
function A(e, t, n = null, i = 0) {
|
|
445
445
|
if (typeof e == "string" || typeof e == "number")
|
|
446
446
|
return document.createTextNode(String(e));
|
|
447
447
|
if (typeof e.tag == "function")
|
|
448
|
-
return
|
|
449
|
-
const
|
|
450
|
-
return e.el = s,
|
|
448
|
+
return Ce({ index: i, namespace: t, parent: n, vNode: e });
|
|
449
|
+
const o = e.tag, r = ke(o, t), s = r ? document.createElementNS(r, o) : document.createElement(o);
|
|
450
|
+
return e.el = s, z(s, e.props), Ee({ element: s, namespace: r, tag: o, vNode: e }), s;
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function Ce({ index: e, namespace: t, parent: n, vNode: i }) {
|
|
453
453
|
if (n)
|
|
454
|
-
return
|
|
455
|
-
const
|
|
456
|
-
return
|
|
454
|
+
return _({ index: e, newVNode: i, oldVNode: null, parent: n }), i.el;
|
|
455
|
+
const o = document.createDocumentFragment();
|
|
456
|
+
return _({
|
|
457
457
|
index: 0,
|
|
458
|
-
newVNode:
|
|
458
|
+
newVNode: i,
|
|
459
459
|
oldVNode: null,
|
|
460
|
-
parent:
|
|
461
|
-
}),
|
|
462
|
-
}
|
|
463
|
-
function Ee({ element: e, namespace: t, tag: n, vNode:
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
const s =
|
|
467
|
-
i,
|
|
460
|
+
parent: o
|
|
461
|
+
}), i.el || o.firstChild;
|
|
462
|
+
}
|
|
463
|
+
function Ee({ element: e, namespace: t, tag: n, vNode: i }) {
|
|
464
|
+
const o = n === "foreignObject" ? null : t;
|
|
465
|
+
i.children.forEach((r) => {
|
|
466
|
+
const s = A(
|
|
468
467
|
r,
|
|
468
|
+
o,
|
|
469
469
|
e,
|
|
470
470
|
e.childNodes.length
|
|
471
471
|
);
|
|
@@ -473,99 +473,96 @@ function Ee({ element: e, namespace: t, tag: n, vNode: o }) {
|
|
|
473
473
|
});
|
|
474
474
|
}
|
|
475
475
|
function ke(e, t) {
|
|
476
|
-
return e === "svg" ?
|
|
476
|
+
return e === "svg" ? M : e === "math" ? S : t;
|
|
477
477
|
}
|
|
478
478
|
function R(e) {
|
|
479
479
|
return e && e.some((t) => t?.props?.key != null);
|
|
480
480
|
}
|
|
481
|
-
function
|
|
481
|
+
function Me({
|
|
482
482
|
oldChildren: e,
|
|
483
483
|
newChildren: t,
|
|
484
484
|
parent: n,
|
|
485
|
-
patchNode:
|
|
486
|
-
runUnmount:
|
|
485
|
+
patchNode: i,
|
|
486
|
+
runUnmount: o
|
|
487
487
|
}) {
|
|
488
488
|
if (R(t) || R(e)) {
|
|
489
|
-
|
|
489
|
+
Ae({
|
|
490
490
|
oldChildren: e,
|
|
491
491
|
newChildren: t,
|
|
492
492
|
parent: n,
|
|
493
|
-
patchNode:
|
|
494
|
-
runUnmount:
|
|
493
|
+
patchNode: i,
|
|
494
|
+
runUnmount: o
|
|
495
495
|
});
|
|
496
496
|
return;
|
|
497
497
|
}
|
|
498
|
-
|
|
498
|
+
Se({ oldChildren: e, newChildren: t, parent: n, patchNode: i });
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function Se({
|
|
501
501
|
oldChildren: e,
|
|
502
502
|
newChildren: t,
|
|
503
503
|
parent: n,
|
|
504
|
-
patchNode:
|
|
504
|
+
patchNode: i
|
|
505
505
|
}) {
|
|
506
|
-
const
|
|
507
|
-
for (let
|
|
508
|
-
|
|
506
|
+
const o = Math.max(t.length, e.length);
|
|
507
|
+
for (let r = 0; r < o; r++)
|
|
508
|
+
i(n, t[r], e[r], r);
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function Ae({
|
|
511
511
|
oldChildren: e,
|
|
512
512
|
newChildren: t,
|
|
513
513
|
parent: n,
|
|
514
|
-
patchNode:
|
|
515
|
-
runUnmount:
|
|
514
|
+
patchNode: i,
|
|
515
|
+
runUnmount: o
|
|
516
516
|
}) {
|
|
517
|
-
const
|
|
517
|
+
const r = xe(e);
|
|
518
518
|
t.forEach((s, c) => {
|
|
519
|
-
const u =
|
|
519
|
+
const u = q(s, c), a = r[u];
|
|
520
520
|
if (a) {
|
|
521
|
-
|
|
521
|
+
Ke({
|
|
522
522
|
existingChild: a,
|
|
523
523
|
index: c,
|
|
524
524
|
newChild: s,
|
|
525
525
|
parent: n,
|
|
526
|
-
patchNode:
|
|
527
|
-
}), delete
|
|
526
|
+
patchNode: i
|
|
527
|
+
}), delete r[u];
|
|
528
528
|
return;
|
|
529
529
|
}
|
|
530
|
-
|
|
531
|
-
}),
|
|
530
|
+
Ie({ index: c, newChild: s, parent: n, patchNode: i });
|
|
531
|
+
}), ve({ keyedChildren: r, parent: n, runUnmount: o });
|
|
532
532
|
}
|
|
533
533
|
function xe(e) {
|
|
534
534
|
const t = {};
|
|
535
|
-
return e.forEach((n,
|
|
536
|
-
const
|
|
537
|
-
t[
|
|
535
|
+
return e.forEach((n, i) => {
|
|
536
|
+
const o = q(n, i);
|
|
537
|
+
t[o] = { index: i, vNode: n };
|
|
538
538
|
}), t;
|
|
539
539
|
}
|
|
540
|
-
function
|
|
540
|
+
function q(e, t) {
|
|
541
541
|
return e?.props?.key != null ? e.props.key : t;
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function Ke({
|
|
544
544
|
existingChild: e,
|
|
545
545
|
index: t,
|
|
546
546
|
newChild: n,
|
|
547
|
-
parent:
|
|
548
|
-
patchNode:
|
|
547
|
+
parent: i,
|
|
548
|
+
patchNode: o
|
|
549
549
|
}) {
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
const s = n.el ||
|
|
553
|
-
s && c !== s &&
|
|
554
|
-
}
|
|
555
|
-
function
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
function Ie({ keyedChildren: e, parent: t, runUnmount: n }) {
|
|
564
|
-
Object.values(e).forEach(({ vNode: o }) => {
|
|
565
|
-
!o.el || o.el.parentNode !== t || (n(o), t.removeChild(o.el));
|
|
550
|
+
const r = e.vNode;
|
|
551
|
+
o(i, n, r, t);
|
|
552
|
+
const s = n.el || r.el, c = i.childNodes[t];
|
|
553
|
+
s && c !== s && i.insertBefore(s, c);
|
|
554
|
+
}
|
|
555
|
+
function Ie({ index: e, newChild: t, parent: n, patchNode: i }) {
|
|
556
|
+
i(n, t, null, e);
|
|
557
|
+
const o = t.el, r = n.childNodes[e];
|
|
558
|
+
o && r && r !== o && n.insertBefore(o, r);
|
|
559
|
+
}
|
|
560
|
+
function ve({ keyedChildren: e, parent: t, runUnmount: n }) {
|
|
561
|
+
Object.values(e).forEach(({ vNode: i }) => {
|
|
562
|
+
!i.el || i.el.parentNode !== t || (n(i), t.removeChild(i.el));
|
|
566
563
|
});
|
|
567
564
|
}
|
|
568
|
-
function
|
|
565
|
+
function He() {
|
|
569
566
|
const e = {
|
|
570
567
|
index: 0,
|
|
571
568
|
parent: null,
|
|
@@ -581,7 +578,7 @@ function ve() {
|
|
|
581
578
|
props: e.vNode.props,
|
|
582
579
|
tag: e.vNode.tag
|
|
583
580
|
};
|
|
584
|
-
|
|
581
|
+
_({
|
|
585
582
|
index: e.index,
|
|
586
583
|
newVNode: t,
|
|
587
584
|
oldVNode: e.vNode,
|
|
@@ -589,73 +586,93 @@ function ve() {
|
|
|
589
586
|
});
|
|
590
587
|
}, e;
|
|
591
588
|
}
|
|
592
|
-
function
|
|
593
|
-
const
|
|
594
|
-
t.instance =
|
|
595
|
-
const c =
|
|
596
|
-
t.child = c,
|
|
589
|
+
function _({ index: e, newVNode: t, oldVNode: n, parent: i }) {
|
|
590
|
+
const o = n?.instance?.vNode || n, r = o?.instance || He(), s = !o;
|
|
591
|
+
t.instance = r, r.index = e, r.isMounted = !0, r.parent = i;
|
|
592
|
+
const c = w(t, r.update);
|
|
593
|
+
t.child = c, K(i, c, o?.child, e), t.el = typeof c == "object" && c !== null ? c.el : i.childNodes[e], s && P(t.hooks), s || N({
|
|
597
594
|
newHooks: t.hooks,
|
|
598
|
-
oldHooks:
|
|
599
|
-
}), s || (t.hooks =
|
|
595
|
+
oldHooks: o.hooks
|
|
596
|
+
}), s || (t.hooks = o.hooks), r.vNode = t;
|
|
597
|
+
}
|
|
598
|
+
function $(e) {
|
|
599
|
+
return typeof e?.tag == "function";
|
|
600
600
|
}
|
|
601
|
-
function
|
|
601
|
+
function Le(e, t) {
|
|
602
|
+
return $(e) && $(t) && e.tag !== t.tag;
|
|
603
|
+
}
|
|
604
|
+
function K(e, t, n, i = 0) {
|
|
602
605
|
if (t == null) {
|
|
603
|
-
const
|
|
604
|
-
|
|
606
|
+
const r = n?.el || e.childNodes[i];
|
|
607
|
+
g(n), r && r.parentNode === e && e.removeChild(r);
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
if (Le(t, n)) {
|
|
611
|
+
const r = n.el || n.child?.el || e.childNodes[i];
|
|
612
|
+
g(n);
|
|
613
|
+
const s = document.createDocumentFragment();
|
|
614
|
+
_({ index: 0, newVNode: t, oldVNode: null, parent: s }), t.instance.parent = e, t.instance.index = i;
|
|
615
|
+
const c = t.el || s.firstChild;
|
|
616
|
+
if (r && r.parentNode === e)
|
|
617
|
+
e.replaceChild(c, r);
|
|
618
|
+
else {
|
|
619
|
+
const u = e.childNodes[i];
|
|
620
|
+
u && u.parentNode === e ? e.replaceChild(c, u) : e.appendChild(c);
|
|
621
|
+
}
|
|
605
622
|
return;
|
|
606
623
|
}
|
|
607
624
|
if (typeof t.tag == "function") {
|
|
608
|
-
|
|
625
|
+
_({ index: i, newVNode: t, oldVNode: n, parent: e });
|
|
609
626
|
return;
|
|
610
627
|
}
|
|
611
628
|
if (n == null) {
|
|
612
|
-
e.appendChild(
|
|
629
|
+
e.appendChild(A(t, T(e)));
|
|
613
630
|
return;
|
|
614
631
|
}
|
|
615
632
|
if (typeof t != typeof n || typeof t != "string" && t.tag !== n.tag) {
|
|
616
|
-
const
|
|
617
|
-
|
|
633
|
+
const r = n.el || e.childNodes[i];
|
|
634
|
+
r && e.replaceChild(A(t, T(e)), r);
|
|
618
635
|
return;
|
|
619
636
|
}
|
|
620
637
|
if (typeof t == "string" || typeof t == "number") {
|
|
621
638
|
if (t !== n) {
|
|
622
|
-
const
|
|
623
|
-
|
|
639
|
+
const r = e.childNodes[i];
|
|
640
|
+
r ? r.nodeValue = String(t) : e.appendChild(document.createTextNode(String(t)));
|
|
624
641
|
}
|
|
625
642
|
return;
|
|
626
643
|
}
|
|
627
|
-
const
|
|
628
|
-
|
|
644
|
+
const o = n.el || e.childNodes[i];
|
|
645
|
+
o && (t.el = o, z(o, t.props, n.props), Me({
|
|
629
646
|
oldChildren: n.children,
|
|
630
647
|
newChildren: t.children,
|
|
631
|
-
parent:
|
|
632
|
-
patchNode:
|
|
633
|
-
runUnmount:
|
|
648
|
+
parent: o,
|
|
649
|
+
patchNode: K,
|
|
650
|
+
runUnmount: g
|
|
634
651
|
}));
|
|
635
652
|
}
|
|
636
|
-
const
|
|
653
|
+
const De = (e, t) => {
|
|
637
654
|
let n = null;
|
|
638
655
|
(() => {
|
|
639
|
-
const
|
|
656
|
+
const o = {
|
|
640
657
|
tag: t,
|
|
641
658
|
props: {},
|
|
642
659
|
children: []
|
|
643
660
|
};
|
|
644
|
-
|
|
661
|
+
K(e, o, n), n = o;
|
|
645
662
|
})();
|
|
646
|
-
},
|
|
663
|
+
}, Fe = (e, t = {}) => ({
|
|
647
664
|
__humn_persist: !0,
|
|
648
665
|
initial: e,
|
|
649
666
|
config: t
|
|
650
667
|
});
|
|
651
668
|
export {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
669
|
+
Te as Cortex,
|
|
670
|
+
Z as cloneVNode,
|
|
671
|
+
Re as css,
|
|
672
|
+
$e as h,
|
|
673
|
+
De as mount,
|
|
674
|
+
je as onCleanup,
|
|
675
|
+
Oe as onMount,
|
|
676
|
+
Fe as persist
|
|
660
677
|
};
|
|
661
678
|
//# sourceMappingURL=humn.js.map
|