@stacksjs/stx 0.2.675 → 0.2.677

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 (111) hide show
  1. package/dist/{chunk-4x5dk7a4.js → chunk-01cx2p82.js} +1 -1
  2. package/dist/chunk-08d4wb3x.js +2 -0
  3. package/dist/{chunk-nw44qq6h.js → chunk-0rpr2aax.js} +1 -1
  4. package/dist/{chunk-xayfz35c.js → chunk-0wmcs0w3.js} +1 -1
  5. package/dist/{chunk-8md2707p.js → chunk-1nrz39tr.js} +13 -13
  6. package/dist/{chunk-6qh2mx6q.js → chunk-2t51tpkc.js} +2 -2
  7. package/dist/{chunk-n615cbxq.js → chunk-3bfegbpw.js} +1 -1
  8. package/dist/{chunk-shft9r9d.js → chunk-3rde002j.js} +1 -1
  9. package/dist/{chunk-t9bsgbwv.js → chunk-4tn437tn.js} +2 -2
  10. package/dist/{chunk-z6mrnh98.js → chunk-54zkkxmb.js} +1 -1
  11. package/dist/{chunk-7q699phs.js → chunk-569s7hg6.js} +1 -1
  12. package/dist/{chunk-8an7vcxx.js → chunk-69qhykgz.js} +1 -1
  13. package/dist/{chunk-3vwkyjan.js → chunk-7dnpjrqp.js} +12 -12
  14. package/dist/{chunk-09gchq7d.js → chunk-8aq07a1j.js} +3 -3
  15. package/dist/chunk-8z8w9rxc.js +2 -0
  16. package/dist/{chunk-1s2y6f4b.js → chunk-909ymsjz.js} +1 -1
  17. package/dist/{chunk-5zvrbms2.js → chunk-a2zb5fgg.js} +2 -2
  18. package/dist/chunk-adyseb6y.js +2 -0
  19. package/dist/{chunk-54fazdmn.js → chunk-aypmc7qg.js} +1 -1
  20. package/dist/{chunk-9azagdq6.js → chunk-b4709e09.js} +13 -13
  21. package/dist/chunk-bm42rsaa.js +2 -0
  22. package/dist/chunk-br3cde1t.js +2 -0
  23. package/dist/chunk-cep5ba7w.js +2 -0
  24. package/dist/{chunk-29wj0c68.js → chunk-dckjv2vk.js} +2 -2
  25. package/dist/{chunk-03hhanvm.js → chunk-dx037j0p.js} +1 -1
  26. package/dist/{chunk-dba795e1.js → chunk-dxh45gve.js} +1 -1
  27. package/dist/chunk-dzbn56tx.js +2 -0
  28. package/dist/chunk-e0fhfnee.js +2 -0
  29. package/dist/{chunk-g98gafg7.js → chunk-efpd1yyg.js} +1 -1
  30. package/dist/{chunk-etbpzmxv.js → chunk-fjtffqf9.js} +1 -1
  31. package/dist/{chunk-zwkc8yge.js → chunk-fka2073f.js} +48 -48
  32. package/dist/chunk-fp3a3gmr.js +2 -0
  33. package/dist/{chunk-nv0jjhtd.js → chunk-ft3f9nj0.js} +1 -1
  34. package/dist/{chunk-ggf4z3bv.js → chunk-ga5kjf9b.js} +3 -3
  35. package/dist/{chunk-z4bfgvb3.js → chunk-gjdpdvw5.js} +3 -3
  36. package/dist/{chunk-8xxc5edr.js → chunk-hejx7gbs.js} +1 -1
  37. package/dist/{chunk-xtnxvmdb.js → chunk-hg9dxba9.js} +1 -1
  38. package/dist/{chunk-4e5jrxbn.js → chunk-hh2dcnsx.js} +5 -5
  39. package/dist/{chunk-w0vpvcj0.js → chunk-hkfabb1e.js} +1 -1
  40. package/dist/chunk-hqj28381.js +3 -0
  41. package/dist/chunk-j9pwgyf1.js +2 -0
  42. package/dist/{chunk-7475sm3m.js → chunk-je8t9yka.js} +1 -1
  43. package/dist/chunk-jkw89s1t.js +2 -0
  44. package/dist/{chunk-hfbkbrwk.js → chunk-k65zz7t3.js} +3 -3
  45. package/dist/chunk-kas6xn08.js +2 -0
  46. package/dist/{chunk-wtvy9r5w.js → chunk-kxj8e1gd.js} +3 -3
  47. package/dist/{chunk-ram7pa4k.js → chunk-m46bj8c8.js} +2 -2
  48. package/dist/{chunk-gc4w2s5n.js → chunk-mgk7bwb3.js} +2 -2
  49. package/dist/{chunk-hz8dj5jy.js → chunk-mhacarm5.js} +2 -2
  50. package/dist/{chunk-xrrx2ddz.js → chunk-mjsebtg6.js} +1 -1
  51. package/dist/{chunk-81rdyz2n.js → chunk-mzcf1dr1.js} +1 -1
  52. package/dist/{chunk-p6g58hwg.js → chunk-n1d2t5h4.js} +1 -1
  53. package/dist/{chunk-2xv29pfj.js → chunk-n46pv8kp.js} +1 -1
  54. package/dist/{chunk-z17sy8g3.js → chunk-n8wvqnfc.js} +2 -2
  55. package/dist/{chunk-9ybjsfyp.js → chunk-p9az13b2.js} +2 -2
  56. package/dist/{chunk-hg0dd64a.js → chunk-phdd7jxx.js} +1 -1
  57. package/dist/{chunk-c2rq9pap.js → chunk-qjv5tjmy.js} +1 -1
  58. package/dist/{chunk-kzb04293.js → chunk-qwdcts9w.js} +3 -3
  59. package/dist/chunk-r16n5dc4.js +2 -0
  60. package/dist/chunk-r1v1496g.js +2 -0
  61. package/dist/{chunk-q7tfqavs.js → chunk-r9p7r6mx.js} +2 -2
  62. package/dist/chunk-rc79yyqx.js +2 -0
  63. package/dist/chunk-reqdy80m.js +2 -0
  64. package/dist/{chunk-db5017x8.js → chunk-rza3yydb.js} +1 -1
  65. package/dist/{chunk-qdkwg2b8.js → chunk-scgn8dmx.js} +2 -2
  66. package/dist/{chunk-ammn4wbd.js → chunk-sqv40sqk.js} +1 -1
  67. package/dist/chunk-tjqyhgh2.js +2 -0
  68. package/dist/{chunk-j6x7ryyn.js → chunk-tmqrbs98.js} +22 -11
  69. package/dist/{chunk-8jdbrcgt.js → chunk-tqc86aaw.js} +5 -5
  70. package/dist/{chunk-mvz825w0.js → chunk-vdsf1yrt.js} +1 -1
  71. package/dist/{chunk-93z9f2be.js → chunk-wbz32ffd.js} +6 -6
  72. package/dist/{chunk-0thxpgtp.js → chunk-wkkmk4aa.js} +1 -1
  73. package/dist/{chunk-xdn6rtq2.js → chunk-wwgh5ae7.js} +1 -1
  74. package/dist/{chunk-6ncvb8gp.js → chunk-x5sjsf3b.js} +3 -3
  75. package/dist/{chunk-nvbyscdh.js → chunk-x5v3rqbn.js} +1 -1
  76. package/dist/{chunk-e4ezpevb.js → chunk-xnx06qqt.js} +1 -1
  77. package/dist/{chunk-yaccg2c0.js → chunk-y34tyrpb.js} +1 -1
  78. package/dist/chunk-yaej3mgj.js +2 -0
  79. package/dist/chunk-zbp10hjz.js +2 -0
  80. package/dist/{chunk-vf6yaymh.js → chunk-zeyfefpc.js} +1 -1
  81. package/dist/chunk-ztebv7c0.js +2 -0
  82. package/dist/{chunk-5fh9m8fm.js → chunk-zvr3r5p0.js} +1 -1
  83. package/dist/cli.js +8 -8
  84. package/dist/client/signals-for-runtime.js +16 -5
  85. package/dist/craft-entry.js +2 -2
  86. package/dist/craft.js +2 -2
  87. package/dist/desktop.d.ts +5 -0
  88. package/dist/pwa.js +1 -1
  89. package/dist/ssg.js +4 -4
  90. package/package.json +3 -3
  91. package/dist/chunk-1wdawkn8.js +0 -2
  92. package/dist/chunk-41q5rww8.js +0 -2
  93. package/dist/chunk-4c5tk71j.js +0 -2
  94. package/dist/chunk-57ege36s.js +0 -2
  95. package/dist/chunk-5n4c99y5.js +0 -2
  96. package/dist/chunk-6rftdp7c.js +0 -2
  97. package/dist/chunk-7s6hypn5.js +0 -2
  98. package/dist/chunk-7ym269yp.js +0 -2
  99. package/dist/chunk-855h3crg.js +0 -2
  100. package/dist/chunk-bpf3xxng.js +0 -3
  101. package/dist/chunk-dasxbb9y.js +0 -2
  102. package/dist/chunk-e02ne8zd.js +0 -2
  103. package/dist/chunk-fqa5ej45.js +0 -2
  104. package/dist/chunk-hz5eh77e.js +0 -2
  105. package/dist/chunk-prc5dxp1.js +0 -2
  106. package/dist/chunk-qwdgx34g.js +0 -2
  107. package/dist/chunk-r6t1712p.js +0 -2
  108. package/dist/chunk-s5q9ztvj.js +0 -2
  109. package/dist/chunk-sfpymq5h.js +0 -2
  110. package/dist/chunk-t8tst3sk.js +0 -2
  111. package/dist/chunk-xh5mh8kn.js +0 -2
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Ze}from"./chunk-f26n6y9p.js";import{ft,Dn}from"./chunk-j6x7ryyn.js";import{Oe,un,Ya,Za}from"./chunk-3vwkyjan.js";import{mr,hr,yr,vr,Se}from"./chunk-kzb04293.js";import{A}from"./chunk-9wdd7eq6.js";import{zo}from"./chunk-0thxpgtp.js";import{h}from"./chunk-6ncvb8gp.js";import{o}from"./chunk-9azagdq6.js";import{N,i}from"./chunk-6qh2mx6q.js";import{Sa}from"./chunk-q3gactm1.js";import{Ve,_e,Ai,Pi,Cn}from"./chunk-gc4w2s5n.js";import{en,Ys}from"./chunk-54fazdmn.js";import{En}from"./chunk-wav0xbnb.js";import{Gt,Fn,zn}from"./chunk-bpf3xxng.js";import{W}from"./chunk-4e5jrxbn.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function U(n=!1){let l=n?Dn():ft(),a=J(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function V(){let n=Ze(),l=J(n);return{content:n,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(n,l,a={}){let r=q.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Ya();let _={};try{_=await i(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,f;while((f=d.exec(e))!==null){let R=f[1];if(/\bserver\b/.test(R))y.push(f[2])}let u=new Set(y.flatMap((R)=>Oe(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,j={...N,..._,...a,buildMode:"compile",strict:!1},b=await o(e,D,r,j,w),C=Ve(b),P=Za();return{route:l,sourceFile:n,html:b,fragment:C,placeholders:P,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(w),contentHash:S,status:un(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let a=0,r=0;if(!m.existsSync(n))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(re.has(d.name))continue;let f=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(f,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(f,u),a++,r+=m.statSync(u).size}}}return e(n,l),{copied:a,bytes:r}}async function Bu(n={}){let l=Date.now(),a=c.resolve(n.root||process.cwd()),r=c.resolve(a,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await i(a),S=c.resolve(a,n.componentsDir??e.componentsDir??"components"),_=c.resolve(a,n.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",f=Se(e.app?.head,{known:vr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",w=n.routeRules??e.routeRules??{},j=En(w),b=n.serverApi??e.serverApi,C=typeof b==="object"?b:{};if(b)en(a,C);if(e.runtimeConfig)A(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of P)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=W(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((s)=>!Y.some((g)=>s.pattern.startsWith(`/${g}/`)||s.pattern===`/${g}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(n.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],k=[];for(let s of B){let g=j(s.pattern),O=g.rendering==="prerender";if(O&&(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:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=yr(t.html,f,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=mr(t.html,u);if(f.htmlAttrs)t.html=hr(t.html,f.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 I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await h(t.html),O){let p=await Cn(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=_e(t.html,D);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),k.push({pattern:s.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(g).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let E=c.resolve(a,d);if(m.existsSync(E)){let{copied:s,bytes:g}=Z(E,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${d}/`)}let H=zn(a);if(H){let{copied:s,bytes:g}=Z(H,c.join(r,"public",Fn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${Gt}/`)}let F={runtime:v.filename,router:x.filename},T=Ai(k,F,r);if(T.routeRules=w,T.routerContainer=D,b)T.apiRoutes=await Ys(a,r,C);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await zo(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Sa(e._layerGraph),null,2));Pi(T,r);let K=Date.now()-l;return console.log(`
2
+ import{Ze}from"./chunk-f26n6y9p.js";import{ft,Dn}from"./chunk-tmqrbs98.js";import{Oe,un,Ya,Za}from"./chunk-7dnpjrqp.js";import{mr,hr,yr,vr,Se}from"./chunk-qwdcts9w.js";import{A}from"./chunk-9wdd7eq6.js";import{zo}from"./chunk-wkkmk4aa.js";import{h}from"./chunk-x5sjsf3b.js";import{o}from"./chunk-b4709e09.js";import{N,i}from"./chunk-2t51tpkc.js";import{Sa}from"./chunk-q3gactm1.js";import{Ve,_e,Ai,Pi,Cn}from"./chunk-mgk7bwb3.js";import{en,Ys}from"./chunk-aypmc7qg.js";import{En}from"./chunk-wav0xbnb.js";import{Kt,Fn,zn}from"./chunk-hqj28381.js";import{W}from"./chunk-hh2dcnsx.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function U(n=!1){let l=n?Dn():ft(),a=J(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function V(){let n=Ze(),l=J(n);return{content:n,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(n,l,a={}){let r=q.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Ya();let _={};try{_=await i(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,f;while((f=d.exec(e))!==null){let R=f[1];if(/\bserver\b/.test(R))y.push(f[2])}let u=new Set(y.flatMap((R)=>Oe(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,j={...N,..._,...a,buildMode:"compile",strict:!1},b=await o(e,D,r,j,w),C=Ve(b),P=Za();return{route:l,sourceFile:n,html:b,fragment:C,placeholders:P,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(w),contentHash:S,status:un(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let a=0,r=0;if(!m.existsSync(n))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(re.has(d.name))continue;let f=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(f,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(f,u),a++,r+=m.statSync(u).size}}}return e(n,l),{copied:a,bytes:r}}async function Bu(n={}){let l=Date.now(),a=c.resolve(n.root||process.cwd()),r=c.resolve(a,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await i(a),S=c.resolve(a,n.componentsDir??e.componentsDir??"components"),_=c.resolve(a,n.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",f=Se(e.app?.head,{known:vr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",w=n.routeRules??e.routeRules??{},j=En(w),b=n.serverApi??e.serverApi,C=typeof b==="object"?b:{};if(b)en(a,C);if(e.runtimeConfig)A(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of P)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=W(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((s)=>!Y.some((g)=>s.pattern.startsWith(`/${g}/`)||s.pattern===`/${g}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(n.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],k=[];for(let s of B){let g=j(s.pattern),O=g.rendering==="prerender";if(O&&(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:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=yr(t.html,f,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=mr(t.html,u);if(f.htmlAttrs)t.html=hr(t.html,f.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 I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await h(t.html),O){let p=await Cn(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=_e(t.html,D);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),k.push({pattern:s.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(g).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let E=c.resolve(a,d);if(m.existsSync(E)){let{copied:s,bytes:g}=Z(E,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${d}/`)}let H=zn(a);if(H){let{copied:s,bytes:g}=Z(H,c.join(r,"public",Fn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${Kt}/`)}let F={runtime:v.filename,router:x.filename},T=Ai(k,F,r);if(T.routeRules=w,T.routerContainer=D,b)T.apiRoutes=await Ys(a,r,C);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await zo(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Sa(e._layerGraph),null,2));Pi(T,r);let K=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${K}ms \u2014 ${M.length} pages compiled`),{pageCount:M.length,assets:F,outputDir:r,duration:K}}
4
4
  export{Bu};