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