@stacksjs/stx 0.2.221 → 0.2.222

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 (55) hide show
  1. package/dist/{chunk-08031d2g.js → chunk-24271vkv.js} +1 -1
  2. package/dist/chunk-2gwfcgct.js +2 -0
  3. package/dist/{chunk-x0f34a44.js → chunk-409jrxj6.js} +1 -1
  4. package/dist/chunk-4a01b3qp.js +2 -0
  5. package/dist/{chunk-mcz70xms.js → chunk-4thj960e.js} +1 -1
  6. package/dist/{chunk-5a5efazd.js → chunk-53d24qhh.js} +1 -1
  7. package/dist/{chunk-20wgmax7.js → chunk-749d2abw.js} +1 -1
  8. package/dist/{chunk-e890s5em.js → chunk-7cqda8w2.js} +1 -1
  9. package/dist/{chunk-bj25jvsn.js → chunk-7ggk2vmy.js} +1 -1
  10. package/dist/{chunk-7x3nd6r4.js → chunk-7tzyw85k.js} +1 -1
  11. package/dist/{chunk-3zhhytkd.js → chunk-85yfwhdx.js} +1 -1
  12. package/dist/{chunk-qfsktf7s.js → chunk-8j2v2hnc.js} +1 -1
  13. package/dist/{chunk-q5w0fqd5.js → chunk-8rgd1mn9.js} +1 -1
  14. package/dist/{chunk-g3rg8afc.js → chunk-98a8ma06.js} +1 -1
  15. package/dist/{chunk-6sm1vr9h.js → chunk-ansvb340.js} +1 -1
  16. package/dist/{chunk-4svjne4w.js → chunk-bg595da5.js} +1 -1
  17. package/dist/{chunk-ejspksxd.js → chunk-bhz0py78.js} +1 -1
  18. package/dist/{chunk-tgaddq21.js → chunk-cc6b6cvn.js} +1 -1
  19. package/dist/{chunk-xqnwy1t6.js → chunk-ceqzwfcq.js} +1 -1
  20. package/dist/{chunk-6qjzx44j.js → chunk-dbvvgvwk.js} +2 -2
  21. package/dist/{chunk-fw5d1aev.js → chunk-egpmwqas.js} +2 -2
  22. package/dist/{chunk-38zpyb7q.js → chunk-epep418h.js} +1 -1
  23. package/dist/{chunk-2y8ss8b3.js → chunk-etnqfdcj.js} +1 -1
  24. package/dist/{chunk-5y731xe9.js → chunk-fm03jwb1.js} +1 -1
  25. package/dist/chunk-fqrfhf6n.js +2 -0
  26. package/dist/{chunk-zpskp2xb.js → chunk-ftdysk1n.js} +1 -1
  27. package/dist/{chunk-zh75hc6a.js → chunk-gyf7n2as.js} +1 -1
  28. package/dist/chunk-hzj77qay.js +2 -0
  29. package/dist/{chunk-4wdbmjmg.js → chunk-j51tsstz.js} +1 -1
  30. package/dist/{chunk-rmrnnv87.js → chunk-j8dg655g.js} +1 -1
  31. package/dist/{chunk-cw0352e8.js → chunk-jvxc59g1.js} +1 -1
  32. package/dist/{chunk-kdpy5rgk.js → chunk-kwpvv59c.js} +24 -5
  33. package/dist/{chunk-bgb5a3q6.js → chunk-m86nzprx.js} +1 -1
  34. package/dist/{chunk-5fz9n4wq.js → chunk-m8kn995q.js} +1 -1
  35. package/dist/{chunk-pzcf36xm.js → chunk-pbyxj0zr.js} +16 -16
  36. package/dist/{chunk-pscdy0gn.js → chunk-pd8cce9a.js} +9 -9
  37. package/dist/{chunk-1y3kc7mb.js → chunk-qpm1px64.js} +1 -1
  38. package/dist/{chunk-7cq5b6zp.js → chunk-rmyrzcac.js} +1 -1
  39. package/dist/chunk-s0perkbz.js +2 -0
  40. package/dist/{chunk-rq20qvkk.js → chunk-s8x2n1p6.js} +1 -1
  41. package/dist/{chunk-anenwsj3.js → chunk-szw6at2m.js} +1 -1
  42. package/dist/{chunk-7s3wrtpb.js → chunk-td2et1ek.js} +1 -1
  43. package/dist/{chunk-a4329ma8.js → chunk-yf4p02wy.js} +1 -1
  44. package/dist/{chunk-n1b7b20f.js → chunk-zztd93sa.js} +1 -1
  45. package/dist/cli.js +7 -7
  46. package/dist/craft-entry.js +1 -1
  47. package/dist/craft.js +1 -1
  48. package/dist/pwa.js +1 -1
  49. package/dist/ssg.js +2 -2
  50. package/package.json +5 -5
  51. package/dist/chunk-25jkkv9d.js +0 -2
  52. package/dist/chunk-9ktvkzcc.js +0 -2
  53. package/dist/chunk-tc2d9en8.js +0 -2
  54. package/dist/chunk-th7snpq2.js +0 -2
  55. package/dist/chunk-yk45219d.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Bq as k,Fl as A,Gl as D,Pm as T,Qm as y,Uo as x,Wl as B,Yl as F,Yr as w,ap as M,mq as R}from"./chunk-pzcf36xm.js";import{xu as P}from"./chunk-8rn5e39c.js";function b(K){return K.endsWith(".md")||K.endsWith(".markdown")}function C(K){let z=[];_(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let G=[...z];_(/<code\b[^>]*>[\s\S]*?<\/code>/gi,G);function _(J,X){let $;while(($=J.exec(K))!==null){let q=$.index,N=q+$[0].length;if(X?.some((Y)=>q>=Y.start&&N<=Y.end))continue;z.push({start:q,end:N})}}if(z.length===0)return K;z.sort((J,X)=>J.start-X.start);let U="",Q=0;for(let J of z){if(J.start<Q)continue;U+=K.slice(Q,J.start),U+=`@raw${K.slice(J.start,J.end)}@endraw`,Q=J.end}return U+=K.slice(Q),U}async function j(K,z={}){let{data:G,content:_}=A(K),Q=await(z.renderer??((J)=>D(J)))(_);return{html:C(Q),frontmatter:G??{}}}import{dirname as v,resolve as H}from"path";function f(K){let z=K,G=x(K);if(G)z=G.content.trim();let _=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U=[],Q=[],J=[],X=(N)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(N),$;while(($=_.exec(K))!==null){let N=$[1],Y=$[2],E=$[0],Z=N.includes("server");if(X(Y))J.push(E);else if(Z)Q.push(Y);else U.push(E)}let q=z;{let N=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,Y,E=[];while((Y=N.exec(q))!==null){let Z=Y.index+Y[0].length,L=q.indexOf("</script>",Z);if(L===-1)continue;E.push({start:Y.index,end:L+9}),N.lastIndex=L+9}for(let Z=E.length-1;Z>=0;Z--)q=q.substring(0,E[Z].start)+q.substring(E[Z].end)}for(let N of U)q=q.replace(N,"");return{templateContent:q,serverScripts:Q,clientScripts:U,signalsScripts:J}}function g(K,z){return`<!DOCTYPE html>
2
+ import{Bq as k,Fl as A,Gl as D,Pm as T,Qm as y,Uo as x,Wl as B,Yl as F,Yr as w,ap as M,mq as R}from"./chunk-pbyxj0zr.js";import{xu as P}from"./chunk-8rn5e39c.js";function b(K){return K.endsWith(".md")||K.endsWith(".markdown")}function C(K){let z=[];_(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let G=[...z];_(/<code\b[^>]*>[\s\S]*?<\/code>/gi,G);function _(J,X){let $;while(($=J.exec(K))!==null){let q=$.index,N=q+$[0].length;if(X?.some((Y)=>q>=Y.start&&N<=Y.end))continue;z.push({start:q,end:N})}}if(z.length===0)return K;z.sort((J,X)=>J.start-X.start);let U="",Q=0;for(let J of z){if(J.start<Q)continue;U+=K.slice(Q,J.start),U+=`@raw${K.slice(J.start,J.end)}@endraw`,Q=J.end}return U+=K.slice(Q),U}async function j(K,z={}){let{data:G,content:_}=A(K),Q=await(z.renderer??((J)=>D(J)))(_);return{html:C(Q),frontmatter:G??{}}}import{dirname as v,resolve as H}from"path";function f(K){let z=K,G=x(K);if(G)z=G.content.trim();let _=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U=[],Q=[],J=[],X=(N)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(N),$;while(($=_.exec(K))!==null){let N=$[1],Y=$[2],E=$[0],Z=N.includes("server");if(X(Y))J.push(E);else if(Z)Q.push(Y);else U.push(E)}let q=z;{let N=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,Y,E=[];while((Y=N.exec(q))!==null){let Z=Y.index+Y[0].length,L=q.indexOf("</script>",Z);if(L===-1)continue;E.push({start:Y.index,end:L+9}),N.lastIndex=L+9}for(let Z=E.length-1;Z>=0;Z--)q=q.substring(0,E[Z].start)+q.substring(E[Z].end)}for(let N of U)q=q.replace(N,"");return{templateContent:q,serverScripts:Q,clientScripts:U,signalsScripts:J}}function g(K,z){return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -14,5 +14,5 @@ ${Q.join(`
14
14
  `)}`}else{if(G.processClientScripts!==!1&&Q.length>0){let N=X.__stx_event_bindings||[],Y=B(X),Z=(await Promise.all(Q.map(async(V)=>{let W=V.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!W)return V;return await F(W[1],{eventBindings:N,templateContent:q,serverData:Y,filePath:z})}))).join(`
15
15
  `);if(q.match(/(<\/body>)/i))q=q.replace(/(<\/body>)/i,`${Z}
16
16
  $1`);else q+=`
17
- ${Z}`}q=await R(q)}if(G.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=g(q,G.title)}if(G.injectCSS)try{let{injectCrosswindCSS:N}=await import("./chunk-5y731xe9.js");q=await N(q)}catch{}return q}
17
+ ${Z}`}q=await R(q)}if(G.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=g(q,G.title)}if(G.injectCSS)try{let{injectCrosswindCSS:N}=await import("./chunk-fm03jwb1.js");q=await N(q)}catch{}return q}
18
18
  export{b as ok,C as pk,j as qk,s as rk,i as sk,I as tk};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ef as a}from"./chunk-tgaddq21.js";import"./chunk-pzcf36xm.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-qfsktf7s.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kdpy5rgk.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{a as buildApp};
2
+ import{ef as a}from"./chunk-cc6b6cvn.js";import"./chunk-pbyxj0zr.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-8j2v2hnc.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kwpvv59c.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{a as buildApp};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ni as a,Oi as b,Pi as c,Qi as d,Ri as e,Si as f,Ti as g,Ui as h,Vi as i,Wi as j,Xi as k}from"./chunk-mcz70xms.js";import"./chunk-pzcf36xm.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-qfsktf7s.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kdpy5rgk.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{a as templateCache,b as readFileCached,d as invalidateFileCacheByDir,c as invalidateFileCache,k as hashFilePath,f as getCachedSignalsRuntime,g as getCachedRouterScript,h as clearDevCaches,i as checkCache,j as cacheTemplate,e as __setSignalsGeneratorsForTest};
2
+ import{Ni as a,Oi as b,Pi as c,Qi as d,Ri as e,Si as f,Ti as g,Ui as h,Vi as i,Wi as j,Xi as k}from"./chunk-4thj960e.js";import"./chunk-pbyxj0zr.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-8j2v2hnc.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kwpvv59c.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{a as templateCache,b as readFileCached,d as invalidateFileCacheByDir,c as invalidateFileCache,k as hashFilePath,f as getCachedSignalsRuntime,g as getCachedRouterScript,h as clearDevCaches,i as checkCache,j as cacheTemplate,e as __setSignalsGeneratorsForTest};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ks as a,Ls as b,Ms as c,Ns as d,Os as e,Ps as f,Qs as g,Rs as h,Ss as i,Ts as j,Us as k,Vs as l,Ws as m}from"./chunk-qfsktf7s.js";import"./chunk-80qre9zp.js";import"./chunk-8rn5e39c.js";export{f as resolveUserCrosswindConfig,c as resetCssCache,d as resetCrosswindCache,i as rebuildCrosswindCSS,e as loadCrosswindConfig,b as loadCrosswind,m as injectCrosswindCSS,a as getCrosswindServeAsset,j as getCachedCSS,l as generateCrosswindCSS,g as fingerprintConfig,k as extractClassNames,h as buildCrosswindCSS};
2
+ import{Ks as a,Ls as b,Ms as c,Ns as d,Os as e,Ps as f,Qs as g,Rs as h,Ss as i,Ts as j,Us as k,Vs as l,Ws as m}from"./chunk-8j2v2hnc.js";import"./chunk-80qre9zp.js";import"./chunk-8rn5e39c.js";export{f as resolveUserCrosswindConfig,c as resetCssCache,d as resetCrosswindCache,i as rebuildCrosswindCSS,e as loadCrosswindConfig,b as loadCrosswind,m as injectCrosswindCSS,a as getCrosswindServeAsset,j as getCachedCSS,l as generateCrosswindCSS,g as fingerprintConfig,k as extractClassNames,h as buildCrosswindCSS};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Yi as a,Zi as b}from"./chunk-ansvb340.js";import"./chunk-efr3ejqt.js";import"./chunk-pbyxj0zr.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-8j2v2hnc.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kwpvv59c.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{a as getStoreScript,b as clearStoreCache};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$r as d,Yr as a,Zr as b,_r as c,as as e,bs as f}from"./chunk-pzcf36xm.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-qfsktf7s.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kdpy5rgk.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{f as validateConfig,b as resolveStxDirectories,c as loadStxConfig,e as defineStxConfig,a as defaultConfig,d as config};
2
+ import{$r as d,Yr as a,Zr as b,_r as c,as as e,bs as f}from"./chunk-pbyxj0zr.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-8j2v2hnc.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kwpvv59c.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{f as validateConfig,b as resolveStxDirectories,c as loadStxConfig,e as defineStxConfig,a as defaultConfig,d as config};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{nq as a,oq as b,pq as c,qq as d,rq as e,sq as f,tq as g,uq as h,vq as i,wq as j,xq as k}from"./chunk-pzcf36xm.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-qfsktf7s.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kdpy5rgk.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{a as scanScriptTags,k as rewriteStxImportSpecifiers,i as processSignals,g as processScriptSetup,e as preEvalLiteralReactiveIfs,b as parseLoopExpression,c as hasSignalsSyntax,j as findMarkupIndexOutsideScripts,h as extractExports,f as convertSignalLoopsToAttributes,d as convertSignalDirectivesToAttributes};
2
+ import{nq as a,oq as b,pq as c,qq as d,rq as e,sq as f,tq as g,uq as h,vq as i,wq as j,xq as k}from"./chunk-pbyxj0zr.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-8j2v2hnc.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kwpvv59c.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{a as scanScriptTags,k as rewriteStxImportSpecifiers,i as processSignals,g as processScriptSetup,e as preEvalLiteralReactiveIfs,b as parseLoopExpression,c as hasSignalsSyntax,j as findMarkupIndexOutsideScripts,h as extractExports,f as convertSignalLoopsToAttributes,d as convertSignalDirectivesToAttributes};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{qf as a}from"./chunk-m8kn995q.js";import"./chunk-yf4p02wy.js";import"./chunk-pbyxj0zr.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-8j2v2hnc.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kwpvv59c.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{a as startProductionServer};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{bj as _,cj as v,dj as U}from"./chunk-efr3ejqt.js";import{Jq as T,Ml as C,Nl as N,Ol as E,_r as S}from"./chunk-pzcf36xm.js";import{tt as y}from"./chunk-ry86fd41.js";import L from"path";var j=new Map,M=new Map,b=["composables","functions"];function K(V){let J=L.basename(V,".ts");return J==="index"||J==="types"||V.endsWith(".d.ts")}async function F(V){if(V)return L.resolve(V);let J=`<default>:${process.cwd()}`,Q=M.get(J);if(Q!==void 0)return Q;let z=await h();if(z!==null)M.set(J,z);return z}async function h(){let V=await S(),J=V.root||process.cwd(),Q=V.composablesDir;if(Q)return L.resolve(J,Q);for(let z of b){let Z=L.resolve(J,z);try{let W=new Bun.Glob("**/*.ts");for await(let Y of W.scan({cwd:Z,absolute:!0}))if(!K(Y))return Z}catch{}}return null}async function s(V){let J=await F(V);if(!J)return[];let Q=[];try{let W=new Bun.Glob("**/*.ts");for await(let Y of W.scan({cwd:J,absolute:!0}))if(!K(Y))Q.push(Y)}catch{return[]}Q.sort();let z=T({loader:"ts",target:"browser",define:E()}),Z=[];for(let W of Q)try{let Y=await Bun.file(W).text(),G=z.scan(Y).exports.filter(($)=>$!=="default");if(G.length>0)Z.push({file:W,names:G})}catch{}return Z}function u(V,J){return new RegExp(`\\b${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(V)}function f(V,J,Q){let z=new Map;for(let{file:G,names:$}of V)for(let O of $)if(!z.has(O))z.set(O,G);let Z=(G)=>{let $=[];for(let[O,P]of z)if(u(G,O))$.push(P);return $},W=new Set,Y=Z(Q);while(Y.length>0){let G=[];for(let $ of Y){if(W.has($))continue;W.add($);for(let O of Z(J.get($)??""))if(!W.has(O))G.push(O)}Y=G}return W}async function i(V,J){let Q=await F(V);if(!Q)return null;let z=[];try{let q=new Bun.Glob("**/*.ts");for await(let H of q.scan({cwd:Q,absolute:!0})){if(K(H))continue;z.push(H)}}catch{return U(j,Q,"",""),null}let Z=_(z);if(z.length===0)return U(j,Q,Z,""),null;z.sort();let W=T({loader:"ts",target:"browser",define:E()}),Y=new Map,G=[];for(let q of z)try{let H=await Bun.file(q).text();Y.set(q,H);let w=W.scan(H).exports.filter((X)=>X!=="default");if(w.length>0)G.push({file:q,names:w})}catch{Y.set(q,"")}let $=J===void 0?new Set(z):f(G,Y,J);if($.size===0)return null;let O=z.filter((q)=>$.has(q)),P=`${Q}\x00${O.join("\x00")}`,B=v(j,P,Z);if(B!==void 0)return B||null;let A=[],R=new Set,I=new Set;for(let q of O)try{let H=Y.get(q)??await Bun.file(q).text(),w=L.basename(q,".ts");for(let X of H.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(X[1])I.add(X[1]);try{for(let X of W.scan(H).exports)if(X!=="default")R.add(X)}catch{}H=C(H),H=N(H),H=H.replace(/^export\s+(default\s+)?/gm,""),H=W.transformSync(H),A.push(`// Composable: ${w}
2
+ import{bj as _,cj as v,dj as U}from"./chunk-efr3ejqt.js";import{Jq as T,Ml as C,Nl as N,Ol as E,_r as S}from"./chunk-pbyxj0zr.js";import{tt as y}from"./chunk-ry86fd41.js";import L from"path";var j=new Map,M=new Map,b=["composables","functions"];function K(V){let J=L.basename(V,".ts");return J==="index"||J==="types"||V.endsWith(".d.ts")}async function F(V){if(V)return L.resolve(V);let J=`<default>:${process.cwd()}`,Q=M.get(J);if(Q!==void 0)return Q;let z=await h();if(z!==null)M.set(J,z);return z}async function h(){let V=await S(),J=V.root||process.cwd(),Q=V.composablesDir;if(Q)return L.resolve(J,Q);for(let z of b){let Z=L.resolve(J,z);try{let W=new Bun.Glob("**/*.ts");for await(let Y of W.scan({cwd:Z,absolute:!0}))if(!K(Y))return Z}catch{}}return null}async function s(V){let J=await F(V);if(!J)return[];let Q=[];try{let W=new Bun.Glob("**/*.ts");for await(let Y of W.scan({cwd:J,absolute:!0}))if(!K(Y))Q.push(Y)}catch{return[]}Q.sort();let z=T({loader:"ts",target:"browser",define:E()}),Z=[];for(let W of Q)try{let Y=await Bun.file(W).text(),G=z.scan(Y).exports.filter(($)=>$!=="default");if(G.length>0)Z.push({file:W,names:G})}catch{}return Z}function u(V,J){return new RegExp(`\\b${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(V)}function f(V,J,Q){let z=new Map;for(let{file:G,names:$}of V)for(let O of $)if(!z.has(O))z.set(O,G);let Z=(G)=>{let $=[];for(let[O,P]of z)if(u(G,O))$.push(P);return $},W=new Set,Y=Z(Q);while(Y.length>0){let G=[];for(let $ of Y){if(W.has($))continue;W.add($);for(let O of Z(J.get($)??""))if(!W.has(O))G.push(O)}Y=G}return W}async function i(V,J){let Q=await F(V);if(!Q)return null;let z=[];try{let q=new Bun.Glob("**/*.ts");for await(let H of q.scan({cwd:Q,absolute:!0})){if(K(H))continue;z.push(H)}}catch{return U(j,Q,"",""),null}let Z=_(z);if(z.length===0)return U(j,Q,Z,""),null;z.sort();let W=T({loader:"ts",target:"browser",define:E()}),Y=new Map,G=[];for(let q of z)try{let H=await Bun.file(q).text();Y.set(q,H);let w=W.scan(H).exports.filter((X)=>X!=="default");if(w.length>0)G.push({file:q,names:w})}catch{Y.set(q,"")}let $=J===void 0?new Set(z):f(G,Y,J);if($.size===0)return null;let O=z.filter((q)=>$.has(q)),P=`${Q}\x00${O.join("\x00")}`,B=v(j,P,Z);if(B!==void 0)return B||null;let A=[],R=new Set,I=new Set;for(let q of O)try{let H=Y.get(q)??await Bun.file(q).text(),w=L.basename(q,".ts");for(let X of H.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(X[1])I.add(X[1]);try{for(let X of W.scan(H).exports)if(X!=="default")R.add(X)}catch{}H=C(H),H=N(H),H=H.replace(/^export\s+(default\s+)?/gm,""),H=W.transformSync(H),A.push(`// Composable: ${w}
3
3
  ${H.trim()}`)}catch(H){console.warn(`[stx] Failed to load composable ${q}:`,H)}if(A.length===0||R.size===0)return U(j,P,Z,""),null;let D=[...R].map((q)=>` try { __c[${JSON.stringify(q)}] = ${q}; } catch (e) {}`).join(`
4
4
  `),g=JSON.stringify([...R]),k=A.join(`
5
5
 
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{jh as a,kh as b,lh as c,mh as d,nh as e,oh as f}from"./chunk-4svjne4w.js";import"./chunk-pzcf36xm.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-qfsktf7s.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kdpy5rgk.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{c as renderSlot,d as processSlots,a as parseSlots,b as parseSlotElement,e as extractSlotContent,f as applySlots};
2
+ import{jh as a,kh as b,lh as c,mh as d,nh as e,oh as f}from"./chunk-bg595da5.js";import"./chunk-pbyxj0zr.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-8j2v2hnc.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kwpvv59c.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{c as renderSlot,d as processSlots,a as parseSlots,b as parseSlotElement,e as extractSlotContent,f as applySlots};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{kk as a,lk as b,mk as c,nk as d}from"./chunk-e890s5em.js";import"./chunk-fw5d1aev.js";import"./chunk-pzcf36xm.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-qfsktf7s.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kdpy5rgk.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
2
+ import{kk as a,lk as b,mk as c,nk as d}from"./chunk-7cqda8w2.js";import"./chunk-egpmwqas.js";import"./chunk-pbyxj0zr.js";import"./chunk-kvz7rg2x.js";import"./chunk-arnse15r.js";import"./chunk-6b0xz02h.js";import"./chunk-135mme4g.js";import"./chunk-8j2v2hnc.js";import"./chunk-80qre9zp.js";import"./chunk-z794cdmn.js";import"./chunk-dykhpgyx.js";import"./chunk-ry86fd41.js";import"./chunk-kwpvv59c.js";import"./chunk-x0bcc9sj.js";import"./chunk-8rn5e39c.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{vu as Ae,wu as u}from"./chunk-8rn5e39c.js";function _(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>m.includes(a))}function g(e){return _(e.replace(/^\//,""))}var m;var b=u(()=>{m=["components","layouts","partials","emails"]});import d from"fs";import y from"path";function x(e,t){let a=e.filter((o)=>!g(o.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let o of a){let i=[];for(let c of o.params){let f=o.pattern.includes(`:${c}?`)?"?":"";i.push(`${c}${f}: string`)}let l=i.join("; ");r.push(` '${o.pattern}': { ${l} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
3
- `),s=y.join(t,"route-types.d.ts");try{if(d.existsSync(s)&&d.readFileSync(s,"utf8")===n)return;d.mkdirSync(t,{recursive:!0}),d.writeFileSync(s,n)}catch{}}function S(e,t,a){let r=process.cwd(),n=y.relative(r,a),s=e.filter((i)=>!g(i.pattern)),o=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let i of s){let l=y.relative(r,i.filePath).replace(/\\/g,"/"),c=JSON.stringify(i.params),f=i.layout?`, layout: '${y.relative(r,i.layout).replace(/\\/g,"/")}'`:"";o.push(` { pattern: '${i.pattern}', filePath: '${l}', isDynamic: ${i.isDynamic}, params: ${c}${f} },`)}o.push("] as const",""),o.push("export type RouteName = typeof routes[number]['pattern']",""),d.mkdirSync(t,{recursive:!0}),d.writeFileSync(y.join(t,"routes.ts"),o.join(`
4
- `))}var F=u(()=>{b()});import V from"path";function k(e,t){let r=V.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(V.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function v(e){let t=[],a="",r=0;while(r<e.length){let n=e.slice(r),s=/^\/:([^/?*]+)\?/.exec(n);if(s){t.push(s[1]),a+="(?:/([^/]+))?",r+=s[0].length;continue}let o=/^:([^/?*]+)\*/.exec(n);if(o){t.push(o[1]),a+="(.+)",r+=o[0].length;continue}let i=/^:([^/?*]+)/.exec(n);if(i){t.push(i[1]),a+="([^/]+)",r+=i[0].length;continue}a+=e[r].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),r+=1}return{regex:new RegExp(`^${a}$`),params:t}}function W(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let s={};return r.params.forEach((o,i)=>{s[o]=n[i+1]}),{route:r,params:s}}}return null}function D(e){let t=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return v(t)}var I=()=>{};import xe from"fs";import M from"path";function A(e,t){let a=[],r=M.dirname(e);while(r.startsWith(t)||r===t){let n=M.join(r,"_layout.stx");if(xe.existsSync(n))a.unshift(n);if(r===t)break;r=M.dirname(r)}return a}var N=()=>{};import P from"fs";import h from"path";function K(e,t){let a=[];if(!P.existsSync(e))return a;let r=P.readdirSync(e,{withFileTypes:!0});for(let n of r){let s=h.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(m.includes(n.name))continue;a.push(...K(s,t))}else if(n.isFile()){let o=h.extname(n.name);if(t.includes(o)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(s)}}}return a}class C{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((o)=>h.resolve(e,o)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=new Set;this.routes=[];for(let o of this.pagesDirs){let i=K(o,r);for(let l of i){let c=k(l,o);if(n.has(c))continue;n.add(c);let{regex:f,params:H}=v(c),O=t.layouts!==!1?A(l,o):[];this.routes.push({pattern:c,regex:f,params:H,filePath:l,isDynamic:H.length>0,layout:O.length>0?O[O.length-1]:void 0})}}this.routes.sort((o,i)=>{if(!o.isDynamic&&i.isDynamic)return-1;if(o.isDynamic&&!i.isDynamic)return 1;let l=o.pattern.split("/").length,c=i.pattern.split("/").length;if(l!==c)return c-l;return o.pattern.localeCompare(i.pattern)});let s=h.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");x(this.routes,s),S(this.routes,s,this.pagesDir)}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((s,o)=>{n[s]=r[o+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,s]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(s));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function $(e,t){return new C(e,t)}function z(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=h.join(e,r);if(P.existsSync(n))return n}return null}function Y(e,t){return e.map((a)=>{let r=h.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var J=u(()=>{F();I();N();b()});function Z(e){T=e.replace(/\/$/,"")}function Q(e,t,a={}){p[e]={path:t,name:e,params:a}}function ee(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")p[t]={path:a,name:t};else p[t]={...a,name:t}}function te(e,t={},a=!1){let r=p[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},s=r.path;s=s.replace(/:(\w+)/g,(i,l)=>{let c=n[l];if(c===void 0)return console.warn(`Missing parameter [${l}] for route [${e}].`),`:${l}`;return delete n[l],encodeURIComponent(String(c))});let o=Object.entries(n);if(o.length>0){let i=o.map(([l,c])=>`${encodeURIComponent(l)}=${encodeURIComponent(String(c))}`).join("&");s+=(s.includes("?")?"&":"?")+i}return a&&T?`${T}${s}`:s}function re(){for(let e of Object.keys(p))delete p[e];T=""}var p,T="";var ae=u(()=>{p={}});import ne from"fs";import oe from"path";function se(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function ie(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function le(e,t={}){return{handler:e,mode:t.mode??"universal"}}function G(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...s]=r.split("=");if(n){let o=n.trim(),i=s.join("=").trim();if(o)t[o]=decodeURIComponent(i)}}return t}function E(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function B(e,t){let a=e.headers.get("cookie")||"",r=G(a);return{get(n){return r[n]},set(n,s,o={}){r[n]=s,t.append("Set-Cookie",E(n,s,o))},delete(n){delete r[n],t.append("Set-Cookie",E(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function X(){return{get(e){if(typeof document>"u")return;return G(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=E(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=E(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return G(document.cookie)}}}function U(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}function R(e,t){w.set(e,t)}function j(e){return w.get(e)}function ce(e){return w.has(e)}function ue(){w.clear()}function de(){return Array.from(w.keys())}async function he(e,t="middleware"){let a=oe.resolve(e,t);if(!ne.existsSync(a))return;let r=ne.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let s=n.replace(/\.(ts|js)$/,""),o=oe.join(a,n);try{let l=(await import(o)).default;if(l&&typeof l.handler==="function")R(s,l);else if(typeof l==="function")R(s,{handler:l,mode:"universal"})}catch(i){console.warn(`Failed to load middleware '${s}' from ${o}:`,i)}}}function Se(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function pe(e,t,a,r=""){return{path:e,params:t,query:Se(r),fullPath:r?`${e}?${r}`:e,meta:a}}function fe(e,t,a,r){let n=r?.isServer??typeof window>"u",s=!n,o=new Headers;return{to:e,from:t,isClient:s,isServer:n,cookies:n&&a?B(a,o):X(),storage:U(),state:{},request:a,responseHeaders:o}}async function me(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let s=j(n);if(!s)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(s.mode==="server"&&!r)continue;try{let o=await s.handler(t);if(o){if(o.type==="redirect")return{passed:!1,redirect:o,state:t.state,responseHeaders:t.responseHeaders};if(o.type==="abort")return{passed:!1,abort:o,state:t.state,responseHeaders:t.responseHeaders}}}catch(o){return console.error(`Error in middleware '${n}':`,o),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:o instanceof Error?o.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}var w;var ge=u(()=>{w=new Map});function q(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function ye(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||q(n)}}var ve=()=>{};function ke(e){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function we(){if(L)return L;return L=ke(`
2
+ import{vu as Ae,wu as u}from"./chunk-8rn5e39c.js";function _(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>m.includes(a))}function g(e){return _(e.replace(/^\//,""))}var m;var b=u(()=>{m=["components","layouts","partials","emails"]});import d from"fs";import y from"path";function x(e,t){let a=e.filter((o)=>!g(o.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let o of a){let s=[];for(let c of o.params){let f=o.pattern.includes(`:${c}?`)?"?":"";s.push(`${c}${f}: string`)}let l=s.join("; ");r.push(` '${o.pattern}': { ${l} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
3
+ `),i=y.join(t,"route-types.d.ts");try{if(d.existsSync(i)&&d.readFileSync(i,"utf8")===n)return;d.mkdirSync(t,{recursive:!0}),d.writeFileSync(i,n)}catch{}}function S(e,t,a){let r=process.cwd(),n=y.relative(r,a),i=e.filter((s)=>!g(s.pattern)),o=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let s of i){let l=y.relative(r,s.filePath).replace(/\\/g,"/"),c=JSON.stringify(s.params),f=s.layout?`, layout: '${y.relative(r,s.layout).replace(/\\/g,"/")}'`:"";o.push(` { pattern: '${s.pattern}', filePath: '${l}', isDynamic: ${s.isDynamic}, params: ${c}${f} },`)}o.push("] as const",""),o.push("export type RouteName = typeof routes[number]['pattern']",""),d.mkdirSync(t,{recursive:!0}),d.writeFileSync(y.join(t,"routes.ts"),o.join(`
4
+ `))}var F=u(()=>{b()});import V from"path";function k(e,t){let r=V.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(V.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function v(e){let t=[],a="",r=0;while(r<e.length){let n=e.slice(r),i=/^\/:([^/?*]+)\?/.exec(n);if(i){t.push(i[1]),a+="(?:/([^/]+))?",r+=i[0].length;continue}let o=/^:([^/?*]+)\*/.exec(n);if(o){t.push(o[1]),a+="(.+)",r+=o[0].length;continue}let s=/^:([^/?*]+)/.exec(n);if(s){t.push(s[1]),a+="([^/]+)",r+=s[0].length;continue}a+=e[r].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),r+=1}return{regex:new RegExp(`^${a}$`),params:t}}function W(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let i={};return r.params.forEach((o,s)=>{i[o]=n[s+1]}),{route:r,params:i}}}return null}function D(e){let t=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return v(t)}var I=()=>{};import xe from"fs";import M from"path";function A(e,t){let a=[],r=M.dirname(e);while(r.startsWith(t)||r===t){let n=M.join(r,"_layout.stx");if(xe.existsSync(n))a.unshift(n);if(r===t)break;r=M.dirname(r)}return a}var N=()=>{};import P from"fs";import h from"path";function K(e,t){let a=[];if(!P.existsSync(e))return a;let r=P.readdirSync(e,{withFileTypes:!0});for(let n of r){let i=h.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(m.includes(n.name))continue;a.push(...K(i,t))}else if(n.isFile()){let o=h.extname(n.name);if(t.includes(o)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(i)}}}return a}class C{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((o)=>h.resolve(e,o)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=new Set;this.routes=[];for(let o of this.pagesDirs){let s=K(o,r);for(let l of s){let c=k(l,o);if(n.has(c))continue;n.add(c);let{regex:f,params:H}=v(c),O=t.layouts!==!1?A(l,o):[];this.routes.push({pattern:c,regex:f,params:H,filePath:l,isDynamic:H.length>0,layout:O.length>0?O[O.length-1]:void 0})}}this.routes.sort((o,s)=>{if(!o.isDynamic&&s.isDynamic)return-1;if(o.isDynamic&&!s.isDynamic)return 1;let l=o.pattern.split("/").length,c=s.pattern.split("/").length;if(l!==c)return c-l;return o.pattern.localeCompare(s.pattern)});let i=h.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");x(this.routes,i),S(this.routes,i,this.pagesDir)}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((i,o)=>{n[i]=r[o+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,i]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(i));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function z(e,t){return new C(e,t)}function $(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=h.join(e,r);if(P.existsSync(n))return n}return null}function Y(e,t){return e.map((a)=>{let r=h.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var J=u(()=>{F();I();N();b()});function Z(e){T=e.replace(/\/$/,"")}function Q(e,t,a={}){p[e]={path:t,name:e,params:a}}function ee(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")p[t]={path:a,name:t};else p[t]={...a,name:t}}function te(e,t={},a=!1){let r=p[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},i=r.path;i=i.replace(/:(\w+)/g,(s,l)=>{let c=n[l];if(c===void 0)return console.warn(`Missing parameter [${l}] for route [${e}].`),`:${l}`;return delete n[l],encodeURIComponent(String(c))});let o=Object.entries(n);if(o.length>0){let s=o.map(([l,c])=>`${encodeURIComponent(l)}=${encodeURIComponent(String(c))}`).join("&");i+=(i.includes("?")?"&":"?")+s}return a&&T?`${T}${i}`:i}function re(){for(let e of Object.keys(p))delete p[e];T=""}var p,T="";var ae=u(()=>{p={}});import ne from"fs";import oe from"path";function ie(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function se(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function le(e,t={}){return{handler:e,mode:t.mode??"universal"}}function G(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...i]=r.split("=");if(n){let o=n.trim(),s=i.join("=").trim();if(o)t[o]=decodeURIComponent(s)}}return t}function E(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function B(e,t){let a=e.headers.get("cookie")||"",r=G(a);return{get(n){return r[n]},set(n,i,o={}){r[n]=i,t.append("Set-Cookie",E(n,i,o))},delete(n){delete r[n],t.append("Set-Cookie",E(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function X(){return{get(e){if(typeof document>"u")return;return G(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=E(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=E(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return G(document.cookie)}}}function U(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}function R(e,t){w.set(e,t)}function j(e){return w.get(e)}function ce(e){return w.has(e)}function ue(){w.clear()}function de(){return Array.from(w.keys())}async function he(e,t="middleware"){let a=oe.resolve(e,t);if(!ne.existsSync(a))return;let r=ne.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let i=n.replace(/\.(ts|js)$/,""),o=oe.join(a,n);try{let l=(await import(o)).default;if(l&&typeof l.handler==="function")R(i,l);else if(typeof l==="function")R(i,{handler:l,mode:"universal"})}catch(s){console.warn(`Failed to load middleware '${i}' from ${o}:`,s)}}}function Se(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function pe(e,t,a,r=""){return{path:e,params:t,query:Se(r),fullPath:r?`${e}?${r}`:e,meta:a}}function fe(e,t,a,r){let n=r?.isServer??typeof window>"u",i=!n,o=new Headers;return{to:e,from:t,isClient:i,isServer:n,cookies:n&&a?B(a,o):X(),storage:U(),state:{},request:a,responseHeaders:o}}async function me(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let i=j(n);if(!i)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(i.mode==="server"&&!r)continue;try{let o=await i.handler(t);if(o){if(o.type==="redirect")return{passed:!1,redirect:o,state:t.state,responseHeaders:t.responseHeaders};if(o.type==="abort")return{passed:!1,abort:o,state:t.state,responseHeaders:t.responseHeaders}}}catch(o){return console.error(`Error in middleware '${n}':`,o),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:o instanceof Error?o.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}var w;var ge=u(()=>{w=new Map});function q(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function ye(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||q(n)}}var ve=()=>{};function ke(e){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function we(){if(L)return L;return L=ke(`
5
5
  ;(function(){
6
6
  'use strict';
7
7
  var ROUTER_REV=7;
@@ -1541,9 +1541,28 @@ else {
1541
1541
  var isActive=href!=='/'?cur.startsWith(href):cur==='/';
1542
1542
  if(isExact)eac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
1543
1543
  if(isActive)ac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
1544
+ markCurrent(link,isExact);
1544
1545
  });
1545
1546
  }
1546
1547
 
1548
+ // aria-current="page" names the page the user is ON, so it has to move when
1549
+ // the page does. The server stamps it on the link for the page it rendered;
1550
+ // after that, only a full load would ever correct it, and a fragment swap is
1551
+ // not a full load. Left alone, a screen reader announces the entry the user
1552
+ // arrived through as current for the rest of the session, however far they
1553
+ // navigate \u2014 silently wrong, and only to the people relying on it.
1554
+ //
1555
+ // Only ever touched on links that already carry the attribute or are the
1556
+ // current one, so a page using aria-current for something else \u2014 a step in a
1557
+ // wizard, a sort direction \u2014 is not rewritten out from under itself.
1558
+ function markCurrent(link,isExact){
1559
+ if(isExact){
1560
+ if(link.getAttribute('aria-current')!=='page')link.setAttribute('aria-current','page');
1561
+ return;
1562
+ }
1563
+ if(link.getAttribute('aria-current')==='page')link.removeAttribute('aria-current');
1564
+ }
1565
+
1547
1566
  // \u2500\u2500 Progress bar DOM + style \u2500\u2500
1548
1567
  // Injects a fixed-position element at the top of the viewport plus the
1549
1568
  // minimal CSS for its transform/opacity transitions. Kept idempotent so
@@ -1651,5 +1670,5 @@ else {
1651
1670
 
1652
1671
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
1653
1672
  })();
1654
- `),L}var L;var be=()=>{};var Ce={};Ae(Ce,{setAppUrl:()=>Z,runMiddleware:()=>me,route:()=>te,resolveLayoutChain:()=>A,resetRoutes:()=>re,registerMiddleware:()=>R,patternToRegex:()=>v,navigateTo:()=>se,matchRoute:()=>W,loadMiddlewareFromDirectory:()=>he,isNonPageRoutePattern:()=>g,isNonPageRoutePath:()=>_,hasMiddleware:()=>ce,getRouterScript:()=>we,getMiddlewareNames:()=>de,getMiddleware:()=>j,generateRouteTypes:()=>x,generateRouteManifest:()=>S,formatRoutes:()=>Y,findErrorPage:()=>z,filePathToPattern:()=>k,extractLayoutMetadata:()=>ye,deriveLayoutGroup:()=>q,defineRoutes:()=>ee,defineRoute:()=>Q,defineMiddleware:()=>le,createStorageManager:()=>U,createServerCookieManager:()=>B,createRouter:()=>$,createRouteLocation:()=>pe,createMiddlewareContext:()=>fe,createClientCookieManager:()=>X,clearMiddleware:()=>ue,bracketPathToRegex:()=>D,abortNavigation:()=>ie,Router:()=>C,NON_PAGE_DIRS:()=>m});var Te=u(()=>{J();I();ae();ge();N();ve();F();b();be()});
1655
- export{m as Ct,_ as Dt,g as Et,x as Ft,S as Gt,k as Ht,v as It,W as Jt,D as Kt,A as Lt,C as Mt,$ as Nt,z as Ot,Y as Pt,Z as Qt,Q as Rt,ee as St,te as Tt,re as Ut,se as Vt,ie as Wt,le as Xt,B as Yt,X as Zt,U as _t,R as $t,j as au,ce as bu,ue as cu,de as du,he as eu,pe as fu,fe as gu,me as hu,q as iu,ye as ju,ve as ku,we as lu,Ce as mu,Te as nu};
1673
+ `),L}var L;var be=()=>{};var Ce={};Ae(Ce,{setAppUrl:()=>Z,runMiddleware:()=>me,route:()=>te,resolveLayoutChain:()=>A,resetRoutes:()=>re,registerMiddleware:()=>R,patternToRegex:()=>v,navigateTo:()=>ie,matchRoute:()=>W,loadMiddlewareFromDirectory:()=>he,isNonPageRoutePattern:()=>g,isNonPageRoutePath:()=>_,hasMiddleware:()=>ce,getRouterScript:()=>we,getMiddlewareNames:()=>de,getMiddleware:()=>j,generateRouteTypes:()=>x,generateRouteManifest:()=>S,formatRoutes:()=>Y,findErrorPage:()=>$,filePathToPattern:()=>k,extractLayoutMetadata:()=>ye,deriveLayoutGroup:()=>q,defineRoutes:()=>ee,defineRoute:()=>Q,defineMiddleware:()=>le,createStorageManager:()=>U,createServerCookieManager:()=>B,createRouter:()=>z,createRouteLocation:()=>pe,createMiddlewareContext:()=>fe,createClientCookieManager:()=>X,clearMiddleware:()=>ue,bracketPathToRegex:()=>D,abortNavigation:()=>se,Router:()=>C,NON_PAGE_DIRS:()=>m});var Te=u(()=>{J();I();ae();ge();N();ve();F();b();be()});
1674
+ export{m as Ct,_ as Dt,g as Et,x as Ft,S as Gt,k as Ht,v as It,W as Jt,D as Kt,A as Lt,C as Mt,z as Nt,$ as Ot,Y as Pt,Z as Qt,Q as Rt,ee as St,te as Tt,re as Ut,ie as Vt,se as Wt,le as Xt,B as Yt,X as Zt,U as _t,R as $t,j as au,ce as bu,ue as cu,de as du,he as eu,pe as fu,fe as gu,me as hu,q as iu,ye as ju,ve as ku,we as lu,Ce as mu,Te as nu};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Bg as p}from"./chunk-ydk1n77q.js";import{Sg as a,Ug as JF,Vg as ZF,Wg as qF}from"./chunk-a4329ma8.js";import{Bj as C,Cj as D}from"./chunk-ad84gwgv.js";import{Ck as QF,Dk as XF,Ek as YF}from"./chunk-c0n802j1.js";import{Bq as c,Km as u,Pp as o,Yr as n,_r as N,bm as l,bq as e,dm as d,iq as t,jq as FF}from"./chunk-pzcf36xm.js";import{Ws as r}from"./chunk-qfsktf7s.js";import{lu as S,nu as WF}from"./chunk-kdpy5rgk.js";import G from"fs";import Z from"path";import{createHash as $F}from"crypto";WF();function g(J){return $F("sha256").update(J).digest("hex").slice(0,8)}function f(J=!1){let q=J?D():C(),z=g(q);return{content:q,filename:`runtime.${z}.js`,hash:z}}function m(){let J=S(),q=g(J);return{content:J,filename:`router.${q}.js`,hash:q}}function UF(J){return{runtimeTag:J.runtime?`<script src="/__stx/${J.runtime.filename}"></script>`:"",routerTag:J.router?`<script src="/__stx/${J.router.filename}"></script>`:"",cssTag:J.css?`<link rel="stylesheet" href="/__stx/${J.css.filename}">`:""}}import h from"path";import{createHash as GF}from"crypto";function VF(J={}){let q=new Set;return{context:new Proxy(J,{get(Q,X){if(X in Q)return Q[X];if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return},has(Q,X){if(X in Q)return!0;if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return!1}}),accessedKeys:q}}async function i(J,q,z={}){let Q=h.resolve(J),X=await Bun.file(Q).text(),I=GF("sha256").update(X).digest("hex").slice(0,16);l();let K={};try{K=await N()}catch{}let B=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(X))!==null){let $=k[1];if(/\bserver\b/.test($))B.push(k[2])}let W=new Set(B.flatMap(($)=>p($))),{context:E}=VF({__filename:Q,__dirname:h.dirname(Q),__stx_serverDeclared:W}),L=new Set,_={...n,...K,...z,buildMode:"compile",strict:!1},w=await c(X,E,Q,_,L),U=a(w),H=d();return{route:q,sourceFile:J,html:w,fragment:U,placeholders:H,hasServerScripts:B.length>0,serverScriptContent:B,dependencies:Array.from(L),contentHash:I,status:u(X),streamTemplates:E.__streamTemplates}}var kF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function s(J,q){let z=0,Q=0;if(!G.existsSync(J))return{copied:z,bytes:Q};G.mkdirSync(q,{recursive:!0});function X(I,K){let B=G.readdirSync(I,{withFileTypes:!0});for(let V of B){if(kF.has(V.name))continue;let k=Z.join(I,V.name),W=Z.join(K,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),X(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),z++,Q+=G.statSync(W).size}}}return X(J,q),{copied:z,bytes:Q}}async function lF(J={}){let q=Date.now(),z=Z.resolve(J.root||process.cwd()),Q=Z.resolve(z,J.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await N()}catch{}let I=J.componentsDir??X.componentsDir??"components",K=J.partialsDir??X.partialsDir??"partials",B=J.layoutsDir??X.layoutsDir??"layouts",V=J.publicDir??X.publicDir??"public",k=X.app?.head||{},W=X.app?.colorMode,E=X.router?.container||"main";if(G.existsSync(Q))G.rmSync(Q,{recursive:!0});let L=[Z.join(Q,"public","__stx"),Z.join(Q,"public","assets"),Z.join(Q,"server","pages"),Z.join(Q,"server","fragments")];for(let Y of L)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let _=FF(z),w=["components","layouts","partials"],U=_.filter((Y)=>{return!w.some((F)=>Y.pattern.startsWith(`/${F}/`)||Y.pattern===`/${F}`)});console.log(`[stx build] Found ${U.length} page routes (${_.length-U.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=f(J.debug),$=m();await Bun.write(Z.join(Q,"public","__stx",H.filename),H.content),await Bun.write(Z.join(Q,"public","__stx",$.filename),$.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${$.filename} (${($.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],j=[];for(let Y of U)try{let F=await i(Y.filePath,Y.pattern,{componentsDir:I,partialsDir:K,layoutsDir:B,debug:J.debug});if(O.push(F),F.html=F.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,$.filename),F.html=t(F.html,k,{bodyScripts:[`<script src="/__stx/${$.filename}"></script>`],...W&&{colorMode:W}}),W)F.html=o(F.html,W);if(k.htmlAttrs)F.html=e(F.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(F.html)){let T=F.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(T&&T[1]){let P=T[1];F.html=F.html.replace(" "+P,""),F.html=F.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}F.html=F.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),F.html=await r(F.html),F.fragment=JF(F.html,E);let y=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),b=Z.join("server","pages",`${y}.compiled.json`),A=Z.join("server","fragments",`${y}.html`);await Bun.write(Z.join(Q,b),JSON.stringify(F,null,2)),await Bun.write(Z.join(Q,A),F.fragment),j.push({pattern:Y.pattern,compiledPath:b,fragmentPath:A,isDynamic:F.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("[")}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(F){console.error(`[stx build] \u2717 ${Y.pattern}:`,F instanceof Error?F.message:F)}let M=Z.resolve(z,V);if(G.existsSync(M)){let{copied:Y,bytes:F}=s(M,Z.join(Q,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${V}/`)}let v=YF(z);if(v){let{copied:Y,bytes:F}=s(v,Z.join(Q,"public",XF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${QF}/`)}let R={runtime:H.filename,router:$.filename},zF=ZF(j,R,Q);qF(zF,Q);let x=Date.now()-q;return console.log(`
2
+ import{Bg as p}from"./chunk-ydk1n77q.js";import{Sg as a,Ug as JF,Vg as ZF,Wg as qF}from"./chunk-yf4p02wy.js";import{Bj as C,Cj as D}from"./chunk-ad84gwgv.js";import{Ck as QF,Dk as XF,Ek as YF}from"./chunk-c0n802j1.js";import{Bq as c,Km as u,Pp as o,Yr as n,_r as N,bm as l,bq as e,dm as d,iq as t,jq as FF}from"./chunk-pbyxj0zr.js";import{Ws as r}from"./chunk-8j2v2hnc.js";import{lu as S,nu as WF}from"./chunk-kwpvv59c.js";import G from"fs";import Z from"path";import{createHash as $F}from"crypto";WF();function g(J){return $F("sha256").update(J).digest("hex").slice(0,8)}function f(J=!1){let q=J?D():C(),z=g(q);return{content:q,filename:`runtime.${z}.js`,hash:z}}function m(){let J=S(),q=g(J);return{content:J,filename:`router.${q}.js`,hash:q}}function UF(J){return{runtimeTag:J.runtime?`<script src="/__stx/${J.runtime.filename}"></script>`:"",routerTag:J.router?`<script src="/__stx/${J.router.filename}"></script>`:"",cssTag:J.css?`<link rel="stylesheet" href="/__stx/${J.css.filename}">`:""}}import h from"path";import{createHash as GF}from"crypto";function VF(J={}){let q=new Set;return{context:new Proxy(J,{get(Q,X){if(X in Q)return Q[X];if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return},has(Q,X){if(X in Q)return!0;if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return!1}}),accessedKeys:q}}async function i(J,q,z={}){let Q=h.resolve(J),X=await Bun.file(Q).text(),I=GF("sha256").update(X).digest("hex").slice(0,16);l();let K={};try{K=await N()}catch{}let B=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(X))!==null){let $=k[1];if(/\bserver\b/.test($))B.push(k[2])}let W=new Set(B.flatMap(($)=>p($))),{context:E}=VF({__filename:Q,__dirname:h.dirname(Q),__stx_serverDeclared:W}),L=new Set,_={...n,...K,...z,buildMode:"compile",strict:!1},w=await c(X,E,Q,_,L),U=a(w),H=d();return{route:q,sourceFile:J,html:w,fragment:U,placeholders:H,hasServerScripts:B.length>0,serverScriptContent:B,dependencies:Array.from(L),contentHash:I,status:u(X),streamTemplates:E.__streamTemplates}}var kF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function s(J,q){let z=0,Q=0;if(!G.existsSync(J))return{copied:z,bytes:Q};G.mkdirSync(q,{recursive:!0});function X(I,K){let B=G.readdirSync(I,{withFileTypes:!0});for(let V of B){if(kF.has(V.name))continue;let k=Z.join(I,V.name),W=Z.join(K,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),X(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),z++,Q+=G.statSync(W).size}}}return X(J,q),{copied:z,bytes:Q}}async function lF(J={}){let q=Date.now(),z=Z.resolve(J.root||process.cwd()),Q=Z.resolve(z,J.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await N()}catch{}let I=J.componentsDir??X.componentsDir??"components",K=J.partialsDir??X.partialsDir??"partials",B=J.layoutsDir??X.layoutsDir??"layouts",V=J.publicDir??X.publicDir??"public",k=X.app?.head||{},W=X.app?.colorMode,E=X.router?.container||"main";if(G.existsSync(Q))G.rmSync(Q,{recursive:!0});let L=[Z.join(Q,"public","__stx"),Z.join(Q,"public","assets"),Z.join(Q,"server","pages"),Z.join(Q,"server","fragments")];for(let Y of L)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let _=FF(z),w=["components","layouts","partials"],U=_.filter((Y)=>{return!w.some((F)=>Y.pattern.startsWith(`/${F}/`)||Y.pattern===`/${F}`)});console.log(`[stx build] Found ${U.length} page routes (${_.length-U.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=f(J.debug),$=m();await Bun.write(Z.join(Q,"public","__stx",H.filename),H.content),await Bun.write(Z.join(Q,"public","__stx",$.filename),$.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${$.filename} (${($.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],j=[];for(let Y of U)try{let F=await i(Y.filePath,Y.pattern,{componentsDir:I,partialsDir:K,layoutsDir:B,debug:J.debug});if(O.push(F),F.html=F.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,$.filename),F.html=t(F.html,k,{bodyScripts:[`<script src="/__stx/${$.filename}"></script>`],...W&&{colorMode:W}}),W)F.html=o(F.html,W);if(k.htmlAttrs)F.html=e(F.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(F.html)){let T=F.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(T&&T[1]){let P=T[1];F.html=F.html.replace(" "+P,""),F.html=F.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}F.html=F.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),F.html=await r(F.html),F.fragment=JF(F.html,E);let y=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),b=Z.join("server","pages",`${y}.compiled.json`),A=Z.join("server","fragments",`${y}.html`);await Bun.write(Z.join(Q,b),JSON.stringify(F,null,2)),await Bun.write(Z.join(Q,A),F.fragment),j.push({pattern:Y.pattern,compiledPath:b,fragmentPath:A,isDynamic:F.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("[")}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(F){console.error(`[stx build] \u2717 ${Y.pattern}:`,F instanceof Error?F.message:F)}let M=Z.resolve(z,V);if(G.existsSync(M)){let{copied:Y,bytes:F}=s(M,Z.join(Q,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${V}/`)}let v=YF(z);if(v){let{copied:Y,bytes:F}=s(v,Z.join(Q,"public",XF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${QF}/`)}let R={runtime:H.filename,router:$.filename},zF=ZF(j,R,Q);qF(zF,Q);let x=Date.now()-q;return console.log(`
3
3
  [stx build] Done in ${x}ms \u2014 ${O.length} pages compiled`),{pageCount:O.length,assets:R,outputDir:Q,duration:x}}
4
4
  export{g as rg,f as sg,m as tg,UF as ug,i as vg,lF as wg};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Lg as o,Mg as e,Og as b,Xg as JJ}from"./chunk-a4329ma8.js";import{Nm as m,Om as l,ap as g,fm as y,gm as P,lq as t,pm as v,wm as x}from"./chunk-pzcf36xm.js";import{It as a,ju as s,nu as OJ}from"./chunk-kdpy5rgk.js";import{xu as R}from"./chunk-8rn5e39c.js";import r from"fs";import B from"path";var{serve:IJ}=globalThis.Bun;function q(J,K,Q={}){let X=`${encodeURIComponent(J)}=${encodeURIComponent(K)}`;if(Q.maxAge!==void 0)X+=`; Max-Age=${Q.maxAge}`;if(Q.expires)X+=`; Expires=${Q.expires.toUTCString()}`;if(Q.path)X+=`; Path=${Q.path}`;if(Q.domain)X+=`; Domain=${Q.domain}`;if(Q.secure)X+="; Secure";if(Q.httpOnly)X+="; HttpOnly";if(Q.sameSite)X+=`; SameSite=${Q.sameSite}`;return X}async function KJ(J){let K=J.headers.get("content-type")||"",Q={},X=(Z,G)=>{let $=Q[Z];if($===void 0)Q[Z]=G;else if(Array.isArray($))$.push(G);else Q[Z]=[$,G]};if(K.includes("multipart/form-data")){let Z=await J.formData();for(let[G,$]of Z.entries())if(typeof $==="string")X(G,$);return Q}if(K.includes("application/x-www-form-urlencoded")){for(let[Z,G]of new URLSearchParams(await J.text()).entries())X(Z,G);return Q}return Q}function f(J){if(!J)return!1;let K=J.toUpperCase();return K!=="GET"&&K!=="HEAD"}async function h(J,K={}){let Q=K.request,X=K.method??Q?.method;if(!Q||!f(X))return{ran:!1};if(typeof J.action!=="function")return{ran:!1};let Z={};try{Z=await KJ(Q)}catch{}let G=await J.action({request:Q,form:Z,params:K.params??{},query:J.query??{},cookies:K.cookies??{}});if(G&&typeof G==="object"){let $=G,W=QJ($.cookies),I=$.redirect;if(typeof I==="string"&&I)return{redirect:I,ran:!0,...W.length>0?{cookies:W}:{}};let{cookies:_,redirect:w,...U}=$;if(Object.assign(J,U),W.length>0)return{ran:!0,cookies:W}}return{ran:!0}}function QJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return[];let K=[];for(let[Q,X]of Object.entries(J)){if(!Q)continue;if(typeof X==="string"){K.push(q(Q,X));continue}if(X&&typeof X==="object"){let Z=X;if(typeof Z.value!=="string")continue;K.push(q(Q,Z.value,Z))}}return K}function u(J,K=[]){let Q=new Headers({Location:J,"Cache-Control":"no-store"});for(let X of K)Q.append("Set-Cookie",X);return new Response(null,{status:303,headers:Q})}async function HJ(J,K={}){return(await c(J,K)).html}async function d(J,K={}){let{html:Q,context:X,redirect:Z,cookies:G}=await c(J,K),$=m(X),W=l(X);if(Z)return{html:Q,redirect:Z,cookies:G,status:$,headers:W};let{extractStreamBoundaries:I}=await import("./chunk-g3rg8afc.js"),_=I(X),w=J.streamTemplates;if(w&&Object.keys(w).length>0){let{processDirectives:U}=await import("./chunk-3zhhytkd.js"),{defaultConfig:z}=await import("./chunk-zpskp2xb.js"),O=X.streamBoundaries||{},N={...z,autoShell:!1},L=Object.keys(w).map((V)=>({id:V,render:async()=>{let D=typeof O[V]==="function"?await O[V]():void 0;return U(w[V],{...X,$boundary:D},J.sourceFile,N,new Set)}})),E=new Set(L.map((V)=>V.id));_=[...(_||[]).filter((V)=>!E.has(V.id)),...L]}return{html:Q,boundaries:_&&_.length>0?_:void 0,cookies:G,status:$,headers:W}}async function c(J,K){let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};if(!J.hasServerScripts&&!P(J.html))return{html:J.html,context:Q};for(let G of J.serverScriptContent)try{await g(G,Q,J.sourceFile)}catch($){console.warn(`[stx] Server script error in ${J.sourceFile}:`,$)}let X=await h(Q,{request:K.request,method:K.method,params:K.params??{},cookies:K.cookies??{}});if(X.redirect)return{html:J.html,context:Q,redirect:X.redirect,cookies:X.cookies};if(!P(J.html))return{html:J.html,context:Q,cookies:X.cookies};let Z=new Map;for(let[G,$]of Object.entries(J.placeholders))if($.expression)try{let W=x($.expression,Q);if($.type==="raw")Z.set(G,W!==void 0&&W!==null?String(W):"");else Z.set(G,W!==void 0&&W!==null?v(String(W)):"")}catch{Z.set(G,"")}return{html:y(J.html,Z),context:Q,cookies:X.cookies}}async function SJ(J,K={}){if(!J.hasServerScripts&&!P(J.fragment))return J.fragment;let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};for(let Z of J.serverScriptContent)try{await g(Z,Q,J.sourceFile)}catch(G){console.warn(`[stx] Server script error in ${J.sourceFile}:`,G)}if(!P(J.fragment))return J.fragment;let X=new Map;for(let[Z,G]of Object.entries(J.placeholders))if(G.expression)try{let $=x(G.expression,Q);if(G.type==="raw")X.set(Z,$!==void 0&&$!==null?String($):"");else X.set(Z,$!==void 0&&$!==null?v(String($)):"")}catch{X.set(Z,"")}return y(J.fragment,X)}OJ();import C from"zlib";import{promisify as n}from"util";var XJ=n(C.brotliCompress),ZJ=n(C.gzip),$J=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],GJ=["text/event-stream","multipart/x-mixed-replace"],UJ=1024;function WJ(J){if(!J)return!1;let K=J.toLowerCase();if(GJ.some((Q)=>K.startsWith(Q)))return!1;return $J.some((Q)=>K.startsWith(Q))}function YJ(J){let K=new Map;for(let Q of J.split(",")){let[X,...Z]=Q.trim().split(";"),G=X.trim().toLowerCase();if(!G)continue;let $=1;for(let W of Z){let I=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(W);if(!I)continue;let _=Number.parseFloat(I[1]);if(Number.isFinite(_))$=_}K.set(G,$)}return K}function jJ(J){if(!J)return null;let K=YJ(J),Q=K.get("*"),X=(Z)=>K.get(Z)??Q??0;if(X("br")>0)return"br";if(X("gzip")>0)return"gzip";return null}async function i(J,K,Q={}){if(K.headers.get("content-encoding"))return K;if(K.status===204||K.status===304||!K.body)return K;if(!WJ(K.headers.get("content-type")))return K;let X=jJ(J.headers.get("accept-encoding"));if(!X)return K;let Z;try{Z=new Uint8Array(await K.arrayBuffer())}catch{return K}let G=()=>new Response(Z,{status:K.status,statusText:K.statusText,headers:p(K.headers)});if(Z.length<(Q.threshold??UJ))return G();try{let $=X==="br"?await XJ(Z,{params:{[C.constants.BROTLI_PARAM_QUALITY]:Q.quality??5,[C.constants.BROTLI_PARAM_SIZE_HINT]:Z.length}}):await ZJ(Z);if($.length>=Z.length)return G();let W=p(K.headers);return W.set("Content-Encoding",X),W.set("Content-Length",String($.length)),new Response($,{status:K.status,statusText:K.statusText,headers:W})}catch{return G()}}function p(J){let K=new Headers(J),Q=K.get("Vary");if(!Q)return K.set("Vary","Accept-Encoding"),K;if(!Q.split(",").some((Z)=>Z.trim().toLowerCase()==="accept-encoding"))K.set("Vary",`${Q}, Accept-Encoding`);return K}var _J={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function uJ(J={}){let K=B.resolve(J.outputDir||".output"),Q=J.port||3000,X=JJ(K);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let Z=new Map,G=new Map,$=new Map,W=new Map;for(let U of X.routes)try{let z=B.join(K,U.compiledPath),O=JSON.parse(await Bun.file(z).text());Z.set(U.pattern,O),$.set(U.pattern,s(O.html)),W.set(U.pattern,t(O.html));let N=B.join(K,U.fragmentPath);if(await Bun.file(N).exists())G.set(U.pattern,await Bun.file(N).text())}catch(z){console.warn(`[stx] Failed to load route ${U.pattern}:`,z)}let I=new Map,_=[];for(let U of X.routes)if(U.hasParams){let{regex:z,params:O}=a(U.pattern);_.push({regex:z,route:U,paramNames:O})}else I.set(U.pattern,U);let w=IJ({port:Q,async fetch(U){return i(U,await(async()=>{let O=new URL(U.url).pathname;if(J.onRequest){let Y=await J.onRequest(U);if(Y)return Y}if(J.apiRoutes?.[O])return J.apiRoutes[O](U);if((U.method==="GET"||U.method==="HEAD")&&O!=="/"){let Y=B.resolve(K,"public"),j;try{j=decodeURIComponent(O)}catch{j=O}if(!j.includes("\x00")){let F=B.resolve(Y,`.${j}`);if(F===Y||F.startsWith(`${Y}${B.sep}`))try{if(r.existsSync(F)&&r.statSync(F).isFile()){let S=B.extname(F).toLowerCase(),A=_J[S]||"application/octet-stream",M=O.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(O);return new Response(Bun.file(F),{headers:{"Content-Type":A,"Cache-Control":M?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let N=e(U),L=null,E={};if(L=I.get(O)||null,!L)for(let{regex:Y,route:j,paramNames:F}of _){let H=O.match(Y);if(H){L=j,F.forEach((S,A)=>{E[S]=H[A+1]});break}}if(!L){let Y=I.get("/404")||null;if(Y){let j=Z.get(Y.pattern);if(j)return new Response(j.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(N){let Y=G.get(L.pattern);if(Y){let j=$.get(L.pattern);return new Response(Y,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...W.has(L.pattern)?{"X-STX-Runtime":W.get(L.pattern)?"true":"false"}:{},...j?{"X-STX-Layout":j.layout,"X-STX-Layout-Group":j.group}:{},...b(),"Cache-Control":o}})}}let V=f(U.method),D=Z.get(L.pattern);if(!D){let Y=I.get("/500")||null;if(Y){let j=Z.get(Y.pattern);if(j)return new Response(j.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!V&&!D.hasServerScripts&&Object.keys(D.placeholders).length===0)return new Response(D.html,{status:D.status??200,headers:{"Content-Type":"text/html",...b(),"Cache-Control":"public, max-age=60"}});try{let{html:Y,boundaries:j,redirect:F,cookies:H,status:S,headers:A}=await d(D,{params:E,request:U,method:U.method});if(F)return u(F,H);if(j&&j.length>0){let{renderStreamingPage:T,streamToResponse:k}=await import("./chunk-g3rg8afc.js");return k(T(Y,j,{timeoutMs:30000}),{status:S??D.status??200,headers:{"Cache-Control":"no-cache",...A}})}let M=new Headers({"Content-Type":"text/html",...b(),"Cache-Control":"no-cache"});for(let T of H??[])M.append("Set-Cookie",T);for(let[T,k]of Object.entries(A??{}))M.set(T,k);return new Response(Y,{status:S??D.status??200,headers:M})}catch(Y){return console.error(`[stx] Hydration error for ${O}:`,Y),new Response(D.html,{headers:{"Content-Type":"text/html"}})}})())}});return console.log(`[stx] Production server running at http://localhost:${Q}`),console.log(`[stx] Serving ${X.routes.length} routes (${Z.size} pre-loaded)`),{port:Q,stop:()=>w.stop()}}
2
+ import{Lg as o,Mg as e,Og as b,Xg as JJ}from"./chunk-yf4p02wy.js";import{Nm as m,Om as l,ap as g,fm as y,gm as P,lq as t,pm as v,wm as x}from"./chunk-pbyxj0zr.js";import{It as a,ju as s,nu as OJ}from"./chunk-kwpvv59c.js";import{xu as R}from"./chunk-8rn5e39c.js";import r from"fs";import B from"path";var{serve:IJ}=globalThis.Bun;function q(J,K,Q={}){let X=`${encodeURIComponent(J)}=${encodeURIComponent(K)}`;if(Q.maxAge!==void 0)X+=`; Max-Age=${Q.maxAge}`;if(Q.expires)X+=`; Expires=${Q.expires.toUTCString()}`;if(Q.path)X+=`; Path=${Q.path}`;if(Q.domain)X+=`; Domain=${Q.domain}`;if(Q.secure)X+="; Secure";if(Q.httpOnly)X+="; HttpOnly";if(Q.sameSite)X+=`; SameSite=${Q.sameSite}`;return X}async function KJ(J){let K=J.headers.get("content-type")||"",Q={},X=(Z,G)=>{let $=Q[Z];if($===void 0)Q[Z]=G;else if(Array.isArray($))$.push(G);else Q[Z]=[$,G]};if(K.includes("multipart/form-data")){let Z=await J.formData();for(let[G,$]of Z.entries())if(typeof $==="string")X(G,$);return Q}if(K.includes("application/x-www-form-urlencoded")){for(let[Z,G]of new URLSearchParams(await J.text()).entries())X(Z,G);return Q}return Q}function f(J){if(!J)return!1;let K=J.toUpperCase();return K!=="GET"&&K!=="HEAD"}async function h(J,K={}){let Q=K.request,X=K.method??Q?.method;if(!Q||!f(X))return{ran:!1};if(typeof J.action!=="function")return{ran:!1};let Z={};try{Z=await KJ(Q)}catch{}let G=await J.action({request:Q,form:Z,params:K.params??{},query:J.query??{},cookies:K.cookies??{}});if(G&&typeof G==="object"){let $=G,W=QJ($.cookies),I=$.redirect;if(typeof I==="string"&&I)return{redirect:I,ran:!0,...W.length>0?{cookies:W}:{}};let{cookies:_,redirect:w,...U}=$;if(Object.assign(J,U),W.length>0)return{ran:!0,cookies:W}}return{ran:!0}}function QJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return[];let K=[];for(let[Q,X]of Object.entries(J)){if(!Q)continue;if(typeof X==="string"){K.push(q(Q,X));continue}if(X&&typeof X==="object"){let Z=X;if(typeof Z.value!=="string")continue;K.push(q(Q,Z.value,Z))}}return K}function u(J,K=[]){let Q=new Headers({Location:J,"Cache-Control":"no-store"});for(let X of K)Q.append("Set-Cookie",X);return new Response(null,{status:303,headers:Q})}async function HJ(J,K={}){return(await c(J,K)).html}async function d(J,K={}){let{html:Q,context:X,redirect:Z,cookies:G}=await c(J,K),$=m(X),W=l(X);if(Z)return{html:Q,redirect:Z,cookies:G,status:$,headers:W};let{extractStreamBoundaries:I}=await import("./chunk-98a8ma06.js"),_=I(X),w=J.streamTemplates;if(w&&Object.keys(w).length>0){let{processDirectives:U}=await import("./chunk-85yfwhdx.js"),{defaultConfig:z}=await import("./chunk-ftdysk1n.js"),O=X.streamBoundaries||{},N={...z,autoShell:!1},L=Object.keys(w).map((V)=>({id:V,render:async()=>{let D=typeof O[V]==="function"?await O[V]():void 0;return U(w[V],{...X,$boundary:D},J.sourceFile,N,new Set)}})),E=new Set(L.map((V)=>V.id));_=[...(_||[]).filter((V)=>!E.has(V.id)),...L]}return{html:Q,boundaries:_&&_.length>0?_:void 0,cookies:G,status:$,headers:W}}async function c(J,K){let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};if(!J.hasServerScripts&&!P(J.html))return{html:J.html,context:Q};for(let G of J.serverScriptContent)try{await g(G,Q,J.sourceFile)}catch($){console.warn(`[stx] Server script error in ${J.sourceFile}:`,$)}let X=await h(Q,{request:K.request,method:K.method,params:K.params??{},cookies:K.cookies??{}});if(X.redirect)return{html:J.html,context:Q,redirect:X.redirect,cookies:X.cookies};if(!P(J.html))return{html:J.html,context:Q,cookies:X.cookies};let Z=new Map;for(let[G,$]of Object.entries(J.placeholders))if($.expression)try{let W=x($.expression,Q);if($.type==="raw")Z.set(G,W!==void 0&&W!==null?String(W):"");else Z.set(G,W!==void 0&&W!==null?v(String(W)):"")}catch{Z.set(G,"")}return{html:y(J.html,Z),context:Q,cookies:X.cookies}}async function SJ(J,K={}){if(!J.hasServerScripts&&!P(J.fragment))return J.fragment;let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};for(let Z of J.serverScriptContent)try{await g(Z,Q,J.sourceFile)}catch(G){console.warn(`[stx] Server script error in ${J.sourceFile}:`,G)}if(!P(J.fragment))return J.fragment;let X=new Map;for(let[Z,G]of Object.entries(J.placeholders))if(G.expression)try{let $=x(G.expression,Q);if(G.type==="raw")X.set(Z,$!==void 0&&$!==null?String($):"");else X.set(Z,$!==void 0&&$!==null?v(String($)):"")}catch{X.set(Z,"")}return y(J.fragment,X)}OJ();import C from"zlib";import{promisify as n}from"util";var XJ=n(C.brotliCompress),ZJ=n(C.gzip),$J=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],GJ=["text/event-stream","multipart/x-mixed-replace"],UJ=1024;function WJ(J){if(!J)return!1;let K=J.toLowerCase();if(GJ.some((Q)=>K.startsWith(Q)))return!1;return $J.some((Q)=>K.startsWith(Q))}function YJ(J){let K=new Map;for(let Q of J.split(",")){let[X,...Z]=Q.trim().split(";"),G=X.trim().toLowerCase();if(!G)continue;let $=1;for(let W of Z){let I=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(W);if(!I)continue;let _=Number.parseFloat(I[1]);if(Number.isFinite(_))$=_}K.set(G,$)}return K}function jJ(J){if(!J)return null;let K=YJ(J),Q=K.get("*"),X=(Z)=>K.get(Z)??Q??0;if(X("br")>0)return"br";if(X("gzip")>0)return"gzip";return null}async function i(J,K,Q={}){if(K.headers.get("content-encoding"))return K;if(K.status===204||K.status===304||!K.body)return K;if(!WJ(K.headers.get("content-type")))return K;let X=jJ(J.headers.get("accept-encoding"));if(!X)return K;let Z;try{Z=new Uint8Array(await K.arrayBuffer())}catch{return K}let G=()=>new Response(Z,{status:K.status,statusText:K.statusText,headers:p(K.headers)});if(Z.length<(Q.threshold??UJ))return G();try{let $=X==="br"?await XJ(Z,{params:{[C.constants.BROTLI_PARAM_QUALITY]:Q.quality??5,[C.constants.BROTLI_PARAM_SIZE_HINT]:Z.length}}):await ZJ(Z);if($.length>=Z.length)return G();let W=p(K.headers);return W.set("Content-Encoding",X),W.set("Content-Length",String($.length)),new Response($,{status:K.status,statusText:K.statusText,headers:W})}catch{return G()}}function p(J){let K=new Headers(J),Q=K.get("Vary");if(!Q)return K.set("Vary","Accept-Encoding"),K;if(!Q.split(",").some((Z)=>Z.trim().toLowerCase()==="accept-encoding"))K.set("Vary",`${Q}, Accept-Encoding`);return K}var _J={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function uJ(J={}){let K=B.resolve(J.outputDir||".output"),Q=J.port||3000,X=JJ(K);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let Z=new Map,G=new Map,$=new Map,W=new Map;for(let U of X.routes)try{let z=B.join(K,U.compiledPath),O=JSON.parse(await Bun.file(z).text());Z.set(U.pattern,O),$.set(U.pattern,s(O.html)),W.set(U.pattern,t(O.html));let N=B.join(K,U.fragmentPath);if(await Bun.file(N).exists())G.set(U.pattern,await Bun.file(N).text())}catch(z){console.warn(`[stx] Failed to load route ${U.pattern}:`,z)}let I=new Map,_=[];for(let U of X.routes)if(U.hasParams){let{regex:z,params:O}=a(U.pattern);_.push({regex:z,route:U,paramNames:O})}else I.set(U.pattern,U);let w=IJ({port:Q,async fetch(U){return i(U,await(async()=>{let O=new URL(U.url).pathname;if(J.onRequest){let Y=await J.onRequest(U);if(Y)return Y}if(J.apiRoutes?.[O])return J.apiRoutes[O](U);if((U.method==="GET"||U.method==="HEAD")&&O!=="/"){let Y=B.resolve(K,"public"),j;try{j=decodeURIComponent(O)}catch{j=O}if(!j.includes("\x00")){let F=B.resolve(Y,`.${j}`);if(F===Y||F.startsWith(`${Y}${B.sep}`))try{if(r.existsSync(F)&&r.statSync(F).isFile()){let S=B.extname(F).toLowerCase(),A=_J[S]||"application/octet-stream",M=O.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(O);return new Response(Bun.file(F),{headers:{"Content-Type":A,"Cache-Control":M?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let N=e(U),L=null,E={};if(L=I.get(O)||null,!L)for(let{regex:Y,route:j,paramNames:F}of _){let H=O.match(Y);if(H){L=j,F.forEach((S,A)=>{E[S]=H[A+1]});break}}if(!L){let Y=I.get("/404")||null;if(Y){let j=Z.get(Y.pattern);if(j)return new Response(j.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(N){let Y=G.get(L.pattern);if(Y){let j=$.get(L.pattern);return new Response(Y,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...W.has(L.pattern)?{"X-STX-Runtime":W.get(L.pattern)?"true":"false"}:{},...j?{"X-STX-Layout":j.layout,"X-STX-Layout-Group":j.group}:{},...b(),"Cache-Control":o}})}}let V=f(U.method),D=Z.get(L.pattern);if(!D){let Y=I.get("/500")||null;if(Y){let j=Z.get(Y.pattern);if(j)return new Response(j.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!V&&!D.hasServerScripts&&Object.keys(D.placeholders).length===0)return new Response(D.html,{status:D.status??200,headers:{"Content-Type":"text/html",...b(),"Cache-Control":"public, max-age=60"}});try{let{html:Y,boundaries:j,redirect:F,cookies:H,status:S,headers:A}=await d(D,{params:E,request:U,method:U.method});if(F)return u(F,H);if(j&&j.length>0){let{renderStreamingPage:T,streamToResponse:k}=await import("./chunk-98a8ma06.js");return k(T(Y,j,{timeoutMs:30000}),{status:S??D.status??200,headers:{"Cache-Control":"no-cache",...A}})}let M=new Headers({"Content-Type":"text/html",...b(),"Cache-Control":"no-cache"});for(let T of H??[])M.append("Set-Cookie",T);for(let[T,k]of Object.entries(A??{}))M.set(T,k);return new Response(Y,{status:S??D.status??200,headers:M})}catch(Y){return console.error(`[stx] Hydration error for ${O}:`,Y),new Response(D.html,{headers:{"Content-Type":"text/html"}})}})())}});return console.log(`[stx] Production server running at http://localhost:${Q}`),console.log(`[stx] Serving ${X.routes.length} routes (${Z.size} pre-loaded)`),{port:Q,stop:()=>w.stop()}}
3
3
  export{WJ as ff,jJ as gf,i as hf,q as if,KJ as jf,f as kf,h as lf,u as mf,HJ as nf,d as of,SJ as pf,uJ as qf};