sinho 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +8 -2
- package/dist/bundle.min.js +1 -1
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +9 -2
- package/dist/dom.js.map +1 -1
- package/package.json +1 -1
- package/src/dom.ts +12 -7
package/dist/bundle.js
CHANGED
|
@@ -587,9 +587,10 @@ const setStyle = (node, key, value) => {
|
|
|
587
587
|
const setAttr = (node, name, value, heuristic) => {
|
|
588
588
|
const removeAttribute = value == null || (value === false && !name.includes("-"));
|
|
589
589
|
if (name.startsWith("prop:")) {
|
|
590
|
-
node[name] = value;
|
|
590
|
+
node[name.slice(5)] = value;
|
|
591
591
|
}
|
|
592
592
|
else if (name.startsWith("attr:")) {
|
|
593
|
+
name = name.slice(5);
|
|
593
594
|
if (!removeAttribute) {
|
|
594
595
|
node.setAttribute(name, value);
|
|
595
596
|
}
|
|
@@ -618,7 +619,12 @@ const setAttr = (node, name, value, heuristic) => {
|
|
|
618
619
|
].includes(name) &&
|
|
619
620
|
name in node) {
|
|
620
621
|
try {
|
|
621
|
-
node
|
|
622
|
+
if (isComponent(node)) {
|
|
623
|
+
node[name] = value;
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
node[name] = value == null ? "" : value;
|
|
627
|
+
}
|
|
622
628
|
return;
|
|
623
629
|
}
|
|
624
630
|
catch (e) { }
|
package/dist/bundle.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=t=>({t:t,o:[],i:[],l:{...t?.l},u(t){const n=o;o=this;try{return t()}finally{o=n}},h(){for(let t=this.i.length-1;t>=0;t--)this.i[t].h();this.i=[];for(let t=this.o.length-1;t>=0;t--){const n=this.o[t];n._?.(),n.u=()=>{},n.p.forEach((t=>t.o.delete(n))),n.p.clear()}this.o=[]}});let n,e,o=t(),s=!1;const r=()=>o,c=(t,o)=>{const r=()=>(!s&&n&&(n.p.add(r),r.o.add(n)),r.peek());r.o=new Set,r.peek=()=>t;const c=(n,s)=>{if(s={...o,...s},e){const o="function"==typeof n?n(r.peek()):n;(s?.force||o!==r.peek())&&(s?.force?t=o:e.m.push((()=>t=o)),s?.silent||r.o.forEach((t=>e.o.add(t))))}else i((()=>c(n,s)))};return[r,c]},i=t=>{const n=e;e={m:[],o:new Set};try{const n=t();for(;e.m.length>0||e.o.size>0;){const t=e.o;e.o=new Set,t.forEach((t=>t._?.())),e.m.forEach((t=>t())),e.m=[],t.forEach((t=>t.u()))}return n}finally{e=n}},l=(t,e)=>{const r=!!e,c={v:o,p:new Set,u(){const o=n,c=s;n=this;try{this.p.forEach((t=>t.o.delete(this))),this.p.clear(),e&&(s=!1,e.forEach((t=>t()))),s=r,this._?.();const n=this.v.u((()=>i(t)));this._=n?()=>{this.v.u((()=>i(n))),this._=null}:null}finally{n=o,s=c}}};o.o.push(c),c.u(),c.p.size||c._||o.o.pop()},u=(t,n)=>{const[e,o]=c();let s=!0;return l((()=>{o(t,s?{...n,force:!0}:n),s=!1})),e},f=(n,e)=>{const s=o,r=t(s);Object.assign(r.l,e?.details),s.i.push(r);return[r.u(n),()=>{const t=s.i.indexOf(r);t>=0&&s.i.splice(t,1),r.h()}]},a=(t,n)=>{const[e,o]=c(t,n);return e.set=o,e},d={upgrade:t=>()=>d.get(t),get:t=>"function"==typeof t?t():t,peek(t){const n=s;s=!0;try{return this.get(t)}finally{s=n}}},h=(t={})=>({S:[],M(t){return this.k?.next().value??t()},...t}),_=()=>{const t=r();return t.l.C??=h()},p=(t,n)=>{const e=_(),o=h({...e,...t}),[s,r]=f(n,{details:{C:o}});return l((()=>r)),s},m=t=>(t[0]??"").toLowerCase()+t.slice(1).replace(/[A-Z]/g,(t=>"-"+t.toLowerCase())),y=t=>t.startsWith("on:")?t.slice(3):m(t.slice(2)),w=Symbol(),b=(t,n)=>({[w]:Math.random().toString(36).slice(2),N:t,j:n}),g=t=>!!t?.[w],v=(t,n,e)=>{n.addEventListener(t[w],(t=>{const n=d.get(e);void 0!==n&&(t.stopPropagation(),t.detail(n))}))},x=t=>{const n=_();return u((()=>{let e=t.N;return n.H?.dispatchEvent(new CustomEvent(t[w],{detail:t=>e=t,bubbles:!0,composed:!0})),e}))},S=(t,n)=>({L:"p",T:t,...n}),M=(t=CustomEvent)=>({L:"e",A:t}),k=Symbol();let C;const E=(t,n)=>{C?C.push([t,n]):l(t,n)},N=(t,n={},e={})=>{const o=[],s=new Map;for(const t in n){const e=n[t];if("p"==e.L&&e.attribute){"function"==typeof e.attribute&&(e.attribute={transform:e.attribute});const n=e.attribute={name:m(t),static:!1,transform:t=>t,...e.attribute};s.set(n.name,{name:t,meta:e}),n.static||o.push(n.name)}}e.shadow??={mode:"open"};class i extends HTMLElement{static[k]={O:t};static observedAttributes=o;props={};events={};[k]={};constructor(){super();for(const t in n){const e=n[t];if("p"==e.L){const n=g(e.T)?e.T:null,[o,s]=c(n?void 0:e.T);this.props[t]=o,n&&v(n,this,o),Object.defineProperty(this,t,{get:o.peek,set:t=>s((()=>t),{force:!0})})}else if("e"==e.L&&t.startsWith("on")){const n=y(t);this.events[t]=t=>this.dispatchEvent(new e.A(n,t))}}}connectedCallback(){const t=(n=this,e.shadow?n.shadowRoot??n.attachShadow(e.shadow):n);var n;this[k].D=f((()=>p({I:!1,H:this,k:t.childNodes.values()},(()=>{this[k].v=r();const n=C;C=[];try{t?.append(...this.render().build()),C.forEach((([t,n])=>l(t,n)))}finally{C=n}}))))[1]}disconnectedCallback(){this[k].D?.()}attributeChangedCallback(t,n,e){const o=s.get(t);o&&(this[o.name]=null!=e?o.meta.attribute.transform.call(this,e):g(o.meta.T)?void 0:o.meta.T)}}return i},j=t=>!!t?.[k],H=(...t)=>{const[n,e]="string"==typeof t[0]?[t[0],t.slice(1)]:["",t];for(const t of e)customElements.define(n+t[k].O,t)},L=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,T=(t,n,e)=>{"-"==n[0]?t.style.setProperty(n,""+e):t.style[n]=null==e?"":"number"!=typeof e||L.test(n)?""+e:e+"px"},A=(t,n,e,o)=>{const s=null==e||!1===e&&!n.includes("-");if(n.startsWith("prop:"))t[n]=e;else if(n.startsWith("attr:"))s?t.removeAttribute(n):t.setAttribute(n,e);else if(!["innerHTML","outerHTML"].includes(n)){if(!["tabIndex","role",...o?["width","height","href","list","form","download","rowSpan","colSpan"]:[]].includes(n)&&n in t)try{return void(t[n]=e??"")}catch(t){}"function"==typeof e||(s?t.removeAttribute(n):t.setAttribute(n,e))}},O=t=>({build(){const n=t();return n.build?.()??n}}),D=({text:t,marker:n})=>O((()=>{const e=_(),o=n&&e.M((()=>document.createComment(""))),s=e.M((()=>document.createTextNode("")));return l((()=>{const n=""+(d.get(t)??"");s.textContent!=n&&(s.textContent=n)})),o?[o,s]:[s]})),I=({children:t})=>O((()=>Array.isArray(t)?t.flatMap((t=>I({children:t}).build())):null==t?[]:"object"==typeof t?t:D({text:t}))),$=(t,n,e,o)=>{const{ref:s,style:c,children:u,dangerouslySetInnerHTML:f,...a}=e;for(const n in c??{}){const e=c[n];l((()=>{T(t,n,d.get(e))}))}for(const n in a){const e=a[n];if(n.startsWith("on")){const o=r(),s=t=>{o.u((()=>i((()=>e(t)))))},c=y(n);l((()=>(t.addEventListener(c,s),()=>t.removeEventListener(c,s))))}else l((()=>{A(t,n,d.get(e),o)}))}return f&&l((()=>{const n=d.get(f).__html;t.innerHTML!=n&&(t.innerHTML=n)})),s&&l((()=>(s.set(t),()=>s.set(void 0)))),null!=e.children&&t.append(...p({I:n,k:t.childNodes.values()},(()=>I({children:e.children}).build()))),t},z=(t,n={},e)=>(null!=e&&(n.children=e),j(t)?((t,n)=>O((()=>{const e=_().M((()=>new t));return customElements.upgrade(e),$(e,!1,n),[e]})))(t,n):"function"==typeof t?O((()=>t(n))):((t,n={})=>O((()=>{const e=_(),o="svg"==t||!!e.I;return[$(e.M((()=>o?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t))),o,n,!0)]})))(t,n)),P=new Proxy(z,{get:(t,n)=>(e,o)=>t(n,e,o)}),V=(t,n)=>{const[e,o]=c({$:[],P:new Map});let s=new Map;return l((()=>{const e=[],r=s,c=((t,n)=>{const e=new Map;for(let o=0;o<t.length;o++){const s=n(t[o],o);if(e.has(s))throw Error(`Duplicate key '${s}'`);e.set(s,o)}return e})(t(),n),i=(t=NaN)=>e.map((t=>"r"==t.V?n=>n<t.Z?n:n==t.Z?NaN:n-1:"a"==t.V?n=>n<t.Z?n:n+1:"m"==t.V?n=>t.q<=n&&n<t.B?n+1:n==t.B?t.q:n:t=>t)).reduce(((t,n)=>n(t)),t);for(const t of r.keys()){const n=i(r.get(t));c.has(t)||e.push({V:"r",F:t,Z:n})}for(let o=0;o<t().length;o++){const s=n(t()[o],o),c=i(r.get(s));isNaN(c)?e.push({V:"a",F:s,Z:o}):c!=o&&e.push({V:"m",F:s,B:c,q:o})}e.length>0&&o({$:e,P:c}),s=c})),e},Z=t=>O((()=>{const n=_(),e=d.upgrade(t.each??[]),o=n.M((()=>document.createComment(""))),s=t.key??((t,n)=>n),r=[o],i=new Map,u=V(e,s),a=t=>{for(let n=t-1;n>=0;n--){const n=s(e()[t-1],t-1),o=i.get(n)?.G??[];if(o.length>0)return o[o.length-1]}return o};return l((()=>{for(const n of u().$)if("r"==n.V){const{G:t=[],D:e}=i.get(n.F)??{};e?.();const o=r.indexOf(t[0]);o>0&&r.splice(o,t.length),t.forEach((t=>t.parentNode?.removeChild(t))),i.delete(n.F)}else if("a"==n.V){let o=[];const[,s]=f((()=>{const[s,i]=c(n.Z),[f,d]=c(e()[n.Z]);l((()=>{0<=s()&&s()<e().length&&d((()=>e()[s()]))})),l((()=>{const t=u().P.get(n.F);null!=t&&i(t)})),o=t.children?.(f,s,e).build()??[];const h=a(n.Z),_=r.indexOf(h);_>=0&&r.splice(_+1,0,...o),o.forEach((t=>h.parentNode?.insertBefore(t,h.nextSibling)))}));i.set(n.F,{G:o,D:s})}else if("m"==n.V){const{G:t=[]}=i.get(n.F)??{},e=r.indexOf(t[0]);e>=0&&r.splice(e,t.length);const o=a(n.q),s=r.indexOf(o);s>=0&&r.splice(s+1,0,...t),t.forEach((t=>o.parentNode?.insertBefore(t,o.nextSibling)))}}),[u]),r})),q=t=>(_().S=[],B({condition:t.condition,children:t.children})),B=t=>{const n=_(),e=n.S,o=u((()=>e.every((t=>!t()))&&d.get(t.condition)));return n.S=[...e,o],p({S:[]},(()=>O((()=>{const e=n.M((()=>document.createComment(""))),s=[e],r=u((()=>o()?I({children:t.children}):null));let c=[];return l((()=>{c.forEach((t=>t.parentNode?.removeChild(t))),s.length=1;const[,t]=f((()=>{c=r()?.build()??[],e.after(...c),s.push(...c)}));return t}),[r]),s}))))},F=({children:t})=>B({condition:!0,children:t}),G=({mount:t,children:n})=>O((()=>p({k:void 0},(()=>{const e=I({children:n}).build();return l((()=>(e.forEach((n=>t.appendChild(n))),()=>{e.forEach((t=>t.parentNode?.removeChild(t)))}))),[]})))),J=Symbol(),K=new Map,Q=t=>{const n=t.children;if("function"==typeof n){const e=z("style",{},D({text:n,marker:!1}));return t.light?G({mount:document.head,children:e}):e}if(n){const o=_(),s=t.light?document:o.H?.shadowRoot??document,r=((t,n,e)=>{if(!K.has(n)){const t=new CSSStyleSheet;t.replaceSync(n),K.set(n,{J:t,K:0})}const o=K.get(n);o.K++,t.has(n)||t.set(n,{J:o.J,K:0});const s=t.get(n);return s.K++,l((()=>()=>{--s.K||(t.delete(n),e()),--o.K||K.delete(n)})),s.J})((e=s,e[J]??=new Map),n,(()=>{s.adoptedStyleSheets=s.adoptedStyleSheets.filter((t=>t!=r))}));s.adoptedStyleSheets.push(r)}var e;return I({})},R=(t,...n)=>{const e=()=>t.reduce(((t,e,o)=>t+e+(d.get(n[o])??"")),"");return n.some((t=>"function"==typeof t))?e:e()},U=(t,n,e)=>(n&&null!=e&&(n.key=e),z(t,n));export{N as Component,F as Else,B as ElseIf,Z as For,I as Fragment,q as If,d as MaybeSignal,G as Portal,Q as Style,b as createContext,z as createElement,R as css,H as defineComponents,M as event,P as h,j as isComponent,U as jsx,U as jsxDEV,U as jsxs,S as prop,i as useBatch,x as useContext,E as useEffect,u as useMemo,a as useRef,c as useSignal,f as useSubscope};
|
|
1
|
+
const t=t=>({t:t,o:[],i:[],l:{...t?.l},u(t){const n=o;o=this;try{return t()}finally{o=n}},h(){for(let t=this.i.length-1;t>=0;t--)this.i[t].h();this.i=[];for(let t=this.o.length-1;t>=0;t--){const n=this.o[t];n._?.(),n.u=()=>{},n.p.forEach((t=>t.o.delete(n))),n.p.clear()}this.o=[]}});let n,e,o=t(),s=!1;const r=()=>o,c=(t,o)=>{const r=()=>(!s&&n&&(n.p.add(r),r.o.add(n)),r.peek());r.o=new Set,r.peek=()=>t;const c=(n,s)=>{if(s={...o,...s},e){const o="function"==typeof n?n(r.peek()):n;(s?.force||o!==r.peek())&&(s?.force?t=o:e.m.push((()=>t=o)),s?.silent||r.o.forEach((t=>e.o.add(t))))}else i((()=>c(n,s)))};return[r,c]},i=t=>{const n=e;e={m:[],o:new Set};try{const n=t();for(;e.m.length>0||e.o.size>0;){const t=e.o;e.o=new Set,t.forEach((t=>t._?.())),e.m.forEach((t=>t())),e.m=[],t.forEach((t=>t.u()))}return n}finally{e=n}},l=(t,e)=>{const r=!!e,c={v:o,p:new Set,u(){const o=n,c=s;n=this;try{this.p.forEach((t=>t.o.delete(this))),this.p.clear(),e&&(s=!1,e.forEach((t=>t()))),s=r,this._?.();const n=this.v.u((()=>i(t)));this._=n?()=>{this.v.u((()=>i(n))),this._=null}:null}finally{n=o,s=c}}};o.o.push(c),c.u(),c.p.size||c._||o.o.pop()},u=(t,n)=>{const[e,o]=c();let s=!0;return l((()=>{o(t,s?{...n,force:!0}:n),s=!1})),e},f=(n,e)=>{const s=o,r=t(s);Object.assign(r.l,e?.details),s.i.push(r);return[r.u(n),()=>{const t=s.i.indexOf(r);t>=0&&s.i.splice(t,1),r.h()}]},a=(t,n)=>{const[e,o]=c(t,n);return e.set=o,e},d={upgrade:t=>()=>d.get(t),get:t=>"function"==typeof t?t():t,peek(t){const n=s;s=!0;try{return this.get(t)}finally{s=n}}},h=(t={})=>({S:[],M(t){return this.k?.next().value??t()},...t}),_=()=>{const t=r();return t.l.C??=h()},p=(t,n)=>{const e=_(),o=h({...e,...t}),[s,r]=f(n,{details:{C:o}});return l((()=>r)),s},m=t=>(t[0]??"").toLowerCase()+t.slice(1).replace(/[A-Z]/g,(t=>"-"+t.toLowerCase())),y=t=>t.startsWith("on:")?t.slice(3):m(t.slice(2)),w=Symbol(),b=(t,n)=>({[w]:Math.random().toString(36).slice(2),N:t,j:n}),g=t=>!!t?.[w],v=(t,n,e)=>{n.addEventListener(t[w],(t=>{const n=d.get(e);void 0!==n&&(t.stopPropagation(),t.detail(n))}))},x=t=>{const n=_();return u((()=>{let e=t.N;return n.H?.dispatchEvent(new CustomEvent(t[w],{detail:t=>e=t,bubbles:!0,composed:!0})),e}))},S=(t,n)=>({L:"p",T:t,...n}),M=(t=CustomEvent)=>({L:"e",A:t}),k=Symbol();let C;const E=(t,n)=>{C?C.push([t,n]):l(t,n)},N=(t,n={},e={})=>{const o=[],s=new Map;for(const t in n){const e=n[t];if("p"==e.L&&e.attribute){"function"==typeof e.attribute&&(e.attribute={transform:e.attribute});const n=e.attribute={name:m(t),static:!1,transform:t=>t,...e.attribute};s.set(n.name,{name:t,meta:e}),n.static||o.push(n.name)}}e.shadow??={mode:"open"};class i extends HTMLElement{static[k]={O:t};static observedAttributes=o;props={};events={};[k]={};constructor(){super();for(const t in n){const e=n[t];if("p"==e.L){const n=g(e.T)?e.T:null,[o,s]=c(n?void 0:e.T);this.props[t]=o,n&&v(n,this,o),Object.defineProperty(this,t,{get:o.peek,set:t=>s((()=>t),{force:!0})})}else if("e"==e.L&&t.startsWith("on")){const n=y(t);this.events[t]=t=>this.dispatchEvent(new e.A(n,t))}}}connectedCallback(){const t=(n=this,e.shadow?n.shadowRoot??n.attachShadow(e.shadow):n);var n;this[k].D=f((()=>p({I:!1,H:this,k:t.childNodes.values()},(()=>{this[k].v=r();const n=C;C=[];try{t?.append(...this.render().build()),C.forEach((([t,n])=>l(t,n)))}finally{C=n}}))))[1]}disconnectedCallback(){this[k].D?.()}attributeChangedCallback(t,n,e){const o=s.get(t);o&&(this[o.name]=null!=e?o.meta.attribute.transform.call(this,e):g(o.meta.T)?void 0:o.meta.T)}}return i},j=t=>!!t?.[k],H=(...t)=>{const[n,e]="string"==typeof t[0]?[t[0],t.slice(1)]:["",t];for(const t of e)customElements.define(n+t[k].O,t)},L=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,T=(t,n,e)=>{"-"==n[0]?t.style.setProperty(n,""+e):t.style[n]=null==e?"":"number"!=typeof e||L.test(n)?""+e:e+"px"},A=(t,n,e,o)=>{const s=null==e||!1===e&&!n.includes("-");if(n.startsWith("prop:"))t[n.slice(5)]=e;else if(n.startsWith("attr:"))n=n.slice(5),s?t.removeAttribute(n):t.setAttribute(n,e);else if(!["innerHTML","outerHTML"].includes(n)){if(!["tabIndex","role",...o?["width","height","href","list","form","download","rowSpan","colSpan"]:[]].includes(n)&&n in t)try{return void(j(t)?t[n]=e:t[n]=e??"")}catch(t){}"function"==typeof e||(s?t.removeAttribute(n):t.setAttribute(n,e))}},O=t=>({build(){const n=t();return n.build?.()??n}}),D=({text:t,marker:n})=>O((()=>{const e=_(),o=n&&e.M((()=>document.createComment(""))),s=e.M((()=>document.createTextNode("")));return l((()=>{const n=""+(d.get(t)??"");s.textContent!=n&&(s.textContent=n)})),o?[o,s]:[s]})),I=({children:t})=>O((()=>Array.isArray(t)?t.flatMap((t=>I({children:t}).build())):null==t?[]:"object"==typeof t?t:D({text:t}))),$=(t,n,e,o)=>{const{ref:s,style:c,children:u,dangerouslySetInnerHTML:f,...a}=e;for(const n in c??{}){const e=c[n];l((()=>{T(t,n,d.get(e))}))}for(const n in a){const e=a[n];if(n.startsWith("on")){const o=r(),s=t=>{o.u((()=>i((()=>e(t)))))},c=y(n);l((()=>(t.addEventListener(c,s),()=>t.removeEventListener(c,s))))}else l((()=>{A(t,n,d.get(e),o)}))}return f&&l((()=>{const n=d.get(f).__html;t.innerHTML!=n&&(t.innerHTML=n)})),s&&l((()=>(s.set(t),()=>s.set(void 0)))),null!=e.children&&t.append(...p({I:n,k:t.childNodes.values()},(()=>I({children:e.children}).build()))),t},z=(t,n={},e)=>(null!=e&&(n.children=e),j(t)?((t,n)=>O((()=>{const e=_().M((()=>new t));return customElements.upgrade(e),$(e,!1,n),[e]})))(t,n):"function"==typeof t?O((()=>t(n))):((t,n={})=>O((()=>{const e=_(),o="svg"==t||!!e.I;return[$(e.M((()=>o?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t))),o,n,!0)]})))(t,n)),P=new Proxy(z,{get:(t,n)=>(e,o)=>t(n,e,o)}),V=(t,n)=>{const[e,o]=c({$:[],P:new Map});let s=new Map;return l((()=>{const e=[],r=s,c=((t,n)=>{const e=new Map;for(let o=0;o<t.length;o++){const s=n(t[o],o);if(e.has(s))throw Error(`Duplicate key '${s}'`);e.set(s,o)}return e})(t(),n),i=(t=NaN)=>e.map((t=>"r"==t.V?n=>n<t.Z?n:n==t.Z?NaN:n-1:"a"==t.V?n=>n<t.Z?n:n+1:"m"==t.V?n=>t.q<=n&&n<t.B?n+1:n==t.B?t.q:n:t=>t)).reduce(((t,n)=>n(t)),t);for(const t of r.keys()){const n=i(r.get(t));c.has(t)||e.push({V:"r",F:t,Z:n})}for(let o=0;o<t().length;o++){const s=n(t()[o],o),c=i(r.get(s));isNaN(c)?e.push({V:"a",F:s,Z:o}):c!=o&&e.push({V:"m",F:s,B:c,q:o})}e.length>0&&o({$:e,P:c}),s=c})),e},Z=t=>O((()=>{const n=_(),e=d.upgrade(t.each??[]),o=n.M((()=>document.createComment(""))),s=t.key??((t,n)=>n),r=[o],i=new Map,u=V(e,s),a=t=>{for(let n=t-1;n>=0;n--){const n=s(e()[t-1],t-1),o=i.get(n)?.G??[];if(o.length>0)return o[o.length-1]}return o};return l((()=>{for(const n of u().$)if("r"==n.V){const{G:t=[],D:e}=i.get(n.F)??{};e?.();const o=r.indexOf(t[0]);o>0&&r.splice(o,t.length),t.forEach((t=>t.parentNode?.removeChild(t))),i.delete(n.F)}else if("a"==n.V){let o=[];const[,s]=f((()=>{const[s,i]=c(n.Z),[f,d]=c(e()[n.Z]);l((()=>{0<=s()&&s()<e().length&&d((()=>e()[s()]))})),l((()=>{const t=u().P.get(n.F);null!=t&&i(t)})),o=t.children?.(f,s,e).build()??[];const h=a(n.Z),_=r.indexOf(h);_>=0&&r.splice(_+1,0,...o),o.forEach((t=>h.parentNode?.insertBefore(t,h.nextSibling)))}));i.set(n.F,{G:o,D:s})}else if("m"==n.V){const{G:t=[]}=i.get(n.F)??{},e=r.indexOf(t[0]);e>=0&&r.splice(e,t.length);const o=a(n.q),s=r.indexOf(o);s>=0&&r.splice(s+1,0,...t),t.forEach((t=>o.parentNode?.insertBefore(t,o.nextSibling)))}}),[u]),r})),q=t=>(_().S=[],B({condition:t.condition,children:t.children})),B=t=>{const n=_(),e=n.S,o=u((()=>e.every((t=>!t()))&&d.get(t.condition)));return n.S=[...e,o],p({S:[]},(()=>O((()=>{const e=n.M((()=>document.createComment(""))),s=[e],r=u((()=>o()?I({children:t.children}):null));let c=[];return l((()=>{c.forEach((t=>t.parentNode?.removeChild(t))),s.length=1;const[,t]=f((()=>{c=r()?.build()??[],e.after(...c),s.push(...c)}));return t}),[r]),s}))))},F=({children:t})=>B({condition:!0,children:t}),G=({mount:t,children:n})=>O((()=>p({k:void 0},(()=>{const e=I({children:n}).build();return l((()=>(e.forEach((n=>t.appendChild(n))),()=>{e.forEach((t=>t.parentNode?.removeChild(t)))}))),[]})))),J=Symbol(),K=new Map,Q=t=>{const n=t.children;if("function"==typeof n){const e=z("style",{},D({text:n,marker:!1}));return t.light?G({mount:document.head,children:e}):e}if(n){const o=_(),s=t.light?document:o.H?.shadowRoot??document,r=((t,n,e)=>{if(!K.has(n)){const t=new CSSStyleSheet;t.replaceSync(n),K.set(n,{J:t,K:0})}const o=K.get(n);o.K++,t.has(n)||t.set(n,{J:o.J,K:0});const s=t.get(n);return s.K++,l((()=>()=>{--s.K||(t.delete(n),e()),--o.K||K.delete(n)})),s.J})((e=s,e[J]??=new Map),n,(()=>{s.adoptedStyleSheets=s.adoptedStyleSheets.filter((t=>t!=r))}));s.adoptedStyleSheets.push(r)}var e;return I({})},R=(t,...n)=>{const e=()=>t.reduce(((t,e,o)=>t+e+(d.get(n[o])??"")),"");return n.some((t=>"function"==typeof t))?e:e()},U=(t,n,e)=>(n&&null!=e&&(n.key=e),z(t,n));export{N as Component,F as Else,B as ElseIf,Z as For,I as Fragment,q as If,d as MaybeSignal,G as Portal,Q as Style,b as createContext,z as createElement,R as css,H as defineComponents,M as event,P as h,j as isComponent,U as jsx,U as jsxDEV,U as jsxs,S as prop,i as useBatch,x as useContext,E as useEffect,u as useMemo,a as useRef,c as useSignal,f as useSubscope};
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Children, type MaybeSignal, type RefSignalSetter } from "./mod.js";
|
|
2
2
|
export declare const setStyle: (node: ElementCSSInlineStyle, key: any, value: string | number | null | undefined) => void;
|
|
3
3
|
export declare const setAttr: (node: any, name: string, value: unknown, heuristic?: boolean) => void;
|
|
4
4
|
export interface DomIntrinsicElements {
|
package/dist/dom.js
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
|
+
import { isComponent } from "./component.js";
|
|
27
28
|
const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
|
|
28
29
|
export const setStyle = (node, key, value) => {
|
|
29
30
|
if (key[0] == "-") {
|
|
@@ -41,9 +42,10 @@ export const setStyle = (node, key, value) => {
|
|
|
41
42
|
export const setAttr = (node, name, value, heuristic) => {
|
|
42
43
|
const removeAttribute = value == null || (value === false && !name.includes("-"));
|
|
43
44
|
if (name.startsWith("prop:")) {
|
|
44
|
-
node[name] = value;
|
|
45
|
+
node[name.slice(5)] = value;
|
|
45
46
|
}
|
|
46
47
|
else if (name.startsWith("attr:")) {
|
|
48
|
+
name = name.slice(5);
|
|
47
49
|
if (!removeAttribute) {
|
|
48
50
|
node.setAttribute(name, value);
|
|
49
51
|
}
|
|
@@ -72,7 +74,12 @@ export const setAttr = (node, name, value, heuristic) => {
|
|
|
72
74
|
].includes(name) &&
|
|
73
75
|
name in node) {
|
|
74
76
|
try {
|
|
75
|
-
node
|
|
77
|
+
if (isComponent(node)) {
|
|
78
|
+
node[name] = value;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
node[name] = value == null ? "" : value;
|
|
82
|
+
}
|
|
76
83
|
return;
|
|
77
84
|
}
|
|
78
85
|
catch (e) { }
|
package/dist/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;
|
|
1
|
+
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
package/src/dom.ts
CHANGED
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import
|
|
29
|
-
Children,
|
|
30
|
-
MaybeSignal,
|
|
31
|
-
RefSignalSetter,
|
|
32
|
-
SignalLike,
|
|
28
|
+
import {
|
|
29
|
+
type Children,
|
|
30
|
+
type MaybeSignal,
|
|
31
|
+
type RefSignalSetter,
|
|
33
32
|
} from "./mod.js";
|
|
33
|
+
import { isComponent } from "./component.js";
|
|
34
34
|
|
|
35
35
|
const IS_NON_DIMENSIONAL =
|
|
36
36
|
/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
|
|
@@ -62,8 +62,9 @@ export const setAttr = (
|
|
|
62
62
|
value == null || (value === false && !name.includes("-"));
|
|
63
63
|
|
|
64
64
|
if (name.startsWith("prop:")) {
|
|
65
|
-
node[name] = value;
|
|
65
|
+
node[name.slice(5)] = value;
|
|
66
66
|
} else if (name.startsWith("attr:")) {
|
|
67
|
+
name = name.slice(5);
|
|
67
68
|
if (!removeAttribute) {
|
|
68
69
|
node.setAttribute(name, value);
|
|
69
70
|
} else {
|
|
@@ -92,7 +93,11 @@ export const setAttr = (
|
|
|
92
93
|
name in node
|
|
93
94
|
) {
|
|
94
95
|
try {
|
|
95
|
-
node
|
|
96
|
+
if (isComponent(node)) {
|
|
97
|
+
(node as any)[name] = value;
|
|
98
|
+
} else {
|
|
99
|
+
node[name] = value == null ? "" : value;
|
|
100
|
+
}
|
|
96
101
|
return;
|
|
97
102
|
} catch (e) {}
|
|
98
103
|
}
|