1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-04-03 04:25:53 +02:00

🐛 improves/fixes queue

This commit is contained in:
Jan Andrle 2024-12-12 20:05:21 +01:00
parent 5098fb7fa2
commit 99d073b87a
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
7 changed files with 60 additions and 63 deletions

View File

@ -52,8 +52,7 @@ var d = {
H: globalThis.HTMLElement, H: globalThis.HTMLElement,
S: globalThis.SVGElement, S: globalThis.SVGElement,
M: globalThis.MutationObserver, M: globalThis.MutationObserver,
qa: (t) => t, q: (t) => t || Promise.resolve()
qw: () => Promise.resolve()
}; };
function pt(t, e, n) { function pt(t, e, n) {
if (Reflect.set(t, e, n), !!A(n)) { if (Reflect.set(t, e, n), !!A(n)) {
@ -67,7 +66,7 @@ var O = "__dde_lifecyclesToEvents", _ = "dde:connected", S = "dde:disconnected",
// src/dom.js // src/dom.js
function Mt(t) { function Mt(t) {
return d.qa(t); return d.q(t);
} }
var y = [{ var y = [{
get scope() { get scope() {
@ -467,7 +466,7 @@ E.on = function t(e, n, r = {}) {
let { signal: o } = r; let { signal: o } = r;
if (!(o && o.aborted)) { if (!(o && o.aborted)) {
if (Array.isArray(e)) return e.forEach((c) => t(c, n, r)); if (Array.isArray(e)) return e.forEach((c) => t(c, n, r));
K(e, n), o && o.addEventListener("abort", () => R(e, n)); Q(e, n), o && o.addEventListener("abort", () => R(e, n));
} }
}; };
E.symbols = { E.symbols = {
@ -508,7 +507,7 @@ E.el = function(t, e) {
k.remove(); k.remove();
m.remove(), n.isConnected && yt(c.host()); m.remove(), n.isConnected && yt(c.host());
}; };
return K(t, a), ut(t, a, n, e), a(t()), o; return Q(t, a), ut(t, a, n, e), a(t()), o;
}; };
function yt(t) { function yt(t) {
!t || !t[D] || (requestIdleCallback || setTimeout)(function() { !t || !t[D] || (requestIdleCallback || setTimeout)(function() {
@ -522,7 +521,7 @@ var At = {
}; };
function Ot(t) { function Ot(t) {
return function(e, n) { return function(e, n) {
let r = (...c) => c.length ? e.setAttribute(n, ...c) : V(r), o = ft(r, e.getAttribute(n), At); let r = (...c) => c.length ? e.setAttribute(n, ...c) : K(r), o = ft(r, e.getAttribute(n), At);
return t[n] = o, o; return t[n] = o, o;
}; };
} }
@ -549,7 +548,7 @@ var st = {
return R(n, o); return R(n, o);
r(e, c); r(e, c);
}; };
return K(n, o), ut(n, o, t, e), n(); return Q(n, o), ut(n, o, t, e), n();
} }
}; };
function ut(t, e, ...n) { function ut(t, e, ...n) {
@ -567,14 +566,14 @@ function ut(t, e, ...n) {
}); });
} }
function it(t, e, n) { function it(t, e, n) {
let r = t ? () => V(r) : (...o) => o.length ? at(r, ...o) : V(r); let r = t ? () => K(r) : (...o) => o.length ? at(r, ...o) : K(r);
return ft(r, e, n, t); return ft(r, e, n, t);
} }
var St = Object.assign(/* @__PURE__ */ Object.create(null), { var St = Object.assign(/* @__PURE__ */ Object.create(null), {
stopPropagation() { stopPropagation() {
this.skip = !0; this.skip = !0;
} }
}), Q = class extends Error { }), V = class extends Error {
constructor() { constructor() {
super(); super();
let [e, ...n] = this.stack.split(` let [e, ...n] = this.stack.split(`
@ -595,7 +594,7 @@ function ft(t, e, n, r = !1) {
onclear: o, onclear: o,
host: u, host: u,
listeners: /* @__PURE__ */ new Set(), listeners: /* @__PURE__ */ new Set(),
defined: new Q().stack, defined: new V().stack,
readonly: r readonly: r
}, },
enumerable: !1, enumerable: !1,
@ -606,7 +605,7 @@ function ft(t, e, n, r = !1) {
function Ct() { function Ct() {
return z[z.length - 1]; return z[z.length - 1];
} }
function V(t) { function K(t) {
if (!t[p]) return; if (!t[p]) return;
let { value: e, listeners: n } = t[p], r = Ct(); let { value: e, listeners: n } = t[p], r = Ct();
return r && n.add(r), g.has(r) && g.get(r).add(t), e; return r && n.add(r), g.has(r) && g.get(r).add(t), e;
@ -617,7 +616,7 @@ function at(t, e, n) {
if (!(!n && r.value === e)) if (!(!n && r.value === e))
return r.value = e, r.listeners.forEach((o) => o(e)), e; return r.value = e, r.listeners.forEach((o) => o(e)), e;
} }
function K(t, e) { function Q(t, e) {
if (t[p]) if (t[p])
return t[p].listeners.add(e); return t[p].listeners.add(e);
} }
@ -641,7 +640,6 @@ globalThis.dde= {
S: E, S: E,
assign: q, assign: q,
assignAttribute: nt, assignAttribute: nt,
asyncQueueAdd: Mt,
chainableAppend: lt, chainableAppend: lt,
classListDeclarative: ht, classListDeclarative: ht,
createElement: M, createElement: M,
@ -656,6 +654,7 @@ globalThis.dde= {
lifecyclesToEvents: xt, lifecyclesToEvents: xt,
observedAttributes: wt, observedAttributes: wt,
on: w, on: w,
queue: Mt,
registerReactivity: H, registerReactivity: H,
scope: x, scope: x,
signal: E, signal: E,

29
dist/dde.js vendored
View File

@ -40,17 +40,16 @@ function G(t) {
// src/dom-common.js // src/dom-common.js
var f = { var f = {
setDeleteAttr: Q, setDeleteAttr: V,
ssr: "", ssr: "",
D: globalThis.document, D: globalThis.document,
F: globalThis.DocumentFragment, F: globalThis.DocumentFragment,
H: globalThis.HTMLElement, H: globalThis.HTMLElement,
S: globalThis.SVGElement, S: globalThis.SVGElement,
M: globalThis.MutationObserver, M: globalThis.MutationObserver,
qa: (t) => t, q: (t) => t || Promise.resolve()
qw: () => Promise.resolve()
}; };
function Q(t, e, n) { function V(t, e, n) {
if (Reflect.set(t, e, n), !!x(n)) { if (Reflect.set(t, e, n), !!x(n)) {
if (Reflect.deleteProperty(t, e), t instanceof f.H && t.getAttribute(e) === "undefined") if (Reflect.deleteProperty(t, e), t instanceof f.H && t.getAttribute(e) === "undefined")
return t.removeAttribute(e); return t.removeAttribute(e);
@ -62,7 +61,7 @@ var w = "__dde_lifecyclesToEvents", v = "dde:connected", m = "dde:disconnected",
// src/dom.js // src/dom.js
function dt(t) { function dt(t) {
return f.qa(t); return f.q(t);
} }
var g = [{ var g = [{
get scope() { get scope() {
@ -98,7 +97,7 @@ var g = [{
function q(...t) { function q(...t) {
return this.appendOriginal(...t), this; return this.appendOriginal(...t), this;
} }
function V(t) { function J(t) {
return t.append === q || (t.appendOriginal = t.append, t.append = q), t; return t.append === q || (t.appendOriginal = t.append, t.append = q), t;
} }
var T; var T;
@ -131,7 +130,7 @@ function P(t, e, ...n) {
case !c: case !c:
c = R.call(this, f.D.createElement(t), e); c = R.call(this, f.D.createElement(t), e);
} }
return V(c), a || (a = c), n.forEach((d) => d(a)), o && D.pop(), o = 2, c; return J(c), a || (a = c), n.forEach((d) => d(a)), o && D.pop(), o = 2, c;
} }
P.mark = function(t, e = !1) { P.mark = function(t, e = !1) {
t = Object.entries(t).map(([o, c]) => o + `="${c}"`).join(" "); t = Object.entries(t).map(([o, c]) => o + `="${c}"`).join(" ");
@ -156,7 +155,7 @@ function ht(t, e = t) {
for (let p of d) { for (let p of d) {
let b = (p.slot || "") + n; let b = (p.slot || "") + n;
try { try {
K(p, "remove", "slot"); Q(p, "remove", "slot");
} catch { } catch {
} }
let h = o[b]; let h = o[b];
@ -205,7 +204,7 @@ function U(t, e, n) {
case "ariaset": case "ariaset":
return M(o, n, (d, p) => r("aria-" + d, p)); return M(o, n, (d, p) => r("aria-" + d, p));
case "classList": case "classList":
return J.call(c, t, n); return K.call(c, t, n);
} }
return X(t, e) ? $(t, e, n) : r(e, n); return X(t, e) ? $(t, e, n) : r(e, n);
} }
@ -214,7 +213,7 @@ function H(t, e) {
let r = (t instanceof f.S ? tt : Y).bind(null, t, "Attribute"), o = S(e); let r = (t instanceof f.S ? tt : Y).bind(null, t, "Attribute"), o = S(e);
return { setRemoveAttr: r, s: o }; return { setRemoveAttr: r, s: o };
} }
function J(t, e) { function K(t, e) {
let n = S(this); let n = S(this);
return M( return M(
n, n,
@ -222,7 +221,7 @@ function J(t, e) {
(r, o) => t.classList.toggle(r, o === -1 ? void 0 : !!o) (r, o) => t.classList.toggle(r, o === -1 ? void 0 : !!o)
), t; ), t;
} }
function K(t, e, n, r) { function Q(t, e, n, r) {
return t instanceof f.H ? t[e + "Attribute"](n, r) : t[e + "AttributeNS"](null, n, r); return t instanceof f.H ? t[e + "Attribute"](n, r) : t[e + "AttributeNS"](null, n, r);
} }
function X(t, e) { function X(t, e) {
@ -431,9 +430,8 @@ _.attributeChanged = function(t, e) {
globalThis.dde= { globalThis.dde= {
assign: R, assign: R,
assignAttribute: U, assignAttribute: U,
asyncQueueAdd: dt, chainableAppend: J,
chainableAppend: V, classListDeclarative: K,
classListDeclarative: J,
createElement: P, createElement: P,
createElementNS: pt, createElementNS: pt,
customElementRender: mt, customElementRender: mt,
@ -441,10 +439,11 @@ globalThis.dde= {
dispatchEvent: Ot, dispatchEvent: Ot,
el: P, el: P,
elNS: pt, elNS: pt,
elementAttribute: K, elementAttribute: Q,
lifecyclesToEvents: nt, lifecyclesToEvents: nt,
observedAttributes: rt, observedAttributes: rt,
on: _, on: _,
queue: dt,
registerReactivity: Z, registerReactivity: Z,
scope: D, scope: D,
simulateSlots: ht simulateSlots: ht

View File

@ -50,8 +50,7 @@ var d = {
H: globalThis.HTMLElement, H: globalThis.HTMLElement,
S: globalThis.SVGElement, S: globalThis.SVGElement,
M: globalThis.MutationObserver, M: globalThis.MutationObserver,
qa: (t) => t, q: (t) => t || Promise.resolve()
qw: () => Promise.resolve()
}; };
function pt(t, e, n) { function pt(t, e, n) {
if (Reflect.set(t, e, n), !!A(n)) { if (Reflect.set(t, e, n), !!A(n)) {
@ -65,7 +64,7 @@ var O = "__dde_lifecyclesToEvents", _ = "dde:connected", S = "dde:disconnected",
// src/dom.js // src/dom.js
function Mt(t) { function Mt(t) {
return d.qa(t); return d.q(t);
} }
var y = [{ var y = [{
get scope() { get scope() {
@ -465,7 +464,7 @@ E.on = function t(e, n, r = {}) {
let { signal: o } = r; let { signal: o } = r;
if (!(o && o.aborted)) { if (!(o && o.aborted)) {
if (Array.isArray(e)) return e.forEach((c) => t(c, n, r)); if (Array.isArray(e)) return e.forEach((c) => t(c, n, r));
K(e, n), o && o.addEventListener("abort", () => R(e, n)); Q(e, n), o && o.addEventListener("abort", () => R(e, n));
} }
}; };
E.symbols = { E.symbols = {
@ -506,7 +505,7 @@ E.el = function(t, e) {
k.remove(); k.remove();
m.remove(), n.isConnected && yt(c.host()); m.remove(), n.isConnected && yt(c.host());
}; };
return K(t, a), ut(t, a, n, e), a(t()), o; return Q(t, a), ut(t, a, n, e), a(t()), o;
}; };
function yt(t) { function yt(t) {
!t || !t[D] || (requestIdleCallback || setTimeout)(function() { !t || !t[D] || (requestIdleCallback || setTimeout)(function() {
@ -520,7 +519,7 @@ var At = {
}; };
function Ot(t) { function Ot(t) {
return function(e, n) { return function(e, n) {
let r = (...c) => c.length ? e.setAttribute(n, ...c) : V(r), o = ft(r, e.getAttribute(n), At); let r = (...c) => c.length ? e.setAttribute(n, ...c) : K(r), o = ft(r, e.getAttribute(n), At);
return t[n] = o, o; return t[n] = o, o;
}; };
} }
@ -547,7 +546,7 @@ var st = {
return R(n, o); return R(n, o);
r(e, c); r(e, c);
}; };
return K(n, o), ut(n, o, t, e), n(); return Q(n, o), ut(n, o, t, e), n();
} }
}; };
function ut(t, e, ...n) { function ut(t, e, ...n) {
@ -565,14 +564,14 @@ function ut(t, e, ...n) {
}); });
} }
function it(t, e, n) { function it(t, e, n) {
let r = t ? () => V(r) : (...o) => o.length ? at(r, ...o) : V(r); let r = t ? () => K(r) : (...o) => o.length ? at(r, ...o) : K(r);
return ft(r, e, n, t); return ft(r, e, n, t);
} }
var St = Object.assign(/* @__PURE__ */ Object.create(null), { var St = Object.assign(/* @__PURE__ */ Object.create(null), {
stopPropagation() { stopPropagation() {
this.skip = !0; this.skip = !0;
} }
}), Q = class extends Error { }), V = class extends Error {
constructor() { constructor() {
super(); super();
let [e, ...n] = this.stack.split(` let [e, ...n] = this.stack.split(`
@ -593,7 +592,7 @@ function ft(t, e, n, r = !1) {
onclear: o, onclear: o,
host: u, host: u,
listeners: /* @__PURE__ */ new Set(), listeners: /* @__PURE__ */ new Set(),
defined: new Q().stack, defined: new V().stack,
readonly: r readonly: r
}, },
enumerable: !1, enumerable: !1,
@ -604,7 +603,7 @@ function ft(t, e, n, r = !1) {
function Ct() { function Ct() {
return z[z.length - 1]; return z[z.length - 1];
} }
function V(t) { function K(t) {
if (!t[p]) return; if (!t[p]) return;
let { value: e, listeners: n } = t[p], r = Ct(); let { value: e, listeners: n } = t[p], r = Ct();
return r && n.add(r), g.has(r) && g.get(r).add(t), e; return r && n.add(r), g.has(r) && g.get(r).add(t), e;
@ -615,7 +614,7 @@ function at(t, e, n) {
if (!(!n && r.value === e)) if (!(!n && r.value === e))
return r.value = e, r.listeners.forEach((o) => o(e)), e; return r.value = e, r.listeners.forEach((o) => o(e)), e;
} }
function K(t, e) { function Q(t, e) {
if (t[p]) if (t[p])
return t[p].listeners.add(e); return t[p].listeners.add(e);
} }
@ -638,7 +637,6 @@ export {
E as S, E as S,
q as assign, q as assign,
nt as assignAttribute, nt as assignAttribute,
Mt as asyncQueueAdd,
lt as chainableAppend, lt as chainableAppend,
ht as classListDeclarative, ht as classListDeclarative,
M as createElement, M as createElement,
@ -653,6 +651,7 @@ export {
xt as lifecyclesToEvents, xt as lifecyclesToEvents,
wt as observedAttributes, wt as observedAttributes,
w as on, w as on,
Mt as queue,
H as registerReactivity, H as registerReactivity,
x as scope, x as scope,
E as signal, E as signal,

29
dist/esm.js vendored
View File

@ -38,17 +38,16 @@ function G(t) {
// src/dom-common.js // src/dom-common.js
var f = { var f = {
setDeleteAttr: Q, setDeleteAttr: V,
ssr: "", ssr: "",
D: globalThis.document, D: globalThis.document,
F: globalThis.DocumentFragment, F: globalThis.DocumentFragment,
H: globalThis.HTMLElement, H: globalThis.HTMLElement,
S: globalThis.SVGElement, S: globalThis.SVGElement,
M: globalThis.MutationObserver, M: globalThis.MutationObserver,
qa: (t) => t, q: (t) => t || Promise.resolve()
qw: () => Promise.resolve()
}; };
function Q(t, e, n) { function V(t, e, n) {
if (Reflect.set(t, e, n), !!x(n)) { if (Reflect.set(t, e, n), !!x(n)) {
if (Reflect.deleteProperty(t, e), t instanceof f.H && t.getAttribute(e) === "undefined") if (Reflect.deleteProperty(t, e), t instanceof f.H && t.getAttribute(e) === "undefined")
return t.removeAttribute(e); return t.removeAttribute(e);
@ -60,7 +59,7 @@ var w = "__dde_lifecyclesToEvents", v = "dde:connected", m = "dde:disconnected",
// src/dom.js // src/dom.js
function dt(t) { function dt(t) {
return f.qa(t); return f.q(t);
} }
var g = [{ var g = [{
get scope() { get scope() {
@ -96,7 +95,7 @@ var g = [{
function q(...t) { function q(...t) {
return this.appendOriginal(...t), this; return this.appendOriginal(...t), this;
} }
function V(t) { function J(t) {
return t.append === q || (t.appendOriginal = t.append, t.append = q), t; return t.append === q || (t.appendOriginal = t.append, t.append = q), t;
} }
var T; var T;
@ -129,7 +128,7 @@ function P(t, e, ...n) {
case !c: case !c:
c = R.call(this, f.D.createElement(t), e); c = R.call(this, f.D.createElement(t), e);
} }
return V(c), a || (a = c), n.forEach((d) => d(a)), o && D.pop(), o = 2, c; return J(c), a || (a = c), n.forEach((d) => d(a)), o && D.pop(), o = 2, c;
} }
P.mark = function(t, e = !1) { P.mark = function(t, e = !1) {
t = Object.entries(t).map(([o, c]) => o + `="${c}"`).join(" "); t = Object.entries(t).map(([o, c]) => o + `="${c}"`).join(" ");
@ -154,7 +153,7 @@ function ht(t, e = t) {
for (let p of d) { for (let p of d) {
let b = (p.slot || "") + n; let b = (p.slot || "") + n;
try { try {
K(p, "remove", "slot"); Q(p, "remove", "slot");
} catch { } catch {
} }
let h = o[b]; let h = o[b];
@ -203,7 +202,7 @@ function U(t, e, n) {
case "ariaset": case "ariaset":
return M(o, n, (d, p) => r("aria-" + d, p)); return M(o, n, (d, p) => r("aria-" + d, p));
case "classList": case "classList":
return J.call(c, t, n); return K.call(c, t, n);
} }
return X(t, e) ? $(t, e, n) : r(e, n); return X(t, e) ? $(t, e, n) : r(e, n);
} }
@ -212,7 +211,7 @@ function H(t, e) {
let r = (t instanceof f.S ? tt : Y).bind(null, t, "Attribute"), o = S(e); let r = (t instanceof f.S ? tt : Y).bind(null, t, "Attribute"), o = S(e);
return { setRemoveAttr: r, s: o }; return { setRemoveAttr: r, s: o };
} }
function J(t, e) { function K(t, e) {
let n = S(this); let n = S(this);
return M( return M(
n, n,
@ -220,7 +219,7 @@ function J(t, e) {
(r, o) => t.classList.toggle(r, o === -1 ? void 0 : !!o) (r, o) => t.classList.toggle(r, o === -1 ? void 0 : !!o)
), t; ), t;
} }
function K(t, e, n, r) { function Q(t, e, n, r) {
return t instanceof f.H ? t[e + "Attribute"](n, r) : t[e + "AttributeNS"](null, n, r); return t instanceof f.H ? t[e + "Attribute"](n, r) : t[e + "AttributeNS"](null, n, r);
} }
function X(t, e) { function X(t, e) {
@ -428,9 +427,8 @@ _.attributeChanged = function(t, e) {
export { export {
R as assign, R as assign,
U as assignAttribute, U as assignAttribute,
dt as asyncQueueAdd, J as chainableAppend,
V as chainableAppend, K as classListDeclarative,
J as classListDeclarative,
P as createElement, P as createElement,
pt as createElementNS, pt as createElementNS,
mt as customElementRender, mt as customElementRender,
@ -438,10 +436,11 @@ export {
Ot as dispatchEvent, Ot as dispatchEvent,
P as el, P as el,
pt as elNS, pt as elNS,
K as elementAttribute, Q as elementAttribute,
nt as lifecyclesToEvents, nt as lifecyclesToEvents,
rt as observedAttributes, rt as observedAttributes,
_ as on, _ as on,
dt as queue,
Z as registerReactivity, Z as registerReactivity,
D as scope, D as scope,
ht as simulateSlots ht as simulateSlots

View File

@ -2,10 +2,12 @@
import { enviroment as env } from './src/dom-common.js'; import { enviroment as env } from './src/dom-common.js';
env.ssr= " ssr"; env.ssr= " ssr";
const wa_store= new Set(); const q_store= new Set();
env.qa= function(promise){ wa_store.add(promise); return promise; }; env.q= function(promise){
env.qw= function(){ return Promise.allSettled(Array.from(wa_store)).then(()=> wa_store.clear()); }; if(promise) return ( q_store.add(promise), promise );
export const asyncQueue= env.ww; return Promise.allSettled(Array.from(q_store)).then(()=> q_store.clear());
};
export const queue= env.q;
const { setDeleteAttr }= env; const { setDeleteAttr }= env;
/** @param {HTMLElement} obj */ /** @param {HTMLElement} obj */

View File

@ -6,8 +6,7 @@ export const enviroment= {
H: globalThis.HTMLElement, H: globalThis.HTMLElement,
S: globalThis.SVGElement, S: globalThis.SVGElement,
M: globalThis.MutationObserver, M: globalThis.MutationObserver,
qa: (p)=> p, q: p=> p || Promise.resolve(),
qw: ()=> Promise.resolve(),
}; };
import { isUndef } from './helpers.js'; import { isUndef } from './helpers.js';
function setDeleteAttr(obj, prop, val){ function setDeleteAttr(obj, prop, val){

View File

@ -1,7 +1,7 @@
import { signals } from "./signals-common.js"; import { signals } from "./signals-common.js";
import { enviroment as env } from './dom-common.js'; import { enviroment as env } from './dom-common.js';
export function asyncQueueAdd(promise){ return env.qa(promise); } export function queue(promise){ return env.q(promise); }
/** @type {{ scope: object, prevent: boolean, host: function }[]} */ /** @type {{ scope: object, prevent: boolean, host: function }[]} */
const scopes= [ { const scopes= [ {
get scope(){ return env.D.body; }, get scope(){ return env.D.body; },