@stacksjs/stx 0.2.305 → 0.2.307

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 (163) hide show
  1. package/dist/{chunk-0gz0rhvs.js → chunk-0gbptqh2.js} +1 -1
  2. package/dist/{chunk-g97atepq.js → chunk-0mnv8pf5.js} +1 -1
  3. package/dist/{chunk-4mrhxtn3.js → chunk-0va2vsqa.js} +2 -2
  4. package/dist/chunk-0wwgr4wv.js +2 -0
  5. package/dist/{chunk-nqq7y7m9.js → chunk-18p8dqya.js} +1 -1
  6. package/dist/chunk-1vwgywtn.js +2 -0
  7. package/dist/{chunk-awj7yy37.js → chunk-1ztjv7a4.js} +1 -1
  8. package/dist/{chunk-eans1ct0.js → chunk-20yc1zrp.js} +1 -1
  9. package/dist/{chunk-f1cgyd2h.js → chunk-24bgm3hh.js} +1 -1
  10. package/dist/{chunk-rvyfyc43.js → chunk-2559vc7d.js} +1 -1
  11. package/dist/{chunk-9nf3hgvq.js → chunk-286rffvb.js} +2 -2
  12. package/dist/{chunk-qev11kg8.js → chunk-2kv2gnzc.js} +1 -1
  13. package/dist/chunk-2pv79p7x.js +2 -0
  14. package/dist/{chunk-b4xwbh8a.js → chunk-322qz0cj.js} +1 -1
  15. package/dist/{chunk-t51mwjyq.js → chunk-397rqs12.js} +1 -1
  16. package/dist/{chunk-env6knrs.js → chunk-3by4c2g9.js} +1 -1
  17. package/dist/{chunk-tt4r8q4v.js → chunk-3pv0qj5f.js} +1 -1
  18. package/dist/chunk-455m2k1y.js +2 -0
  19. package/dist/{chunk-c131k3mt.js → chunk-4ee1aaet.js} +1 -1
  20. package/dist/{chunk-d3srvh3q.js → chunk-4hk5ewgp.js} +1 -1
  21. package/dist/chunk-4z3yyryn.js +2 -0
  22. package/dist/{chunk-wx13qmaw.js → chunk-51gea48g.js} +1 -1
  23. package/dist/{chunk-bk95q0bw.js → chunk-58xpr98x.js} +1 -1
  24. package/dist/chunk-59fva5cz.js +2 -0
  25. package/dist/{chunk-gbwhbasw.js → chunk-5g39e9ra.js} +1 -1
  26. package/dist/{chunk-xsfwcj6x.js → chunk-604qr43v.js} +1 -1
  27. package/dist/chunk-64ttktzc.js +4 -0
  28. package/dist/chunk-6dmrpd71.js +2 -0
  29. package/dist/chunk-6vt9ddra.js +2 -0
  30. package/dist/{chunk-k23r03qj.js → chunk-6xqgkfb3.js} +1 -1
  31. package/dist/chunk-75vxhxn1.js +2 -0
  32. package/dist/{chunk-6zt2y7q3.js → chunk-769jvq54.js} +1 -1
  33. package/dist/{chunk-gssbag3e.js → chunk-7c1qq9zq.js} +1 -1
  34. package/dist/chunk-7n6fq2t7.js +2 -0
  35. package/dist/{chunk-ta398s3d.js → chunk-7xrvkrrx.js} +10 -10
  36. package/dist/{chunk-yyyxt326.js → chunk-7yzyn9k7.js} +1 -1
  37. package/dist/chunk-80rmf67y.js +2 -0
  38. package/dist/{chunk-ppyz9623.js → chunk-85p4dmft.js} +1 -1
  39. package/dist/{chunk-c1ae6afc.js → chunk-8g6jwkjy.js} +2 -2
  40. package/dist/{chunk-8ee62a9q.js → chunk-8q8gj45z.js} +1 -1
  41. package/dist/chunk-8tkn0yxq.js +2 -0
  42. package/dist/{chunk-gecmqs6p.js → chunk-8wqhts61.js} +1 -1
  43. package/dist/chunk-9aw5d4rr.js +2 -0
  44. package/dist/{chunk-fp7ms6e7.js → chunk-9ebfmdyb.js} +1 -1
  45. package/dist/{chunk-rzevgemj.js → chunk-a50hb40e.js} +1 -1
  46. package/dist/{chunk-jfzfrmzy.js → chunk-ajhrz96a.js} +1 -1
  47. package/dist/{chunk-wfffa8zm.js → chunk-aqrp68m6.js} +1 -1
  48. package/dist/{chunk-8jam44my.js → chunk-at84gyvf.js} +1 -1
  49. package/dist/{chunk-ess2pgt5.js → chunk-b8cteeha.js} +1 -1
  50. package/dist/chunk-ba5t40dx.js +2 -0
  51. package/dist/{chunk-mbmqpaq1.js → chunk-bnq0p4r4.js} +1 -1
  52. package/dist/chunk-bzmxbz48.js +2 -0
  53. package/dist/{chunk-wnamjw6n.js → chunk-cpsepyzg.js} +1 -1
  54. package/dist/chunk-czje8k8c.js +2 -0
  55. package/dist/chunk-d4b67e6m.js +2 -0
  56. package/dist/chunk-e16hkjh9.js +2 -0
  57. package/dist/{chunk-gt8ja700.js → chunk-f044qmn3.js} +1 -1
  58. package/dist/chunk-f7e286pa.js +2 -0
  59. package/dist/{chunk-f325jzsk.js → chunk-f91yrkcz.js} +2 -2
  60. package/dist/chunk-fsee2x1q.js +2 -0
  61. package/dist/chunk-fwdn408g.js +2 -0
  62. package/dist/chunk-gy3sf0fw.js +2 -0
  63. package/dist/chunk-h78pksyp.js +2 -0
  64. package/dist/chunk-hg7ptfd4.js +2 -0
  65. package/dist/{chunk-s3dnk3gc.js → chunk-hsbrta4s.js} +1 -1
  66. package/dist/{chunk-695fkras.js → chunk-j3ajrx2n.js} +1 -1
  67. package/dist/{chunk-jsg1rthc.js → chunk-jd9nv63q.js} +1 -1
  68. package/dist/{chunk-jp2f8yzw.js → chunk-jryjwara.js} +1 -1
  69. package/dist/{chunk-4evbx7sz.js → chunk-jwnbwemq.js} +1 -1
  70. package/dist/{chunk-zhcs8m2a.js → chunk-k14nr7rz.js} +1 -1
  71. package/dist/{chunk-mv5fdcwc.js → chunk-k1qzydkj.js} +3 -3
  72. package/dist/chunk-k48jp969.js +2 -0
  73. package/dist/{chunk-hg2afckn.js → chunk-ka2xspj3.js} +1 -1
  74. package/dist/{chunk-mygq61f5.js → chunk-ka5wtqmw.js} +1 -1
  75. package/dist/{chunk-d5cqnwdd.js → chunk-kexk6z9s.js} +1 -1
  76. package/dist/{chunk-m8n0s4tk.js → chunk-kh9r3pfb.js} +1 -1
  77. package/dist/{chunk-qeyw5za9.js → chunk-ksqba0cq.js} +1 -1
  78. package/dist/chunk-kwjgt9jx.js +2 -0
  79. package/dist/{chunk-t8fqjb25.js → chunk-mk0j30e1.js} +1 -1
  80. package/dist/{chunk-m31n9pkr.js → chunk-msmhta0w.js} +1 -1
  81. package/dist/chunk-mvj75wef.js +2 -0
  82. package/dist/{chunk-1jbjrc0w.js → chunk-mvyadg84.js} +1 -1
  83. package/dist/{chunk-cbgh359m.js → chunk-n43zq50e.js} +1 -1
  84. package/dist/{chunk-g912mb7x.js → chunk-nnv8wytm.js} +1 -1
  85. package/dist/{chunk-w6d91maa.js → chunk-ns8fx1f9.js} +1 -1
  86. package/dist/{chunk-ydgdq45a.js → chunk-pwv15j35.js} +1 -1
  87. package/dist/{chunk-fczfdsab.js → chunk-r7qap4bh.js} +2 -2
  88. package/dist/{chunk-fg0nf7cv.js → chunk-r8z1rexd.js} +277 -272
  89. package/dist/chunk-raxr83fs.js +60 -0
  90. package/dist/{chunk-jxxv18a0.js → chunk-ry1key0g.js} +1 -1
  91. package/dist/{chunk-9c835qjn.js → chunk-s3pvp8qv.js} +1 -1
  92. package/dist/{chunk-sart9ehj.js → chunk-snmtft92.js} +1 -1
  93. package/dist/{chunk-zs5y7xnt.js → chunk-t5kwx6fa.js} +1 -1
  94. package/dist/{chunk-rrankpmj.js → chunk-ttny9g8k.js} +1 -1
  95. package/dist/chunk-v0ne90ft.js +2 -0
  96. package/dist/chunk-v33qvj8y.js +2 -0
  97. package/dist/{chunk-ze44hhxb.js → chunk-vbwq7he6.js} +2 -2
  98. package/dist/{chunk-d19tvdvv.js → chunk-vhan24as.js} +1 -1
  99. package/dist/chunk-vpbw6g2t.js +2 -0
  100. package/dist/{chunk-ek8cgwcg.js → chunk-vtd5bgt9.js} +1 -1
  101. package/dist/{chunk-00rtz7nw.js → chunk-vwq4kwwj.js} +1 -1
  102. package/dist/{chunk-bd9wrcq1.js → chunk-w8hkprzv.js} +1 -1
  103. package/dist/chunk-wbt9kz3j.js +2 -0
  104. package/dist/{chunk-ghw5p1yk.js → chunk-wm86mmgq.js} +1 -1
  105. package/dist/{chunk-d57gb0v2.js → chunk-wwghzbbg.js} +1 -1
  106. package/dist/{chunk-kxavsh3m.js → chunk-xcsf7my7.js} +1 -1
  107. package/dist/{chunk-hrcxfvh1.js → chunk-y4dd2n2n.js} +1 -1
  108. package/dist/{chunk-7skk34dh.js → chunk-ybct46zd.js} +1 -1
  109. package/dist/chunk-yp0jymdz.js +2 -0
  110. package/dist/{chunk-7m4yhzhb.js → chunk-yyxhjfgd.js} +2 -2
  111. package/dist/{chunk-t3qb9s6s.js → chunk-zdzd2jb4.js} +1 -1
  112. package/dist/{chunk-7gqbr8nr.js → chunk-zr1r73p3.js} +1 -1
  113. package/dist/cli.js +14 -14
  114. package/dist/craft-entry.js +1 -1
  115. package/dist/craft.js +1 -1
  116. package/dist/database.js +1 -1
  117. package/dist/expressions.d.ts +10 -1
  118. package/dist/expressions.js +42 -11
  119. package/dist/head.d.ts +12 -0
  120. package/dist/head.js +21 -2
  121. package/dist/pwa.js +2 -2
  122. package/dist/safe-evaluator.d.ts +18 -0
  123. package/dist/safe-evaluator.js +100 -17
  124. package/dist/seo.js +56 -4
  125. package/dist/ssg.js +2 -2
  126. package/dist/types/config-types.d.ts +20 -0
  127. package/dist/types/index.d.ts +1 -1
  128. package/dist/visual-testing.js +1 -1
  129. package/package.json +5 -5
  130. package/dist/chunk-02hm88m5.js +0 -2
  131. package/dist/chunk-044mychj.js +0 -2
  132. package/dist/chunk-113y4ywy.js +0 -2
  133. package/dist/chunk-1c2j4eby.js +0 -4
  134. package/dist/chunk-2h94c5hm.js +0 -60
  135. package/dist/chunk-3eervtf9.js +0 -2
  136. package/dist/chunk-4jgr954p.js +0 -2
  137. package/dist/chunk-57ea6ye2.js +0 -2
  138. package/dist/chunk-8z0n5mtg.js +0 -2
  139. package/dist/chunk-92zzryxw.js +0 -2
  140. package/dist/chunk-a87jqtmd.js +0 -2
  141. package/dist/chunk-bezqaxqt.js +0 -2
  142. package/dist/chunk-dgpjxmhs.js +0 -2
  143. package/dist/chunk-er848s6f.js +0 -2
  144. package/dist/chunk-hftqr8ej.js +0 -2
  145. package/dist/chunk-hzav4hyd.js +0 -2
  146. package/dist/chunk-m537zgay.js +0 -2
  147. package/dist/chunk-n99ajrwv.js +0 -2
  148. package/dist/chunk-ncrfrp95.js +0 -2
  149. package/dist/chunk-nws8fbde.js +0 -2
  150. package/dist/chunk-phcvbqzn.js +0 -2
  151. package/dist/chunk-qpzxgkc5.js +0 -2
  152. package/dist/chunk-qt2dmyq5.js +0 -2
  153. package/dist/chunk-r2k2sewg.js +0 -2
  154. package/dist/chunk-r808fpme.js +0 -2
  155. package/dist/chunk-sen2cxqm.js +0 -2
  156. package/dist/chunk-tc6gqeha.js +0 -2
  157. package/dist/chunk-twbw18vs.js +0 -2
  158. package/dist/chunk-wjdfhfj6.js +0 -2
  159. package/dist/chunk-x10mrzgp.js +0 -2
  160. package/dist/chunk-xd5ahrtn.js +0 -2
  161. package/dist/chunk-xzgvcrnz.js +0 -2
  162. package/dist/chunk-yd7jyyr7.js +0 -2
  163. package/dist/chunk-zs95z9tf.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Cm as O,Po as R,_p as H,qq as x,vr as g}from"./chunk-fg0nf7cv.js";import b from"path";var v={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},M=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var T=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function f(q){let B=[],Q=0,G;T.lastIndex=0;while((G=T.exec(q))!==null){if(G.index>Q){let X=q.slice(Q,G.index);if(X.trim())B.push({type:B.length===0?"shell":"content",content:X})}let J=G[1],K=G[2];B.push({type:"suspense",name:J,content:K}),Q=G.index+G[0].length}if(Q<q.length){let J=q.slice(Q);if(J.trim())B.push({type:B.length===0?"shell":"content",content:J})}if(B.length===0)B.push({type:"shell",content:q});return B}async function r(q,B={},Q={}){let G={...g,...Q,streaming:{...v,...Q.streaming}},J=G.streaming?.bufferSize||16384;return new ReadableStream({async start(K){try{let X=await Bun.file(q).text(),z=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),L=z?z[1]:"",Y=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),j={...B,__filename:q,__dirname:b.dirname(q)};if(L.trim())await R(L,j,q);let D=f(Y),$=new Set;if(!D.some((w)=>w.type==="suspense")){let w=G.streaming?.strategy||"auto",U=new RegExp(M.source,"g");if(!(w!=="manual"&&U.test(Y))){let F=await H(Y,j,q,G,$);for(let V=0;V<F.length;V+=J)K.enqueue(F.slice(V,V+J)),await new Promise((W)=>setTimeout(W,0))}else{let F=[],V=new RegExp(M.source,"g"),W;while((W=V.exec(Y))!==null)F.push({name:W[1],content:W[2],start:W.index,end:W.index+W[0].length});let y=0;for(let A of F){if(A.start>y){let k=Y.slice(y,A.start);if(k.trim()){let E=await H(k,j,q,G,$);K.enqueue(E),await new Promise((S)=>setTimeout(S,0))}}let I=await H(A.content,j,q,G,$);K.enqueue(I),await new Promise((k)=>setTimeout(k,0)),y=A.end}if(y<Y.length){let A=Y.slice(y);if(A.trim()){let I=await H(A,j,q,G,$);K.enqueue(I)}}}}else{let w=new Map;for(let Z of D)if(Z.type==="shell"||Z.type==="content"){let F=await H(Z.content,j,q,G,$);K.enqueue(F)}else if(Z.type==="suspense"&&Z.name){let F=`stx-suspense-${Z.name}`;K.enqueue(`<div id="${F}" data-suspense="${Z.name}" style="display:contents;">
2
+ import{$p as H,Cm as O,Qo as R,rq as x,wr as g}from"./chunk-r8z1rexd.js";import b from"path";var v={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},M=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var T=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function f(q){let B=[],Q=0,G;T.lastIndex=0;while((G=T.exec(q))!==null){if(G.index>Q){let X=q.slice(Q,G.index);if(X.trim())B.push({type:B.length===0?"shell":"content",content:X})}let J=G[1],K=G[2];B.push({type:"suspense",name:J,content:K}),Q=G.index+G[0].length}if(Q<q.length){let J=q.slice(Q);if(J.trim())B.push({type:B.length===0?"shell":"content",content:J})}if(B.length===0)B.push({type:"shell",content:q});return B}async function r(q,B={},Q={}){let G={...g,...Q,streaming:{...v,...Q.streaming}},J=G.streaming?.bufferSize||16384;return new ReadableStream({async start(K){try{let X=await Bun.file(q).text(),z=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),L=z?z[1]:"",Y=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),j={...B,__filename:q,__dirname:b.dirname(q)};if(L.trim())await R(L,j,q);let D=f(Y),$=new Set;if(!D.some((w)=>w.type==="suspense")){let w=G.streaming?.strategy||"auto",U=new RegExp(M.source,"g");if(!(w!=="manual"&&U.test(Y))){let F=await H(Y,j,q,G,$);for(let V=0;V<F.length;V+=J)K.enqueue(F.slice(V,V+J)),await new Promise((W)=>setTimeout(W,0))}else{let F=[],V=new RegExp(M.source,"g"),W;while((W=V.exec(Y))!==null)F.push({name:W[1],content:W[2],start:W.index,end:W.index+W[0].length});let y=0;for(let A of F){if(A.start>y){let k=Y.slice(y,A.start);if(k.trim()){let E=await H(k,j,q,G,$);K.enqueue(E),await new Promise((S)=>setTimeout(S,0))}}let I=await H(A.content,j,q,G,$);K.enqueue(I),await new Promise((k)=>setTimeout(k,0)),y=A.end}if(y<Y.length){let A=Y.slice(y);if(A.trim()){let I=await H(A,j,q,G,$);K.enqueue(I)}}}}else{let w=new Map;for(let Z of D)if(Z.type==="shell"||Z.type==="content"){let F=await H(Z.content,j,q,G,$);K.enqueue(F)}else if(Z.type==="suspense"&&Z.name){let F=`stx-suspense-${Z.name}`;K.enqueue(`<div id="${F}" data-suspense="${Z.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),w.set(Z.name,H(Z.content,j,q,G,$))}K.enqueue(`
5
5
  <script>
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{aw as Te,bw as u}from"./chunk-jp2f8yzw.js";function F(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>m.includes(a))}function y(e){return F(e.replace(/^\//,""))}var m;var x=u(()=>{m=["components","layouts","partials","emails"]});import d from"fs";import v from"path";function S(e,t){let a=e.filter((o)=>!y(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 h=o.pattern.includes(`:${c}?`)?"?":"";i.push(`${c}${h}: string`)}let l=i.join("; ");r.push(` '${o.pattern}': { ${l} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
2
+ import{cw as Te,dw as u}from"./chunk-jryjwara.js";function F(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>m.includes(a))}function y(e){return F(e.replace(/^\//,""))}var m;var x=u(()=>{m=["components","layouts","partials","emails"]});import d from"fs";import v from"path";function S(e,t){let a=e.filter((o)=>!y(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 h=o.pattern.includes(`:${c}?`)?"?":"";i.push(`${c}${h}: string`)}let l=i.join("; ");r.push(` '${o.pattern}': { ${l} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
3
3
  `),s=v.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 k(e,t,a){let r=process.cwd(),n=v.relative(r,a),s=e.filter((i)=>!y(i.pattern)),o=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let i of s){let l=v.relative(r,i.filePath).replace(/\\/g,"/"),c=JSON.stringify(i.params),h=i.layout?`, layout: '${v.relative(r,i.layout).replace(/\\/g,"/")}'`:"";o.push(` { pattern: '${i.pattern}', filePath: '${l}', isDynamic: ${i.isDynamic}, params: ${c}${h} },`)}o.push("] as const",""),o.push("export type RouteName = typeof routes[number]['pattern']",""),d.mkdirSync(t,{recursive:!0}),d.writeFileSync(v.join(t,"routes.ts"),o.join(`
4
4
  `))}var M=u(()=>{x()});import D from"path";function A(e,t){let r=D.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(D.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 w(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 K(e){let t=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return w(t)}var I=()=>{};import ke from"fs";import N from"path";function C(e,t){let a=[],r=N.dirname(e);while(r.startsWith(t)||r===t){let n=N.join(r,"_layout.stx");if(ke.existsSync(n))a.unshift(n);if(r===t)break;r=N.dirname(r)}return a}var B=()=>{};import P from"fs";import p from"path";function $(e,t){let a=[];if(!P.existsSync(e))return a;let r=P.readdirSync(e,{withFileTypes:!0});for(let n of r){let s=p.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(m.includes(n.name))continue;a.push(...$(s,t))}else if(n.isFile()){let o=p.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 T{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)=>p.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=$(o,r),l=new Map;for(let c of i){let h=A(c,o),g=t.pagesDirs?h.replace(/:[\w]+/g,":param"):h;if(t.pagesDirs&&l.has(g))throw Error(`Conflicting layer pages for ${h}: ${l.get(g)} and ${c}`);if(l.set(g,c),n.has(g))continue;n.add(g);let{regex:Se,params:V}=w(h),O=t.layouts!==!1?C(c,o):[];this.routes.push({pattern:h,regex:Se,params:V,filePath:c,isDynamic:V.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=p.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");S(this.routes,s),k(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 z(e,t){return new T(e,t)}function J(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=p.join(e,r);if(P.existsSync(n))return n}return null}function Y(e,t){return e.map((a)=>{let r=p.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var Z=u(()=>{M();I();B();x()});function Q(e){R=e.replace(/\/$/,"")}function ee(e,t,a={}){f[e]={path:t,name:e,params:a}}function te(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function re(e,t={},a=!1){let r=f[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&&R?`${R}${s}`:s}function ae(){for(let e of Object.keys(f))delete f[e];R=""}var f,R="";var ne=u(()=>{f={}});import oe from"fs";import se 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 le(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function ce(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 U(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 j(){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 L(e,t){b.set(e,t)}function q(e){return b.get(e)}function ue(e){return b.has(e)}function he(){b.clear()}function de(){return Array.from(b.keys())}async function pe(e,t="middleware"){let a=se.resolve(e,t);if(!oe.existsSync(a))return;let r=oe.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=se.join(a,n);try{let l=(await import(o)).default;if(l&&typeof l.handler==="function")L(s,l);else if(typeof l==="function")L(s,{handler:l,mode:"universal"})}catch(i){console.warn(`Failed to load middleware '${s}' from ${o}:`,i)}}}function Ae(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function fe(e,t,a,r=""){return{path:e,params:t,query:Ae(r),fullPath:r?`${e}?${r}`:e,meta:a}}function ge(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?U(a,o):X(),storage:j(),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=q(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 b;var ye=u(()=>{b=new Map});function H(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 ve(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]||H(n)}}var we=()=>{};function Ce(e){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function be(){if(_)return _;return _=Ce(`
5
5
  ;(function(){
@@ -1997,4 +1997,4 @@ else {
1997
1997
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
1998
1998
  })();
1999
1999
  `),_}var _;var xe=()=>{};var Re={};Te(Re,{setAppUrl:()=>Q,runMiddleware:()=>me,route:()=>re,resolveLayoutChain:()=>C,resetRoutes:()=>ae,registerMiddleware:()=>L,patternToRegex:()=>w,navigateTo:()=>ie,matchRoute:()=>W,loadMiddlewareFromDirectory:()=>pe,isNonPageRoutePattern:()=>y,isNonPageRoutePath:()=>F,hasMiddleware:()=>ue,getRouterScript:()=>be,getMiddlewareNames:()=>de,getMiddleware:()=>q,generateRouteTypes:()=>S,generateRouteManifest:()=>k,formatRoutes:()=>Y,findErrorPage:()=>J,filePathToPattern:()=>A,extractLayoutMetadata:()=>ve,deriveLayoutGroup:()=>H,defineRoutes:()=>te,defineRoute:()=>ee,defineMiddleware:()=>ce,createStorageManager:()=>j,createServerCookieManager:()=>U,createRouter:()=>z,createRouteLocation:()=>fe,createMiddlewareContext:()=>ge,createClientCookieManager:()=>X,clearMiddleware:()=>he,bracketPathToRegex:()=>K,abortNavigation:()=>le,Router:()=>T,NON_PAGE_DIRS:()=>m});var Ee=u(()=>{Z();I();ne();ye();B();we();M();x();xe()});
2000
- export{m as hv,F as iv,y as jv,S as kv,k as lv,A as mv,w as nv,W as ov,K as pv,C as qv,T as rv,z as sv,J as tv,Y as uv,Q as vv,ee as wv,te as xv,re as yv,ae as zv,ie as Av,le as Bv,ce as Cv,U as Dv,X as Ev,j as Fv,L as Gv,q as Hv,ue as Iv,he as Jv,de as Kv,pe as Lv,fe as Mv,ge as Nv,me as Ov,H as Pv,ve as Qv,we as Rv,be as Sv,Re as Tv,Ee as Uv};
2000
+ export{m as jv,F as kv,y as lv,S as mv,k as nv,A as ov,w as pv,W as qv,K as rv,C as sv,T as tv,z as uv,J as vv,Y as wv,Q as xv,ee as yv,te as zv,re as Av,ae as Bv,ie as Cv,le as Dv,ce as Ev,U as Fv,X as Gv,j as Hv,L as Iv,q as Jv,ue as Kv,he as Lv,de as Mv,pe as Nv,fe as Ov,ge as Pv,me as Qv,H as Rv,ve as Sv,we as Tv,be as Uv,Re as Vv,Ee as Wv};