@stacksjs/stx 0.2.442 → 0.2.444

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 (60) hide show
  1. package/dist/{chunk-v93znq7a.js → chunk-0qsn5vsd.js} +1 -1
  2. package/dist/{chunk-hwaxjfr0.js → chunk-1189skf4.js} +1 -1
  3. package/dist/{chunk-rk3nsd1x.js → chunk-1bfwtrtr.js} +1 -1
  4. package/dist/{chunk-7x8nd4fw.js → chunk-1n4j4h0w.js} +1 -1
  5. package/dist/chunk-2k4dryxp.js +33 -0
  6. package/dist/{chunk-2rs6n7c0.js → chunk-2qnvrj31.js} +1 -1
  7. package/dist/{chunk-xf873x70.js → chunk-2wsfvjhe.js} +1 -1
  8. package/dist/{chunk-xh420ckt.js → chunk-4djmatx7.js} +1 -1
  9. package/dist/{chunk-4ta6131h.js → chunk-4n38vrh9.js} +1 -1
  10. package/dist/{chunk-5vgyr78g.js → chunk-4rpfmh9w.js} +1 -1
  11. package/dist/{chunk-phafsgd9.js → chunk-4s0xfpsn.js} +1 -1
  12. package/dist/{chunk-drsy8gek.js → chunk-4vzbt8p6.js} +1 -1
  13. package/dist/{chunk-qg5e32gx.js → chunk-7bc50hm4.js} +1 -1
  14. package/dist/{chunk-6nxzh304.js → chunk-7cq9k3kd.js} +1 -1
  15. package/dist/{chunk-m0nw8he9.js → chunk-8tket3q3.js} +1 -1
  16. package/dist/{chunk-t5wfq4r9.js → chunk-9v2w774g.js} +1 -1
  17. package/dist/{chunk-wf2gq6hc.js → chunk-a14z0mp4.js} +1 -1
  18. package/dist/{chunk-a3smkhem.js → chunk-c2yt6czn.js} +1 -1
  19. package/dist/{chunk-fx994kkj.js → chunk-ca24g1fa.js} +4 -0
  20. package/dist/{chunk-dftp2bp0.js → chunk-dxsrq87y.js} +1 -1
  21. package/dist/{chunk-vhywbdej.js → chunk-hbmr3fz6.js} +1 -1
  22. package/dist/{chunk-0ahjxtkx.js → chunk-kf6j2zxr.js} +5 -5
  23. package/dist/{chunk-7416mm6g.js → chunk-mkst2aqd.js} +1 -1
  24. package/dist/chunk-n54srgdv.js +2 -0
  25. package/dist/{chunk-1rn1g4ac.js → chunk-nhz583np.js} +1 -1
  26. package/dist/{chunk-gsgkaa1g.js → chunk-nk8wcwtw.js} +1 -1
  27. package/dist/{chunk-wn1p05ac.js → chunk-p3dqn89d.js} +1 -1
  28. package/dist/{chunk-fgedcdc1.js → chunk-prz1qw2w.js} +1 -1
  29. package/dist/{chunk-d6npyn3x.js → chunk-pxnwk92z.js} +1 -1
  30. package/dist/{chunk-y3695sgc.js → chunk-r3647v1d.js} +1 -1
  31. package/dist/{chunk-7cvc6hdw.js → chunk-rwrj33bt.js} +1 -1
  32. package/dist/{chunk-1ghj9pgz.js → chunk-sszxyg08.js} +18 -18
  33. package/dist/{chunk-3n8qh43z.js → chunk-t8fm46p6.js} +1 -1
  34. package/dist/{chunk-1gsr2z6s.js → chunk-v23g5dwz.js} +1 -1
  35. package/dist/{chunk-zntspqxt.js → chunk-vbsv4e1q.js} +1 -1
  36. package/dist/{chunk-1k55q9ff.js → chunk-vt8heeds.js} +1 -1
  37. package/dist/{chunk-1s04q9hz.js → chunk-vteymh4f.js} +1 -1
  38. package/dist/{chunk-wbdk7bcw.js → chunk-w56svnna.js} +1 -1
  39. package/dist/{chunk-tr1q484n.js → chunk-wpvnynj7.js} +1 -1
  40. package/dist/{chunk-6a1jr9pp.js → chunk-x87j60sq.js} +2 -2
  41. package/dist/{chunk-kagy1rcd.js → chunk-y29k6k0v.js} +1 -1
  42. package/dist/{chunk-8sbm4bza.js → chunk-y3xrvykj.js} +2 -2
  43. package/dist/{chunk-tz32ndmq.js → chunk-y763qg35.js} +1 -1
  44. package/dist/{chunk-yqnkzkd3.js → chunk-yakw5x0h.js} +1 -1
  45. package/dist/{chunk-yva29j3q.js → chunk-yg494zzb.js} +1 -1
  46. package/dist/{chunk-qqq7jr16.js → chunk-yxg5v05n.js} +1 -1
  47. package/dist/{chunk-kpz3tpx7.js → chunk-z0ce8mz5.js} +2 -2
  48. package/dist/{chunk-cpfnd8ta.js → chunk-z7ezbcaj.js} +1 -1
  49. package/dist/{chunk-htwgkg91.js → chunk-zhf93rbk.js} +1 -1
  50. package/dist/{chunk-ra2wyhrd.js → chunk-zhh4cccp.js} +1 -1
  51. package/dist/cli.js +8 -8
  52. package/dist/craft-entry.js +1 -1
  53. package/dist/craft.js +1 -1
  54. package/dist/native/compiler/render-screen.js +3 -2
  55. package/dist/pwa.js +1 -1
  56. package/dist/signals.js +4 -0
  57. package/dist/ssg.js +2 -2
  58. package/package.json +5 -5
  59. package/dist/chunk-d59cjrpm.js +0 -2
  60. package/dist/chunk-v4mrkvzc.js +0 -33
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{K,un,te,_,Et}from"./chunk-56hvemdx.js";import{Ze,gn,ir,or,ar,Qe,et,tt,nt,rt,st,xe}from"./chunk-b5emjcf1.js";import{U,h,Zt,Qt,e,vt,en,f,je,xt,Be,Fe,Z,M,ae,q,d,ye,Zi,us,n,r,ee,qn,i,T,ce}from"./chunk-1ghj9pgz.js";import{_e,ni,ne,C,ri,vr,kn,ge,si,re}from"./chunk-6a1jr9pp.js";import{At}from"./chunk-hwaxjfr0.js";import{De}from"./chunk-m0nw8he9.js";import{a}from"./chunk-cm875f73.js";import{D}from"./chunk-yqsza22w.js";function zs(t,o){let s=[],p=`${o}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)s.push(m);continue}if(l===o){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))s.push(m),c++}}return s}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
2
+ import{K,un,te,_,Et}from"./chunk-56hvemdx.js";import{Ze,gn,ir,or,ar,Qe,et,tt,nt,rt,st,xe}from"./chunk-b5emjcf1.js";import{U,h,Zt,Qt,e,vt,en,f,je,xt,Be,Fe,Z,M,ae,q,d,ye,Zi,us,n,r,ee,qn,i,T,ce}from"./chunk-sszxyg08.js";import{_e,ni,ne,C,ri,vr,kn,ge,si,re}from"./chunk-x87j60sq.js";import{At}from"./chunk-1189skf4.js";import{De}from"./chunk-8tket3q3.js";import{a}from"./chunk-cm875f73.js";import{D}from"./chunk-yqsza22w.js";function zs(t,o){let s=[],p=`${o}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)s.push(m);continue}if(l===o){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))s.push(m),c++}}return s}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 Me from"fs";import Te from"path";function An(t){try{return Me.statSync(t).mtimeMs}catch{return null}}function Mt(t,o){let s=Math.max(0,Math.round((o-t)/1000));if(s<60)return`${s}s ago`;if(s<3600)return`${Math.round(s/60)}m ago`;return`${Math.round(s/3600)}h ago`}function Pi(t,o){try{return globalThis.Bun?.resolveSync(t,o)??null}catch{return null}}function Dn(t,o="stx"){let s=Te.resolve(t);for(let p=0;p<10;p++){let c=Te.join(s,"pantry","@stacksjs",o);if(Me.existsSync(c))return c;let l=Te.dirname(s);if(l===s)break;s=l}return null}var Mn=["@stacksjs/stx","bun-plugin-stx"];function Oi(t){try{let o=Me.readFileSync(Te.join(t,"package.json"),"utf8"),s=JSON.parse(o)?.version;return typeof s==="string"?s:null}catch{return null}}function Ai(t,o=6){let s=Te.resolve(t),p=[],c=new Set;function l(u,y){if(y>o)return;let g;try{g=Me.realpathSync(u)}catch{return}if(c.has(g))return;c.add(g);for(let w of Mn){let S=Te.join(u,w),E=Oi(S);if(E!==null)p.push({name:w,version:E,dir:Te.relative(s,S)||S,nested:y>0})}let b;try{b=Me.readdirSync(u,{withFileTypes:!0})}catch{return}for(let w of b){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=Me.readdirSync(S,{withFileTypes:!0})}catch{continue}for(let x of v){let R=Te.join(S,x.name,"node_modules");if(Me.existsSync(R))l(R,y+1)}continue}let E=Te.join(S,"node_modules");if(Me.existsSync(E))l(E,y+1)}}let m=Te.join(s,"node_modules");if(Me.existsSync(m))l(m,0);return p}function Di(t){let o=[];for(let s of Mn){let p=t.filter((m)=>m.name===s);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){o.push({name:`${s} copies`,status:"info",detail:`${p.length} copies, all ${c[0]} \u2014 duplicated but in agreement`});continue}o.push({name:`${s} 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 ${s}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${s}/package.json' -exec grep -H '"version"' {} +`})}return o}async function fr(t={}){let o=t.cwd?Te.resolve(t.cwd):process.cwd(),s=t.resolve??Pi,p=Date.now(),c=[],l=s("@stacksjs/stx",o);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=s("bun-plugin-stx",o);if(m)c.push({name:"bun-plugin-stx resolves to",status:"ok",detail:m});for(let y of Di(Ai(o)))c.push(y);let u=Dn(o,"stx");if(!u)c.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let y=Te.join(u,"src/signals.ts"),g=[Te.join(u,"dist/index.js"),Te.join(u,"dist/signals.js")].find((v)=>Me.existsSync(v))||null,b=An(y),w=g?An(g):null;if(b==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<b){let v=Math.round((b-w)/1000);c.push({name:"pantry dist freshness",status:"error",detail:`dist (${Mt(w,p)}) is OLDER than src/signals.ts (${Mt(b,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 ${Mt(b,p)}, dist ${Mt(w,p)})`});let S=Te.join(o,"node_modules/@stacksjs/stx"),E=null;try{E=Me.lstatSync(S)}catch{E=null}if(!E)c.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(E.isSymbolicLink()){let v=null;try{v=Me.realpathSync(S)}catch{}let x=(()=>{try{return Me.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(y){c.push({name:"signals runtime",status:"error",detail:`failed to generate: ${y.message}`})}return{checks:c,ok:!c.some((y)=>y.status==="error")}}function gr(t){let o={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},s=["stx runtime resolution:"];for(let p of t.checks)if(s.push(` ${o[p.status]} ${p.name}: ${p.detail}`),p.fix)s.push(` \u2192 ${p.fix}`);return s.push(""),s.push(t.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),s.join(`
1789
- `)}var ft={name:"bun-plugin-stx",async setup(t){let s={...await i(),...t.config?.stx},p=new Set,c=s.webComponents?.enabled?`./${_t.relative(_t.dirname(t.config?.outdir||"dist"),s.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(s.webComponents?.enabled)try{let m=await qn(s,p);if(l.push(...m),s.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(s.cache&&s.cachePath){let x=await Zt(m,s);if(x){if(s.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let y=await te(()=>Bun.file(m).text(),"",(x)=>{throw new un(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!y)throw new un(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:b,allScripts:w}=U.time("script-extraction",()=>{let x=y,R=Z(y);if(R)x=R.content.trim();let k=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],B="",L=[];for(let P of k){let I=P.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",F=P.match(/<script\b([^>]*)>/i),G=F?F[1]:"";if(/\bserver\b/i.test(G))B=I;else L.push(P)}let j=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:B,templateContent:j,allScripts:L}}),S={__filename:m,__dirname:_t.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await te(()=>d(g,S,m),void 0,(x)=>{let R=new K(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(_.log(R,{filePath:m,scriptContent:g}),s.debug)throw R});let v=await U.timeAsync("directive-processing",async()=>await n(b,S,m,s,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-2rs6n7c0.js"),R=x(w.join(`
1789
+ `)}var ft={name:"bun-plugin-stx",async setup(t){let s={...await i(),...t.config?.stx},p=new Set,c=s.webComponents?.enabled?`./${_t.relative(_t.dirname(t.config?.outdir||"dist"),s.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(s.webComponents?.enabled)try{let m=await qn(s,p);if(l.push(...m),s.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(s.cache&&s.cachePath){let x=await Zt(m,s);if(x){if(s.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let y=await te(()=>Bun.file(m).text(),"",(x)=>{throw new un(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!y)throw new un(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:b,allScripts:w}=U.time("script-extraction",()=>{let x=y,R=Z(y);if(R)x=R.content.trim();let k=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],B="",L=[];for(let P of k){let I=P.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",F=P.match(/<script\b([^>]*)>/i),G=F?F[1]:"";if(/\bserver\b/i.test(G))B=I;else L.push(P)}let j=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:B,templateContent:j,allScripts:L}}),S={__filename:m,__dirname:_t.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await te(()=>d(g,S,m),void 0,(x)=>{let R=new K(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(_.log(R,{filePath:m,scriptContent:g}),s.debug)throw R});let v=await U.timeAsync("directive-processing",async()=>await n(b,S,m,s,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-2qnvrj31.js"),R=x(w.join(`
1790
1790
  `),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+R+`
1791
1791
  `+v.slice(k);else v+=`
1792
1792
  ${R}`}if(v=await q(v),u.forEach((x)=>p.add(x)),s.cache&&s.cachePath){if(await Qt(m,v,u,s),s.debug)console.log(`Cached template ${m} with ${u.size} dependencies`)}return{contents:v,loader:"html"}}catch(u){let y=u instanceof Error?u:new K(`Plugin processing failed: ${String(u)}`,m);if(_.log(y,{filePath:m,buildConfig:t.config}),Et.logDetailedError(y,{filePath:m,plugin:"bun-plugin-stx"}),s.debug)console.error("stx Plugin Error:",y);let g=y,b=g.line||null,w=g.context||null;return{contents:s.debug||D()?`<!DOCTYPE html>
@@ -1849,7 +1849,7 @@ ${R}`}if(v=await q(v),u.forEach((x)=>p.add(x)),s.cache&&s.cachePath){if(await Qt
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 yn(t,o={}){let s=o.port||3000,p=o.watch!==!1,c=o.hotReload!==!1&&p,l=null,m=o.hmrPort||s+1,u=Se.resolve(t);if(!Ne.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,o);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 y=a(process.cwd(),"output");Ne.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let I={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(he)=>({path:he.path,external:!0}))}},F=await Bun.build({entrypoints:[u],outdir:y,plugins:[I,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...o.stxOptions});if(!F.success)return console.error(`${e.red}Build failed:${e.reset}`,F.logs),!1;let G=F.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(I){return console.error(`${e.red}Error building stx file:${e.reset}`,I),!1}};if(!await b())return!1;let S=Se.dirname(u);await vt(S);let E=s;try{if(E=await Ye(s),E!==s)console.log(`${e.yellow}Port ${s} is busy, using port ${E} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let I=o.hmrPort||E+1;l=Pt({wsPort:I,verbose:!1}),m=l.start(I)}let v={},x=null,R;try{let{loadStxConfig:I}=await import("./chunk-d59cjrpm.js"),F=await I();if(R=o.stxOptions?.serverApi??F.serverApi,F?.apiRouter)x=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){v=F.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(F?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:oe}=await import("./chunk-06qhvtsv.js"),$e=F.broadcasting;await G($e);let he=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${he}/ws${e.reset}`);let Oe=Se.join(process.cwd(),"channels.ts");if(Ne.existsSync(Oe))try{let le=await oe(Oe);console.log(`${e.blue}Loaded ${e.bright}${le} broadcast channel${le!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(le){console.warn(`${e.yellow}Failed to load channels.ts: ${le.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:B}=await import("./chunk-6nxzh304.js"),L=await k(process.cwd(),R);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${E}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let j=zi({port:E,async fetch(I){return At(I,await(async()=>{let F=new URL(I.url);if([y,Se.dirname(u),Se.join(process.cwd(),"public")].some((le)=>B(Se.join(le,F.pathname),process.cwd(),R)))return new Response("Not Found",{status:404});if(x)try{let le=await x.handleRequest(I);if(le.status!==404)return le}catch{}if(v[F.pathname])try{return await v[F.pathname](I)}catch(le){return new Response(JSON.stringify({error:le.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await L(I);if(G)return G;if(F.pathname==="/")return(async()=>{let W=await f(g||"");if(c)W=Xe(W,m);if(o.native)if(W.includes("<head>"))W=W.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else W="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+W;if(o.titlebarHidden)if(W.includes("<head>"))W=W.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else W=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${W}`;return W})().then((W)=>new Response(W,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let oe=Se.join(y,F.pathname);if(Ne.existsSync(oe)&&Ne.statSync(oe).isFile()){let le=Bun.file(oe),W=Se.extname(oe).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}let $e=Se.dirname(u),he=Se.join($e,F.pathname);if(Ne.existsSync(he)&&Ne.statSync(he).isFile()){let le=Bun.file(he),W=Se.extname(he).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}let Oe=Se.join(process.cwd(),"public",F.pathname);if(Ne.existsSync(Oe)&&Ne.statSync(Oe).isFile()){let le=Bun.file(Oe),W=Se.extname(Oe).toLowerCase(),H="application/octet-stream";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
1852
+ </html>`,loader:"html"}}})}};async function yn(t,o={}){let s=o.port||3000,p=o.watch!==!1,c=o.hotReload!==!1&&p,l=null,m=o.hmrPort||s+1,u=Se.resolve(t);if(!Ne.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,o);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 y=a(process.cwd(),"output");Ne.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let I={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(he)=>({path:he.path,external:!0}))}},F=await Bun.build({entrypoints:[u],outdir:y,plugins:[I,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...o.stxOptions});if(!F.success)return console.error(`${e.red}Build failed:${e.reset}`,F.logs),!1;let G=F.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(I){return console.error(`${e.red}Error building stx file:${e.reset}`,I),!1}};if(!await b())return!1;let S=Se.dirname(u);await vt(S);let E=s;try{if(E=await Ye(s),E!==s)console.log(`${e.yellow}Port ${s} is busy, using port ${E} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let I=o.hmrPort||E+1;l=Pt({wsPort:I,verbose:!1}),m=l.start(I)}let v={},x=null,R;try{let{loadStxConfig:I}=await import("./chunk-n54srgdv.js"),F=await I();if(R=o.stxOptions?.serverApi??F.serverApi,F?.apiRouter)x=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){v=F.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(F?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:oe}=await import("./chunk-06qhvtsv.js"),$e=F.broadcasting;await G($e);let he=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${he}/ws${e.reset}`);let Oe=Se.join(process.cwd(),"channels.ts");if(Ne.existsSync(Oe))try{let le=await oe(Oe);console.log(`${e.blue}Loaded ${e.bright}${le} broadcast channel${le!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(le){console.warn(`${e.yellow}Failed to load channels.ts: ${le.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:B}=await import("./chunk-7cq9k3kd.js"),L=await k(process.cwd(),R);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${E}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let j=zi({port:E,async fetch(I){return At(I,await(async()=>{let F=new URL(I.url);if([y,Se.dirname(u),Se.join(process.cwd(),"public")].some((le)=>B(Se.join(le,F.pathname),process.cwd(),R)))return new Response("Not Found",{status:404});if(x)try{let le=await x.handleRequest(I);if(le.status!==404)return le}catch{}if(v[F.pathname])try{return await v[F.pathname](I)}catch(le){return new Response(JSON.stringify({error:le.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await L(I);if(G)return G;if(F.pathname==="/")return(async()=>{let W=await f(g||"");if(c)W=Xe(W,m);if(o.native)if(W.includes("<head>"))W=W.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else W="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+W;if(o.titlebarHidden)if(W.includes("<head>"))W=W.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else W=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${W}`;return W})().then((W)=>new Response(W,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let oe=Se.join(y,F.pathname);if(Ne.existsSync(oe)&&Ne.statSync(oe).isFile()){let le=Bun.file(oe),W=Se.extname(oe).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}let $e=Se.dirname(u),he=Se.join($e,F.pathname);if(Ne.existsSync(he)&&Ne.statSync(he).isFile()){let le=Bun.file(he),W=Se.extname(he).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}let Oe=Se.join(process.cwd(),"public",F.pathname);if(Ne.existsSync(Oe)&&Ne.statSync(Oe).isFile()){let le=Bun.file(Oe),W=Se.extname(Oe).toLowerCase(),H="application/octet-stream";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
1853
1853
  ${I.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:${E}/${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:${b}/${e.reset}`),console.log(`
2027
2027
  ${e.yellow}Routes:${e.reset}`);let S=new Set(u.map((v)=>v.routeTemplate)),E=Object.entries(m).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Pe.relative(process.cwd(),x.filePath),fileType:x.fileType}));for(let v of u){let x=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");E.push({route:x,filePath:Pe.relative(process.cwd(),v.filePath),fileType:"stx"})}if(E.sort((v,x)=>v.route.localeCompare(x.route)),E.forEach((v,x)=>{let k=x===E.length-1?"\u2514\u2500 ":"\u251C\u2500 ",B=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${B}`)}),console.log(`
2028
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(w.url.toString(),()=>{if(p)it.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=it.watch(l,{recursive:!0},async(x,R)=>{if(!R)return;if(R.endsWith(".stx")||R.endsWith(".js")||R.endsWith(".ts")||R.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${R}${e.yellow} changed, rebuilding...${e.reset}`),ye.clear(),ee(),await y()});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:Ui}=globalThis.Bun;import ve from"fs";import ie from"path";async function Kn(t){try{return xt(await Bun.file(t).text())}catch{return}}function qt(t){let o=Bun.file(t),s=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(s)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(o,{headers:{"Content-Type":p[s]||"application/octet-stream",...l}})}async function wn(t=".",o={}){let s=o.port||3000,p=o.watch!==!1,c=o.hotReload!==!1&&p,l=null,m=o.hmrPort||s+1,u=ie.resolve(t),{loadStxConfig:y}=await import("./chunk-d59cjrpm.js"),g=await y(u),{createServerApi:b,isServerApiSource:w}=await import("./chunk-6nxzh304.js"),S=o.stxOptions?.serverApi??g.serverApi,E=await b(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=o.pagesDir||g.pagesDir||"pages",R=ie.join(v,x);if(!ve.existsSync(R)&&!g._layerPageDirs?.some((O)=>ve.existsSync(O)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${R}${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=M(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[R,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${R}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let B=g?._pluginPageDirs||[],L=[];for(let{dir:O,prefix:z}of B)if(ve.existsSync(O)){let N=M(ie.dirname(O),{pagesDir:ie.basename(O)});for(let V of N){let we=z==="/"?V.pattern:`${z}${V.pattern==="/"?"":V.pattern}`;L.push({route:{...V,pattern:we},prefix:z})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${z}${e.reset}`)}let j=new Map,P=null,I=null;if(o.stxOptions?.shell!==!1){if(I=await ri(u,o.stxOptions?.shell),I){if(P=await vr(I,o.stxOptions||{}),P)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,I)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Qe(),await tt(u);let F=et();if(F.length>0)console.log(`${e.blue}Loaded ${e.bright}${F.length}${e.blue} middleware: ${e.dim}${F.join(", ")}${e.reset}`);let G={},oe=null;try{let{loadStxConfig:O}=await import("./chunk-d59cjrpm.js"),z=await O(u);if(z?.apiRouter)oe=z?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(z?.apiRoutes){G=z.apiRoutes;let N=Object.keys(G).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(z?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:V}=await import("./chunk-06qhvtsv.js"),we=z.broadcasting;await N(we);let We=we.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(ve.existsSync(Ge))try{let se=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let $e=a(u,"output");ve.mkdirSync($e,{recursive:!0});let he=new Map,Oe=new Set,le=async(O)=>{let z=or(R,O);if(!z)return null;try{let N=await Bun.build({entrypoints:[z],outdir:$e,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...o.stxOptions});if(!N.success)return null;let V=N.outputs.find((we)=>we.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,H=async(O,z)=>{try{let{processDirectives:N,extractVariables:V,defaultConfig:we,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-d59cjrpm.js"),{checkCache:se,cacheTemplate:Q,readFileCached:X,templateCache:J}=await import("./chunk-dftp2bp0.js"),ke=await We(u),Je=(de)=>{if(!de)return de;if(ie.isAbsolute(de))return de;return ie.resolve(u,de)},A={...we,...ke,...o.stxOptions,autoShell:!0};if(o.debugDirectives)A.debug=!0;A.partialsDir=Je(A.partialsDir),A.componentsDir=Je(A.componentsDir),A.layoutsDir=Je(A.layoutsDir),A.storesDir=Je(A.storesDir||"stores"),A.cachePath=Je(A.cachePath)??a(u,"cache");let be=!z&&!o.profile,pe=A.cache!==!1;if(pe&&be){let de=J.get(O.filePath);if(de)try{if((await ve.promises.stat(O.filePath)).mtime.getTime()<=de.mtime){let ze=!0;for(let Re of de.dependencies){if(!ve.existsSync(Re)){ze=!1;break}if((await ve.promises.stat(Re)).mtime.getTime()>de.mtime){ze=!1;break}}if(ze){let Re=de.output;if(P)Re=ge(Re,{preserveHead:!0});let gt=W.get(O.filePath);return{route:O,content:Re,status:gt?.status??await Kn(O.filePath),headers:gt?.headers}}}}catch{}let Ie=await se(O.filePath,A);if(Ie){let He=Ie;if(P)He=ge(He,{preserveHead:!0});let ze=W.get(O.filePath);return{route:O,content:He,status:ze?.status??await Kn(O.filePath),headers:ze?.headers}}}let me=pe?await X(O.filePath):await Bun.file(O.filePath).text(),Ce=xt(me),{classifyAllScripts:Y}=await import("./chunk-d59cjrpm.js"),Le=Y(me),Ve=Le.server.map((de)=>de.content),ue=me;for(let de of Le.server)ue=ue.replace(de.fullTag,"");let fe={__filename:O.filePath,__dirname:ie.dirname(O.filePath),__stx_options:A,params:z??{},__stx_runtime_head:{}};for(let de of Ve)try{await V(de,fe,O.filePath)}catch(Ie){if(o.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let Ke=new Set,Ae;if(o.profile){let de=performance.now();Ae=await N(ue,fe,O.filePath,A,Ke);let Ie=performance.now()-de,He=ie.relative(u,O.filePath)||O.filePath;console.log(`[stx:profile] ${He} \u2192 ${Ie.toFixed(2)}ms`)}else Ae=await N(ue,fe,O.filePath,A,Ke);if(!P)Ae=await Ge(Ae,{router:A.router});{let{interpolateScriptExpressions:de}=await import("./chunk-2rs6n7c0.js");Ae=Ae.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,He,ze)=>{if(!/function\s+__stx_setup_/.test(ze))return Ie;return`<script${He}>${de(ze,fe)}</script>`})}if(P)Ae=ge(Ae,{preserveHead:!0});if(pe&&be)await Q(O.filePath,Ae,Ke,A);let{extractStreamBoundaries:Xn}=await import("./chunk-7416mm6g.js"),lt=Xn(fe),mt=fe.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let de=fe.streamBoundaries||{},Ie={...A,autoShell:!1},He=Object.keys(mt).map((Re)=>({id:Re,render:async()=>{let gt=typeof de[Re]==="function"?await de[Re]():void 0;return N(mt[Re],{...fe,$boundary:gt},O.filePath,Ie,new Set)}})),ze=new Set(He.map((Re)=>Re.id));lt=[...(lt||[]).filter((Re)=>!ze.has(Re.id)),...He]}if(lt&&lt.length>0)Oe.add(O.pattern);else lt=void 0;let Kt=Be(fe),Xt=Fe(fe);if(be)W.set(O.filePath,{status:Kt,headers:Xt});return{route:O,content:Ae,status:Kt??Ce,headers:Xt,boundaries:lt}}catch(N){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,N),null}},Ue=8,qe=async()=>{he.clear(),j.clear();for(let O=0;O<k.length;O+=Ue){let z=k.slice(O,O+Ue),N=await Promise.all(z.map((V)=>H(V)));for(let V of N)if(V)he.set(V.route.pattern,V)}for(let O=0;O<L.length;O+=Ue){let z=L.slice(O,O+Ue),N=await Promise.all(z.map(({route:V})=>H(V)));for(let V of N)if(V)j.set(V.route.pattern,V)}return he.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await vt(u);let at=s;try{if(at=await Ye(s),at!==s)console.log(`${e.yellow}Port ${s} is busy, using port ${at} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let O=o.hmrPort||at+1;l=Pt({wsPort:O,verbose:!1}),m=l.start(O)}let Lt=(O,z)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(z).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(O.includes("</head>"))return O.replace("</head>",`${V}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+O};console.log(`${e.blue}Starting server...${e.reset}`);let It=Ui({port:at,async fetch(O){let z=new URL(O.url),N=g?.publicDir||"public",V=ie.join(u,N,z.pathname),we=ie.join(u,z.pathname),We=ie.join($e,z.pathname);if([V,we,We].some((A)=>w(A,u,S)))return new Response("Not Found",{status:404});let[Ge,se,Q]=await Promise.all([ve.promises.stat(V).catch(()=>null),ve.promises.stat(we).catch(()=>null),ve.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(se?.isFile()&&!w(we,u,S))return qt(we);if(Q?.isFile()&&!w(We,u,S))return qt(We);if(z.pathname.startsWith("/_stx/component/")){let A=decodeURIComponent(z.pathname.slice(16));if(A)try{let be=`<${A} />`,pe={...buildConfig,autoShell:!1},me=await processDirectives(be,{},ie.join(u,"components",`${A}.stx`),pe,new Set);return new Response(me,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(z.pathname==="/_stx/img"){let{handleImageRequest:A}=await import("./chunk-kr2phxhf.js"),be=await A(O,{publicDir:ie.join(u,N),cacheDir:a(u,"cache","img")});if(be)return be}if(oe)try{let A=await oe.handleRequest(O);if(A.status!==404)return A}catch{}if(G[z.pathname])try{return await G[z.pathname](O)}catch(A){return new Response(JSON.stringify({error:A.message}),{status:500,headers:{"Content-Type":"application/json"}})}let X=await E(O);if(X)return X;let J=gn(z.pathname,k);if(J){let A=he.get(J.route.pattern),be=Oe.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let pe=await H(J.route,J.params);if(pe)A=pe}if(A){let pe=A.status??200,me=A.headers??{},Ce=(J.route.filePath?je(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Ce.validate){if(!await Ce.validate({params:J.params})){let Ve=await le(404);if(Ve){let ue=Ve;if(ue=await f(ue,u),c)ue=Xe(ue,m);return new Response(ue,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Ce.middleware){let Le=nt(z.pathname,J.params,Ce,z.search),Ve=rt(Le,null,O,{isServer:!0}),ue=await st(Ce.middleware,Ve);if(ue.redirect){let fe=ue.redirect.path,Ke=ue.redirect.options.redirectCode||302,Ae=new Headers(ue.responseHeaders);return Ae.set("Location",fe),new Response(null,{status:Ke,headers:Ae})}if(ue.abort){let{statusCode:fe,message:Ke}=ue.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${fe}</title></head><body><h1>Error ${fe}</h1><p>${Ke}</p></body></html>`,{status:fe,headers:{"Content-Type":"text/html"}})}if(Object.keys(ue.state).length>0){let fe=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ue.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;A.content=A.content.replace("</head>",`${fe}</head>`)}}let Y=A.content;if(P&&si(O)){let Le=xe(Y),Ve=ae(Y),ue=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),fe=ue?ni(ue[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=re(Y,Ke),new Response(Y,{status:pe,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...fe&&{"X-STX-Title":encodeURIComponent(fe)},[Zi]:us(),...C(),"Cache-Control":_e}})}if(P)Y=kn(P,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(o.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(o.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(A.boundaries&&A.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-7416mm6g.js");return Ve(Le(Y,A.boundaries,{timeoutMs:30000}),{status:pe,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:pe,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...me}})}}if(L.length>0){let A=L.map((pe)=>pe.route),be=gn(z.pathname,A);if(be){let pe=j.get(be.route.pattern);if(pe){let me=pe.content;if(P)me=kn(P,me);if(Object.keys(be.params).length>0)me=Lt(me,be.params);if(me=await f(me,u),c)me=Xe(me,m);return new Response(me,{status:pe.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:pe}of B)if(pe!=="/"&&z.pathname.startsWith(pe)){let me=j.get(pe)||j.get(pe+"/");if(me){let Ce=me.content;if(P)Ce=kn(P,Ce);if(Ce=await f(Ce,u),c)Ce=Xe(Ce,m);return new Response(Ce,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Ze(z.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=he.get("/");if(ke){let A=ke.content;if(A=await f(A,u),c)A=Xe(A,m);if(o.native)if(A.includes("<head>"))A=A.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 A="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+A;return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await le(404);if(Je){let A=Je;if(A=await f(A,u),c)A=Xe(A,m);return new Response(A,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let z=await le(500);if(z)return new Response(z,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
2028
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(w.url.toString(),()=>{if(p)it.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=it.watch(l,{recursive:!0},async(x,R)=>{if(!R)return;if(R.endsWith(".stx")||R.endsWith(".js")||R.endsWith(".ts")||R.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${R}${e.yellow} changed, rebuilding...${e.reset}`),ye.clear(),ee(),await y()});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:Ui}=globalThis.Bun;import ve from"fs";import ie from"path";async function Kn(t){try{return xt(await Bun.file(t).text())}catch{return}}function qt(t){let o=Bun.file(t),s=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(s)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(o,{headers:{"Content-Type":p[s]||"application/octet-stream",...l}})}async function wn(t=".",o={}){let s=o.port||3000,p=o.watch!==!1,c=o.hotReload!==!1&&p,l=null,m=o.hmrPort||s+1,u=ie.resolve(t),{loadStxConfig:y}=await import("./chunk-n54srgdv.js"),g=await y(u),{createServerApi:b,isServerApiSource:w}=await import("./chunk-7cq9k3kd.js"),S=o.stxOptions?.serverApi??g.serverApi,E=await b(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=o.pagesDir||g.pagesDir||"pages",R=ie.join(v,x);if(!ve.existsSync(R)&&!g._layerPageDirs?.some((O)=>ve.existsSync(O)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${R}${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=M(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[R,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${R}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let B=g?._pluginPageDirs||[],L=[];for(let{dir:O,prefix:z}of B)if(ve.existsSync(O)){let N=M(ie.dirname(O),{pagesDir:ie.basename(O)});for(let V of N){let we=z==="/"?V.pattern:`${z}${V.pattern==="/"?"":V.pattern}`;L.push({route:{...V,pattern:we},prefix:z})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${z}${e.reset}`)}let j=new Map,P=null,I=null;if(o.stxOptions?.shell!==!1){if(I=await ri(u,o.stxOptions?.shell),I){if(P=await vr(I,o.stxOptions||{}),P)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,I)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Qe(),await tt(u);let F=et();if(F.length>0)console.log(`${e.blue}Loaded ${e.bright}${F.length}${e.blue} middleware: ${e.dim}${F.join(", ")}${e.reset}`);let G={},oe=null;try{let{loadStxConfig:O}=await import("./chunk-n54srgdv.js"),z=await O(u);if(z?.apiRouter)oe=z?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(z?.apiRoutes){G=z.apiRoutes;let N=Object.keys(G).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(z?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:V}=await import("./chunk-06qhvtsv.js"),we=z.broadcasting;await N(we);let We=we.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(ve.existsSync(Ge))try{let se=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let $e=a(u,"output");ve.mkdirSync($e,{recursive:!0});let he=new Map,Oe=new Set,le=async(O)=>{let z=or(R,O);if(!z)return null;try{let N=await Bun.build({entrypoints:[z],outdir:$e,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...o.stxOptions});if(!N.success)return null;let V=N.outputs.find((we)=>we.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,H=async(O,z)=>{try{let{processDirectives:N,extractVariables:V,defaultConfig:we,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-n54srgdv.js"),{checkCache:se,cacheTemplate:Q,readFileCached:X,templateCache:J}=await import("./chunk-dxsrq87y.js"),ke=await We(u),Je=(de)=>{if(!de)return de;if(ie.isAbsolute(de))return de;return ie.resolve(u,de)},A={...we,...ke,...o.stxOptions,autoShell:!0};if(o.debugDirectives)A.debug=!0;A.partialsDir=Je(A.partialsDir),A.componentsDir=Je(A.componentsDir),A.layoutsDir=Je(A.layoutsDir),A.storesDir=Je(A.storesDir||"stores"),A.cachePath=Je(A.cachePath)??a(u,"cache");let be=!z&&!o.profile,pe=A.cache!==!1;if(pe&&be){let de=J.get(O.filePath);if(de)try{if((await ve.promises.stat(O.filePath)).mtime.getTime()<=de.mtime){let ze=!0;for(let Re of de.dependencies){if(!ve.existsSync(Re)){ze=!1;break}if((await ve.promises.stat(Re)).mtime.getTime()>de.mtime){ze=!1;break}}if(ze){let Re=de.output;if(P)Re=ge(Re,{preserveHead:!0});let gt=W.get(O.filePath);return{route:O,content:Re,status:gt?.status??await Kn(O.filePath),headers:gt?.headers}}}}catch{}let Ie=await se(O.filePath,A);if(Ie){let He=Ie;if(P)He=ge(He,{preserveHead:!0});let ze=W.get(O.filePath);return{route:O,content:He,status:ze?.status??await Kn(O.filePath),headers:ze?.headers}}}let me=pe?await X(O.filePath):await Bun.file(O.filePath).text(),Ce=xt(me),{classifyAllScripts:Y}=await import("./chunk-n54srgdv.js"),Le=Y(me),Ve=Le.server.map((de)=>de.content),ue=me;for(let de of Le.server)ue=ue.replace(de.fullTag,"");let fe={__filename:O.filePath,__dirname:ie.dirname(O.filePath),__stx_options:A,params:z??{},__stx_runtime_head:{}};for(let de of Ve)try{await V(de,fe,O.filePath)}catch(Ie){if(o.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let Ke=new Set,Ae;if(o.profile){let de=performance.now();Ae=await N(ue,fe,O.filePath,A,Ke);let Ie=performance.now()-de,He=ie.relative(u,O.filePath)||O.filePath;console.log(`[stx:profile] ${He} \u2192 ${Ie.toFixed(2)}ms`)}else Ae=await N(ue,fe,O.filePath,A,Ke);if(!P)Ae=await Ge(Ae,{router:A.router});{let{interpolateScriptExpressions:de}=await import("./chunk-2qnvrj31.js");Ae=Ae.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,He,ze)=>{if(!/function\s+__stx_setup_/.test(ze))return Ie;return`<script${He}>${de(ze,fe)}</script>`})}if(P)Ae=ge(Ae,{preserveHead:!0});if(pe&&be)await Q(O.filePath,Ae,Ke,A);let{extractStreamBoundaries:Xn}=await import("./chunk-mkst2aqd.js"),lt=Xn(fe),mt=fe.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let de=fe.streamBoundaries||{},Ie={...A,autoShell:!1},He=Object.keys(mt).map((Re)=>({id:Re,render:async()=>{let gt=typeof de[Re]==="function"?await de[Re]():void 0;return N(mt[Re],{...fe,$boundary:gt},O.filePath,Ie,new Set)}})),ze=new Set(He.map((Re)=>Re.id));lt=[...(lt||[]).filter((Re)=>!ze.has(Re.id)),...He]}if(lt&&lt.length>0)Oe.add(O.pattern);else lt=void 0;let Kt=Be(fe),Xt=Fe(fe);if(be)W.set(O.filePath,{status:Kt,headers:Xt});return{route:O,content:Ae,status:Kt??Ce,headers:Xt,boundaries:lt}}catch(N){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,N),null}},Ue=8,qe=async()=>{he.clear(),j.clear();for(let O=0;O<k.length;O+=Ue){let z=k.slice(O,O+Ue),N=await Promise.all(z.map((V)=>H(V)));for(let V of N)if(V)he.set(V.route.pattern,V)}for(let O=0;O<L.length;O+=Ue){let z=L.slice(O,O+Ue),N=await Promise.all(z.map(({route:V})=>H(V)));for(let V of N)if(V)j.set(V.route.pattern,V)}return he.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await vt(u);let at=s;try{if(at=await Ye(s),at!==s)console.log(`${e.yellow}Port ${s} is busy, using port ${at} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let O=o.hmrPort||at+1;l=Pt({wsPort:O,verbose:!1}),m=l.start(O)}let Lt=(O,z)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(z).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(O.includes("</head>"))return O.replace("</head>",`${V}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+O};console.log(`${e.blue}Starting server...${e.reset}`);let It=Ui({port:at,async fetch(O){let z=new URL(O.url),N=g?.publicDir||"public",V=ie.join(u,N,z.pathname),we=ie.join(u,z.pathname),We=ie.join($e,z.pathname);if([V,we,We].some((A)=>w(A,u,S)))return new Response("Not Found",{status:404});let[Ge,se,Q]=await Promise.all([ve.promises.stat(V).catch(()=>null),ve.promises.stat(we).catch(()=>null),ve.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(se?.isFile()&&!w(we,u,S))return qt(we);if(Q?.isFile()&&!w(We,u,S))return qt(We);if(z.pathname.startsWith("/_stx/component/")){let A=decodeURIComponent(z.pathname.slice(16));if(A)try{let be=`<${A} />`,pe={...buildConfig,autoShell:!1},me=await processDirectives(be,{},ie.join(u,"components",`${A}.stx`),pe,new Set);return new Response(me,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(z.pathname==="/_stx/img"){let{handleImageRequest:A}=await import("./chunk-kr2phxhf.js"),be=await A(O,{publicDir:ie.join(u,N),cacheDir:a(u,"cache","img")});if(be)return be}if(oe)try{let A=await oe.handleRequest(O);if(A.status!==404)return A}catch{}if(G[z.pathname])try{return await G[z.pathname](O)}catch(A){return new Response(JSON.stringify({error:A.message}),{status:500,headers:{"Content-Type":"application/json"}})}let X=await E(O);if(X)return X;let J=gn(z.pathname,k);if(J){let A=he.get(J.route.pattern),be=Oe.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let pe=await H(J.route,J.params);if(pe)A=pe}if(A){let pe=A.status??200,me=A.headers??{},Ce=(J.route.filePath?je(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Ce.validate){if(!await Ce.validate({params:J.params})){let Ve=await le(404);if(Ve){let ue=Ve;if(ue=await f(ue,u),c)ue=Xe(ue,m);return new Response(ue,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Ce.middleware){let Le=nt(z.pathname,J.params,Ce,z.search),Ve=rt(Le,null,O,{isServer:!0}),ue=await st(Ce.middleware,Ve);if(ue.redirect){let fe=ue.redirect.path,Ke=ue.redirect.options.redirectCode||302,Ae=new Headers(ue.responseHeaders);return Ae.set("Location",fe),new Response(null,{status:Ke,headers:Ae})}if(ue.abort){let{statusCode:fe,message:Ke}=ue.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${fe}</title></head><body><h1>Error ${fe}</h1><p>${Ke}</p></body></html>`,{status:fe,headers:{"Content-Type":"text/html"}})}if(Object.keys(ue.state).length>0){let fe=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ue.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;A.content=A.content.replace("</head>",`${fe}</head>`)}}let Y=A.content;if(P&&si(O)){let Le=xe(Y),Ve=ae(Y),ue=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),fe=ue?ni(ue[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=re(Y,Ke),new Response(Y,{status:pe,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...fe&&{"X-STX-Title":encodeURIComponent(fe)},[Zi]:us(),...C(),"Cache-Control":_e}})}if(P)Y=kn(P,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(o.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(o.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(A.boundaries&&A.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-mkst2aqd.js");return Ve(Le(Y,A.boundaries,{timeoutMs:30000}),{status:pe,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:pe,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...me}})}}if(L.length>0){let A=L.map((pe)=>pe.route),be=gn(z.pathname,A);if(be){let pe=j.get(be.route.pattern);if(pe){let me=pe.content;if(P)me=kn(P,me);if(Object.keys(be.params).length>0)me=Lt(me,be.params);if(me=await f(me,u),c)me=Xe(me,m);return new Response(me,{status:pe.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:pe}of B)if(pe!=="/"&&z.pathname.startsWith(pe)){let me=j.get(pe)||j.get(pe+"/");if(me){let Ce=me.content;if(P)Ce=kn(P,Ce);if(Ce=await f(Ce,u),c)Ce=Xe(Ce,m);return new Response(Ce,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Ze(z.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=he.get("/");if(ke){let A=ke.content;if(A=await f(A,u),c)A=Xe(A,m);if(o.native)if(A.includes("<head>"))A=A.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 A="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+A;return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await le(404);if(Je){let A=Je;if(A=await f(A,u),c)A=Xe(A,m);return new Response(A,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let z=await le(500);if(z)return new Response(z,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
2029
2029
  ${O.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
2030
2030
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
2031
2031
  ${e.bright}\u2192 ${e.cyan}http://localhost:${at}/${e.reset}`),c)console.log(`${e.dim} HMR: ws://localhost:${m}${e.reset}`);console.log(`
2032
2032
  ${e.yellow}Routes:${e.reset}`);let jt=[...ar(k,u)];for(let{route:O}of L)jt.push(`${O.pattern}`);if(jt.forEach((O,z)=>{let V=z===jt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${V}${e.reset}${O}`)}),console.log(`
2033
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(It.url.toString(),()=>{if(l)ht();It.stop()}),o.native){let O,z=ie.join(R,"index.stx");if(ve.existsSync(z)){let V=await Bun.file(z).text();O=Tt(V)}let N=g?.app?.window??{};await dt(at,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??o.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(se)=>se.startsWith("public/")||se.startsWith("public\\"),z=(se)=>{let Q=se.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},N=new Map,V=()=>{let se=new Set([u,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>ie.dirname(Q))??[]].filter((Q)=>ve.existsSync(Q)).map((Q)=>ve.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let X of Object.values(Q.resources)){if(!ve.existsSync(X))continue;let J=ve.realpathSync(X);if(![...se].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))se.add(J)}for(let[Q,X]of N)if(!se.has(Q))X.close(),N.delete(Q);for(let Q of se)if(!N.has(Q)&&ve.existsSync(Q))N.set(Q,ve.watch(Q,{recursive:!0},(X,J)=>{We(Q,X,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},we=Promise.resolve(),We=(se,Q,X)=>(we=we.catch(()=>{}).then(()=>Ge(se,Q,X)),we),Ge=async(se,Q,X)=>{if(!X||Rt(X))return;if(Ct(X)){if(g._layerGraph){let J=await y(u);Object.assign(g,J),k.splice(0,k.length,...M(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[R,...J._layerPageDirs.slice(1)]:void 0})),V()}if(O(X)){if(console.log(`${e.cyan}${X} changed${e.reset}`),c&&l)l.reload(X)}else if(z(X)){console.log(`${e.yellow}${X} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-dftp2bp0.js");J(ie.resolve(se,X)),ke.delete(ie.resolve(se,X))}catch{}if(I&&X){if(ie.resolve(se,X)===I||ie.basename(I)===X){let ke=await vr(I,o.stxOptions||{});if(ke)P=ke}}if(await qe(),await en(u),c&&l)l.reload(X)}else{console.log(`${e.yellow}${X} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-dftp2bp0.js");J(ie.resolve(se,X)),ke.delete(ie.resolve(se,X))}catch{}if(await qe(),c&&l)l.reload(X)}}else if($t(X)){if(console.log(`${e.cyan}CSS ${X} changed${e.reset}`),c&&l)l.updateCss(X)}};V(),process.on("SIGINT",()=>{for(let se of N.values())se.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{zs,Hs,Vs,Us,pr,Ws,qs,Ks,Do,Oo,fr,gr,yn,bn,wn};
2033
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(It.url.toString(),()=>{if(l)ht();It.stop()}),o.native){let O,z=ie.join(R,"index.stx");if(ve.existsSync(z)){let V=await Bun.file(z).text();O=Tt(V)}let N=g?.app?.window??{};await dt(at,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??o.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(se)=>se.startsWith("public/")||se.startsWith("public\\"),z=(se)=>{let Q=se.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},N=new Map,V=()=>{let se=new Set([u,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>ie.dirname(Q))??[]].filter((Q)=>ve.existsSync(Q)).map((Q)=>ve.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let X of Object.values(Q.resources)){if(!ve.existsSync(X))continue;let J=ve.realpathSync(X);if(![...se].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))se.add(J)}for(let[Q,X]of N)if(!se.has(Q))X.close(),N.delete(Q);for(let Q of se)if(!N.has(Q)&&ve.existsSync(Q))N.set(Q,ve.watch(Q,{recursive:!0},(X,J)=>{We(Q,X,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},we=Promise.resolve(),We=(se,Q,X)=>(we=we.catch(()=>{}).then(()=>Ge(se,Q,X)),we),Ge=async(se,Q,X)=>{if(!X||Rt(X))return;if(Ct(X)){if(g._layerGraph){let J=await y(u);Object.assign(g,J),k.splice(0,k.length,...M(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[R,...J._layerPageDirs.slice(1)]:void 0})),V()}if(O(X)){if(console.log(`${e.cyan}${X} changed${e.reset}`),c&&l)l.reload(X)}else if(z(X)){console.log(`${e.yellow}${X} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-dxsrq87y.js");J(ie.resolve(se,X)),ke.delete(ie.resolve(se,X))}catch{}if(I&&X){if(ie.resolve(se,X)===I||ie.basename(I)===X){let ke=await vr(I,o.stxOptions||{});if(ke)P=ke}}if(await qe(),await en(u),c&&l)l.reload(X)}else{console.log(`${e.yellow}${X} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-dxsrq87y.js");J(ie.resolve(se,X)),ke.delete(ie.resolve(se,X))}catch{}if(await qe(),c&&l)l.reload(X)}}else if($t(X)){if(console.log(`${e.cyan}CSS ${X} changed${e.reset}`),c&&l)l.updateCss(X)}};V(),process.on("SIGINT",()=>{for(let se of N.values())se.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{zs,Hs,Vs,Us,pr,Ws,qs,Ks,Do,Oo,fr,gr,yn,bn,wn};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Yl,mi,Ea,Zl,Ql,eu,tu,nu,Ta,_a,ru,su,iu,ou}from"./chunk-7cvc6hdw.js";import"./chunk-1ghj9pgz.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-wf2gq6hc.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{Ea as SUSPENSE_RESOLVER_RUNTIME,mi as buildSuspenseResolveScript,nu as createStreamRenderer,eu as extractStreamBoundaries,ou as generateHydrationRuntime,_a as islandDirective,su as processSectionDirectives,Ql as processStreamDirectives,ru as registerStreamingDirectives,Zl as renderStreamingPage,Yl as streamTemplate,tu as streamTemplateSimple,iu as streamToResponse,Ta as streamingSuspenseDirective};
2
+ import{Yl,mi,Ea,Zl,Ql,eu,tu,nu,Ta,_a,ru,su,iu,ou}from"./chunk-rwrj33bt.js";import"./chunk-sszxyg08.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-a14z0mp4.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{Ea as SUSPENSE_RESOLVER_RUNTIME,mi as buildSuspenseResolveScript,nu as createStreamRenderer,eu as extractStreamBoundaries,ou as generateHydrationRuntime,_a as islandDirective,su as processSectionDirectives,Ql as processStreamDirectives,ru as registerStreamingDirectives,Zl as renderStreamingPage,Yl as streamTemplate,tu as streamTemplateSimple,iu as streamToResponse,Ta as streamingSuspenseDirective};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Do,Oo}from"./chunk-kf6j2zxr.js";import"./chunk-fmj4xvqm.js";import"./chunk-mcgpeyy8.js";import"./chunk-4s0xfpsn.js";import"./chunk-8nsmx2w4.js";import"./chunk-1n4j4h0w.js";import"./chunk-4djmatx7.js";import"./chunk-rvbcnahe.js";import"./chunk-bh432b7n.js";import"./chunk-9v2w774g.js";import"./chunk-1189skf4.js";import{ti}from"./chunk-x87j60sq.js";import"./chunk-9f0srtmg.js";import"./chunk-dn9thd0h.js";import"./chunk-c2yt6czn.js";import"./chunk-hkx8pggg.js";import"./chunk-m4q2e418.js";import"./chunk-qa7j3j71.js";import"./chunk-s5drjm2j.js";import"./chunk-0xntpjmp.js";import"./chunk-7mbx7dzg.js";import"./chunk-t8fm46p6.js";import"./chunk-n9jn3qzw.js";import"./chunk-dwp3knc4.js";import"./chunk-hqywyyez.js";import"./chunk-mnz6bdp3.js";import"./chunk-0vbpcef6.js";import"./chunk-nw8p8eg9.js";import"./chunk-yg494zzb.js";import"./chunk-ca24g1fa.js";import"./chunk-rwrj33bt.js";import"./chunk-z0ce8mz5.js";import"./chunk-r3f9jcf7.js";import"./chunk-8tket3q3.js";import"./chunk-zhf93rbk.js";import{me,Zt,Qt,q,d,n,qn,A,i,ce}from"./chunk-sszxyg08.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-a14z0mp4.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{qn as buildWebComponents,Qt as cacheTemplate,Zt as checkCache,ti as classifyAllScripts,Do as createMiddleware,Oo as createRoute,A as defaultConfig,d as extractVariables,q as injectRouterScript,i as loadStxConfig,me as processClientScript,n as processDirectives,ce as readMarkdownFile};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$i}from"./chunk-kpz3tpx7.js";import{u}from"./chunk-cg8hg6cs.js";var au=`
2
+ import{$i}from"./chunk-z0ce8mz5.js";import{u}from"./chunk-cg8hg6cs.js";var au=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jo,ll,Yo,Zo,ul,dl}from"./chunk-a3smkhem.js";import"./chunk-1ghj9pgz.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-wf2gq6hc.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{dl as applySlots,ul as extractSlotContent,ll as parseSlotElement,Jo as parseSlots,Zo as processSlots,Yo as renderSlot};
2
+ import{Jo,ll,Yo,Zo,ul,dl}from"./chunk-c2yt6czn.js";import"./chunk-sszxyg08.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-a14z0mp4.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{dl as applySlots,ul as extractSlotContent,ll as parseSlotElement,Jo as parseSlots,Zo as processSlots,Yo as renderSlot};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{kt,os,Ji,fc}from"./chunk-1ghj9pgz.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-wf2gq6hc.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{fc as declareBareLoopHead,kt as parseLoopBinding,Ji as processLoops,os as reportDeferredLoopWarnings};
2
+ import{kt,os,Ji,fc}from"./chunk-sszxyg08.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-a14z0mp4.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{fc as declareBareLoopHead,kt as parseLoopBinding,Ji as processLoops,os as reportDeferredLoopWarnings};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Yr,Zr,Qr,Du,Ln,Ou}from"./chunk-1ghj9pgz.js";export{Ln as clearImageDeliveryCatalog,Du as deliveredImage,Qr as efficientDeliverySources,Yr as getImageDelivery,Zr as isTransparentImage,Ou as prepareImageDelivery};
2
+ import{Yr,Zr,Qr,Du,Ln,Ou}from"./chunk-sszxyg08.js";export{Ln as clearImageDeliveryCatalog,Du as deliveredImage,Qr as efficientDeliverySources,Yr as getImageDelivery,Zr as isTransparentImage,Ou as prepareImageDelivery};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Nu,ye,Yi,Lu,as,cs,ls}from"./chunk-1ghj9pgz.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-wf2gq6hc.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{Lu as clearOnceStore,Yi as onceStore,ye as partialsCache,as as processIncludes,cs as processStackPushDirectives,ls as processStackReplacements,Nu as resetUnscopedSignalWarnings};
2
+ import{Nu,ye,Yi,Lu,as,cs,ls}from"./chunk-sszxyg08.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-a14z0mp4.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{Lu as clearOnceStore,Yi as onceStore,ye as partialsCache,as as processIncludes,cs as processStackPushDirectives,ls as processStackReplacements,Nu as resetUnscopedSignalWarnings};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{al}from"./chunk-hwaxjfr0.js";import"./chunk-6a1jr9pp.js";import"./chunk-htwgkg91.js";import"./chunk-1ghj9pgz.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-wf2gq6hc.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{al as startProductionServer};
2
+ import{al}from"./chunk-1189skf4.js";import"./chunk-x87j60sq.js";import"./chunk-zhf93rbk.js";import"./chunk-sszxyg08.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-a14z0mp4.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{al as startProductionServer};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{h,d,n,g,A}from"./chunk-1ghj9pgz.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,s;M.lastIndex=0;while((s=M.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 Yl(e,t={},o={}){let s={...A,...o,streaming:{...q,...o.streaming}},r=s.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(m.trim())await d(m,y,e);let E=H(c),u=new Set;if(!E.some((w)=>w.type==="suspense")){let w=s.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let p=await n(c,y,e,s,u);for(let b=0;b<p.length;b+=r)i.enqueue(p.slice(b,b+r)),await new Promise((f)=>setTimeout(f,0))}else{let p=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)p.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of p){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await n(I,y,e,s,u);i.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await n(_.content,y,e,s,u);i.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await n(_,y,e,s,u);i.enqueue(C)}}}}else{let w=new Map;for(let l of E)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{h,d,n,g,A}from"./chunk-sszxyg08.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,s;M.lastIndex=0;while((s=M.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 Yl(e,t={},o={}){let s={...A,...o,streaming:{...q,...o.streaming}},r=s.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(m.trim())await d(m,y,e);let E=H(c),u=new Set;if(!E.some((w)=>w.type==="suspense")){let w=s.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let p=await n(c,y,e,s,u);for(let b=0;b<p.length;b+=r)i.enqueue(p.slice(b,b+r)),await new Promise((f)=>setTimeout(f,0))}else{let p=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)p.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of p){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await n(I,y,e,s,u);i.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await n(_.content,y,e,s,u);i.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await n(_,y,e,s,u);i.enqueue(C)}}}}else{let w=new Map;for(let l of E)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>`),w.set(l.name,n(l.content,y,e,s,u))}i.enqueue(`
5
5
  <script>