@stacksjs/stx 0.2.855 → 0.2.857

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 (154) hide show
  1. package/dist/{chunk-6w3gv9d6.js → chunk-03t7tk2k.js} +1 -1
  2. package/dist/{chunk-jn6mdfrs.js → chunk-08a7j82a.js} +1 -1
  3. package/dist/{chunk-5ppe8d51.js → chunk-08vwk3x7.js} +1 -1
  4. package/dist/{chunk-0dmpc70r.js → chunk-0d3z8hwz.js} +14 -14
  5. package/dist/{chunk-k0arm18k.js → chunk-0hrkpb2h.js} +1 -1
  6. package/dist/{chunk-yzvp90yk.js → chunk-0veh8bcn.js} +2 -2
  7. package/dist/{chunk-4cd94cd5.js → chunk-1277d5we.js} +4 -4
  8. package/dist/{chunk-279n7sde.js → chunk-16p1vkn6.js} +3 -3
  9. package/dist/{chunk-zqb294v2.js → chunk-1772ax8e.js} +1 -1
  10. package/dist/chunk-1ffkbwdz.js +2 -0
  11. package/dist/{chunk-xfb7fdeq.js → chunk-1kmzj10y.js} +10 -10
  12. package/dist/{chunk-w032x0zm.js → chunk-1nankvf6.js} +2 -2
  13. package/dist/chunk-1qbagang.js +2 -0
  14. package/dist/{chunk-7tteg9bn.js → chunk-1qvtme01.js} +1 -1
  15. package/dist/{chunk-gn1dmfdv.js → chunk-1xx55d2p.js} +1 -1
  16. package/dist/{chunk-q0ycypnt.js → chunk-1ywqsmy2.js} +1 -1
  17. package/dist/{chunk-9n3584wt.js → chunk-23mccy5y.js} +1 -1
  18. package/dist/{chunk-2j2qzv8g.js → chunk-27zp4q77.js} +2 -2
  19. package/dist/chunk-2a471sw1.js +3 -0
  20. package/dist/{chunk-33ph9zb2.js → chunk-2cy33z00.js} +2 -2
  21. package/dist/chunk-2jrf9m4w.js +2 -0
  22. package/dist/chunk-3jgrrjvx.js +2 -0
  23. package/dist/{chunk-q0jmc3m4.js → chunk-3wabhzf4.js} +8 -8
  24. package/dist/{chunk-68pvvd7v.js → chunk-3zjyhhg4.js} +3 -3
  25. package/dist/{chunk-gxqtbbz0.js → chunk-41md2f3q.js} +3 -3
  26. package/dist/{chunk-ngnvyqk3.js → chunk-432c35hs.js} +2 -2
  27. package/dist/{chunk-a2fngjfx.js → chunk-4h9kkkh7.js} +1 -1
  28. package/dist/{chunk-h1f3dpvq.js → chunk-4tzsze9z.js} +2 -2
  29. package/dist/chunk-655m8g98.js +2 -0
  30. package/dist/chunk-68kspmq4.js +2 -0
  31. package/dist/{chunk-e8zpzt9s.js → chunk-6tpcm12w.js} +1 -1
  32. package/dist/chunk-6x0jm4bv.js +2 -0
  33. package/dist/{chunk-w835crjw.js → chunk-6zj9wsy3.js} +1 -1
  34. package/dist/{chunk-0vg0j7xa.js → chunk-827rt3ew.js} +1 -1
  35. package/dist/{chunk-fzkyk5j4.js → chunk-8hymdzv2.js} +4 -4
  36. package/dist/chunk-8j8fth4b.js +2 -0
  37. package/dist/{chunk-enxnw50k.js → chunk-8ta5b0eb.js} +1 -1
  38. package/dist/{chunk-pwem4sed.js → chunk-914wcp1a.js} +3 -3
  39. package/dist/{chunk-f858fazq.js → chunk-93cgpqva.js} +1 -1
  40. package/dist/{chunk-car6nhfe.js → chunk-9n8t7v78.js} +2 -2
  41. package/dist/chunk-9wf5fx4s.js +2 -0
  42. package/dist/chunk-a4v8z93r.js +2 -0
  43. package/dist/{chunk-463zkecq.js → chunk-a53jtd74.js} +1 -1
  44. package/dist/{chunk-krtkxnz6.js → chunk-admnvsmx.js} +2 -2
  45. package/dist/chunk-b16g785w.js +2 -0
  46. package/dist/{chunk-ctb1bj28.js → chunk-bg574nvy.js} +3 -3
  47. package/dist/{chunk-fbpqkrvb.js → chunk-bq6jy4yk.js} +3 -3
  48. package/dist/{chunk-hgy98n76.js → chunk-cama7kaq.js} +3 -3
  49. package/dist/chunk-ccdp6g5z.js +2 -0
  50. package/dist/chunk-chr56bhk.js +2 -0
  51. package/dist/{chunk-v8p8t3t4.js → chunk-cskmp5p1.js} +1 -1
  52. package/dist/{chunk-77kanny8.js → chunk-cvrkr3re.js} +9 -9
  53. package/dist/{chunk-9r999ees.js → chunk-dhpd4mx7.js} +2 -2
  54. package/dist/{chunk-9hvfmqs1.js → chunk-dnrgcjds.js} +8 -8
  55. package/dist/chunk-dtxg2a6m.js +2 -0
  56. package/dist/{chunk-wzv7k91a.js → chunk-e8we717q.js} +2 -2
  57. package/dist/{chunk-zswtgwxg.js → chunk-eefdz43s.js} +1 -1
  58. package/dist/chunk-ent64fyq.js +2 -0
  59. package/dist/chunk-erfspa7v.js +2 -0
  60. package/dist/chunk-f0kveh4g.js +2 -0
  61. package/dist/{chunk-anva219c.js → chunk-f1vvhbmw.js} +2 -2
  62. package/dist/chunk-f1z6y2ts.js +2 -0
  63. package/dist/chunk-f3msj6jf.js +2 -0
  64. package/dist/chunk-fk7wk568.js +2 -0
  65. package/dist/{chunk-mv48q1p4.js → chunk-fp24ecp8.js} +65 -65
  66. package/dist/{chunk-9z7fnv33.js → chunk-fyp1v087.js} +1 -1
  67. package/dist/{chunk-1qybwj8k.js → chunk-g0h1gxew.js} +11 -11
  68. package/dist/{chunk-kez50h8a.js → chunk-gggethdc.js} +1 -1
  69. package/dist/{chunk-7kc9xwht.js → chunk-gqrypyk7.js} +2 -2
  70. package/dist/chunk-gr19kv83.js +2 -0
  71. package/dist/{chunk-ynd2nfvs.js → chunk-hfng042r.js} +26 -26
  72. package/dist/chunk-hj1yn8w5.js +2 -0
  73. package/dist/{chunk-7hp50cpd.js → chunk-htwn1f36.js} +6 -6
  74. package/dist/chunk-hzrcnxzg.js +2 -0
  75. package/dist/{chunk-vw73gsxx.js → chunk-j2s8j7ff.js} +3 -3
  76. package/dist/chunk-jed9n2hz.js +2 -0
  77. package/dist/{chunk-xn2gyhes.js → chunk-jefafv6s.js} +4 -4
  78. package/dist/chunk-jhm1228j.js +4 -0
  79. package/dist/chunk-js7nmw8v.js +2 -0
  80. package/dist/chunk-k0ert6e7.js +3 -0
  81. package/dist/{chunk-2rxr5cj6.js → chunk-mfwfaggj.js} +9 -9
  82. package/dist/{chunk-hpwtjb4a.js → chunk-mzes9ds7.js} +2 -2
  83. package/dist/chunk-n68sanmz.js +2 -0
  84. package/dist/{chunk-cy60hmv2.js → chunk-npzzbdn1.js} +1 -1
  85. package/dist/chunk-nstcwcpj.js +2 -0
  86. package/dist/{chunk-ybq56wam.js → chunk-pb09xy77.js} +2 -2
  87. package/dist/chunk-q87hkwfg.js +3 -0
  88. package/dist/chunk-qe6631me.js +2 -0
  89. package/dist/{chunk-ma4ftg5p.js → chunk-qvydfw8g.js} +4 -4
  90. package/dist/{chunk-pesgcwrj.js → chunk-qw0ctwnc.js} +3 -3
  91. package/dist/chunk-rrf78ezg.js +2 -0
  92. package/dist/{chunk-4dfz7cdr.js → chunk-sb7zn84j.js} +5 -5
  93. package/dist/{chunk-f9thwm8c.js → chunk-sftyb8k4.js} +8 -8
  94. package/dist/{chunk-zme05d1n.js → chunk-sgnkbgx1.js} +1 -1
  95. package/dist/chunk-shy2hkvj.js +2 -0
  96. package/dist/{chunk-v4bqmzj9.js → chunk-sny8rqe8.js} +2 -2
  97. package/dist/{chunk-csgfws3j.js → chunk-v1eycdhj.js} +2 -2
  98. package/dist/{chunk-eegs2at0.js → chunk-vmrvkbw6.js} +1 -1
  99. package/dist/chunk-vr5h5jpw.js +2 -0
  100. package/dist/{chunk-11y3106w.js → chunk-wdh20fxz.js} +1 -1
  101. package/dist/chunk-wg7xzens.js +2 -0
  102. package/dist/{chunk-te82sjhy.js → chunk-xejhmsfw.js} +7 -7
  103. package/dist/{chunk-4wrddn8m.js → chunk-xfymp197.js} +9 -9
  104. package/dist/{chunk-qxk9grjm.js → chunk-xqr2ec9k.js} +1 -1
  105. package/dist/{chunk-fba71th7.js → chunk-xw12cd90.js} +7 -7
  106. package/dist/{chunk-gsn5vvw4.js → chunk-y5agvhgg.js} +1 -1
  107. package/dist/chunk-zd2c84ct.js +2 -0
  108. package/dist/{chunk-yscys65t.js → chunk-zrsc45wv.js} +1 -1
  109. package/dist/{chunk-mhjxx64x.js → chunk-zx5bt056.js} +24 -24
  110. package/dist/cli.js +17 -17
  111. package/dist/component-client-factories.js +6 -5
  112. package/dist/craft-entry.js +1 -1
  113. package/dist/craft.js +1 -1
  114. package/dist/pwa.js +3 -3
  115. package/dist/ssg.js +8 -8
  116. package/dist/utils.js +3 -2
  117. package/package.json +5 -5
  118. package/dist/chunk-161ksm7f.js +0 -2
  119. package/dist/chunk-1p968nww.js +0 -2
  120. package/dist/chunk-2y20dvab.js +0 -2
  121. package/dist/chunk-33yeb861.js +0 -2
  122. package/dist/chunk-3pm6d9zj.js +0 -2
  123. package/dist/chunk-3wt0nh3p.js +0 -2
  124. package/dist/chunk-5dykcrnv.js +0 -2
  125. package/dist/chunk-5xcxc9f8.js +0 -2
  126. package/dist/chunk-6bm19d4k.js +0 -2
  127. package/dist/chunk-81z64a84.js +0 -2
  128. package/dist/chunk-8gsd2n0j.js +0 -2
  129. package/dist/chunk-8kqqxqyp.js +0 -2
  130. package/dist/chunk-8qe34jb8.js +0 -3
  131. package/dist/chunk-bk0arddt.js +0 -2
  132. package/dist/chunk-c557w9e6.js +0 -2
  133. package/dist/chunk-cfmjtyzm.js +0 -2
  134. package/dist/chunk-ck9zengd.js +0 -2
  135. package/dist/chunk-cwt26rvt.js +0 -3
  136. package/dist/chunk-dbag44ta.js +0 -2
  137. package/dist/chunk-dfcnaaym.js +0 -2
  138. package/dist/chunk-ehp792dy.js +0 -3
  139. package/dist/chunk-ggthncvg.js +0 -2
  140. package/dist/chunk-hfcagm39.js +0 -2
  141. package/dist/chunk-hfe2byfx.js +0 -2
  142. package/dist/chunk-hmys6w75.js +0 -2
  143. package/dist/chunk-hqtj4ngq.js +0 -2
  144. package/dist/chunk-j3s5y2k5.js +0 -2
  145. package/dist/chunk-ns5epsng.js +0 -2
  146. package/dist/chunk-p91288ce.js +0 -2
  147. package/dist/chunk-pw6n7a9k.js +0 -2
  148. package/dist/chunk-qccpfn5x.js +0 -2
  149. package/dist/chunk-vbsr76qe.js +0 -2
  150. package/dist/chunk-vgaqznwt.js +0 -2
  151. package/dist/chunk-w165qe5q.js +0 -2
  152. package/dist/chunk-wz54wsm7.js +0 -2
  153. package/dist/chunk-x4077p94.js +0 -2
  154. package/dist/chunk-z0qfspzg.js +0 -4
package/dist/cli.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{ce}from"./chunk-0dmpc70r.js";import"./chunk-ngnvyqk3.js";import"./chunk-xppm4cs4.js";import{Ie}from"./chunk-mv48q1p4.js";import"./chunk-v4bqmzj9.js";import"./chunk-e8zpzt9s.js";import"./chunk-kvafq9gy.js";import"./chunk-9r999ees.js";import"./chunk-1qybwj8k.js";import"./chunk-vw73gsxx.js";import"./chunk-tm8a2b69.js";import"./chunk-ynd2nfvs.js";import"./chunk-k0arm18k.js";import"./chunk-9hvfmqs1.js";import"./chunk-q0jmc3m4.js";import"./chunk-xfb7fdeq.js";import"./chunk-0vg0j7xa.js";import"./chunk-2rxr5cj6.js";import"./chunk-68pvvd7v.js";import"./chunk-h1f3dpvq.js";import"./chunk-5erremft.js";import"./chunk-q0ycypnt.js";import"./chunk-ma4ftg5p.js";import"./chunk-fba71th7.js";import"./chunk-ya6f7mt5.js";import"./chunk-zme05d1n.js";import"./chunk-f9thwm8c.js";import"./chunk-t3a3wbjk.js";import"./chunk-n77xrpv9.js";import"./chunk-d4gy4yz0.js";import"./chunk-4wrddn8m.js";import"./chunk-279n7sde.js";import"./chunk-t5q31st4.js";import"./chunk-zqb294v2.js";import"./chunk-mpmnbvy4.js";import"./chunk-4cd94cd5.js";import"./chunk-w835crjw.js";import"./chunk-9n3584wt.js";import"./chunk-11y3106w.js";import"./chunk-fphnst8a.js";import"./chunk-63rvsnt2.js";import"./chunk-4nhbbcr9.js";import"./chunk-hpwtjb4a.js";import{rn,sn}from"./chunk-pesgcwrj.js";import"./chunk-pwem4sed.js";import"./chunk-xn2gyhes.js";import"./chunk-bkefg64w.js";import"./chunk-fj5jw2jd.js";import"./chunk-w7p34cr3.js";import"./chunk-jr346anv.js";import"./chunk-r69en2jg.js";import"./chunk-fbpqkrvb.js";import"./chunk-jn6mdfrs.js";import{ea,ta,na,ra,uo,sa,oa,ia,po,fo,Ur,Wr,qr}from"./chunk-mhjxx64x.js";import"./chunk-hgy98n76.js";import"./chunk-qa4vs1qg.js";import"./chunk-yzvp90yk.js";import"./chunk-8qe34jb8.js";import"./chunk-v8p8t3t4.js";import"./chunk-7hp50cpd.js";import"./chunk-zswtgwxg.js";import{Cc}from"./chunk-qxk9grjm.js";import{h}from"./chunk-kgrvvtcy.js";import{spawn as R}from"child_process";import S from"fs";import p 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(f){let m=typeof f==="string"?Number.parseInt(f,10):f;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(f){try{if(!S.existsSync(f)){let x=p.dirname(f),t=p.basename(f);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: ${f}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${f}`,suggestion:"Check the file path and try again"}}if(S.statSync(f).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${f}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${f}`,suggestion:"Check file permissions and path"}}}function I(f){let m=typeof f==="string"?Number.parseInt(f,10):f;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=(f)=>f.includes("*")||f.includes("?")||f.includes("{")||f.includes("["),W=(f)=>f.endsWith(".stx")||f.endsWith(".md");function F(f,m=1){if(console.error(`\u274C ${f.error}`),f.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${f.suggestion}`);n.exit(m)}function M(f){if(!f)return;let m;try{m=JSON.parse(f)}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(f,m){try{let x=["test"],t=[];if(f&&f.length>0)for(let c of f)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=p.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",p.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{le}from"./chunk-0d3z8hwz.js";import"./chunk-432c35hs.js";import"./chunk-xppm4cs4.js";import{Oe}from"./chunk-fp24ecp8.js";import"./chunk-sny8rqe8.js";import"./chunk-6tpcm12w.js";import"./chunk-kvafq9gy.js";import"./chunk-dhpd4mx7.js";import"./chunk-g0h1gxew.js";import"./chunk-j2s8j7ff.js";import"./chunk-tm8a2b69.js";import"./chunk-hfng042r.js";import"./chunk-0hrkpb2h.js";import"./chunk-dnrgcjds.js";import"./chunk-3wabhzf4.js";import"./chunk-1kmzj10y.js";import"./chunk-827rt3ew.js";import"./chunk-mfwfaggj.js";import"./chunk-3zjyhhg4.js";import"./chunk-4tzsze9z.js";import"./chunk-5erremft.js";import"./chunk-1ywqsmy2.js";import"./chunk-qvydfw8g.js";import"./chunk-xw12cd90.js";import"./chunk-ya6f7mt5.js";import"./chunk-sgnkbgx1.js";import"./chunk-sftyb8k4.js";import"./chunk-t3a3wbjk.js";import"./chunk-n77xrpv9.js";import"./chunk-d4gy4yz0.js";import"./chunk-xfymp197.js";import"./chunk-16p1vkn6.js";import"./chunk-t5q31st4.js";import"./chunk-1772ax8e.js";import"./chunk-mpmnbvy4.js";import"./chunk-1277d5we.js";import"./chunk-6zj9wsy3.js";import"./chunk-23mccy5y.js";import"./chunk-wdh20fxz.js";import"./chunk-fphnst8a.js";import"./chunk-63rvsnt2.js";import"./chunk-4nhbbcr9.js";import"./chunk-mzes9ds7.js";import{sn,on}from"./chunk-qw0ctwnc.js";import"./chunk-914wcp1a.js";import"./chunk-jefafv6s.js";import"./chunk-bkefg64w.js";import"./chunk-fj5jw2jd.js";import"./chunk-w7p34cr3.js";import"./chunk-jr346anv.js";import"./chunk-r69en2jg.js";import"./chunk-bq6jy4yk.js";import"./chunk-08a7j82a.js";import{ea,ta,na,ra,uo,sa,oa,ia,po,fo,Ur,Wr,qr}from"./chunk-zx5bt056.js";import"./chunk-cama7kaq.js";import"./chunk-qa4vs1qg.js";import"./chunk-0veh8bcn.js";import"./chunk-2a471sw1.js";import"./chunk-cskmp5p1.js";import"./chunk-htwn1f36.js";import"./chunk-eefdz43s.js";import{Cc}from"./chunk-xqr2ec9k.js";import{h}from"./chunk-kgrvvtcy.js";import{spawn as R}from"child_process";import S from"fs";import p 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(f){let m=typeof f==="string"?Number.parseInt(f,10):f;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(f){try{if(!S.existsSync(f)){let x=p.dirname(f),t=p.basename(f);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: ${f}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${f}`,suggestion:"Check the file path and try again"}}if(S.statSync(f).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${f}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${f}`,suggestion:"Check file permissions and path"}}}function I(f){let m=typeof f==="string"?Number.parseInt(f,10):f;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=(f)=>f.includes("*")||f.includes("?")||f.includes("{")||f.includes("["),W=(f)=>f.endsWith(".stx")||f.endsWith(".md");function F(f,m=1){if(console.error(`\u274C ${f.error}`),f.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${f.suggestion}`);n.exit(m)}function M(f){if(!f)return;let m;try{m=JSON.parse(f)}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(f,m){try{let x=["test"],t=[];if(f&&f.length>0)for(let c of f)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=p.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",p.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 f=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(f))try{let x=await Array.fromAsync(new Bun.Glob(f).scan({onlyFiles:!0,absolute:!0})),t=f.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):f.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=f.split("*")[0].replace(/\/$/,"")||".",o=p.resolve(e);try{let s=new Bun.Glob("**/*.stx"),i=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(p.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: ${f}`),n.exit(1);if(!await Wr(t,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Ur(f,m).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let f=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 ra(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-qkcn0exq.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||p.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-0xwmweqm.js"),{loadConfig:s}=await import("./chunk-hfe2byfx.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-0xwmweqm.js"),{loadConfig:s}=await import("./chunk-655m8g98.js");console.log(`
11
11
  \uD83D\uDD0D Running PWA audit...
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 qr(".",{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 qr(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 ce.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=p.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((g)=>/\[.+\]/.test(p.basename(g)));for(let g of u)if(!s.includes(g))s.push(g)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await Wr(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 Ur(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 Cc(t,{recursive:e.recursive!==!1,ignorePaths:o});if(s.length===0)console.log(`
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 qr(".",{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 qr(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 le.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=p.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((g)=>/\[.+\]/.test(p.basename(g)));for(let g of u)if(!s.includes(g))s.push(g)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await Wr(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 Ur(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 Cc(t,{recursive:e.recursive!==!1,ignorePaths:o});if(s.length===0)console.log(`
13
13
  No .stx files matched ${t}
14
14
  `),n.exit(1);let c=Object.keys(r).length,i=Object.values(r).reduce((l,d)=>l+d.length,0);if(e.json){let l=JSON.stringify(r,null,2);if(e.output)await Bun.write(e.output,l),console.log(`A11y scan results written to ${e.output}`);else console.log(l)}else if(c===0)console.log(`\u2713 No accessibility issues found in ${s.length} file(s)!`);else{console.log(`Found ${i} accessibility issues in ${c} files:
15
15
  `);for(let[l,d]of Object.entries(r)){let a=p.relative(n.cwd(),l);console.log(`
@@ -69,13 +69,13 @@ 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=p.resolve(e.pages),s=p.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-wz54wsm7.js");sn();let i=await c({root:t?p.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-hj1yn8w5.js");on();let i=await c({root:t?p.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(`
76
76
  Build complete! (SSG)
77
77
  `),console.log(` Pages generated: ${i.ssg.successCount}`),i.ssg.failedCount>0)console.log(` Failed: ${i.ssg.failedCount}`);if(i.ssg.cachedCount>0)console.log(` From cache: ${i.ssg.cachedCount}`);if(i.ssg.sitemapPath)console.log(` Sitemap: ${p.relative(n.cwd(),i.ssg.sitemapPath)}`);if(i.ssg.rssPath)console.log(` RSS: ${p.relative(n.cwd(),i.ssg.rssPath)}`);if(console.log(` Build time: ${l}s`),console.log(` Output: ${p.relative(n.cwd(),e.out||"dist")}/
78
- `),i.ssg.errors.length>0){console.log(" Errors:");for(let a of i.ssg.errors)console.error(` ${a.route}: ${a.error}`);console.log("")}if(e.verbose&&i.ssg.pages.length>0&&i.ssg.pages.length<=20){console.log(" Generated pages:");for(let a of i.ssg.pages){let u=p.relative(n.cwd(),a.outputPath),g=(a.size/1024).toFixed(1);console.log(` ${u} (${g} KB)${a.cached?" [cached]":""}`)}console.log("")}let d=rn();if(d.length>0){console.error(`
78
+ `),i.ssg.errors.length>0){console.log(" Errors:");for(let a of i.ssg.errors)console.error(` ${a.route}: ${a.error}`);console.log("")}if(e.verbose&&i.ssg.pages.length>0&&i.ssg.pages.length<=20){console.log(" Generated pages:");for(let a of i.ssg.pages){let u=p.relative(n.cwd(),a.outputPath),g=(a.size/1024).toFixed(1);console.log(` ${u} (${g} KB)${a.cached?" [cached]":""}`)}console.log("")}let d=sn();if(d.length>0){console.error(`
79
79
  ${d.length} client script(s) failed to bundle:
80
80
  `);for(let a of d)console.error(` ${p.relative(n.cwd(),a.filePath)}
81
81
  ${a.message}
@@ -84,8 +84,8 @@ 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=p.resolve(t.output);if(!S.existsSync(p.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-c557w9e6.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
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-gn1dmfdv.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Ie}\x1B[0m`),e.init){console.log(`
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=p.resolve(t.output);if(!S.existsSync(p.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-gr19kv83.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
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-1xx55d2p.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Oe}\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(`
91
91
  You can now deploy with: stx deploy`);return}if(e.build!==!1){if(console.log(`
@@ -97,7 +97,7 @@ You can now deploy with: stx deploy`);return}if(e.build!==!1){if(console.log(`
97
97
  `),console.log(` ${e.dryRun?"Would deploy":"Draft URL"}: ${c.url}`),c.siteUrl)console.log(` Site URL: ${c.siteUrl}`);if(!e.dryRun)console.log(`
98
98
  Deploy ID: ${c.deployId}`),console.log(` Duration: ${(c.duration/1000).toFixed(1)}s`),console.log(` Files: ${c.filesUploaded}`)}}catch(o){if(o instanceof Error&&o.name==="DeployError")console.error(`
99
99
  \u274C ${o.message}`),n.exit(1);console.error(`
100
- \u274C Deploy failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(t,e)=>{try{let{optimizeDirectory:o,isSharpAvailable:r,formatSize:s}=await import("./chunk-enxnw50k.js"),c=await import("fs"),i=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${Ie}\x1B[0m`),!await r())console.error(`
100
+ \u274C Deploy failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(t,e)=>{try{let{optimizeDirectory:o,isSharpAvailable:r,formatSize:s}=await import("./chunk-8ta5b0eb.js"),c=await import("fs"),i=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${Oe}\x1B[0m`),!await r())console.error(`
101
101
  \u274C sharp is required for image optimization.`),console.log(`
102
102
  Install sharp with:`),console.log(" bun add sharp"),n.exit(1);let d=e.widths.split(",").map((v)=>Number.parseInt(v.trim(),10)).filter((v)=>!Number.isNaN(v)),a=e.formats.split(",").map((v)=>v.trim().toLowerCase()),u=Number.parseInt(e.quality,10)||80,g=e.placeholder,b=i.resolve(t);if(!c.existsSync(b))console.error(`
103
103
  \u274C Input directory not found: ${b}`),n.exit(1);if(!c.statSync(b).isDirectory())console.error(`
@@ -110,21 +110,21 @@ Would generate ~${P} image variants`);return}console.log(`
110
110
  `);let k=await o(b,e.output,{widths:d,formats:a,quality:u,placeholder:g,verbose:e.verbose});if(console.log(`
111
111
  \u2713 Optimization complete!
112
112
  `),console.log(` Images processed: ${k.stats.optimizedImages}/${k.stats.totalImages}`),console.log(` Variants created: ${k.stats.variants}`),k.stats.savedBytes>0)console.log(` Estimated savings: ~${s(k.stats.savedBytes)}`)}catch(o){console.error(`
113
- \u274C Image optimization failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("bundle [directory]","Analyze bundle size and composition").option("-o, --output <file>","Output file path").option("--json","Output as JSON").option("--text","Output as text summary").option("--markdown","Output as Markdown").option("--no-open","Do not open HTML report in browser").option("--no-gzip","Do not show gzip sizes").option("--threshold <size>","Fail if total size exceeds threshold (e.g., 500KB, 1MB)").option("--top <n>","Number of top modules to show",{default:"20"}).example("stx bundle").example("stx bundle dist/").example("stx bundle dist/ --json").example("stx bundle dist/ --text").example("stx bundle dist/ --threshold 500KB").example("stx bundle dist/ --no-open").action(async(t,e)=>{try{let{analyze:o,formatBytes:r,parseSize:s}=await import("./chunk-6q6g76vg.js"),c=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${Ie}\x1B[0m`);let l=c.resolve(t||"dist"),d=await import("fs");if(!d.existsSync(l))console.error(`
113
+ \u274C Image optimization failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("bundle [directory]","Analyze bundle size and composition").option("-o, --output <file>","Output file path").option("--json","Output as JSON").option("--text","Output as text summary").option("--markdown","Output as Markdown").option("--no-open","Do not open HTML report in browser").option("--no-gzip","Do not show gzip sizes").option("--threshold <size>","Fail if total size exceeds threshold (e.g., 500KB, 1MB)").option("--top <n>","Number of top modules to show",{default:"20"}).example("stx bundle").example("stx bundle dist/").example("stx bundle dist/ --json").example("stx bundle dist/ --text").example("stx bundle dist/ --threshold 500KB").example("stx bundle dist/ --no-open").action(async(t,e)=>{try{let{analyze:o,formatBytes:r,parseSize:s}=await import("./chunk-6q6g76vg.js"),c=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${Oe}\x1B[0m`);let l=c.resolve(t||"dist"),d=await import("fs");if(!d.existsSync(l))console.error(`
114
114
  \u274C Directory not found: ${l}`),console.log("\nRun `stx build` first to generate build output."),n.exit(1);let a="html";if(e.json)a="json";else if(e.text)a="text";else if(e.markdown)a="markdown";console.log(`
115
115
  \uD83D\uDCE6 Analyzing: ${l}`);let u=await o({directory:l,output:e.output,format:a,open:e.open!==!1&&a==="html",gzip:e.gzip!==!1,threshold:e.threshold,topModules:Number.parseInt(e.top||"20",10),recommendations:!0});if(a==="html"){if(console.log(`
116
116
  \u2713 Report generated: ${u.outputPath}`),e.open!==!1)console.log(" Opening in browser...")}else console.log(u.report);if(u.exceedsThreshold){let g=e.threshold;console.error(`
117
117
  \u274C Bundle size (${r(u.stats.totalSize)}) exceeds threshold (${g})`),n.exit(1)}if(a==="html"){if(console.log(`
118
118
  \uD83D\uDCCA Summary:`),console.log(` Total Size: ${r(u.stats.totalSize)}`),console.log(` Gzip Size: ${r(u.stats.totalGzipSize)}`),console.log(` Modules: ${u.stats.moduleCount}`),console.log(` Chunks: ${u.stats.chunks.length}`),u.stats.duplicates.length>0)console.log(` Duplicates: ${u.stats.duplicates.length}`)}}catch(o){console.error(`
119
- \u274C Bundle analysis failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(t,e)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${Ie} (${ia})\x1B[0m`),e.timeout){let s=I(e.timeout);if(!s.isValid)F(s)}let o=typeof t==="string"?[t]:t||[];if(o.length===0)o.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(e.verbose)console.log("Test patterns:",o),console.log("Options:",JSON.stringify({watch:e.watch||!1,filter:e.filter||"none",reporter:e.reporter||"default",timeout:e.timeout||5000,coverage:e.coverage||!1,ui:e.ui||!1},null,2));if(!await ce.timeAsync("test-execution",()=>V(o,e))&&!e.watch)n.exit(1)}catch(o){console.error("Error running tests:",o),n.exit(1)}}),y.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(t="index.stx",e)=>{try{if(await oa(t,{force:e.force,template:e.template}))console.log(`
119
+ \u274C Bundle analysis failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(t,e)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${Oe} (${ia})\x1B[0m`),e.timeout){let s=I(e.timeout);if(!s.isValid)F(s)}let o=typeof t==="string"?[t]:t||[];if(o.length===0)o.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(e.verbose)console.log("Test patterns:",o),console.log("Options:",JSON.stringify({watch:e.watch||!1,filter:e.filter||"none",reporter:e.reporter||"default",timeout:e.timeout||5000,coverage:e.coverage||!1,ui:e.ui||!1},null,2));if(!await le.timeAsync("test-execution",()=>V(o,e))&&!e.watch)n.exit(1)}catch(o){console.error("Error running tests:",o),n.exit(1)}}),y.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(t="index.stx",e)=>{try{if(await oa(t,{force:e.force,template:e.template}))console.log(`
120
120
  \u2728 Successfully created file: ${t}`),console.log(`
121
121
  To view it in the development server:`),console.log(` stx dev ${t}
122
122
  `);else console.error(`
123
123
  \u274C Failed to create file: ${t}`),n.exit(1)}catch(o){console.error("Error creating file:",o),n.exit(1)}}),y.command("format [patterns...]","Format STX and Markdown files automatically").option("--check","Check if files are formatted (exit with error if not)").option("--write","Write formatted files back to disk (default)").option("--diff","Show diff of changes that would be made").option("--ignore <patterns>","Comma-separated patterns to ignore").example("stx format").example("stx format **/*.stx").example("stx format **/*.md").example("stx format **/*.{stx,md}").example("stx format --check").example("stx format --diff --ignore node_modules/**").action(async(t,e)=>{try{if(e.check&&e.write)console.error("\u274C Options --check and --write are mutually exclusive"),console.error("\uD83D\uDCA1 Use --check to verify formatting or --write to apply changes, but not both"),n.exit(1);let o=t&&t.length>0?t:["**/*.stx","**/*.md"],r=e.ignore?e.ignore.split(",").map((a)=>a.trim()):["node_modules/**","dist/**",".git/**"],s=[];for(let a of o){let u=await Array.fromAsync(new Bun.Glob(a).scan({onlyFiles:!0,absolute:!0}));s.push(...u.filter((g)=>g.endsWith(".stx")||g.endsWith(".md")))}if(s=s.filter((a)=>!r.some((u)=>{let g=u.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*");return new RegExp(g).test(a)})),s.length===0){console.log("No STX or Markdown files found to format.");return}let c=s.filter((a)=>a.endsWith(".stx")),i=s.filter((a)=>a.endsWith(".md"));console.log(`Formatting ${s.length} files (${c.length} .stx, ${i.length} .md)...`);let l=0,d=0;for(let a of s)try{let u=await Bun.file(a).text(),b=a.endsWith(".md")?sa(u):uo(u);if(u!==b)if(e.check)console.log(`\u274C ${p.relative(n.cwd(),a)} needs formatting`),d++;else if(e.diff)console.log(`
124
124
  \uD83D\uDCDD ${p.relative(n.cwd(),a)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${p.basename(a)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(a,b),console.log(`\u2705 Formatted ${p.relative(n.cwd(),a)}`),l++}catch(u){console.error(`\u274C Error formatting ${p.relative(n.cwd(),a)}:`,u),d++}if(e.check&&d>0)console.log(`
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){ce.clear(),console.log("\u2705 Performance statistics cleared");return}let o=ce.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(`
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){le.clear(),console.log("\u2705 Performance statistics cleared");return}let o=le.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-p91288ce.js"),{resolveStxTargets:s}=await import("./chunk-syww37qd.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-vr5h5jpw.js"),{resolveStxTargets:s}=await import("./chunk-syww37qd.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=ea(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.
@@ -135,8 +135,8 @@ ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.chec
135
135
  `),n.exit(2);let g=u.diagnostics.filter((b)=>b.category==="error");if(u.diagnostics.length>0)console.error(`
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 `+`${g.length} error(s), ${u.diagnostics.length-g.length} warning(s)
138
- `),g.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-9z7fnv33.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,g=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)g.add(p.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)||g.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-cfmjtyzm.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await po({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(fo(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}
138
+ `),g.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-fyp1v087.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,g=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)g.add(p.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)||g.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-ent64fyq.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await po({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(fo(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,15 +160,15 @@ Press Ctrl+C to stop watching...
160
160
  \uD83D\uDCC4 Files with issues:`),d.forEach((a)=>{let u=a.issues.filter((g)=>s[g.type]>=c).length;if(u>0)console.log(` ${p.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-m3kc2a3v.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(Ie)}),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-w165qe5q.js"),o={};if(t.context){let r=p.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?p.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-dbag44ta.js"),c=p.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(Oe)}),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-ccdp6g5z.js"),o={};if(t.context){let r=p.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?p.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-f3msj6jf.js"),c=p.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:p.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?p.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-4dfz7cdr.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-a2fngjfx.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-3wt0nh3p.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-cy60hmv2.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-77kanny8.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 ${p.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-mx79sfyr.js"),r=p.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-sb7zn84j.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-4h9kkkh7.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-qe6631me.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-npzzbdn1.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-cvrkr3re.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 ${p.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-mx79sfyr.js"),r=p.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=p.resolve(e.output);if(!S.existsSync(d))S.mkdirSync(d,{recursive:!0});let a=p.basename(t,p.extname(t)),u=e.format==="typescript"?"ts":e.format==="json"?"json":"zig",g=p.join(d,`${a}.${u}`);S.writeFileSync(g,l.code);let b=p.join(d,`${a}.manifest.json`);if(S.writeFileSync(b,JSON.stringify(l.manifest,null,2)),e.sourcemaps&&l.sourceMaps){let w=p.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=p.join(d,`${a}.${w}.${u}`);S.writeFileSync(v,k)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${g}`),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(`
171
171
  \u26A0\uFE0F Warnings:`);for(let w of l.stats.warnings)console.log(` - ${w.message}`)}if(l.stats.errors.length>0){console.log(`
172
172
  \u274C Errors:`);for(let w of l.stats.errors)console.log(` - ${w.message}`)}}catch(o){console.error(`\u274C Compilation error: ${o.message}`),n.exit(1)}});let m=y.commands.flatMap((t)=>[t.name,...t.aliasNames??[]]).filter((t)=>Boolean(t)),x=n.argv.slice(2);if(x.length>0&&!x[0].startsWith("-")){let t=x[0];if(t==="")console.error("\u274C No command provided"),console.error("\uD83D\uDCA1 Use --help to see available commands"),n.exit(1);if(!m.includes(t)){let e=h("fs"),o=h("path"),r=t;if(!o.isAbsolute(r))r=o.resolve(n.cwd(),r);if(e.existsSync(r)){let s=e.statSync(r);if(s.isFile()||s.isDirectory())n.argv=[n.argv[0],n.argv[1],"dev",...x]}else{let s=m.map((i)=>({command:i,distance:f(t,i)}));s.sort((i,l)=>i.distance-l.distance);let c=s[0];if(c.distance<=3)console.error(`\u274C Unknown command: ${t}`),console.error(`\uD83D\uDCA1 Did you mean: ${c.command}?`),console.error(`
173
173
  Run 'stx --help' to see available commands.`),n.exit(1);console.error(`\u274C Unknown command or path: ${t}`),console.error(`
174
- Run 'stx --help' to see available commands.`),n.exit(1)}}}y.help(),y.version(Ie),y.parse(n.argv)}
174
+ Run 'stx --help' to see available commands.`),n.exit(1)}}}y.help(),y.version(Oe),y.parse(n.argv)}
@@ -1,5 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { scanAtElementPosition } from "./html-masking.js";
3
+ import { escapeScriptBody } from "./script-emit.js";
3
4
  export const COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY = "__stx_component_client_factories";
4
5
  function registryFrom(context) {
5
6
  const registry = context[COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY];
@@ -37,7 +38,7 @@ export function injectComponentClientFactories(html, context) {
37
38
  edits.push({
38
39
  start: match.index,
39
40
  end: match.index + match[0].length,
40
- replacement: `(${body})(${match[2]});`
41
+ replacement: escapeScriptBody(`(${body})(${match[2]});`)
41
42
  });
42
43
  match = invocation.exec(html);
43
44
  }
@@ -45,12 +46,12 @@ export function injectComponentClientFactories(html, context) {
45
46
  const repeatedFactories = [...registry].filter(([, factory]) => factory.instances > 1);
46
47
  if (repeatedFactories.length === 0)
47
48
  return applyFactoryEdits(html, edits);
48
- const prelude = `<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
49
+ const definitions = repeatedFactories.map(([id, factory]) => ` try { factories[${JSON.stringify(id)}] = factories[${JSON.stringify(id)}] || ${factory.body}; }
50
+ catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(id)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
51
+ `), prelude = `<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
49
52
  (function() {
50
53
  const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
51
- ${repeatedFactories.map(([id, factory]) => ` try { factories[${JSON.stringify(id)}] = factories[${JSON.stringify(id)}] || ${factory.body}; }
52
- catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(id)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
53
- `)}
54
+ ${escapeScriptBody(definitions)}
54
55
  })();
55
56
  </script>`;
56
57
  let insertionPoint;
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-mv48q1p4.js";import{Eo,Ea,Ta}from"./chunk-csksn1kg.js";import"./chunk-te82sjhy.js";import"./chunk-0dmpc70r.js";import"./chunk-ngnvyqk3.js";import"./chunk-xppm4cs4.js";import"./chunk-v4bqmzj9.js";import"./chunk-e8zpzt9s.js";import"./chunk-kvafq9gy.js";import"./chunk-9r999ees.js";import"./chunk-1qybwj8k.js";import"./chunk-vw73gsxx.js";import"./chunk-tm8a2b69.js";import"./chunk-k0arm18k.js";import"./chunk-9hvfmqs1.js";import"./chunk-ynd2nfvs.js";import"./chunk-q0jmc3m4.js";import"./chunk-xfb7fdeq.js";import"./chunk-4wrddn8m.js";import"./chunk-279n7sde.js";import"./chunk-t5q31st4.js";import"./chunk-68pvvd7v.js";import{xu,$a,Th,$h,Ra,To,ns,Aa,Pa,Rh,Ah,Ia,Oa,Na,Ma}from"./chunk-fzkyk5j4.js";import"./chunk-hgy98n76.js";import"./chunk-8qe34jb8.js";import"./chunk-v8p8t3t4.js";import"./chunk-7hp50cpd.js";import"./chunk-zswtgwxg.js";import"./chunk-qxk9grjm.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"./chunk-fp24ecp8.js";import{Eo,Ea,Ta}from"./chunk-csksn1kg.js";import"./chunk-xejhmsfw.js";import"./chunk-0d3z8hwz.js";import"./chunk-432c35hs.js";import"./chunk-xppm4cs4.js";import"./chunk-sny8rqe8.js";import"./chunk-6tpcm12w.js";import"./chunk-kvafq9gy.js";import"./chunk-dhpd4mx7.js";import"./chunk-g0h1gxew.js";import"./chunk-j2s8j7ff.js";import"./chunk-tm8a2b69.js";import"./chunk-0hrkpb2h.js";import"./chunk-dnrgcjds.js";import"./chunk-hfng042r.js";import"./chunk-3wabhzf4.js";import"./chunk-1kmzj10y.js";import"./chunk-xfymp197.js";import"./chunk-16p1vkn6.js";import"./chunk-t5q31st4.js";import"./chunk-3zjyhhg4.js";import{xu,$a,Th,$h,Ra,To,ns,Aa,Pa,Rh,Ah,Ia,Oa,Na,Ma}from"./chunk-8hymdzv2.js";import"./chunk-cama7kaq.js";import"./chunk-2a471sw1.js";import"./chunk-cskmp5p1.js";import"./chunk-htwn1f36.js";import"./chunk-eefdz43s.js";import"./chunk-xqr2ec9k.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"./chunk-mv48q1p4.js";import{Eo,Ea,Ta}from"./chunk-csksn1kg.js";import"./chunk-te82sjhy.js";import"./chunk-0dmpc70r.js";import"./chunk-ngnvyqk3.js";import"./chunk-xppm4cs4.js";import"./chunk-v4bqmzj9.js";import"./chunk-e8zpzt9s.js";import"./chunk-kvafq9gy.js";import"./chunk-9r999ees.js";import"./chunk-1qybwj8k.js";import"./chunk-vw73gsxx.js";import"./chunk-tm8a2b69.js";import"./chunk-k0arm18k.js";import"./chunk-9hvfmqs1.js";import"./chunk-ynd2nfvs.js";import"./chunk-q0jmc3m4.js";import"./chunk-xfb7fdeq.js";import"./chunk-4wrddn8m.js";import"./chunk-279n7sde.js";import"./chunk-t5q31st4.js";import"./chunk-68pvvd7v.js";import{xu,$a,Th,$h,Ra,To,ns,Aa,Pa,Rh,Ah,Ia,Oa,Na,Ma}from"./chunk-fzkyk5j4.js";import"./chunk-hgy98n76.js";import"./chunk-8qe34jb8.js";import"./chunk-v8p8t3t4.js";import"./chunk-7hp50cpd.js";import"./chunk-zswtgwxg.js";import"./chunk-qxk9grjm.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"./chunk-fp24ecp8.js";import{Eo,Ea,Ta}from"./chunk-csksn1kg.js";import"./chunk-xejhmsfw.js";import"./chunk-0d3z8hwz.js";import"./chunk-432c35hs.js";import"./chunk-xppm4cs4.js";import"./chunk-sny8rqe8.js";import"./chunk-6tpcm12w.js";import"./chunk-kvafq9gy.js";import"./chunk-dhpd4mx7.js";import"./chunk-g0h1gxew.js";import"./chunk-j2s8j7ff.js";import"./chunk-tm8a2b69.js";import"./chunk-0hrkpb2h.js";import"./chunk-dnrgcjds.js";import"./chunk-hfng042r.js";import"./chunk-3wabhzf4.js";import"./chunk-1kmzj10y.js";import"./chunk-xfymp197.js";import"./chunk-16p1vkn6.js";import"./chunk-t5q31st4.js";import"./chunk-3zjyhhg4.js";import{xu,$a,Th,$h,Ra,To,ns,Aa,Pa,Rh,Ah,Ia,Oa,Na,Ma}from"./chunk-8hymdzv2.js";import"./chunk-cama7kaq.js";import"./chunk-2a471sw1.js";import"./chunk-cskmp5p1.js";import"./chunk-htwn1f36.js";import"./chunk-eefdz43s.js";import"./chunk-xqr2ec9k.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/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{so,Ut,Al,Mg}from"./chunk-ctb1bj28.js";import{ro,ji,Ig,Og,Ng}from"./chunk-33ph9zb2.js";import{Tl,$l,Rl,Ag,Pg}from"./chunk-j2wcawmf.js";import{We,Pn,Bi}from"./chunk-krtkxnz6.js";import{Dg,Lg,jg,Bg,oo,ky}from"./chunk-fhrvxfq9.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
- Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-vgaqznwt.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
2
+ import{so,Wt,Al,Mg}from"./chunk-bg574nvy.js";import{ro,ji,Ig,Og,Ng}from"./chunk-2cy33z00.js";import{Tl,$l,Rl,Ag,Pg}from"./chunk-j2wcawmf.js";import{qe,Pn,Bi}from"./chunk-admnvsmx.js";import{Dg,Lg,jg,Bg,oo,ky}from"./chunk-fhrvxfq9.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
+ Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-68kspmq4.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8">
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
233
233
  }, 5000);
234
234
  </script>
235
235
  </body>
236
- </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=We(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=so(n,t);if(a){let s=Ut(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return ji(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,$l as auditBuildOutput,Tl as auditConfig,re as buildPwaAssets,Rl as calculateAuditResult,Pg as formatAuditResult,Bi as formatSize,j as generateManifest,_ as generateManifestJson,Og as generateManifestLink,F as generateOfflinePage,We as generatePrecacheManifest,Pn as generatePrecacheManifestJs,M as generatePwaIcons,ro as generatePwaTags,so as generateServiceWorker,Mg as generateServiceWorkerAuto,Ig as generateSwRegistrationScript,Ng as generateThemeColorMeta,N as getExpectedIconPaths,Ut as getServiceWorkerFileName,ji as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Al as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,oo as pwaDirectives,Dg as pwaInstallDirective,jg as pwaOfflineDirective,Bg as pwaPushDirective,Lg as pwaUpdateDirective,ky as registerPwaDirectives,Ag as runPwaAudit,D as validateManifest};
236
+ </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=qe(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=so(n,t);if(a){let s=Wt(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return ji(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,$l as auditBuildOutput,Tl as auditConfig,re as buildPwaAssets,Rl as calculateAuditResult,Pg as formatAuditResult,Bi as formatSize,j as generateManifest,_ as generateManifestJson,Og as generateManifestLink,F as generateOfflinePage,qe as generatePrecacheManifest,Pn as generatePrecacheManifestJs,M as generatePwaIcons,ro as generatePwaTags,so as generateServiceWorker,Mg as generateServiceWorkerAuto,Ig as generateSwRegistrationScript,Ng as generateThemeColorMeta,N as getExpectedIconPaths,Wt as getServiceWorkerFileName,ji as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Al as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,oo as pwaDirectives,Dg as pwaInstallDirective,jg as pwaOfflineDirective,Bg as pwaPushDirective,Lg as pwaUpdateDirective,ky as registerPwaDirectives,Ag as runPwaAudit,D as validateManifest};