@stacksjs/stx 0.2.654 → 0.2.656

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 (136) hide show
  1. package/dist/{chunk-ff1cb7k4.js → chunk-0gqmp9sa.js} +2 -2
  2. package/dist/{chunk-48acjmeg.js → chunk-0jhdrgpr.js} +2 -2
  3. package/dist/{chunk-q1x7ckfw.js → chunk-1z1fmda6.js} +1 -1
  4. package/dist/chunk-26qc9v36.js +2 -0
  5. package/dist/{chunk-y8881za3.js → chunk-27v1ehy0.js} +1 -1
  6. package/dist/{chunk-3v8yejzc.js → chunk-2h92dm3t.js} +3 -3
  7. package/dist/{chunk-46w53nj5.js → chunk-2jh21f1n.js} +1 -1
  8. package/dist/chunk-2qf9vt7y.js +2 -0
  9. package/dist/{chunk-k7nan28e.js → chunk-31yb0253.js} +4 -4
  10. package/dist/chunk-3p7xp7de.js +2 -0
  11. package/dist/{chunk-6rparhvs.js → chunk-5cyznacz.js} +1 -1
  12. package/dist/{chunk-j2bkjtp3.js → chunk-5w2jy5r9.js} +4 -4
  13. package/dist/chunk-67rvd6qy.js +2 -0
  14. package/dist/{chunk-h4vg78mw.js → chunk-6c2pvrw8.js} +1 -1
  15. package/dist/{chunk-4qwvqbzf.js → chunk-7rta163c.js} +2 -2
  16. package/dist/{chunk-s4cs2n2c.js → chunk-80fkh83p.js} +1 -1
  17. package/dist/{chunk-g7j3mwzd.js → chunk-889evdcy.js} +12 -12
  18. package/dist/{chunk-znnfjxph.js → chunk-8d2f2e42.js} +1 -1
  19. package/dist/{chunk-wh838rdh.js → chunk-8nryyqb5.js} +1 -1
  20. package/dist/chunk-9c3cq8ks.js +2 -0
  21. package/dist/chunk-9q23eed0.js +2 -0
  22. package/dist/chunk-a2bw46t9.js +2 -0
  23. package/dist/{chunk-phws2c9s.js → chunk-a2dnv6n9.js} +1 -1
  24. package/dist/{chunk-t7j4h3nf.js → chunk-ajjcp56c.js} +3 -3
  25. package/dist/{chunk-vngnface.js → chunk-aprhqxky.js} +3 -3
  26. package/dist/chunk-b4fd2dtk.js +2 -0
  27. package/dist/chunk-bpm8tyvc.js +2 -0
  28. package/dist/{chunk-a2a74f6c.js → chunk-c9k40352.js} +1 -1
  29. package/dist/{chunk-5yxd4ryz.js → chunk-cjj9b9wf.js} +2 -2
  30. package/dist/chunk-da6qbwqs.js +2 -0
  31. package/dist/chunk-dknd9nhz.js +2 -0
  32. package/dist/{chunk-v9bmw06j.js → chunk-ds3qn1ty.js} +1 -1
  33. package/dist/{chunk-x9d4bpmh.js → chunk-dv7dm5z1.js} +20 -20
  34. package/dist/{chunk-26whq1rg.js → chunk-e7z85137.js} +1 -1
  35. package/dist/{chunk-c9b0cme2.js → chunk-eecgcj41.js} +1 -1
  36. package/dist/chunk-fbtv2k1p.js +3 -0
  37. package/dist/chunk-fjqphdvp.js +2 -0
  38. package/dist/{chunk-xq410rsc.js → chunk-g96m1a69.js} +1 -1
  39. package/dist/{chunk-hjmnsa6a.js → chunk-gf3bxnpq.js} +1 -1
  40. package/dist/{chunk-vmn2b6p6.js → chunk-gz90fqn8.js} +1 -1
  41. package/dist/{chunk-50pkybyn.js → chunk-gzd7bmp5.js} +1 -1
  42. package/dist/{chunk-4e0z858k.js → chunk-hb08vrbb.js} +1 -1
  43. package/dist/{chunk-2yg9y1na.js → chunk-hzjvpcmj.js} +109 -94
  44. package/dist/chunk-j2hkxwjy.js +2 -0
  45. package/dist/{chunk-35zjpdcb.js → chunk-jf17b7y9.js} +1 -1
  46. package/dist/{chunk-m47spkxr.js → chunk-jfmjw734.js} +2 -2
  47. package/dist/{chunk-xdgvb5a5.js → chunk-jrf01hfv.js} +1 -1
  48. package/dist/{chunk-71mthavp.js → chunk-jvv9p6v6.js} +1 -1
  49. package/dist/{chunk-kcrtqyek.js → chunk-k9amsnfj.js} +4 -4
  50. package/dist/chunk-kg54zsda.js +2 -0
  51. package/dist/chunk-kpycf9tz.js +2 -0
  52. package/dist/{chunk-ra56jh7e.js → chunk-mz1npbyk.js} +1 -1
  53. package/dist/chunk-ne72vxmc.js +2 -0
  54. package/dist/{chunk-cvw7gknw.js → chunk-nn138y2w.js} +3 -3
  55. package/dist/{chunk-cq40n7ak.js → chunk-np1k9vsr.js} +1 -1
  56. package/dist/{chunk-sd4jwn3y.js → chunk-p314pg80.js} +1 -1
  57. package/dist/chunk-p7096wfv.js +2 -0
  58. package/dist/{chunk-vs8kg85h.js → chunk-p7bqzhe1.js} +1 -1
  59. package/dist/{chunk-en8jgavy.js → chunk-pxqh758g.js} +81 -19
  60. package/dist/chunk-qc5wyxvc.js +2 -0
  61. package/dist/{chunk-ht3dxx5m.js → chunk-qkasqamj.js} +1 -1
  62. package/dist/{chunk-7wnd2psp.js → chunk-qkq8at1r.js} +1 -1
  63. package/dist/{chunk-8gewq710.js → chunk-r7kmsq3n.js} +1 -1
  64. package/dist/{chunk-929zbzh7.js → chunk-rccpf74y.js} +1 -1
  65. package/dist/{chunk-d4tf0tfn.js → chunk-rjh2jwxx.js} +4 -4
  66. package/dist/chunk-s2qv0y4x.js +2 -0
  67. package/dist/{chunk-36649w15.js → chunk-sdknbvh8.js} +1 -1
  68. package/dist/{chunk-khvc43pq.js → chunk-t2pzy3x1.js} +2 -2
  69. package/dist/{chunk-h09a03ay.js → chunk-t9mfztcs.js} +4 -4
  70. package/dist/{chunk-n7xbhzzt.js → chunk-teahew39.js} +4 -4
  71. package/dist/{chunk-9y2ncrnq.js → chunk-v2x9vzgw.js} +2 -2
  72. package/dist/{chunk-xhmpfq9d.js → chunk-v3kc2anv.js} +1 -1
  73. package/dist/{chunk-hw7sv4ac.js → chunk-v5r6abrq.js} +1 -1
  74. package/dist/{chunk-bgt1dx8c.js → chunk-vm26nak1.js} +1 -1
  75. package/dist/chunk-vmzkbdmp.js +2 -0
  76. package/dist/{chunk-6598d3m6.js → chunk-vqc4h16r.js} +2 -2
  77. package/dist/{chunk-qygynhzc.js → chunk-w2zceynt.js} +1 -1
  78. package/dist/chunk-weqc0ssb.js +2 -0
  79. package/dist/chunk-wp0jtntj.js +54 -0
  80. package/dist/{chunk-gmrc24cb.js → chunk-x2wgczak.js} +1 -1
  81. package/dist/{chunk-ktvr9ta8.js → chunk-x5777qkq.js} +2 -2
  82. package/dist/chunk-xesyd9nx.js +2 -0
  83. package/dist/{chunk-nttspz8c.js → chunk-xv43szx0.js} +4 -4
  84. package/dist/{chunk-ex1kd5gs.js → chunk-y4waj1p4.js} +2 -2
  85. package/dist/chunk-yb89cj9s.js +2 -0
  86. package/dist/{chunk-mgj34bbg.js → chunk-yh0wb4n1.js} +1 -1
  87. package/dist/chunk-ypsym37h.js +2 -0
  88. package/dist/{chunk-4nbq7mnp.js → chunk-yq021b3r.js} +4 -4
  89. package/dist/{chunk-6raq8r7w.js → chunk-yr34z9ey.js} +1 -1
  90. package/dist/{chunk-qrt8b179.js → chunk-zaaeneq6.js} +2 -2
  91. package/dist/{chunk-1zb7ar32.js → chunk-zaj65qc1.js} +2 -2
  92. package/dist/{chunk-k49fg322.js → chunk-zfeq5h13.js} +2 -2
  93. package/dist/{chunk-dxk5sqtv.js → chunk-zhf01af3.js} +2 -2
  94. package/dist/{chunk-2zqg980j.js → chunk-zyv28182.js} +1 -1
  95. package/dist/cli.js +11 -11
  96. package/dist/client/signals-dom-ready-runtime.js +2 -2
  97. package/dist/client/signals-effect-runtime.js +22 -9
  98. package/dist/client/signals-lifecycle-runtime.js +15 -0
  99. package/dist/client/signals-manifest-hydration-runtime.js +8 -1
  100. package/dist/client/signals-mount-runtime.js +16 -4
  101. package/dist/client/signals-public-api-runtime.js +1 -0
  102. package/dist/client/signals-scope-disposal-runtime.js +14 -0
  103. package/dist/client/signals-spa-load-runtime.js +2 -2
  104. package/dist/craft-entry.js +1 -1
  105. package/dist/craft.js +1 -1
  106. package/dist/includes.js +9 -0
  107. package/dist/pwa.js +3 -3
  108. package/dist/ssg.js +12 -12
  109. package/dist/utils.js +15 -0
  110. package/package.json +5 -5
  111. package/dist/chunk-17srvghf.js +0 -2
  112. package/dist/chunk-3634ds4n.js +0 -2
  113. package/dist/chunk-3msbc4zj.js +0 -2
  114. package/dist/chunk-3q3gsr7m.js +0 -2
  115. package/dist/chunk-42v0vegr.js +0 -2
  116. package/dist/chunk-73swyb5p.js +0 -2
  117. package/dist/chunk-d0xcykw6.js +0 -2
  118. package/dist/chunk-dxjc11hx.js +0 -2
  119. package/dist/chunk-edz1h5f9.js +0 -2
  120. package/dist/chunk-etw04j02.js +0 -2
  121. package/dist/chunk-ewng6v6g.js +0 -49
  122. package/dist/chunk-fbd9w4ys.js +0 -2
  123. package/dist/chunk-fnj3gja0.js +0 -2
  124. package/dist/chunk-fsnby15p.js +0 -2
  125. package/dist/chunk-h0bg2h0j.js +0 -2
  126. package/dist/chunk-j3472s37.js +0 -3
  127. package/dist/chunk-jmx4q1yr.js +0 -2
  128. package/dist/chunk-m947aq9a.js +0 -2
  129. package/dist/chunk-ndtxkps4.js +0 -2
  130. package/dist/chunk-pge3bzqx.js +0 -2
  131. package/dist/chunk-q79ksfcd.js +0 -2
  132. package/dist/chunk-qjf1c8fa.js +0 -2
  133. package/dist/chunk-rmdw6s65.js +0 -2
  134. package/dist/chunk-s0crnpyx.js +0 -2
  135. package/dist/chunk-z75bp57x.js +0 -2
  136. package/dist/chunk-zrqremja.js +0 -2
package/dist/cli.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import"./chunk-4e0z858k.js";import"./chunk-4qwvqbzf.js";import"./chunk-ce6zddpf.js";import{$e,te}from"./chunk-2yg9y1na.js";import"./chunk-2h8ea0we.js";import"./chunk-35zjpdcb.js";import"./chunk-a3d0g4mr.js";import"./chunk-qrt8b179.js";import"./chunk-3v8yejzc.js";import"./chunk-h09a03ay.js";import"./chunk-04kg16qs.js";import"./chunk-g7j3mwzd.js";import"./chunk-xhmpfq9d.js";import"./chunk-ff1cb7k4.js";import"./chunk-929zbzh7.js";import"./chunk-ewng6v6g.js";import"./chunk-ra56jh7e.js";import"./chunk-d4tf0tfn.js";import"./chunk-c1dkh0es.js";import"./chunk-48acjmeg.js";import"./chunk-tre98h62.js";import"./chunk-46w53nj5.js";import"./chunk-4nbq7mnp.js";import"./chunk-kcrtqyek.js";import"./chunk-kgfgb971.js";import"./chunk-phws2c9s.js";import"./chunk-en8jgavy.js";import"./chunk-jxda11cg.js";import"./chunk-dgb4z4kw.js";import"./chunk-h4vg78mw.js";import"./chunk-zqtbtqbq.js";import"./chunk-36649w15.js";import"./chunk-k7nan28e.js";import"./chunk-prf164ct.js";import"./chunk-vs8kg85h.js";import"./chunk-nrvwejdw.js";import"./chunk-5yxd4ryz.js";import"./chunk-s4cs2n2c.js";import"./chunk-2zqg980j.js";import"./chunk-vngnface.js";import"./chunk-r3e6x87d.js";import"./chunk-mmwedr93.js";import"./chunk-9y2ncrnq.js";import{Gt,Kt}from"./chunk-cvw7gknw.js";import"./chunk-m47spkxr.js";import"./chunk-k49fg322.js";import"./chunk-ym41ybz2.js";import"./chunk-n38yb274.js";import"./chunk-9p6efb17.js";import"./chunk-khvc43pq.js";import"./chunk-rcadtv3x.js";import"./chunk-ex1kd5gs.js";import"./chunk-v9bmw06j.js";import{di,pi,fi,gi,As,mi,hi,yi,Ps,Is,Sr,kr,Cr}from"./chunk-x9d4bpmh.js";import"./chunk-ktvr9ta8.js";import"./chunk-6ajahb2x.js";import"./chunk-8gewq710.js";import"./chunk-n7xbhzzt.js";import"./chunk-wh838rdh.js";import{ma}from"./chunk-26whq1rg.js";import{p}from"./chunk-2a4szpje.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as z}from"@stacksjs/clapp";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new z("stx");function E(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),r=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function I(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),W=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function M(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function V(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let i=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(i.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...i),m.verbose)console.log(`Found ${i.length} file(s) matching pattern: ${c}`)}catch(i){return console.error(`Error expanding glob pattern ${c}:`,i),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let r=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(i)=>{let d=((performance.now()-r)/1000).toFixed(2);if(i===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
3
+ import"./chunk-hb08vrbb.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import{$e,te}from"./chunk-hzjvpcmj.js";import"./chunk-2h8ea0we.js";import"./chunk-jf17b7y9.js";import"./chunk-a3d0g4mr.js";import"./chunk-zaaeneq6.js";import"./chunk-2h92dm3t.js";import"./chunk-t9mfztcs.js";import"./chunk-04kg16qs.js";import"./chunk-889evdcy.js";import"./chunk-v3kc2anv.js";import"./chunk-0gqmp9sa.js";import"./chunk-rccpf74y.js";import"./chunk-wp0jtntj.js";import"./chunk-mz1npbyk.js";import"./chunk-rjh2jwxx.js";import"./chunk-c1dkh0es.js";import"./chunk-0jhdrgpr.js";import"./chunk-tre98h62.js";import"./chunk-2jh21f1n.js";import"./chunk-yq021b3r.js";import"./chunk-k9amsnfj.js";import"./chunk-kgfgb971.js";import"./chunk-a2dnv6n9.js";import"./chunk-pxqh758g.js";import"./chunk-jxda11cg.js";import"./chunk-dgb4z4kw.js";import"./chunk-6c2pvrw8.js";import"./chunk-zqtbtqbq.js";import"./chunk-sdknbvh8.js";import"./chunk-31yb0253.js";import"./chunk-prf164ct.js";import"./chunk-p7bqzhe1.js";import"./chunk-nrvwejdw.js";import"./chunk-cjj9b9wf.js";import"./chunk-80fkh83p.js";import"./chunk-zyv28182.js";import"./chunk-aprhqxky.js";import"./chunk-r3e6x87d.js";import"./chunk-mmwedr93.js";import"./chunk-v2x9vzgw.js";import{Gt,Kt}from"./chunk-nn138y2w.js";import"./chunk-jfmjw734.js";import"./chunk-zfeq5h13.js";import"./chunk-ym41ybz2.js";import"./chunk-n38yb274.js";import"./chunk-9p6efb17.js";import"./chunk-t2pzy3x1.js";import"./chunk-rcadtv3x.js";import"./chunk-y4waj1p4.js";import"./chunk-ds3qn1ty.js";import{di,pi,fi,gi,As,mi,hi,yi,Ps,Is,Sr,kr,_r}from"./chunk-dv7dm5z1.js";import"./chunk-x5777qkq.js";import"./chunk-6ajahb2x.js";import"./chunk-r7kmsq3n.js";import"./chunk-teahew39.js";import"./chunk-8nryyqb5.js";import{ma}from"./chunk-e7z85137.js";import{p}from"./chunk-2a4szpje.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as z}from"@stacksjs/clapp";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new z("stx");function E(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),r=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function I(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),W=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function M(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function V(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let i=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(i.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...i),m.verbose)console.log(`Found ${i.length} file(s) matching pattern: ${c}`)}catch(i){return console.error(`Error expanding glob pattern ${c}:`,i),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let r=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(i)=>{let d=((performance.now()-r)/1000).toFixed(2);if(i===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
4
4
  Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var U=n.argv.length>=3&&(W(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(U){let h=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=E(n.argv[++x]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),i=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of i)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await kr(t,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Sr(h,m).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let r=0;r<=e.length;r++)o[r]=[r];for(let r=0;r<=t.length;r++)o[0][r]=r;for(let r=1;r<=e.length;r++)for(let s=1;s<=t.length;s++)if(e.charAt(r-1)===t.charAt(s-1))o[r][s]=o[r-1][s-1];else o[r][s]=Math.min(o[r-1][s-1]+1,o[r][s-1]+1,o[r-1][s]+1);return o[e.length][t.length]};y.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(t)=>{try{if(await gi(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(t,e)=>{try{let{fetchCollections:o,generatePackage:r}=await import("./chunk-2qbvsvwc.js");if(t==="list"){console.log(`
5
5
  \uD83D\uDCDA Fetching available icon collections...
6
6
  `);let s=await o(),c=Object.entries(s).sort((i,l)=>l[1].total-i[1].total);console.log(`Available collections:
7
7
  `);for(let[i,l]of c){let d=l;console.log(` ${i.padEnd(30)} ${d.name} (${d.total} icons)`)}console.log(`
8
8
  Total: ${c.length} collections`)}else if(t.startsWith("generate")){let s=t==="generate"?"":t.replace("generate:","").replace("generate-","").replace("generate","").trim();if(!s)console.error("Error: Please specify a collection prefix"),console.error("Usage: stx iconify generate <prefix> [--icons icon1,icon2,...]"),n.exit(1);let c=e.output||f.join(n.cwd(),"packages/collections"),i=e.icons?e.icons.split(",").map((l)=>l.trim()):void 0;await r(s,c,i),console.log(`
9
9
  \u2713 Package generated successfully!`),console.log(`
10
- To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-864qtx7y.js"),{loadConfig:s}=await import("./chunk-s0crnpyx.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-864qtx7y.js"),{loadConfig:s}=await import("./chunk-vmzkbdmp.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 Cr(".",{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 Cr(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 te.timeAsync("glob-expansion",async()=>Array.fromAsync(new Bun.Glob(t).scan({onlyFiles:!0,absolute:!0}))),s=t.endsWith(".stx")?r.filter((d)=>d.endsWith(".stx")):t.endsWith(".md")?r.filter((d)=>d.endsWith(".md")):r.filter((d)=>d.endsWith(".stx")||d.endsWith(".md"));if(s.length===0)console.error(`No STX or Markdown files found matching pattern: ${t}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),n.exit(1);let c=t.split("*")[0].replace(/\/$/,"")||".",i=f.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((g)=>/\[.+\]/.test(f.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 kr(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 Sr(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 ma(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 _r(".",{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 _r(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 te.timeAsync("glob-expansion",async()=>Array.fromAsync(new Bun.Glob(t).scan({onlyFiles:!0,absolute:!0}))),s=t.endsWith(".stx")?r.filter((d)=>d.endsWith(".stx")):t.endsWith(".md")?r.filter((d)=>d.endsWith(".md")):r.filter((d)=>d.endsWith(".stx")||d.endsWith(".md"));if(s.length===0)console.error(`No STX or Markdown files found matching pattern: ${t}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),n.exit(1);let c=t.split("*")[0].replace(/\/$/,"")||".",i=f.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((g)=>/\[.+\]/.test(f.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 kr(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 Sr(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 ma(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=f.relative(n.cwd(),l);console.log(`
@@ -69,7 +69,7 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
69
69
  File not found: ${t}`),n.exit(1);if(!t.endsWith(".stx"))console.error(`
70
70
  File must have .stx extension: ${t}`),n.exit(1)}let r=f.resolve(e.pages),s=f.resolve(e.out);if(!t&&!S.existsSync(r))console.error(`
71
71
  Pages directory not found: ${r}`),console.log(`
72
- Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-dxjc11hx.js");Kt();let i=await c({root:t?f.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(i.mode==="ssr"&&i.ssr)console.log(`
72
+ Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-kpycf9tz.js");Kt();let i=await c({root:t?f.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(i.mode==="ssr"&&i.ssr)console.log(`
73
73
  Build complete! (SSR)
74
74
  `),console.log(` Pages compiled: ${i.ssr.pageCount}`),console.log(` Output: ${i.ssr.outputDir}`),console.log(` Duration: ${l}s
75
75
  `);else if(i.ssg){if(console.log(`
@@ -84,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=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-etw04j02.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-a2a74f6c.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${$e}\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=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-9q23eed0.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-c9k40352.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${$e}\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-qygynhzc.js"),c=await import("fs"),i=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${$e}\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-w2zceynt.js"),c=await import("fs"),i=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${$e}\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(`
@@ -124,7 +124,7 @@ To view it in the development server:`),console.log(` stx dev ${t}
124
124
  \uD83D\uDCDD ${f.relative(n.cwd(),a)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${f.basename(a)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(a,b),console.log(`\u2705 Formatted ${f.relative(n.cwd(),a)}`),l++}catch(u){console.error(`\u274C Error formatting ${f.relative(n.cwd(),a)}:`,u),d++}if(e.check&&d>0)console.log(`
125
125
  ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.check&&!e.diff)console.log(`\u2728 Formatted ${l} files successfully`)}catch(o){console.error("Error formatting files:",o),n.exit(1)}}),y.command("perf [command...]","Show performance statistics for STX operations").option("--clear","Clear performance statistics").option("--json","Output as JSON").example("stx perf").example("stx perf --clear").example("stx perf --json").action(async(t,e)=>{try{if(e.clear){te.clear(),console.log("\u2705 Performance statistics cleared");return}let o=te.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-17srvghf.js"),{resolveStxTargets:s}=await import("./chunk-52gp2xxk.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-dknd9nhz.js"),{resolveStxTargets:s}=await import("./chunk-52gp2xxk.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=di(n.argv,"--lib"),a=d.length>0?d:e.lib?Array.isArray(e.lib)?e.lib:[e.lib]:[],u=await r(l,{client:e.client!==!1,server:e.server!==!1,templates:e.templates!==!1,extraLibs:a});if(u.failure)console.error(`
130
130
  Type-check did not run.
@@ -136,7 +136,7 @@ ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.chec
136
136
  ${o(u.diagnostics)}
137
137
  `);if(console.log(` Checked ${u.blockCount} script block(s) and ${u.expressionCount} template expression(s) in ${u.checkedFiles.length} file(s) \u2014 `+`${g.length} error(s), ${u.diagnostics.length-g.length} warning(s)
138
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-vmwdt8fr.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(f.resolve(n.cwd(),w))}catch{}for(let b of i)for await(let w of new s(b).scan({cwd:n.cwd(),absolute:!0})){if(w.includes("/node_modules/")||w.includes("/dist/")||d.has(w)||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-c9b0cme2.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await Ps({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(Is(o));if(!o.ok)n.exit(1)}catch(e){console.error("Error running doctor:",e),n.exit(1)}}),y.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(t,e)=>{try{let o=A(t);if(!o.isValid)F(o);console.log(`\uD83D\uDD0D Debugging stx template: ${t}
139
+ ${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime resolution + staleness chain").option("--json","Output the report as JSON").example("stx doctor").example("stx doctor --json").action(async(t)=>{try{let e;try{let r=await import("./chunk-eecgcj41.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await Ps({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(Is(o));if(!o.ok)n.exit(1)}catch(e){console.error("Error running doctor:",e),n.exit(1)}}),y.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(t,e)=>{try{let o=A(t);if(!o.isValid)F(o);console.log(`\uD83D\uDD0D Debugging stx template: ${t}
140
140
  `);let r={};if(e.context)try{r=JSON.parse(e.context)}catch(i){console.error("\u274C Invalid JSON in --context option"),n.exit(1)}let s=await Bun.file(t).text();console.log(`\uD83D\uDCC4 Template Content (${s.length} chars):`),console.log("\u2500".repeat(50)),console.log(s.substring(0,500)+(s.length>500?`
141
141
  ...
142
142
  `:"")),console.log("\u2500".repeat(50));let c=s.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(c)console.log(`
@@ -160,11 +160,11 @@ Press Ctrl+C to stop watching...
160
160
  \uD83D\uDCC4 Files with issues:`),d.forEach((a)=>{let u=a.issues.filter((g)=>s[g.type]>=c).length;if(u>0)console.log(` ${f.relative(n.cwd(),a.file)} (${u} issues)`)});if(e.saveReport){let a={summary:l,results:d,generatedAt:new Date().toISOString(),commandOptions:e};await Bun.write(e.saveReport,JSON.stringify(a,null,2)),console.log(`
161
161
  \uD83D\uDCCB Analysis report saved to: ${e.saveReport}`)}console.log(`
162
162
  \u2728 Analysis complete! Use --detailed for more information.`)}catch(o){console.error("Error analyzing templates:",o),n.exit(1)}}),y.command("screenshot [input]","Capture PNG screenshot(s) of page(s) via Bun WebView \u2014 a file, URL, or dist directory").option("--out <dir>","Output directory",{default:"screenshots"}).option("--width <px>","Viewport width",{default:"1440"}).option("--height <px>","Viewport height",{default:"2200"}).option("--wait <ms>","Settle time after navigation before capture",{default:"800"}).option("--timeout <ms>","Hard cap on waiting for navigation",{default:"15000"}).option("--full-page","Capture the entire scrollable page, not just the viewport").option("--wait-selector <sel>","Wait until a CSS selector exists before capturing").option("--format <fmt>","Image format: png | jpeg | webp",{default:"png"}).option("--backend <name>","WebView backend: webkit (macOS, default) | chrome").action(async(t,e)=>{let{captureScreenshots:o}=await import("./chunk-jk41jwsc.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($e)}),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-73swyb5p.js"),o={};if(t.context){let r=f.resolve(t.context);if(S.existsSync(r))try{let s=S.readFileSync(r,"utf-8");o=JSON.parse(s)}catch(s){console.error("Error loading context file:",s),n.exit(1)}else console.error(`Context file not found: ${r}`),n.exit(1)}await e({context:o,cwd:t.cwd?f.resolve(t.cwd):n.cwd(),verbose:t.verbose})}),y.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(t,e)=>{try{let{buildNative:o,getAvailableTargets:r,getAvailableFormats:s}=await import("./chunk-fnj3gja0.js"),c=f.resolve(t);if(!S.existsSync(c))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let i=r();if(e.target&&!["macos","windows","linux","ios","android"].includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${i.join(", ")}`),n.exit(1);let l=e.target||i[0],d=s(l);if(e.format&&!d.includes(e.format))console.error(`\u274C Invalid format for ${l}: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${d.join(", ")}`),n.exit(1);console.log(`
163
+ \u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log($e)}),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-xesyd9nx.js"),o={};if(t.context){let r=f.resolve(t.context);if(S.existsSync(r))try{let s=S.readFileSync(r,"utf-8");o=JSON.parse(s)}catch(s){console.error("Error loading context file:",s),n.exit(1)}else console.error(`Context file not found: ${r}`),n.exit(1)}await e({context:o,cwd:t.cwd?f.resolve(t.cwd):n.cwd(),verbose:t.verbose})}),y.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(t,e)=>{try{let{buildNative:o,getAvailableTargets:r,getAvailableFormats:s}=await import("./chunk-da6qbwqs.js"),c=f.resolve(t);if(!S.existsSync(c))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let i=r();if(e.target&&!["macos","windows","linux","ios","android"].includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${i.join(", ")}`),n.exit(1);let l=e.target||i[0],d=s(l);if(e.format&&!d.includes(e.format))console.error(`\u274C Invalid format for ${l}: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${d.join(", ")}`),n.exit(1);console.log(`
164
164
  \uD83D\uDD28 Building native app...`),console.log(` Input: ${t}`),console.log(` Target: ${l}`),console.log(` Format: ${e.format||"default"}`),console.log(` Output: ${e.output}
165
165
  `);let a=await o({input:c,output:f.resolve(e.output),target:l,format:e.format,name:e.name,version:e.version,description:e.description,author:e.author,bundleId:e.bundleId,icon:e.icon?f.resolve(e.icon):void 0,window:{title:e.title,width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),frameless:e.frameless,alwaysOnTop:e.alwaysOnTop},systemTray:e.systemTray,menubarOnly:e.menubarOnly,category:e.category,copyright:e.copyright,minimumSystemVersion:e.minSystemVersion,infoPlist:M(e.infoPlist),devTools:e.devTools,craftPath:e.craftPath,verbose:e.verbose});if(a.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${a.outputPath}`),a.duration)console.log(` Duration: ${(a.duration/1000).toFixed(2)}s`);if(l==="macos"&&a.format==="app")console.log(`
166
166
  \uD83D\uDCA1 To run: open "${a.outputPath}"`);else if(l==="linux"&&a.format==="appimage")console.log(`
167
- \uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-1zb7ar32.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-mrrrngzd.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-t6yjxhn8.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-6raq8r7w.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-t7j4h3nf.js"),s=await r(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(r){console.error(r instanceof Error?r.message:String(r)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-g2jmwh7p.js"),r=f.resolve(t);if(!S.existsSync(r))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
167
+ \uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-zaj65qc1.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-mrrrngzd.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-t6yjxhn8.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-yr34z9ey.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-ajjcp56c.js"),s=await r(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(r){console.error(r instanceof Error?r.message:String(r)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-g2jmwh7p.js"),r=f.resolve(t);if(!S.existsSync(r))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
168
168
  \uD83D\uDD27 Compiling stx template to native code...`),console.log(` Input: ${t}`),console.log(` Target: ${e.target}`),console.log(` Format: ${e.format}`),console.log(` Output: ${e.output}
169
169
  `);let i=S.readFileSync(r,"utf-8"),l=await o(i,{target:e.target,format:e.format,optimize:e.optimize,treeShake:e.treeShake,hotReload:e.hotReload,debug:e.verbose,sourceMaps:e.sourcemaps,bundle:e.bundle,minify:e.minify}),d=f.resolve(e.output);if(!S.existsSync(d))S.mkdirSync(d,{recursive:!0});let a=f.basename(t,f.extname(t)),u=e.format==="typescript"?"ts":e.format==="json"?"json":"zig",g=f.join(d,`${a}.${u}`);S.writeFileSync(g,l.code);let b=f.join(d,`${a}.manifest.json`);if(S.writeFileSync(b,JSON.stringify(l.manifest,null,2)),e.sourcemaps&&l.sourceMaps){let w=f.join(d,`${a}.${u}.map`);S.writeFileSync(w,l.sourceMaps)}if(e.target==="universal"&&l.platformCode.size>0)for(let[w,k]of l.platformCode){let v=f.join(d,`${a}.${w}.${u}`);S.writeFileSync(v,k)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${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(`
@@ -23,7 +23,7 @@ export const SIGNALS_DOM_READY_RUNTIME = ` // =================================
23
23
  .some(el => el.getAttribute('data-stx') === latestSetupName);
24
24
  if (latestSetup && !hasLatestSetupMarker) {
25
25
  try {
26
- const result = latestSetup();
26
+ const result = runPageSetup(latestSetup);
27
27
  if (typeof result === 'object' && result !== null)
28
28
  assignTemplateScope(componentScope, result);
29
29
  }
@@ -45,7 +45,7 @@ export const SIGNALS_DOM_READY_RUNTIME = ` // =================================
45
45
  // page unhydrated \u2014 the user sees raw {{ }}, and the console names the
46
46
  // identifier without saying it cost them the document (#1805).
47
47
  try {
48
- const result = window[setupName]();
48
+ const result = runPageSetup(window[setupName]);
49
49
  console.log('[DOMContentLoaded] setup returned:', result ? Object.keys(result).slice(0, 10) : 'null');
50
50
  if (typeof result === 'object' && result !== null) {
51
51
  assignTemplateScope(componentScope, result);
@@ -83,26 +83,39 @@ export const SIGNALS_EFFECT_RUNTIME = ` // ====================================
83
83
  // Effect Tracking
84
84
  // ==========================================================================
85
85
 
86
- function trackEffects(fn) {
86
+ // Collect the effects made from now until the returned end() is called, which
87
+ // hands back one disposer for all of them. trackEffects for code that cannot
88
+ // be passed as a callback: a component's setup script is its own block, and
89
+ // opens and closes the collection around its body.
90
+ function beginEffects() {
87
91
  var parentDisposers = activeDisposers;
88
92
  var disposers = [];
89
93
  activeDisposers = disposers;
90
- try {
91
- fn();
92
- }
93
- finally {
94
+ return function endEffects() {
94
95
  activeDisposers = parentDisposers;
95
96
  if (parentDisposers) {
96
97
  disposers.forEach(function(d) { parentDisposers.push(d); });
97
98
  }
98
- }
99
- return function disposeAll() {
100
- disposers.forEach(function(d) { try { d(); }
99
+ return function disposeAll() {
100
+ disposers.forEach(function(d) { try { d(); }
101
101
  catch (e) { console.warn('[stx] dispose error:', e); } });
102
- disposers.length = 0;
102
+ disposers.length = 0;
103
+ };
103
104
  };
104
105
  }
105
106
 
107
+ function trackEffects(fn) {
108
+ var endEffects = beginEffects();
109
+ var disposeAll;
110
+ try {
111
+ fn();
112
+ }
113
+ finally {
114
+ disposeAll = endEffects();
115
+ }
116
+ return disposeAll;
117
+ }
118
+
106
119
  // ==========================================================================
107
120
  // Batch
108
121
  // ==========================================================================
@@ -108,6 +108,21 @@ export const SIGNALS_LIFECYCLE_RUNTIME = ` // =================================
108
108
  return scopeVars.__destroyCallbacks;
109
109
  }
110
110
 
111
+ // Run a page's setup with its effects collected, and queue their disposal
112
+ // with the page-level onDestroy callbacks, so they end when the page does:
113
+ // on the next swap, or with a retained screen when the router disposes it.
114
+ // Untracked, an effect a page script made (on a store, typically) kept
115
+ // running after the router had swapped its page out.
116
+ function runPageSetup(setup) {
117
+ var endEffects = beginEffects();
118
+ try {
119
+ return setup();
120
+ }
121
+ finally {
122
+ destroyCallbacks.push(endEffects());
123
+ }
124
+ }
125
+
111
126
  // Drain any early mount/destroy calls captured by the pre-initialization shim
112
127
  if (window.__stx_early_mounts) { window.__stx_early_mounts.forEach(function(fn) { mountCallbacks.push(fn); }); window.__stx_early_mounts = null; }
113
128
  if (window.__stx_early_destroys) { window.__stx_early_destroys.forEach(function(fn) { destroyCallbacks.push(fn); }); window.__stx_early_destroys = null; }
@@ -63,8 +63,14 @@ export const SIGNALS_MANIFEST_HYDRATION_RUNTIME = ` /**
63
63
  var outerSink = activeDestroySink;
64
64
  activeDestroySink = null;
65
65
  var values;
66
+ // The setup's own effects end with the host, as its bindings do.
67
+ var endSetupEffects = beginEffects();
68
+ var disposeSetupEffects;
66
69
  try { values = typeof setup === 'function' ? setup() : setup; }
67
- finally { activeDestroySink = outerSink; }
70
+ finally {
71
+ activeDestroySink = outerSink;
72
+ disposeSetupEffects = endSetupEffects();
73
+ }
68
74
  var localMountHooks = mountCallbacks.splice(mountStart);
69
75
  var localDestroyHooks = destroyCallbacks.splice(destroyStart);
70
76
  var scope = mergeTemplateScopes({ $refs: {} }, values);
@@ -90,6 +96,7 @@ export const SIGNALS_MANIFEST_HYDRATION_RUNTIME = ` /**
90
96
  if (!mounted) return;
91
97
  mounted = false;
92
98
  disposeEffects();
99
+ disposeSetupEffects();
93
100
  disposeSubtreeEffects(root);
94
101
  disposeSubtreeScopes(root);
95
102
  var hooks = localDestroyHooks.splice(0, localDestroyHooks.length);
@@ -18,8 +18,14 @@ export const SIGNALS_MOUNT_RUNTIME = ` mountEl: function(selector, setupFn) {
18
18
  var outerSink = activeDestroySink;
19
19
  activeDestroySink = null;
20
20
  var scope;
21
+ // Its effects too: they go with the root's bindings (__stx_disposers).
22
+ var endSetupEffects = beginEffects();
23
+ var disposeSetupEffects;
21
24
  try { scope = setupFn(); }
22
- finally { activeDestroySink = outerSink; }
25
+ finally {
26
+ activeDestroySink = outerSink;
27
+ disposeSetupEffects = endSetupEffects();
28
+ }
23
29
 
24
30
  // Restore previous context (supports nested components)
25
31
  window.__STX_CURRENT_PROPS__ = prevProps;
@@ -37,7 +43,7 @@ export const SIGNALS_MOUNT_RUNTIME = ` mountEl: function(selector, setupFn) {
37
43
  var disposeEffects = trackEffects(function() {
38
44
  processElement(root, mergeTemplateScopes(componentScope, (scope || {})));
39
45
  });
40
- root.__stx_disposers = disposeEffects;
46
+ root.__stx_disposers = function() { disposeEffects(); disposeSetupEffects(); };
41
47
 
42
48
  root.removeAttribute('x-cloak');
43
49
  root.querySelectorAll('[x-cloak]').forEach(function(el) { el.removeAttribute('x-cloak'); });
@@ -181,8 +187,14 @@ else {
181
187
  var outerSink = activeDestroySink;
182
188
  activeDestroySink = null;
183
189
  var scope;
190
+ // Its effects too: they go with the root's bindings (__stx_disposers).
191
+ var endSetupEffects = beginEffects();
192
+ var disposeSetupEffects;
184
193
  try { scope = setupFn(); }
185
- finally { activeDestroySink = outerSink; }
194
+ finally {
195
+ activeDestroySink = outerSink;
196
+ disposeSetupEffects = endSetupEffects();
197
+ }
186
198
  console.log('[mount] root:', root.tagName, 'scope keys:', scope ? Object.keys(scope).slice(0, 10) : 'null');
187
199
 
188
200
  // Restore previous context (supports nested components)
@@ -209,7 +221,7 @@ else {
209
221
  var disposeEffects = trackEffects(function() {
210
222
  processElement(root, mergeTemplateScopes(componentScope, (scope || {})));
211
223
  });
212
- root.__stx_disposers = disposeEffects;
224
+ root.__stx_disposers = function() { disposeEffects(); disposeSetupEffects(); };
213
225
 
214
226
  // Remove x-cloak after bindings are applied (prevents FOUC)
215
227
  root.removeAttribute('x-cloak');
@@ -116,6 +116,7 @@ ${componentApiRuntime}
116
116
  _cleanupContainer: cleanupContainer,
117
117
  _flushLoad: flushStxLoad,
118
118
  _beginSwap: beginSwap,
119
+ _beginEffects: beginEffects, // A component setup collects its effects (utils.ts)
119
120
  _registerSuspense: registerSuspense, // <Suspense> query registration (#1742)
120
121
  _tg: { enter: tgEnter, leave: tgLeave, flip: tgFlip, snapshot: tgSnapshot }, // <TransitionGroup> helpers (#1742)
121
122
  _scopes: {}, // Component-level scopes
@@ -114,6 +114,18 @@ export const SIGNALS_SCOPE_DISPOSAL_RUNTIME = ` // ============================
114
114
  }
115
115
  }
116
116
 
117
+ // The effects a scope's setup script made, collected by the script itself
118
+ // (beginEffects). They go when the scope goes for good, not when an :if
119
+ // hides it: the setup does not run again on a re-show, so they would not
120
+ // come back.
121
+ function disposeScopeEffects(scopeVars) {
122
+ var dispose = scopeVars.__disposeEffects;
123
+ if (typeof dispose !== 'function') return;
124
+ scopeVars.__disposeEffects = null;
125
+ try { dispose(); }
126
+ catch (e) { console.warn('[stx] scope effect dispose error:', e); }
127
+ }
128
+
117
129
  function disposeSubtreeScopes(root) {
118
130
  if (!root || !window.stx || !window.stx._scopes) return;
119
131
  // The host reports which scopes live in this subtree: the document finds
@@ -136,6 +148,7 @@ export const SIGNALS_SCOPE_DISPOSAL_RUNTIME = ` // ============================
136
148
  catch (e) { console.warn('[stx] scope destroy error:', e); }
137
149
  }
138
150
  }
151
+ disposeScopeEffects(scopeVars);
139
152
  delete window.stx._scopes[scopeId];
140
153
  }
141
154
  }
@@ -189,6 +202,7 @@ export const SIGNALS_SCOPE_DISPOSAL_RUNTIME = ` // ============================
189
202
  catch (e) { console.warn('[stx] scope destroy error:', e); }
190
203
  }
191
204
  }
205
+ disposeScopeEffects(entry);
192
206
  delete scopes[id];
193
207
  }
194
208
  }
@@ -26,7 +26,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
26
26
  var usedLatestSetup = false;
27
27
  if (window.stx._latestSetup && typeof window.stx._latestSetup === 'function') {
28
28
  try {
29
- var setupResult = window.stx._latestSetup();
29
+ var setupResult = runPageSetup(window.stx._latestSetup);
30
30
  // Keep _latestSetup for re-fires (HMR, auto-refresh re-navigation)
31
31
  // It will be overwritten when a NEW page's script sets it
32
32
  usedLatestSetup = true;
@@ -47,7 +47,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
47
47
  document.querySelectorAll('[data-stx]').forEach(function(el) {
48
48
  var setupName = el.getAttribute('data-stx');
49
49
  if (setupName && window[setupName]) {
50
- var result = window[setupName]();
50
+ var result = runPageSetup(window[setupName]);
51
51
  if (typeof result === 'object') assignTemplateScope(componentScope, result);
52
52
  }
53
53
  });
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ws,qi,Gi}from"./chunk-120ze5ms.js";import"./chunk-4e0z858k.js";import"./chunk-4qwvqbzf.js";import"./chunk-ce6zddpf.js";import"./chunk-2yg9y1na.js";import"./chunk-2h8ea0we.js";import"./chunk-35zjpdcb.js";import"./chunk-a3d0g4mr.js";import"./chunk-qrt8b179.js";import"./chunk-3v8yejzc.js";import"./chunk-h09a03ay.js";import"./chunk-04kg16qs.js";import"./chunk-xhmpfq9d.js";import"./chunk-ff1cb7k4.js";import"./chunk-g7j3mwzd.js";import"./chunk-929zbzh7.js";import"./chunk-ewng6v6g.js";import"./chunk-36649w15.js";import"./chunk-k7nan28e.js";import"./chunk-prf164ct.js";import"./chunk-c1dkh0es.js";import{Xd,ji,Jd,Yd,Bi,Us,Fi,Zd,zi,Qd,ep,Hi,Vi,Ui,Wi}from"./chunk-71mthavp.js";import"./chunk-ktvr9ta8.js";import"./chunk-8gewq710.js";import"./chunk-n7xbhzzt.js";import"./chunk-wh838rdh.js";import"./chunk-26whq1rg.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{Ws,qi,Gi}from"./chunk-120ze5ms.js";import"./chunk-hb08vrbb.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import"./chunk-hzjvpcmj.js";import"./chunk-2h8ea0we.js";import"./chunk-jf17b7y9.js";import"./chunk-a3d0g4mr.js";import"./chunk-zaaeneq6.js";import"./chunk-2h92dm3t.js";import"./chunk-t9mfztcs.js";import"./chunk-04kg16qs.js";import"./chunk-v3kc2anv.js";import"./chunk-0gqmp9sa.js";import"./chunk-889evdcy.js";import"./chunk-rccpf74y.js";import"./chunk-wp0jtntj.js";import"./chunk-sdknbvh8.js";import"./chunk-31yb0253.js";import"./chunk-prf164ct.js";import"./chunk-c1dkh0es.js";import{Xd,ji,Jd,Yd,Bi,Us,Fi,Zd,zi,Qd,ep,Hi,Vi,Ui,Wi}from"./chunk-jvv9p6v6.js";import"./chunk-x5777qkq.js";import"./chunk-r7kmsq3n.js";import"./chunk-teahew39.js";import"./chunk-8nryyqb5.js";import"./chunk-e7z85137.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{Ws,qi,Gi}from"./chunk-120ze5ms.js";import"./chunk-4e0z858k.js";import"./chunk-4qwvqbzf.js";import"./chunk-ce6zddpf.js";import"./chunk-2yg9y1na.js";import"./chunk-2h8ea0we.js";import"./chunk-35zjpdcb.js";import"./chunk-a3d0g4mr.js";import"./chunk-qrt8b179.js";import"./chunk-3v8yejzc.js";import"./chunk-h09a03ay.js";import"./chunk-04kg16qs.js";import"./chunk-xhmpfq9d.js";import"./chunk-ff1cb7k4.js";import"./chunk-g7j3mwzd.js";import"./chunk-929zbzh7.js";import"./chunk-ewng6v6g.js";import"./chunk-36649w15.js";import"./chunk-k7nan28e.js";import"./chunk-prf164ct.js";import"./chunk-c1dkh0es.js";import{Xd,ji,Jd,Yd,Bi,Us,Fi,Zd,zi,Qd,ep,Hi,Vi,Ui,Wi}from"./chunk-71mthavp.js";import"./chunk-ktvr9ta8.js";import"./chunk-8gewq710.js";import"./chunk-n7xbhzzt.js";import"./chunk-wh838rdh.js";import"./chunk-26whq1rg.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{Ws,qi,Gi}from"./chunk-120ze5ms.js";import"./chunk-hb08vrbb.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import"./chunk-hzjvpcmj.js";import"./chunk-2h8ea0we.js";import"./chunk-jf17b7y9.js";import"./chunk-a3d0g4mr.js";import"./chunk-zaaeneq6.js";import"./chunk-2h92dm3t.js";import"./chunk-t9mfztcs.js";import"./chunk-04kg16qs.js";import"./chunk-v3kc2anv.js";import"./chunk-0gqmp9sa.js";import"./chunk-889evdcy.js";import"./chunk-rccpf74y.js";import"./chunk-wp0jtntj.js";import"./chunk-sdknbvh8.js";import"./chunk-31yb0253.js";import"./chunk-prf164ct.js";import"./chunk-c1dkh0es.js";import{Xd,ji,Jd,Yd,Bi,Us,Fi,Zd,zi,Qd,ep,Hi,Vi,Ui,Wi}from"./chunk-jvv9p6v6.js";import"./chunk-x5777qkq.js";import"./chunk-r7kmsq3n.js";import"./chunk-teahew39.js";import"./chunk-8nryyqb5.js";import"./chunk-e7z85137.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/includes.js CHANGED
@@ -232,8 +232,17 @@ function wrapScopedInclude(body, scopeId) {
232
232
  if (!window.stx._scopes) window.stx._scopes = {};
233
233
  window.stx._scopes['${scopeId}'] = {};
234
234
  }
235
+ var __stxEndEffects = (typeof window !== 'undefined' && window.stx && window.stx._beginEffects) ? window.stx._beginEffects() : null;
235
236
  try {`, foot = `
236
237
  } finally {
238
+ // The body's effects end where its onDestroy callbacks run: with the scope
239
+ // when the partial has a root, with the page when it has none.
240
+ if (__stxEndEffects) {
241
+ var __stxDisposeEffects = __stxEndEffects();
242
+ var __stxRegistered = __stxScopeEl && window.stx._scopes && window.stx._scopes['${scopeId}'];
243
+ if (__stxRegistered) __stxRegistered.__disposeEffects = __stxDisposeEffects;
244
+ else if (window.stx._destroyCallbacks) window.stx._destroyCallbacks.push(__stxDisposeEffects);
245
+ }
237
246
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
238
247
  }
239
248
  })();`;
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Es,jt,bc,gu}from"./chunk-mgj34bbg.js";import{_s,Xo,du,pu,fu}from"./chunk-nttspz8c.js";import{mc,hc,yc,lu,uu}from"./chunk-wpmrz872.js";import{Fe,wn,Jo}from"./chunk-wpm58d6p.js";import{mu,hu,yu,bu,Ts,qp}from"./chunk-qv6axke4.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-fsnby15p.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{Es,jt,bc,gu}from"./chunk-yh0wb4n1.js";import{Cs,Xo,du,pu,fu}from"./chunk-xv43szx0.js";import{mc,hc,yc,lu,uu}from"./chunk-wpmrz872.js";import{Fe,wn,Jo}from"./chunk-wpm58d6p.js";import{mu,hu,yu,bu,Ts,qp}from"./chunk-qv6axke4.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-j2hkxwjy.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=Fe(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Es(n,t);if(a){let s=jt(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 Xo(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,hc as auditBuildOutput,mc as auditConfig,re as buildPwaAssets,yc as calculateAuditResult,uu as formatAuditResult,Jo as formatSize,j as generateManifest,_ as generateManifestJson,pu as generateManifestLink,F as generateOfflinePage,Fe as generatePrecacheManifest,wn as generatePrecacheManifestJs,M as generatePwaIcons,_s as generatePwaTags,Es as generateServiceWorker,gu as generateServiceWorkerAuto,du as generateSwRegistrationScript,fu as generateThemeColorMeta,N as getExpectedIconPaths,jt as getServiceWorkerFileName,Xo as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,bc as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Ts as pwaDirectives,mu as pwaInstallDirective,yu as pwaOfflineDirective,bu as pwaPushDirective,hu as pwaUpdateDirective,qp as registerPwaDirectives,lu 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=Fe(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Es(n,t);if(a){let s=jt(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 Xo(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,hc as auditBuildOutput,mc as auditConfig,re as buildPwaAssets,yc as calculateAuditResult,uu as formatAuditResult,Jo as formatSize,j as generateManifest,_ as generateManifestJson,pu as generateManifestLink,F as generateOfflinePage,Fe as generatePrecacheManifest,wn as generatePrecacheManifestJs,M as generatePwaIcons,Cs as generatePwaTags,Es as generateServiceWorker,gu as generateServiceWorkerAuto,du as generateSwRegistrationScript,fu as generateThemeColorMeta,N as getExpectedIconPaths,jt as getServiceWorkerFileName,Xo as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,bc as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Ts as pwaDirectives,mu as pwaInstallDirective,yu as pwaOfflineDirective,bu as pwaPushDirective,hu as pwaUpdateDirective,qp as registerPwaDirectives,lu as runPwaAudit,D as validateManifest};