@stacksjs/stx 0.2.122 → 0.2.124
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/cli.js +28 -10
- package/dist/component-renderer.js +18 -5
- package/dist/craft.js +241 -223
- package/dist/pwa.js +143 -125
- package/dist/signals.js +26 -8
- package/dist/ssg.js +216 -198
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -2143,7 +2143,7 @@ ${k}
|
|
|
2143
2143
|
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
2144
2144
|
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
2145
2145
|
</style>`}}});import{existsSync as PE,readFileSync as yE}from"fs";function xB($){if(yB.has($))return;yB.add($),console.warn(`[stx] icon collection "${$}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${$}\`.`)}function vB($){let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify-json/${$}/icons.json`,`${Z}/pantry/@iconify-json/${$}/icons.json`,`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(PE(Y))return Y;for(let Y of[`@iconify-json/${$}/icons.json`,`@iconify/json/json/${$}.json`])try{return Z0.resolve(Y)}catch{}return null}function xE($){if(d6.has($))return d6.get($);let Z=vB($);if(!Z)return xB($),null;try{let Y=JSON.parse(yE(Z,"utf8"));return d6.set($,Y.icons),Y.icons}catch{return null}}async function vE($){if(d6.has($))return d6.get($);let Z=vB($);if(!Z)return xB($),null;try{let Y=await Bun.file(Z).json();return d6.set($,Y.icons),Y.icons}catch{return null}}function v$($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}async function Z2($="lucide"){await vE($)}var d6,yB,$2;var Y2=D(()=>{d6=new Map,yB=new Set;$2={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=v$($,"name")??v$($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let L=X.split(":");J=L[0],Q=L[1]}let G=j1(v$($,"size")||"24"),K=j1(v$($,"color")||"currentColor"),W=j1(v$($,"class")||""),U=j1(v$($,"style")||""),z=d6.get(J)??xE(J);if(!z)return`<!-- Icon: collection "${J}" not loaded -->`;let _=z[Q];if(!_)return`<!-- Icon: "${Q}" not found in ${J} -->`;let B=_.width||24,q=_.height||24,j=`0 0 ${B} ${q}`,H=_.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let O=W?` class="${W}"`:"",V=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${O}${V}>${H}</svg>`}}});function fB($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}function gB($,Z){let Y=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${Z}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),X=$.match(Y);if(!X)return{region:null,rest:$};return{region:X[2],rest:$.replace(X[0],"")}}var X2;var J2=D(()=>{X2={name:"Suspense",aliases:["suspense"],render($,Z,Y){let X=gB(Z,"fallback"),J=X.rest,Q=gB(J,"error"),G=Q.rest,K=X.region??fB($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',W=Q.region??fB($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${K}</div><div data-stx-suspense-error hidden>${W}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function fZ($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}var Q2;var G2=D(()=>{Q2={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let X=(fZ($,"name")||"v").replace(/["'<>]/g,""),J=(fZ($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=fZ($,"class"),G=fZ($,"id"),K=[`data-stx-transition-group="${X}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${J} ${K}>${Z}</${J}>`}}});function hB(){R1.registerBuiltin(v9),R1.registerBuiltin(u9),R1.registerBuiltin(c9),R1.registerBuiltin(i9),R1.registerBuiltin(r9),R1.registerBuiltin(s9),R1.registerBuiltin(t9),R1.registerBuiltin($2),R1.registerBuiltin(X2),R1.registerBuiltin(Q2)}var K2=D(()=>{f9();m9();l9();n9();a9();o9();e9();Y2();J2();G2();x9();f9();m9();l9();n9();a9();o9();e9();Y2();J2();G2()});function gZ($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function dB($,Z,Y){let X=[],J=0;while(J<$.length){let Q=$.indexOf("<",J);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${Z.source})`));if(!K){J=Q+1;continue}let W=K[1];if(Y&&Y.has(W.toLowerCase())){let H=Q+1+W.length;while(H<$.length&&$[H]!==">")H++;J=H+1;continue}let U=Q+1+W.length,z=null,_=U,B=-1,q=!1;while(U<$.length){let H=$[U];if(z){if(H==="\\"&&U+1<$.length){U+=2;continue}if(H===z)z=null;U++;continue}if(H==='"'||H==="'"){z=H,U++;continue}if(H==="/"&&U+1<$.length&&$[U+1]===">"){B=U+2,q=!0;break}if(H===">"){B=U+1;break}U++}if(B===-1){J=Q+1;continue}let j=$.slice(_,q?B-2:B-1).trim();if(q)X.push({fullMatch:$.slice(Q,B),tagName:W,attributes:j,content:"",startIndex:Q,endIndex:B,isSelfClosing:!0}),J=B;else{let H=`<${W}`,O=`</${W}>`,V=1,L=B,F=-1;while(V>0&&L<$.length){let w=$.indexOf(H,L),R=$.indexOf(O,L);if(R===-1)break;if(w!==-1&&w<R){let E=$[w+H.length];if(E===" "||E===">"||E==="/"||E===`
|
|
2146
|
-
`||E==="\t")V++;L=w+H.length}else{if(V--,V===0){F=R;break}L=R+O.length}}if(F===-1){J=B;continue}let A=$.slice(B,F),N=F+O.length;X.push({fullMatch:$.slice(Q,N),tagName:W,attributes:j,content:A,startIndex:Q,endIndex:N,isSelfClosing:!1}),J=N}}return X}function uB($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var mB=D(()=>{i0();w0();C6()});var aB={};e(aB,{processESImports:()=>nB,processComponents:()=>dZ});import hZ from"fs";import C1 from"path";function gE($,Z,Y){let X={static:{},staticNames:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(K)=>{if(!K.includes("-")||K.startsWith("@")||K.startsWith(":")||K.startsWith("x-")||K.startsWith("__"))return K;if(K.startsWith("aria-")||K.startsWith("data-"))return K;return K.replace(/-([a-z0-9])/g,(W,U)=>U.toUpperCase())},G=(K,W)=>{let U=Q(K);if(X.static[U]=W,U!==K)X.staticNames[U]=K};for(let[K,W]of Object.entries($)){let U=K.startsWith("x-")&&!J.has(K)&&!K.startsWith("x-bind:")&&!K.startsWith("x-on:")?`:${K.slice(2)}`:K;if(U.startsWith("@")){X.events[U]=W;continue}if(U.startsWith("__stx_")){let z=Q(U.slice(6));X.serverDynamic[z]=uB(W,Y);continue}if(U.startsWith(":")){let z=Q(U.slice(1)),_=W===W2?z:W;try{if(!R0(_)){if(Y.debug)console.error(`Unsafe expression in :${z} binding: ${_}`);X.clientReactive[z]=_;continue}let B=Object.keys(Z),j=M0(_,B)(...Object.values(Z));if(j===void 0){let H=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],O=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(H.some((L)=>!O.has(L)&&!B.includes(L))){X.clientReactive[z]=_;continue}}X.serverDynamic[z]=j}catch{X.clientReactive[z]=_}continue}if(typeof W==="string"&&W.includes("{{")&&W.includes("}}")){let z=W.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(z)try{let _=z[1];if(R0(_)){let q=M0(_,Object.keys(Z))(...Object.values(Z));G(U,q!=null?String(q):"")}else{if(Y.debug)console.error(`Unsafe expression in ${U}: ${_}`);G(U,W)}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${U}:`,_);G(U,W)}else{let _=W,B=/\{\{\s*([\s\S]+?)\s*\}\}/g,q;while((q=B.exec(W))!==null)try{let j=q[1];if(!R0(j)){if(Y.debug)console.error(`Unsafe expression in ${U}: ${j}`);continue}let O=M0(j,Object.keys(Z))(...Object.values(Z));_=_.replace(q[0],String(O??""))}catch(j){if(Y.debug)console.error(`Error evaluating expression in ${U}:`,j)}G(U,_)}continue}G(U,W===W2?"true":W)}return X}function hE($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let J="";while(Y<X&&!/[\s=]/.test($[Y]))J+=$[Y],Y++;if(!J)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let Q="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[J]=Q}else Z[J]=W2}return Z}function lB($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function dE($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let J=X[1];if(R1.isBuiltin(J))Z.add(J)}return[...Z].sort()}function uE($){let Z=pB.get($);if(Z)return Z;let Y=new Map,X=[C1.join($,"src"),C1.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=hZ.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=C1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;J(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let z=W.name.slice(0,-4);if(!Y.has(z))Y.set(z,U);let _=z.toLowerCase();if(!Y.has(_))Y.set(_,U);let B=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(B))Y.set(B,U)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return pB.set($,Y),Y}function mE($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=C1.join(Y,"node_modules",$);try{if(hZ.statSync(X).isDirectory())return X}catch{}let J=C1.dirname(Y);if(J===Y)return null;Y=J}}async function nB($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=C1.dirname(Y),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,z,_)=>{let B=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=_,j,H=[];while((j=B.exec(_))!==null){let[O,V,L,F]=j,A=null,N=null;if(F.startsWith(".")||F.startsWith("/")){let E=C1.resolve(G,F);if(E.endsWith(".stx"))N=E;else{let M=`${E}.stx`;try{if(hZ.statSync(M).isFile())N=M}catch{try{if(hZ.statSync(E).isDirectory())A=E}catch{}}}}else A=mE(F,G);if(!A&&!N)continue;let w=!1,R=(E,M)=>{Q.set(E,M),Q.set(E.toLowerCase(),M);let I=E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,M),J.add(M)};if(L&&N)R(L,N),w=!0;else if(V){let E=V.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let S=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(S)return{source:S[1],local:S[2]};return{source:I,local:I}}),M=A?uE(A):null;for(let{source:I,local:S}of E){let k=null;if(N)k=N;else if(M)k=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(k)R(S,k),w=!0}}if(w)H.push({start:j.index,end:j.index+O.length})}if(H.length===0)return U;for(let O=H.length-1;O>=0;O--)q=q.slice(0,H[O].start)+q.slice(H[O].end);return`<script${z}>${q}</script>`}),K}async function cE($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,z]=W,_=z.split(",").map((B)=>B.trim().replace(/^['"]|['"]$/g,"")).filter((B)=>B.length>0);for(let B of _){let q=B.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),V=null,L=[C1.resolve(C1.dirname(Y),`${B}.stx`),C1.resolve(C1.dirname(Y),B),C1.resolve(X.componentsDir||"components",`${B}.stx`),C1.resolve(X.componentsDir||"components",B),B.endsWith(".stx")?B:`${B}.stx`];for(let F of L)try{if(await Bun.file(F).exists()){V=F;break}}catch{}if(V){G.set(O,V),G.set(H,V),G.set(H.toLowerCase(),V);let F=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(F,V),J.add(V),X.debug)console.log(`Imported component: ${O} -> ${V}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${B}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function lE($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let z=U.index,_=z+U[0].length-1,B=1,q=_+1;while(q<Q.length&&B>0){if(Q[q]==="(")B++;else if(Q[q]===")"){if(B--,B===0)break}q++}if(B!==0)break;let j=Q.substring(_+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let V=O[1],L,F=j.slice(O[0].length),A=F.match(/^\s*,\s*/);if(A)L=F.slice(A[0].length).trim();let N={};if(L)try{N=p0(L,Z)}catch(S){let k=S instanceof Error?S.message:String(S);Q=Q.replace(Q.substring(z,H),`[Error parsing component props: ${k}]`);continue}let w="",R=H,M=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)w=M[1].trim(),R=H+M[0].length;let I=await z4(V,N,w,G,Z,Y,X,K,J);Q=Q.substring(0,z)+I+Q.substring(R),W.lastIndex=0}return Q}async function pE($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=n4(Q);return Q=W.output,Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,fE),Q=_7(Q,W.scripts),Q;async function B(q,j,H,O){if(!q)return q;let V=q,L=dB(V,j,O);for(let F=L.length-1;F>=0;F--){let A=L[F],N=H?gZ(A.tagName):A.tagName,w=hE(A.attributes),R=gE(w,Z,X),E=R1.getBuiltin(A.tagName),M=E?await g7(N,G,Z,Y,X):!1;if(E&&!M){let x={context:Z,filePath:Y,options:X,dependencies:J},y=E.render(R,A.content,x);if(Object.keys(R.clientReactive).length>0)y=iB(y,R.clientReactive);if(Object.keys(R.events).length>0){let b=Object.entries(R.events).map(([g,r])=>`${g}="${lB(r)}"`).join(" ");y=y.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}V=V.substring(0,A.startIndex)+y+V.substring(A.endIndex);continue}if(!H&&A.tagName.includes("-")&&!await g7(N,G,Z,Y,X))continue;let I={};for(let[x,y]of Object.entries(R.static))I[x]=y;for(let[x,y]of Object.entries(R.serverDynamic))I[x]=y;let k=await z4(N,I,A.content,G,Z,Y,X,K,J);if(Object.keys(R.clientReactive).length>0)k=iB(k,R.clientReactive);if(Object.keys(R.events).length>0){let x=rB(k);if(x){let y=Object.entries(R.events).map(([g,r])=>`${g}="${lB(r)}"`).join(" "),b=Object.keys(R.events).map((g)=>g.replace(/^@/,"").split(".")[0]).join(" ");k=k.substring(0,x.insertPos)+` data-stx-parent-events="${b}" ${y}`+k.substring(x.insertPos)}}V=V.substring(0,A.startIndex)+k+V.substring(A.endIndex)}return V}}function iB($,Z){let Y=rB($);if(!Y)return $;let X=new Set(["if","for","show"]),J=Object.entries(Z).map(([K,W])=>`:${gZ(K)}="${W.replace(/"/g,""")}"`).join(" "),Q=Object.keys(Z).filter((K)=>!X.has(K)).map((K)=>gZ(K)).join(" "),G=Q?` data-stx-parent-bindings="${Q}"`:"";return $.substring(0,Y.insertPos)+`${G} ${J}`+$.substring(Y.insertPos)}function rB($){let Z=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec($);if(Z)return{insertPos:Z.index+1+Z[1].length};let Y=0;while(Y<$.length){let X=$.slice(Y),J=X.match(/^\s+/);if(J){Y+=J[0].length;continue}if(X.startsWith("<!--")){let K=$.indexOf("-->",Y+4);if(K===-1)return null;Y=K+3;continue}let Q=X.match(/^<(script|style)\b[^>]*>/i);if(Q){let K=`</${Q[1].toLowerCase()}>`,W=$.toLowerCase().indexOf(K,Y+Q[0].length);if(W===-1)return null;Y=W+K.length;continue}let G=X.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!G)return null;return{insertPos:Y+1+G[1].length}}return null}async function dZ($,Z,Y,X,J){if(!cB)hB(),cB=!0;let Q=await nB($,Z,Y,X,J);Q=await cE(Q,Z,Y,X,J),Q=await lE(Q,Z,Y,X,J);let G=[];for(let K=0;K<3;K++){let W=Q4(Q,z7,(z,_)=>`\x00STX_COMPONENT_COMMENT_${G.length+_}\x00`);G.push(...W.tokens);let U=Q;if(Q=await pE(W.output,Z,Y,X,J),Q===U)break}if(G.length>0)Q=Q.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(K,W)=>G[Number(W)]??"");if(X.debug){let K=dE(Q);if(K.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${K.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var cB=!1,W2="\x00stx-boolean-attribute",fE,pB;var U2=D(()=>{x9();K2();mB();C6();w0();i0();fE=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);pB=new Map});var mZ={};e(mZ,{stripTypeScript:()=>$q,hasVariables:()=>B2,extractVariables:()=>D0,extractScriptFromTemplate:()=>_2,convertToCommonJS:()=>uZ});import f$ from"path";import h7 from"process";function iE($){let Z=[],Y=0,X=$.split(`
|
|
2146
|
+
`||E==="\t")V++;L=w+H.length}else{if(V--,V===0){F=R;break}L=R+O.length}}if(F===-1){J=B;continue}let A=$.slice(B,F),N=F+O.length;X.push({fullMatch:$.slice(Q,N),tagName:W,attributes:j,content:A,startIndex:Q,endIndex:N,isSelfClosing:!1}),J=N}}return X}function uB($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var mB=D(()=>{i0();w0();C6()});var aB={};e(aB,{processESImports:()=>nB,processComponents:()=>dZ});import hZ from"fs";import C1 from"path";function gE($,Z,Y){let X={static:{},staticNames:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(K)=>{if(!K.includes("-")||K.startsWith("@")||K.startsWith(":")||K.startsWith("x-")||K.startsWith("__"))return K;if(K.startsWith("aria-")||K.startsWith("data-"))return K;return K.replace(/-([a-z0-9])/g,(W,U)=>U.toUpperCase())},G=(K,W)=>{let U=Q(K);if(X.static[U]=W,U!==K)X.staticNames[U]=K};for(let[K,W]of Object.entries($)){let U=K.startsWith("x-")&&!J.has(K)&&!K.startsWith("x-bind:")&&!K.startsWith("x-on:")?`:${K.slice(2)}`:K;if(U.startsWith("@")){X.events[U]=W;continue}if(U.startsWith("__stx_")){let z=Q(U.slice(6));X.serverDynamic[z]=uB(W,Y);continue}if(U.startsWith(":")){let z=Q(U.slice(1)),_=W===W2?z:W;if(z==="if"||z==="for"||z==="show"){X.clientReactive[z]=_;continue}try{if(!R0(_)){if(Y.debug)console.error(`Unsafe expression in :${z} binding: ${_}`);X.clientReactive[z]=_;continue}let B=Object.keys(Z),j=M0(_,B)(...Object.values(Z));if(j===void 0){let H=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],O=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(H.some((L)=>!O.has(L)&&!B.includes(L))){X.clientReactive[z]=_;continue}}X.serverDynamic[z]=j}catch{X.clientReactive[z]=_}continue}if(typeof W==="string"&&W.includes("{{")&&W.includes("}}")){let z=W.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(z)try{let _=z[1];if(R0(_)){let q=M0(_,Object.keys(Z))(...Object.values(Z));G(U,q!=null?String(q):"")}else{if(Y.debug)console.error(`Unsafe expression in ${U}: ${_}`);G(U,W)}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${U}:`,_);G(U,W)}else{let _=W,B=/\{\{\s*([\s\S]+?)\s*\}\}/g,q;while((q=B.exec(W))!==null)try{let j=q[1];if(!R0(j)){if(Y.debug)console.error(`Unsafe expression in ${U}: ${j}`);continue}let O=M0(j,Object.keys(Z))(...Object.values(Z));_=_.replace(q[0],String(O??""))}catch(j){if(Y.debug)console.error(`Error evaluating expression in ${U}:`,j)}G(U,_)}continue}G(U,W===W2?"true":W)}return X}function hE($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let J="";while(Y<X&&!/[\s=]/.test($[Y]))J+=$[Y],Y++;if(!J)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let Q="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[J]=Q}else Z[J]=W2}return Z}function lB($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function dE($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let J=X[1];if(R1.isBuiltin(J))Z.add(J)}return[...Z].sort()}function uE($){let Z=pB.get($);if(Z)return Z;let Y=new Map,X=[C1.join($,"src"),C1.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=hZ.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=C1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;J(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let z=W.name.slice(0,-4);if(!Y.has(z))Y.set(z,U);let _=z.toLowerCase();if(!Y.has(_))Y.set(_,U);let B=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(B))Y.set(B,U)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return pB.set($,Y),Y}function mE($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=C1.join(Y,"node_modules",$);try{if(hZ.statSync(X).isDirectory())return X}catch{}let J=C1.dirname(Y);if(J===Y)return null;Y=J}}async function nB($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=C1.dirname(Y),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,z,_)=>{let B=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=_,j,H=[];while((j=B.exec(_))!==null){let[O,V,L,F]=j,A=null,N=null;if(F.startsWith(".")||F.startsWith("/")){let E=C1.resolve(G,F);if(E.endsWith(".stx"))N=E;else{let M=`${E}.stx`;try{if(hZ.statSync(M).isFile())N=M}catch{try{if(hZ.statSync(E).isDirectory())A=E}catch{}}}}else A=mE(F,G);if(!A&&!N)continue;let w=!1,R=(E,M)=>{Q.set(E,M),Q.set(E.toLowerCase(),M);let I=E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,M),J.add(M)};if(L&&N)R(L,N),w=!0;else if(V){let E=V.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let S=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(S)return{source:S[1],local:S[2]};return{source:I,local:I}}),M=A?uE(A):null;for(let{source:I,local:S}of E){let k=null;if(N)k=N;else if(M)k=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(k)R(S,k),w=!0}}if(w)H.push({start:j.index,end:j.index+O.length})}if(H.length===0)return U;for(let O=H.length-1;O>=0;O--)q=q.slice(0,H[O].start)+q.slice(H[O].end);return`<script${z}>${q}</script>`}),K}async function cE($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,z]=W,_=z.split(",").map((B)=>B.trim().replace(/^['"]|['"]$/g,"")).filter((B)=>B.length>0);for(let B of _){let q=B.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),V=null,L=[C1.resolve(C1.dirname(Y),`${B}.stx`),C1.resolve(C1.dirname(Y),B),C1.resolve(X.componentsDir||"components",`${B}.stx`),C1.resolve(X.componentsDir||"components",B),B.endsWith(".stx")?B:`${B}.stx`];for(let F of L)try{if(await Bun.file(F).exists()){V=F;break}}catch{}if(V){G.set(O,V),G.set(H,V),G.set(H.toLowerCase(),V);let F=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(F,V),J.add(V),X.debug)console.log(`Imported component: ${O} -> ${V}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${B}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function lE($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let z=U.index,_=z+U[0].length-1,B=1,q=_+1;while(q<Q.length&&B>0){if(Q[q]==="(")B++;else if(Q[q]===")"){if(B--,B===0)break}q++}if(B!==0)break;let j=Q.substring(_+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let V=O[1],L,F=j.slice(O[0].length),A=F.match(/^\s*,\s*/);if(A)L=F.slice(A[0].length).trim();let N={};if(L)try{N=p0(L,Z)}catch(S){let k=S instanceof Error?S.message:String(S);Q=Q.replace(Q.substring(z,H),`[Error parsing component props: ${k}]`);continue}let w="",R=H,M=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)w=M[1].trim(),R=H+M[0].length;let I=await z4(V,N,w,G,Z,Y,X,K,J);Q=Q.substring(0,z)+I+Q.substring(R),W.lastIndex=0}return Q}async function pE($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=n4(Q);return Q=W.output,Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,fE),Q=_7(Q,W.scripts),Q;async function B(q,j,H,O){if(!q)return q;let V=q,L=dB(V,j,O);for(let F=L.length-1;F>=0;F--){let A=L[F],N=H?gZ(A.tagName):A.tagName,w=hE(A.attributes),R=gE(w,Z,X),E=R1.getBuiltin(A.tagName),M=E?await g7(N,G,Z,Y,X):!1;if(E&&!M){let x={context:Z,filePath:Y,options:X,dependencies:J},y=E.render(R,A.content,x);if(Object.keys(R.clientReactive).length>0)y=iB(y,R.clientReactive);if(Object.keys(R.events).length>0){let b=Object.entries(R.events).map(([g,r])=>`${g}="${lB(r)}"`).join(" ");y=y.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}V=V.substring(0,A.startIndex)+y+V.substring(A.endIndex);continue}if(!H&&A.tagName.includes("-")&&!await g7(N,G,Z,Y,X))continue;let I={};for(let[x,y]of Object.entries(R.static))I[x]=y;for(let[x,y]of Object.entries(R.serverDynamic))I[x]=y;let k=await z4(N,I,A.content,G,Z,Y,X,K,J);if(Object.keys(R.clientReactive).length>0)k=iB(k,R.clientReactive);if(Object.keys(R.events).length>0){let x=rB(k);if(x){let y=Object.entries(R.events).map(([g,r])=>`${g}="${lB(r)}"`).join(" "),b=Object.keys(R.events).map((g)=>g.replace(/^@/,"").split(".")[0]).join(" ");k=k.substring(0,x.insertPos)+` data-stx-parent-events="${b}" ${y}`+k.substring(x.insertPos)}}V=V.substring(0,A.startIndex)+k+V.substring(A.endIndex)}return V}}function iB($,Z){let Y=new Set(["if","for"]),X=new Set(["show"]),J=Object.entries(Z).filter(([z])=>!Y.has(z)),Q=J.filter(([z])=>!X.has(z)).map(([z])=>gZ(z)).join(" "),G=$,K=J.length>0?rB(G):null;if(K){let z=J.map(([B,q])=>`:${gZ(B)}="${q.replace(/"/g,""")}"`).join(" "),_=Q?` data-stx-parent-bindings="${Q}"`:"";G=G.substring(0,K.insertPos)+`${_} ${z}`+G.substring(K.insertPos)}let W=Z.if;if(W)G=`<template :if="${W.replace(/"/g,""")}">${G}</template>`;let U=Z.for;if(U)G=`<template :for="${U.replace(/"/g,""")}">${G}</template>`;return G}function rB($){let Z=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec($);if(Z)return{insertPos:Z.index+1+Z[1].length};let Y=0;while(Y<$.length){let X=$.slice(Y),J=X.match(/^\s+/);if(J){Y+=J[0].length;continue}if(X.startsWith("<!--")){let K=$.indexOf("-->",Y+4);if(K===-1)return null;Y=K+3;continue}let Q=X.match(/^<(script|style)\b[^>]*>/i);if(Q){let K=`</${Q[1].toLowerCase()}>`,W=$.toLowerCase().indexOf(K,Y+Q[0].length);if(W===-1)return null;Y=W+K.length;continue}let G=X.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!G)return null;return{insertPos:Y+1+G[1].length}}return null}async function dZ($,Z,Y,X,J){if(!cB)hB(),cB=!0;let Q=await nB($,Z,Y,X,J);Q=await cE(Q,Z,Y,X,J),Q=await lE(Q,Z,Y,X,J);let G=[];for(let K=0;K<3;K++){let W=Q4(Q,z7,(z,_)=>`\x00STX_COMPONENT_COMMENT_${G.length+_}\x00`);G.push(...W.tokens);let U=Q;if(Q=await pE(W.output,Z,Y,X,J),Q===U)break}if(G.length>0)Q=Q.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(K,W)=>G[Number(W)]??"");if(X.debug){let K=dE(Q);if(K.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${K.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var cB=!1,W2="\x00stx-boolean-attribute",fE,pB;var U2=D(()=>{x9();K2();mB();C6();w0();i0();fE=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);pB=new Map});var mZ={};e(mZ,{stripTypeScript:()=>$q,hasVariables:()=>B2,extractVariables:()=>D0,extractScriptFromTemplate:()=>_2,convertToCommonJS:()=>uZ});import f$ from"path";import h7 from"process";function iE($){let Z=[],Y=0,X=$.split(`
|
|
2147
2147
|
`);for(let J of X){let Q=Y,G=null,K=!1;for(let W=0;W<J.length;W++){let U=J[W];if(K){K=!1;continue}if(U==="\\"){K=!0;continue}if(G){if(U===G)G=null;continue}if(U==="'"||U==='"'||U==="`"){G=U;continue}if(U==="/"&&W+1<J.length&&J[W+1]==="/")break;if(U==="{")Y++;else if(U==="}")Y--}if(Q===0){let W=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(W)Z.push(W[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(J)){let U=J.match(/(?:const|let|var)\s+(\w+)/);if(U)Z.push(U[1])}else{let U=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(U){let _=U[1].slice(1,-1).split(",").map((B)=>{let q=B.split(":");return(q.length>1?q[1]:q[0]).trim()}).filter((B)=>/^\w+$/.test(B));Z.push(..._)}}}}return[...new Set(Z)]}function $q($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function Y(X){if(!X.includes(":"))return X;let J=[],Q="",G=0,K=0,W=null;for(let U=0;U<X.length;U++){let z=X[U];if(W){if(Q+=z,z===W)W=null;continue}if(z==='"'||z==="'"||z==="`"){W=z,Q+=z;continue}if(z==="<")G++;else if(z===">"&&G>0)G--;else if(z==="(")K++;else if(z===")")K--;if(z===","&&G===0&&K===0){J.push(Q),Q="";continue}Q+=z}if(Q)J.push(Q);return J.map((U)=>{let z=U.trim(),_=z.startsWith("..."),B=_?z.slice(3):z,q=-1,j=0;for(let N=0;N<B.length;N++)if(B[N]==="<")j++;else if(B[N]===">")j--;else if(B[N]===":"&&j===0){q=N;break}if(q===-1)return U;let O=B.substring(0,q).trim().replace(/\?$/,""),V=B.substring(q+1),L=-1,F=0;for(let N=0;N<V.length;N++)if(V[N]==="<")F++;else if(V[N]===">")F--;else if(V[N]==="="&&F===0){L=N;break}let A=_?"...":"";if(L!==-1)return`${A}${O} = ${V.substring(L+1).trim()}`;return`${A}${O}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,J,Q)=>{if(!Q.includes(":"))return X;return`${J}(${Y(Q)})`});{let X=/\b(function\s+\w*\s*)\(/g,J,Q=[];while((J=X.exec(Z))!==null){let G=J.index+J[0].length-1,K=1,W=G+1,U=0,z=null;while(W<Z.length&&K>0){let q=Z[W];if(z){if(q===z)z=null;W++;continue}if(q==='"'||q==="'"||q==="`"){z=q,W++;continue}if(q==="<")U++;else if(q===">"&&U>0)U--;else if(U===0){if(q==="(")K++;else if(q===")")K--}if(K>0)W++}if(K!==0)continue;let _=Z.substring(G+1,W);if(!_.includes(":"))continue;let B=Y(_);Q.push({start:G+1,end:W,replacement:B})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];Z=Z.substring(0,K)+U+Z.substring(W)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(X,J)=>{if(!J.includes(":"))return X;if(J.includes("{")||J.includes("}"))return X;return`(${J.split(",").map((G)=>{let[K,...W]=G.split("="),U=K.split(":")[0].trim();if(W.length>0)return`${U} = ${W.join("=").trim()}`;return U}).join(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),Z=Z.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),Z=Z.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),Z=Z.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),Z=Z.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),Z=Z.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),Z=Z.replace(/\n\s*\n\s*\n/g,`
|
|
2148
2148
|
|
|
2149
2149
|
`),Z}async function D0($,Z,Y,X={}){if(!$.trim())return;let J;try{let C=new Bun.Transpiler({loader:"ts",target:"browser",define:F1()}),d=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");d=d.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=C.transformSync(d)}catch{J=$q($)}let Q={exports:{}},G=Q.exports,K=h7.cwd(),W={},U=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((C)=>C[1]).filter((C)=>!C.startsWith("node:")&&!C.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(C));for(let C of U)try{let d=f$.resolve(K,"node_modules",C),o=f$.join(d,"package.json"),a=JSON.parse(Z0("fs").readFileSync(o,"utf8")),z0=a.main||"index.js";if(a.exports){let O0=typeof a.exports==="string"?a.exports:a.exports["."];if(typeof O0==="string")z0=O0;else if(O0?.bun)z0=O0.bun;else if(O0?.import)z0=O0.import;else if(O0?.default)z0=O0.default}W[C]=await import(f$.resolve(d,z0))}catch{}let z=(C)=>{if(W[C])return W[C];return Z0(C)},_=Z.props||{},B=(C)=>{if(!C)return _;let d={};for(let[o,a]of Object.entries(C)){let z0=_[o];if(z0!==void 0)d[o]=z0;else if(typeof a==="function")d[o]=a();else d[o]=a}return d};for(let[C,d]of Object.entries(_))Object.defineProperty(B,C,{value:d,enumerable:!0,configurable:!0,writable:!0});for(let C of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(_,C))continue;try{Object.defineProperty(B,C,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let q=(C)=>{if(!C)return _;let d={..._};for(let[o,a]of Object.entries(C)){let z0=a&&typeof a==="object"&&!Array.isArray(a)?a:{type:a};if(d[o]===void 0&&z0.default!==void 0)d[o]=typeof z0.default==="function"?z0.default():z0.default}return d},j=()=>Z.slots||{},H=(C,d)=>{let o={...C};for(let[a,z0]of Object.entries(d))if(o[a]===void 0)if(typeof z0==="function")o[a]=z0();else o[a]=z0;return o},O=(C)=>{let d=()=>C;return d.set=(o)=>{},d.update=(o)=>{},d},V=(C)=>{let d,o=!1;return()=>{if(!o)try{d=C(),o=!0}catch{d=void 0}return d}},L=(C)=>{},F=(C)=>C(),A=(C)=>{},N=(C)=>{},w=(C)=>{},R=()=>{let C=Z.__stxServeContext,d=Z.__stxServeSearch??C?.search??"",o=C?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(d)),path:o,name:"",fullPath:o+d,hash:"",matched:[]}},E=()=>({push:(C)=>{},replace:(C)=>{},back:()=>{},forward:()=>{},go:(C)=>{}}),M=(C)=>{let d=Z.__stx_runtime_head||{};Z.__stx_runtime_head=v6(d,C||{})},I=(C)=>{M(D7(C||{}))},S=(C)=>({value:C}),k=(C)=>C,x=(C)=>({value:typeof C==="function"?C():C}),y=(C,d)=>{},b=(C)=>{},g=(C)=>{},r=(C)=>C?C():Promise.resolve(),l=(C)=>(d,...o)=>{},P=(C)=>{},h=(C,d)=>{},m=(C,d)=>d,i=()=>({value:"light"}),s=()=>O(!1),q0=(C)=>O(!1),K0=()=>O(!1),S0=()=>q0("(prefers-color-scheme: dark)"),z1=()=>q0("(prefers-color-scheme: light)"),C0=()=>q0("(prefers-reduced-motion: reduce)"),h1=()=>q0("(prefers-contrast: more)"),X0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},c=new Proxy(X0,{get(C,d){if(d in C)return C[d];return},set(C,d,o){return C[d]=o,!0}}),u={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},n=console;try{let C=uZ(J,Y),d=new Set(Object.keys(_)),o=(G0)=>/^[a-z_$][\w$]*$/i.test(G0),a=Object.keys(Z).filter((G0)=>!d.has(G0)&&G0!=="props"&&o(G0)),z0=a.map((G0)=>Z[G0]),O0=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),N0=[],Q1=[];for(let[G0,I0]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(G0))continue;if(O0.has(G0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${G0}\\b`).test(C))continue;N0.push(G0),Q1.push(I0)}let b0=iE(C).map((G0)=>`module.exports.${G0} = typeof ${G0} !== 'undefined' ? ${G0} : module.exports.${G0};`).join(`
|
|
@@ -4226,7 +4226,10 @@ catch (e) {
|
|
|
4226
4226
|
}
|
|
4227
4227
|
}
|
|
4228
4228
|
if (el.nodeType === Node.TEXT_NODE) {
|
|
4229
|
-
|
|
4229
|
+
// DOM textContent is specified as a string, but lightweight DOM
|
|
4230
|
+
// implementations and user-created nodes can retain a numeric value
|
|
4231
|
+
// assigned by a binding. Normalize before interpolation detection.
|
|
4232
|
+
const text = el.textContent == null ? '' : String(el.textContent);
|
|
4230
4233
|
if (text && text.includes('{{')) {
|
|
4231
4234
|
const parts = text.split(/(\\{\\{[\\s\\S]+?\\}\\})/g);
|
|
4232
4235
|
if (parts.length > 1) {
|
|
@@ -5136,13 +5139,24 @@ else if (typeof value === 'string') {
|
|
|
5136
5139
|
var __forComponentSetupFactories = new Map();
|
|
5137
5140
|
|
|
5138
5141
|
function forEachGroupElement(nodes, callback) {
|
|
5139
|
-
|
|
5142
|
+
function visit(node, insideTemplateContent) {
|
|
5140
5143
|
if (!node || node.nodeType !== Node.ELEMENT_NODE) return;
|
|
5141
|
-
callback(node);
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5144
|
+
callback(node, insideTemplateContent);
|
|
5145
|
+
|
|
5146
|
+
// HTMLTemplateElement children live in template.content, outside the
|
|
5147
|
+
// element's ordinary descendant tree. Component roots and setup scripts
|
|
5148
|
+
// wrapped by caller-owned :if/:for directives must still be discoverable
|
|
5149
|
+
// for scope remapping before those templates are cloned.
|
|
5150
|
+
var entersTemplateContent = node.tagName === 'TEMPLATE' && node.content;
|
|
5151
|
+
var childRoot = entersTemplateContent
|
|
5152
|
+
? node.content
|
|
5153
|
+
: node;
|
|
5154
|
+
Array.from(childRoot.childNodes || []).forEach(function(child) {
|
|
5155
|
+
visit(child, insideTemplateContent || entersTemplateContent);
|
|
5156
|
+
});
|
|
5157
|
+
}
|
|
5158
|
+
|
|
5159
|
+
nodes.forEach(function(node) { visit(node, false); });
|
|
5146
5160
|
}
|
|
5147
5161
|
|
|
5148
5162
|
// A signal component expanded inside <template :for> carries a compiled
|
|
@@ -5190,7 +5204,11 @@ else if (typeof value === 'string') {
|
|
|
5190
5204
|
function hydrateComponentScopes(nodes, callerScope) {
|
|
5191
5205
|
var roots = [];
|
|
5192
5206
|
var scripts = [];
|
|
5193
|
-
forEachGroupElement(nodes, function(node) {
|
|
5207
|
+
forEachGroupElement(nodes, function(node, insideTemplateContent) {
|
|
5208
|
+
// A template's content is inert source material. Remapping must traverse
|
|
5209
|
+
// it, but setup and event hydration belong to the live clones inserted by
|
|
5210
|
+
// bindIf/bindFor, where the correct iteration scope is available.
|
|
5211
|
+
if (insideTemplateContent) return;
|
|
5194
5212
|
if (node.hasAttribute && node.hasAttribute('data-stx-scope')) roots.push(node);
|
|
5195
5213
|
if (node.tagName === 'SCRIPT' && node.hasAttribute('data-stx-scoped')) scripts.push(node);
|
|
5196
5214
|
});
|
|
@@ -22422,7 +22440,7 @@ else {
|
|
|
22422
22440
|
`)}function QR($,Z){let Y=" ".repeat(Z),X=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);X.push(`${K}: ${U}`)}let J=X.length>0?`{ ${X.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:QR(K,Z+1)),G=Q.length>0?`,
|
|
22423
22441
|
${Y} [${Q.join(`,
|
|
22424
22442
|
${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function ih($,Z,Y){if(Z.target==="universal"){let X=[];X.push("// Universal entry point"),X.push("");for(let[J,Q]of Y)X.push(`// --- ${J.toUpperCase()} ---`),X.push(`#if ${J.toUpperCase()}`),X.push(Q),X.push("#endif"),X.push("");return X.join(`
|
|
22425
|
-
`)}return Y.get(Z.target)||fU($,Z)}function nh($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:KR(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function rh($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function GR(){return`id_${++ah}`}function KR($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function sh($){return $.charAt(0).toUpperCase()+$.slice(1)}function oh($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function th($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function gU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=gU(Y);return Z}function hU($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=hU(Y);return Z}function WR($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var dU,ah=0,eh,$d;var zR=D(()=>{dU=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);eh={compileToNative:$R,createHotReloadServer:WR,NATIVE_COMPONENTS:dU},$d=eh});import{spawn as qR}from"child_process";import f0 from"fs";import Zd from"os";import Y0 from"path";import v from"process";import{CLI as Yd}from"@stacksjs/clapp";var E6="0.2.122";j$();jU();AK();kK();r4();EK();OK();JU();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",V0=new Yd("stx");function _R($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function BR($){try{if(!f0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(f0.existsSync(Y)){let Q=f0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(f0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function uU($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var e5=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),Xd=($)=>$.endsWith(".stx")||$.endsWith(".md");function t5($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);v.exit(Z)}function Jd($){if(!$)return;let Z;try{Z=JSON.parse($)}catch(Y){console.error(`\u274C --info-plist is not valid JSON: ${Y.message}`),v.exit(1)}if(typeof Z!=="object"||Z===null||Array.isArray(Z))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),v.exit(1);for(let[Y,X]of Object.entries(Z))if(typeof X!=="string"&&typeof X!=="number"&&typeof X!=="boolean")console.error(`\u274C --info-plist value for "${Y}" must be a string, number or boolean`),v.exit(1);return Z}async function Qd($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(e5(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(Zd.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...v.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=qR(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let _=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),v.on("SIGINT",()=>{console.log(`
|
|
22443
|
+
`)}return Y.get(Z.target)||fU($,Z)}function nh($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:KR(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function rh($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function GR(){return`id_${++ah}`}function KR($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function sh($){return $.charAt(0).toUpperCase()+$.slice(1)}function oh($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function th($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function gU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=gU(Y);return Z}function hU($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=hU(Y);return Z}function WR($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var dU,ah=0,eh,$d;var zR=D(()=>{dU=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);eh={compileToNative:$R,createHotReloadServer:WR,NATIVE_COMPONENTS:dU},$d=eh});import{spawn as qR}from"child_process";import f0 from"fs";import Zd from"os";import Y0 from"path";import v from"process";import{CLI as Yd}from"@stacksjs/clapp";var E6="0.2.124";j$();jU();AK();kK();r4();EK();OK();JU();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",V0=new Yd("stx");function _R($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function BR($){try{if(!f0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(f0.existsSync(Y)){let Q=f0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(f0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function uU($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var e5=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),Xd=($)=>$.endsWith(".stx")||$.endsWith(".md");function t5($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);v.exit(Z)}function Jd($){if(!$)return;let Z;try{Z=JSON.parse($)}catch(Y){console.error(`\u274C --info-plist is not valid JSON: ${Y.message}`),v.exit(1)}if(typeof Z!=="object"||Z===null||Array.isArray(Z))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),v.exit(1);for(let[Y,X]of Object.entries(Z))if(typeof X!=="string"&&typeof X!=="number"&&typeof X!=="boolean")console.error(`\u274C --info-plist value for "${Y}" must be a string, number or boolean`),v.exit(1);return Z}async function Qd($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(e5(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(Zd.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...v.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=qR(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let _=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),v.on("SIGINT",()=>{console.log(`
|
|
22426
22444
|
Test run interrupted`),K.kill("SIGINT"),v.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var Gd=v.argv.length>=3&&(Xd(v.argv[2])&&f0.existsSync(v.argv[2])||e5(v.argv[2]));if(Gd){let $=v.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Y=3;Y<v.argv.length;Y++){let X=v.argv[Y];if(X==="--port"&&Y+1<v.argv.length){let J=_R(v.argv[++Y]);if(!J.isValid)t5(J);Z.port=Number.parseInt(v.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<v.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=v.argv[++Y]}else if(X==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(X==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(X==="--no-cache")Z.cache=!1;else if(X==="--native")Z.native=!0}if(e5($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),X=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),J=$.split("*")[0].replace(/\/$/,"")||".",Q=Y0.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((z)=>/\[.+\]/.test(Y0.basename(z)));for(let z of U)if(!X.includes(z))X.push(z)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),v.exit(1);if(!await w3(X,Z))v.exit(1)}catch(Y){console.error("Failed to process files:",Y),v.exit(1)}else N3($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),v.exit(1)})}else{let $=function(X,J){let Q=[];for(let G=0;G<=J.length;G++)Q[G]=[G];for(let G=0;G<=X.length;G++)Q[0][G]=G;for(let G=1;G<=J.length;G++)for(let K=1;K<=X.length;K++)if(J.charAt(G-1)===X.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[J.length][X.length]};V0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(X)=>{try{if(await FK(X))console.log("Documentation generated successfully."),v.exit(0);else console.error("Documentation generation failed."),v.exit(1)}catch(J){console.error("Error generating documentation:",J),v.exit(1)}}),V0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(X,J)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(X==="list"){console.log(`
|
|
22427
22445
|
\uD83D\uDCDA Fetching available icon collections...
|
|
22428
22446
|
`);let K=await Q(),W=Object.entries(K).sort((U,z)=>z[1].total-U[1].total);console.log(`Available collections:
|
|
@@ -222,6 +222,10 @@ function parseComponentProps(rawProps, context, options) {
|
|
|
222
222
|
}
|
|
223
223
|
if (attrName.startsWith(":")) {
|
|
224
224
|
const propName = kebabToCamel(attrName.slice(1)), expression = attrValue === BOOLEAN_ATTRIBUTE_SENTINEL ? propName : attrValue;
|
|
225
|
+
if (propName === "if" || propName === "for" || propName === "show") {
|
|
226
|
+
resolved.clientReactive[propName] = expression;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
225
229
|
try {
|
|
226
230
|
if (!isExpressionSafe(expression)) {
|
|
227
231
|
if (options.debug)
|
|
@@ -642,11 +646,20 @@ async function processCustomElementTags(template, context, filePath, options, de
|
|
|
642
646
|
}
|
|
643
647
|
}
|
|
644
648
|
function emitClientReactiveAttrs(html, clientReactive) {
|
|
645
|
-
const
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
649
|
+
const componentControlBindings = new Set(["if", "for"]), rootStructuralBindings = new Set(["show"]), rootBindings = Object.entries(clientReactive).filter(([key]) => !componentControlBindings.has(key)), parentBindings = rootBindings.filter(([key]) => !rootStructuralBindings.has(key)).map(([key]) => pascalToKebab(key)).join(" ");
|
|
650
|
+
let output = html;
|
|
651
|
+
const root = rootBindings.length > 0 ? findRenderedComponentRoot(output) : null;
|
|
652
|
+
if (root) {
|
|
653
|
+
const reactiveAttrs = rootBindings.map(([key, expr]) => `:${pascalToKebab(key)}="${expr.replace(/"/g, """)}"`).join(" "), parentBindingAttr = parentBindings ? ` data-stx-parent-bindings="${parentBindings}"` : "";
|
|
654
|
+
output = output.substring(0, root.insertPos) + `${parentBindingAttr} ${reactiveAttrs}` + output.substring(root.insertPos);
|
|
655
|
+
}
|
|
656
|
+
const ifExpression = clientReactive.if;
|
|
657
|
+
if (ifExpression)
|
|
658
|
+
output = `<template :if="${ifExpression.replace(/"/g, """)}">${output}</template>`;
|
|
659
|
+
const forExpression = clientReactive.for;
|
|
660
|
+
if (forExpression)
|
|
661
|
+
output = `<template :for="${forExpression.replace(/"/g, """)}">${output}</template>`;
|
|
662
|
+
return output;
|
|
650
663
|
}
|
|
651
664
|
function findRenderedComponentRoot(html) {
|
|
652
665
|
const scopedRoot = /<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(html);
|