@stacksjs/stx 0.2.791 → 0.2.793

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.
Files changed (104) hide show
  1. package/dist/chunk-0a9ceqa8.js +2 -0
  2. package/dist/{chunk-vqwxv8ck.js → chunk-0cm94ksp.js} +1 -1
  3. package/dist/{chunk-894fga23.js → chunk-0ppx28f6.js} +1 -1
  4. package/dist/{chunk-064faxda.js → chunk-0ykteae5.js} +1 -1
  5. package/dist/{chunk-c046mq5d.js → chunk-1aent61q.js} +1 -1
  6. package/dist/{chunk-4vj99vqh.js → chunk-1pbyr47e.js} +1 -1
  7. package/dist/{chunk-xxkxk6j2.js → chunk-1z9hbzpk.js} +1 -1
  8. package/dist/chunk-22z2cwhv.js +2 -0
  9. package/dist/{chunk-98bxcss9.js → chunk-276e3d0g.js} +1 -1
  10. package/dist/chunk-27vn4674.js +2 -0
  11. package/dist/{chunk-09ybdmk1.js → chunk-2hwwmn7c.js} +3 -3
  12. package/dist/{chunk-xfnj17kd.js → chunk-44ep7dkr.js} +1 -1
  13. package/dist/{chunk-3tmcmbj6.js → chunk-44tq4d62.js} +1 -1
  14. package/dist/chunk-499v1ade.js +2 -0
  15. package/dist/{chunk-a8sb2jwq.js → chunk-4cffjp4f.js} +6 -6
  16. package/dist/{chunk-axfz9jcz.js → chunk-4de6rhaj.js} +2 -2
  17. package/dist/{chunk-mbm6vg8r.js → chunk-4gx5ze56.js} +1 -1
  18. package/dist/{chunk-gvr9kdqp.js → chunk-55j4jxwe.js} +5 -5
  19. package/dist/chunk-55wsqxfk.js +2 -0
  20. package/dist/{chunk-a3v7jkp6.js → chunk-56yhvhjq.js} +2 -2
  21. package/dist/{chunk-838nk7ad.js → chunk-5pe7wcvh.js} +1 -1
  22. package/dist/chunk-5y5k6x3r.js +2 -0
  23. package/dist/{chunk-dmkaaf3k.js → chunk-628jcm1d.js} +1 -1
  24. package/dist/{chunk-x4ssghte.js → chunk-66r0f799.js} +1 -1
  25. package/dist/{chunk-m58ga249.js → chunk-6h7yhyb8.js} +1 -1
  26. package/dist/{chunk-q5jxnqfr.js → chunk-6jx0trea.js} +4 -4
  27. package/dist/{chunk-e4x4q5rf.js → chunk-6jzqzap6.js} +4 -4
  28. package/dist/{chunk-ahvtsmj7.js → chunk-7fx8p9w5.js} +1 -1
  29. package/dist/{chunk-np7ryj86.js → chunk-7yb8943c.js} +1 -1
  30. package/dist/{chunk-sc5fx7vj.js → chunk-8698v9gf.js} +1 -1
  31. package/dist/{chunk-fdafgcxp.js → chunk-98308vtv.js} +1 -1
  32. package/dist/{chunk-3a5qnt2f.js → chunk-a1ynjj47.js} +21 -4
  33. package/dist/{chunk-khjcp7jn.js → chunk-a4cse2tj.js} +1 -1
  34. package/dist/{chunk-p3qx6bhx.js → chunk-ad2fk303.js} +1 -1
  35. package/dist/{chunk-efpsvjp9.js → chunk-bb2zfgwf.js} +2 -2
  36. package/dist/{chunk-j3qpzk2g.js → chunk-brqcepmv.js} +1 -1
  37. package/dist/{chunk-pa785cdg.js → chunk-bxxgr5c5.js} +1 -1
  38. package/dist/{chunk-mafav2b3.js → chunk-c2qwbej3.js} +2 -2
  39. package/dist/{chunk-40tsja2j.js → chunk-ddbkw53b.js} +1 -1
  40. package/dist/{chunk-qm79fkj3.js → chunk-dtnyrjcj.js} +1 -1
  41. package/dist/chunk-dyp0kgmr.js +177 -0
  42. package/dist/chunk-fc384a2h.js +2 -0
  43. package/dist/{chunk-4jxfd333.js → chunk-g3z2g6hm.js} +1 -1
  44. package/dist/{chunk-4pkhz90f.js → chunk-g7anxh36.js} +1 -1
  45. package/dist/{chunk-njse2cjy.js → chunk-g89fx9rq.js} +4 -4
  46. package/dist/{chunk-j0ye6whq.js → chunk-gg71gm25.js} +1 -1
  47. package/dist/{chunk-s5cmn70z.js → chunk-gnydrw29.js} +1 -1
  48. package/dist/{chunk-kpreycjr.js → chunk-hs9fzxn0.js} +1 -1
  49. package/dist/{chunk-8vq5w11w.js → chunk-j4s5k8sp.js} +2 -2
  50. package/dist/chunk-jkm34gec.js +2 -0
  51. package/dist/{chunk-f5zktb21.js → chunk-js5zve3p.js} +1 -1
  52. package/dist/chunk-k3mcb700.js +3 -0
  53. package/dist/{chunk-8ft5vgp3.js → chunk-m997knnz.js} +1 -1
  54. package/dist/{chunk-tkyqm6tq.js → chunk-ncxed9r1.js} +1 -1
  55. package/dist/chunk-nptp3x62.js +2 -0
  56. package/dist/{chunk-c2s10cg6.js → chunk-qd9f47ds.js} +1 -1
  57. package/dist/{chunk-hmncyjhc.js → chunk-r2nvxbjc.js} +1 -1
  58. package/dist/{chunk-xwqkmkvw.js → chunk-spt5kmb2.js} +1 -1
  59. package/dist/{chunk-sqq3hqpb.js → chunk-syheccfj.js} +1 -1
  60. package/dist/chunk-t8vtf522.js +2 -0
  61. package/dist/{chunk-nmpkabry.js → chunk-t9744tty.js} +1 -1
  62. package/dist/{chunk-sg63qj3m.js → chunk-vaqqch06.js} +1 -1
  63. package/dist/{chunk-bnpckvpq.js → chunk-vj59es75.js} +1 -1
  64. package/dist/{chunk-64g7z2m2.js → chunk-xadd911n.js} +1 -1
  65. package/dist/{chunk-xws9e6j9.js → chunk-xc0vws7m.js} +2 -2
  66. package/dist/{chunk-07fj6472.js → chunk-zsjw2jgy.js} +1 -1
  67. package/dist/cli.js +8 -8
  68. package/dist/client/signals-component-hydration-runtime.js +3 -1
  69. package/dist/client/signals-component-props-runtime.js +1 -1
  70. package/dist/client/signals-expression-compiler-runtime.js +4 -1
  71. package/dist/client/signals-expression-runtime.js +3 -1
  72. package/dist/client/signals-pipe-runtime.js +10 -0
  73. package/dist/craft-entry.js +1 -1
  74. package/dist/craft.js +1 -1
  75. package/dist/native/compiler/class-table.d.ts +24 -0
  76. package/dist/native/compiler/class-table.js +46 -0
  77. package/dist/native/compiler/headwind-to-style.d.ts +4 -0
  78. package/dist/native/compiler/headwind-to-style.js +23 -7
  79. package/dist/native/compiler/inline-style.d.ts +0 -1
  80. package/dist/native/compiler/inline-style.js +5 -1
  81. package/dist/native/compiler/ir.d.ts +2 -0
  82. package/dist/native/compiler/render-screen.js +4 -0
  83. package/dist/native/compiler/style-config.d.ts +2 -0
  84. package/dist/native/compiler/style-config.js +3 -0
  85. package/dist/native/runtime/binding-tree.d.ts +10 -5
  86. package/dist/native/runtime/binding-tree.js +18 -10
  87. package/dist/native/runtime/native-host.d.ts +4 -0
  88. package/dist/native/runtime/native-host.js +128 -55
  89. package/dist/native/runtime/shared-screen.js +1 -0
  90. package/dist/pwa.js +1 -1
  91. package/dist/ssg.js +2 -2
  92. package/package.json +5 -5
  93. package/dist/chunk-07w4gp1w.js +0 -2
  94. package/dist/chunk-1ac8dt85.js +0 -2
  95. package/dist/chunk-1nr15t1f.js +0 -2
  96. package/dist/chunk-1vr1gw3h.js +0 -2
  97. package/dist/chunk-513b47g2.js +0 -177
  98. package/dist/chunk-5c89afzb.js +0 -3
  99. package/dist/chunk-6g0nqqf5.js +0 -2
  100. package/dist/chunk-cjwghh53.js +0 -2
  101. package/dist/chunk-fpxwpxwr.js +0 -2
  102. package/dist/chunk-h84k7ybc.js +0 -2
  103. package/dist/chunk-jwt8034r.js +0 -2
  104. package/dist/chunk-qngta0pe.js +0 -2
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  import R from"path";var O=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function Lr(...g){let d=new Set;for(let c of g){if(!c||!c.includes("__stxModules["))continue;for(let s of c.matchAll(O))try{d.add(JSON.parse(`"${s[1]}"`))}catch{}}return[...d].sort()}function no(...g){let d=new Map,c=(s,e)=>{let r=d.get(s);if(r===null)return;if(e===null){d.set(s,null);return}let n=r??new Set;for(let i of e)n.add(i);d.set(s,n)};for(let s of g){if(!s||!s.includes("__stxModules["))continue;let e=[];for(let n of s.matchAll(/([\w$]+)\s*=\s*globalThis\.__stxModules\s*&&\s*globalThis\.__stxModules\["((?:[^"\\]|\\.)*)"\]/g)){let i;try{i=JSON.parse(`"${n[2]}"`)}catch{continue}e.push({variable:n[1],id:i,start:n.index+n[0].length,end:s.length})}let r=s.match(/__stxModules\["(?:[^"\\]|\\.)*"\]/g)?.length??0;if(e.length===0||r!==e.length){for(let n of Lr(s))c(n,null);continue}for(let[n,i]of e.entries()){let p=e.slice(n+1).find((h)=>h.variable===i.variable);i.end=p?p.start:s.length}for(let n of e){let i=new Set,p=!1,h=n.variable.replace(/[$]/g,"\\$&"),o=s.slice(n.start,n.end);for(let l of o.matchAll(new RegExp(`(?<![\\w$.])${h}(?![\\w$])`,"g"))){let f=o.slice(l.index+n.variable.length,l.index+n.variable.length+200),a=/^\s*\[\s*(["'])([A-Za-z_$][\w$]*)\1\s*\]/.exec(f)??/^\s*\.\s*([A-Za-z_$][\w$]*)/.exec(f);if(a){i.add(a[a.length-1]);continue}if(/^\s*[!=]==?\s*(?:undefined|void 0)\b/.test(f))continue;p=!0;break}c(n.id,p?null:i)}}return d}function v(g,d,c){let s=[],e=[];return g.forEach((r,n)=>{let i=r.startsWith("npm:")?r.slice(4):R.resolve(d,r),p=`__stxRegistered${n}`,h=JSON.stringify(r),o=c?.get(r);if(o&&[...o].every((l)=>/^[A-Za-z_$][\w$]*$/.test(l))){let l=[...o].sort(),f=l.map((m,_)=>`${m} as ${p}_${_}`);s.push(l.length>0?`import { ${f.join(", ")} } from ${JSON.stringify(i)};`:`import ${JSON.stringify(i)};`);let a=l.map((m,_)=>`get ${JSON.stringify(m)}() { return ${p}_${_}; }`).join(", ");e.push(`if (!globalThis.__stxModules[${h}]) globalThis.__stxModules[${h}] = { ${a} };`);return}s.push(`import * as ${p} from ${JSON.stringify(i)};`),e.push(`if (!globalThis.__stxModules[${h}]) globalThis.__stxModules[${h}] = ${p};`)}),[...s,"globalThis.__stxModules = globalThis.__stxModules || {};",...e].join(`
3
- `)}async function Dg(g,d={}){if(g.length===0)return null;let c=process.cwd(),s=v(g,c,d.names),e;try{let{bundleClientScript:l}=await import("./chunk-tkyqm6tq.js"),f=()=>l(s,R.join(c,".stx-module-registry.ts"),{projectRoot:c,minify:d.minify,externalizeUserModules:!1,collectInputs:d.collectInputs,throwOnFailure:!0});try{e=await f()}catch(a){if(!d.names)throw a;s=v(g,c,void 0),e=await f()}}catch(l){let{formatBuildFailure:f}=await import("./chunk-0jvrzpfs.js"),a=f(l);console.warn(`[stx] could not build the page module registry (#1957): ${a}`);let m=`[stx] the page module registry did not build, so ${g.join(", ")} cannot load (#1957): ${a}`;return`;console.error(${JSON.stringify(m)});`}let{transformAutoImports:r,generateAutoImportDestructuring:n}=await import("./chunk-3tmcmbj6.js"),i=r(e),p=n(i.stxImports,i.browserImports),{transformStoreImports:h}=await import("./chunk-b3b9tfpx.js");e=h(i.code);let o=JSON.stringify(new Bun.CryptoHasher("md5").update(s).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${o}]) return;`,` __stxBundles[${o}] = true;`,p,e,"})();"].join(`
3
+ `)}async function Dg(g,d={}){if(g.length===0)return null;let c=process.cwd(),s=v(g,c,d.names),e;try{let{bundleClientScript:l}=await import("./chunk-ncxed9r1.js"),f=()=>l(s,R.join(c,".stx-module-registry.ts"),{projectRoot:c,minify:d.minify,externalizeUserModules:!1,collectInputs:d.collectInputs,throwOnFailure:!0});try{e=await f()}catch(a){if(!d.names)throw a;s=v(g,c,void 0),e=await f()}}catch(l){let{formatBuildFailure:f}=await import("./chunk-0jvrzpfs.js"),a=f(l);console.warn(`[stx] could not build the page module registry (#1957): ${a}`);let m=`[stx] the page module registry did not build, so ${g.join(", ")} cannot load (#1957): ${a}`;return`;console.error(${JSON.stringify(m)});`}let{transformAutoImports:r,generateAutoImportDestructuring:n}=await import("./chunk-44tq4d62.js"),i=r(e),p=n(i.stxImports,i.browserImports),{transformStoreImports:h}=await import("./chunk-b3b9tfpx.js");e=h(i.code);let o=JSON.stringify(new Bun.CryptoHasher("md5").update(s).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${o}]) return;`,` __stxBundles[${o}] = true;`,p,e,"})();"].join(`
4
4
  `)}var P=/^import(?:[ \t]*(\{[^}]*\})[ \t]*from|[ \t]*\*[ \t]*as[ \t]+([\w$]+)[ \t]+from)?[ \t]*["']\.\/(chunk-[\w-]+)\.js["'][ \t]*;?[ \t]*$/gm,j=/^export\s*\{([^}]*)\}\s*;?[ \t]*$/gm,I=new Set(["__preload","__chunks"]),N=/^("[^"]*"|[\w$]+)(?:\s+as\s+("[^"]*"|[\w$]+))?$/;function J(g){let d=[],c=[],s=!0,r=g.replace(/^var __chunkGraphs;[\s\S]*?^var __chunks = [\s\S]*?^\};[ \t]*\n?/m,"").replace(/^__chunks\(import\.meta\.url,[^\n]*\);[ \t]*\n?/gm,"").replace(P,(h,o,l,f)=>{let a=`__stxChunkExports${d.length}`;if(d.push(f),c.push(`var ${a} = __stxChunk(${JSON.stringify(f)});`),l)c.push(`var ${l} = ${a};`);else if(o)for(let m of o.slice(1,-1).split(",")){let _=m.trim();if(!_)continue;let w=N.exec(_);if(!w){s=!1;continue}if(I.has(w[1]))continue;let M=w[1].startsWith('"')?JSON.parse(w[1]):w[1],t=w[2]??w[1];if(t.startsWith('"')){s=!1;continue}c.push(`var ${t} = ${a}[${JSON.stringify(M)}];`)}return""});if(!s)throw Error("an import it does not read");let n=[];r=r.replace(/\(\s*__preload\([^)]*\)\s*,\s*import\(\s*["']\.\/(chunk-[\w-]+)\.js["']\s*\)\s*\)|\bimport\(\s*["']\.\/(chunk-[\w-]+)\.js["']\s*\)/g,(h,o,l)=>{let f=o??l;return n.push(f),`Promise.resolve().then(function () { return __stxChunk(${JSON.stringify(f)}); })`});let i=[];r=r.replace(j,(h,o)=>{for(let l of o.split(",")){let f=l.trim();if(!f)continue;let a=N.exec(f);if(!a||a[1].startsWith('"')){s=!1;continue}if(I.has(a[1]))continue;let m=a[2]??a[1];i.push([a[1],m.startsWith('"')?JSON.parse(m):m])}return""});let p=[/\bimport\.meta\b/,/\b__chunks\b/,/\b__preload\b/,/^\s*export\s+(?:default\b|const\b|let\b|var\b|function\b|class\b|async\b|\*|\{)/m,/\bfrom\s*["']\.\/chunk-/,/^\s*import\s*["']\.\/chunk-/m].find((h)=>h.test(r));if(!s||p)throw Error(`${p?`${p.source} is left in it`:"an export it does not read"}`);return{reads:c.join(`
5
5
  `),chunks:d,lazy:n,body:r,exports:i}}function kl(g){if(/\bexport\s+(?:let|var)\b/.test(g))return!0;if(g.length/Math.max(1,g.split(`
6
- `).length)>200)return!1;for(let d of g.matchAll(/\bexport\s*\{([^}]*)\}(?!\s*from\b)/g))for(let c of d[1].split(",")){let s=c.trim().split(/\s+as\s+/)[0].trim();if(!/^[A-Za-z_$][\w$]*$/.test(s))continue;let e=s.replace(/[$]/g,"\\$&");if(!new RegExp(`(?<![\\w$.])(?:let|var)\\s+${e}(?![\\w$])`,"g").test(g))continue;let n=new RegExp(`(?<![\\w$.])${e}\\s*(?:=(?![=>])|[-+*/%&|^]=|\\*\\*=|<<=|>>>?=|&&=|\\|\\|=|\\?\\?=|\\+\\+|--)|(?:\\+\\+|--)\\s*${e}(?![\\w$])`,"g"),i=new RegExp(`(?<![\\w$.])(?:let|var|const)\\s+${e}\\s*=`,"g");if((g.match(n)?.length??0)>(g.match(i)?.length??0))return!0}return!1}async function ro(g,d={}){let c=g.filter((e)=>e.ids.length>0);if(c.length===0)return{chunks:new Map,routes:new Map,reads:new Map};let s=process.cwd();try{let{bundleClientEntriesSplit:e}=await import("./chunk-tkyqm6tq.js"),r=[],n=await e(new Map(c.map((t)=>[t.name,v(t.ids,s,t.names)])),{projectRoot:s,filePath:R.join(s,".stx-module-registry.ts"),collectInputs:r});d.collectInputs?.push(...r);let{transformAutoImports:i,generateAutoImportDestructuring:p}=await import("./chunk-3tmcmbj6.js"),{transformStoreImports:h}=await import("./chunk-b3b9tfpx.js"),o=new Map;for(let[t,u]of[...n.chunks,...n.entries])try{o.set(t,J(u))}catch(b){throw Error(`cannot read ${t}: ${b instanceof Error?b.message:String(b)}`)}for(let[t,u]of[...n.chunks,...n.entries])if(/\b__esm\(/.test(u))throw Error(`${t} initialises a module lazily`);for(let t of r)if(/\.(?:[cm]?[jt]sx?)$/.test(t)&&kl(await Bun.file(t).text()))throw Error(`${t} exports a binding that changes after it is read`);let l=new Set,f=new Set,a=(t)=>{if(f.has(t))return;if(l.has(t))throw Error(`the chunks import each other (${t})`);l.add(t);for(let u of o.get(t)?.chunks??[]){if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);a(u)}for(let u of o.get(t)?.lazy??[])if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);l.delete(t),f.add(t)};for(let t of o.keys())a(t);let m=(t)=>{let u=i(t.body);return{prelude:p(u.stxImports,u.browserImports),body:h(u.code)}},_=new Map;for(let t of n.chunks.keys()){let u=o.get(t),{prelude:b,body:k}=m(u),y=u.exports.map(([S,x])=>`get ${JSON.stringify(x)}() { return ${S}; }`).join(", ");_.set(t,`function (__stxChunk) {
6
+ `).length)>200)return!1;for(let d of g.matchAll(/\bexport\s*\{([^}]*)\}(?!\s*from\b)/g))for(let c of d[1].split(",")){let s=c.trim().split(/\s+as\s+/)[0].trim();if(!/^[A-Za-z_$][\w$]*$/.test(s))continue;let e=s.replace(/[$]/g,"\\$&");if(!new RegExp(`(?<![\\w$.])(?:let|var)\\s+${e}(?![\\w$])`,"g").test(g))continue;let n=new RegExp(`(?<![\\w$.])${e}\\s*(?:=(?![=>])|[-+*/%&|^]=|\\*\\*=|<<=|>>>?=|&&=|\\|\\|=|\\?\\?=|\\+\\+|--)|(?:\\+\\+|--)\\s*${e}(?![\\w$])`,"g"),i=new RegExp(`(?<![\\w$.])(?:let|var|const)\\s+${e}\\s*=`,"g");if((g.match(n)?.length??0)>(g.match(i)?.length??0))return!0}return!1}async function ro(g,d={}){let c=g.filter((e)=>e.ids.length>0);if(c.length===0)return{chunks:new Map,routes:new Map,reads:new Map};let s=process.cwd();try{let{bundleClientEntriesSplit:e}=await import("./chunk-ncxed9r1.js"),r=[],n=await e(new Map(c.map((t)=>[t.name,v(t.ids,s,t.names)])),{projectRoot:s,filePath:R.join(s,".stx-module-registry.ts"),collectInputs:r});d.collectInputs?.push(...r);let{transformAutoImports:i,generateAutoImportDestructuring:p}=await import("./chunk-44tq4d62.js"),{transformStoreImports:h}=await import("./chunk-b3b9tfpx.js"),o=new Map;for(let[t,u]of[...n.chunks,...n.entries])try{o.set(t,J(u))}catch(b){throw Error(`cannot read ${t}: ${b instanceof Error?b.message:String(b)}`)}for(let[t,u]of[...n.chunks,...n.entries])if(/\b__esm\(/.test(u))throw Error(`${t} initialises a module lazily`);for(let t of r)if(/\.(?:[cm]?[jt]sx?)$/.test(t)&&kl(await Bun.file(t).text()))throw Error(`${t} exports a binding that changes after it is read`);let l=new Set,f=new Set,a=(t)=>{if(f.has(t))return;if(l.has(t))throw Error(`the chunks import each other (${t})`);l.add(t);for(let u of o.get(t)?.chunks??[]){if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);a(u)}for(let u of o.get(t)?.lazy??[])if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);l.delete(t),f.add(t)};for(let t of o.keys())a(t);let m=(t)=>{let u=i(t.body);return{prelude:p(u.stxImports,u.browserImports),body:h(u.code)}},_=new Map;for(let t of n.chunks.keys()){let u=o.get(t),{prelude:b,body:k}=m(u),y=u.exports.map(([S,x])=>`get ${JSON.stringify(x)}() { return ${S}; }`).join(", ");_.set(t,`function (__stxChunk) {
7
7
  ${b}
8
8
  ${u.reads}
9
9
  ${k}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{hn,Jf,Yf,Zf,Qf,eg,m,tg,pi,ng,Vc,Uc}from"./chunk-a8sb2jwq.js";import"./chunk-sqq3hqpb.js";import"./chunk-27rzdq3n.js";import"./chunk-94gyfwpz.js";import"./chunk-2yxva96k.js";import"./chunk-gb65t4n1.js";export{hn as STX_ENGINE_BINDING_NAMES,pi as convertToCommonJS,Vc as extractScriptFromTemplate,m as extractVariables,Uc as hasVariables,tg as isCompleteImport,eg as isMissingBindingFailure,Zf as isModuleResolutionFailure,Qf as isSyntaxFailure,ng as splitDeclaration,Jf as stripTypeScript,Yf as withoutStxReferrer};
2
+ import{hn,Jf,Yf,Zf,Qf,eg,m,tg,pi,ng,Vc,Uc}from"./chunk-4cffjp4f.js";import"./chunk-syheccfj.js";import"./chunk-27rzdq3n.js";import"./chunk-94gyfwpz.js";import"./chunk-2yxva96k.js";import"./chunk-gb65t4n1.js";export{hn as STX_ENGINE_BINDING_NAMES,pi as convertToCommonJS,Vc as extractScriptFromTemplate,m as extractVariables,Uc as hasVariables,tg as isCompleteImport,eg as isMissingBindingFailure,Zf as isModuleResolutionFailure,Qf as isSyntaxFailure,ng as splitDeclaration,Jf as stripTypeScript,Yf as withoutStxReferrer};
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import"./chunk-94gyfwpz.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import{Pe,oe}from"./chunk-a8sb2jwq.js";import"./chunk-27rzdq3n.js";import"./chunk-sqq3hqpb.js";import"./chunk-h0jnatd4.js";import"./chunk-q14d714d.js";import"./chunk-8vq5w11w.js";import"./chunk-w9nwb8r3.js";import"./chunk-605b93pe.js";import"./chunk-njse2cjy.js";import"./chunk-98bxcss9.js";import"./chunk-efpsvjp9.js";import"./chunk-m58ga249.js";import"./chunk-e4x4q5rf.js";import"./chunk-hmncyjhc.js";import"./chunk-b4r7d6me.js";import"./chunk-c0ejyxfj.js";import"./chunk-0r61tkfe.js";import"./chunk-vkn133cs.js";import"./chunk-v8rfeev5.js";import"./chunk-h0c6jtrj.js";import"./chunk-09ybdmk1.js";import"./chunk-2p4yad7w.js";import"./chunk-bnpckvpq.js";import"./chunk-3a5qnt2f.js";import"./chunk-5j619xgb.js";import"./chunk-agtvdtx4.js";import"./chunk-xxkxk6j2.js";import"./chunk-1y9ez7nz.js";import"./chunk-a3v7jkp6.js";import"./chunk-khjcp7jn.js";import"./chunk-2gqhfge6.js";import"./chunk-xwqkmkvw.js";import"./chunk-rrb9m2q2.js";import"./chunk-4pkhz90f.js";import"./chunk-64g7z2m2.js";import"./chunk-x4ssghte.js";import"./chunk-tnkxww7b.js";import"./chunk-tnn0br4w.js";import"./chunk-gv3bfkdm.js";import"./chunk-7sh9fa3q.js";import{en,tn}from"./chunk-j0ye6whq.js";import"./chunk-064faxda.js";import"./chunk-fdafgcxp.js";import"./chunk-6v4b0xc1.js";import"./chunk-pa9zfbh6.js";import"./chunk-5a92srn2.js";import"./chunk-e3wmnjz8.js";import"./chunk-vrbcdds3.js";import"./chunk-np7ryj86.js";import"./chunk-pa785cdg.js";import{qi,Ki,Xi,Gi,so,Ji,Yi,Zi,oo,io,Fr,zr,Hr}from"./chunk-gvr9kdqp.js";import"./chunk-axfz9jcz.js";import"./chunk-d18xd9x5.js";import"./chunk-dmkaaf3k.js";import"./chunk-5c89afzb.js";import"./chunk-qv85c3qy.js";import"./chunk-q5jxnqfr.js";import"./chunk-w5hhqjwr.js";import{mc}from"./chunk-8ft5vgp3.js";import{g}from"./chunk-0dve54ne.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as z}from"@stacksjs/clapp";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new z("stx");function E(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>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 A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),r=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function I(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>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 O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),W=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function M(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function V(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let i=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(i.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...i),m.verbose)console.log(`Found ${i.length} file(s) matching pattern: ${c}`)}catch(i){return console.error(`Error expanding glob pattern ${c}:`,i),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let r=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(i)=>{let d=((performance.now()-r)/1000).toFixed(2);if(i===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
3
+ import"./chunk-94gyfwpz.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import{Pe,oe}from"./chunk-4cffjp4f.js";import"./chunk-27rzdq3n.js";import"./chunk-syheccfj.js";import"./chunk-h0jnatd4.js";import"./chunk-q14d714d.js";import"./chunk-j4s5k8sp.js";import"./chunk-w9nwb8r3.js";import"./chunk-605b93pe.js";import"./chunk-g89fx9rq.js";import"./chunk-276e3d0g.js";import"./chunk-bb2zfgwf.js";import"./chunk-6h7yhyb8.js";import"./chunk-6jzqzap6.js";import"./chunk-r2nvxbjc.js";import"./chunk-b4r7d6me.js";import"./chunk-c0ejyxfj.js";import"./chunk-0r61tkfe.js";import"./chunk-vkn133cs.js";import"./chunk-v8rfeev5.js";import"./chunk-h0c6jtrj.js";import"./chunk-2hwwmn7c.js";import"./chunk-2p4yad7w.js";import"./chunk-vj59es75.js";import"./chunk-a1ynjj47.js";import"./chunk-5j619xgb.js";import"./chunk-agtvdtx4.js";import"./chunk-1z9hbzpk.js";import"./chunk-1y9ez7nz.js";import"./chunk-56yhvhjq.js";import"./chunk-a4cse2tj.js";import"./chunk-2gqhfge6.js";import"./chunk-spt5kmb2.js";import"./chunk-rrb9m2q2.js";import"./chunk-g7anxh36.js";import"./chunk-xadd911n.js";import"./chunk-66r0f799.js";import"./chunk-tnkxww7b.js";import"./chunk-tnn0br4w.js";import"./chunk-gv3bfkdm.js";import"./chunk-7sh9fa3q.js";import{en,tn}from"./chunk-gg71gm25.js";import"./chunk-0ykteae5.js";import"./chunk-98308vtv.js";import"./chunk-6v4b0xc1.js";import"./chunk-pa9zfbh6.js";import"./chunk-5a92srn2.js";import"./chunk-e3wmnjz8.js";import"./chunk-vrbcdds3.js";import"./chunk-7yb8943c.js";import"./chunk-bxxgr5c5.js";import{qi,Ki,Xi,Gi,so,Ji,Yi,Zi,oo,io,Fr,zr,Hr}from"./chunk-55j4jxwe.js";import"./chunk-4de6rhaj.js";import"./chunk-d18xd9x5.js";import"./chunk-628jcm1d.js";import"./chunk-k3mcb700.js";import"./chunk-qv85c3qy.js";import"./chunk-6jx0trea.js";import"./chunk-w5hhqjwr.js";import{mc}from"./chunk-m997knnz.js";import{g}from"./chunk-0dve54ne.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as z}from"@stacksjs/clapp";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new z("stx");function E(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>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 A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),r=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function I(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>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 O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),W=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function M(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function V(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let i=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(i.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...i),m.verbose)console.log(`Found ${i.length} file(s) matching pattern: ${c}`)}catch(i){return console.error(`Error expanding glob pattern ${c}:`,i),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let r=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(i)=>{let d=((performance.now()-r)/1000).toFixed(2);if(i===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
4
4
  Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var U=n.argv.length>=3&&(W(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(U){let h=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=E(n.argv[++x]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),i=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of i)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await zr(t,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Fr(h,m).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let r=0;r<=e.length;r++)o[r]=[r];for(let r=0;r<=t.length;r++)o[0][r]=r;for(let r=1;r<=e.length;r++)for(let s=1;s<=t.length;s++)if(e.charAt(r-1)===t.charAt(s-1))o[r][s]=o[r-1][s-1];else o[r][s]=Math.min(o[r-1][s-1]+1,o[r][s-1]+1,o[r-1][s]+1);return o[e.length][t.length]};y.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(t)=>{try{if(await Gi(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.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(t,e)=>{try{let{fetchCollections:o,generatePackage:r}=await import("./chunk-3wkgd883.js");if(t==="list"){console.log(`
5
5
  \uD83D\uDCDA Fetching available icon collections...
6
6
  `);let s=await o(),c=Object.entries(s).sort((i,l)=>l[1].total-i[1].total);console.log(`Available collections:
7
7
  `);for(let[i,l]of c){let d=l;console.log(` ${i.padEnd(30)} ${d.name} (${d.total} icons)`)}console.log(`
8
8
  Total: ${c.length} collections`)}else if(t.startsWith("generate")){let s=t==="generate"?"":t.replace("generate:","").replace("generate-","").replace("generate","").trim();if(!s)console.error("Error: Please specify a collection prefix"),console.error("Usage: stx iconify generate <prefix> [--icons icon1,icon2,...]"),n.exit(1);let c=e.output||f.join(n.cwd(),"packages/collections"),i=e.icons?e.icons.split(",").map((l)=>l.trim()):void 0;await r(s,c,i),console.log(`
9
9
  \u2713 Package generated successfully!`),console.log(`
10
- To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-6f6xqzhb.js"),{loadConfig:s}=await import("./chunk-838nk7ad.js");console.log(`
10
+ To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-6f6xqzhb.js"),{loadConfig:s}=await import("./chunk-5pe7wcvh.js");console.log(`
11
11
  \uD83D\uDD0D Running PWA audit...
12
12
  `);let c=await s(),i=e.output||"dist",l=o(c,i);if(console.log(r(l)),l.failed>0)n.exit(1)}else console.error(`Unknown pwa command: ${t}`),console.error("Available commands: audit"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("dev [file]","Start a development server for an STX app or file").option("--port <port>","Port to use for the dev server",{default:3000}).option("--pages <dir>",'Directory containing page templates (default: pagesDir from stx.config.ts, else "pages")').option("--no-watch","Disable file watching and auto-reload").option("--native","Open in a native desktop window using Zyte").option("--titlebar-hidden","Hide the native titlebar but keep the traffic-light buttons (web content draws under a transparent full-size titlebar). Implies --native.").option("--highlight-theme <theme>","Syntax highlighting theme for Markdown code blocks",{default:"github-dark"}).option("--no-highlight","Disable syntax highlighting for Markdown code blocks").option("--no-highlight-unknown","Disable syntax highlighting for unknown languages in Markdown").option("--no-cache","Disable caching of parsed files").option("--no-hmr","Disable HMR / live-reload script injection (useful for clean network traces)").option("--profile","Print per-directive timing for every page render via performanceMonitor").option("--debug-directives","Log directive ordering and intermediate template state during rendering").example("stx dev").example("stx dev --port 8080").example("stx dev --pages src/pages").example("stx dev template.stx").example("stx dev components/hero.stx --port 8080").example("stx dev **/*.stx").example("stx dev docs/guide.md").example("stx dev template.stx --native").action(async(t,e)=>{try{if(e.port!==void 0){let r=E(e.port);if(!r.isValid)F(r);e.port=Number.parseInt(String(e.port),10)}if(e.timeout!==void 0){let r=I(e.timeout);if(!r.isValid)F(r)}let o={syntaxHighlighting:{enabled:e.highlight!==!1,serverSide:!0,defaultTheme:e.highlightTheme||"github-dark",highlightUnknownLanguages:e.highlightUnknown!==!1}};if(!t){if(!await Hr(".",{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}if(!O(t))try{let r=await import("fs");if(r.existsSync(t)&&r.statSync(t).isDirectory()){if(!await Hr(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}}catch{}if(O(t)){console.log(`Expanding glob pattern: ${t}`);let r=await oe.timeAsync("glob-expansion",async()=>Array.fromAsync(new Bun.Glob(t).scan({onlyFiles:!0,absolute:!0}))),s=t.endsWith(".stx")?r.filter((d)=>d.endsWith(".stx")):t.endsWith(".md")?r.filter((d)=>d.endsWith(".md")):r.filter((d)=>d.endsWith(".stx")||d.endsWith(".md"));if(s.length===0)console.error(`No STX or Markdown files found matching pattern: ${t}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),n.exit(1);let c=t.split("*")[0].replace(/\/$/,"")||".",i=f.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((p)=>/\[.+\]/.test(f.basename(p)));for(let p of u)if(!s.includes(p))s.push(p)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await zr(s,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}else{if(!O(t)){let s=A(t);if(!s.isValid)F(s)}if(!await Fr(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}}catch(o){console.error("Error starting dev server:",o),n.exit(1)}}),y.command("a11y [target]","Scan .stx files for accessibility issues (directory, file, or glob)").option("--no-recursive","Disable recursive scanning of directories").option("--ignore <paths>","Comma-separated paths to ignore",{default:""}).option("--json","Output results as JSON").option("--output <file>","Write results to a file instead of stdout").option("--fix","Automatically fix common accessibility issues").example("stx a11y ./templates").example('stx a11y "resources/**/*.stx"').example("stx a11y resources/emails/welcome.stx").example("stx a11y --json --output a11y-report.json").action(async(t=".",e)=>{try{console.log(`Scanning ${t} for accessibility issues...`);let o=e.ignore?e.ignore.split(",").map((l)=>l.trim()):[],{results:r,scannedFiles:s}=await mc(t,{recursive:e.recursive!==!1,ignorePaths:o});if(s.length===0)console.log(`
13
13
  No .stx files matched ${t}
@@ -69,7 +69,7 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
69
69
  File not found: ${t}`),n.exit(1);if(!t.endsWith(".stx"))console.error(`
70
70
  File must have .stx extension: ${t}`),n.exit(1)}let r=f.resolve(e.pages),s=f.resolve(e.out);if(!t&&!S.existsSync(r))console.error(`
71
71
  Pages directory not found: ${r}`),console.log(`
72
- Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-f5zktb21.js");tn();let i=await c({root:t?f.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(i.mode==="ssr"&&i.ssr)console.log(`
72
+ Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-js5zve3p.js");tn();let i=await c({root:t?f.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(i.mode==="ssr"&&i.ssr)console.log(`
73
73
  Build complete! (SSR)
74
74
  `),console.log(` Pages compiled: ${i.ssr.pageCount}`),console.log(` Output: ${i.ssr.outputDir}`),console.log(` Duration: ${l}s
75
75
  `);else if(i.ssg){if(console.log(`
@@ -84,7 +84,7 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
84
84
  Build completed with ${i.ssg.failedCount} error(s). Fix the issues above and try again.
85
85
  `),n.exit(1);console.log(" To preview locally:"),console.log(` cd ${e.out||"dist"} && npx serve
86
86
  `)}}catch(o){console.error(`
87
- Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-07w4gp1w.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
87
+ Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-55wsqxfk.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
88
88
  Failed to start production server:`,e instanceof Error?e.message:String(e)),n.exit(1)}}),y.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(t,e)=>{try{let{deploy:o,initNetlify:r,DeployError:s}=await import("./chunk-kn38mjpp.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Pe}\x1B[0m`),e.init){console.log(`
89
89
  \uD83D\uDCDD Initializing Netlify configuration...
90
90
  `);let i=await r({directory:t||n.cwd(),siteId:e.siteId});if(console.log(`\u2713 Created ${i.configPath}`),i.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
@@ -124,7 +124,7 @@ To view it in the development server:`),console.log(` stx dev ${t}
124
124
  \uD83D\uDCDD ${f.relative(n.cwd(),a)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${f.basename(a)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(a,b),console.log(`\u2705 Formatted ${f.relative(n.cwd(),a)}`),l++}catch(u){console.error(`\u274C Error formatting ${f.relative(n.cwd(),a)}:`,u),d++}if(e.check&&d>0)console.log(`
125
125
  ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.check&&!e.diff)console.log(`\u2728 Formatted ${l} files successfully`)}catch(o){console.error("Error formatting files:",o),n.exit(1)}}),y.command("perf [command...]","Show performance statistics for STX operations").option("--clear","Clear performance statistics").option("--json","Output as JSON").example("stx perf").example("stx perf --clear").example("stx perf --json").action(async(t,e)=>{try{if(e.clear){oe.clear(),console.log("\u2705 Performance statistics cleared");return}let o=oe.getStats();if(Object.keys(o).length===0){if(e.json){console.log(JSON.stringify({},null,2));return}console.log("No performance data available. Run some STX commands first.");return}if(e.json)console.log(JSON.stringify(o,null,2));else{console.log(`
126
126
  \uD83D\uDCCA STX Performance Statistics
127
- `);for(let[r,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${r}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:r}=await import("./chunk-6g0nqqf5.js"),{resolveStxTargets:s}=await import("./chunk-zyf6737j.js"),c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx"],l=await s(i);if(l.length===0){console.log(`
127
+ `);for(let[r,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${r}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:r}=await import("./chunk-499v1ade.js"),{resolveStxTargets:s}=await import("./chunk-zyf6737j.js"),c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx"],l=await s(i);if(l.length===0){console.log(`
128
128
  No .stx files matched ${i.join(", ")}
129
129
  `);return}let d=qi(n.argv,"--lib"),a=d.length>0?d:e.lib?Array.isArray(e.lib)?e.lib:[e.lib]:[],u=await r(l,{client:e.client!==!1,server:e.server!==!1,templates:e.templates!==!1,extraLibs:a});if(u.failure)console.error(`
130
130
  Type-check did not run.
@@ -136,7 +136,7 @@ ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.chec
136
136
  ${o(u.diagnostics)}
137
137
  `);if(console.log(` Checked ${u.blockCount} script block(s) and ${u.expressionCount} template expression(s) in ${u.checkedFiles.length} file(s) \u2014 `+`${p.length} error(s), ${u.diagnostics.length-p.length} warning(s)
138
138
  `),p.length>0)n.exit(1)}),y.command("codemod [patterns...]","Find hand-rolled code that an stx primitive already covers").option("--fix","Write the safe rewrites (default is report-only)").option("--rule <rule>","Run one rule only: confirm | tooltip (rewritable) \xB7 alert | route-params | search-params | navigate | "+"fetch | polling | debounce | click-outside | focus | clipboard | watch (report-only)").example("stx codemod").example("stx codemod --rule route-params").example('stx codemod --fix "resources/views/**/*.stx"').action(async(t,e)=>{let{codemodSource:o,formatCodemodFindings:r}=await import("./chunk-v1z6n7wz.js"),s=globalThis.Bun.Glob,c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx","**/*.ts"],l=e.rule?[e.rule]:void 0;if(e.rule&&e.rule!=="confirm"&&e.rule!=="tooltip")console.error(`Unknown rule "${e.rule}". Expected: confirm | tooltip`),n.exit(1);let d=new Set,a=[],u=0,p=new Set;try{let b=Bun.spawnSync(["git","ls-files","--others","--ignored","--exclude-standard","-z"],{cwd:n.cwd(),stdout:"pipe",stderr:"pipe"});for(let w of new TextDecoder().decode(b.stdout).split("\x00"))if(w)p.add(f.resolve(n.cwd(),w))}catch{}for(let b of i)for await(let w of new s(b).scan({cwd:n.cwd(),absolute:!0})){if(w.includes("/node_modules/")||w.includes("/dist/")||d.has(w)||p.has(w))continue;d.add(w);let k=await Bun.file(w).text(),v=o(k,{file:w,rules:l});if(a.push(...v.findings),e.fix&&v.code!==k)await Bun.write(w,v.code),u++}if(console.error(r(a,Boolean(e.fix))),e.fix)console.error(`
139
- ${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime resolution + staleness chain").option("--json","Output the report as JSON").example("stx doctor").example("stx doctor --json").action(async(t)=>{try{let e;try{let r=await import("./chunk-p3qx6bhx.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await oo({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(io(o));if(!o.ok)n.exit(1)}catch(e){console.error("Error running doctor:",e),n.exit(1)}}),y.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(t,e)=>{try{let o=A(t);if(!o.isValid)F(o);console.log(`\uD83D\uDD0D Debugging stx template: ${t}
139
+ ${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime resolution + staleness chain").option("--json","Output the report as JSON").example("stx doctor").example("stx doctor --json").action(async(t)=>{try{let e;try{let r=await import("./chunk-ad2fk303.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await oo({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(io(o));if(!o.ok)n.exit(1)}catch(e){console.error("Error running doctor:",e),n.exit(1)}}),y.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(t,e)=>{try{let o=A(t);if(!o.isValid)F(o);console.log(`\uD83D\uDD0D Debugging stx template: ${t}
140
140
  `);let r={};if(e.context)try{r=JSON.parse(e.context)}catch(i){console.error("\u274C Invalid JSON in --context option"),n.exit(1)}let s=await Bun.file(t).text();console.log(`\uD83D\uDCC4 Template Content (${s.length} chars):`),console.log("\u2500".repeat(50)),console.log(s.substring(0,500)+(s.length>500?`
141
141
  ...
142
142
  `:"")),console.log("\u2500".repeat(50));let c=s.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(c)console.log(`
@@ -160,11 +160,11 @@ Press Ctrl+C to stop watching...
160
160
  \uD83D\uDCC4 Files with issues:`),d.forEach((a)=>{let u=a.issues.filter((p)=>s[p.type]>=c).length;if(u>0)console.log(` ${f.relative(n.cwd(),a.file)} (${u} issues)`)});if(e.saveReport){let a={summary:l,results:d,generatedAt:new Date().toISOString(),commandOptions:e};await Bun.write(e.saveReport,JSON.stringify(a,null,2)),console.log(`
161
161
  \uD83D\uDCCB Analysis report saved to: ${e.saveReport}`)}console.log(`
162
162
  \u2728 Analysis complete! Use --detailed for more information.`)}catch(o){console.error("Error analyzing templates:",o),n.exit(1)}}),y.command("screenshot [input]","Capture PNG screenshot(s) of page(s) via Bun WebView \u2014 a file, URL, or dist directory").option("--out <dir>","Output directory",{default:"screenshots"}).option("--width <px>","Viewport width",{default:"1440"}).option("--height <px>","Viewport height",{default:"2200"}).option("--wait <ms>","Settle time after navigation before capture",{default:"800"}).option("--timeout <ms>","Hard cap on waiting for navigation",{default:"15000"}).option("--full-page","Capture the entire scrollable page, not just the viewport").option("--wait-selector <sel>","Wait until a CSS selector exists before capturing").option("--format <fmt>","Image format: png | jpeg | webp",{default:"png"}).option("--backend <name>","WebView backend: webkit (macOS, default) | chrome").action(async(t,e)=>{let{captureScreenshots:o}=await import("./chunk-kvmpc0sg.js"),r=t||"dist";try{let s=await o(r,e.out,{width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),waitMs:Number.parseInt(e.wait,10),timeoutMs:Number.parseInt(e.timeout,10),fullPage:Boolean(e.fullPage),waitSelector:e.waitSelector,format:e.format,backend:e.backend});for(let c of s)console.log(`\uD83D\uDCF8 ${c.output} (${(c.bytes/1024).toFixed(0)} KB)`);console.log(`
163
- \u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(Pe)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-cjwghh53.js"),o={};if(t.context){let r=f.resolve(t.context);if(S.existsSync(r))try{let s=S.readFileSync(r,"utf-8");o=JSON.parse(s)}catch(s){console.error("Error loading context file:",s),n.exit(1)}else console.error(`Context file not found: ${r}`),n.exit(1)}await e({context:o,cwd:t.cwd?f.resolve(t.cwd):n.cwd(),verbose:t.verbose})}),y.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(t,e)=>{try{let{buildNative:o,getAvailableTargets:r,getAvailableFormats:s}=await import("./chunk-1nr15t1f.js"),c=f.resolve(t);if(!S.existsSync(c))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let i=r();if(e.target&&!["macos","windows","linux","ios","android"].includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${i.join(", ")}`),n.exit(1);let l=e.target||i[0],d=s(l);if(e.format&&!d.includes(e.format))console.error(`\u274C Invalid format for ${l}: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${d.join(", ")}`),n.exit(1);console.log(`
163
+ \u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(Pe)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-0a9ceqa8.js"),o={};if(t.context){let r=f.resolve(t.context);if(S.existsSync(r))try{let s=S.readFileSync(r,"utf-8");o=JSON.parse(s)}catch(s){console.error("Error loading context file:",s),n.exit(1)}else console.error(`Context file not found: ${r}`),n.exit(1)}await e({context:o,cwd:t.cwd?f.resolve(t.cwd):n.cwd(),verbose:t.verbose})}),y.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(t,e)=>{try{let{buildNative:o,getAvailableTargets:r,getAvailableFormats:s}=await import("./chunk-fc384a2h.js"),c=f.resolve(t);if(!S.existsSync(c))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let i=r();if(e.target&&!["macos","windows","linux","ios","android"].includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${i.join(", ")}`),n.exit(1);let l=e.target||i[0],d=s(l);if(e.format&&!d.includes(e.format))console.error(`\u274C Invalid format for ${l}: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${d.join(", ")}`),n.exit(1);console.log(`
164
164
  \uD83D\uDD28 Building native app...`),console.log(` Input: ${t}`),console.log(` Target: ${l}`),console.log(` Format: ${e.format||"default"}`),console.log(` Output: ${e.output}
165
165
  `);let a=await o({input:c,output:f.resolve(e.output),target:l,format:e.format,name:e.name,version:e.version,description:e.description,author:e.author,bundleId:e.bundleId,icon:e.icon?f.resolve(e.icon):void 0,window:{title:e.title,width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),frameless:e.frameless,alwaysOnTop:e.alwaysOnTop},systemTray:e.systemTray,menubarOnly:e.menubarOnly,category:e.category,copyright:e.copyright,minimumSystemVersion:e.minSystemVersion,infoPlist:M(e.infoPlist),devTools:e.devTools,craftPath:e.craftPath,verbose:e.verbose});if(a.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${a.outputPath}`),a.duration)console.log(` Duration: ${(a.duration/1000).toFixed(2)}s`);if(l==="macos"&&a.format==="app")console.log(`
166
166
  \uD83D\uDCA1 To run: open "${a.outputPath}"`);else if(l==="linux"&&a.format==="appimage")console.log(`
167
- \uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-mafav2b3.js");await e({port:t.port?Number.parseInt(t.port,10):6006,open:t.open,host:t.host})}catch(e){console.error(`\u274C Story error: ${e.message}`),n.exit(1)}}),y.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(t)=>{try{let{buildCommand:e}=await import("./chunk-fpn4dren.js");await e({outDir:t.outDir})}catch(e){console.error(`\u274C Story build error: ${e.message}`),n.exit(1)}}),y.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(t)=>{try{let{createContext:e}=await import("./chunk-cgamtmxv.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-xfnj17kd.js"),c=await e({mode:"build"});if(t.update){let i=await r(c,{filter:t.filter?[t.filter]:void 0});console.log(`Updated ${i} snapshots`)}else{let i=await o(c,{filter:t.filter?[t.filter]:void 0});if(console.log(s(i)),i.failed>0)n.exit(1)}}catch(e){console.error(`\u274C Story test error: ${e.message}`),n.exit(1)}}),y.command("native <action> [file]","Compile .stx screens into the JavaScriptCore bundle Craft renders natively").option("--format <format>","bundle (the JavaScriptCore bundle) or ir (the template as JSON)",{default:"ir"}).option("--output <path>","Write to this file instead of stdout").option("--minify","Minify the bundle",{default:!1}).option("--config <file>","Screens config (default: native.config.json in the working directory)").example("stx native compile Screen.stx --format bundle --output native-screen.js").example("stx native compile --format bundle --output native-screen.js --minify").example("stx native compile Screen.stx").action(async(t,e,o)=>{if(t!=="compile")console.error(`Unknown native command: ${t}`),console.error("Usage: stx native compile [file.stx] --format bundle|ir [--output <file>] [--minify] [--config <file>]"),n.exit(1);try{let{runNativeCompile:r}=await import("./chunk-513b47g2.js"),s=await r(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(r){console.error(r instanceof Error?r.message:String(r)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-fkkdt6sj.js"),r=f.resolve(t);if(!S.existsSync(r))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
167
+ \uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-c2qwbej3.js");await e({port:t.port?Number.parseInt(t.port,10):6006,open:t.open,host:t.host})}catch(e){console.error(`\u274C Story error: ${e.message}`),n.exit(1)}}),y.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(t)=>{try{let{buildCommand:e}=await import("./chunk-fpn4dren.js");await e({outDir:t.outDir})}catch(e){console.error(`\u274C Story build error: ${e.message}`),n.exit(1)}}),y.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(t)=>{try{let{createContext:e}=await import("./chunk-cgamtmxv.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-44ep7dkr.js"),c=await e({mode:"build"});if(t.update){let i=await r(c,{filter:t.filter?[t.filter]:void 0});console.log(`Updated ${i} snapshots`)}else{let i=await o(c,{filter:t.filter?[t.filter]:void 0});if(console.log(s(i)),i.failed>0)n.exit(1)}}catch(e){console.error(`\u274C Story test error: ${e.message}`),n.exit(1)}}),y.command("native <action> [file]","Compile .stx screens into the JavaScriptCore bundle Craft renders natively").option("--format <format>","bundle (the JavaScriptCore bundle) or ir (the template as JSON)",{default:"ir"}).option("--output <path>","Write to this file instead of stdout").option("--minify","Minify the bundle",{default:!1}).option("--config <file>","Screens config (default: native.config.json in the working directory)").example("stx native compile Screen.stx --format bundle --output native-screen.js").example("stx native compile --format bundle --output native-screen.js --minify").example("stx native compile Screen.stx").action(async(t,e,o)=>{if(t!=="compile")console.error(`Unknown native command: ${t}`),console.error("Usage: stx native compile [file.stx] --format bundle|ir [--output <file>] [--minify] [--config <file>]"),n.exit(1);try{let{runNativeCompile:r}=await import("./chunk-dyp0kgmr.js"),s=await r(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(r){console.error(r instanceof Error?r.message:String(r)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-fkkdt6sj.js"),r=f.resolve(t);if(!S.existsSync(r))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
168
168
  \uD83D\uDD27 Compiling stx template to native code...`),console.log(` Input: ${t}`),console.log(` Target: ${e.target}`),console.log(` Format: ${e.format}`),console.log(` Output: ${e.output}
169
169
  `);let i=S.readFileSync(r,"utf-8"),l=await o(i,{target:e.target,format:e.format,optimize:e.optimize,treeShake:e.treeShake,hotReload:e.hotReload,debug:e.verbose,sourceMaps:e.sourcemaps,bundle:e.bundle,minify:e.minify}),d=f.resolve(e.output);if(!S.existsSync(d))S.mkdirSync(d,{recursive:!0});let a=f.basename(t,f.extname(t)),u=e.format==="typescript"?"ts":e.format==="json"?"json":"zig",p=f.join(d,`${a}.${u}`);S.writeFileSync(p,l.code);let b=f.join(d,`${a}.manifest.json`);if(S.writeFileSync(b,JSON.stringify(l.manifest,null,2)),e.sourcemaps&&l.sourceMaps){let w=f.join(d,`${a}.${u}.map`);S.writeFileSync(w,l.sourceMaps)}if(e.target==="universal"&&l.platformCode.size>0)for(let[w,k]of l.platformCode){let v=f.join(d,`${a}.${w}.${u}`);S.writeFileSync(v,k)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${p}`),console.log(` Manifest: ${b}`),console.log(`
170
170
  \uD83D\uDCCA Statistics:`),console.log(` Compilation time: ${l.stats.compilationTime.toFixed(2)}ms`),console.log(` Total components: ${l.stats.totalComponents}`),console.log(` Native components: ${l.stats.nativeComponents}`),console.log(` Web fallback components: ${l.stats.webComponents}`),console.log(` Bundle size: ${(l.stats.bundleSize/1024).toFixed(2)}KB`),l.stats.warnings.length>0){console.log(`
@@ -168,7 +168,9 @@ export const SIGNALS_COMPONENT_HYDRATION_RUNTIME = ` /*
168
168
  return;
169
169
  }
170
170
  scopeVars.__el = root;
171
- var childScope = mergeTemplateScopes(resolvedCallerScope, scopeVars);
171
+ // Layered: copying the caller's scope (a view over the page's hundreds
172
+ // of names) into every instance read each of them through the view.
173
+ var childScope = layerTemplateScopes(resolvedCallerScope, scopeVars);
172
174
  root.__stx_disposers = trackEffects(function() {
173
175
  processElement(root, childScope);
174
176
  });
@@ -16,7 +16,7 @@ export const SIGNALS_COMPONENT_PROPS_RUNTIME = ` function bindParentComponentPr
16
16
  }).filter(Boolean);
17
17
  if (!bindings.length) return;
18
18
  el.__stx_parent_props_bound = true;
19
- var scope = mergeTemplateScopes(globalHelpers, callerScope);
19
+ var scope = layerTemplateScopes(globalHelpers, callerScope);
20
20
 
21
21
  bindings.forEach(function(binding) {
22
22
  var name = binding.name;
@@ -49,8 +49,11 @@ export const SIGNALS_EXPRESSION_COMPILER_RUNTIME = ` // Compiled expression fun
49
49
  function __stxCompileScoped(scope, extraParams, body) {
50
50
  const keys = [];
51
51
  const names = __stxNamesIn(body);
52
+ // A layered view answers from its layers directly: through the proxy,
53
+ // each name cost a trap and a fresh property descriptor.
54
+ const own = __stxOwnOf.get(scope);
52
55
  for (let i = 0; i < names.length; i++) {
53
- if (Object.prototype.propertyIsEnumerable.call(scope, names[i])) keys.push(names[i]);
56
+ if (own !== undefined ? __stxLayerOf(own, names[i]) !== null : Object.prototype.propertyIsEnumerable.call(scope, names[i])) keys.push(names[i]);
54
57
  }
55
58
  const fn = __stxCompile(extraParams.length ? keys.concat(extraParams) : keys, body);
56
59
  // The cache keys on the parameter list, so a function always has these keys.
@@ -126,8 +126,10 @@ export const SIGNALS_EXPRESSION_RUNTIME = ` // Setup accessors refer to lexical
126
126
  }
127
127
  else layers.push(source);
128
128
  }
129
+ // A symbol key, so it is never one of the view's names; assigned rather
130
+ // than defined, which an interpreter makes a far slower path.
129
131
  const own = {};
130
- Object.defineProperty(own, __STX_LAYERS, { value: layers, configurable: true });
132
+ own[__STX_LAYERS] = layers;
131
133
  const view = new Proxy(own, __stxScopeHandler);
132
134
  __stxOwnOf.set(view, own);
133
135
  return view;
@@ -4,7 +4,15 @@ export const SIGNALS_PIPE_RUNTIME = ` // ======================================
4
4
 
5
5
  // Parse and execute pipe expressions like "value | fmt" or "value | truncate:20"
6
6
  // Must distinguish single | (pipe) from || (logical OR) and ?? (nullish coalescing)
7
+ // Where an expression's top-level pipe is, by its text: every binding
8
+ // evaluation asked, and the answer was a character-by-character scan, which
9
+ // an interpreted engine paid for on each evaluation of each binding.
10
+ const __stxPipeIndex = new Map();
7
11
  function parsePipeExpression(expr, scope) {
12
+ // No bar at all, no pipe: the case nearly every expression is.
13
+ if (expr.indexOf('|') === -1) return null;
14
+ const known = __stxPipeIndex.get(expr);
15
+ if (known === -1) return null;
8
16
  // Find pipe operators: single | that's not part of || or preceded by ?
9
17
  // We need to find | that is:
10
18
  // 1. Not preceded by | or ?
@@ -59,6 +67,8 @@ else if (char === stringChar) {
59
67
  }
60
68
  }
61
69
 
70
+ if (__stxPipeIndex.size >= 5000) __stxPipeIndex.clear();
71
+ __stxPipeIndex.set(expr, pipeIndex);
62
72
  if (pipeIndex === -1) return null;
63
73
 
64
74
  const valueExpr = expr.slice(0, pipeIndex).trim();
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{vo,ya,ba}from"./chunk-es006emk.js";import"./chunk-3gn1t0pa.js";import"./chunk-94gyfwpz.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import"./chunk-a8sb2jwq.js";import"./chunk-27rzdq3n.js";import"./chunk-sqq3hqpb.js";import"./chunk-h0jnatd4.js";import"./chunk-q14d714d.js";import"./chunk-8vq5w11w.js";import"./chunk-w9nwb8r3.js";import"./chunk-605b93pe.js";import"./chunk-98bxcss9.js";import"./chunk-efpsvjp9.js";import"./chunk-njse2cjy.js";import"./chunk-m58ga249.js";import"./chunk-e4x4q5rf.js";import"./chunk-a3v7jkp6.js";import"./chunk-khjcp7jn.js";import"./chunk-2gqhfge6.js";import"./chunk-c0ejyxfj.js";import{pu,wa,gh,mh,va,xo,Zr,xa,Sa,hh,yh,ka,_a,Ca,Ea}from"./chunk-kpreycjr.js";import"./chunk-axfz9jcz.js";import"./chunk-5c89afzb.js";import"./chunk-qv85c3qy.js";import"./chunk-q5jxnqfr.js";import"./chunk-w5hhqjwr.js";import"./chunk-8ft5vgp3.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{vo,ya,ba}from"./chunk-es006emk.js";import"./chunk-3gn1t0pa.js";import"./chunk-94gyfwpz.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import"./chunk-4cffjp4f.js";import"./chunk-27rzdq3n.js";import"./chunk-syheccfj.js";import"./chunk-h0jnatd4.js";import"./chunk-q14d714d.js";import"./chunk-j4s5k8sp.js";import"./chunk-w9nwb8r3.js";import"./chunk-605b93pe.js";import"./chunk-276e3d0g.js";import"./chunk-bb2zfgwf.js";import"./chunk-g89fx9rq.js";import"./chunk-6h7yhyb8.js";import"./chunk-6jzqzap6.js";import"./chunk-56yhvhjq.js";import"./chunk-a4cse2tj.js";import"./chunk-2gqhfge6.js";import"./chunk-c0ejyxfj.js";import{pu,wa,gh,mh,va,xo,Zr,xa,Sa,hh,yh,ka,_a,Ca,Ea}from"./chunk-hs9fzxn0.js";import"./chunk-4de6rhaj.js";import"./chunk-k3mcb700.js";import"./chunk-qv85c3qy.js";import"./chunk-6jx0trea.js";import"./chunk-w5hhqjwr.js";import"./chunk-m997knnz.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
package/dist/craft.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{vo,ya,ba}from"./chunk-es006emk.js";import"./chunk-3gn1t0pa.js";import"./chunk-94gyfwpz.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import"./chunk-a8sb2jwq.js";import"./chunk-27rzdq3n.js";import"./chunk-sqq3hqpb.js";import"./chunk-h0jnatd4.js";import"./chunk-q14d714d.js";import"./chunk-8vq5w11w.js";import"./chunk-w9nwb8r3.js";import"./chunk-605b93pe.js";import"./chunk-98bxcss9.js";import"./chunk-efpsvjp9.js";import"./chunk-njse2cjy.js";import"./chunk-m58ga249.js";import"./chunk-e4x4q5rf.js";import"./chunk-a3v7jkp6.js";import"./chunk-khjcp7jn.js";import"./chunk-2gqhfge6.js";import"./chunk-c0ejyxfj.js";import{pu,wa,gh,mh,va,xo,Zr,xa,Sa,hh,yh,ka,_a,Ca,Ea}from"./chunk-kpreycjr.js";import"./chunk-axfz9jcz.js";import"./chunk-5c89afzb.js";import"./chunk-qv85c3qy.js";import"./chunk-q5jxnqfr.js";import"./chunk-w5hhqjwr.js";import"./chunk-8ft5vgp3.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{vo,ya,ba}from"./chunk-es006emk.js";import"./chunk-3gn1t0pa.js";import"./chunk-94gyfwpz.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import"./chunk-4cffjp4f.js";import"./chunk-27rzdq3n.js";import"./chunk-syheccfj.js";import"./chunk-h0jnatd4.js";import"./chunk-q14d714d.js";import"./chunk-j4s5k8sp.js";import"./chunk-w9nwb8r3.js";import"./chunk-605b93pe.js";import"./chunk-276e3d0g.js";import"./chunk-bb2zfgwf.js";import"./chunk-g89fx9rq.js";import"./chunk-6h7yhyb8.js";import"./chunk-6jzqzap6.js";import"./chunk-56yhvhjq.js";import"./chunk-a4cse2tj.js";import"./chunk-2gqhfge6.js";import"./chunk-c0ejyxfj.js";import{pu,wa,gh,mh,va,xo,Zr,xa,Sa,hh,yh,ka,_a,Ca,Ea}from"./chunk-hs9fzxn0.js";import"./chunk-4de6rhaj.js";import"./chunk-k3mcb700.js";import"./chunk-qv85c3qy.js";import"./chunk-6jx0trea.js";import"./chunk-w5hhqjwr.js";import"./chunk-m997knnz.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
@@ -0,0 +1,24 @@
1
+ import type { ClassStyles } from './headwind-to-style';
2
+ import type { NativeStylesheetRules } from './stylesheet-rules';
3
+ import type { NativeStyleVariables } from './style-variables';
4
+ import type { STXNode } from './ir';
5
+ export declare function buildClassTable(root: STXNode): NativeClassTable | undefined;
6
+ /** Seed the class cache from a shipped table: the plain lists, and `scheme`'s against `variables`. */
7
+ export declare function seedClassTable(table: NativeClassTable, scheme: 'light' | 'dark', variables: NativeStyleVariables, rules: NativeStylesheetRules | undefined, plain?: boolean): void;
8
+ /**
9
+ * The screen's class lists, compiled by the build and shipped with it.
10
+ *
11
+ * A native screen compiled every class list it used as it mounted: in an
12
+ * interpreted engine that was about a tenth of the browser's start, for lists
13
+ * the build had already read. The table holds each static list as each runtime
14
+ * caller asks for it (as `adopt` reads it, and against the screen's theme in
15
+ * each appearance, with and without a pointer), deduplicated, and the runtime
16
+ * seeds its cache from it. A list the build could not see (a `:class` value,
17
+ * classes forwarded from a caller) is still compiled when it appears.
18
+ */
19
+ export declare interface NativeClassTable {
20
+ entries: ClassStyles[]
21
+ plain: Record<string, number>
22
+ light: Record<string, number>
23
+ dark: Record<string, number>
24
+ }
@@ -0,0 +1,46 @@
1
+ import { classStyleKey, compileClassStyles, seedClassStyles } from "./headwind-to-style.js";
2
+ import { createStyleVariables } from "./style-variables.js";
3
+ export function buildClassTable(root) {
4
+ const lists = new Map, visit = (node) => {
5
+ if (typeof node === "string")
6
+ return;
7
+ if (node._classes)
8
+ lists.set(node._classes, lists.get(node._classes) === !0 || node.type === "TextInput");
9
+ for (const child of node.children)
10
+ visit(child);
11
+ };
12
+ visit(root);
13
+ if (!lists.size)
14
+ return;
15
+ const entries = [], indexOf = new Map, store = (compiled) => {
16
+ const text = JSON.stringify(compiled);
17
+ let index = indexOf.get(text);
18
+ if (index === void 0) {
19
+ index = entries.push(compiled) - 1;
20
+ indexOf.set(text, index);
21
+ }
22
+ return index;
23
+ }, table = { entries, plain: {}, light: {}, dark: {} };
24
+ for (const list of lists.keys())
25
+ table.plain[classStyleKey(list)] = store(compileClassStyles(list));
26
+ const rules = root._stylesheetRules;
27
+ for (const scheme of ["light", "dark"]) {
28
+ const variables = createStyleVariables(root._stylesheetTheme?.[scheme] ?? []).computed();
29
+ for (const [list, focus] of lists) {
30
+ const classes = `${list} `;
31
+ for (const options of [
32
+ { focus, focusWithin: !0, appearance: scheme, pointer: !1 },
33
+ { focus, focusWithin: !0, appearance: scheme, pointer: !0 },
34
+ { focus, focusWithin: !0 }
35
+ ])
36
+ table[scheme][classStyleKey(classes, options)] = store(compileClassStyles(classes, variables, { ...options, rules }));
37
+ }
38
+ }
39
+ return table;
40
+ }
41
+ export function seedClassTable(table, scheme, variables, rules, plain = !0) {
42
+ const pick = (keys) => Object.entries(keys).map(([key, index]) => [key, table.entries[index]]);
43
+ if (plain)
44
+ seedClassStyles(void 0, void 0, pick(table.plain));
45
+ seedClassStyles(variables, rules, pick(table[scheme]));
46
+ }
@@ -7,6 +7,10 @@ import type { STXStyle } from './ir';
7
7
  * neither host parses, so an app's role answers resolve here for a phone.
8
8
  */
9
9
  export declare function nativePaletteColor(reference: string): string | undefined;
10
+ /** How a class list and its flags are remembered: the build's class table uses the same keys. */
11
+ export declare function classStyleKey(classes: string, options?: Omit<ClassStyleOptions, 'rules'>): string;
12
+ /** Remember class lists compiled elsewhere (the build's class table) as if they had been compiled here. */
13
+ export declare function seedClassStyles(variables: NativeStyleVariables | undefined, rules: NativeStylesheetRules | undefined, entries: Iterable<[string, ClassStyles]>): void;
10
14
  /**
11
15
  * The style a class list gives, with its dark, focus, pointer, width and state
12
16
  * layers. Remembered: callers must treat the result as read-only.
@@ -1,6 +1,6 @@
1
1
  import { DENSITY_FONT_SIZES, DENSITY_SPACING, SEMANTIC_TOKENS, SHAPE_TOKENS, tokenVariable } from "../../theme-tokens.js";
2
2
  import { nativeDensitySpacing, nativeDensityType, nativeShapeRadius } from "./design-tokens.js";
3
- import { nativeBreakpoint, nativeShortcut, nativeThemeColor, nativeThemeFont } from "./style-config.js";
3
+ import { activeNativeStyleConfig, nativeBreakpoint, nativeShortcut, nativeThemeColor, nativeThemeFont } from "./style-config.js";
4
4
  import { parseNativeStyle } from "./inline-style.js";
5
5
  const colors = {
6
6
  transparent: "transparent",
@@ -1340,14 +1340,30 @@ function transitionMilliseconds(utility) {
1340
1340
  return duration ? Number(duration[1]) : void 0;
1341
1341
  }
1342
1342
  const classStyleCache = new WeakMap, NONE = {};
1343
- export function compileClassStyles(classes, variables, options = {}) {
1344
- let byRules = classStyleCache.get(variables ?? NONE);
1343
+ function classStylesFor(variables, rules) {
1344
+ const config = activeNativeStyleConfig();
1345
+ let byVariables = classStyleCache.get(config);
1346
+ if (!byVariables)
1347
+ classStyleCache.set(config, byVariables = new WeakMap);
1348
+ let byRules = byVariables.get(variables ?? NONE);
1345
1349
  if (!byRules)
1346
- classStyleCache.set(variables ?? NONE, byRules = new WeakMap);
1347
- let byClasses = byRules.get(options.rules ?? NONE);
1350
+ byVariables.set(variables ?? NONE, byRules = new WeakMap);
1351
+ let byClasses = byRules.get(rules ?? NONE);
1348
1352
  if (!byClasses)
1349
- byRules.set(options.rules ?? NONE, byClasses = new Map);
1350
- const key = `${options.focus ? 1 : 0}${options.focusWithin ? 1 : 0}${options.pointer ? 1 : 0}${options.appearance ?? ""}|${classes}`;
1353
+ byRules.set(rules ?? NONE, byClasses = new Map);
1354
+ return byClasses;
1355
+ }
1356
+ export function classStyleKey(classes, options = {}) {
1357
+ return `${options.focus ? 1 : 0}${options.focusWithin ? 1 : 0}${options.pointer ? 1 : 0}${options.appearance ?? ""}|${classes}`;
1358
+ }
1359
+ export function seedClassStyles(variables, rules, entries) {
1360
+ const byClasses = classStylesFor(variables, rules);
1361
+ for (const [key, compiled] of entries)
1362
+ if (!byClasses.has(key))
1363
+ byClasses.set(key, compiled);
1364
+ }
1365
+ export function compileClassStyles(classes, variables, options = {}) {
1366
+ const byClasses = classStylesFor(variables, options.rules), key = classStyleKey(classes, options);
1351
1367
  let compiled = byClasses.get(key);
1352
1368
  if (!compiled) {
1353
1369
  if (byClasses.size >= 4096)
@@ -8,7 +8,6 @@ import type { STXStyle } from './ir';
8
8
  */
9
9
  export declare function applyNativeLayoutDefaults(style: STXStyle): STXStyle;
10
10
  export declare function parseNativeStyle(input: unknown, report?: (diagnostic: NativeStyleDiagnostic) => void, context?: NativeStyleContext): STXStyle;
11
- /** Resolve all same-element variable declarations before evaluating any style layer. */
12
11
  export declare function parseNativeStyleLayers(inputs: unknown[], inheritedVariables: NativeStyleVariables | undefined, report: (diagnostic: NativeStyleDiagnostic) => void): { variables: NativeStyleVariables, styles: STXStyle[] };
13
12
  export declare interface NativeStyleContext {
14
13
  inheritedVariables?: NativeStyleVariables
@@ -245,8 +245,12 @@ export function parseNativeStyle(input, report = () => {}, context = {}) {
245
245
  context.onVariables?.(variables.computed());
246
246
  return parseEntries(entries, variables, report);
247
247
  }
248
+ const NO_STYLE_VARIABLES = new Map;
248
249
  export function parseNativeStyleLayers(inputs, inheritedVariables, report) {
249
- const layers = inputs.map((input) => styleEntries(input, report)), variables = createStyleVariables(layers.flat(), inheritedVariables);
250
+ const layers = inputs.map((input) => styleEntries(input, report));
251
+ if (layers.every((entries) => entries.length === 0))
252
+ return { variables: inheritedVariables ?? NO_STYLE_VARIABLES, styles: layers.map(() => ({})) };
253
+ const variables = createStyleVariables(layers.flat(), inheritedVariables);
250
254
  return { variables: variables.computed(), styles: layers.map((entries) => parseEntries(entries, variables, report)) };
251
255
  }
252
256
  function parseEntries(entries, variables, report) {
@@ -1,3 +1,4 @@
1
+ import type { NativeClassTable } from './class-table';
1
2
  import type { NativeStylesheetRules } from './stylesheet-rules';
2
3
  import type { NativeStylesheetTheme } from './stylesheet-theme';
3
4
  // ============================================================================
@@ -25,6 +26,7 @@ export declare interface STXNode {
25
26
  _styleAncestors?: string[]
26
27
  _stylesheetTheme?: NativeStylesheetTheme
27
28
  _stylesheetRules?: NativeStylesheetRules
29
+ _classTable?: NativeClassTable
28
30
  _classes?: string
29
31
  _templated?: string[]
30
32
  _source?: {
@@ -3,6 +3,7 @@ import path from "node:path";
3
3
  import { loadStxConfig } from "../../config.js";
4
4
  import { classifyAttribute, extractBindingManifest } from "../../binding-manifest.js";
5
5
  import { processDirectives } from "../../process.js";
6
+ import { buildClassTable } from "./class-table.js";
6
7
  import { processScriptSetup } from "../../signal-processing.js";
7
8
  import { appThemeCSS } from "./app-theme.js";
8
9
  import { excludeNativeSubtrees, translateHtmlToDocument } from "./html-to-ir.js";
@@ -35,6 +36,9 @@ export async function compileScreenSource(source, filePath, options = {}) {
35
36
  });
36
37
  diagnostics.unshift(...chromeDiagnostics);
37
38
  enterTemplatedBindings(document.root, manifest);
39
+ const classTable = buildClassTable(document.root);
40
+ if (classTable)
41
+ document.root._classTable = classTable;
38
42
  const head = context.__stx_runtime_head;
39
43
  if (typeof head?.title === "string" && head.title.trim())
40
44
  document.title = head.title.trim();
@@ -1,3 +1,5 @@
1
+ /** The resolved config in force, by identity: what a cache of compiled classes is valid for. */
2
+ export declare function activeNativeStyleConfig(): object;
1
3
  /** Use `config` for every native class resolution from now on. */
2
4
  export declare function setNativeStyleConfig(config: NativeStyleConfig | null | undefined): void;
3
5
  /** Run `work` with `config` in force, then put back what was there (a compile's config is its own). */
@@ -38,6 +38,9 @@ function resolve(config) {
38
38
  };
39
39
  }
40
40
  let currentSource = {};
41
+ export function activeNativeStyleConfig() {
42
+ return active();
43
+ }
41
44
  export function setNativeStyleConfig(config) {
42
45
  currentSource = config ?? {};
43
46
  current = resolve(currentSource);