1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-22 07:49:38 +01:00

📦 dist

This commit is contained in:
Jan Andrle 2023-10-15 11:13:36 +02:00
parent f08d495a5c
commit 995bacde7a
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
4 changed files with 1024 additions and 964 deletions

View File

@ -2,57 +2,57 @@
(()=> {
// src/signals-common.js
var x = {
isSignal(e) {
isSignal(t) {
return !1;
},
processReactiveAttribute(e, t, n, o) {
processReactiveAttribute(t, e, n, o) {
return n;
}
};
function D(e, t = !0) {
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e);
function P(t, e = !0) {
return e ? Object.assign(x, t) : (Object.setPrototypeOf(t, x), t);
}
function y(e) {
return x.isPrototypeOf(e) && e !== x ? e : x;
function S(t) {
return x.isPrototypeOf(t) && t !== x ? t : x;
}
// src/helpers.js
function E(e) {
return typeof e > "u";
function E(t) {
return typeof t > "u";
}
function T(e) {
let t = typeof e;
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
function M(t) {
let e = typeof t;
return e !== "object" ? e : t === null ? "null" : Object.prototype.toString.call(t);
}
function A(e, t) {
if (!e || !(e instanceof AbortSignal))
function A(t, e) {
if (!t || !(t instanceof AbortSignal))
return !0;
if (!e.aborted)
return e.addEventListener("abort", t), function() {
e.removeEventListener("abort", t);
if (!t.aborted)
return t.addEventListener("abort", e), function() {
t.removeEventListener("abort", e);
};
}
// src/dom-common.js
var M = { setDeleteAttr: I };
function I(e, t, n) {
if (Reflect.set(e, t, n), !!E(n)) {
if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t);
if (Reflect.get(e, t) === "undefined")
return Reflect.set(e, t, "");
var W = { setDeleteAttr: Z };
function Z(t, e, n) {
if (Reflect.set(t, e, n), !!E(n)) {
if (Reflect.deleteProperty(t, e), t instanceof HTMLElement && t.getAttribute(e) === "undefined")
return t.removeAttribute(e);
if (Reflect.get(t, e) === "undefined")
return Reflect.set(t, e, "");
}
}
// src/dom.js
var S = [{
var y = [{
scope: document.body,
namespace: "html",
host: (e) => e ? e(document.body) : document.body,
host: (t) => t ? t(document.body) : document.body,
prevent: !0
}], W = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, b = {
}], F = (t) => t === "svg" ? "http://www.w3.org/2000/svg" : t, m = {
get current() {
return S[S.length - 1];
return y[y.length - 1];
},
get host() {
return this.current.host;
@ -60,444 +60,459 @@
get namespace() {
return this.current.namespace;
},
set namespace(e) {
return this.current.namespace = W(e);
set namespace(t) {
return this.current.namespace = F(t);
},
preventDefault() {
let { current: e } = this;
return e.prevent = !0, e;
let { current: t } = this;
return t.prevent = !0, t;
},
elNamespace(e) {
let t = this.namespace;
return this.namespace = e, {
elNamespace(t) {
let e = this.namespace;
return this.namespace = t, {
append(...n) {
return b.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
return m.namespace = e, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
}
};
},
get state() {
return [...S];
return [...y];
},
push(e = {}) {
return e.namespace && (e.namespace = W(e.namespace)), S.push(Object.assign({}, this.current, { prevent: !1 }, e));
push(t = {}) {
return t.namespace && (t.namespace = F(t.namespace)), y.push(Object.assign({}, this.current, { prevent: !1 }, t));
},
pop() {
return S.pop();
return y.pop();
}
};
function ie(e, t, ...n) {
let o = y(this), { namespace: r } = b, c = 0, i;
switch ((Object(t) !== t || o.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": {
c = 1, b.push({ scope: e, host: (s) => s ? (c === 1 ? n.unshift(s) : s(i), void 0) : i }), i = e(t || void 0), (i instanceof HTMLElement ? $ : q)(i, "Attribute", "dde-fun", e.name);
function at(t, e, ...n) {
let o = S(this), { namespace: r } = m, c = 0, s;
switch ((Object(e) !== e || o.isSignal(e)) && (e = { textContent: e }), !0) {
case typeof t == "function": {
c = 1, m.push({ scope: t, host: (a) => a ? (c === 1 ? n.unshift(a) : a(s), void 0) : s }), s = t(e || void 0), (s instanceof HTMLElement ? B : G)(s, "Attribute", "dde-fun", t.name);
break;
}
case e === "#text":
i = O.call(this, document.createTextNode(""), t);
case t === "#text":
s = R.call(this, document.createTextNode(""), e);
break;
case e === "<>":
i = O.call(this, document.createDocumentFragment(), t);
case t === "<>":
s = R.call(this, document.createDocumentFragment(), e);
break;
case r !== "html":
i = O.call(this, document.createElementNS(r, e), t);
s = R.call(this, document.createElementNS(r, t), e);
break;
case !i:
i = O.call(this, document.createElement(e), t);
case !s:
s = R.call(this, document.createElement(t), e);
}
return n.forEach((s) => s(i)), c && b.pop(), c = 2, i;
return n.forEach((a) => a(s)), c && m.pop(), c = 2, s;
}
var { setDeleteAttr: F } = M;
function O(e, ...t) {
let n = this, o = y(this);
if (!t.length)
return e;
let c = (e instanceof SVGElement ? q : $).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function i([s, d]) {
d = o.processReactiveAttribute(e, s, d, i);
let [m] = s;
if (m === "=")
return c(s.slice(1), d);
if (m === ".")
return z(e, s.slice(1), d);
if (/(aria|data)([A-Z])/.test(s))
return s = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), c(s, d);
switch (s === "className" && (s = "class"), s) {
case "xlink:href":
return c(s, d, "http://www.w3.org/1999/xlink");
case "textContent":
return F(e, s, d);
case "style":
if (typeof d != "object")
break;
case "dataset":
return P(o, d, z.bind(null, e[s]));
case "ariaset":
return P(o, d, (v, u) => c("aria-" + v, u));
case "classList":
return J.call(n, e, d);
}
return V(e, s) ? F(e, s, d) : c(s, d);
}), e;
var { setDeleteAttr: z } = W, O = /* @__PURE__ */ new WeakMap();
function R(t, ...e) {
if (!e.length)
return t;
O.set(t, U(t, this));
for (let [n, o] of Object.entries(Object.assign({}, ...e)))
H.call(this, t, n, o);
return O.delete(t), t;
}
function J(e, t) {
let n = y(this);
return P(
n,
function H(t, e, n) {
let { setRemoveAttr: o, s: r } = U(t, this), c = this;
n = r.processReactiveAttribute(
t,
(o, r) => e.classList.toggle(o, r === -1 ? void 0 : !!r)
), e;
e,
n,
(a, p) => H.call(c, t, a, p)
);
let [s] = e;
if (s === "=")
return o(e.slice(1), n);
if (s === ".")
return k(t, e.slice(1), n);
if (/(aria|data)([A-Z])/.test(e))
return e = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), o(e, n);
switch (e === "className" && (e = "class"), e) {
case "xlink:href":
return o(e, n, "http://www.w3.org/1999/xlink");
case "textContent":
return z(t, e, n);
case "style":
if (typeof n != "object")
break;
case "dataset":
return j(r, n, k.bind(null, t[e]));
case "ariaset":
return j(r, n, (a, p) => o("aria-" + a, p));
case "classList":
return K.call(c, t, n);
}
return Q(t, e) ? z(t, e, n) : o(e, n);
}
function fe(e) {
return Array.from(e.children).forEach((t) => t.remove()), e;
function U(t, e) {
if (O.has(t))
return O.get(t);
let o = (t instanceof SVGElement ? G : B).bind(null, t, "Attribute"), r = S(e);
return { setRemoveAttr: o, s: r };
}
function V(e, t) {
if (!Reflect.has(e, t))
function K(t, e) {
let n = S(this);
return j(
n,
e,
(o, r) => t.classList.toggle(o, r === -1 ? void 0 : !!r)
), t;
}
function pt(t) {
return Array.from(t.children).forEach((e) => e.remove()), t;
}
function Q(t, e) {
if (!Reflect.has(t, e))
return !1;
let n = H(e, t);
let n = $(t, e);
return !E(n.set);
}
function H(e, t) {
if (e = Object.getPrototypeOf(e), !e)
function $(t, e) {
if (t = Object.getPrototypeOf(t), !t)
return {};
let n = Object.getOwnPropertyDescriptor(e, t);
return n || H(e, t);
let n = Object.getOwnPropertyDescriptor(t, e);
return n || $(t, e);
}
function P(e, t, n) {
if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([r, c]) {
r && (c = e.processReactiveAttribute(t, r, c, (i) => n(...i)), n(r, c));
function j(t, e, n) {
if (!(typeof e != "object" || e === null))
return Object.entries(e).forEach(function([r, c]) {
r && (c = t.processReactiveAttribute(e, r, c, n), n(r, c));
});
}
function U(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
function q(t) {
return Array.isArray(t) ? t.filter(Boolean).join(" ") : t;
}
function $(e, t, n, o) {
return e[(E(o) ? "remove" : "set") + t](n, U(o));
function B(t, e, n, o) {
return t[(E(o) ? "remove" : "set") + e](n, q(o));
}
function q(e, t, n, o, r = null) {
return e[(E(o) ? "remove" : "set") + t + "NS"](r, n, U(o));
function G(t, e, n, o, r = null) {
return t[(E(o) ? "remove" : "set") + e + "NS"](r, n, q(o));
}
function z(e, t, n) {
if (Reflect.set(e, t, n), !!E(n))
return Reflect.deleteProperty(e, t);
function k(t, e, n) {
if (Reflect.set(t, e, n), !!E(n))
return Reflect.deleteProperty(t, e);
}
// src/events.js
function le(e, t, ...n) {
let o = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(o);
function gt(t, e, ...n) {
let o = n.length ? new CustomEvent(e, { detail: n[0] }) : new Event(e);
return t.dispatchEvent(o);
}
function _(e, t, n) {
function v(t, e, n) {
return function(r) {
return r.addEventListener(e, t, n), r;
return r.addEventListener(t, e, n), r;
};
}
var R = K(), Z = /* @__PURE__ */ new WeakSet();
_.connected = function(e, t) {
var C = Y(), X = /* @__PURE__ */ new WeakSet();
v.connected = function(t, e) {
let n = "connected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
let c = "dde:" + n;
return r.addEventListener(c, e, t), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(c)), r) : (A(t.signal, () => R.offConnected(r, e)) && R.onConnected(r, e), r);
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(c)), r) : (A(e.signal, () => C.offConnected(r, t)) && C.onConnected(r, t), r);
};
};
_.disconnected = function(e, t) {
v.disconnected = function(t, e) {
let n = "disconnected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
let c = "dde:" + n;
return r.addEventListener(c, e, t), r.__dde_lifecycleToEvents || A(t.signal, () => R.offDisconnected(r, e)) && R.onDisconnected(r, e), r;
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || A(e.signal, () => C.offDisconnected(r, t)) && C.onDisconnected(r, t), r;
};
};
_.attributeChanged = function(e, t) {
v.attributeChanged = function(t, e) {
let n = "attributeChanged";
return typeof t != "object" && (t = {}), function(r) {
return typeof e != "object" && (e = {}), function(r) {
let c = "dde:" + n;
if (r.addEventListener(c, e, t), r.__dde_lifecycleToEvents || Z.has(r))
if (r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || X.has(r))
return r;
let i = new MutationObserver(function(d) {
for (let { attributeName: m, target: v } of d)
v.dispatchEvent(
new CustomEvent(c, { detail: [m, v.getAttribute(m)] })
let s = new MutationObserver(function(p) {
for (let { attributeName: b, target: _ } of p)
_.dispatchEvent(
new CustomEvent(c, { detail: [b, _.getAttribute(b)] })
);
});
return A(t.signal, () => i.disconnect()) && i.observe(r, { attributes: !0 }), r;
return A(e.signal, () => s.disconnect()) && s.observe(r, { attributes: !0 }), r;
};
};
function K() {
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(u) {
for (let f of u)
if (f.type === "childList") {
if (m(f.addedNodes, !0)) {
i();
function Y() {
let t = /* @__PURE__ */ new Map(), e = !1, n = new MutationObserver(function(i) {
for (let u of i)
if (u.type === "childList") {
if (b(u.addedNodes, !0)) {
s();
continue;
}
v(f.removedNodes, !0) && i();
_(u.removedNodes, !0) && s();
}
});
return {
onConnected(u, f) {
onConnected(i, u) {
c();
let a = r(u);
a.connected.has(f) || (a.connected.add(f), a.length_c += 1);
let f = r(i);
f.connected.has(u) || (f.connected.add(u), f.length_c += 1);
},
offConnected(u, f) {
if (!e.has(u))
offConnected(i, u) {
if (!t.has(i))
return;
let a = e.get(u);
a.connected.has(f) && (a.connected.delete(f), a.length_c -= 1, o(u, a));
let f = t.get(i);
f.connected.has(u) && (f.connected.delete(u), f.length_c -= 1, o(i, f));
},
onDisconnected(u, f) {
onDisconnected(i, u) {
c();
let a = r(u);
a.disconnected.has(f) || (a.disconnected.add(f), a.length_d += 1);
let f = r(i);
f.disconnected.has(u) || (f.disconnected.add(u), f.length_d += 1);
},
offDisconnected(u, f) {
if (!e.has(u))
offDisconnected(i, u) {
if (!t.has(i))
return;
let a = e.get(u);
a.disconnected.has(f) && (a.disconnected.delete(f), a.length_d -= 1, o(u, a));
let f = t.get(i);
f.disconnected.has(u) && (f.disconnected.delete(u), f.length_d -= 1, o(i, f));
}
};
function o(u, f) {
f.length_c || f.length_d || (e.delete(u), i());
function o(i, u) {
u.length_c || u.length_d || (t.delete(i), s());
}
function r(u) {
if (e.has(u))
return e.get(u);
let f = {
function r(i) {
if (t.has(i))
return t.get(i);
let u = {
connected: /* @__PURE__ */ new WeakSet(),
length_c: 0,
disconnected: /* @__PURE__ */ new WeakSet(),
length_d: 0
};
return e.set(u, f), f;
return t.set(i, u), u;
}
function c() {
t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
}
function i() {
!t || e.size || (t = !1, n.disconnect());
e || (e = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
}
function s() {
return new Promise(function(u) {
(requestIdleCallback || requestAnimationFrame)(u);
!e || t.size || (e = !1, n.disconnect());
}
function a() {
return new Promise(function(i) {
(requestIdleCallback || requestAnimationFrame)(i);
});
}
async function d(u) {
e.size > 30 && await s();
let f = [];
if (!(u instanceof Node))
return f;
for (let a of e.keys())
a === u || !(a instanceof Node) || u.contains(a) && f.push(a);
async function p(i) {
t.size > 30 && await a();
let u = [];
if (!(i instanceof Node))
return u;
for (let f of t.keys())
f === i || !(f instanceof Node) || i.contains(f) && u.push(f);
return u;
}
function b(i, u) {
let f = !1;
for (let h of i) {
if (u && p(h).then(b), !t.has(h))
continue;
let w = t.get(h);
w.length_c && (h.dispatchEvent(new Event("dde:connected")), w.connected = /* @__PURE__ */ new WeakSet(), w.length_c = 0, w.length_d || t.delete(h), f = !0);
}
return f;
}
function m(u, f) {
let a = !1;
for (let h of u) {
if (f && d(h).then(m), !e.has(h))
continue;
let w = e.get(h);
w.length_c && (h.dispatchEvent(new Event("dde:connected")), w.connected = /* @__PURE__ */ new WeakSet(), w.length_c = 0, w.length_d || e.delete(h), a = !0);
}
return a;
}
function v(u, f) {
let a = !1;
for (let h of u)
f && d(h).then(v), !(!e.has(h) || !e.get(h).length_d) && (h.dispatchEvent(new Event("dde:disconnected")), e.delete(h), a = !0);
return a;
function _(i, u) {
let f = !1;
for (let h of i)
u && p(h).then(_), !(!t.has(h) || !t.get(h).length_d) && (h.dispatchEvent(new Event("dde:disconnected")), t.delete(h), f = !0);
return f;
}
}
// index.js
[HTMLElement, SVGElement, DocumentFragment].forEach((e) => {
let { append: t } = e.prototype;
e.prototype.append = function(...n) {
return t.apply(this, n), this;
[HTMLElement, SVGElement, DocumentFragment].forEach((t) => {
let { append: e } = t.prototype;
t.prototype.append = function(...n) {
return e.apply(this, n), this;
};
});
// src/signals-lib.js
var l = Symbol.for("Signal");
function C(e) {
var d = Symbol.for("Signal");
function L(t) {
try {
return Reflect.has(e, l);
return Reflect.has(t, d);
} catch {
return !1;
}
}
var L = [], g = /* @__PURE__ */ new WeakMap();
function p(e, t) {
if (typeof e != "function")
return k(e, t);
if (C(e))
return e;
let n = k(), o = function() {
L.push(o), n(e()), L.pop();
var D = [], g = /* @__PURE__ */ new WeakMap();
function l(t, e) {
if (typeof t != "function")
return I(t, e);
if (L(t))
return t;
let n = I(), o = function() {
D.push(o), n(t()), D.pop();
};
return g.set(o, /* @__PURE__ */ new Set([n])), g.set(n[l], o), o(), n;
return g.set(o, /* @__PURE__ */ new Set([n])), g.set(n[d], o), o(), n;
}
p.action = function(e, t, ...n) {
let o = e[l], { actions: r } = o;
if (!r || !Reflect.has(r, t))
throw new Error(`'${e}' has no action with name '${t}'!`);
if (r[t].apply(o, n), o.skip)
l.action = function(t, e, ...n) {
let o = t[d], { actions: r } = o;
if (!r || !Reflect.has(r, e))
throw new Error(`'${t}' has no action with name '${e}'!`);
if (r[e].apply(o, n), o.skip)
return Reflect.deleteProperty(o, "skip");
o.listeners.forEach((c) => c(o.value));
};
p.on = function e(t, n, o = {}) {
l.on = function t(e, n, o = {}) {
let { signal: r } = o;
if (!(r && r.aborted)) {
if (Array.isArray(t))
return t.forEach((c) => e(c, n, o));
j(t, n), r && r.addEventListener("abort", () => N(t, n));
if (Array.isArray(e))
return e.forEach((c) => t(c, n, o));
T(e, n), r && r.addEventListener("abort", () => N(e, n));
}
};
p.symbols = {
signal: l,
l.symbols = {
signal: d,
onclear: Symbol.for("Signal.onclear")
};
p.attribute = function(e, t = void 0) {
let { host: n } = b, o = n() && n().hasAttribute(e) ? n().getAttribute(e) : t, r = new AbortController(), c = p(o, {
[p.symbols.onclear]() {
l.attribute = function(t, e = void 0) {
let { host: n } = m, o = n() && n().hasAttribute(t) ? n().getAttribute(t) : e, r = new AbortController(), c = l(o, {
[l.symbols.onclear]() {
r.abort();
}
});
return b.host(_.attributeChanged(function({ detail: s }) {
let [d, m] = s;
d === e && c(m);
return m.host(v.attributeChanged(function({ detail: a }) {
let [p, b] = a;
p === t && c(b);
}, { signal: r.signal })), c;
};
p.clear = function(...e) {
for (let n of e) {
l.clear = function(...t) {
for (let n of t) {
Reflect.deleteProperty(n, "toJSON");
let o = n[l];
o.onclear.forEach((r) => r.call(o)), t(n, o), Reflect.deleteProperty(n, l);
let o = n[d];
o.onclear.forEach((r) => r.call(o)), e(n, o), Reflect.deleteProperty(n, d);
}
function t(n, o) {
function e(n, o) {
o.listeners.forEach((r) => {
if (o.listeners.delete(r), !g.has(r))
return;
let c = g.get(r);
c.delete(n), !(c.size > 1) && (p.clear(...c), g.delete(r));
c.delete(n), !(c.size > 1) && (l.clear(...c), g.delete(r));
});
}
};
p.el = function(e, t) {
l.el = function(t, e) {
let n = document.createComment("<#reactive>"), o = document.createComment("</#reactive>"), r = document.createDocumentFragment();
r.append(n, o);
let c = (i) => {
let c = (s) => {
if (!n.parentNode || !o.parentNode)
return N(e, c);
let s = t(i);
Array.isArray(s) || (s = [s]);
let d = n;
for (; (d = n.nextSibling) !== o; )
d.remove();
n.after(...s);
return N(t, c);
let a = e(s);
Array.isArray(a) || (a = [a]);
let p = n;
for (; (p = n.nextSibling) !== o; )
p.remove();
n.after(...a);
};
return j(e, c), G(e, c, n, t), c(e()), r;
return T(t, c), V(t, c, n, e), c(t()), r;
};
var B = {
isSignal: C,
processReactiveAttribute(e, t, n, o) {
if (!C(n))
var J = {
isSignal: L,
processReactiveAttribute(t, e, n, o) {
if (!L(n))
return n;
let r = (c) => o([t, c]);
return j(n, r), G(n, r, e, t), n();
let r = (c) => o(e, c);
return T(n, r), V(n, r, t, e), n();
}
};
function G(e, t, ...n) {
let { current: o } = b;
function V(t, e, ...n) {
let { current: o } = m;
if (o.prevent)
return;
let r = "__dde_reactive";
o.host(function(c) {
c[r] || (c[r] = [], _.disconnected(
c[r] || (c[r] = [], v.disconnected(
() => (
/*!
* Clears all signals listeners added in the current scope/host (`S.el`, `assign`, ?).
* You can investigate the `__dde_reactive` key of the element.
* */
c[r].forEach(([i]) => N(...i, e[l]?.host() === c))
c[r].forEach(([s]) => N(...s, t[d]?.host() === c))
)
)(c)), c[r].push([[e, t], ...n]);
)(c)), c[r].push([[t, e], ...n]);
});
}
function k(e, t) {
let n = (...o) => o.length ? te(n, ...o) : ee(n);
return X(n, e, t);
function I(t, e) {
let n = (...o) => o.length ? ot(n, ...o) : rt(n);
return et(n, t, e);
}
var Q = Object.assign(/* @__PURE__ */ Object.create(null), {
var tt = Object.assign(/* @__PURE__ */ Object.create(null), {
stopPropagation() {
this.skip = !0;
}
});
function X(e, t, n) {
function et(t, e, n) {
let o = [];
T(n) !== "[object Object]" && (n = {});
let { onclear: r } = p.symbols;
M(n) !== "[object Object]" && (n = {});
let { onclear: r } = l.symbols;
n[r] && (o.push(n[r]), Reflect.deleteProperty(n, r));
let { host: c } = b;
return e[l] = {
value: t,
let { host: c } = m;
return t[d] = {
value: e,
actions: n,
onclear: o,
host: c,
listeners: /* @__PURE__ */ new Set()
}, e.toJSON = () => e(), Object.setPrototypeOf(e[l], Q), e;
}, t.toJSON = () => t(), Object.setPrototypeOf(t[d], tt), t;
}
function Y() {
return L[L.length - 1];
function nt() {
return D[D.length - 1];
}
function ee(e) {
if (!e[l])
function rt(t) {
if (!t[d])
return;
let { value: t, listeners: n } = e[l], o = Y();
return o && n.add(o), g.has(o) && g.get(o).add(e), t;
let { value: e, listeners: n } = t[d], o = nt();
return o && n.add(o), g.has(o) && g.get(o).add(t), e;
}
function te(e, t, n) {
if (!e[l])
function ot(t, e, n) {
if (!t[d])
return;
let o = e[l];
if (!(!n && o.value === t))
return o.value = t, o.listeners.forEach((r) => r(t)), t;
let o = t[d];
if (!(!n && o.value === e))
return o.value = e, o.listeners.forEach((r) => r(e)), e;
}
function j(e, t) {
if (e[l])
return e[l].listeners.add(t);
function T(t, e) {
if (t[d])
return t[d].listeners.add(e);
}
function N(e, t, n) {
let o = e[l];
function N(t, e, n) {
let o = t[d];
if (!o)
return;
let r = o.listeners.delete(t);
let r = o.listeners.delete(e);
if (n && !o.listeners.size) {
if (p.clear(e), !g.has(o))
if (l.clear(t), !g.has(o))
return r;
let c = g.get(o);
if (!g.has(c))
return r;
g.get(c).forEach((i) => N(i, c, !0));
g.get(c).forEach((s) => N(s, c, !0));
}
return r;
}
// signals.js
D(B);
P(J);
globalThis.dde= {
S: p,
assign: O,
classListDeclarative: J,
createElement: ie,
dispatchEvent: le,
el: ie,
empty: fe,
isSignal: C,
on: _,
registerReactivity: D,
scope: b
S: l,
assign: R,
assignAttribute: H,
classListDeclarative: K,
createElement: at,
dispatchEvent: gt,
el: at,
empty: pt,
isSignal: L,
on: v,
registerReactivity: P,
scope: m
};
})();

399
dist/dde.js vendored
View File

@ -1,42 +1,42 @@
//deka-dom-el library is available via global namespace `dde`
(()=> {
// src/signals-common.js
var m = {
isSignal(e) {
var v = {
isSignal(t) {
return !1;
},
processReactiveAttribute(e, t, n, u) {
processReactiveAttribute(t, e, n, c) {
return n;
}
};
function T(e, t = !0) {
return t ? Object.assign(m, e) : (Object.setPrototypeOf(e, m), e);
function F(t, e = !0) {
return e ? Object.assign(v, t) : (Object.setPrototypeOf(t, v), t);
}
function b(e) {
return m.isPrototypeOf(e) && e !== m ? e : m;
function m(t) {
return v.isPrototypeOf(t) && t !== v ? t : v;
}
// src/helpers.js
function g(e) {
return typeof e > "u";
function h(t) {
return typeof t > "u";
}
function _(e, t) {
if (!e || !(e instanceof AbortSignal))
function _(t, e) {
if (!t || !(t instanceof AbortSignal))
return !0;
if (!e.aborted)
return e.addEventListener("abort", t), function() {
e.removeEventListener("abort", t);
if (!t.aborted)
return t.addEventListener("abort", e), function() {
t.removeEventListener("abort", e);
};
}
// src/dom-common.js
var C = { setDeleteAttr: M };
function M(e, t, n) {
if (Reflect.set(e, t, n), !!g(n)) {
if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t);
if (Reflect.get(e, t) === "undefined")
return Reflect.set(e, t, "");
var R = { setDeleteAttr: H };
function H(t, e, n) {
if (Reflect.set(t, e, n), !!h(n)) {
if (Reflect.deleteProperty(t, e), t instanceof HTMLElement && t.getAttribute(e) === "undefined")
return t.removeAttribute(e);
if (Reflect.get(t, e) === "undefined")
return Reflect.set(t, e, "");
}
}
@ -44,9 +44,9 @@
var E = [{
scope: document.body,
namespace: "html",
host: (e) => e ? e(document.body) : document.body,
host: (t) => t ? t(document.body) : document.body,
prevent: !0
}], R = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, x = {
}], S = (t) => t === "svg" ? "http://www.w3.org/2000/svg" : t, x = {
get current() {
return E[E.length - 1];
},
@ -56,272 +56,287 @@
get namespace() {
return this.current.namespace;
},
set namespace(e) {
return this.current.namespace = R(e);
set namespace(t) {
return this.current.namespace = S(t);
},
preventDefault() {
let { current: e } = this;
return e.prevent = !0, e;
let { current: t } = this;
return t.prevent = !0, t;
},
elNamespace(e) {
let t = this.namespace;
return this.namespace = e, {
elNamespace(t) {
let e = this.namespace;
return this.namespace = t, {
append(...n) {
return x.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
return x.namespace = e, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
}
};
},
get state() {
return [...E];
},
push(e = {}) {
return e.namespace && (e.namespace = R(e.namespace)), E.push(Object.assign({}, this.current, { prevent: !1 }, e));
push(t = {}) {
return t.namespace && (t.namespace = S(t.namespace)), E.push(Object.assign({}, this.current, { prevent: !1 }, t));
},
pop() {
return E.pop();
}
};
function V(e, t, ...n) {
let u = b(this), { namespace: r } = x, f = 0, a;
switch ((Object(t) !== t || u.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": {
f = 1, x.push({ scope: e, host: (i) => i ? (f === 1 ? n.unshift(i) : i(a), void 0) : a }), a = e(t || void 0), (a instanceof HTMLElement ? P : j)(a, "Attribute", "dde-fun", e.name);
function J(t, e, ...n) {
let c = m(this), { namespace: r } = x, f = 0, u;
switch ((Object(e) !== e || c.isSignal(e)) && (e = { textContent: e }), !0) {
case typeof t == "function": {
f = 1, x.push({ scope: t, host: (a) => a ? (f === 1 ? n.unshift(a) : a(u), void 0) : u }), u = t(e || void 0), (u instanceof HTMLElement ? M : W)(u, "Attribute", "dde-fun", t.name);
break;
}
case e === "#text":
a = w.call(this, document.createTextNode(""), t);
case t === "#text":
u = w.call(this, document.createTextNode(""), e);
break;
case e === "<>":
a = w.call(this, document.createDocumentFragment(), t);
case t === "<>":
u = w.call(this, document.createDocumentFragment(), e);
break;
case r !== "html":
a = w.call(this, document.createElementNS(r, e), t);
u = w.call(this, document.createElementNS(r, t), e);
break;
case !a:
a = w.call(this, document.createElement(e), t);
case !u:
u = w.call(this, document.createElement(t), e);
}
return n.forEach((i) => i(a)), f && x.pop(), f = 2, a;
return n.forEach((a) => a(u)), f && x.pop(), f = 2, u;
}
var { setDeleteAttr: S } = C;
function w(e, ...t) {
let n = this, u = b(this);
if (!t.length)
return e;
let f = (e instanceof SVGElement ? j : P).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function a([i, d]) {
d = u.processReactiveAttribute(e, i, d, a);
let [l] = i;
if (l === "=")
return f(i.slice(1), d);
if (l === ".")
return L(e, i.slice(1), d);
if (/(aria|data)([A-Z])/.test(i))
return i = i.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), f(i, d);
switch (i === "className" && (i = "class"), i) {
case "xlink:href":
return f(i, d, "http://www.w3.org/1999/xlink");
case "textContent":
return S(e, i, d);
case "style":
if (typeof d != "object")
break;
case "dataset":
return O(u, d, L.bind(null, e[i]));
case "ariaset":
return O(u, d, (h, c) => f("aria-" + h, c));
case "classList":
return W.call(n, e, d);
}
return F(e, i) ? S(e, i, d) : f(i, d);
}), e;
var { setDeleteAttr: L } = R, A = /* @__PURE__ */ new WeakMap();
function w(t, ...e) {
if (!e.length)
return t;
A.set(t, P(t, this));
for (let [n, c] of Object.entries(Object.assign({}, ...e)))
N.call(this, t, n, c);
return A.delete(t), t;
}
function W(e, t) {
let n = b(this);
return O(
n,
function N(t, e, n) {
let { setRemoveAttr: c, s: r } = P(t, this), f = this;
n = r.processReactiveAttribute(
t,
(u, r) => e.classList.toggle(u, r === -1 ? void 0 : !!r)
), e;
e,
n,
(a, p) => N.call(f, t, a, p)
);
let [u] = e;
if (u === "=")
return c(e.slice(1), n);
if (u === ".")
return D(t, e.slice(1), n);
if (/(aria|data)([A-Z])/.test(e))
return e = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), c(e, n);
switch (e === "className" && (e = "class"), e) {
case "xlink:href":
return c(e, n, "http://www.w3.org/1999/xlink");
case "textContent":
return L(t, e, n);
case "style":
if (typeof n != "object")
break;
case "dataset":
return y(r, n, D.bind(null, t[e]));
case "ariaset":
return y(r, n, (a, p) => c("aria-" + a, p));
case "classList":
return U.call(f, t, n);
}
return q(t, e) ? L(t, e, n) : c(e, n);
}
function $(e) {
return Array.from(e.children).forEach((t) => t.remove()), e;
function P(t, e) {
if (A.has(t))
return A.get(t);
let c = (t instanceof SVGElement ? W : M).bind(null, t, "Attribute"), r = m(e);
return { setRemoveAttr: c, s: r };
}
function F(e, t) {
if (!Reflect.has(e, t))
function U(t, e) {
let n = m(this);
return y(
n,
e,
(c, r) => t.classList.toggle(c, r === -1 ? void 0 : !!r)
), t;
}
function Q(t) {
return Array.from(t.children).forEach((e) => e.remove()), t;
}
function q(t, e) {
if (!Reflect.has(t, e))
return !1;
let n = D(e, t);
return !g(n.set);
let n = j(t, e);
return !h(n.set);
}
function D(e, t) {
if (e = Object.getPrototypeOf(e), !e)
function j(t, e) {
if (t = Object.getPrototypeOf(t), !t)
return {};
let n = Object.getOwnPropertyDescriptor(e, t);
return n || D(e, t);
let n = Object.getOwnPropertyDescriptor(t, e);
return n || j(t, e);
}
function O(e, t, n) {
if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([r, f]) {
r && (f = e.processReactiveAttribute(t, r, f, (a) => n(...a)), n(r, f));
function y(t, e, n) {
if (!(typeof e != "object" || e === null))
return Object.entries(e).forEach(function([r, f]) {
r && (f = t.processReactiveAttribute(e, r, f, n), n(r, f));
});
}
function N(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
function T(t) {
return Array.isArray(t) ? t.filter(Boolean).join(" ") : t;
}
function P(e, t, n, u) {
return e[(g(u) ? "remove" : "set") + t](n, N(u));
function M(t, e, n, c) {
return t[(h(c) ? "remove" : "set") + e](n, T(c));
}
function j(e, t, n, u, r = null) {
return e[(g(u) ? "remove" : "set") + t + "NS"](r, n, N(u));
function W(t, e, n, c, r = null) {
return t[(h(c) ? "remove" : "set") + e + "NS"](r, n, T(c));
}
function L(e, t, n) {
if (Reflect.set(e, t, n), !!g(n))
return Reflect.deleteProperty(e, t);
function D(t, e, n) {
if (Reflect.set(t, e, n), !!h(n))
return Reflect.deleteProperty(t, e);
}
// src/events.js
function Q(e, t, ...n) {
let u = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(u);
function k(t, e, ...n) {
let c = n.length ? new CustomEvent(e, { detail: n[0] }) : new Event(e);
return t.dispatchEvent(c);
}
function y(e, t, n) {
function C(t, e, n) {
return function(r) {
return r.addEventListener(e, t, n), r;
return r.addEventListener(t, e, n), r;
};
}
var A = U(), H = /* @__PURE__ */ new WeakSet();
y.connected = function(e, t) {
var O = B(), z = /* @__PURE__ */ new WeakSet();
C.connected = function(t, e) {
let n = "connected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
let f = "dde:" + n;
return r.addEventListener(f, e, t), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(f)), r) : (_(t.signal, () => A.offConnected(r, e)) && A.onConnected(r, e), r);
return r.addEventListener(f, t, e), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(f)), r) : (_(e.signal, () => O.offConnected(r, t)) && O.onConnected(r, t), r);
};
};
y.disconnected = function(e, t) {
C.disconnected = function(t, e) {
let n = "disconnected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
let f = "dde:" + n;
return r.addEventListener(f, e, t), r.__dde_lifecycleToEvents || _(t.signal, () => A.offDisconnected(r, e)) && A.onDisconnected(r, e), r;
return r.addEventListener(f, t, e), r.__dde_lifecycleToEvents || _(e.signal, () => O.offDisconnected(r, t)) && O.onDisconnected(r, t), r;
};
};
y.attributeChanged = function(e, t) {
C.attributeChanged = function(t, e) {
let n = "attributeChanged";
return typeof t != "object" && (t = {}), function(r) {
return typeof e != "object" && (e = {}), function(r) {
let f = "dde:" + n;
if (r.addEventListener(f, e, t), r.__dde_lifecycleToEvents || H.has(r))
if (r.addEventListener(f, t, e), r.__dde_lifecycleToEvents || z.has(r))
return r;
let a = new MutationObserver(function(d) {
for (let { attributeName: l, target: h } of d)
h.dispatchEvent(
new CustomEvent(f, { detail: [l, h.getAttribute(l)] })
let u = new MutationObserver(function(p) {
for (let { attributeName: l, target: g } of p)
g.dispatchEvent(
new CustomEvent(f, { detail: [l, g.getAttribute(l)] })
);
});
return _(t.signal, () => a.disconnect()) && a.observe(r, { attributes: !0 }), r;
return _(e.signal, () => u.disconnect()) && u.observe(r, { attributes: !0 }), r;
};
};
function U() {
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(c) {
for (let o of c)
if (o.type === "childList") {
if (l(o.addedNodes, !0)) {
a();
function B() {
let t = /* @__PURE__ */ new Map(), e = !1, n = new MutationObserver(function(o) {
for (let s of o)
if (s.type === "childList") {
if (l(s.addedNodes, !0)) {
u();
continue;
}
h(o.removedNodes, !0) && a();
g(s.removedNodes, !0) && u();
}
});
return {
onConnected(c, o) {
onConnected(o, s) {
f();
let s = r(c);
s.connected.has(o) || (s.connected.add(o), s.length_c += 1);
let i = r(o);
i.connected.has(s) || (i.connected.add(s), i.length_c += 1);
},
offConnected(c, o) {
if (!e.has(c))
offConnected(o, s) {
if (!t.has(o))
return;
let s = e.get(c);
s.connected.has(o) && (s.connected.delete(o), s.length_c -= 1, u(c, s));
let i = t.get(o);
i.connected.has(s) && (i.connected.delete(s), i.length_c -= 1, c(o, i));
},
onDisconnected(c, o) {
onDisconnected(o, s) {
f();
let s = r(c);
s.disconnected.has(o) || (s.disconnected.add(o), s.length_d += 1);
let i = r(o);
i.disconnected.has(s) || (i.disconnected.add(s), i.length_d += 1);
},
offDisconnected(c, o) {
if (!e.has(c))
offDisconnected(o, s) {
if (!t.has(o))
return;
let s = e.get(c);
s.disconnected.has(o) && (s.disconnected.delete(o), s.length_d -= 1, u(c, s));
let i = t.get(o);
i.disconnected.has(s) && (i.disconnected.delete(s), i.length_d -= 1, c(o, i));
}
};
function u(c, o) {
o.length_c || o.length_d || (e.delete(c), a());
function c(o, s) {
s.length_c || s.length_d || (t.delete(o), u());
}
function r(c) {
if (e.has(c))
return e.get(c);
let o = {
function r(o) {
if (t.has(o))
return t.get(o);
let s = {
connected: /* @__PURE__ */ new WeakSet(),
length_c: 0,
disconnected: /* @__PURE__ */ new WeakSet(),
length_d: 0
};
return e.set(c, o), o;
return t.set(o, s), s;
}
function f() {
t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
e || (e = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
}
function u() {
!e || t.size || (e = !1, n.disconnect());
}
function a() {
!t || e.size || (t = !1, n.disconnect());
}
function i() {
return new Promise(function(c) {
(requestIdleCallback || requestAnimationFrame)(c);
return new Promise(function(o) {
(requestIdleCallback || requestAnimationFrame)(o);
});
}
async function d(c) {
e.size > 30 && await i();
let o = [];
if (!(c instanceof Node))
return o;
for (let s of e.keys())
s === c || !(s instanceof Node) || c.contains(s) && o.push(s);
return o;
async function p(o) {
t.size > 30 && await a();
let s = [];
if (!(o instanceof Node))
return s;
for (let i of t.keys())
i === o || !(i instanceof Node) || o.contains(i) && s.push(i);
return s;
}
function l(c, o) {
let s = !1;
for (let p of c) {
if (o && d(p).then(l), !e.has(p))
function l(o, s) {
let i = !1;
for (let d of o) {
if (s && p(d).then(l), !t.has(d))
continue;
let v = e.get(p);
v.length_c && (p.dispatchEvent(new Event("dde:connected")), v.connected = /* @__PURE__ */ new WeakSet(), v.length_c = 0, v.length_d || e.delete(p), s = !0);
let b = t.get(d);
b.length_c && (d.dispatchEvent(new Event("dde:connected")), b.connected = /* @__PURE__ */ new WeakSet(), b.length_c = 0, b.length_d || t.delete(d), i = !0);
}
return s;
return i;
}
function h(c, o) {
let s = !1;
for (let p of c)
o && d(p).then(h), !(!e.has(p) || !e.get(p).length_d) && (p.dispatchEvent(new Event("dde:disconnected")), e.delete(p), s = !0);
return s;
function g(o, s) {
let i = !1;
for (let d of o)
s && p(d).then(g), !(!t.has(d) || !t.get(d).length_d) && (d.dispatchEvent(new Event("dde:disconnected")), t.delete(d), i = !0);
return i;
}
}
// index.js
[HTMLElement, SVGElement, DocumentFragment].forEach((e) => {
let { append: t } = e.prototype;
e.prototype.append = function(...n) {
return t.apply(this, n), this;
[HTMLElement, SVGElement, DocumentFragment].forEach((t) => {
let { append: e } = t.prototype;
t.prototype.append = function(...n) {
return e.apply(this, n), this;
};
});
globalThis.dde= {
assign: w,
classListDeclarative: W,
createElement: V,
dispatchEvent: Q,
el: V,
empty: $,
on: y,
registerReactivity: T,
assignAttribute: N,
classListDeclarative: U,
createElement: J,
dispatchEvent: k,
el: J,
empty: Q,
on: C,
registerReactivity: F,
scope: x
};

View File

@ -1,56 +1,56 @@
// src/signals-common.js
var x = {
isSignal(e) {
isSignal(t) {
return !1;
},
processReactiveAttribute(e, t, n, o) {
processReactiveAttribute(t, e, n, o) {
return n;
}
};
function D(e, t = !0) {
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e);
function P(t, e = !0) {
return e ? Object.assign(x, t) : (Object.setPrototypeOf(t, x), t);
}
function y(e) {
return x.isPrototypeOf(e) && e !== x ? e : x;
function S(t) {
return x.isPrototypeOf(t) && t !== x ? t : x;
}
// src/helpers.js
function E(e) {
return typeof e > "u";
function E(t) {
return typeof t > "u";
}
function T(e) {
let t = typeof e;
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
function M(t) {
let e = typeof t;
return e !== "object" ? e : t === null ? "null" : Object.prototype.toString.call(t);
}
function A(e, t) {
if (!e || !(e instanceof AbortSignal))
function A(t, e) {
if (!t || !(t instanceof AbortSignal))
return !0;
if (!e.aborted)
return e.addEventListener("abort", t), function() {
e.removeEventListener("abort", t);
if (!t.aborted)
return t.addEventListener("abort", e), function() {
t.removeEventListener("abort", e);
};
}
// src/dom-common.js
var M = { setDeleteAttr: I };
function I(e, t, n) {
if (Reflect.set(e, t, n), !!E(n)) {
if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t);
if (Reflect.get(e, t) === "undefined")
return Reflect.set(e, t, "");
var W = { setDeleteAttr: Z };
function Z(t, e, n) {
if (Reflect.set(t, e, n), !!E(n)) {
if (Reflect.deleteProperty(t, e), t instanceof HTMLElement && t.getAttribute(e) === "undefined")
return t.removeAttribute(e);
if (Reflect.get(t, e) === "undefined")
return Reflect.set(t, e, "");
}
}
// src/dom.js
var S = [{
var y = [{
scope: document.body,
namespace: "html",
host: (e) => e ? e(document.body) : document.body,
host: (t) => t ? t(document.body) : document.body,
prevent: !0
}], W = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, b = {
}], F = (t) => t === "svg" ? "http://www.w3.org/2000/svg" : t, m = {
get current() {
return S[S.length - 1];
return y[y.length - 1];
},
get host() {
return this.current.host;
@ -58,441 +58,456 @@ var S = [{
get namespace() {
return this.current.namespace;
},
set namespace(e) {
return this.current.namespace = W(e);
set namespace(t) {
return this.current.namespace = F(t);
},
preventDefault() {
let { current: e } = this;
return e.prevent = !0, e;
let { current: t } = this;
return t.prevent = !0, t;
},
elNamespace(e) {
let t = this.namespace;
return this.namespace = e, {
elNamespace(t) {
let e = this.namespace;
return this.namespace = t, {
append(...n) {
return b.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
return m.namespace = e, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
}
};
},
get state() {
return [...S];
return [...y];
},
push(e = {}) {
return e.namespace && (e.namespace = W(e.namespace)), S.push(Object.assign({}, this.current, { prevent: !1 }, e));
push(t = {}) {
return t.namespace && (t.namespace = F(t.namespace)), y.push(Object.assign({}, this.current, { prevent: !1 }, t));
},
pop() {
return S.pop();
return y.pop();
}
};
function ie(e, t, ...n) {
let o = y(this), { namespace: r } = b, c = 0, i;
switch ((Object(t) !== t || o.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": {
c = 1, b.push({ scope: e, host: (s) => s ? (c === 1 ? n.unshift(s) : s(i), void 0) : i }), i = e(t || void 0), (i instanceof HTMLElement ? $ : q)(i, "Attribute", "dde-fun", e.name);
function at(t, e, ...n) {
let o = S(this), { namespace: r } = m, c = 0, s;
switch ((Object(e) !== e || o.isSignal(e)) && (e = { textContent: e }), !0) {
case typeof t == "function": {
c = 1, m.push({ scope: t, host: (a) => a ? (c === 1 ? n.unshift(a) : a(s), void 0) : s }), s = t(e || void 0), (s instanceof HTMLElement ? B : G)(s, "Attribute", "dde-fun", t.name);
break;
}
case e === "#text":
i = O.call(this, document.createTextNode(""), t);
case t === "#text":
s = R.call(this, document.createTextNode(""), e);
break;
case e === "<>":
i = O.call(this, document.createDocumentFragment(), t);
case t === "<>":
s = R.call(this, document.createDocumentFragment(), e);
break;
case r !== "html":
i = O.call(this, document.createElementNS(r, e), t);
s = R.call(this, document.createElementNS(r, t), e);
break;
case !i:
i = O.call(this, document.createElement(e), t);
case !s:
s = R.call(this, document.createElement(t), e);
}
return n.forEach((s) => s(i)), c && b.pop(), c = 2, i;
return n.forEach((a) => a(s)), c && m.pop(), c = 2, s;
}
var { setDeleteAttr: F } = M;
function O(e, ...t) {
let n = this, o = y(this);
if (!t.length)
return e;
let c = (e instanceof SVGElement ? q : $).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function i([s, d]) {
d = o.processReactiveAttribute(e, s, d, i);
let [m] = s;
if (m === "=")
return c(s.slice(1), d);
if (m === ".")
return z(e, s.slice(1), d);
if (/(aria|data)([A-Z])/.test(s))
return s = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), c(s, d);
switch (s === "className" && (s = "class"), s) {
case "xlink:href":
return c(s, d, "http://www.w3.org/1999/xlink");
case "textContent":
return F(e, s, d);
case "style":
if (typeof d != "object")
break;
case "dataset":
return P(o, d, z.bind(null, e[s]));
case "ariaset":
return P(o, d, (v, u) => c("aria-" + v, u));
case "classList":
return J.call(n, e, d);
}
return V(e, s) ? F(e, s, d) : c(s, d);
}), e;
var { setDeleteAttr: z } = W, O = /* @__PURE__ */ new WeakMap();
function R(t, ...e) {
if (!e.length)
return t;
O.set(t, U(t, this));
for (let [n, o] of Object.entries(Object.assign({}, ...e)))
H.call(this, t, n, o);
return O.delete(t), t;
}
function J(e, t) {
let n = y(this);
return P(
n,
function H(t, e, n) {
let { setRemoveAttr: o, s: r } = U(t, this), c = this;
n = r.processReactiveAttribute(
t,
(o, r) => e.classList.toggle(o, r === -1 ? void 0 : !!r)
), e;
e,
n,
(a, p) => H.call(c, t, a, p)
);
let [s] = e;
if (s === "=")
return o(e.slice(1), n);
if (s === ".")
return k(t, e.slice(1), n);
if (/(aria|data)([A-Z])/.test(e))
return e = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), o(e, n);
switch (e === "className" && (e = "class"), e) {
case "xlink:href":
return o(e, n, "http://www.w3.org/1999/xlink");
case "textContent":
return z(t, e, n);
case "style":
if (typeof n != "object")
break;
case "dataset":
return j(r, n, k.bind(null, t[e]));
case "ariaset":
return j(r, n, (a, p) => o("aria-" + a, p));
case "classList":
return K.call(c, t, n);
}
return Q(t, e) ? z(t, e, n) : o(e, n);
}
function fe(e) {
return Array.from(e.children).forEach((t) => t.remove()), e;
function U(t, e) {
if (O.has(t))
return O.get(t);
let o = (t instanceof SVGElement ? G : B).bind(null, t, "Attribute"), r = S(e);
return { setRemoveAttr: o, s: r };
}
function V(e, t) {
if (!Reflect.has(e, t))
function K(t, e) {
let n = S(this);
return j(
n,
e,
(o, r) => t.classList.toggle(o, r === -1 ? void 0 : !!r)
), t;
}
function pt(t) {
return Array.from(t.children).forEach((e) => e.remove()), t;
}
function Q(t, e) {
if (!Reflect.has(t, e))
return !1;
let n = H(e, t);
let n = $(t, e);
return !E(n.set);
}
function H(e, t) {
if (e = Object.getPrototypeOf(e), !e)
function $(t, e) {
if (t = Object.getPrototypeOf(t), !t)
return {};
let n = Object.getOwnPropertyDescriptor(e, t);
return n || H(e, t);
let n = Object.getOwnPropertyDescriptor(t, e);
return n || $(t, e);
}
function P(e, t, n) {
if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([r, c]) {
r && (c = e.processReactiveAttribute(t, r, c, (i) => n(...i)), n(r, c));
function j(t, e, n) {
if (!(typeof e != "object" || e === null))
return Object.entries(e).forEach(function([r, c]) {
r && (c = t.processReactiveAttribute(e, r, c, n), n(r, c));
});
}
function U(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
function q(t) {
return Array.isArray(t) ? t.filter(Boolean).join(" ") : t;
}
function $(e, t, n, o) {
return e[(E(o) ? "remove" : "set") + t](n, U(o));
function B(t, e, n, o) {
return t[(E(o) ? "remove" : "set") + e](n, q(o));
}
function q(e, t, n, o, r = null) {
return e[(E(o) ? "remove" : "set") + t + "NS"](r, n, U(o));
function G(t, e, n, o, r = null) {
return t[(E(o) ? "remove" : "set") + e + "NS"](r, n, q(o));
}
function z(e, t, n) {
if (Reflect.set(e, t, n), !!E(n))
return Reflect.deleteProperty(e, t);
function k(t, e, n) {
if (Reflect.set(t, e, n), !!E(n))
return Reflect.deleteProperty(t, e);
}
// src/events.js
function le(e, t, ...n) {
let o = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(o);
function gt(t, e, ...n) {
let o = n.length ? new CustomEvent(e, { detail: n[0] }) : new Event(e);
return t.dispatchEvent(o);
}
function _(e, t, n) {
function v(t, e, n) {
return function(r) {
return r.addEventListener(e, t, n), r;
return r.addEventListener(t, e, n), r;
};
}
var R = K(), Z = /* @__PURE__ */ new WeakSet();
_.connected = function(e, t) {
var C = Y(), X = /* @__PURE__ */ new WeakSet();
v.connected = function(t, e) {
let n = "connected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
let c = "dde:" + n;
return r.addEventListener(c, e, t), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(c)), r) : (A(t.signal, () => R.offConnected(r, e)) && R.onConnected(r, e), r);
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(c)), r) : (A(e.signal, () => C.offConnected(r, t)) && C.onConnected(r, t), r);
};
};
_.disconnected = function(e, t) {
v.disconnected = function(t, e) {
let n = "disconnected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
let c = "dde:" + n;
return r.addEventListener(c, e, t), r.__dde_lifecycleToEvents || A(t.signal, () => R.offDisconnected(r, e)) && R.onDisconnected(r, e), r;
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || A(e.signal, () => C.offDisconnected(r, t)) && C.onDisconnected(r, t), r;
};
};
_.attributeChanged = function(e, t) {
v.attributeChanged = function(t, e) {
let n = "attributeChanged";
return typeof t != "object" && (t = {}), function(r) {
return typeof e != "object" && (e = {}), function(r) {
let c = "dde:" + n;
if (r.addEventListener(c, e, t), r.__dde_lifecycleToEvents || Z.has(r))
if (r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || X.has(r))
return r;
let i = new MutationObserver(function(d) {
for (let { attributeName: m, target: v } of d)
v.dispatchEvent(
new CustomEvent(c, { detail: [m, v.getAttribute(m)] })
let s = new MutationObserver(function(p) {
for (let { attributeName: b, target: _ } of p)
_.dispatchEvent(
new CustomEvent(c, { detail: [b, _.getAttribute(b)] })
);
});
return A(t.signal, () => i.disconnect()) && i.observe(r, { attributes: !0 }), r;
return A(e.signal, () => s.disconnect()) && s.observe(r, { attributes: !0 }), r;
};
};
function K() {
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(u) {
for (let f of u)
if (f.type === "childList") {
if (m(f.addedNodes, !0)) {
i();
function Y() {
let t = /* @__PURE__ */ new Map(), e = !1, n = new MutationObserver(function(i) {
for (let u of i)
if (u.type === "childList") {
if (b(u.addedNodes, !0)) {
s();
continue;
}
v(f.removedNodes, !0) && i();
_(u.removedNodes, !0) && s();
}
});
return {
onConnected(u, f) {
onConnected(i, u) {
c();
let a = r(u);
a.connected.has(f) || (a.connected.add(f), a.length_c += 1);
let f = r(i);
f.connected.has(u) || (f.connected.add(u), f.length_c += 1);
},
offConnected(u, f) {
if (!e.has(u))
offConnected(i, u) {
if (!t.has(i))
return;
let a = e.get(u);
a.connected.has(f) && (a.connected.delete(f), a.length_c -= 1, o(u, a));
let f = t.get(i);
f.connected.has(u) && (f.connected.delete(u), f.length_c -= 1, o(i, f));
},
onDisconnected(u, f) {
onDisconnected(i, u) {
c();
let a = r(u);
a.disconnected.has(f) || (a.disconnected.add(f), a.length_d += 1);
let f = r(i);
f.disconnected.has(u) || (f.disconnected.add(u), f.length_d += 1);
},
offDisconnected(u, f) {
if (!e.has(u))
offDisconnected(i, u) {
if (!t.has(i))
return;
let a = e.get(u);
a.disconnected.has(f) && (a.disconnected.delete(f), a.length_d -= 1, o(u, a));
let f = t.get(i);
f.disconnected.has(u) && (f.disconnected.delete(u), f.length_d -= 1, o(i, f));
}
};
function o(u, f) {
f.length_c || f.length_d || (e.delete(u), i());
function o(i, u) {
u.length_c || u.length_d || (t.delete(i), s());
}
function r(u) {
if (e.has(u))
return e.get(u);
let f = {
function r(i) {
if (t.has(i))
return t.get(i);
let u = {
connected: /* @__PURE__ */ new WeakSet(),
length_c: 0,
disconnected: /* @__PURE__ */ new WeakSet(),
length_d: 0
};
return e.set(u, f), f;
return t.set(i, u), u;
}
function c() {
t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
}
function i() {
!t || e.size || (t = !1, n.disconnect());
e || (e = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
}
function s() {
return new Promise(function(u) {
(requestIdleCallback || requestAnimationFrame)(u);
!e || t.size || (e = !1, n.disconnect());
}
function a() {
return new Promise(function(i) {
(requestIdleCallback || requestAnimationFrame)(i);
});
}
async function d(u) {
e.size > 30 && await s();
let f = [];
if (!(u instanceof Node))
return f;
for (let a of e.keys())
a === u || !(a instanceof Node) || u.contains(a) && f.push(a);
async function p(i) {
t.size > 30 && await a();
let u = [];
if (!(i instanceof Node))
return u;
for (let f of t.keys())
f === i || !(f instanceof Node) || i.contains(f) && u.push(f);
return u;
}
function b(i, u) {
let f = !1;
for (let h of i) {
if (u && p(h).then(b), !t.has(h))
continue;
let w = t.get(h);
w.length_c && (h.dispatchEvent(new Event("dde:connected")), w.connected = /* @__PURE__ */ new WeakSet(), w.length_c = 0, w.length_d || t.delete(h), f = !0);
}
return f;
}
function m(u, f) {
let a = !1;
for (let h of u) {
if (f && d(h).then(m), !e.has(h))
continue;
let w = e.get(h);
w.length_c && (h.dispatchEvent(new Event("dde:connected")), w.connected = /* @__PURE__ */ new WeakSet(), w.length_c = 0, w.length_d || e.delete(h), a = !0);
}
return a;
}
function v(u, f) {
let a = !1;
for (let h of u)
f && d(h).then(v), !(!e.has(h) || !e.get(h).length_d) && (h.dispatchEvent(new Event("dde:disconnected")), e.delete(h), a = !0);
return a;
function _(i, u) {
let f = !1;
for (let h of i)
u && p(h).then(_), !(!t.has(h) || !t.get(h).length_d) && (h.dispatchEvent(new Event("dde:disconnected")), t.delete(h), f = !0);
return f;
}
}
// index.js
[HTMLElement, SVGElement, DocumentFragment].forEach((e) => {
let { append: t } = e.prototype;
e.prototype.append = function(...n) {
return t.apply(this, n), this;
[HTMLElement, SVGElement, DocumentFragment].forEach((t) => {
let { append: e } = t.prototype;
t.prototype.append = function(...n) {
return e.apply(this, n), this;
};
});
// src/signals-lib.js
var l = Symbol.for("Signal");
function C(e) {
var d = Symbol.for("Signal");
function L(t) {
try {
return Reflect.has(e, l);
return Reflect.has(t, d);
} catch {
return !1;
}
}
var L = [], g = /* @__PURE__ */ new WeakMap();
function p(e, t) {
if (typeof e != "function")
return k(e, t);
if (C(e))
return e;
let n = k(), o = function() {
L.push(o), n(e()), L.pop();
var D = [], g = /* @__PURE__ */ new WeakMap();
function l(t, e) {
if (typeof t != "function")
return I(t, e);
if (L(t))
return t;
let n = I(), o = function() {
D.push(o), n(t()), D.pop();
};
return g.set(o, /* @__PURE__ */ new Set([n])), g.set(n[l], o), o(), n;
return g.set(o, /* @__PURE__ */ new Set([n])), g.set(n[d], o), o(), n;
}
p.action = function(e, t, ...n) {
let o = e[l], { actions: r } = o;
if (!r || !Reflect.has(r, t))
throw new Error(`'${e}' has no action with name '${t}'!`);
if (r[t].apply(o, n), o.skip)
l.action = function(t, e, ...n) {
let o = t[d], { actions: r } = o;
if (!r || !Reflect.has(r, e))
throw new Error(`'${t}' has no action with name '${e}'!`);
if (r[e].apply(o, n), o.skip)
return Reflect.deleteProperty(o, "skip");
o.listeners.forEach((c) => c(o.value));
};
p.on = function e(t, n, o = {}) {
l.on = function t(e, n, o = {}) {
let { signal: r } = o;
if (!(r && r.aborted)) {
if (Array.isArray(t))
return t.forEach((c) => e(c, n, o));
j(t, n), r && r.addEventListener("abort", () => N(t, n));
if (Array.isArray(e))
return e.forEach((c) => t(c, n, o));
T(e, n), r && r.addEventListener("abort", () => N(e, n));
}
};
p.symbols = {
signal: l,
l.symbols = {
signal: d,
onclear: Symbol.for("Signal.onclear")
};
p.attribute = function(e, t = void 0) {
let { host: n } = b, o = n() && n().hasAttribute(e) ? n().getAttribute(e) : t, r = new AbortController(), c = p(o, {
[p.symbols.onclear]() {
l.attribute = function(t, e = void 0) {
let { host: n } = m, o = n() && n().hasAttribute(t) ? n().getAttribute(t) : e, r = new AbortController(), c = l(o, {
[l.symbols.onclear]() {
r.abort();
}
});
return b.host(_.attributeChanged(function({ detail: s }) {
let [d, m] = s;
d === e && c(m);
return m.host(v.attributeChanged(function({ detail: a }) {
let [p, b] = a;
p === t && c(b);
}, { signal: r.signal })), c;
};
p.clear = function(...e) {
for (let n of e) {
l.clear = function(...t) {
for (let n of t) {
Reflect.deleteProperty(n, "toJSON");
let o = n[l];
o.onclear.forEach((r) => r.call(o)), t(n, o), Reflect.deleteProperty(n, l);
let o = n[d];
o.onclear.forEach((r) => r.call(o)), e(n, o), Reflect.deleteProperty(n, d);
}
function t(n, o) {
function e(n, o) {
o.listeners.forEach((r) => {
if (o.listeners.delete(r), !g.has(r))
return;
let c = g.get(r);
c.delete(n), !(c.size > 1) && (p.clear(...c), g.delete(r));
c.delete(n), !(c.size > 1) && (l.clear(...c), g.delete(r));
});
}
};
p.el = function(e, t) {
l.el = function(t, e) {
let n = document.createComment("<#reactive>"), o = document.createComment("</#reactive>"), r = document.createDocumentFragment();
r.append(n, o);
let c = (i) => {
let c = (s) => {
if (!n.parentNode || !o.parentNode)
return N(e, c);
let s = t(i);
Array.isArray(s) || (s = [s]);
let d = n;
for (; (d = n.nextSibling) !== o; )
d.remove();
n.after(...s);
return N(t, c);
let a = e(s);
Array.isArray(a) || (a = [a]);
let p = n;
for (; (p = n.nextSibling) !== o; )
p.remove();
n.after(...a);
};
return j(e, c), G(e, c, n, t), c(e()), r;
return T(t, c), V(t, c, n, e), c(t()), r;
};
var B = {
isSignal: C,
processReactiveAttribute(e, t, n, o) {
if (!C(n))
var J = {
isSignal: L,
processReactiveAttribute(t, e, n, o) {
if (!L(n))
return n;
let r = (c) => o([t, c]);
return j(n, r), G(n, r, e, t), n();
let r = (c) => o(e, c);
return T(n, r), V(n, r, t, e), n();
}
};
function G(e, t, ...n) {
let { current: o } = b;
function V(t, e, ...n) {
let { current: o } = m;
if (o.prevent)
return;
let r = "__dde_reactive";
o.host(function(c) {
c[r] || (c[r] = [], _.disconnected(
c[r] || (c[r] = [], v.disconnected(
() => (
/*!
* Clears all signals listeners added in the current scope/host (`S.el`, `assign`, ?).
* You can investigate the `__dde_reactive` key of the element.
* */
c[r].forEach(([i]) => N(...i, e[l]?.host() === c))
c[r].forEach(([s]) => N(...s, t[d]?.host() === c))
)
)(c)), c[r].push([[e, t], ...n]);
)(c)), c[r].push([[t, e], ...n]);
});
}
function k(e, t) {
let n = (...o) => o.length ? te(n, ...o) : ee(n);
return X(n, e, t);
function I(t, e) {
let n = (...o) => o.length ? ot(n, ...o) : rt(n);
return et(n, t, e);
}
var Q = Object.assign(/* @__PURE__ */ Object.create(null), {
var tt = Object.assign(/* @__PURE__ */ Object.create(null), {
stopPropagation() {
this.skip = !0;
}
});
function X(e, t, n) {
function et(t, e, n) {
let o = [];
T(n) !== "[object Object]" && (n = {});
let { onclear: r } = p.symbols;
M(n) !== "[object Object]" && (n = {});
let { onclear: r } = l.symbols;
n[r] && (o.push(n[r]), Reflect.deleteProperty(n, r));
let { host: c } = b;
return e[l] = {
value: t,
let { host: c } = m;
return t[d] = {
value: e,
actions: n,
onclear: o,
host: c,
listeners: /* @__PURE__ */ new Set()
}, e.toJSON = () => e(), Object.setPrototypeOf(e[l], Q), e;
}, t.toJSON = () => t(), Object.setPrototypeOf(t[d], tt), t;
}
function Y() {
return L[L.length - 1];
function nt() {
return D[D.length - 1];
}
function ee(e) {
if (!e[l])
function rt(t) {
if (!t[d])
return;
let { value: t, listeners: n } = e[l], o = Y();
return o && n.add(o), g.has(o) && g.get(o).add(e), t;
let { value: e, listeners: n } = t[d], o = nt();
return o && n.add(o), g.has(o) && g.get(o).add(t), e;
}
function te(e, t, n) {
if (!e[l])
function ot(t, e, n) {
if (!t[d])
return;
let o = e[l];
if (!(!n && o.value === t))
return o.value = t, o.listeners.forEach((r) => r(t)), t;
let o = t[d];
if (!(!n && o.value === e))
return o.value = e, o.listeners.forEach((r) => r(e)), e;
}
function j(e, t) {
if (e[l])
return e[l].listeners.add(t);
function T(t, e) {
if (t[d])
return t[d].listeners.add(e);
}
function N(e, t, n) {
let o = e[l];
function N(t, e, n) {
let o = t[d];
if (!o)
return;
let r = o.listeners.delete(t);
let r = o.listeners.delete(e);
if (n && !o.listeners.size) {
if (p.clear(e), !g.has(o))
if (l.clear(t), !g.has(o))
return r;
let c = g.get(o);
if (!g.has(c))
return r;
g.get(c).forEach((i) => N(i, c, !0));
g.get(c).forEach((s) => N(s, c, !0));
}
return r;
}
// signals.js
D(B);
P(J);
export {
p as S,
O as assign,
J as classListDeclarative,
ie as createElement,
le as dispatchEvent,
ie as el,
fe as empty,
C as isSignal,
_ as on,
D as registerReactivity,
b as scope
l as S,
R as assign,
H as assignAttribute,
K as classListDeclarative,
at as createElement,
gt as dispatchEvent,
at as el,
pt as empty,
L as isSignal,
v as on,
P as registerReactivity,
m as scope
};

399
dist/esm.js vendored
View File

@ -1,40 +1,40 @@
// src/signals-common.js
var m = {
isSignal(e) {
var v = {
isSignal(t) {
return !1;
},
processReactiveAttribute(e, t, n, u) {
processReactiveAttribute(t, e, n, c) {
return n;
}
};
function T(e, t = !0) {
return t ? Object.assign(m, e) : (Object.setPrototypeOf(e, m), e);
function F(t, e = !0) {
return e ? Object.assign(v, t) : (Object.setPrototypeOf(t, v), t);
}
function b(e) {
return m.isPrototypeOf(e) && e !== m ? e : m;
function m(t) {
return v.isPrototypeOf(t) && t !== v ? t : v;
}
// src/helpers.js
function g(e) {
return typeof e > "u";
function h(t) {
return typeof t > "u";
}
function _(e, t) {
if (!e || !(e instanceof AbortSignal))
function _(t, e) {
if (!t || !(t instanceof AbortSignal))
return !0;
if (!e.aborted)
return e.addEventListener("abort", t), function() {
e.removeEventListener("abort", t);
if (!t.aborted)
return t.addEventListener("abort", e), function() {
t.removeEventListener("abort", e);
};
}
// src/dom-common.js
var C = { setDeleteAttr: M };
function M(e, t, n) {
if (Reflect.set(e, t, n), !!g(n)) {
if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t);
if (Reflect.get(e, t) === "undefined")
return Reflect.set(e, t, "");
var R = { setDeleteAttr: H };
function H(t, e, n) {
if (Reflect.set(t, e, n), !!h(n)) {
if (Reflect.deleteProperty(t, e), t instanceof HTMLElement && t.getAttribute(e) === "undefined")
return t.removeAttribute(e);
if (Reflect.get(t, e) === "undefined")
return Reflect.set(t, e, "");
}
}
@ -42,9 +42,9 @@ function M(e, t, n) {
var E = [{
scope: document.body,
namespace: "html",
host: (e) => e ? e(document.body) : document.body,
host: (t) => t ? t(document.body) : document.body,
prevent: !0
}], R = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, x = {
}], S = (t) => t === "svg" ? "http://www.w3.org/2000/svg" : t, x = {
get current() {
return E[E.length - 1];
},
@ -54,270 +54,285 @@ var E = [{
get namespace() {
return this.current.namespace;
},
set namespace(e) {
return this.current.namespace = R(e);
set namespace(t) {
return this.current.namespace = S(t);
},
preventDefault() {
let { current: e } = this;
return e.prevent = !0, e;
let { current: t } = this;
return t.prevent = !0, t;
},
elNamespace(e) {
let t = this.namespace;
return this.namespace = e, {
elNamespace(t) {
let e = this.namespace;
return this.namespace = t, {
append(...n) {
return x.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
return x.namespace = e, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
}
};
},
get state() {
return [...E];
},
push(e = {}) {
return e.namespace && (e.namespace = R(e.namespace)), E.push(Object.assign({}, this.current, { prevent: !1 }, e));
push(t = {}) {
return t.namespace && (t.namespace = S(t.namespace)), E.push(Object.assign({}, this.current, { prevent: !1 }, t));
},
pop() {
return E.pop();
}
};
function V(e, t, ...n) {
let u = b(this), { namespace: r } = x, f = 0, a;
switch ((Object(t) !== t || u.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": {
f = 1, x.push({ scope: e, host: (i) => i ? (f === 1 ? n.unshift(i) : i(a), void 0) : a }), a = e(t || void 0), (a instanceof HTMLElement ? P : j)(a, "Attribute", "dde-fun", e.name);
function J(t, e, ...n) {
let c = m(this), { namespace: r } = x, f = 0, u;
switch ((Object(e) !== e || c.isSignal(e)) && (e = { textContent: e }), !0) {
case typeof t == "function": {
f = 1, x.push({ scope: t, host: (a) => a ? (f === 1 ? n.unshift(a) : a(u), void 0) : u }), u = t(e || void 0), (u instanceof HTMLElement ? M : W)(u, "Attribute", "dde-fun", t.name);
break;
}
case e === "#text":
a = w.call(this, document.createTextNode(""), t);
case t === "#text":
u = w.call(this, document.createTextNode(""), e);
break;
case e === "<>":
a = w.call(this, document.createDocumentFragment(), t);
case t === "<>":
u = w.call(this, document.createDocumentFragment(), e);
break;
case r !== "html":
a = w.call(this, document.createElementNS(r, e), t);
u = w.call(this, document.createElementNS(r, t), e);
break;
case !a:
a = w.call(this, document.createElement(e), t);
case !u:
u = w.call(this, document.createElement(t), e);
}
return n.forEach((i) => i(a)), f && x.pop(), f = 2, a;
return n.forEach((a) => a(u)), f && x.pop(), f = 2, u;
}
var { setDeleteAttr: S } = C;
function w(e, ...t) {
let n = this, u = b(this);
if (!t.length)
return e;
let f = (e instanceof SVGElement ? j : P).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function a([i, d]) {
d = u.processReactiveAttribute(e, i, d, a);
let [l] = i;
if (l === "=")
return f(i.slice(1), d);
if (l === ".")
return L(e, i.slice(1), d);
if (/(aria|data)([A-Z])/.test(i))
return i = i.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), f(i, d);
switch (i === "className" && (i = "class"), i) {
case "xlink:href":
return f(i, d, "http://www.w3.org/1999/xlink");
case "textContent":
return S(e, i, d);
case "style":
if (typeof d != "object")
break;
case "dataset":
return O(u, d, L.bind(null, e[i]));
case "ariaset":
return O(u, d, (h, c) => f("aria-" + h, c));
case "classList":
return W.call(n, e, d);
}
return F(e, i) ? S(e, i, d) : f(i, d);
}), e;
var { setDeleteAttr: L } = R, A = /* @__PURE__ */ new WeakMap();
function w(t, ...e) {
if (!e.length)
return t;
A.set(t, P(t, this));
for (let [n, c] of Object.entries(Object.assign({}, ...e)))
N.call(this, t, n, c);
return A.delete(t), t;
}
function W(e, t) {
let n = b(this);
return O(
n,
function N(t, e, n) {
let { setRemoveAttr: c, s: r } = P(t, this), f = this;
n = r.processReactiveAttribute(
t,
(u, r) => e.classList.toggle(u, r === -1 ? void 0 : !!r)
), e;
e,
n,
(a, p) => N.call(f, t, a, p)
);
let [u] = e;
if (u === "=")
return c(e.slice(1), n);
if (u === ".")
return D(t, e.slice(1), n);
if (/(aria|data)([A-Z])/.test(e))
return e = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), c(e, n);
switch (e === "className" && (e = "class"), e) {
case "xlink:href":
return c(e, n, "http://www.w3.org/1999/xlink");
case "textContent":
return L(t, e, n);
case "style":
if (typeof n != "object")
break;
case "dataset":
return y(r, n, D.bind(null, t[e]));
case "ariaset":
return y(r, n, (a, p) => c("aria-" + a, p));
case "classList":
return U.call(f, t, n);
}
return q(t, e) ? L(t, e, n) : c(e, n);
}
function $(e) {
return Array.from(e.children).forEach((t) => t.remove()), e;
function P(t, e) {
if (A.has(t))
return A.get(t);
let c = (t instanceof SVGElement ? W : M).bind(null, t, "Attribute"), r = m(e);
return { setRemoveAttr: c, s: r };
}
function F(e, t) {
if (!Reflect.has(e, t))
function U(t, e) {
let n = m(this);
return y(
n,
e,
(c, r) => t.classList.toggle(c, r === -1 ? void 0 : !!r)
), t;
}
function Q(t) {
return Array.from(t.children).forEach((e) => e.remove()), t;
}
function q(t, e) {
if (!Reflect.has(t, e))
return !1;
let n = D(e, t);
return !g(n.set);
let n = j(t, e);
return !h(n.set);
}
function D(e, t) {
if (e = Object.getPrototypeOf(e), !e)
function j(t, e) {
if (t = Object.getPrototypeOf(t), !t)
return {};
let n = Object.getOwnPropertyDescriptor(e, t);
return n || D(e, t);
let n = Object.getOwnPropertyDescriptor(t, e);
return n || j(t, e);
}
function O(e, t, n) {
if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([r, f]) {
r && (f = e.processReactiveAttribute(t, r, f, (a) => n(...a)), n(r, f));
function y(t, e, n) {
if (!(typeof e != "object" || e === null))
return Object.entries(e).forEach(function([r, f]) {
r && (f = t.processReactiveAttribute(e, r, f, n), n(r, f));
});
}
function N(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
function T(t) {
return Array.isArray(t) ? t.filter(Boolean).join(" ") : t;
}
function P(e, t, n, u) {
return e[(g(u) ? "remove" : "set") + t](n, N(u));
function M(t, e, n, c) {
return t[(h(c) ? "remove" : "set") + e](n, T(c));
}
function j(e, t, n, u, r = null) {
return e[(g(u) ? "remove" : "set") + t + "NS"](r, n, N(u));
function W(t, e, n, c, r = null) {
return t[(h(c) ? "remove" : "set") + e + "NS"](r, n, T(c));
}
function L(e, t, n) {
if (Reflect.set(e, t, n), !!g(n))
return Reflect.deleteProperty(e, t);
function D(t, e, n) {
if (Reflect.set(t, e, n), !!h(n))
return Reflect.deleteProperty(t, e);
}
// src/events.js
function Q(e, t, ...n) {
let u = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(u);
function k(t, e, ...n) {
let c = n.length ? new CustomEvent(e, { detail: n[0] }) : new Event(e);
return t.dispatchEvent(c);
}
function y(e, t, n) {
function C(t, e, n) {
return function(r) {
return r.addEventListener(e, t, n), r;
return r.addEventListener(t, e, n), r;
};
}
var A = U(), H = /* @__PURE__ */ new WeakSet();
y.connected = function(e, t) {
var O = B(), z = /* @__PURE__ */ new WeakSet();
C.connected = function(t, e) {
let n = "connected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
let f = "dde:" + n;
return r.addEventListener(f, e, t), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(f)), r) : (_(t.signal, () => A.offConnected(r, e)) && A.onConnected(r, e), r);
return r.addEventListener(f, t, e), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(f)), r) : (_(e.signal, () => O.offConnected(r, t)) && O.onConnected(r, t), r);
};
};
y.disconnected = function(e, t) {
C.disconnected = function(t, e) {
let n = "disconnected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
let f = "dde:" + n;
return r.addEventListener(f, e, t), r.__dde_lifecycleToEvents || _(t.signal, () => A.offDisconnected(r, e)) && A.onDisconnected(r, e), r;
return r.addEventListener(f, t, e), r.__dde_lifecycleToEvents || _(e.signal, () => O.offDisconnected(r, t)) && O.onDisconnected(r, t), r;
};
};
y.attributeChanged = function(e, t) {
C.attributeChanged = function(t, e) {
let n = "attributeChanged";
return typeof t != "object" && (t = {}), function(r) {
return typeof e != "object" && (e = {}), function(r) {
let f = "dde:" + n;
if (r.addEventListener(f, e, t), r.__dde_lifecycleToEvents || H.has(r))
if (r.addEventListener(f, t, e), r.__dde_lifecycleToEvents || z.has(r))
return r;
let a = new MutationObserver(function(d) {
for (let { attributeName: l, target: h } of d)
h.dispatchEvent(
new CustomEvent(f, { detail: [l, h.getAttribute(l)] })
let u = new MutationObserver(function(p) {
for (let { attributeName: l, target: g } of p)
g.dispatchEvent(
new CustomEvent(f, { detail: [l, g.getAttribute(l)] })
);
});
return _(t.signal, () => a.disconnect()) && a.observe(r, { attributes: !0 }), r;
return _(e.signal, () => u.disconnect()) && u.observe(r, { attributes: !0 }), r;
};
};
function U() {
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(c) {
for (let o of c)
if (o.type === "childList") {
if (l(o.addedNodes, !0)) {
a();
function B() {
let t = /* @__PURE__ */ new Map(), e = !1, n = new MutationObserver(function(o) {
for (let s of o)
if (s.type === "childList") {
if (l(s.addedNodes, !0)) {
u();
continue;
}
h(o.removedNodes, !0) && a();
g(s.removedNodes, !0) && u();
}
});
return {
onConnected(c, o) {
onConnected(o, s) {
f();
let s = r(c);
s.connected.has(o) || (s.connected.add(o), s.length_c += 1);
let i = r(o);
i.connected.has(s) || (i.connected.add(s), i.length_c += 1);
},
offConnected(c, o) {
if (!e.has(c))
offConnected(o, s) {
if (!t.has(o))
return;
let s = e.get(c);
s.connected.has(o) && (s.connected.delete(o), s.length_c -= 1, u(c, s));
let i = t.get(o);
i.connected.has(s) && (i.connected.delete(s), i.length_c -= 1, c(o, i));
},
onDisconnected(c, o) {
onDisconnected(o, s) {
f();
let s = r(c);
s.disconnected.has(o) || (s.disconnected.add(o), s.length_d += 1);
let i = r(o);
i.disconnected.has(s) || (i.disconnected.add(s), i.length_d += 1);
},
offDisconnected(c, o) {
if (!e.has(c))
offDisconnected(o, s) {
if (!t.has(o))
return;
let s = e.get(c);
s.disconnected.has(o) && (s.disconnected.delete(o), s.length_d -= 1, u(c, s));
let i = t.get(o);
i.disconnected.has(s) && (i.disconnected.delete(s), i.length_d -= 1, c(o, i));
}
};
function u(c, o) {
o.length_c || o.length_d || (e.delete(c), a());
function c(o, s) {
s.length_c || s.length_d || (t.delete(o), u());
}
function r(c) {
if (e.has(c))
return e.get(c);
let o = {
function r(o) {
if (t.has(o))
return t.get(o);
let s = {
connected: /* @__PURE__ */ new WeakSet(),
length_c: 0,
disconnected: /* @__PURE__ */ new WeakSet(),
length_d: 0
};
return e.set(c, o), o;
return t.set(o, s), s;
}
function f() {
t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
e || (e = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
}
function u() {
!e || t.size || (e = !1, n.disconnect());
}
function a() {
!t || e.size || (t = !1, n.disconnect());
}
function i() {
return new Promise(function(c) {
(requestIdleCallback || requestAnimationFrame)(c);
return new Promise(function(o) {
(requestIdleCallback || requestAnimationFrame)(o);
});
}
async function d(c) {
e.size > 30 && await i();
let o = [];
if (!(c instanceof Node))
return o;
for (let s of e.keys())
s === c || !(s instanceof Node) || c.contains(s) && o.push(s);
return o;
async function p(o) {
t.size > 30 && await a();
let s = [];
if (!(o instanceof Node))
return s;
for (let i of t.keys())
i === o || !(i instanceof Node) || o.contains(i) && s.push(i);
return s;
}
function l(c, o) {
let s = !1;
for (let p of c) {
if (o && d(p).then(l), !e.has(p))
function l(o, s) {
let i = !1;
for (let d of o) {
if (s && p(d).then(l), !t.has(d))
continue;
let v = e.get(p);
v.length_c && (p.dispatchEvent(new Event("dde:connected")), v.connected = /* @__PURE__ */ new WeakSet(), v.length_c = 0, v.length_d || e.delete(p), s = !0);
let b = t.get(d);
b.length_c && (d.dispatchEvent(new Event("dde:connected")), b.connected = /* @__PURE__ */ new WeakSet(), b.length_c = 0, b.length_d || t.delete(d), i = !0);
}
return s;
return i;
}
function h(c, o) {
let s = !1;
for (let p of c)
o && d(p).then(h), !(!e.has(p) || !e.get(p).length_d) && (p.dispatchEvent(new Event("dde:disconnected")), e.delete(p), s = !0);
return s;
function g(o, s) {
let i = !1;
for (let d of o)
s && p(d).then(g), !(!t.has(d) || !t.get(d).length_d) && (d.dispatchEvent(new Event("dde:disconnected")), t.delete(d), i = !0);
return i;
}
}
// index.js
[HTMLElement, SVGElement, DocumentFragment].forEach((e) => {
let { append: t } = e.prototype;
e.prototype.append = function(...n) {
return t.apply(this, n), this;
[HTMLElement, SVGElement, DocumentFragment].forEach((t) => {
let { append: e } = t.prototype;
t.prototype.append = function(...n) {
return e.apply(this, n), this;
};
});
export {
w as assign,
W as classListDeclarative,
V as createElement,
Q as dispatchEvent,
V as el,
$ as empty,
y as on,
T as registerReactivity,
N as assignAttribute,
U as classListDeclarative,
J as createElement,
k as dispatchEvent,
J as el,
Q as empty,
C as on,
F as registerReactivity,
x as scope
};