@stacksjs/stx 0.2.462 → 0.2.463

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 (142) hide show
  1. package/dist/{chunk-kcs71ks8.js → chunk-02e24cym.js} +1 -1
  2. package/dist/chunk-0fvz8wad.js +2 -0
  3. package/dist/chunk-0yba08sr.js +2 -0
  4. package/dist/{chunk-3rpbzfw5.js → chunk-14vnnx44.js} +2 -2
  5. package/dist/chunk-1mfggkga.js +2 -0
  6. package/dist/chunk-1p5ge6fq.js +2 -0
  7. package/dist/{chunk-rcr57c30.js → chunk-2cqymwe8.js} +2 -2
  8. package/dist/{chunk-8xz8t9xp.js → chunk-2n5pjbw9.js} +2 -2
  9. package/dist/{chunk-44msrx2e.js → chunk-2tn3dkcy.js} +2 -2
  10. package/dist/{chunk-5pgvfxtx.js → chunk-39q77svv.js} +3 -3
  11. package/dist/{chunk-hehtgsrt.js → chunk-3q2z7cts.js} +1 -1
  12. package/dist/chunk-4yjtwjrw.js +2 -0
  13. package/dist/chunk-5127n7rc.js +2 -0
  14. package/dist/{chunk-462jmw0a.js → chunk-544e2jvd.js} +2 -2
  15. package/dist/chunk-5564cka1.js +2 -0
  16. package/dist/{chunk-e02b66yn.js → chunk-5yn0gpcj.js} +3 -3
  17. package/dist/{chunk-t0j0d802.js → chunk-627af18j.js} +1 -1
  18. package/dist/chunk-6876vczs.js +2 -0
  19. package/dist/chunk-7fjatz47.js +2 -0
  20. package/dist/chunk-7j1cpa9d.js +2 -0
  21. package/dist/{chunk-5w87wmc4.js → chunk-88px183j.js} +2 -2
  22. package/dist/{chunk-ree9weje.js → chunk-90drf2ag.js} +2 -2
  23. package/dist/chunk-938g2a3d.js +2 -0
  24. package/dist/{chunk-5qns2sdz.js → chunk-9fr19qe4.js} +2 -2
  25. package/dist/{chunk-6r2709dj.js → chunk-9pt8fd2n.js} +3 -3
  26. package/dist/{chunk-6wqvgy6x.js → chunk-a35c060g.js} +1 -1
  27. package/dist/{chunk-tpeyn7wr.js → chunk-a8q8m5pp.js} +2 -2
  28. package/dist/chunk-ajqwjevt.js +2 -0
  29. package/dist/{chunk-z3etxty5.js → chunk-amd6ey3t.js} +5 -5
  30. package/dist/{chunk-n1mspzv7.js → chunk-bddjx2a2.js} +2 -2
  31. package/dist/chunk-bp53x03f.js +2 -0
  32. package/dist/{chunk-jnn745tt.js → chunk-ccy6avqe.js} +5 -5
  33. package/dist/{chunk-pe214qcn.js → chunk-cfk3skk4.js} +1 -1
  34. package/dist/chunk-d1x5r4p6.js +2 -0
  35. package/dist/{chunk-5bqs0ve6.js → chunk-d2zw2e5m.js} +1 -1
  36. package/dist/chunk-d9360m89.js +2 -0
  37. package/dist/chunk-dcv6absa.js +2 -0
  38. package/dist/{chunk-b6e36vr2.js → chunk-dqdggvq4.js} +180 -180
  39. package/dist/{chunk-rvgvt161.js → chunk-e15a8txv.js} +2 -2
  40. package/dist/{chunk-hp901qmd.js → chunk-eegxyqk3.js} +2 -2
  41. package/dist/{chunk-9yywhkc7.js → chunk-ery19t9s.js} +3 -3
  42. package/dist/{chunk-6yt2dpsb.js → chunk-etjw0he9.js} +3 -3
  43. package/dist/{chunk-gxhwg1f4.js → chunk-fh1qrp68.js} +5 -5
  44. package/dist/{chunk-a51ftv2n.js → chunk-hhsynd7c.js} +3 -3
  45. package/dist/chunk-j9qcrwbg.js +2 -0
  46. package/dist/chunk-jmabeqfq.js +2 -0
  47. package/dist/{chunk-yfbj4qce.js → chunk-jmhhv817.js} +2 -2
  48. package/dist/chunk-jr3g08vs.js +2 -0
  49. package/dist/chunk-k2vcwa7m.js +2 -0
  50. package/dist/{chunk-tbjyp03h.js → chunk-k9sbgax8.js} +1 -1
  51. package/dist/{chunk-a6pjaw6w.js → chunk-kdk0jy1h.js} +3 -3
  52. package/dist/chunk-kmb9qrdg.js +2 -0
  53. package/dist/{chunk-q0d0q8r8.js → chunk-krsdcjxk.js} +6 -6
  54. package/dist/{chunk-bagh6sc1.js → chunk-mfxf378k.js} +2 -2
  55. package/dist/chunk-mhfwdyeg.js +2 -0
  56. package/dist/chunk-mxt11ejx.js +2 -0
  57. package/dist/chunk-mxtah7y5.js +2 -0
  58. package/dist/{chunk-n3r5m938.js → chunk-ng61wjke.js} +1 -1
  59. package/dist/{chunk-qer8jpr5.js → chunk-nkxa7men.js} +1 -1
  60. package/dist/{chunk-501kq69r.js → chunk-nwwzf7h1.js} +1 -1
  61. package/dist/{chunk-z2daw0th.js → chunk-pbh4smw3.js} +4 -4
  62. package/dist/{chunk-9n10mh5q.js → chunk-ptek61ts.js} +1 -1
  63. package/dist/chunk-q316y302.js +2 -0
  64. package/dist/chunk-q7qchkvk.js +2 -0
  65. package/dist/{chunk-18pagcsc.js → chunk-qr15ksz9.js} +4 -4
  66. package/dist/chunk-qyq7j8hp.js +2 -0
  67. package/dist/chunk-r5gyx7ch.js +2 -0
  68. package/dist/chunk-raeyd6e5.js +2 -0
  69. package/dist/chunk-raqqq3mm.js +2 -0
  70. package/dist/chunk-rjm3n62n.js +2 -0
  71. package/dist/{chunk-ty3j2ryw.js → chunk-skjwh35r.js} +2 -2
  72. package/dist/{chunk-6ths0ktv.js → chunk-sprx02g0.js} +1 -1
  73. package/dist/{chunk-x4yqyea2.js → chunk-t1py7rbg.js} +5 -5
  74. package/dist/{chunk-vxhy0a3n.js → chunk-tesmv3m9.js} +2 -2
  75. package/dist/chunk-tkakxkbx.js +2 -0
  76. package/dist/{chunk-pq84ycrv.js → chunk-tsg7bj9p.js} +3 -3
  77. package/dist/chunk-txkfp4v5.js +2 -0
  78. package/dist/chunk-tzjqtweb.js +2 -0
  79. package/dist/{chunk-8yrk8ybh.js → chunk-v83bpj84.js} +3 -3
  80. package/dist/chunk-vhdemrec.js +2 -0
  81. package/dist/chunk-wsftz3vj.js +2 -0
  82. package/dist/chunk-wvxj6r2a.js +2 -0
  83. package/dist/{chunk-wz29ahjp.js → chunk-xbm2gcb6.js} +2 -2
  84. package/dist/chunk-xek78ez1.js +2 -0
  85. package/dist/chunk-xjb0yzvq.js +2 -0
  86. package/dist/{chunk-ver2yf41.js → chunk-y36av1ac.js} +6 -6
  87. package/dist/{chunk-m2yy86d8.js → chunk-y8mx0hab.js} +2 -2
  88. package/dist/{chunk-ptxvex42.js → chunk-y9j2kf3k.js} +5 -5
  89. package/dist/chunk-ydjfar14.js +2 -0
  90. package/dist/chunk-ymk7eswy.js +2 -0
  91. package/dist/{chunk-gkqxnetc.js → chunk-zasd9166.js} +2 -2
  92. package/dist/chunk-zhexga43.js +2 -0
  93. package/dist/cli.js +11 -11
  94. package/dist/craft-entry.js +2 -2
  95. package/dist/craft.js +2 -2
  96. package/dist/includes.d.ts +17 -0
  97. package/dist/includes.js +43 -1
  98. package/dist/pwa.js +3 -3
  99. package/dist/ssg.js +2 -2
  100. package/package.json +5 -5
  101. package/dist/chunk-03ek5ag5.js +0 -2
  102. package/dist/chunk-0a2w25j8.js +0 -2
  103. package/dist/chunk-0f1f6y2w.js +0 -2
  104. package/dist/chunk-14p5jgqp.js +0 -2
  105. package/dist/chunk-1fccwkkq.js +0 -2
  106. package/dist/chunk-32t5agpk.js +0 -2
  107. package/dist/chunk-3rrzxapr.js +0 -2
  108. package/dist/chunk-3s2vnqcf.js +0 -2
  109. package/dist/chunk-4henqdjf.js +0 -2
  110. package/dist/chunk-4mcmbvxb.js +0 -2
  111. package/dist/chunk-561yczfn.js +0 -2
  112. package/dist/chunk-5ex4hjt3.js +0 -2
  113. package/dist/chunk-68txmj8d.js +0 -2
  114. package/dist/chunk-6qv189mb.js +0 -2
  115. package/dist/chunk-8xkr55v2.js +0 -2
  116. package/dist/chunk-995ytskb.js +0 -2
  117. package/dist/chunk-9mmsb0zb.js +0 -2
  118. package/dist/chunk-9t50hw97.js +0 -2
  119. package/dist/chunk-9y6bn8hk.js +0 -2
  120. package/dist/chunk-amvnckr7.js +0 -2
  121. package/dist/chunk-c0wcvbhr.js +0 -2
  122. package/dist/chunk-darbqs38.js +0 -2
  123. package/dist/chunk-e38fyh0y.js +0 -2
  124. package/dist/chunk-gcz1wex2.js +0 -2
  125. package/dist/chunk-gn32cr6z.js +0 -2
  126. package/dist/chunk-jbdvkj3q.js +0 -2
  127. package/dist/chunk-jy58t59b.js +0 -2
  128. package/dist/chunk-kggx9jc1.js +0 -2
  129. package/dist/chunk-khx54f41.js +0 -2
  130. package/dist/chunk-n76phhd2.js +0 -2
  131. package/dist/chunk-n8hd5qap.js +0 -2
  132. package/dist/chunk-neq30d52.js +0 -2
  133. package/dist/chunk-qr68w6qf.js +0 -2
  134. package/dist/chunk-sd2gc341.js +0 -2
  135. package/dist/chunk-t1s00kj6.js +0 -2
  136. package/dist/chunk-vrvnctex.js +0 -2
  137. package/dist/chunk-vvyfeyxk.js +0 -2
  138. package/dist/chunk-w28dbef2.js +0 -2
  139. package/dist/chunk-y2p3scx0.js +0 -2
  140. package/dist/chunk-yxwam84p.js +0 -2
  141. package/dist/chunk-zkp2cw7q.js +0 -2
  142. package/dist/chunk-zxbz8v00.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{y}from"./chunk-2jbyks2t.js";import{P,Tt}from"./chunk-pf0d8y9n.js";import{w,He,L,o}from"./chunk-b6e36vr2.js";import{ie,ht,yt}from"./chunk-a6pjaw6w.js";import{Ae,Ut,dt,H}from"./chunk-8efg91ak.js";import f from"path";var l=new Map;function v(a,s){for(let n of a.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(n[1])s.add(n[1]);for(let n of a.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let r of(n[1]??"").split(",")){let i=((r.includes(":")?r.split(":").pop():r)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(i))s.add(i)}for(let n of a.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let r of(n[1]??"").split(",")){let c=r.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(c))s.add(c)}}async function Wl(a){let s;if(a)s=f.resolve(a);else{let t=await o();s=f.resolve(t.root||process.cwd(),t.storesDir||"stores")}let n=new Bun.Glob("*.ts"),r=[];try{for await(let t of n.scan({cwd:s,absolute:!0})){let e=f.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return H(l,s,"",""),null}let c=()=>[...new Set([...r,...r.flatMap((t)=>ie(t))])],i=Ae(c()),d=dt(l,s,i);if(d!==void 0)return d||null;if(r.length===0)return H(l,s,i,""),null;let p=[];for(let t of r){let e=await Bun.file(t).text();p.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}p.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let h=p.map((t)=>t.file),u=[],m=new Set,b=L({loader:"ts",target:"browser",define:w()});for(let t of h)try{let e=await Bun.file(t).text(),x=f.basename(t,".ts");if(v(e,m),ht(e))e=await yt(e,t,{projectRoot:process.cwd(),externalizeUserModules:!1});e=He(e),e=P(e),e=Tt(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=b.transformSync(e),u.push(`// Store: ${x}
2
+ import{y}from"./chunk-2jbyks2t.js";import{P,Tt}from"./chunk-pf0d8y9n.js";import{w,He,L,o}from"./chunk-dqdggvq4.js";import{ie,ht,yt}from"./chunk-kdk0jy1h.js";import{Ae,Ut,dt,H}from"./chunk-8efg91ak.js";import f from"path";var l=new Map;function v(a,s){for(let n of a.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(n[1])s.add(n[1]);for(let n of a.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let r of(n[1]??"").split(",")){let i=((r.includes(":")?r.split(":").pop():r)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(i))s.add(i)}for(let n of a.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let r of(n[1]??"").split(",")){let c=r.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(c))s.add(c)}}async function ql(a){let s;if(a)s=f.resolve(a);else{let t=await o();s=f.resolve(t.root||process.cwd(),t.storesDir||"stores")}let n=new Bun.Glob("*.ts"),r=[];try{for await(let t of n.scan({cwd:s,absolute:!0})){let e=f.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return H(l,s,"",""),null}let c=()=>[...new Set([...r,...r.flatMap((t)=>ie(t))])],i=Ae(c()),d=dt(l,s,i);if(d!==void 0)return d||null;if(r.length===0)return H(l,s,i,""),null;let p=[];for(let t of r){let e=await Bun.file(t).text();p.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}p.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let h=p.map((t)=>t.file),u=[],m=new Set,b=L({loader:"ts",target:"browser",define:w()});for(let t of h)try{let e=await Bun.file(t).text(),x=f.basename(t,".ts");if(v(e,m),ht(e))e=await yt(e,t,{projectRoot:process.cwd(),externalizeUserModules:!1});e=He(e),e=P(e),e=Tt(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=b.transformSync(e),u.push(`// Store: ${x}
3
3
  ${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(u.length===0)return H(l,s,i,""),null;let g=u.join(`
4
4
 
5
5
  `),S=`;(function(){
@@ -7,5 +7,5 @@ var __stx = window.stx || {};
7
7
  ${y.filter((t)=>!m.has(t)&&new RegExp(`\\b${t}\\b`).test(g)).map((t)=>`var ${t} = __stx[${JSON.stringify(t)}];`).join(`
8
8
  `)}
9
9
  ${g}
10
- })();`;return i=Ae(c()),H(l,s,i,S),S}function ql(){l.clear(),Ut()}
11
- export{Wl,ql};
10
+ })();`;return i=Ae(c()),H(l,s,i,S),S}function Kl(){l.clear(),Ut()}
11
+ export{ql,Kl};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ui,eo,Wc,Wi,qi,qc,Kc}from"./chunk-ccy6avqe.js";import"./chunk-5yn0gpcj.js";import"./chunk-kdk0jy1h.js";import"./chunk-39q77svv.js";import{ze,rc}from"./chunk-dqdggvq4.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-ng61wjke.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{Ui as buildVirtualSource,ze as extractScriptBlocks,rc as extractTemplateExpressions,Wi as findRuntimeTypeDeclarations,qi as findStxModuleDeclarations,Kc as formatTypecheckDiagnostics,Wc as sourcePathFor,qc as typecheckStxFiles,eo as virtualPathFor};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{cl}from"./chunk-jmhhv817.js";import"./chunk-dqdggvq4.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-ng61wjke.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{cl as buildApp};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
2
  import{t,i,pn,Ps,ve,l}from"./chunk-ynvce0q6.js";function S(e,n,r,o=0){let a=0,s=o,u=null,c=0,p=!1;while(s<e.length){let h=e[s];if(u&&p){p=!1,s++;continue}if(u&&h==="\\"){p=!0,s++;continue}if(p=!1,(h==='"'||h==="'"||h==="`")&&!u){u=h,s++;continue}if(h===u&&u!=="`"){u=null,s++;continue}if(u==="`"&&h==="$"&&e[s+1]==="{"){c++,s+=2;continue}if(c>0&&h==="}"){c--,s++;continue}if(h==="`"&&u==="`"&&c===0){u=null,s++;continue}if(u){s++;continue}if(h===n)a++;else if(h===r){if(a--,a===0)return s}s++}return-1}import T from"path";function _s(e,n){let r=[];n.lastIndex=0;let o;while((o=n.exec(e))!==null){let a=o.index,s=a+o[0].length-1,u=S(e,"(",")",s);if(u===-1){r.push({start:a,end:-1,args:"",call:e.slice(a,Math.min(e.length,a+80))}),n.lastIndex=s+1;continue}r.push({start:a,end:u+1,args:e.slice(s+1,u),call:e.slice(a,u+1)}),n.lastIndex=u+1}return r}function Xe(e,n,r,o){let a="",s=0;for(let u of _s(e,n)){if(a+=e.slice(s,u.start),u.end===-1){a+=o(u.call),s=u.start;continue}a+=r(u.args,u.call),s=u.end}return a+e.slice(s)}function Ge(e){let n=[],r=0,o=null,a="";for(let s=0;s<e.length;s++){let u=e[s];if(o){if(a+=u,u==="\\"&&s+1<e.length){a+=e[++s];continue}if(u===o)o=null;continue}if(u==="'"||u==='"'||u==="`")o=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0){n.push(a.trim()),a="";continue}a+=u}if(a.trim())n.push(a.trim());return n}function y(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let o="";for(let a=1;a<n.length-1;a++){let s=n[a];if(s==="\\"&&a+1<n.length-1){let u=n[++a];o+=u==="n"?`
3
- `:u==="t"?"\t":u;continue}if(s===r)return null;if(r==="`"&&s==="$"&&n[a+1]==="{")return null;o+=s}return o}var R=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Je(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let o=pn(r);if(o)return{ok:!1,message:`the expression is not allowed (${o})`,code:t.UNSAFE_EXPRESSION};let a=Ps(n),s;try{s=l(r,Object.keys(a))(...Object.values(a))}catch(c){return{ok:!1,message:`the expression could not be evaluated: ${c instanceof Error?c.message:String(c)}`,code:t.EVALUATION_ERROR}}if(s!==void 0&&s!==null)return{ok:!0,value:s};let u=[...new Set(ve(r))].filter((c)=>!R.has(c)&&!(c in a)&&!(c in globalThis));if(u.length>0)return{ok:!1,message:`${u.map((p)=>`"${p}"`).join(", ")} ${u.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(s===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:s}}function ue(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function we(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function v(e){if(!e)return"";return T.isAbsolute(e)?T.relative(process.cwd(),e)||e:e}function f(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function E(e,n,r,o,a=t.EVALUATION_ERROR){let s=o?` in ${v(o)}`:"";return console.warn(`[stx] ${f(n)}${s}: ${r}`),i(e,`${f(n)}: ${r}`,a)}function er(e,n,r){let o=r?` in ${v(r)}`:"";console.warn(`[stx] ${f(e)}${o}: ${n}`)}var x=["og:","article:","book:","profile:","fb:","music:","video:"],I=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function ln(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=_(e[0],n);if(typeof r!=="string")return r;let o;if(e.length===2){let s=C(e[1],n);if(typeof s!=="string")return s;o=s}else{let s=r.includes(":")?r.slice(r.indexOf(":")+1):r,u=n.openGraph,c=n[s]??(we(u)?u[s]:void 0);o=c===void 0||c===null||typeof c==="object"?"":String(c)}if(!o)return{kind:"empty"};return{kind:"tag",tag:x.some((s)=>r.startsWith(s))?{property:r,content:o}:{name:r,content:o}}}function _(e,n){let r=y(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(I.test(e.trim()))return e.trim();let o=Je(e,n);if(!o.ok)return{kind:"error",message:`meta name: ${o.message}`,code:o.code};if(typeof o.value!=="string"||!o.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${ue(o.value)}`,code:t.TYPE_ERROR};return o.value}function C(e,n){let r=y(e);if(r!==null)return r;let o=Je(e,n);if(!o.ok)return{kind:"error",message:o.message,code:o.code};let a=o.value;if(a===void 0||a===null||a===!1)return"";if(Array.isArray(a))return a.filter((s)=>s!==void 0&&s!==null&&s!=="").map(String).join(", ");if(typeof a==="object"&&!(a instanceof Date))return{kind:"error",message:`the content must be text, got ${ue(a)}`,code:t.TYPE_ERROR};return String(a)}var un=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],tr=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],w={links:"link",metas:"meta",scripts:"script",styles:"style"},b=new Set,A=new WeakMap;function k(e){if(b.has(e))return;b.add(e),console.warn(e)}function N(e,n){let r=Array.from({length:n.length+1},(o,a)=>a);for(let o=1;o<=e.length;o++){let a=r[0];r[0]=o;for(let s=1;s<=n.length;s++){let u=r[s];r[s]=Math.min(r[s]+1,r[s-1]+1,a+(e[o-1]===n[s-1]?0:1)),a=u}}return r[n.length]}function M(e,n){let r=e.toLowerCase(),o=n.find((p)=>p.toLowerCase()===r);if(o)return o;let a=w[r];if(a&&n.includes(a))return a;let s,u=1/0;for(let p of n){let h=N(r,p.toLowerCase());if(h<u)s=p,u=h}let c=Math.min(e.length,s?.length??0)<=4?1:2;return u<=c?s:void 0}function de(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=A.get(e);if(r)return r;let{known:o,source:a}=n,s=e;for(let u of Object.keys(e)){if(o.includes(u))continue;let c=w[u];if(c&&o.includes(c)&&Array.isArray(e[u])){if(s===e)s={...e};let h=Array.isArray(s[c])?s[c]:[];s[c]=[...h,...e[u]],delete s[u],k(`[stx] ${a}.${u} is not a head key; reading it as ${a}.${c}. Rename it to \`${c}\`.`);continue}if(/^styles?$/.test(u)&&!o.includes("style")){k(`[stx] ${a}.${u} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let p=M(u,o);k(p?`[stx] ${a}.${u} is not a head key and is ignored. Did you mean \`${p}\`?`:`[stx] ${a}.${u} is not a head key and is ignored. Known keys: ${o.join(", ")}.`)}return A.set(e,s),s}var d={},D=[],g={};function Ts(){return d}function Ku(){return g}function Xu(){d={},D.length=0,g={}}function vi(e){d=pe(d,de(e,{known:tr,source:"useHead()"}))}function pe(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:[...e.meta||[],...n.meta||[]],link:[...e.link||[],...n.link||[]],script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function _c(e){vi(nr(e))}function nr(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let p=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:p})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,o=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(o)n.push({property:"og:description",content:o});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.push({property:"profile:username",content:e.profileUsername});let a=e.twitterTitle??e.title,s=e.twitterDescription??e.description,u=e.twitterImage??e.ogImage;if(e.twitterCard)n.push({name:"twitter:card",content:e.twitterCard});if(a)n.push({name:"twitter:title",content:a});if(s)n.push({name:"twitter:description",content:s});if(u){n.push({name:"twitter:image",content:u});let p=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(p)n.push({name:"twitter:image:alt",content:p})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let p of e.articleTags)n.push({property:"article:tag",content:p});let c=[];if(e.canonical)c.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:c}}function Gu(e){if(g={...g,...e},e.title||e.description)_c({title:e.title,description:e.description})}function Ju(e){let n=typeof e==="function"?e():e;vi({title:n})}function Yu(e=d){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${m(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([o,a])=>`${o}="${m(a)}"`).join(" ");n.push(`<base ${r}>`)}for(let r of e.meta||[]){let o=Object.entries(r).filter(([a,s])=>s!==void 0).map(([a,s])=>`${a==="httpEquiv"?"http-equiv":a}="${m(String(s))}"`).join(" ");n.push(`<meta ${o}>`)}for(let r of e.link||[]){let o=Object.entries(r).filter(([a,s])=>s!==void 0).map(([a,s])=>`${a}="${m(String(s))}"`).join(" ");n.push(`<link ${o}>`)}for(let r of e.script||[]){let{content:o,...a}=r,s=Object.entries(a).filter(([u,c])=>c!==void 0).map(([u,c])=>{if(typeof c==="boolean")return c?u:"";return`${u}="${m(String(c))}"`}).filter(Boolean).join(" ");if(o)n.push(`<script ${s}>${o}</script>`);else n.push(`<script ${s}></script>`)}for(let r of e.style||[]){let o=r.type?` type="${r.type}"`:"";n.push(`<style${o}>${r.content}</style>`)}return n.join(`
4
- `)}function Zu(e=d){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([n,r])=>`${n}="${m(r)}"`).join(" ")}function Qu(e=d){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([n,r])=>`${n}="${m(r)}"`).join(" ")}function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ed(e=d){if(typeof document>"u")return;if(e.title){let n=e.title;if(e.titleTemplate)n=typeof e.titleTemplate==="function"?e.titleTemplate(n):e.titleTemplate.replace("%s",n);document.title=n}for(let n of e.meta||[]){let r=n.name?`meta[name="${n.name}"]`:n.property?`meta[property="${n.property}"]`:null;if(r){let o=document.querySelector(r);if(!o){if(o=document.createElement("meta"),n.name)o.setAttribute("name",n.name);if(n.property)o.setAttribute("property",n.property);document.head.appendChild(o)}o.setAttribute("content",n.content)}}for(let n of e.link||[]){let r=`link[rel="${n.rel}"]${n.href?`[href="${n.href}"]`:""}`,o=document.querySelector(r);if(!o)o=document.createElement("link"),document.head.appendChild(o);for(let[a,s]of Object.entries(n))if(s!==void 0)o.setAttribute(a,String(s))}if(e.htmlAttrs)for(let[n,r]of Object.entries(e.htmlAttrs))if(n==="class")for(let o of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(o);else document.documentElement.setAttribute(n,r);if(e.bodyAttrs)for(let[n,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(n,r)}function td(e){let n="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(o,a)=>(n+=a.trim()+`
5
- `,"")),headContent:n.trim()}}function nd(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,o,a,s)=>{let u=o?a:n[(s||"").trim()]??s,c=n.__stx_runtime_head??{};return n.__stx_runtime_head=pe(c,{title:u}),""})}function rd(e,n,r=""){if(!e.includes("@meta"))return e;return Xe(e,/(?<![\w$@])@meta\s*\(/g,(o,a)=>{let s=ln(Ge(o),n);if(s.kind==="error")return E("Meta",a,s.message,r,s.code);if(s.kind==="tag"){let u=n.__stx_runtime_head??{};n.__stx_runtime_head=pe(u,{meta:[s.tag]})}return""},(o)=>E("Meta",o,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{S,_s,Xe,Ge,Je,ue,we,E,er,ln,un,tr,de,Ts,Ku,Xu,vi,pe,_c,nr,Gu,Ju,Yu,Zu,Qu,ed,td,nd,rd};
3
+ `:u==="t"?"\t":u;continue}if(s===r)return null;if(r==="`"&&s==="$"&&n[a+1]==="{")return null;o+=s}return o}var R=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Je(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let o=pn(r);if(o)return{ok:!1,message:`the expression is not allowed (${o})`,code:t.UNSAFE_EXPRESSION};let a=Ps(n),s;try{s=l(r,Object.keys(a))(...Object.values(a))}catch(c){return{ok:!1,message:`the expression could not be evaluated: ${c instanceof Error?c.message:String(c)}`,code:t.EVALUATION_ERROR}}if(s!==void 0&&s!==null)return{ok:!0,value:s};let u=[...new Set(ve(r))].filter((c)=>!R.has(c)&&!(c in a)&&!(c in globalThis));if(u.length>0)return{ok:!1,message:`${u.map((p)=>`"${p}"`).join(", ")} ${u.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(s===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:s}}function ue(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function we(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function v(e){if(!e)return"";return T.isAbsolute(e)?T.relative(process.cwd(),e)||e:e}function f(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function E(e,n,r,o,a=t.EVALUATION_ERROR){let s=o?` in ${v(o)}`:"";return console.warn(`[stx] ${f(n)}${s}: ${r}`),i(e,`${f(n)}: ${r}`,a)}function er(e,n,r){let o=r?` in ${v(r)}`:"";console.warn(`[stx] ${f(e)}${o}: ${n}`)}var x=["og:","article:","book:","profile:","fb:","music:","video:"],I=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function ln(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=_(e[0],n);if(typeof r!=="string")return r;let o;if(e.length===2){let s=C(e[1],n);if(typeof s!=="string")return s;o=s}else{let s=r.includes(":")?r.slice(r.indexOf(":")+1):r,u=n.openGraph,c=n[s]??(we(u)?u[s]:void 0);o=c===void 0||c===null||typeof c==="object"?"":String(c)}if(!o)return{kind:"empty"};return{kind:"tag",tag:x.some((s)=>r.startsWith(s))?{property:r,content:o}:{name:r,content:o}}}function _(e,n){let r=y(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(I.test(e.trim()))return e.trim();let o=Je(e,n);if(!o.ok)return{kind:"error",message:`meta name: ${o.message}`,code:o.code};if(typeof o.value!=="string"||!o.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${ue(o.value)}`,code:t.TYPE_ERROR};return o.value}function C(e,n){let r=y(e);if(r!==null)return r;let o=Je(e,n);if(!o.ok)return{kind:"error",message:o.message,code:o.code};let a=o.value;if(a===void 0||a===null||a===!1)return"";if(Array.isArray(a))return a.filter((s)=>s!==void 0&&s!==null&&s!=="").map(String).join(", ");if(typeof a==="object"&&!(a instanceof Date))return{kind:"error",message:`the content must be text, got ${ue(a)}`,code:t.TYPE_ERROR};return String(a)}var un=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],tr=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],w={links:"link",metas:"meta",scripts:"script",styles:"style"},b=new Set,A=new WeakMap;function k(e){if(b.has(e))return;b.add(e),console.warn(e)}function N(e,n){let r=Array.from({length:n.length+1},(o,a)=>a);for(let o=1;o<=e.length;o++){let a=r[0];r[0]=o;for(let s=1;s<=n.length;s++){let u=r[s];r[s]=Math.min(r[s]+1,r[s-1]+1,a+(e[o-1]===n[s-1]?0:1)),a=u}}return r[n.length]}function M(e,n){let r=e.toLowerCase(),o=n.find((p)=>p.toLowerCase()===r);if(o)return o;let a=w[r];if(a&&n.includes(a))return a;let s,u=1/0;for(let p of n){let h=N(r,p.toLowerCase());if(h<u)s=p,u=h}let c=Math.min(e.length,s?.length??0)<=4?1:2;return u<=c?s:void 0}function de(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=A.get(e);if(r)return r;let{known:o,source:a}=n,s=e;for(let u of Object.keys(e)){if(o.includes(u))continue;let c=w[u];if(c&&o.includes(c)&&Array.isArray(e[u])){if(s===e)s={...e};let h=Array.isArray(s[c])?s[c]:[];s[c]=[...h,...e[u]],delete s[u],k(`[stx] ${a}.${u} is not a head key; reading it as ${a}.${c}. Rename it to \`${c}\`.`);continue}if(/^styles?$/.test(u)&&!o.includes("style")){k(`[stx] ${a}.${u} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let p=M(u,o);k(p?`[stx] ${a}.${u} is not a head key and is ignored. Did you mean \`${p}\`?`:`[stx] ${a}.${u} is not a head key and is ignored. Known keys: ${o.join(", ")}.`)}return A.set(e,s),s}var d={},D=[],g={};function Ts(){return d}function Xu(){return g}function Gu(){d={},D.length=0,g={}}function vi(e){d=pe(d,de(e,{known:tr,source:"useHead()"}))}function pe(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:[...e.meta||[],...n.meta||[]],link:[...e.link||[],...n.link||[]],script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function Tc(e){vi(nr(e))}function nr(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let p=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:p})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,o=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(o)n.push({property:"og:description",content:o});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.push({property:"profile:username",content:e.profileUsername});let a=e.twitterTitle??e.title,s=e.twitterDescription??e.description,u=e.twitterImage??e.ogImage;if(e.twitterCard)n.push({name:"twitter:card",content:e.twitterCard});if(a)n.push({name:"twitter:title",content:a});if(s)n.push({name:"twitter:description",content:s});if(u){n.push({name:"twitter:image",content:u});let p=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(p)n.push({name:"twitter:image:alt",content:p})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let p of e.articleTags)n.push({property:"article:tag",content:p});let c=[];if(e.canonical)c.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:c}}function Ju(e){if(g={...g,...e},e.title||e.description)Tc({title:e.title,description:e.description})}function Yu(e){let n=typeof e==="function"?e():e;vi({title:n})}function Zu(e=d){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${m(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([o,a])=>`${o}="${m(a)}"`).join(" ");n.push(`<base ${r}>`)}for(let r of e.meta||[]){let o=Object.entries(r).filter(([a,s])=>s!==void 0).map(([a,s])=>`${a==="httpEquiv"?"http-equiv":a}="${m(String(s))}"`).join(" ");n.push(`<meta ${o}>`)}for(let r of e.link||[]){let o=Object.entries(r).filter(([a,s])=>s!==void 0).map(([a,s])=>`${a}="${m(String(s))}"`).join(" ");n.push(`<link ${o}>`)}for(let r of e.script||[]){let{content:o,...a}=r,s=Object.entries(a).filter(([u,c])=>c!==void 0).map(([u,c])=>{if(typeof c==="boolean")return c?u:"";return`${u}="${m(String(c))}"`}).filter(Boolean).join(" ");if(o)n.push(`<script ${s}>${o}</script>`);else n.push(`<script ${s}></script>`)}for(let r of e.style||[]){let o=r.type?` type="${r.type}"`:"";n.push(`<style${o}>${r.content}</style>`)}return n.join(`
4
+ `)}function Qu(e=d){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([n,r])=>`${n}="${m(r)}"`).join(" ")}function ed(e=d){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([n,r])=>`${n}="${m(r)}"`).join(" ")}function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function td(e=d){if(typeof document>"u")return;if(e.title){let n=e.title;if(e.titleTemplate)n=typeof e.titleTemplate==="function"?e.titleTemplate(n):e.titleTemplate.replace("%s",n);document.title=n}for(let n of e.meta||[]){let r=n.name?`meta[name="${n.name}"]`:n.property?`meta[property="${n.property}"]`:null;if(r){let o=document.querySelector(r);if(!o){if(o=document.createElement("meta"),n.name)o.setAttribute("name",n.name);if(n.property)o.setAttribute("property",n.property);document.head.appendChild(o)}o.setAttribute("content",n.content)}}for(let n of e.link||[]){let r=`link[rel="${n.rel}"]${n.href?`[href="${n.href}"]`:""}`,o=document.querySelector(r);if(!o)o=document.createElement("link"),document.head.appendChild(o);for(let[a,s]of Object.entries(n))if(s!==void 0)o.setAttribute(a,String(s))}if(e.htmlAttrs)for(let[n,r]of Object.entries(e.htmlAttrs))if(n==="class")for(let o of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(o);else document.documentElement.setAttribute(n,r);if(e.bodyAttrs)for(let[n,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(n,r)}function nd(e){let n="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(o,a)=>(n+=a.trim()+`
5
+ `,"")),headContent:n.trim()}}function rd(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,o,a,s)=>{let u=o?a:n[(s||"").trim()]??s,c=n.__stx_runtime_head??{};return n.__stx_runtime_head=pe(c,{title:u}),""})}function sd(e,n,r=""){if(!e.includes("@meta"))return e;return Xe(e,/(?<![\w$@])@meta\s*\(/g,(o,a)=>{let s=ln(Ge(o),n);if(s.kind==="error")return E("Meta",a,s.message,r,s.code);if(s.kind==="tag"){let u=n.__stx_runtime_head??{};n.__stx_runtime_head=pe(u,{meta:[s.tag]})}return""},(o)=>E("Meta",o,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{S,_s,Xe,Ge,Je,ue,we,E,er,ln,un,tr,de,Ts,Xu,Gu,vi,pe,Tc,nr,Ju,Yu,Zu,Qu,ed,td,nd,rd,sd};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{I,Ec,o,R,zu,Hu}from"./chunk-dqdggvq4.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-ng61wjke.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{R as config,I as defaultConfig,zu as defineStxConfig,o as loadStxConfig,Ec as resolveStxDirectories,Hu as validateConfig};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ki,Xc}from"./chunk-90drf2ag.js";export{Ki as captureScreenshot,Xc as captureScreenshots};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Pe,Wt,Xl}from"./chunk-hhsynd7c.js";import{V,_n,qt,Mr,Nr,Tn,Gl,Jl,Yl,Kt,Xt,Lr,Rn,Zl}from"./chunk-14vnnx44.js";import"./chunk-2jbyks2t.js";export{Mr as batch,Xl as default,_n as derived,qt as effect,Pe as generateSignalsRuntime,Wt as generateSignalsRuntimeDev,Xt as isDerived,Kt as isSignal,Tn as onDestroy,Nr as onMount,Rn as peek,Yl as pendingLifecycleCounts,Jl as runDestroyCallbacks,Gl as runMountCallbacks,V as state,Lr as untrack,Zl as useOptimistic};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{M,ae}from"./chunk-b6e36vr2.js";import{le,C,Ke}from"./chunk-zydg3wgt.js";import{Ze,G,xe}from"./chunk-5w87wmc4.js";import{Te,ne,_,re,co,Sr,lo,It}from"./chunk-m2yy86d8.js";import{Ur}from"./chunk-5pgvfxtx.js";import{Dt}from"./chunk-r80km6mn.js";import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),se=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ie=1024;function ce(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return se.some((o)=>e.startsWith(o))}function pe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ue(t){if(!t)return null;let e=pe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function me(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=J)break;H.delete(o),U-=r.length}}async function Pt(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ce(e.headers.get("content-type")))return e;let r=ue(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(a.length<(o.threshold??ie))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),me(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}import K from"fs";import P from"path";var{serve:fe}=globalThis.Bun;class q{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",_(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${ne(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):a()}}var de={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function cl(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=co(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Dt(r.routeRules),f=new q,h=Ur(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Ke(i.html,m);b.set(n.pattern,i),v.set(n.pattern,xe(i.html)),E.set(n.pattern,ae(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Ke(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=G(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=fe({port:o,async fetch(n){return Pt(n,await le(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=de[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),w=null,W={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,L)=>{W[R]=c[L+1]});break}}if(!w){let p=Ze(i)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=a(i),Y=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Te}}})}}let d=Sr(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await It(u,{params:W,request:n,method:n.method,__stx_strict_hydration:Y,__stx_runtime_config:m});if(L)return lo(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-amvnckr7.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=xe(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ae(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?re(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=xe(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",ae(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(re(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),Y)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
3
- export{Pt,cl};
2
+ import{M,ae}from"./chunk-dqdggvq4.js";import{le,C,Ke}from"./chunk-zydg3wgt.js";import{Ze,G,xe}from"./chunk-88px183j.js";import{Te,ne,_,re,co,Sr,lo,It}from"./chunk-y8mx0hab.js";import{Ur}from"./chunk-39q77svv.js";import{Dt}from"./chunk-r80km6mn.js";import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),se=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ie=1024;function ce(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return se.some((o)=>e.startsWith(o))}function pe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ue(t){if(!t)return null;let e=pe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function me(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=J)break;H.delete(o),U-=r.length}}async function Pt(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ce(e.headers.get("content-type")))return e;let r=ue(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(a.length<(o.threshold??ie))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),me(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}import K from"fs";import P from"path";var{serve:fe}=globalThis.Bun;class q{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",_(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${ne(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):a()}}var de={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function ll(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=co(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Dt(r.routeRules),f=new q,h=Ur(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Ke(i.html,m);b.set(n.pattern,i),v.set(n.pattern,xe(i.html)),E.set(n.pattern,ae(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Ke(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=G(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=fe({port:o,async fetch(n){return Pt(n,await le(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=de[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),w=null,W={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,L)=>{W[R]=c[L+1]});break}}if(!w){let p=Ze(i)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=a(i),Y=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Te}}})}}let d=Sr(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await It(u,{params:W,request:n,method:n.method,__stx_strict_hydration:Y,__stx_runtime_config:m});if(L)return lo(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-1p5ge6fq.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=xe(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ae(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?re(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=xe(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",ae(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(re(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),Y)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
3
+ export{Pt,ll};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Oi,Mi}from"./chunk-y9j2kf3k.js";import"./chunk-ery19t9s.js";import"./chunk-2cqymwe8.js";import"./chunk-ccy6avqe.js";import"./chunk-90drf2ag.js";import"./chunk-etjw0he9.js";import"./chunk-eegxyqk3.js";import"./chunk-a8q8m5pp.js";import"./chunk-rgwvqmhh.js";import"./chunk-jmhhv817.js";import"./chunk-xbm2gcb6.js";import{no}from"./chunk-y8mx0hab.js";import"./chunk-k9sbgax8.js";import"./chunk-z80d9dd2.js";import"./chunk-skjwh35r.js";import"./chunk-1k01h1zb.js";import"./chunk-7h57dt0z.js";import"./chunk-544e2jvd.js";import"./chunk-zasd9166.js";import"./chunk-bddjx2a2.js";import"./chunk-2bdthb37.js";import"./chunk-5yn0gpcj.js";import"./chunk-9fr19qe4.js";import"./chunk-9pt8fd2n.js";import"./chunk-t1py7rbg.js";import"./chunk-fh1qrp68.js";import"./chunk-pbh4smw3.js";import"./chunk-amd6ey3t.js";import"./chunk-tsg7bj9p.js";import"./chunk-hhsynd7c.js";import"./chunk-qr15ksz9.js";import"./chunk-mfxf378k.js";import"./chunk-5j5msbks.js";import"./chunk-kdk0jy1h.js";import"./chunk-39q77svv.js";import{me,Qt,en,K,d,n,Kn,I,o,ce}from"./chunk-dqdggvq4.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-ng61wjke.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{Kn as buildWebComponents,en as cacheTemplate,Qt as checkCache,no as classifyAllScripts,Oi as createMiddleware,Mi as createRoute,I as defaultConfig,d as extractVariables,K as injectRouterScript,o as loadStxConfig,me as processClientScript,n as processDirectives,ce as readMarkdownFile};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{uo,ul}from"./chunk-k9sbgax8.js";export{uo as definePlugin,ul as pluginManager};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{t,i}from"./chunk-ynvce0q6.js";import{Xe,Ge,Je,ue,we,E,er,ln,pe}from"./chunk-8yrk8ybh.js";var C=/(?<![\w$@])@meta\s*\(/g,x=/(?<![\w$@])@metaTag\s*\(/g,N=/(?<![\w$@])@structuredData\s*\(/g,k=/(?<![\w$@])@seo\s*\(/g;function S(e,r){return(n)=>E(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function j(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function ks(e,r,n,p){if(!e.includes("@meta"))return e;let s=Xe(e,C,(a,c)=>{let o=ln(Ge(a),r);if(o.kind==="tag")return j(o.tag);if(o.kind==="empty")return"";return E("Meta",c,o.message,n,o.code)},S("Meta",n));return s=Xe(s,x,(a,c)=>{let o=Je(a,r);if(!o.ok)return E("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!we(o.value))return E("MetaTag",c,`expected an object such as { name, content }, got ${ue(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return E("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let g="<meta";if(u.name)g+=` name="${l(u.name)}"`;if(u.property)g+=` property="${l(u.property)}"`;if(u.httpEquiv)g+=` http-equiv="${l(u.httpEquiv)}"`;return g+=` content="${l(u.content)}">`,g},S("MetaTag",n)),s}function b(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(we(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(we))return e.map(r);return null}function _(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function Cs(e,r,n){if(!e.includes("@structuredData"))return e;return Xe(e,N,(p,s)=>{let a=Je(p,r);if(!a.ok)return E("StructuredData",s,a.message,n,a.code);if(a.value===void 0||a.value===null)return"";let c=b(a.value);if(!c)return E("StructuredData",s,`expected an object or an array of objects, got ${ue(a.value)}`,n,t.TYPE_ERROR);try{return _(c)}catch(o){let u=o instanceof Error?o.message:String(o);return E("StructuredData",s,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},S("StructuredData",n))}var L=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),A={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function $s(e,r,n,p){if(!e.includes("@seo"))return e;return Xe(e,k,(s,a)=>{if(!s.trim())return E("SEO",a,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Je(s,r);if(!c.ok)return E("SEO",a,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!we(c.value))return E("SEO",a,`expected an object such as { title, description }, got ${ue(c.value)}`,n,t.TYPE_ERROR);try{return q(c.value,a,n)}catch(o){let u=o instanceof Error?o.message:String(o);return E("SEO",a,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},S("SEO",n))}function R(e,r,n,p){let s=e[r];if(s===void 0||s===null||s===!1)return;if(we(s))return s;er(n,`${r} must be an object, got ${ue(s)}; its tags were left out`,p);return}function q(e,r,n){let p=Object.keys(e).filter((o)=>!L.has(o));if(p.length>0){let o=p.map((u)=>A[u]?`${u} (use ${A[u]})`:u).join(", ");er(r,`@seo does not read ${o}; ${p.length===1?"it was":"they were"} ignored`,n)}let s="";if(e.title)s+=`<title>${l(e.title)}</title>
2
+ import{t,i}from"./chunk-ynvce0q6.js";import{Xe,Ge,Je,ue,we,E,er,ln,pe}from"./chunk-v83bpj84.js";var C=/(?<![\w$@])@meta\s*\(/g,x=/(?<![\w$@])@metaTag\s*\(/g,N=/(?<![\w$@])@structuredData\s*\(/g,k=/(?<![\w$@])@seo\s*\(/g;function S(e,r){return(n)=>E(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function j(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function ks(e,r,n,p){if(!e.includes("@meta"))return e;let s=Xe(e,C,(a,c)=>{let o=ln(Ge(a),r);if(o.kind==="tag")return j(o.tag);if(o.kind==="empty")return"";return E("Meta",c,o.message,n,o.code)},S("Meta",n));return s=Xe(s,x,(a,c)=>{let o=Je(a,r);if(!o.ok)return E("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!we(o.value))return E("MetaTag",c,`expected an object such as { name, content }, got ${ue(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return E("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let g="<meta";if(u.name)g+=` name="${l(u.name)}"`;if(u.property)g+=` property="${l(u.property)}"`;if(u.httpEquiv)g+=` http-equiv="${l(u.httpEquiv)}"`;return g+=` content="${l(u.content)}">`,g},S("MetaTag",n)),s}function b(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(we(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(we))return e.map(r);return null}function _(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function Cs(e,r,n){if(!e.includes("@structuredData"))return e;return Xe(e,N,(p,s)=>{let a=Je(p,r);if(!a.ok)return E("StructuredData",s,a.message,n,a.code);if(a.value===void 0||a.value===null)return"";let c=b(a.value);if(!c)return E("StructuredData",s,`expected an object or an array of objects, got ${ue(a.value)}`,n,t.TYPE_ERROR);try{return _(c)}catch(o){let u=o instanceof Error?o.message:String(o);return E("StructuredData",s,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},S("StructuredData",n))}var L=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),A={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function $s(e,r,n,p){if(!e.includes("@seo"))return e;return Xe(e,k,(s,a)=>{if(!s.trim())return E("SEO",a,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Je(s,r);if(!c.ok)return E("SEO",a,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!we(c.value))return E("SEO",a,`expected an object such as { title, description }, got ${ue(c.value)}`,n,t.TYPE_ERROR);try{return q(c.value,a,n)}catch(o){let u=o instanceof Error?o.message:String(o);return E("SEO",a,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},S("SEO",n))}function R(e,r,n,p){let s=e[r];if(s===void 0||s===null||s===!1)return;if(we(s))return s;er(n,`${r} must be an object, got ${ue(s)}; its tags were left out`,p);return}function q(e,r,n){let p=Object.keys(e).filter((o)=>!L.has(o));if(p.length>0){let o=p.map((u)=>A[u]?`${u} (use ${A[u]})`:u).join(", ");er(r,`@seo does not read ${o}; ${p.length===1?"it was":"they were"} ignored`,n)}let s="";if(e.title)s+=`<title>${l(e.title)}</title>
3
3
  `,s+=`<meta name="title" content="${l(e.title)}">
4
4
  `;if(e.description)s+=`<meta name="description" content="${l(e.description)}">
5
5
  `;if(e.keywords){let o=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;s+=`<meta name="keywords" content="${l(o)}">
@@ -43,7 +43,7 @@ import{t,i}from"./chunk-ynvce0q6.js";import{Xe,Ge,Je,ue,we,E,er,ln,pe}from"./chu
43
43
  ${T}
44
44
  `),y;return y.replace(/<head[^>]*>/,`$&
45
45
  ${T}
46
- `)}function M(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function v(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0*39;|&apos;/g,"'").replace(/&amp;/g,"&")}function V(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?v(r[1].trim()):""}function O(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function G(e){return O(e).length>0}function U(e){for(let r of O(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),p=(n?.[1]??n?.[2]??"").trim();if(p)return v(p)}return""}function l(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var Yn={name:"meta",rawParams:!0,handler:(e,r,n,p)=>{let s=ln(r,n??{});if(s.kind==="error")return E("Meta",`@meta(${r.join(", ")})`,s.message,p,s.code);if(s.kind==="empty")return"";if(n)n.__stx_runtime_head=pe(n.__stx_runtime_head??{},{meta:[s.tag]});return""},hasEndTag:!1},Zn={name:"structuredData",handler:(e,r,n,p)=>{if(e.trim()==="")return i("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let s=JSON.parse(e);if(!s["@context"])s["@context"]="https://schema.org";if(!s["@type"])return i("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return _(s)}catch(s){let a=s instanceof Error?s.message:String(s);return i("StructuredData",a,t.EVALUATION_ERROR)}},hasEndTag:!0};function Hu(){return[Yn,Zn]}function Vu(e,r){let{baseUrl:n,defaultChangefreq:p="weekly",defaultPriority:s=0.5,includeLastmod:a=!0}=r,c=n.replace(/\/$/,"");return`<?xml version="1.0" encoding="UTF-8"?>
46
+ `)}function M(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function v(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0*39;|&apos;/g,"'").replace(/&amp;/g,"&")}function V(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?v(r[1].trim()):""}function O(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function G(e){return O(e).length>0}function U(e){for(let r of O(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),p=(n?.[1]??n?.[2]??"").trim();if(p)return v(p)}return""}function l(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var Yn={name:"meta",rawParams:!0,handler:(e,r,n,p)=>{let s=ln(r,n??{});if(s.kind==="error")return E("Meta",`@meta(${r.join(", ")})`,s.message,p,s.code);if(s.kind==="empty")return"";if(n)n.__stx_runtime_head=pe(n.__stx_runtime_head??{},{meta:[s.tag]});return""},hasEndTag:!1},Zn={name:"structuredData",handler:(e,r,n,p)=>{if(e.trim()==="")return i("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let s=JSON.parse(e);if(!s["@context"])s["@context"]="https://schema.org";if(!s["@type"])return i("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return _(s)}catch(s){let a=s instanceof Error?s.message:String(s);return i("StructuredData",a,t.EVALUATION_ERROR)}},hasEndTag:!0};function Vu(){return[Yn,Zn]}function Uu(e,r){let{baseUrl:n,defaultChangefreq:p="weekly",defaultPriority:s=0.5,includeLastmod:a=!0}=r,c=n.replace(/\/$/,"");return`<?xml version="1.0" encoding="UTF-8"?>
47
47
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
48
48
  ${e.map((u)=>{let g=u.loc.startsWith("http")?u.loc:`${c}${u.loc.startsWith("/")?"":"/"}${u.loc}`,m=u.lastmod||(a?new Date().toISOString().split("T")[0]:void 0),d=u.changefreq||p,f=u.priority??s,h=` <url>
49
49
  <loc>${I(g)}</loc>`;if(m)h+=`
@@ -52,13 +52,13 @@ ${e.map((u)=>{let g=u.loc.startsWith("http")?u.loc:`${c}${u.loc.startsWith("/")?
52
52
  <priority>${f.toFixed(1)}</priority>`,h+=`
53
53
  </url>`,h}).join(`
54
54
  `)}
55
- </urlset>`}function Uu(e,r){let n=r.replace(/\/$/,""),p=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
55
+ </urlset>`}function Wu(e,r){let n=r.replace(/\/$/,""),p=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
56
56
  <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
57
57
  ${e.map((a)=>{let c=a.startsWith("http")?a:`${n}${a.startsWith("/")?"":"/"}${a}`;return` <sitemap>
58
58
  <loc>${I(c)}</loc>
59
59
  <lastmod>${p}</lastmod>
60
60
  </sitemap>`}).join(`
61
61
  `)}
62
- </sitemapindex>`}async function Wu(e,r){let{extensions:n=[".stx",".html",".htm"],ignore:p=["_*",".*","node_modules","components","partials","layouts"]}=r,s=[],a=n.length===1?`*${n[0]}`:`*{${n.join(",")}}`,c=new Bun.Glob(`**/${a}`);for await(let o of c.scan(e)){if(p.some((f)=>{if(f.startsWith("*"))return o.includes(f.slice(1));return o.startsWith(f)||o.includes(`/${f}`)}))continue;let g=o.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!g.startsWith("/"))g=`/${g}`;if(g!=="/"&&g.endsWith("/"))g=g.slice(0,-1);let m=`${e}/${o}`,d;try{let f=await Bun.file(m).stat();if(f)d=new Date(f.mtime).toISOString().split("T")[0]}catch{}s.push({loc:g||"/",lastmod:d,priority:g==="/"?1:0.5})}return s.sort((o,u)=>o.loc.localeCompare(u.loc)),s}function Qn(e){let r=[];for(let n of e.rules){if(r.push(`User-agent: ${n.userAgent}`),n.allow)for(let p of n.allow)r.push(`Allow: ${p}`);if(n.disallow)for(let p of n.disallow)r.push(`Disallow: ${p}`);if(n.crawlDelay!==void 0)r.push(`Crawl-delay: ${n.crawlDelay}`);r.push("")}if(e.sitemap){let n=Array.isArray(e.sitemap)?e.sitemap:[e.sitemap];for(let p of n)r.push(`Sitemap: ${p}`)}if(e.host)r.push(`Host: ${e.host}`);return r.join(`
63
- `).trim()}function qu(e){return Qn({rules:[{userAgent:"*",allow:["/"]}],sitemap:e})}function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}
64
- export{ks,Cs,$s,Es,Yn,Zn,Hu,Vu,Uu,Wu,Qn,qu};
62
+ </sitemapindex>`}async function qu(e,r){let{extensions:n=[".stx",".html",".htm"],ignore:p=["_*",".*","node_modules","components","partials","layouts"]}=r,s=[],a=n.length===1?`*${n[0]}`:`*{${n.join(",")}}`,c=new Bun.Glob(`**/${a}`);for await(let o of c.scan(e)){if(p.some((f)=>{if(f.startsWith("*"))return o.includes(f.slice(1));return o.startsWith(f)||o.includes(`/${f}`)}))continue;let g=o.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!g.startsWith("/"))g=`/${g}`;if(g!=="/"&&g.endsWith("/"))g=g.slice(0,-1);let m=`${e}/${o}`,d;try{let f=await Bun.file(m).stat();if(f)d=new Date(f.mtime).toISOString().split("T")[0]}catch{}s.push({loc:g||"/",lastmod:d,priority:g==="/"?1:0.5})}return s.sort((o,u)=>o.loc.localeCompare(u.loc)),s}function Qn(e){let r=[];for(let n of e.rules){if(r.push(`User-agent: ${n.userAgent}`),n.allow)for(let p of n.allow)r.push(`Allow: ${p}`);if(n.disallow)for(let p of n.disallow)r.push(`Disallow: ${p}`);if(n.crawlDelay!==void 0)r.push(`Crawl-delay: ${n.crawlDelay}`);r.push("")}if(e.sitemap){let n=Array.isArray(e.sitemap)?e.sitemap:[e.sitemap];for(let p of n)r.push(`Sitemap: ${p}`)}if(e.host)r.push(`Host: ${e.host}`);return r.join(`
63
+ `).trim()}function Ku(e){return Qn({rules:[{userAgent:"*",allow:["/"]}],sitemap:e})}function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}
64
+ export{ks,Cs,$s,Es,Yn,Zn,Vu,Uu,Wu,qu,Qn,Ku};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{zo,Jr,Y,Le,vt,x,Be,Fe,zn,d,sn}from"./chunk-b6e36vr2.js";import{O}from"./chunk-58n62bxb.js";import v from"path";var D=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(D.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function no(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=Le(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),u=H.exec(c);if(u){let l=F(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(P(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,p;while((p=l.exec(t))!==null){if(P(p.index,o))continue;let h=p[1]==="/";if(!h&&(p[2]||"").trimEnd().endsWith("/"))continue;if(f+=h?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:p.index,tagName:a}}return null}return null}var Te="private, no-store";function ro(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function _(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,A={dev:null,prod:null};function W(){let t=O()?"dev":"prod",n=A[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-gn32cr6z.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;A[t]=`<script>${r()}</script>`}catch{A[t]=""}return A[t]}async function so(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=v.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=v.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function xr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=no(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)i.push(u[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:p,extractVariables:h,defaultConfig:S,loadStxConfig:b}=await import("./chunk-y2p3scx0.js"),R=await b(),g={__filename:t,__dirname:v.dirname(t)};for(let m of a){let C=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!m.includes("client")&&!m.includes('type="module"'))await h(C[1],g,t)}let y=await p(l,g,t,{...S,...R,...n},new Set),w=y.indexOf(f);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:y.substring(0,w),afterSlot:y.substring(w+f.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function Cn(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),f=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(f)r=f[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
2
+ import{zo,Jr,Y,Le,vt,x,Be,Fe,zn,d,sn}from"./chunk-dqdggvq4.js";import{O}from"./chunk-58n62bxb.js";import v from"path";var D=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(D.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function no(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=Le(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),u=H.exec(c);if(u){let l=F(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(P(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,p;while((p=l.exec(t))!==null){if(P(p.index,o))continue;let h=p[1]==="/";if(!h&&(p[2]||"").trimEnd().endsWith("/"))continue;if(f+=h?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:p.index,tagName:a}}return null}return null}var Te="private, no-store";function ro(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function _(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,A={dev:null,prod:null};function W(){let t=O()?"dev":"prod",n=A[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-5564cka1.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;A[t]=`<script>${r()}</script>`}catch{A[t]=""}return A[t]}async function so(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=v.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=v.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function xr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=no(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)i.push(u[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:p,extractVariables:h,defaultConfig:S,loadStxConfig:b}=await import("./chunk-xek78ez1.js"),R=await b(),g={__filename:t,__dirname:v.dirname(t)};for(let m of a){let C=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!m.includes("client")&&!m.includes('type="module"'))await h(C[1],g,t)}let y=await p(l,g,t,{...S,...R,...n},new Set),w=y.indexOf(f);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:y.substring(0,w),afterSlot:y.substring(w+f.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function Cn(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),f=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(f)r=f[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -26,5 +26,5 @@ ${i}
26
26
  `));if(o.length>0)S.push(o.join(`
27
27
  `));if(f.length>0)S.push(f.join(`
28
28
  `));return S.push(l),S.join(`
29
- `)}function E(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function Sr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function I(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Sr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(E(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(E(e,o.value,o))}}return n}function lo(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import j from"path";function io(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function ao(t,n){let e=j.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function co(t){let n=j.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function It(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Be(r),i=Fe(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-amvnckr7.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-yxwam84p.js"),{defaultConfig:p}=await import("./chunk-1fccwkkq.js"),h=r.streamBoundaries||{},S={...p,autoShell:!1},b=Object.keys(l).map((g)=>({id:g,render:async()=>{let y=typeof h[g]==="function"?await h[g]():void 0;return f(l[g],{...r,$boundary:y},t.sourceFile,S,new Set)}})),R=new Set(b.map((g)=>g.id));u=[...(u||[]).filter((g)=>!R.has(g.id)),...b]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Jr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await d(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await I(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=zn(e);if(!c)return i;let u=i.indexOf("</head>");return u<0?c+i:i.slice(0,u)+c+i.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Jr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=x(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?vt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(zo(t.html,s)),context:e,cookies:r.cookies}}
29
+ `)}function E(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function Sr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function I(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Sr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(E(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(E(e,o.value,o))}}return n}function lo(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import j from"path";function io(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function ao(t,n){let e=j.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function co(t){let n=j.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function It(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Be(r),i=Fe(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-1p5ge6fq.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-rjm3n62n.js"),{defaultConfig:p}=await import("./chunk-vhdemrec.js"),h=r.streamBoundaries||{},S={...p,autoShell:!1},b=Object.keys(l).map((g)=>({id:g,render:async()=>{let y=typeof h[g]==="function"?await h[g]():void 0;return f(l[g],{...r,$boundary:y},t.sourceFile,S,new Set)}})),R=new Set(b.map((g)=>g.id));u=[...(u||[]).filter((g)=>!R.has(g.id)),...b]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Jr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await d(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await I(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=zn(e);if(!c)return i;let u=i.indexOf("</head>");return u<0?c+i:i.slice(0,u)+c+i.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Jr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=x(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?vt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(zo(t.html,s)),context:e,cookies:r.cookies}}
30
30
  export{no,Te,ro,ne,_,so,xr,Cn,ge,oo,re,io,ao,co,Sr,lo,It};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{X,dn,te,A,_t}from"./chunk-ynvce0q6.js";import{Ze,mn,ir,ar,cr,Qe,et,tt,nt,rt,st,xe}from"./chunk-5w87wmc4.js";import{U,b,Qt,en,e,xt,tn,f,je,St,Be,Fe,Z,N,ae,K,d,ye,ai,ms,n,r,ee,Kn,o,R,ce}from"./chunk-b6e36vr2.js";import{Te,ro,ne,_,so,xr,Cn,ge,oo,re}from"./chunk-m2yy86d8.js";import{Pt}from"./chunk-wz29ahjp.js";import{De}from"./chunk-a6pjaw6w.js";import{a}from"./chunk-7tt84v1y.js";import{O}from"./chunk-58n62bxb.js";function Hs(t,s){let i=[],p=`${s}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)i.push(m);continue}if(l===s){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))i.push(m),c++}}return i}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
2
+ import{X,dn,te,A,_t}from"./chunk-ynvce0q6.js";import{Ze,mn,ir,ar,cr,Qe,et,tt,nt,rt,st,xe}from"./chunk-88px183j.js";import{U,b,Qt,en,e,xt,tn,f,je,St,Be,Fe,Z,N,ae,K,d,ye,ai,ms,n,r,ee,Kn,o,R,ce}from"./chunk-dqdggvq4.js";import{Te,ro,ne,_,so,xr,Cn,ge,oo,re}from"./chunk-y8mx0hab.js";import{Pt}from"./chunk-xbm2gcb6.js";import{De}from"./chunk-kdk0jy1h.js";import{a}from"./chunk-7tt84v1y.js";import{O}from"./chunk-58n62bxb.js";function Hs(t,s){let i=[],p=`${s}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)i.push(m);continue}if(l===s){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))i.push(m),c++}}return i}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
3
3
  /* Theme selector for code blocks */
4
4
  .theme-selector {
5
5
  margin: 1rem 0;
@@ -1786,7 +1786,7 @@ else {
1786
1786
  })()
1787
1787
  </script>
1788
1788
  `;import _e from"fs";import $e from"path";function An(t){try{return _e.statSync(t).mtimeMs}catch{return null}}function Dt(t,s){let i=Math.max(0,Math.round((s-t)/1000));if(i<60)return`${i}s ago`;if(i<3600)return`${Math.round(i/60)}m ago`;return`${Math.round(i/3600)}h ago`}function Ei(t,s){try{return globalThis.Bun?.resolveSync(t,s)??null}catch{return null}}function Dn(t,s="stx"){let i=$e.resolve(t);for(let p=0;p<10;p++){let c=$e.join(i,"pantry","@stacksjs",s);if(_e.existsSync(c))return c;let l=$e.dirname(i);if(l===i)break;i=l}return null}var Mn=["@stacksjs/stx","bun-plugin-stx"];function Pi(t){try{let s=_e.readFileSync($e.join(t,"package.json"),"utf8"),i=JSON.parse(s)?.version;return typeof i==="string"?i:null}catch{return null}}function Ai(t,s=6){let i=$e.resolve(t),p=[],c=new Set;function l(u,h){if(h>s)return;let g;try{g=_e.realpathSync(u)}catch{return}if(c.has(g))return;c.add(g);for(let w of Mn){let S=$e.join(u,w),C=Pi(S);if(C!==null)p.push({name:w,version:C,dir:$e.relative(i,S)||S,nested:h>0})}let y;try{y=_e.readdirSync(u,{withFileTypes:!0})}catch{return}for(let w of y){if(!w.isDirectory()&&!w.isSymbolicLink())continue;if(w.name===".bin"||w.name===".cache")continue;let S=$e.join(u,w.name);if(w.name.startsWith("@")){let v;try{v=_e.readdirSync(S,{withFileTypes:!0})}catch{continue}for(let x of v){let T=$e.join(S,x.name,"node_modules");if(_e.existsSync(T))l(T,h+1)}continue}let C=$e.join(S,"node_modules");if(_e.existsSync(C))l(C,h+1)}}let m=$e.join(i,"node_modules");if(_e.existsSync(m))l(m,0);return p}function Di(t){let s=[];for(let i of Mn){let p=t.filter((m)=>m.name===i);if(p.length<=1)continue;let c=[...new Set(p.map((m)=>m.version))],l=p.map((m)=>`${m.version} at ${m.dir}`).join("; ");if(c.length===1){s.push({name:`${i} copies`,status:"info",detail:`${p.length} copies, all ${c[0]} \u2014 duplicated but in agreement`});continue}s.push({name:`${i} copies disagree`,status:"error",detail:`${c.length} versions installed, so which one runs depends on who imports it: ${l}`,fix:`remove the nested copies, or add an overrides entry pinning ${i}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${i}/package.json' -exec grep -H '"version"' {} +`})}return s}async function gr(t={}){let s=t.cwd?$e.resolve(t.cwd):process.cwd(),i=t.resolve??Ei,p=Date.now(),c=[],l=i("@stacksjs/stx",s);c.push(l?{name:"@stacksjs/stx resolves to",status:"ok",detail:l}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let m=i("bun-plugin-stx",s);if(m)c.push({name:"bun-plugin-stx resolves to",status:"ok",detail:m});for(let h of Di(Ai(s)))c.push(h);let u=Dn(s,"stx");if(!u)c.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let h=$e.join(u,"src/signals.ts"),g=[$e.join(u,"dist/index.js"),$e.join(u,"dist/signals.js")].find((v)=>_e.existsSync(v))||null,y=An(h),w=g?An(g):null;if(y==null)c.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${u} but no src/signals.ts to compare`});else if(w==null)c.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${u} && bun build.ts`});else if(w<y){let v=Math.round((y-w)/1000);c.push({name:"pantry dist freshness",status:"error",detail:`dist (${Dt(w,p)}) is OLDER than src/signals.ts (${Dt(y,p)}) by ${v}s \u2014 your edit isn't built`,fix:`cd ${u} && bun build.ts`})}else c.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${Dt(y,p)}, dist ${Dt(w,p)})`});let S=$e.join(s,"node_modules/@stacksjs/stx"),C=null;try{C=_e.lstatSync(S)}catch{C=null}if(!C)c.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(C.isSymbolicLink()){let v=null;try{v=_e.realpathSync(S)}catch{}let x=(()=>{try{return _e.realpathSync(u)}catch{return u}})();c.push(v===x?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${v||"(dangling)"}, not pantry`})}else c.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(c.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),t.generateRuntime)try{let g=t.generateRuntime().length;c.push(g>1000?{name:"signals runtime",status:"ok",detail:`generated ${g.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${g} chars \u2014 suspiciously short`})}catch(h){c.push({name:"signals runtime",status:"error",detail:`failed to generate: ${h.message}`})}return{checks:c,ok:!c.some((h)=>h.status==="error")}}function mr(t){let s={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},i=["stx runtime resolution:"];for(let p of t.checks)if(i.push(` ${s[p.status]} ${p.name}: ${p.detail}`),p.fix)i.push(` \u2192 ${p.fix}`);return i.push(""),i.push(t.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),i.join(`
1789
- `)}var ft={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},p=new Set,c=i.webComponents?.enabled?`./${Mt.relative(Mt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await Kn(i,p);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let u=new Set;if(i.cache&&i.cachePath){let x=await Qt(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await te(()=>Bun.file(m).text(),"",(x)=>{throw new dn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new dn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=U.time("script-extraction",()=>{let x=h,T=Z(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",M=[];for(let E of k){let L=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=E.match(/<script\b([^>]*)>/i),G=B?B[1]:"";if(/\bserver\b/i.test(G))H=L;else M.push(E)}let I=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:I,allScripts:M}}),S={__filename:m,__dirname:Mt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await te(()=>d(g,S,m),void 0,(x)=>{let T=new X(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(A.log(T,{filePath:m,scriptContent:g}),i.debug)throw T});let v=await U.timeAsync("directive-processing",async()=>await n(y,S,m,i,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-9y6bn8hk.js"),T=x(w.join(`
1789
+ `)}var ft={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},p=new Set,c=i.webComponents?.enabled?`./${Mt.relative(Mt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await Kn(i,p);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let u=new Set;if(i.cache&&i.cachePath){let x=await Qt(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await te(()=>Bun.file(m).text(),"",(x)=>{throw new dn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new dn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=U.time("script-extraction",()=>{let x=h,T=Z(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",M=[];for(let E of k){let L=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=E.match(/<script\b([^>]*)>/i),G=B?B[1]:"";if(/\bserver\b/i.test(G))H=L;else M.push(E)}let I=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:I,allScripts:M}}),S={__filename:m,__dirname:Mt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await te(()=>d(g,S,m),void 0,(x)=>{let T=new X(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(A.log(T,{filePath:m,scriptContent:g}),i.debug)throw T});let v=await U.timeAsync("directive-processing",async()=>await n(y,S,m,i,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-raeyd6e5.js"),T=x(w.join(`
1790
1790
  `),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+T+`
1791
1791
  `+v.slice(k);else v+=`
1792
1792
  ${T}`}if(v=await K(v),u.forEach((x)=>p.add(x)),i.cache&&i.cachePath){if(await en(m,v,u,i),i.debug)console.log(`Cached template ${m} with ${u.size} dependencies`)}return{contents:v,loader:"html"}}catch(u){let h=u instanceof Error?u:new X(`Plugin processing failed: ${String(u)}`,m);if(A.log(h,{filePath:m,buildConfig:t.config}),_t.logDetailedError(h,{filePath:m,plugin:"bun-plugin-stx"}),i.debug)console.error("stx Plugin Error:",h);let g=h,y=g.line||null,w=g.context||null;return{contents:i.debug||O()?`<!DOCTYPE html>
@@ -1849,7 +1849,7 @@ ${T}`}if(v=await K(v),u.forEach((x)=>p.add(x)),i.cache&&i.cachePath){if(await en
1849
1849
  <h1>Something went wrong</h1>
1850
1850
  <p>An internal error occurred. Please try again later.</p>
1851
1851
  </body>
1852
- </html>`,loader:"html"}}})}};async function bn(t,s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=Se.resolve(t);if(!Ne.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,s);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");Ne.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let L={name:"public-assets",setup(Ce){Ce.onResolve({filter:/^\/(images|fonts|assets|public)\//},(he)=>({path:he.path,external:!0}))}},B=await Bun.build({entrypoints:[u],outdir:h,plugins:[L,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let G=B.outputs.find((Ce)=>Ce.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(L){return console.error(`${e.red}Error building stx file:${e.reset}`,L),!1}};if(!await y())return!1;let S=Se.dirname(u);await xt(S);let C=i;try{if(C=await Ye(i),C!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let L=s.hmrPort||C+1;l=Et({wsPort:L,verbose:!1}),m=l.start(L)}let v={},x=null,T;try{let{loadStxConfig:L}=await import("./chunk-y2p3scx0.js"),B=await L();if(T=s.stxOptions?.serverApi??B.serverApi,B?.apiRouter)x=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){v=B.apiRoutes;let G=Object.keys(v).length;if(G>0)console.log(`${e.blue}Loaded ${e.bright}${G} API route${G>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:oe}=await import("./chunk-vrvnctex.js"),Ce=B.broadcasting;await G(Ce);let he=Ce.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${he}/ws${e.reset}`);let Ae=Se.join(process.cwd(),"channels.ts");if(Ne.existsSync(Ae))try{let le=await oe(Ae);console.log(`${e.blue}Loaded ${e.bright}${le} broadcast channel${le!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(le){console.warn(`${e.yellow}Failed to load channels.ts: ${le.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:H}=await import("./chunk-0f1f6y2w.js"),M=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let I=Ni({port:C,async fetch(L){return Pt(L,await(async()=>{let B=new URL(L.url);if([h,Se.dirname(u),Se.join(process.cwd(),"public")].some((le)=>H(Se.join(le,B.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let le=await x.handleRequest(L);if(le.status!==404)return le}catch{}if(v[B.pathname])try{return await v[B.pathname](L)}catch(le){return new Response(JSON.stringify({error:le.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await M(L);if(G)return G;if(B.pathname==="/")return(async()=>{let W=await f(g||"");if(c)W=Xe(W,m);if(s.native)if(W.includes("<head>"))W=W.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else W="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+W;if(s.titlebarHidden)if(W.includes("<head>"))W=W.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else W=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${W}`;return W})().then((W)=>new Response(W,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let oe=Se.join(h,B.pathname);if(Ne.existsSync(oe)&&Ne.statSync(oe).isFile()){let le=Bun.file(oe),W=Se.extname(oe).toLowerCase(),j="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":j}})}let Ce=Se.dirname(u),he=Se.join(Ce,B.pathname);if(Ne.existsSync(he)&&Ne.statSync(he).isFile()){let le=Bun.file(he),W=Se.extname(he).toLowerCase(),j="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":j}})}let Ae=Se.join(process.cwd(),"public",B.pathname);if(Ne.existsSync(Ae)&&Ne.statSync(Ae).isFile()){let le=Bun.file(Ae),W=Se.extname(Ae).toLowerCase(),j="application/octet-stream";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(L){return new Response(`<pre>${L}
1852
+ </html>`,loader:"html"}}})}};async function bn(t,s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=Se.resolve(t);if(!Ne.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,s);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");Ne.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let L={name:"public-assets",setup(Ce){Ce.onResolve({filter:/^\/(images|fonts|assets|public)\//},(he)=>({path:he.path,external:!0}))}},B=await Bun.build({entrypoints:[u],outdir:h,plugins:[L,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let G=B.outputs.find((Ce)=>Ce.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(L){return console.error(`${e.red}Error building stx file:${e.reset}`,L),!1}};if(!await y())return!1;let S=Se.dirname(u);await xt(S);let C=i;try{if(C=await Ye(i),C!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let L=s.hmrPort||C+1;l=Et({wsPort:L,verbose:!1}),m=l.start(L)}let v={},x=null,T;try{let{loadStxConfig:L}=await import("./chunk-xek78ez1.js"),B=await L();if(T=s.stxOptions?.serverApi??B.serverApi,B?.apiRouter)x=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){v=B.apiRoutes;let G=Object.keys(v).length;if(G>0)console.log(`${e.blue}Loaded ${e.bright}${G} API route${G>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:oe}=await import("./chunk-k2vcwa7m.js"),Ce=B.broadcasting;await G(Ce);let he=Ce.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${he}/ws${e.reset}`);let Ae=Se.join(process.cwd(),"channels.ts");if(Ne.existsSync(Ae))try{let le=await oe(Ae);console.log(`${e.blue}Loaded ${e.bright}${le} broadcast channel${le!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(le){console.warn(`${e.yellow}Failed to load channels.ts: ${le.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:H}=await import("./chunk-r5gyx7ch.js"),M=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let I=Ni({port:C,async fetch(L){return Pt(L,await(async()=>{let B=new URL(L.url);if([h,Se.dirname(u),Se.join(process.cwd(),"public")].some((le)=>H(Se.join(le,B.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let le=await x.handleRequest(L);if(le.status!==404)return le}catch{}if(v[B.pathname])try{return await v[B.pathname](L)}catch(le){return new Response(JSON.stringify({error:le.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await M(L);if(G)return G;if(B.pathname==="/")return(async()=>{let W=await f(g||"");if(c)W=Xe(W,m);if(s.native)if(W.includes("<head>"))W=W.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else W="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+W;if(s.titlebarHidden)if(W.includes("<head>"))W=W.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else W=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${W}`;return W})().then((W)=>new Response(W,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let oe=Se.join(h,B.pathname);if(Ne.existsSync(oe)&&Ne.statSync(oe).isFile()){let le=Bun.file(oe),W=Se.extname(oe).toLowerCase(),j="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":j}})}let Ce=Se.dirname(u),he=Se.join(Ce,B.pathname);if(Ne.existsSync(he)&&Ne.statSync(he).isFile()){let le=Bun.file(he),W=Se.extname(he).toLowerCase(),j="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":j}})}let Ae=Se.join(process.cwd(),"public",B.pathname);if(Ne.existsSync(Ae)&&Ne.statSync(Ae).isFile()){let le=Bun.file(Ae),W=Se.extname(Ae).toLowerCase(),j="application/octet-stream";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(L){return new Response(`<pre>${L}
1853
1853
  ${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1854
1854
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1855
1855
  ${e.bright}\u2192 ${e.cyan}http://localhost:${C}/${e.reset}`),console.log(`
@@ -2025,9 +2025,9 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
2025
2025
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
2026
2026
  ${e.bright}\u2192 ${e.cyan}http://localhost:${y}/${e.reset}`),console.log(`
2027
2027
  ${e.yellow}Routes:${e.reset}`);let S=new Set(u.map((v)=>v.routeTemplate)),C=Object.entries(m).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Oe.relative(process.cwd(),x.filePath),fileType:x.fileType}));for(let v of u){let x=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");C.push({route:x,filePath:Oe.relative(process.cwd(),v.filePath),fileType:"stx"})}if(C.sort((v,x)=>v.route.localeCompare(x.route)),C.forEach((v,x)=>{let k=x===C.length-1?"\u2514\u2500 ":"\u251C\u2500 ",H=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${H}`)}),console.log(`
2028
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(w.url.toString(),()=>{if(p)it.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=it.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),ye.clear(),ee(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Wn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Wi}=globalThis.Bun;import ve from"fs";import ie from"path";async function qn(t){try{return St(await Bun.file(t).text())}catch{return}}function qt(t){let s=Bun.file(t),i=ie.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":p[i]||"application/octet-stream",...l}})}async function vn(t=".",s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=ie.resolve(t),{loadStxConfig:h}=await import("./chunk-y2p3scx0.js"),g=await h(u),{createServerApi:y,isServerApiSource:w}=await import("./chunk-0f1f6y2w.js"),S=s.stxOptions?.serverApi??g.serverApi,C=await y(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=s.pagesDir||g.pagesDir||"pages",T=ie.join(v,x);if(!ve.existsSync(T)&&!g._layerPageDirs?.some((P)=>ve.existsSync(P)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${T}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=N(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],M=[];for(let{dir:P,prefix:F}of H)if(ve.existsSync(P)){let z=N(ie.dirname(P),{pagesDir:ie.basename(P)});for(let V of z){let we=F==="/"?V.pattern:`${F}${V.pattern==="/"?"":V.pattern}`;M.push({route:{...V,pattern:we},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let I=new Map,E=null,L=null;if(s.stxOptions?.shell!==!1){if(L=await so(u,s.stxOptions?.shell),L){if(E=await xr(L,s.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,L)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Qe(),await tt(u);let B=et();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let G={},oe=null;try{let{loadStxConfig:P}=await import("./chunk-y2p3scx0.js"),F=await P(u);if(F?.apiRouter)oe=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){G=F.apiRoutes;let z=Object.keys(G).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:V}=await import("./chunk-vrvnctex.js"),we=F.broadcasting;await z(we);let We=we.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(ve.existsSync(Ge))try{let se=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let Ce=a(u,"output");ve.mkdirSync(Ce,{recursive:!0});let he=new Map,Ae=new Set,le=async(P)=>{let F=ar(T,P);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:Ce,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let V=z.outputs.find((we)=>we.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,j=async(P,F)=>{try{let{processDirectives:z,extractVariables:V,defaultConfig:we,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-y2p3scx0.js"),{checkCache:se,cacheTemplate:Q,readFileCached:q,templateCache:J}=await import("./chunk-9mmsb0zb.js"),ke=await We(u),Je=(de)=>{if(!de)return de;if(ie.isAbsolute(de))return de;return ie.resolve(u,de)},D={...we,...ke,...s.stxOptions,autoShell:!0};if(s.debugDirectives)D.debug=!0;D.partialsDir=Je(D.partialsDir),D.componentsDir=Je(D.componentsDir),D.layoutsDir=Je(D.layoutsDir),D.storesDir=Je(D.storesDir||"stores"),D.cachePath=Je(D.cachePath)??a(u,"cache");let be=!F&&!s.profile,pe=D.cache!==!1;if(pe&&be){let de=J.get(P.filePath);if(de)try{if((await ve.promises.stat(P.filePath)).mtime.getTime()<=de.mtime){let ze=!0;for(let Ee of de.dependencies){if(!ve.existsSync(Ee)){ze=!1;break}if((await ve.promises.stat(Ee)).mtime.getTime()>de.mtime){ze=!1;break}}if(ze){let Ee=de.output;if(E)Ee=ge(Ee,{preserveHead:!0});let gt=W.get(P.filePath);return{route:P,content:Ee,status:gt?.status??await qn(P.filePath),headers:gt?.headers}}}}catch{}let Ie=await se(P.filePath,D);if(Ie){let He=Ie;if(E)He=ge(He,{preserveHead:!0});let ze=W.get(P.filePath);return{route:P,content:He,status:ze?.status??await qn(P.filePath),headers:ze?.headers}}}let me=pe?await q(P.filePath):await Bun.file(P.filePath).text(),Re=St(me),{classifyAllScripts:Y}=await import("./chunk-y2p3scx0.js"),Le=Y(me),Ve=Le.server.map((de)=>de.content),ue=me;for(let de of Le.server)ue=ue.replace(de.fullTag,"");let fe={__filename:P.filePath,__dirname:ie.dirname(P.filePath),__stx_options:D,params:F??{},__stx_runtime_head:{}};for(let de of Ve)try{await V(de,fe,P.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,Ie?.message||Ie)}let Ke=new Set,Me;if(s.profile){let de=performance.now();Me=await z(ue,fe,P.filePath,D,Ke);let Ie=performance.now()-de,He=ie.relative(u,P.filePath)||P.filePath;console.log(`[stx:profile] ${He} \u2192 ${Ie.toFixed(2)}ms`)}else Me=await z(ue,fe,P.filePath,D,Ke);if(!E)Me=await Ge(Me,{router:D.router});{let{interpolateScriptExpressions:de}=await import("./chunk-9y6bn8hk.js");Me=Me.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,He,ze)=>{if(!/function\s+__stx_setup_/.test(ze))return Ie;return`<script${He}>${de(ze,fe)}</script>`})}if(E)Me=ge(Me,{preserveHead:!0});if(pe&&be)await Q(P.filePath,Me,Ke,D);let{extractStreamBoundaries:Xn}=await import("./chunk-amvnckr7.js"),lt=Xn(fe),mt=fe.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let de=fe.streamBoundaries||{},Ie={...D,autoShell:!1},He=Object.keys(mt).map((Ee)=>({id:Ee,render:async()=>{let gt=typeof de[Ee]==="function"?await de[Ee]():void 0;return z(mt[Ee],{...fe,$boundary:gt},P.filePath,Ie,new Set)}})),ze=new Set(He.map((Ee)=>Ee.id));lt=[...(lt||[]).filter((Ee)=>!ze.has(Ee.id)),...He]}if(lt&&lt.length>0)Ae.add(P.pattern);else lt=void 0;let Kt=Be(fe),Xt=Fe(fe);if(be)W.set(P.filePath,{status:Kt,headers:Xt});return{route:P,content:Me,status:Kt??Re,headers:Xt,boundaries:lt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${P.pattern}${e.reset}:`,z),null}},Ue=8,qe=async()=>{he.clear(),I.clear();for(let P=0;P<k.length;P+=Ue){let F=k.slice(P,P+Ue),z=await Promise.all(F.map((V)=>j(V)));for(let V of z)if(V)he.set(V.route.pattern,V)}for(let P=0;P<M.length;P+=Ue){let F=M.slice(P,P+Ue),z=await Promise.all(F.map(({route:V})=>j(V)));for(let V of z)if(V)I.set(V.route.pattern,V)}return he.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await xt(u);let at=i;try{if(at=await Ye(i),at!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${at} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let P=s.hmrPort||at+1;l=Et({wsPort:P,verbose:!1}),m=l.start(P)}let Lt=(P,F)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${V}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+P};console.log(`${e.blue}Starting server...${e.reset}`);let It=Wi({port:at,async fetch(P){let F=new URL(P.url),z=g?.publicDir||"public",V=ie.join(u,z,F.pathname),we=ie.join(u,F.pathname),We=ie.join(Ce,F.pathname);if([V,we,We].some((D)=>w(D,u,S)))return new Response("Not Found",{status:404});let[Ge,se,Q]=await Promise.all([ve.promises.stat(V).catch(()=>null),ve.promises.stat(we).catch(()=>null),ve.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(se?.isFile()&&!w(we,u,S))return qt(we);if(Q?.isFile()&&!w(We,u,S))return qt(We);if(F.pathname.startsWith("/_stx/component/")){let D=decodeURIComponent(F.pathname.slice(16));if(D)try{let be=`<${D} />`,pe={...buildConfig,autoShell:!1},me=await processDirectives(be,{},ie.join(u,"components",`${D}.stx`),pe,new Set);return new Response(me,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:D}=await import("./chunk-z990jtmx.js"),be=await D(P,{publicDir:ie.join(u,z),cacheDir:a(u,"cache","img")});if(be)return be}if(oe)try{let D=await oe.handleRequest(P);if(D.status!==404)return D}catch{}if(G[F.pathname])try{return await G[F.pathname](P)}catch(D){return new Response(JSON.stringify({error:D.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await C(P);if(q)return q;let J=mn(F.pathname,k);if(J){let D=he.get(J.route.pattern),be=Ae.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let pe=await j(J.route,J.params);if(pe)D=pe}if(D){let pe=D.status??200,me=D.headers??{},Re=(J.route.filePath?je(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Re.validate){if(!await Re.validate({params:J.params})){let Ve=await le(404);if(Ve){let ue=Ve;if(ue=await f(ue,u),c)ue=Xe(ue,m);return new Response(ue,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Re.middleware){let Le=nt(F.pathname,J.params,Re,F.search),Ve=rt(Le,null,P,{isServer:!0}),ue=await st(Re.middleware,Ve);if(ue.redirect){let fe=ue.redirect.path,Ke=ue.redirect.options.redirectCode||302,Me=new Headers(ue.responseHeaders);return Me.set("Location",fe),new Response(null,{status:Ke,headers:Me})}if(ue.abort){let{statusCode:fe,message:Ke}=ue.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${fe}</title></head><body><h1>Error ${fe}</h1><p>${Ke}</p></body></html>`,{status:fe,headers:{"Content-Type":"text/html"}})}if(Object.keys(ue.state).length>0){let fe=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ue.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;D.content=D.content.replace("</head>",`${fe}</head>`)}}let Y=D.content;if(E&&oo(P)){let Le=xe(Y),Ve=ae(Y),ue=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),fe=ue?ro(ue[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=re(Y,Ke),new Response(Y,{status:pe,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...fe&&{"X-STX-Title":encodeURIComponent(fe)},[ai]:ms(),..._(),"Cache-Control":Te}})}if(E)Y=Cn(E,Y);if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);if(Y=await f(Y,u),c)Y=Xe(Y,m);if(s.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(s.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(D.boundaries&&D.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-amvnckr7.js");return Ve(Le(Y,D.boundaries,{timeoutMs:30000}),{status:pe,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:pe,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...me}})}}if(M.length>0){let D=M.map((pe)=>pe.route),be=mn(F.pathname,D);if(be){let pe=I.get(be.route.pattern);if(pe){let me=pe.content;if(E)me=Cn(E,me);if(Object.keys(be.params).length>0)me=Lt(me,be.params);if(me=await f(me,u),c)me=Xe(me,m);return new Response(me,{status:pe.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:pe}of H)if(pe!=="/"&&F.pathname.startsWith(pe)){let me=I.get(pe)||I.get(pe+"/");if(me){let Re=me.content;if(E)Re=Cn(E,Re);if(Re=await f(Re,u),c)Re=Xe(Re,m);return new Response(Re,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Ze(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=he.get("/");if(ke){let D=ke.content;if(D=await f(D,u),c)D=Xe(D,m);if(s.native)if(D.includes("<head>"))D=D.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else D="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+D;return new Response(D,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await le(404);if(Je){let D=Je;if(D=await f(D,u),c)D=Xe(D,m);return new Response(D,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let F=await le(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
2028
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(w.url.toString(),()=>{if(p)it.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=it.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),ye.clear(),ee(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Wn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Wi}=globalThis.Bun;import ve from"fs";import ie from"path";async function qn(t){try{return St(await Bun.file(t).text())}catch{return}}function qt(t){let s=Bun.file(t),i=ie.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":p[i]||"application/octet-stream",...l}})}async function vn(t=".",s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=ie.resolve(t),{loadStxConfig:h}=await import("./chunk-xek78ez1.js"),g=await h(u),{createServerApi:y,isServerApiSource:w}=await import("./chunk-r5gyx7ch.js"),S=s.stxOptions?.serverApi??g.serverApi,C=await y(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=s.pagesDir||g.pagesDir||"pages",T=ie.join(v,x);if(!ve.existsSync(T)&&!g._layerPageDirs?.some((P)=>ve.existsSync(P)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${T}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=N(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],M=[];for(let{dir:P,prefix:F}of H)if(ve.existsSync(P)){let z=N(ie.dirname(P),{pagesDir:ie.basename(P)});for(let V of z){let we=F==="/"?V.pattern:`${F}${V.pattern==="/"?"":V.pattern}`;M.push({route:{...V,pattern:we},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let I=new Map,E=null,L=null;if(s.stxOptions?.shell!==!1){if(L=await so(u,s.stxOptions?.shell),L){if(E=await xr(L,s.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,L)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Qe(),await tt(u);let B=et();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let G={},oe=null;try{let{loadStxConfig:P}=await import("./chunk-xek78ez1.js"),F=await P(u);if(F?.apiRouter)oe=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){G=F.apiRoutes;let z=Object.keys(G).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:V}=await import("./chunk-k2vcwa7m.js"),we=F.broadcasting;await z(we);let We=we.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(ve.existsSync(Ge))try{let se=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let Ce=a(u,"output");ve.mkdirSync(Ce,{recursive:!0});let he=new Map,Ae=new Set,le=async(P)=>{let F=ar(T,P);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:Ce,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let V=z.outputs.find((we)=>we.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,j=async(P,F)=>{try{let{processDirectives:z,extractVariables:V,defaultConfig:we,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-xek78ez1.js"),{checkCache:se,cacheTemplate:Q,readFileCached:q,templateCache:J}=await import("./chunk-d1x5r4p6.js"),ke=await We(u),Je=(de)=>{if(!de)return de;if(ie.isAbsolute(de))return de;return ie.resolve(u,de)},D={...we,...ke,...s.stxOptions,autoShell:!0};if(s.debugDirectives)D.debug=!0;D.partialsDir=Je(D.partialsDir),D.componentsDir=Je(D.componentsDir),D.layoutsDir=Je(D.layoutsDir),D.storesDir=Je(D.storesDir||"stores"),D.cachePath=Je(D.cachePath)??a(u,"cache");let be=!F&&!s.profile,pe=D.cache!==!1;if(pe&&be){let de=J.get(P.filePath);if(de)try{if((await ve.promises.stat(P.filePath)).mtime.getTime()<=de.mtime){let ze=!0;for(let Ee of de.dependencies){if(!ve.existsSync(Ee)){ze=!1;break}if((await ve.promises.stat(Ee)).mtime.getTime()>de.mtime){ze=!1;break}}if(ze){let Ee=de.output;if(E)Ee=ge(Ee,{preserveHead:!0});let gt=W.get(P.filePath);return{route:P,content:Ee,status:gt?.status??await qn(P.filePath),headers:gt?.headers}}}}catch{}let Ie=await se(P.filePath,D);if(Ie){let He=Ie;if(E)He=ge(He,{preserveHead:!0});let ze=W.get(P.filePath);return{route:P,content:He,status:ze?.status??await qn(P.filePath),headers:ze?.headers}}}let me=pe?await q(P.filePath):await Bun.file(P.filePath).text(),Re=St(me),{classifyAllScripts:Y}=await import("./chunk-xek78ez1.js"),Le=Y(me),Ve=Le.server.map((de)=>de.content),ue=me;for(let de of Le.server)ue=ue.replace(de.fullTag,"");let fe={__filename:P.filePath,__dirname:ie.dirname(P.filePath),__stx_options:D,params:F??{},__stx_runtime_head:{}};for(let de of Ve)try{await V(de,fe,P.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,Ie?.message||Ie)}let Ke=new Set,Me;if(s.profile){let de=performance.now();Me=await z(ue,fe,P.filePath,D,Ke);let Ie=performance.now()-de,He=ie.relative(u,P.filePath)||P.filePath;console.log(`[stx:profile] ${He} \u2192 ${Ie.toFixed(2)}ms`)}else Me=await z(ue,fe,P.filePath,D,Ke);if(!E)Me=await Ge(Me,{router:D.router});{let{interpolateScriptExpressions:de}=await import("./chunk-raeyd6e5.js");Me=Me.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,He,ze)=>{if(!/function\s+__stx_setup_/.test(ze))return Ie;return`<script${He}>${de(ze,fe)}</script>`})}if(E)Me=ge(Me,{preserveHead:!0});if(pe&&be)await Q(P.filePath,Me,Ke,D);let{extractStreamBoundaries:Xn}=await import("./chunk-1p5ge6fq.js"),lt=Xn(fe),mt=fe.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let de=fe.streamBoundaries||{},Ie={...D,autoShell:!1},He=Object.keys(mt).map((Ee)=>({id:Ee,render:async()=>{let gt=typeof de[Ee]==="function"?await de[Ee]():void 0;return z(mt[Ee],{...fe,$boundary:gt},P.filePath,Ie,new Set)}})),ze=new Set(He.map((Ee)=>Ee.id));lt=[...(lt||[]).filter((Ee)=>!ze.has(Ee.id)),...He]}if(lt&&lt.length>0)Ae.add(P.pattern);else lt=void 0;let Kt=Be(fe),Xt=Fe(fe);if(be)W.set(P.filePath,{status:Kt,headers:Xt});return{route:P,content:Me,status:Kt??Re,headers:Xt,boundaries:lt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${P.pattern}${e.reset}:`,z),null}},Ue=8,qe=async()=>{he.clear(),I.clear();for(let P=0;P<k.length;P+=Ue){let F=k.slice(P,P+Ue),z=await Promise.all(F.map((V)=>j(V)));for(let V of z)if(V)he.set(V.route.pattern,V)}for(let P=0;P<M.length;P+=Ue){let F=M.slice(P,P+Ue),z=await Promise.all(F.map(({route:V})=>j(V)));for(let V of z)if(V)I.set(V.route.pattern,V)}return he.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await xt(u);let at=i;try{if(at=await Ye(i),at!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${at} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let P=s.hmrPort||at+1;l=Et({wsPort:P,verbose:!1}),m=l.start(P)}let Lt=(P,F)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${V}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+P};console.log(`${e.blue}Starting server...${e.reset}`);let It=Wi({port:at,async fetch(P){let F=new URL(P.url),z=g?.publicDir||"public",V=ie.join(u,z,F.pathname),we=ie.join(u,F.pathname),We=ie.join(Ce,F.pathname);if([V,we,We].some((D)=>w(D,u,S)))return new Response("Not Found",{status:404});let[Ge,se,Q]=await Promise.all([ve.promises.stat(V).catch(()=>null),ve.promises.stat(we).catch(()=>null),ve.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(se?.isFile()&&!w(we,u,S))return qt(we);if(Q?.isFile()&&!w(We,u,S))return qt(We);if(F.pathname.startsWith("/_stx/component/")){let D=decodeURIComponent(F.pathname.slice(16));if(D)try{let be=`<${D} />`,pe={...buildConfig,autoShell:!1},me=await processDirectives(be,{},ie.join(u,"components",`${D}.stx`),pe,new Set);return new Response(me,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:D}=await import("./chunk-z990jtmx.js"),be=await D(P,{publicDir:ie.join(u,z),cacheDir:a(u,"cache","img")});if(be)return be}if(oe)try{let D=await oe.handleRequest(P);if(D.status!==404)return D}catch{}if(G[F.pathname])try{return await G[F.pathname](P)}catch(D){return new Response(JSON.stringify({error:D.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await C(P);if(q)return q;let J=mn(F.pathname,k);if(J){let D=he.get(J.route.pattern),be=Ae.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let pe=await j(J.route,J.params);if(pe)D=pe}if(D){let pe=D.status??200,me=D.headers??{},Re=(J.route.filePath?je(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Re.validate){if(!await Re.validate({params:J.params})){let Ve=await le(404);if(Ve){let ue=Ve;if(ue=await f(ue,u),c)ue=Xe(ue,m);return new Response(ue,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Re.middleware){let Le=nt(F.pathname,J.params,Re,F.search),Ve=rt(Le,null,P,{isServer:!0}),ue=await st(Re.middleware,Ve);if(ue.redirect){let fe=ue.redirect.path,Ke=ue.redirect.options.redirectCode||302,Me=new Headers(ue.responseHeaders);return Me.set("Location",fe),new Response(null,{status:Ke,headers:Me})}if(ue.abort){let{statusCode:fe,message:Ke}=ue.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${fe}</title></head><body><h1>Error ${fe}</h1><p>${Ke}</p></body></html>`,{status:fe,headers:{"Content-Type":"text/html"}})}if(Object.keys(ue.state).length>0){let fe=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ue.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;D.content=D.content.replace("</head>",`${fe}</head>`)}}let Y=D.content;if(E&&oo(P)){let Le=xe(Y),Ve=ae(Y),ue=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),fe=ue?ro(ue[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=re(Y,Ke),new Response(Y,{status:pe,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...fe&&{"X-STX-Title":encodeURIComponent(fe)},[ai]:ms(),..._(),"Cache-Control":Te}})}if(E)Y=Cn(E,Y);if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);if(Y=await f(Y,u),c)Y=Xe(Y,m);if(s.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(s.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(D.boundaries&&D.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-1p5ge6fq.js");return Ve(Le(Y,D.boundaries,{timeoutMs:30000}),{status:pe,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:pe,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...me}})}}if(M.length>0){let D=M.map((pe)=>pe.route),be=mn(F.pathname,D);if(be){let pe=I.get(be.route.pattern);if(pe){let me=pe.content;if(E)me=Cn(E,me);if(Object.keys(be.params).length>0)me=Lt(me,be.params);if(me=await f(me,u),c)me=Xe(me,m);return new Response(me,{status:pe.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:pe}of H)if(pe!=="/"&&F.pathname.startsWith(pe)){let me=I.get(pe)||I.get(pe+"/");if(me){let Re=me.content;if(E)Re=Cn(E,Re);if(Re=await f(Re,u),c)Re=Xe(Re,m);return new Response(Re,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Ze(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=he.get("/");if(ke){let D=ke.content;if(D=await f(D,u),c)D=Xe(D,m);if(s.native)if(D.includes("<head>"))D=D.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else D="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+D;return new Response(D,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await le(404);if(Je){let D=Je;if(D=await f(D,u),c)D=Xe(D,m);return new Response(D,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let F=await le(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
2029
2029
  ${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
2030
2030
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
2031
2031
  ${e.bright}\u2192 ${e.cyan}http://localhost:${at}/${e.reset}`),c)console.log(`${e.dim} HMR: ws://localhost:${m}${e.reset}`);console.log(`
2032
2032
  ${e.yellow}Routes:${e.reset}`);let jt=[...cr(k,u)];for(let{route:P}of M)jt.push(`${P.pattern}`);if(jt.forEach((P,F)=>{let V=F===jt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${V}${e.reset}${P}`)}),console.log(`
2033
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(It.url.toString(),()=>{if(l)ht();It.stop()}),s.native){let P,F=ie.join(T,"index.stx");if(ve.existsSync(F)){let V=await Bun.file(F).text();P=Tt(V)}let z=g?.app?.window??{};await dt(at,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let P=(se)=>se.startsWith("public/")||se.startsWith("public\\"),F=(se)=>{let Q=se.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},z=new Map,V=()=>{let se=new Set([u,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>ie.dirname(Q))??[]].filter((Q)=>ve.existsSync(Q)).map((Q)=>ve.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let q of Object.values(Q.resources)){if(!ve.existsSync(q))continue;let J=ve.realpathSync(q);if(![...se].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))se.add(J)}for(let[Q,q]of z)if(!se.has(Q))q.close(),z.delete(Q);for(let Q of se)if(!z.has(Q)&&ve.existsSync(Q))z.set(Q,ve.watch(Q,{recursive:!0},(q,J)=>{We(Q,q,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},we=Promise.resolve(),We=(se,Q,q)=>(we=we.catch(()=>{}).then(()=>Ge(se,Q,q)),we),Ge=async(se,Q,q)=>{if(!q||Rt(q))return;if(Ct(q)){if(g._layerGraph){let J=await h(u);Object.assign(g,J),k.splice(0,k.length,...N(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[T,...J._layerPageDirs.slice(1)]:void 0})),V()}if(P(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(F(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-9mmsb0zb.js");J(ie.resolve(se,q)),ke.delete(ie.resolve(se,q))}catch{}if(L&&q){if(ie.resolve(se,q)===L||ie.basename(L)===q){let ke=await xr(L,s.stxOptions||{});if(ke)E=ke}}if(await qe(),await tn(u),c&&l)l.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-9mmsb0zb.js");J(ie.resolve(se,q)),ke.delete(ie.resolve(se,q))}catch{}if(await qe(),c&&l)l.reload(q)}}else if($t(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),c&&l)l.updateCss(q)}};V(),process.on("SIGINT",()=>{for(let se of z.values())se.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{Hs,Vs,Us,Ws,fr,qs,Ks,Xs,Oi,Mi,gr,mr,bn,wn,vn};
2033
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(It.url.toString(),()=>{if(l)ht();It.stop()}),s.native){let P,F=ie.join(T,"index.stx");if(ve.existsSync(F)){let V=await Bun.file(F).text();P=Tt(V)}let z=g?.app?.window??{};await dt(at,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let P=(se)=>se.startsWith("public/")||se.startsWith("public\\"),F=(se)=>{let Q=se.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},z=new Map,V=()=>{let se=new Set([u,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>ie.dirname(Q))??[]].filter((Q)=>ve.existsSync(Q)).map((Q)=>ve.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let q of Object.values(Q.resources)){if(!ve.existsSync(q))continue;let J=ve.realpathSync(q);if(![...se].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))se.add(J)}for(let[Q,q]of z)if(!se.has(Q))q.close(),z.delete(Q);for(let Q of se)if(!z.has(Q)&&ve.existsSync(Q))z.set(Q,ve.watch(Q,{recursive:!0},(q,J)=>{We(Q,q,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},we=Promise.resolve(),We=(se,Q,q)=>(we=we.catch(()=>{}).then(()=>Ge(se,Q,q)),we),Ge=async(se,Q,q)=>{if(!q||Rt(q))return;if(Ct(q)){if(g._layerGraph){let J=await h(u);Object.assign(g,J),k.splice(0,k.length,...N(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[T,...J._layerPageDirs.slice(1)]:void 0})),V()}if(P(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(F(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-d1x5r4p6.js");J(ie.resolve(se,q)),ke.delete(ie.resolve(se,q))}catch{}if(L&&q){if(ie.resolve(se,q)===L||ie.basename(L)===q){let ke=await xr(L,s.stxOptions||{});if(ke)E=ke}}if(await qe(),await tn(u),c&&l)l.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-d1x5r4p6.js");J(ie.resolve(se,q)),ke.delete(ie.resolve(se,q))}catch{}if(await qe(),c&&l)l.reload(q)}}else if($t(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),c&&l)l.updateCss(q)}};V(),process.on("SIGINT",()=>{for(let se of z.values())se.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{Hs,Vs,Us,Ws,fr,qs,Ks,Xs,Oi,Mi,gr,mr,bn,wn,vn};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Bl,Fl,zl,Hl,Vl,Ul,Wl}from"./chunk-amd6ey3t.js";export{Fl as createKeepAliveCache,Hl as generateKeepAliveCSS,Vl as generateKeepAliveRuntime,Ul as onActivated,Wl as onDeactivated,Bl as processKeepAliveDirectives,zl as shouldCacheComponent};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ho,Sa,Vt,hl,ka,Ca,$a,yl}from"./chunk-bddjx2a2.js";export{Vt as Validator,Sa as defineForm,ka as processErrorDirective,Ca as processErrorsDirective,yl as processFormValidationDirectives,$a as processHasErrorsDirective,ho as useForm,hl as v};
@@ -387,5 +387,5 @@ else {
387
387
  <script type="application/json" id="stx-island-manifest">
388
388
  ${JSON.stringify(t)}
389
389
  </script>
390
- `}var gl={processPartialHydrationDirectives:fa,processStaticDirectives:va,generatePartialHydrationCSS:ga,generateIslandManifest:xa,createIslandRegistry:pa,hydrateIsland:ma,hydrateByStrategy:ha,hydrateAll:ya,isHydrated:ba,onHydrated:wa};
391
- export{pa,fa,ga,ma,ha,ya,ba,wa,va,xa,gl};
390
+ `}var ml={processPartialHydrationDirectives:fa,processStaticDirectives:va,generatePartialHydrationCSS:ga,generateIslandManifest:xa,createIslandRegistry:pa,hydrateIsland:ma,hydrateByStrategy:ha,hydrateAll:ya,isHydrated:ba,onHydrated:wa};
391
+ export{pa,fa,ga,ma,ha,ya,ba,wa,va,xa,ml};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ju,hc,ye,ii,Bu,ds,ps,gs}from"./chunk-dqdggvq4.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-ng61wjke.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{Bu as clearOnceStore,ii as onceStore,ye as partialsCache,ds as processIncludes,ps as processStackPushDirectives,gs as processStackReplacements,ju as resetUnscopedSignalWarnings,hc as topLevelElements};