@stacksjs/stx 0.2.917 → 0.2.921

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 (294) hide show
  1. package/dist/app-shell.js +3 -2
  2. package/dist/chunk-0678sab4.js +2 -0
  3. package/dist/chunk-0bnv0aaz.js +2 -0
  4. package/dist/chunk-0bvfm5h5.js +2 -0
  5. package/dist/chunk-0c3q5h03.js +2 -0
  6. package/dist/chunk-0fh84wr5.js +2 -0
  7. package/dist/chunk-0p9x0m5n.js +2 -0
  8. package/dist/{chunk-ngqb22wj.js → chunk-0rq1w0xr.js} +9 -9
  9. package/dist/{chunk-t65f98qv.js → chunk-1pc2p489.js} +2 -2
  10. package/dist/{chunk-1hx6dyy9.js → chunk-1ts1pg90.js} +2 -2
  11. package/dist/{chunk-h0aw9hmc.js → chunk-29cy41z3.js} +5 -5
  12. package/dist/{chunk-952dfmcb.js → chunk-2d0pemtc.js} +3 -3
  13. package/dist/{chunk-0vyytd9v.js → chunk-2qnpr0ty.js} +3 -3
  14. package/dist/chunk-2r2tayyd.js +3 -0
  15. package/dist/chunk-2sfxj244.js +2 -0
  16. package/dist/{chunk-nwef47nx.js → chunk-30d298vs.js} +1 -1
  17. package/dist/chunk-36j2drjv.js +42 -0
  18. package/dist/{chunk-pyyda92j.js → chunk-3d0bjcn7.js} +1 -1
  19. package/dist/chunk-3k9d0h11.js +2 -0
  20. package/dist/chunk-3mc9ew9r.js +25 -0
  21. package/dist/chunk-43r0h76m.js +2 -0
  22. package/dist/{chunk-95j8660f.js → chunk-4f8h38xr.js} +2 -2
  23. package/dist/{chunk-16sfjkc4.js → chunk-4jg8ddfy.js} +2 -2
  24. package/dist/chunk-4jh5t3rz.js +2 -0
  25. package/dist/{chunk-v78hjbz0.js → chunk-4nabpd82.js} +5 -5
  26. package/dist/{chunk-z110bf2c.js → chunk-4w203ddt.js} +9 -9
  27. package/dist/chunk-4y2k14ec.js +2 -0
  28. package/dist/chunk-57xcb1wn.js +2 -0
  29. package/dist/chunk-5ekbye3p.js +2 -0
  30. package/dist/chunk-5s1q4y2j.js +2 -0
  31. package/dist/chunk-6359fekc.js +2 -0
  32. package/dist/{chunk-sdmq09jw.js → chunk-66cz2ph7.js} +2 -2
  33. package/dist/chunk-6bm7t0hm.js +3 -0
  34. package/dist/{chunk-xc5esqcb.js → chunk-6ybq9pfh.js} +2 -2
  35. package/dist/{chunk-nhyv3w4r.js → chunk-7767n5k6.js} +1 -1
  36. package/dist/{chunk-0sj79ha5.js → chunk-78j6c3sf.js} +5 -5
  37. package/dist/{chunk-ftvpz1j4.js → chunk-7d0h2pa3.js} +5 -5
  38. package/dist/{chunk-1hbf5e1h.js → chunk-7g720sk3.js} +2 -2
  39. package/dist/chunk-7nshr15z.js +2 -0
  40. package/dist/{chunk-w98yt4d4.js → chunk-875wejw1.js} +2 -2
  41. package/dist/chunk-8g6cmgn8.js +2 -0
  42. package/dist/chunk-8gfdy17b.js +2 -0
  43. package/dist/{chunk-mgj074y2.js → chunk-8vjsmyrk.js} +5 -5
  44. package/dist/chunk-8yx65vb0.js +2 -0
  45. package/dist/{chunk-frpsrv1e.js → chunk-90ps064x.js} +2 -2
  46. package/dist/chunk-91nwc581.js +2 -0
  47. package/dist/{chunk-mt5ewkbg.js → chunk-94001bha.js} +6 -6
  48. package/dist/chunk-94skx5m6.js +2 -0
  49. package/dist/chunk-9aegppj7.js +2 -0
  50. package/dist/{chunk-11c7xg1z.js → chunk-9ch2qhbw.js} +1 -1
  51. package/dist/{chunk-da05660m.js → chunk-9sk596tw.js} +58 -58
  52. package/dist/{chunk-fn1reean.js → chunk-a3qb13vr.js} +20 -20
  53. package/dist/chunk-a5vzdhsk.js +2 -0
  54. package/dist/{chunk-0jdz31q1.js → chunk-a78k8fkg.js} +3 -3
  55. package/dist/{chunk-jr2r2nh5.js → chunk-ag07tdhn.js} +4 -4
  56. package/dist/chunk-amnfd29h.js +7 -0
  57. package/dist/chunk-aqh48tyw.js +2 -0
  58. package/dist/{chunk-fs43342z.js → chunk-avtq2p0c.js} +2 -2
  59. package/dist/{chunk-phzhmnnm.js → chunk-ayrd026n.js} +3 -3
  60. package/dist/{chunk-eptzpvn0.js → chunk-b0kq5mzq.js} +3 -3
  61. package/dist/chunk-b6am4h24.js +2 -0
  62. package/dist/{chunk-dwt2drzf.js → chunk-b9z4nb1v.js} +8 -8
  63. package/dist/{chunk-qsexsrw2.js → chunk-bwnx71s8.js} +5 -5
  64. package/dist/{chunk-2vx2ben8.js → chunk-c3nmjx26.js} +2 -2
  65. package/dist/chunk-cajg2sz0.js +2 -0
  66. package/dist/{chunk-2f5jjxcj.js → chunk-dhx4m7mf.js} +2 -2
  67. package/dist/chunk-dktqmf4t.js +2 -0
  68. package/dist/chunk-dqwxyk1m.js +2 -0
  69. package/dist/chunk-e2kk1d9z.js +2 -0
  70. package/dist/{chunk-ra2tzsvz.js → chunk-e8aqkt1b.js} +6 -6
  71. package/dist/{chunk-1jxkc6d0.js → chunk-e8hvbc53.js} +2 -2
  72. package/dist/{chunk-p3fepzt9.js → chunk-edjzm0vj.js} +3 -3
  73. package/dist/chunk-ee4ejnk2.js +2 -0
  74. package/dist/chunk-eezp4a40.js +2 -0
  75. package/dist/chunk-eh2ynja3.js +2 -0
  76. package/dist/chunk-emk29htn.js +2 -0
  77. package/dist/{chunk-va4xam1q.js → chunk-eqj8nj5c.js} +1 -1
  78. package/dist/{chunk-xnp031ba.js → chunk-f8sh6289.js} +7 -7
  79. package/dist/{chunk-wj9bqkc0.js → chunk-fb1hyhgf.js} +3 -3
  80. package/dist/chunk-fd0vnz09.js +2 -0
  81. package/dist/chunk-fyhtp2nt.js +2 -0
  82. package/dist/{chunk-ywrpmyzj.js → chunk-g2fxp9zp.js} +3 -3
  83. package/dist/chunk-gbct53j0.js +2 -0
  84. package/dist/{chunk-1jvt9t3r.js → chunk-gsm3rk4j.js} +2 -2
  85. package/dist/{chunk-gfp39bzr.js → chunk-gt9bt8xa.js} +2 -2
  86. package/dist/{chunk-ar6jeqmm.js → chunk-gxdy4qjj.js} +4 -4
  87. package/dist/chunk-gxtq25gr.js +2 -0
  88. package/dist/chunk-h1dnjn9g.js +2 -0
  89. package/dist/chunk-h4nqjks2.js +2 -0
  90. package/dist/{chunk-f0sxbgbm.js → chunk-h7z23fpq.js} +2 -2
  91. package/dist/{chunk-cq4cwfqf.js → chunk-hakevnm1.js} +2 -2
  92. package/dist/chunk-hn7fv830.js +2 -0
  93. package/dist/chunk-hx6tr46s.js +1459 -0
  94. package/dist/chunk-jenk04c8.js +2 -0
  95. package/dist/{chunk-ezqfrea9.js → chunk-jfy0r3hx.js} +28 -28
  96. package/dist/{chunk-3jc6yb02.js → chunk-jh007a8k.js} +9 -9
  97. package/dist/chunk-jh1hdq31.js +3 -0
  98. package/dist/{chunk-fzcqw147.js → chunk-jk1hzawb.js} +3 -3
  99. package/dist/{chunk-wm24jx3t.js → chunk-jya12bfn.js} +2 -2
  100. package/dist/chunk-k1qbgpfy.js +2 -0
  101. package/dist/chunk-kgmwja6f.js +2 -0
  102. package/dist/{chunk-91p8p2cc.js → chunk-khf62zkn.js} +6 -6
  103. package/dist/chunk-kppj8rqa.js +2 -0
  104. package/dist/{chunk-vayzmvf5.js → chunk-m3ra99h8.js} +6 -6
  105. package/dist/{chunk-fznjm7qt.js → chunk-m8rzaqm8.js} +2 -2
  106. package/dist/chunk-msvphygp.js +2 -0
  107. package/dist/chunk-mzbejejf.js +2 -0
  108. package/dist/{chunk-8b8az19t.js → chunk-nkgqhb7s.js} +8 -8
  109. package/dist/{chunk-npj20tj9.js → chunk-p17jeqz0.js} +2 -2
  110. package/dist/{chunk-bvqgq18r.js → chunk-p97h91zx.js} +2 -2
  111. package/dist/{chunk-cxsc37fg.js → chunk-pe5sstex.js} +2 -2
  112. package/dist/chunk-pjv4dskp.js +2 -0
  113. package/dist/chunk-pqr4gn9b.js +4 -0
  114. package/dist/{chunk-zv3rn0ch.js → chunk-prj38cyp.js} +6 -6
  115. package/dist/{chunk-5jc9hmwg.js → chunk-pwg544dw.js} +2 -2
  116. package/dist/chunk-pxvp0cc9.js +3 -0
  117. package/dist/{chunk-hhspwfva.js → chunk-q8snpht6.js} +3 -3
  118. package/dist/chunk-q99y5115.js +3 -0
  119. package/dist/chunk-qnytvyy0.js +2 -0
  120. package/dist/{chunk-23x3k751.js → chunk-qzspvwv6.js} +2 -2
  121. package/dist/chunk-r02asm46.js +2 -0
  122. package/dist/chunk-r7zvrh58.js +70 -0
  123. package/dist/chunk-ra35ptjg.js +3 -0
  124. package/dist/chunk-rc4712qh.js +2 -0
  125. package/dist/chunk-rq7sg012.js +33 -0
  126. package/dist/{chunk-302nw40c.js → chunk-rt4gzqs9.js} +1 -1
  127. package/dist/chunk-rx1xw7q2.js +2 -0
  128. package/dist/{chunk-36cz2v8k.js → chunk-rzmephr2.js} +31 -31
  129. package/dist/{chunk-cwcmmgvz.js → chunk-s1x2pc9b.js} +2 -2
  130. package/dist/{chunk-r7y1196g.js → chunk-s3rhbwgf.js} +4 -4
  131. package/dist/{chunk-0asdv3hk.js → chunk-s6w14v6h.js} +2 -2
  132. package/dist/chunk-sdvv8zge.js +3 -0
  133. package/dist/chunk-sgppgy5e.js +20 -0
  134. package/dist/chunk-sk7pptzf.js +38 -0
  135. package/dist/{chunk-w6ydg43d.js → chunk-sk8x8nw8.js} +3 -3
  136. package/dist/chunk-skjm3zdh.js +2 -0
  137. package/dist/{chunk-388xpdw5.js → chunk-t4exh7c9.js} +76 -36
  138. package/dist/{chunk-yq2krsc9.js → chunk-t64mp8x1.js} +6 -6
  139. package/dist/{chunk-8wqhzzkn.js → chunk-tfpd7aht.js} +3 -3
  140. package/dist/chunk-tsnzhke9.js +2 -0
  141. package/dist/{chunk-c13dv3wm.js → chunk-tt6n2mx6.js} +14 -14
  142. package/dist/chunk-txyze88n.js +2 -0
  143. package/dist/chunk-v1t7sees.js +2 -0
  144. package/dist/chunk-vhp5hqwp.js +54 -0
  145. package/dist/{chunk-88fx8xc1.js → chunk-vn3hsx7v.js} +2 -2
  146. package/dist/chunk-vt410s5m.js +2 -0
  147. package/dist/{chunk-mf5cqv1k.js → chunk-w27j0apm.js} +29 -29
  148. package/dist/{chunk-gg715pj6.js → chunk-w5vxzk5j.js} +6 -6
  149. package/dist/chunk-w81a1e14.js +9 -0
  150. package/dist/{chunk-m8n14s3z.js → chunk-wajvxzt0.js} +2 -2
  151. package/dist/chunk-wrva7jes.js +2 -0
  152. package/dist/chunk-ws25jw6x.js +6 -0
  153. package/dist/{chunk-789yp1tg.js → chunk-ww24mxmd.js} +3 -3
  154. package/dist/chunk-xdprx6tx.js +1331 -0
  155. package/dist/chunk-xgv3gy1b.js +2 -0
  156. package/dist/chunk-xjhv5e5f.js +2 -0
  157. package/dist/{chunk-zkwkhesc.js → chunk-xmy75h5v.js} +2 -2
  158. package/dist/chunk-xnvh4jk2.js +21 -0
  159. package/dist/chunk-xtakhmnb.js +2 -0
  160. package/dist/{chunk-2qk2ppgm.js → chunk-y97g0kwc.js} +1 -1
  161. package/dist/chunk-y9f9d4zv.js +2 -0
  162. package/dist/{chunk-p3x84jj0.js → chunk-yfe380a4.js} +2 -2
  163. package/dist/chunk-ygtz9kc7.js +3 -0
  164. package/dist/chunk-yyypc7s3.js +2 -0
  165. package/dist/chunk-z5j4prza.js +2 -0
  166. package/dist/{chunk-ma5ptt4m.js → chunk-z68teecy.js} +2 -2
  167. package/dist/cli.js +38 -38
  168. package/dist/color-mode-boot.d.ts +1 -8
  169. package/dist/color-mode-boot.js +46 -2
  170. package/dist/composables/use-media-query.js +23 -22
  171. package/dist/craft-entry.js +2 -2
  172. package/dist/craft.js +2 -2
  173. package/dist/document-shell.d.ts +2 -0
  174. package/dist/document-shell.js +15 -3
  175. package/dist/document-tags.d.ts +2 -0
  176. package/dist/document-tags.js +9 -0
  177. package/dist/head-injection.d.ts +2 -0
  178. package/dist/head-injection.js +1 -0
  179. package/dist/head.d.ts +2 -0
  180. package/dist/head.js +2 -2
  181. package/dist/native/accessibility.d.ts +1 -1
  182. package/dist/native/accessibility.js +5 -3
  183. package/dist/native/bridge/protocol.d.ts +1 -0
  184. package/dist/native/compiler/html-to-ir.js +15 -1
  185. package/dist/native/compiler/ir.d.ts +8 -0
  186. package/dist/native/components/primitives.d.ts +2 -0
  187. package/dist/native/event-names.js +6 -0
  188. package/dist/native/prop-names.js +3 -1
  189. package/dist/native/runtime/browser-renderer.d.ts +1 -0
  190. package/dist/native/runtime/browser-renderer.js +27 -6
  191. package/dist/native/runtime/craft-bridge.js +1 -0
  192. package/dist/native/runtime/craft.d.ts +3 -0
  193. package/dist/native/runtime/jsc-globals.js +1 -1
  194. package/dist/native/runtime/native-media.js +8 -3
  195. package/dist/native/runtime/shared-screen.js +8 -3
  196. package/dist/native/testing.d.ts +3 -1
  197. package/dist/native/testing.js +35 -1
  198. package/dist/page-head.js +1 -9
  199. package/dist/process.js +6 -3
  200. package/dist/pwa.js +3 -3
  201. package/dist/signal-processing.d.ts +2 -2
  202. package/dist/signal-processing.js +17 -11
  203. package/dist/ssg.js +13 -13
  204. package/dist/types/config-types.d.ts +1 -1
  205. package/dist/utils.js +2 -1
  206. package/dist/variable-extractor.js +6 -1
  207. package/dist/vue-template.d.ts +2 -0
  208. package/dist/vue-template.js +72 -2
  209. package/package.json +6 -6
  210. package/dist/chunk-0adc8x2h.js +0 -9
  211. package/dist/chunk-0atz8fjx.js +0 -20
  212. package/dist/chunk-0fm6avxt.js +0 -3
  213. package/dist/chunk-0v7555tr.js +0 -42
  214. package/dist/chunk-11rnqey0.js +0 -2
  215. package/dist/chunk-1mx3j280.js +0 -2
  216. package/dist/chunk-20hy5p3p.js +0 -2
  217. package/dist/chunk-29v3b5ks.js +0 -2
  218. package/dist/chunk-2cay3heb.js +0 -2
  219. package/dist/chunk-31yx4sjh.js +0 -2
  220. package/dist/chunk-33fnbw33.js +0 -2
  221. package/dist/chunk-357qjcj1.js +0 -3
  222. package/dist/chunk-38kerh2r.js +0 -2
  223. package/dist/chunk-38y11q8x.js +0 -2
  224. package/dist/chunk-3h4db9yb.js +0 -33
  225. package/dist/chunk-3q80f7mt.js +0 -2
  226. package/dist/chunk-43kz6rx9.js +0 -2
  227. package/dist/chunk-43sgpy4e.js +0 -54
  228. package/dist/chunk-4e18r89n.js +0 -3
  229. package/dist/chunk-4pve3r5a.js +0 -2
  230. package/dist/chunk-4vz17ytv.js +0 -68
  231. package/dist/chunk-5afnyvw5.js +0 -2
  232. package/dist/chunk-5d5dxts6.js +0 -2
  233. package/dist/chunk-5fdsyyfe.js +0 -2
  234. package/dist/chunk-67yr4m5h.js +0 -2
  235. package/dist/chunk-6aqr0e6s.js +0 -2
  236. package/dist/chunk-6bw02d1t.js +0 -2
  237. package/dist/chunk-76mn123c.js +0 -2
  238. package/dist/chunk-7ar11ccn.js +0 -2
  239. package/dist/chunk-7fc0vrs5.js +0 -2
  240. package/dist/chunk-82fg5gp6.js +0 -2
  241. package/dist/chunk-89r7bbsk.js +0 -2
  242. package/dist/chunk-8egbh6z1.js +0 -2
  243. package/dist/chunk-8n9jd8cz.js +0 -2
  244. package/dist/chunk-8tfpv6zf.js +0 -6
  245. package/dist/chunk-8x3yaahc.js +0 -2
  246. package/dist/chunk-94qc4zwb.js +0 -2
  247. package/dist/chunk-9928zdej.js +0 -3
  248. package/dist/chunk-9ay18k46.js +0 -2
  249. package/dist/chunk-9kn81bmp.js +0 -2
  250. package/dist/chunk-9tv0tw7f.js +0 -3
  251. package/dist/chunk-9w9y84t5.js +0 -21
  252. package/dist/chunk-a5h9bwrc.js +0 -2
  253. package/dist/chunk-b5qzed8y.js +0 -1323
  254. package/dist/chunk-bej9kz05.js +0 -2
  255. package/dist/chunk-bh2khcet.js +0 -2
  256. package/dist/chunk-bm6y085n.js +0 -25
  257. package/dist/chunk-c6096ssb.js +0 -2
  258. package/dist/chunk-ccgabq3a.js +0 -2
  259. package/dist/chunk-e0tvd7jj.js +0 -2
  260. package/dist/chunk-e5rag6rh.js +0 -3
  261. package/dist/chunk-fvr3h2fr.js +0 -7
  262. package/dist/chunk-gmmqz698.js +0 -2
  263. package/dist/chunk-hxftzw0x.js +0 -2
  264. package/dist/chunk-js1wayhb.js +0 -2
  265. package/dist/chunk-jz37h2z0.js +0 -4
  266. package/dist/chunk-k2t0w8z1.js +0 -2
  267. package/dist/chunk-k8s3hyh2.js +0 -2
  268. package/dist/chunk-kcpxqsdj.js +0 -2
  269. package/dist/chunk-mjr5fkc2.js +0 -2
  270. package/dist/chunk-n4m50dpk.js +0 -1467
  271. package/dist/chunk-na0e3s88.js +0 -2
  272. package/dist/chunk-new89wh2.js +0 -2
  273. package/dist/chunk-nrap20qt.js +0 -2
  274. package/dist/chunk-p9bghe13.js +0 -2
  275. package/dist/chunk-q2cwzgd0.js +0 -2
  276. package/dist/chunk-q60afqr7.js +0 -2
  277. package/dist/chunk-q9yahsww.js +0 -2
  278. package/dist/chunk-qdwtemy1.js +0 -2
  279. package/dist/chunk-qp0ndbk6.js +0 -2
  280. package/dist/chunk-rzsvxjse.js +0 -2
  281. package/dist/chunk-s2c0ynn9.js +0 -2
  282. package/dist/chunk-senrtnx2.js +0 -2
  283. package/dist/chunk-v1wr2vdx.js +0 -2
  284. package/dist/chunk-v6gkjg5f.js +0 -3
  285. package/dist/chunk-wc10m4tp.js +0 -38
  286. package/dist/chunk-wcxa8xy2.js +0 -2
  287. package/dist/chunk-wgrj0cvs.js +0 -2
  288. package/dist/chunk-wpkwx3wq.js +0 -2
  289. package/dist/chunk-wq17dce6.js +0 -2
  290. package/dist/chunk-wvc6eayq.js +0 -2
  291. package/dist/chunk-xa98a901.js +0 -2
  292. package/dist/chunk-xjt5129x.js +0 -2
  293. package/dist/chunk-yc3frw0z.js +0 -3
  294. package/dist/chunk-yn02d599.js +0 -2
@@ -145,6 +145,29 @@ export function mountNativeScreen(code, screen, options = {}) {
145
145
  for (const child of node.children || [])
146
146
  if (typeof child !== "string")
147
147
  visit(child);
148
+ }, modalCompletions = new Map, modalVisible = (node) => typeof node.props.visible === "boolean" ? node.props.visible : Boolean(node.style.display && node.style.display !== "none"), cancelModalCompletion = (id) => {
149
+ const pending = modalCompletions.get(id);
150
+ if (pending?.timer !== void 0)
151
+ timers.clearTimeout(pending.timer);
152
+ modalCompletions.delete(id);
153
+ }, finishModalDismissal = (node) => {
154
+ cancelModalCompletion(node.id);
155
+ const pending = {};
156
+ modalCompletions.set(node.id, pending);
157
+ const deliver = () => {
158
+ if (ended || modalCompletions.get(node.id) !== pending)
159
+ return;
160
+ modalCompletions.delete(node.id);
161
+ if (nodes.get(node.id) !== node || modalVisible(node))
162
+ return;
163
+ const handlerId = node.events.onDismissComplete;
164
+ if (handlerId)
165
+ receive(JSON.stringify({ type: "EVENT", payload: { handlerId, nativeEvent: {} } }));
166
+ }, delay = options.modalDismissDelayMs ?? 0;
167
+ if (delay > 0)
168
+ pending.timer = timers.setTimeout(deliver, delay);
169
+ else
170
+ queueMicrotask(deliver);
148
171
  }, openStream = (at, signal) => {
149
172
  const queue = [], waiting = [], encode = (text) => new TextEncoder().encode(text), stop = () => {
150
173
  stream.open = !1;
@@ -307,6 +330,7 @@ export function mountNativeScreen(code, screen, options = {}) {
307
330
  platform: options.platform ?? "ios",
308
331
  capabilityTimeoutMs: options.capabilityTimeoutMs ?? 100,
309
332
  colorScheme: options.colorScheme ?? "light",
333
+ appearance: { reduceMotion: options.reducedMotion },
310
334
  ...options.viewportWidth === void 0 ? {} : { viewportWidth: options.viewportWidth },
311
335
  capabilities: options.capabilities ?? [],
312
336
  initialAppState: options.initialAppState ?? "active",
@@ -337,6 +361,8 @@ export function mountNativeScreen(code, screen, options = {}) {
337
361
  const drop = (node) => {
338
362
  if (!node)
339
363
  return;
364
+ if (node.type === "Modal")
365
+ cancelModalCompletion(node.id);
340
366
  nodes.delete(node.id);
341
367
  for (const child of node.children || [])
342
368
  if (typeof child !== "string")
@@ -358,11 +384,18 @@ export function mountNativeScreen(code, screen, options = {}) {
358
384
  }
359
385
  const node = nodes.get(operation.id);
360
386
  if (node && operation.patch) {
387
+ const wasModalVisible = node.type === "Modal" && modalVisible(node);
361
388
  node.style = { ...node.style, ...operation.patch.style };
362
389
  node.props = { ...node.props, ...operation.patch.props };
363
390
  node.events = { ...node.events, ...operation.patch.events };
364
391
  if (operation.patch.children)
365
392
  node.children = operation.patch.children;
393
+ if (node.type === "Modal") {
394
+ if (modalVisible(node))
395
+ cancelModalCompletion(node.id);
396
+ else if (wasModalVisible && node.events.onDismissComplete)
397
+ finishModalDismissal(node);
398
+ }
366
399
  }
367
400
  }
368
401
  if (message.type === "NAVIGATE_OPEN")
@@ -440,6 +473,7 @@ export function mountNativeScreen(code, screen, options = {}) {
440
473
  timeouts.clear();
441
474
  immediateTimeouts.clear();
442
475
  intervals.clear();
476
+ modalCompletions.clear();
443
477
  streams.forEach((stream) => stream.end());
444
478
  }
445
479
  };
@@ -508,7 +542,7 @@ export function mountNativeScreen(code, screen, options = {}) {
508
542
  appState,
509
543
  background: () => appState("background"),
510
544
  resume: () => appState("active"),
511
- appearance: (scheme) => send("APPEARANCE", { colorScheme: scheme }),
545
+ appearance: (scheme, reduceMotion) => send("APPEARANCE", { colorScheme: scheme, reduceMotion }),
512
546
  viewport: (width, height = 800) => send("VIEWPORT", { width, height }),
513
547
  appear: () => send("SCREEN_FOCUS", { focused: !0 }),
514
548
  disappear: () => send("SCREEN_FOCUS", { focused: !1 }),
package/dist/page-head.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { escapeAttr } from "./builtins/escape.js";
2
+ import { tagAttributes } from "./document-tags.js";
2
3
  import { scanAtElementPosition } from "./html-masking.js";
3
4
  import { decodeTitleEntities } from "./spa-nav.js";
4
5
  function quoteValue(value) {
@@ -11,15 +12,6 @@ function headTags(html) {
11
12
  return tag.exec(source) ? tag.lastIndex : -1;
12
13
  }).map(({ token }) => token);
13
14
  }
14
- function tagAttributes(token) {
15
- const attrs = Object.create(null), attributes = token.replace(/^<\w+\b|>$/g, "");
16
- for (const match of attributes.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)) {
17
- const name = match[1].toLowerCase();
18
- if (!(name in attrs))
19
- attrs[name] = match[2] ?? match[3] ?? match[4] ?? "";
20
- }
21
- return attrs;
22
- }
23
15
  export function pageHeadFragment(html) {
24
16
  const metadata = [];
25
17
  for (const token of headTags(html)) {
package/dist/process.js CHANGED
@@ -42,7 +42,7 @@ import { injectSeoTags, processMetaDirectives, processSeoDirective, processStruc
42
42
  import { fileExists, resolveTemplatePath, scopeSequenceKey } from "./utils.js";
43
43
  import { runComposers } from "./view-composers.js";
44
44
  import { processServerBindings } from "./server-bindings.js";
45
- import { processVueTemplate } from "./vue-template.js";
45
+ import { normalizeVueSetupScripts, processVueTemplate } from "./vue-template.js";
46
46
  import { processDynamicComponents } from "./dynamic-components.js";
47
47
  import { dedupeScopedStyles, processScopedStyles } from "./style-scoping.js";
48
48
  import { injectColorModeBootScript, normalizeCriticalHeadOrder } from "./color-mode-boot.js";
@@ -377,6 +377,7 @@ export async function processDirectives(template, context, filePath, options, de
377
377
  await yieldDuringRendering();
378
378
  if (options.ssr === !1 && !options.autoShell && options.buildMode === "spa")
379
379
  return template;
380
+ template = normalizeVueSetupScripts(template, filePath);
380
381
  if (context.__stx_signals_gate === void 0)
381
382
  context.__stx_signals_gate = usesSignalsInScript(template, filePath);
382
383
  const isTopLevel = !context.__stxProcessingDepth;
@@ -838,8 +839,10 @@ async function processOtherDirectives(template, context, filePath, options, depe
838
839
  output = await interpolateClientScriptExpressions(output, context, filePath);
839
840
  await yieldDuringRendering();
840
841
  output = await processCustomDirectives(output, context, filePath, opts);
841
- if (usesSignalsInScript(output)) {
842
- output = convertSignalDirectivesToAttributes(output, context);
842
+ const hasSignalScript = usesSignalsInScript(output), componentSignals = !opts._nativeHostAttrs && Array.isArray(context.__stx_client_signal_names) ? context.__stx_client_signal_names : [];
843
+ if (hasSignalScript || componentSignals.length > 0)
844
+ output = convertSignalDirectivesToAttributes(output, context, componentSignals);
845
+ if (hasSignalScript) {
843
846
  output = convertSignalLoopsToAttributes(output, context);
844
847
  output = convertServerLoopAttributesToDirectives(output, context);
845
848
  }
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{_o,tn,ru,lm}from"./chunk-r7y1196g.js";import{ko,aa,im,am,cm}from"./chunk-zv3rn0ch.js";import{eu,tu,nu,sm,om}from"./chunk-npj20tj9.js";import{st,Vn,ca}from"./chunk-eptzpvn0.js";import{um,dm,pm,fm,Co,Yy}from"./chunk-23x3k751.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
- Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-31yx4sjh.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
2
+ import{$o,sn,cu,gm}from"./chunk-s3rhbwgf.js";import{To,da,dm,pm,fm}from"./chunk-prj38cyp.js";import{ou,iu,au,lm,um}from"./chunk-p17jeqz0.js";import{ot,Xn,pa}from"./chunk-b0kq5mzq.js";import{mm,hm,ym,bm,Ro,nb}from"./chunk-qzspvwv6.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
+ Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-tsnzhke9.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8">
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
233
233
  }, 5000);
234
234
  </script>
235
235
  </body>
236
- </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=st(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=_o(n,t);if(a){let s=tn(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return aa(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,tu as auditBuildOutput,eu as auditConfig,re as buildPwaAssets,nu as calculateAuditResult,om as formatAuditResult,ca as formatSize,j as generateManifest,_ as generateManifestJson,am as generateManifestLink,F as generateOfflinePage,st as generatePrecacheManifest,Vn as generatePrecacheManifestJs,M as generatePwaIcons,ko as generatePwaTags,_o as generateServiceWorker,lm as generateServiceWorkerAuto,im as generateSwRegistrationScript,cm as generateThemeColorMeta,N as getExpectedIconPaths,tn as getServiceWorkerFileName,aa as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,ru as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Co as pwaDirectives,um as pwaInstallDirective,pm as pwaOfflineDirective,fm as pwaPushDirective,dm as pwaUpdateDirective,Yy as registerPwaDirectives,sm as runPwaAudit,D as validateManifest};
236
+ </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=ot(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=$o(n,t);if(a){let s=sn(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return da(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,iu as auditBuildOutput,ou as auditConfig,re as buildPwaAssets,au as calculateAuditResult,um as formatAuditResult,pa as formatSize,j as generateManifest,_ as generateManifestJson,pm as generateManifestLink,F as generateOfflinePage,ot as generatePrecacheManifest,Xn as generatePrecacheManifestJs,M as generatePwaIcons,To as generatePwaTags,$o as generateServiceWorker,gm as generateServiceWorkerAuto,dm as generateSwRegistrationScript,fm as generateThemeColorMeta,N as getExpectedIconPaths,sn as getServiceWorkerFileName,da as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,cu as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Ro as pwaDirectives,mm as pwaInstallDirective,ym as pwaOfflineDirective,bm as pwaPushDirective,hm as pwaUpdateDirective,nb as registerPwaDirectives,lm as runPwaAudit,D as validateManifest};
@@ -53,7 +53,7 @@ export declare function hasSignalsSyntax(template: string, filePath?: string): b
53
53
  * via `state()`/etc., so they never land in this set — which is exactly why a
54
54
  * server-loop `@if/@else` chain is left alone.
55
55
  */
56
- export declare function extractClientSignalNames(template: string): Set<string>;
56
+ export declare function extractClientSignalNames(template: string, context?: Record<string, unknown>): Set<string>;
57
57
  /**
58
58
  * Convert @if(expr)...@endif directive blocks to attribute-style for signal templates.
59
59
  *
@@ -83,7 +83,7 @@ export declare function extractClientSignalNames(template: string): Set<string>;
83
83
  *
84
84
  * Note: Uses <template> wrapper for branches with multiple children or text nodes.
85
85
  */
86
- export declare function convertSignalDirectivesToAttributes(template: string, context?: Record<string, any>): string;
86
+ export declare function convertSignalDirectivesToAttributes(template: string, context?: Record<string, any>, componentSignals?: readonly string[]): string;
87
87
  /**
88
88
  * SSR pre-eval for literal-valued reactive conditional attributes
89
89
  * (stacksjs/stx#1739, Phase A).
@@ -5,7 +5,7 @@ import { escapeScriptBody } from "./script-emit.js";
5
5
  import { transformStoreImports } from "./store-imports.js";
6
6
  import { shouldTranspileTypeScript, transpileTypeScript } from "./utils.js";
7
7
  import { injectSignalsRuntime } from "./runtime-injection.js";
8
- import { evictOldest, matchScriptElement, scanAtElementPosition } from "./html-masking.js";
8
+ import { evictOldest, matchScriptElement, scanAtElementPosition, scanHtmlTags } from "./html-masking.js";
9
9
  import { importOnce } from "./lazy-module.js";
10
10
  import { findBodyOpenTag } from "./find-body-tag.js";
11
11
  import { stripCommentsAndLiterals } from "./strip-literals.js";
@@ -101,8 +101,8 @@ function hasTopLevelElseBranch(content) {
101
101
  }
102
102
  return !1;
103
103
  }
104
- export function extractClientSignalNames(template) {
105
- const names = new Set, scriptRe = /<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi, declRe = /\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g;
104
+ export function extractClientSignalNames(template, context) {
105
+ const inherited = context?.__stx_client_signal_names, names = new Set(Array.isArray(inherited) ? inherited.filter((name) => typeof name === "string") : []), scriptRe = /<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi, declRe = /\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g;
106
106
  let scriptMatch;
107
107
  while ((scriptMatch = scriptRe.exec(template)) !== null) {
108
108
  const body = scriptMatch[1];
@@ -231,10 +231,16 @@ function isBalancedForTag(inner, tag) {
231
231
  depth++;
232
232
  return !0;
233
233
  }
234
- export function convertSignalDirectivesToAttributes(template, context) {
234
+ export function convertSignalDirectivesToAttributes(template, context, componentSignals = []) {
235
235
  const signalNames = extractClientSignalNames(template);
236
+ for (const name of componentSignals)
237
+ signalNames.add(name);
236
238
  function convert(input) {
239
+ if (!input.includes("@if"))
240
+ return input;
237
241
  let output = input;
242
+ const tags = scanHtmlTags(input);
243
+ let tagIndex = 0;
238
244
  const clientLoopScopes = collectClientLoopScopes(input), loopVarsAt = (position) => {
239
245
  const vars = new Set;
240
246
  for (const scope of clientLoopScopes)
@@ -246,7 +252,12 @@ export function convertSignalDirectivesToAttributes(template, context) {
246
252
  let match;
247
253
  const replacements = [];
248
254
  while ((match = ifDirectiveStart.exec(output)) !== null) {
249
- const startIdx = match.index, exprStart = startIdx + match[0].length;
255
+ const startIdx = match.index;
256
+ while (tagIndex < tags.length && tags[tagIndex].end <= startIdx)
257
+ tagIndex++;
258
+ if (tags[tagIndex] && tags[tagIndex].start < startIdx)
259
+ continue;
260
+ const exprStart = startIdx + match[0].length;
250
261
  let depth = 1, i = exprStart;
251
262
  while (i < output.length && depth > 0) {
252
263
  if (output[i] === "(")
@@ -571,12 +582,7 @@ export function convertServerLoopAttributesToDirectives(template, context) {
571
582
  return template;
572
583
  if (!LOOP_ATTRS.some((attr) => template.includes(`${attr}=`)))
573
584
  return template;
574
- const signalNames = extractClientSignalNames(template);
575
- if (Array.isArray(context.__stx_client_signal_names)) {
576
- for (const name of context.__stx_client_signal_names)
577
- if (typeof name === "string")
578
- signalNames.add(name);
579
- }
585
+ const signalNames = extractClientSignalNames(template, context);
580
586
  let output = template;
581
587
  const replacements = [], tagRe = /<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
582
588
  let match;
package/dist/ssg.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- import"./chunk-0jdz31q1.js";import"./chunk-9928zdej.js";import"./chunk-0adc8x2h.js";import"./chunk-cwcmmgvz.js";import{_,Ml}from"./chunk-4vz17ytv.js";import"./chunk-16sfjkc4.js";import"./chunk-phzhmnnm.js";import{Ut}from"./chunk-b5qzed8y.js";import"./chunk-w98yt4d4.js";import"./chunk-p3x84jj0.js";import"./chunk-2vx2ben8.js";import{Lt,jt,Bt,Ft,zt,Ht}from"./chunk-388xpdw5.js";import{a}from"./chunk-mf5cqv1k.js";import{qs}from"./chunk-xnp031ba.js";import"./chunk-jr2r2nh5.js";import"./chunk-0sj79ha5.js";import{$e,mn,hn}from"./chunk-0atz8fjx.js";import"./chunk-t65f98qv.js";import{S}from"./chunk-ngqb22wj.js";import{Pt,i}from"./chunk-n4m50dpk.js";import"./chunk-0v7555tr.js";import"./chunk-43sgpy4e.js";import{Os}from"./chunk-9w9y84t5.js";import"./chunk-bm6y085n.js";import"./chunk-fs43342z.js";import{Ec,Tc,$c,Rc,Ac}from"./chunk-ywrpmyzj.js";import{fn,gr,mr}from"./chunk-357qjcj1.js";import{gn}from"./chunk-f0sxbgbm.js";import"./chunk-0fm6avxt.js";import"./chunk-9tv0tw7f.js";import{re,Pe}from"./chunk-8b8az19t.js";import"./chunk-nhyv3w4r.js";import"./chunk-w6ydg43d.js";import{l}from"./chunk-4e18r89n.js";import{rt}from"./chunk-e5rag6rh.js";import{t,h}from"./chunk-fvr3h2fr.js";import{f}from"./chunk-8tfpv6zf.js";import v from"fs";import p from"path";var xt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(e){let n=e.trim();if(!n)return null;let s=/^https?:\/\//i.test(n)?n:`https://${n}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function bt(e){for(let n of xt){let s=e[n];if(!s)continue;let o=X(s);if(o)return{url:o,source:"env",via:n}}return null}function ct(e){if(!e||typeof e!=="object")return null;let n=e,s=n.site?.url??n.url??n.app?.url;return typeof s==="string"?X(s):null}async function vt(e){let{existsSync:n}=await import("fs"),s=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(e,o);if(!n(c))continue;try{let r=await import(c),u=ct(r.default??r);if(u)return u}catch{}}return null}async function lt(e={}){let n=e.cwd??process.cwd(),s=e.env??process.env;if(e.explicit){let u=X(e.explicit);if(u)return{url:u,source:"option"}}let o=ct(e.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await vt(n);if(c)return{url:c,source:"site.config",via:"url"};let r=bt(s);if(r)return r;return{url:"http://localhost",source:"fallback"}}function ut(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
3
- `)}function J(e){return async()=>({paths:await e(),fallback:!1})}var Dt;function $t(e){let n=t(e),{depths:s}=h(n),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(n))!==null){if(s[c.index]!==0)continue;let u=_(n,"(",")",o.lastIndex-1),y=n.indexOf("{",u+1),P=_(n,"{","}",y);if(u<0||y<0||P<0)break;return e.slice(c.index,P+1)}let r=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=r.exec(n))!==null){if(s[c.index]!==0)continue;let u=Ml(n,r.lastIndex).endPos;return e.slice(r.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function dt(e){let n="read";try{let s=await Bun.file(e).text();n="parse";let o=gn(s),c=[...o.server,...o.client,...o.signals].filter((r)=>/(?:^|\s)server(?:\s|=|$)/i.test(t(r.attrs))).sort((r,u)=>s.indexOf(r.fullTag)-s.indexOf(u.fullTag));for(let r of c){if(!/\bgetStaticPaths\b/.test(t(r.content)))continue;let u=(Dt??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(r.content);if(!/\bgetStaticPaths\b/.test(t(u)))continue;let y=$t(u);if(/\bdefineStaticPaths\b/.test(t(y))&&Ut(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");n="execute";let P=Function("defineStaticPaths",`return (${y})`)(J);if(typeof P!=="function")throw TypeError("getStaticPaths must be a function");let k=await P();n="result";let x=Array.isArray(k)?{paths:k}:k;if(!x||typeof x!=="object"||!("paths"in x)||!Array.isArray(x.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let D of x.paths)if(!D||typeof D!=="object"||!D.params||typeof D.params!=="object"||Array.isArray(D.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:x}}return{kind:"absent"}}catch(s){return{kind:"error",phase:n,error:s instanceof Error?s:Error(String(s))}}}class gt{cacheDir;cache=new Map;loaded=!1;salt;constructor(e,n=""){this.cacheDir=e,this.salt=n}async load(){if(this.loaded)return;let e=p.join(this.cacheDir,"build-cache.json");if(await Bun.file(e).exists())try{let n=JSON.parse(await Bun.file(e).text());for(let[s,o]of Object.entries(n))this.cache.set(s,o)}catch{}this.loaded=!0}async save(){await v.promises.mkdir(this.cacheDir,{recursive:!0});let e=p.join(this.cacheDir,"build-cache.json"),n={};for(let[s,o]of this.cache)n[s]=o;await Bun.write(e,JSON.stringify(n))}getHash(e,n){let s=v.statSync(e),o=`${this.salt}|${e}:${s.mtimeMs}`;for(let r of n)if(v.existsSync(r)){let u=v.statSync(r);o+=`:${r}:${u.mtimeMs}`}let c=0;for(let r=0;r<o.length;r++){let u=o.charCodeAt(r);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(e,n){let s=this.cache.get(e);if(!s)return null;let o=ft(n).some((u)=>v.existsSync(u)),c=[n,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&v.existsSync(u)&&Os(v.readFileSync(u,"utf8")).some((y)=>/\bserver\b/.test(y.attrs)));if(o||c)return this.cache.delete(e),null;let r=this.getHash(n,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(e),null;return s.html}set(e,n,s,o){let c=this.getHash(n,s);this.cache.set(e,{hash:c,html:o,generatedAt:Date.now(),dependencies:s})}}class pt{cacheDir;constructor(e){this.cacheDir=e}getFilePath(e){let n=e.replace(/[^a-zA-Z0-9]/g,"_")+".json";return p.join(this.cacheDir,"isr",n)}async get(e){let n=this.getFilePath(e);if(!await Bun.file(n).exists())return null;try{return JSON.parse(await Bun.file(n).text())}catch{return null}}async set(e,n){let s=this.getFilePath(e);await v.promises.mkdir(p.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(n))}async invalidate(e){let n=this.getFilePath(e);if(await Bun.file(n).exists())await v.promises.unlink(n)}async invalidatePattern(e){let n=p.join(this.cacheDir,"isr");if(!v.existsSync(n))return;let s=await v.promises.readdir(n);for(let o of s){let c=o.replace(/_/g,"/").replace(".json","");if(e.test(c))await v.promises.unlink(p.join(n,o))}}async needsRevalidation(e){let n=await this.get(e);if(!n)return!0;return Date.now()>n.revalidateAfter}}async function kt(e){let n=[];if(!e.isDynamic)n.push({url:e.pattern,params:{}});else{let s=await dt(e.filePath);if(s.kind==="error")throw Error(`getStaticPaths ${s.phase} failed for ${e.pattern} (${e.filePath}): ${s.error.message}`,{cause:s.error});if(s.kind==="absent")return console.warn(`Warning: Dynamic route ${e.pattern} (${e.filePath}) has no getStaticPaths`),n;let o=s.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${e.pattern} (${e.filePath})`),n;for(let c of o.paths){let r=e.pattern;for(let[u,y]of Object.entries(c.params))r=r.replace(`:${u}`,y).replace(`:${u}*`,y);n.push({url:r,params:c.params,props:c.props,revalidate:c.revalidate})}}return n}function ft(e){return[e.replace(/\.stx$/,".data.ts"),e.replace(/\.stx$/,".data.js"),e+".data.ts",e+".data.js"]}async function Rt(e){for(let n of ft(e))if(await Bun.file(n).exists())try{let s=await import(n);if(typeof s.default==="function")return await s.default();else if(typeof s.default==="object")return s.default;else if(typeof s.getData==="function")return await s.getData();else{let{default:o,...c}=s;return c}}catch(s){console.error(`Error loading data file ${n}:`,s)}return null}async function Et(e,n,s){let o=e.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let c=o[1];if(!c.includes("getStaticProps"))return null;try{let r=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!r)return null;return await Function("params",`
2
+ import"./chunk-a78k8fkg.js";import"./chunk-ra35ptjg.js";import"./chunk-w81a1e14.js";import"./chunk-s1x2pc9b.js";import{_,Bl}from"./chunk-r7zvrh58.js";import"./chunk-4jg8ddfy.js";import"./chunk-ayrd026n.js";import{Vt}from"./chunk-xdprx6tx.js";import"./chunk-875wejw1.js";import"./chunk-yfe380a4.js";import"./chunk-c3nmjx26.js";import{jt,Bt,Ft,zt,Ht,Ut}from"./chunk-t4exh7c9.js";import{a}from"./chunk-w27j0apm.js";import{Xs}from"./chunk-f8sh6289.js";import"./chunk-ag07tdhn.js";import"./chunk-78j6c3sf.js";import{Re,bn,wn}from"./chunk-sgppgy5e.js";import"./chunk-1pc2p489.js";import{S}from"./chunk-0rq1w0xr.js";import{It,i}from"./chunk-hx6tr46s.js";import"./chunk-36j2drjv.js";import"./chunk-vhp5hqwp.js";import{Ms}from"./chunk-xnvh4jk2.js";import"./chunk-3mc9ew9r.js";import"./chunk-avtq2p0c.js";import{Ac,Pc,Ic,Oc,Nc}from"./chunk-g2fxp9zp.js";import{hn,br,wr}from"./chunk-pxvp0cc9.js";import{yn}from"./chunk-h7z23fpq.js";import"./chunk-jh1hdq31.js";import"./chunk-2r2tayyd.js";import{oe,Ie}from"./chunk-nkgqhb7s.js";import"./chunk-7767n5k6.js";import"./chunk-sk8x8nw8.js";import{l}from"./chunk-ygtz9kc7.js";import{st}from"./chunk-q99y5115.js";import{t,y}from"./chunk-amnfd29h.js";import{f}from"./chunk-ws25jw6x.js";import v from"fs";import p from"path";var xt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(e){let n=e.trim();if(!n)return null;let s=/^https?:\/\//i.test(n)?n:`https://${n}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function bt(e){for(let n of xt){let s=e[n];if(!s)continue;let o=X(s);if(o)return{url:o,source:"env",via:n}}return null}function ct(e){if(!e||typeof e!=="object")return null;let n=e,s=n.site?.url??n.url??n.app?.url;return typeof s==="string"?X(s):null}async function vt(e){let{existsSync:n}=await import("fs"),s=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(e,o);if(!n(c))continue;try{let r=await import(c),u=ct(r.default??r);if(u)return u}catch{}}return null}async function lt(e={}){let n=e.cwd??process.cwd(),s=e.env??process.env;if(e.explicit){let u=X(e.explicit);if(u)return{url:u,source:"option"}}let o=ct(e.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await vt(n);if(c)return{url:c,source:"site.config",via:"url"};let r=bt(s);if(r)return r;return{url:"http://localhost",source:"fallback"}}function ut(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
3
+ `)}function J(e){return async()=>({paths:await e(),fallback:!1})}var Pt;function Dt(e){let n=t(e),{depths:s}=y(n),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(n))!==null){if(s[c.index]!==0)continue;let u=_(n,"(",")",o.lastIndex-1),w=n.indexOf("{",u+1),P=_(n,"{","}",w);if(u<0||w<0||P<0)break;return e.slice(c.index,P+1)}let r=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=r.exec(n))!==null){if(s[c.index]!==0)continue;let u=Bl(n,r.lastIndex).endPos;return e.slice(r.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function dt(e){let n="read";try{let s=await Bun.file(e).text();n="parse";let o=yn(s),c=[...o.server,...o.client,...o.signals].filter((r)=>/(?:^|\s)server(?:\s|=|$)/i.test(t(r.attrs))).sort((r,u)=>s.indexOf(r.fullTag)-s.indexOf(u.fullTag));for(let r of c){if(!/\bgetStaticPaths\b/.test(t(r.content)))continue;let u=(Pt??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(r.content);if(!/\bgetStaticPaths\b/.test(t(u)))continue;let w=Dt(u);if(/\bdefineStaticPaths\b/.test(t(w))&&Vt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");n="execute";let P=Function("defineStaticPaths",`return (${w})`)(J);if(typeof P!=="function")throw TypeError("getStaticPaths must be a function");let k=await P();n="result";let x=Array.isArray(k)?{paths:k}:k;if(!x||typeof x!=="object"||!("paths"in x)||!Array.isArray(x.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let D of x.paths)if(!D||typeof D!=="object"||!D.params||typeof D.params!=="object"||Array.isArray(D.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:x}}return{kind:"absent"}}catch(s){return{kind:"error",phase:n,error:s instanceof Error?s:Error(String(s))}}}class gt{cacheDir;cache=new Map;loaded=!1;salt;constructor(e,n=""){this.cacheDir=e,this.salt=n}async load(){if(this.loaded)return;let e=p.join(this.cacheDir,"build-cache.json");if(await Bun.file(e).exists())try{let n=JSON.parse(await Bun.file(e).text());for(let[s,o]of Object.entries(n))this.cache.set(s,o)}catch{}this.loaded=!0}async save(){await v.promises.mkdir(this.cacheDir,{recursive:!0});let e=p.join(this.cacheDir,"build-cache.json"),n={};for(let[s,o]of this.cache)n[s]=o;await Bun.write(e,JSON.stringify(n))}getHash(e,n){let s=v.statSync(e),o=`${this.salt}|${e}:${s.mtimeMs}`;for(let r of n)if(v.existsSync(r)){let u=v.statSync(r);o+=`:${r}:${u.mtimeMs}`}let c=0;for(let r=0;r<o.length;r++){let u=o.charCodeAt(r);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(e,n){let s=this.cache.get(e);if(!s)return null;let o=ft(n).some((u)=>v.existsSync(u)),c=[n,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&v.existsSync(u)&&Ms(v.readFileSync(u,"utf8")).some((w)=>/\bserver\b/.test(w.attrs)));if(o||c)return this.cache.delete(e),null;let r=this.getHash(n,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(e),null;return s.html}set(e,n,s,o){let c=this.getHash(n,s);this.cache.set(e,{hash:c,html:o,generatedAt:Date.now(),dependencies:s})}}class pt{cacheDir;constructor(e){this.cacheDir=e}getFilePath(e){let n=e.replace(/[^a-zA-Z0-9]/g,"_")+".json";return p.join(this.cacheDir,"isr",n)}async get(e){let n=this.getFilePath(e);if(!await Bun.file(n).exists())return null;try{return JSON.parse(await Bun.file(n).text())}catch{return null}}async set(e,n){let s=this.getFilePath(e);await v.promises.mkdir(p.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(n))}async invalidate(e){let n=this.getFilePath(e);if(await Bun.file(n).exists())await v.promises.unlink(n)}async invalidatePattern(e){let n=p.join(this.cacheDir,"isr");if(!v.existsSync(n))return;let s=await v.promises.readdir(n);for(let o of s){let c=o.replace(/_/g,"/").replace(".json","");if(e.test(c))await v.promises.unlink(p.join(n,o))}}async needsRevalidation(e){let n=await this.get(e);if(!n)return!0;return Date.now()>n.revalidateAfter}}async function $t(e){let n=[];if(!e.isDynamic)n.push({url:e.pattern,params:{}});else{let s=await dt(e.filePath);if(s.kind==="error")throw Error(`getStaticPaths ${s.phase} failed for ${e.pattern} (${e.filePath}): ${s.error.message}`,{cause:s.error});if(s.kind==="absent")return console.warn(`Warning: Dynamic route ${e.pattern} (${e.filePath}) has no getStaticPaths`),n;let o=s.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${e.pattern} (${e.filePath})`),n;for(let c of o.paths){let r=e.pattern;for(let[u,w]of Object.entries(c.params))r=r.replace(`:${u}`,w).replace(`:${u}*`,w);n.push({url:r,params:c.params,props:c.props,revalidate:c.revalidate})}}return n}function ft(e){return[e.replace(/\.stx$/,".data.ts"),e.replace(/\.stx$/,".data.js"),e+".data.ts",e+".data.js"]}async function kt(e){for(let n of ft(e))if(await Bun.file(n).exists())try{let s=await import(n);if(typeof s.default==="function")return await s.default();else if(typeof s.default==="object")return s.default;else if(typeof s.getData==="function")return await s.getData();else{let{default:o,...c}=s;return c}}catch(s){console.error(`Error loading data file ${n}:`,s)}return null}async function Rt(e,n,s){let o=e.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let c=o[1];if(!c.includes("getStaticProps"))return null;try{let r=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!r)return null;return await Function("params",`
4
4
  return (async function getStaticProps() {
5
5
  ${r[1]}
6
6
  })()
7
- `)(n)}catch(r){return console.error(`Error executing getStaticProps in ${s}:`,r),null}}function Ct(e){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(e)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(e)}async function ht(e,n,s={},o,c){let r=await Bun.file(e.filePath).text(),u=await Rt(e.filePath),y=await Et(r,n,e.filePath),P={...u||{},...y||{},...s,params:n,$route:{path:e.pattern,params:n}},k=new Set,x=[],D=[],E={...c,minifyClient:!0,...o.partialsDir?{partialsDir:o.partialsDir}:{},...o.componentsDir?{componentsDir:o.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(R)=>{x.push(`${p.relative(process.cwd(),R.templatePath)}: ${R.message}
8
- resolved against partialsDir: ${R.partialsDir}`)},onServerScriptError:(R)=>{D.push(`${p.relative(process.cwd(),R.sourcePath)} (${R.kind}): ${R.message}`)}};if(Ct(r))console.warn(`Warning: ${e.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let w=await i(r,P,e.filePath,E,k);for(let R of[e.filePath,...k])for(let O of $e(R))k.add(O);if(Object.keys(n).length>0){let R=`<script>if(window.stx)window.stx._rp=${JSON.stringify(n)};else window.__stx_rp=${JSON.stringify(n)};</script>`;if(w.includes("</head>"))w=f(w,R);else w=`${R}
9
- ${w}`}if(w=await Pe(w,{router:o.router}),w=await S(w),o.minify!==!1)return{html:It(w),dependencies:Array.from(k),includeFailures:x,serverScriptFailures:D};return{html:w,dependencies:Array.from(k),includeFailures:x,serverScriptFailures:D}}function It(e){let n=[],s=0,o=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=o.exec(e))!==null){let u=e.slice(s,c.index);n.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let y=c[1],P=c[2],k=c[3];P=rt(P).replace(/<\/script/gi,"<\\/script"),n.push(y+P+k),s=c.index+c[0].length}let r=e.slice(s);return n.push(r.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),n.join("").trim()}function Tt(e){let n=0;for(let s=0;s<e.length;s++){let o=e.charCodeAt(s);n=(n<<5)-n+o,n=n&n}return`"${Math.abs(n).toString(36)}"`}function Ot(e,n,s,o){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(n))return!0;return o.some((c)=>{if(c instanceof RegExp)return c.test(e);return c.endsWith("/")?e===c.slice(0,-1)||e.startsWith(c):e===c})}function At(e,n){return`<?xml version="1.0" encoding="UTF-8"?>
7
+ `)(n)}catch(r){return console.error(`Error executing getStaticProps in ${s}:`,r),null}}function Et(e){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(e)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(e)}async function ht(e,n,s={},o,c){let r=await Bun.file(e.filePath).text(),u=await kt(e.filePath),w=await Rt(r,n,e.filePath),P={...u||{},...w||{},...s,params:n,$route:{path:e.pattern,params:n}},k=new Set,x=[],D=[],E={...c,minifyClient:!0,...o.partialsDir?{partialsDir:o.partialsDir}:{},...o.componentsDir?{componentsDir:o.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(R)=>{x.push(`${p.relative(process.cwd(),R.templatePath)}: ${R.message}
8
+ resolved against partialsDir: ${R.partialsDir}`)},onServerScriptError:(R)=>{D.push(`${p.relative(process.cwd(),R.sourcePath)} (${R.kind}): ${R.message}`)}};if(Et(r))console.warn(`Warning: ${e.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let m=await i(r,P,e.filePath,E,k);for(let R of[e.filePath,...k])for(let O of Re(R))k.add(O);if(Object.keys(n).length>0){let R=`<script>if(window.stx)window.stx._rp=${JSON.stringify(n)};else window.__stx_rp=${JSON.stringify(n)};</script>`;if(m.includes("</head>"))m=f(m,R);else m=`${R}
9
+ ${m}`}if(m=await Ie(m,{router:o.router}),m=await S(m),o.minify!==!1)return{html:Ct(m),dependencies:Array.from(k),includeFailures:x,serverScriptFailures:D};return{html:m,dependencies:Array.from(k),includeFailures:x,serverScriptFailures:D}}function Ct(e){let n=[],s=0,o=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=o.exec(e))!==null){let u=e.slice(s,c.index);n.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let w=c[1],P=c[2],k=c[3];P=st(P).replace(/<\/script/gi,"<\\/script"),n.push(w+P+k),s=c.index+c[0].length}let r=e.slice(s);return n.push(r.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),n.join("").trim()}function Tt(e){let n=0;for(let s=0;s<e.length;s++){let o=e.charCodeAt(s);n=(n<<5)-n+o,n=n&n}return`"${Math.abs(n).toString(36)}"`}function Ot(e,n,s,o){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(n))return!0;return o.some((c)=>{if(c instanceof RegExp)return c.test(e);return c.endsWith("/")?e===c.slice(0,-1)||e.startsWith(c):e===c})}function At(e,n){return`<?xml version="1.0" encoding="UTF-8"?>
10
10
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
11
11
  ${e.map((o)=>{let c=new URL(o.loc,n).href,r=` <url>
12
12
  <loc>${F(c)}</loc>`;if(o.lastmod)r+=`
@@ -15,7 +15,7 @@ ${e.map((o)=>{let c=new URL(o.loc,n).href,r=` <url>
15
15
  <priority>${o.priority}</priority>`;return r+=`
16
16
  </url>`,r}).join(`
17
17
  `)}
18
- </urlset>`}function F(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Mt(e,n){let s=n.map((o)=>{let c=" <item>";if(c+=`
18
+ </urlset>`}function F(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Lt(e,n){let s=n.map((o)=>{let c=" <item>";if(c+=`
19
19
  <title>${F(o.title)}</title>`,c+=`
20
20
  <link>${F(o.link)}</link>`,o.description)c+=`
21
21
  <description>${F(o.description)}</description>`;if(o.pubDate)c+=`
@@ -36,15 +36,15 @@ ${e.map((o)=>{let c=new URL(o.loc,n).href,r=` <url>
36
36
  ${s.join(`
37
37
  `)}
38
38
  </channel>
39
- </rss>`}async function _t(e={}){let n=Date.now();hn();let s=await a(process.cwd()),o=s.build||{},c=await lt({explicit:e.domain||o.domain,stxConfig:s});if(c.source==="fallback"&&(e.sitemap??o.sitemap??!0))console.warn(ut());let r={router:e.router??s?.router??{},pagesDir:e.pagesDir||o.pagesDir||"pages",outputDir:e.outputDir||o.outputDir||"dist",baseUrl:e.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:e.revalidate??o.revalidate??!1,sitemap:e.sitemap??o.sitemap??!0,sitemapExclude:e.sitemapExclude||o.sitemapExclude||[],robots:e.robots??o.robots??!0,rss:e.rss??o.rss??!1,concurrency:e.concurrency||o.concurrency||10,cache:e.cache??o.cache??!0,cacheDir:e.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:e.contentLoaders||[],hooks:e.hooks||{},minify:e.minify??o.minify??!0,generate404:e.generate404??o.generate404??!0,publicDir:e.publicDir||o.publicDir||"public",trailingSlash:e.trailingSlash??o.trailingSlash??!1,cleanOutput:e.cleanOutput??o.cleanOutput??!0,cacheSalt:e.cacheSalt??"",partialsDir:e.partialsDir||s?.partialsDir||"",componentsDir:e.componentsDir||s?.componentsDir||"",failOnIncludeError:e.failOnIncludeError??!0,failOnServerScriptError:e.failOnServerScriptError??!0,chunkIslands:e.chunkIslands===!0,prefetchIslands:e.prefetchIslands===!0,integrityIslands:e.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},y=new Set,P=0,k={},x={};await r.hooks.onBuildStart?.();try{if(r.cleanOutput&&v.existsSync(r.outputDir))await v.promises.rm(r.outputDir,{recursive:!0});await v.promises.mkdir(r.outputDir,{recursive:!0});let E=r.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-q60afqr7.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:w}=await import("./chunk-js1wayhb.js"),R=await w(r.publicDir,r.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let O=new gt(r.cacheDir,E);if(r.cache)await O.load();try{let{generateCss:d}=await import("./chunk-q60afqr7.js");await d('<div class="bg-black"></div>')}catch{}Lt();let mt=s?.routeMiddleware?.dir||"middleware";await Bt(process.cwd(),mt);let V=jt();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let wt=s?.routeMiddleware?.global||[];Ac(s?.layoutsDir,l(process.cwd()));let Z=re(".",{pagesDir:r.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Z.length} routes`);let L=[];for(let d of Z)try{let m=await kt(d);for(let b of m)L.push({route:d,url:b.url,params:b.params,props:b.props,revalidate:b.revalidate??r.revalidate})}catch(m){let b=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:b}),await r.hooks.onError?.(b,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,b)}u.totalPages=L.length+u.failedCount,console.log(`Generating ${L.length} pages...`);let U=[],Q=[];for(let d=0;d<L.length;d+=r.concurrency)Q.push(L.slice(d,d+r.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:b,url:g,params:M,props:yt,revalidate:nt}=m;try{await r.hooks.onPageStart?.(g);let G=await Bun.file(b.filePath).text(),T=Wt(G),St=T?.middleware?Array.isArray(T.middleware)?T.middleware:[T.middleware]:[],it=[...wt,...St];if(it.length>0){let j=Ft(g,M,T||{}),z=zt(j,null,void 0,{isServer:!0}),I=await Ht(it,z);if(I.redirect){let C=typeof I.redirect==="string"?I.redirect:I.redirect.path||I.redirect,H=qt(String(C),g),A=Jt(g,r);await v.promises.mkdir(p.dirname(A),{recursive:!0}),await Bun.write(A,H),u.successCount++,u.pages.push({route:g,outputPath:A,size:Buffer.byteLength(H),cached:!1}),U.push({loc:g,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${g} \u2192 redirect to ${C}`);return}if(I.abort){let C=typeof I.abort==="string"?I.abort:I.abort?.error?.message||"aborted";console.warn(` \u21B3 ${g} \u2014 middleware aborted: ${C}`);return}}let st=T?.validate;if(typeof st==="function")try{if(!await st({params:M})){console.warn(`Validation failed for ${g}, skipping...`);return}}catch{}let B=null,at=!1;if(r.cache){if(B=O.get(g,b.filePath),B)at=!0,u.cachedCount++}if(!B){let j=await ht(b,M,yt,r,s);if(B=j.html,r.failOnIncludeError&&j.includeFailures.length>0)throw Error(`${j.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
39
+ </rss>`}async function Mt(e={}){let n=Date.now();wn();let s=await a(process.cwd()),o=s.build||{},c=await lt({explicit:e.domain||o.domain,stxConfig:s});if(c.source==="fallback"&&(e.sitemap??o.sitemap??!0))console.warn(ut());let r={router:e.router??s?.router??{},pagesDir:e.pagesDir||o.pagesDir||"pages",outputDir:e.outputDir||o.outputDir||"dist",baseUrl:e.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:e.revalidate??o.revalidate??!1,sitemap:e.sitemap??o.sitemap??!0,sitemapExclude:e.sitemapExclude||o.sitemapExclude||[],robots:e.robots??o.robots??!0,rss:e.rss??o.rss??!1,concurrency:e.concurrency||o.concurrency||10,cache:e.cache??o.cache??!0,cacheDir:e.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:e.contentLoaders||[],hooks:e.hooks||{},minify:e.minify??o.minify??!0,generate404:e.generate404??o.generate404??!0,publicDir:e.publicDir||o.publicDir||"public",trailingSlash:e.trailingSlash??o.trailingSlash??!1,cleanOutput:e.cleanOutput??o.cleanOutput??!0,cacheSalt:e.cacheSalt??"",partialsDir:e.partialsDir||s?.partialsDir||"",componentsDir:e.componentsDir||s?.componentsDir||"",failOnIncludeError:e.failOnIncludeError??!0,failOnServerScriptError:e.failOnServerScriptError??!0,chunkIslands:e.chunkIslands===!0,prefetchIslands:e.prefetchIslands===!0,integrityIslands:e.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,P=0,k={},x={};await r.hooks.onBuildStart?.();try{if(r.cleanOutput&&v.existsSync(r.outputDir))await v.promises.rm(r.outputDir,{recursive:!0});await v.promises.mkdir(r.outputDir,{recursive:!0});let E=r.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:h}=await import("./chunk-8g6cmgn8.js");try{E=h(await d(process.cwd()))}catch{}}let{prepareImageDelivery:m}=await import("./chunk-xjhv5e5f.js"),R=await m(r.publicDir,r.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let O=new gt(r.cacheDir,E);if(r.cache)await O.load();try{let{generateCss:d}=await import("./chunk-8g6cmgn8.js");await d('<div class="bg-black"></div>')}catch{}jt();let mt=s?.routeMiddleware?.dir||"middleware";await Ft(process.cwd(),mt);let V=Bt();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let wt=s?.routeMiddleware?.global||[];Nc(s?.layoutsDir,l(process.cwd()));let Z=oe(".",{pagesDir:r.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Z.length} routes`);let L=[];for(let d of Z)try{let h=await $t(d);for(let b of h)L.push({route:d,url:b.url,params:b.params,props:b.props,revalidate:b.revalidate??r.revalidate})}catch(h){let b=h instanceof Error?h:Error(String(h));u.failedCount++,u.errors.push({route:d.pattern,error:b}),await r.hooks.onError?.(b,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,b)}u.totalPages=L.length+u.failedCount,console.log(`Generating ${L.length} pages...`);let U=[],Q=[];for(let d=0;d<L.length;d+=r.concurrency)Q.push(L.slice(d,d+r.concurrency));for(let d of Q)await Promise.all(d.map(async(h)=>{let{route:b,url:g,params:M,props:yt,revalidate:rt}=h;try{await r.hooks.onPageStart?.(g);let G=await Bun.file(b.filePath).text(),T=Nt(G),St=T?.middleware?Array.isArray(T.middleware)?T.middleware:[T.middleware]:[],nt=[...wt,...St];if(nt.length>0){let j=zt(g,M,T||{}),z=Ht(j,null,void 0,{isServer:!0}),I=await Ut(nt,z);if(I.redirect){let C=typeof I.redirect==="string"?I.redirect:I.redirect.path||I.redirect,H=Wt(String(C),g),A=qt(g,r);await v.promises.mkdir(p.dirname(A),{recursive:!0}),await Bun.write(A,H),u.successCount++,u.pages.push({route:g,outputPath:A,size:Buffer.byteLength(H),cached:!1}),U.push({loc:g,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${g} \u2192 redirect to ${C}`);return}if(I.abort){let C=typeof I.abort==="string"?I.abort:I.abort?.error?.message||"aborted";console.warn(` \u21B3 ${g} \u2014 middleware aborted: ${C}`);return}}let it=T?.validate;if(typeof it==="function")try{if(!await it({params:M})){console.warn(`Validation failed for ${g}, skipping...`);return}}catch{}let B=null,at=!1;if(r.cache){if(B=O.get(g,b.filePath),B)at=!0,u.cachedCount++}if(!B){let j=await ht(b,M,yt,r,s);if(B=j.html,r.failOnIncludeError&&j.includeFailures.length>0)throw Error(`${j.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
40
40
  ${j.includeFailures.join(`
41
41
  `)}
42
42
  Set ssg.failOnIncludeError to false to build anyway.`);if(r.failOnServerScriptError&&j.serverScriptFailures.length>0)throw Error(`${j.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
43
43
  ${j.serverScriptFailures.join(`
44
44
  `)}
45
- Set ssg.failOnServerScriptError to false to build anyway.`);if(r.cache)O.set(g,b.filePath,j.dependencies,B)}let N;if(r.trailingSlash)N=p.join(r.outputDir,g,"index.html");else N=g==="/"?p.join(r.outputDir,"index.html"):p.join(r.outputDir,`${g}.html`);if(r.chunkIslands){let{html:j,chunks:z}=Ec(B,{integrity:r.integrityIslands,minify:r.minify});if(z.length>0){let I=p.join(r.outputDir,"_stx","islands");await v.promises.mkdir(I,{recursive:!0});for(let C of z){let H=p.join(I,`${C.hash}.js`);if(!await Bun.file(H).exists())await Bun.write(H,C.code);if(!y.has(C.hash)){y.add(C.hash);let A=Buffer.byteLength(C.code,"utf8");P+=A,k[C.hash]={bytes:A,file:`/_stx/islands/${C.hash}.js`}}}if(x[g]=z.map((C)=>C.hash),B=j,r.prefetchIslands)B=Tc(B)}}if(await v.promises.mkdir(p.dirname(N),{recursive:!0}),await Bun.write(N,B),!Ot(g,B,T,r.sitemapExclude))U.push({loc:g,lastmod:new Date().toISOString().split("T")[0],priority:g==="/"?1:0.8});let ot={route:g,outputPath:N,size:Buffer.byteLength(B,"utf8"),cached:at};if(nt!==!1)ot.revalidateAt=Date.now()+nt*1000;u.pages.push(ot),u.successCount++,await r.hooks.onPageEnd?.(g,B)}catch(G){u.failedCount++,u.errors.push({route:g,error:G}),await r.hooks.onError?.(G,g),console.error(`Error generating ${g}:`,G)}}));let tt=mn();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
45
+ Set ssg.failOnServerScriptError to false to build anyway.`);if(r.cache)O.set(g,b.filePath,j.dependencies,B)}let N;if(r.trailingSlash)N=p.join(r.outputDir,g,"index.html");else N=g==="/"?p.join(r.outputDir,"index.html"):p.join(r.outputDir,`${g}.html`);if(r.chunkIslands){let{html:j,chunks:z}=Ac(B,{integrity:r.integrityIslands,minify:r.minify});if(z.length>0){let I=p.join(r.outputDir,"_stx","islands");await v.promises.mkdir(I,{recursive:!0});for(let C of z){let H=p.join(I,`${C.hash}.js`);if(!await Bun.file(H).exists())await Bun.write(H,C.code);if(!w.has(C.hash)){w.add(C.hash);let A=Buffer.byteLength(C.code,"utf8");P+=A,k[C.hash]={bytes:A,file:`/_stx/islands/${C.hash}.js`}}}if(x[g]=z.map((C)=>C.hash),B=j,r.prefetchIslands)B=Pc(B)}}if(await v.promises.mkdir(p.dirname(N),{recursive:!0}),await Bun.write(N,B),!Ot(g,B,T,r.sitemapExclude))U.push({loc:g,lastmod:new Date().toISOString().split("T")[0],priority:g==="/"?1:0.8});let ot={route:g,outputPath:N,size:Buffer.byteLength(B,"utf8"),cached:at};if(rt!==!1)ot.revalidateAt=Date.now()+rt*1000;u.pages.push(ot),u.successCount++,await r.hooks.onPageEnd?.(g,B)}catch(G){u.failedCount++,u.errors.push({route:g,error:G}),await r.hooks.onError?.(G,g),console.error(`Error generating ${g}:`,G)}}));let tt=bn();if(tt.length>0){let d=tt.map((h)=>`${h.filePath}: ${h.message}`).join(`
46
46
  `);throw Error(`Client script bundling failed:
47
- ${d}`)}if(r.cache)await O.save();if(r.generate404){let d=p.join(r.pagesDir,"404.stx");if(await Bun.file(d).exists()){let m=new Set,b={...s,minifyClient:!0,debug:!1,cache:!1},g=await i(await Bun.file(d).text(),{},d,b,m);await Bun.write(p.join(r.outputDir,"404.html"),g)}else await Bun.write(p.join(r.outputDir,"404.html"),`<!DOCTYPE html>
47
+ ${d}`)}if(r.cache)await O.save();if(r.generate404){let d=p.join(r.pagesDir,"404.stx");if(await Bun.file(d).exists()){let h=new Set,b={...s,minifyClient:!0,debug:!1,cache:!1},g=await i(await Bun.file(d).text(),{},d,b,h);await Bun.write(p.join(r.outputDir,"404.html"),g)}else await Bun.write(p.join(r.outputDir,"404.html"),`<!DOCTYPE html>
48
48
  <html lang="en">
49
49
  <head>
50
50
  <meta charset="UTF-8">
@@ -65,7 +65,7 @@ ${d}`)}if(r.cache)await O.save();if(r.generate404){let d=p.join(r.pagesDir,"404.
65
65
  <a href="/">Go home</a>
66
66
  </div>
67
67
  </body>
68
- </html>`)}for(let d of[500]){let m=p.join(r.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let b=new Set,g={...s,minifyClient:!0,debug:!1,cache:!1},M=await i(await Bun.file(m).text(),{},m,g,b);await Bun.write(p.join(r.outputDir,`${d}.html`),M)}}let K=p.join(r.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,m={...s,minifyClient:!0,debug:!1,cache:!1},b=await i(await Bun.file(K).text(),{},K,m,d);await Bun.write(p.join(r.outputDir,"error.html"),b)}if(r.sitemap&&U.length>0){let d=At(U,r.domain),m=p.join(r.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${U.length} URLs`)}if(r.robots!==!1){let d=typeof r.robots==="object"?r.robots:{},m=[...r.sitemapExclude.filter((g)=>typeof g==="string"),...d.disallow||[]],b=qs({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...m.length>0?{disallow:m}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",r.domain).href}:{}});await Bun.write(p.join(r.outputDir,"robots.txt"),b),console.log("Generated robots.txt")}if(r.rss){let d=typeof r.rss==="object"?r.rss:{title:"Site Feed",description:"Latest updates",link:r.domain},m=[];if(d.getItems)m=await d.getItems();let b=Mt(d,m),g=p.join(r.outputDir,"rss.xml");await Bun.write(g,b),u.rssPath=g,console.log(`Generated rss.xml with ${m.length} items`)}let W=$c(r.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=Rc(r.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(r.publicDir&&v.existsSync(r.publicDir))await Y(r.publicDir,r.outputDir),console.log(`Copied public assets from ${r.publicDir}`);let et=mr();if(et)await Y(et,p.join(r.outputDir,gr)),console.log(`Copied assets from ${fn}`)}catch(E){throw await r.hooks.onError?.(E),E}if(u.buildTime=Date.now()-n,y.size>0){u.islandChunks={count:y.size,totalBytes:P};let E={generatedChunks:y.size,totalBytes:P,chunks:k,pages:x};await Bun.write(p.join(r.outputDir,"_stx","islands-manifest.json"),JSON.stringify(E,null,2))}await r.hooks.onBuildEnd?.(u);let D=u.islandChunks?`
68
+ </html>`)}for(let d of[500]){let h=p.join(r.pagesDir,`${d}.stx`);if(await Bun.file(h).exists()){let b=new Set,g={...s,minifyClient:!0,debug:!1,cache:!1},M=await i(await Bun.file(h).text(),{},h,g,b);await Bun.write(p.join(r.outputDir,`${d}.html`),M)}}let K=p.join(r.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,h={...s,minifyClient:!0,debug:!1,cache:!1},b=await i(await Bun.file(K).text(),{},K,h,d);await Bun.write(p.join(r.outputDir,"error.html"),b)}if(r.sitemap&&U.length>0){let d=At(U,r.domain),h=p.join(r.outputDir,"sitemap.xml");await Bun.write(h,d),u.sitemapPath=h,console.log(`Generated sitemap.xml with ${U.length} URLs`)}if(r.robots!==!1){let d=typeof r.robots==="object"?r.robots:{},h=[...r.sitemapExclude.filter((g)=>typeof g==="string"),...d.disallow||[]],b=Xs({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...h.length>0?{disallow:h}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",r.domain).href}:{}});await Bun.write(p.join(r.outputDir,"robots.txt"),b),console.log("Generated robots.txt")}if(r.rss){let d=typeof r.rss==="object"?r.rss:{title:"Site Feed",description:"Latest updates",link:r.domain},h=[];if(d.getItems)h=await d.getItems();let b=Lt(d,h),g=p.join(r.outputDir,"rss.xml");await Bun.write(g,b),u.rssPath=g,console.log(`Generated rss.xml with ${h.length} items`)}let W=Ic(r.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=Oc(r.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(r.publicDir&&v.existsSync(r.publicDir))await Y(r.publicDir,r.outputDir),console.log(`Copied public assets from ${r.publicDir}`);let et=wr();if(et)await Y(et,p.join(r.outputDir,br)),console.log(`Copied assets from ${hn}`)}catch(E){throw await r.hooks.onError?.(E),E}if(u.buildTime=Date.now()-n,w.size>0){u.islandChunks={count:w.size,totalBytes:P};let E={generatedChunks:w.size,totalBytes:P,chunks:k,pages:x};await Bun.write(p.join(r.outputDir,"_stx","islands-manifest.json"),JSON.stringify(E,null,2))}await r.hooks.onBuildEnd?.(u);let D=u.islandChunks?`
69
69
  Island chunks: ${u.islandChunks.count} (${(u.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
70
70
  Build complete!
71
71
  Total: ${u.totalPages} pages
@@ -73,8 +73,8 @@ Build complete!
73
73
  Cached: ${u.cachedCount}
74
74
  Failed: ${u.failedCount}
75
75
  Time: ${u.buildTime}ms${D}
76
- `),u}async function Y(e,n){await v.promises.mkdir(n,{recursive:!0});let s=await v.promises.readdir(e,{withFileTypes:!0});for(let o of s){let c=p.join(e,o.name),r=p.join(n,o.name);if(o.isDirectory())await v.promises.mkdir(r,{recursive:!0}),await Y(c,r);else await v.promises.copyFile(c,r)}}function Gt(e={}){let n=e.cacheDir||l(process.cwd(),"ssg-cache"),s=new pt(n),o=e.revalidate||3600;return{async get(c){let r=await s.get(c);if(!r)return null;if(Date.now()>r.revalidateAfter)this.revalidate(c).catch(console.error);return{html:r.html,headers:{"Cache-Control":`public, max-age=${o}, stale-while-revalidate=${o*2}`,ETag:r.etag,"X-ISR-Generated":new Date(r.generatedAt).toISOString(),...r.headers}}},async revalidate(c){let u=re(".",{pagesDir:e.pagesDir||"pages"}).find((D)=>c.match(D.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let y=c.match(u.regex),P={};if(y)u.params.forEach((D,E)=>{P[D]=y[E+1]});let k=await a(),{html:x}=await ht(u,P,{},e,k);await s.set(c,{html:x,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:Tt(x)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Nt(){return{name:"markdown",extensions:[".md",".mdx"],async load(e){let n=await Bun.file(e).text(),s=n.match(/^---\n([\s\S]*?)\n---/),o={},c=n;if(s){let k=s[1];c=n.slice(s[0].length).trim();for(let x of k.split(`
77
- `)){let D=x.indexOf(":");if(D>0){let E=x.slice(0,D).trim(),w=x.slice(D+1).trim();if(w==="true")w=!0;else if(w==="false")w=!1;else if(/^\d+$/.test(w))w=parseInt(w,10);else if(/^\d+\.\d+$/.test(w))w=parseFloat(w);else if(w.startsWith("[")&&w.endsWith("]"))w=w.slice(1,-1).split(",").map((R)=>R.trim().replace(/^['"]|['"]$/g,""));o[E]=w}}}let r=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),u=[],y=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,P;while((P=y.exec(r))!==null){let k=parseInt(P[1],10),x=P[2],D=x.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:D,text:x,level:k})}return{content:r,data:o,toc:u}}}}function Wt(e){return Pt(e)}function qt(e,n){return`<!DOCTYPE html>
76
+ `),u}async function Y(e,n){await v.promises.mkdir(n,{recursive:!0});let s=await v.promises.readdir(e,{withFileTypes:!0});for(let o of s){let c=p.join(e,o.name),r=p.join(n,o.name);if(o.isDirectory())await v.promises.mkdir(r,{recursive:!0}),await Y(c,r);else await v.promises.copyFile(c,r)}}function _t(e={}){let n=e.cacheDir||l(process.cwd(),"ssg-cache"),s=new pt(n),o=e.revalidate||3600;return{async get(c){let r=await s.get(c);if(!r)return null;if(Date.now()>r.revalidateAfter)this.revalidate(c).catch(console.error);return{html:r.html,headers:{"Cache-Control":`public, max-age=${o}, stale-while-revalidate=${o*2}`,ETag:r.etag,"X-ISR-Generated":new Date(r.generatedAt).toISOString(),...r.headers}}},async revalidate(c){let u=oe(".",{pagesDir:e.pagesDir||"pages"}).find((D)=>c.match(D.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(u.regex),P={};if(w)u.params.forEach((D,E)=>{P[D]=w[E+1]});let k=await a(),{html:x}=await ht(u,P,{},e,k);await s.set(c,{html:x,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:Tt(x)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Gt(){return{name:"markdown",extensions:[".md",".mdx"],async load(e){let n=await Bun.file(e).text(),s=n.match(/^---\n([\s\S]*?)\n---/),o={},c=n;if(s){let k=s[1];c=n.slice(s[0].length).trim();for(let x of k.split(`
77
+ `)){let D=x.indexOf(":");if(D>0){let E=x.slice(0,D).trim(),m=x.slice(D+1).trim();if(m==="true")m=!0;else if(m==="false")m=!1;else if(/^\d+$/.test(m))m=parseInt(m,10);else if(/^\d+\.\d+$/.test(m))m=parseFloat(m);else if(m.startsWith("[")&&m.endsWith("]"))m=m.slice(1,-1).split(",").map((R)=>R.trim().replace(/^['"]|['"]$/g,""));o[E]=m}}}let r=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),u=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,P;while((P=w.exec(r))!==null){let k=parseInt(P[1],10),x=P[2],D=x.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:D,text:x,level:k})}return{content:r,data:o,toc:u}}}}function Nt(e){return It(e)}function Wt(e,n){return`<!DOCTYPE html>
78
78
  <html>
79
79
  <head>
80
80
  <meta charset="utf-8">
@@ -86,4 +86,4 @@ Build complete!
86
86
  <p>Redirecting to <a href="${e}">${e}</a>...</p>
87
87
  <script>window.location.replace('${e}')</script>
88
88
  </body>
89
- </html>`}function Jt(e,n){if(e==="/"||e==="")return p.join(n.outputDir,"index.html");let s=e.replace(/^\/|\/$/g,"");if(n.trailingSlash)return p.join(n.outputDir,s,"index.html");return p.join(n.outputDir,`${s}.html`)}var De={generateStaticSite:_t,createISRHandler:Gt,defineStaticPaths:J,createMarkdownLoader:Nt};export{Gt as createISRHandler,Nt as createMarkdownLoader,Ct as declaresPageAction,De as default,J as defineStaticPaths,_t as generateStaticSite,Ot as isExcludedFromSitemap};
89
+ </html>`}function qt(e,n){if(e==="/"||e==="")return p.join(n.outputDir,"index.html");let s=e.replace(/^\/|\/$/g,"");if(n.trailingSlash)return p.join(n.outputDir,s,"index.html");return p.join(n.outputDir,`${s}.html`)}var Pe={generateStaticSite:Mt,createISRHandler:_t,defineStaticPaths:J,createMarkdownLoader:Gt};export{_t as createISRHandler,Gt as createMarkdownLoader,Et as declaresPageAction,Pe as default,J as defineStaticPaths,Mt as generateStaticSite,Ot as isExcludedFromSitemap};
@@ -254,7 +254,7 @@ export declare interface AppHeadConfig {
254
254
  lang?: string
255
255
  meta?: Array<Record<string, string>>
256
256
  link?: Array<Record<string, string>>
257
- script?: Array<{ src?: string, content?: string, [key: string]: any }>
257
+ script?: Array<{ src?: string, content?: string, beforeRuntime?: boolean, [key: string]: any }>
258
258
  headRaw?: string
259
259
  htmlAttrs?: Record<string, string>
260
260
  bodyClass?: string
package/dist/utils.js CHANGED
@@ -32,6 +32,7 @@ import { validateClientScript } from "./script-validation.js";
32
32
  import { escapeScriptBody } from "./script-emit.js";
33
33
  import { literalValue, parsePropsDeclaration } from "./props-declaration.js";
34
34
  import { scriptAttributes, scriptContainsCode } from "./script-attributes.js";
35
+ import { normalizeVueSetupScripts } from "./vue-template.js";
35
36
  function renderExternalComponentScript(script, context, filePath) {
36
37
  const opening = /^<script\b([^>]*)>/i.exec(script);
37
38
  if (!opening || !/(?:^|\s)src\s*=/i.test(opening[1] ?? ""))
@@ -802,7 +803,7 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
802
803
  else
803
804
  try {
804
805
  const stamp = fileStamp(componentFilePath);
805
- componentContent = await Bun.file(componentFilePath).text();
806
+ componentContent = normalizeVueSetupScripts(await Bun.file(componentFilePath).text(), componentFilePath);
806
807
  componentsCache.set(componentFilePath, componentContent);
807
808
  componentStamps.set(componentFilePath, stamp);
808
809
  } catch (error) {
@@ -379,6 +379,8 @@ export async function extractVariables(scriptContent, context, filePath, options
379
379
  }, effect = (_fn) => {}, batch = (fn) => fn(), onMount = (_fn) => {}, onDestroy = (_fn) => {}, responseApi = responseBindings(context);
380
380
  function definePageMeta(meta) {
381
381
  const config = meta || {};
382
+ if (config.cache === !1)
383
+ context.__stx_skip_cache = !0;
382
384
  if (config.title !== void 0 || config.description !== void 0)
383
385
  useSeoMeta({ title: config.title, description: config.description });
384
386
  }
@@ -659,7 +661,10 @@ export function convertToCommonJS(scriptContent, filePath) {
659
661
  if (!done)
660
662
  i = lines.length;
661
663
  const callText = lines.slice(callStart, i).join(`
662
- `), lifted = [];
664
+ `);
665
+ if (/\bcache\s*:\s*false\s*[,}]/.test(callText))
666
+ convertedLines.push("definePageMeta({ cache: false });");
667
+ const lifted = [];
663
668
  for (const key of ["title", "description"]) {
664
669
  const match = new RegExp(`\\b${key}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(callText);
665
670
  if (match)
@@ -1,3 +1,5 @@
1
+ /** Resolve supported named Vue imports in .stx setup blocks through the STX client runtime. */
2
+ export declare function normalizeVueSetupScripts(template: string, filePath: string): string;
1
3
  /**
2
4
  * Check if template contains any Vue-style directives.
3
5
  * Quick check to avoid unnecessary processing.
@@ -1,3 +1,49 @@
1
+ import { scanHtmlScriptElements, scanHtmlTags } from "./html-masking.js";
2
+ import { isRuntimeOwnedColonAttr } from "./runtime-globals.js";
3
+ import { scriptAttributes, scriptContainsCode } from "./script-attributes.js";
4
+ import { stripCommentsAndLiterals } from "./strip-literals.js";
5
+ const vueSetupApis = new Set([
6
+ "computed",
7
+ "inject",
8
+ "nextTick",
9
+ "onBeforeMount",
10
+ "onBeforeUnmount",
11
+ "onMounted",
12
+ "onUnmounted",
13
+ "provide",
14
+ "reactive",
15
+ "ref",
16
+ "useSlots",
17
+ "watch",
18
+ "watchEffect"
19
+ ]);
20
+ export function normalizeVueSetupScripts(template, filePath) {
21
+ if (!filePath.endsWith(".stx") || !template.includes("vue") || !template.includes("setup"))
22
+ return template;
23
+ const declaration = /^([ \t]*import\s*\{)([^}]*)(\}\s*from\s*)(['"])vue\4/gm, specifier = /^([A-Za-z_$][\w$]*)(?:\s+as\s+[A-Za-z_$][\w$]*)?$/, parts = [];
24
+ let cursor = 0;
25
+ for (const block of scanHtmlScriptElements(template)) {
26
+ const attrs = scriptAttributes(block.attrs);
27
+ if (!attrs.has("setup") || attrs.has("server") || attrs.has("src") || !scriptContainsCode(attrs))
28
+ continue;
29
+ const source = template.slice(block.bodyStart, block.bodyEnd);
30
+ if (!source.includes("vue"))
31
+ continue;
32
+ const tokens = stripCommentsAndLiterals(source), result = source.replace(declaration, (statement, start, imports, from, quote, offset) => {
33
+ if (tokens.slice(offset, offset + start.length).trimStart().slice(0, 6) !== "import")
34
+ return statement;
35
+ return imports.split(",").filter((name) => name.trim()).every((name) => {
36
+ const exported = specifier.exec(name.trim())?.[1];
37
+ return exported !== void 0 && vueSetupApis.has(exported);
38
+ }) ? start + imports + from + quote + "stx" + quote : statement;
39
+ });
40
+ if (result === source)
41
+ continue;
42
+ parts.push(template.slice(cursor, block.bodyStart), result);
43
+ cursor = block.bodyEnd;
44
+ }
45
+ return parts.length ? parts.join("") + template.slice(cursor) : template;
46
+ }
1
47
  const VOID_ELEMENTS = new Set([
2
48
  "area",
3
49
  "base",
@@ -201,7 +247,31 @@ function replaceTagAttrs(html, parsed, newAttrs) {
201
247
  return html.slice(0, parsed.start) + newTag + html.slice(parsed.end);
202
248
  }
203
249
  export function hasVueTemplateSyntax(template) {
204
- return /\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(template);
250
+ return /\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(template) || sameNameBinding.test(template);
251
+ }
252
+ const sameNameBinding = /\s(?:v-bind)?:[a-zA-Z_][\w-]*(?=[\s/>])(?!\s*=)/;
253
+ function expandSameNameBindings(html) {
254
+ if (!sameNameBinding.test(html))
255
+ return html;
256
+ const attribute = /([^\s="'<>]+)(\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>]+))?/g, bindingName = /^(?:v-bind)?:([a-zA-Z_][\w-]*)$/, parts = [];
257
+ let cursor = 0;
258
+ for (const tag of scanHtmlTags(html)) {
259
+ if (tag.closing || !tag.attributes.includes(":"))
260
+ continue;
261
+ const attrs = tag.attributes.replace(attribute, (original, name, value) => {
262
+ const binding = value === void 0 ? bindingName.exec(name)?.[1] : void 0;
263
+ if (!binding || isRuntimeOwnedColonAttr(binding))
264
+ return original;
265
+ const expression = binding.replace(/-([a-zA-Z0-9])/g, (_, letter) => letter.toUpperCase());
266
+ return `:${binding}="${expression}"`;
267
+ });
268
+ if (attrs === tag.attributes)
269
+ continue;
270
+ const start = tag.start + tag.name.length + 1;
271
+ parts.push(html.slice(cursor, start), attrs);
272
+ cursor = start + tag.attributes.length;
273
+ }
274
+ return parts.length ? parts.join("") + html.slice(cursor) : html;
205
275
  }
206
276
  function transformVFor(html) {
207
277
  let result = html, searchFrom = 0;
@@ -437,7 +507,7 @@ function transformVSlot(html) {
437
507
  export function processVueTemplate(template) {
438
508
  if (!hasVueTemplateSyntax(template))
439
509
  return template;
440
- let result = template;
510
+ let result = expandSameNameBindings(template);
441
511
  result = transformVFor(result);
442
512
  result = transformVIfChain(result);
443
513
  result = transformVOnce(result);