@stacksjs/stx 0.2.876 → 0.2.881

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 (278) hide show
  1. package/dist/{chunk-h17pfbng.js → chunk-002zrse4.js} +2 -2
  2. package/dist/{chunk-fdjx4vs3.js → chunk-00tq7ghn.js} +2 -2
  3. package/dist/{chunk-nv4c25zj.js → chunk-02qmvcmv.js} +3 -3
  4. package/dist/chunk-08cb7cyw.js +2 -0
  5. package/dist/chunk-0h1dyd38.js +2 -0
  6. package/dist/chunk-1jk46ve0.js +2 -0
  7. package/dist/chunk-1z6rrqvm.js +2 -0
  8. package/dist/{chunk-w8k9fz1w.js → chunk-1zkymrw0.js} +7 -7
  9. package/dist/chunk-2cvwjtjh.js +16 -0
  10. package/dist/{chunk-k0t9ye9j.js → chunk-2gg3vjks.js} +126 -71
  11. package/dist/{chunk-1q5w3xav.js → chunk-2r0nrvqe.js} +2 -2
  12. package/dist/{chunk-3922g6sh.js → chunk-345waetq.js} +9 -9
  13. package/dist/{chunk-eknm4jrm.js → chunk-3sema2js.js} +2 -2
  14. package/dist/{chunk-cvbwxskc.js → chunk-45jpwbzd.js} +5 -5
  15. package/dist/{chunk-qnwd5bz4.js → chunk-463weehv.js} +1 -1
  16. package/dist/{chunk-wm029dh0.js → chunk-4fkcn6z5.js} +18 -12
  17. package/dist/chunk-4frh1qg5.js +2 -0
  18. package/dist/{chunk-976kgb3r.js → chunk-4n45qa0b.js} +9 -9
  19. package/dist/chunk-4pjqj54a.js +2 -0
  20. package/dist/{chunk-ft6em3wm.js → chunk-50cnypys.js} +6 -6
  21. package/dist/chunk-51qyxm0y.js +2 -0
  22. package/dist/chunk-53cc06w7.js +2 -0
  23. package/dist/{chunk-y2e2zm6y.js → chunk-57q4nvs9.js} +3 -3
  24. package/dist/{chunk-3mz9bdf7.js → chunk-59er0fc7.js} +3 -3
  25. package/dist/chunk-5hrx1p6g.js +2 -0
  26. package/dist/chunk-5mwzea5d.js +2 -0
  27. package/dist/chunk-5rd0an89.js +2 -0
  28. package/dist/{chunk-pk714ynv.js → chunk-69ezjc8k.js} +4 -4
  29. package/dist/{chunk-75v0yxeh.js → chunk-6c1vm6bs.js} +2 -2
  30. package/dist/{chunk-d3q0cg47.js → chunk-6df3j3qq.js} +3 -3
  31. package/dist/{chunk-kzc2tqzr.js → chunk-6t04tqvh.js} +2 -2
  32. package/dist/chunk-78zgmqhd.js +2 -0
  33. package/dist/chunk-7kqgp3p7.js +2 -0
  34. package/dist/{chunk-wzvdr4ta.js → chunk-7mcs59pr.js} +2 -2
  35. package/dist/chunk-86nsbxep.js +61 -0
  36. package/dist/{chunk-0g2mg8cw.js → chunk-8e1cv1hh.js} +3 -3
  37. package/dist/chunk-8h5nje66.js +2 -0
  38. package/dist/chunk-8nqyyj1h.js +33 -0
  39. package/dist/chunk-8qr3cmpb.js +2 -0
  40. package/dist/{chunk-ae8q4gze.js → chunk-8va3fs07.js} +5 -5
  41. package/dist/chunk-909tgpxp.js +2 -0
  42. package/dist/{chunk-xmws1gaf.js → chunk-94ctmp0j.js} +2 -2
  43. package/dist/chunk-95j7y1rt.js +2 -0
  44. package/dist/chunk-97kgrevs.js +4 -0
  45. package/dist/{chunk-mce3g2wb.js → chunk-9f31gs4m.js} +2 -2
  46. package/dist/chunk-9fvjr9dd.js +4 -0
  47. package/dist/chunk-9kza7gxd.js +2 -0
  48. package/dist/chunk-9yx7cbhz.js +25 -0
  49. package/dist/{chunk-nn6hvsxp.js → chunk-9zj3xztb.js} +2 -2
  50. package/dist/{chunk-b4d4tjvx.js → chunk-a0q0kb0s.js} +5 -5
  51. package/dist/chunk-a60ztvnp.js +3 -0
  52. package/dist/{chunk-s7fhpkvf.js → chunk-a7ryj8z8.js} +6 -6
  53. package/dist/{chunk-gqtb53s8.js → chunk-aaea157p.js} +2 -2
  54. package/dist/{chunk-wp0qpa50.js → chunk-agd2b928.js} +59 -27
  55. package/dist/chunk-aqxh80vh.js +2 -0
  56. package/dist/chunk-asv4b65m.js +12 -0
  57. package/dist/chunk-axra1yas.js +2 -0
  58. package/dist/chunk-bhc25n2n.js +2 -0
  59. package/dist/chunk-brp8np3t.js +2 -0
  60. package/dist/{chunk-r2bxjna3.js → chunk-c0g30cjs.js} +2 -2
  61. package/dist/{chunk-jt5tzddc.js → chunk-c73c0wf9.js} +2 -2
  62. package/dist/{chunk-bjjfr7qt.js → chunk-care745q.js} +2 -2
  63. package/dist/chunk-cv1vm1w0.js +2 -0
  64. package/dist/{chunk-mw0rb1sf.js → chunk-czcx3nbx.js} +6 -6
  65. package/dist/{chunk-vnkvnenn.js → chunk-czzehcxs.js} +7 -7
  66. package/dist/chunk-d7b30bg6.js +2 -0
  67. package/dist/{chunk-cj44e8mw.js → chunk-d8qt6hjg.js} +5 -5
  68. package/dist/chunk-dfbbkjz6.js +3 -0
  69. package/dist/chunk-dv0cpmat.js +2 -0
  70. package/dist/{chunk-stn7p7f1.js → chunk-dwyhpbpx.js} +2 -2
  71. package/dist/chunk-dze7f9vv.js +2 -0
  72. package/dist/{chunk-y75bds1g.js → chunk-e362e615.js} +30 -30
  73. package/dist/{chunk-ydppkb8y.js → chunk-e41pgmgk.js} +2 -2
  74. package/dist/chunk-ekdhjm8p.js +54 -0
  75. package/dist/chunk-etavf6mr.js +2 -0
  76. package/dist/{chunk-jqxerj6k.js → chunk-ezna4dhj.js} +2 -2
  77. package/dist/chunk-f3j1h3ch.js +2 -0
  78. package/dist/chunk-f6ac0gbe.js +2 -0
  79. package/dist/chunk-fwhr3jda.js +2 -0
  80. package/dist/chunk-fxhgj8tp.js +2 -0
  81. package/dist/chunk-fz4c5e9m.js +2 -0
  82. package/dist/{chunk-esjr9qhe.js → chunk-g2xy0z0e.js} +2 -2
  83. package/dist/chunk-g5q0wgzk.js +2 -0
  84. package/dist/{chunk-j0rqa9bk.js → chunk-gad3ebgr.js} +5 -5
  85. package/dist/{chunk-kywe0f1v.js → chunk-gbncp2gp.js} +2 -2
  86. package/dist/{chunk-df6vjs3p.js → chunk-gmbw1xhm.js} +5 -5
  87. package/dist/chunk-gmp10259.js +2 -0
  88. package/dist/chunk-gs6geqeg.js +2 -0
  89. package/dist/chunk-h26mpqrh.js +2 -0
  90. package/dist/{chunk-0sa9gqmc.js → chunk-h2tq6cbr.js} +11 -11
  91. package/dist/chunk-h3fv0q25.js +2 -0
  92. package/dist/{chunk-r09kz9bf.js → chunk-h63ma36g.js} +2 -2
  93. package/dist/{chunk-g15reb1h.js → chunk-hnxwqamj.js} +8 -8
  94. package/dist/{chunk-3w7gacva.js → chunk-hxhmhw23.js} +3 -3
  95. package/dist/{chunk-6kp4mg3h.js → chunk-jc74097x.js} +2 -2
  96. package/dist/chunk-jghpzx5m.js +2 -0
  97. package/dist/{chunk-fh72k2ks.js → chunk-jqvc2wbz.js} +6 -6
  98. package/dist/chunk-k52126rh.js +2 -0
  99. package/dist/chunk-k7ffxfgp.js +3 -0
  100. package/dist/{chunk-f4vgagjb.js → chunk-kee5a3ce.js} +3 -3
  101. package/dist/chunk-kyh32kma.js +20 -0
  102. package/dist/{chunk-2tcyfrvb.js → chunk-m91jj8nq.js} +2 -2
  103. package/dist/chunk-my3yv4sg.js +2 -0
  104. package/dist/chunk-nb6erf75.js +9 -0
  105. package/dist/chunk-ndqq991c.js +26 -0
  106. package/dist/chunk-ngzyzcrp.js +2 -0
  107. package/dist/chunk-nj1ssjtd.js +2 -0
  108. package/dist/chunk-njza56wn.js +1198 -0
  109. package/dist/{chunk-ttjscvre.js → chunk-nnynrb97.js} +3 -3
  110. package/dist/chunk-p6hcrg3r.js +3 -0
  111. package/dist/chunk-pa2vt2ej.js +2 -0
  112. package/dist/chunk-pa6kgbmw.js +2 -0
  113. package/dist/{chunk-saqzk45g.js → chunk-pdprhg5k.js} +1 -1
  114. package/dist/chunk-pjjrx9pk.js +2 -0
  115. package/dist/{chunk-mkwavsb3.js → chunk-pm27mcfp.js} +3 -3
  116. package/dist/chunk-pstbfz5g.js +2 -0
  117. package/dist/chunk-pt3rp3zg.js +2 -0
  118. package/dist/chunk-pw9qqcw3.js +2 -0
  119. package/dist/chunk-q1jjgg4w.js +2 -0
  120. package/dist/{chunk-4517hny7.js → chunk-q1mb0fbt.js} +2 -2
  121. package/dist/{chunk-k1ew643q.js → chunk-q74affc4.js} +2 -2
  122. package/dist/chunk-qg1kw5yf.js +2 -0
  123. package/dist/chunk-r32ddrvn.js +21 -0
  124. package/dist/{chunk-rzd9hyhv.js → chunk-ram5944w.js} +2 -2
  125. package/dist/{chunk-p5m1z6e1.js → chunk-rcxer2km.js} +4 -4
  126. package/dist/{chunk-x2ftkaz3.js → chunk-rsxxajv6.js} +2 -2
  127. package/dist/chunk-rw5sxr5a.js +2 -0
  128. package/dist/chunk-s29hp1qw.js +14 -0
  129. package/dist/chunk-s7xywsqd.js +3 -0
  130. package/dist/{chunk-d6gqh2wv.js → chunk-satrf398.js} +1 -1
  131. package/dist/{chunk-zn6n075d.js → chunk-shcnt6aa.js} +3 -3
  132. package/dist/{chunk-zgds9nwv.js → chunk-smkerejj.js} +44 -44
  133. package/dist/{chunk-ysfgabpf.js → chunk-sn4ndpd7.js} +3 -3
  134. package/dist/{chunk-7rep2jqh.js → chunk-sq6werer.js} +23 -23
  135. package/dist/{chunk-zc8a2erc.js → chunk-ssg6ne5b.js} +4 -4
  136. package/dist/{chunk-afxfkb60.js → chunk-sv7fdqmc.js} +6 -6
  137. package/dist/chunk-t8r40wgf.js +2 -0
  138. package/dist/{chunk-dbvsa5ya.js → chunk-t94y8g35.js} +2 -2
  139. package/dist/{chunk-xtaq95em.js → chunk-v1s838fe.js} +1 -1
  140. package/dist/chunk-v5cah9pt.js +2 -0
  141. package/dist/chunk-v8ea76j6.js +2 -0
  142. package/dist/chunk-vxw92h3q.js +2 -0
  143. package/dist/{chunk-ctjxcaxq.js → chunk-w53p65hy.js} +66 -66
  144. package/dist/chunk-w5zzwe2f.js +2 -0
  145. package/dist/chunk-wbmx0rge.js +2 -0
  146. package/dist/chunk-wfthd3n5.js +2 -0
  147. package/dist/chunk-wjafpvjv.js +2 -0
  148. package/dist/chunk-ws2h92mm.js +3 -0
  149. package/dist/chunk-xf6snj8e.js +38 -0
  150. package/dist/chunk-xfhxfcvk.js +2 -0
  151. package/dist/chunk-xhr35ctb.js +2 -0
  152. package/dist/chunk-xmmr0916.js +2 -0
  153. package/dist/{chunk-yxdhz4ps.js → chunk-xpbakn6t.js} +2 -2
  154. package/dist/{chunk-v0tdg16k.js → chunk-ybjgnnyf.js} +5 -5
  155. package/dist/{chunk-x4jzhgdm.js → chunk-yffqfgjx.js} +2 -2
  156. package/dist/chunk-yh2hnt3m.js +12 -0
  157. package/dist/{chunk-2mt2zc5y.js → chunk-ym0cdk7m.js} +10 -10
  158. package/dist/{chunk-w6pzkcjp.js → chunk-ymqm898x.js} +2 -2
  159. package/dist/{chunk-2zaatnnh.js → chunk-yp4tn4zn.js} +4 -4
  160. package/dist/{chunk-fwbccyhw.js → chunk-ypsf5y5g.js} +2 -2
  161. package/dist/chunk-z7k1xn6k.js +2 -0
  162. package/dist/{chunk-nnp6rf4c.js → chunk-zch65qrd.js} +1 -1
  163. package/dist/{chunk-pbakxcv8.js → chunk-zek9t5za.js} +2 -2
  164. package/dist/cli.js +23 -23
  165. package/dist/client/signals-dom-ready-runtime.js +6 -0
  166. package/dist/client/signals-mount-runtime.js +1 -1
  167. package/dist/client-module-registry.js +10 -4
  168. package/dist/client-parameter-bindings.d.ts +5 -0
  169. package/dist/client-parameter-bindings.js +47 -6
  170. package/dist/client-script-bundler.js +4 -3
  171. package/dist/component-library.d.ts +1 -0
  172. package/dist/component-library.js +42 -14
  173. package/dist/composable-loader.js +19 -9
  174. package/dist/craft-entry.js +2 -2
  175. package/dist/craft.js +2 -2
  176. package/dist/dev-server/ts-css.js +3 -3
  177. package/dist/html-masking.d.ts +2 -0
  178. package/dist/html-masking.js +10 -0
  179. package/dist/inherited-context.d.ts +1 -1
  180. package/dist/inherited-context.js +43 -14
  181. package/dist/module-syntax.d.ts +2 -0
  182. package/dist/module-syntax.js +21 -0
  183. package/dist/native-component-context.js +42 -16
  184. package/dist/page-module-order.d.ts +10 -0
  185. package/dist/page-module-order.js +139 -0
  186. package/dist/process.js +6 -4
  187. package/dist/pwa.js +3 -3
  188. package/dist/script-attributes.d.ts +4 -0
  189. package/dist/script-attributes.js +10 -0
  190. package/dist/ssg.js +39 -39
  191. package/dist/strip-literals.d.ts +2 -0
  192. package/dist/strip-literals.js +12 -6
  193. package/dist/stx-virtual-ts.d.ts +1 -0
  194. package/dist/stx-virtual-ts.js +21 -27
  195. package/dist/typecheck.js +8 -0
  196. package/package.json +5 -5
  197. package/dist/chunk-027meh1k.js +0 -2
  198. package/dist/chunk-0hs633pt.js +0 -2
  199. package/dist/chunk-0j8zre1m.js +0 -2
  200. package/dist/chunk-0v02qms8.js +0 -2
  201. package/dist/chunk-0z9gttw0.js +0 -2
  202. package/dist/chunk-11dwmcpy.js +0 -3
  203. package/dist/chunk-1a237qky.js +0 -33
  204. package/dist/chunk-1ehjzhnc.js +0 -25
  205. package/dist/chunk-1gfg6qmr.js +0 -2
  206. package/dist/chunk-1kgnk6ds.js +0 -2
  207. package/dist/chunk-1ztp5vkh.js +0 -3
  208. package/dist/chunk-32wvc376.js +0 -2
  209. package/dist/chunk-3k2d2jsn.js +0 -2
  210. package/dist/chunk-3te2y9qf.js +0 -2
  211. package/dist/chunk-40330tm5.js +0 -2
  212. package/dist/chunk-447jc6zc.js +0 -2
  213. package/dist/chunk-4dk6k0ad.js +0 -2
  214. package/dist/chunk-4e48zkq0.js +0 -2
  215. package/dist/chunk-5ep7p8te.js +0 -2
  216. package/dist/chunk-5gx403te.js +0 -1184
  217. package/dist/chunk-6q9a5bph.js +0 -2
  218. package/dist/chunk-7ds9mx4c.js +0 -2
  219. package/dist/chunk-7njy024g.js +0 -2
  220. package/dist/chunk-7tjewwmd.js +0 -2
  221. package/dist/chunk-85xabvtj.js +0 -2
  222. package/dist/chunk-880f8j99.js +0 -2
  223. package/dist/chunk-8f3dbthj.js +0 -2
  224. package/dist/chunk-99e3mxnn.js +0 -20
  225. package/dist/chunk-9gv847nn.js +0 -2
  226. package/dist/chunk-9mz2n39m.js +0 -2
  227. package/dist/chunk-akthsg33.js +0 -54
  228. package/dist/chunk-b1tcym2x.js +0 -2
  229. package/dist/chunk-bdh73gxd.js +0 -4
  230. package/dist/chunk-bspj1rf1.js +0 -2
  231. package/dist/chunk-bx3hpsxn.js +0 -2
  232. package/dist/chunk-byq488g4.js +0 -2
  233. package/dist/chunk-c4s25bm2.js +0 -2
  234. package/dist/chunk-csjqtzwc.js +0 -2
  235. package/dist/chunk-df78j74w.js +0 -4
  236. package/dist/chunk-dgs3d367.js +0 -2
  237. package/dist/chunk-dmf6zcf4.js +0 -2
  238. package/dist/chunk-dv56x3g8.js +0 -16
  239. package/dist/chunk-e2b2f502.js +0 -2
  240. package/dist/chunk-ec6mrad6.js +0 -2
  241. package/dist/chunk-eecctzgp.js +0 -17
  242. package/dist/chunk-fa57bncd.js +0 -2
  243. package/dist/chunk-g4eheg0t.js +0 -24
  244. package/dist/chunk-gfe1jrw9.js +0 -2
  245. package/dist/chunk-gn16yq49.js +0 -2
  246. package/dist/chunk-gvs61tqn.js +0 -2
  247. package/dist/chunk-h2928108.js +0 -2
  248. package/dist/chunk-hat353vx.js +0 -2
  249. package/dist/chunk-jmjgj3nh.js +0 -2
  250. package/dist/chunk-jqtpzzz4.js +0 -12
  251. package/dist/chunk-jvy7z3hz.js +0 -3
  252. package/dist/chunk-k9dne5by.js +0 -12
  253. package/dist/chunk-kq8mffgf.js +0 -2
  254. package/dist/chunk-kx06jzdw.js +0 -2
  255. package/dist/chunk-n5pvdrkb.js +0 -2
  256. package/dist/chunk-ne8q191s.js +0 -2
  257. package/dist/chunk-np8wgbsa.js +0 -3
  258. package/dist/chunk-nthw4dca.js +0 -2
  259. package/dist/chunk-pp99rmjm.js +0 -72
  260. package/dist/chunk-pqmjeea6.js +0 -2
  261. package/dist/chunk-qggwr60r.js +0 -2
  262. package/dist/chunk-qm3v4qb7.js +0 -2
  263. package/dist/chunk-qty0t69x.js +0 -2
  264. package/dist/chunk-rjv6885r.js +0 -2
  265. package/dist/chunk-rm5gbthk.js +0 -2
  266. package/dist/chunk-sgengtap.js +0 -2
  267. package/dist/chunk-snz2cxqv.js +0 -2
  268. package/dist/chunk-szp7ajfm.js +0 -33
  269. package/dist/chunk-ts37jw3s.js +0 -2
  270. package/dist/chunk-v4emesnw.js +0 -2
  271. package/dist/chunk-vnrbjbrw.js +0 -3
  272. package/dist/chunk-vxra53wq.js +0 -2
  273. package/dist/chunk-x76qvq1n.js +0 -2
  274. package/dist/chunk-x85z6dmw.js +0 -2
  275. package/dist/chunk-xkfe03y9.js +0 -2
  276. package/dist/chunk-y4hn1qh0.js +0 -2
  277. package/dist/chunk-yc8ggeh2.js +0 -2
  278. package/dist/chunk-yfed67yc.js +0 -2
@@ -0,0 +1,139 @@
1
+ import { scanHtmlTags } from "./html-masking.js";
2
+ import { scriptAttributes } from "./script-attributes.js";
3
+ import { requiresAsyncBody } from "./module-syntax.js";
4
+ import { stripBindingLiterals } from "./strip-literals.js";
5
+ export function usesImportMeta(code) {
6
+ return /\bimport\s*\.\s*meta\b/.test(stripBindingLiterals(code));
7
+ }
8
+ function pageScripts(html) {
9
+ const tags = scanHtmlTags(html), scripts = [];
10
+ let templateDepth = 0;
11
+ for (let index = 0;index < tags.length; index++) {
12
+ const tag = tags[index], name = tag.name.toLowerCase();
13
+ if (name === "template")
14
+ templateDepth += tag.closing ? -1 : 1;
15
+ if (name !== "script" || tag.closing)
16
+ continue;
17
+ const close = tags[index + 1];
18
+ if (close?.name.toLowerCase() !== "script" || !close.closing)
19
+ continue;
20
+ scripts.push({ start: tag.start, end: close.end, attrs: tag.attributes, body: html.slice(tag.end, close.start), inert: templateDepth > 0 });
21
+ }
22
+ return scripts;
23
+ }
24
+ function renderAttributes(attrs) {
25
+ return [...attrs].map(([name, value]) => value === !0 ? name : `${name}="${value.replace(/"/g, "&quot;")}"`).join(" ");
26
+ }
27
+ export function orderPageModules(html) {
28
+ const scripts = pageScripts(html);
29
+ if (scripts.some((script) => scriptAttributes(script.attrs).has("data-stx-module-bootstrap")))
30
+ return html;
31
+ const needsModule = (body) => {
32
+ if (usesImportMeta(body))
33
+ return !0;
34
+ try {
35
+ return requiresAsyncBody(body);
36
+ } catch {
37
+ return !1;
38
+ }
39
+ };
40
+ if (!scripts.some((script) => needsModule(script.body) || scriptAttributes(script.attrs).get("type") === "module"))
41
+ return html;
42
+ const batch = new Bun.CryptoHasher("md5").update(html).digest("hex").slice(0, 16);
43
+ let result = "", cursor = 0, started = !1, index = 0;
44
+ for (const script of scripts) {
45
+ const attrs = scriptAttributes(script.attrs), type = attrs.get("type");
46
+ if (script.inert || attrs.has("data-stx-module-job") || attrs.has("data-stx-runtime") || attrs.has("data-stx-router"))
47
+ continue;
48
+ if (typeof type === "string" && !["module", "text/javascript", "application/javascript"].includes(type.toLowerCase()))
49
+ continue;
50
+ if (![...attrs.keys()].some((name) => /^data-stx-(?:scoped|modules|stores|(?:framework-)?composables)$/.test(name)))
51
+ continue;
52
+ const module = type === "module" || needsModule(script.body);
53
+ if (module)
54
+ started = !0;
55
+ if (!started)
56
+ continue;
57
+ if (!module && (attrs.has("data-stx-owner") || attrs.has("data-stx-instance")))
58
+ continue;
59
+ result += html.slice(cursor, script.start);
60
+ let body = script.body;
61
+ const src = attrs.get("src");
62
+ if (typeof src === "string") {
63
+ attrs.delete("src");
64
+ attrs.set("data-stx-source-url", src);
65
+ body = `${module ? "await" : "return"} new Promise(function(resolve,reject){
66
+ var source=globalThis.__stxExecutingScript,script=document.createElement('script');
67
+ for(var attr of source.attributes)if(!['type','src','data-stx-module-job'].includes(attr.name))script.setAttribute(attr.name,attr.value);
68
+ ${module ? "script.type='module';" : ""}
69
+ if(source.nonce)script.nonce=source.nonce;
70
+ script.src=new URL(source.getAttribute('data-stx-source-url'),document.baseURI).href;
71
+ script.onload=function(){${module ? "" : "globalThis.__stxExecutingScript=__stxPreviousScript;"}resolve();};
72
+ script.onerror=function(error){${module ? "" : "globalThis.__stxExecutingScript=__stxPreviousScript;"}reject(error);};
73
+ source.parentNode.insertBefore(script,source);
74
+ });`;
75
+ }
76
+ if (module) {
77
+ const job = `${batch}-${index++}`, key = JSON.stringify(job), bootstrapAttrs = new Map(attrs);
78
+ bootstrapAttrs.delete("type");
79
+ bootstrapAttrs.delete("async");
80
+ bootstrapAttrs.delete("defer");
81
+ bootstrapAttrs.set("data-stx-module-bootstrap", !0);
82
+ result += `<script ${renderAttributes(bootstrapAttrs)}>
83
+ ;(function(){
84
+ var resolve,reject,previous=globalThis.__stxPageModulesReady||Promise.resolve();
85
+ var ready=new Promise(function(ok,fail){resolve=ok;reject=fail;});
86
+ var job={previous:previous,resolve:resolve,reject:reject};
87
+ (globalThis.__stxModuleJobs||(globalThis.__stxModuleJobs={}))[${key}]=job;
88
+ job.fail=function(event){
89
+ var script=document.querySelector('script[data-stx-module-job="${job}"]');
90
+ if((event.target&&event.target===script)||(event.filename&&event.filename===(script&&script.src||document.URL))){
91
+ window.removeEventListener('error',job.fail,true);
92
+ if(globalThis.__stxExecutingScript===job.script)globalThis.__stxExecutingScript=job.previousScript;
93
+ reject(event.error||new Error(event.message||'Page module failed to load'));
94
+ delete globalThis.__stxModuleJobs[${key}];
95
+ }
96
+ };
97
+ window.addEventListener('error',job.fail,true);
98
+ globalThis.__stxPageModulesReady=ready;
99
+ ready.catch(function(error){console.error('[stx] page module failed',error);});
100
+ })();
101
+ </script>`;
102
+ attrs.set("type", "module");
103
+ attrs.delete("async");
104
+ attrs.delete("defer");
105
+ attrs.set("data-stx-module-job", job);
106
+ result += `<script ${renderAttributes(attrs)}>
107
+ await globalThis.__stxModuleJobs[${key}].previous;
108
+ globalThis.__stxModuleJobs[${key}].previousScript=globalThis.__stxExecutingScript;
109
+ globalThis.__stxModuleJobs[${key}].script=document.querySelector('script[data-stx-module-job="${job}"]');
110
+ globalThis.__stxExecutingScript=globalThis.__stxModuleJobs[${key}].script;
111
+ ${body}
112
+ globalThis.__stxExecutingScript=globalThis.__stxModuleJobs[${key}].previousScript;
113
+ window.removeEventListener('error',globalThis.__stxModuleJobs[${key}].fail,true);
114
+ globalThis.__stxModuleJobs[${key}].resolve();
115
+ delete globalThis.__stxModuleJobs[${key}];
116
+ </script>`;
117
+ } else
118
+ result += `<script ${renderAttributes(attrs)}>
119
+ ;(function(__stxSource){
120
+ globalThis.__stxPageModulesReady=(globalThis.__stxPageModulesReady||Promise.resolve()).then(function(){
121
+ var __stxPreviousScript=globalThis.__stxExecutingScript;
122
+ globalThis.__stxExecutingScript=__stxSource;
123
+ ${typeof src === "string" ? body : `var __stxLive=document.createElement('script');
124
+ for(var __stxAttr of __stxSource.attributes)if(!['src','type'].includes(__stxAttr.name))__stxLive.setAttribute(__stxAttr.name,__stxAttr.value);
125
+ if(__stxSource.nonce)__stxLive.nonce=__stxSource.nonce;
126
+ __stxLive.textContent=${JSON.stringify(body).replace(/<\/script/gi, "<\\/script")};
127
+ var __stxFailure;
128
+ function __stxCapture(event){__stxFailure=event.error||new Error(event.message);}
129
+ window.addEventListener('error',__stxCapture);
130
+ try { __stxSource.parentNode.replaceChild(__stxLive,__stxSource); }
131
+ finally { window.removeEventListener('error',__stxCapture); globalThis.__stxExecutingScript=__stxPreviousScript; }
132
+ if(__stxFailure)throw __stxFailure;`}
133
+ });
134
+ })(document.currentScript);
135
+ </script>`;
136
+ cursor = script.end;
137
+ }
138
+ return result + html.slice(cursor);
139
+ }
package/dist/process.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { requiresAsyncBody } from "./module-syntax.js";
2
+ import { orderPageModules, usesImportMeta } from "./page-module-order.js";
1
3
  import { bodyCloseIndex, headCloseIndex, insertBeforeHeadClose } from "./document-tags.js";
2
4
  import fs from "node:fs";
3
5
  import path from "node:path";
@@ -223,7 +225,7 @@ function findScriptBlockByAttribute(html, attribute) {
223
225
  }
224
226
  const EXTERNAL_BUNDLE_MIN_BYTES = 4096;
225
227
  async function externalBundleTag(attrs, code, options) {
226
- if (options.buildMode !== "serve" || code.length < EXTERNAL_BUNDLE_MIN_BYTES)
228
+ if (usesImportMeta(code) || requiresAsyncBody(code) || options.buildMode !== "serve" || code.length < EXTERNAL_BUNDLE_MIN_BYTES)
227
229
  return null;
228
230
  const { registerServeModuleBundle } = await import("./caching.js");
229
231
  return `<script ${attrs} src="${registerServeModuleBundle(code)}"></script>`;
@@ -242,7 +244,7 @@ export async function buildModulesTag(sources, options, dependencies, built) {
242
244
  }
243
245
  if (!code)
244
246
  return null;
245
- if (options.buildMode === "serve") {
247
+ if (options.buildMode === "serve" && !usesImportMeta(code) && !requiresAsyncBody(code)) {
246
248
  const { registerServeModuleBundle } = await import("./caching.js");
247
249
  return `<script data-stx-scoped data-stx-run="always" data-stx-modules src="${registerServeModuleBundle(code)}"></script>`;
248
250
  }
@@ -295,7 +297,7 @@ async function buildPageBundles(result, options, dependencies, context) {
295
297
  const { getComposableScript } = await importOnce("stx/composable-loader", () => import("./composable-loader.js")), resolvedComposablesDir = options.composablesDir, pending = [built.modulesCode ?? built.modulesTag, storeScan, built.frameworkScript].filter((text) => text !== null), composableCode = await getComposableScript(options._layerComposableDirs ?? resolvedComposablesDir, result, pending, composableInputs);
296
298
  if (composableCode) {
297
299
  built.composableCode = composableCode;
298
- built.composableTag = await externalBundleTag('data-stx-scoped data-stx-run="always" data-stx-composables', composableCode, options) ?? `<script data-stx-scoped data-stx-run="always" data-stx-composables>${composableCode}</script>`;
300
+ built.composableTag = await externalBundleTag('data-stx-scoped data-stx-run="always" data-stx-composables', composableCode, options) ?? `<script data-stx-scoped data-stx-run="always" data-stx-composables>${composableCode.replace(/<\/script/gi, "<\\/script")}</script>`;
299
301
  }
300
302
  } catch {}
301
303
  if (everyStore || !storeLoader)
@@ -495,7 +497,7 @@ ${tag}`).join(""));
495
497
  result = result.slice(0, at) + dataTag + result.slice(at);
496
498
  }
497
499
  }
498
- return result;
500
+ return isTopLevel ? orderPageModules(result) : result;
499
501
  });
500
502
  } catch (error) {
501
503
  if (error instanceof StxValidationError)
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{uo,Gt,Bl,qg}from"./chunk-pk714ynv.js";import{lo,Ki,Vg,Ug,Wg}from"./chunk-ft6em3wm.js";import{Ml,Ll,jl,zg,Hg}from"./chunk-ydppkb8y.js";import{Je,Dn,Gi}from"./chunk-nv4c25zj.js";import{Kg,Gg,Xg,Jg,po,Ny}from"./chunk-stn7p7f1.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-vxra53wq.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{bo,en,Xl,tm}from"./chunk-69ezjc8k.js";import{yo,ta,Zg,Qg,em}from"./chunk-50cnypys.js";import{ql,Kl,Gl,Jg,Yg}from"./chunk-e41pgmgk.js";import{tt,Fn,na}from"./chunk-02qmvcmv.js";import{nm,rm,sm,om,wo,Vy}from"./chunk-dwyhpbpx.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-8qr3cmpb.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=Je(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=uo(n,t);if(a){let s=Gt(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 Ki(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,Ll as auditBuildOutput,Ml as auditConfig,re as buildPwaAssets,jl as calculateAuditResult,Hg as formatAuditResult,Gi as formatSize,j as generateManifest,_ as generateManifestJson,Ug as generateManifestLink,F as generateOfflinePage,Je as generatePrecacheManifest,Dn as generatePrecacheManifestJs,M as generatePwaIcons,lo as generatePwaTags,uo as generateServiceWorker,qg as generateServiceWorkerAuto,Vg as generateSwRegistrationScript,Wg as generateThemeColorMeta,N as getExpectedIconPaths,Gt as getServiceWorkerFileName,Ki as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Bl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,po as pwaDirectives,Kg as pwaInstallDirective,Xg as pwaOfflineDirective,Jg as pwaPushDirective,Gg as pwaUpdateDirective,Ny as registerPwaDirectives,zg 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=tt(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=bo(n,t);if(a){let s=en(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 ta(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,Kl as auditBuildOutput,ql as auditConfig,re as buildPwaAssets,Gl as calculateAuditResult,Yg as formatAuditResult,na as formatSize,j as generateManifest,_ as generateManifestJson,Qg as generateManifestLink,F as generateOfflinePage,tt as generatePrecacheManifest,Fn as generatePrecacheManifestJs,M as generatePwaIcons,yo as generatePwaTags,bo as generateServiceWorker,tm as generateServiceWorkerAuto,Zg as generateSwRegistrationScript,em as generateThemeColorMeta,N as getExpectedIconPaths,en as getServiceWorkerFileName,ta as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Xl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,wo as pwaDirectives,nm as pwaInstallDirective,sm as pwaOfflineDirective,om as pwaPushDirective,rm as pwaUpdateDirective,Vy as registerPwaDirectives,Jg as runPwaAudit,D as validateManifest};
@@ -0,0 +1,4 @@
1
+ /** Script mode is an attribute name, never a word inside an attribute value. */
2
+ export declare function scriptAttributes(source: string): Map<string, string | true>;
3
+ /** Authored JavaScript/TypeScript bodies, excluding data and template script types. */
4
+ export declare function scriptContainsCode(attributes: ReadonlyMap<string, string | true>): boolean;
@@ -0,0 +1,10 @@
1
+ export function scriptAttributes(source) {
2
+ const attributes = new Map;
3
+ for (const match of source.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))
4
+ attributes.set(match[1].toLowerCase(), match[2] ?? match[3] ?? match[4] ?? !0);
5
+ return attributes;
6
+ }
7
+ export function scriptContainsCode(attributes) {
8
+ const type = attributes.get("type");
9
+ return typeof type !== "string" || !type.trim() || /^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(type.trim());
10
+ }
package/dist/ssg.js CHANGED
@@ -1,50 +1,50 @@
1
1
  // @bun
2
- import"./chunk-mce3g2wb.js";import{k,vl}from"./chunk-pp99rmjm.js";import"./chunk-fdjx4vs3.js";import"./chunk-3w7gacva.js";import{Dt,w}from"./chunk-5gx403te.js";import"./chunk-kzc2tqzr.js";import"./chunk-x4jzhgdm.js";import"./chunk-r09kz9bf.js";import{Rt,At,Pt,It,Ot,Nt}from"./chunk-wp0qpa50.js";import{a}from"./chunk-ctjxcaxq.js";import{Ns}from"./chunk-0sa9gqmc.js";import"./chunk-zc8a2erc.js";import"./chunk-cvbwxskc.js";import{ke,cn,ln}from"./chunk-99e3mxnn.js";import"./chunk-6kp4mg3h.js";import{x}from"./chunk-dv56x3g8.js";import{kt,i}from"./chunk-k0t9ye9j.js";import"./chunk-3922g6sh.js";import"./chunk-akthsg33.js";import{xs}from"./chunk-2mt2zc5y.js";import"./chunk-1ehjzhnc.js";import"./chunk-r2bxjna3.js";import{pc,fc,gc}from"./chunk-3mz9bdf7.js";import{on,or,ir}from"./chunk-vnrbjbrw.js";import{an}from"./chunk-nn6hvsxp.js";import"./chunk-11dwmcpy.js";import"./chunk-dbvsa5ya.js";import{Q,Ee}from"./chunk-w8k9fz1w.js";import"./chunk-xtaq95em.js";import"./chunk-ttjscvre.js";import{l}from"./chunk-np8wgbsa.js";import{n,se}from"./chunk-jqtpzzz4.js";import{f}from"./chunk-yxdhz4ps.js";import R from"fs";import m from"path";import{createHash as vt}from"crypto";function $t(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Et=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ct(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,o=t.replace(Et,(e,u,g,v)=>{let S=v.trim();if(!S)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)S=$t(S);let p=Ct(S);if(!s.has(p))s.set(p,S);let P=r.integrity?` data-stx-integrity="sha384-${vt("sha384").update(S).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(s,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=new Set(["visible","idle"]);function lt(t){if(!t.includes("data-stx-src="))return t;let r=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=s.exec(t))!==null)r.set(o[1],o[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(r.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=w(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let S=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!S)return t;return t.slice(0,v)+S+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let r=t.trim();if(!r)return null;let s=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let r of jt){let s=t[r];if(!s)continue;let o=X(s);if(o)return{url:o,source:"env",via:r}}return null}function ut(t){if(!t||typeof t!=="object")return null;let r=t,s=r.site?.url??r.url??r.app?.url;return typeof s==="string"?X(s):null}async function Tt(t){let{existsSync:r}=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(t,o);if(!r(c))continue;try{let e=await import(c),u=ut(e.default??e);if(u)return u}catch{}}return null}async function dt(t={}){let r=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let u=X(t.explicit);if(u)return{url:u,source:"option"}}let o=ut(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await Tt(r);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function gt(){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(t){return async()=>({paths:await t(),fallback:!1})}var Lt;function Ut(t){let r=n(t),{depths:s}=se(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(r))!==null){if(s[c.index]!==0)continue;let u=k(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=k(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(r))!==null){if(s[c.index]!==0)continue;let u=vl(r,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function pt(t){let r="read";try{let s=await Bun.file(t).text();r="parse";let o=an(s),c=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(n(e.attrs))).sort((e,u)=>s.indexOf(e.fullTag)-s.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(n(e.content)))continue;let u=(Lt??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(n(u)))continue;let g=Ut(u);if(/\bdefineStaticPaths\b/.test(n(g))&&Dt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${g})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let S=await v();r="result";let p=Array.isArray(S)?{paths:S}:S;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(s){return{kind:"error",phase:r,error:s instanceof Error?s:Error(String(s))}}}class ft{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,r=""){this.cacheDir=t,this.salt=r}async load(){if(this.loaded)return;let t=m.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let r=JSON.parse(await Bun.file(t).text());for(let[s,o]of Object.entries(r))this.cache.set(s,o)}catch{}this.loaded=!0}async save(){await R.promises.mkdir(this.cacheDir,{recursive:!0});let t=m.join(this.cacheDir,"build-cache.json"),r={};for(let[s,o]of this.cache)r[s]=o;await Bun.write(t,JSON.stringify(r))}getHash(t,r){let s=R.statSync(t),o=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of r)if(R.existsSync(e)){let u=R.statSync(e);o+=`:${e}:${u.mtimeMs}`}let c=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,r){let s=this.cache.get(t);if(!s)return null;let o=mt(r).some((u)=>R.existsSync(u)),c=[r,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&R.existsSync(u)&&xs(R.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)return this.cache.delete(t),null;let e=this.getHash(r,s.dependencies??[]);if(s.hash!==e)return this.cache.delete(t),null;return s.html}set(t,r,s,o){let c=this.getHash(r,s);this.cache.set(t,{hash:c,html:o,generatedAt:Date.now(),dependencies:s})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let r=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return m.join(this.cacheDir,"isr",r)}async get(t){let r=this.getFilePath(t);if(!await Bun.file(r).exists())return null;try{return JSON.parse(await Bun.file(r).text())}catch{return null}}async set(t,r){let s=this.getFilePath(t);await R.promises.mkdir(m.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(r))}async invalidate(t){let r=this.getFilePath(t);if(await Bun.file(r).exists())await R.promises.unlink(r)}async invalidatePattern(t){let r=m.join(this.cacheDir,"isr");if(!R.existsSync(r))return;let s=await R.promises.readdir(r);for(let o of s){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await R.promises.unlink(m.join(r,o))}}async needsRevalidation(t){let r=await this.get(t);if(!r)return!0;return Date.now()>r.revalidateAfter}}async function _t(t){let r=[];if(!t.isDynamic)r.push({url:t.pattern,params:{}});else{let s=await pt(t.filePath);if(s.kind==="error")throw Error(`getStaticPaths ${s.phase} failed for ${t.pattern} (${t.filePath}): ${s.error.message}`,{cause:s.error});if(s.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),r;let o=s.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),r;for(let c of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(c.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);r.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return r}function mt(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let r of mt(t))if(await Bun.file(r).exists())try{let s=await import(r);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 ${r}:`,s)}return null}async function Gt(t,r,s){let o=t.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 e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
2
+ import"./chunk-s29hp1qw.js";import"./chunk-a60ztvnp.js";import"./chunk-9f31gs4m.js";import{k,Tl}from"./chunk-86nsbxep.js";import"./chunk-00tq7ghn.js";import"./chunk-hxhmhw23.js";import{zt,w}from"./chunk-njza56wn.js";import"./chunk-6t04tqvh.js";import"./chunk-yffqfgjx.js";import"./chunk-h63ma36g.js";import{Mt,Dt,Lt,jt,Bt,Ft}from"./chunk-agd2b928.js";import{a}from"./chunk-w53p65hy.js";import{Fs}from"./chunk-h2tq6cbr.js";import"./chunk-ssg6ne5b.js";import"./chunk-45jpwbzd.js";import{Ce,gn,mn}from"./chunk-kyh32kma.js";import"./chunk-jc74097x.js";import{x}from"./chunk-2cvwjtjh.js";import{Rt,i}from"./chunk-2gg3vjks.js";import"./chunk-345waetq.js";import"./chunk-ekdhjm8p.js";import{Ts}from"./chunk-ym0cdk7m.js";import"./chunk-9yx7cbhz.js";import"./chunk-c0g30cjs.js";import{vc,xc,Sc}from"./chunk-59er0fc7.js";import{pn,ur,dr}from"./chunk-p6hcrg3r.js";import{fn}from"./chunk-9zj3xztb.js";import"./chunk-k7ffxfgp.js";import"./chunk-t94y8g35.js";import{ne,$e}from"./chunk-1zkymrw0.js";import"./chunk-v1s838fe.js";import"./chunk-nb6erf75.js";import"./chunk-nnynrb97.js";import{l}from"./chunk-s7xywsqd.js";import{et}from"./chunk-ws2h92mm.js";import{t,C}from"./chunk-yh2hnt3m.js";import{f}from"./chunk-xpbakn6t.js";import R from"fs";import m from"path";import{createHash as Pt}from"crypto";function $t(e){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Et(e){return Bun.hash(e).toString(16)}function lt(e,n={}){if(!e.includes('type="stx/island"'))return{html:e,chunks:[]};let s=new Map,o=e.replace(kt,(r,u,g,v)=>{let S=v.trim();if(!S)return r;if(/\bdata-stx-src=/.test(g))return r;if(n.minify)S=$t(S);let p=Et(S);if(!s.has(p))s.set(p,S);let P=n.integrity?` data-stx-integrity="sha384-${Pt("sha384").update(S).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(s,([r,u])=>({hash:r,code:u}));return{html:o,chunks:c}}var Ct=new Set(["visible","idle"]);function ut(e){if(!e.includes("data-stx-src="))return e;let n=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=s.exec(e))!==null)n.set(o[1],o[2]);let c=new Set,r=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=r.exec(e))!==null)if(Ct.has(n.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=w(e,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return e;let S=Array.from(c).filter((p)=>!e.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!S)return e;return e.slice(0,v)+S+e.slice(v)}var It=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function Y(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 Tt(e){for(let n of It){let s=e[n];if(!s)continue;let o=Y(s);if(o)return{url:o,source:"env",via:n}}return null}function dt(e){if(!e||typeof e!=="object")return null;let n=e,s=n.site?.url??n.url??n.app?.url;return typeof s==="string"?Y(s):null}async function At(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=dt(r.default??r);if(u)return u}catch{}}return null}async function gt(e={}){let n=e.cwd??process.cwd(),s=e.env??process.env;if(e.explicit){let u=Y(e.explicit);if(u)return{url:u,source:"option"}}let o=dt(e.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await At(n);if(c)return{url:c,source:"site.config",via:"url"};let r=Tt(s);if(r)return r;return{url:"http://localhost",source:"fallback"}}function pt(){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 V(e){return async()=>({paths:await e(),fallback:!1})}var Ot;function Ut(e){let n=t(e),{depths:s}=C(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=k(n,"(",")",o.lastIndex-1),g=n.indexOf("{",u+1),v=k(n,"{","}",g);if(u<0||g<0||v<0)break;return e.slice(c.index,v+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=Tl(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 ft(e){let n="read";try{let s=await Bun.file(e).text();n="parse";let o=fn(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=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(r.content);if(!/\bgetStaticPaths\b/.test(t(u)))continue;let g=Ut(u);if(/\bdefineStaticPaths\b/.test(t(g))&&zt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");n="execute";let v=Function("defineStaticPaths",`return (${g})`)(V);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let S=await v();n="result";let p=Array.isArray(S)?{paths:S}:S;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(s){return{kind:"error",phase:n,error:s instanceof Error?s:Error(String(s))}}}class ht{cacheDir;cache=new Map;loaded=!1;salt;constructor(e,n=""){this.cacheDir=e,this.salt=n}async load(){if(this.loaded)return;let e=m.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 R.promises.mkdir(this.cacheDir,{recursive:!0});let e=m.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=R.statSync(e),o=`${this.salt}|${e}:${s.mtimeMs}`;for(let r of n)if(R.existsSync(r)){let u=R.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=wt(n).some((u)=>R.existsSync(u)),c=[n,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&R.existsSync(u)&&Ts(R.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.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 mt{cacheDir;constructor(e){this.cacheDir=e}getFilePath(e){let n=e.replace(/[^a-zA-Z0-9]/g,"_")+".json";return m.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 R.promises.mkdir(m.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 R.promises.unlink(n)}async invalidatePattern(e){let n=m.join(this.cacheDir,"isr");if(!R.existsSync(n))return;let s=await R.promises.readdir(n);for(let o of s){let c=o.replace(/_/g,"/").replace(".json","");if(e.test(c))await R.promises.unlink(m.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 ft(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,g]of Object.entries(c.params))r=r.replace(`:${u}`,g).replace(`:${u}*`,g);n.push({url:r,params:c.params,props:c.props,revalidate:c.revalidate})}}return n}function wt(e){return[e.replace(/\.stx$/,".data.ts"),e.replace(/\.stx$/,".data.js"),e+".data.ts",e+".data.js"]}async function Gt(e){for(let n of wt(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 Ht(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
- ${e[1]}
5
+ ${r[1]}
6
6
  })()
7
- `)(r)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Ht(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function wt(t,r,s={},o,c){let e=await Bun.file(t.filePath).text(),u=await Mt(t.filePath),g=await Gt(e,r,t.filePath),v={...u||{},...g||{},...s,params:r,$route:{path:t.pattern,params:r}},S=new Set,p=[],P=[],C={...c,minifyClient:!0,...o.partialsDir?{partialsDir:o.partialsDir}:{},...o.componentsDir?{componentsDir:o.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(E)=>{p.push(`${m.relative(process.cwd(),E.templatePath)}: ${E.message}
8
- resolved against partialsDir: ${E.partialsDir}`)},onServerScriptError:(E)=>{P.push(`${m.relative(process.cwd(),E.sourcePath)} (${E.kind}): ${E.message}`)}};if(Ht(e))console.warn(`Warning: ${t.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 b=await i(e,v,t.filePath,C,S);for(let E of[t.filePath,...S])for(let O of ke(E))S.add(O);if(Object.keys(r).length>0){let E=`<script>if(window.stx)window.stx._rp=${JSON.stringify(r)};else window.__stx_rp=${JSON.stringify(r)};</script>`;if(b.includes("</head>"))b=f(b,E);else b=`${E}
9
- ${b}`}if(b=await Ee(b,{router:o.router}),b=await x(b),o.minify!==!1)return{html:zt(b),dependencies:Array.from(S),includeFailures:p,serverScriptFailures:P};return{html:b,dependencies:Array.from(S),includeFailures:p,serverScriptFailures:P}}function zt(t){let r=[],s=0,o=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=o.exec(t))!==null){let u=t.slice(s,c.index);r.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let g=c[1],v=c[2],S=c[3];v=v.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),r.push(g+v+S),s=c.index+c[0].length}let e=t.slice(s);return r.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),r.join("").trim()}function Wt(t){let r=0;for(let s=0;s<t.length;s++){let o=t.charCodeAt(s);r=(r<<5)-r+o,r=r&r}return`"${Math.abs(r).toString(36)}"`}function qt(t,r,s,o){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(r))return!0;return o.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function Jt(t,r){return`<?xml version="1.0" encoding="UTF-8"?>
7
+ `)(n)}catch(r){return console.error(`Error executing getStaticProps in ${s}:`,r),null}}function Nt(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 yt(e,n,s={},o,c){let r=await Bun.file(e.filePath).text(),u=await Gt(e.filePath),g=await Ht(r,n,e.filePath),v={...u||{},...g||{},...s,params:n,$route:{path:e.pattern,params:n}},S=new Set,p=[],P=[],I={...c,minifyClient:!0,...o.partialsDir?{partialsDir:o.partialsDir}:{},...o.componentsDir?{componentsDir:o.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(E)=>{p.push(`${m.relative(process.cwd(),E.templatePath)}: ${E.message}
8
+ resolved against partialsDir: ${E.partialsDir}`)},onServerScriptError:(E)=>{P.push(`${m.relative(process.cwd(),E.sourcePath)} (${E.kind}): ${E.message}`)}};if(Nt(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 b=await i(r,v,e.filePath,I,S);for(let E of[e.filePath,...S])for(let L of Ce(E))S.add(L);if(Object.keys(n).length>0){let E=`<script>if(window.stx)window.stx._rp=${JSON.stringify(n)};else window.__stx_rp=${JSON.stringify(n)};</script>`;if(b.includes("</head>"))b=f(b,E);else b=`${E}
9
+ ${b}`}if(b=await $e(b,{router:o.router}),b=await x(b),o.minify!==!1)return{html:Wt(b),dependencies:Array.from(S),includeFailures:p,serverScriptFailures:P};return{html:b,dependencies:Array.from(S),includeFailures:p,serverScriptFailures:P}}function Wt(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 g=c[1],v=c[2],S=c[3];v=et(v).replace(/<\/script/gi,"<\\/script"),n.push(g+v+S),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 qt(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 Jt(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 Vt(e,n){return`<?xml version="1.0" encoding="UTF-8"?>
10
10
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
11
- ${t.map((o)=>{let c=new URL(o.loc,r).href,e=` <url>
12
- <loc>${T(c)}</loc>`;if(o.lastmod)e+=`
13
- <lastmod>${o.lastmod}</lastmod>`;if(o.changefreq)e+=`
14
- <changefreq>${o.changefreq}</changefreq>`;if(o.priority!==void 0)e+=`
15
- <priority>${o.priority}</priority>`;return e+=`
16
- </url>`,e}).join(`
11
+ ${e.map((o)=>{let c=new URL(o.loc,n).href,r=` <url>
12
+ <loc>${A(c)}</loc>`;if(o.lastmod)r+=`
13
+ <lastmod>${o.lastmod}</lastmod>`;if(o.changefreq)r+=`
14
+ <changefreq>${o.changefreq}</changefreq>`;if(o.priority!==void 0)r+=`
15
+ <priority>${o.priority}</priority>`;return r+=`
16
+ </url>`,r}).join(`
17
17
  `)}
18
- </urlset>`}function T(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Vt(t,r){let s=r.map((o)=>{let c=" <item>";if(c+=`
19
- <title>${T(o.title)}</title>`,c+=`
20
- <link>${T(o.link)}</link>`,o.description)c+=`
21
- <description>${T(o.description)}</description>`;if(o.pubDate)c+=`
18
+ </urlset>`}function A(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Kt(e,n){let s=n.map((o)=>{let c=" <item>";if(c+=`
19
+ <title>${A(o.title)}</title>`,c+=`
20
+ <link>${A(o.link)}</link>`,o.description)c+=`
21
+ <description>${A(o.description)}</description>`;if(o.pubDate)c+=`
22
22
  <pubDate>${o.pubDate.toUTCString()}</pubDate>`;if(o.author)c+=`
23
- <author>${T(o.author)}</author>`;if(o.categories)for(let e of o.categories)c+=`
24
- <category>${T(e)}</category>`;if(o.guid)c+=`
25
- <guid>${T(o.guid)}</guid>`;return c+=`
23
+ <author>${A(o.author)}</author>`;if(o.categories)for(let r of o.categories)c+=`
24
+ <category>${A(r)}</category>`;if(o.guid)c+=`
25
+ <guid>${A(o.guid)}</guid>`;return c+=`
26
26
  </item>`,c});return`<?xml version="1.0" encoding="UTF-8"?>
27
27
  <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
28
28
  <channel>
29
- <title>${T(t.title)}</title>
30
- <link>${T(t.link)}</link>
31
- <description>${T(t.description)}</description>
32
- ${t.language?`<language>${t.language}</language>`:""}
33
- ${t.copyright?`<copyright>${T(t.copyright)}</copyright>`:""}
29
+ <title>${A(e.title)}</title>
30
+ <link>${A(e.link)}</link>
31
+ <description>${A(e.description)}</description>
32
+ ${e.language?`<language>${e.language}</language>`:""}
33
+ ${e.copyright?`<copyright>${A(e.copyright)}</copyright>`:""}
34
34
  <lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
35
- <atom:link href="${t.link}/rss.xml" rel="self" type="application/rss+xml"/>
35
+ <atom:link href="${e.link}/rss.xml" rel="self" type="application/rss+xml"/>
36
36
  ${s.join(`
37
37
  `)}
38
38
  </channel>
39
- </rss>`}async function Kt(t={}){let r=Date.now();ln();let s=await a(process.cwd()),o=s.build||{},c=await dt({explicit:t.domain||o.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(gt());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,S={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&R.existsSync(e.outputDir))await R.promises.rm(e.outputDir,{recursive:!0});await R.promises.mkdir(e.outputDir,{recursive:!0});let C=e.cacheSalt;if(!C){let{resolveUserCssConfig:d,fingerprintConfig:y}=await import("./chunk-8f3dbthj.js");try{C=y(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-5ep7p8te.js"),E=await b(e.publicDir,e.outputDir);if(E.count>0)console.log(`Optimized ${E.count} image(s) for responsive delivery`),C=[C,E.fingerprint].filter(Boolean).join(":");let O=new ft(e.cacheDir,C);if(e.cache)await O.load();try{let{generateCss:d}=await import("./chunk-8f3dbthj.js");await d('<div class="bg-black"></div>')}catch{}Rt();let yt=s?.routeMiddleware?.dir||"middleware";await Pt(process.cwd(),yt);let V=At();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let St=s?.routeMiddleware?.global||[];gc(s?.layoutsDir,l(process.cwd()));let Z=Q(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Z.length} routes`);let U=[];for(let d of Z)try{let y=await _t(d);for(let D of y)U.push({route:d,url:D.url,params:D.params,props:D.props,revalidate:D.revalidate??e.revalidate})}catch(y){let D=y instanceof Error?y:Error(String(y));u.failedCount++,u.errors.push({route:d.pattern,error:D}),await e.hooks.onError?.(D,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,D)}u.totalPages=U.length+u.failedCount,console.log(`Generating ${U.length} pages...`);let _=[],tt=[];for(let d=0;d<U.length;d+=e.concurrency)tt.push(U.slice(d,d+e.concurrency));for(let d of tt)await Promise.all(d.map(async(y)=>{let{route:D,url:h,params:M,props:xt,revalidate:nt}=y;try{await e.hooks.onPageStart?.(h);let G=await Bun.file(D.filePath).text(),A=Zt(G),bt=A?.middleware?Array.isArray(A.middleware)?A.middleware:[A.middleware]:[],it=[...St,...bt];if(it.length>0){let j=It(h,M,A||{}),N=Ot(j,null,void 0,{isServer:!0}),F=await Nt(it,N);if(F.redirect){let I=typeof F.redirect==="string"?F.redirect:F.redirect.path||F.redirect,z=Qt(String(I),h),L=te(h,e);await R.promises.mkdir(m.dirname(L),{recursive:!0}),await Bun.write(L,z),u.successCount++,u.pages.push({route:h,outputPath:L,size:Buffer.byteLength(z),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${I}`);return}if(F.abort){let I=typeof F.abort==="string"?F.abort:F.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${I}`);return}}let st=A?.validate;if(typeof st==="function")try{if(!await st({params:M})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let B=null,at=!1;if(e.cache){if(B=O.get(h,D.filePath),B)at=!0,u.cachedCount++}if(!B){let j=await wt(D,M,xt,e,s);if(B=j.html,e.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
- ${j.includeFailures.join(`
39
+ </rss>`}async function Xt(e={}){let n=Date.now();mn();let s=await a(process.cwd()),o=s.build||{},c=await gt({explicit:e.domain||o.domain,stxConfig:s});if(c.source==="fallback"&&(e.sitemap??o.sitemap??!0))console.warn(pt());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:[]},g=new Set,v=0,S={},p={};await r.hooks.onBuildStart?.();try{if(r.cleanOutput&&R.existsSync(r.outputDir))await R.promises.rm(r.outputDir,{recursive:!0});await R.promises.mkdir(r.outputDir,{recursive:!0});let I=r.cacheSalt;if(!I){let{resolveUserCssConfig:d,fingerprintConfig:y}=await import("./chunk-xfhxfcvk.js");try{I=y(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-fxhgj8tp.js"),E=await b(r.publicDir,r.outputDir);if(E.count>0)console.log(`Optimized ${E.count} image(s) for responsive delivery`),I=[I,E.fingerprint].filter(Boolean).join(":");let L=new ht(r.cacheDir,I);if(r.cache)await L.load();try{let{generateCss:d}=await import("./chunk-xfhxfcvk.js");await d('<div class="bg-black"></div>')}catch{}Mt();let St=s?.routeMiddleware?.dir||"middleware";await Lt(process.cwd(),St);let K=Dt();if(K.length>0)console.log(`Loaded ${K.length} middleware: ${K.join(", ")}`);let xt=s?.routeMiddleware?.global||[];Sc(s?.layoutsDir,l(process.cwd()));let Q=ne(".",{pagesDir:r.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Q.length} routes`);let _=[];for(let d of Q)try{let y=await _t(d);for(let D of y)_.push({route:d,url:D.url,params:D.params,props:D.props,revalidate:D.revalidate??r.revalidate})}catch(y){let D=y instanceof Error?y:Error(String(y));u.failedCount++,u.errors.push({route:d.pattern,error:D}),await r.hooks.onError?.(D,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,D)}u.totalPages=_.length+u.failedCount,console.log(`Generating ${_.length} pages...`);let M=[],tt=[];for(let d=0;d<_.length;d+=r.concurrency)tt.push(_.slice(d,d+r.concurrency));for(let d of tt)await Promise.all(d.map(async(y)=>{let{route:D,url:h,params:G,props:bt,revalidate:it}=y;try{await r.hooks.onPageStart?.(h);let H=await Bun.file(D.filePath).text(),O=Qt(H),vt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],st=[...xt,...vt];if(st.length>0){let F=jt(h,G,O||{}),z=Bt(F,null,void 0,{isServer:!0}),T=await Ft(st,z);if(T.redirect){let B=typeof T.redirect==="string"?T.redirect:T.redirect.path||T.redirect,W=te(String(B),h),U=ee(h,r);await R.promises.mkdir(m.dirname(U),{recursive:!0}),await Bun.write(U,W),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(W),cached:!1}),M.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${B}`);return}if(T.abort){let B=typeof T.abort==="string"?T.abort:T.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${B}`);return}}let at=O?.validate;if(typeof at==="function")try{if(!await at({params:G})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let j=null,ot=!1;if(r.cache){if(j=L.get(h,D.filePath),j)ot=!0,u.cachedCount++}if(!j){let F=await yt(D,G,bt,r,s);if(j=F.html,r.failOnIncludeError&&F.includeFailures.length>0)throw Error(`${F.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
40
+ ${F.includeFailures.join(`
41
41
  `)}
42
- Set ssg.failOnIncludeError to false to build anyway.`);if(e.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
- ${j.serverScriptFailures.join(`
42
+ Set ssg.failOnIncludeError to false to build anyway.`);if(r.failOnServerScriptError&&F.serverScriptFailures.length>0)throw Error(`${F.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
43
+ ${F.serverScriptFailures.join(`
44
44
  `)}
45
- Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)O.set(h,D.filePath,j.dependencies,B)}let H;if(e.trailingSlash)H=m.join(e.outputDir,h,"index.html");else H=h==="/"?m.join(e.outputDir,"index.html"):m.join(e.outputDir,`${h}.html`);if(e.chunkIslands){let{html:j,chunks:N}=ct(B,{integrity:e.integrityIslands,minify:e.minify});if(N.length>0){let F=m.join(e.outputDir,"_stx","islands");await R.promises.mkdir(F,{recursive:!0});for(let I of N){let z=m.join(F,`${I.hash}.js`);if(!await Bun.file(z).exists())await Bun.write(z,I.code);if(!g.has(I.hash)){g.add(I.hash);let L=Buffer.byteLength(I.code,"utf8");v+=L,S[I.hash]={bytes:L,file:`/_stx/islands/${I.hash}.js`}}}if(p[h]=N.map((I)=>I.hash),B=j,e.prefetchIslands)B=lt(B)}}if(await R.promises.mkdir(m.dirname(H),{recursive:!0}),await Bun.write(H,B),!qt(h,B,A,e.sitemapExclude))_.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let ot={route:h,outputPath:H,size:Buffer.byteLength(B,"utf8"),cached:at};if(nt!==!1)ot.revalidateAt=Date.now()+nt*1000;u.pages.push(ot),u.successCount++,await e.hooks.onPageEnd?.(h,B)}catch(G){u.failedCount++,u.errors.push({route:h,error:G}),await e.hooks.onError?.(G,h),console.error(`Error generating ${h}:`,G)}}));let et=cn();if(et.length>0){let d=et.map((y)=>`${y.filePath}: ${y.message}`).join(`
45
+ Set ssg.failOnServerScriptError to false to build anyway.`);if(r.cache)L.set(h,D.filePath,F.dependencies,j)}let N;if(r.trailingSlash)N=m.join(r.outputDir,h,"index.html");else N=h==="/"?m.join(r.outputDir,"index.html"):m.join(r.outputDir,`${h}.html`);if(r.chunkIslands){let{html:F,chunks:z}=lt(j,{integrity:r.integrityIslands,minify:r.minify});if(z.length>0){let T=m.join(r.outputDir,"_stx","islands");await R.promises.mkdir(T,{recursive:!0});for(let B of z){let W=m.join(T,`${B.hash}.js`);if(!await Bun.file(W).exists())await Bun.write(W,B.code);if(!g.has(B.hash)){g.add(B.hash);let U=Buffer.byteLength(B.code,"utf8");v+=U,S[B.hash]={bytes:U,file:`/_stx/islands/${B.hash}.js`}}}if(p[h]=z.map((B)=>B.hash),j=F,r.prefetchIslands)j=ut(j)}}if(await R.promises.mkdir(m.dirname(N),{recursive:!0}),await Bun.write(N,j),!Jt(h,j,O,r.sitemapExclude))M.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let ct={route:h,outputPath:N,size:Buffer.byteLength(j,"utf8"),cached:ot};if(it!==!1)ct.revalidateAt=Date.now()+it*1000;u.pages.push(ct),u.successCount++,await r.hooks.onPageEnd?.(h,j)}catch(H){u.failedCount++,u.errors.push({route:h,error:H}),await r.hooks.onError?.(H,h),console.error(`Error generating ${h}:`,H)}}));let rt=gn();if(rt.length>0){let d=rt.map((y)=>`${y.filePath}: ${y.message}`).join(`
46
46
  `);throw Error(`Client script bundling failed:
47
- ${d}`)}if(e.cache)await O.save();if(e.generate404){let d=m.join(e.pagesDir,"404.stx");if(await Bun.file(d).exists()){let y=new Set,D={...s,minifyClient:!0,debug:!1,cache:!1},h=await i(await Bun.file(d).text(),{},d,D,y);await Bun.write(m.join(e.outputDir,"404.html"),h)}else await Bun.write(m.join(e.outputDir,"404.html"),`<!DOCTYPE html>
47
+ ${d}`)}if(r.cache)await L.save();if(r.generate404){let d=m.join(r.pagesDir,"404.stx");if(await Bun.file(d).exists()){let y=new Set,D={...s,minifyClient:!0,debug:!1,cache:!1},h=await i(await Bun.file(d).text(),{},d,D,y);await Bun.write(m.join(r.outputDir,"404.html"),h)}else await Bun.write(m.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(e.cache)await O.save();if(e.generate404){let d=m.join(e.pagesDir,"404.
65
65
  <a href="/">Go home</a>
66
66
  </div>
67
67
  </body>
68
- </html>`)}for(let d of[500]){let y=m.join(e.pagesDir,`${d}.stx`);if(await Bun.file(y).exists()){let D=new Set,h={...s,minifyClient:!0,debug:!1,cache:!1},M=await i(await Bun.file(y).text(),{},y,h,D);await Bun.write(m.join(e.outputDir,`${d}.html`),M)}}let K=m.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,y={...s,minifyClient:!0,debug:!1,cache:!1},D=await i(await Bun.file(K).text(),{},K,y,d);await Bun.write(m.join(e.outputDir,"error.html"),D)}if(e.sitemap&&_.length>0){let d=Jt(_,e.domain),y=m.join(e.outputDir,"sitemap.xml");await Bun.write(y,d),u.sitemapPath=y,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},y=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],D=Ns({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...y.length>0?{disallow:y}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(m.join(e.outputDir,"robots.txt"),D),console.log("Generated robots.txt")}if(e.rss){let d=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},y=[];if(d.getItems)y=await d.getItems();let D=Vt(d,y),h=m.join(e.outputDir,"rss.xml");await Bun.write(h,D),u.rssPath=h,console.log(`Generated rss.xml with ${y.length} items`)}let W=pc(e.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=fc(e.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(e.publicDir&&R.existsSync(e.publicDir))await Y(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let rt=ir();if(rt)await Y(rt,m.join(e.outputDir,or)),console.log(`Copied assets from ${on}`)}catch(C){throw await e.hooks.onError?.(C),C}if(u.buildTime=Date.now()-r,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let C={generatedChunks:g.size,totalBytes:v,chunks:S,pages:p};await Bun.write(m.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(C,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
68
+ </html>`)}for(let d of[500]){let y=m.join(r.pagesDir,`${d}.stx`);if(await Bun.file(y).exists()){let D=new Set,h={...s,minifyClient:!0,debug:!1,cache:!1},G=await i(await Bun.file(y).text(),{},y,h,D);await Bun.write(m.join(r.outputDir,`${d}.html`),G)}}let X=m.join(r.pagesDir,"error.stx");if(await Bun.file(X).exists()){let d=new Set,y={...s,minifyClient:!0,debug:!1,cache:!1},D=await i(await Bun.file(X).text(),{},X,y,d);await Bun.write(m.join(r.outputDir,"error.html"),D)}if(r.sitemap&&M.length>0){let d=Vt(M,r.domain),y=m.join(r.outputDir,"sitemap.xml");await Bun.write(y,d),u.sitemapPath=y,console.log(`Generated sitemap.xml with ${M.length} URLs`)}if(r.robots!==!1){let d=typeof r.robots==="object"?r.robots:{},y=[...r.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],D=Fs({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...y.length>0?{disallow:y}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",r.domain).href}:{}});await Bun.write(m.join(r.outputDir,"robots.txt"),D),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},y=[];if(d.getItems)y=await d.getItems();let D=Kt(d,y),h=m.join(r.outputDir,"rss.xml");await Bun.write(h,D),u.rssPath=h,console.log(`Generated rss.xml with ${y.length} items`)}let q=vc(r.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let J=xc(r.outputDir);if(J.assets>0)console.log(`Externalized ${J.assets} repeated asset(s) from ${J.pages} page(s) (${(J.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(r.publicDir&&R.existsSync(r.publicDir))await Z(r.publicDir,r.outputDir),console.log(`Copied public assets from ${r.publicDir}`);let nt=dr();if(nt)await Z(nt,m.join(r.outputDir,ur)),console.log(`Copied assets from ${pn}`)}catch(I){throw await r.hooks.onError?.(I),I}if(u.buildTime=Date.now()-n,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let I={generatedChunks:g.size,totalBytes:v,chunks:S,pages:p};await Bun.write(m.join(r.outputDir,"_stx","islands-manifest.json"),JSON.stringify(I,null,2))}await r.hooks.onBuildEnd?.(u);let P=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,17 +73,17 @@ Build complete!
73
73
  Cached: ${u.cachedCount}
74
74
  Failed: ${u.failedCount}
75
75
  Time: ${u.buildTime}ms${P}
76
- `),u}async function Y(t,r){await R.promises.mkdir(r,{recursive:!0});let s=await R.promises.readdir(t,{withFileTypes:!0});for(let o of s){let c=m.join(t,o.name),e=m.join(r,o.name);if(o.isDirectory())await R.promises.mkdir(e,{recursive:!0}),await Y(c,e);else await R.promises.copyFile(c,e)}}function Xt(t={}){let r=t.cacheDir||l(process.cwd(),"ssg-cache"),s=new ht(r),o=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${o}, stale-while-revalidate=${o*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let u=Q(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let g=c.match(u.regex),v={};if(g)u.params.forEach((P,C)=>{v[P]=g[C+1]});let S=await a(),{html:p}=await wt(u,v,{},t,S);await s.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:Wt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Yt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let r=await Bun.file(t).text(),s=r.match(/^---\n([\s\S]*?)\n---/),o={},c=r;if(s){let S=s[1];c=r.slice(s[0].length).trim();for(let p of S.split(`
77
- `)){let P=p.indexOf(":");if(P>0){let C=p.slice(0,P).trim(),b=p.slice(P+1).trim();if(b==="true")b=!0;else if(b==="false")b=!1;else if(/^\d+$/.test(b))b=parseInt(b,10);else if(/^\d+\.\d+$/.test(b))b=parseFloat(b);else if(b.startsWith("[")&&b.endsWith("]"))b=b.slice(1,-1).split(",").map((E)=>E.trim().replace(/^['"]|['"]$/g,""));o[C]=b}}}let e=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=[],g=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,v;while((v=g.exec(e))!==null){let S=parseInt(v[1],10),p=v[2],P=p.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:p,level:S})}return{content:e,data:o,toc:u}}}}function Zt(t){return kt(t)}function Qt(t,r){return`<!DOCTYPE html>
76
+ `),u}async function Z(e,n){await R.promises.mkdir(n,{recursive:!0});let s=await R.promises.readdir(e,{withFileTypes:!0});for(let o of s){let c=m.join(e,o.name),r=m.join(n,o.name);if(o.isDirectory())await R.promises.mkdir(r,{recursive:!0}),await Z(c,r);else await R.promises.copyFile(c,r)}}function Yt(e={}){let n=e.cacheDir||l(process.cwd(),"ssg-cache"),s=new mt(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=ne(".",{pagesDir:e.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let g=c.match(u.regex),v={};if(g)u.params.forEach((P,I)=>{v[P]=g[I+1]});let S=await a(),{html:p}=await yt(u,v,{},e,S);await s.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:qt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Zt(){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 S=s[1];c=n.slice(s[0].length).trim();for(let p of S.split(`
77
+ `)){let P=p.indexOf(":");if(P>0){let I=p.slice(0,P).trim(),b=p.slice(P+1).trim();if(b==="true")b=!0;else if(b==="false")b=!1;else if(/^\d+$/.test(b))b=parseInt(b,10);else if(/^\d+\.\d+$/.test(b))b=parseFloat(b);else if(b.startsWith("[")&&b.endsWith("]"))b=b.slice(1,-1).split(",").map((E)=>E.trim().replace(/^['"]|['"]$/g,""));o[I]=b}}}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=[],g=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,v;while((v=g.exec(r))!==null){let S=parseInt(v[1],10),p=v[2],P=p.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:p,level:S})}return{content:r,data:o,toc:u}}}}function Qt(e){return Rt(e)}function te(e,n){return`<!DOCTYPE html>
78
78
  <html>
79
79
  <head>
80
80
  <meta charset="utf-8">
81
- <meta http-equiv="refresh" content="0; url=${t}">
82
- <link rel="canonical" href="${t}">
81
+ <meta http-equiv="refresh" content="0; url=${e}">
82
+ <link rel="canonical" href="${e}">
83
83
  <title>Redirecting...</title>
84
84
  </head>
85
85
  <body>
86
- <p>Redirecting to <a href="${t}">${t}</a>...</p>
87
- <script>window.location.replace('${t}')</script>
86
+ <p>Redirecting to <a href="${e}">${e}</a>...</p>
87
+ <script>window.location.replace('${e}')</script>
88
88
  </body>
89
- </html>`}function te(t,r){if(t==="/"||t==="")return m.join(r.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(r.trailingSlash)return m.join(r.outputDir,s,"index.html");return m.join(r.outputDir,`${s}.html`)}var Te={generateStaticSite:Kt,createISRHandler:Xt,defineStaticPaths:J,createMarkdownLoader:Yt};export{Xt as createISRHandler,Yt as createMarkdownLoader,Ht as declaresPageAction,Te as default,J as defineStaticPaths,Kt as generateStaticSite,qt as isExcludedFromSitemap};
89
+ </html>`}function ee(e,n){if(e==="/"||e==="")return m.join(n.outputDir,"index.html");let s=e.replace(/^\/|\/$/g,"");if(n.trailingSlash)return m.join(n.outputDir,s,"index.html");return m.join(n.outputDir,`${s}.html`)}var Oe={generateStaticSite:Xt,createISRHandler:Yt,defineStaticPaths:V,createMarkdownLoader:Zt};export{Yt as createISRHandler,Zt as createMarkdownLoader,Nt as declaresPageAction,Oe as default,V as defineStaticPaths,Xt as generateStaticSite,Jt as isExcludedFromSitemap};
@@ -25,6 +25,8 @@ export declare function findInterpolationEnd(code: string, start: number): numbe
25
25
  * undefined name.
26
26
  */
27
27
  export declare function stripCommentsAndLiterals(code: string): string;
28
+ /** Keep a literal terminator and template expression boundaries for binding scopes. */
29
+ export declare function stripBindingLiterals(code: string): string;
28
30
  /**
29
31
  * Bracket nesting at each index of already-stripped source, so a declaration
30
32
  * can be told apart from one nested inside a function, block or loop head.
@@ -124,6 +124,12 @@ function regexEnd(code, start) {
124
124
  return -1;
125
125
  }
126
126
  export function stripCommentsAndLiterals(code) {
127
+ return stripLiterals(code, !1);
128
+ }
129
+ export function stripBindingLiterals(code) {
130
+ return stripLiterals(code, !0);
131
+ }
132
+ function stripLiterals(code, bindingBoundaries) {
127
133
  let out = "", i = 0, lastSig = "", lastWord = "";
128
134
  while (i < code.length) {
129
135
  const two = code.slice(i, i + 2);
@@ -158,7 +164,7 @@ export function stripCommentsAndLiterals(code) {
158
164
  ` : " ";
159
165
  i++;
160
166
  }
161
- out += " ";
167
+ out += bindingBoundaries ? "$" : " ";
162
168
  i++;
163
169
  lastSig = LITERAL_END;
164
170
  lastWord = "";
@@ -175,7 +181,7 @@ export function stripCommentsAndLiterals(code) {
175
181
  }
176
182
  }
177
183
  if (ch === "`") {
178
- out += " ";
184
+ out += bindingBoundaries ? "(" : " ";
179
185
  i++;
180
186
  while (i < code.length && code[i] !== "`") {
181
187
  if (code[i] === "\\") {
@@ -185,10 +191,10 @@ export function stripCommentsAndLiterals(code) {
185
191
  }
186
192
  if (code[i] === "$" && code[i + 1] === "{") {
187
193
  const bodyStart = i + 2, bodyEnd = findInterpolationEnd(code, bodyStart);
188
- out += " ";
189
- out += stripCommentsAndLiterals(code.slice(bodyStart, bodyEnd));
194
+ out += bindingBoundaries ? " {" : " ";
195
+ out += stripLiterals(code.slice(bodyStart, bodyEnd), bindingBoundaries);
190
196
  if (bodyEnd < code.length)
191
- out += " ";
197
+ out += bindingBoundaries ? "}" : " ";
192
198
  i = bodyEnd + 1;
193
199
  continue;
194
200
  }
@@ -197,7 +203,7 @@ export function stripCommentsAndLiterals(code) {
197
203
  ` : " ";
198
204
  i++;
199
205
  }
200
- out += " ";
206
+ out += bindingBoundaries ? ")" : " ";
201
207
  i++;
202
208
  lastSig = LITERAL_END;
203
209
  lastWord = "";
@@ -462,6 +462,7 @@ export declare interface TemplateExpression {
462
462
  }
463
463
  /** A synthetic line's origin, for diagnostics that land outside the source. */
464
464
  export declare interface MappedLine {
465
+ anchor?: boolean
465
466
  diagnosticOrigin?: ScriptKind | 'component'
466
467
  line: number
467
468
  column: number