Comparing version
@@ -32,3 +32,3 @@ export declare const append: unique symbol; | ||
export declare const render: (node: any, root: HTMLElement) => TreeNode; | ||
export declare const render: (node: any, root: HTMLElement) => any; | ||
@@ -35,0 +35,0 @@ export declare const set: unique symbol; |
@@ -1,5 +0,5 @@ | ||
import { contextStack as E } from "./contexts.js"; | ||
import { currentContext as g, contextStack as x } from "./contexts.js"; | ||
import { useEffect as v } from "./signals.js"; | ||
const d = Symbol("insert"), P = Symbol("append"), C = Symbol("assign"), O = Symbol("set"), A = Symbol("create"), b = Symbol("listeners"), m = Symbol("on"), w = Symbol("childrenIndex"), i = Symbol("remove"), f = Symbol("context"), B = Symbol("call"), T = Symbol("empty"), I = Symbol("parent"), S = Symbol("cleanup"), y = Element.prototype; | ||
y[i] = Text.prototype[i] = function() { | ||
const d = Symbol("insert"), C = Symbol("append"), O = Symbol("assign"), A = Symbol("set"), B = Symbol("create"), b = Symbol("listeners"), m = Symbol("on"), w = Symbol("childrenIndex"), l = Symbol("remove"), i = Symbol("context"), I = Symbol("call"), P = Symbol("empty"), G = Symbol("parent"), a = Symbol("cleanup"), y = Element.prototype; | ||
y[l] = Text.prototype[l] = function() { | ||
this.remove(); | ||
@@ -14,3 +14,3 @@ }; | ||
let j; | ||
y[T] = function() { | ||
y[P] = function() { | ||
return j ?? (j = document.createTextNode("")), j.cloneNode(); | ||
@@ -28,3 +28,3 @@ }; | ||
}; | ||
o[i] = function() { | ||
o[l] = function() { | ||
const t = this[b].remove; | ||
@@ -34,12 +34,12 @@ if (t) | ||
}; | ||
o[A] = function(...t) { | ||
o[B] = function(...t) { | ||
return Reflect.construct(this, t); | ||
}; | ||
o[P] = function(...t) { | ||
return h(this, t, this), this; | ||
o[C] = function(...t) { | ||
return p(this, t, this), this; | ||
}; | ||
o[S] = function() { | ||
o[a] = function() { | ||
const t = this[b], n = t.cleanup; | ||
if (n) for (const e of n) e(); | ||
delete t.cleanup, this[i](); | ||
delete t.cleanup, this[l](); | ||
}; | ||
@@ -50,47 +50,47 @@ o[m] = function(t, n) { | ||
}; | ||
o[O] = function(t, ...n) { | ||
o[A] = function(t, ...n) { | ||
const e = n.pop(); | ||
return N(this, n)[e] = t, this; | ||
}; | ||
o[C] = function(t, ...n) { | ||
o[O] = function(t, ...n) { | ||
const e = n.pop(), c = N(this, n); | ||
return v(() => c[e] = t()), this; | ||
}; | ||
o[B] = function(t, ...n) { | ||
const e = n.pop(), c = N(this, n), l = c[e].bind(c); | ||
return v(() => l(...t())), this; | ||
o[I] = function(t, ...n) { | ||
const e = n.pop(), c = N(this, n), u = c[e].bind(c); | ||
return v(() => u(...t())), this; | ||
}; | ||
const p = Symbol("l"); | ||
const h = Symbol("l"); | ||
Object.defineProperty(o, b, { | ||
get() { | ||
return this[p] ?? (this[p] = {}), this[p]; | ||
return this[h] ?? (this[h] = {}), this[h]; | ||
} | ||
}); | ||
function h(t, n, e, c = { v: -1 }) { | ||
let l = null; | ||
for (let a = 0; a < n.length; a++) { | ||
const u = n[a]; | ||
if (typeof u == "function") { | ||
function p(t, n, e, c = { v: -1 }) { | ||
let u = null; | ||
for (let S = 0; S < n.length; S++) { | ||
const f = n[S]; | ||
if (typeof f == "function") { | ||
let s = c; | ||
v(() => { | ||
const r = new Object(); | ||
e[m]("remove", () => r[i]()), e[m]("cleanup", () => r[S]()), r[f] = { | ||
...e[f], | ||
[d]: (...g) => h(t, g, r, s), | ||
[I]: r | ||
}, E.push(r[f]); | ||
const x = h(t, [u()], r, s); | ||
return E.pop(), l ?? (l = x), () => { | ||
s = { v: t[w](x) }, r[i](); | ||
e[m]("remove", () => r[l]()), e[m]("cleanup", () => r[a]()), e[i] ?? (e[i] = g()), r[i] = { | ||
...e[i], | ||
[d]: (...T) => p(t, T, r, s), | ||
[G]: r | ||
}, x.push(r[i]); | ||
const E = p(t, [f()], r, s); | ||
return x.pop(), u ?? (u = E), () => { | ||
s = { v: t[w](E) }, r[l](); | ||
}; | ||
}); | ||
} else if (Array.isArray(u)) { | ||
const s = h(t, u, e, c); | ||
l ?? (l = s); | ||
} else if (Array.isArray(f)) { | ||
const s = p(t, f, e, c); | ||
u ?? (u = s); | ||
} else { | ||
const s = t[d](u ?? t[T](), c.v); | ||
c.v > -1 && c.v++, s[f] = e[f], e[m]("remove", () => s[i]()), e[m]("cleanup", () => s[S]()), l ?? (l = s); | ||
const s = t[d](f ?? t[P](), c.v); | ||
c.v > -1 && c.v++, s[i] = e[i], e[m]("remove", () => s[l]()), e[m]("cleanup", () => s[a]()), u ?? (u = s); | ||
} | ||
} | ||
return l; | ||
return u; | ||
} | ||
@@ -101,21 +101,21 @@ function N(t, n) { | ||
} | ||
const V = document.createElement.bind(document), q = document.createElementNS.bind(document, "http://www.w3.org/2000/svg"), z = (t, n) => n[P](t); | ||
const q = document.createElement.bind(document), z = document.createElementNS.bind(document, "http://www.w3.org/2000/svg"), D = (t, n) => n[C](t); | ||
export { | ||
P as append, | ||
C as assign, | ||
B as call, | ||
C as append, | ||
O as assign, | ||
I as call, | ||
w as childrenIndex, | ||
S as cleanup, | ||
f as context, | ||
A as create, | ||
V as createElement, | ||
q as createSVGElement, | ||
T as empty, | ||
a as cleanup, | ||
i as context, | ||
B as create, | ||
q as createElement, | ||
z as createSVGElement, | ||
P as empty, | ||
d as insert, | ||
b as listeners, | ||
m as on, | ||
I as parent, | ||
i as remove, | ||
z as render, | ||
O as set | ||
G as parent, | ||
l as remove, | ||
D as render, | ||
A as set | ||
}; |
{ | ||
"name": "battuta", | ||
"private": false, | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -0,0 +0,0 @@ # Battuta |
61783
0.92%