mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-25 09:49:36 +01:00
♻️ Remove signals from elements + better debbuging options
This commit is contained in:
parent
702278c883
commit
46869736d5
292
dist/dde-with-signals.js
vendored
292
dist/dde-with-signals.js
vendored
@ -1,7 +1,7 @@
|
|||||||
//deka-dom-el library is available via global namespace `dde`
|
//deka-dom-el library is available via global namespace `dde`
|
||||||
(()=> {
|
(()=> {
|
||||||
// src/signals-common.js
|
// src/signals-common.js
|
||||||
var x = {
|
var w = {
|
||||||
isSignal(t) {
|
isSignal(t) {
|
||||||
return !1;
|
return !1;
|
||||||
},
|
},
|
||||||
@ -9,22 +9,22 @@
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function P(t, e = !0) {
|
function j(t, e = !0) {
|
||||||
return e ? Object.assign(x, t) : (Object.setPrototypeOf(t, x), t);
|
return e ? Object.assign(w, t) : (Object.setPrototypeOf(t, w), t);
|
||||||
}
|
}
|
||||||
function S(t) {
|
function A(t) {
|
||||||
return x.isPrototypeOf(t) && t !== x ? t : x;
|
return w.isPrototypeOf(t) && t !== w ? t : w;
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/helpers.js
|
// src/helpers.js
|
||||||
function E(t) {
|
function E(t) {
|
||||||
return typeof t > "u";
|
return typeof t > "u";
|
||||||
}
|
}
|
||||||
function M(t) {
|
function k(t) {
|
||||||
let e = typeof t;
|
let e = typeof t;
|
||||||
return e !== "object" ? e : t === null ? "null" : Object.prototype.toString.call(t);
|
return e !== "object" ? e : t === null ? "null" : Object.prototype.toString.call(t);
|
||||||
}
|
}
|
||||||
function A(t, e) {
|
function O(t, e) {
|
||||||
if (!t || !(t instanceof AbortSignal))
|
if (!t || !(t instanceof AbortSignal))
|
||||||
return !0;
|
return !0;
|
||||||
if (!t.aborted)
|
if (!t.aborted)
|
||||||
@ -34,8 +34,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/dom-common.js
|
// src/dom-common.js
|
||||||
var W = { setDeleteAttr: Z };
|
var F = { setDeleteAttr: Q };
|
||||||
function Z(t, e, n) {
|
function Q(t, e, n) {
|
||||||
if (Reflect.set(t, e, n), !!E(n)) {
|
if (Reflect.set(t, e, n), !!E(n)) {
|
||||||
if (Reflect.deleteProperty(t, e), t instanceof HTMLElement && t.getAttribute(e) === "undefined")
|
if (Reflect.deleteProperty(t, e), t instanceof HTMLElement && t.getAttribute(e) === "undefined")
|
||||||
return t.removeAttribute(e);
|
return t.removeAttribute(e);
|
||||||
@ -50,7 +50,7 @@
|
|||||||
namespace: "html",
|
namespace: "html",
|
||||||
host: (t) => t ? t(document.body) : document.body,
|
host: (t) => t ? t(document.body) : document.body,
|
||||||
prevent: !0
|
prevent: !0
|
||||||
}], F = (t) => t === "svg" ? "http://www.w3.org/2000/svg" : t, m = {
|
}], z = (t) => t === "svg" ? "http://www.w3.org/2000/svg" : t, h = {
|
||||||
get current() {
|
get current() {
|
||||||
return y[y.length - 1];
|
return y[y.length - 1];
|
||||||
},
|
},
|
||||||
@ -61,7 +61,7 @@
|
|||||||
return this.current.namespace;
|
return this.current.namespace;
|
||||||
},
|
},
|
||||||
set namespace(t) {
|
set namespace(t) {
|
||||||
return this.current.namespace = F(t);
|
return this.current.namespace = z(t);
|
||||||
},
|
},
|
||||||
preventDefault() {
|
preventDefault() {
|
||||||
let { current: t } = this;
|
let { current: t } = this;
|
||||||
@ -71,7 +71,7 @@
|
|||||||
let e = this.namespace;
|
let e = this.namespace;
|
||||||
return this.namespace = t, {
|
return this.namespace = t, {
|
||||||
append(...n) {
|
append(...n) {
|
||||||
return m.namespace = e, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
|
return h.namespace = e, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -79,17 +79,17 @@
|
|||||||
return [...y];
|
return [...y];
|
||||||
},
|
},
|
||||||
push(t = {}) {
|
push(t = {}) {
|
||||||
return t.namespace && (t.namespace = F(t.namespace)), y.push(Object.assign({}, this.current, { prevent: !1 }, t));
|
return t.namespace && (t.namespace = z(t.namespace)), y.push(Object.assign({}, this.current, { prevent: !1 }, t));
|
||||||
},
|
},
|
||||||
pop() {
|
pop() {
|
||||||
return y.pop();
|
return y.pop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function at(t, e, ...n) {
|
function pt(t, e, ...n) {
|
||||||
let o = S(this), { namespace: r } = m, c = 0, s;
|
let o = A(this), { namespace: r } = h, c = 0, s;
|
||||||
switch ((Object(e) !== e || o.isSignal(e)) && (e = { textContent: e }), !0) {
|
switch ((Object(e) !== e || o.isSignal(e)) && (e = { textContent: e }), !0) {
|
||||||
case typeof t == "function": {
|
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);
|
c = 1, h.push({ scope: t, host: (a) => a ? (c === 1 ? n.unshift(a) : a(s), void 0) : s }), s = t(e || void 0), (s instanceof HTMLElement ? I : J)(s, "Attribute", "dde-fun", t.name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case t === "#text":
|
case t === "#text":
|
||||||
@ -104,100 +104,100 @@
|
|||||||
case !s:
|
case !s:
|
||||||
s = R.call(this, document.createElement(t), e);
|
s = R.call(this, document.createElement(t), e);
|
||||||
}
|
}
|
||||||
return n.forEach((a) => a(s)), c && m.pop(), c = 2, s;
|
return n.forEach((a) => a(s)), c && h.pop(), c = 2, s;
|
||||||
}
|
}
|
||||||
var { setDeleteAttr: z } = W, O = /* @__PURE__ */ new WeakMap();
|
var { setDeleteAttr: H } = F, C = /* @__PURE__ */ new WeakMap();
|
||||||
function R(t, ...e) {
|
function R(t, ...e) {
|
||||||
if (!e.length)
|
if (!e.length)
|
||||||
return t;
|
return t;
|
||||||
O.set(t, U(t, this));
|
C.set(t, q(t, this));
|
||||||
for (let [n, o] of Object.entries(Object.assign({}, ...e)))
|
for (let [n, o] of Object.entries(Object.assign({}, ...e)))
|
||||||
H.call(this, t, n, o);
|
$.call(this, t, n, o);
|
||||||
return O.delete(t), t;
|
return C.delete(t), t;
|
||||||
}
|
}
|
||||||
function H(t, e, n) {
|
function $(t, e, n) {
|
||||||
let { setRemoveAttr: o, s: r } = U(t, this), c = this;
|
let { setRemoveAttr: o, s: r } = q(t, this), c = this;
|
||||||
n = r.processReactiveAttribute(
|
n = r.processReactiveAttribute(
|
||||||
t,
|
t,
|
||||||
e,
|
e,
|
||||||
n,
|
n,
|
||||||
(a, p) => H.call(c, t, a, p)
|
(a, p) => $.call(c, t, a, p)
|
||||||
);
|
);
|
||||||
let [s] = e;
|
let [s] = e;
|
||||||
if (s === "=")
|
if (s === "=")
|
||||||
return o(e.slice(1), n);
|
return o(e.slice(1), n);
|
||||||
if (s === ".")
|
if (s === ".")
|
||||||
return k(t, e.slice(1), n);
|
return U(t, e.slice(1), n);
|
||||||
if (/(aria|data)([A-Z])/.test(e))
|
if (/(aria|data)([A-Z])/.test(e))
|
||||||
return e = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), o(e, n);
|
return e = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), o(e, n);
|
||||||
switch (e === "className" && (e = "class"), e) {
|
switch (e === "className" && (e = "class"), e) {
|
||||||
case "xlink:href":
|
case "xlink:href":
|
||||||
return o(e, n, "http://www.w3.org/1999/xlink");
|
return o(e, n, "http://www.w3.org/1999/xlink");
|
||||||
case "textContent":
|
case "textContent":
|
||||||
return z(t, e, n);
|
return H(t, e, n);
|
||||||
case "style":
|
case "style":
|
||||||
if (typeof n != "object")
|
if (typeof n != "object")
|
||||||
break;
|
break;
|
||||||
case "dataset":
|
case "dataset":
|
||||||
return j(r, n, k.bind(null, t[e]));
|
return T(r, n, U.bind(null, t[e]));
|
||||||
case "ariaset":
|
case "ariaset":
|
||||||
return j(r, n, (a, p) => o("aria-" + a, p));
|
return T(r, n, (a, p) => o("aria-" + a, p));
|
||||||
case "classList":
|
case "classList":
|
||||||
return K.call(c, t, n);
|
return X.call(c, t, n);
|
||||||
}
|
}
|
||||||
return Q(t, e) ? z(t, e, n) : o(e, n);
|
return Y(t, e) ? H(t, e, n) : o(e, n);
|
||||||
}
|
}
|
||||||
function U(t, e) {
|
function q(t, e) {
|
||||||
if (O.has(t))
|
if (C.has(t))
|
||||||
return O.get(t);
|
return C.get(t);
|
||||||
let o = (t instanceof SVGElement ? G : B).bind(null, t, "Attribute"), r = S(e);
|
let o = (t instanceof SVGElement ? J : I).bind(null, t, "Attribute"), r = A(e);
|
||||||
return { setRemoveAttr: o, s: r };
|
return { setRemoveAttr: o, s: r };
|
||||||
}
|
}
|
||||||
function K(t, e) {
|
function X(t, e) {
|
||||||
let n = S(this);
|
let n = A(this);
|
||||||
return j(
|
return T(
|
||||||
n,
|
n,
|
||||||
e,
|
e,
|
||||||
(o, r) => t.classList.toggle(o, r === -1 ? void 0 : !!r)
|
(o, r) => t.classList.toggle(o, r === -1 ? void 0 : !!r)
|
||||||
), t;
|
), t;
|
||||||
}
|
}
|
||||||
function pt(t) {
|
function ht(t) {
|
||||||
return Array.from(t.children).forEach((e) => e.remove()), t;
|
return Array.from(t.children).forEach((e) => e.remove()), t;
|
||||||
}
|
}
|
||||||
function Q(t, e) {
|
function Y(t, e) {
|
||||||
if (!Reflect.has(t, e))
|
if (!Reflect.has(t, e))
|
||||||
return !1;
|
return !1;
|
||||||
let n = $(t, e);
|
let n = B(t, e);
|
||||||
return !E(n.set);
|
return !E(n.set);
|
||||||
}
|
}
|
||||||
function $(t, e) {
|
function B(t, e) {
|
||||||
if (t = Object.getPrototypeOf(t), !t)
|
if (t = Object.getPrototypeOf(t), !t)
|
||||||
return {};
|
return {};
|
||||||
let n = Object.getOwnPropertyDescriptor(t, e);
|
let n = Object.getOwnPropertyDescriptor(t, e);
|
||||||
return n || $(t, e);
|
return n || B(t, e);
|
||||||
}
|
}
|
||||||
function j(t, e, n) {
|
function T(t, e, n) {
|
||||||
if (!(typeof e != "object" || e === null))
|
if (!(typeof e != "object" || e === null))
|
||||||
return Object.entries(e).forEach(function([r, c]) {
|
return Object.entries(e).forEach(function([r, c]) {
|
||||||
r && (c = t.processReactiveAttribute(e, r, c, n), n(r, c));
|
r && (c = t.processReactiveAttribute(e, r, c, n), n(r, c));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function q(t) {
|
function G(t) {
|
||||||
return Array.isArray(t) ? t.filter(Boolean).join(" ") : t;
|
return Array.isArray(t) ? t.filter(Boolean).join(" ") : t;
|
||||||
}
|
}
|
||||||
function B(t, e, n, o) {
|
function I(t, e, n, o) {
|
||||||
return t[(E(o) ? "remove" : "set") + e](n, q(o));
|
return t[(E(o) ? "remove" : "set") + e](n, G(o));
|
||||||
}
|
}
|
||||||
function G(t, e, n, o, r = null) {
|
function J(t, e, n, o, r = null) {
|
||||||
return t[(E(o) ? "remove" : "set") + e + "NS"](r, n, q(o));
|
return t[(E(o) ? "remove" : "set") + e + "NS"](r, n, G(o));
|
||||||
}
|
}
|
||||||
function k(t, e, n) {
|
function U(t, e, n) {
|
||||||
if (Reflect.set(t, e, n), !!E(n))
|
if (Reflect.set(t, e, n), !!E(n))
|
||||||
return Reflect.deleteProperty(t, e);
|
return Reflect.deleteProperty(t, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/events.js
|
// src/events.js
|
||||||
function gt(t, e, ...n) {
|
function bt(t, e, ...n) {
|
||||||
let o = n.length ? new CustomEvent(e, { detail: n[0] }) : new Event(e);
|
let o = n.length ? new CustomEvent(e, { detail: n[0] }) : new Event(e);
|
||||||
return t.dispatchEvent(o);
|
return t.dispatchEvent(o);
|
||||||
}
|
}
|
||||||
@ -206,26 +206,26 @@
|
|||||||
return r.addEventListener(t, e, n), r;
|
return r.addEventListener(t, e, n), r;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var C = Y(), X = /* @__PURE__ */ new WeakSet();
|
var L = et(), tt = /* @__PURE__ */ new WeakSet();
|
||||||
v.connected = function(t, e) {
|
v.connected = function(t, e) {
|
||||||
let n = "connected";
|
let n = "connected";
|
||||||
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
|
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
|
||||||
let c = "dde:" + n;
|
let c = "dde:" + n;
|
||||||
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);
|
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(c)), r) : (O(e.signal, () => L.offConnected(r, t)) && L.onConnected(r, t), r);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
v.disconnected = function(t, e) {
|
v.disconnected = function(t, e) {
|
||||||
let n = "disconnected";
|
let n = "disconnected";
|
||||||
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
|
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
|
||||||
let c = "dde:" + n;
|
let c = "dde:" + n;
|
||||||
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || A(e.signal, () => C.offDisconnected(r, t)) && C.onDisconnected(r, t), r;
|
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || O(e.signal, () => L.offDisconnected(r, t)) && L.onDisconnected(r, t), r;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
v.attributeChanged = function(t, e) {
|
v.attributeChanged = function(t, e) {
|
||||||
let n = "attributeChanged";
|
let n = "attributeChanged";
|
||||||
return typeof e != "object" && (e = {}), function(r) {
|
return typeof e != "object" && (e = {}), function(r) {
|
||||||
let c = "dde:" + n;
|
let c = "dde:" + n;
|
||||||
if (r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || X.has(r))
|
if (r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || tt.has(r))
|
||||||
return r;
|
return r;
|
||||||
let s = new MutationObserver(function(p) {
|
let s = new MutationObserver(function(p) {
|
||||||
for (let { attributeName: b, target: _ } of p)
|
for (let { attributeName: b, target: _ } of p)
|
||||||
@ -233,10 +233,10 @@
|
|||||||
new CustomEvent(c, { detail: [b, _.getAttribute(b)] })
|
new CustomEvent(c, { detail: [b, _.getAttribute(b)] })
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return A(e.signal, () => s.disconnect()) && s.observe(r, { attributes: !0 }), r;
|
return O(e.signal, () => s.disconnect()) && s.observe(r, { attributes: !0 }), r;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
function Y() {
|
function et() {
|
||||||
let t = /* @__PURE__ */ new Map(), e = !1, n = new MutationObserver(function(i) {
|
let t = /* @__PURE__ */ new Map(), e = !1, n = new MutationObserver(function(i) {
|
||||||
for (let u of i)
|
for (let u of i)
|
||||||
if (u.type === "childList") {
|
if (u.type === "childList") {
|
||||||
@ -307,18 +307,18 @@
|
|||||||
}
|
}
|
||||||
function b(i, u) {
|
function b(i, u) {
|
||||||
let f = !1;
|
let f = !1;
|
||||||
for (let h of i) {
|
for (let m of i) {
|
||||||
if (u && p(h).then(b), !t.has(h))
|
if (u && p(m).then(b), !t.has(m))
|
||||||
continue;
|
continue;
|
||||||
let w = t.get(h);
|
let x = t.get(m);
|
||||||
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);
|
x.length_c && (m.dispatchEvent(new Event("dde:connected")), x.connected = /* @__PURE__ */ new WeakSet(), x.length_c = 0, x.length_d || t.delete(m), f = !0);
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
function _(i, u) {
|
function _(i, u) {
|
||||||
let f = !1;
|
let f = !1;
|
||||||
for (let h of i)
|
for (let m 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);
|
u && p(m).then(_), !(!t.has(m) || !t.get(m).length_d) && (m.dispatchEvent(new Event("dde:disconnected")), t.delete(m), f = !0);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,25 +333,30 @@
|
|||||||
|
|
||||||
// src/signals-lib.js
|
// src/signals-lib.js
|
||||||
var d = Symbol.for("Signal");
|
var d = Symbol.for("Signal");
|
||||||
function L(t) {
|
function N(t) {
|
||||||
try {
|
try {
|
||||||
return Reflect.has(t, d);
|
return Reflect.has(t, d);
|
||||||
} catch {
|
} catch {
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var D = [], g = /* @__PURE__ */ new WeakMap();
|
var P = [], l = /* @__PURE__ */ new WeakMap();
|
||||||
function l(t, e) {
|
function g(t, e) {
|
||||||
if (typeof t != "function")
|
if (typeof t != "function")
|
||||||
return I(t, e);
|
return V(t, e);
|
||||||
if (L(t))
|
if (N(t))
|
||||||
return t;
|
return t;
|
||||||
let n = I(), o = function() {
|
let n = V(), o = function() {
|
||||||
D.push(o), n(t()), D.pop();
|
let [r, ...c] = l.get(o);
|
||||||
|
if (l.set(o, /* @__PURE__ */ new Set([r])), P.push(o), n(t()), P.pop(), !c.length)
|
||||||
|
return;
|
||||||
|
let s = l.get(o);
|
||||||
|
for (let a of c)
|
||||||
|
s.has(a) || S(a, o);
|
||||||
};
|
};
|
||||||
return g.set(o, /* @__PURE__ */ new Set([n])), g.set(n[d], o), o(), n;
|
return l.set(n[d], o), l.set(o, /* @__PURE__ */ new Set([n])), o(), n;
|
||||||
}
|
}
|
||||||
l.action = function(t, e, ...n) {
|
g.action = function(t, e, ...n) {
|
||||||
let o = t[d], { actions: r } = o;
|
let o = t[d], { actions: r } = o;
|
||||||
if (!r || !Reflect.has(r, e))
|
if (!r || !Reflect.has(r, e))
|
||||||
throw new Error(`'${t}' has no action with name '${e}'!`);
|
throw new Error(`'${t}' has no action with name '${e}'!`);
|
||||||
@ -359,30 +364,30 @@
|
|||||||
return Reflect.deleteProperty(o, "skip");
|
return Reflect.deleteProperty(o, "skip");
|
||||||
o.listeners.forEach((c) => c(o.value));
|
o.listeners.forEach((c) => c(o.value));
|
||||||
};
|
};
|
||||||
l.on = function t(e, n, o = {}) {
|
g.on = function t(e, n, o = {}) {
|
||||||
let { signal: r } = o;
|
let { signal: r } = o;
|
||||||
if (!(r && r.aborted)) {
|
if (!(r && r.aborted)) {
|
||||||
if (Array.isArray(e))
|
if (Array.isArray(e))
|
||||||
return e.forEach((c) => t(c, n, o));
|
return e.forEach((c) => t(c, n, o));
|
||||||
T(e, n), r && r.addEventListener("abort", () => N(e, n));
|
W(e, n), r && r.addEventListener("abort", () => S(e, n));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
l.symbols = {
|
g.symbols = {
|
||||||
signal: d,
|
signal: d,
|
||||||
onclear: Symbol.for("Signal.onclear")
|
onclear: Symbol.for("Signal.onclear")
|
||||||
};
|
};
|
||||||
l.attribute = function(t, e = void 0) {
|
g.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, {
|
let { host: n } = h, o = n() && n().hasAttribute(t) ? n().getAttribute(t) : e, r = new AbortController(), c = g(o, {
|
||||||
[l.symbols.onclear]() {
|
[g.symbols.onclear]() {
|
||||||
r.abort();
|
r.abort();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return m.host(v.attributeChanged(function({ detail: a }) {
|
return h.host(v.attributeChanged(function({ detail: a }) {
|
||||||
let [p, b] = a;
|
let [p, b] = a;
|
||||||
p === t && c(b);
|
p === t && c(b);
|
||||||
}, { signal: r.signal })), c;
|
}, { signal: r.signal })), c;
|
||||||
};
|
};
|
||||||
l.clear = function(...t) {
|
g.clear = function(...t) {
|
||||||
for (let n of t) {
|
for (let n of t) {
|
||||||
Reflect.deleteProperty(n, "toJSON");
|
Reflect.deleteProperty(n, "toJSON");
|
||||||
let o = n[d];
|
let o = n[d];
|
||||||
@ -390,129 +395,136 @@
|
|||||||
}
|
}
|
||||||
function e(n, o) {
|
function e(n, o) {
|
||||||
o.listeners.forEach((r) => {
|
o.listeners.forEach((r) => {
|
||||||
if (o.listeners.delete(r), !g.has(r))
|
if (o.listeners.delete(r), !l.has(r))
|
||||||
return;
|
return;
|
||||||
let c = g.get(r);
|
let c = l.get(r);
|
||||||
c.delete(n), !(c.size > 1) && (l.clear(...c), g.delete(r));
|
c.delete(n), !(c.size > 1) && (g.clear(...c), l.delete(r));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
l.el = function(t, e) {
|
var D = "__dde_reactive";
|
||||||
let n = document.createComment("<#reactive>"), o = document.createComment("</#reactive>"), r = document.createDocumentFragment();
|
g.el = function(t, e) {
|
||||||
|
let n = document.createComment("<dde:reactive>"), o = document.createComment("</dde:reactive>"), r = document.createDocumentFragment();
|
||||||
r.append(n, o);
|
r.append(n, o);
|
||||||
let c = (s) => {
|
let { current: c } = h, s = (a) => {
|
||||||
if (!n.parentNode || !o.parentNode)
|
if (!n.parentNode || !o.parentNode)
|
||||||
return N(t, c);
|
return S(t, s);
|
||||||
let a = e(s);
|
h.push(c);
|
||||||
Array.isArray(a) || (a = [a]);
|
let p = e(a);
|
||||||
let p = n;
|
h.pop(), Array.isArray(p) || (p = [p]);
|
||||||
for (; (p = n.nextSibling) !== o; )
|
let b = n;
|
||||||
p.remove();
|
for (; (b = n.nextSibling) !== o; )
|
||||||
n.after(...a);
|
b.remove();
|
||||||
|
n.after(...p);
|
||||||
};
|
};
|
||||||
return T(t, c), V(t, c, n, e), c(t()), r;
|
return W(t, s), K(t, s, n, e), s(t()), r;
|
||||||
};
|
};
|
||||||
var J = {
|
var Z = {
|
||||||
isSignal: L,
|
isSignal: N,
|
||||||
processReactiveAttribute(t, e, n, o) {
|
processReactiveAttribute(t, e, n, o) {
|
||||||
if (!L(n))
|
if (!N(n))
|
||||||
return n;
|
return n;
|
||||||
let r = (c) => o(e, c);
|
let r = (c) => o(e, c);
|
||||||
return T(n, r), V(n, r, t, e), n();
|
return W(n, r), K(n, r, t, e), n();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function V(t, e, ...n) {
|
function K(t, e, ...n) {
|
||||||
let { current: o } = m;
|
let { current: o } = h;
|
||||||
if (o.prevent)
|
o.prevent || o.host(function(r) {
|
||||||
return;
|
r[D] || (r[D] = [], v.disconnected(
|
||||||
let r = "__dde_reactive";
|
|
||||||
o.host(function(c) {
|
|
||||||
c[r] || (c[r] = [], v.disconnected(
|
|
||||||
() => (
|
() => (
|
||||||
/*!
|
/*!
|
||||||
* Clears all signals listeners added in the current scope/host (`S.el`, `assign`, …?).
|
* Clears all signals listeners added in the current scope/host (`S.el`, `assign`, …?).
|
||||||
* You can investigate the `__dde_reactive` key of the element.
|
* You can investigate the `__dde_reactive` key of the element.
|
||||||
* */
|
* */
|
||||||
c[r].forEach(([s]) => N(...s, t[d]?.host() === c))
|
r[D].forEach(([[c, s]]) => S(c, s, c[d]?.host() === r))
|
||||||
)
|
)
|
||||||
)(c)), c[r].push([[t, e], ...n]);
|
)(r)), r[D].push([[t, e], ...n]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function I(t, e) {
|
function V(t, e) {
|
||||||
let n = (...o) => o.length ? ot(n, ...o) : rt(n);
|
let n = (...o) => o.length ? st(n, ...o) : ct(n);
|
||||||
return et(n, t, e);
|
return rt(n, t, e);
|
||||||
}
|
}
|
||||||
var tt = Object.assign(/* @__PURE__ */ Object.create(null), {
|
var nt = Object.assign(/* @__PURE__ */ Object.create(null), {
|
||||||
stopPropagation() {
|
stopPropagation() {
|
||||||
this.skip = !0;
|
this.skip = !0;
|
||||||
}
|
}
|
||||||
});
|
}), M = class extends Error {
|
||||||
function et(t, e, n) {
|
constructor() {
|
||||||
|
super();
|
||||||
|
let [e, ...n] = this.stack.split(`
|
||||||
|
`), o = e.slice(e.indexOf("@"), e.indexOf(".js:") + 4);
|
||||||
|
this.stack = n.find((r) => !r.includes(o));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function rt(t, e, n) {
|
||||||
let o = [];
|
let o = [];
|
||||||
M(n) !== "[object Object]" && (n = {});
|
k(n) !== "[object Object]" && (n = {});
|
||||||
let { onclear: r } = l.symbols;
|
let { onclear: r } = g.symbols;
|
||||||
n[r] && (o.push(n[r]), Reflect.deleteProperty(n, r));
|
n[r] && (o.push(n[r]), Reflect.deleteProperty(n, r));
|
||||||
let { host: c } = m;
|
let { host: c } = h;
|
||||||
return t[d] = {
|
return t[d] = {
|
||||||
value: e,
|
value: e,
|
||||||
actions: n,
|
actions: n,
|
||||||
onclear: o,
|
onclear: o,
|
||||||
host: c,
|
host: c,
|
||||||
listeners: /* @__PURE__ */ new Set()
|
listeners: /* @__PURE__ */ new Set(),
|
||||||
}, t.toJSON = () => t(), Object.setPrototypeOf(t[d], tt), t;
|
defined: new M()
|
||||||
|
}, t.toJSON = () => t(), Object.setPrototypeOf(t[d], nt), t;
|
||||||
}
|
}
|
||||||
function nt() {
|
function ot() {
|
||||||
return D[D.length - 1];
|
return P[P.length - 1];
|
||||||
}
|
}
|
||||||
function rt(t) {
|
function ct(t) {
|
||||||
if (!t[d])
|
if (!t[d])
|
||||||
return;
|
return;
|
||||||
let { value: e, listeners: n } = t[d], o = nt();
|
let { value: e, listeners: n } = t[d], o = ot();
|
||||||
return o && n.add(o), g.has(o) && g.get(o).add(t), e;
|
return o && n.add(o), l.has(o) && l.get(o).add(t), e;
|
||||||
}
|
}
|
||||||
function ot(t, e, n) {
|
function st(t, e, n) {
|
||||||
if (!t[d])
|
if (!t[d])
|
||||||
return;
|
return;
|
||||||
let o = t[d];
|
let o = t[d];
|
||||||
if (!(!n && o.value === e))
|
if (!(!n && o.value === e))
|
||||||
return o.value = e, o.listeners.forEach((r) => r(e)), e;
|
return o.value = e, o.listeners.forEach((r) => r(e)), e;
|
||||||
}
|
}
|
||||||
function T(t, e) {
|
function W(t, e) {
|
||||||
if (t[d])
|
if (t[d])
|
||||||
return t[d].listeners.add(e);
|
return t[d].listeners.add(e);
|
||||||
}
|
}
|
||||||
function N(t, e, n) {
|
function S(t, e, n) {
|
||||||
let o = t[d];
|
let o = t[d];
|
||||||
if (!o)
|
if (!o)
|
||||||
return;
|
return;
|
||||||
let r = o.listeners.delete(e);
|
let r = o.listeners.delete(e);
|
||||||
if (n && !o.listeners.size) {
|
if (n && !o.listeners.size) {
|
||||||
if (l.clear(t), !g.has(o))
|
if (g.clear(t), !l.has(o))
|
||||||
return r;
|
return r;
|
||||||
let c = g.get(o);
|
let c = l.get(o);
|
||||||
if (!g.has(c))
|
if (!l.has(c))
|
||||||
return r;
|
return r;
|
||||||
g.get(c).forEach((s) => N(s, c, !0));
|
l.get(c).forEach((s) => S(s, c, !0));
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// signals.js
|
// signals.js
|
||||||
P(J);
|
j(Z);
|
||||||
|
|
||||||
globalThis.dde= {
|
globalThis.dde= {
|
||||||
S: l,
|
S: g,
|
||||||
assign: R,
|
assign: R,
|
||||||
assignAttribute: H,
|
assignAttribute: $,
|
||||||
classListDeclarative: K,
|
classListDeclarative: X,
|
||||||
createElement: at,
|
createElement: pt,
|
||||||
dispatchEvent: gt,
|
dispatchEvent: bt,
|
||||||
el: at,
|
el: pt,
|
||||||
empty: pt,
|
empty: ht,
|
||||||
isSignal: L,
|
isSignal: N,
|
||||||
on: v,
|
on: v,
|
||||||
registerReactivity: P,
|
registerReactivity: j,
|
||||||
scope: m
|
scope: h
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
292
dist/esm-with-signals.js
vendored
292
dist/esm-with-signals.js
vendored
@ -1,5 +1,5 @@
|
|||||||
// src/signals-common.js
|
// src/signals-common.js
|
||||||
var x = {
|
var w = {
|
||||||
isSignal(t) {
|
isSignal(t) {
|
||||||
return !1;
|
return !1;
|
||||||
},
|
},
|
||||||
@ -7,22 +7,22 @@ var x = {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function P(t, e = !0) {
|
function j(t, e = !0) {
|
||||||
return e ? Object.assign(x, t) : (Object.setPrototypeOf(t, x), t);
|
return e ? Object.assign(w, t) : (Object.setPrototypeOf(t, w), t);
|
||||||
}
|
}
|
||||||
function S(t) {
|
function A(t) {
|
||||||
return x.isPrototypeOf(t) && t !== x ? t : x;
|
return w.isPrototypeOf(t) && t !== w ? t : w;
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/helpers.js
|
// src/helpers.js
|
||||||
function E(t) {
|
function E(t) {
|
||||||
return typeof t > "u";
|
return typeof t > "u";
|
||||||
}
|
}
|
||||||
function M(t) {
|
function k(t) {
|
||||||
let e = typeof t;
|
let e = typeof t;
|
||||||
return e !== "object" ? e : t === null ? "null" : Object.prototype.toString.call(t);
|
return e !== "object" ? e : t === null ? "null" : Object.prototype.toString.call(t);
|
||||||
}
|
}
|
||||||
function A(t, e) {
|
function O(t, e) {
|
||||||
if (!t || !(t instanceof AbortSignal))
|
if (!t || !(t instanceof AbortSignal))
|
||||||
return !0;
|
return !0;
|
||||||
if (!t.aborted)
|
if (!t.aborted)
|
||||||
@ -32,8 +32,8 @@ function A(t, e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/dom-common.js
|
// src/dom-common.js
|
||||||
var W = { setDeleteAttr: Z };
|
var F = { setDeleteAttr: Q };
|
||||||
function Z(t, e, n) {
|
function Q(t, e, n) {
|
||||||
if (Reflect.set(t, e, n), !!E(n)) {
|
if (Reflect.set(t, e, n), !!E(n)) {
|
||||||
if (Reflect.deleteProperty(t, e), t instanceof HTMLElement && t.getAttribute(e) === "undefined")
|
if (Reflect.deleteProperty(t, e), t instanceof HTMLElement && t.getAttribute(e) === "undefined")
|
||||||
return t.removeAttribute(e);
|
return t.removeAttribute(e);
|
||||||
@ -48,7 +48,7 @@ var y = [{
|
|||||||
namespace: "html",
|
namespace: "html",
|
||||||
host: (t) => t ? t(document.body) : document.body,
|
host: (t) => t ? t(document.body) : document.body,
|
||||||
prevent: !0
|
prevent: !0
|
||||||
}], F = (t) => t === "svg" ? "http://www.w3.org/2000/svg" : t, m = {
|
}], z = (t) => t === "svg" ? "http://www.w3.org/2000/svg" : t, h = {
|
||||||
get current() {
|
get current() {
|
||||||
return y[y.length - 1];
|
return y[y.length - 1];
|
||||||
},
|
},
|
||||||
@ -59,7 +59,7 @@ var y = [{
|
|||||||
return this.current.namespace;
|
return this.current.namespace;
|
||||||
},
|
},
|
||||||
set namespace(t) {
|
set namespace(t) {
|
||||||
return this.current.namespace = F(t);
|
return this.current.namespace = z(t);
|
||||||
},
|
},
|
||||||
preventDefault() {
|
preventDefault() {
|
||||||
let { current: t } = this;
|
let { current: t } = this;
|
||||||
@ -69,7 +69,7 @@ var y = [{
|
|||||||
let e = this.namespace;
|
let e = this.namespace;
|
||||||
return this.namespace = t, {
|
return this.namespace = t, {
|
||||||
append(...n) {
|
append(...n) {
|
||||||
return m.namespace = e, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
|
return h.namespace = e, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -77,17 +77,17 @@ var y = [{
|
|||||||
return [...y];
|
return [...y];
|
||||||
},
|
},
|
||||||
push(t = {}) {
|
push(t = {}) {
|
||||||
return t.namespace && (t.namespace = F(t.namespace)), y.push(Object.assign({}, this.current, { prevent: !1 }, t));
|
return t.namespace && (t.namespace = z(t.namespace)), y.push(Object.assign({}, this.current, { prevent: !1 }, t));
|
||||||
},
|
},
|
||||||
pop() {
|
pop() {
|
||||||
return y.pop();
|
return y.pop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function at(t, e, ...n) {
|
function pt(t, e, ...n) {
|
||||||
let o = S(this), { namespace: r } = m, c = 0, s;
|
let o = A(this), { namespace: r } = h, c = 0, s;
|
||||||
switch ((Object(e) !== e || o.isSignal(e)) && (e = { textContent: e }), !0) {
|
switch ((Object(e) !== e || o.isSignal(e)) && (e = { textContent: e }), !0) {
|
||||||
case typeof t == "function": {
|
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);
|
c = 1, h.push({ scope: t, host: (a) => a ? (c === 1 ? n.unshift(a) : a(s), void 0) : s }), s = t(e || void 0), (s instanceof HTMLElement ? I : J)(s, "Attribute", "dde-fun", t.name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case t === "#text":
|
case t === "#text":
|
||||||
@ -102,100 +102,100 @@ function at(t, e, ...n) {
|
|||||||
case !s:
|
case !s:
|
||||||
s = R.call(this, document.createElement(t), e);
|
s = R.call(this, document.createElement(t), e);
|
||||||
}
|
}
|
||||||
return n.forEach((a) => a(s)), c && m.pop(), c = 2, s;
|
return n.forEach((a) => a(s)), c && h.pop(), c = 2, s;
|
||||||
}
|
}
|
||||||
var { setDeleteAttr: z } = W, O = /* @__PURE__ */ new WeakMap();
|
var { setDeleteAttr: H } = F, C = /* @__PURE__ */ new WeakMap();
|
||||||
function R(t, ...e) {
|
function R(t, ...e) {
|
||||||
if (!e.length)
|
if (!e.length)
|
||||||
return t;
|
return t;
|
||||||
O.set(t, U(t, this));
|
C.set(t, q(t, this));
|
||||||
for (let [n, o] of Object.entries(Object.assign({}, ...e)))
|
for (let [n, o] of Object.entries(Object.assign({}, ...e)))
|
||||||
H.call(this, t, n, o);
|
$.call(this, t, n, o);
|
||||||
return O.delete(t), t;
|
return C.delete(t), t;
|
||||||
}
|
}
|
||||||
function H(t, e, n) {
|
function $(t, e, n) {
|
||||||
let { setRemoveAttr: o, s: r } = U(t, this), c = this;
|
let { setRemoveAttr: o, s: r } = q(t, this), c = this;
|
||||||
n = r.processReactiveAttribute(
|
n = r.processReactiveAttribute(
|
||||||
t,
|
t,
|
||||||
e,
|
e,
|
||||||
n,
|
n,
|
||||||
(a, p) => H.call(c, t, a, p)
|
(a, p) => $.call(c, t, a, p)
|
||||||
);
|
);
|
||||||
let [s] = e;
|
let [s] = e;
|
||||||
if (s === "=")
|
if (s === "=")
|
||||||
return o(e.slice(1), n);
|
return o(e.slice(1), n);
|
||||||
if (s === ".")
|
if (s === ".")
|
||||||
return k(t, e.slice(1), n);
|
return U(t, e.slice(1), n);
|
||||||
if (/(aria|data)([A-Z])/.test(e))
|
if (/(aria|data)([A-Z])/.test(e))
|
||||||
return e = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), o(e, n);
|
return e = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), o(e, n);
|
||||||
switch (e === "className" && (e = "class"), e) {
|
switch (e === "className" && (e = "class"), e) {
|
||||||
case "xlink:href":
|
case "xlink:href":
|
||||||
return o(e, n, "http://www.w3.org/1999/xlink");
|
return o(e, n, "http://www.w3.org/1999/xlink");
|
||||||
case "textContent":
|
case "textContent":
|
||||||
return z(t, e, n);
|
return H(t, e, n);
|
||||||
case "style":
|
case "style":
|
||||||
if (typeof n != "object")
|
if (typeof n != "object")
|
||||||
break;
|
break;
|
||||||
case "dataset":
|
case "dataset":
|
||||||
return j(r, n, k.bind(null, t[e]));
|
return T(r, n, U.bind(null, t[e]));
|
||||||
case "ariaset":
|
case "ariaset":
|
||||||
return j(r, n, (a, p) => o("aria-" + a, p));
|
return T(r, n, (a, p) => o("aria-" + a, p));
|
||||||
case "classList":
|
case "classList":
|
||||||
return K.call(c, t, n);
|
return X.call(c, t, n);
|
||||||
}
|
}
|
||||||
return Q(t, e) ? z(t, e, n) : o(e, n);
|
return Y(t, e) ? H(t, e, n) : o(e, n);
|
||||||
}
|
}
|
||||||
function U(t, e) {
|
function q(t, e) {
|
||||||
if (O.has(t))
|
if (C.has(t))
|
||||||
return O.get(t);
|
return C.get(t);
|
||||||
let o = (t instanceof SVGElement ? G : B).bind(null, t, "Attribute"), r = S(e);
|
let o = (t instanceof SVGElement ? J : I).bind(null, t, "Attribute"), r = A(e);
|
||||||
return { setRemoveAttr: o, s: r };
|
return { setRemoveAttr: o, s: r };
|
||||||
}
|
}
|
||||||
function K(t, e) {
|
function X(t, e) {
|
||||||
let n = S(this);
|
let n = A(this);
|
||||||
return j(
|
return T(
|
||||||
n,
|
n,
|
||||||
e,
|
e,
|
||||||
(o, r) => t.classList.toggle(o, r === -1 ? void 0 : !!r)
|
(o, r) => t.classList.toggle(o, r === -1 ? void 0 : !!r)
|
||||||
), t;
|
), t;
|
||||||
}
|
}
|
||||||
function pt(t) {
|
function ht(t) {
|
||||||
return Array.from(t.children).forEach((e) => e.remove()), t;
|
return Array.from(t.children).forEach((e) => e.remove()), t;
|
||||||
}
|
}
|
||||||
function Q(t, e) {
|
function Y(t, e) {
|
||||||
if (!Reflect.has(t, e))
|
if (!Reflect.has(t, e))
|
||||||
return !1;
|
return !1;
|
||||||
let n = $(t, e);
|
let n = B(t, e);
|
||||||
return !E(n.set);
|
return !E(n.set);
|
||||||
}
|
}
|
||||||
function $(t, e) {
|
function B(t, e) {
|
||||||
if (t = Object.getPrototypeOf(t), !t)
|
if (t = Object.getPrototypeOf(t), !t)
|
||||||
return {};
|
return {};
|
||||||
let n = Object.getOwnPropertyDescriptor(t, e);
|
let n = Object.getOwnPropertyDescriptor(t, e);
|
||||||
return n || $(t, e);
|
return n || B(t, e);
|
||||||
}
|
}
|
||||||
function j(t, e, n) {
|
function T(t, e, n) {
|
||||||
if (!(typeof e != "object" || e === null))
|
if (!(typeof e != "object" || e === null))
|
||||||
return Object.entries(e).forEach(function([r, c]) {
|
return Object.entries(e).forEach(function([r, c]) {
|
||||||
r && (c = t.processReactiveAttribute(e, r, c, n), n(r, c));
|
r && (c = t.processReactiveAttribute(e, r, c, n), n(r, c));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function q(t) {
|
function G(t) {
|
||||||
return Array.isArray(t) ? t.filter(Boolean).join(" ") : t;
|
return Array.isArray(t) ? t.filter(Boolean).join(" ") : t;
|
||||||
}
|
}
|
||||||
function B(t, e, n, o) {
|
function I(t, e, n, o) {
|
||||||
return t[(E(o) ? "remove" : "set") + e](n, q(o));
|
return t[(E(o) ? "remove" : "set") + e](n, G(o));
|
||||||
}
|
}
|
||||||
function G(t, e, n, o, r = null) {
|
function J(t, e, n, o, r = null) {
|
||||||
return t[(E(o) ? "remove" : "set") + e + "NS"](r, n, q(o));
|
return t[(E(o) ? "remove" : "set") + e + "NS"](r, n, G(o));
|
||||||
}
|
}
|
||||||
function k(t, e, n) {
|
function U(t, e, n) {
|
||||||
if (Reflect.set(t, e, n), !!E(n))
|
if (Reflect.set(t, e, n), !!E(n))
|
||||||
return Reflect.deleteProperty(t, e);
|
return Reflect.deleteProperty(t, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/events.js
|
// src/events.js
|
||||||
function gt(t, e, ...n) {
|
function bt(t, e, ...n) {
|
||||||
let o = n.length ? new CustomEvent(e, { detail: n[0] }) : new Event(e);
|
let o = n.length ? new CustomEvent(e, { detail: n[0] }) : new Event(e);
|
||||||
return t.dispatchEvent(o);
|
return t.dispatchEvent(o);
|
||||||
}
|
}
|
||||||
@ -204,26 +204,26 @@ function v(t, e, n) {
|
|||||||
return r.addEventListener(t, e, n), r;
|
return r.addEventListener(t, e, n), r;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var C = Y(), X = /* @__PURE__ */ new WeakSet();
|
var L = et(), tt = /* @__PURE__ */ new WeakSet();
|
||||||
v.connected = function(t, e) {
|
v.connected = function(t, e) {
|
||||||
let n = "connected";
|
let n = "connected";
|
||||||
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
|
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
|
||||||
let c = "dde:" + n;
|
let c = "dde:" + n;
|
||||||
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);
|
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(c)), r) : (O(e.signal, () => L.offConnected(r, t)) && L.onConnected(r, t), r);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
v.disconnected = function(t, e) {
|
v.disconnected = function(t, e) {
|
||||||
let n = "disconnected";
|
let n = "disconnected";
|
||||||
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
|
return typeof e != "object" && (e = {}), e.once = !0, function(r) {
|
||||||
let c = "dde:" + n;
|
let c = "dde:" + n;
|
||||||
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || A(e.signal, () => C.offDisconnected(r, t)) && C.onDisconnected(r, t), r;
|
return r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || O(e.signal, () => L.offDisconnected(r, t)) && L.onDisconnected(r, t), r;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
v.attributeChanged = function(t, e) {
|
v.attributeChanged = function(t, e) {
|
||||||
let n = "attributeChanged";
|
let n = "attributeChanged";
|
||||||
return typeof e != "object" && (e = {}), function(r) {
|
return typeof e != "object" && (e = {}), function(r) {
|
||||||
let c = "dde:" + n;
|
let c = "dde:" + n;
|
||||||
if (r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || X.has(r))
|
if (r.addEventListener(c, t, e), r.__dde_lifecycleToEvents || tt.has(r))
|
||||||
return r;
|
return r;
|
||||||
let s = new MutationObserver(function(p) {
|
let s = new MutationObserver(function(p) {
|
||||||
for (let { attributeName: b, target: _ } of p)
|
for (let { attributeName: b, target: _ } of p)
|
||||||
@ -231,10 +231,10 @@ v.attributeChanged = function(t, e) {
|
|||||||
new CustomEvent(c, { detail: [b, _.getAttribute(b)] })
|
new CustomEvent(c, { detail: [b, _.getAttribute(b)] })
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return A(e.signal, () => s.disconnect()) && s.observe(r, { attributes: !0 }), r;
|
return O(e.signal, () => s.disconnect()) && s.observe(r, { attributes: !0 }), r;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
function Y() {
|
function et() {
|
||||||
let t = /* @__PURE__ */ new Map(), e = !1, n = new MutationObserver(function(i) {
|
let t = /* @__PURE__ */ new Map(), e = !1, n = new MutationObserver(function(i) {
|
||||||
for (let u of i)
|
for (let u of i)
|
||||||
if (u.type === "childList") {
|
if (u.type === "childList") {
|
||||||
@ -305,18 +305,18 @@ function Y() {
|
|||||||
}
|
}
|
||||||
function b(i, u) {
|
function b(i, u) {
|
||||||
let f = !1;
|
let f = !1;
|
||||||
for (let h of i) {
|
for (let m of i) {
|
||||||
if (u && p(h).then(b), !t.has(h))
|
if (u && p(m).then(b), !t.has(m))
|
||||||
continue;
|
continue;
|
||||||
let w = t.get(h);
|
let x = t.get(m);
|
||||||
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);
|
x.length_c && (m.dispatchEvent(new Event("dde:connected")), x.connected = /* @__PURE__ */ new WeakSet(), x.length_c = 0, x.length_d || t.delete(m), f = !0);
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
function _(i, u) {
|
function _(i, u) {
|
||||||
let f = !1;
|
let f = !1;
|
||||||
for (let h of i)
|
for (let m 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);
|
u && p(m).then(_), !(!t.has(m) || !t.get(m).length_d) && (m.dispatchEvent(new Event("dde:disconnected")), t.delete(m), f = !0);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,25 +331,30 @@ function Y() {
|
|||||||
|
|
||||||
// src/signals-lib.js
|
// src/signals-lib.js
|
||||||
var d = Symbol.for("Signal");
|
var d = Symbol.for("Signal");
|
||||||
function L(t) {
|
function N(t) {
|
||||||
try {
|
try {
|
||||||
return Reflect.has(t, d);
|
return Reflect.has(t, d);
|
||||||
} catch {
|
} catch {
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var D = [], g = /* @__PURE__ */ new WeakMap();
|
var P = [], l = /* @__PURE__ */ new WeakMap();
|
||||||
function l(t, e) {
|
function g(t, e) {
|
||||||
if (typeof t != "function")
|
if (typeof t != "function")
|
||||||
return I(t, e);
|
return V(t, e);
|
||||||
if (L(t))
|
if (N(t))
|
||||||
return t;
|
return t;
|
||||||
let n = I(), o = function() {
|
let n = V(), o = function() {
|
||||||
D.push(o), n(t()), D.pop();
|
let [r, ...c] = l.get(o);
|
||||||
|
if (l.set(o, /* @__PURE__ */ new Set([r])), P.push(o), n(t()), P.pop(), !c.length)
|
||||||
|
return;
|
||||||
|
let s = l.get(o);
|
||||||
|
for (let a of c)
|
||||||
|
s.has(a) || S(a, o);
|
||||||
};
|
};
|
||||||
return g.set(o, /* @__PURE__ */ new Set([n])), g.set(n[d], o), o(), n;
|
return l.set(n[d], o), l.set(o, /* @__PURE__ */ new Set([n])), o(), n;
|
||||||
}
|
}
|
||||||
l.action = function(t, e, ...n) {
|
g.action = function(t, e, ...n) {
|
||||||
let o = t[d], { actions: r } = o;
|
let o = t[d], { actions: r } = o;
|
||||||
if (!r || !Reflect.has(r, e))
|
if (!r || !Reflect.has(r, e))
|
||||||
throw new Error(`'${t}' has no action with name '${e}'!`);
|
throw new Error(`'${t}' has no action with name '${e}'!`);
|
||||||
@ -357,30 +362,30 @@ l.action = function(t, e, ...n) {
|
|||||||
return Reflect.deleteProperty(o, "skip");
|
return Reflect.deleteProperty(o, "skip");
|
||||||
o.listeners.forEach((c) => c(o.value));
|
o.listeners.forEach((c) => c(o.value));
|
||||||
};
|
};
|
||||||
l.on = function t(e, n, o = {}) {
|
g.on = function t(e, n, o = {}) {
|
||||||
let { signal: r } = o;
|
let { signal: r } = o;
|
||||||
if (!(r && r.aborted)) {
|
if (!(r && r.aborted)) {
|
||||||
if (Array.isArray(e))
|
if (Array.isArray(e))
|
||||||
return e.forEach((c) => t(c, n, o));
|
return e.forEach((c) => t(c, n, o));
|
||||||
T(e, n), r && r.addEventListener("abort", () => N(e, n));
|
W(e, n), r && r.addEventListener("abort", () => S(e, n));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
l.symbols = {
|
g.symbols = {
|
||||||
signal: d,
|
signal: d,
|
||||||
onclear: Symbol.for("Signal.onclear")
|
onclear: Symbol.for("Signal.onclear")
|
||||||
};
|
};
|
||||||
l.attribute = function(t, e = void 0) {
|
g.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, {
|
let { host: n } = h, o = n() && n().hasAttribute(t) ? n().getAttribute(t) : e, r = new AbortController(), c = g(o, {
|
||||||
[l.symbols.onclear]() {
|
[g.symbols.onclear]() {
|
||||||
r.abort();
|
r.abort();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return m.host(v.attributeChanged(function({ detail: a }) {
|
return h.host(v.attributeChanged(function({ detail: a }) {
|
||||||
let [p, b] = a;
|
let [p, b] = a;
|
||||||
p === t && c(b);
|
p === t && c(b);
|
||||||
}, { signal: r.signal })), c;
|
}, { signal: r.signal })), c;
|
||||||
};
|
};
|
||||||
l.clear = function(...t) {
|
g.clear = function(...t) {
|
||||||
for (let n of t) {
|
for (let n of t) {
|
||||||
Reflect.deleteProperty(n, "toJSON");
|
Reflect.deleteProperty(n, "toJSON");
|
||||||
let o = n[d];
|
let o = n[d];
|
||||||
@ -388,126 +393,133 @@ l.clear = function(...t) {
|
|||||||
}
|
}
|
||||||
function e(n, o) {
|
function e(n, o) {
|
||||||
o.listeners.forEach((r) => {
|
o.listeners.forEach((r) => {
|
||||||
if (o.listeners.delete(r), !g.has(r))
|
if (o.listeners.delete(r), !l.has(r))
|
||||||
return;
|
return;
|
||||||
let c = g.get(r);
|
let c = l.get(r);
|
||||||
c.delete(n), !(c.size > 1) && (l.clear(...c), g.delete(r));
|
c.delete(n), !(c.size > 1) && (g.clear(...c), l.delete(r));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
l.el = function(t, e) {
|
var D = "__dde_reactive";
|
||||||
let n = document.createComment("<#reactive>"), o = document.createComment("</#reactive>"), r = document.createDocumentFragment();
|
g.el = function(t, e) {
|
||||||
|
let n = document.createComment("<dde:reactive>"), o = document.createComment("</dde:reactive>"), r = document.createDocumentFragment();
|
||||||
r.append(n, o);
|
r.append(n, o);
|
||||||
let c = (s) => {
|
let { current: c } = h, s = (a) => {
|
||||||
if (!n.parentNode || !o.parentNode)
|
if (!n.parentNode || !o.parentNode)
|
||||||
return N(t, c);
|
return S(t, s);
|
||||||
let a = e(s);
|
h.push(c);
|
||||||
Array.isArray(a) || (a = [a]);
|
let p = e(a);
|
||||||
let p = n;
|
h.pop(), Array.isArray(p) || (p = [p]);
|
||||||
for (; (p = n.nextSibling) !== o; )
|
let b = n;
|
||||||
p.remove();
|
for (; (b = n.nextSibling) !== o; )
|
||||||
n.after(...a);
|
b.remove();
|
||||||
|
n.after(...p);
|
||||||
};
|
};
|
||||||
return T(t, c), V(t, c, n, e), c(t()), r;
|
return W(t, s), K(t, s, n, e), s(t()), r;
|
||||||
};
|
};
|
||||||
var J = {
|
var Z = {
|
||||||
isSignal: L,
|
isSignal: N,
|
||||||
processReactiveAttribute(t, e, n, o) {
|
processReactiveAttribute(t, e, n, o) {
|
||||||
if (!L(n))
|
if (!N(n))
|
||||||
return n;
|
return n;
|
||||||
let r = (c) => o(e, c);
|
let r = (c) => o(e, c);
|
||||||
return T(n, r), V(n, r, t, e), n();
|
return W(n, r), K(n, r, t, e), n();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function V(t, e, ...n) {
|
function K(t, e, ...n) {
|
||||||
let { current: o } = m;
|
let { current: o } = h;
|
||||||
if (o.prevent)
|
o.prevent || o.host(function(r) {
|
||||||
return;
|
r[D] || (r[D] = [], v.disconnected(
|
||||||
let r = "__dde_reactive";
|
|
||||||
o.host(function(c) {
|
|
||||||
c[r] || (c[r] = [], v.disconnected(
|
|
||||||
() => (
|
() => (
|
||||||
/*!
|
/*!
|
||||||
* Clears all signals listeners added in the current scope/host (`S.el`, `assign`, …?).
|
* Clears all signals listeners added in the current scope/host (`S.el`, `assign`, …?).
|
||||||
* You can investigate the `__dde_reactive` key of the element.
|
* You can investigate the `__dde_reactive` key of the element.
|
||||||
* */
|
* */
|
||||||
c[r].forEach(([s]) => N(...s, t[d]?.host() === c))
|
r[D].forEach(([[c, s]]) => S(c, s, c[d]?.host() === r))
|
||||||
)
|
)
|
||||||
)(c)), c[r].push([[t, e], ...n]);
|
)(r)), r[D].push([[t, e], ...n]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function I(t, e) {
|
function V(t, e) {
|
||||||
let n = (...o) => o.length ? ot(n, ...o) : rt(n);
|
let n = (...o) => o.length ? st(n, ...o) : ct(n);
|
||||||
return et(n, t, e);
|
return rt(n, t, e);
|
||||||
}
|
}
|
||||||
var tt = Object.assign(/* @__PURE__ */ Object.create(null), {
|
var nt = Object.assign(/* @__PURE__ */ Object.create(null), {
|
||||||
stopPropagation() {
|
stopPropagation() {
|
||||||
this.skip = !0;
|
this.skip = !0;
|
||||||
}
|
}
|
||||||
});
|
}), M = class extends Error {
|
||||||
function et(t, e, n) {
|
constructor() {
|
||||||
|
super();
|
||||||
|
let [e, ...n] = this.stack.split(`
|
||||||
|
`), o = e.slice(e.indexOf("@"), e.indexOf(".js:") + 4);
|
||||||
|
this.stack = n.find((r) => !r.includes(o));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function rt(t, e, n) {
|
||||||
let o = [];
|
let o = [];
|
||||||
M(n) !== "[object Object]" && (n = {});
|
k(n) !== "[object Object]" && (n = {});
|
||||||
let { onclear: r } = l.symbols;
|
let { onclear: r } = g.symbols;
|
||||||
n[r] && (o.push(n[r]), Reflect.deleteProperty(n, r));
|
n[r] && (o.push(n[r]), Reflect.deleteProperty(n, r));
|
||||||
let { host: c } = m;
|
let { host: c } = h;
|
||||||
return t[d] = {
|
return t[d] = {
|
||||||
value: e,
|
value: e,
|
||||||
actions: n,
|
actions: n,
|
||||||
onclear: o,
|
onclear: o,
|
||||||
host: c,
|
host: c,
|
||||||
listeners: /* @__PURE__ */ new Set()
|
listeners: /* @__PURE__ */ new Set(),
|
||||||
}, t.toJSON = () => t(), Object.setPrototypeOf(t[d], tt), t;
|
defined: new M()
|
||||||
|
}, t.toJSON = () => t(), Object.setPrototypeOf(t[d], nt), t;
|
||||||
}
|
}
|
||||||
function nt() {
|
function ot() {
|
||||||
return D[D.length - 1];
|
return P[P.length - 1];
|
||||||
}
|
}
|
||||||
function rt(t) {
|
function ct(t) {
|
||||||
if (!t[d])
|
if (!t[d])
|
||||||
return;
|
return;
|
||||||
let { value: e, listeners: n } = t[d], o = nt();
|
let { value: e, listeners: n } = t[d], o = ot();
|
||||||
return o && n.add(o), g.has(o) && g.get(o).add(t), e;
|
return o && n.add(o), l.has(o) && l.get(o).add(t), e;
|
||||||
}
|
}
|
||||||
function ot(t, e, n) {
|
function st(t, e, n) {
|
||||||
if (!t[d])
|
if (!t[d])
|
||||||
return;
|
return;
|
||||||
let o = t[d];
|
let o = t[d];
|
||||||
if (!(!n && o.value === e))
|
if (!(!n && o.value === e))
|
||||||
return o.value = e, o.listeners.forEach((r) => r(e)), e;
|
return o.value = e, o.listeners.forEach((r) => r(e)), e;
|
||||||
}
|
}
|
||||||
function T(t, e) {
|
function W(t, e) {
|
||||||
if (t[d])
|
if (t[d])
|
||||||
return t[d].listeners.add(e);
|
return t[d].listeners.add(e);
|
||||||
}
|
}
|
||||||
function N(t, e, n) {
|
function S(t, e, n) {
|
||||||
let o = t[d];
|
let o = t[d];
|
||||||
if (!o)
|
if (!o)
|
||||||
return;
|
return;
|
||||||
let r = o.listeners.delete(e);
|
let r = o.listeners.delete(e);
|
||||||
if (n && !o.listeners.size) {
|
if (n && !o.listeners.size) {
|
||||||
if (l.clear(t), !g.has(o))
|
if (g.clear(t), !l.has(o))
|
||||||
return r;
|
return r;
|
||||||
let c = g.get(o);
|
let c = l.get(o);
|
||||||
if (!g.has(c))
|
if (!l.has(c))
|
||||||
return r;
|
return r;
|
||||||
g.get(c).forEach((s) => N(s, c, !0));
|
l.get(c).forEach((s) => S(s, c, !0));
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// signals.js
|
// signals.js
|
||||||
P(J);
|
j(Z);
|
||||||
export {
|
export {
|
||||||
l as S,
|
g as S,
|
||||||
R as assign,
|
R as assign,
|
||||||
H as assignAttribute,
|
$ as assignAttribute,
|
||||||
K as classListDeclarative,
|
X as classListDeclarative,
|
||||||
at as createElement,
|
pt as createElement,
|
||||||
gt as dispatchEvent,
|
bt as dispatchEvent,
|
||||||
at as el,
|
pt as el,
|
||||||
pt as empty,
|
ht as empty,
|
||||||
L as isSignal,
|
N as isSignal,
|
||||||
v as on,
|
v as on,
|
||||||
P as registerReactivity,
|
j as registerReactivity,
|
||||||
m as scope
|
h as scope
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,13 @@ export function isSignal(candidate){
|
|||||||
}
|
}
|
||||||
/** @type {function[]} */
|
/** @type {function[]} */
|
||||||
const stack_watch= [];
|
const stack_watch= [];
|
||||||
/** @type {WeakMap<function|ddeSignal<any, any>,Set<ddeSignal<any, any>>|function>} */
|
/**
|
||||||
|
* ### `WeakMap<function, Set<ddeSignal<any, any>>>`
|
||||||
|
* The `Set` is in the form of `[ source, ...depended signals (DSs) ]`. When the DS is cleaned it is removed from DSs, if remains only one (`source`) it is cleared too.
|
||||||
|
* ### `WeakMap<object, function>`
|
||||||
|
* This is used for revesed deps, the `function` is also key for `deps`.
|
||||||
|
* @type {WeakMap<function|object,Set<ddeSignal<any, any>>|function>}
|
||||||
|
* */
|
||||||
const deps= new WeakMap();
|
const deps= new WeakMap();
|
||||||
export function S(value, actions){
|
export function S(value, actions){
|
||||||
if(typeof value!=="function")
|
if(typeof value!=="function")
|
||||||
@ -15,12 +21,22 @@ export function S(value, actions){
|
|||||||
|
|
||||||
const out= create();
|
const out= create();
|
||||||
const contextReWatch= function(){
|
const contextReWatch= function(){
|
||||||
|
const [ origin, ...deps_old ]= deps.get(contextReWatch);
|
||||||
|
deps.set(contextReWatch, new Set([ origin ]));
|
||||||
|
|
||||||
stack_watch.push(contextReWatch);
|
stack_watch.push(contextReWatch);
|
||||||
out(value());
|
out(value());
|
||||||
stack_watch.pop();
|
stack_watch.pop();
|
||||||
|
|
||||||
|
if(!deps_old.length) return;
|
||||||
|
const deps_curr= deps.get(contextReWatch);
|
||||||
|
for (const dep_signal of deps_old){
|
||||||
|
if(deps_curr.has(dep_signal)) continue;
|
||||||
|
removeSignalListener(dep_signal, contextReWatch);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
deps.set(contextReWatch, new Set([ out ]));
|
|
||||||
deps.set(out[mark], contextReWatch);
|
deps.set(out[mark], contextReWatch);
|
||||||
|
deps.set(contextReWatch, new Set([ out ]));
|
||||||
contextReWatch();
|
contextReWatch();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -82,15 +98,19 @@ S.clear= function(...signals){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const key_reactive= "__dde_reactive";
|
||||||
S.el= function(signal, map){
|
S.el= function(signal, map){
|
||||||
const mark_start= document.createComment("<#reactive>");
|
const mark_start= document.createComment(`<dde:reactive>`);
|
||||||
const mark_end= document.createComment("</#reactive>");
|
const mark_end= document.createComment("</dde:reactive>");
|
||||||
const out= document.createDocumentFragment();
|
const out= document.createDocumentFragment();
|
||||||
out.append(mark_start, mark_end);
|
out.append(mark_start, mark_end);
|
||||||
|
const { current }= scope;
|
||||||
const reRenderReactiveElement= v=> {
|
const reRenderReactiveElement= v=> {
|
||||||
if(!mark_start.parentNode || !mark_end.parentNode)
|
if(!mark_start.parentNode || !mark_end.parentNode)
|
||||||
return removeSignalListener(signal, reRenderReactiveElement);
|
return removeSignalListener(signal, reRenderReactiveElement);
|
||||||
|
scope.push(current);
|
||||||
let els= map(v);
|
let els= map(v);
|
||||||
|
scope.pop();
|
||||||
if(!Array.isArray(els))
|
if(!Array.isArray(els))
|
||||||
els= [ els ];
|
els= [ els ];
|
||||||
let el_r= mark_start;
|
let el_r= mark_start;
|
||||||
@ -107,30 +127,30 @@ S.el= function(signal, map){
|
|||||||
import { typeOf } from './helpers.js';
|
import { typeOf } from './helpers.js';
|
||||||
export const signals_config= {
|
export const signals_config= {
|
||||||
isSignal,
|
isSignal,
|
||||||
processReactiveAttribute(_, key, attrs, set){
|
processReactiveAttribute(element, key, attrs, set){
|
||||||
if(!isSignal(attrs)) return attrs;
|
if(!isSignal(attrs)) return attrs;
|
||||||
const l= attr=> set(key, attr);
|
const l= attr=> set(key, attr);
|
||||||
addSignalListener(attrs, l);
|
addSignalListener(attrs, l);
|
||||||
removeSignalsFromElements(attrs, l, _, key);
|
removeSignalsFromElements(attrs, l, element, key);
|
||||||
return attrs();
|
return attrs();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function removeSignalsFromElements(signal, listener, ...notes){
|
function removeSignalsFromElements(signal, listener, ...notes){
|
||||||
const { current }= scope;
|
const { current }= scope;
|
||||||
if(current.prevent) return;
|
if(current.prevent) return;
|
||||||
const k= "__dde_reactive";
|
|
||||||
current.host(function(element){
|
current.host(function(element){
|
||||||
if(!element[k]){
|
if(!element[key_reactive]){
|
||||||
element[k]= [];
|
element[key_reactive]= [];
|
||||||
on.disconnected(()=>
|
on.disconnected(()=>
|
||||||
/*!
|
/*!
|
||||||
* Clears all signals listeners added in the current scope/host (`S.el`, `assign`, …?).
|
* Clears all signals listeners added in the current scope/host (`S.el`, `assign`, …?).
|
||||||
* You can investigate the `__dde_reactive` key of the element.
|
* You can investigate the `__dde_reactive` key of the element.
|
||||||
* */
|
* */
|
||||||
element[k].forEach(([ sl ])=> removeSignalListener(...sl, signal[mark]?.host() === element))
|
element[key_reactive].forEach(([ [ signal, listener ] ])=>
|
||||||
|
removeSignalListener(signal, listener, signal[mark]?.host() === element))
|
||||||
)(element);
|
)(element);
|
||||||
}
|
}
|
||||||
element[k].push([ [ signal, listener ], ...notes ]);
|
element[key_reactive].push([ [ signal, listener ], ...notes ]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +164,14 @@ const protoSigal= Object.assign(Object.create(null), {
|
|||||||
this.skip= true;
|
this.skip= true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
class SignalDefined extends Error{
|
||||||
|
constructor(){
|
||||||
|
super();
|
||||||
|
const [ curr, ...rest ]= this.stack.split("\n");
|
||||||
|
const curr_file= curr.slice(curr.indexOf("@"), curr.indexOf(".js:")+4);
|
||||||
|
this.stack= rest.find(l=> !l.includes(curr_file));
|
||||||
|
}
|
||||||
|
}
|
||||||
function toSignal(signal, value, actions){
|
function toSignal(signal, value, actions){
|
||||||
const onclear= [];
|
const onclear= [];
|
||||||
if(typeOf(actions)!=="[object Object]")
|
if(typeOf(actions)!=="[object Object]")
|
||||||
@ -156,7 +184,8 @@ function toSignal(signal, value, actions){
|
|||||||
const { host }= scope;
|
const { host }= scope;
|
||||||
signal[mark]= {
|
signal[mark]= {
|
||||||
value, actions, onclear, host,
|
value, actions, onclear, host,
|
||||||
listeners: new Set()
|
listeners: new Set(),
|
||||||
|
defined: new SignalDefined()
|
||||||
};
|
};
|
||||||
signal.toJSON= ()=> signal();
|
signal.toJSON= ()=> signal();
|
||||||
Object.setPrototypeOf(signal[mark], protoSigal);
|
Object.setPrototypeOf(signal[mark], protoSigal);
|
||||||
|
Loading…
Reference in New Issue
Block a user