2023-09-13 13:20:00 +02:00
|
|
|
// src/signals-common.js
|
2023-10-14 12:43:53 +02:00
|
|
|
var x = {
|
2023-09-21 12:35:27 +02:00
|
|
|
isSignal(e) {
|
|
|
|
return !1;
|
2023-09-13 13:20:00 +02:00
|
|
|
},
|
2023-10-14 12:43:53 +02:00
|
|
|
processReactiveAttribute(e, t, n, o) {
|
2023-09-19 12:34:42 +02:00
|
|
|
return n;
|
2023-09-13 13:20:00 +02:00
|
|
|
}
|
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
function N(e, t = !0) {
|
|
|
|
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e);
|
2023-09-13 13:20:00 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function y(e) {
|
|
|
|
return x.isPrototypeOf(e) && e !== x ? e : x;
|
2023-09-13 13:20:00 +02:00
|
|
|
}
|
|
|
|
|
2023-09-05 09:25:47 +02:00
|
|
|
// src/helpers.js
|
2023-10-14 12:43:53 +02:00
|
|
|
function v(e) {
|
2023-09-13 13:20:00 +02:00
|
|
|
return typeof e > "u";
|
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
function T(e) {
|
2023-09-05 09:25:47 +02:00
|
|
|
let t = typeof e;
|
|
|
|
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
|
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function A(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-14 12:43:53 +02:00
|
|
|
var M = { setDeleteAttr: I };
|
|
|
|
function I(e, t, n) {
|
|
|
|
if (Reflect.set(e, t, n), !!v(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 20:57:21 +02:00
|
|
|
var S = [{
|
|
|
|
scope: document.body,
|
|
|
|
namespace: "html",
|
|
|
|
host: (e) => e ? e(document.body) : document.body,
|
|
|
|
prevent: !0
|
2023-10-14 12:43:53 +02:00
|
|
|
}], W = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, m = {
|
2023-10-10 10:55:00 +02:00
|
|
|
get current() {
|
2023-10-13 20:57:21 +02:00
|
|
|
return S[S.length - 1];
|
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:51:43 +02:00
|
|
|
return this.current.namespace = W(e);
|
2023-10-10 10:55:00 +02:00
|
|
|
},
|
2023-10-13 20:57:21 +02:00
|
|
|
preventDefault() {
|
|
|
|
let { current: e } = this;
|
|
|
|
return e.prevent = !0, e;
|
|
|
|
},
|
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-14 12:43:53 +02:00
|
|
|
return m.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
|
2023-10-09 13:49:38 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
2023-10-14 12:43:53 +02:00
|
|
|
get state() {
|
|
|
|
return [...S];
|
|
|
|
},
|
2023-10-10 10:55:00 +02:00
|
|
|
push(e = {}) {
|
2023-10-13 20:57:21 +02:00
|
|
|
return e.namespace && (e.namespace = W(e.namespace)), S.push(Object.assign({}, this.current, { prevent: !1 }, e));
|
2023-10-09 13:49:38 +02:00
|
|
|
},
|
2023-10-10 10:55:00 +02:00
|
|
|
pop() {
|
2023-10-13 20:57:21 +02:00
|
|
|
return S.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 ie(e, t, ...n) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let o = y(this), { namespace: r } = m, c = 0, u;
|
2023-09-21 17:04:40 +02:00
|
|
|
switch ((Object(t) !== t || o.isSignal(t)) && (t = { textContent: t }), !0) {
|
2023-09-09 21:15:43 +02:00
|
|
|
case typeof e == "function": {
|
2023-10-14 12:43:53 +02:00
|
|
|
c = 1, m.push({ scope: e, host: (s) => s ? (c === 1 ? n.unshift(s) : s(u), void 0) : u }), u = e(t || void 0), (u instanceof HTMLElement ? $ : q)(u, "Attribute", "dde-fun", e.name);
|
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-14 12:43:53 +02:00
|
|
|
u = O.call(this, document.createTextNode(""), t);
|
2023-09-08 20:18:58 +02:00
|
|
|
break;
|
|
|
|
case e === "<>":
|
2023-10-14 12:43:53 +02:00
|
|
|
u = O.call(this, document.createDocumentFragment(), t);
|
2023-09-05 09:25:47 +02:00
|
|
|
break;
|
2023-10-14 12:43:53 +02:00
|
|
|
case r !== "html":
|
|
|
|
u = O.call(this, document.createElementNS(r, e), t);
|
2023-09-05 09:25:47 +02:00
|
|
|
break;
|
2023-10-14 12:43:53 +02:00
|
|
|
case !u:
|
|
|
|
u = O.call(this, document.createElement(e), t);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
return n.forEach((s) => s(u)), c && m.pop(), c = 2, u;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
var { setDeleteAttr: F } = M;
|
2023-10-13 16:37:04 +02:00
|
|
|
function O(e, ...t) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let n = this, o = y(this);
|
2023-09-05 09:25:47 +02:00
|
|
|
if (!t.length)
|
|
|
|
return e;
|
2023-10-13 20:57:21 +02:00
|
|
|
let c = (e instanceof SVGElement ? q : $).bind(null, e, "Attribute");
|
2023-10-14 12:43:53 +02:00
|
|
|
return Object.entries(Object.assign({}, ...t)).forEach(function u([s, d]) {
|
|
|
|
d = o.processReactiveAttribute(e, s, d, u);
|
2023-10-13 20:57:21 +02:00
|
|
|
let [p] = s;
|
|
|
|
if (p === "=")
|
2023-10-14 12:43:53 +02:00
|
|
|
return c(s.slice(1), d);
|
2023-10-13 20:57:21 +02:00
|
|
|
if (p === ".")
|
2023-10-14 12:43:53 +02:00
|
|
|
return z(e, s.slice(1), d);
|
2023-10-10 10:55:00 +02:00
|
|
|
if (/(aria|data)([A-Z])/.test(s))
|
2023-10-14 12:43:53 +02:00
|
|
|
return s = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), c(s, d);
|
2023-10-10 10:55:00 +02:00
|
|
|
switch (s === "className" && (s = "class"), s) {
|
2023-09-21 13:14:55 +02:00
|
|
|
case "xlink:href":
|
2023-10-14 12:43:53 +02:00
|
|
|
return c(s, d, "http://www.w3.org/1999/xlink");
|
2023-09-05 09:25:47 +02:00
|
|
|
case "textContent":
|
2023-10-14 12:43:53 +02:00
|
|
|
return F(e, s, d);
|
2023-09-21 14:37:20 +02:00
|
|
|
case "style":
|
2023-10-14 12:43:53 +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-14 12:43:53 +02:00
|
|
|
return D(o, d, z.bind(null, e[s]));
|
2023-09-21 14:37:20 +02:00
|
|
|
case "ariaset":
|
2023-10-14 12:43:53 +02:00
|
|
|
return D(o, d, (b, i) => c("aria-" + b, i));
|
2023-09-21 14:37:20 +02:00
|
|
|
case "classList":
|
2023-10-14 12:43:53 +02:00
|
|
|
return J.call(n, e, d);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
return V(e, s) ? F(e, s, d) : c(s, d);
|
2023-09-05 09:25:47 +02:00
|
|
|
}), e;
|
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function J(e, t) {
|
|
|
|
let n = y(this);
|
|
|
|
return D(
|
2023-09-21 12:35:27 +02:00
|
|
|
n,
|
2023-09-05 09:25:47 +02:00
|
|
|
t,
|
2023-10-14 12:43:53 +02:00
|
|
|
(o, r) => e.classList.toggle(o, r === -1 ? void 0 : !!r)
|
2023-09-05 09:25:47 +02:00
|
|
|
), e;
|
|
|
|
}
|
2023-10-09 13:49:38 +02:00
|
|
|
function fe(e) {
|
2023-09-05 09:25:47 +02:00
|
|
|
return Array.from(e.children).forEach((t) => t.remove()), e;
|
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function V(e, t) {
|
2023-09-21 12:35:27 +02:00
|
|
|
if (!Reflect.has(e, t))
|
|
|
|
return !1;
|
2023-10-13 20:57:21 +02:00
|
|
|
let n = H(e, t);
|
2023-10-14 12:43:53 +02:00
|
|
|
return !v(n.set);
|
2023-09-06 14:54:28 +02:00
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
function H(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-09-21 16:27:00 +02:00
|
|
|
let n = Object.getOwnPropertyDescriptor(e, t);
|
2023-10-13 20:57:21 +02:00
|
|
|
return n || H(e, t);
|
2023-09-06 14:54:28 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function D(e, t, n) {
|
2023-09-21 16:27:00 +02:00
|
|
|
if (!(typeof t != "object" || t === null))
|
2023-10-14 12:43:53 +02:00
|
|
|
return Object.entries(t).forEach(function([r, c]) {
|
|
|
|
r && (c = e.processReactiveAttribute(t, r, c, (u) => n(...u)), n(r, c));
|
2023-09-21 14:37:20 +02:00
|
|
|
});
|
2023-09-21 12:35:27 +02:00
|
|
|
}
|
2023-10-13 16:51:43 +02:00
|
|
|
function U(e) {
|
2023-09-21 12:35:27 +02:00
|
|
|
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
|
2023-09-19 12:34:42 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function $(e, t, n, o) {
|
|
|
|
return e[(v(o) ? "remove" : "set") + t](n, U(o));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function q(e, t, n, o, r = null) {
|
|
|
|
return e[(v(o) ? "remove" : "set") + t + "NS"](r, n, U(o));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
function z(e, t, n) {
|
2023-10-14 12:43:53 +02:00
|
|
|
if (Reflect.set(e, t, n), !!v(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 le(e, t, ...n) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let o = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
|
|
|
|
return e.dispatchEvent(o);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function E(e, t, n) {
|
|
|
|
return function(r) {
|
|
|
|
return r.addEventListener(e, t, n), r;
|
2023-09-09 21:15:43 +02:00
|
|
|
};
|
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
var R = K(), Z = /* @__PURE__ */ new WeakSet();
|
|
|
|
E.connected = function(e, t) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let n = "connected";
|
2023-10-14 12:43:53 +02:00
|
|
|
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let c = "dde:" + n;
|
2023-10-14 12:43:53 +02:00
|
|
|
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);
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
E.disconnected = function(e, t) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let n = "disconnected";
|
2023-10-14 12:43:53 +02:00
|
|
|
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let c = "dde:" + n;
|
2023-10-14 12:43:53 +02:00
|
|
|
return r.addEventListener(c, e, t), r.__dde_lifecycleToEvents || A(t.signal, () => R.offDisconnected(r, e)) && R.onDisconnected(r, e), r;
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
E.attributeChanged = function(e, t) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let n = "attributeChanged";
|
2023-10-14 12:43:53 +02:00
|
|
|
return typeof t != "object" && (t = {}), function(r) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let c = "dde:" + n;
|
2023-10-14 12:43:53 +02:00
|
|
|
if (r.addEventListener(c, e, t), r.__dde_lifecycleToEvents || Z.has(r))
|
|
|
|
return r;
|
|
|
|
let u = new MutationObserver(function(d) {
|
|
|
|
for (let { attributeName: p, target: b } of d)
|
|
|
|
b.dispatchEvent(
|
|
|
|
new CustomEvent(c, { detail: [p, b.getAttribute(p)] })
|
2023-10-13 16:37:04 +02:00
|
|
|
);
|
|
|
|
});
|
2023-10-14 12:43:53 +02:00
|
|
|
return A(t.signal, () => u.disconnect()) && u.observe(r, { attributes: !0 }), r;
|
2023-10-13 16:37:04 +02:00
|
|
|
};
|
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
function K() {
|
2023-10-13 16:37:04 +02:00
|
|
|
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(i) {
|
2023-10-13 20:57:21 +02:00
|
|
|
for (let f of i)
|
|
|
|
if (f.type === "childList") {
|
|
|
|
if (p(f.addedNodes, !0)) {
|
2023-10-14 12:43:53 +02:00
|
|
|
u();
|
2023-09-05 09:25:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
b(f.removedNodes, !0) && u();
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return {
|
2023-10-13 20:57:21 +02:00
|
|
|
onConnected(i, f) {
|
2023-10-13 16:37:04 +02:00
|
|
|
c();
|
2023-10-14 12:43:53 +02:00
|
|
|
let a = r(i);
|
2023-10-13 20:57:21 +02:00
|
|
|
a.connected.has(f) || (a.connected.add(f), a.length_c += 1);
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-10-13 20:57:21 +02:00
|
|
|
offConnected(i, f) {
|
2023-10-13 16:37:04 +02:00
|
|
|
if (!e.has(i))
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-10-13 17:13:03 +02:00
|
|
|
let a = e.get(i);
|
2023-10-14 12:43:53 +02:00
|
|
|
a.connected.has(f) && (a.connected.delete(f), a.length_c -= 1, o(i, a));
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-10-13 20:57:21 +02:00
|
|
|
onDisconnected(i, f) {
|
2023-10-13 16:37:04 +02:00
|
|
|
c();
|
2023-10-14 12:43:53 +02:00
|
|
|
let a = r(i);
|
2023-10-13 20:57:21 +02:00
|
|
|
a.disconnected.has(f) || (a.disconnected.add(f), a.length_d += 1);
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-10-13 20:57:21 +02:00
|
|
|
offDisconnected(i, f) {
|
2023-10-13 16:37:04 +02:00
|
|
|
if (!e.has(i))
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-10-13 17:13:03 +02:00
|
|
|
let a = e.get(i);
|
2023-10-14 12:43:53 +02:00
|
|
|
a.disconnected.has(f) && (a.disconnected.delete(f), a.length_d -= 1, o(i, a));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
function o(i, f) {
|
|
|
|
f.length_c || f.length_d || (e.delete(i), u());
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function r(i) {
|
2023-10-13 16:37:04 +02:00
|
|
|
if (e.has(i))
|
|
|
|
return e.get(i);
|
2023-10-13 20:57:21 +02:00
|
|
|
let f = {
|
2023-10-09 13:49:38 +02:00
|
|
|
connected: /* @__PURE__ */ new WeakSet(),
|
|
|
|
length_c: 0,
|
|
|
|
disconnected: /* @__PURE__ */ new WeakSet(),
|
|
|
|
length_d: 0
|
|
|
|
};
|
2023-10-13 20:57:21 +02:00
|
|
|
return e.set(i, f), f;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function c() {
|
2023-09-19 12:34:42 +02:00
|
|
|
t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function u() {
|
2023-09-19 12:34:42 +02:00
|
|
|
!t || e.size || (t = !1, n.disconnect());
|
2023-09-11 18:32:05 +02:00
|
|
|
}
|
2023-10-10 10:55:00 +02:00
|
|
|
function s() {
|
2023-10-13 16:37:04 +02:00
|
|
|
return new Promise(function(i) {
|
|
|
|
(requestIdleCallback || requestAnimationFrame)(i);
|
2023-09-05 09:25:47 +02:00
|
|
|
});
|
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
async function d(i) {
|
2023-10-10 10:55:00 +02:00
|
|
|
e.size > 30 && await s();
|
2023-10-13 20:57:21 +02:00
|
|
|
let f = [];
|
2023-10-13 16:37:04 +02:00
|
|
|
if (!(i instanceof Node))
|
2023-10-13 20:57:21 +02:00
|
|
|
return f;
|
2023-10-13 17:13:03 +02:00
|
|
|
for (let a of e.keys())
|
2023-10-13 20:57:21 +02:00
|
|
|
a === i || !(a instanceof Node) || i.contains(a) && f.push(a);
|
|
|
|
return f;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
function p(i, f) {
|
2023-10-13 17:13:03 +02:00
|
|
|
let a = !1;
|
2023-10-14 12:43:53 +02:00
|
|
|
for (let g of i) {
|
|
|
|
if (f && d(g).then(p), !e.has(g))
|
2023-09-09 21:15:43 +02:00
|
|
|
continue;
|
2023-10-14 12:43:53 +02:00
|
|
|
let w = e.get(g);
|
|
|
|
w.length_c && (g.dispatchEvent(new Event("dde:connected")), w.connected = /* @__PURE__ */ new WeakSet(), w.length_c = 0, w.length_d || e.delete(g), a = !0);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 17:13:03 +02:00
|
|
|
return a;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function b(i, f) {
|
2023-10-13 17:13:03 +02:00
|
|
|
let a = !1;
|
2023-10-14 12:43:53 +02:00
|
|
|
for (let g of i)
|
|
|
|
f && d(g).then(b), !(!e.has(g) || !e.get(g).length_d) && (g.dispatchEvent(new Event("dde:disconnected")), e.delete(g), a = !0);
|
2023-10-13 17:13:03 +02:00
|
|
|
return a;
|
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-09-19 12:34:42 +02:00
|
|
|
e.prototype.append = function(...n) {
|
|
|
|
return t.apply(this, n), this;
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
// src/signals-lib.js
|
2023-10-13 16:37:04 +02:00
|
|
|
var l = Symbol.for("Signal");
|
|
|
|
function C(e) {
|
2023-09-05 09:25:47 +02:00
|
|
|
try {
|
2023-10-13 16:37:04 +02:00
|
|
|
return Reflect.has(e, l);
|
2023-09-05 09:25:47 +02:00
|
|
|
} catch {
|
|
|
|
return !1;
|
|
|
|
}
|
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
var L = [], _ = /* @__PURE__ */ new WeakMap();
|
|
|
|
function h(e, t) {
|
2023-09-05 09:25:47 +02:00
|
|
|
if (typeof e != "function")
|
2023-10-13 20:57:21 +02:00
|
|
|
return k(e, t);
|
2023-10-13 16:37:04 +02:00
|
|
|
if (C(e))
|
2023-09-05 09:25:47 +02:00
|
|
|
return e;
|
2023-10-14 12:43:53 +02:00
|
|
|
let n = k(), o = function() {
|
|
|
|
L.push(o), n(e()), L.pop();
|
|
|
|
};
|
|
|
|
return _.set(o, /* @__PURE__ */ new Set([n])), o(), n;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
h.action = function(e, t, ...n) {
|
|
|
|
let o = e[l], { actions: r } = o;
|
|
|
|
if (!r || !Reflect.has(r, t))
|
2023-09-05 09:25:47 +02:00
|
|
|
throw new Error(`'${e}' has no action with name '${t}'!`);
|
2023-10-14 12:43:53 +02:00
|
|
|
if (r[t].apply(o, n), o.skip)
|
|
|
|
return Reflect.deleteProperty(o, "skip");
|
|
|
|
o.listeners.forEach((c) => c(o.value));
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
h.on = function e(t, n, o = {}) {
|
|
|
|
let { signal: r } = o;
|
|
|
|
if (!(r && r.aborted)) {
|
2023-09-07 17:35:23 +02:00
|
|
|
if (Array.isArray(t))
|
2023-10-14 12:43:53 +02:00
|
|
|
return t.forEach((c) => e(c, n, o));
|
|
|
|
P(t, n), r && r.addEventListener("abort", () => j(t, n));
|
2023-09-07 17:35:23 +02:00
|
|
|
}
|
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
h.symbols = {
|
2023-10-13 16:37:04 +02:00
|
|
|
signal: l,
|
2023-09-07 17:35:23 +02:00
|
|
|
onclear: Symbol.for("Signal.onclear")
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
h.attribute = function(e, t = void 0) {
|
|
|
|
let { host: n } = m, o = n() && n().hasAttribute(e) ? n().getAttribute(e) : t, r = new AbortController(), c = h(o, {
|
|
|
|
[h.symbols.onclear]() {
|
|
|
|
r.abort();
|
2023-10-13 16:37:04 +02:00
|
|
|
}
|
|
|
|
});
|
2023-10-14 12:43:53 +02:00
|
|
|
return m.host(E.attributeChanged(function({ detail: s }) {
|
|
|
|
let [d, p] = s;
|
|
|
|
d === e && c(p);
|
|
|
|
}, { signal: r.signal })), c;
|
2023-10-13 16:37:04 +02:00
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
h.clear = function(...e) {
|
2023-09-19 12:34:42 +02:00
|
|
|
for (let n of e) {
|
|
|
|
Reflect.deleteProperty(n, "toJSON");
|
2023-10-14 12:43:53 +02:00
|
|
|
let o = n[l];
|
|
|
|
o.onclear.forEach((r) => r.call(o)), t(n, o), Reflect.deleteProperty(n, l);
|
2023-09-08 10:52:45 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function t(n, o) {
|
|
|
|
o.listeners.forEach((r) => {
|
|
|
|
if (o.listeners.delete(r), !_.has(r))
|
2023-09-08 10:52:45 +02:00
|
|
|
return;
|
2023-10-14 12:43:53 +02:00
|
|
|
let c = _.get(r);
|
|
|
|
c.delete(n), !(c.size > 1) && (h.clear(...c), _.delete(r));
|
2023-09-08 10:52:45 +02:00
|
|
|
});
|
2023-09-07 17:35:23 +02:00
|
|
|
}
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
h.el = function(e, t) {
|
|
|
|
let n = document.createComment("<#reactive>"), o = document.createComment("</#reactive>"), r = document.createDocumentFragment();
|
|
|
|
r.append(n, o);
|
|
|
|
let c = (u) => {
|
|
|
|
if (!n.parentNode || !o.parentNode)
|
|
|
|
return j(e, c);
|
|
|
|
let s = t(u);
|
|
|
|
Array.isArray(s) || (s = [s]);
|
|
|
|
let d = n;
|
|
|
|
for (; (d = n.nextSibling) !== o; )
|
|
|
|
d.remove();
|
|
|
|
n.after(...s);
|
2023-09-08 20:18:58 +02:00
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
return P(e, c), G(e, c, n, t), c(e()), r;
|
2023-09-08 20:18:58 +02:00
|
|
|
};
|
2023-10-13 20:57:21 +02:00
|
|
|
var B = {
|
2023-10-13 16:37:04 +02:00
|
|
|
isSignal: C,
|
2023-10-14 12:43:53 +02:00
|
|
|
processReactiveAttribute(e, t, n, o) {
|
2023-10-13 20:57:21 +02:00
|
|
|
if (!C(n))
|
|
|
|
return n;
|
2023-10-14 12:43:53 +02:00
|
|
|
let r = (c) => o([t, c]);
|
|
|
|
return P(n, r), G(n, r, e, t), n();
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
function G(e, t, ...n) {
|
|
|
|
let { current: o } = m;
|
|
|
|
if (o.prevent)
|
|
|
|
return;
|
|
|
|
let r = "__dde_reactive";
|
|
|
|
o.host(function(c) {
|
|
|
|
c[r] || (c[r] = [], E.disconnected(
|
|
|
|
() => (
|
|
|
|
/*!
|
|
|
|
* Clears all signals listeners the current element is depending on (`S.el`, `assign`, …?).
|
|
|
|
* You can investigate the `__dde_reactive` key of the element.
|
|
|
|
* */
|
|
|
|
c[r].forEach(([u, s, d, p]) => j(d, p, d[l].host() === c))
|
|
|
|
)
|
|
|
|
)(c)), c[r].push([...n, e, t]);
|
|
|
|
});
|
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
function k(e, t) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let n = (...o) => o.length ? te(n, ...o) : ee(n);
|
|
|
|
return X(n, e, t);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
var Q = Object.assign(/* @__PURE__ */ Object.create(null), {
|
2023-09-05 09:25:47 +02:00
|
|
|
stopPropagation() {
|
|
|
|
this.skip = !0;
|
|
|
|
}
|
|
|
|
});
|
2023-10-14 12:43:53 +02:00
|
|
|
function X(e, t, n) {
|
|
|
|
let o = [];
|
|
|
|
T(n) !== "[object Object]" && (n = {});
|
|
|
|
let { onclear: r } = h.symbols;
|
|
|
|
n[r] && (o.push(n[r]), Reflect.deleteProperty(n, r));
|
|
|
|
let { host: c } = m;
|
|
|
|
return e[l] = {
|
2023-09-05 09:25:47 +02:00
|
|
|
value: t,
|
2023-09-19 12:34:42 +02:00
|
|
|
actions: n,
|
2023-10-14 12:43:53 +02:00
|
|
|
onclear: o,
|
|
|
|
host: c,
|
2023-09-05 09:25:47 +02:00
|
|
|
listeners: /* @__PURE__ */ new Set()
|
2023-10-14 12:43:53 +02:00
|
|
|
}, e.toJSON = () => e(), Object.setPrototypeOf(e[l], Q), e;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function Y() {
|
|
|
|
return L[L.length - 1];
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function ee(e) {
|
|
|
|
if (!e[l])
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-10-14 12:43:53 +02:00
|
|
|
let { value: t, listeners: n } = e[l], o = Y();
|
|
|
|
return o && n.add(o), _.has(o) && _.get(o).add(e), t;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function te(e, t, n) {
|
|
|
|
if (!e[l])
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-10-14 12:43:53 +02:00
|
|
|
let o = e[l];
|
|
|
|
if (!(!n && o.value === t))
|
|
|
|
return o.value = t, o.listeners.forEach((r) => r(t)), t;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function P(e, t) {
|
2023-10-13 16:37:04 +02:00
|
|
|
if (e[l])
|
|
|
|
return e[l].listeners.add(t);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function j(e, t, n) {
|
|
|
|
if (!e[l])
|
|
|
|
return;
|
|
|
|
let o = e[l].listeners.delete(t);
|
|
|
|
return n && e[l].listeners.size === 0 && h.clear(e), o;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
|
2023-09-19 09:30:21 +02:00
|
|
|
// signals.js
|
2023-10-14 12:43:53 +02:00
|
|
|
N(B);
|
2023-09-05 09:25:47 +02:00
|
|
|
export {
|
2023-10-14 12:43:53 +02:00
|
|
|
h as S,
|
2023-10-13 16:37:04 +02:00
|
|
|
O as assign,
|
2023-10-14 12:43:53 +02:00
|
|
|
J as classListDeclarative,
|
2023-10-13 16:37:04 +02:00
|
|
|
ie as createElement,
|
|
|
|
le as dispatchEvent,
|
|
|
|
ie as el,
|
2023-10-09 13:49:38 +02:00
|
|
|
fe as empty,
|
2023-10-13 16:37:04 +02:00
|
|
|
C as isSignal,
|
2023-10-14 12:43:53 +02:00
|
|
|
E as on,
|
|
|
|
N as registerReactivity,
|
|
|
|
m as scope
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|