1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-22 07:49:38 +01:00
This commit is contained in:
Jan Andrle 2023-09-13 13:20:00 +02:00
parent 5436e50a95
commit d7e0b17e38
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
6 changed files with 390 additions and 376 deletions

View File

@ -1,7 +1,26 @@
//deka-dom-el library is available via global namespace `dde` //deka-dom-el library is available via global namespace `dde`
(()=> { (()=> {
// src/signals-common.js
var x = {
isTextContent(e) {
return typeof e == "string";
},
processReactiveAttribute(e, t, r, n) {
return r;
}
};
function _(e, t = !0) {
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e);
}
function N(e) {
return x.isPrototypeOf(e) && e !== x ? e : x;
}
// src/helpers.js // src/helpers.js
function m(e) { function m(e) {
return typeof e > "u";
}
function w(e) {
let t = typeof e; let t = typeof e;
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e); return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
} }
@ -14,75 +33,65 @@
}; };
} }
// src/signals-common.js // src/dom-common.js
var b = { var b = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), T = { setDelete: $ };
isTextContent(e) { function $(e, t, r) {
return m(e) !== "[object Object]"; Reflect.set(e, t, r), m(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
},
processReactiveAttribute(e, t, r, n) {
return r;
}
};
function N(e, t = !0) {
return t ? Object.assign(b, e) : (Object.setPrototypeOf(e, b), e);
}
function A(e) {
return b.isPrototypeOf(e) && e !== b ? e : b;
} }
// src/dom.js // src/dom.js
var O = "html"; var S = "html";
function te(e) { function oe(e) {
return O = e === "svg" ? "http://www.w3.org/2000/svg" : e, { return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
append(t) { append(t) {
return O = "html", t; return S = "html", t;
} }
}; };
} }
function ne(e, t, ...r) { function ce(e, t, ...r) {
let n = A(this), o; let n = N(this), o;
switch (n.isTextContent(t) && (t = { textContent: t }), !0) { switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
o = e(t || void 0, (i) => i ? (r.unshift(i), void 0) : o); o = e(t || void 0, (i) => i ? (r.unshift(i), void 0) : o);
break; break;
} }
case e === "#text": case e === "#text":
o = w(document.createTextNode(""), t); o = y(document.createTextNode(""), t);
break; break;
case e === "<>": case e === "<>":
o = w(document.createDocumentFragment(), t); o = y(document.createDocumentFragment(), t);
break; break;
case O !== "html": case S !== "html":
o = w(document.createElementNS(O, e), t); o = y(document.createElementNS(S, e), t);
break; break;
case !o: case !o:
o = w(document.createElement(e), t); o = y(document.createElement(e), t);
} }
return r.forEach((a) => a(o)), o; return r.forEach((a) => a(o)), o;
} }
var x = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')); var { setDelete: D } = T;
function w(e, ...t) { function y(e, ...t) {
let r = A(this); let r = N(this);
if (!t.length) if (!t.length)
return e; return e;
let n = e instanceof SVGElement, o = (n ? J : T).bind(null, e, "Attribute"); let n = e instanceof SVGElement, o = (n ? W : M).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function a([i, s]) { return Object.entries(Object.assign({}, ...t)).forEach(function a([i, s]) {
s = r.processReactiveAttribute(e, i, s, a); s = r.processReactiveAttribute(e, i, s, a);
let [h] = i; let [h] = i;
if (h === "=") if (h === "=")
return o(i.slice(1), s); return o(i.slice(1), s);
if (h === ".") if (h === ".")
return _(e, i.slice(1), s); return D(e, i.slice(1), s);
if (typeof s == "object") if (typeof s == "object")
switch (i) { switch (i) {
case "style": case "style":
return y(s, T.bind(null, e.style, "Property")); return O(s, M.bind(null, e.style, "Property"));
case "dataset": case "dataset":
return y(s, _.bind(null, e.dataset)); return O(s, D.bind(null, e.dataset));
case "ariaset": case "ariaset":
return y(s, (E, v) => o("aria-" + E, v)); return O(s, (E, v) => o("aria-" + E, v));
case "classList": case "classList":
return $(e, s); return q(e, s);
default: default:
return Reflect.set(e, i, s); return Reflect.set(e, i, s);
} }
@ -98,72 +107,66 @@
break; break;
return e.appendChild(document.createTextNode(s)); return e.appendChild(document.createTextNode(s));
} }
return q(e, i) ? _(e, i, s) : o(i, s); return J(e, i) ? D(e, i, s) : o(i, s);
}), e; }), e;
} }
function $(e, t) { function q(e, t) {
return typeof t != "object" || y( return typeof t != "object" || O(
t, t,
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n) (r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
), e; ), e;
} }
function re(e) { function se(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function q(e, t) { function J(e, t) {
let r = "HTMLElement," + t; let r = "HTMLElement," + t;
if (e instanceof HTMLElement && x.has(r)) if (e instanceof HTMLElement && b.has(r))
return x.get(r); return b.get(r);
let n = e.nodeName + "," + t; let n = e.nodeName + "," + t;
if (x.has(n)) if (b.has(n))
return x.get(n); return b.get(n);
let [o, a, i] = M(e, t), s = !P(o.set); let [o, a, i] = H(e, t), s = !m(o.set);
return (!s || a) && x.set(i === HTMLElement.prototype ? r : n, s), s; return (!s || a) && b.set(i === HTMLElement.prototype ? r : n, s), s;
} }
function M(e, t, r = 0) { function H(e, t, r = 0) {
if (e = Object.getPrototypeOf(e), !e) if (e = Object.getPrototypeOf(e), !e)
return [{}, r, e]; return [{}, r, e];
let n = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return n ? [n, r, e] : M(e, t, r + 1); return n ? [n, r, e] : H(e, t, r + 1);
} }
function y(e, t) { function O(e, t) {
return Object.entries(e).forEach(([r, n]) => t(r, n)); return Object.entries(e).forEach(([r, n]) => t(r, n));
} }
function P(e) { function M(e, t, r, n) {
return typeof e > "u"; return e[(m(n) ? "remove" : "set") + t](r, n);
} }
function T(e, t, r, n) { function W(e, t, r, n, o = null) {
return e[(P(n) ? "remove" : "set") + t](r, n); return e[(m(n) ? "remove" : "set") + t + "NS"](o, r, n);
}
function J(e, t, r, n, o = null) {
return e[(P(n) ? "remove" : "set") + t + "NS"](o, r, n);
}
function _(e, t, r) {
return Reflect.set(e, t, r);
} }
// src/events.js // src/events.js
function ce(e, t, ...r) { function ae(e, t, ...r) {
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t); let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
return e.dispatchEvent(n); return e.dispatchEvent(n);
} }
function H(e, t, r) { function k(e, t, r) {
return function(o) { return function(o) {
return o.addEventListener(e, t, r), o; return o.addEventListener(e, t, r), o;
}; };
} }
var S = W(); var C = I();
H.connected = function(e, t) { k.connected = function(e, t) {
return function(n) { return function(n) {
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (j(t && t.signal, () => S.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : S.onConnected(n, e)), n); return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (j(t && t.signal, () => C.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : C.onConnected(n, e)), n);
}; };
}; };
H.disconnected = function(e, t) { k.disconnected = function(e, t) {
return function(n) { return function(n) {
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (j(t && t.signal, () => S.offDisconnected(n, e)) && S.onDisconnected(n, e), n); return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (j(t && t.signal, () => C.offDisconnected(n, e)) && C.onDisconnected(n, e), n);
}; };
}; };
function W() { function I() {
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(c) { let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(c) {
for (let f of c) for (let f of c)
if (f.type === "childList") { if (f.type === "childList") {
@ -228,7 +231,7 @@
if (f && h(u).then(E), !e.has(u)) if (f && h(u).then(E), !e.has(u))
continue; continue;
let p = e.get(u); let p = e.get(u);
return p.connected.forEach((R) => R(u)), p.connected.length = 0, p.disconnected.length || e.delete(u), !0; return p.connected.forEach((A) => A(u)), p.connected.length = 0, p.disconnected.length || e.delete(u), !0;
} }
return !1; return !1;
} }
@ -237,7 +240,7 @@
if (f && h(u).then(v), !e.has(u)) if (f && h(u).then(v), !e.has(u))
continue; continue;
let p = e.get(u); let p = e.get(u);
return p.disconnected.forEach((R) => R(u)), p.connected.length = 0, p.disconnected.length = 0, e.delete(u), !0; return p.disconnected.forEach((A) => A(u)), p.connected.length = 0, p.disconnected.length = 0, e.delete(u), !0;
} }
return !1; return !1;
} }
@ -253,7 +256,7 @@
// src/signals-lib.js // src/signals-lib.js
var d = Symbol.for("Signal"); var d = Symbol.for("Signal");
function C(e) { function L(e) {
try { try {
return Reflect.has(e, d); return Reflect.has(e, d);
} catch { } catch {
@ -263,11 +266,11 @@
var l = /* @__PURE__ */ new WeakMap(); var l = /* @__PURE__ */ new WeakMap();
function g(e, t) { function g(e, t) {
if (typeof e != "function") if (typeof e != "function")
return k(e, t); return z(e, t);
if (C(e)) if (L(e))
return e; return e;
let r = k(""), n = () => r(e()); let r = z(""), n = () => r(e());
return l.set(n, /* @__PURE__ */ new Set([r])), Z(n), r; return l.set(n, /* @__PURE__ */ new Set([r])), G(n), r;
} }
g.action = function(e, t, ...r) { g.action = function(e, t, ...r) {
let n = e[d], { actions: o } = n; let n = e[d], { actions: o } = n;
@ -282,7 +285,7 @@
if (!(o && o.aborted)) { if (!(o && o.aborted)) {
if (Array.isArray(t)) if (Array.isArray(t))
return t.forEach((a) => e(a, r, n)); return t.forEach((a) => e(a, r, n));
D(t, r), o && o.addEventListener("abort", () => F(t, r)); P(t, r), o && o.addEventListener("abort", () => U(t, r));
} }
}; };
g.symbols = { g.symbols = {
@ -309,7 +312,7 @@
o.append(r, n); o.append(r, n);
let a = (i) => { let a = (i) => {
if (!r.parentNode || !n.parentNode) if (!r.parentNode || !n.parentNode)
return F(e, a); return U(e, a);
let s = t(i); let s = t(i);
Array.isArray(s) || (s = [s]); Array.isArray(s) || (s = [s]);
let h = r; let h = r;
@ -317,82 +320,82 @@
h.remove(); h.remove();
r.after(...s); r.after(...s);
}; };
return D(e, a), a(e()), o; return P(e, a), a(e()), o;
}; };
var z = { var F = {
isTextContent(e) { isTextContent(e) {
return m(e) === "string" || C(e) && m(K(e)) === "string"; return w(e) === "string" || L(e) && w(X(e)) === "string";
}, },
processReactiveAttribute(e, t, r, n) { processReactiveAttribute(e, t, r, n) {
return C(r) ? (D(r, (o) => n([t, o])), r()) : r; return L(r) ? (P(r, (o) => n([t, o])), r()) : r;
} }
}; };
function k(e, t) { function z(e, t) {
let r = (...n) => n.length ? V(r, n[0]) : G(r); let r = (...n) => n.length ? Q(r, n[0]) : K(r);
return U(r, e, t); return B(r, e, t);
} }
var I = Object.assign(/* @__PURE__ */ Object.create(null), { var Z = Object.assign(/* @__PURE__ */ Object.create(null), {
stopPropagation() { stopPropagation() {
this.skip = !0; this.skip = !0;
} }
}); });
function U(e, t, r) { function B(e, t, r) {
return m(r) !== "[object Object]" && (r = {}), e[d] = { return w(r) !== "[object Object]" && (r = {}), e[d] = {
value: t, value: t,
actions: r, actions: r,
listeners: /* @__PURE__ */ new Set() listeners: /* @__PURE__ */ new Set()
}, e.toJSON = () => e(), Object.setPrototypeOf(e[d], I), e; }, e.toJSON = () => e(), Object.setPrototypeOf(e[d], Z), e;
} }
var L = []; var R = [];
function Z(e) { function G(e) {
let t = function() { let t = function() {
L.push(t), e(), L.pop(); R.push(t), e(), R.pop();
}; };
l.has(e) && (l.set(t, l.get(e)), l.delete(e)), t(); l.has(e) && (l.set(t, l.get(e)), l.delete(e)), t();
} }
function B() { function V() {
return L[L.length - 1]; return R[R.length - 1];
} }
function G(e) { function K(e) {
if (!e[d]) if (!e[d])
return; return;
let { value: t, listeners: r } = e[d], n = B(); let { value: t, listeners: r } = e[d], n = V();
return n && r.add(n), l.has(n) && l.get(n).add(e), t; return n && r.add(n), l.has(n) && l.get(n).add(e), t;
} }
function V(e, t) { function Q(e, t) {
if (!e[d]) if (!e[d])
return; return;
let r = e[d]; let r = e[d];
if (r.value !== t) if (r.value !== t)
return r.value = t, r.listeners.forEach((n) => n(t)), t; return r.value = t, r.listeners.forEach((n) => n(t)), t;
} }
function K(e) { function X(e) {
return e[d].value; return e[d].value;
} }
function D(e, t) { function P(e, t) {
if (e[d]) if (e[d])
return e[d].listeners.add(t); return e[d].listeners.add(t);
} }
function F(e, t) { function U(e, t) {
if (e[d]) if (e[d])
return e[d].listeners.delete(t); return e[d].listeners.delete(t);
} }
// src/signals.js // src/signals.js
N(z); _(F);
globalThis.dde= { globalThis.dde= {
S: g, S: g,
assign: w, assign: y,
classListDeclarative: $, classListDeclarative: q,
createElement: ne, createElement: ce,
dispatchEvent: ce, dispatchEvent: ae,
el: ne, el: ce,
empty: re, empty: se,
isSignal: C, isSignal: L,
namespace: te, namespace: oe,
on: H, on: k,
registerReactivity: N registerReactivity: _
}; };
})(); })();

155
dist/dde.js vendored
View File

@ -1,11 +1,26 @@
//deka-dom-el library is available via global namespace `dde` //deka-dom-el library is available via global namespace `dde`
(()=> { (()=> {
// src/helpers.js // src/signals-common.js
function N(e) { var g = {
let t = typeof e; isTextContent(e) {
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e); return typeof e == "string";
},
processReactiveAttribute(e, t, r, n) {
return r;
} }
function O(e, t) { };
function T(e, t = !0) {
return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e);
}
function O(e) {
return g.isPrototypeOf(e) && e !== g ? e : g;
}
// src/helpers.js
function p(e) {
return typeof e > "u";
}
function L(e, t) {
if (!e || !(e instanceof AbortSignal)) if (!e || !(e instanceof AbortSignal))
return !0; return !0;
if (!e.aborted) if (!e.aborted)
@ -14,33 +29,23 @@
}; };
} }
// src/signals-common.js // src/dom-common.js
var l = { var h = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), A = { setDelete: R };
isTextContent(e) { function R(e, t, r) {
return N(e) !== "[object Object]"; Reflect.set(e, t, r), p(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
},
processReactiveAttribute(e, t, r, n) {
return r;
}
};
function D(e, t = !0) {
return t ? Object.assign(l, e) : (Object.setPrototypeOf(e, l), e);
}
function C(e) {
return l.isPrototypeOf(e) && e !== l ? e : l;
} }
// src/dom.js // src/dom.js
var v = "html"; var m = "html";
function F(e) { function I(e) {
return v = e === "svg" ? "http://www.w3.org/2000/svg" : e, { return m = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
append(t) { append(t) {
return v = "html", t; return m = "html", t;
} }
}; };
} }
function I(e, t, ...r) { function Z(e, t, ...r) {
let n = C(this), c; let n = O(this), c;
switch (n.isTextContent(t) && (t = { textContent: t }), !0) { switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
c = e(t || void 0, (s) => s ? (r.unshift(s), void 0) : c); c = e(t || void 0, (s) => s ? (r.unshift(s), void 0) : c);
@ -52,37 +57,37 @@
case e === "<>": case e === "<>":
c = E(document.createDocumentFragment(), t); c = E(document.createDocumentFragment(), t);
break; break;
case v !== "html": case m !== "html":
c = E(document.createElementNS(v, e), t); c = E(document.createElementNS(m, e), t);
break; break;
case !c: case !c:
c = E(document.createElement(e), t); c = E(document.createElement(e), t);
} }
return r.forEach((a) => a(c)), c; return r.forEach((a) => a(c)), c;
} }
var h = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')); var { setDelete: y } = A;
function E(e, ...t) { function E(e, ...t) {
let r = C(this); let r = O(this);
if (!t.length) if (!t.length)
return e; return e;
let n = e instanceof SVGElement, c = (n ? S : j).bind(null, e, "Attribute"); let n = e instanceof SVGElement, c = (n ? S : N).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function a([s, f]) { return Object.entries(Object.assign({}, ...t)).forEach(function a([s, f]) {
f = r.processReactiveAttribute(e, s, f, a); f = r.processReactiveAttribute(e, s, f, a);
let [p] = s; let [l] = s;
if (p === "=") if (l === "=")
return c(s.slice(1), f); return c(s.slice(1), f);
if (p === ".") if (l === ".")
return L(e, s.slice(1), f); return y(e, s.slice(1), f);
if (typeof f == "object") if (typeof f == "object")
switch (s) { switch (s) {
case "style": case "style":
return x(f, j.bind(null, e.style, "Property")); return v(f, N.bind(null, e.style, "Property"));
case "dataset": case "dataset":
return x(f, L.bind(null, e.dataset)); return v(f, y.bind(null, e.dataset));
case "ariaset": case "ariaset":
return x(f, (g, b) => c("aria-" + g, b)); return v(f, (x, b) => c("aria-" + x, b));
case "classList": case "classList":
return R(e, f); return j(e, f);
default: default:
return Reflect.set(e, s, f); return Reflect.set(e, s, f);
} }
@ -98,16 +103,16 @@
break; break;
return e.appendChild(document.createTextNode(f)); return e.appendChild(document.createTextNode(f));
} }
return M(e, s) ? L(e, s, f) : c(s, f); return M(e, s) ? y(e, s, f) : c(s, f);
}), e; }), e;
} }
function R(e, t) { function j(e, t) {
return typeof t != "object" || x( return typeof t != "object" || v(
t, t,
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n) (r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
), e; ), e;
} }
function U(e) { function B(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function M(e, t) { function M(e, t) {
@ -117,57 +122,51 @@
let n = e.nodeName + "," + t; let n = e.nodeName + "," + t;
if (h.has(n)) if (h.has(n))
return h.get(n); return h.get(n);
let [c, a, s] = A(e, t), f = !y(c.set); let [c, a, s] = _(e, t), f = !p(c.set);
return (!f || a) && h.set(s === HTMLElement.prototype ? r : n, f), f; return (!f || a) && h.set(s === HTMLElement.prototype ? r : n, f), f;
} }
function A(e, t, r = 0) { function _(e, t, r = 0) {
if (e = Object.getPrototypeOf(e), !e) if (e = Object.getPrototypeOf(e), !e)
return [{}, r, e]; return [{}, r, e];
let n = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return n ? [n, r, e] : A(e, t, r + 1); return n ? [n, r, e] : _(e, t, r + 1);
} }
function x(e, t) { function v(e, t) {
return Object.entries(e).forEach(([r, n]) => t(r, n)); return Object.entries(e).forEach(([r, n]) => t(r, n));
} }
function y(e) { function N(e, t, r, n) {
return typeof e > "u"; return e[(p(n) ? "remove" : "set") + t](r, n);
}
function j(e, t, r, n) {
return e[(y(n) ? "remove" : "set") + t](r, n);
} }
function S(e, t, r, n, c = null) { function S(e, t, r, n, c = null) {
return e[(y(n) ? "remove" : "set") + t + "NS"](c, r, n); return e[(p(n) ? "remove" : "set") + t + "NS"](c, r, n);
}
function L(e, t, r) {
return Reflect.set(e, t, r);
} }
// src/events.js // src/events.js
function $(e, t, ...r) { function V(e, t, ...r) {
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t); let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
return e.dispatchEvent(n); return e.dispatchEvent(n);
} }
function T(e, t, r) { function D(e, t, r) {
return function(c) { return function(c) {
return c.addEventListener(e, t, r), c; return c.addEventListener(e, t, r), c;
}; };
} }
var m = _(); var w = P();
T.connected = function(e, t) { D.connected = function(e, t) {
return function(n) { return function(n) {
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (O(t && t.signal, () => m.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : m.onConnected(n, e)), n); return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (L(t && t.signal, () => w.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : w.onConnected(n, e)), n);
}; };
}; };
T.disconnected = function(e, t) { D.disconnected = function(e, t) {
return function(n) { return function(n) {
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (O(t && t.signal, () => m.offDisconnected(n, e)) && m.onDisconnected(n, e), n); return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (L(t && t.signal, () => w.offDisconnected(n, e)) && w.onDisconnected(n, e), n);
}; };
}; };
function _() { function P() {
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) { let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) {
for (let i of o) for (let i of o)
if (i.type === "childList") { if (i.type === "childList") {
if (g(i.addedNodes, !0)) { if (x(i.addedNodes, !0)) {
s(); s();
continue; continue;
} }
@ -214,7 +213,7 @@
(requestIdleCallback || requestAnimationFrame)(o); (requestIdleCallback || requestAnimationFrame)(o);
}); });
} }
async function p(o) { async function l(o) {
e.size > 30 && await f(); e.size > 30 && await f();
let i = []; let i = [];
if (!(o instanceof Node)) if (!(o instanceof Node))
@ -223,21 +222,21 @@
u === o || !(u instanceof Node) || o.contains(u) && i.push(u); u === o || !(u instanceof Node) || o.contains(u) && i.push(u);
return i; return i;
} }
function g(o, i) { function x(o, i) {
for (let u of o) { for (let u of o) {
if (i && p(u).then(g), !e.has(u)) if (i && l(u).then(x), !e.has(u))
continue; continue;
let d = e.get(u); let d = e.get(u);
return d.connected.forEach((w) => w(u)), d.connected.length = 0, d.disconnected.length || e.delete(u), !0; return d.connected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length || e.delete(u), !0;
} }
return !1; return !1;
} }
function b(o, i) { function b(o, i) {
for (let u of o) { for (let u of o) {
if (i && p(u).then(b), !e.has(u)) if (i && l(u).then(b), !e.has(u))
continue; continue;
let d = e.get(u); let d = e.get(u);
return d.disconnected.forEach((w) => w(u)), d.connected.length = 0, d.disconnected.length = 0, e.delete(u), !0; return d.disconnected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length = 0, e.delete(u), !0;
} }
return !1; return !1;
} }
@ -253,14 +252,14 @@
globalThis.dde= { globalThis.dde= {
assign: E, assign: E,
classListDeclarative: R, classListDeclarative: j,
createElement: I, createElement: Z,
dispatchEvent: $, dispatchEvent: V,
el: I, el: Z,
empty: U, empty: B,
namespace: F, namespace: I,
on: T, on: D,
registerReactivity: D registerReactivity: T
}; };
})(); })();

View File

@ -1,5 +1,24 @@
// src/signals-common.js
var x = {
isTextContent(e) {
return typeof e == "string";
},
processReactiveAttribute(e, t, r, n) {
return r;
}
};
function _(e, t = !0) {
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e);
}
function N(e) {
return x.isPrototypeOf(e) && e !== x ? e : x;
}
// src/helpers.js // src/helpers.js
function m(e) { function m(e) {
return typeof e > "u";
}
function w(e) {
let t = typeof e; let t = typeof e;
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e); return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
} }
@ -12,75 +31,65 @@ function j(e, t) {
}; };
} }
// src/signals-common.js // src/dom-common.js
var b = { var b = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), T = { setDelete: $ };
isTextContent(e) { function $(e, t, r) {
return m(e) !== "[object Object]"; Reflect.set(e, t, r), m(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
},
processReactiveAttribute(e, t, r, n) {
return r;
}
};
function N(e, t = !0) {
return t ? Object.assign(b, e) : (Object.setPrototypeOf(e, b), e);
}
function A(e) {
return b.isPrototypeOf(e) && e !== b ? e : b;
} }
// src/dom.js // src/dom.js
var O = "html"; var S = "html";
function te(e) { function oe(e) {
return O = e === "svg" ? "http://www.w3.org/2000/svg" : e, { return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
append(t) { append(t) {
return O = "html", t; return S = "html", t;
} }
}; };
} }
function ne(e, t, ...r) { function ce(e, t, ...r) {
let n = A(this), o; let n = N(this), o;
switch (n.isTextContent(t) && (t = { textContent: t }), !0) { switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
o = e(t || void 0, (i) => i ? (r.unshift(i), void 0) : o); o = e(t || void 0, (i) => i ? (r.unshift(i), void 0) : o);
break; break;
} }
case e === "#text": case e === "#text":
o = w(document.createTextNode(""), t); o = y(document.createTextNode(""), t);
break; break;
case e === "<>": case e === "<>":
o = w(document.createDocumentFragment(), t); o = y(document.createDocumentFragment(), t);
break; break;
case O !== "html": case S !== "html":
o = w(document.createElementNS(O, e), t); o = y(document.createElementNS(S, e), t);
break; break;
case !o: case !o:
o = w(document.createElement(e), t); o = y(document.createElement(e), t);
} }
return r.forEach((a) => a(o)), o; return r.forEach((a) => a(o)), o;
} }
var x = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')); var { setDelete: D } = T;
function w(e, ...t) { function y(e, ...t) {
let r = A(this); let r = N(this);
if (!t.length) if (!t.length)
return e; return e;
let n = e instanceof SVGElement, o = (n ? J : T).bind(null, e, "Attribute"); let n = e instanceof SVGElement, o = (n ? W : M).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function a([i, s]) { return Object.entries(Object.assign({}, ...t)).forEach(function a([i, s]) {
s = r.processReactiveAttribute(e, i, s, a); s = r.processReactiveAttribute(e, i, s, a);
let [h] = i; let [h] = i;
if (h === "=") if (h === "=")
return o(i.slice(1), s); return o(i.slice(1), s);
if (h === ".") if (h === ".")
return _(e, i.slice(1), s); return D(e, i.slice(1), s);
if (typeof s == "object") if (typeof s == "object")
switch (i) { switch (i) {
case "style": case "style":
return y(s, T.bind(null, e.style, "Property")); return O(s, M.bind(null, e.style, "Property"));
case "dataset": case "dataset":
return y(s, _.bind(null, e.dataset)); return O(s, D.bind(null, e.dataset));
case "ariaset": case "ariaset":
return y(s, (E, v) => o("aria-" + E, v)); return O(s, (E, v) => o("aria-" + E, v));
case "classList": case "classList":
return $(e, s); return q(e, s);
default: default:
return Reflect.set(e, i, s); return Reflect.set(e, i, s);
} }
@ -96,72 +105,66 @@ function w(e, ...t) {
break; break;
return e.appendChild(document.createTextNode(s)); return e.appendChild(document.createTextNode(s));
} }
return q(e, i) ? _(e, i, s) : o(i, s); return J(e, i) ? D(e, i, s) : o(i, s);
}), e; }), e;
} }
function $(e, t) { function q(e, t) {
return typeof t != "object" || y( return typeof t != "object" || O(
t, t,
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n) (r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
), e; ), e;
} }
function re(e) { function se(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function q(e, t) { function J(e, t) {
let r = "HTMLElement," + t; let r = "HTMLElement," + t;
if (e instanceof HTMLElement && x.has(r)) if (e instanceof HTMLElement && b.has(r))
return x.get(r); return b.get(r);
let n = e.nodeName + "," + t; let n = e.nodeName + "," + t;
if (x.has(n)) if (b.has(n))
return x.get(n); return b.get(n);
let [o, a, i] = M(e, t), s = !P(o.set); let [o, a, i] = H(e, t), s = !m(o.set);
return (!s || a) && x.set(i === HTMLElement.prototype ? r : n, s), s; return (!s || a) && b.set(i === HTMLElement.prototype ? r : n, s), s;
} }
function M(e, t, r = 0) { function H(e, t, r = 0) {
if (e = Object.getPrototypeOf(e), !e) if (e = Object.getPrototypeOf(e), !e)
return [{}, r, e]; return [{}, r, e];
let n = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return n ? [n, r, e] : M(e, t, r + 1); return n ? [n, r, e] : H(e, t, r + 1);
} }
function y(e, t) { function O(e, t) {
return Object.entries(e).forEach(([r, n]) => t(r, n)); return Object.entries(e).forEach(([r, n]) => t(r, n));
} }
function P(e) { function M(e, t, r, n) {
return typeof e > "u"; return e[(m(n) ? "remove" : "set") + t](r, n);
} }
function T(e, t, r, n) { function W(e, t, r, n, o = null) {
return e[(P(n) ? "remove" : "set") + t](r, n); return e[(m(n) ? "remove" : "set") + t + "NS"](o, r, n);
}
function J(e, t, r, n, o = null) {
return e[(P(n) ? "remove" : "set") + t + "NS"](o, r, n);
}
function _(e, t, r) {
return Reflect.set(e, t, r);
} }
// src/events.js // src/events.js
function ce(e, t, ...r) { function ae(e, t, ...r) {
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t); let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
return e.dispatchEvent(n); return e.dispatchEvent(n);
} }
function H(e, t, r) { function k(e, t, r) {
return function(o) { return function(o) {
return o.addEventListener(e, t, r), o; return o.addEventListener(e, t, r), o;
}; };
} }
var S = W(); var C = I();
H.connected = function(e, t) { k.connected = function(e, t) {
return function(n) { return function(n) {
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (j(t && t.signal, () => S.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : S.onConnected(n, e)), n); return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (j(t && t.signal, () => C.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : C.onConnected(n, e)), n);
}; };
}; };
H.disconnected = function(e, t) { k.disconnected = function(e, t) {
return function(n) { return function(n) {
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (j(t && t.signal, () => S.offDisconnected(n, e)) && S.onDisconnected(n, e), n); return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (j(t && t.signal, () => C.offDisconnected(n, e)) && C.onDisconnected(n, e), n);
}; };
}; };
function W() { function I() {
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(c) { let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(c) {
for (let f of c) for (let f of c)
if (f.type === "childList") { if (f.type === "childList") {
@ -226,7 +229,7 @@ function W() {
if (f && h(u).then(E), !e.has(u)) if (f && h(u).then(E), !e.has(u))
continue; continue;
let p = e.get(u); let p = e.get(u);
return p.connected.forEach((R) => R(u)), p.connected.length = 0, p.disconnected.length || e.delete(u), !0; return p.connected.forEach((A) => A(u)), p.connected.length = 0, p.disconnected.length || e.delete(u), !0;
} }
return !1; return !1;
} }
@ -235,7 +238,7 @@ function W() {
if (f && h(u).then(v), !e.has(u)) if (f && h(u).then(v), !e.has(u))
continue; continue;
let p = e.get(u); let p = e.get(u);
return p.disconnected.forEach((R) => R(u)), p.connected.length = 0, p.disconnected.length = 0, e.delete(u), !0; return p.disconnected.forEach((A) => A(u)), p.connected.length = 0, p.disconnected.length = 0, e.delete(u), !0;
} }
return !1; return !1;
} }
@ -251,7 +254,7 @@ function W() {
// src/signals-lib.js // src/signals-lib.js
var d = Symbol.for("Signal"); var d = Symbol.for("Signal");
function C(e) { function L(e) {
try { try {
return Reflect.has(e, d); return Reflect.has(e, d);
} catch { } catch {
@ -261,11 +264,11 @@ function C(e) {
var l = /* @__PURE__ */ new WeakMap(); var l = /* @__PURE__ */ new WeakMap();
function g(e, t) { function g(e, t) {
if (typeof e != "function") if (typeof e != "function")
return k(e, t); return z(e, t);
if (C(e)) if (L(e))
return e; return e;
let r = k(""), n = () => r(e()); let r = z(""), n = () => r(e());
return l.set(n, /* @__PURE__ */ new Set([r])), Z(n), r; return l.set(n, /* @__PURE__ */ new Set([r])), G(n), r;
} }
g.action = function(e, t, ...r) { g.action = function(e, t, ...r) {
let n = e[d], { actions: o } = n; let n = e[d], { actions: o } = n;
@ -280,7 +283,7 @@ g.on = function e(t, r, n = {}) {
if (!(o && o.aborted)) { if (!(o && o.aborted)) {
if (Array.isArray(t)) if (Array.isArray(t))
return t.forEach((a) => e(a, r, n)); return t.forEach((a) => e(a, r, n));
D(t, r), o && o.addEventListener("abort", () => F(t, r)); P(t, r), o && o.addEventListener("abort", () => U(t, r));
} }
}; };
g.symbols = { g.symbols = {
@ -307,7 +310,7 @@ g.el = function(e, t) {
o.append(r, n); o.append(r, n);
let a = (i) => { let a = (i) => {
if (!r.parentNode || !n.parentNode) if (!r.parentNode || !n.parentNode)
return F(e, a); return U(e, a);
let s = t(i); let s = t(i);
Array.isArray(s) || (s = [s]); Array.isArray(s) || (s = [s]);
let h = r; let h = r;
@ -315,79 +318,79 @@ g.el = function(e, t) {
h.remove(); h.remove();
r.after(...s); r.after(...s);
}; };
return D(e, a), a(e()), o; return P(e, a), a(e()), o;
}; };
var z = { var F = {
isTextContent(e) { isTextContent(e) {
return m(e) === "string" || C(e) && m(K(e)) === "string"; return w(e) === "string" || L(e) && w(X(e)) === "string";
}, },
processReactiveAttribute(e, t, r, n) { processReactiveAttribute(e, t, r, n) {
return C(r) ? (D(r, (o) => n([t, o])), r()) : r; return L(r) ? (P(r, (o) => n([t, o])), r()) : r;
} }
}; };
function k(e, t) { function z(e, t) {
let r = (...n) => n.length ? V(r, n[0]) : G(r); let r = (...n) => n.length ? Q(r, n[0]) : K(r);
return U(r, e, t); return B(r, e, t);
} }
var I = Object.assign(/* @__PURE__ */ Object.create(null), { var Z = Object.assign(/* @__PURE__ */ Object.create(null), {
stopPropagation() { stopPropagation() {
this.skip = !0; this.skip = !0;
} }
}); });
function U(e, t, r) { function B(e, t, r) {
return m(r) !== "[object Object]" && (r = {}), e[d] = { return w(r) !== "[object Object]" && (r = {}), e[d] = {
value: t, value: t,
actions: r, actions: r,
listeners: /* @__PURE__ */ new Set() listeners: /* @__PURE__ */ new Set()
}, e.toJSON = () => e(), Object.setPrototypeOf(e[d], I), e; }, e.toJSON = () => e(), Object.setPrototypeOf(e[d], Z), e;
} }
var L = []; var R = [];
function Z(e) { function G(e) {
let t = function() { let t = function() {
L.push(t), e(), L.pop(); R.push(t), e(), R.pop();
}; };
l.has(e) && (l.set(t, l.get(e)), l.delete(e)), t(); l.has(e) && (l.set(t, l.get(e)), l.delete(e)), t();
} }
function B() { function V() {
return L[L.length - 1]; return R[R.length - 1];
} }
function G(e) { function K(e) {
if (!e[d]) if (!e[d])
return; return;
let { value: t, listeners: r } = e[d], n = B(); let { value: t, listeners: r } = e[d], n = V();
return n && r.add(n), l.has(n) && l.get(n).add(e), t; return n && r.add(n), l.has(n) && l.get(n).add(e), t;
} }
function V(e, t) { function Q(e, t) {
if (!e[d]) if (!e[d])
return; return;
let r = e[d]; let r = e[d];
if (r.value !== t) if (r.value !== t)
return r.value = t, r.listeners.forEach((n) => n(t)), t; return r.value = t, r.listeners.forEach((n) => n(t)), t;
} }
function K(e) { function X(e) {
return e[d].value; return e[d].value;
} }
function D(e, t) { function P(e, t) {
if (e[d]) if (e[d])
return e[d].listeners.add(t); return e[d].listeners.add(t);
} }
function F(e, t) { function U(e, t) {
if (e[d]) if (e[d])
return e[d].listeners.delete(t); return e[d].listeners.delete(t);
} }
// src/signals.js // src/signals.js
N(z); _(F);
export { export {
g as S, g as S,
w as assign, y as assign,
$ as classListDeclarative, q as classListDeclarative,
ne as createElement, ce as createElement,
ce as dispatchEvent, ae as dispatchEvent,
ne as el, ce as el,
re as empty, se as empty,
C as isSignal, L as isSignal,
te as namespace, oe as namespace,
H as on, k as on,
N as registerReactivity _ as registerReactivity
}; };

155
dist/esm.js vendored
View File

@ -1,9 +1,24 @@
// src/helpers.js // src/signals-common.js
function N(e) { var g = {
let t = typeof e; isTextContent(e) {
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e); return typeof e == "string";
},
processReactiveAttribute(e, t, r, n) {
return r;
} }
function O(e, t) { };
function T(e, t = !0) {
return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e);
}
function O(e) {
return g.isPrototypeOf(e) && e !== g ? e : g;
}
// src/helpers.js
function p(e) {
return typeof e > "u";
}
function L(e, t) {
if (!e || !(e instanceof AbortSignal)) if (!e || !(e instanceof AbortSignal))
return !0; return !0;
if (!e.aborted) if (!e.aborted)
@ -12,33 +27,23 @@ function O(e, t) {
}; };
} }
// src/signals-common.js // src/dom-common.js
var l = { var h = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), A = { setDelete: R };
isTextContent(e) { function R(e, t, r) {
return N(e) !== "[object Object]"; Reflect.set(e, t, r), p(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
},
processReactiveAttribute(e, t, r, n) {
return r;
}
};
function D(e, t = !0) {
return t ? Object.assign(l, e) : (Object.setPrototypeOf(e, l), e);
}
function C(e) {
return l.isPrototypeOf(e) && e !== l ? e : l;
} }
// src/dom.js // src/dom.js
var v = "html"; var m = "html";
function F(e) { function I(e) {
return v = e === "svg" ? "http://www.w3.org/2000/svg" : e, { return m = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
append(t) { append(t) {
return v = "html", t; return m = "html", t;
} }
}; };
} }
function I(e, t, ...r) { function Z(e, t, ...r) {
let n = C(this), c; let n = O(this), c;
switch (n.isTextContent(t) && (t = { textContent: t }), !0) { switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
c = e(t || void 0, (s) => s ? (r.unshift(s), void 0) : c); c = e(t || void 0, (s) => s ? (r.unshift(s), void 0) : c);
@ -50,37 +55,37 @@ function I(e, t, ...r) {
case e === "<>": case e === "<>":
c = E(document.createDocumentFragment(), t); c = E(document.createDocumentFragment(), t);
break; break;
case v !== "html": case m !== "html":
c = E(document.createElementNS(v, e), t); c = E(document.createElementNS(m, e), t);
break; break;
case !c: case !c:
c = E(document.createElement(e), t); c = E(document.createElement(e), t);
} }
return r.forEach((a) => a(c)), c; return r.forEach((a) => a(c)), c;
} }
var h = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')); var { setDelete: y } = A;
function E(e, ...t) { function E(e, ...t) {
let r = C(this); let r = O(this);
if (!t.length) if (!t.length)
return e; return e;
let n = e instanceof SVGElement, c = (n ? S : j).bind(null, e, "Attribute"); let n = e instanceof SVGElement, c = (n ? S : N).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function a([s, f]) { return Object.entries(Object.assign({}, ...t)).forEach(function a([s, f]) {
f = r.processReactiveAttribute(e, s, f, a); f = r.processReactiveAttribute(e, s, f, a);
let [p] = s; let [l] = s;
if (p === "=") if (l === "=")
return c(s.slice(1), f); return c(s.slice(1), f);
if (p === ".") if (l === ".")
return L(e, s.slice(1), f); return y(e, s.slice(1), f);
if (typeof f == "object") if (typeof f == "object")
switch (s) { switch (s) {
case "style": case "style":
return x(f, j.bind(null, e.style, "Property")); return v(f, N.bind(null, e.style, "Property"));
case "dataset": case "dataset":
return x(f, L.bind(null, e.dataset)); return v(f, y.bind(null, e.dataset));
case "ariaset": case "ariaset":
return x(f, (g, b) => c("aria-" + g, b)); return v(f, (x, b) => c("aria-" + x, b));
case "classList": case "classList":
return R(e, f); return j(e, f);
default: default:
return Reflect.set(e, s, f); return Reflect.set(e, s, f);
} }
@ -96,16 +101,16 @@ function E(e, ...t) {
break; break;
return e.appendChild(document.createTextNode(f)); return e.appendChild(document.createTextNode(f));
} }
return M(e, s) ? L(e, s, f) : c(s, f); return M(e, s) ? y(e, s, f) : c(s, f);
}), e; }), e;
} }
function R(e, t) { function j(e, t) {
return typeof t != "object" || x( return typeof t != "object" || v(
t, t,
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n) (r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
), e; ), e;
} }
function U(e) { function B(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function M(e, t) { function M(e, t) {
@ -115,57 +120,51 @@ function M(e, t) {
let n = e.nodeName + "," + t; let n = e.nodeName + "," + t;
if (h.has(n)) if (h.has(n))
return h.get(n); return h.get(n);
let [c, a, s] = A(e, t), f = !y(c.set); let [c, a, s] = _(e, t), f = !p(c.set);
return (!f || a) && h.set(s === HTMLElement.prototype ? r : n, f), f; return (!f || a) && h.set(s === HTMLElement.prototype ? r : n, f), f;
} }
function A(e, t, r = 0) { function _(e, t, r = 0) {
if (e = Object.getPrototypeOf(e), !e) if (e = Object.getPrototypeOf(e), !e)
return [{}, r, e]; return [{}, r, e];
let n = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return n ? [n, r, e] : A(e, t, r + 1); return n ? [n, r, e] : _(e, t, r + 1);
} }
function x(e, t) { function v(e, t) {
return Object.entries(e).forEach(([r, n]) => t(r, n)); return Object.entries(e).forEach(([r, n]) => t(r, n));
} }
function y(e) { function N(e, t, r, n) {
return typeof e > "u"; return e[(p(n) ? "remove" : "set") + t](r, n);
}
function j(e, t, r, n) {
return e[(y(n) ? "remove" : "set") + t](r, n);
} }
function S(e, t, r, n, c = null) { function S(e, t, r, n, c = null) {
return e[(y(n) ? "remove" : "set") + t + "NS"](c, r, n); return e[(p(n) ? "remove" : "set") + t + "NS"](c, r, n);
}
function L(e, t, r) {
return Reflect.set(e, t, r);
} }
// src/events.js // src/events.js
function $(e, t, ...r) { function V(e, t, ...r) {
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t); let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
return e.dispatchEvent(n); return e.dispatchEvent(n);
} }
function T(e, t, r) { function D(e, t, r) {
return function(c) { return function(c) {
return c.addEventListener(e, t, r), c; return c.addEventListener(e, t, r), c;
}; };
} }
var m = _(); var w = P();
T.connected = function(e, t) { D.connected = function(e, t) {
return function(n) { return function(n) {
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (O(t && t.signal, () => m.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : m.onConnected(n, e)), n); return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (L(t && t.signal, () => w.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : w.onConnected(n, e)), n);
}; };
}; };
T.disconnected = function(e, t) { D.disconnected = function(e, t) {
return function(n) { return function(n) {
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (O(t && t.signal, () => m.offDisconnected(n, e)) && m.onDisconnected(n, e), n); return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (L(t && t.signal, () => w.offDisconnected(n, e)) && w.onDisconnected(n, e), n);
}; };
}; };
function _() { function P() {
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) { let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) {
for (let i of o) for (let i of o)
if (i.type === "childList") { if (i.type === "childList") {
if (g(i.addedNodes, !0)) { if (x(i.addedNodes, !0)) {
s(); s();
continue; continue;
} }
@ -212,7 +211,7 @@ function _() {
(requestIdleCallback || requestAnimationFrame)(o); (requestIdleCallback || requestAnimationFrame)(o);
}); });
} }
async function p(o) { async function l(o) {
e.size > 30 && await f(); e.size > 30 && await f();
let i = []; let i = [];
if (!(o instanceof Node)) if (!(o instanceof Node))
@ -221,21 +220,21 @@ function _() {
u === o || !(u instanceof Node) || o.contains(u) && i.push(u); u === o || !(u instanceof Node) || o.contains(u) && i.push(u);
return i; return i;
} }
function g(o, i) { function x(o, i) {
for (let u of o) { for (let u of o) {
if (i && p(u).then(g), !e.has(u)) if (i && l(u).then(x), !e.has(u))
continue; continue;
let d = e.get(u); let d = e.get(u);
return d.connected.forEach((w) => w(u)), d.connected.length = 0, d.disconnected.length || e.delete(u), !0; return d.connected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length || e.delete(u), !0;
} }
return !1; return !1;
} }
function b(o, i) { function b(o, i) {
for (let u of o) { for (let u of o) {
if (i && p(u).then(b), !e.has(u)) if (i && l(u).then(b), !e.has(u))
continue; continue;
let d = e.get(u); let d = e.get(u);
return d.disconnected.forEach((w) => w(u)), d.connected.length = 0, d.disconnected.length = 0, e.delete(u), !0; return d.disconnected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length = 0, e.delete(u), !0;
} }
return !1; return !1;
} }
@ -250,12 +249,12 @@ function _() {
}); });
export { export {
E as assign, E as assign,
R as classListDeclarative, j as classListDeclarative,
I as createElement, Z as createElement,
$ as dispatchEvent, V as dispatchEvent,
I as el, Z as el,
U as empty, B as empty,
F as namespace, I as namespace,
T as on, D as on,
D as registerReactivity T as registerReactivity
}; };

View File

@ -73,12 +73,22 @@
"size-limit": [ "size-limit": [
{ {
"path": "./index.js", "path": "./index.js",
"limit": "10 kB", "limit": "7 kB",
"gzip": false "gzip": false
}, },
{ {
"path": "./index-with-signals.js", "path": "./src/signals.js",
"limit": "10 kB", "limit": "4 kB",
"gzip": false
},
{
"path": "./src/jsdom.js",
"limit": "8 kB",
"gzip": false
},
{
"path": "./test/components/webComponent.js",
"limit": "10kb",
"gzip": false "gzip": false
} }
], ],

View File

@ -5,7 +5,7 @@ prop_process.setDelete= function(obj, prop, value){
if("checked"!==prop) return setDelete(obj, prop, value); if("checked"!==prop) return setDelete(obj, prop, value);
if(value) return obj.setAttribute("checked", ""); if(value) return obj.setAttribute("checked", "");
obj.removeAttribute("checked"); obj.removeAttribute("checked");
} };
const keys= [ "HTMLElement", "SVGElement", "DocumentFragment", "MutationObserver", "document" ]; const keys= [ "HTMLElement", "SVGElement", "DocumentFragment", "MutationObserver", "document" ];
let dom_last; let dom_last;
export let el; export let el;