sinho 0.3.4 → 0.3.6
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.d.ts +74 -84
- package/dist/bundle.js +4 -4
- package/dist/bundle.min.js +1 -1
- package/dist/component.d.ts +4 -4
- package/dist/component.js +4 -4
- package/dist/component.js.map +1 -1
- package/dist/dom.d.ts +69 -81
- package/dist/dom.js.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js.map +1 -1
- package/package.json +2 -1
- package/src/component.ts +18 -6
- package/src/utils.ts +8 -0
- package/web/static/dist/bundle.d.ts +0 -1147
- package/web/static/dist/bundle.min.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
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)=>{const l={...o,...s};if(l.equals??=(t,n)=>t===n,e){const o="function"==typeof n?n(r.peek()):n;!l?.force&&l.equals(o,r.peek())||(l?.force?t=o:e.m.push(()=>t=o),l?.silent||r.o.forEach(t=>{t.v?e.S.add(t):e.o.add(t)}))}else i(()=>c(n,l))};return[r,c]},i=t=>{if(e)return t();e={m:[],o:new Set,S:new Set};try{const n=t();return l(),n}finally{e=void 0}},l=()=>{for(;e&&e.m.length+e.o.size+e.S.size>0;){e.o.forEach(t=>t._?.()),e.m.forEach(t=>t()),e.m=[];const t=e.S.values().next().value??e.o.values().next().value;t&&(t.u(),e.S.delete(t),e.o.delete(t))}};let u=!1;const f=(t,e)=>{const r=!!e,c={M:o,v:u,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.M.u(()=>i(t));this._=n?()=>{this.M.u(()=>i(n)),this._=null}:null}finally{n=o,s=c}}};o.o.push(c),c.u(),c.p.size||c._||o.o.pop()},a=(t,n)=>{const[e,o]=c(void 0,n);let s=!0;u=!0;try{f(()=>{o(t,s?{force:!0}:{}),s=!1})}finally{u=!1}return e},d=(n,s)=>{const r=e;e=void 0;const c=o,i=t(c);Object.assign(i.l,s?.details);try{c.i.push(i);return[i.u(n),()=>{const t=c.i.indexOf(i);t>=0&&c.i.splice(t,1),i.h()}]}finally{e=r}},h=(t,n)=>{const[e,o]=c(t,n);return e.set=o,e},_={upgrade:t=>()=>_.get(t),get:t=>"function"==typeof t?t():t,peek(t){const n=s;s=!0;try{return this.get(t)}finally{s=n}}},p=(t={})=>({k:[],C(t){return this.N?.next().value??t()},...t}),y=()=>{const t=r();return t.l.j??=p()},m=(t,n)=>{const e=y(),o=p({...e,...t}),[s,r]=d(n,{details:{j:o}});return f(()=>r),s},w=t=>(t[0]??"").toLowerCase()+t.slice(1).replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),b=t=>t.startsWith("on:")?t.slice(3):w(t.slice(2)),v=Symbol(),g=(t,n)=>({[v]:Math.random().toString(36).slice(2),A:t,H:n}),x=t=>!!t?.[v],S=(t,n,e)=>{n.addEventListener(t[v],t=>{const n=_.get(e);void 0!==n&&(t.stopPropagation(),t.detail(n))})},M=t=>{const n=y();return a(()=>{let e=t.A;return n.L?.dispatchEvent(new CustomEvent(t[v],{detail:t=>e=t,bubbles:!0,composed:!0})),e})};var k;!function(t){t.forEach=(n,e)=>n.forEach(n=>Array.isArray(n)?t.forEach(n,e):e(n)),t.last=(n,e=n.length-1)=>{if(n.length)for(let o=e;o>=0;o--){const e=n[o];if(!Array.isArray(e))return e;const s=t.last(e);if(s)return s}}}(k||(k={}));const C=t=>({build(){const n=t();return n.build?.()??n}}),E=(t,n)=>({T:"p",O:t,...n}),N=(t=CustomEvent)=>({T:"e",D:t}),j=Symbol();let A;const H=(t,n)=>{A?A.push([t,n]):f(t,n)},L=(t,n={},e={})=>{const o=[],s=new Map;for(const t in n){const e=n[t];if("p"==e.T&&e.attribute){"function"==typeof e.attribute&&(e.attribute={transform:e.attribute});const n=e.attribute={name:w(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[j]={I:t};static observedAttributes=o;props={};events={};[j]={};constructor(){super();for(const t in n){const e=n[t];if("p"==e.T){const n=x(e.O)?e.O:null,[o,s]=c(n?void 0:e.O);this.props[t]=o,n&&S(n,this,o),Object.defineProperty(this,t,{get:o.peek,set:t=>s(()=>t,{force:!0})})}else if("e"==e.T&&t.startsWith("on")){const n=b(t);this.events[t]=t=>this.dispatchEvent(new e.D(n,t))}}}connectedCallback(){const t=(n=this,e.shadow?n.shadowRoot??n.attachShadow(e.shadow):n);var n;this[j].$=d(()=>m({P:!1,L:this,N:t.childNodes.values()},()=>{this[j].M=r();const n=A;A=[];try{k.forEach(this.render().build(),n=>{t.append(n)}),A.forEach(([t,n])=>f(t,n))}finally{A=n}}))[1]}disconnectedCallback(){this[j].$?.()}attributeChangedCallback(t,n,e){const o=s.get(t);o&&(this[o.name]=null!=e?o.meta.attribute.transform.call(this,e):x(o.meta.O)?void 0:o.meta.O)}}return i},T=t=>!!t?.[j],O=(...t)=>{const[n,e]="string"==typeof t[0]?[t[0],t.slice(1)]:["",t];for(const t of e)customElements.define(n+t[j].I,t)},D=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,I=(t,n,e)=>{"-"==n[0]?t.style.setProperty(n,""+e):t.style[n]=null==e?"":"number"!=typeof e||D.test(n)?""+e:e+"px"},$=(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(t[n]=e)}catch(t){}"function"==typeof e||(s?t.removeAttribute(n):t.setAttribute(n,e))}},z=({text:t,marker:n})=>C(()=>{const e=y(),o=n&&e.C(()=>document.createComment("")),s=e.C(()=>document.createTextNode(""));return f(()=>{const n=""+(_.get(t)??"");s.textContent!=n&&(s.textContent=n)}),o?[o,s]:[s]}),P=({children:t})=>C(()=>Array.isArray(t)?t.flatMap(t=>P({children:t}).build()):null==t?[]:["object"==typeof t?t.build():z({text:t}).build()]),V=(t,n,e,o)=>{const{ref:s,style:c,children:l,dangerouslySetInnerHTML:u,...a}=e;for(const n in c??{}){const e=c[n];f(()=>{I(t,n,_.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=b(n);f(()=>(t.addEventListener(c,s),()=>t.removeEventListener(c,s)))}else f(()=>{$(t,n,_.get(e),o)})}return u&&f(()=>{const n=_.get(u).__html;t.innerHTML!=n&&(t.innerHTML=n)}),s&&f(()=>(s.set(t),()=>s.set(void 0))),null!=e.children&&k.forEach(m({P:n,N:t.childNodes.values()},()=>P({children:e.children}).build()),n=>t.append(n)),t},Z=(t,n={},e)=>(null!=e&&(n.children=e),T(t)?((t,n)=>C(()=>{const e=y().C(()=>new t);return customElements.upgrade(e),V(e,!1,n),[e]}))(t,n):"function"==typeof t?C(()=>t(n)):((t,n={})=>C(()=>{const e=y(),o="svg"==t||!!e.P;return[V(e.C(()=>o?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)),o,n,!0)]}))(t,n)),q=new Proxy(Z,{get:(t,n)=>(e,o)=>t(n,e,o)}),B=(t,n)=>{const[e,o]=c({V:[],Z:new Map},{force:!0});let s=new Map;return f(()=>{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.q?n=>n<t.B?n:n==t.B?NaN:n-1:"a"==t.q?n=>n<t.B?n:n+1:"m"==t.q?n=>t.F<=n&&n<t.G?n+1:n==t.G?t.F: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({q:"r",J:t,B:n})}for(let o=0;o<t().length;o++){const s=n(t()[o],o),c=i(r.get(s));isNaN(c)?e.push({q:"a",J:s,B:o}):c!=o&&e.push({q:"m",J:s,G:c,F:o})}e.length>0&&o({V:e,Z:c}),s=c}),e},F=t=>C(()=>{const n=y(),e=_.upgrade(t.each??[]),o=n.C(()=>document.createComment("")),s=t.key??((t,n)=>n),r=[o,[]],i=new Map,l=B(e,s),u=t=>k.last(r[1],t-1)??o;return f(()=>{for(const n of l().V)if("r"==n.q){const{K:t,$:e}=i.get(n.J)??{};e?.(),r[1].splice(n.B,1),k.forEach(t??[],t=>t.parentNode?.removeChild(t)),i.delete(n.J)}else if("a"==n.q){let o;const[,s]=d(()=>{const[s,i]=c(n.B),[a,d]=c(e()[n.B]);f(()=>{0<=s()&&s()<e().length&&d(()=>e()[s()])}),f(()=>{const t=l().Z.get(n.J);null!=t&&i(t)}),o=t.children?.(a,s,e).build()??[],r[1].splice(n.B,0,o);let h=u(n.B);k.forEach(o,t=>{h.parentNode?.insertBefore(t,h.nextSibling),h=t})});i.set(n.J,{K:o,$:s})}else if("m"==n.q){const{K:t}=i.get(n.J)??{};r[1].splice(n.G,1),r[1].splice(n.F,0,t??[]);let e=u(n.F);k.forEach(t??[],t=>{e.parentNode?.insertBefore(t,e.nextSibling),e=t})}},[l]),r}),G=t=>(y().k=[],J({condition:t.condition,children:t.children})),J=t=>{const n=y(),e=n.k,o=_.upgrade(t.condition),s=a(()=>e.every(t=>!t())&&o());return n.k=[...e,o],C(()=>m({k:[]},()=>{const e=n.C(()=>document.createComment("")),o=[e,[]],r=a(()=>s()?P({children:t.children}):null);let c=[];return f(()=>{k.forEach(c,t=>t.parentNode?.removeChild(t)),o[1]=[];const[,t]=d(()=>{c=r()?.build()??[],o[1]=c;let t=e;k.forEach(c,n=>{t.parentNode?.insertBefore(n,t.nextSibling),t=n})});return t},[r]),o}))},K=({children:t})=>J({condition:!0,children:t}),Q=({mount:t,children:n})=>C(()=>m({N:void 0},()=>{const e=P({children:n}).build();return f(()=>(k.forEach(e,n=>t.appendChild(n)),()=>{k.forEach(e,t=>t.parentNode?.removeChild(t))}),[]),[]})),R=Symbol(),U=new Map,W=t=>{const n=t.children;if("function"==typeof n){const e=Z("style",{},z({text:n,marker:!1}));return t.light?Q({mount:document.head,children:e}):e}if(n){const o=y(),s=t.light?document:o.L?.shadowRoot??document,r=((t,n,e)=>{if(!U.has(n)){const t=new CSSStyleSheet;t.replaceSync(n),U.set(n,{R:t,U:0})}const o=U.get(n);o.U++,t.has(n)||t.set(n,{R:o.R,U:0});const s=t.get(n);return s.U++,f(()=>()=>{--s.U||(t.delete(n),e()),--o.U||U.delete(n)}),s.R})((e=s,e[R]??=new Map),n,()=>{s.adoptedStyleSheets=s.adoptedStyleSheets.filter(t=>t!=r)});s.adoptedStyleSheets.push(r)}var e;return P({})},X=(t,...n)=>{const e=()=>t.reduce((t,e,o)=>t+e+(_.get(n[o])??""),"");return n.some(t=>"function"==typeof t)?e:e()},Y=(t,n,e)=>(n&&null!=e&&(n.key=e),Z(t,n));export{L as Component,K as Else,J as ElseIf,F as For,P as Fragment,G as If,_ as MaybeSignal,Q as Portal,W as Style,k as TemplateNodes,g as createContext,Z as createElement,X as css,O as defineComponents,N as event,l as flushBatch,q as h,T as isComponent,Y as jsx,Y as jsxDEV,Y as jsxs,E as prop,i as useBatch,M as useContext,H as useEffect,a as useMemo,h as useRef,c as useSignal,d as useSubscope};
|