@stacksjs/stx 0.2.354 → 0.2.356

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 (195) hide show
  1. package/dist/chunk-0c49cy69.js +2 -0
  2. package/dist/chunk-0chkqvs1.js +2 -0
  3. package/dist/chunk-0d6qgbks.js +2 -0
  4. package/dist/{chunk-84bhnp6p.js → chunk-0dj2gne3.js} +2 -2
  5. package/dist/{chunk-57atgbyq.js → chunk-0knxnyq6.js} +1 -1
  6. package/dist/{chunk-m6dstr44.js → chunk-0smr2xjs.js} +2 -2
  7. package/dist/{chunk-e4g8wz6t.js → chunk-0t1yyn1d.js} +1 -1
  8. package/dist/{chunk-xvh1k1a4.js → chunk-19m7hed6.js} +1 -1
  9. package/dist/{chunk-vhta1be7.js → chunk-1nnza3m6.js} +1 -1
  10. package/dist/chunk-284kattb.js +2 -0
  11. package/dist/{chunk-n5657hm3.js → chunk-2gtwha4k.js} +1 -1
  12. package/dist/{chunk-f5veee11.js → chunk-2s3wvns6.js} +1 -1
  13. package/dist/chunk-2x3zy811.js +2 -0
  14. package/dist/chunk-38mpg3kn.js +2 -0
  15. package/dist/chunk-3eya6sbk.js +2 -0
  16. package/dist/chunk-3f782ywp.js +2 -0
  17. package/dist/{chunk-mmnf2pac.js → chunk-3kd0zn9c.js} +2 -2
  18. package/dist/{chunk-avye7h5s.js → chunk-3kyydhzt.js} +1 -1
  19. package/dist/{chunk-msq8xvhp.js → chunk-3ssjb8cx.js} +309 -312
  20. package/dist/{chunk-6r3aavbv.js → chunk-3y8vvkar.js} +2 -2
  21. package/dist/chunk-4ce5ma6a.js +20 -0
  22. package/dist/{chunk-8cc4vdkh.js → chunk-4gtsf1xw.js} +1 -1
  23. package/dist/chunk-4mkqzhfh.js +2 -0
  24. package/dist/{chunk-xj6bcwqa.js → chunk-5270fyk7.js} +1 -1
  25. package/dist/{chunk-a1knndrh.js → chunk-57kxjr4t.js} +10 -10
  26. package/dist/chunk-596cftgk.js +2 -0
  27. package/dist/{chunk-8bxtvsgm.js → chunk-634gaa9d.js} +1 -1
  28. package/dist/{chunk-pwh8pbks.js → chunk-6gsgayq3.js} +1 -1
  29. package/dist/{chunk-a8ghkfh6.js → chunk-6qhatdte.js} +2 -2
  30. package/dist/{chunk-6zrg2mmc.js → chunk-6yfccnr7.js} +2 -2
  31. package/dist/{chunk-z23sc9p4.js → chunk-79fj9zem.js} +2 -2
  32. package/dist/{chunk-2ver2s2y.js → chunk-7hb89n3z.js} +1 -1
  33. package/dist/{chunk-05zfez2g.js → chunk-7jcntsp4.js} +1 -1
  34. package/dist/{chunk-nf7k53ap.js → chunk-7kw3grq5.js} +1 -1
  35. package/dist/chunk-7nf8azjh.js +2 -0
  36. package/dist/{chunk-g5mhck0r.js → chunk-801bg5d8.js} +2 -2
  37. package/dist/chunk-8wgsjh65.js +2 -0
  38. package/dist/{chunk-34f8c48f.js → chunk-8xjasa91.js} +1 -1
  39. package/dist/{chunk-w5j9tbsk.js → chunk-94dz7hrj.js} +1 -1
  40. package/dist/{chunk-6h3r8v55.js → chunk-9qdn9y72.js} +1 -1
  41. package/dist/chunk-a6x0czvr.js +2 -0
  42. package/dist/{chunk-72x62kch.js → chunk-aa8015mk.js} +1 -1
  43. package/dist/{chunk-64n10kpa.js → chunk-aacfyyya.js} +1 -1
  44. package/dist/chunk-abtxpqna.js +2 -0
  45. package/dist/{chunk-c30qnb6z.js → chunk-apbr1kb1.js} +2 -2
  46. package/dist/{chunk-nm60wh6r.js → chunk-awyyskad.js} +1 -1
  47. package/dist/{chunk-ppzz953j.js → chunk-b8ywrx2w.js} +1 -1
  48. package/dist/{chunk-18018jkn.js → chunk-bcpjhcpn.js} +1 -1
  49. package/dist/{chunk-kw9cgyfc.js → chunk-c17ybabd.js} +1 -1
  50. package/dist/chunk-c4rpdtvw.js +2 -0
  51. package/dist/{chunk-zk6ghjnj.js → chunk-c79nfdyj.js} +1 -1
  52. package/dist/chunk-cgs5xpsn.js +2 -0
  53. package/dist/{chunk-avwywzsj.js → chunk-czj6nq0b.js} +2 -2
  54. package/dist/{chunk-9kmhwbwy.js → chunk-czypgdc1.js} +1 -1
  55. package/dist/{chunk-epqd3eah.js → chunk-degz74nv.js} +2 -2
  56. package/dist/chunk-dpyc7pht.js +2 -0
  57. package/dist/{chunk-hay8nwv3.js → chunk-dtdwjpvf.js} +2 -2
  58. package/dist/{chunk-dsztk2kp.js → chunk-e48050x3.js} +1 -1
  59. package/dist/{chunk-3nx7z086.js → chunk-ec8jsqgm.js} +3 -3
  60. package/dist/{chunk-86c461ca.js → chunk-eg8k598q.js} +1 -1
  61. package/dist/{chunk-bgrkxzr7.js → chunk-ej8mv2k6.js} +1 -1
  62. package/dist/{chunk-y2f41kaq.js → chunk-ejwfnttb.js} +1 -1
  63. package/dist/{chunk-ejqpq0wc.js → chunk-emjmshj8.js} +1 -1
  64. package/dist/{chunk-59906baj.js → chunk-ep034wt0.js} +1 -1
  65. package/dist/{chunk-njx93b4z.js → chunk-ez003q74.js} +1 -1
  66. package/dist/{chunk-ws0282jr.js → chunk-f11z7q5g.js} +1 -1
  67. package/dist/chunk-f3eb1f6z.js +2 -0
  68. package/dist/{chunk-1z1efvtw.js → chunk-fqq5k9ve.js} +1 -1
  69. package/dist/{chunk-c0n802j1.js → chunk-frp9fc7j.js} +1 -1
  70. package/dist/chunk-fzq2n865.js +2 -0
  71. package/dist/{chunk-g6czgcg4.js → chunk-g1vxsvqv.js} +1 -1
  72. package/dist/chunk-g3cmkyk2.js +2 -0
  73. package/dist/{chunk-7r9vgzg4.js → chunk-g7bpkpd4.js} +1 -1
  74. package/dist/{chunk-at622hg0.js → chunk-gn2qc03b.js} +1 -1
  75. package/dist/chunk-gxgrzeeh.js +2 -0
  76. package/dist/{chunk-a9w1ds4w.js → chunk-h99qxgbr.js} +1 -1
  77. package/dist/{chunk-dgv43ccd.js → chunk-hcf8399w.js} +1 -1
  78. package/dist/{chunk-hbkjzx1h.js → chunk-hh0aaxxy.js} +1 -1
  79. package/dist/{chunk-tc4pj651.js → chunk-hkrzv980.js} +2 -2
  80. package/dist/{chunk-7qp3zphs.js → chunk-hy79zwyy.js} +2 -2
  81. package/dist/chunk-j6kec9kp.js +2 -0
  82. package/dist/{chunk-e631svvs.js → chunk-j8wycqve.js} +1 -1
  83. package/dist/chunk-jmdxn2mq.js +2 -0
  84. package/dist/chunk-jwmact5f.js +2 -0
  85. package/dist/{chunk-g7msqva8.js → chunk-jy451jg5.js} +3 -3
  86. package/dist/{chunk-a959m68j.js → chunk-k33778kc.js} +1 -1
  87. package/dist/{chunk-wvc7t11n.js → chunk-kaet6r9w.js} +1 -1
  88. package/dist/chunk-kdmkk0rb.js +2 -0
  89. package/dist/{chunk-9e20mgwc.js → chunk-kjd9hbg4.js} +3 -3
  90. package/dist/{chunk-8m0g0h4x.js → chunk-krt45cqy.js} +2 -2
  91. package/dist/{chunk-2wb3pgp4.js → chunk-kyyt9xhs.js} +1 -1
  92. package/dist/{chunk-0k1mtwby.js → chunk-mdbj7sq8.js} +1 -1
  93. package/dist/{chunk-d86q27j8.js → chunk-mere396d.js} +1 -1
  94. package/dist/{chunk-1c9453w0.js → chunk-ms25gb16.js} +1 -1
  95. package/dist/{chunk-ym3r8ktq.js → chunk-n0d7nwhd.js} +1 -1
  96. package/dist/{chunk-7h9fajgs.js → chunk-n1y0hjk1.js} +2 -2
  97. package/dist/{chunk-bk1zb1xp.js → chunk-n5tpqzcb.js} +1 -1
  98. package/dist/{chunk-b5hank5e.js → chunk-nybn003d.js} +2 -2
  99. package/dist/chunk-p1426yar.js +2 -0
  100. package/dist/chunk-p78b80dp.js +2 -0
  101. package/dist/chunk-pr3hz3ec.js +2 -0
  102. package/dist/{chunk-gtqbvt3a.js → chunk-q4kgqqed.js} +2 -2
  103. package/dist/{chunk-san1eq0r.js → chunk-qbz6yn8c.js} +2 -2
  104. package/dist/{chunk-fvsefztj.js → chunk-qjvny3wf.js} +1 -1
  105. package/dist/{chunk-v0e259x2.js → chunk-qnptmtqh.js} +1 -1
  106. package/dist/{chunk-msywnv5n.js → chunk-qrvey4wk.js} +2 -2
  107. package/dist/{chunk-7we3xfde.js → chunk-ra1s4s6b.js} +1 -1
  108. package/dist/{chunk-62nz9v8t.js → chunk-rbfm5sjt.js} +2 -2
  109. package/dist/{chunk-99b5tfxc.js → chunk-rcbt11p8.js} +1 -1
  110. package/dist/{chunk-9nrgjtah.js → chunk-rtfwn4cm.js} +1 -1
  111. package/dist/chunk-rydb5n5b.js +2 -0
  112. package/dist/{chunk-6k5a03pw.js → chunk-s5dwatkj.js} +2 -2
  113. package/dist/chunk-sa6cgj9h.js +2 -0
  114. package/dist/chunk-skdfq4hq.js +2 -0
  115. package/dist/{chunk-ngjkzaj7.js → chunk-t23kccpz.js} +3 -3
  116. package/dist/{chunk-89mqnh67.js → chunk-tf16jtj4.js} +1 -1
  117. package/dist/{chunk-swvm1wgn.js → chunk-trva71am.js} +2 -2
  118. package/dist/{chunk-rwwfzkz4.js → chunk-tv04k7gq.js} +1 -1
  119. package/dist/{chunk-5wbdbcvf.js → chunk-v1qm7p7t.js} +2 -2
  120. package/dist/chunk-w1a8dwgx.js +2 -0
  121. package/dist/{chunk-y6xzr30x.js → chunk-wkyt4j9e.js} +1 -1
  122. package/dist/{chunk-p3p4d6g1.js → chunk-wz4fnsat.js} +2 -2
  123. package/dist/chunk-x131a0jq.js +2 -0
  124. package/dist/{chunk-f5cw54q3.js → chunk-x21hdhjw.js} +1 -1
  125. package/dist/chunk-x5b8az2h.js +2 -0
  126. package/dist/chunk-xk782v5z.js +2 -0
  127. package/dist/{chunk-qsbjtp60.js → chunk-y4nzmkea.js} +1 -1
  128. package/dist/{chunk-sqvqwd0p.js → chunk-y4zddt5r.js} +1 -1
  129. package/dist/{chunk-vgfd9582.js → chunk-ya5m5vbn.js} +1 -1
  130. package/dist/{chunk-1vb2rj09.js → chunk-yg0qm73a.js} +2 -2
  131. package/dist/{chunk-8y1ve8tc.js → chunk-ykevda74.js} +2 -2
  132. package/dist/chunk-ynj1y0qm.js +2 -0
  133. package/dist/{chunk-v6e35j4g.js → chunk-z50ex86m.js} +1 -1
  134. package/dist/chunk-z8gccz1q.js +2 -0
  135. package/dist/{chunk-wj21f1e0.js → chunk-zxfejz72.js} +1 -1
  136. package/dist/chunk-zxnf0c9x.js +2 -0
  137. package/dist/cli.js +14 -14
  138. package/dist/craft-entry.js +1 -1
  139. package/dist/craft.js +1 -1
  140. package/dist/database.js +1 -1
  141. package/dist/engine-bindings.d.ts +35 -0
  142. package/dist/engine-bindings.js +55 -0
  143. package/dist/pwa.js +2 -2
  144. package/dist/ssg.js +2 -2
  145. package/dist/stx-module-imports.d.ts +24 -0
  146. package/dist/stx-module-imports.js +57 -0
  147. package/dist/stx-module.d.ts +154 -0
  148. package/dist/stx-virtual-ts.d.ts +74 -1
  149. package/dist/stx-virtual-ts.js +81 -21
  150. package/dist/typecheck.d.ts +13 -0
  151. package/dist/typecheck.js +31 -25
  152. package/dist/variable-extractor.d.ts +2 -22
  153. package/dist/variable-extractor.js +3 -55
  154. package/dist/visual-testing.js +1 -1
  155. package/package.json +7 -6
  156. package/stx-module.d.ts +154 -0
  157. package/dist/chunk-04x3vny9.js +0 -19
  158. package/dist/chunk-1apnswz7.js +0 -2
  159. package/dist/chunk-1qvf8ase.js +0 -2
  160. package/dist/chunk-1vt1h19d.js +0 -2
  161. package/dist/chunk-32x78na8.js +0 -2
  162. package/dist/chunk-3z4d7kmp.js +0 -2
  163. package/dist/chunk-4b2vsawv.js +0 -2
  164. package/dist/chunk-616fn77w.js +0 -2
  165. package/dist/chunk-70zk8tj2.js +0 -2
  166. package/dist/chunk-86q2h34b.js +0 -2
  167. package/dist/chunk-88e14er7.js +0 -2
  168. package/dist/chunk-8yydz0hk.js +0 -2
  169. package/dist/chunk-a7yxvxke.js +0 -2
  170. package/dist/chunk-aanwshk6.js +0 -2
  171. package/dist/chunk-ahfj7dc7.js +0 -2
  172. package/dist/chunk-bed5f4bp.js +0 -2
  173. package/dist/chunk-dxkjvajv.js +0 -2
  174. package/dist/chunk-e7np0h2q.js +0 -2
  175. package/dist/chunk-erb294sv.js +0 -2
  176. package/dist/chunk-evfr2zgg.js +0 -2
  177. package/dist/chunk-f85f75jh.js +0 -2
  178. package/dist/chunk-gsc2vds7.js +0 -2
  179. package/dist/chunk-h5jt4mxx.js +0 -2
  180. package/dist/chunk-hke0k33t.js +0 -2
  181. package/dist/chunk-hysq9e9t.js +0 -2
  182. package/dist/chunk-kq30wqp6.js +0 -2
  183. package/dist/chunk-m2j5skez.js +0 -2
  184. package/dist/chunk-ntzzhw3w.js +0 -2
  185. package/dist/chunk-px0bs815.js +0 -2
  186. package/dist/chunk-qw92p9za.js +0 -2
  187. package/dist/chunk-rjwnw5hj.js +0 -2
  188. package/dist/chunk-tmr3xq5d.js +0 -2
  189. package/dist/chunk-tpk6wm38.js +0 -2
  190. package/dist/chunk-vw4b7g24.js +0 -2
  191. package/dist/chunk-x054qzma.js +0 -2
  192. package/dist/chunk-x2n1x19t.js +0 -2
  193. package/dist/chunk-zks9ft7n.js +0 -2
  194. package/dist/chunk-zkxnarrh.js +0 -2
  195. package/dist/chunk-zp14ksx1.js +0 -2
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{Du as Y,Tu as y,gv as A,iv as H,mv as q,ov as b}from"./chunk-avwywzsj.js";import M from"path";class S{source;pos=0;line=1;column=0;tokens=[];constructor(K){this.source=K}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let K=this.nextToken();if(K)this.tokens.push(K)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let K=this.pos,Q=this.line,Z=this.column,$=this.source[this.pos];if(/\s/.test($))return this.readWhitespace(K,Q,Z);if($==="/"&&this.peek(1)==="/")return this.readLineComment(K,Q,Z);if($==="/"&&this.peek(1)==="*")return this.readBlockComment(K,Q,Z);if($==='"'||$==="'")return this.readString($,K,Q,Z);if($==="`")return this.readTemplateString(K,Q,Z);if(/\d/.test($)||$==="."&&/\d/.test(this.peek(1)||""))return this.readNumber(K,Q,Z);if(/[a-z_$]/i.test($))return this.readIdentifier(K,Q,Z);if($==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:K,end:this.pos,line:Q,column:Z};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:K,end:this.pos,line:Q,column:Z};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:K,end:this.pos,line:Q,column:Z}}if($==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:K,end:this.pos,line:Q,column:Z};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:K,end:this.pos,line:Q,column:Z}}if($==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:K,end:this.pos,line:Q,column:Z};if($==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective(K,Q,Z);let z=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let j of z)if(this.source.slice(this.pos,this.pos+j.length)===j)return this.advance(j.length),{type:"OPERATOR",value:j,start:K,end:this.pos,line:Q,column:Z};if(/[+\-*/%<>=!&|^~?:]/.test($))return this.advance(),{type:"OPERATOR",value:$,start:K,end:this.pos,line:Q,column:Z};if(/[()[\]{},;.]/.test($))return this.advance(),{type:"PUNCTUATION",value:$,start:K,end:this.pos,line:Q,column:Z};return this.advance(),{type:"PUNCTUATION",value:$,start:K,end:this.pos,line:Q,column:Z}}readWhitespace(K,Q,Z){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice(K,this.pos),start:K,end:this.pos,line:Q,column:Z}}readLineComment(K,Q,Z){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
2
+ import{Hu as Y,Xu as y,kv as A,mv as H,qv as q,sv as b}from"./chunk-czj6nq0b.js";import M from"path";class S{source;pos=0;line=1;column=0;tokens=[];constructor(K){this.source=K}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let K=this.nextToken();if(K)this.tokens.push(K)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let K=this.pos,Q=this.line,Z=this.column,$=this.source[this.pos];if(/\s/.test($))return this.readWhitespace(K,Q,Z);if($==="/"&&this.peek(1)==="/")return this.readLineComment(K,Q,Z);if($==="/"&&this.peek(1)==="*")return this.readBlockComment(K,Q,Z);if($==='"'||$==="'")return this.readString($,K,Q,Z);if($==="`")return this.readTemplateString(K,Q,Z);if(/\d/.test($)||$==="."&&/\d/.test(this.peek(1)||""))return this.readNumber(K,Q,Z);if(/[a-z_$]/i.test($))return this.readIdentifier(K,Q,Z);if($==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:K,end:this.pos,line:Q,column:Z};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:K,end:this.pos,line:Q,column:Z};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:K,end:this.pos,line:Q,column:Z}}if($==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:K,end:this.pos,line:Q,column:Z};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:K,end:this.pos,line:Q,column:Z}}if($==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:K,end:this.pos,line:Q,column:Z};if($==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective(K,Q,Z);let z=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let j of z)if(this.source.slice(this.pos,this.pos+j.length)===j)return this.advance(j.length),{type:"OPERATOR",value:j,start:K,end:this.pos,line:Q,column:Z};if(/[+\-*/%<>=!&|^~?:]/.test($))return this.advance(),{type:"OPERATOR",value:$,start:K,end:this.pos,line:Q,column:Z};if(/[()[\]{},;.]/.test($))return this.advance(),{type:"PUNCTUATION",value:$,start:K,end:this.pos,line:Q,column:Z};return this.advance(),{type:"PUNCTUATION",value:$,start:K,end:this.pos,line:Q,column:Z}}readWhitespace(K,Q,Z){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice(K,this.pos),start:K,end:this.pos,line:Q,column:Z}}readLineComment(K,Q,Z){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
3
3
  `)this.advance();return{type:"COMMENT",value:this.source.slice(K,this.pos),start:K,end:this.pos,line:Q,column:Z}}readBlockComment(K,Q,Z){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice(K,this.pos),start:K,end:this.pos,line:Q,column:Z}}readString(K,Q,Z,$){this.advance();while(this.pos<this.source.length){let z=this.source[this.pos];if(z==="\\"){this.advance(2);continue}if(z===K){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(Q,this.pos),start:Q,end:this.pos,line:Z,column:$}}readTemplateString(K,Q,Z){this.advance();let $=0,z=256;while(this.pos<this.source.length){let j=this.source[this.pos];if(j==="\\"){this.advance(2);continue}if(j==="$"&&this.peek(1)==="{"){if($>=z){this.pos=this.source.length;break}this.advance(2),$++;continue}if(j==="{"&&$>0){$++,this.advance();continue}if(j==="}"&&$>0){$--,this.advance();continue}if(j==="`"&&$===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice(K,this.pos),start:K,end:this.pos,line:Q,column:Z}}readNumber(K,Q,Z){if(this.source[this.pos]==="0"){let $=this.peek(1)?.toLowerCase();if($==="x"||$==="o"||$==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice(K,this.pos),start:K,end:this.pos,line:Q,column:Z}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&/\d/.test(this.peek(1)||"")){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice(K,this.pos),start:K,end:this.pos,line:Q,column:Z}}readIdentifier(K,Q,Z){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice(K,this.pos),start:K,end:this.pos,line:Q,column:Z}}readDirective(K,Q,Z){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice(K,this.pos),start:K,end:this.pos,line:Q,column:Z}}advance(K=1){for(let Q=0;Q<K&&this.pos<this.source.length;Q++){if(this.source[this.pos]===`
4
4
  `)this.line++,this.column=0;else this.column++;this.pos++}}peek(K){return this.source[this.pos+K]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState(K){this.pos=K.pos,this.line=K.line,this.column=K.column}}function D(K,Q,Z,$=0){let z=0,j=$,J=null,W=0,X=!1;while(j<K.length){let B=K[j];if(J&&X){X=!1,j++;continue}if(J&&B==="\\"){X=!0,j++;continue}if(X=!1,(B==='"'||B==="'"||B==="`")&&!J){J=B,j++;continue}if(B===J&&J!=="`"){J=null,j++;continue}if(J==="`"&&B==="$"&&K[j+1]==="{"){W++,j+=2;continue}if(W>0&&B==="}"){W--,j++;continue}if(B==="`"&&J==="`"&&W===0){J=null,j++;continue}if(J){j++;continue}if(B===Q)z++;else if(B===Z){if(z--,z===0)return j}j++}return-1}function g(K,Q){let Z=Q,$={paren:0,bracket:0,brace:0},z=null,j=0;while(Z<K.length){let J=K[Z];if((Z>0?K[Z-1]:"")==="\\"&&z){Z++;continue}if((J==='"'||J==="'")&&!z){z=J,Z++;continue}if(J===z&&z!=="`"){z=null,Z++;continue}if(J==="`"&&!z){z="`",Z++;continue}if(J==="`"&&z==="`"&&j===0){z=null,Z++;continue}if(z==="`"&&J==="$"&&K[Z+1]==="{"){j++,Z+=2;continue}if(j>0){if(J==="{")j++;else if(J==="}")j--;Z++;continue}if(z){Z++;continue}if($.paren===0&&$.bracket===0&&$.brace===0){if(K.slice(Z,Z+2)==="}}"||K.slice(Z,Z+3)==="!!}")break;if(J===","||J===";")break}if(J==="(")$.paren++;else if(J===")"){if($.paren--,$.paren<0)break}else if(J==="[")$.bracket++;else if(J==="]"){if($.bracket--,$.bracket<0)break}else if(J==="{")$.brace++;else if(J==="}"){if($.brace--,$.brace<0)break}Z++}return{expression:K.slice(Q,Z),endPos:Z}}function l(K){let Q=[],Z="",$={paren:0,bracket:0,brace:0},z=null,j=0;for(let J=0;J<K.length;J++){let W=K[J];if((J>0?K[J-1]:"")==="\\"&&z){Z+=W;continue}if((W==='"'||W==="'")&&!z){z=W,Z+=W;continue}if(W===z&&z!=="`"){z=null,Z+=W;continue}if(W==="`"&&!z){z="`",Z+=W;continue}if(W==="`"&&z==="`"&&j===0){z=null,Z+=W;continue}if(z==="`"&&W==="$"&&K[J+1]==="{"){j++,Z+=W+K[J+1],J++;continue}if(j>0&&W==="{"){j++,Z+=W;continue}if(j>0&&W==="}"){j--,Z+=W;continue}if(z){Z+=W;continue}if(W==="(")$.paren++;else if(W===")")$.paren--;else if(W==="[")$.bracket++;else if(W==="]")$.bracket--;else if(W==="{")$.brace++;else if(W==="}")$.brace--;if(W==="|"&&K[J+1]!=="|"&&(J===0||K[J-1]!=="|")&&K[J-1]!=="\\"&&$.paren===0&&$.bracket===0&&$.brace===0){Q.push(Z.trim()),Z="";continue}if(W==="|"&&K[J-1]==="\\"&&!z){Z=Z.slice(0,-1)+W;continue}Z+=W}if(Z.trim())Q.push(Z.trim());return Q}function C(K,Q){let Z=[];Q.lastIndex=0;let $;while(($=Q.exec(K))!==null){let z=$.index,j=z+$[0].length-1,J=D(K,"(",")",j);if(J===-1){Z.push({start:z,end:-1,args:"",call:K.slice(z,Math.min(K.length,z+80))}),Q.lastIndex=j+1;continue}Z.push({start:z,end:J+1,args:K.slice(j+1,J),call:K.slice(z,J+1)}),Q.lastIndex=J+1}return Z}function w(K,Q,Z,$){let z="",j=0;for(let J of C(K,Q)){if(z+=K.slice(j,J.start),J.end===-1){z+=$(J.call),j=J.start;continue}z+=Z(J.args,J.call),j=J.end}return z+K.slice(j)}function k(K){let Q=[],Z=0,$=null,z="";for(let j=0;j<K.length;j++){let J=K[j];if($){if(z+=J,J==="\\"&&j+1<K.length){z+=K[++j];continue}if(J===$)$=null;continue}if(J==="'"||J==='"'||J==="`")$=J;else if(J==="("||J==="["||J==="{")Z++;else if(J===")"||J==="]"||J==="}")Z--;else if(J===","&&Z===0){Q.push(z.trim()),z="";continue}z+=J}if(z.trim())Q.push(z.trim());return Q}function V(K){let Q=K.trim(),Z=Q[0];if(Z!=="'"&&Z!=='"'&&Z!=="`"||Q.length<2||Q.at(-1)!==Z)return null;let $="";for(let z=1;z<Q.length-1;z++){let j=Q[z];if(j==="\\"&&z+1<Q.length-1){let J=Q[++z];$+=J==="n"?`
5
5
  `:J==="t"?"\t":J;continue}if(j===Z)return null;if(Z==="`"&&j==="$"&&Q[z+1]==="{")return null;$+=j}return $}var x=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function N(K,Q){let Z=K.trim();if(!Z)return{ok:!1,message:"the argument is empty",code:Y.INVALID_DIRECTIVE_SYNTAX};let $=A(Z);if($)return{ok:!1,message:`the expression is not allowed (${$})`,code:Y.UNSAFE_EXPRESSION};let z=H(Q),j;try{j=b(Z,Object.keys(z))(...Object.values(z))}catch(W){return{ok:!1,message:`the expression could not be evaluated: ${W instanceof Error?W.message:String(W)}`,code:Y.EVALUATION_ERROR}}if(j!==void 0&&j!==null)return{ok:!0,value:j};let J=[...new Set(q(Z))].filter((W)=>!x.has(W)&&!(W in z)&&!(W in globalThis));if(J.length>0)return{ok:!1,message:`${J.map((X)=>`"${X}"`).join(", ")} ${J.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:Y.UNDEFINED_VARIABLE};if(j===void 0&&(Z.startsWith("{")||Z.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:Y.EVALUATION_ERROR};return{ok:!0,value:j}}function _(K){if(K===null)return"null";if(Array.isArray(K))return"an array";if(typeof K==="object")return"an object";if(typeof K==="string")return`a string ("${K.length>40?`${K.slice(0,40)}...`:K}")`;return`${/^[aeiou]/.test(typeof K)?"an":"a"} ${typeof K}`}function T(K){return typeof K==="object"&&K!==null&&!Array.isArray(K)}function L(K){if(!K)return"";return M.isAbsolute(K)?M.relative(process.cwd(),K)||K:K}function G(K){let Q=K.replace(/\s+/g," ").trim();return Q.length>80?`${Q.slice(0,77)}...`:Q}function I(K,Q,Z,$,z=Y.EVALUATION_ERROR){let j=$?` in ${L($)}`:"";return console.warn(`[stx] ${G(Q)}${j}: ${Z}`),y(K,`${G(Q)}: ${Z}`,z)}function a(K,Q,Z){let $=Z?` in ${L(Z)}`:"";console.warn(`[stx] ${G(K)}${$}: ${Q}`)}var v=["og:","article:","book:","profile:","fb:","music:","video:"],d=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function E(K,Q){if(K.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:Y.INVALID_DIRECTIVE_SYNTAX};if(K.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${K.length} arguments`,code:Y.INVALID_DIRECTIVE_SYNTAX};let Z=m(K[0],Q);if(typeof Z!=="string")return Z;let $;if(K.length===2){let j=h(K[1],Q);if(typeof j!=="string")return j;$=j}else{let j=Z.includes(":")?Z.slice(Z.indexOf(":")+1):Z,J=Q.openGraph,W=Q[j]??(T(J)?J[j]:void 0);$=W===void 0||W===null||typeof W==="object"?"":String(W)}if(!$)return{kind:"empty"};return{kind:"tag",tag:v.some((j)=>Z.startsWith(j))?{property:Z,content:$}:{name:Z,content:$}}}function m(K,Q){let Z=V(K);if(Z!==null)return Z.trim()?Z:{kind:"error",message:"the meta name is empty",code:Y.INVALID_DIRECTIVE_SYNTAX};if(d.test(K.trim()))return K.trim();let $=N(K,Q);if(!$.ok)return{kind:"error",message:`meta name: ${$.message}`,code:$.code};if(typeof $.value!=="string"||!$.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${_($.value)}`,code:Y.TYPE_ERROR};return $.value}function h(K,Q){let Z=V(K);if(Z!==null)return Z;let $=N(K,Q);if(!$.ok)return{kind:"error",message:$.message,code:$.code};let z=$.value;if(z===void 0||z===null||z===!1)return"";if(Array.isArray(z))return z.filter((j)=>j!==void 0&&j!==null&&j!=="").map(String).join(", ");if(typeof z==="object"&&!(z instanceof Date))return{kind:"error",message:`the content must be text, got ${_(z)}`,code:Y.TYPE_ERROR};return String(z)}var O={},p=[],F={};function jK(){return O}function zK(){return F}function JK(){O={},p.length=0,F={}}function P(K){O=R(O,K)}function R(K,Q){return{title:Q.title??K.title,titleTemplate:Q.titleTemplate??K.titleTemplate,base:Q.base??K.base,meta:[...K.meta||[],...Q.meta||[]],link:[...K.link||[],...Q.link||[]],script:[...K.script||[],...Q.script||[]],style:[...K.style||[],...Q.style||[]],htmlAttrs:{...K.htmlAttrs,...Q.htmlAttrs},bodyAttrs:{...K.bodyAttrs,...Q.bodyAttrs}}}function u(K){P(f(K))}function f(K){let Q=[];if(K.description)Q.push({name:"description",content:K.description});if(K.keywords){let X=Array.isArray(K.keywords)?K.keywords.join(", "):K.keywords;Q.push({name:"keywords",content:X})}if(K.author)Q.push({name:"author",content:K.author});if(K.robots)Q.push({name:"robots",content:K.robots});let Z=K.ogTitle??K.title,$=K.ogDescription??K.description;if(Z)Q.push({property:"og:title",content:Z});if($)Q.push({property:"og:description",content:$});if(K.ogImage){if(Q.push({property:"og:image",content:K.ogImage}),K.ogImageType)Q.push({property:"og:image:type",content:K.ogImageType});if(K.ogImageWidth)Q.push({property:"og:image:width",content:String(K.ogImageWidth)});if(K.ogImageHeight)Q.push({property:"og:image:height",content:String(K.ogImageHeight)});if(K.ogImageAlt)Q.push({property:"og:image:alt",content:K.ogImageAlt})}if(K.ogUrl)Q.push({property:"og:url",content:K.ogUrl});if(K.ogType)Q.push({property:"og:type",content:K.ogType});if(K.ogSiteName)Q.push({property:"og:site_name",content:K.ogSiteName});if(K.ogLocale)Q.push({property:"og:locale",content:K.ogLocale});if(K.profileFirstName)Q.push({property:"profile:first_name",content:K.profileFirstName});if(K.profileLastName)Q.push({property:"profile:last_name",content:K.profileLastName});if(K.profileUsername)Q.push({property:"profile:username",content:K.profileUsername});let z=K.twitterTitle??K.title,j=K.twitterDescription??K.description,J=K.twitterImage??K.ogImage;if(K.twitterCard)Q.push({name:"twitter:card",content:K.twitterCard});if(z)Q.push({name:"twitter:title",content:z});if(j)Q.push({name:"twitter:description",content:j});if(J){Q.push({name:"twitter:image",content:J});let X=K.twitterImageAlt??(K.twitterImage?void 0:K.ogImageAlt);if(X)Q.push({name:"twitter:image:alt",content:X})}if(K.twitterSite)Q.push({name:"twitter:site",content:K.twitterSite});if(K.twitterCreator)Q.push({name:"twitter:creator",content:K.twitterCreator});if(K.articleAuthor)Q.push({property:"article:author",content:K.articleAuthor});if(K.articlePublishedTime)Q.push({property:"article:published_time",content:K.articlePublishedTime});if(K.articleModifiedTime)Q.push({property:"article:modified_time",content:K.articleModifiedTime});if(K.articleSection)Q.push({property:"article:section",content:K.articleSection});if(K.articleTags)for(let X of K.articleTags)Q.push({property:"article:tag",content:X});let W=[];if(K.canonical)W.push({rel:"canonical",href:K.canonical});return{title:K.title,titleTemplate:K.titleTemplate,meta:Q,link:W}}function WK(K){if(F={...F,...K},K.title||K.description)u({title:K.title,description:K.description})}function XK(K){let Q=typeof K==="function"?K():K;P({title:Q})}function YK(K=O){let Q=[];if(K.title){let Z=K.title;if(K.titleTemplate)Z=typeof K.titleTemplate==="function"?K.titleTemplate(Z):K.titleTemplate.replace("%s",Z);Q.push(`<title>${U(Z)}</title>`)}if(K.base){let Z=Object.entries(K.base).map(([$,z])=>`${$}="${U(z)}"`).join(" ");Q.push(`<base ${Z}>`)}for(let Z of K.meta||[]){let $=Object.entries(Z).filter(([z,j])=>j!==void 0).map(([z,j])=>{return`${z==="httpEquiv"?"http-equiv":z}="${U(String(j))}"`}).join(" ");Q.push(`<meta ${$}>`)}for(let Z of K.link||[]){let $=Object.entries(Z).filter(([z,j])=>j!==void 0).map(([z,j])=>`${z}="${U(String(j))}"`).join(" ");Q.push(`<link ${$}>`)}for(let Z of K.script||[]){let{content:$,...z}=Z,j=Object.entries(z).filter(([J,W])=>W!==void 0).map(([J,W])=>{if(typeof W==="boolean")return W?J:"";return`${J}="${U(String(W))}"`}).filter(Boolean).join(" ");if($)Q.push(`<script ${j}>${$}</script>`);else Q.push(`<script ${j}></script>`)}for(let Z of K.style||[]){let $=Z.type?` type="${Z.type}"`:"";Q.push(`<style${$}>${Z.content}</style>`)}return Q.join(`
6
6
  `)}function BK(K=O){if(!K.htmlAttrs)return"";return Object.entries(K.htmlAttrs).map(([Q,Z])=>`${Q}="${U(Z)}"`).join(" ")}function OK(K=O){if(!K.bodyAttrs)return"";return Object.entries(K.bodyAttrs).map(([Q,Z])=>`${Q}="${U(Z)}"`).join(" ")}function U(K){return K.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function UK(K=O){if(typeof document>"u")return;if(K.title){let Q=K.title;if(K.titleTemplate)Q=typeof K.titleTemplate==="function"?K.titleTemplate(Q):K.titleTemplate.replace("%s",Q);document.title=Q}for(let Q of K.meta||[]){let Z=Q.name?`meta[name="${Q.name}"]`:Q.property?`meta[property="${Q.property}"]`:null;if(Z){let $=document.querySelector(Z);if(!$){if($=document.createElement("meta"),Q.name)$.setAttribute("name",Q.name);if(Q.property)$.setAttribute("property",Q.property);document.head.appendChild($)}$.setAttribute("content",Q.content)}}for(let Q of K.link||[]){let Z=`link[rel="${Q.rel}"]${Q.href?`[href="${Q.href}"]`:""}`,$=document.querySelector(Z);if(!$)$=document.createElement("link"),document.head.appendChild($);for(let[z,j]of Object.entries(Q))if(j!==void 0)$.setAttribute(z,String(j))}if(K.htmlAttrs)for(let[Q,Z]of Object.entries(K.htmlAttrs))if(Q==="class")for(let $ of String(Z).split(/\s+/).filter(Boolean))document.documentElement.classList.add($);else document.documentElement.setAttribute(Q,Z);if(K.bodyAttrs)for(let[Q,Z]of Object.entries(K.bodyAttrs))document.body.setAttribute(Q,Z)}function FK(K){let Q="";return{content:K.replace(/@head\s*([\s\S]*?)@endhead/g,($,z)=>{return Q+=z.trim()+`
7
- `,""}),headContent:Q.trim()}}function GK(K,Q){return K.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Z,$,z,j)=>{let J=$?z:Q[(j||"").trim()]??j,W=Q.__stx_runtime_head??{};return Q.__stx_runtime_head=R(W,{title:J}),""})}function VK(K,Q,Z=""){if(!K.includes("@meta"))return K;return w(K,/(?<![\w$@])@meta\s*\(/g,($,z)=>{let j=E(k($),Q);if(j.kind==="error")return I("Meta",z,j.message,Z,j.code);if(j.kind==="tag"){let J=Q.__stx_runtime_head??{};Q.__stx_runtime_head=R(J,{meta:[j.tag]})}return""},($)=>I("Meta",$,"the call has no closing parenthesis",Z,Y.INVALID_DIRECTIVE_SYNTAX))}export{S as Wt,D as Xt,g as Yt,l as Zt,C as _t,w as $t,k as au,N as bu,_ as cu,T as du,I as eu,a as fu,E as gu,jK as hu,zK as iu,JK as ju,P as ku,R as lu,u as mu,f as nu,WK as ou,XK as pu,YK as qu,BK as ru,OK as su,UK as tu,FK as uu,GK as vu,VK as wu};
7
+ `,""}),headContent:Q.trim()}}function GK(K,Q){return K.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Z,$,z,j)=>{let J=$?z:Q[(j||"").trim()]??j,W=Q.__stx_runtime_head??{};return Q.__stx_runtime_head=R(W,{title:J}),""})}function VK(K,Q,Z=""){if(!K.includes("@meta"))return K;return w(K,/(?<![\w$@])@meta\s*\(/g,($,z)=>{let j=E(k($),Q);if(j.kind==="error")return I("Meta",z,j.message,Z,j.code);if(j.kind==="tag"){let J=Q.__stx_runtime_head??{};Q.__stx_runtime_head=R(J,{meta:[j.tag]})}return""},($)=>I("Meta",$,"the call has no closing parenthesis",Z,Y.INVALID_DIRECTIVE_SYNTAX))}export{S as _t,D as $t,g as au,l as bu,C as cu,w as du,k as eu,N as fu,_ as gu,T as hu,I as iu,a as ju,E as ku,jK as lu,zK as mu,JK as nu,P as ou,R as pu,u as qu,f as ru,WK as su,XK as tu,YK as uu,BK as vu,OK as wu,UK as xu,FK as yu,GK as zu,VK as Au};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  import v from"fs";import z from"path";import{fileURLToPath as B}from"url";var x;function G(){if(x)return x;let j="unknown";try{j=String(JSON.parse(v.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let A=z.dirname(B(import.meta.url)),q=0;for(let k of v.readdirSync(A,{recursive:!0,withFileTypes:!0}))if(k.isFile()&&k.name.endsWith(".ts"))q=Math.max(q,v.statSync(z.join(k.parentPath,k.name)).mtimeMs);j+=`+src.${Math.trunc(q)}`}catch{}return x=j,j}
3
- export{G as tl};
3
+ export{G as ul};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{am as x,aq as M}from"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import{Fs as B,Hs as P}from"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";import G from"path";var T=["broadcast","calculateDistance","canNotify","clearCookies","clearFetchCache","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],O=new Set(T);var K=new Map,U=B(64),V=new Set,D=0,N=new Set(T);function f(){K.clear(),U.clear()}function S(H){let J=new Map;for(let Q of H){let Z=G.basename(Q);if(Z.endsWith(".d.ts"))continue;let z=Z.replace(/\.[jt]s$/,"");if(z==="index")continue;if(z===Z)continue;let X=J.get(z);if(X&&!X.endsWith(".js"))continue;J.set(z,Q)}return[...J.values()].sort()}function g(H,J){let Q=J.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${Q}\\b`).test(H)}function y(H){if(!H)return[];let J=P(H,D),Q=U.get(J);if(Q)return Q.slice();let Z=H.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),z=[];for(let X of N){if(V.has(X))continue;let A=X.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${A}\\s*\\(`).test(Z))z.push(X)}return z.sort(),U.set(J,z),z.slice()}async function p(H,J){let Q=y(H);if(Q.length===0)return null;let Z=J??G.join(import.meta.dir,"composables"),z=`${Z}\x00${Q.join(",")}`,X=K.get(z);if(X!==void 0)return X||null;let A=M({loader:"ts",target:"browser",define:x()}),L=new Set(Q),W=[],C=new Set,F=[];try{let q=new Bun.Glob("*.{ts,js}");for await(let j of q.scan({cwd:Z,absolute:!0}))F.push(j)}catch{return K.set(z,""),null}F=S(F);for(let q of F){let j;try{j=await Bun.file(q).text()}catch{continue}let I=[];try{I=A.scan(j).exports.filter(($)=>$!=="default")}catch{continue}if(!I.some(($)=>L.has($)))continue;try{j=j.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^import\s+type\s+.*$/gm,""),j=j.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),j=j.replace(/^export\s+default\s+/gm,""),j=j.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),W.push(`// ${G.basename(q).replace(/\.[jt]s$/,"")}
2
+ import{bm as x,eq as M}from"./chunk-3ssjb8cx.js";import"./chunk-ykevda74.js";import"./chunk-ez003q74.js";import"./chunk-kyyt9xhs.js";import"./chunk-tf16jtj4.js";import"./chunk-19m7hed6.js";import{Js as B,Ls as P}from"./chunk-kjd9hbg4.js";import"./chunk-ejwfnttb.js";import"./chunk-5270fyk7.js";import"./chunk-q4kgqqed.js";import"./chunk-1nnza3m6.js";import"./chunk-hkrzv980.js";import"./chunk-qbz6yn8c.js";import"./chunk-czj6nq0b.js";import"./chunk-zxfejz72.js";import"./chunk-mere396d.js";import"./chunk-aa8015mk.js";import"./chunk-trva71am.js";import"./chunk-rtfwn4cm.js";import"./chunk-emjmshj8.js";import G from"path";var T=["broadcast","calculateDistance","canNotify","clearCookies","clearFetchCache","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],O=new Set(T);var K=new Map,U=B(64),V=new Set,D=0,N=new Set(T);function f(){K.clear(),U.clear()}function S(H){let J=new Map;for(let Q of H){let Z=G.basename(Q);if(Z.endsWith(".d.ts"))continue;let z=Z.replace(/\.[jt]s$/,"");if(z==="index")continue;if(z===Z)continue;let X=J.get(z);if(X&&!X.endsWith(".js"))continue;J.set(z,Q)}return[...J.values()].sort()}function g(H,J){let Q=J.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${Q}\\b`).test(H)}function y(H){if(!H)return[];let J=P(H,D),Q=U.get(J);if(Q)return Q.slice();let Z=H.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),z=[];for(let X of N){if(V.has(X))continue;let A=X.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${A}\\s*\\(`).test(Z))z.push(X)}return z.sort(),U.set(J,z),z.slice()}async function p(H,J){let Q=y(H);if(Q.length===0)return null;let Z=J??G.join(import.meta.dir,"composables"),z=`${Z}\x00${Q.join(",")}`,X=K.get(z);if(X!==void 0)return X||null;let A=M({loader:"ts",target:"browser",define:x()}),L=new Set(Q),W=[],C=new Set,F=[];try{let q=new Bun.Glob("*.{ts,js}");for await(let j of q.scan({cwd:Z,absolute:!0}))F.push(j)}catch{return K.set(z,""),null}F=S(F);for(let q of F){let j;try{j=await Bun.file(q).text()}catch{continue}let I=[];try{I=A.scan(j).exports.filter(($)=>$!=="default")}catch{continue}if(!I.some(($)=>L.has($)))continue;try{j=j.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^import\s+type\s+.*$/gm,""),j=j.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),j=j.replace(/^export\s+default\s+/gm,""),j=j.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),W.push(`// ${G.basename(q).replace(/\.[jt]s$/,"")}
3
3
  ${A.transformSync(j).trim()}`);for(let $ of I)C.add($)}catch($){console.warn(`[stx] framework composable ${G.basename(q)} could not be bundled:`,$)}}let Y=Q.filter((q)=>!C.has(q)&&!g(H,q));if(Y.length>0)console.warn(`[stx] could not bundle ${Y.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(W.length===0)return K.set(z,""),null;let k=[...C].map((q)=>` try { if (!(${JSON.stringify(q)} in __s)) { __s[${JSON.stringify(q)}] = ${q}; if (!(${JSON.stringify(q)} in window)) window[${JSON.stringify(q)}] = ${q}; } } catch (e) {}`).join(`
4
4
  `),w=`<script data-stx-framework-composables>
5
5
  ;(function(){
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Af as L,Bf as w,Cf as x,Df as p,Ef as F,Ff as T,If as I,Jf as f,Kf as l,Lf as n,Mf as i,Nf as P,Of as o,Pf as a}from"./chunk-7qp3zphs.js";import{xs as ZG}from"./chunk-xvh1k1a4.js";function HG(X,Z={}){let{src:G,alt:J,width:q,height:$,sizes:K="100vw",loading:Q="lazy",priority:Y=!1,quality:M=x,placeholder:N="none",formats:j=w,widths:C=L,decoding:B="async",fetchpriority:V,objectFit:O,objectPosition:W}=X,H=X.class,z=X.style,{processedImage:R,variants:_,optimize:E=!0,isDev:S=!1}=Z;if(_&&_.length>0)return OG(X,_,R);if(S||!E)return MG(X);return VG(X)}function OG(X,Z,G){let{src:J,alt:q,width:$,height:K,sizes:Q="100vw",loading:Y="lazy",priority:M=!1,decoding:N="async",fetchpriority:j,objectFit:C,objectPosition:B,placeholder:V="none"}=X,O=X.class,W=X.style,H=n(Z),z=l(Z),R=typeof Q==="object"?f(Q):Q,_=G?G.aspectRatio:$&&K?Number($)/Number(K):void 0,E=[];if(_)E.push(`aspect-ratio: ${_}`);if(C)E.push(`object-fit: ${C}`);if(B)E.push(`object-position: ${B}`);if(W)E.push(W);let S=E.length>0?` style="${E.join("; ")}"`:"",b=O?` class="${O}"`:"",u=M?"":` loading="${Y}"`,d=` decoding="${N}"`,h=j?` fetchpriority="${j}"`:M?' fetchpriority="high"':"",r=["avif","webp","jpeg","png"],s=[];for(let U of r){let D=H.get(U);if(D&&D.length>0){let m=I(D),QG=P(U);s.push(` <source type="${QG}" srcset="${m}" sizes="${R}" />`)}}let e="",t="",g;if(V!=="none"&&G?.placeholder){let U=`img-${Math.random().toString(36).slice(2,8)}`;if(e=`<div class="stx-image-wrapper" id="${U}">`,t="</div>",V==="blur")g=`
2
+ import{Bf as L,Cf as w,Df as x,Ef as p,Ff as F,Gf as T,Jf as I,Kf as f,Lf as l,Mf as n,Nf as i,Of as P,Pf as o,Qf as a}from"./chunk-hy79zwyy.js";import{Bs as ZG}from"./chunk-19m7hed6.js";function HG(X,Z={}){let{src:G,alt:J,width:q,height:$,sizes:K="100vw",loading:Q="lazy",priority:Y=!1,quality:M=x,placeholder:N="none",formats:j=w,widths:C=L,decoding:B="async",fetchpriority:V,objectFit:O,objectPosition:W}=X,H=X.class,z=X.style,{processedImage:R,variants:_,optimize:E=!0,isDev:S=!1}=Z;if(_&&_.length>0)return OG(X,_,R);if(S||!E)return MG(X);return VG(X)}function OG(X,Z,G){let{src:J,alt:q,width:$,height:K,sizes:Q="100vw",loading:Y="lazy",priority:M=!1,decoding:N="async",fetchpriority:j,objectFit:C,objectPosition:B,placeholder:V="none"}=X,O=X.class,W=X.style,H=n(Z),z=l(Z),R=typeof Q==="object"?f(Q):Q,_=G?G.aspectRatio:$&&K?Number($)/Number(K):void 0,E=[];if(_)E.push(`aspect-ratio: ${_}`);if(C)E.push(`object-fit: ${C}`);if(B)E.push(`object-position: ${B}`);if(W)E.push(W);let S=E.length>0?` style="${E.join("; ")}"`:"",b=O?` class="${O}"`:"",u=M?"":` loading="${Y}"`,d=` decoding="${N}"`,h=j?` fetchpriority="${j}"`:M?' fetchpriority="high"':"",r=["avif","webp","jpeg","png"],s=[];for(let U of r){let D=H.get(U);if(D&&D.length>0){let m=I(D),QG=P(U);s.push(` <source type="${QG}" srcset="${m}" sizes="${R}" />`)}}let e="",t="",g;if(V!=="none"&&G?.placeholder){let U=`img-${Math.random().toString(36).slice(2,8)}`;if(e=`<div class="stx-image-wrapper" id="${U}">`,t="</div>",V==="blur")g=`
3
3
  #${U} {
4
4
  position: relative;
5
5
  background-image: url('${G.placeholder}');
@@ -40,4 +40,4 @@ ${O}
40
40
  ${O}
41
41
  </div>`}}if(G.priority&&C){let W=P(C.format);O=`<link rel="preload" as="image" href="${k(C.url)}" type="${W}" />
42
42
  `+O}return O}function k(X){return X.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var UG=$G();import v from"fs";import A from"path";function LG(X={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:G="dist/images",baseUrl:J="/images",formats:q=w,widths:$=L,quality:K=x,placeholder:Q="none",concurrency:Y=4,cache:M=!0,cacheDir:N=".stx/image-cache",referencedOnly:j=!1,verbose:C=!1}=X,B={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(V){if(!await F()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(M)await v.promises.mkdir(N,{recursive:!0});if(C){let W=await p();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${W?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),console.log(` Input dirs: ${Z.join(", ")}`),console.log(` Output dir: ${G}`),console.log(` Formats: ${q.join(", ")}`),console.log(` Widths: ${$.join(", ")}`)}},async buildStart(){B.imageReferences.clear(),B.processedImages.clear(),B.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(V,O){if(O.endsWith(".html")||O.endsWith(".stx")){let W=wG(V);for(let H of W)B.imageReferences.add(H)}if(V.includes("<Image")||V.includes("@image"))return await kG(V,{formats:q,widths:$,quality:K,placeholder:Q,outputDir:G,baseUrl:J,processedImages:B.processedImages});return V},async buildEnd(V){if(!await F())return;await v.promises.mkdir(G,{recursive:!0});let W=[];for(let R of Z){if(!v.existsSync(R))continue;let _=await KG(R);W.push(..._)}let H=j?W.filter((R)=>xG(R,B.imageReferences)):W;if(B.stats.totalImages=H.length,C)console.log(`[stx-images] Processing ${H.length} images...`);let z=qG(H,Y);for(let R of z)await Promise.all(R.map(async(_)=>{try{let E=await T(_,{formats:q,widths:$,quality:K,placeholder:Q,outputDir:G,baseUrl:J});B.processedImages.set(_,E),B.stats.optimizedImages++,B.stats.variants+=E.variants.length;let S=v.statSync(_).size,b=o(E.variants);if(B.stats.savedBytes+=Math.max(0,S-b/E.variants.length),C)console.log(` \u2713 ${A.basename(_)} \u2192 ${E.variants.length} variants`)}catch(E){console.error(`[stx-images] Error processing ${_}:`,E)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${B.stats.optimizedImages}/${B.stats.totalImages}`),console.log(` Variants: ${B.stats.variants}`),B.stats.savedBytes>0)console.log(` Saved: ~${a(B.stats.savedBytes)}`)}}}function wG(X){let Z=[],G=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,J;while((J=G.exec(X))!==null)Z.push(J[1]);let q=/<Image[^>]+src=["']([^"']+)["']/gi;while((J=q.exec(X))!==null)Z.push(J[1]);let $=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((J=$.exec(X))!==null)Z.push(J[1]);let K=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((J=K.exec(X))!==null)Z.push(J[1]);return Z}function xG(X,Z){let G=A.basename(X);for(let J of Z)if(J.endsWith(G)||J.includes(G))return!0;return!1}async function kG(X,Z){return X}async function KG(X){let Z=[];async function G(J){let q=await v.promises.readdir(J,{withFileTypes:!0});for(let $ of q){let K=A.join(J,$.name);if($.isDirectory())await G(K);else if($.isFile()&&i(K))Z.push(K)}}return await G(X),Z}function qG(X,Z){let G=[];for(let J=0;J<X.length;J+=Z)G.push(X.slice(J,J+Z));return G}async function FG(X,Z,G={}){if(!await F())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return T(X,{...G,outputDir:Z})}async function SG(X,Z,G={}){let{formats:J=w,widths:q=L,quality:$=x,placeholder:K="none",concurrency:Q=4,verbose:Y=!1}=G;if(!await F())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await v.promises.mkdir(Z,{recursive:!0});let N=await KG(X),j=[],C={totalImages:N.length,optimizedImages:0,savedBytes:0,variants:0},B=qG(N,Q);for(let V of B){let O=await Promise.all(V.map(async(W)=>{try{let H=await T(W,{formats:J,widths:q,quality:$,placeholder:K,outputDir:Z,baseUrl:"/"});if(C.optimizedImages++,C.variants+=H.variants.length,Y)console.log(` \u2713 ${A.basename(W)}`);return H}catch(H){return console.error(`Error processing ${W}:`,H),null}}));j.push(...O.filter((W)=>W!==null))}return{processed:j,stats:C}}function YG(X){let Z={};for(let G of X)Z[G.src]={variants:G.variants,placeholder:G.placeholder};return Z}async function PG(X,Z){let G=YG(X);await Bun.write(Z,JSON.stringify(G,null,2))}var cG={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"};
43
- export{HG as mf,JG as nf,jG as of,CG as pf,$G as qf,UG as rf,LG as sf,FG as tf,SG as uf,YG as vf,PG as wf,cG as xf};
43
+ export{HG as nf,JG as of,jG as pf,CG as qf,$G as rf,UG as sf,LG as tf,FG as uf,SG as vf,YG as wf,PG as xf,cG as yf};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  import z from"fs";function B(x){return[...x].sort().map((b)=>{try{let j=z.statSync(b);return`${b}:${j.size}:${j.mtimeMs}`}catch{return`${b}:missing`}}).join(`
3
3
  `)}function C(x,b,j){let q=x.get(b);return q!==void 0&&q.signature===j?q.value:void 0}function D(x,b,j,q){return x.set(b,{signature:j,value:q}),q}
4
- export{B as Ji,C as Ki,D as Li};
4
+ export{B as Ki,C as Li,D as Mi};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{ig as e,kg as kF,lg as UF,mg as wF,ug as EF}from"./chunk-g7msqva8.js";import{xg as BF}from"./chunk-57atgbyq.js";import{nj as l,oj as d}from"./chunk-8m0g0h4x.js";import{Ck as HF,Dk as IF,Ek as KF}from"./chunk-c0n802j1.js";import{ml as YF,ol as ZF}from"./chunk-ngjkzaj7.js";import{Fp as VF,Jp as r,Op as o,Wm as s,io as zF,ip as $F,nm as p,pm as i,qr as t,sr as M,xp as GF}from"./chunk-msq8xvhp.js";import{ss as XF}from"./chunk-89mqnh67.js";import{it as qF}from"./chunk-9e20mgwc.js";import{Ct as WF}from"./chunk-gtqbvt3a.js";import{Ht as QF}from"./chunk-vhta1be7.js";import{Aw as h,Dw as _F}from"./chunk-swvm1wgn.js";import G from"fs";import q from"path";import{createHash as NF}from"crypto";_F();function u(Q){return NF("sha256").update(Q).digest("hex").slice(0,8)}function c(Q=!1){let z=Q?d():l(),Z=u(z);return{content:z,filename:`runtime.${Z}.js`,hash:Z}}function a(){let Q=h(),z=u(Q);return{content:Q,filename:`router.${z}.js`,hash:z}}function bF(Q){return{runtimeTag:Q.runtime?`<script src="/__stx/${Q.runtime.filename}"></script>`:"",routerTag:Q.router?`<script src="/__stx/${Q.router.filename}"></script>`:"",cssTag:Q.css?`<link rel="stylesheet" href="/__stx/${Q.css.filename}">`:""}}import n from"path";import{createHash as OF}from"crypto";function TF(Q={}){let z=new Set;return{context:new Proxy(Q,{get(X,F){if(F in X)return X[F];if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return},has(X,F){if(F in X)return!0;if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return!1}}),accessedKeys:z}}async function FF(Q,z,Z={}){let X=n.resolve(Q),F=await Bun.file(X).text(),U=OF("sha256").update(F).digest("hex").slice(0,16);p();let w={};try{w=await M(Z.configDir)}catch{}let H=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(F))!==null){let E=k[1];if(/\bserver\b/.test(E))H.push(k[2])}let W=new Set(H.flatMap((E)=>o(E))),{context:_}=TF({__filename:X,__dirname:n.dirname(X),__stx_serverDeclared:W}),N=new Set,x={...t,...w,...Z,buildMode:"compile",strict:!1},I=await r(F,_,X,x,N),O=e(I),j=i();return{route:z,sourceFile:Q,html:I,fragment:O,placeholders:j,hasServerScripts:H.length>0,serverScriptContent:H,dependencies:Array.from(N),contentHash:U,status:s(F),streamTemplates:_.__streamTemplates}}var MF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function JF(Q,z){let Z=0,X=0;if(!G.existsSync(Q))return{copied:Z,bytes:X};G.mkdirSync(z,{recursive:!0});function F(U,w){let H=G.readdirSync(U,{withFileTypes:!0});for(let V of H){if(MF.has(V.name))continue;let k=q.join(U,V.name),W=q.join(w,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),F(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),Z++,X+=G.statSync(W).size}}}return F(Q,z),{copied:Z,bytes:X}}async function qJ(Q={}){let z=Date.now(),Z=q.resolve(Q.root||process.cwd()),X=q.resolve(Z,Q.outputDir||".output");console.log("[stx build] Starting production build...");let F=await M(Z),U=q.resolve(Z,Q.componentsDir??F.componentsDir??"components"),w=q.resolve(Z,Q.partialsDir??F.partialsDir??"partials"),H=q.resolve(Z,Q.layoutsDir??F.layoutsDir??"layouts"),V=Q.publicDir??F.publicDir??"public",k=F.app?.head||{},W=F.app?.colorMode,_=F.router?.container||"main",N=Q.routeRules??F.routeRules??{},x=BF(N),I=Q.serverApi??F.serverApi,O=typeof I==="object"?I:{};if(I)YF(Z,O);if(F.runtimeConfig)QF(F.runtimeConfig,{});if(G.existsSync(X))G.rmSync(X,{recursive:!0});let j=[q.join(X,"public","__stx"),q.join(X,"public","assets"),q.join(X,"server","pages"),q.join(X,"server","fragments")];for(let Y of j)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let E=zF(Z,{pagesDirs:F._layerPageDirs}),LF=["components","layouts","partials"],y=E.filter((Y)=>{return!LF.some((B)=>Y.pattern.startsWith(`/${B}/`)||Y.pattern===`/${B}`)});console.log(`[stx build] Found ${y.length} page routes (${E.length-y.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let L=c(Q.debug),K=a();await Bun.write(q.join(X,"public","__stx",L.filename),L.content),await Bun.write(q.join(X,"public","__stx",K.filename),K.content),console.log(`[stx build] Runtime: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${K.filename} (${(K.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let R=[],v=[];for(let Y of y){let B=x(Y.pattern),b=B.rendering==="prerender";if(b&&(Y.pattern.includes(":")||Y.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${Y.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let J=await FF(Y.filePath,Y.pattern,{configDir:Z,componentsDir:U,partialsDir:w,layoutsDir:H,debug:Q.debug});if(R.push(J),J.html=J.html.replace(/runtime\.__STX_HASH__\.js/g,L.filename).replace(/router\.__STX_HASH__\.js/g,K.filename),J.html=VF(J.html,k,{bodyScripts:[`<script src="/__stx/${K.filename}"></script>`],...W&&{colorMode:W}}),W)J.html=$F(J.html,W);if(k.htmlAttrs)J.html=GF(J.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(J.html)){let $=J.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if($&&$[1]){let m=$[1];J.html=J.html.replace(" "+m,""),J.html=J.html.replace(/<body([^>]*)>/,`<body$1 ${m}>`)}}if(J.html=J.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),J.html=await qF(J.html),b){let $=await EF(J,{params:{},request:new Request(`http://stx.build${Y.pattern}`),method:"GET",__stx_strict_hydration:!0});if($.redirect||$.cookies?.length||$.boundaries?.length||$.headers&&Object.keys($.headers).length)throw Error(`Prerendered route ${Y.pattern} cannot set response headers/cookies, redirect or stream`);J.html=$.html,J.status=$.status??J.status,J.hasServerScripts=!1,J.serverScriptContent=[],J.placeholders={}}J.fragment=kF(J.html,_);let C=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),g=q.join("server","pages",`${C}.compiled.json`),f=q.join("server","fragments",`${C}.html`);await Bun.write(q.join(X,g),JSON.stringify(J,null,2)),await Bun.write(q.join(X,f),J.fragment),v.push({pattern:Y.pattern,compiledPath:g,fragmentPath:f,isDynamic:J.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("["),prerendered:b}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(J){if(Object.keys(B).length)throw J;console.error(`[stx build] \u2717 ${Y.pattern}:`,J instanceof Error?J.message:J)}}let P=q.resolve(Z,V);if(G.existsSync(P)){let{copied:Y,bytes:B}=JF(P,q.join(X,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${V}/`)}let A=KF(Z);if(A){let{copied:Y,bytes:B}=JF(A,q.join(X,"public",IF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${HF}/`)}let S={runtime:L.filename,router:K.filename},T=UF(v,S,X);if(T.routeRules=N,T.routerContainer=_,I)T.apiRoutes=await ZF(Z,X,O);if(F.runtimeConfig)await Bun.write(q.join(X,"server/runtime-config.json"),JSON.stringify(F.runtimeConfig)),await WF(Z,F.runtimeConfig);if(F._layerGraph)await Bun.write(q.join(X,"server/layers.json"),JSON.stringify(XF(F._layerGraph),null,2));wF(T,X);let D=Date.now()-z;return console.log(`
2
+ import{jg as e,lg as kF,mg as UF,ng as wF,vg as EF}from"./chunk-jy451jg5.js";import{yg as BF}from"./chunk-0knxnyq6.js";import{oj as l,pj as d}from"./chunk-krt45cqy.js";import{Dk as HF,Ek as IF,Fk as KF}from"./chunk-frp9fc7j.js";import{nl as YF,pl as ZF}from"./chunk-t23kccpz.js";import{Gp as VF,Kp as r,Pp as o,Xm as s,jo as zF,jp as $F,om as p,qm as i,ur as t,wr as M,yp as GF}from"./chunk-3ssjb8cx.js";import{ws as XF}from"./chunk-tf16jtj4.js";import{mt as qF}from"./chunk-kjd9hbg4.js";import{Gt as WF}from"./chunk-q4kgqqed.js";import{Lt as QF}from"./chunk-1nnza3m6.js";import{Ew as h,Hw as _F}from"./chunk-trva71am.js";import G from"fs";import q from"path";import{createHash as NF}from"crypto";_F();function u(Q){return NF("sha256").update(Q).digest("hex").slice(0,8)}function c(Q=!1){let z=Q?d():l(),Z=u(z);return{content:z,filename:`runtime.${Z}.js`,hash:Z}}function a(){let Q=h(),z=u(Q);return{content:Q,filename:`router.${z}.js`,hash:z}}function bF(Q){return{runtimeTag:Q.runtime?`<script src="/__stx/${Q.runtime.filename}"></script>`:"",routerTag:Q.router?`<script src="/__stx/${Q.router.filename}"></script>`:"",cssTag:Q.css?`<link rel="stylesheet" href="/__stx/${Q.css.filename}">`:""}}import n from"path";import{createHash as OF}from"crypto";function TF(Q={}){let z=new Set;return{context:new Proxy(Q,{get(X,F){if(F in X)return X[F];if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return},has(X,F){if(F in X)return!0;if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return!1}}),accessedKeys:z}}async function FF(Q,z,Z={}){let X=n.resolve(Q),F=await Bun.file(X).text(),U=OF("sha256").update(F).digest("hex").slice(0,16);p();let w={};try{w=await M(Z.configDir)}catch{}let H=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(F))!==null){let E=k[1];if(/\bserver\b/.test(E))H.push(k[2])}let W=new Set(H.flatMap((E)=>o(E))),{context:_}=TF({__filename:X,__dirname:n.dirname(X),__stx_serverDeclared:W}),N=new Set,x={...t,...w,...Z,buildMode:"compile",strict:!1},I=await r(F,_,X,x,N),O=e(I),j=i();return{route:z,sourceFile:Q,html:I,fragment:O,placeholders:j,hasServerScripts:H.length>0,serverScriptContent:H,dependencies:Array.from(N),contentHash:U,status:s(F),streamTemplates:_.__streamTemplates}}var MF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function JF(Q,z){let Z=0,X=0;if(!G.existsSync(Q))return{copied:Z,bytes:X};G.mkdirSync(z,{recursive:!0});function F(U,w){let H=G.readdirSync(U,{withFileTypes:!0});for(let V of H){if(MF.has(V.name))continue;let k=q.join(U,V.name),W=q.join(w,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),F(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),Z++,X+=G.statSync(W).size}}}return F(Q,z),{copied:Z,bytes:X}}async function qJ(Q={}){let z=Date.now(),Z=q.resolve(Q.root||process.cwd()),X=q.resolve(Z,Q.outputDir||".output");console.log("[stx build] Starting production build...");let F=await M(Z),U=q.resolve(Z,Q.componentsDir??F.componentsDir??"components"),w=q.resolve(Z,Q.partialsDir??F.partialsDir??"partials"),H=q.resolve(Z,Q.layoutsDir??F.layoutsDir??"layouts"),V=Q.publicDir??F.publicDir??"public",k=F.app?.head||{},W=F.app?.colorMode,_=F.router?.container||"main",N=Q.routeRules??F.routeRules??{},x=BF(N),I=Q.serverApi??F.serverApi,O=typeof I==="object"?I:{};if(I)YF(Z,O);if(F.runtimeConfig)QF(F.runtimeConfig,{});if(G.existsSync(X))G.rmSync(X,{recursive:!0});let j=[q.join(X,"public","__stx"),q.join(X,"public","assets"),q.join(X,"server","pages"),q.join(X,"server","fragments")];for(let Y of j)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let E=zF(Z,{pagesDirs:F._layerPageDirs}),LF=["components","layouts","partials"],y=E.filter((Y)=>{return!LF.some((B)=>Y.pattern.startsWith(`/${B}/`)||Y.pattern===`/${B}`)});console.log(`[stx build] Found ${y.length} page routes (${E.length-y.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let L=c(Q.debug),K=a();await Bun.write(q.join(X,"public","__stx",L.filename),L.content),await Bun.write(q.join(X,"public","__stx",K.filename),K.content),console.log(`[stx build] Runtime: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${K.filename} (${(K.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let R=[],v=[];for(let Y of y){let B=x(Y.pattern),b=B.rendering==="prerender";if(b&&(Y.pattern.includes(":")||Y.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${Y.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let J=await FF(Y.filePath,Y.pattern,{configDir:Z,componentsDir:U,partialsDir:w,layoutsDir:H,debug:Q.debug});if(R.push(J),J.html=J.html.replace(/runtime\.__STX_HASH__\.js/g,L.filename).replace(/router\.__STX_HASH__\.js/g,K.filename),J.html=VF(J.html,k,{bodyScripts:[`<script src="/__stx/${K.filename}"></script>`],...W&&{colorMode:W}}),W)J.html=$F(J.html,W);if(k.htmlAttrs)J.html=GF(J.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(J.html)){let $=J.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if($&&$[1]){let m=$[1];J.html=J.html.replace(" "+m,""),J.html=J.html.replace(/<body([^>]*)>/,`<body$1 ${m}>`)}}if(J.html=J.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),J.html=await qF(J.html),b){let $=await EF(J,{params:{},request:new Request(`http://stx.build${Y.pattern}`),method:"GET",__stx_strict_hydration:!0});if($.redirect||$.cookies?.length||$.boundaries?.length||$.headers&&Object.keys($.headers).length)throw Error(`Prerendered route ${Y.pattern} cannot set response headers/cookies, redirect or stream`);J.html=$.html,J.status=$.status??J.status,J.hasServerScripts=!1,J.serverScriptContent=[],J.placeholders={}}J.fragment=kF(J.html,_);let C=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),g=q.join("server","pages",`${C}.compiled.json`),f=q.join("server","fragments",`${C}.html`);await Bun.write(q.join(X,g),JSON.stringify(J,null,2)),await Bun.write(q.join(X,f),J.fragment),v.push({pattern:Y.pattern,compiledPath:g,fragmentPath:f,isDynamic:J.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("["),prerendered:b}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(J){if(Object.keys(B).length)throw J;console.error(`[stx build] \u2717 ${Y.pattern}:`,J instanceof Error?J.message:J)}}let P=q.resolve(Z,V);if(G.existsSync(P)){let{copied:Y,bytes:B}=JF(P,q.join(X,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${V}/`)}let A=KF(Z);if(A){let{copied:Y,bytes:B}=JF(A,q.join(X,"public",IF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${HF}/`)}let S={runtime:L.filename,router:K.filename},T=UF(v,S,X);if(T.routeRules=N,T.routerContainer=_,I)T.apiRoutes=await ZF(Z,X,O);if(F.runtimeConfig)await Bun.write(q.join(X,"server/runtime-config.json"),JSON.stringify(F.runtimeConfig)),await WF(Z,F.runtimeConfig);if(F._layerGraph)await Bun.write(q.join(X,"server/layers.json"),JSON.stringify(XF(F._layerGraph),null,2));wF(T,X);let D=Date.now()-z;return console.log(`
3
3
  [stx build] Done in ${D}ms \u2014 ${R.length} pages compiled`),{pageCount:R.length,assets:S,outputDir:X,duration:D}}
4
- export{u as Rf,c as Sf,a as Tf,bF as Uf,FF as Vf,qJ as Wf};
4
+ export{u as Sf,c as Tf,a as Uf,bF as Vf,FF as Wf,qJ as Xf};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-ejqpq0wc.js";var Y=null,S=[],F=new WeakMap;function I(z){let K=z,B=new Set,G={get value(){if(Y){let H=F.get(G);if(!H)H=new Set,F.set(G,H);H.add(Y)}return K},set value(H){if(!Object.is(K,H)){K=H,B.forEach((J)=>J(H));let L=F.get(G);if(L)L.forEach((J)=>J())}},subscribe(H){return B.add(H),()=>B.delete(H)},peek(){return K}};return G}function W(z){return z!==null&&typeof z==="object"&&"value"in z&&"subscribe"in z&&"peek"in z}function P(z){return W(z)?z.value:z}function j(z){let K={};for(let B in z)if(Object.prototype.hasOwnProperty.call(z,B))K[B]=I(z[B]);return K}function D(z){return I(z)}function U(z){let K=typeof z==="function",B=K?z:z.get,G=K?void 0:z.set,H=K?Object.is:z.equals||Object.is,L,J=!0,Q=new Set,X=new Set,_=()=>{if(J=!0,X.size>0){let N=T.value;X.forEach(($)=>$(N))}};function Z(){Q.clear();let N=Y;Y=_,S.push(_);try{return B()}finally{S.pop(),Y=N}}let T={get value(){if(Y){let N=F.get(T);if(!N)N=new Set,F.set(T,N);N.add(Y)}if(J){let N=Z();if(!H(L,N))L=N;J=!1}return L},set value(N){if(G)G(N);else console.warn("Computed property is readonly")},subscribe(N){return X.add(N),()=>X.delete(N)},peek(){if(J)L=B(),J=!1;return L},invalidate(){J=!0},get dirty(){return J},get deps(){return Q}};return T}function x(z,K,B={}){let{immediate:G=!1,deep:H=!1,flush:L="pre",once:J=!1}=B,Q,X=!0,_=!1,Z=()=>{if(W(z))return H?q(z.value):z.value;return z()},T=()=>{if(!X||_)return;let M=Z();if(Q!==void 0&&Object.is(Q,M)&&!H)return;let A=()=>{if(K(M,Q),Q=H?q(M):M,J)$()};if(L==="sync")A();else if(L==="post")queueMicrotask(A);else Promise.resolve().then(A)},N=null;if(W(z))N=z.subscribe(()=>T());else N=U(z).subscribe(()=>T());if(G)Q=void 0,T();else Q=Z();let $=()=>{if(X=!1,N)N(),N=null};return $.pause=()=>{_=!0},$.resume=()=>{_=!1},$}function E(z,K,B={}){let{immediate:G=!1,once:H=!1}=B,L=z.map((T)=>W(T)?T.value:void 0),J=!0,Q=!1,X=()=>{if(!J||Q)return;let T=z.map((N)=>W(N)?N.value:void 0);if(K(T,L),L=[...T],H)Z()},_=z.map((T)=>{if(W(T))return T.subscribe(()=>X());return()=>{}});if(G)X();let Z=()=>{J=!1,_.forEach((T)=>T())};return Z.pause=()=>{Q=!0},Z.resume=()=>{Q=!1},Z}function y(z,K={}){let{flush:B="pre"}=K,G,H=!0,L=!1,J=()=>{if(!H||L)return;if(G)G();let X=Y;Y=J,S.push(J);try{G=z()}finally{S.pop(),Y=X}};if(B==="sync")J();else if(B==="post")queueMicrotask(J);else Promise.resolve().then(J);let Q=()=>{if(H=!1,G)G()};return Q.pause=()=>{L=!0},Q.resume=()=>{L=!1},Q}function C(z,K={},B){let G=/@computed\s*\(\s*(\w+)\s*,\s*(.+?)\s*\)/gi;return z.replace(G,(H,L,J)=>{try{let X=Function(...Object.keys(K),`return ${J}`)(...Object.values(K));return K[L]=X,`<!-- computed: ${L} = ${X} -->`}catch(Q){return`<!-- computed error: ${L} - ${Q} -->`}})}function R(z,K={},B){let G=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return z.replace(G,(H,L,J)=>{return`
2
+ import"./chunk-emjmshj8.js";var Y=null,S=[],F=new WeakMap;function I(z){let K=z,B=new Set,G={get value(){if(Y){let H=F.get(G);if(!H)H=new Set,F.set(G,H);H.add(Y)}return K},set value(H){if(!Object.is(K,H)){K=H,B.forEach((J)=>J(H));let L=F.get(G);if(L)L.forEach((J)=>J())}},subscribe(H){return B.add(H),()=>B.delete(H)},peek(){return K}};return G}function W(z){return z!==null&&typeof z==="object"&&"value"in z&&"subscribe"in z&&"peek"in z}function P(z){return W(z)?z.value:z}function j(z){let K={};for(let B in z)if(Object.prototype.hasOwnProperty.call(z,B))K[B]=I(z[B]);return K}function D(z){return I(z)}function U(z){let K=typeof z==="function",B=K?z:z.get,G=K?void 0:z.set,H=K?Object.is:z.equals||Object.is,L,J=!0,Q=new Set,X=new Set,_=()=>{if(J=!0,X.size>0){let N=T.value;X.forEach(($)=>$(N))}};function Z(){Q.clear();let N=Y;Y=_,S.push(_);try{return B()}finally{S.pop(),Y=N}}let T={get value(){if(Y){let N=F.get(T);if(!N)N=new Set,F.set(T,N);N.add(Y)}if(J){let N=Z();if(!H(L,N))L=N;J=!1}return L},set value(N){if(G)G(N);else console.warn("Computed property is readonly")},subscribe(N){return X.add(N),()=>X.delete(N)},peek(){if(J)L=B(),J=!1;return L},invalidate(){J=!0},get dirty(){return J},get deps(){return Q}};return T}function x(z,K,B={}){let{immediate:G=!1,deep:H=!1,flush:L="pre",once:J=!1}=B,Q,X=!0,_=!1,Z=()=>{if(W(z))return H?q(z.value):z.value;return z()},T=()=>{if(!X||_)return;let M=Z();if(Q!==void 0&&Object.is(Q,M)&&!H)return;let A=()=>{if(K(M,Q),Q=H?q(M):M,J)$()};if(L==="sync")A();else if(L==="post")queueMicrotask(A);else Promise.resolve().then(A)},N=null;if(W(z))N=z.subscribe(()=>T());else N=U(z).subscribe(()=>T());if(G)Q=void 0,T();else Q=Z();let $=()=>{if(X=!1,N)N(),N=null};return $.pause=()=>{_=!0},$.resume=()=>{_=!1},$}function E(z,K,B={}){let{immediate:G=!1,once:H=!1}=B,L=z.map((T)=>W(T)?T.value:void 0),J=!0,Q=!1,X=()=>{if(!J||Q)return;let T=z.map((N)=>W(N)?N.value:void 0);if(K(T,L),L=[...T],H)Z()},_=z.map((T)=>{if(W(T))return T.subscribe(()=>X());return()=>{}});if(G)X();let Z=()=>{J=!1,_.forEach((T)=>T())};return Z.pause=()=>{Q=!0},Z.resume=()=>{Q=!1},Z}function y(z,K={}){let{flush:B="pre"}=K,G,H=!0,L=!1,J=()=>{if(!H||L)return;if(G)G();let X=Y;Y=J,S.push(J);try{G=z()}finally{S.pop(),Y=X}};if(B==="sync")J();else if(B==="post")queueMicrotask(J);else Promise.resolve().then(J);let Q=()=>{if(H=!1,G)G()};return Q.pause=()=>{L=!0},Q.resume=()=>{L=!1},Q}function C(z,K={},B){let G=/@computed\s*\(\s*(\w+)\s*,\s*(.+?)\s*\)/gi;return z.replace(G,(H,L,J)=>{try{let X=Function(...Object.keys(K),`return ${J}`)(...Object.values(K));return K[L]=X,`<!-- computed: ${L} = ${X} -->`}catch(Q){return`<!-- computed error: ${L} - ${Q} -->`}})}function R(z,K={},B){let G=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return z.replace(G,(H,L,J)=>{return`
3
3
  <script data-watch="${`watch-${Math.random().toString(36).substring(2,9)}`}">
4
4
  (function() {
5
5
  // Watch implementation for ${L}
@@ -299,4 +299,4 @@ catch (error) {
299
299
  }
300
300
  })();
301
301
  </script>`}var N={name:"pwa.installButton",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return H(j,q)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},Q={name:"pwa.updatePrompt",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return J(j,q)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},T={name:"pwa.offlineIndicator",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return L(j,q)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},V={name:"pwa.pushSubscribe",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return M(j,q)},hasEndTag:!0,description:"Renders a push notification subscription button"},X=[N,Q,T,V];function Z(j){return[...j,...X]}
302
- export{N as Ew,Q as Fw,T as Gw,V as Hw,X as Iw,Z as Jw};
302
+ export{N as Iw,Q as Jw,T as Kw,V as Lw,X as Mw,Z as Nw};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Se as a,Te as b}from"./chunk-7hb89n3z.js";import"./chunk-emjmshj8.js";export{b as captureScreenshots,a as captureScreenshot};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{ag as ZJ,cg as g,eg as A,kg as n,ng as GJ,qg as WJ,sg as YJ,ug as jJ}from"./chunk-g7msqva8.js";import{xg as $J}from"./chunk-57atgbyq.js";import{ql as XJ}from"./chunk-ngjkzaj7.js";import{ko as h}from"./chunk-msq8xvhp.js";import{Cs as e}from"./chunk-9e20mgwc.js";import{Dt as QJ,Ht as i,Jt as p}from"./chunk-vhta1be7.js";import{Dw as VJ,Xv as KJ,yw as l}from"./chunk-swvm1wgn.js";import{Nw as DJ}from"./chunk-ejqpq0wc.js";import JJ from"fs";import k from"path";var{serve:wJ}=globalThis.Bun;VJ();import y from"zlib";import{promisify as a}from"util";var IJ=a(y.brotliCompress),OJ=a(y.gzip),UJ=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],BJ=["text/event-stream","multipart/x-mixed-replace"],_J=1024;function zJ(K){if(!K)return!1;let J=K.toLowerCase();if(BJ.some((G)=>J.startsWith(G)))return!1;return UJ.some((G)=>J.startsWith(G))}function FJ(K){let J=new Map;for(let G of K.split(",")){let[Z,...W]=G.trim().split(";"),O=Z.trim().toLowerCase();if(!O)continue;let U=1;for(let B of W){let w=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(B);if(!w)continue;let F=Number.parseFloat(w[1]);if(Number.isFinite(F))U=F}J.set(O,U)}return J}function LJ(K){if(!K)return null;let J=FJ(K),G=J.get("*"),Z=(W)=>J.get(W)??G??0;if(Z("br")>0)return"br";if(Z("gzip")>0)return"gzip";return null}async function t(K,J,G={}){if(J.headers.get("content-encoding"))return J;if(J.status===204||J.status===304||!J.body)return J;if(!zJ(J.headers.get("content-type")))return J;let Z=LJ(K.headers.get("accept-encoding"));if(!Z)return J;let W;try{W=new Uint8Array(await J.arrayBuffer())}catch{return J}let O=()=>new Response(W,{status:J.status,statusText:J.statusText,headers:s(J.headers)});if(W.length<(G.threshold??_J))return O();try{let U=Z==="br"?await IJ(W,{params:{[y.constants.BROTLI_PARAM_QUALITY]:G.quality??5,[y.constants.BROTLI_PARAM_SIZE_HINT]:W.length}}):await OJ(W);if(U.length>=W.length)return O();let B=s(J.headers);return B.set("Content-Encoding",Z),B.set("Content-Length",String(U.length)),new Response(U,{status:J.status,statusText:J.statusText,headers:B})}catch{return O()}}function s(K){let J=new Headers(K),G=J.get("Vary");if(!G)return J.set("Vary","Accept-Encoding"),J;if(!G.split(",").some((W)=>W.trim().toLowerCase()==="accept-encoding"))J.set("Vary",`${G}, Accept-Encoding`);return J}class d{now;entries=new e(1000,{maxBytes:33554432,sizeOf:(K)=>K.body.byteLength+JSON.stringify(K.headers).length*2});pending=new Map;generation=0;constructor(K=Date.now){this.now=K}invalidate(K){this.generation++,this.pending.clear();for(let J of Array.from(this.entries.keys()))if(K===void 0||this.entries.get(J)?.path===K)this.entries.delete(J)}async respond(K,J,G){let Z,W=async()=>{let X=Z??await G();return X.headers.set("Cache-Control","private, no-store"),X.headers.set("Vary",A(X.headers.get("Vary")).Vary),X};if(!J||K.method!=="GET"||K.headers.has("Cookie")||K.headers.has("Authorization")||K.headers.has("Range"))return W();let O=new URL(K.url),U=`${O.origin}${O.pathname}${O.search}|${g(K)?"fragment":"document"}`,B=this.entries.get(U),w=(X)=>{let T=new Headers(X.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-X.created)/1000)))),new Response(X.body.slice(0),{headers:T})},F=B?(this.now()-B.created)/1000:1/0;if(B&&F<J.maxAge)return w(B);let S=this.generation,q=async()=>{let X=await G();Z=X;let T=(X.headers.get("Vary")??"").toLowerCase().split(",").map((L)=>L.trim()).filter(Boolean);if(X.status!==200||X.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(X.headers.get("Cache-Control")??"")||T.some((L)=>L!=="x-stx-router"&&L!=="accept-encoding"))return null;let M=await X.clone().arrayBuffer();if(M.byteLength>1048576)return null;X.headers.set("Vary",A(X.headers.get("Vary")).Vary);let Q={body:M,headers:Array.from(X.headers.entries()),created:this.now(),path:O.pathname};if(this.generation===S)this.entries.set(U,Q);return Q},H=this.pending.get(U);if(!H){if(this.pending.size>=1000)return W();H=q().finally(()=>{if(this.pending.get(U)===H)this.pending.delete(U)}),this.pending.set(U,H)}if(B&&F<J.maxAge+(J.swr??0))return H.catch(()=>{}),w(B);let x=await H;return x?w(x):W()}}var HJ={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function uJ(K={}){let J=k.resolve(K.outputDir||".output"),G=K.port??3000,Z=GJ(J);if(!Z)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${Z.routes.length} routes...`);let W=$J(Z.routeRules),O=new d,U=XJ(J,Z.apiRoutes??[]),B=Bun.file(k.join(J,"server/runtime-config.json")),w=K.runtimeConfig??(await B.exists()?await B.json():void 0),F=w?i(w):void 0,S=new Map,q=new Map,H=new Map,x=new Map;for(let Q of Z.routes)try{let L=k.join(J,Q.compiledPath),Y=JSON.parse(await Bun.file(L).text());if(F)Y.html=p(Y.html,F);S.set(Q.pattern,Y),H.set(Q.pattern,l(Y.html)),x.set(Q.pattern,h(Y.html));let C=k.join(J,Q.fragmentPath);if(await Bun.file(C).exists()){let P=await Bun.file(C).text();q.set(Q.pattern,F?p(P,F):P)}}catch(L){console.warn(`[stx] Failed to load route ${Q.pattern}:`,L)}let X=new Map,T=[];for(let Q of Z.routes)if(Q.hasParams){let{regex:L,params:Y}=KJ(Q.pattern);T.push({regex:L,route:Q,paramNames:Y})}else X.set(Q.pattern,Q);let M=wJ({port:G,async fetch(Q){return t(Q,await QJ(F??i(),async()=>{let Y=new URL(Q.url).pathname;if(K.onRequest){let j=await K.onRequest(Q);if(j)return j}if(K.apiRouter){let j=await K.apiRouter.handleRequest(Q);if(j.status!==404)return j}if(K.apiRoutes?.[Y])return K.apiRoutes[Y](Q);let C=await U(Q);if(C)return C;if((Q.method==="GET"||Q.method==="HEAD")&&Y!=="/"){let j=k.resolve(J,"public"),_;try{_=decodeURIComponent(Y)}catch{_=Y}if(!_.includes("\x00")){let I=k.resolve(j,`.${_}`);if(I===j||I.startsWith(`${j}${k.sep}`))try{if(JJ.existsSync(I)&&JJ.statSync(I).isFile()){let z=k.extname(I).toLowerCase(),E=HJ[z]||"application/octet-stream",v=Y.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(Y);return new Response(Bun.file(I),{headers:{"Content-Type":E,"Cache-Control":v?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=g(Q),D=null,o={};if(D=X.get(Y)||null,!D)for(let{regex:j,route:_,paramNames:I}of T){let $=Y.match(j);if($){D=_,I.forEach((z,E)=>{o[z]=$[E+1]});break}}if(!D){let j=X.get("/404")||null;if(j){let _=S.get(j.pattern);if(_)return new Response(_.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}let R=W(Y),r=Object.keys(R).length>0;return O.respond(Q,R.cache,async()=>{let j=S.get(D.pattern);if(P&&Q.method==="GET"&&j&&!j.hasServerScripts&&Object.keys(j.placeholders).length===0){let $=q.get(D.pattern);if($){let z=H.get(D.pattern);return new Response($,{status:j.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...x.has(D.pattern)?{"X-STX-Runtime":x.get(D.pattern)?"true":"false"}:{},...z?{"X-STX-Layout":z.layout,"X-STX-Layout-Group":z.group}:{},...A(),...R.cache?{}:{"Cache-Control":ZJ}}})}}let _=WJ(Q.method),I=S.get(D.pattern);if(!I){let $=X.get("/500")||null;if($){let z=S.get($.pattern);if(z)return new Response(z.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(D.prerendered&&_)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!_&&!I.hasServerScripts&&Object.keys(I.placeholders).length===0)return new Response(I.html,{status:I.status??200,headers:{"Content-Type":"text/html",...A(),"Cache-Control":"public, max-age=60"}});try{let{html:$,boundaries:z,redirect:E,cookies:v,status:m,headers:c}=await jJ(I,{params:o,request:Q,method:Q.method,__stx_strict_hydration:r,__stx_runtime_config:F});if(E)return YJ(E,v,c);if(z&&z.length>0){let{renderStreamingPage:N,streamToResponse:u}=await import("./chunk-h5jt4mxx.js"),b=new Headers({...A(),...c,"Cache-Control":"private, no-store"});for(let f of v??[])b.append("Set-Cookie",f);if(P&&!_){let f=l($);b.set("X-STX-Fragment","true"),b.set("X-STX-Runtime",h($)?"true":"false"),b.set("X-STX-Layout",f.layout),b.set("X-STX-Layout-Group",f.group)}return u(N(P&&!_?n($,Z.routerContainer||"main"):$,z,{timeoutMs:30000}),{status:m??I.status??200,headers:b})}let V=new Headers({"Content-Type":"text/html",...A(),...R.cache?{}:{"Cache-Control":"private, no-store"}});for(let N of v??[])V.append("Set-Cookie",N);for(let[N,u]of Object.entries(c??{}))V.set(N,u);if(V.set("Vary",A(V.get("Vary")).Vary),P&&!_){let N=l($);return V.set("X-STX-Fragment","true"),V.set("X-STX-Runtime",h($)?"true":"false"),V.set("X-STX-Layout",N.layout),V.set("X-STX-Layout-Group",N.group),new Response(n($,Z.routerContainer||"main"),{status:m??I.status??200,headers:V})}return new Response($,{status:m??I.status??200,headers:V})}catch($){if(console.error(`[stx] Hydration error for ${Y}:`,$),r)return new Response("Internal Server Error",{status:500});return new Response(I.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${M.port}`),console.log(`[stx] Serving ${Z.routes.length} routes (${S.size} pre-loaded)`),{port:M.port,stop:()=>{O.invalidate(),M.stop()},invalidate:(Q)=>O.invalidate(Q)}}
3
- export{zJ as Ve,LJ as We,t as Xe,uJ as Ye};
2
+ import{bg as ZJ,dg as g,fg as A,lg as n,og as GJ,rg as WJ,tg as YJ,vg as jJ}from"./chunk-jy451jg5.js";import{yg as $J}from"./chunk-0knxnyq6.js";import{rl as XJ}from"./chunk-t23kccpz.js";import{lo as h}from"./chunk-3ssjb8cx.js";import{Gs as e}from"./chunk-kjd9hbg4.js";import{Ht as QJ,Lt as i,Nt as p}from"./chunk-1nnza3m6.js";import{$v as KJ,Cw as l,Hw as VJ}from"./chunk-trva71am.js";import{Rw as DJ}from"./chunk-emjmshj8.js";import JJ from"fs";import k from"path";var{serve:wJ}=globalThis.Bun;VJ();import y from"zlib";import{promisify as a}from"util";var IJ=a(y.brotliCompress),OJ=a(y.gzip),UJ=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],BJ=["text/event-stream","multipart/x-mixed-replace"],_J=1024;function zJ(K){if(!K)return!1;let J=K.toLowerCase();if(BJ.some((G)=>J.startsWith(G)))return!1;return UJ.some((G)=>J.startsWith(G))}function FJ(K){let J=new Map;for(let G of K.split(",")){let[Z,...W]=G.trim().split(";"),O=Z.trim().toLowerCase();if(!O)continue;let U=1;for(let B of W){let w=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(B);if(!w)continue;let F=Number.parseFloat(w[1]);if(Number.isFinite(F))U=F}J.set(O,U)}return J}function LJ(K){if(!K)return null;let J=FJ(K),G=J.get("*"),Z=(W)=>J.get(W)??G??0;if(Z("br")>0)return"br";if(Z("gzip")>0)return"gzip";return null}async function t(K,J,G={}){if(J.headers.get("content-encoding"))return J;if(J.status===204||J.status===304||!J.body)return J;if(!zJ(J.headers.get("content-type")))return J;let Z=LJ(K.headers.get("accept-encoding"));if(!Z)return J;let W;try{W=new Uint8Array(await J.arrayBuffer())}catch{return J}let O=()=>new Response(W,{status:J.status,statusText:J.statusText,headers:s(J.headers)});if(W.length<(G.threshold??_J))return O();try{let U=Z==="br"?await IJ(W,{params:{[y.constants.BROTLI_PARAM_QUALITY]:G.quality??5,[y.constants.BROTLI_PARAM_SIZE_HINT]:W.length}}):await OJ(W);if(U.length>=W.length)return O();let B=s(J.headers);return B.set("Content-Encoding",Z),B.set("Content-Length",String(U.length)),new Response(U,{status:J.status,statusText:J.statusText,headers:B})}catch{return O()}}function s(K){let J=new Headers(K),G=J.get("Vary");if(!G)return J.set("Vary","Accept-Encoding"),J;if(!G.split(",").some((W)=>W.trim().toLowerCase()==="accept-encoding"))J.set("Vary",`${G}, Accept-Encoding`);return J}class d{now;entries=new e(1000,{maxBytes:33554432,sizeOf:(K)=>K.body.byteLength+JSON.stringify(K.headers).length*2});pending=new Map;generation=0;constructor(K=Date.now){this.now=K}invalidate(K){this.generation++,this.pending.clear();for(let J of Array.from(this.entries.keys()))if(K===void 0||this.entries.get(J)?.path===K)this.entries.delete(J)}async respond(K,J,G){let Z,W=async()=>{let X=Z??await G();return X.headers.set("Cache-Control","private, no-store"),X.headers.set("Vary",A(X.headers.get("Vary")).Vary),X};if(!J||K.method!=="GET"||K.headers.has("Cookie")||K.headers.has("Authorization")||K.headers.has("Range"))return W();let O=new URL(K.url),U=`${O.origin}${O.pathname}${O.search}|${g(K)?"fragment":"document"}`,B=this.entries.get(U),w=(X)=>{let T=new Headers(X.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-X.created)/1000)))),new Response(X.body.slice(0),{headers:T})},F=B?(this.now()-B.created)/1000:1/0;if(B&&F<J.maxAge)return w(B);let S=this.generation,q=async()=>{let X=await G();Z=X;let T=(X.headers.get("Vary")??"").toLowerCase().split(",").map((L)=>L.trim()).filter(Boolean);if(X.status!==200||X.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(X.headers.get("Cache-Control")??"")||T.some((L)=>L!=="x-stx-router"&&L!=="accept-encoding"))return null;let M=await X.clone().arrayBuffer();if(M.byteLength>1048576)return null;X.headers.set("Vary",A(X.headers.get("Vary")).Vary);let Q={body:M,headers:Array.from(X.headers.entries()),created:this.now(),path:O.pathname};if(this.generation===S)this.entries.set(U,Q);return Q},H=this.pending.get(U);if(!H){if(this.pending.size>=1000)return W();H=q().finally(()=>{if(this.pending.get(U)===H)this.pending.delete(U)}),this.pending.set(U,H)}if(B&&F<J.maxAge+(J.swr??0))return H.catch(()=>{}),w(B);let x=await H;return x?w(x):W()}}var HJ={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function uJ(K={}){let J=k.resolve(K.outputDir||".output"),G=K.port??3000,Z=GJ(J);if(!Z)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${Z.routes.length} routes...`);let W=$J(Z.routeRules),O=new d,U=XJ(J,Z.apiRoutes??[]),B=Bun.file(k.join(J,"server/runtime-config.json")),w=K.runtimeConfig??(await B.exists()?await B.json():void 0),F=w?i(w):void 0,S=new Map,q=new Map,H=new Map,x=new Map;for(let Q of Z.routes)try{let L=k.join(J,Q.compiledPath),Y=JSON.parse(await Bun.file(L).text());if(F)Y.html=p(Y.html,F);S.set(Q.pattern,Y),H.set(Q.pattern,l(Y.html)),x.set(Q.pattern,h(Y.html));let C=k.join(J,Q.fragmentPath);if(await Bun.file(C).exists()){let P=await Bun.file(C).text();q.set(Q.pattern,F?p(P,F):P)}}catch(L){console.warn(`[stx] Failed to load route ${Q.pattern}:`,L)}let X=new Map,T=[];for(let Q of Z.routes)if(Q.hasParams){let{regex:L,params:Y}=KJ(Q.pattern);T.push({regex:L,route:Q,paramNames:Y})}else X.set(Q.pattern,Q);let M=wJ({port:G,async fetch(Q){return t(Q,await QJ(F??i(),async()=>{let Y=new URL(Q.url).pathname;if(K.onRequest){let j=await K.onRequest(Q);if(j)return j}if(K.apiRouter){let j=await K.apiRouter.handleRequest(Q);if(j.status!==404)return j}if(K.apiRoutes?.[Y])return K.apiRoutes[Y](Q);let C=await U(Q);if(C)return C;if((Q.method==="GET"||Q.method==="HEAD")&&Y!=="/"){let j=k.resolve(J,"public"),_;try{_=decodeURIComponent(Y)}catch{_=Y}if(!_.includes("\x00")){let I=k.resolve(j,`.${_}`);if(I===j||I.startsWith(`${j}${k.sep}`))try{if(JJ.existsSync(I)&&JJ.statSync(I).isFile()){let z=k.extname(I).toLowerCase(),E=HJ[z]||"application/octet-stream",v=Y.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(Y);return new Response(Bun.file(I),{headers:{"Content-Type":E,"Cache-Control":v?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=g(Q),D=null,o={};if(D=X.get(Y)||null,!D)for(let{regex:j,route:_,paramNames:I}of T){let $=Y.match(j);if($){D=_,I.forEach((z,E)=>{o[z]=$[E+1]});break}}if(!D){let j=X.get("/404")||null;if(j){let _=S.get(j.pattern);if(_)return new Response(_.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}let R=W(Y),r=Object.keys(R).length>0;return O.respond(Q,R.cache,async()=>{let j=S.get(D.pattern);if(P&&Q.method==="GET"&&j&&!j.hasServerScripts&&Object.keys(j.placeholders).length===0){let $=q.get(D.pattern);if($){let z=H.get(D.pattern);return new Response($,{status:j.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...x.has(D.pattern)?{"X-STX-Runtime":x.get(D.pattern)?"true":"false"}:{},...z?{"X-STX-Layout":z.layout,"X-STX-Layout-Group":z.group}:{},...A(),...R.cache?{}:{"Cache-Control":ZJ}}})}}let _=WJ(Q.method),I=S.get(D.pattern);if(!I){let $=X.get("/500")||null;if($){let z=S.get($.pattern);if(z)return new Response(z.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(D.prerendered&&_)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!_&&!I.hasServerScripts&&Object.keys(I.placeholders).length===0)return new Response(I.html,{status:I.status??200,headers:{"Content-Type":"text/html",...A(),"Cache-Control":"public, max-age=60"}});try{let{html:$,boundaries:z,redirect:E,cookies:v,status:m,headers:c}=await jJ(I,{params:o,request:Q,method:Q.method,__stx_strict_hydration:r,__stx_runtime_config:F});if(E)return YJ(E,v,c);if(z&&z.length>0){let{renderStreamingPage:N,streamToResponse:u}=await import("./chunk-0d6qgbks.js"),b=new Headers({...A(),...c,"Cache-Control":"private, no-store"});for(let f of v??[])b.append("Set-Cookie",f);if(P&&!_){let f=l($);b.set("X-STX-Fragment","true"),b.set("X-STX-Runtime",h($)?"true":"false"),b.set("X-STX-Layout",f.layout),b.set("X-STX-Layout-Group",f.group)}return u(N(P&&!_?n($,Z.routerContainer||"main"):$,z,{timeoutMs:30000}),{status:m??I.status??200,headers:b})}let V=new Headers({"Content-Type":"text/html",...A(),...R.cache?{}:{"Cache-Control":"private, no-store"}});for(let N of v??[])V.append("Set-Cookie",N);for(let[N,u]of Object.entries(c??{}))V.set(N,u);if(V.set("Vary",A(V.get("Vary")).Vary),P&&!_){let N=l($);return V.set("X-STX-Fragment","true"),V.set("X-STX-Runtime",h($)?"true":"false"),V.set("X-STX-Layout",N.layout),V.set("X-STX-Layout-Group",N.group),new Response(n($,Z.routerContainer||"main"),{status:m??I.status??200,headers:V})}return new Response($,{status:m??I.status??200,headers:V})}catch($){if(console.error(`[stx] Hydration error for ${Y}:`,$),r)return new Response("Internal Server Error",{status:500});return new Response(I.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${M.port}`),console.log(`[stx] Serving ${Z.routes.length} routes (${S.size} pre-loaded)`),{port:M.port,stop:()=>{O.invalidate(),M.stop()},invalidate:(Q)=>O.invalidate(Q)}}
3
+ export{zJ as We,LJ as Xe,t as Ye,uJ as Ze};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Gk as a,Hk as b,Ik as c,Jk as d,Kk as e}from"./chunk-kaet6r9w.js";import"./chunk-emjmshj8.js";export{d as runPwaAudit,e as formatAuditResult,c as calculateAuditResult,a as auditConfig,b as auditBuildOutput};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{lk as a,mk as b,nk as c,ok as d}from"./chunk-0dj2gne3.js";import"./chunk-ec8jsqgm.js";import"./chunk-3ssjb8cx.js";import"./chunk-ykevda74.js";import"./chunk-ez003q74.js";import"./chunk-kyyt9xhs.js";import"./chunk-tf16jtj4.js";import"./chunk-19m7hed6.js";import"./chunk-kjd9hbg4.js";import"./chunk-ejwfnttb.js";import"./chunk-5270fyk7.js";import"./chunk-q4kgqqed.js";import"./chunk-1nnza3m6.js";import"./chunk-hkrzv980.js";import"./chunk-qbz6yn8c.js";import"./chunk-czj6nq0b.js";import"./chunk-zxfejz72.js";import"./chunk-mere396d.js";import"./chunk-aa8015mk.js";import"./chunk-trva71am.js";import"./chunk-rtfwn4cm.js";import"./chunk-emjmshj8.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{ns as x}from"./chunk-89mqnh67.js";import{nt as A}from"./chunk-y2f41kaq.js";import{Dt as T,Ht as q}from"./chunk-vhta1be7.js";import{Dw as y,Xv as C}from"./chunk-swvm1wgn.js";import{Nw as P}from"./chunk-ejqpq0wc.js";y();import H from"fs";import $ from"path";import{pathToFileURL as b}from"url";var R=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],O=new Set;function N(J,Y={}){let K=$.resolve(J,Y.dir??"server/api"),Q=[],Z=new Map;if(!H.existsSync(K))return Q;let B=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:K})).sort();for(let z of B){if(z.endsWith(".d.ts"))continue;let W=z.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),I=W.pop(),X=I.lastIndexOf("."),_=X>=0?I.slice(X+1):"get",F=_.toUpperCase();if(!R.includes(F)||_!==_.toLowerCase())throw Error(`Unsupported API method suffix in ${z}; use ${R.map((k)=>k.toLowerCase()).join(", ")}`);if(X>=0)I=I.slice(0,X);if(I!=="index")W.push(I);let G=new Set,j=W.map((k,S)=>{let E=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(k);if(E){if(G.has(E[2])||E[1]&&S!==W.length-1)throw Error(`Invalid API parameter in ${z}`);return G.add(E[2]),`:${E[2]}${E[1]?"*":""}`}if(!/^[\w-]+$/.test(k))throw Error(`Unsupported API path segment ${k} in ${z}`);return k}),U=`/api${j.length?`/${j.join("/")}`:""}`,L=`${F} ${U.replace(/:\w+/g,":param")}`;if(Z.has(L))throw Error(`Ambiguous API route ${F} ${U}: ${Z.get(L)} and ${z}`);Z.set(L,z);let M=$.join(K,z);O.add($.resolve(M)),O.add(H.realpathSync(M)),Q.push({pattern:U,method:F,filePath:M})}return Q.sort((z,V)=>{let W=z.pattern.split("/"),I=V.pattern.split("/"),X=(_)=>_?.endsWith("*")?0:_?.startsWith(":")?1:2;for(let _=0;_<Math.max(W.length,I.length);_++){let F=X(I[_])-X(W[_]);if(F)return F}return z.pattern.localeCompare(V.pattern)||z.method.localeCompare(V.method)})}async function w(J,Y){let K=A(J,"api-types.d.ts"),Q=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let B of Y){let z=`./${$.relative($.dirname(K),B.filePath).replace(/\\/g,"/")}`,{params:V}=C(B.pattern);Q.push(` ${JSON.stringify(`${B.method} ${B.pattern}`)}: { params: { ${V.map((W)=>`${JSON.stringify(W)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(z)}).default>> }`)}Q.push(" }","}","export {}","");let Z=Q.join(`
2
+ import{rs as x}from"./chunk-tf16jtj4.js";import{rt as A}from"./chunk-ejwfnttb.js";import{Ht as T,Lt as q}from"./chunk-1nnza3m6.js";import{$v as C,Hw as y}from"./chunk-trva71am.js";import{Rw as P}from"./chunk-emjmshj8.js";y();import H from"fs";import $ from"path";import{pathToFileURL as b}from"url";var R=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],O=new Set;function N(J,Y={}){let K=$.resolve(J,Y.dir??"server/api"),Q=[],Z=new Map;if(!H.existsSync(K))return Q;let B=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:K})).sort();for(let z of B){if(z.endsWith(".d.ts"))continue;let W=z.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),I=W.pop(),X=I.lastIndexOf("."),_=X>=0?I.slice(X+1):"get",F=_.toUpperCase();if(!R.includes(F)||_!==_.toLowerCase())throw Error(`Unsupported API method suffix in ${z}; use ${R.map((k)=>k.toLowerCase()).join(", ")}`);if(X>=0)I=I.slice(0,X);if(I!=="index")W.push(I);let G=new Set,j=W.map((k,S)=>{let E=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(k);if(E){if(G.has(E[2])||E[1]&&S!==W.length-1)throw Error(`Invalid API parameter in ${z}`);return G.add(E[2]),`:${E[2]}${E[1]?"*":""}`}if(!/^[\w-]+$/.test(k))throw Error(`Unsupported API path segment ${k} in ${z}`);return k}),U=`/api${j.length?`/${j.join("/")}`:""}`,L=`${F} ${U.replace(/:\w+/g,":param")}`;if(Z.has(L))throw Error(`Ambiguous API route ${F} ${U}: ${Z.get(L)} and ${z}`);Z.set(L,z);let M=$.join(K,z);O.add($.resolve(M)),O.add(H.realpathSync(M)),Q.push({pattern:U,method:F,filePath:M})}return Q.sort((z,V)=>{let W=z.pattern.split("/"),I=V.pattern.split("/"),X=(_)=>_?.endsWith("*")?0:_?.startsWith(":")?1:2;for(let _=0;_<Math.max(W.length,I.length);_++){let F=X(I[_])-X(W[_]);if(F)return F}return z.pattern.localeCompare(V.pattern)||z.method.localeCompare(V.method)})}async function w(J,Y){let K=A(J,"api-types.d.ts"),Q=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let B of Y){let z=`./${$.relative($.dirname(K),B.filePath).replace(/\\/g,"/")}`,{params:V}=C(B.pattern);Q.push(` ${JSON.stringify(`${B.method} ${B.pattern}`)}: { params: { ${V.map((W)=>`${JSON.stringify(W)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(z)}).default>> }`)}Q.push(" }","}","export {}","");let Z=Q.join(`
3
3
  `);if(!await Bun.file(K).exists()||await Bun.file(K).text()!==Z)await Bun.write(K,Z);return K}async function p(J,Y,K={}){let Q=N(J,K);await w(J,Q);let Z=[];for(let B of Q){let z=await Bun.build({entrypoints:[B.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!z.success)throw Error(`API build failed for ${B.filePath}: ${z.logs.join(`
4
- `)}`);let V=z.outputs.find((X)=>X.kind==="entry-point");if(!V)throw Error(`No API bundle for ${B.filePath}`);if(z.outputs.length!==1)throw Error(`API endpoint ${B.filePath} emits assets; package those explicitly instead`);let I=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await V.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write($.join(Y,I),V),Z.push({...B,filePath:I})}return Z}function D(J,Y){let K=J.map((Q)=>({route:Q,...C(Q.pattern)}));return async(Q)=>{let Z=new URL(Q.url).pathname,B=K.filter((G)=>G.regex.test(Z));if(!B.length)return null;let z=B[0].route.pattern,V=(G)=>G.replace(/:\w+/g,":param"),W=B.filter((G)=>V(G.route.pattern)===V(z)),I=Q.method,X=W.find((G)=>G.route.method===I)??(I==="HEAD"?W.find((G)=>G.route.method==="GET"):void 0);if(!X){let G=new Set(W.map((j)=>j.route.method));if(G.has("GET"))G.add("HEAD");return G.add("OPTIONS"),new Response(null,{status:I==="OPTIONS"?204:405,headers:{Allow:Array.from(G).sort().join(", ")}})}let _=X.regex.exec(Z),F=Object.create(null);try{X.params.forEach((G,j)=>{F[G]=decodeURIComponent(_[j+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let G=await Y(X.route);if(typeof G!=="function")throw Error(`API endpoint ${X.route.filePath} must default-export a handler`);let j=await G(Q,{params:F}),U=j instanceof Response?j:j===void 0?new Response(null,{status:204}):Response.json(j);if(I==="HEAD")return new Response(null,{status:U.status,headers:U.headers});return U}catch(G){return console.error(`[stx] API error for ${I} ${z}:`,G),Response.json({error:"Internal Server Error"},{status:500})}}}function l(J,Y){return D(Y,async(K)=>(await import(b($.resolve(J,K.filePath)).href)).default)}async function s(J,Y){if(!Y)return async()=>null;let K=Y===!0?{}:Y,Q=N(J,K);return await w(J,Q),async(Z)=>{if(!new URL(Z.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let B=N(J,K);await w(J,B);let{loadStxConfig:z}=await import("./chunk-32x78na8.js"),V=q((await z(J)).runtimeConfig);return await T(V,()=>D(B,async(W)=>{let I=await Bun.build({entrypoints:[W.filePath],target:"bun",format:"esm",splitting:!1});if(!I.success)throw Error(I.logs.join(`
4
+ `)}`);let V=z.outputs.find((X)=>X.kind==="entry-point");if(!V)throw Error(`No API bundle for ${B.filePath}`);if(z.outputs.length!==1)throw Error(`API endpoint ${B.filePath} emits assets; package those explicitly instead`);let I=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await V.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write($.join(Y,I),V),Z.push({...B,filePath:I})}return Z}function D(J,Y){let K=J.map((Q)=>({route:Q,...C(Q.pattern)}));return async(Q)=>{let Z=new URL(Q.url).pathname,B=K.filter((G)=>G.regex.test(Z));if(!B.length)return null;let z=B[0].route.pattern,V=(G)=>G.replace(/:\w+/g,":param"),W=B.filter((G)=>V(G.route.pattern)===V(z)),I=Q.method,X=W.find((G)=>G.route.method===I)??(I==="HEAD"?W.find((G)=>G.route.method==="GET"):void 0);if(!X){let G=new Set(W.map((j)=>j.route.method));if(G.has("GET"))G.add("HEAD");return G.add("OPTIONS"),new Response(null,{status:I==="OPTIONS"?204:405,headers:{Allow:Array.from(G).sort().join(", ")}})}let _=X.regex.exec(Z),F=Object.create(null);try{X.params.forEach((G,j)=>{F[G]=decodeURIComponent(_[j+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let G=await Y(X.route);if(typeof G!=="function")throw Error(`API endpoint ${X.route.filePath} must default-export a handler`);let j=await G(Q,{params:F}),U=j instanceof Response?j:j===void 0?new Response(null,{status:204}):Response.json(j);if(I==="HEAD")return new Response(null,{status:U.status,headers:U.headers});return U}catch(G){return console.error(`[stx] API error for ${I} ${z}:`,G),Response.json({error:"Internal Server Error"},{status:500})}}}function l(J,Y){return D(Y,async(K)=>(await import(b($.resolve(J,K.filePath)).href)).default)}async function s(J,Y){if(!Y)return async()=>null;let K=Y===!0?{}:Y,Q=N(J,K);return await w(J,Q),async(Z)=>{if(!new URL(Z.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let B=N(J,K);await w(J,B);let{loadStxConfig:z}=await import("./chunk-c4rpdtvw.js"),V=q((await z(J)).runtimeConfig);return await T(V,()=>D(B,async(W)=>{let I=await Bun.build({entrypoints:[W.filePath],target:"bun",format:"esm",splitting:!1});if(!I.success)throw Error(I.logs.join(`
5
5
  `));let X=I.outputs.find((_)=>_.kind==="entry-point");if(!X||I.outputs.length!==1)throw Error(`Unsupported API bundle output: ${W.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await X.text()).toString("base64")}`)).default})(Z))}catch(B){return console.error("[stx] API discovery failed:",B),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function u(J,Y,K){if(x(J))return!0;let Q=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(Q.test($.basename(J)))return!0;try{if(Q.test($.basename(H.realpathSync(J))))return!0}catch{}if(O.has($.resolve(J)))return!0;if(!K)return!1;let Z=$.resolve(Y,typeof K==="object"?K.dir??"server/api":"server/api"),B=(V)=>{try{return H.realpathSync(V)}catch{return $.resolve(V)}},z=B(J);return[Z,$.resolve(Y,"server"),$.resolve(Y,".output/server")].some((V)=>{let W=B(V);return z===W||z.startsWith(`${W}${$.sep}`)})}
6
- export{N as ml,w as nl,p as ol,D as pl,l as ql,s as rl,u as sl};
6
+ export{N as nl,w as ol,p as pl,D as ql,l as rl,s as sl,u as tl};
@@ -2,4 +2,4 @@
2
2
  import I from"fs";import F from"path";import{createHash as w}from"crypto";var H=["pages","components","layouts","partials","composables"],Y=new Set;function u(j){try{return Y.has(I.realpathSync(j))}catch{return Y.has(F.resolve(j))}}var L=new Set(["extends","root",...H.map((j)=>`${j}Dir`),"publicDir","stateDir","cachePath"]),Z=(j)=>j!==null&&typeof j==="object"&&(Object.getPrototypeOf(j)===Object.prototype||Object.getPrototypeOf(j)===null);function _(j,z,A=""){if(Array.isArray(z))return["middleware","plugins"].includes(A)?[...Array.isArray(j)?j:[],...z]:[...z];if(!Z(z))return z;let E={...Z(j)?j:{}};for(let[B,G]of Object.entries(z)){if(["__proto__","constructor","prototype"].includes(B))throw Error(`Invalid layer config key: ${B}`);E[B]=_(E[B],G,B)}return E}function $(j){for(let z of["stx.config.ts","stx.config.js","stx.config.mjs",".config/stx.config.ts",".config/stx.ts","ui.config.ts"]){let A=F.join(j,z);if(I.existsSync(A))return I.realpathSync(A)}throw Error(`Application layer has no stx.config.ts: ${j}`)}function S(j,z,A){if(typeof j!=="string"||!j||/^(?:https?:|git[+:])/.test(j))throw Error(`Invalid application layer ${JSON.stringify(j)} in ${z}; use a local path or installed package`);if(j.startsWith(".")||F.isAbsolute(j)){let B=F.resolve(z,j);return I.statSync(B).isDirectory()?$(B):I.realpathSync(B)}let E=z;while(!0){let B=F.join(E,"node_modules",j),G=F.join(B,"package.json");if(I.existsSync(G)){A.add(I.realpathSync(G));let T=JSON.parse(I.readFileSync(G,"utf8"));return T.stx?.layer?I.realpathSync(F.resolve(B,T.stx.layer)):$(B)}let J=F.dirname(E);if(J===E)break;E=J}throw Error(`Cannot resolve application layer ${JSON.stringify(j)} from ${z}`)}async function C(j,z){let A=await Bun.build({entrypoints:[j],target:"bun",format:"esm",splitting:!1,plugins:[{name:"stx-layer-config",setup(G){G.onResolve({filter:/^[^./]/},(J)=>{if(J.path.startsWith("node:"))return{path:J.path,external:!0};return{path:Bun.resolveSync(J.path,J.resolveDir),external:!0}}),G.onLoad({filter:/./},(J)=>{let T=I.realpathSync(J.path);z.add(T),Y.add(T);return})}}]});if(!A.success)throw Error(`Cannot load layer ${j}: ${A.logs.join(`
3
3
  `)}`);let E=A.outputs.find((G)=>G.kind==="entry-point");if(!E||A.outputs.length!==1)throw Error(`Unsupported layer config output: ${j}`);let B=(await import(`data:text/javascript;base64,${Buffer.from(await E.text()).toString("base64")}`)).default;if(!Z(B))throw Error(`Layer ${j} must default-export a config object`);return B}async function v(j,z){let A=new Set,E=[],B=[],G=new Set,J=[];async function T(q,M){if(q=I.realpathSync(q),J.includes(q))throw Error(`Application layer cycle: ${[...J,q].join(" -> ")}`);if(G.has(q))return;G.add(q),J.push(q);let U=await C(q,A);M??=F.basename(F.dirname(q))===".config"?F.dirname(F.dirname(q)):F.dirname(q),M=I.realpathSync(M);let D=F.resolve(M,U.root??"."),K=Object.fromEntries(H.map((Q)=>[Q,F.resolve(D,U[`${Q}Dir`]??(Q==="composables"?"functions":Q))]));E.push({root:M,configFile:q,resources:K});let N={...U};if(N.plugins)N.plugins=N.plugins.map((Q)=>{let W=typeof Q==="string"?Q:Q[0],X=W.startsWith(".")?F.resolve(M,W):F.isAbsolute(W)?W:Bun.resolveSync(W,M);return A.add(I.realpathSync(X)),typeof Q==="string"?X:[X,Q[1]]});if(typeof N.css==="string")N.css=F.resolve(M,N.css);if(N.serverApi)N.serverApi={...typeof N.serverApi==="object"?N.serverApi:{},dir:F.resolve(M,typeof N.serverApi==="object"?N.serverApi.dir??"server/api":"server/api")};if(B.push(N),U.extends!==void 0&&!Array.isArray(U.extends))throw Error(`extends in ${q} must be an array`);for(let Q of U.extends??[])await T(S(Q,M,A));J.pop()}await T($(j),j);for(let q of["package.json","bun.lock","package-lock.json","pnpm-lock.yaml"]){let M=F.join(j,q);if(I.existsSync(M))A.add(I.realpathSync(M))}let O=_({},z);for(let q=B.length-1;q>=0;q--){let M=q===0?B[q]:Object.fromEntries(Object.entries(B[q]).filter(([U])=>!L.has(U)));O=_(O,M)}let V={layers:E,configDependencies:[...A].sort()};return O._layerGraph=V,O._layerPageDirs=E.map((q)=>q.resources.pages),O._layerComponentDirs=E.map((q)=>q.resources.components),O._layerLayoutDirs=E.map((q)=>q.resources.layouts),O._layerPartialDirs=E.map((q)=>q.resources.partials),O._layerComposableDirs=E.map((q)=>q.resources.composables),await R(V,j),{config:O,graph:V}}async function R(j,z){let A=new Map,E=[];for(let B of j.layers)for(let[G,J]of Object.entries(B.resources)){if(!I.existsSync(J))continue;let T=new Bun.Glob(G==="composables"?"**/*.ts":"**/*.stx");for(let O of[...T.scanSync({cwd:J})].sort()){let V=`${G}/${O}`,q=F.join(J,O),M=A.get(V);if(M)E.push({resource:V,winner:M,shadowed:q});else A.set(V,q)}}Object.assign(j,{overrides:E}),await Bun.write(F.join(z,".stx/layers.json"),JSON.stringify(j,null,2))}function P(j){let z=new Set(j.configDependencies);function A(E){if(!I.existsSync(E))return;z.add(E);for(let B of I.readdirSync(E,{withFileTypes:!0}).sort((G,J)=>G.name.localeCompare(J.name))){if(B.name.startsWith(".")||B.name==="node_modules")continue;let G=F.join(E,B.name);if(B.isDirectory())A(G);else if(B.isFile())z.add(G)}}for(let E of j.layers)for(let B of Object.values(E.resources))A(B);return[...z].sort()}function h(j){return x(P(j))}function y(j){return x(j.configDependencies)}function x(j){return j.map((z)=>{try{let A=I.statSync(z);return`${z}:${A.mtimeMs}:${A.size}`}catch{return`${z}:missing`}}).join(`
4
4
  `)}function g(j){return j.layers.map((z)=>({config:F.relative(z.root,z.configFile),files:P({layers:[z],configDependencies:j.configDependencies.filter((A)=>A.startsWith(`${z.root}${F.sep}`))}).filter((A)=>I.statSync(A).isFile()).map((A)=>({path:F.relative(z.root,A).replaceAll(F.sep,"/"),sha256:w("sha256").update(I.readFileSync(A)).digest("hex")}))}))}
5
- export{u as ns,v as os,R as ps,h as qs,y as rs,g as ss};
5
+ export{u as rs,v as ss,R as ts,h as us,y as vs,g as ws};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Lw as v$,Mw as G}from"./chunk-ejqpq0wc.js";function y($){return $.split(/[\\/]/).filter(Boolean).slice(0,-1).some((O)=>F.includes(O))}function A($){return y($.replace(/^\//,""))}var F;var C=G(()=>{F=["components","layouts","partials","emails"]});import W from"fs";import E from"path";function H($,U){let O=$.filter((K)=>!A(K.pattern)),I=["// Auto-generated by STX - do not edit"];if(O.length===0)I.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{I.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let K of O){let V=[];for(let X of K.params){let Y=K.pattern.includes(`:${X}?`)?"?":"";V.push(`${X}${Y}: string`)}let J=V.join("; ");I.push(` '${K.pattern}': { ${J} }`)}I.push(" }","}","","export {}","")}let B=I.join(`
2
+ import{Pw as v$,Qw as G}from"./chunk-emjmshj8.js";function y($){return $.split(/[\\/]/).filter(Boolean).slice(0,-1).some((O)=>F.includes(O))}function A($){return y($.replace(/^\//,""))}var F;var C=G(()=>{F=["components","layouts","partials","emails"]});import W from"fs";import E from"path";function H($,U){let O=$.filter((K)=>!A(K.pattern)),I=["// Auto-generated by STX - do not edit"];if(O.length===0)I.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{I.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let K of O){let V=[];for(let X of K.params){let Y=K.pattern.includes(`:${X}?`)?"?":"";V.push(`${X}${Y}: string`)}let J=V.join("; ");I.push(` '${K.pattern}': { ${J} }`)}I.push(" }","}","","export {}","")}let B=I.join(`
3
3
  `),L=E.join(U,"route-types.d.ts");try{if(W.existsSync(L)&&W.readFileSync(L,"utf8")===B)return;W.mkdirSync(U,{recursive:!0}),W.writeFileSync(L,B)}catch{}}function q($,U,O){let I=process.cwd(),B=E.relative(I,O),L=$.filter((V)=>!A(V.pattern)),K=["// Auto-generated by stx \u2014 do not edit",`// Source: ${B||"pages"}/`,"","export const routes = ["];for(let V of L){let J=E.relative(I,V.filePath).replace(/\\/g,"/"),X=JSON.stringify(V.params),Y=V.layout?`, layout: '${E.relative(I,V.layout).replace(/\\/g,"/")}'`:"";K.push(` { pattern: '${V.pattern}', filePath: '${J}', isDynamic: ${V.isDynamic}, params: ${X}${Y} },`)}K.push("] as const",""),K.push("export type RouteName = typeof routes[number]['pattern']",""),W.mkdirSync(U,{recursive:!0}),W.writeFileSync(E.join(U,"routes.ts"),K.join(`
4
4
  `))}var f=G(()=>{C()});import i from"path";function N($,U){let I=i.relative(U,$).replace(/\.(stx|md)$/,"");if(I=I.split(i.sep).join("/"),I==="index")return"/";if(I.endsWith("/index"))I=I.slice(0,-6);return I=I.replace(/\[\[([^\]]+)\]\]/g,":$1?"),I=I.replace(/\[([^\]]+)\]/g,":$1"),I=I.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${I}`}function j($){let U=[],O="",I=0;while(I<$.length){let B=$.slice(I),L=/^\/:([^/?*]+)\?/.exec(B);if(L){U.push(L[1]),O+="(?:/([^/]+))?",I+=L[0].length;continue}let K=/^:([^/?*]+)\*/.exec(B);if(K){U.push(K[1]),O+="(.+)",I+=K[0].length;continue}let V=/^:([^/?*]+)/.exec(B);if(V){U.push(V[1]),O+="([^/]+)",I+=V[0].length;continue}O+=$[I].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),I+=1}return{regex:new RegExp(`^${O}$`),params:U}}function o($,U){let O=$===""?"/":$;for(let I of U){let B=O.match(I.regex);if(B){let L={};return I.params.forEach((K,V)=>{L[K]=B[V+1]}),{route:I,params:L}}}return null}function r($){let U=$.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return j(U)}var g=()=>{};import b$ from"fs";import d from"path";function R($,U){let O=[],I=d.dirname($);while(I.startsWith(U)||I===U){let B=d.join(I,"_layout.stx");if(b$.existsSync(B))O.unshift(B);if(I===U)break;I=d.dirname(I)}return O}var m=()=>{};import S from"fs";import Q from"path";function t($,U){let O=[];if(!S.existsSync($))return O;let I=S.readdirSync($,{withFileTypes:!0});for(let B of I){let L=Q.join($,B.name);if(B.isDirectory()){if(B.name.startsWith("."))continue;if(F.includes(B.name))continue;O.push(...t(L,U))}else if(B.isFile()){let K=Q.extname(B.name);if(U.includes(K)){if(B.name.startsWith("_")&&B.name!=="_layout.stx")continue;if(B.name==="_layout.stx")continue;O.push(L)}}}return O}class b{routes;pagesDir;pagesDirs;config;constructor($,U={}){this.config=U;let O=U.pagesDirs&&U.pagesDirs.length>0?U.pagesDirs:[U.pagesDir||"pages"];this.pagesDirs=O.map((J)=>Q.resolve($,J)),this.pagesDir=this.pagesDirs[0];let I=U.extensions||[".stx"],B=(J)=>{let X=Q.resolve($,J);try{return S.realpathSync(X)}catch{return X}},L=(U.exclude??[]).filter((J)=>typeof J==="string"&&J.trim()!=="").map(B),K=(J)=>{if(L.length===0)return!1;let X=B(J);return L.some((Y)=>X===Y||X.startsWith(`${Y}${Q.sep}`))},V=new Set;this.routes=[];for(let J of this.pagesDirs){let X=t(J,I).filter((Z)=>!K(Z)),Y=new Map;for(let Z of X){let _=N(Z,J),z=U.pagesDirs?_.replace(/:[\w]+/g,":param"):_;if(U.pagesDirs&&Y.has(z))throw Error(`Conflicting layer pages for ${_}: ${Y.get(z)} and ${Z}`);if(Y.set(z,Z),V.has(z))continue;V.add(z);let{regex:S$,params:s}=j(_),D=U.layouts!==!1?R(Z,J):[];this.routes.push({pattern:_,regex:S$,params:s,filePath:Z,isDynamic:s.length>0,layout:D.length>0?D[D.length-1]:void 0})}}if(this.routes.sort((J,X)=>{if(!J.isDynamic&&X.isDynamic)return-1;if(J.isDynamic&&!X.isDynamic)return 1;let Y=J.pattern.split("/").length,Z=X.pattern.split("/").length;if(Y!==Z)return Z-Y;return J.pattern.localeCompare(X.pattern)}),U.emit!==!1){let J=Q.resolve($,U.stateDir||process.env.STX_DIR?.trim()||".stx");H(this.routes,J),q(this.routes,J,this.pagesDir)}}match($){let U=$===""?"/":$;for(let O of this.routes){let I=U.match(O.regex);if(I){let B={};return O.params.forEach((L,K)=>{B[L]=I[K+1]}),{route:O,params:B}}}return null}resolve($,U){let O=this.routes.find((B)=>B.pattern===$||B.filePath.includes($));if(!O)return"#not-found";let I=O.pattern;if(U)for(let[B,L]of Object.entries(U))I=I.replace(`:${B}`,encodeURIComponent(L));return I}addRoute($){this.routes.push($),this.routes.sort((U,O)=>{if(!U.isDynamic&&O.isDynamic)return-1;if(U.isDynamic&&!O.isDynamic)return 1;return U.pattern.localeCompare(O.pattern)})}getLayout($){return $.layout??null}}function a($,U){return new b($,U)}function e($,U){let O=[`${U}.stx`,"error.stx"];for(let I of O){let B=Q.join($,I);if(S.existsSync(B))return B}return null}function $$($,U){return $.map((O)=>{let I=Q.relative(U,O.filePath),B=O.isDynamic?" (dynamic)":"";return`${O.pattern} \u2192 ${I}${B}`})}var U$=G(()=>{f();g();m();C()});function I$($){x=$.replace(/\/$/,"")}function O$($,U,O={}){M[$]={path:U,name:$,params:O}}function B$($){for(let[U,O]of Object.entries($))if(typeof O==="string")M[U]={path:O,name:U};else M[U]={...O,name:U}}function J$($,U={},O=!1){let I=M[$];if(!I)return console.warn(`Route [${$}] not defined.`),"#undefined-route";let B={...I.params,...U},L=I.path;L=L.replace(/:(\w+)/g,(V,J)=>{let X=B[J];if(X===void 0)return console.warn(`Missing parameter [${J}] for route [${$}].`),`:${J}`;return delete B[J],encodeURIComponent(String(X))});let K=Object.entries(B);if(K.length>0){let V=K.map(([J,X])=>`${encodeURIComponent(J)}=${encodeURIComponent(String(X))}`).join("&");L+=(L.includes("?")?"&":"?")+V}return O&&x?`${x}${L}`:L}function K$(){for(let $ of Object.keys(M))delete M[$];x=""}var M,x="";var L$=G(()=>{M={}});import V$ from"fs";import X$ from"path";function Y$($,U={}){return{type:"redirect",path:$,options:{replace:U.replace??!1,external:U.external??!1,redirectCode:U.redirectCode??302}}}function Z$($){return{type:"abort",error:typeof $==="string"?{statusCode:500,message:$}:$}}function G$($,U={}){return{handler:$,mode:U.mode??"universal"}}function h($){let U={};if(!$)return U;let O=$.split(";");for(let I of O){let[B,...L]=I.split("=");if(B){let K=B.trim(),V=L.join("=").trim();if(K)U[K]=decodeURIComponent(V)}}return U}function k($,U,O={}){let I=`${encodeURIComponent($)}=${encodeURIComponent(U)}`;if(O.expires){let B=typeof O.expires==="number"?new Date(Date.now()+O.expires*1000):O.expires;I+=`; Expires=${B.toUTCString()}`}if(O.path)I+=`; Path=${O.path}`;if(O.domain)I+=`; Domain=${O.domain}`;if(O.secure)I+="; Secure";if(O.httpOnly)I+="; HttpOnly";if(O.sameSite)I+=`; SameSite=${O.sameSite}`;return I}function c($,U){let O=$.headers.get("cookie")||"",I=h(O);return{get(B){return I[B]},set(B,L,K={}){I[B]=L,U.append("Set-Cookie",k(B,L,K))},delete(B){delete I[B],U.append("Set-Cookie",k(B,"",{expires:new Date(0),path:"/"}))},getAll(){return{...I}}}}function l(){return{get($){if(typeof document>"u")return;return h(document.cookie)[$]},set($,U,O={}){if(typeof document>"u")return;document.cookie=k($,U,O)},delete($){if(typeof document>"u")return;document.cookie=k($,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return h(document.cookie)}}}function u(){let $=typeof window<"u"&&typeof window.localStorage<"u";return{get(U){if(!$)return null;try{return window.localStorage.getItem(U)}catch{return null}},set(U,O){if(!$)return;try{window.localStorage.setItem(U,O)}catch{}},remove(U){if(!$)return;try{window.localStorage.removeItem(U)}catch{}},isAvailable(){return $}}}function v($,U){T.set($,U)}function p($){return T.get($)}function Q$($){return T.has($)}function W$(){T.clear()}function M$(){return Array.from(T.keys())}async function _$($,U="middleware"){let O=X$.resolve($,U);if(!V$.existsSync(O))return;let I=V$.readdirSync(O);for(let B of I){if(!B.endsWith(".ts")&&!B.endsWith(".js"))continue;if(B.includes(".test.")||B.includes(".spec."))continue;let L=B.replace(/\.(ts|js)$/,""),K=X$.join(O,B);try{let J=(await import(K)).default;if(J&&typeof J.handler==="function")v(L,J);else if(typeof J==="function")v(L,{handler:J,mode:"universal"})}catch(V){console.warn(`Failed to load middleware '${L}' from ${K}:`,V)}}}function x$($){let U={};if(!$)return U;let O=new URLSearchParams($);for(let[I,B]of O)U[I]=B;return U}function z$($,U,O,I=""){return{path:$,params:U,query:x$(I),fullPath:I?`${$}?${I}`:$,meta:O}}function F$($,U,O,I){let B=I?.isServer??typeof window>"u",L=!B,K=new Headers;return{to:$,from:U,isClient:L,isServer:B,cookies:B&&O?c(O,K):l(),storage:u(),state:{},request:O,responseHeaders:K}}async function A$($,U){let O=Array.isArray($)?$:[$],I=U.isServer;for(let B of O){let L=p(B);if(!L)return console.error(`Route middleware '${B}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${B}' is not registered`}},state:U.state,responseHeaders:U.responseHeaders};if(L.mode==="server"&&!I)continue;try{let K=await L.handler(U);if(K){if(K.type==="redirect")return{passed:!1,redirect:K,state:U.state,responseHeaders:U.responseHeaders};if(K.type==="abort")return{passed:!1,abort:K,state:U.state,responseHeaders:U.responseHeaders}}}catch(K){return console.error(`Error in middleware '${B}':`,K),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:K instanceof Error?K.message:"Middleware error"}},state:U.state,responseHeaders:U.responseHeaders}}}return{passed:!0,state:U.state,responseHeaders:U.responseHeaders}}var T;var E$=G(()=>{T=new Map});function n($){let O=$.replace(/\\/g,"/").split("/").filter(Boolean),I=O.lastIndexOf("layouts"),B=I>=0?O[I+1]:O.at(-1);if(!B)return"app";return B.replace(/\.stx$/i,"")||"app"}function j$($){let U=$.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),O=$.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),I=$.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),B=U?.[1]||I?.[1]||"";return{layout:B,group:O?.[1]||n(B)}}var T$=()=>{};function k$($){let U=[],O="log(",I=0;while(I<$.length){let B=$.indexOf("log(",I);if(B===-1){U.push($.slice(I));break}let L=B>0?$[B-1]:" ",K=/\bfunction\s+$/.test($.slice(Math.max(0,B-16),B));if(/[\w$.]/.test(L)||K){U.push($.slice(I,B+4)),I=B+4;continue}U.push($.slice(I,B));let V=1,J=B+4;while(J<$.length&&V>0){let X=$[J];if(X==='"'||X==="'"||X==="`"){let Y=X;J++;while(J<$.length&&$[J]!==Y){if($[J]==="\\")J++;J++}J++;continue}if(X==="(")V++;else if(X===")")V--;J++}U.push("0"),I=J}return U.join("")}function C$($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}function H$(){return`
5
5
  ;(function(){
@@ -2275,4 +2275,4 @@ else {
2275
2275
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
2276
2276
  })();
2277
2277
  `}function q$(){if(w)return w;return w=C$(k$(H$())),w}function N$(){if(P)return P;return P=C$(H$()),P}var w,P;var R$=()=>{};var w$={};v$(w$,{setAppUrl:()=>I$,runMiddleware:()=>A$,route:()=>J$,resolveLayoutChain:()=>R,resetRoutes:()=>K$,registerMiddleware:()=>v,patternToRegex:()=>j,navigateTo:()=>Y$,matchRoute:()=>o,loadMiddlewareFromDirectory:()=>_$,isNonPageRoutePattern:()=>A,isNonPageRoutePath:()=>y,hasMiddleware:()=>Q$,getRouterScriptDev:()=>N$,getRouterScript:()=>q$,getMiddlewareNames:()=>M$,getMiddleware:()=>p,generateRouteTypes:()=>H,generateRouteManifest:()=>q,formatRoutes:()=>$$,findErrorPage:()=>e,filePathToPattern:()=>N,extractLayoutMetadata:()=>j$,deriveLayoutGroup:()=>n,defineRoutes:()=>B$,defineRoute:()=>O$,defineMiddleware:()=>G$,createStorageManager:()=>u,createServerCookieManager:()=>c,createRouter:()=>a,createRouteLocation:()=>z$,createMiddlewareContext:()=>F$,createClientCookieManager:()=>l,clearMiddleware:()=>W$,bracketPathToRegex:()=>r,abortNavigation:()=>Z$,Router:()=>b,NON_PAGE_DIRS:()=>F});var P$=G(()=>{U$();g();L$();E$();m();T$();f();C();R$()});
2278
- export{F as Rv,y as Sv,A as Tv,H as Uv,q as Vv,N as Wv,j as Xv,o as Yv,r as Zv,R as _v,b as $v,a as aw,e as bw,$$ as cw,I$ as dw,O$ as ew,B$ as fw,J$ as gw,K$ as hw,Y$ as iw,Z$ as jw,G$ as kw,c as lw,l as mw,u as nw,v as ow,p as pw,Q$ as qw,W$ as rw,M$ as sw,_$ as tw,z$ as uw,F$ as vw,A$ as ww,n as xw,j$ as yw,T$ as zw,q$ as Aw,N$ as Bw,w$ as Cw,P$ as Dw};
2278
+ export{F as Vv,y as Wv,A as Xv,H as Yv,q as Zv,N as _v,j as $v,o as aw,r as bw,R as cw,b as dw,a as ew,e as fw,$$ as gw,I$ as hw,O$ as iw,B$ as jw,J$ as kw,K$ as lw,Y$ as mw,Z$ as nw,G$ as ow,c as pw,l as qw,u as rw,v as sw,p as tw,Q$ as uw,W$ as vw,M$ as ww,_$ as xw,z$ as yw,F$ as zw,A$ as Aw,n as Bw,j$ as Cw,T$ as Dw,q$ as Ew,N$ as Fw,w$ as Gw,P$ as Hw};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ih as x,nh as M,oh as C,ph as v,qh as P}from"./chunk-18018jkn.js";import{Nw as y}from"./chunk-ejqpq0wc.js";import{resolve as h,basename as f,extname as u,join as m}from"path";import{mkdir as l}from"fs/promises";var I={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0};class z{config;constructor(J={}){this.config={...I,...J}}async get(J,Z){return C(J,Z,"image",this.config)}async set(J,Z,Y){return v(J,Z,Y,"image",this.config)}async clear(){return P("image",this.config)}updateConfig(J){this.config={...this.config,...J}}}var H=null;function S(J){if(!H)H=new z(J);else if(J)H.updateConfig(J);return H}async function w(J,Z,Y){let K=Y?{directory:`${Y.outputDir}/../.cache`}:{};return S(K).get(J,Z)}async function Q(J,Z,Y,K){let X=K?{directory:`${K.outputDir}/../.cache`}:{};return S(X).set(J,Z,Y)}async function d(){return S().clear()}async function R(){try{return await import("ts-images")}catch{return null}}function b(J){switch(J){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function p(J,Z){let Y=Z?b(Z):b("web"),K=J.formatQuality||{};return{jpeg:{...Y.jpeg,...K.jpeg},png:{...Y.png,...K.png},webp:{...Y.webp,...K.webp},avif:{...Y.avif,...K.avif}}}async function g(J,Z,Y){let K=await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:J,processed:!1};let X=await w(J,Z,Y);if(X)return X;try{let N=h(J);if(!await M(N))return{src:J,processed:!1,errors:[`Source file not found: ${J}`]};let L=p(Y,Z.preset),V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await l(V,{recursive:!0});let q=await x(N),U=f(J,u(J)),E=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],G={src:J,processed:!0,variants:[],hash:q},j=null;if(Z.transformations&&Z.transformations.length>0)j=await D(N,Z.transformations,K);for(let $ of E){let A=L[$]||{},W=`${U}-${q}.${$}`,_=m(V,W);try{let O=await K.optimizeImage({input:j||N,output:_,format:$,quality:A.quality,progressive:A.progressive});if(O){if(G.variants.push({path:_,url:`${F}/${W}`,width:O.width||0,height:O.height||0,format:$,size:O.outputSize||0}),!G.originalWidth&&O.width)G.originalWidth=O.width,G.originalHeight=O.height}}catch(O){G.errors=G.errors||[],G.errors.push(`Failed to optimize ${$}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let $=await K.generateThumbHash(N);G.placeholder=$.dataUrl}catch($){G.errors=G.errors||[],G.errors.push(`Failed to generate thumbhash: ${$}`)}if(Z.useDominantColor)try{let $=await K.generatePlaceholder(N,{strategy:"dominant-color"});G.dominantColor=$.dominantColor}catch($){G.errors=G.errors||[],G.errors.push(`Failed to extract dominant color: ${$}`)}return await Q(J,Z,G,Y),G}catch(N){return{src:J,processed:!1,errors:[`Processing failed: ${N}`]}}}async function n(J,Z,Y,K){let X=await R();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:J,output:K,format:Z,quality:Y}))?.outputSize}}catch(N){return{success:!1,error:String(N)}}}async function D(J,Z,Y){let K=Y||await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await K.decode(J);for(let N of Z){let L=N.options||{};switch(N.type){case"resize":if(L.width||L.height)X=await K.resize(X,{width:L.width,height:L.height,fit:L.fit});break;case"blur":if(L.sigma!==void 0)X=await K.blur(X,L.sigma);break;case"sharpen":if(L.amount!==void 0)X=await K.sharpen(X,L.amount);break;case"grayscale":X=await K.grayscale(X);break;case"rotate":if(L.angle!==void 0)X=await K.rotate(X,L.angle);break;case"flip":X=await K.flip(X);break;case"flop":X=await K.flop(X);break;case"brightness":if(L.value!==void 0)X=await K.brightness(X,L.value);break;case"contrast":if(L.value!==void 0)X=await K.contrast(X,L.value);break;case"saturation":if(L.value!==void 0)X=await K.saturation(X,L.value);break}}return await K.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}import{resolve as c,basename as i,extname as r,join as o}from"path";import{mkdir as a}from"fs/promises";async function e(){try{return await import("ts-images")}catch{return null}}var s=[320,480,640,768,1024,1280,1536,1920];async function t(J,Z,Y){let K=await e();if(!K)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=c(J);if(!await M(X))return console.warn(`[stx-media] Source file not found: ${J}`),null;try{let N=Z.responsiveWidths||Y.breakpoints||s,L=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await a(V,{recursive:!0});let q=await x(X),U=i(J,r(J)),E=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},G={src:J,byFormat:{},srcsets:{}};for(let $ of L){G.byFormat[$]=[];let A=[];for(let W of N){let _=`${U}-${W}w-${q}.${$}`,O=o(V,_),B=`${F}/${_}`;try{let T=E[$]?.quality||80;if(await M(O)){G.byFormat[$].push({path:O,url:B,width:W,height:0,format:$,size:0}),A.push(`${B} ${W}w`);continue}let k=await K.processImage({input:X,output:O,format:$,quality:T,resize:{width:W}});if(k)G.byFormat[$].push({path:O,url:B,width:W,height:k.height||Math.round(W*(k.height||1)/(k.width||1)),format:$,size:k.outputSize||0}),A.push(`${B} ${W}w`)}catch(T){console.warn(`[stx-media] Failed to generate ${$} at ${W}w: ${T}`)}}G.srcsets[$]=A.join(", ")}let j=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(j!=="none")try{if(j==="thumbhash"){let $=await K.generateThumbHash(X);G.placeholder={dataURL:$.dataUrl,width:$.width||32,height:$.height||32,strategy:"thumbhash"}}else{let $=await K.generatePlaceholder(X,{strategy:j,width:20});G.placeholder={dataURL:$.dataURL,width:$.width,height:$.height,strategy:j}}}catch($){console.warn(`[stx-media] Failed to generate placeholder: ${$}`)}return G.sizes=Z.sizes||JJ(N),G}catch(N){return console.error(`[stx-media] Responsive generation failed: ${N}`),null}}function JJ(J){let Z=[...J].sort((K,X)=>K-X),Y=[];for(let K=0;K<Z.length-1;K++){let X=Z[K];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function KJ(J,Z="width"){if(!J||J.length===0)return"";if(Z==="dpr")return J.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return J.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}export{z as Qg,w as Rg,Q as Sg,d as Tg,g as Ug,n as Vg,D as Wg,t as Xg,KJ as Yg};
2
+ import{jh as x,oh as M,ph as C,qh as v,rh as P}from"./chunk-bcpjhcpn.js";import{Rw as y}from"./chunk-emjmshj8.js";import{resolve as h,basename as f,extname as u,join as m}from"path";import{mkdir as l}from"fs/promises";var I={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0};class z{config;constructor(J={}){this.config={...I,...J}}async get(J,Z){return C(J,Z,"image",this.config)}async set(J,Z,Y){return v(J,Z,Y,"image",this.config)}async clear(){return P("image",this.config)}updateConfig(J){this.config={...this.config,...J}}}var H=null;function S(J){if(!H)H=new z(J);else if(J)H.updateConfig(J);return H}async function w(J,Z,Y){let K=Y?{directory:`${Y.outputDir}/../.cache`}:{};return S(K).get(J,Z)}async function Q(J,Z,Y,K){let X=K?{directory:`${K.outputDir}/../.cache`}:{};return S(X).set(J,Z,Y)}async function d(){return S().clear()}async function R(){try{return await import("ts-images")}catch{return null}}function b(J){switch(J){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function p(J,Z){let Y=Z?b(Z):b("web"),K=J.formatQuality||{};return{jpeg:{...Y.jpeg,...K.jpeg},png:{...Y.png,...K.png},webp:{...Y.webp,...K.webp},avif:{...Y.avif,...K.avif}}}async function g(J,Z,Y){let K=await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:J,processed:!1};let X=await w(J,Z,Y);if(X)return X;try{let N=h(J);if(!await M(N))return{src:J,processed:!1,errors:[`Source file not found: ${J}`]};let L=p(Y,Z.preset),V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await l(V,{recursive:!0});let q=await x(N),U=f(J,u(J)),E=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],G={src:J,processed:!0,variants:[],hash:q},j=null;if(Z.transformations&&Z.transformations.length>0)j=await D(N,Z.transformations,K);for(let $ of E){let A=L[$]||{},W=`${U}-${q}.${$}`,_=m(V,W);try{let O=await K.optimizeImage({input:j||N,output:_,format:$,quality:A.quality,progressive:A.progressive});if(O){if(G.variants.push({path:_,url:`${F}/${W}`,width:O.width||0,height:O.height||0,format:$,size:O.outputSize||0}),!G.originalWidth&&O.width)G.originalWidth=O.width,G.originalHeight=O.height}}catch(O){G.errors=G.errors||[],G.errors.push(`Failed to optimize ${$}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let $=await K.generateThumbHash(N);G.placeholder=$.dataUrl}catch($){G.errors=G.errors||[],G.errors.push(`Failed to generate thumbhash: ${$}`)}if(Z.useDominantColor)try{let $=await K.generatePlaceholder(N,{strategy:"dominant-color"});G.dominantColor=$.dominantColor}catch($){G.errors=G.errors||[],G.errors.push(`Failed to extract dominant color: ${$}`)}return await Q(J,Z,G,Y),G}catch(N){return{src:J,processed:!1,errors:[`Processing failed: ${N}`]}}}async function n(J,Z,Y,K){let X=await R();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:J,output:K,format:Z,quality:Y}))?.outputSize}}catch(N){return{success:!1,error:String(N)}}}async function D(J,Z,Y){let K=Y||await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await K.decode(J);for(let N of Z){let L=N.options||{};switch(N.type){case"resize":if(L.width||L.height)X=await K.resize(X,{width:L.width,height:L.height,fit:L.fit});break;case"blur":if(L.sigma!==void 0)X=await K.blur(X,L.sigma);break;case"sharpen":if(L.amount!==void 0)X=await K.sharpen(X,L.amount);break;case"grayscale":X=await K.grayscale(X);break;case"rotate":if(L.angle!==void 0)X=await K.rotate(X,L.angle);break;case"flip":X=await K.flip(X);break;case"flop":X=await K.flop(X);break;case"brightness":if(L.value!==void 0)X=await K.brightness(X,L.value);break;case"contrast":if(L.value!==void 0)X=await K.contrast(X,L.value);break;case"saturation":if(L.value!==void 0)X=await K.saturation(X,L.value);break}}return await K.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}import{resolve as c,basename as i,extname as r,join as o}from"path";import{mkdir as a}from"fs/promises";async function e(){try{return await import("ts-images")}catch{return null}}var s=[320,480,640,768,1024,1280,1536,1920];async function t(J,Z,Y){let K=await e();if(!K)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=c(J);if(!await M(X))return console.warn(`[stx-media] Source file not found: ${J}`),null;try{let N=Z.responsiveWidths||Y.breakpoints||s,L=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await a(V,{recursive:!0});let q=await x(X),U=i(J,r(J)),E=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},G={src:J,byFormat:{},srcsets:{}};for(let $ of L){G.byFormat[$]=[];let A=[];for(let W of N){let _=`${U}-${W}w-${q}.${$}`,O=o(V,_),B=`${F}/${_}`;try{let T=E[$]?.quality||80;if(await M(O)){G.byFormat[$].push({path:O,url:B,width:W,height:0,format:$,size:0}),A.push(`${B} ${W}w`);continue}let k=await K.processImage({input:X,output:O,format:$,quality:T,resize:{width:W}});if(k)G.byFormat[$].push({path:O,url:B,width:W,height:k.height||Math.round(W*(k.height||1)/(k.width||1)),format:$,size:k.outputSize||0}),A.push(`${B} ${W}w`)}catch(T){console.warn(`[stx-media] Failed to generate ${$} at ${W}w: ${T}`)}}G.srcsets[$]=A.join(", ")}let j=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(j!=="none")try{if(j==="thumbhash"){let $=await K.generateThumbHash(X);G.placeholder={dataURL:$.dataUrl,width:$.width||32,height:$.height||32,strategy:"thumbhash"}}else{let $=await K.generatePlaceholder(X,{strategy:j,width:20});G.placeholder={dataURL:$.dataURL,width:$.width,height:$.height,strategy:j}}}catch($){console.warn(`[stx-media] Failed to generate placeholder: ${$}`)}return G.sizes=Z.sizes||JJ(N),G}catch(N){return console.error(`[stx-media] Responsive generation failed: ${N}`),null}}function JJ(J){let Z=[...J].sort((K,X)=>K-X),Y=[];for(let K=0;K<Z.length-1;K++){let X=Z[K];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function KJ(J,Z="width"){if(!J||J.length===0)return"";if(Z==="dpr")return J.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return J.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}export{z as Rg,w as Sg,Q as Tg,d as Ug,g as Vg,n as Wg,D as Xg,t as Yg,KJ as Zg};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{Ho as V}from"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import{Nw as F}from"./chunk-ejqpq0wc.js";import l from"fs";import R from"path";function m(z,J){let Z=[R.join(z.root,"stx.config.ts"),R.join(z.root,"stx.config.js"),R.join(z.root,"stx.config.mjs")],K=J.debounceMs??300,$=null,X=[];for(let B of Z)try{if(!l.existsSync(B))continue;let Y=l.watch(B,(W)=>{if(W==="change"){if($)clearTimeout($);$=setTimeout(async()=>{d("Config file changed, restarting...");try{await J.onChange()}catch(j){G(`Failed to restart: ${j}`)}},K)}});X.push(Y)}catch{}return{stop(){if($)clearTimeout($);for(let B of X)B.close()}}}import E from"fs";import i from"path";var Gz=".stx/story/analytics.json",Nz=1,c=1e4;class M{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(z){this.storagePath=i.join(z,Gz),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let z=E.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Nz,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let z=i.dirname(this.storagePath);if(await E.promises.mkdir(z,{recursive:!0}),this.storage.events.length>c)this.storage.events=this.storage.events.slice(-c);await E.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Hz(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(z){this.storage.events.push({...z,timestamp:Date.now()}),this.dirty=!0}trackView(z,J){if(this.endViewTiming(z),this.viewStartTimes.set(z,Date.now()),this.track({type:"view",componentId:z,variantId:J}),this.currentSession&&!this.currentSession.componentViews.includes(z))this.currentSession.componentViews.push(z)}endViewTiming(z){let J=this.viewStartTimes.get(z);if(J){let Z=Date.now()-J;this.track({type:"view",componentId:z,metadata:{duration:Z,endView:!0}}),this.viewStartTimes.delete(z)}}trackPropChange(z,J,Z){this.track({type:"prop_change",componentId:z,propName:J,metadata:{value:Z}})}trackVariantSwitch(z,J){this.track({type:"variant_switch",componentId:z,variantId:J})}trackSearch(z,J){this.track({type:"search",query:z,metadata:{resultCount:J}})}getComponentAnalytics(z,J){let Z=this.storage.events.filter((Q)=>Q.componentId===z),K=Z.filter((Q)=>Q.type==="view"&&!Q.metadata?.endView),$=Z.filter((Q)=>Q.type==="prop_change"),X=Z.filter((Q)=>Q.type==="variant_switch"),B={};for(let Q of $)if(Q.propName)B[Q.propName]=(B[Q.propName]||0)+1;let Y={};for(let Q of X)if(Q.variantId)Y[Q.variantId]=(Y[Q.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((Q)=>Q.componentViews.includes(z)).map((Q)=>Q.id)),j=Z.filter((Q)=>Q.metadata?.duration).map((Q)=>Q.metadata.duration),U=j.length>0?j.reduce((Q,D)=>Q+D,0)/j.length:0,_=Object.entries(B).sort((Q,D)=>D[1]-Q[1]).slice(0,5).map(([Q])=>Q);return{componentId:z,componentName:J,viewCount:K.length,uniqueViews:W.size,lastViewed:K[K.length-1]?.timestamp,propChanges:B,topChangedProps:_,variantViews:Y,avgTimeSpent:U}}getMostViewedComponents(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="view"&&Z.componentId&&!Z.metadata?.endView)J.set(Z.componentId,(J.get(Z.componentId)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({componentId:Z,viewCount:K})).sort((Z,K)=>K.viewCount-Z.viewCount).slice(0,z)}getMostChangedProps(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="prop_change"&&Z.propName)J.set(Z.propName,(J.get(Z.propName)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({propName:Z,changeCount:K})).sort((Z,K)=>K.changeCount-Z.changeCount).slice(0,z)}getSearchAnalytics(){let z=this.storage.events.filter(($)=>$.type==="search"),J=new Map,Z=0;for(let $ of z){if($.query)J.set($.query,(J.get($.query)||0)+1);if($.metadata?.resultCount!==void 0)Z+=$.metadata.resultCount}let K=Array.from(J.entries()).map(([$,X])=>({query:$,count:X})).sort(($,X)=>X.count-$.count).slice(0,10);return{totalSearches:z.length,topQueries:K,avgResultCount:z.length>0?Z/z.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Hz(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import P from"fs";import p from"path";var Fz=".stx/story/bookmarks.json",Vz=1;class T{storage;storagePath;dirty=!1;constructor(z){this.storagePath=p.join(z,Fz),this.storage=this.loadStorage()}loadStorage(){try{let z=P.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Vz,bookmarks:[]}}}async save(){if(!this.dirty)return;let z=p.dirname(this.storagePath);await P.promises.mkdir(z,{recursive:!0}),await P.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(z,J,Z,K={}){let $={id:Rz(),name:K.name||`${z}/${J}`,storyId:z,variantId:J,props:Z,created:Date.now(),notes:K.notes,color:K.color};return this.storage.bookmarks.push($),this.dirty=!0,$}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(z){return this.storage.bookmarks.filter((J)=>J.storyId===z)}getBookmark(z){return this.storage.bookmarks.find((J)=>J.id===z)}isBookmarked(z,J){return this.storage.bookmarks.some((Z)=>Z.storyId===z&&Z.variantId===J)}updateBookmark(z,J){let Z=this.getBookmark(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deleteBookmark(z){let J=this.storage.bookmarks.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.bookmarks.splice(J,1),this.dirty=!0,!0}toggleBookmark(z,J,Z){let K=this.storage.bookmarks.find((X)=>X.storyId===z&&X.variantId===J);if(K)return this.deleteBookmark(K.id),{added:!1};return{added:!0,bookmark:this.addBookmark(z,J,Z)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(z,J=!0){let Z=JSON.parse(z),K=0;for(let $ of Z.bookmarks){if(J){let X=this.storage.bookmarks.find((B)=>B.id===$.id);if(X)Object.assign(X,$);else this.storage.bookmarks.push($)}else this.storage.bookmarks.push($);K++}if(K>0)this.dirty=!0;return K}}function Rz(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var N=new Set;function s(){return{open(z){N.add(z),z.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(z){N.delete(z)},message(z,J){}}}function q(z){let J=JSON.stringify({...z,timestamp:z.timestamp||Date.now()});for(let Z of N)try{Z.send(J)}catch{N.delete(Z)}}function n(z,J){q({type:"story-update",data:{storyId:z,...J}})}function a(z,J){q({type:"story-add",data:{storyId:z,...J}})}function o(z){q({type:"story-remove",data:{storyId:z}})}function r(z){return`
2
+ import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{Io as V}from"./chunk-3ssjb8cx.js";import"./chunk-ykevda74.js";import"./chunk-ez003q74.js";import"./chunk-kyyt9xhs.js";import"./chunk-tf16jtj4.js";import"./chunk-19m7hed6.js";import"./chunk-kjd9hbg4.js";import"./chunk-ejwfnttb.js";import"./chunk-5270fyk7.js";import"./chunk-q4kgqqed.js";import"./chunk-1nnza3m6.js";import"./chunk-hkrzv980.js";import"./chunk-qbz6yn8c.js";import"./chunk-czj6nq0b.js";import"./chunk-zxfejz72.js";import"./chunk-mere396d.js";import"./chunk-aa8015mk.js";import"./chunk-trva71am.js";import"./chunk-rtfwn4cm.js";import{Rw as F}from"./chunk-emjmshj8.js";import l from"fs";import R from"path";function m(z,J){let Z=[R.join(z.root,"stx.config.ts"),R.join(z.root,"stx.config.js"),R.join(z.root,"stx.config.mjs")],K=J.debounceMs??300,$=null,X=[];for(let B of Z)try{if(!l.existsSync(B))continue;let Y=l.watch(B,(W)=>{if(W==="change"){if($)clearTimeout($);$=setTimeout(async()=>{d("Config file changed, restarting...");try{await J.onChange()}catch(j){G(`Failed to restart: ${j}`)}},K)}});X.push(Y)}catch{}return{stop(){if($)clearTimeout($);for(let B of X)B.close()}}}import E from"fs";import i from"path";var Gz=".stx/story/analytics.json",Nz=1,c=1e4;class M{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(z){this.storagePath=i.join(z,Gz),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let z=E.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Nz,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let z=i.dirname(this.storagePath);if(await E.promises.mkdir(z,{recursive:!0}),this.storage.events.length>c)this.storage.events=this.storage.events.slice(-c);await E.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Hz(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(z){this.storage.events.push({...z,timestamp:Date.now()}),this.dirty=!0}trackView(z,J){if(this.endViewTiming(z),this.viewStartTimes.set(z,Date.now()),this.track({type:"view",componentId:z,variantId:J}),this.currentSession&&!this.currentSession.componentViews.includes(z))this.currentSession.componentViews.push(z)}endViewTiming(z){let J=this.viewStartTimes.get(z);if(J){let Z=Date.now()-J;this.track({type:"view",componentId:z,metadata:{duration:Z,endView:!0}}),this.viewStartTimes.delete(z)}}trackPropChange(z,J,Z){this.track({type:"prop_change",componentId:z,propName:J,metadata:{value:Z}})}trackVariantSwitch(z,J){this.track({type:"variant_switch",componentId:z,variantId:J})}trackSearch(z,J){this.track({type:"search",query:z,metadata:{resultCount:J}})}getComponentAnalytics(z,J){let Z=this.storage.events.filter((Q)=>Q.componentId===z),K=Z.filter((Q)=>Q.type==="view"&&!Q.metadata?.endView),$=Z.filter((Q)=>Q.type==="prop_change"),X=Z.filter((Q)=>Q.type==="variant_switch"),B={};for(let Q of $)if(Q.propName)B[Q.propName]=(B[Q.propName]||0)+1;let Y={};for(let Q of X)if(Q.variantId)Y[Q.variantId]=(Y[Q.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((Q)=>Q.componentViews.includes(z)).map((Q)=>Q.id)),j=Z.filter((Q)=>Q.metadata?.duration).map((Q)=>Q.metadata.duration),U=j.length>0?j.reduce((Q,D)=>Q+D,0)/j.length:0,_=Object.entries(B).sort((Q,D)=>D[1]-Q[1]).slice(0,5).map(([Q])=>Q);return{componentId:z,componentName:J,viewCount:K.length,uniqueViews:W.size,lastViewed:K[K.length-1]?.timestamp,propChanges:B,topChangedProps:_,variantViews:Y,avgTimeSpent:U}}getMostViewedComponents(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="view"&&Z.componentId&&!Z.metadata?.endView)J.set(Z.componentId,(J.get(Z.componentId)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({componentId:Z,viewCount:K})).sort((Z,K)=>K.viewCount-Z.viewCount).slice(0,z)}getMostChangedProps(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="prop_change"&&Z.propName)J.set(Z.propName,(J.get(Z.propName)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({propName:Z,changeCount:K})).sort((Z,K)=>K.changeCount-Z.changeCount).slice(0,z)}getSearchAnalytics(){let z=this.storage.events.filter(($)=>$.type==="search"),J=new Map,Z=0;for(let $ of z){if($.query)J.set($.query,(J.get($.query)||0)+1);if($.metadata?.resultCount!==void 0)Z+=$.metadata.resultCount}let K=Array.from(J.entries()).map(([$,X])=>({query:$,count:X})).sort(($,X)=>X.count-$.count).slice(0,10);return{totalSearches:z.length,topQueries:K,avgResultCount:z.length>0?Z/z.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Hz(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import P from"fs";import p from"path";var Fz=".stx/story/bookmarks.json",Vz=1;class T{storage;storagePath;dirty=!1;constructor(z){this.storagePath=p.join(z,Fz),this.storage=this.loadStorage()}loadStorage(){try{let z=P.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Vz,bookmarks:[]}}}async save(){if(!this.dirty)return;let z=p.dirname(this.storagePath);await P.promises.mkdir(z,{recursive:!0}),await P.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(z,J,Z,K={}){let $={id:Rz(),name:K.name||`${z}/${J}`,storyId:z,variantId:J,props:Z,created:Date.now(),notes:K.notes,color:K.color};return this.storage.bookmarks.push($),this.dirty=!0,$}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(z){return this.storage.bookmarks.filter((J)=>J.storyId===z)}getBookmark(z){return this.storage.bookmarks.find((J)=>J.id===z)}isBookmarked(z,J){return this.storage.bookmarks.some((Z)=>Z.storyId===z&&Z.variantId===J)}updateBookmark(z,J){let Z=this.getBookmark(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deleteBookmark(z){let J=this.storage.bookmarks.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.bookmarks.splice(J,1),this.dirty=!0,!0}toggleBookmark(z,J,Z){let K=this.storage.bookmarks.find((X)=>X.storyId===z&&X.variantId===J);if(K)return this.deleteBookmark(K.id),{added:!1};return{added:!0,bookmark:this.addBookmark(z,J,Z)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(z,J=!0){let Z=JSON.parse(z),K=0;for(let $ of Z.bookmarks){if(J){let X=this.storage.bookmarks.find((B)=>B.id===$.id);if(X)Object.assign(X,$);else this.storage.bookmarks.push($)}else this.storage.bookmarks.push($);K++}if(K>0)this.dirty=!0;return K}}function Rz(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var N=new Set;function s(){return{open(z){N.add(z),z.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(z){N.delete(z)},message(z,J){}}}function q(z){let J=JSON.stringify({...z,timestamp:z.timestamp||Date.now()});for(let Z of N)try{Z.send(J)}catch{N.delete(Z)}}function n(z,J){q({type:"story-update",data:{storyId:z,...J}})}function a(z,J){q({type:"story-add",data:{storyId:z,...J}})}function o(z){q({type:"story-remove",data:{storyId:z}})}function r(z){return`
3
3
  <script>
4
4
  (function() {
5
5
  const ws = new WebSocket('${z}');
@@ -556,7 +556,7 @@ window.__stxPerformance = {
556
556
 
557
557
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
558
558
  </script>
559
- `}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-4b2vsawv.js"),j={},U=A(Y);if(U)try{await V(U,j,J)}catch(O){$.push(`Warning: Could not extract script variables: ${O instanceof Error?O.message:String(O)}`)}if(Z.props)Object.assign(j,Z.props);let Q=await W(Y,j,J,{},new Set),D=Wz(Y),L=A(Y);return Q=jz(Q),Q=Dz(Q,j),{html:Q,css:D,js:L,errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}async function qz(z){try{let J=await S.promises.readFile(z,"utf-8"),Z=A(J);if(!Z)return null;let K={};if(await V(Z,K,z),Array.isArray(K.variants))return K.variants;return null}catch{return null}}async function Bz(z,J,Z,K){let $=J.story?.variants;if(!$){let Y=await qz(J.path);if(Y)$=Y}if(!$&&Z==="default")return H(z,J.path,{props:K||{}});if(!$)return H(z,J.path,{props:K||{}});let X=$.find((Y)=>Y.id===Z);if(!X&&Z==="default")return H(z,J.path,{props:K||{}});if(!X)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Z}' not found`],duration:0};let B={...X.state,...K};if(X.source)return wz(z,X.source,B);return H(z,J.path,{props:B})}async function wz(z,J,Z={}){let K=performance.now(),$=[];try{let{processDirectives:X}=await import("./chunk-4b2vsawv.js"),B={...Z},Y=A(J);if(Y)try{await V(Y,B,"inline-template.stx")}catch{}let j=await X(J,B,"inline-template.stx",{},new Set);return j=jz(j),j=Dz(j,B),{html:j,css:Wz(J),js:A(J),errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}function Wz(z){let J=[],Z=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
559
+ `}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-38mpg3kn.js"),j={},U=A(Y);if(U)try{await V(U,j,J)}catch(O){$.push(`Warning: Could not extract script variables: ${O instanceof Error?O.message:String(O)}`)}if(Z.props)Object.assign(j,Z.props);let Q=await W(Y,j,J,{},new Set),D=Wz(Y),L=A(Y);return Q=jz(Q),Q=Dz(Q,j),{html:Q,css:D,js:L,errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}async function qz(z){try{let J=await S.promises.readFile(z,"utf-8"),Z=A(J);if(!Z)return null;let K={};if(await V(Z,K,z),Array.isArray(K.variants))return K.variants;return null}catch{return null}}async function Bz(z,J,Z,K){let $=J.story?.variants;if(!$){let Y=await qz(J.path);if(Y)$=Y}if(!$&&Z==="default")return H(z,J.path,{props:K||{}});if(!$)return H(z,J.path,{props:K||{}});let X=$.find((Y)=>Y.id===Z);if(!X&&Z==="default")return H(z,J.path,{props:K||{}});if(!X)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Z}' not found`],duration:0};let B={...X.state,...K};if(X.source)return wz(z,X.source,B);return H(z,J.path,{props:B})}async function wz(z,J,Z={}){let K=performance.now(),$=[];try{let{processDirectives:X}=await import("./chunk-38mpg3kn.js"),B={...Z},Y=A(J);if(Y)try{await V(Y,B,"inline-template.stx")}catch{}let j=await X(J,B,"inline-template.stx",{},new Set);return j=jz(j),j=Dz(j,B),{html:j,css:Wz(J),js:A(J),errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}function Wz(z){let J=[],Z=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
560
560
  `)}function jz(z){return z.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function A(z){let J=[],Z=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
561
561
  `)}function Dz(z,J){let Z=`<script>window.__stxProps = ${JSON.stringify(J)};</script>`;return z+Z}function Lz(z){return z.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function Oz(z,J){let Z=await I(z);f(z,Z);let K=v(z.config,Z);g(z,K),console.log(` Found ${Z.length} story files`);let $=typeof J.host==="string"?J.host:J.host===!0?"0.0.0.0":"localhost",X=new k(z.root),B=new T(z.root),Y=new M(z.root),W=s(),j=Bun.serve({port:J.port,hostname:$,fetch:async(Q,D)=>{let O=new URL(Q.url).pathname;if(O==="/__hmr"){if(D.upgrade(Q,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(O.startsWith("/api/"))return Cz(z,O,Q,{presetsManager:X,bookmarksManager:B,analyticsTracker:Y});return kz(z,O,J.port)},websocket:{open(Q){W.open(Q)},close(Q){W.close(Q)},message(Q,D){W.message(Q,D)}}}),U=`http://${$}:${J.port}`,_=Uz(z,async(Q,D)=>{console.log(` [${Q}] ${D.relativePath}`);let L=await I(z);f(z,L);let O=v(z.config,L);if(g(z,O),Q==="add")a(D.id,{fileName:D.fileName});else if(Q==="unlink")o(D.id);else n(D.id,{fileName:D.fileName})});if(J.open){let Q=U;try{let{exec:D}=await import("child_process"),L=process.platform;D(`${L==="darwin"?"open":L==="win32"?"start":"xdg-open"} ${Q}`)}catch{}}return{server:j,url:U,close:async()=>{_(),j.stop()}}}async function Cz(z,J,Z,K){let{presetsManager:$,bookmarksManager:X,analyticsTracker:B}=K;if(J==="/api/stories")return Response.json({files:z.storyFiles.map((Y)=>({id:Y.id,fileName:Y.fileName,relativePath:Y.relativePath,treePath:Y.treePath})),tree:z.tree});if(J.startsWith("/api/story/")){let Y=J.slice(11),W=z.storyFiles.find((j)=>j.id===Y);if(!W)return new Response("Story not found",{status:404});try{let j=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:j})}catch{return new Response("Error reading story",{status:500})}}if(J==="/api/config")return Response.json({theme:z.config.theme,responsivePresets:z.config.responsivePresets,backgroundPresets:z.config.backgroundPresets});if(J.startsWith("/api/render/")){let Y=new URL(Z.url),W=J.slice(12).split("/"),j=W[0],U=W[1]||"default",_,Q=Y.searchParams.get("props");if(Q)try{_=JSON.parse(Q)}catch{}let D=z.storyFiles.find((L)=>L.id===j);if(!D)return new Response("Story not found",{status:404});try{let L=await Bz(z,D,U,_);return Response.json({html:L.html,css:L.css,js:L.js,errors:L.errors,duration:L.duration})}catch(L){return Response.json({html:"",css:"",js:"",errors:[L instanceof Error?L.message:String(L)],duration:0},{status:500})}}if(J==="/api/presets"&&Z.method==="GET")return Response.json({presets:$.getAllPresets()});if(J==="/api/presets"&&Z.method==="POST")try{let Y=await Z.json(),W=$.createPreset(Y.name,Y.props,{componentId:Y.componentId,description:Y.description});return await $.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/presets/")&&!J.includes("/use")&&Z.method==="GET"){let Y=J.slice(13),W=$.getPreset(Y);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(J.endsWith("/use")&&Z.method==="POST"){let Y=J.slice(13,-4),W=$.usePreset(Y);if(!W)return new Response("Preset not found",{status:404});return await $.save(),Response.json(W)}if(J.startsWith("/api/presets/")&&Z.method==="DELETE"){let Y=J.slice(13);if(!$.deletePreset(Y))return new Response("Preset not found",{status:404});return await $.save(),Response.json({success:!0})}if(J==="/api/bookmarks"&&Z.method==="GET")return Response.json({bookmarks:X.getAllBookmarks()});if(J==="/api/bookmarks"&&Z.method==="POST")try{let Y=await Z.json(),W=X.addBookmark(Y.storyId,Y.variantId,Y.props,{name:Y.name,notes:Y.notes,color:Y.color});return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/bookmarks/toggle"&&Z.method==="POST")try{let Y=await Z.json(),W=X.toggleBookmark(Y.storyId,Y.variantId,Y.props);return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/bookmarks/")&&J!=="/api/bookmarks/toggle"&&Z.method==="GET"){let Y=J.slice(15),W=X.getBookmark(Y);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(J.startsWith("/api/bookmarks/")&&Z.method==="DELETE"){let Y=J.slice(15);if(!X.deleteBookmark(Y))return new Response("Bookmark not found",{status:404});return await X.save(),Response.json({success:!0})}if(J==="/api/analytics/track"&&Z.method==="POST")try{let Y=await Z.json();if(Y.type==="view"&&Y.componentId)B.trackView(Y.componentId,Y.variantId);else if(Y.type==="prop_change"&&Y.componentId&&Y.propName)B.trackPropChange(Y.componentId,Y.propName,null);else if(Y.type==="variant_switch"&&Y.componentId&&Y.variantId)B.trackVariantSwitch(Y.componentId,Y.variantId);else if(Y.type==="search"&&Y.query)B.trackSearch(Y.query,0);return await B.save(),Response.json({success:!0})}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/analytics/summary"&&Z.method==="GET")return Response.json({mostViewed:B.getMostViewedComponents(10),mostChangedProps:B.getMostChangedProps(10),searchAnalytics:B.getSearchAnalytics()});if(J.startsWith("/api/analytics/component/")&&Z.method==="GET"){let Y=J.slice(25),W=z.storyFiles.find((U)=>U.id===Y),j=B.getComponentAnalytics(Y,W?.fileName||Y);return Response.json(j)}return new Response("Not found",{status:404})}function kz(z,J,Z){let K=Sz(z,Z);return new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function Sz(z,J){let{theme:Z}=z.config,K=Z.title||"STX Story",$=`ws://localhost:${J}/__hmr`,X=r($);return`<!DOCTYPE html>
562
562
  <html lang="en" class="${Z.darkClass||"dark"}">
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Lg as a,Mg as b,Ng as c,Og as d,Pg as e,Qg as f}from"./chunk-6yfccnr7.js";import"./chunk-3ssjb8cx.js";import"./chunk-ykevda74.js";import"./chunk-ez003q74.js";import"./chunk-kyyt9xhs.js";import"./chunk-tf16jtj4.js";import"./chunk-19m7hed6.js";import"./chunk-kjd9hbg4.js";import"./chunk-ejwfnttb.js";import"./chunk-5270fyk7.js";import"./chunk-q4kgqqed.js";import"./chunk-1nnza3m6.js";import"./chunk-hkrzv980.js";import"./chunk-qbz6yn8c.js";import"./chunk-czj6nq0b.js";import"./chunk-zxfejz72.js";import"./chunk-mere396d.js";import"./chunk-aa8015mk.js";import"./chunk-trva71am.js";import"./chunk-rtfwn4cm.js";import"./chunk-emjmshj8.js";export{c as renderSlot,d as processSlots,a as parseSlots,b as parseSlotElement,e as extractSlotContent,f as applySlots};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{mf as t,nf as u,of as v,pf as w,qf as x,rf as y,sf as z,tf as A,uf as B,vf as C,wf as D,xf as E}from"./chunk-msywnv5n.js";import{yf as r,zf as s}from"./chunk-b5hank5e.js";import{Af as b,Bf as c,Cf as d,Df as e,Ef as f,Ff as g,Gf as h,If as i,Jf as j,Kf as k,Lf as l,Mf as m,Nf as n,Of as o,Pf as p,Qf as q}from"./chunk-7qp3zphs.js";import{di as a}from"./chunk-g6czgcg4.js";import"./chunk-xvh1k1a4.js";import"./chunk-ejqpq0wc.js";export{D as writeImageManifest,a as rewriteImagesWithSiblings,t as renderImageComponent,v as processImageComponents,g as processImage,u as parseImageComponent,A as optimizeImage,B as optimizeDirectory,e as isSharpAvailable,m as isImageFile,f as isImageBackendAvailable,y as imageDirective,r as handleImageRequest,l as groupVariantsByFormat,o as getTotalSize,n as getMimeType,h as getImageMetadata,k as getFallbackVariant,i as generateSrcSet,j as generateSizes,C as generateImageManifest,p as formatSize,E as defaultImageConfig,z as createImagePlugin,s as createImageHandler,x as createImageDirective,w as clearImageCache,q as ImageProcessingError,b as DEFAULT_WIDTHS,d as DEFAULT_QUALITY,c as DEFAULT_FORMATS};
2
+ import{nf as t,of as u,pf as v,qf as w,rf as x,sf as y,tf as z,uf as A,vf as B,wf as C,xf as D,yf as E}from"./chunk-qrvey4wk.js";import{Af as s,zf as r}from"./chunk-nybn003d.js";import{Bf as b,Cf as c,Df as d,Ef as e,Ff as f,Gf as g,Hf as h,Jf as i,Kf as j,Lf as k,Mf as l,Nf as m,Of as n,Pf as o,Qf as p,Rf as q}from"./chunk-hy79zwyy.js";import{ei as a}from"./chunk-g1vxsvqv.js";import"./chunk-19m7hed6.js";import"./chunk-emjmshj8.js";export{D as writeImageManifest,a as rewriteImagesWithSiblings,t as renderImageComponent,v as processImageComponents,g as processImage,u as parseImageComponent,A as optimizeImage,B as optimizeDirectory,e as isSharpAvailable,m as isImageFile,f as isImageBackendAvailable,y as imageDirective,r as handleImageRequest,l as groupVariantsByFormat,o as getTotalSize,n as getMimeType,h as getImageMetadata,k as getFallbackVariant,i as generateSrcSet,j as generateSizes,C as generateImageManifest,p as formatSize,E as defaultImageConfig,z as createImagePlugin,s as createImageHandler,x as createImageDirective,w as clearImageCache,q as ImageProcessingError,b as DEFAULT_WIDTHS,d as DEFAULT_QUALITY,c as DEFAULT_FORMATS};