:tap: removed on.attributeChanged and static observedAttributes

This commit is contained in:
jaandrle committed 2025-03-10 10:49:26 +01:00
1 parent e1f321004d
commit 15dc342ae8
27 files changed
+33 -210

No files matched your search

-1
View File
@@ -214,7 +214,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.
+4 -28
View File
@@ -32,8 +32,8 @@ function onAbort(signal2, listener) {
};
}
function observedAttributes(instance, observedAttribute2) {
const { observedAttributes: observedAttributes3 = [] } = instance.constructor;
return observedAttributes3.reduce(function(out, name) {
const { observedAttributes: observedAttributes2 = [] } = instance.constructor;
return observedAttributes2.reduce(function(out, name) {
out[kebabToCamel(name)] = observedAttribute2(instance, name);
return out;
}, {});
@@ -545,7 +545,7 @@ function connectionsChangesObserverConstructor() {
}
// src/customElement.js
function customElementRender(target, render, props = observedAttributes2) {
function customElementRender(target, render, props = {}) {
const custom_element = target.host || target;
scope.push({
scope: custom_element,
@@ -586,9 +586,6 @@ function wrapMethod(obj, method, apply) {
obj[method] = new Proxy(obj[method] || (() => {
}), { apply });
}
function observedAttributes2(instance) {
return observedAttributes(instance, (i, n) => i.getAttribute(n));
}
// src/events.js
function dispatchEvent(name, options, host) {
@@ -642,26 +639,6 @@ on.disconnectedAsAbort = function(host) {
host(on.disconnected(() => a.abort()));
return a.signal;
};
var els_attribute_store = /* @__PURE__ */ new WeakSet();
on.attributeChanged = function(listener, options) {
if (typeof options !== "object")
options = {};
return function registerElement(element) {
element.addEventListener(eva, listener, options);
if (element[keyLTE] || els_attribute_store.has(element))
return element;
if (!enviroment.M) return element;
const observer = new enviroment.M(function(mutations) {
for (const { attributeName, target } of mutations)
target.dispatchEvent(
new CustomEvent(eva, { detail: [attributeName, target.getAttribute(attributeName)] })
);
});
const c = onAbort(options.signal, () => observer.disconnect());
if (c) observer.observe(element, { attributes: true });
return element;
};
};
// src/signals-lib/helpers.js
var mark = "__dde_signal";
@@ -846,7 +823,7 @@ var key_attributes = "__dde_attributes";
signal.observedAttributes = function(element) {
const store = element[key_attributes] = {};
const attrs = observedAttributes(element, observedAttribute(store));
on.attributeChanged(function attributeChangeToSignal({ detail }) {
on(eva, function attributeChangeToSignal({ detail }) {
/*! This maps attributes to signals (`S.observedAttributes`).
Investigate `__dde_attributes` key of the element. */
const [name, value] = detail;
@@ -997,7 +974,6 @@ export {
elementAttribute,
isSignal,
lifecyclesToEvents,
observedAttributes2 as observedAttributes,
on,
queue,
registerReactivity,
-1
View File
@@ -214,7 +214,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.
+4 -4
View File
@@ -1,4 +1,4 @@
var Z=(...t)=>Object.prototype.hasOwnProperty.call(...t);function O(t){return typeof t>"u"}function nt(t){let e=typeof t;return e!=="object"?e:t===null?"null":Object.prototype.toString.call(t)}function S(t,e){return t instanceof e}function rt(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function w(t=null,e={}){return Object.create(t,e)}function m(...t){return Object.assign(...t)}function F(t,e){if(!t||!S(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function I(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return r[vt(o)]=e(t,o),r},{})}function vt(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var P=class extends Error{constructor(){super();let[e,...n]=this.stack.split(`
`),r=e.slice(e.indexOf("@"),e.indexOf(".js:")+4),o=r.includes("src/helpers.js")?"src/":r;this.stack=n.find(c=>!c.includes(o))||e}get compact(){let{stack:e}=this;return e.slice(0,e.indexOf("@")+1)+"\u2026"+e.slice(e.lastIndexOf("/"))}};var j={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function G(t,e=!0){return e?m(j,t):(Object.setPrototypeOf(t,j),t)}function $(t){return rt(t,j)&&t!==j?t:j}var d={setDeleteAttr:mt,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function mt(t,e,n){if(Reflect.set(t,e,n),!!O(n)){if(Reflect.deleteProperty(t,e),S(t,d.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var D="__dde_lifecyclesToEvents",y="dde:connected",R="dde:disconnected",q="dde:attributeChanged";function Bt(t){return d.q(t)}var C=[{get scope(){return d.D.body},host:t=>t?t(d.D.body):d.D.body,prevent:!0}],x={get current(){return C[C.length-1]},get host(){return this.current.host},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...C]},push(t={}){return C.push(m({},this.current,{prevent:!1},t))},pushRoot(){return C.push(C[0])},pop(){if(C.length!==1)return C.pop()}};function ot(...t){return this.appendOriginal(...t),this}function xt(t){return t.append===ot||(t.appendOriginal=t.append,t.append=ot),t}var z;function W(t,e,...n){let r=$(this),o=0,c,s;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let i=(...h)=>h.length?(o===1?n.unshift(...h):h.forEach(v=>v(s)),void 0):s;x.push({scope:t,host:i}),c=t(e||void 0);let l=S(c,d.F);if(c.nodeName==="#comment")break;let E=W.mark({type:"component",name:t.name,host:l?"this":"parentElement"});c.prepend(E),l&&(s=E);break}case t==="#text":c=U.call(this,d.D.createTextNode(""),e);break;case(t==="<>"||!t):c=U.call(this,d.D.createDocumentFragment(),e);break;case!!z:c=U.call(this,d.D.createElementNS(z,t),e);break;case!c:c=U.call(this,d.D.createElement(t),e)}return xt(c),s||(s=c),n.forEach(i=>i(s)),o&&x.pop(),o=2,c}W.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=d.D.createComment(`<dde:mark ${t}${d.ssr}${n}>`);return e&&(r.end=d.D.createComment("</dde:mark>")),r};function Jt(t){let e=this;return function(...r){z=t;let o=W.call(e,...r);return z=void 0,o}}function Zt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,s,i){if(i[0]===e)return c.apply(t,i);for(let l of i){let E=(l.slot||"")+n;try{_t(l,"remove","slot")}catch{}let h=o[E];if(!h)return;h.name.startsWith(r)||(h.childNodes.forEach(v=>v.remove()),h.name=r+E),h.append(l)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var H=new WeakMap,{setDeleteAttr:ct}=d;function U(t,...e){if(!e.length)return t;H.set(t,ut(t,this));for(let[n,r]of Object.entries(m({},...e)))it.call(this,t,n,r);return H.delete(t),t}function it(t,e,n){let{setRemoveAttr:r,s:o}=ut(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(i,l)=>it.call(c,t,i,l));let[s]=e;if(s==="=")return r(e.slice(1),n);if(s===".")return st(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return ct(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return V(o,e,t,n,st.bind(null,t[e]));case"ariaset":return V(o,e,t,n,(i,l)=>r("aria-"+i,l));case"classList":return Et.call(c,t,n)}return St(t,e)?ct(t,e,n):r(e,n)}function ut(t,e){if(H.has(t))return H.get(t);let r=(S(t,d.S)?At:wt).bind(null,t,"Attribute"),o=$(e);return{setRemoveAttr:r,s:o}}function Et(t,e){let n=$(this);return V(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function _t(t,e,n,r){return S(t,d.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function St(t,e){if(!(e in t))return!1;let n=ft(t,e);return!O(n.set)}function ft(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||ft(t,e)}function V(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([i,l]){i&&(i=new c(i),i.target=e,l=t.processReactiveAttribute(n,i,l,o),o(i,l))})}function wt(t,e,n,r){return t[(O(r)?"remove":"set")+e](n,r)}function At(t,e,n,r,o=null){return t[(O(r)?"remove":"set")+e+"NS"](o,n,r)}function st(t,e,n){if(Reflect.set(t,e,n),!!O(n))return Reflect.deleteProperty(t,e)}var L=d.M?yt():new Proxy({},{get(){return()=>{}}});function yt(){let t=new Map,e=!1,n=u=>function(a){for(let f of a)if(f.type==="childList"){if(h(f.addedNodes,!0)){u();continue}v(f.removedNodes,!0)&&u()}},r=new d.M(n(i));return{observe(u){let a=new d.M(n(()=>{}));return a.observe(u,{childList Line truncated
Investigate `__dde_attributes` key of the element. */let[c,s]=o,i=this[Y][c];if(i)return g.action(i,"_set",s)})(t),A.disconnected(function(){/*! This removes all signals mapped to attributes (`S.observedAttributes`).
Investigate `__dde_attributes` key of the element. */g.clear(...Object.values(this[Y]))})(t),n};var pt={isSignal:B,processReactiveAttribute(t,e,n,r){if(!B(n))return n;let o=c=>{if(!t.isConnected)return M(n,o);r(e,c)};return et(n,o),ht(n,o,t,e),n.get()}};function ht(t,e,...n){let{current:r}=x;r.host(function(o){if(o[k])return o[k].push([[t,e],...n]);o[k]=[],!r.prevent&&A.disconnected(()=>o[k].forEach(([[c,s]])=>M(c,s,c[p]&&c[p].host&&c[p].host()===o)))(o)})}var Tt=new FinalizationRegistry(function(t){g.clear({[p]:t})});function dt(t,e,n){let r=w(t?Rt:tt),o=gt(r,e,n,t);return Tt.register(o,o[p]),o}var Pt=m(w(),{stopPropagation(){this.skip=!0}});function gt(t,e,n,r=!1){let o=[];nt(n)!=="[object Object]"&&(n={});let{onclear:c}=g.symbols;n[c]&&(o.push(n[c]),delete n[c]);let{host:s}=x;return Reflect.defineProperty(t,p,{value:m(w(Pt),{value:e,actions:n,onclear:o,host:s,listeners:new Set,defined:new P().stack,readonly:r}),enumerable:!1,writable:!1,configurable:!0}),t}function jt(){return J[J.length-1]}function lt(t){if(!t[p])return;let{value:e,listeners:n}=t[p],r=jt();return r&&n.add(r),b.has(r)&&b.get(r).add(t),e}function bt(t,e,n){let r=t[p];if(!(!r||!n&&r.value===e))return r.value=e,X(t),e}function et(t,e){if(t[p])return t[p].listeners.add(e)}function M(t,e,n){let r=t[p];if(!r)return;let{listeners:o}=r,c=o.delete(e);if(!c||!n||o.size)return c;g.clear(t);let s=b.get(r);if(!s)return c;let i=b.get(s);if(!i)return c;for(let l of i)M(l,s,!0);return c}G(pt);export{g as S,U as assign,it as assignAttribute,xt as chainableAppend,Et as classListDeclarative,W as createElement,Jt as createElementNS,ee as customElementRender,Ct as customElementWithDDE,se as dispatchEvent,W as el,Jt as elNS,_t as elementAttribute,B as isSignal,Ct as lifecyclesToEvents,Ot as observedAttributes,A as on,Bt as queue,G as registerReactivity,x as scope,g as signal,Zt as simulateSlots};
var B=(...t)=>Object.prototype.hasOwnProperty.call(...t);function O(t){return typeof t>"u"}function et(t){let e=typeof t;return e!=="object"?e:t===null?"null":Object.prototype.toString.call(t)}function S(t,e){return t instanceof e}function nt(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function w(t=null,e={}){return Object.create(t,e)}function b(...t){return Object.assign(...t)}function J(t,e){if(!t||!S(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function rt(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return r[vt(o)]=e(t,o),r},{})}function vt(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var P=class extends Error{constructor(){super();let[e,...n]=this.stack.split(`
`),r=e.slice(e.indexOf("@"),e.indexOf(".js:")+4),o=r.includes("src/helpers.js")?"src/":r;this.stack=n.find(c=>!c.includes(o))||e}get compact(){let{stack:e}=this;return e.slice(0,e.indexOf("@")+1)+"\u2026"+e.slice(e.lastIndexOf("/"))}};var q={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function Z(t,e=!0){return e?b(q,t):(Object.setPrototypeOf(t,q),t)}function W(t){return nt(t,q)&&t!==q?t:q}var d={setDeleteAttr:bt,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function bt(t,e,n){if(Reflect.set(t,e,n),!!O(n)){if(Reflect.deleteProperty(t,e),S(t,d.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var N="__dde_lifecyclesToEvents",y="dde:connected",D="dde:disconnected",F="dde:attributeChanged";function zt(t){return d.q(t)}var C=[{get scope(){return d.D.body},host:t=>t?t(d.D.body):d.D.body,prevent:!0}],x={get current(){return C[C.length-1]},get host(){return this.current.host},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...C]},push(t={}){return C.push(b({},this.current,{prevent:!1},t))},pushRoot(){return C.push(C[0])},pop(){if(C.length!==1)return C.pop()}};function ot(...t){return this.appendOriginal(...t),this}function xt(t){return t.append===ot||(t.appendOriginal=t.append,t.append=ot),t}var $;function j(t,e,...n){let r=W(this),o=0,c,s;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let i=(...h)=>h.length?(o===1?n.unshift(...h):h.forEach(v=>v(s)),void 0):s;x.push({scope:t,host:i}),c=t(e||void 0);let p=S(c,d.F);if(c.nodeName==="#comment")break;let E=j.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(E),p&&(s=E);break}case t==="#text":c=I.call(this,d.D.createTextNode(""),e);break;case(t==="<>"||!t):c=I.call(this,d.D.createDocumentFragment(),e);break;case!!$:c=I.call(this,d.D.createElementNS($,t),e);break;case!c:c=I.call(this,d.D.createElement(t),e)}return xt(c),s||(s=c),n.forEach(i=>i(s)),o&&x.pop(),o=2,c}j.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=d.D.createComment(`<dde:mark ${t}${d.ssr}${n}>`);return e&&(r.end=d.D.createComment("</dde:mark>")),r};function Ht(t){let e=this;return function(...r){$=t;let o=j.call(e,...r);return $=void 0,o}}function Bt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,s,i){if(i[0]===e)return c.apply(t,i);for(let p of i){let E=(p.slot||"")+n;try{_t(p,"remove","slot")}catch{}let h=o[E];if(!h)return;h.name.startsWith(r)||(h.childNodes.forEach(v=>v.remove()),h.name=r+E),h.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var U=new WeakMap,{setDeleteAttr:ct}=d;function I(t,...e){if(!e.length)return t;U.set(t,ut(t,this));for(let[n,r]of Object.entries(b({},...e)))it.call(this,t,n,r);return U.delete(t),t}function it(t,e,n){let{setRemoveAttr:r,s:o}=ut(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(i,p)=>it.call(c,t,i,p));let[s]=e;if(s==="=")return r(e.slice(1),n);if(s===".")return st(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return ct(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return G(o,e,t,n,st.bind(null,t[e]));case"ariaset":return G(o,e,t,n,(i,p)=>r("aria-"+i,p));case"classList":return Et.call(c,t,n)}return St(t,e)?ct(t,e,n):r(e,n)}function ut(t,e){if(U.has(t))return U.get(t);let r=(S(t,d.S)?At:wt).bind(null,t,"Attribute"),o=W(e);return{setRemoveAttr:r,s:o}}function Et(t,e){let n=W(this);return G(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function _t(t,e,n,r){return S(t,d.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function St(t,e){if(!(e in t))return!1;let n=ft(t,e);return!O(n.set)}function ft(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||ft(t,e)}function G(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([i,p]){i&&(i=new c(i),i.target=e,p=t.processReactiveAttribute(n,i,p,o),o(i,p))})}function wt(t,e,n,r){return t[(O(r)?"remove":"set")+e](n,r)}function At(t,e,n,r,o=null){return t[(O(r)?"remove":"set")+e+"NS"](o,n,r)}function st(t,e,n){if(Reflect.set(t,e,n),!!O(n))return Reflect.deleteProperty(t,e)}var R=d.M?yt():new Proxy({},{get(){return()=>{}}});function yt(){let t=new Map,e=!1,n=u=>function(a){for(let f of a)if(f.type==="childList"){if(h(f.addedNodes,!0)){u();continue}v(f.removedNodes,!0)&&u()}},r=new d.M(n(i));return{observe(u){let a=new d.M(n(()=>{}));return a.observe(u,{childList Line truncated
Investigate `__dde_attributes` key of the element. */let[c,s]=o,i=this[X][c];if(i)return g.action(i,"_set",s)})(t),A.disconnected(function(){/*! This removes all signals mapped to attributes (`S.observedAttributes`).
Investigate `__dde_attributes` key of the element. */g.clear(...Object.values(this[X]))})(t),n};var pt={isSignal:z,processReactiveAttribute(t,e,n,r){if(!z(n))return n;let o=c=>{if(!t.isConnected)return k(n,o);r(e,c)};return tt(n,o),ht(n,o,t,e),n.get()}};function ht(t,e,...n){let{current:r}=x;r.host(function(o){if(o[L])return o[L].push([[t,e],...n]);o[L]=[],!r.prevent&&A.disconnected(()=>o[L].forEach(([[c,s]])=>k(c,s,c[l]&&c[l].host&&c[l].host()===o)))(o)})}var Nt=new FinalizationRegistry(function(t){g.clear({[l]:t})});function dt(t,e,n){let r=w(t?Ot:Y),o=gt(r,e,n,t);return Nt.register(o,o[l]),o}var Tt=b(w(),{stopPropagation(){this.skip=!0}});function gt(t,e,n,r=!1){let o=[];et(n)!=="[object Object]"&&(n={});let{onclear:c}=g.symbols;n[c]&&(o.push(n[c]),delete n[c]);let{host:s}=x;return Reflect.defineProperty(t,l,{value:b(w(Tt),{value:e,actions:n,onclear:o,host:s,listeners:new Set,defined:new P().stack,readonly:r}),enumerable:!1,writable:!1,configurable:!0}),t}function Mt(){return H[H.length-1]}function lt(t){if(!t[l])return;let{value:e,listeners:n}=t[l],r=Mt();return r&&n.add(r),m.has(r)&&m.get(r).add(t),e}function mt(t,e,n){let r=t[l];if(!(!r||!n&&r.value===e))return r.value=e,Q(t),e}function tt(t,e){if(t[l])return t[l].listeners.add(e)}function k(t,e,n){let r=t[l];if(!r)return;let{listeners:o}=r,c=o.delete(e);if(!c||!n||o.size)return c;g.clear(t);let s=m.get(r);if(!s)return c;let i=m.get(s);if(!i)return c;for(let p of i)k(p,s,!0);return c}Z(pt);export{g as S,I as assign,it as assignAttribute,xt as chainableAppend,Et as classListDeclarative,j as createElement,Ht as createElementNS,Yt as customElementRender,Ct as customElementWithDDE,ce as dispatchEvent,j as el,Ht as elNS,_t as elementAttribute,z as isSignal,Ct as lifecyclesToEvents,A as on,zt as queue,Z as registerReactivity,x as scope,g as signal,Bt as simulateSlots};
-1
View File
@@ -213,7 +213,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.
Vendored
+1 -35
View File
@@ -21,16 +21,6 @@ function onAbort(signal, listener) {
signal.removeEventListener("abort", listener);
};
}
function observedAttributes(instance, observedAttribute) {
const { observedAttributes: observedAttributes3 = [] } = instance.constructor;
return observedAttributes3.reduce(function(out, name) {
out[kebabToCamel(name)] = observedAttribute(instance, name);
return out;
}, {});
}
function kebabToCamel(name) {
return name.replace(/-./g, (x) => x[1].toUpperCase());
}
// src/signals-lib/common.js
var signals_global = {
@@ -522,7 +512,7 @@ function connectionsChangesObserverConstructor() {
}
// src/customElement.js
function customElementRender(target, render, props = observedAttributes2) {
function customElementRender(target, render, props = {}) {
const custom_element = target.host || target;
scope.push({
scope: custom_element,
@@ -563,9 +553,6 @@ function wrapMethod(obj, method, apply) {
obj[method] = new Proxy(obj[method] || (() => {
}), { apply });
}
function observedAttributes2(instance) {
return observedAttributes(instance, (i, n) => i.getAttribute(n));
}
// src/events.js
function dispatchEvent(name, options, host) {
@@ -619,26 +606,6 @@ on.disconnectedAsAbort = function(host) {
host(on.disconnected(() => a.abort()));
return a.signal;
};
var els_attribute_store = /* @__PURE__ */ new WeakSet();
on.attributeChanged = function(listener, options) {
if (typeof options !== "object")
options = {};
return function registerElement(element) {
element.addEventListener(eva, listener, options);
if (element[keyLTE] || els_attribute_store.has(element))
return element;
if (!enviroment.M) return element;
const observer = new enviroment.M(function(mutations) {
for (const { attributeName, target } of mutations)
target.dispatchEvent(
new CustomEvent(eva, { detail: [attributeName, target.getAttribute(attributeName)] })
);
});
const c = onAbort(options.signal, () => observer.disconnect());
if (c) observer.observe(element, { attributes: true });
return element;
};
};
export {
assign,
assignAttribute,
@@ -653,7 +620,6 @@ export {
createElementNS as elNS,
elementAttribute,
lifecyclesToEvents,
observedAttributes2 as observedAttributes,
on,
queue,
registerReactivity,
-1
View File
@@ -213,7 +213,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.
+1 -1
View File
@@ -1 +1 @@
function w(t){return typeof t>"u"}function b(t,e){return t instanceof e}function F(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function v(...t){return Object.assign(...t)}function R(t,e){if(!t||!b(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function I(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return r[J(o)]=e(t,o),r},{})}function J(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var O={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function K(t,e=!0){return e?v(O,t):(Object.setPrototypeOf(t,O),t)}function T(t){return F(t,O)&&t!==O?t:O}var a={setDeleteAttr:Q,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function Q(t,e,n){if(Reflect.set(t,e,n),!!w(n)){if(Reflect.deleteProperty(t,e),b(t,a.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var A="__dde_lifecyclesToEvents",m="dde:connected",_="dde:disconnected",D="dde:attributeChanged";function gt(t){return a.q(t)}var x=[{get scope(){return a.D.body},host:t=>t?t(a.D.body):a.D.body,prevent:!0}],S={get current(){return x[x.length-1]},get host(){return this.current.host},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...x]},push(t={}){return x.push(v({},this.current,{prevent:!1},t))},pushRoot(){return x.push(x[0])},pop(){if(x.length!==1)return x.pop()}};function $(...t){return this.appendOriginal(...t),this}function X(t){return t.append===$||(t.appendOriginal=t.append,t.append=$),t}var P;function k(t,e,...n){let r=T(this),o=0,c,d;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let f=(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(E=>E(d)),void 0):d;S.push({scope:t,host:f}),c=t(e||void 0);let p=b(c,a.F);if(c.nodeName==="#comment")break;let g=k.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(g),p&&(d=g);break}case t==="#text":c=N.call(this,a.D.createTextNode(""),e);break;case(t==="<>"||!t):c=N.call(this,a.D.createDocumentFragment(),e);break;case!!P:c=N.call(this,a.D.createElementNS(P,t),e);break;case!c:c=N.call(this,a.D.createElement(t),e)}return X(c),d||(d=c),n.forEach(f=>f(d)),o&&S.pop(),o=2,c}k.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=a.D.createComment(`<dde:mark ${t}${a.ssr}${n}>`);return e&&(r.end=a.D.createComment("</dde:mark>")),r};function vt(t){let e=this;return function(...r){P=t;let o=k.call(e,...r);return P=void 0,o}}function mt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,d,f){if(f[0]===e)return c.apply(t,f);for(let p of f){let g=(p.slot||"")+n;try{tt(p,"remove","slot")}catch{}let l=o[g];if(!l)return;l.name.startsWith(r)||(l.childNodes.forEach(E=>E.remove()),l.name=r+g),l.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var M=new WeakMap,{setDeleteAttr:U}=a;function N(t,...e){if(!e.length)return t;M.set(t,B(t,this));for(let[n,r]of Object.entries(v({},...e)))z.call(this,t,n,r);return M.delete(t),t}function z(t,e,n){let{setRemoveAttr:r,s:o}=B(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(f,p)=>z.call(c,t,f,p));let[d]=e;if(d==="=")return r(e.slice(1),n);if(d===".")return H(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return U(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return j(o,e,t,n,H.bind(null,t[e]));case"ariaset":return j(o,e,t,n,(f,p)=>r("aria-"+f,p));case"classList":return Y.call(c,t,n)}return et(t,e)?U(t,e,n):r(e,n)}function B(t,e){if(M.has(t))return M.get(t);let r=(b(t,a.S)?rt:nt).bind(null,t,"Attribute"),o=T(e);return{setRemoveAttr:r,s:o}}function Y(t,e){let n=T(this);return j(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function tt(t,e,n,r){return b(t,a.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function et(t,e){if(!(e in t))return!1;let n=Z(t,e);return!w(n.set)}function Z(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||Z(t,e)}function j(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([f,p]){f&&(f=new c(f),f.target=e,p=t.processReactiveAttribute(n,f,p,o),o(f,p))})}function nt(t,e,n,r){return t[(w(r)?"remove":"set")+e](n,r)}function rt(t,e,n,r,o=null){return t[(w(r)?"remove":"set")+e+"NS"](o,n,r)}function H(t,e,n){if(Reflect.set(t,e,n),!!w(n))return Reflect.deleteProperty(t,e)}var C=a.M?ot():new Proxy({},{get(){return()=>{}}}Line truncated
function w(t){return typeof t>"u"}function g(t,e){return t instanceof e}function W(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function v(...t){return Object.assign(...t)}function P(t,e){if(!t||!g(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}var C={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function V(t,e=!0){return e?v(C,t):(Object.setPrototypeOf(t,C),t)}function S(t){return W(t,C)&&t!==C?t:C}var a={setDeleteAttr:J,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function J(t,e,n){if(Reflect.set(t,e,n),!!w(n)){if(Reflect.deleteProperty(t,e),g(t,a.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var O="__dde_lifecyclesToEvents",m="dde:connected",_="dde:disconnected",F="dde:attributeChanged";function pt(t){return a.q(t)}var x=[{get scope(){return a.D.body},host:t=>t?t(a.D.body):a.D.body,prevent:!0}],D={get current(){return x[x.length-1]},get host(){return this.current.host},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...x]},push(t={}){return x.push(v({},this.current,{prevent:!1},t))},pushRoot(){return x.push(x[0])},pop(){if(x.length!==1)return x.pop()}};function I(...t){return this.appendOriginal(...t),this}function K(t){return t.append===I||(t.appendOriginal=t.append,t.append=I),t}var R;function j(t,e,...n){let r=S(this),o=0,c,d;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let f=(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(E=>E(d)),void 0):d;D.push({scope:t,host:f}),c=t(e||void 0);let p=g(c,a.F);if(c.nodeName==="#comment")break;let b=j.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(b),p&&(d=b);break}case t==="#text":c=L.call(this,a.D.createTextNode(""),e);break;case(t==="<>"||!t):c=L.call(this,a.D.createDocumentFragment(),e);break;case!!R:c=L.call(this,a.D.createElementNS(R,t),e);break;case!c:c=L.call(this,a.D.createElement(t),e)}return K(c),d||(d=c),n.forEach(f=>f(d)),o&&D.pop(),o=2,c}j.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=a.D.createComment(`<dde:mark ${t}${a.ssr}${n}>`);return e&&(r.end=a.D.createComment("</dde:mark>")),r};function lt(t){let e=this;return function(...r){R=t;let o=j.call(e,...r);return R=void 0,o}}function ht(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,d,f){if(f[0]===e)return c.apply(t,f);for(let p of f){let b=(p.slot||"")+n;try{X(p,"remove","slot")}catch{}let l=o[b];if(!l)return;l.name.startsWith(r)||(l.childNodes.forEach(E=>E.remove()),l.name=r+b),l.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var T=new WeakMap,{setDeleteAttr:$}=a;function L(t,...e){if(!e.length)return t;T.set(t,z(t,this));for(let[n,r]of Object.entries(v({},...e)))H.call(this,t,n,r);return T.delete(t),t}function H(t,e,n){let{setRemoveAttr:r,s:o}=z(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(f,p)=>H.call(c,t,f,p));let[d]=e;if(d==="=")return r(e.slice(1),n);if(d===".")return U(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return $(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return M(o,e,t,n,U.bind(null,t[e]));case"ariaset":return M(o,e,t,n,(f,p)=>r("aria-"+f,p));case"classList":return Q.call(c,t,n)}return Y(t,e)?$(t,e,n):r(e,n)}function z(t,e){if(T.has(t))return T.get(t);let r=(g(t,a.S)?et:tt).bind(null,t,"Attribute"),o=S(e);return{setRemoveAttr:r,s:o}}function Q(t,e){let n=S(this);return M(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function X(t,e,n,r){return g(t,a.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function Y(t,e){if(!(e in t))return!1;let n=B(t,e);return!w(n.set)}function B(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||B(t,e)}function M(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([f,p]){f&&(f=new c(f),f.target=e,p=t.processReactiveAttribute(n,f,p,o),o(f,p))})}function tt(t,e,n,r){return t[(w(r)?"remove":"set")+e](n,r)}function et(t,e,n,r,o=null){return t[(w(r)?"remove":"set")+e+"NS"](o,n,r)}function U(t,e,n){if(Reflect.set(t,e,n),!!w(n))return Reflect.deleteProperty(t,e)}var A=a.M?nt():new Proxy({},{get(){return()=>{}}});function nt(){let t=new Map,e=!1,n=s=>function(u){for(let i of u)if(i.type==="childList"){if(l(i.addedNodes,!0)){s();continue}E(i.removedNodes,!0)&&s()}},r=new a.M(n(f));return{obsLine truncated
-1
View File
@@ -214,7 +214,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.
+4 -28
View File
@@ -35,7 +35,6 @@ var DDE = (() => {
elementAttribute: () => elementAttribute,
isSignal: () => isSignal,
lifecyclesToEvents: () => lifecyclesToEvents,
observedAttributes: () => observedAttributes2,
on: () => on,
queue: () => queue,
registerReactivity: () => registerReactivity,
@@ -78,8 +77,8 @@ var DDE = (() => {
};
}
function observedAttributes(instance, observedAttribute2) {
const { observedAttributes: observedAttributes3 = [] } = instance.constructor;
return observedAttributes3.reduce(function(out, name) {
const { observedAttributes: observedAttributes2 = [] } = instance.constructor;
return observedAttributes2.reduce(function(out, name) {
out[kebabToCamel(name)] = observedAttribute2(instance, name);
return out;
}, {});
@@ -591,7 +590,7 @@ var DDE = (() => {
}
// src/customElement.js
function customElementRender(target, render, props = observedAttributes2) {
function customElementRender(target, render, props = {}) {
const custom_element = target.host || target;
scope.push({
scope: custom_element,
@@ -632,9 +631,6 @@ var DDE = (() => {
obj[method] = new Proxy(obj[method] || (() => {
}), { apply });
}
function observedAttributes2(instance) {
return observedAttributes(instance, (i, n) => i.getAttribute(n));
}
// src/events.js
function dispatchEvent(name, options, host) {
@@ -688,26 +684,6 @@ var DDE = (() => {
host(on.disconnected(() => a.abort()));
return a.signal;
};
var els_attribute_store = /* @__PURE__ */ new WeakSet();
on.attributeChanged = function(listener, options) {
if (typeof options !== "object")
options = {};
return function registerElement(element) {
element.addEventListener(eva, listener, options);
if (element[keyLTE] || els_attribute_store.has(element))
return element;
if (!enviroment.M) return element;
const observer = new enviroment.M(function(mutations) {
for (const { attributeName, target } of mutations)
target.dispatchEvent(
new CustomEvent(eva, { detail: [attributeName, target.getAttribute(attributeName)] })
);
});
const c = onAbort(options.signal, () => observer.disconnect());
if (c) observer.observe(element, { attributes: true });
return element;
};
};
// src/signals-lib/helpers.js
var mark = "__dde_signal";
@@ -892,7 +868,7 @@ var DDE = (() => {
signal.observedAttributes = function(element) {
const store = element[key_attributes] = {};
const attrs = observedAttributes(element, observedAttribute(store));
on.attributeChanged(function attributeChangeToSignal({ detail }) {
on(eva, function attributeChangeToSignal({ detail }) {
/*! This maps attributes to signals (`S.observedAttributes`).
Investigate `__dde_attributes` key of the element. */
const [name, value] = detail;
-1
View File
@@ -214,7 +214,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.
+4 -4
View File
@@ -1,4 +1,4 @@
var DDE=(()=>{var G=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var yt=Object.prototype.hasOwnProperty;var Ct=(t,e)=>{for(var n in e)G(t,n,{get:e[n],enumerable:!0})},Ot=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of At(e))!yt.call(t,o)&&o!==n&&G(t,o,{get:()=>e[o],enumerable:!(r=wt(e,o))||r.enumerable});return t};var Dt=t=>Ot(G({},"__esModule",{value:!0}),t);var Vt={};Ct(Vt,{S:()=>g,assign:()=>F,assignAttribute:()=>Q,chainableAppend:()=>ft,classListDeclarative:()=>dt,createElement:()=>N,createElementNS:()=>Mt,customElementRender:()=>Wt,customElementWithDDE:()=>ht,dispatchEvent:()=>Ft,el:()=>N,elNS:()=>Mt,elementAttribute:()=>lt,isSignal:()=>I,lifecyclesToEvents:()=>ht,observedAttributes:()=>gt,on:()=>E,queue:()=>kt,registerReactivity:()=>z,scope:()=>b,signal:()=>g,simulateSlots:()=>Nt});var V=(...t)=>Object.prototype.hasOwnProperty.call(...t);function O(t){return typeof t>"u"}function ot(t){let e=typeof t;return e!=="object"?e:t===null?"null":Object.prototype.toString.call(t)}function w(t,e){return t instanceof e}function ct(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function A(t=null,e={}){return Object.create(t,e)}function x(...t){return Object.assign(...t)}function $(t,e){if(!t||!w(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function U(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return r[Rt(o)]=e(t,o),r},{})}function Rt(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var j=class extends Error{constructor(){super();let[e,...n]=this.stack.split(`
`),r=e.slice(e.indexOf("@"),e.indexOf(".js:")+4),o=r.includes("src/helpers.js")?"src/":r;this.stack=n.find(c=>!c.includes(o))||e}get compact(){let{stack:e}=this;return e.slice(0,e.indexOf("@")+1)+"\u2026"+e.slice(e.lastIndexOf("/"))}};var q={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function z(t,e=!0){return e?x(q,t):(Object.setPrototypeOf(t,q),t)}function H(t){return ct(t,q)&&t!==q?t:q}var d={setDeleteAttr:Lt,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function Lt(t,e,n){if(Reflect.set(t,e,n),!!O(n)){if(Reflect.deleteProperty(t,e),w(t,d.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var D="__dde_lifecyclesToEvents",y="dde:connected",R="dde:disconnected",W="dde:attributeChanged";function kt(t){return d.q(t)}var C=[{get scope(){return d.D.body},host:t=>t?t(d.D.body):d.D.body,prevent:!0}],b={get current(){return C[C.length-1]},get host(){return this.current.host},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...C]},push(t={}){return C.push(x({},this.current,{prevent:!1},t))},pushRoot(){return C.push(C[0])},pop(){if(C.length!==1)return C.pop()}};function st(...t){return this.appendOriginal(...t),this}function ft(t){return t.append===st||(t.appendOriginal=t.append,t.append=st),t}var B;function N(t,e,...n){let r=H(this),o=0,c,s;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let i=(...h)=>h.length?(o===1?n.unshift(...h):h.forEach(m=>m(s)),void 0):s;b.push({scope:t,host:i}),c=t(e||void 0);let l=w(c,d.F);if(c.nodeName==="#comment")break;let _=N.mark({type:"component",name:t.name,host:l?"this":"parentElement"});c.prepend(_),l&&(s=_);break}case t==="#text":c=F.call(this,d.D.createTextNode(""),e);break;case(t==="<>"||!t):c=F.call(this,d.D.createDocumentFragment(),e);break;case!!B:c=F.call(this,d.D.createElementNS(B,t),e);break;case!c:c=F.call(this,d.D.createElement(t),e)}return ft(c),s||(s=c),n.forEach(i=>i(s)),o&&b.pop(),o=2,c}N.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=d.D.createComment(`<dde:mark ${t}${d.ssr}${n}>`);return e&&(r.end=d.D.createComment("</dde:mark>")),r};function Mt(t){let e=this;return function(...r){B=t;let o=N.call(e,...r);return B=void 0,o}}function Nt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,s,i){if(i[0]===e)return c.apply(t,i);for(let l of i){let _=(l.slot||"")+n;try{lt(l,"remove","slot")}catch{}let h=o[_];if(!h)return;h.name.startsWith(r)||(h.childNodes.forEach(m=>m.remove()),h.name=r+_),h.append(l)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var J=new WeakMap,{setDeleteAttr:it}=d;function F(t,...e){if(!e.length)return t;J.set(t,at(t,this));for(let[n,r]of Object.entries(x({},...e)))Q.call(this,t,n,r);return J.delete(t),t}function Q(t,e,n){let{setRemoveAttr:r,s:o}=at(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(i,l)=>Q.call(c,t,i,l));let[s]=e;if(s==="=")return r(e.slice(1),n);if(s===".")return ut(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return it(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return K(o,e,t,n,ut.bind(null,t[e]));case"ariaset":return K(o,e,t,n,(i,l)=>r("aria-"+i,l));case"classList":return dt.call(c,t,n)}return Tt(t,e)?it(t,e,n):r(e,n)}function at(t,e){if(J.has(t))return J.get(t);let r=(w(t,d.S)?jt:Pt).bind(null,t,"Attribute"),o=H(e);return{setRemoveAttr:r,s:o}}function dt(t,e){let n=H(this);return K(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function lt(t,e,n,r){return w(t,d.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function Tt(t,e){if(!(e in t))return!1;let n=pt(t,e);return!O(n.set)}function pt(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||pt(t,e)}function K(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([i,l]){i&&(i=new c(i),i.target=e,l=t.processReactiveAttribute(n,i,l,o),o(i,l))})}function Pt(t,e,n,r){return t[(O(r)?"remove":"set")+e](n,r)}function jt(t,e,n,r,o=null){return t[(O(r)?"remove":"set")+e+"NS"](o,n,r)}function ut(t,e,n){if(Reflect.set(t,e,n),!!O(n))return Reflect.deleteProperty(t,e)}var L=d.M?qt():new Proxy({},{get(){return()=>{}}});function qt(){let t=new Map,e=!1,n=u=>function(a){for(let f of a)if(f.type==="childList"){if(h(f.addedNodes,!0)){u();continue}m(f.removedNodes,!0)&&u()}},r=new d.M(n(i));return{observe(u){let a=new d.M(n(()=>{}));return a.observe(u,{childList:!0 Line truncated
Investigate `__dde_attributes` key of the element. */let[c,s]=o,i=this[et][c];if(i)return g.action(i,"_set",s)})(t),E.disconnected(function(){/*! This removes all signals mapped to attributes (`S.observedAttributes`).
Investigate `__dde_attributes` key of the element. */g.clear(...Object.values(this[et]))})(t),n};var xt={isSignal:I,processReactiveAttribute(t,e,n,r){if(!I(n))return n;let o=c=>{if(!t.isConnected)return M(n,o);r(e,c)};return rt(n,o),Et(n,o,t,e),n.get()}};function Et(t,e,...n){let{current:r}=b;r.host(function(o){if(o[k])return o[k].push([[t,e],...n]);o[k]=[],!r.prevent&&E.disconnected(()=>o[k].forEach(([[c,s]])=>M(c,s,c[p]&&c[p].host&&c[p].host()===o)))(o)})}var Jt=new FinalizationRegistry(function(t){g.clear({[p]:t})});function vt(t,e,n){let r=A(t?$t:nt),o=_t(r,e,n,t);return Jt.register(o,o[p]),o}var Zt=x(A(),{stopPropagation(){this.skip=!0}});function _t(t,e,n,r=!1){let o=[];ot(n)!=="[object Object]"&&(n={});let{onclear:c}=g.symbols;n[c]&&(o.push(n[c]),delete n[c]);let{host:s}=b;return Reflect.defineProperty(t,p,{value:x(A(Zt),{value:e,actions:n,onclear:o,host:s,listeners:new Set,defined:new j().stack,readonly:r}),enumerable:!1,writable:!1,configurable:!0}),t}function Gt(){return Z[Z.length-1]}function mt(t){if(!t[p])return;let{value:e,listeners:n}=t[p],r=Gt();return r&&n.add(r),v.has(r)&&v.get(r).add(t),e}function St(t,e,n){let r=t[p];if(!(!r||!n&&r.value===e))return r.value=e,tt(t),e}function rt(t,e){if(t[p])return t[p].listeners.add(e)}function M(t,e,n){let r=t[p];if(!r)return;let{listeners:o}=r,c=o.delete(e);if(!c||!n||o.size)return c;g.clear(t);let s=v.get(r);if(!s)return c;let i=v.get(s);if(!i)return c;for(let l of i)M(l,s,!0);return c}z(xt);return Dt(Vt);})();
var DDE=(()=>{var J=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var At=Object.prototype.hasOwnProperty;var yt=(t,e)=>{for(var n in e)J(t,n,{get:e[n],enumerable:!0})},Ct=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wt(e))!At.call(t,o)&&o!==n&&J(t,o,{get:()=>e[o],enumerable:!(r=St(e,o))||r.enumerable});return t};var Ot=t=>Ct(J({},"__esModule",{value:!0}),t);var Zt={};yt(Zt,{S:()=>g,assign:()=>W,assignAttribute:()=>K,chainableAppend:()=>ft,classListDeclarative:()=>dt,createElement:()=>T,createElementNS:()=>kt,customElementRender:()=>jt,customElementWithDDE:()=>ht,dispatchEvent:()=>Wt,el:()=>T,elNS:()=>kt,elementAttribute:()=>lt,isSignal:()=>F,lifecyclesToEvents:()=>ht,on:()=>A,queue:()=>Lt,registerReactivity:()=>I,scope:()=>m,signal:()=>g,simulateSlots:()=>Nt});var Z=(...t)=>Object.prototype.hasOwnProperty.call(...t);function O(t){return typeof t>"u"}function rt(t){let e=typeof t;return e!=="object"?e:t===null?"null":Object.prototype.toString.call(t)}function S(t,e){return t instanceof e}function ot(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function w(t=null,e={}){return Object.create(t,e)}function x(...t){return Object.assign(...t)}function G(t,e){if(!t||!S(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function ct(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return r[Dt(o)]=e(t,o),r},{})}function Dt(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var q=class extends Error{constructor(){super();let[e,...n]=this.stack.split(`
`),r=e.slice(e.indexOf("@"),e.indexOf(".js:")+4),o=r.includes("src/helpers.js")?"src/":r;this.stack=n.find(c=>!c.includes(o))||e}get compact(){let{stack:e}=this;return e.slice(0,e.indexOf("@")+1)+"\u2026"+e.slice(e.lastIndexOf("/"))}};var j={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function I(t,e=!0){return e?x(j,t):(Object.setPrototypeOf(t,j),t)}function $(t){return ot(t,j)&&t!==j?t:j}var d={setDeleteAttr:Rt,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function Rt(t,e,n){if(Reflect.set(t,e,n),!!O(n)){if(Reflect.deleteProperty(t,e),S(t,d.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var N="__dde_lifecyclesToEvents",y="dde:connected",D="dde:disconnected",U="dde:attributeChanged";function Lt(t){return d.q(t)}var C=[{get scope(){return d.D.body},host:t=>t?t(d.D.body):d.D.body,prevent:!0}],m={get current(){return C[C.length-1]},get host(){return this.current.host},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...C]},push(t={}){return C.push(x({},this.current,{prevent:!1},t))},pushRoot(){return C.push(C[0])},pop(){if(C.length!==1)return C.pop()}};function st(...t){return this.appendOriginal(...t),this}function ft(t){return t.append===st||(t.appendOriginal=t.append,t.append=st),t}var z;function T(t,e,...n){let r=$(this),o=0,c,s;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let i=(...h)=>h.length?(o===1?n.unshift(...h):h.forEach(b=>b(s)),void 0):s;m.push({scope:t,host:i}),c=t(e||void 0);let p=S(c,d.F);if(c.nodeName==="#comment")break;let E=T.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(E),p&&(s=E);break}case t==="#text":c=W.call(this,d.D.createTextNode(""),e);break;case(t==="<>"||!t):c=W.call(this,d.D.createDocumentFragment(),e);break;case!!z:c=W.call(this,d.D.createElementNS(z,t),e);break;case!c:c=W.call(this,d.D.createElement(t),e)}return ft(c),s||(s=c),n.forEach(i=>i(s)),o&&m.pop(),o=2,c}T.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=d.D.createComment(`<dde:mark ${t}${d.ssr}${n}>`);return e&&(r.end=d.D.createComment("</dde:mark>")),r};function kt(t){let e=this;return function(...r){z=t;let o=T.call(e,...r);return z=void 0,o}}function Nt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,s,i){if(i[0]===e)return c.apply(t,i);for(let p of i){let E=(p.slot||"")+n;try{lt(p,"remove","slot")}catch{}let h=o[E];if(!h)return;h.name.startsWith(r)||(h.childNodes.forEach(b=>b.remove()),h.name=r+E),h.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var H=new WeakMap,{setDeleteAttr:it}=d;function W(t,...e){if(!e.length)return t;H.set(t,at(t,this));for(let[n,r]of Object.entries(x({},...e)))K.call(this,t,n,r);return H.delete(t),t}function K(t,e,n){let{setRemoveAttr:r,s:o}=at(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(i,p)=>K.call(c,t,i,p));let[s]=e;if(s==="=")return r(e.slice(1),n);if(s===".")return ut(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return it(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return V(o,e,t,n,ut.bind(null,t[e]));case"ariaset":return V(o,e,t,n,(i,p)=>r("aria-"+i,p));case"classList":return dt.call(c,t,n)}return Tt(t,e)?it(t,e,n):r(e,n)}function at(t,e){if(H.has(t))return H.get(t);let r=(S(t,d.S)?Pt:Mt).bind(null,t,"Attribute"),o=$(e);return{setRemoveAttr:r,s:o}}function dt(t,e){let n=$(this);return V(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function lt(t,e,n,r){return S(t,d.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function Tt(t,e){if(!(e in t))return!1;let n=pt(t,e);return!O(n.set)}function pt(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||pt(t,e)}function V(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([i,p]){i&&(i=new c(i),i.target=e,p=t.processReactiveAttribute(n,i,p,o),o(i,p))})}function Mt(t,e,n,r){return t[(O(r)?"remove":"set")+e](n,r)}function Pt(t,e,n,r,o=null){return t[(O(r)?"remove":"set")+e+"NS"](o,n,r)}function ut(t,e,n){if(Reflect.set(t,e,n),!!O(n))return Reflect.deleteProperty(t,e)}var R=d.M?qt():new Proxy({},{get(){return()=>{}}});function qt(){let t=new Map,e=!1,n=u=>function(a){for(let f of a)if(f.type==="childList"){if(h(f.addedNodes,!0)){u();continue}b(f.removedNodes,!0)&&u()}},r=new d.M(n(i));return{observe(u){let a=new d.M(n(()=>{}));return a.observe(u,{childList:!0 Line truncated
Investigate `__dde_attributes` key of the element. */let[c,s]=o,i=this[tt][c];if(i)return g.action(i,"_set",s)})(t),A.disconnected(function(){/*! This removes all signals mapped to attributes (`S.observedAttributes`).
Investigate `__dde_attributes` key of the element. */g.clear(...Object.values(this[tt]))})(t),n};var bt={isSignal:F,processReactiveAttribute(t,e,n,r){if(!F(n))return n;let o=c=>{if(!t.isConnected)return k(n,o);r(e,c)};return nt(n,o),xt(n,o,t,e),n.get()}};function xt(t,e,...n){let{current:r}=m;r.host(function(o){if(o[L])return o[L].push([[t,e],...n]);o[L]=[],!r.prevent&&A.disconnected(()=>o[L].forEach(([[c,s]])=>k(c,s,c[l]&&c[l].host&&c[l].host()===o)))(o)})}var Ht=new FinalizationRegistry(function(t){g.clear({[l]:t})});function mt(t,e,n){let r=w(t?Ft:et),o=Et(r,e,n,t);return Ht.register(o,o[l]),o}var Bt=x(w(),{stopPropagation(){this.skip=!0}});function Et(t,e,n,r=!1){let o=[];rt(n)!=="[object Object]"&&(n={});let{onclear:c}=g.symbols;n[c]&&(o.push(n[c]),delete n[c]);let{host:s}=m;return Reflect.defineProperty(t,l,{value:x(w(Bt),{value:e,actions:n,onclear:o,host:s,listeners:new Set,defined:new q().stack,readonly:r}),enumerable:!1,writable:!1,configurable:!0}),t}function Jt(){return B[B.length-1]}function vt(t){if(!t[l])return;let{value:e,listeners:n}=t[l],r=Jt();return r&&n.add(r),v.has(r)&&v.get(r).add(t),e}function _t(t,e,n){let r=t[l];if(!(!r||!n&&r.value===e))return r.value=e,Y(t),e}function nt(t,e){if(t[l])return t[l].listeners.add(e)}function k(t,e,n){let r=t[l];if(!r)return;let{listeners:o}=r,c=o.delete(e);if(!c||!n||o.size)return c;g.clear(t);let s=v.get(r);if(!s)return c;let i=v.get(s);if(!i)return c;for(let p of i)k(p,s,!0);return c}I(bt);return Ot(Zt);})();
-1
View File
@@ -213,7 +213,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.
+1 -35
View File
@@ -33,7 +33,6 @@ var DDE = (() => {
elNS: () => createElementNS,
elementAttribute: () => elementAttribute,
lifecyclesToEvents: () => lifecyclesToEvents,
observedAttributes: () => observedAttributes2,
on: () => on,
queue: () => queue,
registerReactivity: () => registerReactivity,
@@ -64,16 +63,6 @@ var DDE = (() => {
signal.removeEventListener("abort", listener);
};
}
function observedAttributes(instance, observedAttribute) {
const { observedAttributes: observedAttributes3 = [] } = instance.constructor;
return observedAttributes3.reduce(function(out, name) {
out[kebabToCamel(name)] = observedAttribute(instance, name);
return out;
}, {});
}
function kebabToCamel(name) {
return name.replace(/-./g, (x) => x[1].toUpperCase());
}
// src/signals-lib/common.js
var signals_global = {
@@ -565,7 +554,7 @@ var DDE = (() => {
}
// src/customElement.js
function customElementRender(target, render, props = observedAttributes2) {
function customElementRender(target, render, props = {}) {
const custom_element = target.host || target;
scope.push({
scope: custom_element,
@@ -606,9 +595,6 @@ var DDE = (() => {
obj[method] = new Proxy(obj[method] || (() => {
}), { apply });
}
function observedAttributes2(instance) {
return observedAttributes(instance, (i, n) => i.getAttribute(n));
}
// src/events.js
function dispatchEvent(name, options, host) {
@@ -662,25 +648,5 @@ var DDE = (() => {
host(on.disconnected(() => a.abort()));
return a.signal;
};
var els_attribute_store = /* @__PURE__ */ new WeakSet();
on.attributeChanged = function(listener, options) {
if (typeof options !== "object")
options = {};
return function registerElement(element) {
element.addEventListener(eva, listener, options);
if (element[keyLTE] || els_attribute_store.has(element))
return element;
if (!enviroment.M) return element;
const observer = new enviroment.M(function(mutations) {
for (const { attributeName, target } of mutations)
target.dispatchEvent(
new CustomEvent(eva, { detail: [attributeName, target.getAttribute(attributeName)] })
);
});
const c = onAbort(options.signal, () => observer.disconnect());
if (c) observer.observe(element, { attributes: true });
return element;
};
};
return __toCommonJS(index_exports);
})();
-1
View File
@@ -213,7 +213,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.
+1 -1
View File
@@ -1 +1 @@
var DDE=(()=>{var k=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var ot=Object.prototype.hasOwnProperty;var ct=(t,e)=>{for(var n in e)k(t,n,{get:e[n],enumerable:!0})},st=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of rt(e))!ot.call(t,o)&&o!==n&&k(t,o,{get:()=>e[o],enumerable:!(r=nt(e,o))||r.enumerable});return t};var it=t=>st(k({},"__esModule",{value:!0}),t);var Et={};ct(Et,{assign:()=>R,assignAttribute:()=>q,chainableAppend:()=>G,classListDeclarative:()=>J,createElement:()=>j,createElementNS:()=>dt,customElementRender:()=>vt,customElementWithDDE:()=>X,dispatchEvent:()=>mt,el:()=>j,elNS:()=>dt,elementAttribute:()=>K,lifecyclesToEvents:()=>X,observedAttributes:()=>Y,on:()=>O,queue:()=>at,registerReactivity:()=>H,scope:()=>y,simulateSlots:()=>pt});function w(t){return typeof t>"u"}function b(t,e){return t instanceof e}function $(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function v(...t){return Object.assign(...t)}function T(t,e){if(!t||!b(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function U(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return r[ut(o)]=e(t,o),r},{})}function ut(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var S={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function H(t,e=!0){return e?v(S,t):(Object.setPrototypeOf(t,S),t)}function N(t){return $(t,S)&&t!==S?t:S}var a={setDeleteAttr:ft,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function ft(t,e,n){if(Reflect.set(t,e,n),!!w(n)){if(Reflect.deleteProperty(t,e),b(t,a.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var A="__dde_lifecyclesToEvents",m="dde:connected",_="dde:disconnected",L="dde:attributeChanged";function at(t){return a.q(t)}var x=[{get scope(){return a.D.body},host:t=>t?t(a.D.body):a.D.body,prevent:!0}],y={get current(){return x[x.length-1]},get host(){return this.current.host},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...x]},push(t={}){return x.push(v({},this.current,{prevent:!1},t))},pushRoot(){return x.push(x[0])},pop(){if(x.length!==1)return x.pop()}};function z(...t){return this.appendOriginal(...t),this}function G(t){return t.append===z||(t.appendOriginal=t.append,t.append=z),t}var P;function j(t,e,...n){let r=N(this),o=0,c,d;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let f=(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(E=>E(d)),void 0):d;y.push({scope:t,host:f}),c=t(e||void 0);let p=b(c,a.F);if(c.nodeName==="#comment")break;let g=j.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(g),p&&(d=g);break}case t==="#text":c=R.call(this,a.D.createTextNode(""),e);break;case(t==="<>"||!t):c=R.call(this,a.D.createDocumentFragment(),e);break;case!!P:c=R.call(this,a.D.createElementNS(P,t),e);break;case!c:c=R.call(this,a.D.createElement(t),e)}return G(c),d||(d=c),n.forEach(f=>f(d)),o&&y.pop(),o=2,c}j.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=a.D.createComment(`<dde:mark ${t}${a.ssr}${n}>`);return e&&(r.end=a.D.createComment("</dde:mark>")),r};function dt(t){let e=this;return function(...r){P=t;let o=j.call(e,...r);return P=void 0,o}}function pt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,d,f){if(f[0]===e)return c.apply(t,f);for(let p of f){let g=(p.slot||"")+n;try{K(p,"remove","slot")}catch{}let l=o[g];if(!l)return;l.name.startsWith(r)||(l.childNodes.forEach(E=>E.remove()),l.name=r+g),l.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var M=new WeakMap,{setDeleteAttr:B}=a;function R(t,...e){if(!e.length)return t;M.set(t,V(t,this));for(let[n,r]of Object.entries(v({},...e)))q.call(this,t,n,r);return M.delete(t),t}function q(t,e,n){let{setRemoveAttr:r,s:o}=V(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(f,p)=>q.call(c,t,f,p));let[d]=e;if(d==="=")return r(e.slice(1),n);if(d===".")return Z(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return B(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return W(o,e,t,n,Z.bind(null,t[e]));case"ariaset":return W(o,e,t,n,(f,p)=>r("aria-"+f,p));case"classList":return J.call(c,t,n)}return lt(t,e)?B(t,e,n):r(e,n)}function V(t,e){if(M.has(t))return M.get(t);let r=(b(t,a.S)?bt:ht).bind(null,t,"Attribute"),o=N(e);return{setRemoveAttr:r,s:o}}functLine truncated
var DDE=(()=>{var M=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var rt=(t,e)=>{for(var n in e)M(t,n,{get:e[n],enumerable:!0})},ot=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of et(e))!nt.call(t,o)&&o!==n&&M(t,o,{get:()=>e[o],enumerable:!(r=tt(e,o))||r.enumerable});return t};var ct=t=>ot(M({},"__esModule",{value:!0}),t);var bt={};rt(bt,{assign:()=>S,assignAttribute:()=>q,chainableAppend:()=>Z,classListDeclarative:()=>V,createElement:()=>P,createElementNS:()=>ut,customElementRender:()=>ht,customElementWithDDE:()=>Q,dispatchEvent:()=>gt,el:()=>P,elNS:()=>ut,elementAttribute:()=>J,lifecyclesToEvents:()=>Q,on:()=>L,queue:()=>it,registerReactivity:()=>$,scope:()=>y,simulateSlots:()=>ft});function w(t){return typeof t>"u"}function g(t,e){return t instanceof e}function I(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function v(...t){return Object.assign(...t)}function j(t,e){if(!t||!g(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}var D={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function $(t,e=!0){return e?v(D,t):(Object.setPrototypeOf(t,D),t)}function R(t){return I(t,D)&&t!==D?t:D}var a={setDeleteAttr:st,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function st(t,e,n){if(Reflect.set(t,e,n),!!w(n)){if(Reflect.deleteProperty(t,e),g(t,a.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var O="__dde_lifecyclesToEvents",m="dde:connected",_="dde:disconnected",U="dde:attributeChanged";function it(t){return a.q(t)}var x=[{get scope(){return a.D.body},host:t=>t?t(a.D.body):a.D.body,prevent:!0}],y={get current(){return x[x.length-1]},get host(){return this.current.host},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...x]},push(t={}){return x.push(v({},this.current,{prevent:!1},t))},pushRoot(){return x.push(x[0])},pop(){if(x.length!==1)return x.pop()}};function H(...t){return this.appendOriginal(...t),this}function Z(t){return t.append===H||(t.appendOriginal=t.append,t.append=H),t}var T;function P(t,e,...n){let r=R(this),o=0,c,d;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let f=(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(E=>E(d)),void 0):d;y.push({scope:t,host:f}),c=t(e||void 0);let p=g(c,a.F);if(c.nodeName==="#comment")break;let b=P.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(b),p&&(d=b);break}case t==="#text":c=S.call(this,a.D.createTextNode(""),e);break;case(t==="<>"||!t):c=S.call(this,a.D.createDocumentFragment(),e);break;case!!T:c=S.call(this,a.D.createElementNS(T,t),e);break;case!c:c=S.call(this,a.D.createElement(t),e)}return Z(c),d||(d=c),n.forEach(f=>f(d)),o&&y.pop(),o=2,c}P.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=a.D.createComment(`<dde:mark ${t}${a.ssr}${n}>`);return e&&(r.end=a.D.createComment("</dde:mark>")),r};function ut(t){let e=this;return function(...r){T=t;let o=P.call(e,...r);return T=void 0,o}}function ft(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,d,f){if(f[0]===e)return c.apply(t,f);for(let p of f){let b=(p.slot||"")+n;try{J(p,"remove","slot")}catch{}let l=o[b];if(!l)return;l.name.startsWith(r)||(l.childNodes.forEach(E=>E.remove()),l.name=r+b),l.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var N=new WeakMap,{setDeleteAttr:z}=a;function S(t,...e){if(!e.length)return t;N.set(t,G(t,this));for(let[n,r]of Object.entries(v({},...e)))q.call(this,t,n,r);return N.delete(t),t}function q(t,e,n){let{setRemoveAttr:r,s:o}=G(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(f,p)=>q.call(c,t,f,p));let[d]=e;if(d==="=")return r(e.slice(1),n);if(d===".")return B(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return z(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return k(o,e,t,n,B.bind(null,t[e]));case"ariaset":return k(o,e,t,n,(f,p)=>r("aria-"+f,p));case"classList":return V.call(c,t,n)}return at(t,e)?z(t,e,n):r(e,n)}function G(t,e){if(N.has(t))return N.get(t);let r=(g(t,a.S)?pt:dt).bind(null,t,"Attribute"),o=R(e);return{setRemoveAttr:r,s:o}}function V(t,e){let n=R(this);return k(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function J(t,e,n,r){return g(t,a.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function at(t,e)Line truncated
@@ -2,7 +2,6 @@
import {
customElementRender,
customElementWithDDE,
observedAttributes,
} from "deka-dom-el";
/** @type {ddePublicElementTagNameMap} */
import { S } from "deka-dom-el/signals";
@@ -1,7 +1,6 @@
import {
customElementRender,
customElementWithDDE,
observedAttributes,
el, on, scope,
} from "deka-dom-el";
import { S } from "deka-dom-el/signals";
@@ -9,7 +8,6 @@ export class HTMLCustomElement extends HTMLElement{
static tagName= "custom-element";
static observedAttributes= [ "attr" ];
connectedCallback(){
console.log(observedAttributes(this));
customElementRender(
this.attachShadow({ mode: "open" }),
ddeComponent,
@@ -3,7 +3,6 @@ const paragraph= el("p", "See live-cycle events in console.",
el=> log({ type: "dde:created", detail: el }),
on.connected(log),
on.disconnected(log),
on.attributeChanged(log));
document.body.append(
paragraph,
@@ -11,10 +11,6 @@ export function mnemonic(){
el("code", "customElementWithDDE(<custom-element>)"),
" — register <custom-element> to DDE library, see also `lifecyclesToEvents`, can be also used as decorator",
),
el("li").append(
el("code", "observedAttributes(<custom-element>)"),
" — returns record of observed attributes (keys uses camelCase)",
),
el("li").append(
el("code", "S.observedAttributes(<custom-element>)"),
" — returns record of observed attributes (keys uses camelCase and values are signals)",
@@ -32,4 +28,4 @@ export function mnemonic(){
" — simulate slots for “dde”/functional components",
),
);
}
}
-3
View File
@@ -165,9 +165,6 @@ export function page({ pkg, info }){
el("dt", t`on.disconnected(callback)`),
el("dd", t`Fires when the element is removed from the DOM`),
el("dt", t`on.attributeChanged(callback, attributeName)`),
el("dd", t`Fires when the specified attribute changes`)
)
),
el(example, { src: fileURL("./components/examples/events/live-cycle.js"), page_id }),
+6 -4
View File
@@ -115,7 +115,7 @@ export function page({ pkg, info }){
el("dt", t`Usage`),
el("dd", t`customElementWithDDE(YourElementClass)`),
el("dt", t`Benefits`),
el("dd", t`Allows using on.connected(), on.disconnected(), etc. with your element`)
el("dd", t`Allows using on.connected(), on.disconnected() or S.observedAttributes().`)
)
),
el(example, { src: fileURL("./components/examples/customElement/customElementWithDDE.js"), page_id }),
@@ -142,7 +142,8 @@ export function page({ pkg, info }){
el("ol").append(
el("li", t`Target (usually this or this.shadowRoot)`),
el("li", t`Component function that returns a DOM tree`),
el("li", t`Optional: Attributes transformer function (default or S.observedAttributes)`)
el("li", t`Optional: Attributes transformer function (empty by default or
S.observedAttributes)`)
)
),
el("dt", t`Returns`),
@@ -169,7 +170,8 @@ export function page({ pkg, info }){
`),
el("ol").append(
el("li").append(...T`
${el("code", "observedAttributes")} - Passes attributes as regular values (static)
Using standard attribute access (${el("code", "this.getAttribute(<name>)")}) - Passes attributes as
regular values (static)
`),
el("li").append(...T`
${el("code", "S.observedAttributes")} - Transforms attributes into signals (reactive)
@@ -177,7 +179,7 @@ export function page({ pkg, info }){
)
),
el("p").append(...T`
Using ${el("code", "S.observedAttributes")} creates a reactive connection between your element's attributes
Using the ${el("code", "S.observedAttributes")} creates a reactive connection between your element's attributes
and its internal rendering. When attributes change, your component automatically updates!
`),
el(example, { src: fileURL("./components/examples/customElement/observedAttributes.js"), page_id }),
Vendored
-1
View File
@@ -262,7 +262,6 @@ export function customElementRender<
): EL
export function customElementWithDDE<EL extends (new ()=> HTMLElement)>(custom_element: EL): EL
export function lifecyclesToEvents<EL extends (new ()=> HTMLElement)>(custom_element: EL): EL
export function observedAttributes(custom_element: HTMLElement): Record<string, string>
/**
* This is used primarly for server side rendering. To be sure that all async operations
+2 -1
View File
@@ -100,5 +100,6 @@
"jshint": "~2.13",
"nodejsscript": "^1.0.2",
"size-limit-node-esbuild": "~0.3"
}
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
+2 -14
View File
@@ -7,10 +7,10 @@ import { c_ch_o } from "./events-observer.js";
*
* @param {Element|ShadowRoot} target - The custom element or shadow root to render into
* @param {Function} render - The render function that returns content
* @param {Function|Object} [props=observedAttributes] - Props to pass to the render function
* @param {Function|Object} [props= {}] - Props to pass to the render function
* @returns {Node} The rendered content
*/
export function customElementRender(target, render, props= observedAttributes){
export function customElementRender(target, render, props= {}){
const custom_element= target.host || target;
scope.push({
scope: custom_element,
@@ -69,15 +69,3 @@ export { lifecyclesToEvents as customElementWithDDE };
function wrapMethod(obj, method, apply){
obj[method]= new Proxy(obj[method] || (()=> {}), { apply });
}
import { observedAttributes as oA } from "./helpers.js";
/**
* Gets observed attributes for a custom element
*
* @param {Element} instance - Custom element instance
* @returns {Object} Object mapping camelCase attribute names to their values
*/
export function observedAttributes(instance){
return oA(instance, (i, n)=> i.getAttribute(n));
}
-32
View File
@@ -106,35 +106,3 @@ on.disconnectedAsAbort= function(host){
host(on.disconnected(()=> a.abort()));
return a.signal;
};
/** Store for elements with attribute observers */
const els_attribute_store= new WeakSet();
/**
* Creates a function to register attribute change event listeners
*
* @param {Function} listener - Event handler
* @param {Object} [options] - Event listener options
* @returns {Function} Function that registers the attribute change listener
*/
on.attributeChanged= function(listener, options){
if(typeof options !== "object")
options= {};
return function registerElement(element){
element.addEventListener(eva, listener, options);
if(element[keyLTE] || els_attribute_store.has(element))
return element;
if(!env.M) return element;
const observer= new env.M(function(mutations){
for(const { attributeName, target } of mutations)
target.dispatchEvent(
new CustomEvent(eva, { detail: [ attributeName, target.getAttribute(attributeName) ] }));
});
const c= onAbort(options.signal, ()=> observer.disconnect());
if(c) observer.observe(element, { attributes: true });
//TODO: clean up when element disconnected
return element;
};
};
+2 -2
View File
@@ -159,7 +159,7 @@ signal.clear= function(...signals){
};
/** Property key for tracking reactive elements */
const key_reactive= "__dde_reactive";
import { enviroment as env } from "../dom-common.js";
import { enviroment as env, eva } from "../dom-common.js";
import { el } from "../dom.js";
import { scope } from "../dom.js";
import { on } from "../events.js";
@@ -265,7 +265,7 @@ const key_attributes= "__dde_attributes";
signal.observedAttributes= function(element){
const store= element[key_attributes]= {};
const attrs= observedAttributes(element, observedAttribute(store));
on.attributeChanged(function attributeChangeToSignal({ detail }){
on(eva, function attributeChangeToSignal({ detail }){
/*! This maps attributes to signals (`S.observedAttributes`).
Investigate `__dde_attributes` key of the element. */
const [ name, value ]= detail;