@stacksjs/stx 0.2.552 → 0.2.554

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 (69) hide show
  1. package/dist/app-service-worker.d.ts +2 -0
  2. package/dist/{chunk-5dps9j52.js → chunk-20xnk6jm.js} +1 -1
  3. package/dist/chunk-2dtvrkpk.js +2 -0
  4. package/dist/{chunk-arwy6xnb.js → chunk-2jc9e080.js} +1 -1
  5. package/dist/{chunk-ctxc46xf.js → chunk-3mv77zv3.js} +1 -1
  6. package/dist/chunk-3x3pn8qw.js +2 -0
  7. package/dist/{chunk-w8h7nb1d.js → chunk-4wwpxt4z.js} +226 -226
  8. package/dist/{chunk-1ed2k6tm.js → chunk-58dkqb3y.js} +1 -1
  9. package/dist/chunk-5c5aqc6z.js +2 -0
  10. package/dist/{chunk-2q7dwg3m.js → chunk-6bk7q8ef.js} +1 -1
  11. package/dist/{chunk-drbdamvr.js → chunk-72qdb639.js} +1 -1
  12. package/dist/{chunk-v3w4kamj.js → chunk-7qjnzhbv.js} +1 -1
  13. package/dist/{chunk-zbyxr3gp.js → chunk-8mzsz1k6.js} +1 -1
  14. package/dist/{chunk-4qdn2feh.js → chunk-91za8dqh.js} +1 -1
  15. package/dist/{chunk-ma06ph1w.js → chunk-9m93hezh.js} +1 -1
  16. package/dist/{chunk-qm5em90c.js → chunk-9mcnkrjx.js} +1 -1
  17. package/dist/{chunk-7p0c9hwn.js → chunk-aqpmja5j.js} +1 -1
  18. package/dist/{chunk-pfs583r2.js → chunk-bn25kybp.js} +1 -1
  19. package/dist/{chunk-r18sh8h9.js → chunk-bngcrt1x.js} +1 -1
  20. package/dist/{chunk-4rx8h4pj.js → chunk-bnh24b88.js} +1 -1
  21. package/dist/{chunk-5qpfrvb3.js → chunk-bqg1d720.js} +1 -1
  22. package/dist/{chunk-k59carj9.js → chunk-bzvmtger.js} +1 -1
  23. package/dist/{chunk-7dkjt05z.js → chunk-crcd5phx.js} +1 -1
  24. package/dist/{chunk-pa16zx05.js → chunk-d3gdmf4n.js} +1 -1
  25. package/dist/{chunk-swfbwd6n.js → chunk-d44d4n86.js} +5 -5
  26. package/dist/{chunk-ya0gg9k7.js → chunk-d8221ft9.js} +1 -1
  27. package/dist/{chunk-aykqn3ys.js → chunk-ddg0x0pp.js} +1 -1
  28. package/dist/{chunk-w6eg410v.js → chunk-epxyy8mz.js} +1 -1
  29. package/dist/{chunk-x04bpk0q.js → chunk-f54c3jwk.js} +1 -1
  30. package/dist/{chunk-tza9kvnx.js → chunk-fm0db2ey.js} +1 -1
  31. package/dist/{chunk-zd85q44h.js → chunk-fq58g560.js} +1 -1
  32. package/dist/{chunk-n0hqvqz9.js → chunk-h7kzag56.js} +1 -1
  33. package/dist/{chunk-t3qv2pgr.js → chunk-h8gs6xfz.js} +1 -1
  34. package/dist/{chunk-avtdbnwd.js → chunk-jjx4913r.js} +1 -1
  35. package/dist/{chunk-1r1t5e5d.js → chunk-kqt67yc7.js} +2 -2
  36. package/dist/{chunk-dm4af8rf.js → chunk-kw7t9eq7.js} +1 -1
  37. package/dist/{chunk-jddnfn1x.js → chunk-ndmbsbhk.js} +1 -1
  38. package/dist/{chunk-fbjsx29b.js → chunk-nmeapbn4.js} +1 -1
  39. package/dist/{chunk-3jmpyfmv.js → chunk-q1xay7e8.js} +2 -2
  40. package/dist/{chunk-3tyzjytz.js → chunk-qd367k3a.js} +1 -1
  41. package/dist/{chunk-fe4mge8v.js → chunk-qmew5tzd.js} +1 -1
  42. package/dist/{chunk-1hdezgrx.js → chunk-qvjyyns1.js} +1 -1
  43. package/dist/{chunk-mkx2wyg0.js → chunk-s8x5fe91.js} +1 -1
  44. package/dist/{chunk-dwjxc9xq.js → chunk-ssb2pdn0.js} +1 -1
  45. package/dist/{chunk-4kbzj481.js → chunk-w6mymv3q.js} +1 -1
  46. package/dist/{chunk-s1s6002m.js → chunk-wzb6dfd4.js} +1 -1
  47. package/dist/{chunk-3471jnbx.js → chunk-z0ar2gk7.js} +1 -1
  48. package/dist/{chunk-8qntnkf1.js → chunk-zjerecmr.js} +1 -1
  49. package/dist/{chunk-crpbzgjm.js → chunk-zpyzpp5h.js} +2 -2
  50. package/dist/cli.js +7 -7
  51. package/dist/component-processing.d.ts +1 -16
  52. package/dist/component-processing.js +3 -4
  53. package/dist/component-registry.d.ts +1 -6
  54. package/dist/component-registry.js +1 -3
  55. package/dist/component-renderer.js +2 -2
  56. package/dist/component-resolution.d.ts +16 -0
  57. package/dist/component-resolution.js +5 -2
  58. package/dist/craft-entry.js +1 -1
  59. package/dist/craft.js +1 -1
  60. package/dist/offline/app-service-worker.d.ts +2 -0
  61. package/dist/offline/app-service-worker.js +56 -15
  62. package/dist/pwa.js +1 -1
  63. package/dist/ssg.js +2 -2
  64. package/dist/utils.d.ts +3 -1
  65. package/dist/utils.js +5 -4
  66. package/package.json +5 -5
  67. package/dist/chunk-0tw2hcst.js +0 -2
  68. package/dist/chunk-ngjyts6r.js +0 -2
  69. package/dist/chunk-rw8ybnjq.js +0 -2
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{pl}from"./chunk-4qdn2feh.js";import"./chunk-crpbzgjm.js";import"./chunk-0fatkxpr.js";import"./chunk-zd85q44h.js";import"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{pl as buildForProduction};
2
+ import{pl}from"./chunk-91za8dqh.js";import"./chunk-zpyzpp5h.js";import"./chunk-0fatkxpr.js";import"./chunk-fq58g560.js";import"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{pl as buildForProduction};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Xi,Ji}from"./chunk-d44d4n86.js";import"./chunk-ddg0x0pp.js";import"./chunk-epxyy8mz.js";import"./chunk-b9jb44kv.js";import"./chunk-frgpx23w.js";import"./chunk-crcd5phx.js";import"./chunk-yq1mvakj.js";import"./chunk-91za8dqh.js";import{co}from"./chunk-zpyzpp5h.js";import"./chunk-vvkfde23.js";import"./chunk-ah7h9q0x.js";import"./chunk-s8x5fe91.js";import"./chunk-75hb7wg6.js";import"./chunk-3nc2fr4q.js";import"./chunk-qd367k3a.js";import"./chunk-v79qs0qh.js";import"./chunk-8nwzd6eg.js";import"./chunk-gjx5256r.js";import"./chunk-pz8mf91e.js";import"./chunk-77j26p6r.js";import"./chunk-d37enreq.js";import"./chunk-zmq9hwta.js";import"./chunk-f54c3jwk.js";import"./chunk-kch9a9v1.js";import"./chunk-39tkfkp7.js";import"./chunk-7ze47qgv.js";import"./chunk-wy4hfmjs.js";import"./chunk-m6m19hwd.js";import"./chunk-kw7t9eq7.js";import"./chunk-0fatkxpr.js";import"./chunk-bzvmtger.js";import"./chunk-q1xay7e8.js";import"./chunk-tqnh98j7.js";import"./chunk-wk85dz07.js";import"./chunk-ssb2pdn0.js";import"./chunk-fq58g560.js";import"./chunk-azb58ven.js";import{ye,sn,on,K,d,n,Zn,R,o,de}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Zn as buildWebComponents,on as cacheTemplate,sn as checkCache,co as classifyAllScripts,Xi as createMiddleware,Ji as createRoute,R as defaultConfig,d as extractVariables,K as injectRouterScript,o as loadStxConfig,ye as processClientScript,n as processDirectives,de as readMarkdownFile};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Gd,Zo,Kd,Qo,fc,gc,Et,an,Xd,mc,hc,yc,f}from"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Et as buildCss,mc as extractClassNames,gc as fingerprintConfig,hc as generateCss,Xd as getCachedCSS,Gd as getCssServeAsset,f as injectCss,Zo as loadCssEngine,Qo as loadCssEngineConfig,an as rebuildCss,Kd as resetCssCache,fc as resolveUserCssConfig,yc as withLinkedModuleBundles};
2
+ import{Gd,Zo,Kd,Qo,fc,gc,Et,an,Xd,mc,hc,yc,f}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Et as buildCss,mc as extractClassNames,gc as fingerprintConfig,hc as generateCss,Xd as getCachedCSS,Gd as getCssServeAsset,f as injectCss,Zo as loadCssEngine,Qo as loadCssEngineConfig,an as rebuildCss,Kd as resetCssCache,fc as resolveUserCssConfig,yc as withLinkedModuleBundles};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{pa,_l,fa,ga,Tl,$l}from"./chunk-3tyzjytz.js";import"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{$l as applySlots,Tl as extractSlotContent,_l as parseSlotElement,pa as parseSlots,ga as processSlots,fa as renderSlot};
2
+ import{pa,_l,fa,ga,Tl,$l}from"./chunk-qd367k3a.js";import"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{$l as applySlots,Tl as extractSlotContent,_l as parseSlotElement,pa as parseSlots,ga as processSlots,fa as renderSlot};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Cl}from"./chunk-mkx2wyg0.js";import"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Cl as buildApp};
2
+ import{Cl}from"./chunk-s8x5fe91.js";import"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Cl as buildApp};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Me,V}from"./chunk-tqnh98j7.js";import{Do}from"./chunk-3jmpyfmv.js";import{u}from"./chunk-cg8hg6cs.js";var Cd=`
2
+ import{Me,V}from"./chunk-tqnh98j7.js";import{Do}from"./chunk-q1xay7e8.js";import{u}from"./chunk-cg8hg6cs.js";var Cd=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{De,Xt}from"./chunk-0fatkxpr.js";import{Ee}from"./chunk-kvmg6r89.js";import{Ko,Xo,f,_t,ee,N,n,R,o}from"./chunk-w8h7nb1d.js";import{C}from"./chunk-e124cgb6.js";import{Ts}from"./chunk-r18sh8h9.js";import{gn,mn,hn,bn,fe}from"./chunk-j2erwdgt.js";import{Ti}from"./chunk-dyreg5df.js";import{he,se,fo,go,Nt}from"./chunk-crpbzgjm.js";import{xt,Xr}from"./chunk-zd85q44h.js";import{Lt}from"./chunk-n1cqg89v.js";import{mt,Qt,en}from"./chunk-hpeg9erh.js";import{createHash as Q}from"crypto";function J(i){return Q("sha256").update(i).digest("hex").slice(0,8)}function U(i=!1){let l=i?Xt():De(),a=J(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function V(){let i=Ee(),l=J(i);return{content:i,filename:`router.${l}.js`,hash:l}}import m from"fs";import c from"path";import q from"path";import{createHash as te}from"crypto";function re(i={}){let l=new Set;return{context:new Proxy(i,{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(i,l,a={}){let r=q.resolve(i),e=await Bun.file(r).text(),S=te("sha256").update(e).digest("hex").slice(0,16);Ko();let _={};try{_=await o(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let v=g[1];if(/\bserver\b/.test(v))y.push(g[2])}let u=new Set(y.flatMap((v)=>ee(v))),{context:A}=re({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,P={...R,..._,...a,buildMode:"compile",strict:!1},b=await n(e,A,r,P,w),T=he(b),B=Xo();return{route:l,sourceFile:i,html:b,fragment:T,placeholders:B,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(w),contentHash:S,status:_t(e),streamTemplates:A.__streamTemplates}}var ne=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(i,l){let a=0,r=0;if(!m.existsSync(i))return{copied:a,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(ne.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),a++,r+=m.statSync(u).size}}}return e(i,l),{copied:a,bytes:r}}async function pl(i={}){let l=Date.now(),a=c.resolve(i.root||process.cwd()),r=c.resolve(a,i.outputDir||".output");console.log("[stx build] Starting production build...");let e=await o(a),S=c.resolve(a,i.componentsDir??e.componentsDir??"components"),_=c.resolve(a,i.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,i.layoutsDir??e.layoutsDir??"layouts"),d=i.publicDir??e.publicDir??"public",g=fe(e.app?.head,{known:bn,source:"app.head"}),u=e.app?.colorMode,A=e.router?.container||"main",w=i.routeRules??e.routeRules??{},P=Lt(w),b=i.serverApi??e.serverApi,T=typeof b==="object"?b:{};if(b)xt(a,T);if(e.runtimeConfig)C(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let B=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of B)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let v=N(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],M=v.filter((s)=>!Y.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${M.length} page routes (${v.length-M.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let D=U(i.debug),x=V();await Bun.write(c.join(r,"public","__stx",D.filename),D.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${D.filename} (${(D.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],E=[];for(let s of M){let h=P(s.pattern),k=h.rendering==="prerender";if(k&&(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:a,componentsDir:S,partialsDir:_,layoutsDir:y,debug:i.debug});if(O.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,D.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=hn(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=gn(t.html,u);if(g.htmlAttrs)t.html=mn(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 f(t.html),k){let p=await Nt(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=se(t.html,A);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),E.push({pattern:s.pattern,compiledPath:G,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:k}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let H=c.resolve(a,d);if(m.existsSync(H)){let{copied:s,bytes:h}=Z(H,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let F=en(a);if(F){let{copied:s,bytes:h}=Z(F,c.join(r,"public",Qt));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${mt}/`)}let K={runtime:D.filename,router:x.filename},j=fo(E,K,r);if(j.routeRules=w,j.routerContainer=A,b)j.apiRoutes=await Xr(a,r,T);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Ts(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Ti(e._layerGraph),null,2));go(j,r);let L=Date.now()-l;return console.log(`
2
+ import{De,Xt}from"./chunk-0fatkxpr.js";import{Ee}from"./chunk-kvmg6r89.js";import{Ko,Xo,f,_t,ee,N,n,R,o}from"./chunk-4wwpxt4z.js";import{C}from"./chunk-e124cgb6.js";import{Ts}from"./chunk-bngcrt1x.js";import{gn,mn,hn,bn,fe}from"./chunk-j2erwdgt.js";import{Ti}from"./chunk-dyreg5df.js";import{he,se,fo,go,Nt}from"./chunk-zpyzpp5h.js";import{xt,Xr}from"./chunk-fq58g560.js";import{Lt}from"./chunk-n1cqg89v.js";import{mt,Qt,en}from"./chunk-hpeg9erh.js";import{createHash as Q}from"crypto";function J(i){return Q("sha256").update(i).digest("hex").slice(0,8)}function U(i=!1){let l=i?Xt():De(),a=J(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function V(){let i=Ee(),l=J(i);return{content:i,filename:`router.${l}.js`,hash:l}}import m from"fs";import c from"path";import q from"path";import{createHash as te}from"crypto";function re(i={}){let l=new Set;return{context:new Proxy(i,{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(i,l,a={}){let r=q.resolve(i),e=await Bun.file(r).text(),S=te("sha256").update(e).digest("hex").slice(0,16);Ko();let _={};try{_=await o(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let v=g[1];if(/\bserver\b/.test(v))y.push(g[2])}let u=new Set(y.flatMap((v)=>ee(v))),{context:A}=re({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,P={...R,..._,...a,buildMode:"compile",strict:!1},b=await n(e,A,r,P,w),T=he(b),B=Xo();return{route:l,sourceFile:i,html:b,fragment:T,placeholders:B,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(w),contentHash:S,status:_t(e),streamTemplates:A.__streamTemplates}}var ne=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(i,l){let a=0,r=0;if(!m.existsSync(i))return{copied:a,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(ne.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),a++,r+=m.statSync(u).size}}}return e(i,l),{copied:a,bytes:r}}async function pl(i={}){let l=Date.now(),a=c.resolve(i.root||process.cwd()),r=c.resolve(a,i.outputDir||".output");console.log("[stx build] Starting production build...");let e=await o(a),S=c.resolve(a,i.componentsDir??e.componentsDir??"components"),_=c.resolve(a,i.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,i.layoutsDir??e.layoutsDir??"layouts"),d=i.publicDir??e.publicDir??"public",g=fe(e.app?.head,{known:bn,source:"app.head"}),u=e.app?.colorMode,A=e.router?.container||"main",w=i.routeRules??e.routeRules??{},P=Lt(w),b=i.serverApi??e.serverApi,T=typeof b==="object"?b:{};if(b)xt(a,T);if(e.runtimeConfig)C(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let B=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of B)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let v=N(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],M=v.filter((s)=>!Y.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${M.length} page routes (${v.length-M.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let D=U(i.debug),x=V();await Bun.write(c.join(r,"public","__stx",D.filename),D.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${D.filename} (${(D.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],E=[];for(let s of M){let h=P(s.pattern),k=h.rendering==="prerender";if(k&&(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:a,componentsDir:S,partialsDir:_,layoutsDir:y,debug:i.debug});if(O.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,D.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=hn(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=gn(t.html,u);if(g.htmlAttrs)t.html=mn(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 f(t.html),k){let p=await Nt(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=se(t.html,A);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),E.push({pattern:s.pattern,compiledPath:G,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:k}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let H=c.resolve(a,d);if(m.existsSync(H)){let{copied:s,bytes:h}=Z(H,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let F=en(a);if(F){let{copied:s,bytes:h}=Z(F,c.join(r,"public",Qt));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${mt}/`)}let K={runtime:D.filename,router:x.filename},j=fo(E,K,r);if(j.routeRules=w,j.routerContainer=A,b)j.apiRoutes=await Xr(a,r,T);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Ts(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Ti(e._layerGraph),null,2));go(j,r);let L=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${L}ms \u2014 ${O.length} pages compiled`),{pageCount:O.length,assets:K,outputDir:r,duration:L}}
4
4
  export{pl};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{oa,ao,cl,ia,aa,ll,dl}from"./chunk-7dkjt05z.js";import"./chunk-x04bpk0q.js";import"./chunk-dwjxc9xq.js";import"./chunk-zd85q44h.js";import"./chunk-azb58ven.js";import{Ve,bc}from"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{oa as buildVirtualSource,Ve as extractScriptBlocks,bc as extractTemplateExpressions,ia as findRuntimeTypeDeclarations,aa as findStxModuleDeclarations,dl as formatTypecheckDiagnostics,cl as sourcePathFor,ll as typecheckStxFiles,ao as virtualPathFor};
2
+ import{oa,ao,cl,ia,aa,ll,dl}from"./chunk-crcd5phx.js";import"./chunk-f54c3jwk.js";import"./chunk-ssb2pdn0.js";import"./chunk-fq58g560.js";import"./chunk-azb58ven.js";import{Ve,bc}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{oa as buildVirtualSource,Ve as extractScriptBlocks,bc as extractTemplateExpressions,ia as findRuntimeTypeDeclarations,aa as findStxModuleDeclarations,dl as formatTypecheckDiagnostics,cl as sourcePathFor,ll as typecheckStxFiles,ao as virtualPathFor};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Zd,vc,us,ps,ci,li,gs,ms,Kn,xc,di,ui,Sc,We}from"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Zd as clearScriptScanCache,gs as convertServerLoopAttributesToDirectives,ci as convertSignalDirectivesToAttributes,ms as convertSignalLoopsToAttributes,xc as extractExports,ui as findMarkupIndexOutsideScripts,ps as hasSignalsSyntax,us as parseLoopExpression,li as preEvalLiteralReactiveIfs,Kn as processScriptSetup,di as processSignals,Sc as rewriteStxImportSpecifiers,vc as scanScriptTags,We as stripStxRuntimeImports};
2
+ import{Zd,vc,us,ps,ci,li,gs,ms,Kn,xc,di,ui,Sc,We}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Zd as clearScriptScanCache,gs as convertServerLoopAttributesToDirectives,ci as convertSignalDirectivesToAttributes,ms as convertSignalLoopsToAttributes,xc as extractExports,ui as findMarkupIndexOutsideScripts,ps as hasSignalsSyntax,us as parseLoopExpression,li as preEvalLiteralReactiveIfs,Kn as processScriptSetup,di as processSignals,Sc as rewriteStxImportSpecifiers,vc as scanScriptTags,We as stripStxRuntimeImports};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Qd,Pc,we,mi,eu,bs,ws,vs}from"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{eu as clearOnceStore,mi as onceStore,we as partialsCache,bs as processIncludes,ws as processStackPushDirectives,vs as processStackReplacements,Qd as resetUnscopedSignalWarnings,Pc as topLevelElements};
2
+ import{Qd,Pc,we,mi,eu,bs,ws,vs}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{eu as clearOnceStore,mi as onceStore,we as partialsCache,bs as processIncludes,ws as processStackPushDirectives,vs as processStackReplacements,Qd as resetUnscopedSignalWarnings,Pc as topLevelElements};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{rl}from"./chunk-aykqn3ys.js";import"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{rl as startInteractive};
2
+ import{rl}from"./chunk-ddg0x0pp.js";import"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{rl as startInteractive};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Rt,C}from"./chunk-e124cgb6.js";import m from"fs";import e from"path";async function pn(r,o,i){if(r.__stx_runtime_config)return;let n=Rt();if(n||i){r.__stx_runtime_config=n??C(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-5qpfrvb3.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=C(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Ts(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
2
+ import{Rt,C}from"./chunk-e124cgb6.js";import m from"fs";import e from"path";async function pn(r,o,i){if(r.__stx_runtime_config)return;let n=Rt();if(n||i){r.__stx_runtime_config=n??C(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-bqg1d720.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=C(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Ts(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
3
3
  declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
4
4
  `),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
5
5
  declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  import m from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...o){let r=new Set;for(let s of o){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{r.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...r].sort()}async function w(o,r={}){if(o.length===0)return null;let s=process.cwd(),e=[],a=[];o.forEach((t,c)=>{let i=t.startsWith("npm:")?t.slice(4):m.resolve(s,t),l=`__stxRegistered${c}`,p=JSON.stringify(t);e.push(`import * as ${l} from ${JSON.stringify(i)};`),a.push(`if (!globalThis.__stxModules[${p}]) globalThis.__stxModules[${p}] = ${l};`)});let d=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...a].join(`
3
- `),n;try{let{bundleClientScript:t}=await import("./chunk-jddnfn1x.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-t94z65ry.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-pa16zx05.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-zpftj8s8.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
3
+ `),n;try{let{bundleClientScript:t}=await import("./chunk-ndmbsbhk.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-t94z65ry.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-d3gdmf4n.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-zpftj8s8.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
4
4
  `)}export{w as buildModuleRegistryScript,I as registeredModuleIdsIn};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{R,zc,o,A,nu,ru}from"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{A as config,R as defaultConfig,nu as defineStxConfig,o as loadStxConfig,zc as resolveStxDirectories,ru as validateConfig};
2
+ import{R,zc,o,A,nu,ru}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{A as config,R as defaultConfig,nu as defineStxConfig,o as loadStxConfig,zc as resolveStxDirectories,ru as validateConfig};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{b,d,n,g,R}from"./chunk-w8h7nb1d.js";import q from"path";var M={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},C=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var O=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function z(e){let t=[],o=0,s;O.lastIndex=0;while((s=O.exec(e))!==null){if(s.index>o){let a=e.slice(o,s.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let r=s[1],i=s[2];t.push({type:"suspense",name:r,content:i}),o=s.index+s[0].length}if(o<e.length){let r=e.slice(o);if(r.trim())t.push({type:t.length===0?"shell":"content",content:r})}if(t.length===0)t.push({type:"shell",content:e});return t}async function gd(e,t={},o={}){let s={...R,...o,streaming:{...M,...o.streaming}},r=s.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),w=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=w?w[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:q.dirname(e)};if(m.trim())await d(m,y,e);let T=z(c),u=new Set;if(!T.some((h)=>h.type==="suspense")){let h=s.streaming?.strategy||"auto",S=new RegExp(C.source,"g");if(!(h!=="manual"&&S.test(c))){let p=await n(c,y,e,s,u);for(let x=0;x<p.length;x+=r)i.enqueue(p.slice(x,x+r)),await new Promise((f)=>setTimeout(f,0))}else{let p=[],x=new RegExp(C.source,"g"),f;while((f=x.exec(c))!==null)p.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let E=0;for(let _ of p){if(_.start>E){let k=c.slice(E,_.start);if(k.trim()){let D=await n(k,y,e,s,u);i.enqueue(D),await new Promise((H)=>setTimeout(H,0))}}let I=await n(_.content,y,e,s,u);i.enqueue(I),await new Promise((k)=>setTimeout(k,0)),E=_.end}if(E<c.length){let _=c.slice(E);if(_.trim()){let I=await n(_,y,e,s,u);i.enqueue(I)}}}}else{let h=new Map;for(let l of T)if(l.type==="shell"||l.type==="content"){let p=await n(l.content,y,e,s,u);i.enqueue(p)}else if(l.type==="suspense"&&l.name){let p=`stx-suspense-${l.name}`;i.enqueue(`<div id="${p}" data-suspense="${l.name}" style="display:contents;">
2
+ import{b,d,n,g,R}from"./chunk-4wwpxt4z.js";import q from"path";var M={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},C=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var O=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function z(e){let t=[],o=0,s;O.lastIndex=0;while((s=O.exec(e))!==null){if(s.index>o){let a=e.slice(o,s.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let r=s[1],i=s[2];t.push({type:"suspense",name:r,content:i}),o=s.index+s[0].length}if(o<e.length){let r=e.slice(o);if(r.trim())t.push({type:t.length===0?"shell":"content",content:r})}if(t.length===0)t.push({type:"shell",content:e});return t}async function gd(e,t={},o={}){let s={...R,...o,streaming:{...M,...o.streaming}},r=s.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),w=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=w?w[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:q.dirname(e)};if(m.trim())await d(m,y,e);let T=z(c),u=new Set;if(!T.some((h)=>h.type==="suspense")){let h=s.streaming?.strategy||"auto",S=new RegExp(C.source,"g");if(!(h!=="manual"&&S.test(c))){let p=await n(c,y,e,s,u);for(let x=0;x<p.length;x+=r)i.enqueue(p.slice(x,x+r)),await new Promise((f)=>setTimeout(f,0))}else{let p=[],x=new RegExp(C.source,"g"),f;while((f=x.exec(c))!==null)p.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let E=0;for(let _ of p){if(_.start>E){let k=c.slice(E,_.start);if(k.trim()){let D=await n(k,y,e,s,u);i.enqueue(D),await new Promise((H)=>setTimeout(H,0))}}let I=await n(_.content,y,e,s,u);i.enqueue(I),await new Promise((k)=>setTimeout(k,0)),E=_.end}if(E<c.length){let _=c.slice(E);if(_.trim()){let I=await n(_,y,e,s,u);i.enqueue(I)}}}}else{let h=new Map;for(let l of T)if(l.type==="shell"||l.type==="content"){let p=await n(l.content,y,e,s,u);i.enqueue(p)}else if(l.type==="suspense"&&l.name){let p=`stx-suspense-${l.name}`;i.enqueue(`<div id="${p}" data-suspense="${l.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),h.set(l.name,n(l.content,y,e,s,u))}i.enqueue(`
5
5
  <script>
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{y}from"./chunk-r4199q6x.js";import{q,Ve,as,cs,ti,ni,ri,si,Gn,ls,oi,ii,ai,Tt,o}from"./chunk-w8h7nb1d.js";import{Fr}from"./chunk-x04bpk0q.js";import{a}from"./chunk-4cmqjmqr.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=Tt.filter((e)=>!me.has(e)).sort(),ne=[...y].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let r=x[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+x[0].length-r.length,p=e.slice(0,f),w=p.split(`
2
+ import{y}from"./chunk-r4199q6x.js";import{q,Ve,as,cs,ti,ni,ri,si,Gn,ls,oi,ii,ai,Tt,o}from"./chunk-4wwpxt4z.js";import{Fr}from"./chunk-f54c3jwk.js";import{a}from"./chunk-4cmqjmqr.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=Tt.filter((e)=>!me.has(e)).sort(),ne=[...y].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let r=x[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+x[0].length-r.length,p=e.slice(0,f),w=p.split(`
3
3
  `).length;s.push({line:w,column:f-(p.lastIndexOf(`
4
4
  `)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function se(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...x].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function oa(e,t="",s=""){let u=e.startLine>1?`
5
5
  `.repeat(e.startLine-1):"",i=ls(e)+cs(as(e.code)),l=e.kind==="client"||e.kind==="plain"?ri(t,e.code):"";return Gn(`${u+i}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{q,Zr,Qr,rc,St,qo,es,Go,Dd,Be,ts,ye}from"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import{Ci,s}from"./chunk-7wfh2hqy.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{q as BROWSER_CORE_IMPORTS,rc as STX_AUTO_IMPORTS,Zr as extractAndStripCssImports,Be as extractBridgeData,Ci as findInterpolationEnd,Go as generateAutoImportDestructuring,Dd as generateBrowserAutoImportDestructuring,ts as generateServerDataBridge,St as injectBrowserCoreAutoImports,ye as processClientScript,es as referencesName,Qr as renderVendorStyleTags,s as stripCommentsAndLiterals,qo as transformAutoImports};
2
+ import{q,Zr,Qr,rc,St,qo,es,Go,Dd,Be,ts,ye}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import{Ci,s}from"./chunk-7wfh2hqy.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{q as BROWSER_CORE_IMPORTS,rc as STX_AUTO_IMPORTS,Zr as extractAndStripCssImports,Be as extractBridgeData,Ci as findInterpolationEnd,Go as generateAutoImportDestructuring,Dd as generateBrowserAutoImportDestructuring,ts as generateServerDataBridge,St as injectBrowserCoreAutoImports,ye as processClientScript,es as referencesName,Qr as renderVendorStyleTags,s as stripCommentsAndLiterals,qo as transformAutoImports};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{X,wn,ne,P,Pt}from"./chunk-a5kaw8sc.js";import{tt,kn,pr,fr,gr,nt,rt,st,ot,it,at,Ce}from"./chunk-kvmg6r89.js";import{W,b,sn,on,e,Et,an,f,ze,_t,He,Ue,Q,N,le,K,d,we,hi,xs,n,r,te,Zn,o,A,de}from"./chunk-w8h7nb1d.js";import{Pe,lo,re,_,uo,Tr,In,he,po,se}from"./chunk-crpbzgjm.js";import{Dt}from"./chunk-w6eg410v.js";import{ce}from"./chunk-azb58ven.js";import{a}from"./chunk-4cmqjmqr.js";import{D}from"./chunk-3nk8cnrm.js";function Xs(t,s){let i=[],p=`${s}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)i.push(m);continue}if(l===s){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))i.push(m),c++}}return i}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
2
+ import{X,wn,ne,P,Pt}from"./chunk-a5kaw8sc.js";import{tt,kn,pr,fr,gr,nt,rt,st,ot,it,at,Ce}from"./chunk-kvmg6r89.js";import{W,b,sn,on,e,Et,an,f,ze,_t,He,Ue,Q,N,le,K,d,we,hi,xs,n,r,te,Zn,o,A,de}from"./chunk-4wwpxt4z.js";import{Pe,lo,re,_,uo,Tr,In,he,po,se}from"./chunk-zpyzpp5h.js";import{Dt}from"./chunk-epxyy8mz.js";import{ce}from"./chunk-azb58ven.js";import{a}from"./chunk-4cmqjmqr.js";import{D}from"./chunk-3nk8cnrm.js";function Xs(t,s){let i=[],p=`${s}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)i.push(m);continue}if(l===s){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))i.push(m),c++}}return i}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
3
3
  /* Theme selector for code blocks */
4
4
  .theme-selector {
5
5
  margin: 1rem 0;
@@ -1786,7 +1786,7 @@ else {
1786
1786
  })()
1787
1787
  </script>
1788
1788
  `;import _e from"fs";import Te from"path";function Pn(t){try{return _e.statSync(t).mtimeMs}catch{return null}}function At(t,s){let i=Math.max(0,Math.round((s-t)/1000));if(i<60)return`${i}s ago`;if(i<3600)return`${Math.round(i/60)}m ago`;return`${Math.round(i/3600)}h ago`}function Ei(t,s){try{return globalThis.Bun?.resolveSync(t,s)??null}catch{return null}}function On(t,s="stx"){let i=Te.resolve(t);for(let p=0;p<10;p++){let c=Te.join(i,"pantry","@stacksjs",s);if(_e.existsSync(c))return c;let l=Te.dirname(i);if(l===i)break;i=l}return null}var An=["@stacksjs/stx","bun-plugin-stx"];function Pi(t){try{let s=_e.readFileSync(Te.join(t,"package.json"),"utf8"),i=JSON.parse(s)?.version;return typeof i==="string"?i:null}catch{return null}}function Oi(t,s=6){let i=Te.resolve(t),p=[],c=new Set;function l(u,h){if(h>s)return;let g;try{g=_e.realpathSync(u)}catch{return}if(c.has(g))return;c.add(g);for(let w of An){let S=Te.join(u,w),C=Pi(S);if(C!==null)p.push({name:w,version:C,dir:Te.relative(i,S)||S,nested:h>0})}let y;try{y=_e.readdirSync(u,{withFileTypes:!0})}catch{return}for(let w of y){if(!w.isDirectory()&&!w.isSymbolicLink())continue;if(w.name===".bin"||w.name===".cache")continue;let S=Te.join(u,w.name);if(w.name.startsWith("@")){let v;try{v=_e.readdirSync(S,{withFileTypes:!0})}catch{continue}for(let x of v){let T=Te.join(S,x.name,"node_modules");if(_e.existsSync(T))l(T,h+1)}continue}let C=Te.join(S,"node_modules");if(_e.existsSync(C))l(C,h+1)}}let m=Te.join(i,"node_modules");if(_e.existsSync(m))l(m,0);return p}function Ai(t){let s=[];for(let i of An){let p=t.filter((m)=>m.name===i);if(p.length<=1)continue;let c=[...new Set(p.map((m)=>m.version))],l=p.map((m)=>`${m.version} at ${m.dir}`).join("; ");if(c.length===1){s.push({name:`${i} copies`,status:"info",detail:`${p.length} copies, all ${c[0]} \u2014 duplicated but in agreement`});continue}s.push({name:`${i} copies disagree`,status:"error",detail:`${c.length} versions installed, so which one runs depends on who imports it: ${l}`,fix:`remove the nested copies, or add an overrides entry pinning ${i}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${i}/package.json' -exec grep -H '"version"' {} +`})}return s}async function vr(t={}){let s=t.cwd?Te.resolve(t.cwd):process.cwd(),i=t.resolve??Ei,p=Date.now(),c=[],l=i("@stacksjs/stx",s);c.push(l?{name:"@stacksjs/stx resolves to",status:"ok",detail:l}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let m=i("bun-plugin-stx",s);if(m)c.push({name:"bun-plugin-stx resolves to",status:"ok",detail:m});for(let h of Ai(Oi(s)))c.push(h);let u=On(s,"stx");if(!u)c.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let h=Te.join(u,"src/signals.ts"),g=[Te.join(u,"dist/index.js"),Te.join(u,"dist/signals.js")].find((v)=>_e.existsSync(v))||null,y=Pn(h),w=g?Pn(g):null;if(y==null)c.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${u} but no src/signals.ts to compare`});else if(w==null)c.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${u} && bun build.ts`});else if(w<y){let v=Math.round((y-w)/1000);c.push({name:"pantry dist freshness",status:"error",detail:`dist (${At(w,p)}) is OLDER than src/signals.ts (${At(y,p)}) by ${v}s \u2014 your edit isn't built`,fix:`cd ${u} && bun build.ts`})}else c.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${At(y,p)}, dist ${At(w,p)})`});let S=Te.join(s,"node_modules/@stacksjs/stx"),C=null;try{C=_e.lstatSync(S)}catch{C=null}if(!C)c.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(C.isSymbolicLink()){let v=null;try{v=_e.realpathSync(S)}catch{}let x=(()=>{try{return _e.realpathSync(u)}catch{return u}})();c.push(v===x?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${v||"(dangling)"}, not pantry`})}else c.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(c.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),t.generateRuntime)try{let g=t.generateRuntime().length;c.push(g>1000?{name:"signals runtime",status:"ok",detail:`generated ${g.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${g} chars \u2014 suspiciously short`})}catch(h){c.push({name:"signals runtime",status:"error",detail:`failed to generate: ${h.message}`})}return{checks:c,ok:!c.some((h)=>h.status==="error")}}function xr(t){let s={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},i=["stx runtime resolution:"];for(let p of t.checks)if(i.push(` ${s[p.status]} ${p.name}: ${p.detail}`),p.fix)i.push(` \u2192 ${p.fix}`);return i.push(""),i.push(t.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),i.join(`
1789
- `)}var ft={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},p=new Set,c=i.webComponents?.enabled?`./${Mt.relative(Mt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await Zn(i,p);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let u=new Set;if(i.cache&&i.cachePath){let x=await sn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await ne(()=>Bun.file(m).text(),"",(x)=>{throw new wn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new wn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=W.time("script-extraction",()=>{let x=h,T=Q(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",M=[];for(let R of k){let L=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=R.match(/<script\b([^>]*)>/i),G=B?B[1]:"";if(/\bserver\b/i.test(G))H=L;else M.push(R)}let I=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:I,allScripts:M}}),S={__filename:m,__dirname:Mt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await ne(()=>d(g,S,m),void 0,(x)=>{let T=new X(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(P.log(T,{filePath:m,scriptContent:g}),i.debug)throw T});let v=await W.timeAsync("directive-processing",async()=>await n(y,S,m,i,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-fe4mge8v.js"),T=x(w.join(`
1789
+ `)}var ft={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},p=new Set,c=i.webComponents?.enabled?`./${Mt.relative(Mt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await Zn(i,p);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let u=new Set;if(i.cache&&i.cachePath){let x=await sn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await ne(()=>Bun.file(m).text(),"",(x)=>{throw new wn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new wn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=W.time("script-extraction",()=>{let x=h,T=Q(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",M=[];for(let R of k){let L=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=R.match(/<script\b([^>]*)>/i),G=B?B[1]:"";if(/\bserver\b/i.test(G))H=L;else M.push(R)}let I=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:I,allScripts:M}}),S={__filename:m,__dirname:Mt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await ne(()=>d(g,S,m),void 0,(x)=>{let T=new X(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(P.log(T,{filePath:m,scriptContent:g}),i.debug)throw T});let v=await W.timeAsync("directive-processing",async()=>await n(y,S,m,i,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-qmew5tzd.js"),T=x(w.join(`
1790
1790
  `),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+T+`
1791
1791
  `+v.slice(k);else v+=`
1792
1792
  ${T}`}if(v=await K(v),u.forEach((x)=>p.add(x)),i.cache&&i.cachePath){if(await on(m,v,u,i),i.debug)console.log(`Cached template ${m} with ${u.size} dependencies`)}return{contents:v,loader:"html"}}catch(u){let h=u instanceof Error?u:new X(`Plugin processing failed: ${String(u)}`,m);if(P.log(h,{filePath:m,buildConfig:t.config}),Pt.logDetailedError(h,{filePath:m,plugin:"bun-plugin-stx"}),i.debug)console.error("stx Plugin Error:",h);let g=h,y=g.line||null,w=g.context||null;return{contents:i.debug||D()?`<!DOCTYPE html>
@@ -1849,7 +1849,7 @@ ${T}`}if(v=await K(v),u.forEach((x)=>p.add(x)),i.cache&&i.cachePath){if(await on
1849
1849
  <h1>Something went wrong</h1>
1850
1850
  <p>An internal error occurred. Please try again later.</p>
1851
1851
  </body>
1852
- </html>`,loader:"html"}}})}};async function _n(t,s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=Se.resolve(t);if(!Fe.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,s);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");Fe.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let L={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ye)=>({path:ye.path,external:!0}))}},B=await Bun.build({entrypoints:[u],outdir:h,plugins:[L,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let G=B.outputs.find(($e)=>$e.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(L){return console.error(`${e.red}Error building stx file:${e.reset}`,L),!1}};if(!await y())return!1;let S=Se.dirname(u);await Et(S);let C=i;try{if(C=await Ye(i),C!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let L=s.hmrPort||C+1;l=Ct({wsPort:L,verbose:!1}),m=l.start(L)}let v={},x=null,T;try{let{loadStxConfig:L}=await import("./chunk-rw8ybnjq.js"),B=await L();if(T=s.stxOptions?.serverApi??B.serverApi,B?.apiRouter)x=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){v=B.apiRoutes;let G=Object.keys(v).length;if(G>0)console.log(`${e.blue}Loaded ${e.bright}${G} API route${G>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:ee}=await import("./chunk-tgfpk4ng.js"),$e=B.broadcasting;await G($e);let ye=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ye}/ws${e.reset}`);let De=Se.join(process.cwd(),"channels.ts");if(Fe.existsSync(De))try{let ae=await ee(De);console.log(`${e.blue}Loaded ${e.bright}${ae} broadcast channel${ae!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ae){console.warn(`${e.yellow}Failed to load channels.ts: ${ae.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:H}=await import("./chunk-4kbzj481.js"),M=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let I=Fi({port:C,async fetch(L){return Dt(L,await(async()=>{let B=new URL(L.url);if([h,Se.dirname(u),Se.join(process.cwd(),"public")].some((ae)=>H(Se.join(ae,B.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let ae=await x.handleRequest(L);if(ae.status!==404)return ae}catch{}if(v[B.pathname])try{return await v[B.pathname](L)}catch(ae){return new Response(JSON.stringify({error:ae.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await M(L);if(G)return G;if(B.pathname==="/")return(async()=>{let U=await f(g||"");if(c)U=Xe(U,m);if(s.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 if(U.includes("<html"))U=U.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 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(s.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 if(U.includes("<html"))U=U.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 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}`;return U})().then((U)=>new Response(U,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let ee=Se.join(h,B.pathname);if(Fe.existsSync(ee)&&Fe.statSync(ee).isFile()){let ae=Bun.file(ee),U=Se.extname(ee).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}let $e=Se.dirname(u),ye=Se.join($e,B.pathname);if(Fe.existsSync(ye)&&Fe.statSync(ye).isFile()){let ae=Bun.file(ye),U=Se.extname(ye).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}let De=Se.join(process.cwd(),"public",B.pathname);if(Fe.existsSync(De)&&Fe.statSync(De).isFile()){let ae=Bun.file(De),U=Se.extname(De).toLowerCase(),j="application/octet-stream";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(L){return new Response(`<pre>${L}
1852
+ </html>`,loader:"html"}}})}};async function _n(t,s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=Se.resolve(t);if(!Fe.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,s);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");Fe.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let L={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ye)=>({path:ye.path,external:!0}))}},B=await Bun.build({entrypoints:[u],outdir:h,plugins:[L,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let G=B.outputs.find(($e)=>$e.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(L){return console.error(`${e.red}Error building stx file:${e.reset}`,L),!1}};if(!await y())return!1;let S=Se.dirname(u);await Et(S);let C=i;try{if(C=await Ye(i),C!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let L=s.hmrPort||C+1;l=Ct({wsPort:L,verbose:!1}),m=l.start(L)}let v={},x=null,T;try{let{loadStxConfig:L}=await import("./chunk-5c5aqc6z.js"),B=await L();if(T=s.stxOptions?.serverApi??B.serverApi,B?.apiRouter)x=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){v=B.apiRoutes;let G=Object.keys(v).length;if(G>0)console.log(`${e.blue}Loaded ${e.bright}${G} API route${G>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:ee}=await import("./chunk-tgfpk4ng.js"),$e=B.broadcasting;await G($e);let ye=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ye}/ws${e.reset}`);let De=Se.join(process.cwd(),"channels.ts");if(Fe.existsSync(De))try{let ae=await ee(De);console.log(`${e.blue}Loaded ${e.bright}${ae} broadcast channel${ae!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ae){console.warn(`${e.yellow}Failed to load channels.ts: ${ae.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:H}=await import("./chunk-w6mymv3q.js"),M=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let I=Fi({port:C,async fetch(L){return Dt(L,await(async()=>{let B=new URL(L.url);if([h,Se.dirname(u),Se.join(process.cwd(),"public")].some((ae)=>H(Se.join(ae,B.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let ae=await x.handleRequest(L);if(ae.status!==404)return ae}catch{}if(v[B.pathname])try{return await v[B.pathname](L)}catch(ae){return new Response(JSON.stringify({error:ae.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await M(L);if(G)return G;if(B.pathname==="/")return(async()=>{let U=await f(g||"");if(c)U=Xe(U,m);if(s.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 if(U.includes("<html"))U=U.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 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(s.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 if(U.includes("<html"))U=U.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 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}`;return U})().then((U)=>new Response(U,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let ee=Se.join(h,B.pathname);if(Fe.existsSync(ee)&&Fe.statSync(ee).isFile()){let ae=Bun.file(ee),U=Se.extname(ee).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}let $e=Se.dirname(u),ye=Se.join($e,B.pathname);if(Fe.existsSync(ye)&&Fe.statSync(ye).isFile()){let ae=Bun.file(ye),U=Se.extname(ye).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}let De=Se.join(process.cwd(),"public",B.pathname);if(Fe.existsSync(De)&&Fe.statSync(De).isFile()){let ae=Bun.file(De),U=Se.extname(De).toLowerCase(),j="application/octet-stream";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(L){return new Response(`<pre>${L}
1853
1853
  ${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1854
1854
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1855
1855
  ${e.bright}\u2192 ${e.cyan}http://localhost:${C}/${e.reset}`),console.log(`
@@ -2025,9 +2025,9 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
2025
2025
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
2026
2026
  ${e.bright}\u2192 ${e.cyan}http://localhost:${y}/${e.reset}`),console.log(`
2027
2027
  ${e.yellow}Routes:${e.reset}`);let S=new Set(u.map((v)=>v.routeTemplate)),C=Object.entries(m).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Ae.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:Ae.relative(process.cwd(),v.filePath),fileType:"stx"})}if(C.sort((v,x)=>v.route.localeCompare(x.route)),C.forEach((v,x)=>{let k=x===C.length-1?"\u2514\u2500 ":"\u251C\u2500 ",H=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${H}`)}),console.log(`
2028
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(w.url.toString(),()=>{if(p)Ze.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ze.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),we.clear(),te(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Wn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ni}=globalThis.Bun;import xe from"fs";import ie from"path";async function qn(t){try{return _t(await Bun.file(t).text())}catch{return}}function qt(t){let s=Bun.file(t),i=ie.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":p[i]||"application/octet-stream",...l}})}async function $n(t=".",s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=ie.resolve(t),{loadStxConfig:h}=await import("./chunk-rw8ybnjq.js"),g=await h(u),{createServerApi:y,isServerApiSource:w}=await import("./chunk-4kbzj481.js"),S=s.stxOptions?.serverApi??g.serverApi,C=await y(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=s.pagesDir||g.pagesDir||"pages",T=ie.join(v,x);if(!xe.existsSync(T)&&!g._layerPageDirs?.some((E)=>xe.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=N(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],M=[];for(let{dir:E,prefix:F}of H)if(xe.existsSync(E)){let z=N(ie.dirname(E),{pagesDir:ie.basename(E)});for(let V of z){let ve=F==="/"?V.pattern:`${F}${V.pattern==="/"?"":V.pattern}`;M.push({route:{...V,pattern:ve},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let I=new Map,R=null,L=null;if(s.stxOptions?.shell!==!1){if(L=await uo(u,s.stxOptions?.shell),L){if(R=await Tr(L,s.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,L)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}nt(),await st(u);let B=rt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let G={},ee=null;try{let{loadStxConfig:E}=await import("./chunk-rw8ybnjq.js"),F=await E(u);if(F?.apiRouter)ee=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){G=F.apiRoutes;let z=Object.keys(G).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:V}=await import("./chunk-tgfpk4ng.js"),ve=F.broadcasting;await z(ve);let We=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(xe.existsSync(Ge))try{let oe=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${oe} broadcast channel${oe!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(oe){console.warn(`${e.yellow}Failed to load channels.ts: ${oe.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let $e=a(u,"output");xe.mkdirSync($e,{recursive:!0});let ye=new Map,De=new Set,ae=async(E)=>{let F=fr(T,E);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:$e,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let V=z.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},U=new Map,j=async(E,F)=>{try{let{processDirectives:z,extractVariables:V,defaultConfig:ve,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-rw8ybnjq.js"),{checkCache:oe,cacheTemplate:Z,readFileCached:q,templateCache:J}=await import("./chunk-1hdezgrx.js"),ke=await We(u),Je=(pe)=>{if(!pe)return pe;if(ie.isAbsolute(pe))return pe;return ie.resolve(u,pe)},O={...ve,...ke,...s.stxOptions,autoShell:!0};if(s.debugDirectives)O.debug=!0;O.partialsDir=Je(O.partialsDir),O.componentsDir=Je(O.componentsDir),O.layoutsDir=Je(O.layoutsDir),O.storesDir=Je(O.storesDir||"stores"),O.cachePath=Je(O.cachePath)??a(u,"cache");let be=!F&&!s.profile,ue=O.cache!==!1;if(ue&&be){let pe=J.get(E.filePath);if(pe)try{if((await xe.promises.stat(E.filePath)).mtime.getTime()<=pe.mtime){let Be=!0;for(let Ee of pe.dependencies){if(!xe.existsSync(Ee)){Be=!1;break}if((await xe.promises.stat(Ee)).mtime.getTime()>pe.mtime){Be=!1;break}}if(Be){let Ee=pe.output;if(R)Ee=he(Ee,{preserveHead:!0});let gt=U.get(E.filePath);return{route:E,content:Ee,status:gt?.status??await qn(E.filePath),headers:gt?.headers}}}}catch{}let Ie=await oe(E.filePath,O);if(Ie){let je=Ie;if(R)je=he(je,{preserveHead:!0});let Be=U.get(E.filePath);return{route:E,content:je,status:Be?.status??await qn(E.filePath),headers:Be?.headers}}}let ge=ue?await q(E.filePath):await Bun.file(E.filePath).text(),Re=_t(ge),{classifyAllScripts:Y}=await import("./chunk-rw8ybnjq.js"),Le=Y(ge),Ve=Le.server.map((pe)=>pe.content),fe=ge;for(let pe of Le.server)fe=fe.replace(pe.fullTag,"");let me={__filename:E.filePath,__dirname:ie.dirname(E.filePath),__stx_options:O,params:F??{},__stx_runtime_head:{}};for(let pe of Ve)try{await V(pe,me,E.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ke=new Set,Me;if(s.profile){let pe=performance.now();Me=await z(fe,me,E.filePath,O,Ke);let Ie=performance.now()-pe,je=ie.relative(u,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else Me=await z(fe,me,E.filePath,O,Ke);if(!R)Me=await Ge(Me,{router:O.router});{let{interpolateScriptExpressions:pe}=await import("./chunk-fe4mge8v.js");Me=Me.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,Be)=>{if(!/function\s+__stx_setup_/.test(Be))return Ie;return`<script${je}>${pe(Be,me)}</script>`})}if(R)Me=he(Me,{preserveHead:!0});if(ue&&be)await Z(E.filePath,Me,Ke,O);let{extractStreamBoundaries:Kn}=await import("./chunk-5dps9j52.js"),lt=Kn(me),mt=me.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let pe=me.streamBoundaries||{},Ie={...O,autoShell:!1},je=Object.keys(mt).map((Ee)=>({id:Ee,render:async()=>{let gt=typeof pe[Ee]==="function"?await pe[Ee]():void 0;return z(mt[Ee],{...me,$boundary:gt},E.filePath,Ie,new Set)}})),Be=new Set(je.map((Ee)=>Ee.id));lt=[...(lt||[]).filter((Ee)=>!Be.has(Ee.id)),...je]}if(lt&&lt.length>0)De.add(E.pattern);else lt=void 0;let Kt=He(me),Xt=Ue(me);if(be)U.set(E.filePath,{status:Kt,headers:Xt});return{route:E,content:Me,status:Kt??Re,headers:Xt,boundaries:lt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Ne=8,qe=async()=>{ye.clear(),I.clear();for(let E=0;E<k.length;E+=Ne){let F=k.slice(E,E+Ne),z=await Promise.all(F.map((V)=>j(V)));for(let V of z)if(V)ye.set(V.route.pattern,V)}for(let E=0;E<M.length;E+=Ne){let F=M.slice(E,E+Ne),z=await Promise.all(F.map(({route:V})=>j(V)));for(let V of z)if(V)I.set(V.route.pattern,V)}return ye.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Et(u);let et=i;try{if(et=await Ye(i),et!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${et} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let E=s.hmrPort||et+1;l=Ct({wsPort:E,verbose:!1}),m=l.start(E)}let Lt=(E,F)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(E.includes("</head>"))return E.replace("</head>",`${V}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+E};console.log(`${e.blue}Starting server...${e.reset}`);let It=Ni({port:et,async fetch(E){let F=new URL(E.url),z=g?.publicDir||"public",V=ie.join(u,z,F.pathname),ve=ie.join(u,F.pathname),We=ie.join($e,F.pathname);if([V,ve,We].some((O)=>w(O,u,S)))return new Response("Not Found",{status:404});let[Ge,oe,Z]=await Promise.all([xe.promises.stat(V).catch(()=>null),xe.promises.stat(ve).catch(()=>null),xe.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(oe?.isFile()&&!w(ve,u,S))return qt(ve);if(Z?.isFile()&&!w(We,u,S))return qt(We);if(F.pathname.startsWith("/_stx/component/")){let O=decodeURIComponent(F.pathname.slice(16));if(O)try{let be=`<${O} />`,ue={...buildConfig,autoShell:!1},ge=await processDirectives(be,{},ie.join(u,"components",`${O}.stx`),ue,new Set);return new Response(ge,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:O}=await import("./chunk-zfypzka2.js"),be=await O(E,{publicDir:ie.join(u,z),cacheDir:a(u,"cache","img")});if(be)return be}if(ee)try{let O=await ee.handleRequest(E);if(O.status!==404)return O}catch{}if(G[F.pathname])try{return await G[F.pathname](E)}catch(O){return new Response(JSON.stringify({error:O.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await C(E);if(q)return q;let J=kn(F.pathname,k);if(J){let O=ye.get(J.route.pattern),be=De.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let ue=await j(J.route,J.params);if(ue)O=ue}if(O){let ue=O.status??200,ge=O.headers??{},Re=(J.route.filePath?ze(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Re.validate){if(!await Re.validate({params:J.params})){let Ve=await ae(404);if(Ve){let fe=Ve;if(fe=await f(fe,u),c)fe=Xe(fe,m);return new Response(fe,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Re.middleware){let Le=ot(F.pathname,J.params,Re,F.search),Ve=it(Le,null,E,{isServer:!0}),fe=await at(Re.middleware,Ve);if(fe.redirect){let me=fe.redirect.path,Ke=fe.redirect.options.redirectCode||302,Me=new Headers(fe.responseHeaders);return Me.set("Location",me),new Response(null,{status:Ke,headers:Me})}if(fe.abort){let{statusCode:me,message:Ke}=fe.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${me}</title></head><body><h1>Error ${me}</h1><p>${Ke}</p></body></html>`,{status:me,headers:{"Content-Type":"text/html"}})}if(Object.keys(fe.state).length>0){let me=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(fe.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;O.content=O.content.replace("</head>",`${me}</head>`)}}let Y=O.content;if(R&&po(E)){let Le=Ce(Y),Ve=le(Y),fe=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),me=fe?lo(fe[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=se(Y,Ke),new Response(Y,{status:ue,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...me&&{"X-STX-Title":encodeURIComponent(me)},[hi]:xs(),..._(),"Cache-Control":Pe}})}if(R)Y=In(R,Y);if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);if(Y=await f(Y,u),c)Y=Xe(Y,m);if(s.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(s.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(O.boundaries&&O.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-5dps9j52.js");return Ve(Le(Y,O.boundaries,{timeoutMs:30000}),{status:ue,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:ue,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ge}})}}if(M.length>0){let O=M.map((ue)=>ue.route),be=kn(F.pathname,O);if(be){let ue=I.get(be.route.pattern);if(ue){let ge=ue.content;if(R)ge=In(R,ge);if(Object.keys(be.params).length>0)ge=Lt(ge,be.params);if(ge=await f(ge,u),c)ge=Xe(ge,m);return new Response(ge,{status:ue.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ue}of H)if(ue!=="/"&&F.pathname.startsWith(ue)){let ge=I.get(ue)||I.get(ue+"/");if(ge){let Re=ge.content;if(R)Re=In(R,Re);if(Re=await f(Re,u),c)Re=Xe(Re,m);return new Response(Re,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(tt(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=ye.get("/");if(ke){let O=ke.content;if(O=await f(O,u),c)O=Xe(O,m);if(s.native)if(O.includes("<head>"))O=O.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 O="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+O;return new Response(O,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await ae(404);if(Je){let O=Je;if(O=await f(O,u),c)O=Xe(O,m);return new Response(O,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let F=await ae(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
2028
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(w.url.toString(),()=>{if(p)Ze.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ze.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),we.clear(),te(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Wn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ni}=globalThis.Bun;import xe from"fs";import ie from"path";async function qn(t){try{return _t(await Bun.file(t).text())}catch{return}}function qt(t){let s=Bun.file(t),i=ie.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":p[i]||"application/octet-stream",...l}})}async function $n(t=".",s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=ie.resolve(t),{loadStxConfig:h}=await import("./chunk-5c5aqc6z.js"),g=await h(u),{createServerApi:y,isServerApiSource:w}=await import("./chunk-w6mymv3q.js"),S=s.stxOptions?.serverApi??g.serverApi,C=await y(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=s.pagesDir||g.pagesDir||"pages",T=ie.join(v,x);if(!xe.existsSync(T)&&!g._layerPageDirs?.some((E)=>xe.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=N(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],M=[];for(let{dir:E,prefix:F}of H)if(xe.existsSync(E)){let z=N(ie.dirname(E),{pagesDir:ie.basename(E)});for(let V of z){let ve=F==="/"?V.pattern:`${F}${V.pattern==="/"?"":V.pattern}`;M.push({route:{...V,pattern:ve},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let I=new Map,R=null,L=null;if(s.stxOptions?.shell!==!1){if(L=await uo(u,s.stxOptions?.shell),L){if(R=await Tr(L,s.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,L)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}nt(),await st(u);let B=rt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let G={},ee=null;try{let{loadStxConfig:E}=await import("./chunk-5c5aqc6z.js"),F=await E(u);if(F?.apiRouter)ee=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){G=F.apiRoutes;let z=Object.keys(G).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:V}=await import("./chunk-tgfpk4ng.js"),ve=F.broadcasting;await z(ve);let We=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(xe.existsSync(Ge))try{let oe=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${oe} broadcast channel${oe!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(oe){console.warn(`${e.yellow}Failed to load channels.ts: ${oe.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let $e=a(u,"output");xe.mkdirSync($e,{recursive:!0});let ye=new Map,De=new Set,ae=async(E)=>{let F=fr(T,E);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:$e,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let V=z.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},U=new Map,j=async(E,F)=>{try{let{processDirectives:z,extractVariables:V,defaultConfig:ve,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-5c5aqc6z.js"),{checkCache:oe,cacheTemplate:Z,readFileCached:q,templateCache:J}=await import("./chunk-qvjyyns1.js"),ke=await We(u),Je=(pe)=>{if(!pe)return pe;if(ie.isAbsolute(pe))return pe;return ie.resolve(u,pe)},O={...ve,...ke,...s.stxOptions,autoShell:!0};if(s.debugDirectives)O.debug=!0;O.partialsDir=Je(O.partialsDir),O.componentsDir=Je(O.componentsDir),O.layoutsDir=Je(O.layoutsDir),O.storesDir=Je(O.storesDir||"stores"),O.cachePath=Je(O.cachePath)??a(u,"cache");let be=!F&&!s.profile,ue=O.cache!==!1;if(ue&&be){let pe=J.get(E.filePath);if(pe)try{if((await xe.promises.stat(E.filePath)).mtime.getTime()<=pe.mtime){let Be=!0;for(let Ee of pe.dependencies){if(!xe.existsSync(Ee)){Be=!1;break}if((await xe.promises.stat(Ee)).mtime.getTime()>pe.mtime){Be=!1;break}}if(Be){let Ee=pe.output;if(R)Ee=he(Ee,{preserveHead:!0});let gt=U.get(E.filePath);return{route:E,content:Ee,status:gt?.status??await qn(E.filePath),headers:gt?.headers}}}}catch{}let Ie=await oe(E.filePath,O);if(Ie){let je=Ie;if(R)je=he(je,{preserveHead:!0});let Be=U.get(E.filePath);return{route:E,content:je,status:Be?.status??await qn(E.filePath),headers:Be?.headers}}}let ge=ue?await q(E.filePath):await Bun.file(E.filePath).text(),Re=_t(ge),{classifyAllScripts:Y}=await import("./chunk-5c5aqc6z.js"),Le=Y(ge),Ve=Le.server.map((pe)=>pe.content),fe=ge;for(let pe of Le.server)fe=fe.replace(pe.fullTag,"");let me={__filename:E.filePath,__dirname:ie.dirname(E.filePath),__stx_options:O,params:F??{},__stx_runtime_head:{}};for(let pe of Ve)try{await V(pe,me,E.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ke=new Set,Me;if(s.profile){let pe=performance.now();Me=await z(fe,me,E.filePath,O,Ke);let Ie=performance.now()-pe,je=ie.relative(u,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else Me=await z(fe,me,E.filePath,O,Ke);if(!R)Me=await Ge(Me,{router:O.router});{let{interpolateScriptExpressions:pe}=await import("./chunk-qmew5tzd.js");Me=Me.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,Be)=>{if(!/function\s+__stx_setup_/.test(Be))return Ie;return`<script${je}>${pe(Be,me)}</script>`})}if(R)Me=he(Me,{preserveHead:!0});if(ue&&be)await Z(E.filePath,Me,Ke,O);let{extractStreamBoundaries:Kn}=await import("./chunk-20xnk6jm.js"),lt=Kn(me),mt=me.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let pe=me.streamBoundaries||{},Ie={...O,autoShell:!1},je=Object.keys(mt).map((Ee)=>({id:Ee,render:async()=>{let gt=typeof pe[Ee]==="function"?await pe[Ee]():void 0;return z(mt[Ee],{...me,$boundary:gt},E.filePath,Ie,new Set)}})),Be=new Set(je.map((Ee)=>Ee.id));lt=[...(lt||[]).filter((Ee)=>!Be.has(Ee.id)),...je]}if(lt&&lt.length>0)De.add(E.pattern);else lt=void 0;let Kt=He(me),Xt=Ue(me);if(be)U.set(E.filePath,{status:Kt,headers:Xt});return{route:E,content:Me,status:Kt??Re,headers:Xt,boundaries:lt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Ne=8,qe=async()=>{ye.clear(),I.clear();for(let E=0;E<k.length;E+=Ne){let F=k.slice(E,E+Ne),z=await Promise.all(F.map((V)=>j(V)));for(let V of z)if(V)ye.set(V.route.pattern,V)}for(let E=0;E<M.length;E+=Ne){let F=M.slice(E,E+Ne),z=await Promise.all(F.map(({route:V})=>j(V)));for(let V of z)if(V)I.set(V.route.pattern,V)}return ye.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Et(u);let et=i;try{if(et=await Ye(i),et!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${et} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let E=s.hmrPort||et+1;l=Ct({wsPort:E,verbose:!1}),m=l.start(E)}let Lt=(E,F)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(E.includes("</head>"))return E.replace("</head>",`${V}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+E};console.log(`${e.blue}Starting server...${e.reset}`);let It=Ni({port:et,async fetch(E){let F=new URL(E.url),z=g?.publicDir||"public",V=ie.join(u,z,F.pathname),ve=ie.join(u,F.pathname),We=ie.join($e,F.pathname);if([V,ve,We].some((O)=>w(O,u,S)))return new Response("Not Found",{status:404});let[Ge,oe,Z]=await Promise.all([xe.promises.stat(V).catch(()=>null),xe.promises.stat(ve).catch(()=>null),xe.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(oe?.isFile()&&!w(ve,u,S))return qt(ve);if(Z?.isFile()&&!w(We,u,S))return qt(We);if(F.pathname.startsWith("/_stx/component/")){let O=decodeURIComponent(F.pathname.slice(16));if(O)try{let be=`<${O} />`,ue={...buildConfig,autoShell:!1},ge=await processDirectives(be,{},ie.join(u,"components",`${O}.stx`),ue,new Set);return new Response(ge,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:O}=await import("./chunk-zfypzka2.js"),be=await O(E,{publicDir:ie.join(u,z),cacheDir:a(u,"cache","img")});if(be)return be}if(ee)try{let O=await ee.handleRequest(E);if(O.status!==404)return O}catch{}if(G[F.pathname])try{return await G[F.pathname](E)}catch(O){return new Response(JSON.stringify({error:O.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await C(E);if(q)return q;let J=kn(F.pathname,k);if(J){let O=ye.get(J.route.pattern),be=De.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let ue=await j(J.route,J.params);if(ue)O=ue}if(O){let ue=O.status??200,ge=O.headers??{},Re=(J.route.filePath?ze(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Re.validate){if(!await Re.validate({params:J.params})){let Ve=await ae(404);if(Ve){let fe=Ve;if(fe=await f(fe,u),c)fe=Xe(fe,m);return new Response(fe,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Re.middleware){let Le=ot(F.pathname,J.params,Re,F.search),Ve=it(Le,null,E,{isServer:!0}),fe=await at(Re.middleware,Ve);if(fe.redirect){let me=fe.redirect.path,Ke=fe.redirect.options.redirectCode||302,Me=new Headers(fe.responseHeaders);return Me.set("Location",me),new Response(null,{status:Ke,headers:Me})}if(fe.abort){let{statusCode:me,message:Ke}=fe.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${me}</title></head><body><h1>Error ${me}</h1><p>${Ke}</p></body></html>`,{status:me,headers:{"Content-Type":"text/html"}})}if(Object.keys(fe.state).length>0){let me=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(fe.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;O.content=O.content.replace("</head>",`${me}</head>`)}}let Y=O.content;if(R&&po(E)){let Le=Ce(Y),Ve=le(Y),fe=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),me=fe?lo(fe[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=se(Y,Ke),new Response(Y,{status:ue,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...me&&{"X-STX-Title":encodeURIComponent(me)},[hi]:xs(),..._(),"Cache-Control":Pe}})}if(R)Y=In(R,Y);if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);if(Y=await f(Y,u),c)Y=Xe(Y,m);if(s.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(s.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(O.boundaries&&O.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-20xnk6jm.js");return Ve(Le(Y,O.boundaries,{timeoutMs:30000}),{status:ue,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:ue,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ge}})}}if(M.length>0){let O=M.map((ue)=>ue.route),be=kn(F.pathname,O);if(be){let ue=I.get(be.route.pattern);if(ue){let ge=ue.content;if(R)ge=In(R,ge);if(Object.keys(be.params).length>0)ge=Lt(ge,be.params);if(ge=await f(ge,u),c)ge=Xe(ge,m);return new Response(ge,{status:ue.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ue}of H)if(ue!=="/"&&F.pathname.startsWith(ue)){let ge=I.get(ue)||I.get(ue+"/");if(ge){let Re=ge.content;if(R)Re=In(R,Re);if(Re=await f(Re,u),c)Re=Xe(Re,m);return new Response(Re,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(tt(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=ye.get("/");if(ke){let O=ke.content;if(O=await f(O,u),c)O=Xe(O,m);if(s.native)if(O.includes("<head>"))O=O.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 O="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+O;return new Response(O,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await ae(404);if(Je){let O=Je;if(O=await f(O,u),c)O=Xe(O,m);return new Response(O,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let F=await ae(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
2029
2029
  ${E.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
2030
2030
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
2031
2031
  ${e.bright}\u2192 ${e.cyan}http://localhost:${et}/${e.reset}`),c)console.log(`${e.dim} HMR: ws://localhost:${m}${e.reset}`);console.log(`
2032
2032
  ${e.yellow}Routes:${e.reset}`);let jt=[...gr(k,u)];for(let{route:E}of M)jt.push(`${E.pattern}`);if(jt.forEach((E,F)=>{let V=F===jt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${V}${e.reset}${E}`)}),console.log(`
2033
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(It.url.toString(),()=>{if(l)ht();It.stop()}),s.native){let E,F=ie.join(T,"index.stx");if(xe.existsSync(F)){let V=await Bun.file(F).text();E=St(V)}let z=g?.app?.window??{};await dt(et,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(oe)=>oe.startsWith("public/")||oe.startsWith("public\\"),F=(oe)=>{let Z=oe.toLowerCase();return Z.endsWith(".stx")||Z.endsWith(".html")||Z.endsWith(".md")},z=new Map,V=()=>{let oe=new Set([u,...g._layerGraph?.layers.map((Z)=>Z.root)??[],...g._layerGraph?.configDependencies.map((Z)=>ie.dirname(Z))??[]].filter((Z)=>xe.existsSync(Z)).map((Z)=>xe.realpathSync(Z)));for(let Z of g._layerGraph?.layers??[])for(let q of Object.values(Z.resources)){if(!xe.existsSync(q))continue;let J=xe.realpathSync(q);if(![...oe].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))oe.add(J)}for(let[Z,q]of z)if(!oe.has(Z))q.close(),z.delete(Z);for(let Z of oe)if(!z.has(Z)&&xe.existsSync(Z))z.set(Z,xe.watch(Z,{recursive:!0},(q,J)=>{We(Z,q,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},ve=Promise.resolve(),We=(oe,Z,q)=>(ve=ve.catch(()=>{}).then(()=>Ge(oe,Z,q)),ve),Ge=async(oe,Z,q)=>{if(!q||$t(q))return;if(Tt(q)){if(g._layerGraph){let J=await h(u);Object.assign(g,J),k.splice(0,k.length,...N(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[T,...J._layerPageDirs.slice(1)]:void 0})),V()}if(E(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(F(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),we.clear(),te();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-1hdezgrx.js");J(ie.resolve(oe,q)),ke.delete(ie.resolve(oe,q))}catch{}if(L&&q){if(ie.resolve(oe,q)===L||ie.basename(L)===q){let ke=await Tr(L,s.stxOptions||{});if(ke)R=ke}}if(await qe(),await an(u),c&&l)l.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),we.clear(),te();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-1hdezgrx.js");J(ie.resolve(oe,q)),ke.delete(ie.resolve(oe,q))}catch{}if(await qe(),c&&l)l.reload(q)}}else if(kt(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),c&&l)l.updateCss(q)}};V(),process.on("SIGINT",()=>{for(let oe of z.values())oe.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{Xs,Js,Ys,Zs,wr,Qs,eo,to,Xi,Ji,vr,xr,_n,Tn,$n};
2033
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(It.url.toString(),()=>{if(l)ht();It.stop()}),s.native){let E,F=ie.join(T,"index.stx");if(xe.existsSync(F)){let V=await Bun.file(F).text();E=St(V)}let z=g?.app?.window??{};await dt(et,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(oe)=>oe.startsWith("public/")||oe.startsWith("public\\"),F=(oe)=>{let Z=oe.toLowerCase();return Z.endsWith(".stx")||Z.endsWith(".html")||Z.endsWith(".md")},z=new Map,V=()=>{let oe=new Set([u,...g._layerGraph?.layers.map((Z)=>Z.root)??[],...g._layerGraph?.configDependencies.map((Z)=>ie.dirname(Z))??[]].filter((Z)=>xe.existsSync(Z)).map((Z)=>xe.realpathSync(Z)));for(let Z of g._layerGraph?.layers??[])for(let q of Object.values(Z.resources)){if(!xe.existsSync(q))continue;let J=xe.realpathSync(q);if(![...oe].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))oe.add(J)}for(let[Z,q]of z)if(!oe.has(Z))q.close(),z.delete(Z);for(let Z of oe)if(!z.has(Z)&&xe.existsSync(Z))z.set(Z,xe.watch(Z,{recursive:!0},(q,J)=>{We(Z,q,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},ve=Promise.resolve(),We=(oe,Z,q)=>(ve=ve.catch(()=>{}).then(()=>Ge(oe,Z,q)),ve),Ge=async(oe,Z,q)=>{if(!q||$t(q))return;if(Tt(q)){if(g._layerGraph){let J=await h(u);Object.assign(g,J),k.splice(0,k.length,...N(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[T,...J._layerPageDirs.slice(1)]:void 0})),V()}if(E(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(F(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),we.clear(),te();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-qvjyyns1.js");J(ie.resolve(oe,q)),ke.delete(ie.resolve(oe,q))}catch{}if(L&&q){if(ie.resolve(oe,q)===L||ie.basename(L)===q){let ke=await Tr(L,s.stxOptions||{});if(ke)R=ke}}if(await qe(),await an(u),c&&l)l.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),we.clear(),te();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-qvjyyns1.js");J(ie.resolve(oe,q)),ke.delete(ie.resolve(oe,q))}catch{}if(await qe(),c&&l)l.reload(q)}}else if(kt(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),c&&l)l.updateCss(q)}};V(),process.on("SIGINT",()=>{for(let oe of z.values())oe.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{Xs,Js,Ys,Zs,wr,Qs,eo,to,Xi,Ji,vr,xr,_n,Tn,$n};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-r4199q6x.js";import"./chunk-6v1gwdbv.js";import{m,h,w,L}from"./chunk-w8h7nb1d.js";import"./chunk-a5kaw8sc.js";import"./chunk-ec8k75ep.js";import"./chunk-kvmg6r89.js";import"./chunk-j2erwdgt.js";import"./chunk-jmvp99ay.js";import"./chunk-dyreg5df.js";import"./chunk-e124cgb6.js";import"./chunk-r18sh8h9.js";import"./chunk-1xgs9gd5.js";import"./chunk-1b50m7e7.js";import f from"path";var S=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],_=new Set(S);var l=new Map,x=m(64),y=new Set,O=0,R=new Set(S);function W(){l.clear(),x.clear()}function P(o){let n=new Map;for(let r of o){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function I(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function M(o){if(!o)return[];let n=h(o,O),r=x.get(n);if(r)return r.slice();let a=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of R){if(y.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),x.set(n,t),t.slice()}async function A(o,n){let r=M(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=L({loader:"ts",target:"browser",define:w()}),C=new Set(r),d=[],g=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=P(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let b=[];try{b=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!b.some((c)=>C.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),d.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
2
+ import"./chunk-r4199q6x.js";import"./chunk-6v1gwdbv.js";import{m,h,w,L}from"./chunk-4wwpxt4z.js";import"./chunk-a5kaw8sc.js";import"./chunk-ec8k75ep.js";import"./chunk-kvmg6r89.js";import"./chunk-j2erwdgt.js";import"./chunk-jmvp99ay.js";import"./chunk-dyreg5df.js";import"./chunk-e124cgb6.js";import"./chunk-bngcrt1x.js";import"./chunk-1xgs9gd5.js";import"./chunk-1b50m7e7.js";import f from"path";var S=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],_=new Set(S);var l=new Map,x=m(64),y=new Set,O=0,R=new Set(S);function W(){l.clear(),x.clear()}function P(o){let n=new Map;for(let r of o){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function I(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function M(o){if(!o)return[];let n=h(o,O),r=x.get(n);if(r)return r.slice();let a=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of R){if(y.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),x.set(n,t),t.slice()}async function A(o,n){let r=M(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=L({loader:"ts",target:"browser",define:w()}),C=new Set(r),d=[],g=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=P(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let b=[];try{b=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!b.some((c)=>C.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),d.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
3
3
  ${u.transformSync(e).trim()}`);for(let c of b)g.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let v=r.filter((s)=>!g.has(s)&&!I(o,s));if(v.length>0)console.warn(`[stx] could not bundle ${v.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(d.length===0)return l.set(t,""),null;let E=[...g].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
4
4
  `),k=`<script data-stx-scoped data-stx-run="always" data-stx-framework-composables>
5
5
  ;(function(){
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{G,n}from"./chunk-w8h7nb1d.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let r=u[t[0]];console.log(`
2
+ import{G,n}from"./chunk-4wwpxt4z.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let r=u[t[0]];console.log(`
3
3
  ${e.bold}${t[0]}${e.reset} - ${r.description}`),console.log(` Usage: ${e.cyan}${r.usage}${e.reset}
4
4
  `)}else{console.log(`
5
5
  ${e.bold}Available Commands:${e.reset}
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{M,le}from"./chunk-w8h7nb1d.js";import{ue,C,Je}from"./chunk-e124cgb6.js";import{tt,J,Ce}from"./chunk-kvmg6r89.js";import{Pe,re,_,se,mo,$r,ho,Nt}from"./chunk-crpbzgjm.js";import{Jr}from"./chunk-zd85q44h.js";import{Lt}from"./chunk-n1cqg89v.js";import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),ne=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ae=1024;function ie(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return ne.some((o)=>e.startsWith(o))}function ce(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function pe(t){if(!t)return null;let e=ce(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function me(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=Y)break;H.delete(o),U-=r.length}}async function Dt(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ie(e.headers.get("content-type")))return e;let r=pe(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(a.length<(o.threshold??ae))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),me(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}import K from"fs";import P from"path";var{serve:fe}=globalThis.Bun;class G{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",_(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${re(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):a()}}var de={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function sl(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=mo(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Lt(r.routeRules),f=new G,h=Jr(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Je(i.html,m);b.set(n.pattern,i),v.set(n.pattern,Ce(i.html)),E.set(n.pattern,le(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Je(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=J(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=fe({port:o,async fetch(n){return Dt(n,await ue(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=de[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=re(n),w=null,q={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,L)=>{q[R]=c[L+1]});break}}if(!w){let p=tt(i)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=a(i),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Pe}}})}}let d=$r(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await Nt(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return ho(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-5dps9j52.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=Ce(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",le(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?se(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=Ce(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",le(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(se(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
2
+ import{M,le}from"./chunk-4wwpxt4z.js";import{ue,C,Je}from"./chunk-e124cgb6.js";import{tt,J,Ce}from"./chunk-kvmg6r89.js";import{Pe,re,_,se,mo,$r,ho,Nt}from"./chunk-zpyzpp5h.js";import{Jr}from"./chunk-fq58g560.js";import{Lt}from"./chunk-n1cqg89v.js";import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),ne=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ae=1024;function ie(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return ne.some((o)=>e.startsWith(o))}function ce(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function pe(t){if(!t)return null;let e=ce(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function me(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=Y)break;H.delete(o),U-=r.length}}async function Dt(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ie(e.headers.get("content-type")))return e;let r=pe(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(a.length<(o.threshold??ae))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),me(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}import K from"fs";import P from"path";var{serve:fe}=globalThis.Bun;class G{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",_(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${re(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):a()}}var de={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function sl(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=mo(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Lt(r.routeRules),f=new G,h=Jr(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Je(i.html,m);b.set(n.pattern,i),v.set(n.pattern,Ce(i.html)),E.set(n.pattern,le(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Je(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=J(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=fe({port:o,async fetch(n){return Dt(n,await ue(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=de[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=re(n),w=null,q={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,L)=>{q[R]=c[L+1]});break}}if(!w){let p=tt(i)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=a(i),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Pe}}})}}let d=$r(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await Nt(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return ho(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-20xnk6jm.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=Ce(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",le(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?se(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=Ce(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",le(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(se(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
3
3
  export{Dt,sl};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{y}from"./chunk-r4199q6x.js";import{I,It}from"./chunk-6v1gwdbv.js";import{Wo,m,h,w,We,L,o}from"./chunk-w8h7nb1d.js";import{ae,wt,vt}from"./chunk-dwjxc9xq.js";import{Oe,Kt,gt,H}from"./chunk-mjdyyekx.js";import S from"path";var C=new Map,D=new Map,k=m(64),A=new Map,X=["composables","functions"];function U(t){let n=S.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function Z(t){if(t)return S.resolve(t);let n=`<default>:${process.cwd()}`,a=A.get(n);if(a!==void 0)return a;let e=await q();if(e!==null)A.set(n,e);return e}async function q(){let t=await o(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return S.resolve(n,a);for(let e of X){let s=S.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!U(c))return s}catch{}}return null}async function z(t){let n=Array.isArray(t)?t:t?[S.resolve(t)]:(await o())._layerComposableDirs??[await Z()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=S.relative(e,d);if(!U(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function Fr(t){let{files:n}=await z(t),a=L({loader:"ts",target:"browser",define:w()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((p)=>p!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function Q(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function G(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):Q(t,s))e.add(s);return e}var T=m(64);function V(t,n){let a=h(t,n.size),e=T.get(a);if(e)return e;let s;try{s=Wo(t,n)}catch{s=G(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let p of c[1].split(",")){let g=p.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(g&&n.has(g))s.add(g)}return T.set(a,s),s}function Y(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of G(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of V(u,d))l.push(e.get(f));return l},p=new Set,g=a.flatMap((u,l)=>l===0?s(u):c(u));while(g.length>0){let u=[];for(let l of g){if(p.has(l))continue;p.add(l);for(let f of c(n.get(l)??""))if(!p.has(f))u.push(f)}g=u}return p}async function Fl(t,n,a){let{key:e,files:s}=await z(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((r)=>ae(r))])],c=Oe(d());if(s.length===0)return H(C,e,c,""),null;s.sort();let p=L({loader:"ts",target:"browser",define:w()}),g=gt(D,e,c);if(!g){let r=new Map,i=[];for(let _ of s)try{let x=await Bun.file(_).text();r.set(_,x);let b=p.scan(x).exports.filter((W)=>W!=="default");if(b.length>0)i.push({file:_,names:b})}catch{r.set(_,"")}g=H(D,e,c,{codeByFile:r,modules:i})}let{codeByFile:u,modules:l}=g,f;if(n===void 0)f=new Set(s);else{let r=a?[n,...a]:[n],i=h(r.join("\x00"),e,r.length,c),_=k.get(i);if(f=_??Y(l,u,r),!_)k.set(i,f)}if(f.size===0)return null;let E=s.filter((r)=>f.has(r)),B=`${e}\x00${E.join("\x00")}`,F=gt(C,B,c);if(F!==void 0)return F||null;let M=[],v=new Set,R=new Set;for(let r of E)try{let i=u.get(r)??await Bun.file(r).text(),_=S.basename(r,".ts");for(let b of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(b[1])R.add(b[1]);let x=[];try{for(let b of p.scan(i).exports)if(b!=="default")v.add(b),x.push(b)}catch{}if(i=I(i),wt(i))i=await vt(i,r,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:x}),i=We(i);i=It(i),i=i.replace(/^export\s+(default\s+)?/gm,""),i=p.transformSync(i),M.push(`// Composable: ${_}
2
+ import{y}from"./chunk-r4199q6x.js";import{I,It}from"./chunk-6v1gwdbv.js";import{Wo,m,h,w,We,L,o}from"./chunk-4wwpxt4z.js";import{ae,wt,vt}from"./chunk-ssb2pdn0.js";import{Oe,Kt,gt,H}from"./chunk-mjdyyekx.js";import S from"path";var C=new Map,D=new Map,k=m(64),A=new Map,X=["composables","functions"];function U(t){let n=S.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function Z(t){if(t)return S.resolve(t);let n=`<default>:${process.cwd()}`,a=A.get(n);if(a!==void 0)return a;let e=await q();if(e!==null)A.set(n,e);return e}async function q(){let t=await o(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return S.resolve(n,a);for(let e of X){let s=S.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!U(c))return s}catch{}}return null}async function z(t){let n=Array.isArray(t)?t:t?[S.resolve(t)]:(await o())._layerComposableDirs??[await Z()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=S.relative(e,d);if(!U(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function Fr(t){let{files:n}=await z(t),a=L({loader:"ts",target:"browser",define:w()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((p)=>p!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function Q(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function G(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):Q(t,s))e.add(s);return e}var T=m(64);function V(t,n){let a=h(t,n.size),e=T.get(a);if(e)return e;let s;try{s=Wo(t,n)}catch{s=G(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let p of c[1].split(",")){let g=p.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(g&&n.has(g))s.add(g)}return T.set(a,s),s}function Y(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of G(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of V(u,d))l.push(e.get(f));return l},p=new Set,g=a.flatMap((u,l)=>l===0?s(u):c(u));while(g.length>0){let u=[];for(let l of g){if(p.has(l))continue;p.add(l);for(let f of c(n.get(l)??""))if(!p.has(f))u.push(f)}g=u}return p}async function Fl(t,n,a){let{key:e,files:s}=await z(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((r)=>ae(r))])],c=Oe(d());if(s.length===0)return H(C,e,c,""),null;s.sort();let p=L({loader:"ts",target:"browser",define:w()}),g=gt(D,e,c);if(!g){let r=new Map,i=[];for(let _ of s)try{let x=await Bun.file(_).text();r.set(_,x);let b=p.scan(x).exports.filter((W)=>W!=="default");if(b.length>0)i.push({file:_,names:b})}catch{r.set(_,"")}g=H(D,e,c,{codeByFile:r,modules:i})}let{codeByFile:u,modules:l}=g,f;if(n===void 0)f=new Set(s);else{let r=a?[n,...a]:[n],i=h(r.join("\x00"),e,r.length,c),_=k.get(i);if(f=_??Y(l,u,r),!_)k.set(i,f)}if(f.size===0)return null;let E=s.filter((r)=>f.has(r)),B=`${e}\x00${E.join("\x00")}`,F=gt(C,B,c);if(F!==void 0)return F||null;let M=[],v=new Set,R=new Set;for(let r of E)try{let i=u.get(r)??await Bun.file(r).text(),_=S.basename(r,".ts");for(let b of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(b[1])R.add(b[1]);let x=[];try{for(let b of p.scan(i).exports)if(b!=="default")v.add(b),x.push(b)}catch{}if(i=I(i),wt(i))i=await vt(i,r,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:x}),i=We(i);i=It(i),i=i.replace(/^export\s+(default\s+)?/gm,""),i=p.transformSync(i),M.push(`// Composable: ${_}
3
3
  ${i.trim()}`)}catch(i){console.warn(`[stx] Failed to load composable ${r}:`,i)}if(M.length===0||v.size===0)return H(C,B,c,""),null;let J=[...v].map((r)=>` try { if (!(${JSON.stringify(r)} in __c)) __c[${JSON.stringify(r)}] = ${r}; } catch (e) {}`).join(`
4
4
  `),j=JSON.stringify([...v]),N=M.join(`
5
5
 
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{K,Ss,ks,Cs,n}from"./chunk-w8h7nb1d.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-r18sh8h9.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{K as injectRouterScript,n as processDirectives,Ss as processJsonDirective,ks as processOnceDirective,Cs as validateClientScript};
2
+ import{K,Ss,ks,Cs,n}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{K as injectRouterScript,n as processDirectives,Ss as processJsonDirective,ks as processOnceDirective,Cs as validateClientScript};