@stacksjs/stx 0.2.859 → 0.2.861

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 (208) hide show
  1. package/dist/body-close.d.ts +13 -0
  2. package/dist/body-close.js +8 -0
  3. package/dist/{chunk-5va6c7jf.js → chunk-02css3vk.js} +5 -5
  4. package/dist/chunk-0hqr6bff.js +2 -0
  5. package/dist/{chunk-astcp7bc.js → chunk-121cgm3s.js} +4 -4
  6. package/dist/{chunk-xytq7q8j.js → chunk-15jymk6t.js} +2 -2
  7. package/dist/{chunk-gq9h36jf.js → chunk-15rkvc0t.js} +4 -4
  8. package/dist/chunk-15sgdvyd.js +2 -0
  9. package/dist/{chunk-fkh4xece.js → chunk-1jwcp2k0.js} +2 -2
  10. package/dist/{chunk-b1kc0ka1.js → chunk-261t62q4.js} +38 -38
  11. package/dist/chunk-2b4a8tbd.js +3 -0
  12. package/dist/chunk-2fw36w1x.js +2 -0
  13. package/dist/chunk-2jcxsw75.js +2 -0
  14. package/dist/{chunk-t2nhr2tc.js → chunk-2pbhdaka.js} +1 -1
  15. package/dist/chunk-2wba5ypm.js +2 -0
  16. package/dist/chunk-353gnvfe.js +2 -0
  17. package/dist/{chunk-14h4n1sj.js → chunk-36vksrry.js} +2 -2
  18. package/dist/{chunk-0es47pwe.js → chunk-37tefp7s.js} +5 -5
  19. package/dist/{chunk-ktnb1j54.js → chunk-38qp2pg2.js} +2 -2
  20. package/dist/chunk-3cr5y8v1.js +2 -0
  21. package/dist/{chunk-g17q4y5k.js → chunk-3gfd9t8a.js} +2 -2
  22. package/dist/{chunk-ts4t2n6b.js → chunk-3wg9kr5z.js} +4 -4
  23. package/dist/chunk-3y7yp0ka.js +2 -0
  24. package/dist/chunk-41wwqw0q.js +2 -0
  25. package/dist/chunk-4a1y51fs.js +2 -0
  26. package/dist/chunk-4a751brg.js +2 -0
  27. package/dist/{chunk-kpsxhm4x.js → chunk-4jgcd4d9.js} +3 -3
  28. package/dist/{chunk-k8pzk8v9.js → chunk-4rrxrxp6.js} +4 -4
  29. package/dist/chunk-5awhm4na.js +2 -0
  30. package/dist/chunk-5fhp9hxd.js +2 -0
  31. package/dist/{chunk-ywk6t76q.js → chunk-5ka3h8dy.js} +6 -6
  32. package/dist/chunk-5mg443dw.js +2 -0
  33. package/dist/{chunk-9qe4qsc7.js → chunk-5neezkj1.js} +4 -4
  34. package/dist/{chunk-6w5a5ns4.js → chunk-5q4tncfw.js} +5 -5
  35. package/dist/chunk-5x9ajbq0.js +2 -0
  36. package/dist/{chunk-gndxakrh.js → chunk-5xdkmn39.js} +2 -2
  37. package/dist/{chunk-3w3fxcyx.js → chunk-65cbfx5x.js} +2 -2
  38. package/dist/{chunk-hf9pvmq2.js → chunk-68w65mhs.js} +3 -3
  39. package/dist/chunk-6g7tkmty.js +2 -0
  40. package/dist/{chunk-wfd9e224.js → chunk-6nb49h13.js} +9 -9
  41. package/dist/{chunk-6t0xy3wk.js → chunk-6tp0w6hf.js} +2 -2
  42. package/dist/chunk-72bj7ea4.js +2 -0
  43. package/dist/{chunk-tc31my2p.js → chunk-74g64pzt.js} +4 -4
  44. package/dist/{chunk-0yw86e75.js → chunk-76360zky.js} +5 -5
  45. package/dist/{chunk-wdcz6d20.js → chunk-7bajrfb1.js} +2 -2
  46. package/dist/{chunk-2kc0vsnb.js → chunk-7de5y29a.js} +5 -5
  47. package/dist/{chunk-cj9rev2p.js → chunk-7yhhwv07.js} +2 -2
  48. package/dist/chunk-811hh6vp.js +2 -0
  49. package/dist/{chunk-9nh48zvm.js → chunk-830ej8d2.js} +9 -9
  50. package/dist/chunk-8fkmxrat.js +2 -0
  51. package/dist/{chunk-dbm963p9.js → chunk-8hck9qqm.js} +4 -4
  52. package/dist/chunk-8p9npc8y.js +2 -0
  53. package/dist/chunk-9fz3h6sx.js +2 -0
  54. package/dist/chunk-9jr30fns.js +2 -0
  55. package/dist/{chunk-2sq9pdg3.js → chunk-9pyvc0dc.js} +2 -2
  56. package/dist/{chunk-4yfbd8ny.js → chunk-9syvkm5z.js} +6 -6
  57. package/dist/{chunk-a9c3gndq.js → chunk-a6d92kv6.js} +2 -2
  58. package/dist/chunk-a9m6ajd7.js +2 -0
  59. package/dist/{chunk-403a4pqm.js → chunk-aj6vqdf7.js} +3 -3
  60. package/dist/chunk-asr5v51s.js +2 -0
  61. package/dist/{chunk-v9h7s8ce.js → chunk-avp271q4.js} +1 -1
  62. package/dist/{chunk-3248qphb.js → chunk-b1tctqn5.js} +6 -6
  63. package/dist/{chunk-8mdhencj.js → chunk-b7nmgkwa.js} +3 -3
  64. package/dist/{chunk-6e44f8w8.js → chunk-bag9q4m0.js} +30 -30
  65. package/dist/{chunk-7m17m22p.js → chunk-bg0ywp5w.js} +2 -2
  66. package/dist/{chunk-aq8r4rbs.js → chunk-bv14vry8.js} +2 -2
  67. package/dist/chunk-byx82s10.js +2 -0
  68. package/dist/{chunk-q3cyycnh.js → chunk-c2w4wc9f.js} +1 -1
  69. package/dist/chunk-c9y1g61m.js +2 -0
  70. package/dist/chunk-ck5nzbbv.js +2 -0
  71. package/dist/{chunk-yd6ej23e.js → chunk-cq2hedwn.js} +5 -5
  72. package/dist/chunk-cvdm0hgq.js +2 -0
  73. package/dist/{chunk-6mza6zr3.js → chunk-d6216bcw.js} +3 -3
  74. package/dist/{chunk-s4592dy0.js → chunk-dba4bwkd.js} +6 -6
  75. package/dist/{chunk-rgjjt1mb.js → chunk-dt73ww6m.js} +1 -1
  76. package/dist/chunk-e0fxgbcc.js +2 -0
  77. package/dist/{chunk-49j3cn9h.js → chunk-e8nzbz66.js} +2 -2
  78. package/dist/chunk-ed2m6pjf.js +2 -0
  79. package/dist/chunk-ednwdhv0.js +2 -0
  80. package/dist/chunk-egtphftq.js +2 -0
  81. package/dist/{chunk-2w7csg0c.js → chunk-eye156nv.js} +1 -1
  82. package/dist/chunk-fahqq7c4.js +2 -0
  83. package/dist/chunk-fcbpzdyz.js +2 -0
  84. package/dist/{chunk-x9c4njvx.js → chunk-fyfvqd2s.js} +2 -2
  85. package/dist/{chunk-1v95w26e.js → chunk-gc79s0wh.js} +9 -9
  86. package/dist/{chunk-9a3rv0rj.js → chunk-gggadrs4.js} +2 -2
  87. package/dist/{chunk-vj1bwnvs.js → chunk-gjnrmz2q.js} +2 -2
  88. package/dist/{chunk-w1d8t47c.js → chunk-gp1dt8b8.js} +3 -3
  89. package/dist/{chunk-5t1k0dxm.js → chunk-gx96hctv.js} +2 -2
  90. package/dist/chunk-h0dsxxz4.js +2 -0
  91. package/dist/{chunk-1hebvmaj.js → chunk-h2cvfp9y.js} +1 -1
  92. package/dist/{chunk-ews9yzr7.js → chunk-h4aqpf2r.js} +3 -3
  93. package/dist/{chunk-52b6czss.js → chunk-hyea17hp.js} +69 -69
  94. package/dist/chunk-k3yym9zg.js +2 -0
  95. package/dist/chunk-k9fsd6t3.js +2 -0
  96. package/dist/chunk-kepxsjfx.js +2 -0
  97. package/dist/chunk-kh01rvag.js +2 -0
  98. package/dist/{chunk-qd87dk1d.js → chunk-kv40xq53.js} +14 -14
  99. package/dist/{chunk-m1qqqc2j.js → chunk-m3p4hksq.js} +2 -2
  100. package/dist/chunk-mad172af.js +2 -0
  101. package/dist/{chunk-kvc9cwvx.js → chunk-mjkdskeg.js} +1 -1
  102. package/dist/{chunk-wjamjgx6.js → chunk-naj146zq.js} +1 -1
  103. package/dist/chunk-npt0mdzb.js +2 -0
  104. package/dist/{chunk-shke1fcm.js → chunk-nwxjh1gv.js} +3 -3
  105. package/dist/chunk-ptc3yqn3.js +2 -0
  106. package/dist/chunk-pybm7c9p.js +2 -0
  107. package/dist/{chunk-xpg52hsz.js → chunk-q6w7a1vc.js} +3 -3
  108. package/dist/{chunk-26jt4jvh.js → chunk-qjm23ma2.js} +1 -1
  109. package/dist/chunk-qnx71b17.js +2 -0
  110. package/dist/chunk-qx8cav4w.js +2 -0
  111. package/dist/chunk-rb7cwck6.js +2 -0
  112. package/dist/chunk-s1e0t3hv.js +2 -0
  113. package/dist/chunk-s7vfmasx.js +2 -0
  114. package/dist/{chunk-jd4dr23j.js → chunk-scwbttvt.js} +2 -2
  115. package/dist/{chunk-7trdtz0c.js → chunk-sxtvy0sm.js} +2 -2
  116. package/dist/chunk-t7z67vf6.js +2 -0
  117. package/dist/{chunk-qttq8cje.js → chunk-tarvase5.js} +1 -1
  118. package/dist/{chunk-qgxwf9xr.js → chunk-thdnk1kd.js} +3 -3
  119. package/dist/{chunk-ftwdjgzd.js → chunk-tjz3r7rj.js} +5 -5
  120. package/dist/{chunk-yehdcjn1.js → chunk-tm201m9x.js} +2 -2
  121. package/dist/chunk-tqs9pcga.js +2 -0
  122. package/dist/chunk-twjfrywv.js +2 -0
  123. package/dist/{chunk-rwxg4m3h.js → chunk-v0wdgxga.js} +1 -1
  124. package/dist/{chunk-p9jfn4yh.js → chunk-vggtxttf.js} +5 -5
  125. package/dist/chunk-vyna2rsq.js +2 -0
  126. package/dist/chunk-w4gjx2zs.js +18 -0
  127. package/dist/{chunk-v4rrgphj.js → chunk-wrbhq1y2.js} +3 -3
  128. package/dist/{chunk-4a0x737h.js → chunk-x69457q9.js} +4 -4
  129. package/dist/chunk-xhe7pw6e.js +2 -0
  130. package/dist/{chunk-33x46g87.js → chunk-xmy6g81m.js} +1 -1
  131. package/dist/chunk-y86mpnrg.js +2 -0
  132. package/dist/{chunk-ypgegzh2.js → chunk-yj9nyt93.js} +2 -2
  133. package/dist/{chunk-w1stsxm3.js → chunk-z99bf0q0.js} +2 -2
  134. package/dist/chunk-zm0g7ntw.js +2 -0
  135. package/dist/{chunk-618t6hxp.js → chunk-zpkgs5d3.js} +4 -4
  136. package/dist/chunk-zrm2x65c.js +2 -0
  137. package/dist/{chunk-fxxh149b.js → chunk-zs4s9fcq.js} +4 -4
  138. package/dist/cli.js +13 -13
  139. package/dist/craft-entry.js +2 -2
  140. package/dist/craft.js +2 -2
  141. package/dist/index.d.ts +1 -0
  142. package/dist/index.js +1 -0
  143. package/dist/pwa.js +3 -3
  144. package/dist/render.js +2 -6
  145. package/dist/serve.js +2 -6
  146. package/dist/site-builder/build.js +2 -2
  147. package/dist/site-builder/router.js +2 -5
  148. package/dist/site-builder/theme.js +2 -2
  149. package/dist/ssg.js +4 -4
  150. package/package.json +5 -5
  151. package/dist/chunk-13fe3avf.js +0 -2
  152. package/dist/chunk-1p47cg0g.js +0 -2
  153. package/dist/chunk-1z46g29d.js +0 -2
  154. package/dist/chunk-228cbw2p.js +0 -2
  155. package/dist/chunk-2bggrzv0.js +0 -2
  156. package/dist/chunk-2dnd2s2a.js +0 -3
  157. package/dist/chunk-34rh88vd.js +0 -2
  158. package/dist/chunk-3cqp0m62.js +0 -2
  159. package/dist/chunk-3dtzcc9j.js +0 -2
  160. package/dist/chunk-3rgqrs3c.js +0 -2
  161. package/dist/chunk-51kb36f7.js +0 -2
  162. package/dist/chunk-53ezn1tw.js +0 -2
  163. package/dist/chunk-636j1nmd.js +0 -2
  164. package/dist/chunk-756rpwn0.js +0 -2
  165. package/dist/chunk-7pq02v7n.js +0 -2
  166. package/dist/chunk-7sht1rkv.js +0 -2
  167. package/dist/chunk-9rgp005c.js +0 -2
  168. package/dist/chunk-azvx5gaa.js +0 -2
  169. package/dist/chunk-ebk1723c.js +0 -2
  170. package/dist/chunk-emc7zqry.js +0 -2
  171. package/dist/chunk-eppv6knk.js +0 -2
  172. package/dist/chunk-f935fec7.js +0 -2
  173. package/dist/chunk-g0v1shhr.js +0 -2
  174. package/dist/chunk-g5pg0pg1.js +0 -2
  175. package/dist/chunk-g8x32bq2.js +0 -2
  176. package/dist/chunk-g978f9qg.js +0 -18
  177. package/dist/chunk-hk7vjyqa.js +0 -2
  178. package/dist/chunk-jmaw2cdt.js +0 -2
  179. package/dist/chunk-jw75rmpw.js +0 -2
  180. package/dist/chunk-m3fq72f8.js +0 -2
  181. package/dist/chunk-n54twtm7.js +0 -2
  182. package/dist/chunk-np6y9evb.js +0 -2
  183. package/dist/chunk-pk0mxjxw.js +0 -2
  184. package/dist/chunk-q9r13taa.js +0 -2
  185. package/dist/chunk-qqjhq0hb.js +0 -2
  186. package/dist/chunk-qsjkewah.js +0 -2
  187. package/dist/chunk-qw80eta1.js +0 -2
  188. package/dist/chunk-r51bfc2y.js +0 -2
  189. package/dist/chunk-rbrvepr3.js +0 -2
  190. package/dist/chunk-se4ny3q0.js +0 -2
  191. package/dist/chunk-sxvv9w8t.js +0 -2
  192. package/dist/chunk-sy703233.js +0 -2
  193. package/dist/chunk-syzn6mq5.js +0 -2
  194. package/dist/chunk-v3r1wwec.js +0 -2
  195. package/dist/chunk-vd5d1yb9.js +0 -2
  196. package/dist/chunk-vmdsj8r5.js +0 -2
  197. package/dist/chunk-vmg3f76h.js +0 -2
  198. package/dist/chunk-w63c96ce.js +0 -2
  199. package/dist/chunk-wcgca1q6.js +0 -2
  200. package/dist/chunk-wv8qmwqp.js +0 -2
  201. package/dist/chunk-x90f7h2g.js +0 -2
  202. package/dist/chunk-xhnpgey5.js +0 -2
  203. package/dist/chunk-y54pj23g.js +0 -2
  204. package/dist/chunk-yhrkqcqd.js +0 -2
  205. package/dist/chunk-ykxpzjgy.js +0 -2
  206. package/dist/chunk-zhyrhxdp.js +0 -2
  207. package/dist/chunk-zn5tewws.js +0 -2
  208. package/dist/chunk-zvra3bmk.js +0 -2
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{rt}from"./chunk-g17q4y5k.js";import{wt,qn}from"./chunk-9qe4qsc7.js";import{Ir,Or,Nr,Dr,Ee}from"./chunk-9nh48zvm.js";import{Le,yn,cl,ll}from"./chunk-b1kc0ka1.js";import{M}from"./chunk-5rxks14t.js";import{$i}from"./chunk-wjamjgx6.js";import{b}from"./chunk-6w5a5ns4.js";import{i}from"./chunk-qd87dk1d.js";import{F,a}from"./chunk-wfd9e224.js";import{Ic}from"./chunk-k8pzk8v9.js";import{Nn,Mn,Ke,$e,ya,ba,Dn}from"./chunk-kpsxhm4x.js";import{un,Mo}from"./chunk-gq9h36jf.js";import{Ln}from"./chunk-12r22pf0.js";import{nn,tr,nr}from"./chunk-q87hkwfg.js";import{X}from"./chunk-5va6c7jf.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function W(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function J(n=!1){let l=n?qn():wt(),o=W(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function U(){let n=rt(),l=W(n);return{content:n,filename:`router.${l}.js`,hash:l}}import V from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function q(n,l,o={}){let r=V.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);cl();let _={};try{_=await a(o.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))y.push(g[2])}let u=new Set(y.flatMap((R)=>Le(R))),{context:D}=te({__filename:r,__dirname:V.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...F,..._,...o,buildMode:"compile",strict:!1},f=await i(e,D,r,T,A),w=Nn(f)+Mn(f)+Ke(f),j=ll();return{route:l,sourceFile:n,html:f,fragment:w,placeholders:j,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(A),contentHash:S,status:yn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function mm(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),y=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=Ee(e.app?.head,{known:Dr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=Ln(A),f=n.serverApi??e.serverApi,w=typeof f==="object"?f:{};if(f)un(o,w);if(e.runtimeConfig)M(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=X(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],P=R.filter((s)=>!Y.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=J(n.debug),x=U();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let B=[],H=[];for(let s of P){let h=T(s.pattern),O=h.rendering==="prerender";if(O&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await q(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:y,debug:n.debug});if(B.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Nr(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Ir(t.html,u);if(g.htmlAttrs)t.html=Or(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await b(t.html),O){let p=await Dn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=$e(t.html,D,!0);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),H.push({pattern:s.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:h}=Z(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let E=nr(o);if(E){let{copied:s,bytes:h}=Z(E,c.join(r,"public",tr));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${nn}/`)}let N={runtime:v.filename,router:x.filename},C=ya(H,N,r);if(C.routeRules=A,C.routerContainer=D,f)C.apiRoutes=await Mo(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await $i(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Ic(e._layerGraph),null,2));ba(C,r);let K=Date.now()-l;return console.log(`
2
+ import{rt}from"./chunk-3gfd9t8a.js";import{wt,qn}from"./chunk-5neezkj1.js";import{Ir,Or,Nr,Dr,Ee}from"./chunk-830ej8d2.js";import{Le,yn,ll,ul}from"./chunk-261t62q4.js";import{M}from"./chunk-5rxks14t.js";import{$i}from"./chunk-naj146zq.js";import{b}from"./chunk-5q4tncfw.js";import{i}from"./chunk-kv40xq53.js";import{F,a}from"./chunk-6nb49h13.js";import{Oc}from"./chunk-4rrxrxp6.js";import{Nn,Mn,Ke,$e,ya,ba,Dn}from"./chunk-4jgcd4d9.js";import{un,Mo}from"./chunk-15rkvc0t.js";import{Ln}from"./chunk-12r22pf0.js";import{nn,tr,nr}from"./chunk-q87hkwfg.js";import{X}from"./chunk-02css3vk.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function W(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function J(n=!1){let l=n?qn():wt(),o=W(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function U(){let n=rt(),l=W(n);return{content:n,filename:`router.${l}.js`,hash:l}}import V from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function q(n,l,o={}){let r=V.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);ll();let _={};try{_=await a(o.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))y.push(g[2])}let u=new Set(y.flatMap((R)=>Le(R))),{context:D}=te({__filename:r,__dirname:V.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...F,..._,...o,buildMode:"compile",strict:!1},f=await i(e,D,r,T,A),w=Nn(f)+Mn(f)+Ke(f),j=ul();return{route:l,sourceFile:n,html:f,fragment:w,placeholders:j,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(A),contentHash:S,status:yn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function hm(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),y=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=Ee(e.app?.head,{known:Dr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=Ln(A),f=n.serverApi??e.serverApi,w=typeof f==="object"?f:{};if(f)un(o,w);if(e.runtimeConfig)M(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=X(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],P=R.filter((s)=>!Y.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=J(n.debug),x=U();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let B=[],H=[];for(let s of P){let h=T(s.pattern),O=h.rendering==="prerender";if(O&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await q(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:y,debug:n.debug});if(B.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Nr(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Ir(t.html,u);if(g.htmlAttrs)t.html=Or(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await b(t.html),O){let p=await Dn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=$e(t.html,D,!0);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),H.push({pattern:s.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:h}=Z(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let E=nr(o);if(E){let{copied:s,bytes:h}=Z(E,c.join(r,"public",tr));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${nn}/`)}let N={runtime:v.filename,router:x.filename},C=ya(H,N,r);if(C.routeRules=A,C.routerContainer=D,f)C.apiRoutes=await Mo(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await $i(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Oc(e._layerGraph),null,2));ba(C,r);let K=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${K}ms \u2014 ${B.length} pages compiled`),{pageCount:B.length,assets:N,outputDir:r,duration:K}}
4
- export{mm};
4
+ export{hm};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ne,w,S,C,Z}from"./chunk-b1kc0ka1.js";import{k}from"./chunk-fkh4xece.js";import{I,An}from"./chunk-xppm4cs4.js";import{a}from"./chunk-wfd9e224.js";import{be,an,cn,ln}from"./chunk-tc31my2p.js";import{St}from"./chunk-3248qphb.js";import{bt,Wn,Qt,ue}from"./chunk-jhm1228j.js";import{T,Rn}from"./chunk-9xr628ew.js";import h from"path";var v=new Map,A=new Map,E=w(64),F=new Map,Y=["composables","functions"];function H(e){let s=h.basename(e,".ts");return s==="index"||s==="types"||e.endsWith(".d.ts")}async function ee(e){if(e)return h.resolve(e);let s=`<default>:${process.cwd()}`,r=F.get(s);if(r!==void 0)return r;let t=await te();if(t!==null)F.set(s,t);return t}async function te(){let e=await a(),s=e.root||process.cwd(),r=e.composablesDir;if(r)return h.resolve(s,r);for(let t of Y){let n=h.resolve(s,t);try{let c=new Bun.Glob("**/*.ts");for await(let i of c.scan({cwd:n,absolute:!0}))if(!H(i))return n}catch{}}return null}async function W(e){let s=Array.isArray(e)?e:e?[h.resolve(e)]:(await a())._layerComposableDirs??[await ee()].filter((t)=>!!t),r=new Map;for(let t of s){let n=new Bun.Glob("**/*.ts");try{for await(let c of n.scan({cwd:t,absolute:!0})){let i=h.relative(t,c);if(!H(c)&&!r.has(i))r.set(i,c)}}catch{}}return{key:s.join("\x00"),files:[...r.values()].sort()}}async function ko(e){let{files:s}=await W(e),r=Z({loader:"ts",target:"browser",define:C()}),t=[];for(let n of s)try{let c=await Bun.file(n).text(),i=r.scan(c).exports.filter((u)=>u!=="default");if(i.length>0)t.push({file:n,names:i})}catch{}return t}function ne(e,s){return new RegExp(`\\b${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(e)}function R(e,s){let r=new Set(e.match(/\w+/g)),t=new Set;for(let n of s)if(/^\w+$/.test(n)?r.has(n):ne(e,n))t.add(n);return t}var J=w(64);function X(e,s){let r=S(e,s.size),t=J.get(r);if(t)return t;let n;try{n=Ne(e,s)}catch{n=R(e,s)}let c=[...e.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...e.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let i of c)for(let u of i[1].split(",")){let f=u.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(f&&s.has(f))n.add(f)}return J.set(r,n),n}function se(e){return!e||/^(?:module|(?:text|application)\/(?:java|ecma)script|application\/stx-[\w-]+)$/i.test(e)}var L=w(256);function oe(e,s){let r=new Set(s),t="",n=0,c=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)){t+=e.slice(n,i.index),n=i.index+i[0].length;let u=i[1]??"",f=i[2]??"",d=/\btype\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(u),m=d?(d[1]??d[2]??d[3]??"").trim():void 0;if(!se(m)){if(!/json/i.test(m??""))t+=` ${f} `;continue}let y=R(f,r);if(y.size===0)continue;let _=S(f,[...y].sort().join(",")),b=L.get(_);if(!b)b=X(f,y),L.set(_,b);for(let B of b)c.add(B)}t+=e.slice(n);for(let i of R(t,r))c.add(i);return c}function ie(e,s,r){let t=new Map;for(let{file:f,names:d}of e)for(let m of d)if(!t.has(m))t.set(m,f);let n=new Set(t.keys()),c=(f)=>{let d=[];for(let m of X(f,n))d.push(t.get(m));return d},i=new Set,u=r.flatMap((f,d)=>d===0?[...oe(f,t.keys())].map((m)=>t.get(m)):c(f));while(u.length>0){let f=[];for(let d of u){if(i.has(d))continue;i.add(d);for(let m of c(s.get(d)??""))if(!i.has(m))f.push(m)}u=f}return i}async function Sh(e,s,r,t){let{key:n,files:c}=await W(e);if(!n)return null;let i=()=>[...new Set([...c,...c.flatMap((o)=>be(o))])],u=bt(i());if(c.length===0)return ue(v,n,u,""),null;c.sort();let f=Z({loader:"ts",target:"browser",define:C()}),d=Qt(A,n,u);if(!d){let o=new Map,l=[];for(let p of c)try{let x=await Bun.file(p).text();o.set(p,x);let g=f.scan(x).exports.filter((V)=>V!=="default");if(g.length>0)l.push({file:p,names:g})}catch{o.set(p,"")}d=ue(A,n,u,{codeByFile:o,modules:l})}let{codeByFile:m,modules:y}=d,_;if(s===void 0)_=new Set(c);else{let o=r?[s,...r]:[s],l=S(o.join("\x00"),n,o.length,u),p=E.get(l);if(_=p??ie(y,m,o),!p)E.set(l,_)}if(_.size===0)return null;let b=c.filter((o)=>_.has(o)),B=()=>{if(!t)return;for(let o of b)t.push(o,...be(o))},N=`${n}\x00${b.join("\x00")}\x00${cn()}`,P=Qt(v,N,u);if(P!==void 0)return B(),P||null;let D=[],M=new Set,U=new Set;for(let o of b)try{let l=m.get(o)??await Bun.file(o).text(),p=h.basename(o,".ts");for(let g of l.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(g[1])U.add(g[1]);let x=[];try{for(let g of f.scan(l).exports)if(g!=="default")M.add(g),x.push(g)}catch{}if(l=I(l),an(l))l=await ln(l,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:x}),l=St(l);l=An(l),l=l.replace(/^export\s+(default\s+)?/gm,""),l=f.transformSync(l),D.push(`// Composable: ${p}
2
+ import{Ne,w,S,C,Z}from"./chunk-261t62q4.js";import{k}from"./chunk-1jwcp2k0.js";import{I,An}from"./chunk-xppm4cs4.js";import{a}from"./chunk-6nb49h13.js";import{be,an,cn,ln}from"./chunk-74g64pzt.js";import{St}from"./chunk-b1tctqn5.js";import{bt,Wn,Qt,ue}from"./chunk-jhm1228j.js";import{T,Rn}from"./chunk-9xr628ew.js";import h from"path";var v=new Map,A=new Map,E=w(64),F=new Map,Y=["composables","functions"];function H(e){let s=h.basename(e,".ts");return s==="index"||s==="types"||e.endsWith(".d.ts")}async function ee(e){if(e)return h.resolve(e);let s=`<default>:${process.cwd()}`,r=F.get(s);if(r!==void 0)return r;let t=await te();if(t!==null)F.set(s,t);return t}async function te(){let e=await a(),s=e.root||process.cwd(),r=e.composablesDir;if(r)return h.resolve(s,r);for(let t of Y){let n=h.resolve(s,t);try{let c=new Bun.Glob("**/*.ts");for await(let i of c.scan({cwd:n,absolute:!0}))if(!H(i))return n}catch{}}return null}async function W(e){let s=Array.isArray(e)?e:e?[h.resolve(e)]:(await a())._layerComposableDirs??[await ee()].filter((t)=>!!t),r=new Map;for(let t of s){let n=new Bun.Glob("**/*.ts");try{for await(let c of n.scan({cwd:t,absolute:!0})){let i=h.relative(t,c);if(!H(c)&&!r.has(i))r.set(i,c)}}catch{}}return{key:s.join("\x00"),files:[...r.values()].sort()}}async function ko(e){let{files:s}=await W(e),r=Z({loader:"ts",target:"browser",define:C()}),t=[];for(let n of s)try{let c=await Bun.file(n).text(),i=r.scan(c).exports.filter((u)=>u!=="default");if(i.length>0)t.push({file:n,names:i})}catch{}return t}function ne(e,s){return new RegExp(`\\b${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(e)}function R(e,s){let r=new Set(e.match(/\w+/g)),t=new Set;for(let n of s)if(/^\w+$/.test(n)?r.has(n):ne(e,n))t.add(n);return t}var J=w(64);function X(e,s){let r=S(e,s.size),t=J.get(r);if(t)return t;let n;try{n=Ne(e,s)}catch{n=R(e,s)}let c=[...e.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...e.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let i of c)for(let u of i[1].split(",")){let f=u.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(f&&s.has(f))n.add(f)}return J.set(r,n),n}function se(e){return!e||/^(?:module|(?:text|application)\/(?:java|ecma)script|application\/stx-[\w-]+)$/i.test(e)}var L=w(256);function oe(e,s){let r=new Set(s),t="",n=0,c=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)){t+=e.slice(n,i.index),n=i.index+i[0].length;let u=i[1]??"",f=i[2]??"",d=/\btype\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(u),m=d?(d[1]??d[2]??d[3]??"").trim():void 0;if(!se(m)){if(!/json/i.test(m??""))t+=` ${f} `;continue}let y=R(f,r);if(y.size===0)continue;let _=S(f,[...y].sort().join(",")),b=L.get(_);if(!b)b=X(f,y),L.set(_,b);for(let B of b)c.add(B)}t+=e.slice(n);for(let i of R(t,r))c.add(i);return c}function ie(e,s,r){let t=new Map;for(let{file:f,names:d}of e)for(let m of d)if(!t.has(m))t.set(m,f);let n=new Set(t.keys()),c=(f)=>{let d=[];for(let m of X(f,n))d.push(t.get(m));return d},i=new Set,u=r.flatMap((f,d)=>d===0?[...oe(f,t.keys())].map((m)=>t.get(m)):c(f));while(u.length>0){let f=[];for(let d of u){if(i.has(d))continue;i.add(d);for(let m of c(s.get(d)??""))if(!i.has(m))f.push(m)}u=f}return i}async function kh(e,s,r,t){let{key:n,files:c}=await W(e);if(!n)return null;let i=()=>[...new Set([...c,...c.flatMap((o)=>be(o))])],u=bt(i());if(c.length===0)return ue(v,n,u,""),null;c.sort();let f=Z({loader:"ts",target:"browser",define:C()}),d=Qt(A,n,u);if(!d){let o=new Map,l=[];for(let p of c)try{let x=await Bun.file(p).text();o.set(p,x);let g=f.scan(x).exports.filter((V)=>V!=="default");if(g.length>0)l.push({file:p,names:g})}catch{o.set(p,"")}d=ue(A,n,u,{codeByFile:o,modules:l})}let{codeByFile:m,modules:y}=d,_;if(s===void 0)_=new Set(c);else{let o=r?[s,...r]:[s],l=S(o.join("\x00"),n,o.length,u),p=E.get(l);if(_=p??ie(y,m,o),!p)E.set(l,_)}if(_.size===0)return null;let b=c.filter((o)=>_.has(o)),B=()=>{if(!t)return;for(let o of b)t.push(o,...be(o))},N=`${n}\x00${b.join("\x00")}\x00${cn()}`,P=Qt(v,N,u);if(P!==void 0)return B(),P||null;let D=[],M=new Set,U=new Set;for(let o of b)try{let l=m.get(o)??await Bun.file(o).text(),p=h.basename(o,".ts");for(let g of l.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(g[1])U.add(g[1]);let x=[];try{for(let g of f.scan(l).exports)if(g!=="default")M.add(g),x.push(g)}catch{}if(l=I(l),an(l))l=await ln(l,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:x}),l=St(l);l=An(l),l=l.replace(/^export\s+(default\s+)?/gm,""),l=f.transformSync(l),D.push(`// Composable: ${p}
3
3
  ${l.trim()}`)}catch(l){console.warn(`[stx] Failed to load composable ${o}:`,l)}if(D.length===0||M.size===0)return ue(v,N,u,""),null;let q=[...M].map((o)=>` try { if (!(${JSON.stringify(o)} in __c)) __c[${JSON.stringify(o)}] = ${o}; } catch (e) {}`).join(`
4
4
  `),z=JSON.stringify([...M]),j=D.join(`
5
5
 
@@ -29,5 +29,5 @@ ${q}
29
29
  window[__n] = __c[__n];
30
30
  __published[__n] = true;
31
31
  }
32
- })();`,G=T()?Rn(O):O;return u=bt(i()),ue(v,N,u,G),B(),G}function kh(){v.clear(),Wn(),A.clear(),E.clear(),F.clear()}
33
- export{ko,Sh,kh};
32
+ })();`,G=T()?Rn(O):O;return u=bt(i()),ue(v,N,u,G),B(),G}function _h(){v.clear(),Wn(),A.clear(),E.clear(),F.clear()}
33
+ export{ko,kh,_h};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var{WebView:p}=globalThis.Bun;import{existsSync as y,mkdirSync as b,readdirSync as v,statSync as S}from"fs";import l from"path";var h=16384;function M(e){if(/^https?:\/\//.test(e)||e.startsWith("file://"))return e;return`file://${l.resolve(e)}`}function g(e,n,t,o){return new Promise((s)=>{let i=!1,r,m,c=()=>{if(!i){if(i=!0,clearTimeout(m),r)clearTimeout(r);e.onNavigated=void 0,s()}};m=setTimeout(c,o),e.onNavigated=()=>{if(!i)r=setTimeout(c,t)};try{let u=e.navigate(n);if(u&&typeof u.catch==="function")u.catch(c)}catch{c()}})}async function w(e,n,t){let o=`!!document.querySelector(${JSON.stringify(n)})`,s=Date.now()+t;while(Date.now()<s){try{if(await e.evaluate(o))return}catch{}await new Promise((i)=>setTimeout(i,100))}}async function T(e){try{let n=await e.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof n==="number"&&Number.isFinite(n)&&n>0?Math.min(n,h):0}catch{return 0}}async function jl(e,n,t={}){let o=Math.min(t.width??1440,h),s=Math.min(t.height??2200,h),i=t.waitMs??800,r=t.timeoutMs??15000,m=t.format??"png",c=M(e),u=(f)=>new p({width:o,height:f,headless:!0,...t.backend?{backend:t.backend}:{}}),a=u(s);try{if(await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r);if(t.fullPage){let d=await T(a);if(d>s){if(a.close(),a=u(d),await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r)}}let f=await a.screenshot({encoding:"buffer",format:m});b(l.dirname(l.resolve(n)),{recursive:!0}),await Bun.write(n,f)}finally{a.close()}if(!y(n))throw Error(`Screenshot was not produced for ${e}`);return{input:e,output:n,bytes:S(n).size}}async function sm(e,n,t={}){b(n,{recursive:!0});let o;if(!/^https?:\/\//.test(e)&&y(e)&&S(e).isDirectory())o=v(e).filter((r)=>r.endsWith(".html")).map((r)=>l.join(e,r));else o=[e];let s=t.format??"png",i=[];for(let r of o){let m=/^https?:\/\//.test(r)?new URL(r).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":l.basename(r).replace(/\.html?$/,"");i.push(await jl(r,l.join(n,`${m}.${s}`),t))}return i}
3
- export{jl,sm};
2
+ var{WebView:p}=globalThis.Bun;import{existsSync as y,mkdirSync as b,readdirSync as v,statSync as S}from"fs";import l from"path";var h=16384;function M(e){if(/^https?:\/\//.test(e)||e.startsWith("file://"))return e;return`file://${l.resolve(e)}`}function g(e,n,t,o){return new Promise((s)=>{let i=!1,r,m,c=()=>{if(!i){if(i=!0,clearTimeout(m),r)clearTimeout(r);e.onNavigated=void 0,s()}};m=setTimeout(c,o),e.onNavigated=()=>{if(!i)r=setTimeout(c,t)};try{let u=e.navigate(n);if(u&&typeof u.catch==="function")u.catch(c)}catch{c()}})}async function w(e,n,t){let o=`!!document.querySelector(${JSON.stringify(n)})`,s=Date.now()+t;while(Date.now()<s){try{if(await e.evaluate(o))return}catch{}await new Promise((i)=>setTimeout(i,100))}}async function T(e){try{let n=await e.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof n==="number"&&Number.isFinite(n)&&n>0?Math.min(n,h):0}catch{return 0}}async function Bl(e,n,t={}){let o=Math.min(t.width??1440,h),s=Math.min(t.height??2200,h),i=t.waitMs??800,r=t.timeoutMs??15000,m=t.format??"png",c=M(e),u=(f)=>new p({width:o,height:f,headless:!0,...t.backend?{backend:t.backend}:{}}),a=u(s);try{if(await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r);if(t.fullPage){let d=await T(a);if(d>s){if(a.close(),a=u(d),await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r)}}let f=await a.screenshot({encoding:"buffer",format:m});b(l.dirname(l.resolve(n)),{recursive:!0}),await Bun.write(n,f)}finally{a.close()}if(!y(n))throw Error(`Screenshot was not produced for ${e}`);return{input:e,output:n,bytes:S(n).size}}async function om(e,n,t={}){b(n,{recursive:!0});let o;if(!/^https?:\/\//.test(e)&&y(e)&&S(e).isDirectory())o=v(e).filter((r)=>r.endsWith(".html")).map((r)=>l.join(e,r));else o=[e];let s=t.format??"png",i=[];for(let r of o){let m=/^https?:\/\//.test(r)?new URL(r).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":l.basename(r).replace(/\.html?$/,"");i.push(await Bl(r,l.join(n,`${m}.${s}`),t))}return i}
3
+ export{Bl,om};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{F,eg,ei,Cc,a,O,ry,sy}from"./chunk-6nb49h13.js";import"./chunk-68w65mhs.js";import"./chunk-9pyvc0dc.js";import"./chunk-4rrxrxp6.js";import"./chunk-dba4bwkd.js";import"./chunk-3gfd9t8a.js";import"./chunk-261t62q4.js";import"./chunk-naj146zq.js";import"./chunk-5rxks14t.js";import"./chunk-830ej8d2.js";import"./chunk-xppm4cs4.js";import"./chunk-1jwcp2k0.js";export{O as config,F as defaultConfig,ry as defineStxConfig,ei as discoverConfig,a as loadStxConfig,Cc as resolveInstalledPackage,eg as resolveStxDirectories,sy as validateConfig};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{x}from"./chunk-9nh48zvm.js";function et(e,r){let n=y(e,r);return n.ok?{expression:n.expression,endPos:n.endPos}:null}function y(e,r){let n=r;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]!=="(")return{ok:!1,reason:"missing-open-paren",pos:n};let c=x(e,"(",")",n);if(c===-1)return{ok:!1,reason:"unclosed-paren",pos:n};return{ok:!0,expression:e.slice(n+1,c),endPos:c+1}}function k(e,r){let n=e.lastIndexOf("<",r);if(n===-1)return!1;return n>e.lastIndexOf(">",r)}function kt(e,r,n,c){let o=1,i=c,u=new RegExp(`@${r}\\s*\\(`,"g"),a=new RegExp(`@${n}(?![a-z])`,"g");while(i<e.length&&o>0){u.lastIndex=i,a.lastIndex=i;let p=u.exec(e),t=a.exec(e),s=p?p.index:1/0,f=t?t.index:1/0;if(s<f)o++,i=s+p[0].length;else if(f<1/0){if(o--,o===0)return f;i=f+t[0].length}else break}return-1}function v(e,r){let n=e.slice(r).match(/^@if\s*/);if(!n)return null;let c=r+n[0].length,o=et(e,c);if(!o)return null;let i=o.endPos,u=kt(e,"if","endif",i);if(u===-1)return null;let a=e.slice(i,u),p=[],t=0,s="if",f=o.expression,l=0,g=0;while(t<a.length){let h=a.indexOf("@",t);if(h===-1)break;t=h;let d=a.substring(h);if(k(a,h)){t++;continue}if(/^@if\s*\(/.test(d)){g++,t++;continue}if(/^@endif(?![a-z])/.test(d)){g--,t+=6;continue}if(g===0){let b=d.match(/^@elseif\s*/);if(b){p.push({type:s,condition:f,content:a.substring(l,t),start:i+l,end:i+t});let E=t+b[0].length,m=et(a,E);if(!m){t++;continue}s="elseif",f=m.expression,t=m.endPos,l=t;continue}else if(/^@else(?![a-z])/.test(d)){p.push({type:s,condition:f,content:a.substring(l,t),start:i+l,end:i+t}),s="else",f=void 0,t+=5,l=t;continue}}t++}return p.push({type:s,condition:f,content:a.slice(l),start:i+l,end:i+a.length}),{fullMatch:e.slice(r,u+6),branches:p,start:r,end:u+6}}function fn(e){let r=[],n=/@if\s*\(/g,c=n.exec(e);while(c!==null){if(r.some((u)=>c.index>u.start&&c.index<u.end)){c=n.exec(e);continue}let i=v(e,c.index);if(i)r.push(i),n.lastIndex=i.end;c=n.exec(e)}return r}function Ss(e,r,n){let c=[],o=new RegExp(`@${r}\\s*\\(`,"g"),i=o.exec(e);while(i!==null){if(c.some((d)=>i.index>d.start&&i.index<d.end)){i=o.exec(e);continue}let a=i.index,p=a+i[0].length-1,t=x(e,"(",")",p);if(t===-1){i=o.exec(e);continue}let s=e.slice(p+1,t),f=t+1,l=kt(e,r,n,f);if(l===-1){i=o.exec(e);continue}let g=e.slice(f,l),h=l+`@${n}`.length;c.push({fullMatch:e.slice(a,h),name:r,params:s,content:g,start:a,end:h}),o.lastIndex=h,i=o.exec(e)}return c}function Zo(e,r){let n=e.slice(r).match(/^@switch\s*/);if(!n)return null;let c=r+n[0].length,o=et(e,c);if(!o)return null;let i=o.endPos,u=kt(e,"switch","endswitch",i);if(u===-1)return null;let a=e.slice(i,u),p=[],t=0,s=null,f=0;while(t<a.length){let l=a.slice(t),g=l.match(/^@switch\s*\(/),h=l.match(/^@endswitch(?![a-z])/);if(g){if(f++,s)s.content+=g[0];t+=g[0].length;continue}if(h){if(f--,s)s.content+=h[0];t+=h[0].length;continue}if(f>0){if(s)s.content+=a[t];t++;continue}let d=l.match(/^@case\s*/),b=l.match(/^@default(?![a-z])/),E=l.match(/^@break(?![a-z])/);if(d&&l.startsWith("@case")){if(s)p.push(s);let m=t+d[0].length,P=et(a,m);if(!P){t++;continue}s={type:"case",value:P.expression,content:""},t=P.endPos}else if(b&&l.startsWith("@default")){if(s)p.push(s);s={type:"default",content:""},t+=b[0].length}else if(E&&l.startsWith("@break"))t+=E[0].length;else{if(s)s.content+=a[t];t++}}if(s)p.push(s);return{fullMatch:e.slice(r,u+10),expression:o.expression,cases:p,start:r,end:u+10}}export{et,kt,fn,Ss,Zo};
2
+ import{x}from"./chunk-830ej8d2.js";function et(e,r){let n=y(e,r);return n.ok?{expression:n.expression,endPos:n.endPos}:null}function y(e,r){let n=r;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]!=="(")return{ok:!1,reason:"missing-open-paren",pos:n};let c=x(e,"(",")",n);if(c===-1)return{ok:!1,reason:"unclosed-paren",pos:n};return{ok:!0,expression:e.slice(n+1,c),endPos:c+1}}function k(e,r){let n=e.lastIndexOf("<",r);if(n===-1)return!1;return n>e.lastIndexOf(">",r)}function kt(e,r,n,c){let o=1,i=c,u=new RegExp(`@${r}\\s*\\(`,"g"),a=new RegExp(`@${n}(?![a-z])`,"g");while(i<e.length&&o>0){u.lastIndex=i,a.lastIndex=i;let p=u.exec(e),t=a.exec(e),s=p?p.index:1/0,f=t?t.index:1/0;if(s<f)o++,i=s+p[0].length;else if(f<1/0){if(o--,o===0)return f;i=f+t[0].length}else break}return-1}function v(e,r){let n=e.slice(r).match(/^@if\s*/);if(!n)return null;let c=r+n[0].length,o=et(e,c);if(!o)return null;let i=o.endPos,u=kt(e,"if","endif",i);if(u===-1)return null;let a=e.slice(i,u),p=[],t=0,s="if",f=o.expression,l=0,g=0;while(t<a.length){let h=a.indexOf("@",t);if(h===-1)break;t=h;let d=a.substring(h);if(k(a,h)){t++;continue}if(/^@if\s*\(/.test(d)){g++,t++;continue}if(/^@endif(?![a-z])/.test(d)){g--,t+=6;continue}if(g===0){let b=d.match(/^@elseif\s*/);if(b){p.push({type:s,condition:f,content:a.substring(l,t),start:i+l,end:i+t});let E=t+b[0].length,m=et(a,E);if(!m){t++;continue}s="elseif",f=m.expression,t=m.endPos,l=t;continue}else if(/^@else(?![a-z])/.test(d)){p.push({type:s,condition:f,content:a.substring(l,t),start:i+l,end:i+t}),s="else",f=void 0,t+=5,l=t;continue}}t++}return p.push({type:s,condition:f,content:a.slice(l),start:i+l,end:i+a.length}),{fullMatch:e.slice(r,u+6),branches:p,start:r,end:u+6}}function fn(e){let r=[],n=/@if\s*\(/g,c=n.exec(e);while(c!==null){if(r.some((u)=>c.index>u.start&&c.index<u.end)){c=n.exec(e);continue}let i=v(e,c.index);if(i)r.push(i),n.lastIndex=i.end;c=n.exec(e)}return r}function Ss(e,r,n){let c=[],o=new RegExp(`@${r}\\s*\\(`,"g"),i=o.exec(e);while(i!==null){if(c.some((d)=>i.index>d.start&&i.index<d.end)){i=o.exec(e);continue}let a=i.index,p=a+i[0].length-1,t=x(e,"(",")",p);if(t===-1){i=o.exec(e);continue}let s=e.slice(p+1,t),f=t+1,l=kt(e,r,n,f);if(l===-1){i=o.exec(e);continue}let g=e.slice(f,l),h=l+`@${n}`.length;c.push({fullMatch:e.slice(a,h),name:r,params:s,content:g,start:a,end:h}),o.lastIndex=h,i=o.exec(e)}return c}function Zo(e,r){let n=e.slice(r).match(/^@switch\s*/);if(!n)return null;let c=r+n[0].length,o=et(e,c);if(!o)return null;let i=o.endPos,u=kt(e,"switch","endswitch",i);if(u===-1)return null;let a=e.slice(i,u),p=[],t=0,s=null,f=0;while(t<a.length){let l=a.slice(t),g=l.match(/^@switch\s*\(/),h=l.match(/^@endswitch(?![a-z])/);if(g){if(f++,s)s.content+=g[0];t+=g[0].length;continue}if(h){if(f--,s)s.content+=h[0];t+=h[0].length;continue}if(f>0){if(s)s.content+=a[t];t++;continue}let d=l.match(/^@case\s*/),b=l.match(/^@default(?![a-z])/),E=l.match(/^@break(?![a-z])/);if(d&&l.startsWith("@case")){if(s)p.push(s);let m=t+d[0].length,P=et(a,m);if(!P){t++;continue}s={type:"case",value:P.expression,content:""},t=P.endPos}else if(b&&l.startsWith("@default")){if(s)p.push(s);s={type:"default",content:""},t+=b[0].length}else if(E&&l.startsWith("@break"))t+=E[0].length;else{if(s)s.content+=a[t];t++}}if(s)p.push(s);return{fullMatch:e.slice(r,u+10),expression:o.expression,cases:p,start:r,end:u+10}}export{et,kt,fn,Ss,Zo};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{E}from"./chunk-b1kc0ka1.js";import{i}from"./chunk-qd87dk1d.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
2
+ import{E}from"./chunk-261t62q4.js";import{i}from"./chunk-kv40xq53.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
3
3
  ${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
4
4
  `)}else{console.log(`
5
5
  ${e.bold}Available Commands:${e.reset}
@@ -16,9 +16,9 @@ ${e.bold}Markdown:${e.reset}`),a.forEach((c)=>console.log(` ${e.blue}${c}${e.re
16
16
  ${e.bold}Other:${e.reset}`),d.forEach((c)=>console.log(` ${e.dim}${c}${e.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a file${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);if(!await Bun.file(n).exists()){console.log(`${e.red}Error: File not found: ${n}${e.reset}`);return}let s=(await Bun.file(n).text()).split(`
17
17
  `);console.log(),s.forEach((l,a)=>{let d=String(a+1).padStart(3," ");console.log(`${e.dim}${d}${e.reset} ${l}`)}),console.log()}},load:{description:"Load context from JSON file",usage:"load <file.json>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a JSON file${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);if(!await Bun.file(n).exists()){console.log(`${e.red}Error: File not found: ${n}${e.reset}`);return}try{let r=await Bun.file(n).text(),s=JSON.parse(r);o.context={...o.context,...s},console.log(`${e.green}\u2713${e.reset} Loaded ${Object.keys(s).length} variables from ${t[0]}`)}catch(r){console.log(`${e.red}Error parsing JSON:${e.reset}`,r)}}},save:{description:"Save context to JSON file",usage:"save <file.json>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a file name${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);try{await Bun.write(n,JSON.stringify(o.context,null,2)),console.log(`${e.green}\u2713${e.reset} Context saved to ${t[0]}`)}catch(r){console.log(`${e.red}Error saving file:${e.reset}`,r)}}},history:{description:"Show command history",usage:"history [count]",handler:async(t,o)=>{let n=t[0]?Number.parseInt(t[0],10):20,r=o.history.slice(-n);if(r.length===0){console.log(`${e.dim}No history${e.reset}`);return}console.log(),r.forEach((s,l)=>{let a=String(o.history.length-r.length+l+1).padStart(3," ");console.log(`${e.dim}${a}${e.reset} ${s}`)}),console.log()}},exit:{description:"Exit interactive mode",usage:"exit",handler:async(t,o)=>{o.running=!1,console.log(`
18
18
  ${e.dim}Goodbye!${e.reset}
19
- `)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async(t,o)=>u.exit.handler(t,o)}};function h(t,o){let n=t.split(" "),r=n[0];if(n.length===1)return Object.keys(u).filter((s)=>s.startsWith(r));if(["render","cat","load","cd"].includes(r)){let s=n.slice(1).join(" "),l=g.dirname(s)||".",a=g.basename(s),d=g.resolve(o.cwd,l);if(p.existsSync(d)&&p.statSync(d).isDirectory())try{return p.readdirSync(d).filter((f)=>f.startsWith(a)).map((f)=>`${r} ${l==="."?"":`${l}/`}${f}`)}catch{return[]}}if(["unset","eval","set"].includes(r)){let s=n[1]||"";return Object.keys(o.context).filter((l)=>l.startsWith(s)).map((l)=>`${r} ${l}`)}return[]}async function om(t={}){let o={context:t.context||{},cwd:t.cwd||process.cwd(),history:[],running:!0,lastResult:null},n=y.createInterface({input:process.stdin,output:process.stdout,completer:(s)=>[h(s,o),s],historySize:t.maxHistory||100});console.log(`
19
+ `)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async(t,o)=>u.exit.handler(t,o)}};function h(t,o){let n=t.split(" "),r=n[0];if(n.length===1)return Object.keys(u).filter((s)=>s.startsWith(r));if(["render","cat","load","cd"].includes(r)){let s=n.slice(1).join(" "),l=g.dirname(s)||".",a=g.basename(s),d=g.resolve(o.cwd,l);if(p.existsSync(d)&&p.statSync(d).isDirectory())try{return p.readdirSync(d).filter((f)=>f.startsWith(a)).map((f)=>`${r} ${l==="."?"":`${l}/`}${f}`)}catch{return[]}}if(["unset","eval","set"].includes(r)){let s=n[1]||"";return Object.keys(o.context).filter((l)=>l.startsWith(s)).map((l)=>`${r} ${l}`)}return[]}async function im(t={}){let o={context:t.context||{},cwd:t.cwd||process.cwd(),history:[],running:!0,lastResult:null},n=y.createInterface({input:process.stdin,output:process.stdout,completer:(s)=>[h(s,o),s],historySize:t.maxHistory||100});console.log(`
20
20
  ${e.bold}${e.blue}stx Interactive Mode${e.reset}
21
21
  ${e.dim}Type 'help' for available commands, 'exit' to quit${e.reset}
22
22
  `);let r=()=>{let s=o.cwd.replace(process.env.HOME||"","~");n.question(`${e.cyan}stx${e.reset} ${e.dim}${s}${e.reset} ${e.green}>${e.reset} `,async(l)=>{let a=l.trim();if(!a){if(o.running)r();return}o.history.push(a);let d=a.match(/(?:[^\s"]|"[^"]*")+/g)||[],c=d[0]?.toLowerCase(),f=d.slice(1).map((m)=>m.replace(/^"|"$/g,""));if(c&&u[c])try{await u[c].handler(f,o)}catch(m){console.log(`${e.red}Error:${e.reset}`,m)}else if(c)if(a.includes("{{")||a.includes("}}"))try{let m=await E(a,o.context,"eval");console.log(`${e.green}\u2192${e.reset} ${m}`)}catch{console.log(`${e.red}Unknown command: ${c}${e.reset}`),console.log(`${e.dim}Type 'help' for available commands${e.reset}`)}else console.log(`${e.red}Unknown command: ${c}${e.reset}`),console.log(`${e.dim}Type 'help' for available commands${e.reset}`);if(o.running)r();else n.close()})};n.on("SIGINT",()=>{console.log(`
23
23
  ${e.dim}(Use 'exit' to quit)${e.reset}`),r()}),r()}
24
- export{om};
24
+ export{im};