@stacksjs/stx 0.2.108 → 0.2.109

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
@@ -16471,7 +16471,7 @@ ${Q}`}var P$=null;function l8($,Z){if(Z.theme===!1)return $;let Y=typeof Z.theme
16471
16471
  `);$=$.replace(/<head\b([^>]*)>/i,`<head$1>
16472
16472
  ${K}`)}if(!$.includes("__stxThemeGuard")&&/<head\b[^>]*>/i.test($)){let K=`<script data-stx-theme-guard="1">${vx(X,J,Q,G)};window.__stxThemeGuard=1;</script>`;$=$.replace(/<head\b([^>]*)>/i,`<head$1>
16473
16473
  ${K}`)}if(!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let K=`<script data-stx-theme-toggle="1">${gx(J,Q,G)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
16474
- </body>`)}return $}var vx=($,Z,Y,X)=>`(function(){function read(){try{var k=${JSON.stringify(Z)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify($)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(X)}:${JSON.stringify(Y)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`,gx=($,Z,Y)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Y)}:${JSON.stringify(Z)})});`;import{existsSync as fx,readFileSync as hx}from"fs";import{join as dx,resolve as ux}from"path";import mx from"process";function p8($,Z=mx.cwd()){let Y=$.i18n;if(!Y||!Array.isArray(Y.locales)||Y.locales.length===0)return null;let X=Y.defaultLocale??Y.locales[0],J=cx(Y,Z);return{locales:Y.locales,defaultLocale:X,labels:Y.labels??Object.fromEntries(Y.locales.map((Q)=>[Q,Q.toUpperCase()])),translations:J,pickerSelector:Y.pickerSelector??"#lang-picker"}}function cx($,Z){let Y=$.translations??{},X={},J=$.translationsDir,Q=J===!1?null:ux(Z,typeof J==="string"&&J?J:"translations"),G=$.format??"json";for(let K of $.locales){let W=Q?lx(Q,K,G):{};X[K]={...W,...Y[K]??{}}}return X}function lx($,Z,Y){let X=Y==="json"?[`${Z}.json`]:[`${Z}.${Y}`,`${Z}.${Y==="yaml"?"yml":"yaml"}`];for(let J of X){let Q=dx($,J);if(!fx(Q))continue;try{let G=hx(Q,"utf8"),K=Y==="json"?JSON.parse(G):px(G);return iF(K)}catch{continue}}return{}}function iF($,Z="",Y={}){if(!$||typeof $!=="object")return Y;for(let[X,J]of Object.entries($)){let Q=Z?`${Z}.${X}`:X;if(J&&typeof J==="object"&&!Array.isArray(J))iF(J,Q,Y);else if(typeof J==="string")Y[Q]=J;else if(typeof J==="number"||typeof J==="boolean")Y[Q]=String(J)}return Y}function px($){let Z={},Y=[{obj:Z,indent:-1}];for(let X of $.split(`
16474
+ </body>`)}return $}var vx=($,Z,Y,X)=>`(function(){window.__stxThemeIcon=function(isDark){try{var want=isDark?'dark':'light';var pick=document.querySelector('link[rel~="icon"][media*="prefers-color-scheme: '+want+'"]');if(!pick)return;var live=document.querySelector('link[rel~="icon"]:not([media])');if(!live){live=document.createElement('link');live.setAttribute('rel','icon');document.head.appendChild(live)}if(pick.type)live.setAttribute('type',pick.type);var href=pick.getAttribute('href');if(live.getAttribute('href')!==href)live.setAttribute('href',href)}catch(e){}};function read(){try{var k=${JSON.stringify(Z)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify($)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(X)}:${JSON.stringify(Y)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`,gx=($,Z,Y)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Y)}:${JSON.stringify(Z)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;import{existsSync as fx,readFileSync as hx}from"fs";import{join as dx,resolve as ux}from"path";import mx from"process";function p8($,Z=mx.cwd()){let Y=$.i18n;if(!Y||!Array.isArray(Y.locales)||Y.locales.length===0)return null;let X=Y.defaultLocale??Y.locales[0],J=cx(Y,Z);return{locales:Y.locales,defaultLocale:X,labels:Y.labels??Object.fromEntries(Y.locales.map((Q)=>[Q,Q.toUpperCase()])),translations:J,pickerSelector:Y.pickerSelector??"#lang-picker"}}function cx($,Z){let Y=$.translations??{},X={},J=$.translationsDir,Q=J===!1?null:ux(Z,typeof J==="string"&&J?J:"translations"),G=$.format??"json";for(let K of $.locales){let W=Q?lx(Q,K,G):{};X[K]={...W,...Y[K]??{}}}return X}function lx($,Z,Y){let X=Y==="json"?[`${Z}.json`]:[`${Z}.${Y}`,`${Z}.${Y==="yaml"?"yml":"yaml"}`];for(let J of X){let Q=dx($,J);if(!fx(Q))continue;try{let G=hx(Q,"utf8"),K=Y==="json"?JSON.parse(G):px(G);return iF(K)}catch{continue}}return{}}function iF($,Z="",Y={}){if(!$||typeof $!=="object")return Y;for(let[X,J]of Object.entries($)){let Q=Z?`${Z}.${X}`:X;if(J&&typeof J==="object"&&!Array.isArray(J))iF(J,Q,Y);else if(typeof J==="string")Y[Q]=J;else if(typeof J==="number"||typeof J==="boolean")Y[Q]=String(J)}return Y}function px($){let Z={},Y=[{obj:Z,indent:-1}];for(let X of $.split(`
16475
16475
  `)){let J=X.replace(/#.*$/,"").trimEnd();if(!J.trim())continue;let Q=J.search(/\S/);if(Q===-1)continue;while(Y.length>1&&Y[Y.length-1].indent>=Q)Y.pop();let G=Y[Y.length-1].obj,K=J.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(!K)continue;let[,,W,U]=K,_=W.trim(),z=U.trim();if(z==="")G[_]={},Y.push({obj:G[_],indent:Q});else G[_]=ix(z)}return Z}function ix($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function DX($,Z,Y){let X=$.translations[Z]?.[Y];if(typeof X==="string")return X;let J=$.translations[$.defaultLocale]?.[Y];if(typeof J==="string")return J;return Y}function i8($,Z,Y){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(X,J,Q)=>{let G=DX(Z,Y,Q);return J==="!"?G:nx(G)})}function C4($,Z,Y){if(Z===Y)return $;if($==="/")return`/${Z}/`;if($==="/404.html")return`/${Z}/404.html`;return`/${Z}${$}`}function bW($,Z){for(let Y of Z){if($===`/${Y}`||$===`/${Y}/`)return{locale:Y,path:"/"};if($.startsWith(`/${Y}/`))return{locale:Y,path:$.slice(Y.length+1)}}return{locale:null,path:$}}function n8($,Z,Y){let X=$.replace(/\/$/,""),J=[];for(let G of Y.locales){let K=`${X}${C4(Z,G,Y.defaultLocale)}`;J.push(`<link rel="alternate" hreflang="${CW(G)}" href="${CW(K)}">`)}let Q=`${X}${C4(Z,Y.defaultLocale,Y.defaultLocale)}`;return J.push(`<link rel="alternate" hreflang="x-default" href="${CW(Q)}">`),J.join(`
16476
16476
  `)}function r8($,Z){return`<script data-stx-lang-picker="1">window.__stxI18n=${JSON.stringify({locales:$.locales,defaultLocale:$.defaultLocale,current:Z,pickerSelector:$.pickerSelector})};(function(){function cfg(){return window.__stxI18n}function localeFromPath(p){var d=cfg();for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/')return c;if(p.indexOf('/'+c+'/')===0)return c}return d.defaultLocale}function localePathFor(loc,p){var d=cfg();var stripped=p;for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/'){stripped='/';break}if(p.indexOf('/'+c+'/')===0){stripped=p.slice(c.length+1);break}}if(loc===d.defaultLocale)return stripped;if(stripped==='/')return '/'+loc+'/';return '/'+loc+stripped}cfg().localizeHref=function(href){try{var u=new URL(href,location.origin);if(u.origin!==location.origin)return href;return localePathFor(localeFromPath(location.pathname),u.pathname)+(u.search||'')+(u.hash||'')}catch(_){return href}};function syncFromUrl(){var d=cfg();var loc=localeFromPath(location.pathname);d.current=loc;var picker=document.querySelector(d.pickerSelector);if(picker){var btns=picker.querySelectorAll('[data-lang]');for(var i=0;i<btns.length;i++){var b=btns[i];if(b.getAttribute('data-lang')===loc)b.setAttribute('aria-current','true');else b.removeAttribute('aria-current')}}if(document.documentElement.lang!==loc)document.documentElement.lang=loc}function onLangClick(e){var d=cfg();var btn=e.target&&e.target.closest&&e.target.closest('[data-lang]');if(!btn)return;var picker=document.querySelector(d.pickerSelector);if(!picker||!picker.contains(btn))return;e.preventDefault();e.stopPropagation();var loc=btn.getAttribute('data-lang');if(!loc||loc===localeFromPath(location.pathname))return;var dest=localePathFor(loc,location.pathname);var r=window.__stxRouter;if(r&&r.navigate)r.navigate(dest,true,true);else location.assign(dest)}syncFromUrl();if(window.__stxLangPickerBound){document.removeEventListener('click',window.__stxLangPickerClick,true);window.removeEventListener('stx:navigate',window.__stxLangPickerSync);window.removeEventListener('popstate',window.__stxLangPickerSync)}window.__stxLangPickerClick=onLangClick;window.__stxLangPickerSync=syncFromUrl;window.__stxLangPickerBound=1;document.addEventListener('click',onLangClick,true);window.addEventListener('stx:navigate',syncFromUrl);window.addEventListener('popstate',syncFromUrl)})();</script>`}function CW($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function nx($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var PW=()=>{};var{Glob:rx}=globalThis.Bun;import{cpSync as ax,existsSync as CX,mkdirSync as nF,readFileSync as rF,readdirSync as sx,rmSync as ox,statSync as tx,unlinkSync as ex,writeFileSync as kX}from"fs";import{dirname as $v,join as b4,relative as Zv}from"path";import aF from"process";import Yv from"bun-plugin-stx";async function xW($){let Z=Date.now(),Y=$.pagesDir??"pages",X=$.outDir??"dist",J=$.publicDir??"public";if(!$.noClean)ox(X,{recursive:!0,force:!0});nF(X,{recursive:!0});let Q=new rx(`${Y}/**/*.stx`),G=await Array.fromAsync(Q.scan("."));if(G.length===0)throw Error(`No .stx files found in ${Y}/`);let K=await Bun.build({entrypoints:G,outdir:X,plugins:[Yv()],naming:{entry:"[name].[ext]"}});if(!K.success)throw console.error(K.logs),Error("Build failed");Qv(X);let W=vW(X).filter((j)=>j.endsWith(".html")),U=p8($,aF.cwd()),_=new Set(W.map(SX));for(let j of W){let H=b4(X,j),O=rF(H,"utf8"),V=SX(j),L=U?U.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let F of L){let A=O;if(A=Gv(A),U)A=i8(A,U,F);if(A=await S0(A,aF.cwd()),A=u8(A,$,$.pages?.[V],V),U)A=Kv(A,$,U,F,V),A=Wv(A,F,U.defaultLocale,_);if(A=l8(A,$),A=Uv(A),U)A=A.replace(/<\/body>/i,`${r8(U,F)}
16477
16477
  </body>`);if($.spa!==!1)A=await SW(A,$.router);let N=U?Jv(V,F,U.defaultLocale):j,w=b4(X,N);if(nF(Xv(w),{recursive:!0}),kX(w,A),U&&F!==U.defaultLocale&&N!==j);}}if(CX(J))ax(J,X,{recursive:!0});let z=b4(X,"404.html");if(!CX(z)&&CX(b4(X,"index.html"))){let j=rF(b4(X,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${_v($.name)}</title>`);kX(z,j)}if($.sitemap!==!1){let j=[],H=W.filter((V)=>V!=="404.html").map(SX),O=U?U.locales:[null];for(let V of H){let L=$.pages?.[V];for(let F of O){let A=F&&U?C4(V,F,U.defaultLocale):V;j.push({path:A,page:L})}}kX(b4(X,"sitemap.xml"),m8($,j))}let B=c8($);if(B!==null)kX(b4(X,"robots.txt"),B);let q=W.map(SX);return{outDir:X,pages:q,durationMs:Date.now()-Z}}function Xv($){return $v($)}function Jv($,Z,Y){let X=C4($,Z,Y);if(X==="/")return"index.html";let J=X.replace(/^\//,"").replace(/\/$/,"");if(!J.includes("/")){if(Z!==Y&&J===Z)return`${Z}/index.html`;return`${J}.html`}return`${J}.html`.replace(/\.html\.html$/,".html")}function SX($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function vW($,Z=$){let Y=[];if(!CX($))return Y;for(let X of sx($,{withFileTypes:!0})){let J=b4($,X.name);if(X.isDirectory())Y.push(...vW(J,Z));else Y.push(Zv(Z,J))}return Y}function Qv($){for(let Z of vW($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(Z))continue;let Y=b4($,Z);try{if(tx(Y).size===0)ex(Y)}catch{}}}function Gv($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function Kv($,Z,Y,X,J){if(!Y)return $;if(/<html\b[^>]*\blang=/i.test($))$=$.replace(/<html\b([^>]*)\blang="[^"]*"/i,`<html$1lang="${X}"`);else $=$.replace(/<html\b([^>]*)>/i,`<html$1 lang="${X}">`);let Q=`${Z.url.replace(/\/$/,"")}${C4(J,X,Y.defaultLocale)}`;if(/<link rel="canonical"/.test($))$=$.replace(/<link rel="canonical"[^>]*>/,`<link rel="canonical" href="${yW(Q)}">`);let G=X.includes("_")||X.includes("-")?X:X.toLowerCase();if(/<meta property="og:locale"/.test($))$=$.replace(/<meta property="og:locale"[^>]*>/,`<meta property="og:locale" content="${yW(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${yW(Q)}">`);let K=n8(Z.url,J,Y);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(W)=>`${K}
@@ -20792,7 +20792,7 @@ else {
20792
20792
  `)}function Kw($,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:""}"`:Kw(K,Z+1)),G=Q.length>0?`,
20793
20793
  ${Y} [${Q.join(`,
20794
20794
  ${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function If($,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(`
20795
- `)}return Y.get(Z.target)||WU($,Z)}function Df($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:Uw(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 kf($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function Ww(){return`id_${++Sf}`}function Uw($){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 Cf($){return $.charAt(0).toUpperCase()+$.slice(1)}function bf($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function Pf($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function UU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=UU(Y);return Z}function _U($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=_U(Y);return Z}function _w($){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 zU,Sf=0,yf,xf;var Bw=D(()=>{zU=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"}]]);yf={compileToNative:Yw,createHotReloadServer:_w,NATIVE_COMPONENTS:zU},xf=yf});import{spawn as Hw}from"child_process";import y0 from"fs";import vf from"os";import Y0 from"path";import y from"process";import{CLI as gf}from"@stacksjs/clapp";var R6="0.2.108";G5();hW();nG();YK();h4();eG();cG();kW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",H0=new gf("stx");function qw($){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 jw($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.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(y0.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 BU($){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 m$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),ff=($)=>$.endsWith(".stx")||$.endsWith(".md");function u$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);y.exit(Z)}async function hf($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(m$(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(vf.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={...y.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=Hw(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),y.on("SIGINT",()=>{console.log(`
20795
+ `)}return Y.get(Z.target)||WU($,Z)}function Df($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:Uw(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 kf($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function Ww(){return`id_${++Sf}`}function Uw($){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 Cf($){return $.charAt(0).toUpperCase()+$.slice(1)}function bf($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function Pf($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function UU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=UU(Y);return Z}function _U($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=_U(Y);return Z}function _w($){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 zU,Sf=0,yf,xf;var Bw=D(()=>{zU=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"}]]);yf={compileToNative:Yw,createHotReloadServer:_w,NATIVE_COMPONENTS:zU},xf=yf});import{spawn as Hw}from"child_process";import y0 from"fs";import vf from"os";import Y0 from"path";import y from"process";import{CLI as gf}from"@stacksjs/clapp";var R6="0.2.109";G5();hW();nG();YK();h4();eG();cG();kW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",H0=new gf("stx");function qw($){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 jw($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.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(y0.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 BU($){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 m$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),ff=($)=>$.endsWith(".stx")||$.endsWith(".md");function u$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);y.exit(Z)}async function hf($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(m$(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(vf.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={...y.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=Hw(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),y.on("SIGINT",()=>{console.log(`
20796
20796
  Test run interrupted`),K.kill("SIGINT"),y.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var df=y.argv.length>=3&&(ff(y.argv[2])&&y0.existsSync(y.argv[2])||m$(y.argv[2]));if(df){let $=y.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<y.argv.length;Y++){let X=y.argv[Y];if(X==="--port"&&Y+1<y.argv.length){let J=qw(y.argv[++Y]);if(!J.isValid)u$(J);Z.port=Number.parseInt(y.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<y.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=y.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(m$($))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((_)=>/\[.+\]/.test(Y0.basename(_)));for(let _ of U)if(!X.includes(_))X.push(_)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),y.exit(1);if(!await t8(X,Z))y.exit(1)}catch(Y){console.error("Failed to process files:",Y),y.exit(1)}else o8($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),y.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]};H0.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 iG(X))console.log("Documentation generated successfully."),y.exit(0);else console.error("Documentation generation failed."),y.exit(1)}catch(J){console.error("Error generating documentation:",J),y.exit(1)}}),H0.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(`
20797
20797
  \uD83D\uDCDA Fetching available icon collections...
20798
20798
  `);let K=await Q(),W=Object.entries(K).sort((U,_)=>_[1].total-U[1].total);console.log(`Available collections:
@@ -1,4 +1,4 @@
1
- const FOUC_SCRIPT = (defaultTheme, storageKey, lightColor, darkColor) => `(function(){function read(){try{var k=${JSON.stringify(storageKey)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify(defaultTheme)}==='dark'||(${JSON.stringify(defaultTheme)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify(defaultTheme)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(darkColor)}:${JSON.stringify(lightColor)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`, TOGGLE_HANDLER = (storageKey, lightColor, darkColor) => `document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify(storageKey)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(darkColor)}:${JSON.stringify(lightColor)})});`;
1
+ const FAVICON_FN = `window.__stxThemeIcon=function(isDark){try{var want=isDark?'dark':'light';var pick=document.querySelector('link[rel~="icon"][media*="prefers-color-scheme: '+want+'"]');if(!pick)return;var live=document.querySelector('link[rel~="icon"]:not([media])');if(!live){live=document.createElement('link');live.setAttribute('rel','icon');document.head.appendChild(live)}if(pick.type)live.setAttribute('type',pick.type);var href=pick.getAttribute('href');if(live.getAttribute('href')!==href)live.setAttribute('href',href)}catch(e){}};`, FOUC_SCRIPT = (defaultTheme, storageKey, lightColor, darkColor) => `(function(){${FAVICON_FN}function read(){try{var k=${JSON.stringify(storageKey)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify(defaultTheme)}==='dark'||(${JSON.stringify(defaultTheme)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify(defaultTheme)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(darkColor)}:${JSON.stringify(lightColor)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`, TOGGLE_HANDLER = (storageKey, lightColor, darkColor) => `document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify(storageKey)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(darkColor)}:${JSON.stringify(lightColor)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;
2
2
  export function injectThemeBootstrap(html, site) {
3
3
  if (site.theme === !1)
4
4
  return html;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.108",
4
+ "version": "0.2.109",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,16 +117,16 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.6",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/sanitizer": "0.2.108",
120
+ "@stacksjs/sanitizer": "0.2.109",
121
121
  "@stacksjs/ts-i18n": "^0.1.11",
122
- "bun-plugin-stx": "0.2.108",
122
+ "bun-plugin-stx": "0.2.109",
123
123
  "bunfig": "^0.15.15",
124
- "stx-router": "0.2.108",
124
+ "stx-router": "0.2.109",
125
125
  "ts-broadcasting": "^0.0.9",
126
126
  "ts-images": "^0.1.9",
127
127
  "ts-syntax-highlighter": "^0.2.1"
128
128
  },
129
129
  "optionalDependencies": {
130
- "@stacksjs/desktop": "0.2.108"
130
+ "@stacksjs/desktop": "0.2.109"
131
131
  }
132
132
  }