sinwan 1.1.0 → 1.1.2
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/README.md +34 -3
- package/dist/cjs/index.development.js +357 -221
- package/dist/cjs/index.development.js.map +12 -11
- package/dist/cjs/index.production.min.js +2 -2
- package/dist/cjs/index.production.min.js.map +12 -11
- package/dist/cjs/renderer/index.development.js +300 -116
- package/dist/cjs/renderer/index.development.js.map +11 -10
- package/dist/cjs/renderer/index.production.min.js +2 -2
- package/dist/cjs/renderer/index.production.min.js.map +11 -10
- package/dist/cjs/server/index.development.js +146 -68
- package/dist/cjs/server/index.development.js.map +8 -7
- package/dist/cjs/server/index.production.min.js +2 -2
- package/dist/cjs/server/index.production.min.js.map +8 -7
- package/dist/component/control-flow.d.ts +6 -1
- package/dist/component/control-flow.d.ts.map +1 -1
- package/dist/component/instance.d.ts.map +1 -1
- package/dist/esm/index.development.js +357 -221
- package/dist/esm/index.development.js.map +12 -11
- package/dist/esm/index.production.min.js +2 -2
- package/dist/esm/index.production.min.js.map +12 -11
- package/dist/esm/renderer/index.development.js +300 -116
- package/dist/esm/renderer/index.development.js.map +11 -10
- package/dist/esm/renderer/index.production.min.js +2 -2
- package/dist/esm/renderer/index.production.min.js.map +11 -10
- package/dist/esm/server/index.development.js +146 -68
- package/dist/esm/server/index.development.js.map +8 -7
- package/dist/esm/server/index.production.min.js +2 -2
- package/dist/esm/server/index.production.min.js.map +8 -7
- package/dist/reactivity/index.d.ts +2 -1
- package/dist/reactivity/index.d.ts.map +1 -1
- package/dist/reactivity/normalization.d.ts +19 -0
- package/dist/reactivity/normalization.d.ts.map +1 -0
- package/dist/renderer/attributes.d.ts.map +1 -1
- package/dist/renderer/events.d.ts.map +1 -1
- package/dist/renderer/render-children.d.ts.map +1 -1
- package/dist/renderer/render-control-flow.d.ts.map +1 -1
- package/dist/renderer/render-element.d.ts.map +1 -1
- package/dist/renderer/types.d.ts +2 -0
- package/dist/renderer/types.d.ts.map +1 -1
- package/dist/server/renderer.d.ts.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var PS=Symbol("Fragment");class m extends String{value;constructor(S){super(S);this.value=S}toString(){return this.value}}var pY=(S)=>new m(S);function h(S){if(S==null||typeof S==="boolean")return[];if(Array.isArray(S))return S.flat(1/0);return[S]}function WS(S,Y,P){if(S===PS)return{tag:"",props:{},children:P};if(typeof S==="function"||typeof S==="string"){let x=Y??{};if(P.length>0&&x.children===void 0)x.children=P.length===1?P[0]:P;return{tag:S,props:x,children:P}}return{tag:"",props:{},children:P}}function sY(S,Y,P){return WS(S,Y,h(Y?.children))}function dY(S,Y,P){let x=Y?.children;return WS(S,Y,Array.isArray(x)?x.flat(1/0):h(x))}function cY(S,Y,P,x,W,$){let J=x?Array.isArray(Y?.children)?Y.children.flat(1/0):h(Y?.children):h(Y?.children),T=WS(S,Y,J);if(W)T.__source=W;return T}function YY(){return{createElement(S){return document.createElement(S)},createElementNS(S,Y){return document.createElementNS(S,Y)},createTextNode(S){return document.createTextNode(S)},createComment(S){return document.createComment(S)},setAttribute(S,Y,P){S.setAttribute(Y,P)},removeAttribute(S,Y){S.removeAttribute(Y)},setProperty(S,Y,P){S[Y]=P},insertBefore(S,Y,P){S.insertBefore(Y,P)},appendChild(S,Y){S.appendChild(Y)},remove(S){S.parentNode?.removeChild(S)},setTextContent(S,Y){S.data=Y},addEventListener(S,Y,P){S.addEventListener(Y,P)},removeEventListener(S,Y,P){S.removeEventListener(Y,P)},parentNode(S){return S.parentNode},nextSibling(S){return S.nextSibling}}}var KS=YY(),X={...KS};function PY(S){Object.assign(X,S)}function WY(){for(let S of Object.keys(X))delete X[S];Object.assign(X,KS)}var D=new Set,y=!1,xS=!1,QS=[];function wS(S){if(!S.active)return;D.add(S),xY()}function HS(S){D.delete(S)}function xY(){if(!y)y=!0,queueMicrotask(BS)}function BS(){xS=!0;let S=[...D].sort((x,W)=>x.id-W.id);D.clear();for(let x of S)if(x.active)x.run();let Y=10;while(D.size>0&&Y-- >0){let x=[...D].sort((W,$)=>W.id-$.id);D.clear();for(let W of x)if(W.active)W.run()}y=!1,xS=!1;let P=QS.splice(0);for(let x of P)x()}function $S(S){return new Promise((Y)=>{let P=()=>{S?.(),Y()};if(y||xS)QS.push(P);else queueMicrotask(P)})}function US(){if(y)y=!1,BS()}var C=null,JS=[],$Y=0;class i{id;active=!0;fn;cleanup=void 0;deps=new Set;constructor(S){this.id=$Y++,this.fn=S}run(){if(!this.active)return;if(JS.includes(this))return;if(this.cleanupDeps(),this.cleanup)this.cleanup(),this.cleanup=void 0;JS.push(this);let S=C;C=this;try{let Y=this.fn();if(typeof Y==="function")this.cleanup=Y}finally{C=S,JS.pop()}}cleanupDeps(){for(let S of this.deps)S.subscribers.delete(this);this.deps.clear()}notify(){wS(this)}dispose(){if(!this.active)return;if(this.active=!1,this.cleanup)this.cleanup(),this.cleanup=void 0;this.cleanupDeps(),HS(this)}}function L(S){let Y=new i(S);return Y.run(),()=>Y.dispose()}function p(S){if(C)S.subscribers.add(C),C.deps.add(S)}function s(S){let Y=[...S.subscribers];for(let P of Y)P.notify()}var AS=Symbol("Sinwan:signal");class zS{[AS]=!0;subscribers=new Set;_value;_manualSubs=new Set;constructor(S){this._value=S}get value(){return p(this),this._value}set value(S){if(Object.is(this._value,S))return;this._value=S,s(this);for(let Y of this._manualSubs)Y(S)}peek(){return this._value}subscribe(S){return this._manualSubs.add(S),()=>{this._manualSubs.delete(S)}}toString(){return String(this.value)}valueOf(){return this.value}}function TS(S){return new zS(S)}function w(S){return S!=null&&typeof S==="object"&&AS in S}var IS=Symbol("Sinwan:computed");class ES{[IS]=!0;subscribers=new Set;_value;_dirty=!0;_effect;constructor(S){let Y=this;this._effect=new i(()=>{Y._value=S()}),this._effect.notify=function(){if(!Y._dirty)Y._dirty=!0,s(Y)},this._effect.run(),this._dirty=!1}get value(){if(p(this),this._dirty)this._effect.run(),this._dirty=!1;return this._value}peek(){if(this._dirty)this._effect.run(),this._dirty=!1;return this._value}toString(){return String(this.value)}valueOf(){return this.value}}function XS(S){return new ES(S)}function H(S){return S!=null&&typeof S==="object"&&IS in S}function d(S){return S.length>2&&S[0]==="o"&&S[1]==="n"&&S[2]>="A"&&S[2]<="Z"}function DS(S){return S.slice(2).toLowerCase()}function NS(S,Y,P){return X.addEventListener(S,Y,P),()=>{X.removeEventListener(S,Y,P)}}function ZS(S,Y){let P=[];for(let x of Object.keys(Y))if(d(x)){let W=Y[x];if(typeof W==="function"){let $=DS(x);P.push(NS(S,$,W))}}return P}var JY=0;function c(S,Y,P){return{uid:JY++,component:S,props:Y,element:null,parent:P,children:[],effects:[],_mountedHooks:[],_unmountedHooks:[],_updatedHooks:[],_errorHooks:[],provides:P?Object.create(P.provides):Object.create(null),isMounted:!1,isUnmounted:!1}}var GS=null;function B(){return GS}function R(S){let Y=GS;return GS=S,Y}function MS(S,Y){let P=R(S);try{return Y()}finally{R(P)}}function g(S){if(S.isUnmounted)return;for(let Y of S.children)g(Y);if(!S.isMounted){S.isMounted=!0;for(let Y of S._mountedHooks)Y()}}function v(S){for(let Y of S.children)v(Y);if(S.isMounted&&!S.isUnmounted){S.isUnmounted=!0,S.isMounted=!1;for(let Y of S._unmountedHooks)Y();for(let Y of S.effects)Y();S.effects.length=0}}function TY(S){for(let Y of S._updatedHooks)Y()}var jS=new Set;function z(S){if(!S||!S.isMounted||S.isUnmounted||S._updatedHooks.length===0||jS.has(S))return;jS.add(S),$S(()=>{if(jS.delete(S),S.isMounted&&!S.isUnmounted)TY(S)})}function l(S,Y){let P=S;while(P){if(P._errorHooks.length>0){for(let x of P._errorHooks)x(Y);return}P=P.parent}console.error("[Sinwan] Unhandled component error:",Y)}var XY=new Set(["children","key","ref","dangerouslySetInnerHTML"]),_S=new Set(["value","checked","selected","disabled","readOnly","multiple","indeterminate"]),ZY={className:"class",htmlFor:"for",tabIndex:"tabindex",crossOrigin:"crossorigin"};function FS(S,Y){let P=[],x=B();for(let[W,$]of Object.entries(Y)){if(XY.has(W)||d(W))continue;if(w($)||H($)){let J={previousStyleProps:new Set},T=!1,Z=L(()=>{if(bS(S,W,$.value,J),T)z(x);T=!0});P.push(Z)}else bS(S,W,$)}return P}function bS(S,Y,P,x){let W=jY(Y);if(W==="style"&&typeof P==="object"&&P!==null){GY(S,P,x);return}if(W==="class"&&typeof P==="object"&&P!==null){_Y(S,P);return}if(P==null||P===!1){if(X.removeAttribute(S,W),W==="style"&&x)x.previousStyleProps.clear();if(_S.has(W))X.setProperty(S,W,W==="value"?"":!1);return}if(P===!0){if(X.setAttribute(S,W,""),W==="style"&&x)x.previousStyleProps.clear();if(_S.has(W))X.setProperty(S,W,!0);return}if(_S.has(W)){if(W==="style"&&x)x.previousStyleProps.clear();X.setProperty(S,W,P);return}if(W==="style"&&x)x.previousStyleProps.clear();X.setAttribute(S,W,String(P))}function jY(S){return ZY[S]??S}function GY(S,Y,P){let x=new Set;for(let[W,$]of Object.entries(Y)){if(x.add(W),$==null){yS(S,W);continue}if(W.includes("-"))S.style.setProperty(W,String($));else S.style[W]=$}if(!P)return;for(let W of P.previousStyleProps)if(!x.has(W))yS(S,W);P.previousStyleProps=x}function yS(S,Y){if(Y.includes("-"))S.style.removeProperty(Y);else S.style[Y]=""}function _Y(S,Y){let P;if(Array.isArray(Y))P=Y.filter(Boolean).join(" ");else if(typeof Y==="object"&&Y!==null)P=Object.entries(Y).filter(([,x])=>Boolean(x)).map(([x])=>x).join(" ");else P=String(Y);X.setAttribute(S,"class",P)}var LS=0;function FY(S){LS++;try{S()}finally{if(LS--,LS===0)US()}}var gS=Symbol.for("Sinwan.Show"),OS=Symbol.for("Sinwan.For"),kS=Symbol.for("Sinwan.Switch"),fS=Symbol.for("Sinwan.Match"),vS=Symbol.for("Sinwan.Index"),uS=Symbol.for("Sinwan.Key"),hS=Symbol.for("Sinwan.Dynamic"),mS=Symbol.for("Sinwan.Portal");function iS(S){return{tag:gS,props:S,children:[]}}function pS(S){return{tag:OS,props:S,children:[]}}function sS(S){return{tag:kS,props:S,children:[]}}function RS(S){return{tag:fS,props:S,children:[]}}function dS(S){return{tag:vS,props:S,children:[]}}function cS(S){return{tag:uS,props:S,children:[]}}function lS(S){return{tag:hS,props:S,children:[]}}function oS(S){let{when:Y,as:P="span",style:x,children:W,...$}=S,J=XS(()=>{let T=CS(x),Z=Boolean(CS(Y));if(typeof T==="string")return Z?T:RY(T);let j=T&&typeof T==="object"?{...T}:{};return j.display=Z?j.display:"none",j});return{tag:P,props:{...$,style:J,children:W},children:LY(W)}}function rS(S){return{tag:mS,props:S,children:[]}}function o(S){return S.tag===gS}function r(S){return S.tag===OS}function a(S){return S.tag===kS}function aS(S){return S.tag===fS}function t(S){return S.tag===vS}function n(S){return S.tag===uS}function e(S){return S.tag===hS}function SS(S){return S.tag===mS}function LY(S){if(S==null||typeof S==="boolean")return[];return Array.isArray(S)?S:[S]}function CS(S){return w(S)||H(S)?S.value:S}function RY(S){let Y=S.trim(),P=Y.length>0&&!Y.endsWith(";")?";":"";return`${Y}${P}display:none`}function O(S){switch(S.type){case"text":case"reactive-text":return[S.node];case"element":return[S.node];case"fragment":return[S.anchor,...S.children.flatMap((Y)=>O(Y))];case"reactive-block":return[S.startAnchor,...S.children.flatMap((Y)=>O(Y)),S.endAnchor];case"component":return S.children.flatMap((Y)=>O(Y));case"portal":return[S.anchor]}}function K(S){switch(S.type){case"text":break;case"reactive-text":S.dispose();break;case"element":for(let Y of S.attrDisposers)Y();for(let Y of S.eventCleanups)Y();S.refCleanup?.();for(let Y of S.children)K(Y);break;case"fragment":for(let Y of S.children)K(Y);break;case"reactive-block":S.dispose();for(let Y of S.children)K(Y);break;case"component":if(S.instance)v(S.instance);else for(let Y of S.disposers)Y();for(let Y of S.children)K(Y);break;case"portal":S.dispose();for(let Y of S.children)N(Y);S.children=[];break}}function N(S){let Y=O(S);K(S);for(let P of Y)if(P.parentNode)X.remove(P)}function tS(S,Y,P,x){if(SS(S))return BY(S,Y,P,x);let W=X.createComment("Sinwan-b"),$=X.createComment("/Sinwan-b");VS(Y,W,P),VS(Y,$,P);let J=B(),T=()=>{},Z={type:"reactive-block",dispose:()=>T(),children:[],startAnchor:W,endAnchor:$};if(o(S))T=VY(S,Z,Y,x,J);else if(r(S))T=qY(S,Z,Y,x,J);else if(a(S))T=KY(S,Z,Y,x,J);else if(t(S))T=QY(S,Z,Y,x,J);else if(n(S))T=wY(S,Z,Y,x,J);else if(e(S))T=HY(S,Z,Y,x,J);return Z}function VY(S,Y,P,x,W){let $=!1;return L(()=>{Q(Y);let J=b(S.props.when),T=k(W,()=>J?UY(S,J):S.props.fallback);if(Y.children=M(T,P,Y.endAnchor,x,W),$)U(W);$=!0})}function qY(S,Y,P,x,W){let $=!1,J=[];return L(()=>{let T=S.props,Z=b(T.each),j=Array.isArray(Z)?Z:[],q=T.children;if(typeof q!=="function"){if(Q(Y),J=[],$)z(W);$=!0;return}if(j.length===0){if(Q(Y),J=[],Y.children=M(T.fallback,P,Y.endAnchor,x,W),$)U(W);$=!0;return}if(J.length===0&&Y.children.length>0)Q(Y);let G=new Map;for(let _ of J)G.set(_.key,_);let V=[];j.forEach((_,f)=>{let u=T.key?T.key(_,f):_,E=G.get(u);if(E&&E.item===_){E.index=f,NY(P,E.mounted,Y.endAnchor),V.push(E),G.delete(u);return}if(E)N(E.mounted),G.delete(u);let YS={key:u,item:_,index:f,mounted:{type:"text",node:X.createTextNode("")}};YS.mounted=k(W,()=>F(q(_,()=>YS.index),P,Y.endAnchor,x)),V.push(YS)});for(let _ of G.values())N(_.mounted);if(J=V,Y.children=V.map((_)=>_.mounted),$)U(W);$=!0})}function KY(S,Y,P,x,W){let $=!1;return L(()=>{Q(Y);let J=k(W,()=>AY(S));if(Y.children=M(J,P,Y.endAnchor,x,W),$)U(W);$=!0})}function QY(S,Y,P,x,W){let $=!1,J=[];return L(()=>{let T=S.props,Z=b(T.each),j=Array.isArray(Z)?Z:[],q=T.children;if(typeof q!=="function"){if(Q(Y),J=[],$)z(W);$=!0;return}if(j.length===0){if(Q(Y),J=[],Y.children=M(T.fallback,P,Y.endAnchor,x,W),$)U(W);$=!0;return}if(J.length===0&&Y.children.length>0)Q(Y);for(let G=0;G<j.length;G++){let V=J[G];if(V){V.item.value=j[G];continue}let _=TS(j[G]),f={item:_,mounted:k(W,()=>F(q(()=>_.value,G),P,Y.endAnchor,x))};J.push(f)}while(J.length>j.length){let G=J.pop();N(G.mounted)}if(Y.children=J.map((G)=>G.mounted),$)U(W);$=!0})}function wY(S,Y,P,x,W){let $=!1,J=!1,T;return L(()=>{let Z=b(S.props.when);if(J&&Object.is(T,Z))return;T=Z,J=!0,Q(Y);let j=k(W,()=>IY(S,Z));if(Y.children=M(j,P,Y.endAnchor,x,W),$)U(W);$=!0})}function HY(S,Y,P,x,W){let $=!1,J=!1,T;return L(()=>{let Z=b(S.props.component);if(J&&Object.is(T,Z))return;T=Z,J=!0,Q(Y);let j=Z?EY(S,Z):null;if(Y.children=M(j,P,Y.endAnchor,x,W),$)U(W);$=!0})}function BY(S,Y,P,x){let W=X.createComment("Sinwan-p");VS(Y,W,P);let $=B(),J=()=>{},T={type:"portal",anchor:W,children:[],dispose:()=>J()},Z=!1;return J=L(()=>{DY(T);let j=yY(S.props.mount);if(j)T.children=M(S.props.children??S.children,j,null,x,$);if(Z)U($);Z=!0}),T}function UY(S,Y){let P=S.props.children??S.children;if(typeof P==="function")return P(Y);return P}function AY(S){let Y=S.props,P=nS(Y.children??S.children);for(let x of P){let W=bY(x);if(!W)continue;let $=b(W.props.when);if($)return zY(W,$)}return Y.fallback}function zY(S,Y){let P=S.props.children??S.children;if(typeof P==="function")return P(Y);return P}function IY(S,Y){let P=S.props.children??S.children;if(typeof P==="function")return P(Y);return P}function EY(S,Y){if(typeof Y!=="string"&&typeof Y!=="function")return null;let{component:P,...x}=S.props,W=nS(x.children??S.children);return{tag:Y,props:x,children:W}}function M(S,Y,P,x,W){if(S==null||typeof S==="boolean")return[];return(Array.isArray(S)?S:[S]).map((J)=>k(W,()=>F(J,Y,P,x)))}function Q(S){for(let Y of S.children)N(Y);S.children=[]}function DY(S){for(let Y of S.children)N(Y);S.children=[]}function NY(S,Y,P){for(let x of O(Y))X.insertBefore(S,x,P)}function U(S){if(S)g(S);z(S)}function k(S,Y){return S?MS(S,Y):Y()}function b(S){return w(S)||H(S)?S.value:S}function nS(S){if(S==null||typeof S==="boolean")return[];return Array.isArray(S)?S:[S]}function MY(S){return S!=null&&typeof S==="object"&&"tag"in S}function bY(S){if(!MY(S))return null;if(aS(S))return S;return S.tag===RS?RS(S.props):null}function yY(S){let Y=b(S);if(Y==null)return typeof document>"u"?null:document.body;if(typeof Y==="string")return document.querySelector(Y);if(typeof Y==="function")return Y();if(typeof Y==="object"&&"nodeType"in Y)return Y;return null}function VS(S,Y,P){if(P)X.insertBefore(S,Y,P);else X.appendChild(S,Y)}var CY=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),SY="http://www.w3.org/2000/svg",gY="http://www.w3.org/1998/Math/MathML";function A(S,Y,P=null,x=null){let{tag:W,props:$,children:J}=S;if(W===""||W===PS)return eS(J,Y,P,x);if(W===iS||W===pS||W===sS||W===dS||W===cS||W===lS||W===rS)return A(W($),Y,P,x);if(W===oS)return A(W($),Y,P,x);if(o(S)||r(S)||a(S)||t(S)||n(S)||e(S)||SS(S))return tS(S,Y,P,x);if(typeof W==="function")return kY(W,$,Y,P,x);if(typeof W==="string")return OY(W,$,J,Y,P,x);return eS(J,Y,P,x)}function OY(S,Y,P,x,W,$){let J=fY(S,$),T=J?X.createElementNS(J,S):X.createElement(S),Z=FS(T,Y),j=ZS(T,Y),q=[];if(!CY.has(S)){let V=Y.dangerouslySetInnerHTML;if(V&&typeof V.__html==="string")T.innerHTML=V.__html;else q=qS(P,T,vY(S,J))}if(W)X.insertBefore(x,T,W);else X.appendChild(x,T);let G=uY(T,Y.ref);return{type:"element",node:T,children:q,eventCleanups:j,attrDisposers:Z,refCleanup:G}}function kY(S,Y,P,x,W){let $=B(),J=c(S,Y,$);if($)$.children.push(J);let T=R(J),Z,j;try{if(Z=S(Y),Z&&typeof Z==="object"&&"tag"in Z)j=A(Z,P,x,W);else j=F(Z,P,x,W)}catch(q){R(T),l(J,q);let G=X.createTextNode("");if(x)X.insertBefore(P,G,x);else X.appendChild(P,G);return{type:"component",children:[{type:"text",node:G}],disposers:[],instance:J}}return R(T),J.element=j,{type:"component",children:[j],disposers:J.effects,instance:J}}function eS(S,Y,P,x){let W=X.createComment("Sinwan-f");if(P)X.insertBefore(Y,W,P);else X.appendChild(Y,W);let $=[];for(let J of S)$.push(F(J,Y,P,x));return{type:"fragment",children:$,anchor:W}}function fY(S,Y){if(S==="svg")return SY;if(S==="math")return gY;return Y}function vY(S,Y){if(Y===SY&&S==="foreignObject")return null;return Y}function uY(S,Y){let P=Y;if(!P)return null;if(typeof P==="function")return P(S),()=>P(null);if(typeof P==="object"&&"current"in P)return P.current=S,()=>{P.current=null};return null}function F(S,Y,P=null,x=null){if(S==null||typeof S==="boolean"){let $=X.createTextNode("");return I(Y,$,P),{type:"text",node:$}}if(typeof S==="string"){let $=X.createTextNode(S);return I(Y,$,P),{type:"text",node:$}}if(typeof S==="number"){let $=X.createTextNode(String(S));return I(Y,$,P),{type:"text",node:$}}if(S instanceof m){let $=X.createTextNode(S.value);return I(Y,$,P),{type:"text",node:$}}if(w(S)||H(S)){let $=X.createTextNode(String(S.value));I(Y,$,P);let J=B(),T=!1,Z=L(()=>{if(X.setTextContent($,String(S.value)),T)z(J);T=!0});return{type:"reactive-text",node:$,dispose:Z}}if(Array.isArray(S))return hY(S,Y,P,x);if(S instanceof Promise){let $=X.createTextNode("");return I(Y,$,P),S.then((J)=>{let T=F(J,Y,$,x);X.remove($)}),{type:"text",node:$}}if(typeof S==="object"&&"tag"in S)return A(S,Y,P,x);let W=X.createTextNode(String(S));return I(Y,W,P),{type:"text",node:W}}function hY(S,Y,P,x){let W=X.createComment("Sinwan-f");I(Y,W,P);let $=[];for(let J of S)$.push(F(J,Y,P,x));return{type:"fragment",children:$,anchor:W}}function qS(S,Y,P=null){let x=[];for(let W of S)x.push(F(W,Y,null,P));return x}function I(S,Y,P){if(P)X.insertBefore(S,Y,P);else X.appendChild(S,Y)}function mY(S,Y,P){Y.innerHTML="";let x=P??{},W=c(S,x,null),$,J;R(W);try{if($=S(x),$ instanceof Promise){let T=document.createTextNode("");Y.appendChild(T),J={type:"text",node:T},$.then((Z)=>{Y.innerHTML="",R(W),J=A(Z,Y),R(null),W.element=J,g(W)})}else if($&&typeof $==="object"&&"tag"in $)J=A($,Y);else J=F($,Y)}catch(T){return R(null),l(W,T),{root:{type:"text",node:document.createTextNode("")},unmount(){}}}return R(null),W.element=J,g(W),{root:J,unmount(){v(W),K(J),Y.innerHTML=""}}}function iY(S,Y){Y.innerHTML="";let P=F(S,Y);return{root:P,unmount(){K(P),Y.innerHTML=""}}}export{K as unmountNode,DS as toEventName,PY as setDOMOps,WY as resetDOMOps,F as renderNodeToDOM,A as renderElementToDOM,qS as renderChildrenToDOM,iY as render,mY as mount,d as isEventProp,X as domOps,ZS as bindEvents,NS as bindEvent,FS as applyAttributes};
|
|
2
|
+
var LJ=Symbol("Fragment");class o extends String{value;constructor(J){super(J);this.value=J}toString(){return this.value}}var eZ=(J)=>new o(J);function l(J){if(J==null||typeof J==="boolean")return[];if(Array.isArray(J))return J.flat(1/0);return[J]}function QJ(J,Z,$){if(J===LJ)return{tag:"",props:{},children:$};if(typeof J==="function"||typeof J==="string"){let G=Z??{};if($.length>0&&G.children===void 0)G.children=$.length===1?$[0]:$;return{tag:J,props:G,children:$}}return{tag:"",props:{},children:$}}function J0(J,Z,$){return QJ(J,Z,l(Z?.children))}function Z0(J,Z,$){let G=Z?.children;return QJ(J,Z,Array.isArray(G)?G.flat(1/0):l(G))}function $0(J,Z,$,G,X,W){let q=G?Array.isArray(Z?.children)?Z.children.flat(1/0):l(Z?.children):l(Z?.children),L=QJ(J,Z,q);if(X)L.__source=X;return L}function FZ(){return{createElement(J){return document.createElement(J)},createElementNS(J,Z){return document.createElementNS(J,Z)},createTextNode(J){return document.createTextNode(J)},createComment(J){return document.createComment(J)},setAttribute(J,Z,$){J.setAttribute(Z,$)},removeAttribute(J,Z){J.removeAttribute(Z)},setProperty(J,Z,$){J[Z]=$},insertBefore(J,Z,$){J.insertBefore(Z,$)},appendChild(J,Z){J.appendChild(Z)},remove(J){J.parentNode?.removeChild(J)},setTextContent(J,Z){J.data=Z},addEventListener(J,Z,$){J.addEventListener(Z,$)},removeEventListener(J,Z,$){J.removeEventListener(Z,$)},parentNode(J){return J.parentNode},nextSibling(J){return J.nextSibling}}}var wJ=FZ(),Q={...wJ};function YZ(J){Object.assign(Q,J)}function KZ(){for(let J of Object.keys(Q))delete Q[J];Object.assign(Q,wJ)}var C=new Set,b=!1,jJ=!1,OJ=[];function yJ(J){if(!J.active)return;C.add(J),BZ()}function bJ(J){C.delete(J)}function BZ(){if(!b)b=!0,queueMicrotask(gJ)}function gJ(){jJ=!0;let J=[...C].sort((G,X)=>G.id-X.id);C.clear();for(let G of J)if(G.active)G.run();let Z=10;while(C.size>0&&Z-- >0){let G=[...C].sort((X,W)=>X.id-W.id);C.clear();for(let X of G)if(X.active)X.run()}b=!1,jJ=!1;let $=OJ.splice(0);for(let G of $)G()}function VJ(J){return new Promise((Z)=>{let $=()=>{J?.(),Z()};if(b||jJ)OJ.push($);else queueMicrotask($)})}function FJ(){if(b)b=!1,gJ()}var g=null,YJ=[],UZ=0;class r{id;active=!0;fn;cleanup=void 0;deps=new Set;constructor(J){this.id=UZ++,this.fn=J}run(){if(!this.active)return;if(YJ.includes(this))return;if(this.cleanupDeps(),this.cleanup)this.cleanup(),this.cleanup=void 0;YJ.push(this);let J=g;g=this;try{let Z=this.fn();if(typeof Z==="function")this.cleanup=Z}finally{g=J,YJ.pop()}}cleanupDeps(){for(let J of this.deps)J.subscribers.delete(this);this.deps.clear()}notify(){yJ(this)}dispose(){if(!this.active)return;if(this.active=!1,this.cleanup)this.cleanup(),this.cleanup=void 0;this.cleanupDeps(),bJ(this)}}function U(J){let Z=new r(J);return Z.run(),()=>Z.dispose()}function a(J){if(g)J.subscribers.add(g),g.deps.add(J)}function t(J){let Z=[...J.subscribers];for(let $ of Z)$.notify()}var kJ=Symbol("Sinwan:signal");class fJ{[kJ]=!0;subscribers=new Set;_value;_manualSubs=new Set;constructor(J){this._value=J}get value(){return a(this),this._value}set value(J){if(Object.is(this._value,J))return;this._value=J,t(this);for(let Z of this._manualSubs)Z(J)}peek(){return this._value}subscribe(J){return this._manualSubs.add(J),()=>{this._manualSubs.delete(J)}}toString(){return String(this.value)}valueOf(){return this.value}}function KJ(J){return new fJ(J)}function n(J){return J!=null&&typeof J==="object"&&kJ in J}var vJ=Symbol("Sinwan:computed");class hJ{[vJ]=!0;subscribers=new Set;_value;_dirty=!0;_effect;constructor(J){let Z=this;this._effect=new r(()=>{Z._value=J()}),this._effect.notify=function(){if(!Z._dirty)Z._dirty=!0,t(Z)},this._effect.run(),this._dirty=!1}get value(){if(a(this),this._dirty)this._effect.run(),this._dirty=!1;return this._value}peek(){if(this._dirty)this._effect.run(),this._dirty=!1;return this._value}toString(){return String(this.value)}valueOf(){return this.value}}function BJ(J){return new hJ(J)}function e(J){return J!=null&&typeof J==="object"&&vJ in J}var UJ=0;function HZ(J){UJ++;try{J()}finally{if(UJ--,UJ===0)FJ()}}function k(J){return n(J)||e(J)||typeof J==="function"}function H(J){if(n(J)||e(J))return J.value;if(typeof J==="function")return J();return J}function JJ(J){return J.length>2&&J.startsWith("on")}function uJ(J){return J.slice(2).toLowerCase()}function mJ(J,Z,$){return Q.addEventListener(J,Z,$),()=>{Q.removeEventListener(J,Z,$)}}function HJ(J,Z){let $=[];for(let G of Object.keys(Z))if(JJ(G)){let X=Z[G];if(typeof X==="function"){let W=uJ(G);$.push(mJ(J,W,X))}}return $}var _Z=0;function ZJ(J,Z,$){return{uid:_Z++,component:J,props:Z,element:null,parent:$,children:[],effects:[],_mountedHooks:[],_unmountedHooks:[],_updatedHooks:[],_errorHooks:[],provides:$?Object.create($.provides):Object.create(null),isMounted:!1,isUnmounted:!1}}var zJ=null;function x(){return zJ}function _(J){let Z=zJ;return zJ=J,Z}function pJ(J,Z){let $=_(J);try{return Z()}finally{_($)}}function T(J){if(J.isUnmounted)return;for(let Z of J.children)T(Z);if(!J.isMounted){J.isMounted=!0;for(let Z of J._mountedHooks)Z()}}function m(J){let Z=[...J.children];for(let $ of Z)m($);if(!J.isUnmounted){if(J.isUnmounted=!0,J.isMounted){J.isMounted=!1;for(let $ of J._unmountedHooks)$()}for(let $ of J.effects)$();if(J.effects.length=0,J.parent){let $=J.parent.children.indexOf(J);if($!==-1)J.parent.children.splice($,1)}}}function zZ(J){for(let Z of J._updatedHooks)Z()}var _J=new Set;function M(J){if(!J||!J.isMounted||J.isUnmounted||J._updatedHooks.length===0||_J.has(J))return;_J.add(J),VJ(()=>{if(_J.delete(J),J.isMounted&&!J.isUnmounted)zZ(J)})}function $J(J,Z){let $=J;while($){if($._errorHooks.length>0){for(let G of $._errorHooks)G(Z);return}$=$.parent}console.error("[Sinwan] Unhandled component error:",Z)}var AZ=new Set(["children","key","ref","dangerouslySetInnerHTML"]),AJ=new Set(["value","checked","selected","disabled","readOnly","multiple","indeterminate"]),RZ={className:"class",htmlFor:"for",tabIndex:"tabindex",crossOrigin:"crossorigin"};function xJ(J,Z){let $=[],G=x();for(let[X,W]of Object.entries(Z)){if(AZ.has(X)||JJ(X))continue;let q=dJ(X),L=q==="class"||q==="style";if(k(W)||L&&RJ(W)){let j={previousStyleProps:new Set},V=!1,Y=U(()=>{if(iJ(J,X,H(W),j),V)M(G);V=!0});$.push(Y)}else iJ(J,X,W)}return $}function iJ(J,Z,$,G){let X=dJ(Z);if(X==="style"&&typeof $==="object"&&$!==null){xZ(J,$,G);return}if(X==="class"&&typeof $==="object"&&$!==null){IZ(J,$);return}if($==null||$===!1){if(Q.removeAttribute(J,X),X==="style"&&G)G.previousStyleProps.clear();if(AJ.has(X))Q.setProperty(J,X,X==="value"?"":!1);return}if($===!0){if(Q.setAttribute(J,X,""),X==="style"&&G)G.previousStyleProps.clear();if(AJ.has(X))Q.setProperty(J,X,!0);return}if(AJ.has(X)){if(X==="style"&&G)G.previousStyleProps.clear();Q.setProperty(J,X,$);return}if(X==="style"&&G)G.previousStyleProps.clear();Q.setAttribute(J,X,String($))}function dJ(J){return RZ[J]??J}function xZ(J,Z,$){let G=cJ(Z),X=new Set;for(let[W,q]of Object.entries(G)){if(X.add(W),q==null){sJ(J,W);continue}let L=W.startsWith("--")?W:oJ(W);J.style.setProperty(L,String(q))}if(!$)return;for(let W of $.previousStyleProps)if(!X.has(W))sJ(J,W);$.previousStyleProps=X}function cJ(J){let Z=H(J);if(!Z)return{};if(typeof Z==="string")return PZ(Z);if(Array.isArray(Z))return Z.reduce(($,G)=>{let X=cJ(G);return Object.assign($,X)},{});if(typeof Z==="object"){let $={};for(let[G,X]of Object.entries(Z))$[G]=H(X);return $}return{}}function PZ(J){let Z={};return J.split(";").forEach(($)=>{let G=$.indexOf(":");if(G>0){let X=$.slice(0,G).trim(),W=$.slice(G+1).trim();if(X&&W)Z[X]=W}}),Z}function sJ(J,Z){let $=Z.startsWith("--")?Z:oJ(Z);J.style.removeProperty($)}function IZ(J,Z){Q.setAttribute(J,"class",lJ(Z))}function lJ(J){let Z=H(J);if(!Z)return"";if(typeof Z==="string")return Z;if(Array.isArray(Z))return Z.map(lJ).filter(Boolean).join(" ");if(typeof Z==="object")return Object.entries(Z).filter(([,$])=>Boolean(H($))).map(([$])=>$).join(" ");return String(Z)}function RJ(J){if(k(J))return!0;if(Array.isArray(J))return J.some(RJ);if(typeof J==="object"&&J!==null)return Object.values(J).some(RJ);return!1}function oJ(J){return J.replace(/[A-Z]/g,(Z)=>`-${Z.toLowerCase()}`)}var rJ=Symbol.for("Sinwan.Show"),aJ=Symbol.for("Sinwan.For"),tJ=Symbol.for("Sinwan.Switch"),nJ=Symbol.for("Sinwan.Match"),eJ=Symbol.for("Sinwan.Index"),JZ=Symbol.for("Sinwan.Key"),ZZ=Symbol.for("Sinwan.Dynamic"),$Z=Symbol.for("Sinwan.Portal");function PJ(J){return{tag:rJ,props:J,children:[]}}function IJ(J){return{tag:aJ,props:J,children:[]}}function SJ(J){return{tag:tJ,props:J,children:[]}}function SZ(J){return{tag:nJ,props:J,children:[]}}function DJ(J){return{tag:eJ,props:J,children:[]}}function TJ(J){return{tag:JZ,props:J,children:[]}}function XZ(J){return{tag:ZZ,props:J,children:[]}}function GZ(J){let{when:Z,as:$="span",style:G,children:X,...W}=J,q=BJ(()=>{let L=w(G),j=Boolean(w(Z));if(typeof L==="string")return j?L:CZ(L);let V=L&&typeof L==="object"?{...L}:{};return V.display=j?V.display:"none",V});return{tag:$,props:{...W,style:q,children:X},children:NZ(X)}}function WZ(J){return{tag:$Z,props:J,children:[]}}function DZ(J){return J!=null&&typeof J==="object"&&"tag"in J}function p(J){return J.tag===rJ}function i(J){return J.tag===aJ}function XJ(J){return J.tag===tJ}function TZ(J){return J.tag===nJ}function s(J){return J.tag===eJ}function d(J){return J.tag===JZ}function GJ(J){return J.tag===ZZ}function WJ(J){return J.tag===$Z}function qZ(J){let Z=J.props,$=f(Z.children??J.children),G=E($);return G!==void 0?G:Z.fallback}function E(J){for(let Z of J){if(Z==null||typeof Z==="boolean")continue;if(Array.isArray(Z)){let $=E(Z);if($!==void 0)return $;continue}if(DZ(Z)){let $=Z;if(typeof $.tag==="function"){let G=$.tag;if(G===SZ||G===PJ||G===IJ||G===DJ||G===TJ||G===SJ)$=G($.props)}if(TZ($)){let G=w($.props.when);if(G)return MZ($,G)}else if(p($)){let G=w($.props.when);if(G){let X=MJ($,G),W=E(f(X));if(W!==void 0)return W}else if($.props.fallback){let X=E(f($.props.fallback));if(X!==void 0)return X}}else if(i($)){let G=$.props,X=w(G.each);if(Array.isArray(X))for(let W=0;W<X.length;W++){let q=G.children(X[W],()=>W),L=E(f(q));if(L!==void 0)return L}}else if(s($)){let G=$.props,X=w(G.each);if(Array.isArray(X))for(let W=0;W<X.length;W++){let q=G.children(()=>X[W],W),L=E(f(q));if(L!==void 0)return L}}else if(d($)){let G=w($.props.when),X=NJ($,G),W=E(f(X));if(W!==void 0)return W}}}return}function MZ(J,Z){let $=J.props.children??J.children;if(typeof $==="function")return $(Z);return $}function MJ(J,Z){let $=J.props.children??J.children;if(typeof $==="function")return $(Z);return $}function NJ(J,Z){let $=J.props.children??J.children;if(typeof $==="function")return $(Z);return $}function f(J){if(J==null||typeof J==="boolean")return[];return Array.isArray(J)?J:[J]}function NZ(J){if(J==null||typeof J==="boolean")return[];return Array.isArray(J)?J:[J]}function w(J){return H(J)}function CZ(J){let Z=J.trim(),$=Z.length>0&&!Z.endsWith(";")?";":"";return`${Z}${$}display:none`}function O(J){switch(J.type){case"text":case"reactive-text":return[J.node];case"element":return[J.node];case"fragment":return[J.anchor,...J.children.flatMap((Z)=>O(Z))];case"reactive-block":return[J.startAnchor,...J.children.flatMap((Z)=>O(Z)),J.endAnchor];case"component":return J.children.flatMap((Z)=>O(Z));case"portal":return[J.anchor]}}function A(J){switch(J.type){case"text":break;case"reactive-text":J.dispose();break;case"element":for(let Z of J.attrDisposers)Z();for(let Z of J.eventCleanups)Z();J.refCleanup?.();for(let Z of J.children)A(Z);break;case"fragment":for(let Z of J.children)A(Z);break;case"reactive-block":J.dispose();for(let Z of J.children)A(Z);break;case"component":if(J.instance)m(J.instance);else for(let Z of J.disposers)Z();for(let Z of J.children)A(Z);break;case"portal":J.dispose();for(let Z of J.children)P(Z);J.children=[];break}}function P(J){let Z=O(J);A(J);for(let $ of Z)if($.parentNode)Q.remove($)}function LZ(J,Z,$,G){if(WJ(J))return kZ(J,Z,$,G);let X=Q.createComment("Sinwan-b"),W=Q.createComment("/Sinwan-b");CJ(Z,X,$),CJ(Z,W,$);let q=x(),L=()=>{},j={type:"reactive-block",dispose:()=>L(),children:[],startAnchor:X,endAnchor:W};if(p(J))L=EZ(J,j,Z,G,q);else if(i(J))L=wZ(J,j,Z,G,q);else if(XJ(J))L=OZ(J,j,Z,G,q);else if(s(J))L=yZ(J,j,Z,G,q);else if(d(J))L=bZ(J,j,Z,G,q);else if(GJ(J))L=gZ(J,j,Z,G,q);return j}function EZ(J,Z,$,G,X){let W=!1;return U(()=>{R(Z);let q=h(J.props.when);if(Z.children=v(X,()=>{let L=q?MJ(J,q):J.props.fallback;return y(L,$,Z.endAnchor,G,X)}),W)I(X);W=!0})}function wZ(J,Z,$,G,X){let W=!1,q=[];return U(()=>{let L=J.props,j=h(L.each),V=Array.isArray(j)?j:[],Y=L.children;if(typeof Y!=="function"){if(R(Z),q=[],W)M(X);W=!0;return}if(V.length===0){if(R(Z),q=[],Z.children=y(L.fallback,$,Z.endAnchor,G,X),W)I(X);W=!0;return}if(q.length===0&&Z.children.length>0)R(Z);let F=new Map;for(let B of q)F.set(B.key,B);let z=[];V.forEach((B,u)=>{let c=L.key?L.key(B,u):B,N=F.get(c);if(N&&N.item===B){N.index=u,hZ($,N.mounted,Z.endAnchor),z.push(N),F.delete(c);return}if(N)P(N.mounted),F.delete(c);let qJ={key:c,item:B,index:u,mounted:{type:"text",node:Q.createTextNode("")}};qJ.mounted=v(X,()=>K(Y(B,()=>qJ.index),$,Z.endAnchor,G)),z.push(qJ)});for(let B of F.values())P(B.mounted);if(q=z,Z.children=z.map((B)=>B.mounted),W)I(X);W=!0})}function OZ(J,Z,$,G,X){let W=!1;return U(()=>{R(Z);let q=v(X,()=>qZ(J));if(Z.children=y(q,$,Z.endAnchor,G,X),W)I(X);W=!0})}function yZ(J,Z,$,G,X){let W=!1,q=[];return U(()=>{let L=J.props,j=h(L.each),V=Array.isArray(j)?j:[],Y=L.children;if(typeof Y!=="function"){if(R(Z),q=[],W)M(X);W=!0;return}if(V.length===0){if(R(Z),q=[],Z.children=y(L.fallback,$,Z.endAnchor,G,X),W)I(X);W=!0;return}if(q.length===0&&Z.children.length>0)R(Z);for(let F=0;F<V.length;F++){let z=q[F];if(z){z.item.value=V[F];continue}let B=KJ(V[F]),u={item:B,mounted:v(X,()=>K(Y(()=>B.value,F),$,Z.endAnchor,G))};q.push(u)}while(q.length>V.length){let F=q.pop();P(F.mounted)}if(Z.children=q.map((F)=>F.mounted),W)I(X);W=!0})}function bZ(J,Z,$,G,X){let W=!1,q=!1,L;return U(()=>{let j=h(J.props.when);if(q&&Object.is(L,j))return;L=j,q=!0,R(Z);let V=v(X,()=>NJ(J,j));if(Z.children=y(V,$,Z.endAnchor,G,X),W)I(X);W=!0})}function gZ(J,Z,$,G,X){let W=!1,q=!1,L;return U(()=>{let j=h(J.props.component);if(q&&Object.is(L,j))return;L=j,q=!0,R(Z);let V=j?fZ(J,j):null;if(Z.children=y(V,$,Z.endAnchor,G,X),W)I(X);W=!0})}function kZ(J,Z,$,G){let X=Q.createComment("Sinwan-p");CJ(Z,X,$);let W=x(),q=()=>{},L=Q.createComment("Sinwan-pa"),j=null,V={type:"portal",anchor:X,children:[],dispose:()=>q(),targetAnchor:L},Y=!1;return q=U(()=>{let F=mZ(J.props.mount);if(F!==j){if(j)Q.remove(L);if(F)Q.appendChild(F,L);j=F,V.target=F}if(vZ(V),F)V.children=y(J.props.children??J.children,F,L,G,W);if(Y)I(W);Y=!0}),V}function fZ(J,Z){if(typeof Z!=="string"&&typeof Z!=="function")return null;let{component:$,...G}=J.props,X=uZ(G.children??J.children);return{tag:Z,props:G,children:X}}function y(J,Z,$,G,X){if(J==null||typeof J==="boolean")return[];return v(X,()=>{if(Array.isArray(J))return J.map((W)=>K(W,Z,$,G));return[K(J,Z,$,G)]})}function R(J){for(let Z of J.children)P(Z);J.children=[]}function vZ(J){for(let Z of J.children)P(Z);J.children=[]}function hZ(J,Z,$){for(let G of O(Z))Q.insertBefore(J,G,$);QZ(Z)}function QZ(J){if(J.type==="portal"){if(J.target&&J.targetAnchor){for(let Z of J.children)for(let $ of O(Z))Q.appendChild(J.target,$);Q.appendChild(J.target,J.targetAnchor)}}else if("children"in J&&Array.isArray(J.children))for(let Z of J.children)QZ(Z)}function I(J){if(J)T(J);M(J)}function v(J,Z){return J?pJ(J,Z):Z()}function h(J){return H(J)}function uZ(J){if(J==null||typeof J==="boolean")return[];return Array.isArray(J)?J:[J]}function mZ(J){let Z=h(J);if(Z==null)return typeof document>"u"?null:document.body;if(typeof Z==="string")return document.querySelector(Z);if(typeof Z==="function")return Z();if(typeof Z==="object"&&"nodeType"in Z)return Z;return null}function CJ(J,Z,$){if($)Q.insertBefore(J,Z,$);else Q.appendChild(J,Z)}var pZ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),VZ="http://www.w3.org/2000/svg",iZ="http://www.w3.org/1998/Math/MathML";function S(J,Z,$=null,G=null){let{tag:X,props:W,children:q}=J;if(X===""||X===LJ)return jZ(q,Z,$,G);if(X===PJ||X===IJ||X===SJ||X===DJ||X===TJ||X===XZ||X===WZ)return S(X(W),Z,$,G);if(X===GZ)return S(X(W),Z,$,G);if(p(J)||i(J)||XJ(J)||s(J)||d(J)||GJ(J)||WJ(J))return LZ(J,Z,$,G);if(typeof X==="function")return dZ(X,W,Z,$,G);if(typeof X==="string")return sZ(X,W,q,Z,$,G);return jZ(q,Z,$,G)}function sZ(J,Z,$,G,X,W){let q=cZ(J,W),L=q?Q.createElementNS(q,J):Q.createElement(J),j=xJ(L,Z),V=HJ(L,Z),Y=[];if(!pZ.has(J)){let z=Z.dangerouslySetInnerHTML;if(z&&typeof z.__html==="string")L.innerHTML=z.__html;else Y=EJ($,L,lZ(J,q))}if(X)Q.insertBefore(G,L,X);else Q.appendChild(G,L);let F=oZ(L,Z.ref);return{type:"element",node:L,children:Y,eventCleanups:V,attrDisposers:j,refCleanup:F}}function dZ(J,Z,$,G,X){let W=x(),q=ZJ(J,Z,W);if(W)W.children.push(q);let L=_(q),j,V;try{if(j=J(Z),j&&typeof j==="object"&&"tag"in j)V=S(j,$,G,X);else V=K(j,$,G,X)}catch(Y){_(L),$J(q,Y);let F=Q.createTextNode("");if(G)Q.insertBefore($,F,G);else Q.appendChild($,F);return{type:"component",children:[{type:"text",node:F}],disposers:[],instance:q}}return _(L),q.element=V,{type:"component",children:[V],disposers:q.effects,instance:q}}function jZ(J,Z,$,G){let X=Q.createComment("Sinwan-f");if($)Q.insertBefore(Z,X,$);else Q.appendChild(Z,X);let W=[];for(let q of J)W.push(K(q,Z,$,G));return{type:"fragment",children:W,anchor:X}}function cZ(J,Z){if(J==="svg")return VZ;if(J==="math")return iZ;return Z}function lZ(J,Z){if(Z===VZ&&J==="foreignObject")return null;return Z}function oZ(J,Z){let $=Z;if(!$)return null;if(typeof $==="function")return $(J),()=>$(null);if(typeof $==="object"&&"current"in $)return $.current=J,()=>{$.current=null};return null}function K(J,Z,$=null,G=null){if(J==null||typeof J==="boolean"){let W=Q.createTextNode("");return D(Z,W,$),{type:"text",node:W}}if(typeof J==="string"){let W=Q.createTextNode(J);return D(Z,W,$),{type:"text",node:W}}if(typeof J==="number"){let W=Q.createTextNode(String(J));return D(Z,W,$),{type:"text",node:W}}if(J instanceof o){let W=Q.createTextNode(J.value);return D(Z,W,$),{type:"text",node:W}}if(k(J))return aZ(J,Z,$,G);if(Array.isArray(J))return rZ(J,Z,$,G);if(J instanceof Promise){let W=Q.createTextNode("");return D(Z,W,$),J.then((q)=>{let L=K(q,Z,W,G);Q.remove(W)}),{type:"text",node:W}}if(typeof J==="object"&&"tag"in J)return S(J,Z,$,G);let X=Q.createTextNode(String(J));return D(Z,X,$),{type:"text",node:X}}function rZ(J,Z,$,G){let X=Q.createComment("Sinwan-f");D(Z,X,$);let W=[];for(let q of J)W.push(K(q,Z,$,G));return{type:"fragment",children:W,anchor:X}}function EJ(J,Z,$=null){let G=[];for(let X of J)G.push(K(X,Z,null,$));return G}function aZ(J,Z,$,G){let X=Q.createComment("Sinwan-r"),W=Q.createComment("/Sinwan-r");D(Z,X,$),D(Z,W,$);let q=x(),L=null,j=!1,V={type:"reactive-block",startAnchor:X,endAnchor:W,children:[],dispose:()=>{}};return V.dispose=U(()=>{if(L)P(L);let Y=H(J);if(L=K(Y,Z,W,G),V.children=[L],j){if(q)T(q);M(q)}j=!0}),V}function D(J,Z,$){if($)Q.insertBefore(J,Z,$);else Q.appendChild(J,Z)}function tZ(J,Z,$){Z.innerHTML="";let G=$??{},X=ZJ(J,G,null),W,q;_(X);try{if(W=J(G),W instanceof Promise){let L=document.createTextNode("");Z.appendChild(L),q={type:"text",node:L},W.then((j)=>{Z.innerHTML="",_(X),q=S(j,Z),_(null),X.element=q,T(X)})}else if(W&&typeof W==="object"&&"tag"in W)q=S(W,Z);else q=K(W,Z)}catch(L){return _(null),$J(X,L),{root:{type:"text",node:document.createTextNode("")},unmount(){}}}return _(null),X.element=q,T(X),{root:q,unmount(){m(X),A(q),Z.innerHTML=""}}}function nZ(J,Z){Z.innerHTML="";let $=K(J,Z);return{root:$,unmount(){A($),Z.innerHTML=""}}}export{A as unmountNode,uJ as toEventName,YZ as setDOMOps,KZ as resetDOMOps,K as renderNodeToDOM,S as renderElementToDOM,EJ as renderChildrenToDOM,nZ as render,tZ as mount,JJ as isEventProp,Q as domOps,HJ as bindEvents,mJ as bindEvent,xJ as applyAttributes};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=38B497FBF63C4B4764756E2164756E21
|