@stacksjs/stx 0.2.187 → 0.2.188

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 CHANGED
@@ -18629,7 +18629,7 @@ export function isDirectiveActive(name: string): boolean {
18629
18629
  `}function ak($,X={}){let Z=[],J=/@if\(([^)]+)\)[\s\S]*?@endif/g,Y=$.matchAll(J);for(let U of Y){let z=U[1].trim();if(hY(z,X)===!1)Z.push({start:U.index,end:U.index+U[0].length,reason:`@if condition always false: ${z}`})}let Q=/@unless\(([^)]+)\)[\s\S]*?@endunless/g,G=$.matchAll(Q);for(let U of G){let z=U[1].trim();if(hY(z,X)===!0)Z.push({start:U.index,end:U.index+U[0].length,reason:`@unless condition always true: ${z}`})}let K=/@env\(['"]development['"]\)[\s\S]*?@endenv/g;if(X.__ENV__==="production"){let U=$.matchAll(K);for(let z of U)Z.push({start:z.index,end:z.index+z[0].length,reason:"Development-only code in production build"})}let W=/@debug[\s\S]*?@enddebug/g;if(X.__ENV__==="production"){let U=$.matchAll(W);for(let z of U)Z.push({start:z.index,end:z.index+z[0].length,reason:"Debug code in production build"})}return Z}function sk($,X={}){let Z=ak($,X),J=[];Z.sort((Q,G)=>G.start-Q.start);let Y=$;for(let Q of Z)Y=Y.slice(0,Q.start)+Y.slice(Q.end),J.push(Q.reason);return{content:Y,removed:J}}function hY($,X){if($==="true")return!0;if($==="false")return!1;if($==="null")return null;if(/^\d+$/.test($))return Number.parseInt($,10);if(/^\d+\.\d+$/.test($))return Number.parseFloat($);if(/^['"].*['"]$/.test($))return $.slice(1,-1);if($ in X)return X[$];let Z=$.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(Z){let[,J,Y,Q]=Z,G=J in X?X[J]:void 0,K=hY(Q,X);if(G!==void 0&&K!==void 0)switch(Y){case"==":case"===":return G===K;case"!=":case"!==":return G!==K;case">":return G>K;case"<":return G<K;case">=":return G>=K;case"<=":return G<=K}}return}function ok($,X){let Z=[],J=$;return J=J.replace(/\{\{\s*(\w+)\s*\}\}/g,(Y,Q)=>{if(Q in X)return Z.push(`{{ ${Q} }} -> ${X[Q]}`),String(X[Q]);return Y}),J=J.replace(/\{\{\s*(\d+)\s*([+\-*])\s*(\d+)\s*\}\}/g,(Y,Q,G,K)=>{let W=Number.parseInt(Q,10),U=Number.parseInt(K,10),z;switch(G){case"+":z=W+U;break;case"-":z=W-U;break;case"*":z=W*U;break;default:return Y}return Z.push(`{{ ${Q} ${G} ${K} }} -> ${z}`),String(z)}),{content:J,folded:Z}}function tk($){let X=$,Z=[],J=0;X=X.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(Y)=>{let Q=`__PRESERVE_${J++}__`;return Z.push({marker:Q,content:Y}),Q}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(Y)=>{let Q=`__PRESERVE_${J++}__`;return Z.push({marker:Q,content:Y}),Q}),X=X.replace(/\{\{--([\s\S]*?)--\}\}/g,""),X=X.replace(/<!--[\s\S]*?-->/g,""),X=X.replace(/>\s+</g,"><"),X=X.replace(/^\s+/gm,""),X=X.replace(/\s+$/gm,""),X=X.replace(/\s{2,}/g," ");for(let{marker:Y,content:Q}of Z){let G=X.indexOf(Y);if(G!==-1)X=X.slice(0,G)+Q+X.slice(G+Y.length)}return X.trim()}function ek($){let X=new Map,Z=new Map,J=/(['"])([^'"]{10,})\1/g,Y;while((Y=J.exec($))!==null){let K=Y[2];Z.set(K,(Z.get(K)||0)+1)}let Q=0,G=$;for(let[K,W]of Z)if(W>1){let U=`__STR_${Q++}__`;X.set(U,K);let z=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),q=new RegExp(`(['"])${z}\\1`,"g");G=G.replace(q,U)}return{content:G,pool:X,count:X.size}}function $S($,X={}){let Z={...pk,...X},J=new Blob([$]).size,Y=$,Q=[],G=[],K=[],W=[],U=0;if(Z.target==="production")Z.constants={...Z.constants,__ENV__:"production"};if(Z.deadCodeElimination){let j=sk(Y,Z.constants);if(Y=j.content,j.removed.length>0)Q.push("Dead code elimination"),G.push(...j.removed.map((_)=>`Removed: ${_}`))}if(Z.constantFolding&&Object.keys(Z.constants).length>0){let j=ok(Y,Z.constants);if(Y=j.content,W=j.folded,W.length>0)Q.push("Constant folding")}if(Z.treeShake){if(K=nk(Y,Z.preserveDirectives),K.length>0)Q.push("Tree shaking")}if(Z.stringPooling){let j=ek(Y);if(Y=j.content,U=j.count,U>0)Q.push("String pooling")}if(Z.minifyHtml){let j=tk(Y);if(j.length<Y.length)Y=j,Q.push("HTML minification")}let z=new Blob([Y]).size,q=J>0?Math.round((1-z/J)*100):0;return{content:Y,originalSize:J,optimizedSize:z,reduction:q,appliedOptimizations:Q,removedDirectives:K,foldedConstants:W,pooledStrings:U,warnings:G}}async function cr($,X={}){let Z={...pk,...X},J=new Map,Y=[],Q=0,G=0,K=new Set;for(let[q,j]of $){let _=$S(j,Z);J.set(q,_),Q+=_.originalSize,G+=_.optimizedSize,Y.push(..._.warnings.map((L)=>`${q}: ${L}`));let H=Fj(j);for(let L of H)K.add(L.name)}let W;if(Z.treeShake)W=rk(Array.from(K));let U;if(Z.stringPooling)U=new Map;let z=Q>0?Math.round((1-G/Q)*100):0;return{templates:J,directiveBundle:W,stringPool:U,totalOriginalSize:Q,totalOptimizedSize:G,overallReduction:z,warnings:Y}}function lr($){return $.charAt(0).toUpperCase()+$.slice(1)}var pk,ik;var XS=I(()=>{pk={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},ik=["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty","extends","section","endsection","yield","parent","include","includeIf","includeWhen","includeFirst","once","endonce","push","endpush","prepend","endprepend","stack","component","endcomponent","slot","endslot","props","auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole","csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file","translate","lang","choice","meta","title","seo","jsonld","canonical","robots","sitemap","ts","endts","js","endjs","css","endcss","markdown","endmarkdown","verbatim","endverbatim","env","production","debug","isset","endisset","empty","endempty"]});var Aj={};X0(Aj,{toUsers:()=>WS,toUser:()=>KS,stopBroadcasting:()=>QS,startBroadcasting:()=>YS,loadChannels:()=>GS,getBroadcastServer:()=>JS,channel:()=>qS,broadcastPrivate:()=>US,broadcastPresence:()=>zS,broadcast:()=>wj,BroadcastServer:()=>_S,Broadcast:()=>jS});import{Broadcast as S7,BroadcastServer as pr}from"ts-broadcasting";import{channel as qS}from"ts-broadcasting";import{Broadcast as jS,BroadcastServer as _S}from"ts-broadcasting";function JS(){return Z$}async function YS($){if(Z$)return Z$;let X=$.driver??"bun",Z=$.host??"0.0.0.0",J=$.port??6001,Y=$.scheme??"ws",Q={verbose:$.verbose??!1,driver:X,default:X,connections:{[X]:{driver:X,host:Z,port:J,scheme:Y}}};return Z$=new pr(Q),S7.setServer(Z$),await Z$.start(),Z$}async function QS(){for(let $ of Vj)clearInterval($);if(Vj.length=0,!Z$)return;await Z$.stop(),Z$=null}async function GS($){let X=await import($),Z=X.default??X;if(typeof Z!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof Z}`);let J=0;return Z({channel(Q,G){if(J++,G.authorize&&Z$)Z$.channels.channel(Q,G.authorize);if(G.interval&&G.data){let K=G.event??`${Q}.updated`,W=G.data,U=setInterval(async()=>{try{let z=await W();wj(Q,K,z)}catch{}},G.interval);Vj.push(U)}}}),J}function JZ(){if(Z$)return!0;if(!ZS)ZS=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function wj($,X,Z){if(!JZ())return;S7.send($,X,Z)}function KS($,X,Z){if(!JZ())return;S7.toUser($,X,Z)}function WS($,X,Z){if(!JZ())return;S7.toUsers($,X,Z)}function US($,X,Z){if(!JZ())return;S7.send(`private-${$}`,X,Z)}function zS($,X,Z){if(!JZ())return;S7.presence($,X,Z)}var Z$=null,Vj,ZS=!1;var uY=I(()=>{Vj=[]});function HS($,X){let Z={},J=$.trim();if(J.startsWith("{"))J=J.slice(1);if(J.endsWith("}"))J=J.slice(0,-1);if(J=J.trim(),!J)return Z;let Y=0;while(Y<J.length){while(Y<J.length&&/\s/.test(J[Y]))Y++;if(Y>=J.length)break;let Q="";if(J[Y]==='"'||J[Y]==="'"){let W=J[Y];Y++;while(Y<J.length&&J[Y]!==W)if(J[Y]==="\\"&&Y+1<J.length)Q+=J[Y+1],Y+=2;else Q+=J[Y],Y++;Y++}else while(Y<J.length&&/[\w$]/.test(J[Y]))Q+=J[Y],Y++;while(Y<J.length&&/\s/.test(J[Y]))Y++;if(J[Y]===":")Y++;while(Y<J.length&&/\s/.test(J[Y]))Y++;let G,K=Y;if(J[Y]==='"'||J[Y]==="'"){let W=J[Y];Y++;let U="";while(Y<J.length&&J[Y]!==W)if(J[Y]==="\\"&&Y+1<J.length)U+=J[Y+1],Y+=2;else U+=J[Y],Y++;Y++,G=U}else if(J[Y]==="{"){let W=1;Y++;while(Y<J.length&&W>0){if(J[Y]==="{")W++;else if(J[Y]==="}")W--;else if(J[Y]==='"'||J[Y]==="'"){let z=J[Y];Y++;while(Y<J.length&&J[Y]!==z){if(J[Y]==="\\")Y++;Y++}}Y++}let U=J.slice(K,Y);G=HS(U,X)}else if(J[Y]==="["){let W=1;Y++;while(Y<J.length&&W>0){if(J[Y]==="[")W++;else if(J[Y]==="]")W--;else if(J[Y]==='"'||J[Y]==="'"){let z=J[Y];Y++;while(Y<J.length&&J[Y]!==z){if(J[Y]==="\\")Y++;Y++}}Y++}let U=J.slice(K,Y);try{G=JSON.parse(U.replace(/'/g,'"'))}catch{G=U}}else{let W="";while(Y<J.length&&J[Y]!==","&&!/\s/.test(J[Y]))W+=J[Y],Y++;if(W=W.trim(),W==="true")G=!0;else if(W==="false")G=!1;else if(W==="null")G=null;else if(W==="undefined")G=void 0;else if(/^-?\d+(\.\d+)?$/.test(W))G=Number(W);else if(W in X)G=X[W];else G=W}if(Q)Z[Q]=G;while(Y<J.length&&/\s/.test(J[Y]))Y++;if(J[Y]===",")Y++}return Z}function ir($,X,Z){let J=[];for(let[Y,Q]of Object.entries(X)){let G=$[Y];if(Q.required&&(G===void 0||G===null)){J.push(`Component "${Z}": Missing required prop "${Y}"`);continue}if(G===void 0||G===null)continue;let K=Array.isArray(Q.type)?Q.type:[Q.type];if(!K.includes("any")){let W=rr(G);if(!K.includes(W))J.push(`Component "${Z}": Prop "${Y}" expected ${K.join(" | ")}, got ${W}`)}if(Q.validator&&!Q.validator(G))J.push(`Component "${Z}": Prop "${Y}" failed custom validation`)}return J}function nr($,X){let Z={...$};for(let[J,Y]of Object.entries(X))if(Z[J]===void 0&&Y.default!==void 0)Z[J]=typeof Y.default==="function"?Y.default():Y.default;return Z}function rr($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}function ar(){return[LS]}var LS;var OS=I(()=>{a1();j1();b0();LS={name:"component",handler:async($,X,Z,J)=>{if(X.length<1)return I0("Component","component directive requires at least the component name",_0.INVALID_DIRECTIVE_SYNTAX);let Y=X[0].replace(/['"]/g,""),Q={};if(X.length>1)try{let z=X.slice(1).join(",").trim();if(z.startsWith("{")){if(Q=G1(z,Z),Object.keys(Q).length===0)Q=HS(z,Z)}else{let q=z.trim(),j=Z[q];if(j&&typeof j==="object"&&!Array.isArray(j))Q=j}}catch(z){let q=z instanceof Error?z.message:String(z);return console.error("Component props parsing error:",q),I0("Component",`Error parsing component props: ${q}`,_0.EVALUATION_ERROR)}let G=Z.__stx_options||{},K=G.componentsDir||"components",W=new Set;if(!Z.__processedComponents)Z.__processedComponents=new Set;let U=Z.__processedComponents;try{return await u$(Y,Q,"",K,Z,J,G,U,W)}catch(z){console.error("Component rendering error:",z);let q=z instanceof Error?z.message:String(z);return I0("Component",`Error rendering component: ${q}`,_0.COMPONENT_RENDER_ERROR)}},hasEndTag:!1}});import{mkdir as sr,readFile as or,readdir as tr,stat as BS,writeFile as er}from"fs/promises";import x1 from"path";function $a($){return $.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join("")}function Rj($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Xa($){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test($)&&!$.startsWith("xml")&&!/[A-Z]/.test($)}function Za($){if($===!0)return"open";if($==="open"||$==="closed")return $;return!1}async function Ja($){let X=[];async function Z(J){let Y=await tr(J,{withFileTypes:!0});Y.sort((Q,G)=>Q.name.localeCompare(G.name));for(let Q of Y){let G=x1.join(J,Q.name);if(Q.isDirectory()){if(!Q.name.startsWith(".")&&Q.name!=="node_modules")await Z(G)}else if(Q.isFile()&&Q.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(Q.name))X.push(G)}}return await Z($),X}function Ya($,X){let Z=$.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!Z)return{};let J=Z[1].trim();if(!J)return{};try{return JSON.parse(J)}catch(Y){throw Error(`${X}: <script component> must contain JSON metadata (${Y.message})`)}}function Qa($,X){let Z={},J=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let Y of J){if(!/\bclient\b/i.test(Y[1])||/\bcomponent\b|\bstx:component\b/i.test(Y[1]))continue;let Q;try{Q=new Bun.Transpiler({loader:"ts"}).transformSync(Y[2])}catch(W){throw Error(`${X}: failed to transpile <script client> (${W.message})`)}let G=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,K;while(K=G.exec(Q)){let W=K[1];if(RS.has(W))throw Error(`${X}: client method "${W}" is reserved`);let U=G.lastIndex,z=1,q="",j=!1,_=U;for(;_<Q.length&&z>0;_++){let L=Q[_];if(j){j=!1;continue}if(q){if(L==="\\")j=!0;else if(L===q)q="";continue}if(L==='"'||L==="'"||L==="`")q=L;else if(L==="{")z++;else if(L==="}")z--}if(z!==0)throw Error(`${X}: unterminated client function "${W}"`);let H=K[0].includes("async")?"async ":"";Z[W]=`${H}${W}(${K[2]}) {${Q.slice(U,_-1)}}`,G.lastIndex=_}}return Z}function Ga($){let X=$.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(X?X[1]:$).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function FS($){return[...$.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((X)=>X[1].trim()).filter(Boolean).join(`
18630
18630
 
18631
18631
  `)}function Ka($){if($===void 0)return"object";if($==="true"||$==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test($))return"number";if(/^['"`]/.test($))return"string";return"object"}function Wa($){if($==="true")return!0;if($==="false")return!1;if(/^-?\d+(?:\.\d+)?$/.test($))return Number($);if(/^['"`]/.test($))return $.slice(1,-1);try{return JSON.parse($)}catch{return}}function Ua($){let X=[],Z=0,J=$.replace(/\{\{--[\s\S]*?--\}\}/g,""),Y=/@(if|elseif|else|endif|foreach|endforeach)\s*(?:\(([\s\S]*?)\))?/g,Q,G=(K)=>{if(K==="")return;let W=0,U=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}/g,z;while(z=U.exec(K)){if(z.index>W)X.push(`out += ${JSON.stringify(K.slice(W,z.index))};`);X.push(z[1]!==void 0?`out += __raw(${z[1]});`:`out += __escape(${z[2]});`),W=z.index+z[0].length}if(W<K.length)X.push(`out += ${JSON.stringify(K.slice(W))};`)};while(Q=Y.exec(J))switch(G(J.slice(Z,Q.index)),Z=Q.index+Q[0].length,Q[1]){case"if":X.push(`if (${Q[2]}) {`);break;case"elseif":X.push(`} else if (${Q[2]}) {`);break;case"else":X.push("} else {");break;case"endif":case"endforeach":X.push("}");break;case"foreach":{let K=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec((Q[2]||"").trim());if(!K){X.push(`out += ${JSON.stringify(Q[0])};`);break}let[,W,U,z]=K;X.push(U?`for (const [${U}, ${z}] of __entries(${W})) {`:`for (const ${z} of __values(${W})) {`);break}}return G(J.slice(Z)),X.join(`
18632
- `)}function za($,X,Z){let Y=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].find((q)=>!/\bcomponent\b|\bstx:component\b|\bclient\b/i.test(q[1]));if(!Y)return{imports:[],body:"",propNames:[],defaults:{}};let Q=Y[2],G=[],K=[],W={};Q=Q.replace(/^\s*import\s+[\s\S]*?from\s*['"][^'"]+['"];?\s*$/gm,(q)=>{if(/from\s*['"]stx['"]/.test(q))return"";return G.push(q.trim().replace(/(from\s*['"])(\.[^'"]*)(['"])/,(j,_,H,L)=>{let O=x1.resolve(x1.dirname(X),H),B=x1.relative(Z,O);return`${_}${B.startsWith(".")?B:`./${B}`}${L}`})),""});let z=/const\s*\{([^}]*)\}\s*=\s*(?:withDefaults\s*\(\s*)?defineProps\s*<[^>]*>\s*\(\s*\)\s*(?:,\s*(\{[\s\S]*?\})\s*,?\s*\))?[\s\S]*?$/m.exec(Q);if(z){for(let q of z[1].split(",")){let j=q.split(":")[0].trim();if(j)K.push(j)}for(let q of(z[2]||"").matchAll(/([A-Za-z_$][\w$]*)\s*:\s*([^,}]+)/g))W[q[1]]=q[2].trim();Q=Q.replace(z[0],"")}return Q=Q.replace(/(?:export\s+)?interface\s+[A-Za-z_$][\w$]*\s*\{[\s\S]*?\n\}/g,""),{imports:G,body:Q.trim(),propNames:K,defaults:W}}function qa($){let X=new Set;return{template:$.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(J,Y,Q,G,K)=>{let W=Y.toLowerCase();X.add(W);let U=(Q||"").split(".").filter(Boolean).join(" ");return` data-stx-on-${W}="${K}"${U?` data-stx-mod-${W}="${U}"`:""}`}),eventTypes:[...X].sort()}}function ja($){let X=[];return{template:$.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(J,Y,Q,G)=>{let K=X.length;return X.push({id:K,name:Y,expression:G}),` data-stx-bind-${K}=""`}),bindings:X}}function _a($){let X=new Set;for(let Z of $.matchAll(/<slot\b([^>]*)>/gi))X.add(Z[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...X].map((Z)=>({name:Z}))}function Ha($){return[...new Set([...$.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((X)=>X[1]))].sort().map((X)=>({name:X}))}function VS($,X){if(!X||!new Set(["string","number","boolean","object","array"]).has(X.type))throw Error(`Property "${$}" must declare one of: string, number, boolean, object, array`);return{...X,reflect:X.reflect??X.attribute!==!1}}async function La($,X,Z){let J=x1.isAbsolute(X.file)?X.file:x1.resolve($,X.file),Y=await or(J,"utf8"),Q=Ya(Y,J),G=x1.basename(J,".stx"),K=X.name||Q.name||$a(G),W=`${Rj(Z.prefix||"stx")}-${Rj(G)}`,U=X.tag||Q.tag||W;if(!K||!/^[A-Za-z_$][\w$]*$/.test(K))throw Error(`${J}: invalid component class name "${K}"`);if(!Xa(U))throw Error(`${J}: invalid custom-element tag "${U}"; tags must be lowercase and contain a hyphen`);let z=X.properties||Q.properties||Q.props||{},q=Object.fromEntries(Object.entries(z).map(([V,w])=>[V,VS(V,w)])),j=qa(Ga(Y)),_=ja(j.template),H=za(Y,J,x1.resolve(Z.outputDir)),L=Ua(_.template);for(let V of H.propNames){if(q[V])continue;let w=H.defaults[V];q[V]=VS(V,{type:Ka(w),...w===void 0?{}:{default:Wa(w)}})}let O=Q.methods||{},B=X.methods||{},F=Qa(Y,J);return{file:x1.relative($,J),sourcePath:J,name:K,tag:U,description:X.description||Q.description||"",template:_.template,styles:FS(Y),shadowMode:Za(X.shadowDOM??Q.shadowDOM??Z.shadowDOM),progressive:X.progressive??Q.progressive??Z.progressive??!0,properties:q,events:X.events||Q.events||{},methods:{...O,...B,...F},eventTypes:j.eventTypes,bindings:_.bindings,slots:_a(_.template),cssProperties:Ha(FS(Y)),scope:H,render:L}}function Oa(){let $=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),X=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
18632
+ `)}function za($,X,Z){let Y=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].find((q)=>!/\bcomponent\b|\bstx:component\b|\bclient\b/i.test(q[1]));if(!Y)return{imports:[],body:"",propNames:[],defaults:{}};let Q=Y[2],G=[],K=[],W={};Q=Q.replace(/^\s*import\s+[\s\S]*?from\s*['"][^'"]+['"];?\s*$/gm,(q)=>{if(/from\s*['"]stx['"]/.test(q))return"";return G.push(q.trim().replace(/(from\s*['"])(\.[^'"]*)(['"])/,(j,_,H,L)=>{let O=x1.resolve(x1.dirname(X),H),B=x1.relative(Z,O);return`${_}${B.startsWith(".")?B:`./${B}`}${L}`})),""});let z=/const\s*\{([^}]*)\}\s*=\s*(?:withDefaults\s*\(\s*)?defineProps\s*<[^>]*>\s*\(\s*\)\s*(?:,\s*(\{[\s\S]*?\})\s*,?\s*\))?/.exec(Q);if(z){for(let q of z[1].split(",")){let j=q.split(":")[0].trim();if(j)K.push(j)}for(let q of(z[2]||"").matchAll(/([A-Za-z_$][\w$]*)\s*:\s*([^,}]+)/g))W[q[1]]=q[2].trim();Q=Q.replace(z[0],"")}return Q=Q.replace(/(?:export\s+)?interface\s+[A-Za-z_$][\w$]*\s*\{[\s\S]*?\n\}/g,""),{imports:G,body:Q.trim(),propNames:K,defaults:W}}function qa($){let X=new Set;return{template:$.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(J,Y,Q,G,K)=>{let W=Y.toLowerCase();X.add(W);let U=(Q||"").split(".").filter(Boolean).join(" ");return` data-stx-on-${W}="${K}"${U?` data-stx-mod-${W}="${U}"`:""}`}),eventTypes:[...X].sort()}}function ja($){let X=[];return{template:$.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(J,Y,Q,G)=>{let K=X.length;return X.push({id:K,name:Y,expression:G}),` data-stx-bind-${K}=""`}),bindings:X}}function _a($){let X=new Set;for(let Z of $.matchAll(/<slot\b([^>]*)>/gi))X.add(Z[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...X].map((Z)=>({name:Z}))}function Ha($){return[...new Set([...$.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((X)=>X[1]))].sort().map((X)=>({name:X}))}function VS($,X){if(!X||!new Set(["string","number","boolean","object","array"]).has(X.type))throw Error(`Property "${$}" must declare one of: string, number, boolean, object, array`);return{...X,reflect:X.reflect??X.attribute!==!1}}async function La($,X,Z){let J=x1.isAbsolute(X.file)?X.file:x1.resolve($,X.file),Y=await or(J,"utf8"),Q=Ya(Y,J),G=x1.basename(J,".stx"),K=X.name||Q.name||$a(G),W=`${Rj(Z.prefix||"stx")}-${Rj(G)}`,U=X.tag||Q.tag||W;if(!K||!/^[A-Za-z_$][\w$]*$/.test(K))throw Error(`${J}: invalid component class name "${K}"`);if(!Xa(U))throw Error(`${J}: invalid custom-element tag "${U}"; tags must be lowercase and contain a hyphen`);let z=X.properties||Q.properties||Q.props||{},q=Object.fromEntries(Object.entries(z).map(([V,w])=>[V,VS(V,w)])),j=qa(Ga(Y)),_=ja(j.template),H=za(Y,J,x1.resolve(Z.outputDir)),L=Ua(_.template);for(let V of H.propNames){if(q[V])continue;let w=H.defaults[V];q[V]=VS(V,{type:Ka(w),...w===void 0?{}:{default:Wa(w)}})}let O=Q.methods||{},B=X.methods||{},F=Qa(Y,J);return{file:x1.relative($,J),sourcePath:J,name:K,tag:U,description:X.description||Q.description||"",template:_.template,styles:FS(Y),shadowMode:Za(X.shadowDOM??Q.shadowDOM??Z.shadowDOM),progressive:X.progressive??Q.progressive??Z.progressive??!0,properties:q,events:X.events||Q.events||{},methods:{...O,...B,...F},eventTypes:j.eventTypes,bindings:_.bindings,slots:_a(_.template),cssProperties:Ha(FS(Y)),scope:H,render:L}}function Oa(){let $=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),X=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
18633
18633
 
18634
18634
  const escapeHTML = (value) => String(value ?? '')
18635
18635
  .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
@@ -27354,7 +27354,7 @@ else {
27354
27354
  `)}function tx($,X){let Z=" ".repeat(X),J=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);J.push(`${K}: ${U}`)}let Y=J.length>0?`{ ${J.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:tx(K,X+1)),G=Q.length>0?`,
27355
27355
  ${Z} [${Q.join(`,
27356
27356
  ${Z} `)}]`:"";return`Craft.create("${$.zigType}", ${Y}${G})`}function c10($,X,Z){if(X.target==="universal"){let J=[];J.push("// Universal entry point"),J.push("");for(let[Y,Q]of Z)J.push(`// --- ${Y.toUpperCase()} ---`),J.push(`#if ${Y.toUpperCase()}`),J.push(Q),J.push("#endif"),J.push("");return J.join(`
27357
- `)}return Z.get(X.target)||WL($,X)}function l10($,X,Z){let J=[];function Y(Q){J.push({name:Q.zigType,hash:$v(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)Y(G)}return Y(X),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function p10($,X){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function ex(){return`id_${++i10}`}function $v($){let X=0;for(let Z=0;Z<$.length;Z++){let J=$.charCodeAt(Z);X=(X<<5)-X+J,X=X&X}return Math.abs(X).toString(36)}function n10($){return $.charAt(0).toUpperCase()+$.slice(1)}function r10($){let X=[],Z=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Z.exec($))!==null)X.push(J[1]);return X}function a10($){let X=[],Z=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Z.exec($))!==null)X.push(J[1]);return X}function UL($){let X=$.type==="component"?1:0;if($.children)for(let Z of $.children)X+=UL(Z);return X}function zL($){let X=$.zigType.startsWith("craft.")?1:0;for(let Z of $.children)X+=zL(Z);return X}function Xv($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(X)=>{console.log(`[craft-compiler] File changed: ${X}`)}}}var qL,i10=0,s10,o10;var Jv=I(()=>{qL=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"}]]);s10={compileToNative:nx,createHotReloadServer:Xv,NATIVE_COMPONENTS:qL},o10=s10});import{spawn as Gv}from"child_process";import t0 from"fs";import t10 from"os";import K0 from"path";import g from"process";import{CLI as e10}from"@stacksjs/clapp";var D6="0.2.187";k8();xH();Cj();uj();h4();fj();Mj();b6();NH();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",C0=new e10("stx");function Yv($){let X=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(X))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(X<1024||X>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 Qv($){try{if(!t0.existsSync($)){let Z=K0.dirname($),J=K0.basename($);if(t0.existsSync(Z)){let Q=t0.readdirSync(Z).filter((K)=>K.toLowerCase().includes(J.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Z}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Z} 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(t0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(X){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function jL($){let X=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(X))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(X<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(X>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 s7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),$$0=($)=>$.endsWith(".stx")||$.endsWith(".md");function a7($,X=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);g.exit(X)}function X$0($){if(!$)return;let X;try{X=JSON.parse($)}catch(Z){console.error(`\u274C --info-plist is not valid JSON: ${Z.message}`),g.exit(1)}if(typeof X!=="object"||X===null||Array.isArray(X))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),g.exit(1);for(let[Z,J]of Object.entries(X))if(typeof J!=="string"&&typeof J!=="number"&&typeof J!=="boolean")console.error(`\u274C --info-plist value for "${Z}" must be a string, number or boolean`),g.exit(1);return X}async function Z$0($,X){try{let Z=["test"],J=[];if($&&$.length>0)for(let W of $)if(s7(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(J.push(...U),X.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else J.push(W);if(J.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Z.push(...J),X.filter)Z.push("--pattern",X.filter);if(X.timeout)Z.push("--timeout",X.timeout.toString());if(X.reporter&&X.reporter!=="default")if(X.reporter==="junit"){let W=K0.join(t10.tmpdir(),`stx-test-report-${Date.now()}.xml`);Z.push("--reporter",X.reporter),Z.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${X.reporter}' is not supported. Using default reporter.`);if(X.coverage)Z.push("--coverage");if(X.watch)Z.push("--watch");Z.push("--preload",K0.join(__dirname,"../../../test-utils/happy-dom.ts"));let Y={...g.env,STX_TEST_MODE:"true",STX_TEST_UI:X.ui?"true":"false",STX_TEST_VERBOSE:X.verbose?"true":"false"},Q="bun";if(X.verbose)console.log(`Running: ${Q} ${Z.join(" ")}`);let G=performance.now(),K=Gv(Q,Z,{stdio:"inherit",shell:!1,env:Y});return new Promise((W)=>{K.on("close",(U)=>{let q=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),g.on("SIGINT",()=>{console.log(`
27357
+ `)}return Z.get(X.target)||WL($,X)}function l10($,X,Z){let J=[];function Y(Q){J.push({name:Q.zigType,hash:$v(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)Y(G)}return Y(X),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function p10($,X){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function ex(){return`id_${++i10}`}function $v($){let X=0;for(let Z=0;Z<$.length;Z++){let J=$.charCodeAt(Z);X=(X<<5)-X+J,X=X&X}return Math.abs(X).toString(36)}function n10($){return $.charAt(0).toUpperCase()+$.slice(1)}function r10($){let X=[],Z=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Z.exec($))!==null)X.push(J[1]);return X}function a10($){let X=[],Z=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Z.exec($))!==null)X.push(J[1]);return X}function UL($){let X=$.type==="component"?1:0;if($.children)for(let Z of $.children)X+=UL(Z);return X}function zL($){let X=$.zigType.startsWith("craft.")?1:0;for(let Z of $.children)X+=zL(Z);return X}function Xv($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(X)=>{console.log(`[craft-compiler] File changed: ${X}`)}}}var qL,i10=0,s10,o10;var Jv=I(()=>{qL=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"}]]);s10={compileToNative:nx,createHotReloadServer:Xv,NATIVE_COMPONENTS:qL},o10=s10});import{spawn as Gv}from"child_process";import t0 from"fs";import t10 from"os";import K0 from"path";import g from"process";import{CLI as e10}from"@stacksjs/clapp";var D6="0.2.188";k8();xH();Cj();uj();h4();fj();Mj();b6();NH();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",C0=new e10("stx");function Yv($){let X=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(X))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(X<1024||X>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 Qv($){try{if(!t0.existsSync($)){let Z=K0.dirname($),J=K0.basename($);if(t0.existsSync(Z)){let Q=t0.readdirSync(Z).filter((K)=>K.toLowerCase().includes(J.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Z}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Z} 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(t0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(X){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function jL($){let X=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(X))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(X<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(X>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 s7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),$$0=($)=>$.endsWith(".stx")||$.endsWith(".md");function a7($,X=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);g.exit(X)}function X$0($){if(!$)return;let X;try{X=JSON.parse($)}catch(Z){console.error(`\u274C --info-plist is not valid JSON: ${Z.message}`),g.exit(1)}if(typeof X!=="object"||X===null||Array.isArray(X))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),g.exit(1);for(let[Z,J]of Object.entries(X))if(typeof J!=="string"&&typeof J!=="number"&&typeof J!=="boolean")console.error(`\u274C --info-plist value for "${Z}" must be a string, number or boolean`),g.exit(1);return X}async function Z$0($,X){try{let Z=["test"],J=[];if($&&$.length>0)for(let W of $)if(s7(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(J.push(...U),X.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else J.push(W);if(J.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Z.push(...J),X.filter)Z.push("--pattern",X.filter);if(X.timeout)Z.push("--timeout",X.timeout.toString());if(X.reporter&&X.reporter!=="default")if(X.reporter==="junit"){let W=K0.join(t10.tmpdir(),`stx-test-report-${Date.now()}.xml`);Z.push("--reporter",X.reporter),Z.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${X.reporter}' is not supported. Using default reporter.`);if(X.coverage)Z.push("--coverage");if(X.watch)Z.push("--watch");Z.push("--preload",K0.join(__dirname,"../../../test-utils/happy-dom.ts"));let Y={...g.env,STX_TEST_MODE:"true",STX_TEST_UI:X.ui?"true":"false",STX_TEST_VERBOSE:X.verbose?"true":"false"},Q="bun";if(X.verbose)console.log(`Running: ${Q} ${Z.join(" ")}`);let G=performance.now(),K=Gv(Q,Z,{stdio:"inherit",shell:!1,env:Y});return new Promise((W)=>{K.on("close",(U)=>{let q=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),g.on("SIGINT",()=>{console.log(`
27358
27358
  Test run interrupted`),K.kill("SIGINT"),g.exit(1)})})}catch(Z){return console.error("Error running tests:",Z instanceof Error?Z.message:String(Z)),!1}}var J$0=g.argv.length>=3&&($$0(g.argv[2])&&t0.existsSync(g.argv[2])||s7(g.argv[2]));if(J$0){let $=g.argv[2],X={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Z=3;Z<g.argv.length;Z++){let J=g.argv[Z];if(J==="--port"&&Z+1<g.argv.length){let Y=Yv(g.argv[++Z]);if(!Y.isValid)a7(Y);X.port=Number.parseInt(g.argv[Z],10)}else if(J==="--no-watch")X.watch=!1;else if(J==="--highlight-theme"&&Z+1<g.argv.length){if(!X.markdown)X.markdown={};if(!X.markdown.syntaxHighlighting)X.markdown.syntaxHighlighting={};X.markdown.syntaxHighlighting.defaultTheme=g.argv[++Z]}else if(J==="--no-highlight"){if(!X.markdown)X.markdown={};if(!X.markdown.syntaxHighlighting)X.markdown.syntaxHighlighting={};X.markdown.syntaxHighlighting.enabled=!1}else if(J==="--no-highlight-unknown"){if(!X.markdown)X.markdown={};if(!X.markdown.syntaxHighlighting)X.markdown.syntaxHighlighting={};X.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(J==="--no-cache")X.cache=!1;else if(J==="--native")X.native=!0}if(s7($))try{let Z=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),J=$.endsWith(".stx")?Z.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Z.filter((K)=>K.endsWith(".md")):Z.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),Y=$.split("*")[0].replace(/\/$/,"")||".",Q=K0.resolve(Y);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((z)=>/\[.+\]/.test(K0.basename(z)));for(let z of U)if(!J.includes(z))J.push(z)}catch{}if(J.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),g.exit(1);if(!await yZ(J,X))g.exit(1)}catch(Z){console.error("Failed to process files:",Z),g.exit(1)}else bZ($,X).catch((Z)=>{console.error("Failed to start dev server:",Z),g.exit(1)})}else{let $=function(J,Y){let Q=[];for(let G=0;G<=Y.length;G++)Q[G]=[G];for(let G=0;G<=J.length;G++)Q[0][G]=G;for(let G=1;G<=Y.length;G++)for(let K=1;K<=J.length;K++)if(Y.charAt(G-1)===J.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[Y.length][J.length]};C0.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(J)=>{try{if(await Sj(J))console.log("Documentation generated successfully."),g.exit(0);else console.error("Documentation generation failed."),g.exit(1)}catch(Y){console.error("Error generating documentation:",Y),g.exit(1)}}),C0.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(J,Y)=>{try{let{fetchCollections:Q,generatePackage:G}=await Promise.resolve().then(() => (Zy(),Xy));if(J==="list"){console.log(`
27359
27359
  \uD83D\uDCDA Fetching available icon collections...
27360
27360
  `);let K=await Q(),W=Object.entries(K).sort((U,z)=>z[1].total-U[1].total);console.log(`Available collections:
@@ -204,7 +204,7 @@ function compileScriptScope(source, file, outputDir) {
204
204
  }));
205
205
  return "";
206
206
  });
207
- const propMatch = /const\s*\{([^}]*)\}\s*=\s*(?:withDefaults\s*\(\s*)?defineProps\s*<[^>]*>\s*\(\s*\)\s*(?:,\s*(\{[\s\S]*?\})\s*,?\s*\))?[\s\S]*?$/m.exec(code);
207
+ const propMatch = /const\s*\{([^}]*)\}\s*=\s*(?:withDefaults\s*\(\s*)?defineProps\s*<[^>]*>\s*\(\s*\)\s*(?:,\s*(\{[\s\S]*?\})\s*,?\s*\))?/.exec(code);
208
208
  if (propMatch) {
209
209
  for (const name of propMatch[1].split(",")) {
210
210
  const clean = name.split(":")[0].trim();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.187",
4
+ "version": "0.2.188",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.14",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.187",
121
- "@stacksjs/sanitizer": "0.2.187",
120
+ "@stacksjs/desktop": "0.2.188",
121
+ "@stacksjs/sanitizer": "0.2.188",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.187",
123
+ "bun-plugin-stx": "0.2.188",
124
124
  "bunfig": "^0.15.17",
125
- "stx-router": "0.2.187",
125
+ "stx-router": "0.2.188",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.2.11",
128
128
  "ts-syntax-highlighter": "^0.2.1"