@stacksjs/stx 0.2.708 → 0.2.709

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 (84) hide show
  1. package/dist/{chunk-v5s6r2b3.js → chunk-03xe9hxn.js} +3 -3
  2. package/dist/chunk-20sv64qp.js +2 -0
  3. package/dist/{chunk-xw8wwcr8.js → chunk-2t59wh9y.js} +1 -1
  4. package/dist/{chunk-03p4w958.js → chunk-2xp44gz3.js} +1 -1
  5. package/dist/chunk-40q04wnz.js +2 -0
  6. package/dist/{chunk-f6ybdjt0.js → chunk-4eatxb55.js} +4 -4
  7. package/dist/{chunk-gvs17jd0.js → chunk-4g152e86.js} +32 -16
  8. package/dist/chunk-5p1tvw02.js +2 -0
  9. package/dist/{chunk-d2xnkt8m.js → chunk-5vejh42a.js} +1 -1
  10. package/dist/{chunk-8c4zbq1k.js → chunk-62qjy45q.js} +1 -1
  11. package/dist/{chunk-zjcmybab.js → chunk-659vn8hx.js} +1 -1
  12. package/dist/{chunk-3907sad1.js → chunk-7d2astjj.js} +1 -1
  13. package/dist/{chunk-hmkg3xy0.js → chunk-7f9mmtrs.js} +1 -1
  14. package/dist/{chunk-93y8zwcz.js → chunk-86b173cz.js} +2 -2
  15. package/dist/{chunk-7kaadsd1.js → chunk-89gemg31.js} +1 -1
  16. package/dist/{chunk-9wgvn5rn.js → chunk-8nfrqcd1.js} +1 -1
  17. package/dist/{chunk-qcw1neka.js → chunk-8rvdpsjw.js} +1 -1
  18. package/dist/{chunk-9xb33nz0.js → chunk-8t9ws0ct.js} +1 -1
  19. package/dist/{chunk-sz0e6tpq.js → chunk-9r5ntnef.js} +1 -1
  20. package/dist/chunk-bny1grrf.js +2 -0
  21. package/dist/{chunk-9whmbfwx.js → chunk-c2dqq1mt.js} +1 -1
  22. package/dist/{chunk-w8yv9hnf.js → chunk-ck2kb6hd.js} +1 -1
  23. package/dist/{chunk-e8brwwp1.js → chunk-ck7e0yy2.js} +5 -5
  24. package/dist/{chunk-4cs5t287.js → chunk-d7ayzcyg.js} +1 -1
  25. package/dist/{chunk-kxwfrdt3.js → chunk-dcpgj3c6.js} +1 -1
  26. package/dist/{chunk-fj3pct59.js → chunk-dwda6jcc.js} +1 -1
  27. package/dist/{chunk-f9b7847f.js → chunk-dyhzrdee.js} +1 -1
  28. package/dist/{chunk-bhpsr1mt.js → chunk-e97h1wzd.js} +1 -1
  29. package/dist/{chunk-0jtrdgyv.js → chunk-fgjp28yp.js} +6 -6
  30. package/dist/{chunk-s1vj8gtz.js → chunk-g0eakxxe.js} +2 -2
  31. package/dist/{chunk-27catnpa.js → chunk-gkfm4v2a.js} +1 -1
  32. package/dist/chunk-gsn8mp7c.js +2 -0
  33. package/dist/{chunk-1kwsnqr1.js → chunk-hh3tgx1f.js} +1 -1
  34. package/dist/{chunk-vqratjvb.js → chunk-hjq5463c.js} +1 -1
  35. package/dist/{chunk-75n3vbtk.js → chunk-hv7k0bmv.js} +1 -1
  36. package/dist/{chunk-nde9yj3n.js → chunk-jbxyg5sc.js} +1 -1
  37. package/dist/{chunk-rswg7xsg.js → chunk-jdgfzxyg.js} +2 -2
  38. package/dist/{chunk-3xmt01wr.js → chunk-jh2jmbta.js} +2 -2
  39. package/dist/{chunk-86775qk0.js → chunk-k4dehf34.js} +1 -1
  40. package/dist/{chunk-cjx11tgd.js → chunk-k7e5nv70.js} +1 -1
  41. package/dist/{chunk-dedmk383.js → chunk-kfzenpwm.js} +1 -1
  42. package/dist/{chunk-zaj3gzet.js → chunk-m8zahrwp.js} +1 -1
  43. package/dist/chunk-mg2zgvhz.js +2 -0
  44. package/dist/{chunk-8z469777.js → chunk-n0dajrzk.js} +1 -1
  45. package/dist/{chunk-3vsnnr1b.js → chunk-n3kbyt3h.js} +1 -1
  46. package/dist/{chunk-c71f6mfr.js → chunk-n7cw9ce3.js} +1 -1
  47. package/dist/{chunk-eywx2f4h.js → chunk-nccxqcj2.js} +1 -1
  48. package/dist/{chunk-65fcex5r.js → chunk-nd9rs768.js} +1 -1
  49. package/dist/{chunk-r5k21k3x.js → chunk-p12nxr1r.js} +4 -4
  50. package/dist/{chunk-90kfvtf6.js → chunk-prhws9sn.js} +2 -2
  51. package/dist/{chunk-erqsgfdj.js → chunk-qs2bt5vp.js} +1 -1
  52. package/dist/chunk-rnxrrhbv.js +2 -0
  53. package/dist/{chunk-ccty08sm.js → chunk-t4ak76e6.js} +3 -3
  54. package/dist/{chunk-c2b5p621.js → chunk-tzkyfw0p.js} +5 -5
  55. package/dist/{chunk-e5vsw0fw.js → chunk-vjqm4a5c.js} +1 -1
  56. package/dist/{chunk-hb77kw66.js → chunk-vpe6qaw2.js} +1 -1
  57. package/dist/chunk-w1bxxgm5.js +2 -0
  58. package/dist/{chunk-cqnpjdc9.js → chunk-w7rczhn5.js} +1 -1
  59. package/dist/{chunk-609pekf5.js → chunk-wpfnbcvn.js} +1 -1
  60. package/dist/{chunk-2srb5f7t.js → chunk-x91zfx03.js} +1 -1
  61. package/dist/chunk-xbbxa1t8.js +3 -0
  62. package/dist/{chunk-a32xsr61.js → chunk-xf3bt7xf.js} +1 -1
  63. package/dist/chunk-xnxj3z0t.js +2 -0
  64. package/dist/{chunk-19knw8c6.js → chunk-xz103bfc.js} +1 -1
  65. package/dist/chunk-zsfwzwsd.js +2 -0
  66. package/dist/cli.js +8 -8
  67. package/dist/client/signals-authoring-runtime.js +8 -1
  68. package/dist/client/signals-binding-utils-runtime.js +10 -1
  69. package/dist/craft-entry.js +1 -1
  70. package/dist/craft.js +1 -1
  71. package/dist/pwa.js +1 -1
  72. package/dist/ssg.js +2 -2
  73. package/package.json +5 -5
  74. package/dist/chunk-2k6d8s6h.js +0 -2
  75. package/dist/chunk-3nsdb1fg.js +0 -2
  76. package/dist/chunk-3qnke2jb.js +0 -2
  77. package/dist/chunk-3sg2ardr.js +0 -2
  78. package/dist/chunk-48936paw.js +0 -2
  79. package/dist/chunk-9nvywf05.js +0 -3
  80. package/dist/chunk-axwwhdtt.js +0 -2
  81. package/dist/chunk-h9n71rdn.js +0 -2
  82. package/dist/chunk-j7gg6xrc.js +0 -2
  83. package/dist/chunk-weaxr0qe.js +0 -2
  84. package/dist/chunk-ztckg7a3.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{oe,de,pn,Pt,It,m,r,fe,p}from"./chunk-0jtrdgyv.js";import{mt,Re,Fa,Xr,vo,wo,i}from"./chunk-e8brwwp1.js";import{ae,xr,Se,j,wn}from"./chunk-xyyt8v1r.js";import{wt,lr,ms,hs,ys,xt,St,kt,_t,Ct,Et,Ze}from"./chunk-0myrwz84.js";import{cs,a,P}from"./chunk-90kfvtf6.js";import{dt,Tn,_e,M,qi,eo,Br,Ue,Ki,Ce}from"./chunk-ccty08sm.js";import{ir,ar}from"./chunk-zjcmybab.js";import{Cn}from"./chunk-9xb33nz0.js";import{e,sn,tr,y}from"./chunk-3xmt01wr.js";import{Ge}from"./chunk-r5k21k3x.js";import{$e}from"./chunk-1xjv71dw.js";import{K,ye,be}from"./chunk-f6ybdjt0.js";import{l}from"./chunk-5n4qg8za.js";import{q}from"./chunk-ncs2j5kc.js";async function zn(t){try{let n=await Bun.file(t).text(),o=Nn(n),d=Un(n,t),s=Wn(n,o),c=Vn(n,o);return{file:t,metrics:o,issues:d,suggestions:s,performance:c}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Nn(t){let n=t.split(`
2
+ import{oe,de,pn,Pt,It,m,r,fe,p}from"./chunk-fgjp28yp.js";import{mt,Re,Fa,Xr,vo,wo,i}from"./chunk-ck7e0yy2.js";import{ae,xr,Se,j,wn}from"./chunk-xyyt8v1r.js";import{wt,lr,ms,hs,ys,xt,St,kt,_t,Ct,Et,Ze}from"./chunk-0myrwz84.js";import{cs,a,P}from"./chunk-prhws9sn.js";import{dt,Tn,_e,M,qi,eo,Br,Ue,Ki,Ce}from"./chunk-t4ak76e6.js";import{ir,ar}from"./chunk-659vn8hx.js";import{Cn}from"./chunk-8t9ws0ct.js";import{e,sn,tr,y}from"./chunk-jh2jmbta.js";import{Ge}from"./chunk-p12nxr1r.js";import{$e}from"./chunk-1xjv71dw.js";import{K,ye,be}from"./chunk-4eatxb55.js";import{l}from"./chunk-5n4qg8za.js";import{q}from"./chunk-ncs2j5kc.js";async function zn(t){try{let n=await Bun.file(t).text(),o=Nn(n),d=Un(n,t),s=Wn(n,o),c=Vn(n,o);return{file:t,metrics:o,issues:d,suggestions:s,performance:c}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Nn(t){let n=t.split(`
3
3
  `),o=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),s=(o?o[1]:"").split(`
4
4
  `).length,c={conditionals:(t.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(t.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(t.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};c.total=c.conditionals+c.loops+c.includes+c.custom;let f=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,u=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,h=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,g=f+u+h,b=(t.match(/<[A-Z][^>]*>/g)||[]).length,w=(t.match(/@(?:layout|extends)\(/g)||[]).length,S=0,C=0;for(let T of n)if(/@(?:if|unless|foreach|for|while|section)\b/.test(T)&&!/@end/.test(T)&&!/@else/.test(T))C++,S=Math.max(S,C);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(T))C--;let v=S>=4?3:0,x=Math.min(10,Math.ceil(c.total*0.5+g*0.1+b*0.3+(s>10?s*0.05:0)+v));return{lines:n.length,characters:t.length,directives:c,expressions:g,components:b,layouts:w,scriptLines:s,complexity:x}}function Un(t,n){let o=[],d=Kt(t,"if","endif");if(d>0)o.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let s=Kt(t,"foreach","endforeach");if(s>0)o.push({type:"error",category:"syntax",message:`Found ${s} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let c=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(c&&c.length>0)o.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let f=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(f>0)o.push({type:"warning",category:"security",message:`Found ${f} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let u=t.match(/<img[^>]*>/g);if(u){let b=u.filter((w)=>!w.includes("alt="));if(b.length>0)o.push({type:"warning",category:"accessibility",message:`Found ${b.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let h=t.split(`
5
5
  `).filter((b)=>b.length>120);if(h.length>0)o.push({type:"info",category:"maintainability",message:`Found ${h.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let g=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(g>3)o.push({type:"info",category:"maintainability",message:`Found ${g} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return o}function Wn(t,n){let o=[];if(n.complexity>7)o.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(n.complexity>5&&n.directives.total>8)o.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(n.lines>100&&n.components===0)o.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(n.expressions>20)o.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)o.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(n.directives.total===0&&n.expressions<5)o.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(n.scriptLines>50)o.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return o}function Vn(t,n){let o=1;if(o+=n.directives.conditionals*0.1,o+=n.directives.loops*0.5,o+=n.directives.includes*2,o+=n.expressions*0.05,o+=n.components*1,n.scriptLines>10)o+=n.scriptLines*0.1;let d;if(n.expressions===0&&n.directives.total===0)d="high";else if(n.expressions<5&&n.directives.total<3)d="medium";else d="low";let s=[];if(o>10)s.push("Consider optimizing template complexity");if(d==="low"&&n.directives.total>5)s.push("Reduce dynamic content for better caching");if(n.components===0&&n.lines>40)s.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(o*100)/100,complexityScore:n.complexity,cacheability:d,recommendations:s}}function Kt(t,n,o){let d=t.replace(/<!--[\s\S]*?-->/g,""),s=(d.match(new RegExp(`@${n}\\b`,"g"))||[]).length,c=(d.match(new RegExp(`@${o}\\b`,"g"))||[]).length;return Math.abs(s-c)}async function Ni(t=["**/*.stx"],n){let o=[],d=[];for(let c of t){let f=await Array.fromAsync(new Bun.Glob(c).scan({cwd:n||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...f.filter((u)=>u.endsWith(".stx")))}for(let c of d)try{let f=await zn(c);o.push(f)}catch(f){console.warn(`Failed to analyze ${c}:`,f)}let s=qn(o);return{results:o,summary:s}}function qn(t){let n=t.length,o=t.reduce((g,b)=>g+b.metrics.lines,0),d=n>0?t.reduce((g,b)=>g+b.metrics.complexity,0)/n:0,s=t.reduce((g,b)=>g+b.issues.length,0),c={};t.forEach((g)=>{g.issues.forEach((b)=>{c[b.category]=(c[b.category]||0)+1})});let f=n>0?t.reduce((g,b)=>g+b.performance.estimatedRenderTime,0)/n:0,u=Math.max(1,Math.min(10,Math.round(10-f/2-d/2))),h=[];if(d>6)h.push("Project has high average complexity. Consider refactoring complex templates.");if(s>n*2)h.push("High number of issues detected. Run detailed analysis on individual files.");if(c.security>0)h.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:n,totalLines:o,avgComplexity:Math.round(d*100)/100,totalIssues:s,issuesByCategory:c,performanceScore:u,recommendations:h}}import{mkdir as Kn,readFile as Xn,readdir as Gn,stat as Xt,writeFile as Jn}from"fs/promises";import Te from"path";function en(t){if(t==="connectedCallback")return`method "${t}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(t==="disconnectedCallback")return`method "${t}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${t}" is reserved`}var tn=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function Yn(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function jt(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Qn(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function Zn(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function er(t){let n=[];async function o(d){let s=await Gn(d,{withFileTypes:!0});s.sort((c,f)=>c.name.localeCompare(f.name));for(let c of s){let f=Te.join(d,c.name);if(c.isDirectory()){if(!c.name.startsWith(".")&&c.name!=="node_modules")await o(f)}else if(c.isFile()&&c.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(c.name))n.push(f)}}return await o(t),n}function nr(t,n){let o=t.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!o)return{};let d=o[1].trim();if(!d)return{};try{return JSON.parse(d)}catch(s){throw Error(`${n}: <script component> must contain JSON metadata (${s.message})`)}}function rr(t,n){let o={},d=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let s of d){if(!/\bclient\b/i.test(s[1])||/\bcomponent\b|\bstx:component\b/i.test(s[1]))continue;let c;try{c=new Bun.Transpiler({loader:"ts"}).transformSync(s[2])}catch(h){throw Error(`${n}: failed to transpile <script client> (${h.message})`)}let f=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,u;while(u=f.exec(c)){let h=u[1];if(tn.has(h))throw Error(`${n}: client ${en(h)}`);let g=f.lastIndex,b=1,w="",S=!1,C=g;for(;C<c.length&&b>0;C++){let x=c[C];if(S){S=!1;continue}if(w){if(x==="\\")S=!0;else if(x===w)w="";continue}if(x==='"'||x==="'"||x==="`")w=x;else if(x==="{")b++;else if(x==="}")b--}if(b!==0)throw Error(`${n}: unterminated client function "${h}"`);let v=u[0].includes("async")?"async ":"";o[h]=`${v}${h}(${u[2]}) {${c.slice(g,C-1)}}`,f.lastIndex=C}}return o}function or(t){let n=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Gt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].trim()).filter(Boolean).join(`
@@ -876,7 +876,7 @@ else {
876
876
  };
877
877
  })();
878
878
  </script>
879
- `}function Ne(t,n,o={}){let d=Fr(n,o),s=t.lastIndexOf("</body>");if(s!==-1)return t.slice(0,s)+d+t.slice(s);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function yt(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function vt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(t))}var tt=null;function Tt(t){if(!tt)tt=new rn(t);return tt}function st(){if(tt)tt.stop(),tt=null}import $t from"path";var nt={name:"bun-plugin-stx",async setup(t){let o={...await a(),...t.config?.stx},d=new Set,s=o.webComponents?.enabled?`./${$t.relative($t.dirname(t.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",c=[];if(o.webComponents?.enabled)try{let f=await cs(o,d);if(c.push(...f),o.debug&&f.length>0)console.log(`Successfully built ${f.length} web components`)}catch(f){console.error("Failed to build web components:",f)}t.onLoad({filter:/\.stx$/},async({path:f})=>{try{let u=new Set;if(o.cache&&o.cachePath){let x=await ir(f,o);if(x){if(o.debug)console.log(`Using cached version of ${f}`);return{contents:x,loader:"html"}}}let h=await Se(()=>Bun.file(f).text(),"",(x)=>{throw new xr(`Failed to read stx file: ${f}`,f,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new xr(`stx file is empty: ${f}`,f);let{scriptContent:g,templateContent:b,allScripts:w}=oe.time("script-extraction",()=>{let x=h,T=de(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",O=[];for(let R of k){let D=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",I=R.match(/<script\b([^>]*)>/i),V=I?I[1]:"";if(/\bserver\b/i.test(V))L=D;else O.push(R)}let A=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:O}}),S={__filename:f,__dirname:$t.dirname(f),__stx:{webComponentsPath:s,builtComponents:c}};await Se(()=>m(g,S,f),void 0,(x)=>{let T=new ae(`Script execution failed in ${f}: ${x.message}`,f,void 0,void 0,g.substring(0,100));if(j.log(T,{filePath:f,scriptContent:g}),o.debug)throw T});let v=await oe.timeAsync("directive-processing",async()=>await i(b,S,f,o,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-03p4w958.js"),T=x(w.join(`
879
+ `}function Ne(t,n,o={}){let d=Fr(n,o),s=t.lastIndexOf("</body>");if(s!==-1)return t.slice(0,s)+d+t.slice(s);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function yt(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function vt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(t))}var tt=null;function Tt(t){if(!tt)tt=new rn(t);return tt}function st(){if(tt)tt.stop(),tt=null}import $t from"path";var nt={name:"bun-plugin-stx",async setup(t){let o={...await a(),...t.config?.stx},d=new Set,s=o.webComponents?.enabled?`./${$t.relative($t.dirname(t.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",c=[];if(o.webComponents?.enabled)try{let f=await cs(o,d);if(c.push(...f),o.debug&&f.length>0)console.log(`Successfully built ${f.length} web components`)}catch(f){console.error("Failed to build web components:",f)}t.onLoad({filter:/\.stx$/},async({path:f})=>{try{let u=new Set;if(o.cache&&o.cachePath){let x=await ir(f,o);if(x){if(o.debug)console.log(`Using cached version of ${f}`);return{contents:x,loader:"html"}}}let h=await Se(()=>Bun.file(f).text(),"",(x)=>{throw new xr(`Failed to read stx file: ${f}`,f,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new xr(`stx file is empty: ${f}`,f);let{scriptContent:g,templateContent:b,allScripts:w}=oe.time("script-extraction",()=>{let x=h,T=de(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",O=[];for(let R of k){let D=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",I=R.match(/<script\b([^>]*)>/i),V=I?I[1]:"";if(/\bserver\b/i.test(V))L=D;else O.push(R)}let A=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:O}}),S={__filename:f,__dirname:$t.dirname(f),__stx:{webComponentsPath:s,builtComponents:c}};await Se(()=>m(g,S,f),void 0,(x)=>{let T=new ae(`Script execution failed in ${f}: ${x.message}`,f,void 0,void 0,g.substring(0,100));if(j.log(T,{filePath:f,scriptContent:g}),o.debug)throw T});let v=await oe.timeAsync("directive-processing",async()=>await i(b,S,f,o,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-2xp44gz3.js"),T=x(w.join(`
880
880
  `),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+T+`
881
881
  `+v.slice(k);else v+=`
882
882
  ${T}`}if(v=await be(v),u.forEach((x)=>d.add(x)),o.cache&&o.cachePath){if(await ar(f,v,u,o),o.debug)console.log(`Cached template ${f} with ${u.size} dependencies`)}return{contents:v,loader:"html"}}catch(u){let h=u instanceof Error?u:new ae(`Plugin processing failed: ${String(u)}`,f);if(j.log(h,{filePath:f,buildConfig:t.config}),wn.logDetailedError(h,{filePath:f,plugin:"bun-plugin-stx"}),o.debug)console.error("stx Plugin Error:",h);let g=h,b=g.line||null,w=g.context||null;return{contents:o.debug||q()?`<!DOCTYPE html>
@@ -939,7 +939,7 @@ ${T}`}if(v=await be(v),u.forEach((x)=>d.add(x)),o.cache&&o.cachePath){if(await a
939
939
  <h1>Something went wrong</h1>
940
940
  <p>An internal error occurred. Please try again later.</p>
941
941
  </body>
942
- </html>`,loader:"html"}}})}};async function Or(t,n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,f=n.hmrPort||o+1,u=ge.resolve(t);if(!Be.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,n);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=l(process.cwd(),"output");Be.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let D={name:"public-assets",setup(ve){ve.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},I=await Bun.build({entrypoints:[u],outdir:h,plugins:[D,nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!I.success)return console.error(`${e.red}Build failed:${e.reset}`,I.logs),!1;let V=I.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(V.path).text(),!0}catch(D){return console.error(`${e.red}Error building stx file:${e.reset}`,D),!1}};if(!await b())return!1;let S=ge.dirname(u);await sn(S);let C=o;try{if(C=await Ve(o),C!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let D=n.hmrPort||C+1;c=Tt({wsPort:D,verbose:!1}),f=c.start(D)}let v={},x=null,T;try{let{loadStxConfig:D}=await import("./chunk-weaxr0qe.js"),I=await D();if(T=n.stxOptions?.serverApi??I.serverApi,I?.apiRouter)x=I?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(I?.apiRoutes){v=I.apiRoutes;let V=Object.keys(v).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(I?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:Y}=await import("./chunk-gk0nq2ky.js"),ve=I.broadcasting;await V(ve);let le=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${le}/ws${e.reset}`);let Pe=ge.join(process.cwd(),"channels.ts");if(Be.existsSync(Pe))try{let ne=await Y(Pe);console.log(`${e.blue}Loaded ${e.bright}${ne} broadcast channel${ne!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ne){console.warn(`${e.yellow}Failed to load channels.ts: ${ne.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:L}=await import("./chunk-27catnpa.js"),O=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),s)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${f}${e.reset}`);let A=zr({port:C,async fetch(D){return Cn(D,await(async()=>{let I=new URL(D.url);if([h,ge.dirname(u),ge.join(process.cwd(),"public")].some((ne)=>L(ge.join(ne,I.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let ne=await x.handleRequest(D);if(ne.status!==404)return ne}catch{}if(v[I.pathname])try{return await v[I.pathname](D)}catch(ne){return new Response(JSON.stringify({error:ne.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await O(D);if(V)return V;if(I.pathname==="/")return(async()=>{let F=await y(g||"");if(s)F=Ne(F,f);if(n.native)if(F.includes("<head>"))F=F.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(F.includes("<html"))F=F.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 F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(n.titlebarHidden)if(F.includes("<head>"))F=F.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(F.includes("<html"))F=F.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 F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;return F})().then((F)=>new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=ge.join(h,I.pathname);if(Be.existsSync(Y)&&Be.statSync(Y).isFile()){let ne=Bun.file(Y),F=ge.extname(Y).toLowerCase(),_="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ne.text(),Je=Fe.transformSync(ze);return new Response(Je,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":_="text/html";break;case".css":_="text/css";break;case".js":_="text/javascript";break;case".json":_="application/json";break;case".png":_="image/png";break;case".jpg":case".jpeg":_="image/jpeg";break;case".gif":_="image/gif";break;case".woff":_="font/woff";break;case".woff2":_="font/woff2";break;case".ttf":_="font/ttf";break;case".otf":_="font/otf";break;case".eot":_="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":_}})}let ve=ge.dirname(u),le=ge.join(ve,I.pathname);if(Be.existsSync(le)&&Be.statSync(le).isFile()){let ne=Bun.file(le),F=ge.extname(le).toLowerCase(),_="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ne.text(),Je=Fe.transformSync(ze);return new Response(Je,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":_="text/html";break;case".css":_="text/css";break;case".js":_="text/javascript";break;case".json":_="application/json";break;case".png":_="image/png";break;case".jpg":case".jpeg":_="image/jpeg";break;case".gif":_="image/gif";break;case".svg":_="image/svg+xml";break;case".ico":_="image/x-icon";break;case".woff":_="font/woff";break;case".woff2":_="font/woff2";break;case".ttf":_="font/ttf";break;case".otf":_="font/otf";break;case".eot":_="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":_}})}let Pe=ge.join(process.cwd(),"public",I.pathname);if(Be.existsSync(Pe)&&Be.statSync(Pe).isFile()){let ne=Bun.file(Pe),F=ge.extname(Pe).toLowerCase(),_="application/octet-stream";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ne.text(),Je=Fe.transformSync(ze);return new Response(Je,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":_="text/html";break;case".css":_="text/css";break;case".js":_="text/javascript";break;case".json":_="application/json";break;case".png":_="image/png";break;case".jpg":case".jpeg":_="image/jpeg";break;case".gif":_="image/gif";break;case".svg":_="image/svg+xml";break;case".ico":_="image/x-icon";break;case".woff":_="font/woff";break;case".woff2":_="font/woff2";break;case".ttf":_="font/ttf";break;case".otf":_="font/otf";break;case".eot":_="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":_}})}return new Response("Not Found",{status:404})})())},error(D){return new Response(`<pre>${D}
942
+ </html>`,loader:"html"}}})}};async function Or(t,n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,f=n.hmrPort||o+1,u=ge.resolve(t);if(!Be.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,n);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=l(process.cwd(),"output");Be.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let D={name:"public-assets",setup(ve){ve.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},I=await Bun.build({entrypoints:[u],outdir:h,plugins:[D,nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!I.success)return console.error(`${e.red}Build failed:${e.reset}`,I.logs),!1;let V=I.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(V.path).text(),!0}catch(D){return console.error(`${e.red}Error building stx file:${e.reset}`,D),!1}};if(!await b())return!1;let S=ge.dirname(u);await sn(S);let C=o;try{if(C=await Ve(o),C!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let D=n.hmrPort||C+1;c=Tt({wsPort:D,verbose:!1}),f=c.start(D)}let v={},x=null,T;try{let{loadStxConfig:D}=await import("./chunk-zsfwzwsd.js"),I=await D();if(T=n.stxOptions?.serverApi??I.serverApi,I?.apiRouter)x=I?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(I?.apiRoutes){v=I.apiRoutes;let V=Object.keys(v).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(I?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:Y}=await import("./chunk-gk0nq2ky.js"),ve=I.broadcasting;await V(ve);let le=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${le}/ws${e.reset}`);let Pe=ge.join(process.cwd(),"channels.ts");if(Be.existsSync(Pe))try{let ne=await Y(Pe);console.log(`${e.blue}Loaded ${e.bright}${ne} broadcast channel${ne!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ne){console.warn(`${e.yellow}Failed to load channels.ts: ${ne.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:L}=await import("./chunk-gkfm4v2a.js"),O=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),s)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${f}${e.reset}`);let A=zr({port:C,async fetch(D){return Cn(D,await(async()=>{let I=new URL(D.url);if([h,ge.dirname(u),ge.join(process.cwd(),"public")].some((ne)=>L(ge.join(ne,I.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let ne=await x.handleRequest(D);if(ne.status!==404)return ne}catch{}if(v[I.pathname])try{return await v[I.pathname](D)}catch(ne){return new Response(JSON.stringify({error:ne.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await O(D);if(V)return V;if(I.pathname==="/")return(async()=>{let F=await y(g||"");if(s)F=Ne(F,f);if(n.native)if(F.includes("<head>"))F=F.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(F.includes("<html"))F=F.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 F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(n.titlebarHidden)if(F.includes("<head>"))F=F.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(F.includes("<html"))F=F.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 F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;return F})().then((F)=>new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=ge.join(h,I.pathname);if(Be.existsSync(Y)&&Be.statSync(Y).isFile()){let ne=Bun.file(Y),F=ge.extname(Y).toLowerCase(),_="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ne.text(),Je=Fe.transformSync(ze);return new Response(Je,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":_="text/html";break;case".css":_="text/css";break;case".js":_="text/javascript";break;case".json":_="application/json";break;case".png":_="image/png";break;case".jpg":case".jpeg":_="image/jpeg";break;case".gif":_="image/gif";break;case".woff":_="font/woff";break;case".woff2":_="font/woff2";break;case".ttf":_="font/ttf";break;case".otf":_="font/otf";break;case".eot":_="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":_}})}let ve=ge.dirname(u),le=ge.join(ve,I.pathname);if(Be.existsSync(le)&&Be.statSync(le).isFile()){let ne=Bun.file(le),F=ge.extname(le).toLowerCase(),_="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ne.text(),Je=Fe.transformSync(ze);return new Response(Je,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":_="text/html";break;case".css":_="text/css";break;case".js":_="text/javascript";break;case".json":_="application/json";break;case".png":_="image/png";break;case".jpg":case".jpeg":_="image/jpeg";break;case".gif":_="image/gif";break;case".svg":_="image/svg+xml";break;case".ico":_="image/x-icon";break;case".woff":_="font/woff";break;case".woff2":_="font/woff2";break;case".ttf":_="font/ttf";break;case".otf":_="font/otf";break;case".eot":_="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":_}})}let Pe=ge.join(process.cwd(),"public",I.pathname);if(Be.existsSync(Pe)&&Be.statSync(Pe).isFile()){let ne=Bun.file(Pe),F=ge.extname(Pe).toLowerCase(),_="application/octet-stream";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ne.text(),Je=Fe.transformSync(ze);return new Response(Je,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":_="text/html";break;case".css":_="text/css";break;case".js":_="text/javascript";break;case".json":_="application/json";break;case".png":_="image/png";break;case".jpg":case".jpeg":_="image/jpeg";break;case".gif":_="image/gif";break;case".svg":_="image/svg+xml";break;case".ico":_="image/x-icon";break;case".woff":_="font/woff";break;case".woff2":_="font/woff2";break;case".ttf":_="font/ttf";break;case".otf":_="font/otf";break;case".eot":_="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":_}})}return new Response("Not Found",{status:404})})())},error(D){return new Response(`<pre>${D}
943
943
  ${D.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
944
944
  ${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(`
945
945
  ${e.bright}\u2192 ${e.cyan}http://localhost:${C}/${e.reset}`),console.log(`
@@ -1426,12 +1426,12 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
1426
1426
  ${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(`
1427
1427
  ${e.bright}\u2192 ${e.cyan}http://localhost:${b}/${e.reset}`),console.log(`
1428
1428
  ${e.yellow}Routes:${e.reset}`);let S=new Set(u.map((v)=>v.routeTemplate)),C=Object.entries(f).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Ee.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:Ee.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 ",L=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${L}`)}),console.log(`
1429
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(w.url.toString(),()=>{if(d)Ke.watch(c,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ke.watch(c,{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}`),Ge.clear(),fe(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Wr}=globalThis.Bun;import me from"fs";import te from"path";async function ln(t){try{return pn(await Bun.file(t).text())}catch{return}}function zt(t){let n=Bun.file(t),o=te.extname(t).toLowerCase(),d={".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"},c=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[o]||"application/octet-stream",...c}})}async function Dr(t=".",n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,f=n.hmrPort||o+1,u=te.resolve(t),{loadStxConfig:h}=await import("./chunk-weaxr0qe.js"),g=await h(u),{createServerApi:b,isServerApiSource:w}=await import("./chunk-27catnpa.js"),S=n.stxOptions?.serverApi??g.serverApi,C=await b(u,S),v=g.root&&g.root!=="."?te.join(u,g.root):u,x=n.pagesDir||g.pagesDir||"pages",T=te.join(v,x);if(!me.existsSync(T)&&!g._layerPageDirs?.some((E)=>me.existsSync(E)))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=K(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 L=g?._pluginPageDirs||[],O=[];for(let{dir:E,prefix:H}of L)if(me.existsSync(E)){let z=K(te.dirname(E),{pagesDir:te.basename(E)});for(let Q of z){let X=H==="/"?Q.pattern:`${H}${Q.pattern==="/"?"":Q.pattern}`;O.push({route:{...Q,pattern:X},prefix:H})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${H}${e.reset}`)}let A=new Map,R=null,D=null;if(n.stxOptions?.shell!==!1){if(D=await qi(u,n.stxOptions?.shell),D){if(R=await eo(D,n.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(u,D)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}xt(),await kt(u);let I=St();if(I.length>0)console.log(`${e.blue}Loaded ${e.bright}${I.length}${e.blue} middleware: ${e.dim}${I.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:E}=await import("./chunk-weaxr0qe.js"),H=await E(u);if(H?.apiRouter)Y=H?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(H?.apiRoutes){V=H.apiRoutes;let z=Object.keys(V).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(H?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Q}=await import("./chunk-gk0nq2ky.js"),X=H.broadcasting;await z(X);let Oe=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Oe}/ws${e.reset}`);let we=te.join(process.cwd(),"channels.ts");if(me.existsSync(we))try{let N=await Q(we);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let ve=l(u,"output");me.mkdirSync(ve,{recursive:!0});let le=new Map,Pe=new Set,ne=async(E)=>{let H=hs(T,E);if(!H)return null;try{let z=await Bun.build({entrypoints:[H],outdir:ve,plugins:[nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!z.success)return null;let Q=z.outputs.find((X)=>X.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},F=new Map,_=async(E,H)=>{try{let{processDirectives:z,extractVariables:Q,defaultConfig:X,loadStxConfig:Oe,injectRouterScript:we}=await import("./chunk-weaxr0qe.js"),{checkCache:N,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-eywx2f4h.js"),G=await Oe(u),We=(ie)=>{if(!ie)return ie;if(te.isAbsolute(ie))return ie;return te.resolve(u,ie)},ce={...X,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=We(ce.partialsDir),ce.componentsDir=We(ce.componentsDir),ce.layoutsDir=We(ce.layoutsDir),ce.storesDir=We(ce.storesDir||"stores"),ce.cachePath=We(ce.cachePath)??l(u,"cache");let B=!H&&!n.profile,re=ce.cache!==!1;if(re&&B){let ie=pe.get(E.filePath);if(ie)try{if((await me.promises.stat(E.filePath)).mtime.getTime()<=ie.mtime){let He=!0;for(let ke of ie.dependencies){if(!me.existsSync(ke)){He=!1;break}if((await me.promises.stat(ke)).mtime.getTime()>ie.mtime){He=!1;break}}if(He){let ke=ie.output;if(R)ke=Ue(ke,{preserveHead:!0});let ot=F.get(E.filePath);return{route:E,content:ke,status:ot?.status??await ln(E.filePath),headers:ot?.headers}}}}catch{}let Ie=await N(E.filePath,ce);if(Ie){let je=Ie;if(R)je=Ue(je,{preserveHead:!0});let He=F.get(E.filePath);return{route:E,content:je,status:He?.status??await ln(E.filePath),headers:He?.headers}}}let Z=re?await W(E.filePath):await Bun.file(E.filePath).text(),se=pn(Z),{classifyAllScripts:ue}=await import("./chunk-weaxr0qe.js"),U=ue(Z),Le=U.server.map((ie)=>ie.content),De=Z;for(let ie of U.server)De=De.replace(ie.fullTag,"");let ee={__filename:E.filePath,__dirname:te.dirname(E.filePath),__stx_options:ce,params:H??{},__stx_runtime_head:{}};for(let ie of Le)try{await Q(ie,ee,E.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ae=new Set,he;if(n.profile){let ie=performance.now();he=await z(De,ee,E.filePath,ce,Ae);let Ie=performance.now()-ie,je=te.relative(u,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await z(De,ee,E.filePath,ce,Ae);if(!R)he=await we(he,{router:ce.router});{let{interpolateScriptExpressions:ie}=await import("./chunk-03p4w958.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ie(He,ee)}</script>`})}if(R)he=Ue(he,{preserveHead:!0});if(re&&B)await J(E.filePath,he,Ae,ce);let{extractStreamBoundaries:at}=await import("./chunk-8z469777.js"),Ye=at(ee),rt=ee.__streamTemplates;if(rt&&typeof rt==="object"&&Object.keys(rt).length>0){let ie=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(rt).map((ke)=>({id:ke,render:async()=>{let ot=typeof ie[ke]==="function"?await ie[ke]():void 0;return z(rt[ke],{...ee,$boundary:ot},E.filePath,Ie,new Set)}})),He=new Set(je.map((ke)=>ke.id));Ye=[...(Ye||[]).filter((ke)=>!He.has(ke.id)),...je]}if(Ye&&Ye.length>0)Pe.add(E.pattern);else Ye=void 0;let Wt=Pt(ee),Vt=It(ee);if(B)F.set(E.filePath,{status:Wt,headers:Vt});return{route:E,content:he,status:Wt??se,headers:Vt,boundaries:Ye}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Fe=8,ze=async()=>{let E=new Set(le.keys()),H=new Set(A.keys());le.clear(),A.clear();let z=n.prebuild===!1?k.filter((X)=>E.has(X.pattern)):k,Q=n.prebuild===!1?O.filter(({route:X})=>H.has(X.pattern)):O;for(let X=0;X<z.length;X+=Fe){let Oe=z.slice(X,X+Fe),we=await Promise.all(Oe.map((N)=>_(N)));for(let N of we)if(N)le.set(N.route.pattern,N)}for(let X=0;X<Q.length;X+=Fe){let Oe=Q.slice(X,X+Fe),we=await Promise.all(Oe.map(({route:N})=>_(N)));for(let N of we)if(N)A.set(N.route.pattern,N)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?k.length+O.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await sn(u);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let E=n.hmrPort||Xe+1;c=Tt({wsPort:E,verbose:!1}),f=c.start(E)}let Ot=(E,H)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(H).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(E.includes("</head>"))return E.replace("</head>",`${Q}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+E};console.log(`${e.blue}Starting server...${e.reset}`);let At=Wr({port:Xe,hostname:n.hostname,async fetch(E){let H=new URL(E.url),z=n.stxOptions?.offline??g.offline;if(H.pathname===vo&&z?.enabled){if(!["GET","HEAD"].includes(E.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(E.method==="HEAD"?null:wo(z,Xr()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=g?.publicDir||"public",X=te.join(u,Q,H.pathname),Oe=te.join(u,H.pathname),we=te.join(ve,H.pathname);if([X,Oe,we].some((B)=>w(B,u,S)))return new Response("Not Found",{status:404});let[N,J,W]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Oe).catch(()=>null),me.promises.stat(we).catch(()=>null)]);if(N?.isFile()&&!w(X,u,S))return zt(X);if(J?.isFile()&&!w(Oe,u,S))return zt(Oe);if(W?.isFile()&&!w(we,u,S))return zt(we);if(H.pathname.startsWith("/_stx/component/")){let B=decodeURIComponent(H.pathname.slice(16));if(B)try{let re=`<${B} />`,Z={...buildConfig,autoShell:!1},se=await processDirectives(re,{},te.join(u,"components",`${B}.stx`),Z,new Set);return new Response(se,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(H.pathname==="/_stx/img"){let{handleImageRequest:B}=await import("./chunk-mzwa2478.js"),re=await B(E,{publicDir:te.join(u,Q),cacheDir:l(u,"cache","img")});if(re)return re}if(Y)try{let B=await Y.handleRequest(E);if(B.status!==404)return B}catch{}if(V[H.pathname])try{return await V[H.pathname](E)}catch(B){return new Response(JSON.stringify({error:B.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await C(E);if(pe)return pe;let G=lr(H.pathname,k);if(G){let B=le.get(G.route.pattern),re=Pe.has(G.route.pattern);if(!B||G.route.isDynamic&&Object.keys(G.params).length>0||re){let Z=await _(G.route,G.params);if(Z){if(B=Z,!G.route.isDynamic&&!re)le.set(G.route.pattern,Z)}}if(B){let Z=B.status??200,se=B.headers??{},ue=(G.route.filePath?mt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:G.params})){let De=await ne(404);if(De){let ee=De;if(ee=await y(ee,u),s)ee=Ne(ee,f);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=_t(H.pathname,G.params,ue,H.search),De=Ct(Le,null,E,{isServer:!0}),ee=await Et(ue.middleware,De);if(ee.redirect){let Ae=ee.redirect.path,he=ee.redirect.options.redirectCode||302,at=new Headers(ee.responseHeaders);return at.set("Location",Ae),new Response(null,{status:he,headers:at})}if(ee.abort){let{statusCode:Ae,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${Ae}</title></head><body><h1>Error ${Ae}</h1><p>${he}</p></body></html>`,{status:Ae,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let Ae=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;B.content=B.content.replace("</head>",`${Ae}</head>`)}}let U=B.content;if(R&&Ki(E)){let Le=Ze(U),De=ye(U),ee=U.match(/<title[^>]*>([\s\S]*?)<\/title>/i),Ae=ee?Tn(ee[1].trim()):"";if(Object.keys(G.params).length>0)U=Ot(U,G.params);U=await y(U,u);let he=g?.router?.container||"main";return U=Ce(U,he,!0),new Response(U,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":De?"true":"false",...Ae&&{"X-STX-Title":encodeURIComponent(Ae)},[Fa]:Xr(),...M(),"Cache-Control":dt}})}if(R)U=Br(R,U);if(Object.keys(G.params).length>0)U=Ot(U,G.params);if(U=await y(U,u),s)U=Ne(U,f);if(n.native)if(U.includes("<head>"))U=U.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 U="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+U;if(n.titlebarHidden)if(U.includes("<head>"))U=U.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 U=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${U}`;if(B.boundaries&&B.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:De}=await import("./chunk-8z469777.js");return De(Le(U,B.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(U,{status:Z,headers:{"Content-Type":"text/html",...M(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...se}})}}if(O.length>0){let B=O.map((Z)=>Z.route),re=lr(H.pathname,B);if(re){let Z=A.get(re.route.pattern);if(!Z||re.route.isDynamic){let se=await _(re.route,re.params);if(se){if(Z=se,!re.route.isDynamic)A.set(re.route.pattern,se)}}if(Z){let se=Z.content;if(R)se=Br(R,se);if(Object.keys(re.params).length>0)se=Ot(se,re.params);if(se=await y(se,u),s)se=Ne(se,f);return new Response(se,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of L)if(Z!=="/"&&H.pathname.startsWith(Z)){let se=A.get(Z)||A.get(Z+"/");if(!se){let ue=O.find(({route:U})=>U.pattern===Z||U.pattern===`${Z}/`);if(ue){let U=await _(ue.route);if(U)se=U,A.set(ue.route.pattern,U)}}if(se){let ue=se.content;if(R)ue=Br(R,ue);if(ue=await y(ue,u),s)ue=Ne(ue,f);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(wt(H.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=le.get("/");if(We){let B=We.content;if(B=await y(B,u),s)B=Ne(B,f);if(n.native)if(B.includes("<head>"))B=B.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 B="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+B;return new Response(B,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let B=ce;if(B=await y(B,u),s)B=Ne(B,f);return new Response(B,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let H=await ne(500);if(H)return new Response(H,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
1429
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(w.url.toString(),()=>{if(d)Ke.watch(c,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ke.watch(c,{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}`),Ge.clear(),fe(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Wr}=globalThis.Bun;import me from"fs";import te from"path";async function ln(t){try{return pn(await Bun.file(t).text())}catch{return}}function zt(t){let n=Bun.file(t),o=te.extname(t).toLowerCase(),d={".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"},c=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[o]||"application/octet-stream",...c}})}async function Dr(t=".",n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,f=n.hmrPort||o+1,u=te.resolve(t),{loadStxConfig:h}=await import("./chunk-zsfwzwsd.js"),g=await h(u),{createServerApi:b,isServerApiSource:w}=await import("./chunk-gkfm4v2a.js"),S=n.stxOptions?.serverApi??g.serverApi,C=await b(u,S),v=g.root&&g.root!=="."?te.join(u,g.root):u,x=n.pagesDir||g.pagesDir||"pages",T=te.join(v,x);if(!me.existsSync(T)&&!g._layerPageDirs?.some((E)=>me.existsSync(E)))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=K(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 L=g?._pluginPageDirs||[],O=[];for(let{dir:E,prefix:H}of L)if(me.existsSync(E)){let z=K(te.dirname(E),{pagesDir:te.basename(E)});for(let Q of z){let X=H==="/"?Q.pattern:`${H}${Q.pattern==="/"?"":Q.pattern}`;O.push({route:{...Q,pattern:X},prefix:H})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${H}${e.reset}`)}let A=new Map,R=null,D=null;if(n.stxOptions?.shell!==!1){if(D=await qi(u,n.stxOptions?.shell),D){if(R=await eo(D,n.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(u,D)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}xt(),await kt(u);let I=St();if(I.length>0)console.log(`${e.blue}Loaded ${e.bright}${I.length}${e.blue} middleware: ${e.dim}${I.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:E}=await import("./chunk-zsfwzwsd.js"),H=await E(u);if(H?.apiRouter)Y=H?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(H?.apiRoutes){V=H.apiRoutes;let z=Object.keys(V).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(H?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Q}=await import("./chunk-gk0nq2ky.js"),X=H.broadcasting;await z(X);let Oe=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Oe}/ws${e.reset}`);let we=te.join(process.cwd(),"channels.ts");if(me.existsSync(we))try{let N=await Q(we);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let ve=l(u,"output");me.mkdirSync(ve,{recursive:!0});let le=new Map,Pe=new Set,ne=async(E)=>{let H=hs(T,E);if(!H)return null;try{let z=await Bun.build({entrypoints:[H],outdir:ve,plugins:[nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!z.success)return null;let Q=z.outputs.find((X)=>X.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},F=new Map,_=async(E,H)=>{try{let{processDirectives:z,extractVariables:Q,defaultConfig:X,loadStxConfig:Oe,injectRouterScript:we}=await import("./chunk-zsfwzwsd.js"),{checkCache:N,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-nccxqcj2.js"),G=await Oe(u),We=(ie)=>{if(!ie)return ie;if(te.isAbsolute(ie))return ie;return te.resolve(u,ie)},ce={...X,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=We(ce.partialsDir),ce.componentsDir=We(ce.componentsDir),ce.layoutsDir=We(ce.layoutsDir),ce.storesDir=We(ce.storesDir||"stores"),ce.cachePath=We(ce.cachePath)??l(u,"cache");let B=!H&&!n.profile,re=ce.cache!==!1;if(re&&B){let ie=pe.get(E.filePath);if(ie)try{if((await me.promises.stat(E.filePath)).mtime.getTime()<=ie.mtime){let He=!0;for(let ke of ie.dependencies){if(!me.existsSync(ke)){He=!1;break}if((await me.promises.stat(ke)).mtime.getTime()>ie.mtime){He=!1;break}}if(He){let ke=ie.output;if(R)ke=Ue(ke,{preserveHead:!0});let ot=F.get(E.filePath);return{route:E,content:ke,status:ot?.status??await ln(E.filePath),headers:ot?.headers}}}}catch{}let Ie=await N(E.filePath,ce);if(Ie){let je=Ie;if(R)je=Ue(je,{preserveHead:!0});let He=F.get(E.filePath);return{route:E,content:je,status:He?.status??await ln(E.filePath),headers:He?.headers}}}let Z=re?await W(E.filePath):await Bun.file(E.filePath).text(),se=pn(Z),{classifyAllScripts:ue}=await import("./chunk-zsfwzwsd.js"),U=ue(Z),Le=U.server.map((ie)=>ie.content),De=Z;for(let ie of U.server)De=De.replace(ie.fullTag,"");let ee={__filename:E.filePath,__dirname:te.dirname(E.filePath),__stx_options:ce,params:H??{},__stx_runtime_head:{}};for(let ie of Le)try{await Q(ie,ee,E.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ae=new Set,he;if(n.profile){let ie=performance.now();he=await z(De,ee,E.filePath,ce,Ae);let Ie=performance.now()-ie,je=te.relative(u,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await z(De,ee,E.filePath,ce,Ae);if(!R)he=await we(he,{router:ce.router});{let{interpolateScriptExpressions:ie}=await import("./chunk-2xp44gz3.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ie(He,ee)}</script>`})}if(R)he=Ue(he,{preserveHead:!0});if(re&&B)await J(E.filePath,he,Ae,ce);let{extractStreamBoundaries:at}=await import("./chunk-n0dajrzk.js"),Ye=at(ee),rt=ee.__streamTemplates;if(rt&&typeof rt==="object"&&Object.keys(rt).length>0){let ie=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(rt).map((ke)=>({id:ke,render:async()=>{let ot=typeof ie[ke]==="function"?await ie[ke]():void 0;return z(rt[ke],{...ee,$boundary:ot},E.filePath,Ie,new Set)}})),He=new Set(je.map((ke)=>ke.id));Ye=[...(Ye||[]).filter((ke)=>!He.has(ke.id)),...je]}if(Ye&&Ye.length>0)Pe.add(E.pattern);else Ye=void 0;let Wt=Pt(ee),Vt=It(ee);if(B)F.set(E.filePath,{status:Wt,headers:Vt});return{route:E,content:he,status:Wt??se,headers:Vt,boundaries:Ye}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Fe=8,ze=async()=>{let E=new Set(le.keys()),H=new Set(A.keys());le.clear(),A.clear();let z=n.prebuild===!1?k.filter((X)=>E.has(X.pattern)):k,Q=n.prebuild===!1?O.filter(({route:X})=>H.has(X.pattern)):O;for(let X=0;X<z.length;X+=Fe){let Oe=z.slice(X,X+Fe),we=await Promise.all(Oe.map((N)=>_(N)));for(let N of we)if(N)le.set(N.route.pattern,N)}for(let X=0;X<Q.length;X+=Fe){let Oe=Q.slice(X,X+Fe),we=await Promise.all(Oe.map(({route:N})=>_(N)));for(let N of we)if(N)A.set(N.route.pattern,N)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?k.length+O.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await sn(u);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let E=n.hmrPort||Xe+1;c=Tt({wsPort:E,verbose:!1}),f=c.start(E)}let Ot=(E,H)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(H).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(E.includes("</head>"))return E.replace("</head>",`${Q}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+E};console.log(`${e.blue}Starting server...${e.reset}`);let At=Wr({port:Xe,hostname:n.hostname,async fetch(E){let H=new URL(E.url),z=n.stxOptions?.offline??g.offline;if(H.pathname===vo&&z?.enabled){if(!["GET","HEAD"].includes(E.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(E.method==="HEAD"?null:wo(z,Xr()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=g?.publicDir||"public",X=te.join(u,Q,H.pathname),Oe=te.join(u,H.pathname),we=te.join(ve,H.pathname);if([X,Oe,we].some((B)=>w(B,u,S)))return new Response("Not Found",{status:404});let[N,J,W]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Oe).catch(()=>null),me.promises.stat(we).catch(()=>null)]);if(N?.isFile()&&!w(X,u,S))return zt(X);if(J?.isFile()&&!w(Oe,u,S))return zt(Oe);if(W?.isFile()&&!w(we,u,S))return zt(we);if(H.pathname.startsWith("/_stx/component/")){let B=decodeURIComponent(H.pathname.slice(16));if(B)try{let re=`<${B} />`,Z={...buildConfig,autoShell:!1},se=await processDirectives(re,{},te.join(u,"components",`${B}.stx`),Z,new Set);return new Response(se,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(H.pathname==="/_stx/img"){let{handleImageRequest:B}=await import("./chunk-mzwa2478.js"),re=await B(E,{publicDir:te.join(u,Q),cacheDir:l(u,"cache","img")});if(re)return re}if(Y)try{let B=await Y.handleRequest(E);if(B.status!==404)return B}catch{}if(V[H.pathname])try{return await V[H.pathname](E)}catch(B){return new Response(JSON.stringify({error:B.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await C(E);if(pe)return pe;let G=lr(H.pathname,k);if(G){let B=le.get(G.route.pattern),re=Pe.has(G.route.pattern);if(!B||G.route.isDynamic&&Object.keys(G.params).length>0||re){let Z=await _(G.route,G.params);if(Z){if(B=Z,!G.route.isDynamic&&!re)le.set(G.route.pattern,Z)}}if(B){let Z=B.status??200,se=B.headers??{},ue=(G.route.filePath?mt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:G.params})){let De=await ne(404);if(De){let ee=De;if(ee=await y(ee,u),s)ee=Ne(ee,f);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=_t(H.pathname,G.params,ue,H.search),De=Ct(Le,null,E,{isServer:!0}),ee=await Et(ue.middleware,De);if(ee.redirect){let Ae=ee.redirect.path,he=ee.redirect.options.redirectCode||302,at=new Headers(ee.responseHeaders);return at.set("Location",Ae),new Response(null,{status:he,headers:at})}if(ee.abort){let{statusCode:Ae,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${Ae}</title></head><body><h1>Error ${Ae}</h1><p>${he}</p></body></html>`,{status:Ae,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let Ae=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;B.content=B.content.replace("</head>",`${Ae}</head>`)}}let U=B.content;if(R&&Ki(E)){let Le=Ze(U),De=ye(U),ee=U.match(/<title[^>]*>([\s\S]*?)<\/title>/i),Ae=ee?Tn(ee[1].trim()):"";if(Object.keys(G.params).length>0)U=Ot(U,G.params);U=await y(U,u);let he=g?.router?.container||"main";return U=Ce(U,he,!0),new Response(U,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":De?"true":"false",...Ae&&{"X-STX-Title":encodeURIComponent(Ae)},[Fa]:Xr(),...M(),"Cache-Control":dt}})}if(R)U=Br(R,U);if(Object.keys(G.params).length>0)U=Ot(U,G.params);if(U=await y(U,u),s)U=Ne(U,f);if(n.native)if(U.includes("<head>"))U=U.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 U="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+U;if(n.titlebarHidden)if(U.includes("<head>"))U=U.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 U=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${U}`;if(B.boundaries&&B.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:De}=await import("./chunk-n0dajrzk.js");return De(Le(U,B.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(U,{status:Z,headers:{"Content-Type":"text/html",...M(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...se}})}}if(O.length>0){let B=O.map((Z)=>Z.route),re=lr(H.pathname,B);if(re){let Z=A.get(re.route.pattern);if(!Z||re.route.isDynamic){let se=await _(re.route,re.params);if(se){if(Z=se,!re.route.isDynamic)A.set(re.route.pattern,se)}}if(Z){let se=Z.content;if(R)se=Br(R,se);if(Object.keys(re.params).length>0)se=Ot(se,re.params);if(se=await y(se,u),s)se=Ne(se,f);return new Response(se,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of L)if(Z!=="/"&&H.pathname.startsWith(Z)){let se=A.get(Z)||A.get(Z+"/");if(!se){let ue=O.find(({route:U})=>U.pattern===Z||U.pattern===`${Z}/`);if(ue){let U=await _(ue.route);if(U)se=U,A.set(ue.route.pattern,U)}}if(se){let ue=se.content;if(R)ue=Br(R,ue);if(ue=await y(ue,u),s)ue=Ne(ue,f);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(wt(H.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=le.get("/");if(We){let B=We.content;if(B=await y(B,u),s)B=Ne(B,f);if(n.native)if(B.includes("<head>"))B=B.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 B="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+B;return new Response(B,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let B=ce;if(B=await y(B,u),s)B=Ne(B,f);return new Response(B,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let H=await ne(500);if(H)return new Response(H,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
1430
1430
  ${E.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
1431
1431
  ${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(`
1432
1432
  ${e.bright}\u2192 ${e.cyan}http://localhost:${Xe}/${e.reset}`),s)console.log(`${e.dim} HMR: ws://localhost:${f}${e.reset}`);console.log(`
1433
1433
  ${e.yellow}Routes:${e.reset}`);let Dt=[...ys(k,u)];for(let{route:E}of O)Dt.push(`${E.pattern}`);if(Dt.forEach((E,H)=>{let Q=H===Dt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${Q}${e.reset}${E}`)}),console.log(`
1434
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(At.url.toString(),()=>{if(c)st();At.stop()}),n.native){let E,H=te.join(T,"index.stx");if(me.existsSync(H)){let Q=await Bun.file(H).text();E=ht(Q)}let z=g?.app?.window??{};await Qe(Xe,{title:g?.app?.head?.title||te.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(N)=>N.startsWith("public/")||N.startsWith("public\\"),H=(N)=>{let J=N.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},z=new Map,Q=()=>{let N=new Set([u,...g._layerGraph?.layers.map((J)=>J.root)??[],...g._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of g._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...N].some((G)=>pe===G||pe.startsWith(`${G}${te.sep}`)))N.add(pe)}for(let[J,W]of z)if(!N.has(J))W.close(),z.delete(J);for(let J of N)if(!z.has(J)&&me.existsSync(J))z.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Oe(J,W,pe).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Oe=(N,J,W)=>(X=X.catch(()=>{}).then(()=>we(N,J,W)),X),we=async(N,J,W)=>{if(!W||vt(W))return;if(bt(W)){if(g._layerGraph){let pe=await h(u);Object.assign(g,pe),k.splice(0,k.length,...K(v,{pagesDir:x,pagesDirs:pe._layerPageDirs?[T,...pe._layerPageDirs.slice(1)]:void 0})),Q()}if(E(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),s&&c)c.reload(W)}else if(H(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Ge.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-eywx2f4h.js");pe(te.resolve(N,W)),G.delete(te.resolve(N,W))}catch{}if(D&&W){if(te.resolve(N,W)===D||te.basename(D)===W){let G=await eo(D,n.stxOptions||{});if(G)R=G}}if(await ze(),await tr(u),s&&c)c.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Ge.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-eywx2f4h.js");pe(te.resolve(N,W)),G.delete(te.resolve(N,W))}catch{}if(await ze(),s&&c)c.reload(W)}}else if(yt(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),s&&c)c.updateCss(W)}};Q(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(c)st();At.stop(),process.exit(0)})}return!0}import Nt from"fs";import it from"path";async function Vr(t){try{let o=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],s=[],c=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,f;while((f=c.exec(d))!==null){let u=f[1],h=f[2]||f[3]||f[4];if(!h)continue;let g={name:h},b=u.match(/@type\s+\{([^}]+)\}/i);if(b)g.type=b[1].trim();if(u.match(/@required/i))g.required=!0;let S=u.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)g.default=S[1].trim();let C=u.split(`
1434
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(At.url.toString(),()=>{if(c)st();At.stop()}),n.native){let E,H=te.join(T,"index.stx");if(me.existsSync(H)){let Q=await Bun.file(H).text();E=ht(Q)}let z=g?.app?.window??{};await Qe(Xe,{title:g?.app?.head?.title||te.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(N)=>N.startsWith("public/")||N.startsWith("public\\"),H=(N)=>{let J=N.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},z=new Map,Q=()=>{let N=new Set([u,...g._layerGraph?.layers.map((J)=>J.root)??[],...g._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of g._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...N].some((G)=>pe===G||pe.startsWith(`${G}${te.sep}`)))N.add(pe)}for(let[J,W]of z)if(!N.has(J))W.close(),z.delete(J);for(let J of N)if(!z.has(J)&&me.existsSync(J))z.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Oe(J,W,pe).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Oe=(N,J,W)=>(X=X.catch(()=>{}).then(()=>we(N,J,W)),X),we=async(N,J,W)=>{if(!W||vt(W))return;if(bt(W)){if(g._layerGraph){let pe=await h(u);Object.assign(g,pe),k.splice(0,k.length,...K(v,{pagesDir:x,pagesDirs:pe._layerPageDirs?[T,...pe._layerPageDirs.slice(1)]:void 0})),Q()}if(E(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),s&&c)c.reload(W)}else if(H(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Ge.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-nccxqcj2.js");pe(te.resolve(N,W)),G.delete(te.resolve(N,W))}catch{}if(D&&W){if(te.resolve(N,W)===D||te.basename(D)===W){let G=await eo(D,n.stxOptions||{});if(G)R=G}}if(await ze(),await tr(u),s&&c)c.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Ge.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-nccxqcj2.js");pe(te.resolve(N,W)),G.delete(te.resolve(N,W))}catch{}if(await ze(),s&&c)c.reload(W)}}else if(yt(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),s&&c)c.updateCss(W)}};Q(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(c)st();At.stop(),process.exit(0)})}return!0}import Nt from"fs";import it from"path";async function Vr(t){try{let o=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],s=[],c=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,f;while((f=c.exec(d))!==null){let u=f[1],h=f[2]||f[3]||f[4];if(!h)continue;let g={name:h},b=u.match(/@type\s+\{([^}]+)\}/i);if(b)g.type=b[1].trim();if(u.match(/@required/i))g.required=!0;let S=u.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)g.default=S[1].trim();let C=u.split(`
1435
1435
  `).map((v)=>v.trim().replace(/^\*\s*/,"")).filter((v)=>!v.startsWith("@")&&v.length>0);g.description=C.join(" ").trim(),s.push(g)}if(s.length===0){let u=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(u){let g=u[1].split(",").map((b)=>b.trim()).filter(Boolean);for(let b of g){let[w]=b.split(":").map((S)=>S.trim());if(w)s.push({name:w})}}}return s}catch(n){return console.error(`Error extracting props from ${t}:`,n),[]}}async function qr(t){try{let n=await Bun.file(t).text(),o=n.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||n.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(o)return o[1].split(`
1436
1436
  `).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Kr(t,n=!1,o){let d=it.basename(t,".stx"),s=await Vr(t),c=await qr(t),f="";if(n&&o)f=`<${o}></${o}>`;else{let u=s.map((h)=>{if(h.type==="boolean")return`:${h.name}="true"`;return`${h.name}="value"`}).join(`
1437
1437
  `);f=`<${d}
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Qe}from"./chunk-0myrwz84.js";import{gt,Bn}from"./chunk-gvs17jd0.js";import{Ne,pn,Nc,Dc}from"./chunk-0jtrdgyv.js";import{kr,_r,Cr,Tr,ke}from"./chunk-xyyt8v1r.js";import{O}from"./chunk-wp6q0geg.js";import{ii}from"./chunk-qcw1neka.js";import{y}from"./chunk-3xmt01wr.js";import{i}from"./chunk-e8brwwp1.js";import{L,a}from"./chunk-90kfvtf6.js";import{oc}from"./chunk-zjw6j2x0.js";import{$n,Ue,Ce,Gi,Xi,Rn}from"./chunk-ccty08sm.js";import{nn,ho}from"./chunk-7kaadsd1.js";import{An}from"./chunk-b7j48bq9.js";import{Xt,Gn,Xn}from"./chunk-9adx6f4k.js";import{K}from"./chunk-f6ybdjt0.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function U(n=!1){let l=n?Bn():gt(),o=J(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function V(){let n=Qe(),l=J(n);return{content:n,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(n,l,o={}){let r=q.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Nc();let _={};try{_=await a(o.configDir)}catch{}let h=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))h.push(g[2])}let u=new Set(h.flatMap((R)=>Ne(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...L,..._,...o,buildMode:"compile",strict:!1},b=await i(e,D,r,T,A),w=$n(b)+Ue(b),j=Dc();return{route:l,sourceFile:n,html:b,fragment:w,placeholders:j,hasServerScripts:h.length>0,serverScriptContent:h,dependencies:Array.from(A),contentHash:S,status:pn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let h=m.readdirSync(S,{withFileTypes:!0});for(let d of h){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function Tg(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),h=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=ke(e.app?.head,{known:Tr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=An(A),b=n.serverApi??e.serverApi,w=typeof b==="object"?b:{};if(b)nn(o,w);if(e.runtimeConfig)O(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=K(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],P=R.filter((s)=>!Y.some((f)=>s.pattern.startsWith(`/${f}/`)||s.pattern===`/${f}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(n.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let B=[],H=[];for(let s of P){let f=T(s.pattern),M=f.rendering==="prerender";if(M&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:h,debug:n.debug});if(B.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Cr(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=kr(t.html,u);if(g.htmlAttrs)t.html=_r(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let W=p[1];t.html=t.html.replace(" "+W,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${W}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await y(t.html),M){let p=await Rn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Ce(t.html,D,!0);let z=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),G=c.join("server","pages",`${z}.compiled.json`),I=c.join("server","fragments",`${z}.html`);await Bun.write(c.join(r,G),JSON.stringify(t,null,2)),await Bun.write(c.join(r,I),t.fragment),H.push({pattern:s.pattern,compiledPath:G,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:M}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(f).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:f}=Z(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${d}/`)}let E=Xn(o);if(E){let{copied:s,bytes:f}=Z(E,c.join(r,"public",Gn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${Xt}/`)}let F={runtime:v.filename,router:x.filename},C=Gi(H,F,r);if(C.routeRules=A,C.routerContainer=D,b)C.apiRoutes=await ho(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await ii(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(oc(e._layerGraph),null,2));Xi(C,r);let N=Date.now()-l;return console.log(`
2
+ import{Qe}from"./chunk-0myrwz84.js";import{gt,Bn}from"./chunk-4g152e86.js";import{Ne,pn,Nc,Dc}from"./chunk-fgjp28yp.js";import{kr,_r,Cr,Tr,ke}from"./chunk-xyyt8v1r.js";import{O}from"./chunk-wp6q0geg.js";import{ii}from"./chunk-8rvdpsjw.js";import{y}from"./chunk-jh2jmbta.js";import{i}from"./chunk-ck7e0yy2.js";import{L,a}from"./chunk-prhws9sn.js";import{oc}from"./chunk-zjw6j2x0.js";import{$n,Ue,Ce,Gi,Xi,Rn}from"./chunk-t4ak76e6.js";import{nn,ho}from"./chunk-89gemg31.js";import{An}from"./chunk-b7j48bq9.js";import{Xt,Gn,Xn}from"./chunk-9adx6f4k.js";import{K}from"./chunk-4eatxb55.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function U(n=!1){let l=n?Bn():gt(),o=J(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function V(){let n=Qe(),l=J(n);return{content:n,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(n,l,o={}){let r=q.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Nc();let _={};try{_=await a(o.configDir)}catch{}let h=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))h.push(g[2])}let u=new Set(h.flatMap((R)=>Ne(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...L,..._,...o,buildMode:"compile",strict:!1},b=await i(e,D,r,T,A),w=$n(b)+Ue(b),j=Dc();return{route:l,sourceFile:n,html:b,fragment:w,placeholders:j,hasServerScripts:h.length>0,serverScriptContent:h,dependencies:Array.from(A),contentHash:S,status:pn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let h=m.readdirSync(S,{withFileTypes:!0});for(let d of h){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function Tg(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),h=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=ke(e.app?.head,{known:Tr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=An(A),b=n.serverApi??e.serverApi,w=typeof b==="object"?b:{};if(b)nn(o,w);if(e.runtimeConfig)O(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=K(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],P=R.filter((s)=>!Y.some((f)=>s.pattern.startsWith(`/${f}/`)||s.pattern===`/${f}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(n.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let B=[],H=[];for(let s of P){let f=T(s.pattern),M=f.rendering==="prerender";if(M&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:h,debug:n.debug});if(B.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Cr(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=kr(t.html,u);if(g.htmlAttrs)t.html=_r(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let W=p[1];t.html=t.html.replace(" "+W,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${W}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await y(t.html),M){let p=await Rn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Ce(t.html,D,!0);let z=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),G=c.join("server","pages",`${z}.compiled.json`),I=c.join("server","fragments",`${z}.html`);await Bun.write(c.join(r,G),JSON.stringify(t,null,2)),await Bun.write(c.join(r,I),t.fragment),H.push({pattern:s.pattern,compiledPath:G,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:M}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(f).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:f}=Z(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${d}/`)}let E=Xn(o);if(E){let{copied:s,bytes:f}=Z(E,c.join(r,"public",Gn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${Xt}/`)}let F={runtime:v.filename,router:x.filename},C=Gi(H,F,r);if(C.routeRules=A,C.routerContainer=D,b)C.apiRoutes=await ho(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await ii(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(oc(e._layerGraph),null,2));Xi(C,r);let N=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${N}ms \u2014 ${B.length} pages compiled`),{pageCount:B.length,assets:F,outputDir:r,duration:N}}
4
4
  export{Tg};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-xyyt8v1r.js";import"./chunk-wt18wv6x.js";import"./chunk-zn3c0ew5.js";import"./chunk-0jtrdgyv.js";import"./chunk-wp6q0geg.js";import"./chunk-qcw1neka.js";import"./chunk-stvw8y3c.js";import"./chunk-hmkg3xy0.js";import{l}from"./chunk-5n4qg8za.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
2
+ import"./chunk-xyyt8v1r.js";import"./chunk-wt18wv6x.js";import"./chunk-zn3c0ew5.js";import"./chunk-fgjp28yp.js";import"./chunk-wp6q0geg.js";import"./chunk-8rvdpsjw.js";import"./chunk-stvw8y3c.js";import"./chunk-7f9mmtrs.js";import{l}from"./chunk-5n4qg8za.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
3
3
  `)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Jr,nr,pf}from"./chunk-2t59wh9y.js";import"./chunk-7dc3n69c.js";import"./chunk-g0eakxxe.js";import"./chunk-4eatxb55.js";import"./chunk-8v2vbc4y.js";import"./chunk-prhws9sn.js";import"./chunk-7f9mmtrs.js";import"./chunk-stvw8y3c.js";import"./chunk-zjw6j2x0.js";import"./chunk-3t3p2c1t.js";import"./chunk-0myrwz84.js";import{Rt}from"./chunk-fgjp28yp.js";import"./chunk-8rvdpsjw.js";import"./chunk-wp6q0geg.js";import"./chunk-xyyt8v1r.js";import"./chunk-zn3c0ew5.js";import"./chunk-wt18wv6x.js";export{pf as declareBareLoopHead,Rt as parseLoopBinding,nr as processLoops,Jr as reportDeferredLoopWarnings};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{sh,mf,$o,ns,rr,Ro,Ao,rs,ss,os,Po,Wa,hf,yt}from"./chunk-s1vj8gtz.js";import"./chunk-f6ybdjt0.js";import"./chunk-8v2vbc4y.js";import"./chunk-90kfvtf6.js";import"./chunk-hmkg3xy0.js";import"./chunk-stvw8y3c.js";import"./chunk-zjw6j2x0.js";import"./chunk-3t3p2c1t.js";import"./chunk-0myrwz84.js";import{F}from"./chunk-0jtrdgyv.js";import"./chunk-qcw1neka.js";import"./chunk-wp6q0geg.js";import"./chunk-xyyt8v1r.js";import"./chunk-zn3c0ew5.js";import"./chunk-wt18wv6x.js";export{sh as clearScriptScanCache,rs as convertServerLoopAttributesToDirectives,Ro as convertSignalDirectivesToAttributes,ss as convertSignalLoopsToAttributes,rr as extractClientSignalNames,F as extractExports,Wa as findMarkupIndexOutsideScripts,ns as hasSignalsSyntax,$o as parseLoopExpression,Ao as preEvalLiteralReactiveIfs,os as processScriptSetup,Po as processSignals,hf as rewriteStxImportSpecifiers,mf as scanScriptTags,yt as stripStxRuntimeImports};
2
+ import{sh,mf,$o,ns,rr,Ro,Ao,rs,ss,os,Po,Wa,hf,yt}from"./chunk-g0eakxxe.js";import"./chunk-4eatxb55.js";import"./chunk-8v2vbc4y.js";import"./chunk-prhws9sn.js";import"./chunk-7f9mmtrs.js";import"./chunk-stvw8y3c.js";import"./chunk-zjw6j2x0.js";import"./chunk-3t3p2c1t.js";import"./chunk-0myrwz84.js";import{F}from"./chunk-fgjp28yp.js";import"./chunk-8rvdpsjw.js";import"./chunk-wp6q0geg.js";import"./chunk-xyyt8v1r.js";import"./chunk-zn3c0ew5.js";import"./chunk-wt18wv6x.js";export{sh as clearScriptScanCache,rs as convertServerLoopAttributesToDirectives,Ro as convertSignalDirectivesToAttributes,ss as convertSignalLoopsToAttributes,rr as extractClientSignalNames,F as extractExports,Wa as findMarkupIndexOutsideScripts,ns as hasSignalsSyntax,$o as parseLoopExpression,Ao as preEvalLiteralReactiveIfs,os as processScriptSetup,Po as processSignals,hf as rewriteStxImportSpecifiers,mf as scanScriptTags,yt as stripStxRuntimeImports};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{U,Oe}from"./chunk-0jtrdgyv.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function Jt(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=Oe(t,s);if(p>s){c=p;continue}let a=U(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
2
+ import{U,Oe}from"./chunk-fgjp28yp.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function Jt(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=Oe(t,s);if(p>s){c=p;continue}let a=U(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
3
3
  export{Jt};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Qp,ef,Te,tf,ja,Yt,Zt,Gm,Ba,Qt,Jn,nf,rf,sf,go,en,of,tn,af}from"./chunk-sz0e6tpq.js";import"./chunk-7kaadsd1.js";import"./chunk-1xjv71dw.js";import"./chunk-90kfvtf6.js";import"./chunk-hmkg3xy0.js";import"./chunk-stvw8y3c.js";import"./chunk-zjw6j2x0.js";import"./chunk-3t3p2c1t.js";import"./chunk-0myrwz84.js";import"./chunk-0jtrdgyv.js";import"./chunk-qcw1neka.js";import"./chunk-wp6q0geg.js";import"./chunk-xyyt8v1r.js";import"./chunk-zn3c0ew5.js";import"./chunk-wt18wv6x.js";export{Jn as MODULE_SPECIFIER_PREFIX,Qp as bundleCacheDir,ef as bundleCacheEntryLimit,tn as bundleClientScript,Zt as clearBundleFailures,Te as clientBundleDependencies,Yt as getBundleFailures,Qt as hasUserImports,en as moduleSubstitutionKey,rf as normalizeRegistrySpecifiers,of as queueClientBundleBuild,ja as recordBundleFailure,nf as registryIdForPath,Ba as resolveBundlerFallback,sf as rewriteRegistryImports,Gm as setBundlerFallbackMode,tf as shouldLogBundlerDiagnostics,af as tempBuildName,go as withModuleSubstitutes};
2
+ import{Qp,ef,Te,tf,ja,Yt,Zt,Gm,Ba,Qt,Jn,nf,rf,sf,go,en,of,tn,af}from"./chunk-9r5ntnef.js";import"./chunk-89gemg31.js";import"./chunk-1xjv71dw.js";import"./chunk-prhws9sn.js";import"./chunk-7f9mmtrs.js";import"./chunk-stvw8y3c.js";import"./chunk-zjw6j2x0.js";import"./chunk-3t3p2c1t.js";import"./chunk-0myrwz84.js";import"./chunk-fgjp28yp.js";import"./chunk-8rvdpsjw.js";import"./chunk-wp6q0geg.js";import"./chunk-xyyt8v1r.js";import"./chunk-zn3c0ew5.js";import"./chunk-wt18wv6x.js";export{Jn as MODULE_SPECIFIER_PREFIX,Qp as bundleCacheDir,ef as bundleCacheEntryLimit,tn as bundleClientScript,Zt as clearBundleFailures,Te as clientBundleDependencies,Yt as getBundleFailures,Qt as hasUserImports,en as moduleSubstitutionKey,rf as normalizeRegistrySpecifiers,of as queueClientBundleBuild,ja as recordBundleFailure,nf as registryIdForPath,Ba as resolveBundlerFallback,sf as rewriteRegistryImports,Gm as setBundlerFallbackMode,tf as shouldLogBundlerDiagnostics,af as tempBuildName,go as withModuleSubstitutes};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{H}from"./chunk-fgjp28yp.js";function n(t){return H(t)}
3
+ export{n};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{k}from"./chunk-wt18wv6x.js";import{A,kn}from"./chunk-zn3c0ew5.js";import{_,Y}from"./chunk-0jtrdgyv.js";import{a}from"./chunk-90kfvtf6.js";import{Te,Qt,en,tn}from"./chunk-sz0e6tpq.js";import{yt}from"./chunk-s1vj8gtz.js";import{ft,jn,Kt,ce}from"./chunk-h6pmg82p.js";import{T,$r}from"./chunk-ncs2j5kc.js";import p from"path";var c=new Map;function v(i,n){for(let s of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of i.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let o of(s[1]??"").split(",")){let l=((o.includes(":")?o.split(":").pop():o)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of i.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let o of(s[1]??"").split(",")){let r=o.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Am(i){let n;if(i)n=p.resolve(i);else{let t=await a();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${en()}`,o=new Bun.Glob("*.ts"),r=[];try{for await(let t of o.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return ce(c,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Te(t))])],f=ft(l()),d=Kt(c,s,f);if(d!==void 0)return d||null;if(r.length===0)return ce(c,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let b=u.map((t)=>t.file),m=[],g=new Set,x=Y({loader:"ts",target:"browser",define:_()});for(let t of b)try{let e=await Bun.file(t).text(),y=p.basename(t,".ts");if(v(e,g),Qt(e))e=await tn(e,t,{projectRoot:process.cwd(),externalizeUserModules:T()});e=yt(e),e=A(e),e=kn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=x.transformSync(e),m.push(`// Store: ${y}
2
+ import{k}from"./chunk-wt18wv6x.js";import{A,kn}from"./chunk-zn3c0ew5.js";import{_,Y}from"./chunk-fgjp28yp.js";import{a}from"./chunk-prhws9sn.js";import{Te,Qt,en,tn}from"./chunk-9r5ntnef.js";import{yt}from"./chunk-g0eakxxe.js";import{ft,jn,Kt,ce}from"./chunk-h6pmg82p.js";import{T,$r}from"./chunk-ncs2j5kc.js";import p from"path";var c=new Map;function v(i,n){for(let s of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of i.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let o of(s[1]??"").split(",")){let l=((o.includes(":")?o.split(":").pop():o)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of i.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let o of(s[1]??"").split(",")){let r=o.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Am(i){let n;if(i)n=p.resolve(i);else{let t=await a();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${en()}`,o=new Bun.Glob("*.ts"),r=[];try{for await(let t of o.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return ce(c,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Te(t))])],f=ft(l()),d=Kt(c,s,f);if(d!==void 0)return d||null;if(r.length===0)return ce(c,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let b=u.map((t)=>t.file),m=[],g=new Set,x=Y({loader:"ts",target:"browser",define:_()});for(let t of b)try{let e=await Bun.file(t).text(),y=p.basename(t,".ts");if(v(e,g),Qt(e))e=await tn(e,t,{projectRoot:process.cwd(),externalizeUserModules:T()});e=yt(e),e=A(e),e=kn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=x.transformSync(e),m.push(`// Store: ${y}
3
3
  ${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return ce(c,s,f,""),null;let S=m.join(`
4
4
 
5
5
  `),h=`;(function(){
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Tg}from"./chunk-vjqm4a5c.js";import"./chunk-t4ak76e6.js";import"./chunk-4g152e86.js";import"./chunk-wpfnbcvn.js";import"./chunk-89gemg31.js";import"./chunk-ck7e0yy2.js";import"./chunk-jh2jmbta.js";import"./chunk-ap30qs8p.js";import"./chunk-2t59wh9y.js";import"./chunk-p12nxr1r.js";import"./chunk-nd9rs768.js";import"./chunk-xbbxa1t8.js";import"./chunk-7dc3n69c.js";import"./chunk-g0eakxxe.js";import"./chunk-4eatxb55.js";import"./chunk-8v2vbc4y.js";import"./chunk-659vn8hx.js";import"./chunk-prhws9sn.js";import"./chunk-7f9mmtrs.js";import"./chunk-stvw8y3c.js";import"./chunk-zjw6j2x0.js";import"./chunk-3t3p2c1t.js";import"./chunk-0myrwz84.js";import"./chunk-fgjp28yp.js";import"./chunk-8rvdpsjw.js";import"./chunk-wp6q0geg.js";import"./chunk-xyyt8v1r.js";import"./chunk-zn3c0ew5.js";import"./chunk-wt18wv6x.js";export{Tg as buildForProduction};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{So,ko,_o,nh,es,rh}from"./chunk-65fcex5r.js";export{es as clearImageDeliveryCatalog,nh as deliveredImage,_o as efficientDeliverySources,So as getImageDelivery,ko as isTransparentImage,rh as prepareImageDelivery};
2
+ import{So,ko,_o,nh,es,rh}from"./chunk-nd9rs768.js";export{es as clearImageDeliveryCatalog,nh as deliveredImage,_o as efficientDeliverySources,So as getImageDelivery,ko as isTransparentImage,rh as prepareImageDelivery};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{al,cl}from"./chunk-tzkyfw0p.js";import"./chunk-8nfrqcd1.js";import"./chunk-8t9ws0ct.js";import"./chunk-zav8yrtp.js";import"./chunk-yw66yks2.js";import"./chunk-e97h1wzd.js";import"./chunk-768evhvm.js";import"./chunk-vjqm4a5c.js";import"./chunk-t4ak76e6.js";import"./chunk-cwhzk2n3.js";import"./chunk-g1tq4xdb.js";import"./chunk-jbxyg5sc.js";import"./chunk-67abad76.js";import"./chunk-dcpgj3c6.js";import"./chunk-dxqvv686.js";import"./chunk-2aarvd3a.js";import"./chunk-rb2a1qxb.js";import"./chunk-hh3tgx1f.js";import"./chunk-s9b6abkb.js";import"./chunk-5vejh42a.js";import"./chunk-t6ayy0t5.js";import"./chunk-4ckxs446.js";import"./chunk-029qng4p.js";import"./chunk-ckrmrdjp.js";import"./chunk-42w6snem.js";import"./chunk-6n11z33h.js";import"./chunk-xf3bt7xf.js";import"./chunk-hjq5463c.js";import"./chunk-4g152e86.js";import"./chunk-jdgfzxyg.js";import"./chunk-t63f15yh.js";import"./chunk-edka95zp.js";import{Jt}from"./chunk-wpfnbcvn.js";import"./chunk-9r5ntnef.js";import"./chunk-89gemg31.js";import"./chunk-1xjv71dw.js";import{Re,i}from"./chunk-ck7e0yy2.js";import"./chunk-jh2jmbta.js";import"./chunk-ap30qs8p.js";import"./chunk-2t59wh9y.js";import"./chunk-p12nxr1r.js";import"./chunk-nd9rs768.js";import"./chunk-xbbxa1t8.js";import"./chunk-7dc3n69c.js";import"./chunk-g0eakxxe.js";import{be}from"./chunk-4eatxb55.js";import"./chunk-8v2vbc4y.js";import{ir,ar}from"./chunk-659vn8hx.js";import{cs,L,a}from"./chunk-prhws9sn.js";import"./chunk-7f9mmtrs.js";import"./chunk-stvw8y3c.js";import"./chunk-zjw6j2x0.js";import"./chunk-3t3p2c1t.js";import"./chunk-0myrwz84.js";import{m,Me}from"./chunk-fgjp28yp.js";import"./chunk-8rvdpsjw.js";import"./chunk-wp6q0geg.js";import"./chunk-xyyt8v1r.js";import"./chunk-zn3c0ew5.js";import"./chunk-wt18wv6x.js";import"./chunk-qa9t9k6z.js";import"./chunk-6cz1sbb1.js";export{cs as buildWebComponents,ar as cacheTemplate,ir as checkCache,Jt as classifyAllScripts,al as createMiddleware,cl as createRoute,L as defaultConfig,m as extractVariables,be as injectRouterScript,a as loadStxConfig,Me as processClientScript,i as processDirectives,Re as readMarkdownFile};