@stacksjs/stx 0.2.415 → 0.2.416

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 (203) hide show
  1. package/dist/chunk-02k2v1mb.js +2 -0
  2. package/dist/chunk-0dh1rgg8.js +2 -0
  3. package/dist/{chunk-eed4fwps.js → chunk-0es4h5v1.js} +2 -2
  4. package/dist/chunk-0hrqt5c2.js +2 -0
  5. package/dist/chunk-0vtk2rpr.js +2 -0
  6. package/dist/{chunk-mp6hy8g4.js → chunk-1ctvgd7v.js} +1 -1
  7. package/dist/chunk-1rd3jzrq.js +2 -0
  8. package/dist/{chunk-b98be3yp.js → chunk-26j2q9rq.js} +7 -7
  9. package/dist/chunk-2py27bzq.js +2 -0
  10. package/dist/{chunk-px7fvbj6.js → chunk-2qa7hjp2.js} +2 -2
  11. package/dist/chunk-35e6zj5x.js +2 -0
  12. package/dist/{chunk-qghxz7jm.js → chunk-388rx71h.js} +6 -6
  13. package/dist/chunk-3ch40ebr.js +2 -0
  14. package/dist/{chunk-bay9s6rs.js → chunk-3g8zzdgs.js} +5 -5
  15. package/dist/{chunk-md8rqn48.js → chunk-3t0yaexe.js} +5 -5
  16. package/dist/{chunk-b84h16er.js → chunk-3wrmz1j9.js} +6 -6
  17. package/dist/{chunk-ak1cgcah.js → chunk-41k0th97.js} +4 -4
  18. package/dist/chunk-49cpqjx2.js +2 -0
  19. package/dist/chunk-4k1nkp9r.js +2 -0
  20. package/dist/chunk-50vq8k55.js +2 -0
  21. package/dist/chunk-56pkjk55.js +2 -0
  22. package/dist/chunk-5hnh00ry.js +2 -0
  23. package/dist/chunk-5j52h3e3.js +2 -0
  24. package/dist/chunk-5y1mekxe.js +2 -0
  25. package/dist/chunk-5zryk911.js +2 -0
  26. package/dist/{chunk-h6zsqb9r.js → chunk-6agy2x1f.js} +2 -2
  27. package/dist/chunk-72w28vm8.js +2 -0
  28. package/dist/{chunk-3kthfs03.js → chunk-7mbpjv9e.js} +2 -2
  29. package/dist/chunk-7s7k94as.js +2 -0
  30. package/dist/{chunk-9g27ybyr.js → chunk-7tabykst.js} +2 -2
  31. package/dist/chunk-7wb6jf17.js +2 -0
  32. package/dist/{chunk-9p9qkbtg.js → chunk-7zjvsacw.js} +2 -2
  33. package/dist/{chunk-fh1qrp68.js → chunk-89xcpdsp.js} +5 -5
  34. package/dist/chunk-8cbkqckh.js +2 -0
  35. package/dist/chunk-8ycy1b0e.js +2 -0
  36. package/dist/chunk-8ygks6dx.js +3 -0
  37. package/dist/{chunk-xtvf6n6f.js → chunk-95165j9c.js} +2 -2
  38. package/dist/{chunk-re8b5r9x.js → chunk-9fyss0yk.js} +2 -2
  39. package/dist/{chunk-8eqrwj1k.js → chunk-9rnh52t2.js} +10 -10
  40. package/dist/{chunk-169n1vpx.js → chunk-9t2xx2y4.js} +3 -3
  41. package/dist/{chunk-0zaess6f.js → chunk-a47yp92z.js} +5 -5
  42. package/dist/{chunk-765e1s44.js → chunk-ae7j3n39.js} +6 -6
  43. package/dist/chunk-aqrnpgn7.js +2 -0
  44. package/dist/{chunk-amtr3rmf.js → chunk-at0ar6t3.js} +3 -3
  45. package/dist/chunk-b9rebdtq.js +2 -0
  46. package/dist/{chunk-7gkv67ky.js → chunk-bfjzfrw3.js} +2 -2
  47. package/dist/{chunk-z0g9jvv0.js → chunk-c4bkj1xw.js} +6 -6
  48. package/dist/chunk-c4thhfx9.js +2 -0
  49. package/dist/{chunk-6hc5vz20.js → chunk-cn9hgyh5.js} +2 -2
  50. package/dist/{chunk-pgzvyrv6.js → chunk-cq408jrm.js} +3 -3
  51. package/dist/chunk-cw6kqb63.js +2 -0
  52. package/dist/chunk-d3vtgnep.js +2 -0
  53. package/dist/chunk-d4ynv4z2.js +2 -0
  54. package/dist/chunk-d7xrewxq.js +2 -0
  55. package/dist/{chunk-q9bdh4s5.js → chunk-dd5fa7d6.js} +2 -2
  56. package/dist/{chunk-shr559s7.js → chunk-ddk6fx5b.js} +2 -2
  57. package/dist/{chunk-8nhshfz6.js → chunk-de2pv6ys.js} +2 -2
  58. package/dist/{chunk-3efw27as.js → chunk-dg1n3g1d.js} +146 -146
  59. package/dist/chunk-ecr598p7.js +2 -0
  60. package/dist/chunk-eev80mpy.js +2 -0
  61. package/dist/chunk-ef5vz9w5.js +2 -0
  62. package/dist/chunk-f5qd84w8.js +2 -0
  63. package/dist/{chunk-gawrg4gb.js → chunk-fctjn68q.js} +6 -6
  64. package/dist/{chunk-amd6ey3t.js → chunk-fkhxz1dx.js} +5 -5
  65. package/dist/chunk-g69tnqga.js +2 -0
  66. package/dist/chunk-gacycmb0.js +2 -0
  67. package/dist/chunk-ggywfyzm.js +2 -0
  68. package/dist/chunk-gp1bhn7t.js +2 -0
  69. package/dist/{chunk-vgvtnwxa.js → chunk-gq97zh73.js} +3 -3
  70. package/dist/chunk-gr3r9xdh.js +2 -0
  71. package/dist/{chunk-ngc2wke4.js → chunk-gxrewzhv.js} +2 -2
  72. package/dist/{chunk-wfy1zq53.js → chunk-gyv1t0f0.js} +5 -5
  73. package/dist/{chunk-340a824p.js → chunk-h8wegkb5.js} +1 -1
  74. package/dist/{chunk-e9hs7kk6.js → chunk-hec0bvvf.js} +1 -1
  75. package/dist/chunk-hg1eq72d.js +2 -0
  76. package/dist/chunk-hvyqs5tf.js +2 -0
  77. package/dist/{chunk-y5310237.js → chunk-j8rxdbe5.js} +2 -2
  78. package/dist/{chunk-5qns2sdz.js → chunk-jr4dwkvc.js} +2 -2
  79. package/dist/chunk-kbysqxmd.js +2 -0
  80. package/dist/chunk-kmnsrvrp.js +2 -0
  81. package/dist/chunk-m6fvj7g1.js +2 -0
  82. package/dist/{chunk-j03revz2.js → chunk-m9xdkzm6.js} +3 -3
  83. package/dist/chunk-mgw2cvb7.js +2 -0
  84. package/dist/chunk-mvwt1c8f.js +2 -0
  85. package/dist/{chunk-v91p6ekp.js → chunk-n5k88y07.js} +3 -3
  86. package/dist/{chunk-r3f9jcf7.js → chunk-nj8edn4m.js} +3 -3
  87. package/dist/chunk-nvh31cxn.js +2 -0
  88. package/dist/{chunk-fr2txj8q.js → chunk-p1tb8kxq.js} +4 -4
  89. package/dist/chunk-p34gbb4z.js +2 -0
  90. package/dist/chunk-peyt18ce.js +2 -0
  91. package/dist/{chunk-jnkrn913.js → chunk-ppse812s.js} +1 -1
  92. package/dist/{chunk-752hw7cd.js → chunk-qff4qkx5.js} +3 -3
  93. package/dist/chunk-qpx8kvd8.js +2 -0
  94. package/dist/{chunk-f46qsp4m.js → chunk-qzkebqm3.js} +2 -2
  95. package/dist/chunk-rb272g9d.js +3 -0
  96. package/dist/{chunk-m4sk62wb.js → chunk-rfdqrv5v.js} +4 -4
  97. package/dist/{chunk-9vrja6vp.js → chunk-rg6csnkw.js} +1 -1
  98. package/dist/chunk-rh1dyfsn.js +2 -0
  99. package/dist/{chunk-czxt605c.js → chunk-rhw7pqhy.js} +4 -4
  100. package/dist/{chunk-thyt8ed8.js → chunk-rp4khnan.js} +3 -3
  101. package/dist/{chunk-s5xezjps.js → chunk-rqc4jx2v.js} +1 -1
  102. package/dist/chunk-rspc8gn8.js +2 -0
  103. package/dist/{chunk-9amp82bx.js → chunk-rv5bk83t.js} +2 -2
  104. package/dist/chunk-rvs61c88.js +2 -0
  105. package/dist/chunk-sf1vhfrb.js +2 -0
  106. package/dist/{chunk-96k8s808.js → chunk-sh5c60a2.js} +2 -2
  107. package/dist/{chunk-ym95v4nc.js → chunk-std6xw3y.js} +2 -2
  108. package/dist/{chunk-pbh4smw3.js → chunk-t9axxwy9.js} +4 -4
  109. package/dist/{chunk-wzx0164n.js → chunk-tc274fcv.js} +4 -4
  110. package/dist/{chunk-9pt8fd2n.js → chunk-tfhjbjq5.js} +3 -3
  111. package/dist/chunk-ty7t3gp4.js +3 -0
  112. package/dist/{chunk-6h38kkjf.js → chunk-v096a6fw.js} +6 -6
  113. package/dist/chunk-vc9wa97m.js +2 -0
  114. package/dist/{chunk-y1cmjvk3.js → chunk-vvp4cmfq.js} +5 -5
  115. package/dist/{chunk-t4hzprsm.js → chunk-vvs75dse.js} +2 -2
  116. package/dist/{chunk-tafqyf2g.js → chunk-wjag92ch.js} +73 -73
  117. package/dist/chunk-wjzqz3yr.js +2 -0
  118. package/dist/{chunk-hepd9qgx.js → chunk-wpe72ann.js} +5 -5
  119. package/dist/{chunk-ej9j6k1q.js → chunk-x0mq57pe.js} +2 -2
  120. package/dist/chunk-x7j0krz8.js +2 -0
  121. package/dist/chunk-xkv0evbf.js +2 -0
  122. package/dist/{chunk-x0q32ees.js → chunk-y5cqkmkf.js} +2 -2
  123. package/dist/{chunk-42wbs8vq.js → chunk-y6rahx7t.js} +5 -5
  124. package/dist/{chunk-yazk54jr.js → chunk-yk63jd7v.js} +1 -1
  125. package/dist/chunk-yt452b4a.js +2 -0
  126. package/dist/{chunk-hkrmcbwy.js → chunk-yt6h8c6g.js} +11 -11
  127. package/dist/chunk-yxfx44fv.js +2 -0
  128. package/dist/{chunk-ce1sejr3.js → chunk-yzv8n6qw.js} +2 -2
  129. package/dist/{chunk-g186znp9.js → chunk-zcctf7tx.js} +3 -3
  130. package/dist/{chunk-ft4p6d28.js → chunk-znbay168.js} +2 -2
  131. package/dist/{chunk-xfp7k0v8.js → chunk-zyxp0nb3.js} +7 -7
  132. package/dist/cli.js +20 -20
  133. package/dist/craft-entry.js +2 -2
  134. package/dist/craft.js +2 -2
  135. package/dist/dev-server/serve-app.js +3 -0
  136. package/dist/dev-server/serve-multi.js +1 -1
  137. package/dist/document-shell.js +15 -3
  138. package/dist/native/components/primitives.d.ts +2 -0
  139. package/dist/production-server.js +4 -4
  140. package/dist/pwa.js +3 -3
  141. package/dist/ssg.js +15 -15
  142. package/package.json +5 -5
  143. package/dist/chunk-020xyn9q.js +0 -3
  144. package/dist/chunk-04jhmfbz.js +0 -2
  145. package/dist/chunk-0pnj3zt2.js +0 -2
  146. package/dist/chunk-1098mas0.js +0 -2
  147. package/dist/chunk-18vmfkcc.js +0 -2
  148. package/dist/chunk-1b6t12hd.js +0 -2
  149. package/dist/chunk-1zs30k3y.js +0 -2
  150. package/dist/chunk-2ce7f416.js +0 -2
  151. package/dist/chunk-393341w7.js +0 -2
  152. package/dist/chunk-39g1134q.js +0 -2
  153. package/dist/chunk-3qn1wcdg.js +0 -2
  154. package/dist/chunk-3s2vnqcf.js +0 -2
  155. package/dist/chunk-4bjravgk.js +0 -2
  156. package/dist/chunk-5gsxpaqk.js +0 -2
  157. package/dist/chunk-6cfa3g0r.js +0 -2
  158. package/dist/chunk-7z2ra0yf.js +0 -2
  159. package/dist/chunk-92ps1xpk.js +0 -2
  160. package/dist/chunk-9xrbve19.js +0 -2
  161. package/dist/chunk-atws6p5s.js +0 -2
  162. package/dist/chunk-dd8cja4h.js +0 -2
  163. package/dist/chunk-dgdm3hy3.js +0 -2
  164. package/dist/chunk-f1sxycmv.js +0 -2
  165. package/dist/chunk-fbcv4fes.js +0 -2
  166. package/dist/chunk-fjs0a8h7.js +0 -2
  167. package/dist/chunk-fpfzm238.js +0 -2
  168. package/dist/chunk-fyzajkrx.js +0 -2
  169. package/dist/chunk-fzapbw9p.js +0 -3
  170. package/dist/chunk-g03s93qr.js +0 -3
  171. package/dist/chunk-gc1drn2p.js +0 -2
  172. package/dist/chunk-gea5hf0v.js +0 -2
  173. package/dist/chunk-gqv3ta5d.js +0 -2
  174. package/dist/chunk-h6kp2m9r.js +0 -2
  175. package/dist/chunk-hbxz85wy.js +0 -2
  176. package/dist/chunk-hhnw2sn3.js +0 -2
  177. package/dist/chunk-hjg3ndgh.js +0 -2
  178. package/dist/chunk-hk1mj4tz.js +0 -2
  179. package/dist/chunk-hn9pkyv8.js +0 -2
  180. package/dist/chunk-hpgr4qgp.js +0 -2
  181. package/dist/chunk-hrbbbtbn.js +0 -2
  182. package/dist/chunk-j9qcrwbg.js +0 -2
  183. package/dist/chunk-jk4njz0w.js +0 -2
  184. package/dist/chunk-jmabeqfq.js +0 -2
  185. package/dist/chunk-jp10q90g.js +0 -2
  186. package/dist/chunk-jt0n43mk.js +0 -2
  187. package/dist/chunk-m1vdghnx.js +0 -2
  188. package/dist/chunk-nc8my58s.js +0 -2
  189. package/dist/chunk-nn2vstke.js +0 -2
  190. package/dist/chunk-nppdrf0x.js +0 -2
  191. package/dist/chunk-p2v2a68k.js +0 -2
  192. package/dist/chunk-pazfr1a1.js +0 -2
  193. package/dist/chunk-pdb5fw3r.js +0 -2
  194. package/dist/chunk-pdt69hpb.js +0 -2
  195. package/dist/chunk-q6vrb2pe.js +0 -2
  196. package/dist/chunk-q7qchkvk.js +0 -2
  197. package/dist/chunk-sd321bn3.js +0 -2
  198. package/dist/chunk-t5pvq5mx.js +0 -2
  199. package/dist/chunk-w72qx0eb.js +0 -2
  200. package/dist/chunk-xwzvfqcb.js +0 -2
  201. package/dist/chunk-ydjfar14.js +0 -2
  202. package/dist/chunk-z23kaxq6.js +0 -2
  203. package/dist/chunk-z8xn5ta3.js +0 -2
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{_a}from"./chunk-vvs75dse.js";export{_a as rewriteImagesWithSiblings};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ul}from"./chunk-8ygks6dx.js";import"./chunk-gyv1t0f0.js";import"./chunk-wpe72ann.js";import"./chunk-dg1n3g1d.js";import"./chunk-qff4qkx5.js";import"./chunk-ddk6fx5b.js";import"./chunk-41k0th97.js";import"./chunk-rv5bk83t.js";import"./chunk-26j2q9rq.js";import"./chunk-gxrewzhv.js";import"./chunk-zyxp0nb3.js";import"./chunk-rfdqrv5v.js";import"./chunk-c4bkj1xw.js";import"./chunk-de2pv6ys.js";import"./chunk-bfjzfrw3.js";import"./chunk-yzv8n6qw.js";import"./chunk-rhw7pqhy.js";export{ul as startProductionServer};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{A,kc,i,T,Fu,zu}from"./chunk-dg1n3g1d.js";import"./chunk-qff4qkx5.js";import"./chunk-ddk6fx5b.js";import"./chunk-41k0th97.js";import"./chunk-rv5bk83t.js";import"./chunk-26j2q9rq.js";import"./chunk-gxrewzhv.js";import"./chunk-zyxp0nb3.js";import"./chunk-rfdqrv5v.js";import"./chunk-c4bkj1xw.js";import"./chunk-de2pv6ys.js";import"./chunk-bfjzfrw3.js";import"./chunk-yzv8n6qw.js";import"./chunk-rhw7pqhy.js";export{T as config,A as defaultConfig,Fu as defineStxConfig,i as loadStxConfig,kc as resolveStxDirectories,zu as validateConfig};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ia,uu,du,pu,fu,Da,Oa,gu,mu,hu,yu,Qt,en,On}from"./chunk-9fyss0yk.js";import{he}from"./chunk-et0rr8c7.js";import"./chunk-dg1n3g1d.js";import"./chunk-qff4qkx5.js";import"./chunk-ddk6fx5b.js";import"./chunk-41k0th97.js";import"./chunk-rv5bk83t.js";import"./chunk-26j2q9rq.js";import"./chunk-gxrewzhv.js";import"./chunk-zyxp0nb3.js";import"./chunk-rfdqrv5v.js";import"./chunk-c4bkj1xw.js";import"./chunk-de2pv6ys.js";import"./chunk-bfjzfrw3.js";import"./chunk-yzv8n6qw.js";import"./chunk-rhw7pqhy.js";export{fu as __setSignalsGeneratorsForTest,he as cacheEngineFingerprint,en as cacheTemplate,Qt as checkCache,yu as clearDevCaches,Oa as getCachedRouterScript,Da as getCachedSignalsRuntime,gu as getServeClientAsset,hu as getServeModuleBundle,On as hashFilePath,du as invalidateFileCache,pu as invalidateFileCacheByDir,uu as readFileCached,mu as registerServeModuleBundle,Ia as templateCache};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{jn,Ka,Ru,Ga,Au,Ja,Bn,h,wt,be,Ya,Zr,Za,Pu,q,Qa,Iu,b,Du}from"./chunk-dg1n3g1d.js";import"./chunk-qff4qkx5.js";import"./chunk-ddk6fx5b.js";import"./chunk-41k0th97.js";import"./chunk-rv5bk83t.js";import"./chunk-26j2q9rq.js";import"./chunk-gxrewzhv.js";import"./chunk-zyxp0nb3.js";import"./chunk-rfdqrv5v.js";import"./chunk-c4bkj1xw.js";import"./chunk-de2pv6ys.js";import"./chunk-bfjzfrw3.js";import"./chunk-yzv8n6qw.js";import"./chunk-rhw7pqhy.js";export{Qa as applyFilters,Au as clearCustomFilters,Ya as clientLoopScopes,jn as defaultFilters,h as escapeHtml,wt as escapeHtmlValue,b as evaluateExpression,Ja as findMustacheEnd,Ga as getAllFilters,Za as interpolateScriptAttributes,Zr as interpolateScriptExpressions,Pu as interpolateScriptsInTemplate,q as processExpressions,Ka as registerFilter,Ru as registerFilters,Bn as replaceInterpolations,Iu as resetRejectedExpressionWarnings,Du as unescapeHtml,be as usesSignalsInScript};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Sl,kl}from"./chunk-tfhjbjq5.js";export{kl as ensureTeleportTargets,Sl as processTeleportDirectives};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var w={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},R={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"};function p(e,t){return`${w[t]}${e}\x1B[0m`}function C(e,t){return`${R[t]}${e}\x1B[0m`}var b=(e)=>p(e,"red"),S=(e)=>p(e,"green"),y=(e)=>p(e,"yellow"),O=(e)=>p(e,"blue");var c=(e)=>p(e,"cyan");var a=(e)=>C(e,"bold"),m=(e)=>C(e,"dim");function it(){console.log(""),console.log(c(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(c(" \u2551")+a(" \uD83D\uDCD6 STX Story ")+c("\u2551")),console.log(c(" \u2551")+m(" Component Showcase & Testing ")+c("\u2551")),console.log(c(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function pr(e,t){if(console.log(a(" Server running at:")),console.log(""),console.log(` ${m("\u279C")} ${a("Local:")} ${c(e)}`),t)console.log(` ${m("\u279C")} ${a("Network:")} ${c(t)}`);console.log("")}function ot(e){let t=e>0?"\u2713":"\u25CB",r=e>0?S:y;console.log(` ${r(t)} Found ${a(String(e))} story ${e===1?"file":"files"}`)}function Ls(e,t){if(console.log(""),console.log(` ${b("\u2717")} ${a(b("Error:"))} ${e}`),t)console.log(` ${m(t)}`);console.log("")}function Ee(e){console.log(` ${y("\u26A0")} ${y("Warning:")} ${e}`)}function js(e){console.log(` ${O("\u2139")} ${e}`)}function Bs(e,t,r){console.log(""),console.log(c(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(c(" \u2551")+a(" Build Complete ")+c("\u2551")),console.log(c(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${S("\u2713")} Stories: ${a(String(e))}`),console.log(` ${S("\u2713")} Output: ${a(t)}`),console.log(` ${S("\u2713")} Time: ${a(`${r}ms`)}`),console.log("")}function fr(){console.log(""),console.log(a(" Keyboard Shortcuts:")),console.log(""),console.log(` ${c("h")} Show this help`),console.log(` ${c("o")} Open in browser`),console.log(` ${c("r")} Restart server`),console.log(` ${c("c")} Clear console`),console.log(` ${c("q")} Quit`),console.log("")}import h from"fs";import d from"path";async function at(e){let{root:t,config:r}=e,o=[],i=await P(t,r.storyMatch,r.storyIgnored);for(let s of i){let n=d.resolve(t,s),l=v(s,n);o.push(l)}return o}async function P(e,t,r){let o=[];async function i(s,n){let l=await h.promises.readdir(s,{withFileTypes:!0});for(let g of l){let f=d.join(s,g.name),u=d.relative(n,f);if(T(u,r))continue;if(g.isDirectory())await i(f,n);else if(g.isFile()){if(F(u,t))o.push(u)}}}return await i(e,e),o}function T(e,t){for(let r of t)if(E(e,r))return!0;return!1}function F(e,t){for(let r of t)if(E(e,r))return!0;return!1}function E(e,t){let r=e.replace(/\\/g,"/"),i=t.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return i=`^${i}$`,new RegExp(i).test(r)}function v(e,t){let r=d.basename(e,".story.stx");return{id:e.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:t,relativePath:e,fileName:r,treeFile:{title:r,path:e}}}function Fs(e,t){let{root:r,config:o}=e,i=[],s=h.watch(r,{recursive:!0},async(n,l)=>{if(!l)return;let g=l.replace(/\\/g,"/");if(!F(g,o.storyMatch))return;if(T(g,o.storyIgnored))return;let f=d.resolve(r,g);try{await h.promises.access(f);let u=v(g,f);t(n==="rename"?"add":"change",u)}catch{let u=v(g,f);t("unlink",u)}});return i.push(s),()=>{for(let n of i)n.close()}}function N(e,t){let r=t.treeFile||{title:t.fileName,path:t.relativePath};if(e.tree.file==="title")return r.title.split("/");if(e.tree.file==="path")return[...t.relativePath.split("/").slice(0,-1),r.title];if(typeof e.tree.file==="function")return e.tree.file(r);return[r.title]}function ct(e,t){for(let n of t)n.treePath=N(e,n);let r=(e.tree.groups||[]).map((n)=>({groupConfig:{id:n.id||n.title,title:n.title,include:n.include},treeObject:{}})),o={treeObject:{}};r.push(o);for(let n=0;n<t.length;n++){let l=t[n],g=j(l,r,o);k(l.treePath,n,g.treeObject)}let i=e.tree.order==="asc"?(n,l)=>n.localeCompare(l):e.tree.order,s=[];for(let n of r)if(n===o)s.push(...x(n.treeObject,i));else if(n.groupConfig&&Object.keys(n.treeObject).length>0)s.push({group:!0,id:n.groupConfig.id,title:n.groupConfig.title,children:x(n.treeObject,i)});return s}function j(e,t,r){let o=e.treeFile||{title:e.fileName,path:e.relativePath};for(let i of t)if(i.groupConfig?.include&&i.groupConfig.include(o))return i;return r}function k(e,t,r){let o=r;for(let i=0;i<e.length;i++){let s=e[i];if(i===e.length-1)if(o[s]!==void 0){let l=1;while(o[`${s}-${l}`]!==void 0)l++;o[`${s}-${l}`]=t}else o[s]=t;else{if(o[s]===void 0)o[s]={};else if(typeof o[s]==="number"){let l=o[s];o[s]={"":l}}o=o[s]}}}function x(e,t){let r=[];for(let[o,i]of Object.entries(e))if(typeof i==="number")r.push({title:o,index:i});else r.push({title:o,children:x(i,t)});return r.sort((o,i)=>t(o.title,i.title)),r}
3
- export{it,pr,ot,Ls,Ee,js,Bs,fr,at,Fs,ct};
2
+ var w={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},R={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"};function p(e,t){return`${w[t]}${e}\x1B[0m`}function C(e,t){return`${R[t]}${e}\x1B[0m`}var b=(e)=>p(e,"red"),S=(e)=>p(e,"green"),y=(e)=>p(e,"yellow"),O=(e)=>p(e,"blue");var c=(e)=>p(e,"cyan");var a=(e)=>C(e,"bold"),m=(e)=>C(e,"dim");function ot(){console.log(""),console.log(c(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(c(" \u2551")+a(" \uD83D\uDCD6 STX Story ")+c("\u2551")),console.log(c(" \u2551")+m(" Component Showcase & Testing ")+c("\u2551")),console.log(c(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function fr(e,t){if(console.log(a(" Server running at:")),console.log(""),console.log(` ${m("\u279C")} ${a("Local:")} ${c(e)}`),t)console.log(` ${m("\u279C")} ${a("Network:")} ${c(t)}`);console.log("")}function at(e){let t=e>0?"\u2713":"\u25CB",r=e>0?S:y;console.log(` ${r(t)} Found ${a(String(e))} story ${e===1?"file":"files"}`)}function js(e,t){if(console.log(""),console.log(` ${b("\u2717")} ${a(b("Error:"))} ${e}`),t)console.log(` ${m(t)}`);console.log("")}function Ee(e){console.log(` ${y("\u26A0")} ${y("Warning:")} ${e}`)}function Bs(e){console.log(` ${O("\u2139")} ${e}`)}function Fs(e,t,r){console.log(""),console.log(c(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(c(" \u2551")+a(" Build Complete ")+c("\u2551")),console.log(c(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${S("\u2713")} Stories: ${a(String(e))}`),console.log(` ${S("\u2713")} Output: ${a(t)}`),console.log(` ${S("\u2713")} Time: ${a(`${r}ms`)}`),console.log("")}function gr(){console.log(""),console.log(a(" Keyboard Shortcuts:")),console.log(""),console.log(` ${c("h")} Show this help`),console.log(` ${c("o")} Open in browser`),console.log(` ${c("r")} Restart server`),console.log(` ${c("c")} Clear console`),console.log(` ${c("q")} Quit`),console.log("")}import h from"fs";import d from"path";async function ct(e){let{root:t,config:r}=e,o=[],i=await P(t,r.storyMatch,r.storyIgnored);for(let s of i){let n=d.resolve(t,s),l=v(s,n);o.push(l)}return o}async function P(e,t,r){let o=[];async function i(s,n){let l=await h.promises.readdir(s,{withFileTypes:!0});for(let g of l){let f=d.join(s,g.name),u=d.relative(n,f);if(T(u,r))continue;if(g.isDirectory())await i(f,n);else if(g.isFile()){if(F(u,t))o.push(u)}}}return await i(e,e),o}function T(e,t){for(let r of t)if(E(e,r))return!0;return!1}function F(e,t){for(let r of t)if(E(e,r))return!0;return!1}function E(e,t){let r=e.replace(/\\/g,"/"),i=t.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return i=`^${i}$`,new RegExp(i).test(r)}function v(e,t){let r=d.basename(e,".story.stx");return{id:e.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:t,relativePath:e,fileName:r,treeFile:{title:r,path:e}}}function zs(e,t){let{root:r,config:o}=e,i=[],s=h.watch(r,{recursive:!0},async(n,l)=>{if(!l)return;let g=l.replace(/\\/g,"/");if(!F(g,o.storyMatch))return;if(T(g,o.storyIgnored))return;let f=d.resolve(r,g);try{await h.promises.access(f);let u=v(g,f);t(n==="rename"?"add":"change",u)}catch{let u=v(g,f);t("unlink",u)}});return i.push(s),()=>{for(let n of i)n.close()}}function N(e,t){let r=t.treeFile||{title:t.fileName,path:t.relativePath};if(e.tree.file==="title")return r.title.split("/");if(e.tree.file==="path")return[...t.relativePath.split("/").slice(0,-1),r.title];if(typeof e.tree.file==="function")return e.tree.file(r);return[r.title]}function lt(e,t){for(let n of t)n.treePath=N(e,n);let r=(e.tree.groups||[]).map((n)=>({groupConfig:{id:n.id||n.title,title:n.title,include:n.include},treeObject:{}})),o={treeObject:{}};r.push(o);for(let n=0;n<t.length;n++){let l=t[n],g=j(l,r,o);k(l.treePath,n,g.treeObject)}let i=e.tree.order==="asc"?(n,l)=>n.localeCompare(l):e.tree.order,s=[];for(let n of r)if(n===o)s.push(...x(n.treeObject,i));else if(n.groupConfig&&Object.keys(n.treeObject).length>0)s.push({group:!0,id:n.groupConfig.id,title:n.groupConfig.title,children:x(n.treeObject,i)});return s}function j(e,t,r){let o=e.treeFile||{title:e.fileName,path:e.relativePath};for(let i of t)if(i.groupConfig?.include&&i.groupConfig.include(o))return i;return r}function k(e,t,r){let o=r;for(let i=0;i<e.length;i++){let s=e[i];if(i===e.length-1)if(o[s]!==void 0){let l=1;while(o[`${s}-${l}`]!==void 0)l++;o[`${s}-${l}`]=t}else o[s]=t;else{if(o[s]===void 0)o[s]={};else if(typeof o[s]==="number"){let l=o[s];o[s]={"":l}}o=o[s]}}}function x(e,t){let r=[];for(let[o,i]of Object.entries(e))if(typeof i==="number")r.push({title:o,index:i});else r.push({title:o,children:x(i,t)});return r.sort((o,i)=>t(o.title,i.title)),r}
3
+ export{ot,fr,at,js,Ee,Bs,Fs,gr,ct,zs,lt};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{zr,Ci,$i,$u}from"./chunk-m9xdkzm6.js";export{zr as NATIVE_COMPONENTS,Ci as compileToNative,$i as createHotReloadServer,$u as default};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var{WebView:p}=globalThis.Bun;import{existsSync as y,mkdirSync as b,readdirSync as v,statSync as S}from"fs";import l from"path";var h=16384;function M(e){if(/^https?:\/\//.test(e)||e.startsWith("file://"))return e;return`file://${l.resolve(e)}`}function g(e,n,t,o){return new Promise((s)=>{let i=!1,r,m,c=()=>{if(!i){if(i=!0,clearTimeout(m),r)clearTimeout(r);e.onNavigated=void 0,s()}};m=setTimeout(c,o),e.onNavigated=()=>{if(!i)r=setTimeout(c,t)};try{let u=e.navigate(n);if(u&&typeof u.catch==="function")u.catch(c)}catch{c()}})}async function w(e,n,t){let o=`!!document.querySelector(${JSON.stringify(n)})`,s=Date.now()+t;while(Date.now()<s){try{if(await e.evaluate(o))return}catch{}await new Promise((i)=>setTimeout(i,100))}}async function T(e){try{let n=await e.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof n==="number"&&Number.isFinite(n)&&n>0?Math.min(n,h):0}catch{return 0}}async function Ko(e,n,t={}){let o=Math.min(t.width??1440,h),s=Math.min(t.height??2200,h),i=t.waitMs??800,r=t.timeoutMs??15000,m=t.format??"png",c=M(e),u=(f)=>new p({width:o,height:f,headless:!0,...t.backend?{backend:t.backend}:{}}),a=u(s);try{if(await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r);if(t.fullPage){let d=await T(a);if(d>s){if(a.close(),a=u(d),await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r)}}let f=await a.screenshot({encoding:"buffer",format:m});b(l.dirname(l.resolve(n)),{recursive:!0}),await Bun.write(n,f)}finally{a.close()}if(!y(n))throw Error(`Screenshot was not produced for ${e}`);return{input:e,output:n,bytes:S(n).size}}async function Kc(e,n,t={}){b(n,{recursive:!0});let o;if(!/^https?:\/\//.test(e)&&y(e)&&S(e).isDirectory())o=v(e).filter((r)=>r.endsWith(".html")).map((r)=>l.join(e,r));else o=[e];let s=t.format??"png",i=[];for(let r of o){let m=/^https?:\/\//.test(r)?new URL(r).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":l.basename(r).replace(/\.html?$/,"");i.push(await Ko(r,l.join(n,`${m}.${s}`),t))}return i}
3
- export{Ko,Kc};
2
+ var{WebView:p}=globalThis.Bun;import{existsSync as y,mkdirSync as b,readdirSync as v,statSync as S}from"fs";import l from"path";var h=16384;function M(e){if(/^https?:\/\//.test(e)||e.startsWith("file://"))return e;return`file://${l.resolve(e)}`}function g(e,n,t,o){return new Promise((s)=>{let i=!1,r,m,c=()=>{if(!i){if(i=!0,clearTimeout(m),r)clearTimeout(r);e.onNavigated=void 0,s()}};m=setTimeout(c,o),e.onNavigated=()=>{if(!i)r=setTimeout(c,t)};try{let u=e.navigate(n);if(u&&typeof u.catch==="function")u.catch(c)}catch{c()}})}async function w(e,n,t){let o=`!!document.querySelector(${JSON.stringify(n)})`,s=Date.now()+t;while(Date.now()<s){try{if(await e.evaluate(o))return}catch{}await new Promise((i)=>setTimeout(i,100))}}async function T(e){try{let n=await e.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof n==="number"&&Number.isFinite(n)&&n>0?Math.min(n,h):0}catch{return 0}}async function Go(e,n,t={}){let o=Math.min(t.width??1440,h),s=Math.min(t.height??2200,h),i=t.waitMs??800,r=t.timeoutMs??15000,m=t.format??"png",c=M(e),u=(f)=>new p({width:o,height:f,headless:!0,...t.backend?{backend:t.backend}:{}}),a=u(s);try{if(await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r);if(t.fullPage){let d=await T(a);if(d>s){if(a.close(),a=u(d),await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r)}}let f=await a.screenshot({encoding:"buffer",format:m});b(l.dirname(l.resolve(n)),{recursive:!0}),await Bun.write(n,f)}finally{a.close()}if(!y(n))throw Error(`Screenshot was not produced for ${e}`);return{input:e,output:n,bytes:S(n).size}}async function Gc(e,n,t={}){b(n,{recursive:!0});let o;if(!/^https?:\/\//.test(e)&&y(e)&&S(e).isDirectory())o=v(e).filter((r)=>r.endsWith(".html")).map((r)=>l.join(e,r));else o=[e];let s=t.format??"png",i=[];for(let r of o){let m=/^https?:\/\//.test(r)?new URL(r).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":l.basename(r).replace(/\.html?$/,"");i.push(await Go(r,l.join(n,`${m}.${s}`),t))}return i}
3
+ export{Go,Gc};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Al,Pl,Il,Dl,Ol}from"./chunk-89xcpdsp.js";export{Pl as createSSRSuspense,Dl as generateSuspenseCSS,Ol as generateSuspenseRuntime,Al as processSuspenseDirectives,Il as renderSSRSuspense};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- function c(i){if(!i.startsWith("/")||/[?#\\]/.test(i))throw Error(`Invalid route rule pattern: ${i}`);let t=i==="/"?[]:i.slice(1).split("/");if(t.some((r,e)=>!r||r.includes("*")&&r!=="*"&&r!=="**"||r==="**"&&e!==t.length-1||r.startsWith(":")&&!/^:[\w]+$/.test(r)))throw Error(`Unsupported route rule pattern: ${i}`);return t}function Cr(i){for(let[t,r]of Object.entries(i)){if(c(t),!r||typeof r!=="object"||Object.keys(r).some((e)=>e!=="rendering"&&e!=="cache"))throw Error(`Unsupported route rule for ${t}`);if(r.rendering!==void 0&&r.rendering!=="prerender"&&r.rendering!=="dynamic")throw Error(`Unsupported rendering mode for ${t}`);if(r.cache!==void 0&&r.cache!==!1){let e=r.cache;if(!e||e.public!==!0||Object.keys(e).some((n)=>!["public","maxAge","swr"].includes(n))||!Number.isFinite(e.maxAge)||e.maxAge<=0||e.swr!==void 0&&(!Number.isFinite(e.swr)||e.swr<0))throw Error(`Route cache for ${t} requires public: true, maxAge > 0 and swr >= 0`);if(r.rendering==="prerender")throw Error(`Prerendered route ${t} cannot revalidate; use dynamic rendering with cache`)}}}function Nt(i={}){Cr(i);let t=(e)=>e==="**"?0:e==="*"?1:e.startsWith(":")?2:3,r=Object.entries(i).map(([e,n])=>({pattern:e,parts:c(e),rule:n}));return r.sort((e,n)=>{for(let o=0;o<Math.max(e.parts.length,n.parts.length);o++){let s=(n.parts[o]===void 0?4:t(n.parts[o]))-(e.parts[o]===void 0?4:t(e.parts[o]));if(s)return s}return e.pattern.localeCompare(n.pattern)}),(e)=>{let n=e==="/"?[]:e.replace(/\/$/,"").slice(1).split("/");return r.find(({parts:o})=>o.every((s,u)=>s==="**"||n[u]!==void 0&&(s==="*"||s.startsWith(":")||s===n[u]))&&(o.at(-1)==="**"||o.length===n.length))?.rule??{}}}
3
- export{Cr,Nt};
2
+ function c(i){if(!i.startsWith("/")||/[?#\\]/.test(i))throw Error(`Invalid route rule pattern: ${i}`);let t=i==="/"?[]:i.slice(1).split("/");if(t.some((r,e)=>!r||r.includes("*")&&r!=="*"&&r!=="**"||r==="**"&&e!==t.length-1||r.startsWith(":")&&!/^:[\w]+$/.test(r)))throw Error(`Unsupported route rule pattern: ${i}`);return t}function $r(i){for(let[t,r]of Object.entries(i)){if(c(t),!r||typeof r!=="object"||Object.keys(r).some((e)=>e!=="rendering"&&e!=="cache"))throw Error(`Unsupported route rule for ${t}`);if(r.rendering!==void 0&&r.rendering!=="prerender"&&r.rendering!=="dynamic")throw Error(`Unsupported rendering mode for ${t}`);if(r.cache!==void 0&&r.cache!==!1){let e=r.cache;if(!e||e.public!==!0||Object.keys(e).some((n)=>!["public","maxAge","swr"].includes(n))||!Number.isFinite(e.maxAge)||e.maxAge<=0||e.swr!==void 0&&(!Number.isFinite(e.swr)||e.swr<0))throw Error(`Route cache for ${t} requires public: true, maxAge > 0 and swr >= 0`);if(r.rendering==="prerender")throw Error(`Prerendered route ${t} cannot revalidate; use dynamic rendering with cache`)}}}function Lt(i={}){$r(i);let t=(e)=>e==="**"?0:e==="*"?1:e.startsWith(":")?2:3,r=Object.entries(i).map(([e,n])=>({pattern:e,parts:c(e),rule:n}));return r.sort((e,n)=>{for(let o=0;o<Math.max(e.parts.length,n.parts.length);o++){let s=(n.parts[o]===void 0?4:t(n.parts[o]))-(e.parts[o]===void 0?4:t(e.parts[o]));if(s)return s}return e.pattern.localeCompare(n.pattern)}),(e)=>{let n=e==="/"?[]:e.replace(/\/$/,"").slice(1).split("/");return r.find(({parts:o})=>o.every((s,u)=>s==="**"||n[u]!==void 0&&(s==="*"||s.startsWith(":")||s===n[u]))&&(o.at(-1)==="**"||o.length===n.length))?.rule??{}}}
3
+ export{$r,Lt};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Qr,es,ts,Ou,zn,Mu}from"./chunk-dg1n3g1d.js";export{zn as clearImageDeliveryCatalog,Ou as deliveredImage,ts as efficientDeliverySources,Qr as getImageDelivery,es as isTransparentImage,Mu as prepareImageDelivery};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{i}from"./chunk-3efw27as.js";import{Cr}from"./chunk-9g27ybyr.js";import p from"path";async function cl(t={}){let d=performance.now(),o=t.root||process.cwd(),e=await i(o),u=t.ssr?.routeRules??e.routeRules??{};if(Cr(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:s}=await import("./ssg.js");n=await s({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:s}=await import("./chunk-gqv3ta5d.js");l=await s({root:o,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
3
- export{cl};
2
+ import{i}from"./chunk-dg1n3g1d.js";import{$r}from"./chunk-7tabykst.js";import p from"path";async function ll(t={}){let d=performance.now(),o=t.root||process.cwd(),e=await i(o),u=t.ssr?.routeRules??e.routeRules??{};if($r(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:s}=await import("./ssg.js");n=await s({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:s}=await import("./chunk-cw6kqb63.js");l=await s({root:o,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
3
+ export{ll};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var c=0;function l(){return`suspense-${++c}-${Date.now().toString(36)}`}function Rl(s,n={},t){let e=/@suspense(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@endsuspense/gi;return s.replace(e,(r,i,o,d)=>{let u=l(),a=p(i||"");return f(u,o.trim(),d.trim(),a)})}function p(s){let n={},t=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,e;while((e=t.exec(s))!==null){let r=e[1],i=e[2]||e[3],o=e[4];switch(r){case"id":n.id=i;break;case"timeout":n.timeout=o?parseInt(o,10):void 0;break}}return n}function f(s,n,t,e){let r=e.timeout||30000,i=e.id||s;return`
2
+ var c=0;function l(){return`suspense-${++c}-${Date.now().toString(36)}`}function Al(s,n={},t){let e=/@suspense(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@endsuspense/gi;return s.replace(e,(r,i,o,d)=>{let u=l(),a=p(i||"");return f(u,o.trim(),d.trim(),a)})}function p(s){let n={},t=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,e;while((e=t.exec(s))!==null){let r=e[1],i=e[2]||e[3],o=e[4];switch(r){case"id":n.id=i;break;case"timeout":n.timeout=o?parseInt(o,10):void 0;break}}return n}function f(s,n,t,e){let r=e.timeout||30000,i=e.id||s;return`
3
3
  <div class="stx-suspense" data-suspense-id="${s}" data-custom-id="${i}" data-status="pending">
4
4
  <div class="stx-suspense-fallback" data-suspense-fallback="${s}">
5
5
  ${t}
@@ -189,7 +189,7 @@ else {
189
189
  }, 0);
190
190
  })();
191
191
  </script>
192
- `}function Al(s,n,t){return{id:s,fallback:t,content:n}}async function Pl(s){let n=s.map((e)=>`
192
+ `}function Pl(s,n,t){return{id:s,fallback:t,content:n}}async function Il(s){let n=s.map((e)=>`
193
193
  <div id="stx-ssr-suspense-${e.id}" class="stx-ssr-suspense">
194
194
  ${e.fallback}
195
195
  </div>
@@ -214,7 +214,7 @@ else {
214
214
  }
215
215
  })();
216
216
  </script>
217
- `}}return{initial:n,streaming:t()}}function Il(){return`
217
+ `}}return{initial:n,streaming:t()}}function Dl(){return`
218
218
  /* STX Suspense Styles */
219
219
  .stx-suspense {
220
220
  position: relative;
@@ -270,7 +270,7 @@ else {
270
270
  background-size: 200% 100%;
271
271
  }
272
272
  }
273
- `}function Dl(){return`
273
+ `}function Ol(){return`
274
274
  // STX Suspense Runtime
275
275
  (function() {
276
276
  if (typeof window === 'undefined') return;
@@ -338,4 +338,4 @@ else {
338
338
  console.log('[stx] Suspense runtime initialized');
339
339
  })();
340
340
  `}
341
- export{Rl,Al,Pl,Il,Dl};
341
+ export{Al,Pl,Il,Dl,Ol};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{qo,ei,qc,Xo,Ko,Xc,Kc}from"./chunk-9rnh52t2.js";import"./chunk-zcctf7tx.js";import"./chunk-y6rahx7t.js";import"./chunk-wpe72ann.js";import{He,fc}from"./chunk-dg1n3g1d.js";import"./chunk-qff4qkx5.js";import"./chunk-ddk6fx5b.js";import"./chunk-41k0th97.js";import"./chunk-rv5bk83t.js";import"./chunk-26j2q9rq.js";import"./chunk-gxrewzhv.js";import"./chunk-zyxp0nb3.js";import"./chunk-rfdqrv5v.js";import"./chunk-c4bkj1xw.js";import"./chunk-de2pv6ys.js";import"./chunk-bfjzfrw3.js";import"./chunk-yzv8n6qw.js";import"./chunk-rhw7pqhy.js";export{qo as buildVirtualSource,He as extractScriptBlocks,fc as extractTemplateExpressions,Xo as findRuntimeTypeDeclarations,Ko as findStxModuleDeclarations,Kc as formatTypecheckDiagnostics,qc as sourcePathFor,Xc as typecheckStxFiles,ei as virtualPathFor};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{An,Gt,iu}from"./chunk-ae7j3n39.js";import{U,Pn,Jt,Lr,jr,In,ou,au,cu,Yt,Zt,Br,Dn,lu}from"./chunk-cn9hgyh5.js";import"./chunk-yzv8n6qw.js";export{Lr as batch,iu as default,Pn as derived,Jt as effect,An as generateSignalsRuntime,Gt as generateSignalsRuntimeDev,Zt as isDerived,Yt as isSignal,In as onDestroy,jr as onMount,Dn as peek,cu as pendingLifecycleCounts,au as runDestroyCallbacks,ou as runMountCallbacks,U as state,Br as untrack,lu as useOptimistic};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{le}from"./chunk-dg1n3g1d.js";import{de,S,Ke}from"./chunk-gxrewzhv.js";import{z}from"./chunk-26j2q9rq.js";import{Qe,Y,Ce}from"./chunk-rhw7pqhy.js";import{Pe,se,C,ie,ci,Cr,li,Nt}from"./chunk-gyv1t0f0.js";import{qr}from"./chunk-wpe72ann.js";import{Lt}from"./chunk-7tabykst.js";import J from"fs";import M from"path";var{serve:ae}=globalThis.Bun;import k from"zlib";import{promisify as q}from"util";var Q=q(k.brotliCompress),Z=q(k.gzip),K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((i)=>e.startsWith(i)))return!1;return K.some((i)=>e.startsWith(i))}function re(t){let e=new Map;for(let i of t.split(",")){let[s,...c]=i.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of c){let x=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(f);if(!x)continue;let g=Number.parseFloat(x[1]);if(Number.isFinite(g))m=g}e.set(l,m)}return e}function oe(t){if(!t)return null;let e=re(t),i=e.get("*"),s=(c)=>e.get(c)??i??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function Mt(t,e,i={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let s=oe(t.headers.get("accept-encoding"));if(!s)return e;let c;try{c=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(c,{status:e.status,statusText:e.statusText,headers:W(e.headers)});if(c.length<(i.threshold??te))return l();try{let m=s==="br"?await Q(c,{params:{[k.constants.BROTLI_PARAM_QUALITY]:i.quality??5,[k.constants.BROTLI_PARAM_SIZE_HINT]:c.length}}):await Z(c);if(m.length>=c.length)return l();let f=W(e.headers);return f.set("Content-Encoding",s),f.set("Content-Length",String(m.length)),new Response(m,{status:e.status,statusText:e.statusText,headers:f})}catch{return l()}}function W(t){let e=new Headers(t),i=e.get("Vary");if(!i)return e.set("Vary","Accept-Encoding"),e;if(!i.split(",").some((c)=>c.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${i}, Accept-Encoding`);return e}class D{now;entries=new z(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,i){let s,c=async()=>{let r=s??await i();return r.headers.set("Cache-Control","private, no-store"),r.headers.set("Vary",C(r.headers.get("Vary")).Vary),r};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return c();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${se(t)?"fragment":"document"}`,f=this.entries.get(m),x=(r)=>{let T=new Headers(r.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-r.created)/1000)))),new Response(r.body.slice(0),{headers:T})},g=f?(this.now()-f.created)/1000:1/0;if(f&&g<e.maxAge)return x(f);let b=this.generation,B=async()=>{let r=await i();s=r;let T=(r.headers.get("Vary")??"").toLowerCase().split(",").map((R)=>R.trim()).filter(Boolean);if(r.status!==200||r.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(r.headers.get("Cache-Control")??"")||T.some((R)=>R!=="x-stx-router"&&R!=="accept-encoding"))return null;let L=await r.clone().arrayBuffer();if(L.byteLength>1048576)return null;r.headers.set("Vary",C(r.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(r.headers.entries()),created:this.now(),path:l.pathname};if(this.generation===b)this.entries.set(m,n);return n},v=this.pending.get(m);if(!v){if(this.pending.size>=1000)return c();v=B().finally(()=>{if(this.pending.get(m)===v)this.pending.delete(m)}),this.pending.set(m,v)}if(f&&g<e.maxAge+(e.swr??0))return v.catch(()=>{}),x(f);let E=await v;return E?x(E):c()}}var ce={".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 ul(t={}){let e=M.resolve(t.outputDir||".output"),i=t.port??3000,s=ci(e);if(!s)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${s.routes.length} routes...`);let c=Lt(s.routeRules),l=new D,m=qr(e,s.apiRoutes??[]),f=Bun.file(M.join(e,"server/runtime-config.json")),x=t.runtimeConfig??(await f.exists()?await f.json():void 0),g=x?S(x):void 0,b=new Map,B=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),o=JSON.parse(await Bun.file(R).text());if(g)o.html=Ke(o.html,g);b.set(n.pattern,o),v.set(n.pattern,Ce(o.html)),E.set(n.pattern,le(o.html));let N=M.join(e,n.fragmentPath);if(await Bun.file(N).exists()){let A=await Bun.file(N).text();B.set(n.pattern,g?Ke(A,g):A)}}catch(R){console.warn(`[stx] Failed to load route ${n.pattern}:`,R)}let r=new Map,T=[];for(let n of s.routes)if(n.hasParams){let{regex:R,params:o}=Y(n.pattern,{page:!0});T.push({regex:R,route:n,paramNames:o})}else r.set(n.pattern,n);let L=ae({port:i,async fetch(n){return Mt(n,await de(g??S(),async()=>{let o=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[o])return t.apiRoutes[o](n);let N=await m(n);if(N)return N;if((n.method==="GET"||n.method==="HEAD")&&o!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(o)}catch{d=o}if(!d.includes("\x00")){let u=M.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${M.sep}`))try{if(J.existsSync(u)&&J.statSync(u).isFile()){let h=M.extname(u).toLowerCase(),j=ce[h]||"application/octet-stream",_=o.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(o);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=se(n),y=null,G={};if(y=r.get(o)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let a=o.match(p);if(a){y=d,u.forEach((h,j)=>{G[h]=a[j+1]});break}}if(!y){let p=Qe(o)?null:r.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=c(o),U=Object.keys(O).length>0;return l.respond(n,O.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let a=B.get(y.pattern);if(a){let h=v.get(y.pattern);return new Response(a,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(y.pattern)?{"X-STX-Runtime":E.get(y.pattern)?"true":"false"}:{},...h?{"X-STX-Layout":h.layout,"X-STX-Layout-Group":h.group}:{},...C(),...O.cache?{}:{"Cache-Control":Pe}}})}}let d=Cr(n.method),u=b.get(y.pattern);if(!u){let a=r.get("/500")||null;if(a){let h=b.get(a.pattern);if(h)return new Response(h.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(y.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"public, max-age=60"}});try{let{html:a,boundaries:h,redirect:j,cookies:_,status:F,headers:H}=await Nt(u,{params:G,request:n,method:n.method,__stx_strict_hydration:U,__stx_runtime_config:g});if(j)return li(j,_,H);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:I}=await import("./chunk-ecr598p7.js"),X=new Headers({...C(),...H,"Cache-Control":"private, no-store"});for(let V of _??[])X.append("Set-Cookie",V);if(A&&!d){let V=Ce(a);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",le(a)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return I(P(A&&!d?ie(a,s.routerContainer||"main"):a,h,{timeoutMs:30000}),{status:F??u.status??200,headers:X})}let w=new Headers({"Content-Type":"text/html",...C(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of _??[])w.append("Set-Cookie",P);for(let[P,I]of Object.entries(H??{}))w.set(P,I);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=Ce(a);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",le(a)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(ie(a,s.routerContainer||"main"),{status:F??u.status??200,headers:w})}return new Response(a,{status:F??u.status??200,headers:w})}catch(a){if(console.error(`[stx] Hydration error for ${o}:`,a),U)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
3
+ export{Mt,ul};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{$e}from"./chunk-czxt605c.js";import{Rn,Kt}from"./chunk-765e1s44.js";import{f}from"./chunk-b98be3yp.js";import{ji,Bi,wt,M,Hn,Vn,Un,r,te,A,i}from"./chunk-3efw27as.js";import{S}from"./chunk-ngc2wke4.js";import{xs}from"./chunk-9amp82bx.js";import{mo}from"./chunk-ak1cgcah.js";import{me,ie,ii,oi,Mt}from"./chunk-wfy1zq53.js";import{yt,Ur}from"./chunk-hepd9qgx.js";import{Nt}from"./chunk-9g27ybyr.js";import{dt,en,tn}from"./chunk-020xyn9q.js";import m from"fs";import c from"path";import{createHash as Y}from"crypto";function J(o){return Y("sha256").update(o).digest("hex").slice(0,8)}function U(o=!1){let l=o?Kt():Rn(),a=J(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function V(){let o=$e(),l=J(o);return{content:o,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function re(o={}){let l=new Set;return{context:new Proxy(o,{get(s,e){if(e in s)return s[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(s,e){if(e in s)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(o,l,a={}){let s=q.resolve(o),e=await Bun.file(s).text(),_=ee("sha256").update(e).digest("hex").slice(0,16);ji();let R={};try{R=await i(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let v=g[1];if(/\bserver\b/.test(v))y.push(g[2])}let u=new Set(y.flatMap((v)=>te(v))),{context:w}=re({__filename:s,__dirname:q.dirname(s),__stx_serverDeclared:u}),C=new Set,P={...A,...R,...a,buildMode:"compile",strict:!1},b=await r(e,w,s,P,C),T=me(b),B=Bi();return{route:l,sourceFile:o,html:b,fragment:T,placeholders:B,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(C),contentHash:_,status:wt(e),streamTemplates:w.__streamTemplates}}var se=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(o,l){let a=0,s=0;if(!m.existsSync(o))return{copied:a,bytes:s};m.mkdirSync(l,{recursive:!0});function e(_,R){let y=m.readdirSync(_,{withFileTypes:!0});for(let d of y){if(se.has(d.name))continue;let g=c.join(_,d.name),u=c.join(R,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),a++,s+=m.statSync(u).size}}}return e(o,l),{copied:a,bytes:s}}async function Jc(o={}){let l=Date.now(),a=c.resolve(o.root||process.cwd()),s=c.resolve(a,o.outputDir||".output");console.log("[stx build] Starting production build...");let e=await i(a),_=c.resolve(a,o.componentsDir??e.componentsDir??"components"),R=c.resolve(a,o.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,o.layoutsDir??e.layoutsDir??"layouts"),d=o.publicDir??e.publicDir??"public",g=e.app?.head||{},u=e.app?.colorMode,w=e.router?.container||"main",C=o.routeRules??e.routeRules??{},P=Nt(C),b=o.serverApi??e.serverApi,T=typeof b==="object"?b:{};if(b)yt(a,T);if(e.runtimeConfig)S(e.runtimeConfig,{});if(m.existsSync(s))m.rmSync(s,{recursive:!0});let B=[c.join(s,"public","__stx"),c.join(s,"public","assets"),c.join(s,"server","pages"),c.join(s,"server","fragments")];for(let n of B)m.mkdirSync(n,{recursive:!0});console.log("[stx build] Discovering routes...");let v=M(a,{pagesDirs:e._layerPageDirs}),Q=["components","layouts","partials"],O=v.filter((n)=>!Q.some((h)=>n.pattern.startsWith(`/${h}/`)||n.pattern===`/${h}`));console.log(`[stx build] Found ${O.length} page routes (${v.length-O.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let D=U(o.debug),x=V();await Bun.write(c.join(s,"public","__stx",D.filename),D.content),await Bun.write(c.join(s,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${D.filename} (${(D.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let k=[],F=[];for(let n of O){let h=P(n.pattern),E=h.rendering==="prerender";if(E&&(n.pattern.includes(":")||n.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${n.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(n.filePath,n.pattern,{configDir:a,componentsDir:_,partialsDir:R,layoutsDir:y,debug:o.debug});if(k.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,D.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Un(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Hn(t.html,u);if(g.htmlAttrs)t.html=Vn(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let z=p[1];t.html=t.html.replace(" "+z,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${z}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await f(t.html),E){let p=await Mt(t,{params:{},request:new Request(`http://stx.build${n.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${n.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=ie(t.html,w);let G=n.pattern==="/"?"index":n.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),I=c.join("server","pages",`${G}.compiled.json`),W=c.join("server","fragments",`${G}.html`);await Bun.write(c.join(s,I),JSON.stringify(t,null,2)),await Bun.write(c.join(s,W),t.fragment),F.push({pattern:n.pattern,compiledPath:I,fragmentPath:W,isDynamic:t.hasServerScripts,hasParams:n.pattern.includes(":")||n.pattern.includes("["),prerendered:E}),console.log(`[stx build] \u2713 ${n.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${n.pattern}:`,t instanceof Error?t.message:t)}}let H=c.resolve(a,d);if(m.existsSync(H)){let{copied:n,bytes:h}=Z(H,c.join(s,"public"));if(n>0)console.log(`[stx build] Copied ${n} public asset${n===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let N=tn(a);if(N){let{copied:n,bytes:h}=Z(N,c.join(s,"public",en));if(n>0)console.log(`[stx build] Copied ${n} asset${n===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${dt}/`)}let K={runtime:D.filename,router:x.filename},j=ii(F,K,s);if(j.routeRules=C,j.routerContainer=w,b)j.apiRoutes=await Ur(a,s,T);if(e.runtimeConfig)await Bun.write(c.join(s,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await xs(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(s,"server/layers.json"),JSON.stringify(mo(e._layerGraph),null,2));oi(j,s);let L=Date.now()-l;return console.log(`
2
+ import{$e}from"./chunk-rhw7pqhy.js";import{An,Gt}from"./chunk-ae7j3n39.js";import{f}from"./chunk-26j2q9rq.js";import{Bi,Fi,xt,M,Vn,Un,Wn,r,te,A,i}from"./chunk-dg1n3g1d.js";import{S}from"./chunk-gxrewzhv.js";import{Ss}from"./chunk-rv5bk83t.js";import{ho}from"./chunk-41k0th97.js";import{me,ie,oi,ai,Nt}from"./chunk-gyv1t0f0.js";import{bt,Wr}from"./chunk-wpe72ann.js";import{Lt}from"./chunk-7tabykst.js";import{pt,tn,nn}from"./chunk-rb272g9d.js";import m from"fs";import c from"path";import{createHash as Y}from"crypto";function J(o){return Y("sha256").update(o).digest("hex").slice(0,8)}function U(o=!1){let l=o?Gt():An(),a=J(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function V(){let o=$e(),l=J(o);return{content:o,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function re(o={}){let l=new Set;return{context:new Proxy(o,{get(s,e){if(e in s)return s[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(s,e){if(e in s)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(o,l,a={}){let s=q.resolve(o),e=await Bun.file(s).text(),_=ee("sha256").update(e).digest("hex").slice(0,16);Bi();let R={};try{R=await i(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let v=g[1];if(/\bserver\b/.test(v))y.push(g[2])}let u=new Set(y.flatMap((v)=>te(v))),{context:w}=re({__filename:s,__dirname:q.dirname(s),__stx_serverDeclared:u}),C=new Set,P={...A,...R,...a,buildMode:"compile",strict:!1},b=await r(e,w,s,P,C),T=me(b),B=Fi();return{route:l,sourceFile:o,html:b,fragment:T,placeholders:B,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(C),contentHash:_,status:xt(e),streamTemplates:w.__streamTemplates}}var se=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(o,l){let a=0,s=0;if(!m.existsSync(o))return{copied:a,bytes:s};m.mkdirSync(l,{recursive:!0});function e(_,R){let y=m.readdirSync(_,{withFileTypes:!0});for(let d of y){if(se.has(d.name))continue;let g=c.join(_,d.name),u=c.join(R,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),a++,s+=m.statSync(u).size}}}return e(o,l),{copied:a,bytes:s}}async function Yc(o={}){let l=Date.now(),a=c.resolve(o.root||process.cwd()),s=c.resolve(a,o.outputDir||".output");console.log("[stx build] Starting production build...");let e=await i(a),_=c.resolve(a,o.componentsDir??e.componentsDir??"components"),R=c.resolve(a,o.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,o.layoutsDir??e.layoutsDir??"layouts"),d=o.publicDir??e.publicDir??"public",g=e.app?.head||{},u=e.app?.colorMode,w=e.router?.container||"main",C=o.routeRules??e.routeRules??{},P=Lt(C),b=o.serverApi??e.serverApi,T=typeof b==="object"?b:{};if(b)bt(a,T);if(e.runtimeConfig)S(e.runtimeConfig,{});if(m.existsSync(s))m.rmSync(s,{recursive:!0});let B=[c.join(s,"public","__stx"),c.join(s,"public","assets"),c.join(s,"server","pages"),c.join(s,"server","fragments")];for(let n of B)m.mkdirSync(n,{recursive:!0});console.log("[stx build] Discovering routes...");let v=M(a,{pagesDirs:e._layerPageDirs}),Q=["components","layouts","partials"],O=v.filter((n)=>!Q.some((h)=>n.pattern.startsWith(`/${h}/`)||n.pattern===`/${h}`));console.log(`[stx build] Found ${O.length} page routes (${v.length-O.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let D=U(o.debug),x=V();await Bun.write(c.join(s,"public","__stx",D.filename),D.content),await Bun.write(c.join(s,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${D.filename} (${(D.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let k=[],F=[];for(let n of O){let h=P(n.pattern),E=h.rendering==="prerender";if(E&&(n.pattern.includes(":")||n.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${n.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(n.filePath,n.pattern,{configDir:a,componentsDir:_,partialsDir:R,layoutsDir:y,debug:o.debug});if(k.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,D.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Wn(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Vn(t.html,u);if(g.htmlAttrs)t.html=Un(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let z=p[1];t.html=t.html.replace(" "+z,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${z}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await f(t.html),E){let p=await Nt(t,{params:{},request:new Request(`http://stx.build${n.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${n.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=ie(t.html,w);let G=n.pattern==="/"?"index":n.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),I=c.join("server","pages",`${G}.compiled.json`),W=c.join("server","fragments",`${G}.html`);await Bun.write(c.join(s,I),JSON.stringify(t,null,2)),await Bun.write(c.join(s,W),t.fragment),F.push({pattern:n.pattern,compiledPath:I,fragmentPath:W,isDynamic:t.hasServerScripts,hasParams:n.pattern.includes(":")||n.pattern.includes("["),prerendered:E}),console.log(`[stx build] \u2713 ${n.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${n.pattern}:`,t instanceof Error?t.message:t)}}let H=c.resolve(a,d);if(m.existsSync(H)){let{copied:n,bytes:h}=Z(H,c.join(s,"public"));if(n>0)console.log(`[stx build] Copied ${n} public asset${n===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let N=nn(a);if(N){let{copied:n,bytes:h}=Z(N,c.join(s,"public",tn));if(n>0)console.log(`[stx build] Copied ${n} asset${n===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${pt}/`)}let K={runtime:D.filename,router:x.filename},j=oi(F,K,s);if(j.routeRules=C,j.routerContainer=w,b)j.apiRoutes=await Wr(a,s,T);if(e.runtimeConfig)await Bun.write(c.join(s,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Ss(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(s,"server/layers.json"),JSON.stringify(ho(e._layerGraph),null,2));ai(j,s);let L=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${L}ms \u2014 ${k.length} pages compiled`),{pageCount:k.length,assets:K,outputDir:s,duration:L}}
4
- export{Jc};
4
+ export{Yc};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{n,K}from"./chunk-3efw27as.js";import{ho}from"./chunk-b98be3yp.js";import{he}from"./chunk-et0rr8c7.js";import{o}from"./chunk-fzapbw9p.js";import c from"fs";import l from"path";var Pa=new Map,m=new Map;async function lu(e){let r;for(let s=0;s<3;s++)try{let g=(await c.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),S=(await c.promises.stat(e)).mtime.getTime();if(S!==g)continue;return m.set(e,{content:h,mtime:S}),h}catch(i){r=i;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function uu(e){m.delete(e)}function du(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var d=null,v=null,y=null;function pu(e){y=e}async function Ia(e=!1){let t=y??await import("./chunk-5gsxpaqk.js");if(e)return t.generateSignalsRuntimeDev();if(d===null)d=t.generateSignalsRuntime();return d}var f=null;async function Da(){if(f===null){let{getRouterScript:e}=await import("./chunk-jk4njz0w.js");f=e()}return f}var w={};async function fu(e,t=!1){let r=e==="runtime"?await Ia(t):await Da(),s=e==="runtime"&&t?"runtime-debug":e,i=w[s];if(!i||i.content!==r)i={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},w[s]=i;return{content:r,hash:i.hash,url:`/_stx/${e}.${i.hash}.js`}}var T=500,u=new Map;function x(e){return o(process.cwd(),"module-bundles",`${e}.js`)}function gu(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.has(t);if(r)u.delete(t);u.set(t,e);while(u.size>T)u.delete(u.keys().next().value);if(!r)try{let s=x(t);if(!c.existsSync(s))c.mkdirSync(l.dirname(s),{recursive:!0}),c.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function mu(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return c.readFileSync(x(e),"utf8")}catch{return}}function hu(){m.clear(),K(),ho(),d=null,v=null,f=null}function C(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((r)=>({name:r.name,timing:r.timing,handler:String(r.handler)})),customDirectives:(e.customDirectives??[]).map((r)=>({name:r.name,hasEndTag:r.hasEndTag===!0,rawParams:r.rawParams===!0,handler:String(r.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Zt(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),s=l.join(r,`${Dn(e)}.html`),i=l.join(r,`${Dn(e)}.meta.json`);if(!await n(s)||!await n(i))return null;let g=await Bun.file(i).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==he())return null;if(a.optionsSignature!==C(t))return null;if((await c.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let p of a.dependencies)if(await n(p)){if((await c.promises.stat(p)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(s).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Qt(e,t,r,s){try{if(!s.cachePath)return;let i=l.resolve(s.cachePath);await c.promises.mkdir(i,{recursive:!0});let g=l.join(i,`${Dn(e)}.html`),a=l.join(i,`${Dn(e)}.meta.json`),h=await c.promises.stat(e);await Bun.write(g,t);let p={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:s.cacheVersion,engine:he(),optionsSignature:C(s),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(p,null,2)),Pa.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(i){console.warn(`Failed to cache template ${e}:`,i)}}var E=16;function Dn(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,E)}
3
- export{Pa,lu,uu,du,pu,Ia,Da,fu,gu,mu,hu,Zt,Qt,Dn};
2
+ import{n,K}from"./chunk-dg1n3g1d.js";import{yo}from"./chunk-26j2q9rq.js";import{he}from"./chunk-et0rr8c7.js";import{o}from"./chunk-ty7t3gp4.js";import c from"fs";import l from"path";var Ia=new Map,m=new Map;async function uu(e){let r;for(let s=0;s<3;s++)try{let g=(await c.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),S=(await c.promises.stat(e)).mtime.getTime();if(S!==g)continue;return m.set(e,{content:h,mtime:S}),h}catch(i){r=i;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function du(e){m.delete(e)}function pu(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var d=null,v=null,y=null;function fu(e){y=e}async function Da(e=!1){let t=y??await import("./chunk-8ycy1b0e.js");if(e)return t.generateSignalsRuntimeDev();if(d===null)d=t.generateSignalsRuntime();return d}var f=null;async function Oa(){if(f===null){let{getRouterScript:e}=await import("./chunk-x7j0krz8.js");f=e()}return f}var w={};async function gu(e,t=!1){let r=e==="runtime"?await Da(t):await Oa(),s=e==="runtime"&&t?"runtime-debug":e,i=w[s];if(!i||i.content!==r)i={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},w[s]=i;return{content:r,hash:i.hash,url:`/_stx/${e}.${i.hash}.js`}}var T=500,u=new Map;function x(e){return o(process.cwd(),"module-bundles",`${e}.js`)}function mu(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.has(t);if(r)u.delete(t);u.set(t,e);while(u.size>T)u.delete(u.keys().next().value);if(!r)try{let s=x(t);if(!c.existsSync(s))c.mkdirSync(l.dirname(s),{recursive:!0}),c.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function hu(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return c.readFileSync(x(e),"utf8")}catch{return}}function yu(){m.clear(),K(),yo(),d=null,v=null,f=null}function C(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((r)=>({name:r.name,timing:r.timing,handler:String(r.handler)})),customDirectives:(e.customDirectives??[]).map((r)=>({name:r.name,hasEndTag:r.hasEndTag===!0,rawParams:r.rawParams===!0,handler:String(r.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Qt(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),s=l.join(r,`${On(e)}.html`),i=l.join(r,`${On(e)}.meta.json`);if(!await n(s)||!await n(i))return null;let g=await Bun.file(i).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==he())return null;if(a.optionsSignature!==C(t))return null;if((await c.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let p of a.dependencies)if(await n(p)){if((await c.promises.stat(p)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(s).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function en(e,t,r,s){try{if(!s.cachePath)return;let i=l.resolve(s.cachePath);await c.promises.mkdir(i,{recursive:!0});let g=l.join(i,`${On(e)}.html`),a=l.join(i,`${On(e)}.meta.json`),h=await c.promises.stat(e);await Bun.write(g,t);let p={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:s.cacheVersion,engine:he(),optionsSignature:C(s),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(p,null,2)),Ia.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(i){console.warn(`Failed to cache template ${e}:`,i)}}var E=16;function On(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,E)}
3
+ export{Ia,uu,du,pu,fu,Da,Oa,gu,mu,hu,yu,Qt,en,On};
@@ -1,20 +1,20 @@
1
1
  // @bun
2
- import{m}from"./chunk-ce1sejr3.js";import{W,xt,He,hs,ys,Yi,Zi,Qi,eo,Wn,bs,to,no,ro,i}from"./chunk-3efw27as.js";import{Mr}from"./chunk-g186znp9.js";import{o}from"./chunk-fzapbw9p.js";import{existsSync as M,readFileSync as K}from"fs";import b from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=xt.filter((e)=>!me.has(e)).sort(),ne=[...m].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let r=[];for(let u of t){if(u.offset===void 0)continue;let s=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let h of l[1].matchAll(/[^,]+/g)){let S=h[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let c=x[1];if(!xe.has(c)||s.has(c))continue;let f=u.offset+g+h.index+x[0].length-c.length,p=e.slice(0,f),w=p.split(`
2
+ import{m}from"./chunk-yzv8n6qw.js";import{W,St,He,ys,bs,Zi,Qi,eo,to,qn,vs,no,ro,so,i}from"./chunk-dg1n3g1d.js";import{Nr}from"./chunk-zcctf7tx.js";import{o}from"./chunk-ty7t3gp4.js";import{existsSync as M,readFileSync as K}from"fs";import b from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=St.filter((e)=>!me.has(e)).sort(),ne=[...m].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let r=[];for(let u of t){if(u.offset===void 0)continue;let s=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let h of l[1].matchAll(/[^,]+/g)){let S=h[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let c=x[1];if(!xe.has(c)||s.has(c))continue;let f=u.offset+g+h.index+x[0].length-c.length,p=e.slice(0,f),w=p.split(`
3
3
  `).length;r.push({line:w,column:f-(p.lastIndexOf(`
4
- `)+1)+1,offset:f,length:c.length,name:c,kind:u.kind,message:Se(c,u.kind)})}}}return r}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let r=T.resolve(e);for(;;){let u=T.join(r,"tsconfig.json");if(t(u))return u;let s=T.dirname(r);if(s===r)return;r=s}}function se(e,t,r){let u=we(e,r);if(!u)return;let s=new Set,l=(g)=>{if(s.has(g))return;s.add(g);let h=t(g);if(!h)return;let S=h.compilerOptions?.plugins;if(Array.isArray(S)){let c=S.find((p)=>p?.name===ke),f=Array.isArray(c?.libs)?c.libs.filter((p)=>typeof p==="string"):[];return c?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof h.extends==="string"?[h.extends]:Array.isArray(h.extends)?h.extends:[];for(let c of[...x].reverse()){if(typeof c!=="string"||!c.startsWith("."))continue;let f=T.resolve(T.dirname(g),c.endsWith(".json")?c:`${c}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Wo(e,t="",r=""){let u=e.startLine>1?`
5
- `.repeat(e.startLine-1):"",s=bs(e)+ys(hs(e.code)),l=e.kind==="client"||e.kind==="plain"?Qi(t,e.code):"";return Wn(`${u+s}
4
+ `)+1)+1,offset:f,length:c.length,name:c,kind:u.kind,message:Se(c,u.kind)})}}}return r}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let r=T.resolve(e);for(;;){let u=T.join(r,"tsconfig.json");if(t(u))return u;let s=T.dirname(r);if(s===r)return;r=s}}function se(e,t,r){let u=we(e,r);if(!u)return;let s=new Set,l=(g)=>{if(s.has(g))return;s.add(g);let h=t(g);if(!h)return;let S=h.compilerOptions?.plugins;if(Array.isArray(S)){let c=S.find((p)=>p?.name===ke),f=Array.isArray(c?.libs)?c.libs.filter((p)=>typeof p==="string"):[];return c?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof h.extends==="string"?[h.extends]:Array.isArray(h.extends)?h.extends:[];for(let c of[...x].reverse()){if(typeof c!=="string"||!c.startsWith("."))continue;let f=T.resolve(T.dirname(g),c.endsWith(".json")?c:`${c}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function qo(e,t="",r=""){let u=e.startLine>1?`
5
+ `.repeat(e.startLine-1):"",s=vs(e)+bs(ys(e.code)),l=e.kind==="client"||e.kind==="plain"?eo(t,e.code):"";return qn(`${u+s}
6
6
  ${l}
7
7
  export {}
8
8
  `,r)}var $e=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function ve(e){if(e.length===0)return"";let t=["// Generated \u2014 the composables the runtime publishes as bare globals."],r=new Set(m),u=[];for(let{file:s,names:l}of e){let g=JSON.stringify(s.replace(/\\/g,"/").replace(/\.ts$/,""));u.push(` export * from ${g}`);for(let h of l){if(r.has(h)||$e.has(h))continue;r.add(h),t.push(`declare const ${h}: typeof import(${g})[${JSON.stringify(h)}]`)}}return t.push("declare module '@composables' {",...u,"}"),t.join(`
9
- `)}function Qs(e,t,r){return`${e}.__stx_${t}${r}.ts`}function Wc(e){return e.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function qo(){return re("stx.d.ts")}function Xo(){return re("stx-module.d.ts")}function re(e){for(let t of[b.resolve(import.meta.dir,"..",e),b.resolve(import.meta.dir,"..","..",e)])if(M(t))return t;return null}var Te=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function De(e){return e>=1000&&e<2000}function oe(e){let t="",r=!1,u=!1;for(let s=0;s<e.length;s++){let l=e[s];if(r){if(t+=l,u)u=!1;else if(l==="\\")u=!0;else if(l==='"')r=!1;continue}if(l==='"'){r=!0,t+=l;continue}if(l==="/"&&e[s+1]==="/"){while(s<e.length&&e[s]!==`
9
+ `)}function ei(e,t,r){return`${e}.__stx_${t}${r}.ts`}function qc(e){return e.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function Xo(){return re("stx.d.ts")}function Ko(){return re("stx-module.d.ts")}function re(e){for(let t of[b.resolve(import.meta.dir,"..",e),b.resolve(import.meta.dir,"..","..",e)])if(M(t))return t;return null}var Te=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function De(e){return e>=1000&&e<2000}function oe(e){let t="",r=!1,u=!1;for(let s=0;s<e.length;s++){let l=e[s];if(r){if(t+=l,u)u=!1;else if(l==="\\")u=!0;else if(l==='"')r=!1;continue}if(l==='"'){r=!0,t+=l;continue}if(l==="/"&&e[s+1]==="/"){while(s<e.length&&e[s]!==`
10
10
  `)s++;t+=`
11
- `;continue}if(l==="/"&&e[s+1]==="*"){s+=2;while(s<e.length&&!(e[s]==="*"&&e[s+1]==="/"))s++;s++;continue}t+=l}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(oe(K(e,"utf8")))}catch{return}}function Oe(e){let t=b.resolve(e),r;for(;;){let c=b.join(t,"tsconfig.json");if(M(c)){r=c;break}let f=b.dirname(t);if(f===t)break;t=f}if(!r)return{};let u=new Set,s=r,l,g,h=r;while(s&&!u.has(s)){u.add(s);let c;try{c=JSON.parse(oe(K(s,"utf8")))}catch{break}let f=c?.compilerOptions??{};if(!l&&f.paths&&typeof f.paths==="object")l=f.paths,h=s;if(!g&&typeof f.baseUrl==="string")g=b.resolve(b.dirname(s),f.baseUrl);if(l&&g)break;s=typeof c?.extends==="string"?b.resolve(b.dirname(s),c.extends.endsWith(".json")?c.extends:`${c.extends}.json`):void 0}if(!l)return{};let S=g??b.dirname(h),x={};for(let[c,f]of Object.entries(l)){if(!Array.isArray(f))continue;x[c]=f.map((p)=>typeof p==="string"&&!b.isAbsolute(p)?b.resolve(S,p):p)}return{paths:x}}async function qc(e,t={}){let r=t.client!==!1,u=t.server!==!1,s=t.templates!==!1,l=t.componentsDir??(s?(await i()).componentsDir:void 0),g=new Map,h=new Map,S=[],x=[],c=0,f=0,p=qo();for(let n of e){let a=await Bun.file(n).text(),y=He(a).filter((d)=>{if(d.kind==="server")return u;return r}),k=He(a).filter((d)=>d.kind==="server").map((d)=>d.code).join(`
12
- `);for(let d of ie(a,y))S.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(r&&k){let d=y.filter((O)=>O.kind!=="server"),E=[...new Set(d.flatMap((O)=>eo(k,O.code)))];if(E.length>0)h.set(n,{names:E,line:d[0].startLine,kind:d[0].kind})}let D=b.dirname(b.resolve(n)),v=s?to(a,{runtimeGlobals:!p,originDir:D,filePath:b.resolve(n),componentsDir:l}):null,R=v?[...v.lineMap.values()].filter((d)=>d.expression).length:0;if(y.length===0&&R===0)continue;if(x.push(n),c+=y.length,f+=R,y.forEach((d,E)=>{g.set(Qs(n,d.kind,E),{source:Wo(d,k,D),origin:n,kind:d.kind})}),v&&R>0)g.set(Qs(n,"template",0),{source:v.text,origin:n,kind:"template",virtual:v})}if(g.size===0)return{diagnostics:S,checkedFiles:x,blockCount:0,expressionCount:0};let w=(t.extraLibs??[]).map((n)=>b.resolve(n)),ce=se(e.length>0?b.dirname(b.resolve(e[0])):process.cwd(),Ee,M);for(let n of ce?.libs??[])if(!w.includes(n)&&M(n))w.push(n);if(p)w.push(p);let G=p?Xo():null;if(G)w.push(G);let X=`${o()}/typecheck/__stx_globals.d.ts`,ae=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",Yi(p?Zi(K(p,"utf8")):void 0),...p?[]:["declare const window: any",...m.map((n)=>`declare const ${n}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...W.map((n)=>`declare const ${n}: any`)].join(`
13
- `),ve(await Mr())].filter(Boolean).join(`
11
+ `;continue}if(l==="/"&&e[s+1]==="*"){s+=2;while(s<e.length&&!(e[s]==="*"&&e[s+1]==="/"))s++;s++;continue}t+=l}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(oe(K(e,"utf8")))}catch{return}}function Oe(e){let t=b.resolve(e),r;for(;;){let c=b.join(t,"tsconfig.json");if(M(c)){r=c;break}let f=b.dirname(t);if(f===t)break;t=f}if(!r)return{};let u=new Set,s=r,l,g,h=r;while(s&&!u.has(s)){u.add(s);let c;try{c=JSON.parse(oe(K(s,"utf8")))}catch{break}let f=c?.compilerOptions??{};if(!l&&f.paths&&typeof f.paths==="object")l=f.paths,h=s;if(!g&&typeof f.baseUrl==="string")g=b.resolve(b.dirname(s),f.baseUrl);if(l&&g)break;s=typeof c?.extends==="string"?b.resolve(b.dirname(s),c.extends.endsWith(".json")?c.extends:`${c.extends}.json`):void 0}if(!l)return{};let S=g??b.dirname(h),x={};for(let[c,f]of Object.entries(l)){if(!Array.isArray(f))continue;x[c]=f.map((p)=>typeof p==="string"&&!b.isAbsolute(p)?b.resolve(S,p):p)}return{paths:x}}async function Xc(e,t={}){let r=t.client!==!1,u=t.server!==!1,s=t.templates!==!1,l=t.componentsDir??(s?(await i()).componentsDir:void 0),g=new Map,h=new Map,S=[],x=[],c=0,f=0,p=Xo();for(let n of e){let a=await Bun.file(n).text(),y=He(a).filter((d)=>{if(d.kind==="server")return u;return r}),k=He(a).filter((d)=>d.kind==="server").map((d)=>d.code).join(`
12
+ `);for(let d of ie(a,y))S.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(r&&k){let d=y.filter((O)=>O.kind!=="server"),E=[...new Set(d.flatMap((O)=>to(k,O.code)))];if(E.length>0)h.set(n,{names:E,line:d[0].startLine,kind:d[0].kind})}let D=b.dirname(b.resolve(n)),v=s?no(a,{runtimeGlobals:!p,originDir:D,filePath:b.resolve(n),componentsDir:l}):null,R=v?[...v.lineMap.values()].filter((d)=>d.expression).length:0;if(y.length===0&&R===0)continue;if(x.push(n),c+=y.length,f+=R,y.forEach((d,E)=>{g.set(ei(n,d.kind,E),{source:qo(d,k,D),origin:n,kind:d.kind})}),v&&R>0)g.set(ei(n,"template",0),{source:v.text,origin:n,kind:"template",virtual:v})}if(g.size===0)return{diagnostics:S,checkedFiles:x,blockCount:0,expressionCount:0};let w=(t.extraLibs??[]).map((n)=>b.resolve(n)),ce=se(e.length>0?b.dirname(b.resolve(e[0])):process.cwd(),Ee,M);for(let n of ce?.libs??[])if(!w.includes(n)&&M(n))w.push(n);if(p)w.push(p);let G=p?Ko():null;if(G)w.push(G);let X=`${o()}/typecheck/__stx_globals.d.ts`,ae=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",Zi(p?Qi(K(p,"utf8")):void 0),...p?[]:["declare const window: any",...m.map((n)=>`declare const ${n}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...W.map((n)=>`declare const ${n}: any`)].join(`
13
+ `),ve(await Nr())].filter(Boolean).join(`
14
14
  `),_=`${o()}/typecheck`;await Bun.$`rm -rf ${_}`.quiet().nothrow(),await Bun.$`mkdir -p ${_}`.quiet().nothrow(),await Bun.write(X,ae);let N=new Map,le=0;for(let[n,a]of g){let y=`${le++}_${n.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${_}/${y}`,a.source),N.set(y,a)}let ue={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...Oe(e.length>0?b.dirname(b.resolve(e[0])):process.cwd()),...t.compilerOptions??{}},F=async(n,a)=>{let y=`${_}/tsconfig${a===1?"":`.${a}`}.json`;await Bun.write(y,JSON.stringify({compilerOptions:ue,files:n.map((D)=>`${_}/${D}`).concat(X,...w)},null,2));let k=Bun.spawnSync(["bun","x","tsc","-p",y,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(k.stdout)+new TextDecoder().decode(k.stderr),exitCode:k.exitCode??0}},V=await F([...N.keys()],1),J=V.output,I=[],U=V.exitCode,z=0,pe=new Set(w.map((n)=>n.split("/").pop())),q=0,B=new Set,H=(n)=>{for(let a of n.replace(/\n[\t ]+([^\n]*)/g," $1").split(`
15
- `)){let y=a.match(Te);if(!y)continue;if(z++,pe.has(y[1].split("/").pop()))q++;let[,k,D,v,R,d,E]=y,O=k.split("/").pop(),C=N.get(O);if(!C)continue;if(De(Number(d)))B.add(O);let A=Number(D),L=Number(v),Y;if(C.virtual){let P=ro(C.virtual,A,L);if(!P?.expression)continue;if(no(P,Number(d)))continue;A=P.line,L=P.column,Y=P.expression.code.trim()}I.push({file:C.origin,line:A,column:L,code:Number(d),message:E,category:R==="error"?"error":"warning",blockKind:C.kind,expression:Y})}};H(J);let de=z,fe=q;if(B.size>0&&B.size<N.size){let n=[...N.keys()].filter((a)=>!B.has(a));H((await F(n,2)).output)}if(r)for(let[n,a]of h){if(a.names.length===0)continue;I.push({file:n,line:a.line,column:1,code:0,message:`${a.names.length===1?"1 value reaches":`${a.names.length} values reach`} this block on the implicit bridge and ${a.names.length===1?"is":"are"} untyped: ${a.names.join(", ")}. Declare them with defineClientPayload({ ${a.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:a.kind})}I.push(...S);let Z=new Set,j=I.filter((n)=>{let a=`${n.file}:${n.line}:${n.column}:${n.code}:${n.message}`;if(Z.has(a))return!1;return Z.add(a),!0});j.sort((n,a)=>n.file.localeCompare(a.file)||n.line-a.line||n.column-a.column);let Q=fe>0&&j.length===0,ge=Q||U!==0&&de===0?`${Q?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${U} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
15
+ `)){let y=a.match(Te);if(!y)continue;if(z++,pe.has(y[1].split("/").pop()))q++;let[,k,D,v,R,d,E]=y,O=k.split("/").pop(),C=N.get(O);if(!C)continue;if(De(Number(d)))B.add(O);let A=Number(D),L=Number(v),Y;if(C.virtual){let P=so(C.virtual,A,L);if(!P?.expression)continue;if(ro(P,Number(d)))continue;A=P.line,L=P.column,Y=P.expression.code.trim()}I.push({file:C.origin,line:A,column:L,code:Number(d),message:E,category:R==="error"?"error":"warning",blockKind:C.kind,expression:Y})}};H(J);let de=z,fe=q;if(B.size>0&&B.size<N.size){let n=[...N.keys()].filter((a)=>!B.has(a));H((await F(n,2)).output)}if(r)for(let[n,a]of h){if(a.names.length===0)continue;I.push({file:n,line:a.line,column:1,code:0,message:`${a.names.length===1?"1 value reaches":`${a.names.length} values reach`} this block on the implicit bridge and ${a.names.length===1?"is":"are"} untyped: ${a.names.join(", ")}. Declare them with defineClientPayload({ ${a.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:a.kind})}I.push(...S);let Z=new Set,j=I.filter((n)=>{let a=`${n.file}:${n.line}:${n.column}:${n.code}:${n.message}`;if(Z.has(a))return!1;return Z.add(a),!0});j.sort((n,a)=>n.file.localeCompare(a.file)||n.line-a.line||n.column-a.column);let Q=fe>0&&j.length===0,ge=Q||U!==0&&de===0?`${Q?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${U} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
16
16
  ${J.trim().split(`
17
17
  `).slice(0,12).join(`
18
- `)||"(no output)"}`:void 0;return{diagnostics:j,checkedFiles:x,blockCount:c,expressionCount:f,failure:ge}}function Xc(e){return e.map((t)=>{let r=t.blockKind==="template"?`[template: ${t.expression??""}]`:`[${t.blockKind==="plain"?"<script>":`<script ${t.blockKind}>`}]`;return`${t.file}:${t.line}:${t.column} ${t.category} TS${t.code} ${t.message} ${r}`}).join(`
18
+ `)||"(no output)"}`:void 0;return{diagnostics:j,checkedFiles:x,blockCount:c,expressionCount:f,failure:ge}}function Kc(e){return e.map((t)=>{let r=t.blockKind==="template"?`[template: ${t.expression??""}]`:`[${t.blockKind==="plain"?"<script>":`<script ${t.blockKind}>`}]`;return`${t.file}:${t.line}:${t.column} ${t.category} TS${t.code} ${t.message} ${r}`}).join(`
19
19
  `)}
20
- export{Wo,Qs,Wc,qo,Xo,qc,Xc};
20
+ export{qo,ei,qc,Xo,Ko,Xc,Kc};
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- function a(t,e){let n=t[e],i=e+1;while(i<t.length){if(t[i]==="\\"){i+=2;continue}if(t[i]===n)return i+1;i++}return t.length}function w(t,e){let n=e+1;while(n<t.length){if(t[n]==="\\"){n+=2;continue}if(t[n]==="`")return n+1;if(t[n]==="$"&&t[n+1]==="{"){if(n=po(t,n+2),n<t.length)n++;continue}n++}return t.length}function po(t,e){let n=1,i=e;while(i<t.length){let l=t[i];if(l==="\\"){i+=2;continue}if(l==='"'||l==="'"){i=a(t,i);continue}if(l==="`"){i=w(t,i);continue}if(l==="/"&&t[i+1]==="/"){while(i<t.length&&t[i]!==`
2
+ function a(t,e){let n=t[e],i=e+1;while(i<t.length){if(t[i]==="\\"){i+=2;continue}if(t[i]===n)return i+1;i++}return t.length}function w(t,e){let n=e+1;while(n<t.length){if(t[n]==="\\"){n+=2;continue}if(t[n]==="`")return n+1;if(t[n]==="$"&&t[n+1]==="{"){if(n=fo(t,n+2),n<t.length)n++;continue}n++}return t.length}function fo(t,e){let n=1,i=e;while(i<t.length){let l=t[i];if(l==="\\"){i+=2;continue}if(l==='"'||l==="'"){i=a(t,i);continue}if(l==="`"){i=w(t,i);continue}if(l==="/"&&t[i+1]==="/"){while(i<t.length&&t[i]!==`
3
3
  `)i++;continue}if(l==="/"&&t[i+1]==="*"){i+=2;while(i<t.length&&t.slice(i,i+2)!=="*/")i++;i+=2;continue}if(l==="{"){n++,i++;continue}if(l==="}"){if(n--,n===0)return i;i++;continue}i++}return t.length}var o=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function b(t,e){if(e)return o.has(e);return!(t===")"||t==="]"||t===h)}var h="\x00";function m(t,e){let n=e+1,i=!1;while(n<t.length){let l=t[n];if(l===`
4
4
  `)return-1;if(l==="\\"){n+=2;continue}if(l==="[")i=!0;else if(l==="]")i=!1;else if(l==="/"&&!i){n++;while(n<t.length&&/[a-z]/i.test(t[n]))n++;return n}n++}return-1}function s(t){let e="",n=0,i="",l="";while(n<t.length){let u=t.slice(n,n+2);if(u==="//"){while(n<t.length&&t[n]!==`
5
5
  `)e+=" ",n++;continue}if(u==="/*"){while(n<t.length&&t.slice(n,n+2)!=="*/")e+=t[n]===`
6
6
  `?`
7
7
  `:" ",n++;e+=" ",n+=2;continue}let r=t[n];if(r==='"'||r==="'"){let f=r;e+=" ",n++;while(n<t.length&&t[n]!==f){if(t[n]==="\\"){e+=" ",n+=2;continue}e+=t[n]===`
8
8
  `?`
9
- `:" ",n++}e+=" ",n++,i=h,l="";continue}if(r==="/"&&b(i,l)){let f=m(t,n);if(f!==-1){e+=`/${" ".repeat(f-n-2)}/`,n=f,i=h,l="";continue}}if(r==="`"){e+=" ",n++;while(n<t.length&&t[n]!=="`"){if(t[n]==="\\"){e+=" ",n+=2;continue}if(t[n]==="$"&&t[n+1]==="{"){let f=n+2,g=po(t,f);if(e+=" ",e+=s(t.slice(f,g)),g<t.length)e+=" ";n=g+1;continue}e+=t[n]===`
9
+ `:" ",n++}e+=" ",n++,i=h,l="";continue}if(r==="/"&&b(i,l)){let f=m(t,n);if(f!==-1){e+=`/${" ".repeat(f-n-2)}/`,n=f,i=h,l="";continue}}if(r==="`"){e+=" ",n++;while(n<t.length&&t[n]!=="`"){if(t[n]==="\\"){e+=" ",n+=2;continue}if(t[n]==="$"&&t[n+1]==="{"){let f=n+2,g=fo(t,f);if(e+=" ",e+=s(t.slice(f,g)),g<t.length)e+=" ";n=g+1;continue}e+=t[n]===`
10
10
  `?`
11
11
  `:" ",n++}e+=" ",n++,i=h,l="";continue}if(e+=r,n++,/[\w$]/.test(r))l=/[\w$]/.test(i)?l+r:r,i=r;else if(!/\s/.test(r))i=r,l=""}return e}function we(t){let e=new Uint16Array(t.length),n=0,i=!0;for(let l=0;l<t.length;l++){let u=t[l];if(u===")"||u==="]"||u==="}")if(n===0)i=!1;else n--;if(e[l]=n,u==="("||u==="["||u==="{")n++}return{depths:e,balanced:i&&n===0}}
12
- export{po,s,we};
12
+ export{fo,s,we};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Te,_e,Re}from"./chunk-a688m6js.js";import"./chunk-ce1sejr3.js";import"./chunk-8nhshfz6.js";import{d}from"./chunk-3efw27as.js";import"./chunk-z0g9jvv0.js";import"./chunk-b98be3yp.js";import"./chunk-shr559s7.js";import"./chunk-czxt605c.js";import"./chunk-m4sk62wb.js";import"./chunk-xfp7k0v8.js";import"./chunk-ak1cgcah.js";import"./chunk-ngc2wke4.js";import"./chunk-9amp82bx.js";import"./chunk-7gkv67ky.js";import{it,pr,ot,Ls,Ee,js,fr,at,Fs,ct}from"./chunk-h6zsqb9r.js";import"./chunk-752hw7cd.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(p)=>{if(p==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{js("Config file changed, restarting...");try{await e.onChange()}catch(l){Ee(`Failed to restart: ${l}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var st=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,st),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),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(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let p=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),l=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=l.length>0?l.reduce((i,m)=>i+m,0)/l.length:0,y=Object.entries(c).sort((i,m)=>m[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:p.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.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 pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
2
+ import{Te,_e,Re}from"./chunk-a688m6js.js";import"./chunk-yzv8n6qw.js";import"./chunk-de2pv6ys.js";import{d}from"./chunk-dg1n3g1d.js";import"./chunk-c4bkj1xw.js";import"./chunk-26j2q9rq.js";import"./chunk-ddk6fx5b.js";import"./chunk-rhw7pqhy.js";import"./chunk-rfdqrv5v.js";import"./chunk-zyxp0nb3.js";import"./chunk-41k0th97.js";import"./chunk-gxrewzhv.js";import"./chunk-rv5bk83t.js";import"./chunk-bfjzfrw3.js";import{ot,fr,at,js,Ee,Bs,gr,ct,zs,lt}from"./chunk-6agy2x1f.js";import"./chunk-qff4qkx5.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(p)=>{if(p==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Bs("Config file changed, restarting...");try{await e.onChange()}catch(l){Ee(`Failed to restart: ${l}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var st=".stx/story/analytics.json",it=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,st),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:it,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:dt(),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(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let p=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),l=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=l.length>0?l.reduce((i,m)=>i+m,0)/l.length:0,y=Object.entries(c).sort((i,m)=>m[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:p.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.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 dt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var pt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,pt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
3
3
  <script>
4
4
  (function() {
5
5
  const ws = new WebSocket('${t}');
@@ -556,9 +556,9 @@ window.__stxPerformance = {
556
556
 
557
557
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
558
558
  </script>
559
- `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:p}=await import("./chunk-pdb5fw3r.js"),l={},g=h(n);if(g)try{await d(g,l,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(l,r.props);let i=await p(n,l,e,{},new Set),m=Z(n),u=h(n);return i=Q(i),i=tt(i,l),{html:i,css:m,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await d(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-pdb5fw3r.js"),c={...r},n=h(e);if(n)try{await d(n,c,"inline-template.stx")}catch{}let l=await a(e,c,"inline-template.stx",{},new Set);return l=Q(l),l=tt(l,c),{html:l,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
559
+ `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:p}=await import("./chunk-49cpqjx2.js"),l={},g=h(n);if(g)try{await d(g,l,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(l,r.props);let i=await p(n,l,e,{},new Set),m=Z(n),u=h(n);return i=Q(i),i=tt(i,l),{html:i,css:m,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await d(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-49cpqjx2.js"),c={...r},n=h(e);if(n)try{await d(n,c,"inline-template.stx")}catch{}let l=await a(e,c,"inline-template.stx",{},new Set);return l=Q(l),l=tt(l,c),{html:l,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
560
560
  `)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
561
- `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await at(t);_e(t,r);let s=ct(t.config,r);Re(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),p=N(),l=Bun.serve({port:e.port,hostname:o,fetch:async(i,m)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(m.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){p.open(i)},close(i){p.close(i)},message(i,m){p.message(i,m)}}}),g=`http://${o}:${e.port}`,y=Fs(t,async(i,m)=>{console.log(` [${i}] ${m.relativePath}`);let u=await at(t);_e(t,u);let f=ct(t.config,u);if(Re(t,f),i==="add")H(m.id,{fileName:m.fileName});else if(i==="unlink")O(m.id);else V(m.id,{fileName:m.fileName})});if(e.open){let i=g;try{let{exec:m}=await import("child_process"),u=process.platform;m(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:l,url:g,close:async()=>{y(),l.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),p=t.storyFiles.find((l)=>l.id===n);if(!p)return new Response("Story not found",{status:404});try{let l=await Bun.file(p.path).text();return Response.json({id:p.id,fileName:p.fileName,relativePath:p.relativePath,content:l})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),p=e.slice(12).split("/"),l=p[0],g=p[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let m=t.storyFiles.find((u)=>u.id===l);if(!m)return new Response("Story not found",{status:404});try{let u=await Y(t,m,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),p=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),p=o.getPreset(n);if(!p)return new Response("Preset not found",{status:404});return Response.json(p)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),p=o.usePreset(n);if(!p)return new Response("Preset not found",{status:404});return await o.save(),Response.json(p)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),p=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),p=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),p=a.getBookmark(n);if(!p)return new Response("Bookmark not found",{status:404});return Response.json(p)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),p=t.storyFiles.find((g)=>g.id===n),l=c.getComponentAnalytics(n,p?.fileName||n);return Response.json(l)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
561
+ `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await ct(t);_e(t,r);let s=lt(t.config,r);Re(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),p=N(),l=Bun.serve({port:e.port,hostname:o,fetch:async(i,m)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(m.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){p.open(i)},close(i){p.close(i)},message(i,m){p.message(i,m)}}}),g=`http://${o}:${e.port}`,y=zs(t,async(i,m)=>{console.log(` [${i}] ${m.relativePath}`);let u=await ct(t);_e(t,u);let f=lt(t.config,u);if(Re(t,f),i==="add")H(m.id,{fileName:m.fileName});else if(i==="unlink")O(m.id);else V(m.id,{fileName:m.fileName})});if(e.open){let i=g;try{let{exec:m}=await import("child_process"),u=process.platform;m(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:l,url:g,close:async()=>{y(),l.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),p=t.storyFiles.find((l)=>l.id===n);if(!p)return new Response("Story not found",{status:404});try{let l=await Bun.file(p.path).text();return Response.json({id:p.id,fileName:p.fileName,relativePath:p.relativePath,content:l})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),p=e.slice(12).split("/"),l=p[0],g=p[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let m=t.storyFiles.find((u)=>u.id===l);if(!m)return new Response("Story not found",{status:404});try{let u=await Y(t,m,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),p=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),p=o.getPreset(n);if(!p)return new Response("Preset not found",{status:404});return Response.json(p)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),p=o.usePreset(n);if(!p)return new Response("Preset not found",{status:404});return await o.save(),Response.json(p)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),p=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),p=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),p=a.getBookmark(n);if(!p)return new Response("Bookmark not found",{status:404});return Response.json(p)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),p=t.storyFiles.find((g)=>g.id===n),l=c.getComponentAnalytics(n,p?.fileName||n);return Response.json(l)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
562
562
  <html lang="en" class="${r.darkClass||"dark"}">
563
563
  <head>
564
564
  <meta charset="UTF-8">
@@ -1276,5 +1276,5 @@ else {
1276
1276
  <style>${W()}</style>
1277
1277
  ${D()}
1278
1278
  </body>
1279
- </html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function nt(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function he(t={}){it();let e=await Te({mode:"dev"});if(!e.config.enabled){Ee("Story feature is disabled in config.");return}await nt(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),ot(e.storyFiles.length),pr(s.url),fr()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await Te({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
1280
- `),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":fr();break;case"o":try{let{exec:l}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";l(`${g} ${s.url}`)}catch{Ls("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),it(),ot(e.storyFiles.length),pr(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};
1279
+ </html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function nt(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function he(t={}){ot();let e=await Te({mode:"dev"});if(!e.config.enabled){Ee("Story feature is disabled in config.");return}await nt(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),at(e.storyFiles.length),fr(s.url),gr()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await Te({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
1280
+ `),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":gr();break;case"o":try{let{exec:l}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";l(`${g} ${s.url}`)}catch{js("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),ot(),at(e.storyFiles.length),fr(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};