@stacksjs/stx 0.2.904 → 0.2.907
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.
- package/dist/app-shell.d.ts +1 -1
- package/dist/app-shell.js +1 -1
- package/dist/{chunk-n3fgrsva.js → chunk-0d3pkkrv.js} +2 -2
- package/dist/{chunk-9y83pdcb.js → chunk-0vyytd9v.js} +3 -3
- package/dist/{chunk-v5y66rwr.js → chunk-13awnyq0.js} +1 -1
- package/dist/chunk-1dc6h93m.js +2 -0
- package/dist/{chunk-ffytbb4x.js → chunk-1ezcxbpg.js} +5 -5
- package/dist/{chunk-eb5v9npc.js → chunk-1hx6dyy9.js} +2 -2
- package/dist/{chunk-a7bqrjm5.js → chunk-1jxkc6d0.js} +2 -2
- package/dist/chunk-20hy5p3p.js +2 -0
- package/dist/chunk-20zx1msx.js +2 -0
- package/dist/chunk-218pnbaf.js +2 -0
- package/dist/chunk-257msenj.js +3 -0
- package/dist/chunk-291860br.js +2 -0
- package/dist/chunk-2fyey6pn.js +2 -0
- package/dist/chunk-2jkq15je.js +2 -0
- package/dist/{chunk-eb5cma4b.js → chunk-2m4d8jkv.js} +2 -2
- package/dist/{chunk-p89rpak1.js → chunk-2qk2ppgm.js} +1 -1
- package/dist/{chunk-arfpzf17.js → chunk-357qjcj1.js} +2 -2
- package/dist/chunk-3611xczp.js +3 -0
- package/dist/chunk-3dy3hr8r.js +2 -0
- package/dist/{chunk-edpsk4bg.js → chunk-3m457a9q.js} +9 -9
- package/dist/{chunk-nc5d3a5r.js → chunk-3syagjd7.js} +5 -5
- package/dist/{chunk-9fcanx7q.js → chunk-3yr0wyc9.js} +2 -2
- package/dist/{chunk-n9axtmxs.js → chunk-42z7zv92.js} +5 -5
- package/dist/chunk-4345d8s9.js +2 -0
- package/dist/chunk-43kz6rx9.js +2 -0
- package/dist/chunk-47ver0g7.js +2 -0
- package/dist/chunk-4a6mptfc.js +2 -0
- package/dist/{chunk-hdfhaddy.js → chunk-4b110x6r.js} +2 -2
- package/dist/chunk-4b9jx2c1.js +2 -0
- package/dist/chunk-4dh1b9yr.js +2 -0
- package/dist/chunk-4nc8vdef.js +2 -0
- package/dist/{chunk-pwpge9bj.js → chunk-5jc9hmwg.js} +2 -2
- package/dist/{chunk-ern5hyvr.js → chunk-5jn2qyv7.js} +1 -1
- package/dist/{chunk-fcqc9yws.js → chunk-5m4zgt4m.js} +14 -14
- package/dist/{chunk-0hcek8nq.js → chunk-6bgerbgh.js} +1 -1
- package/dist/{chunk-n1wn4wvm.js → chunk-6qgrr453.js} +3 -3
- package/dist/{chunk-ayady5ws.js → chunk-6w9av0n9.js} +2 -2
- package/dist/{chunk-hnjeqxqy.js → chunk-6yketqa1.js} +2 -2
- package/dist/{chunk-5yvgzh6n.js → chunk-72pbhpq8.js} +2 -2
- package/dist/chunk-7k1thytm.js +2 -0
- package/dist/{chunk-jwvv842z.js → chunk-83g4169y.js} +19 -19
- package/dist/chunk-8f5x16ht.js +2 -0
- package/dist/{chunk-vfctk20v.js → chunk-8n42epb6.js} +3 -3
- package/dist/{chunk-k3ytyhkr.js → chunk-8p3vqt2q.js} +3 -3
- package/dist/{chunk-p92272k0.js → chunk-8tfpv6zf.js} +2 -2
- package/dist/chunk-94r6mkcy.js +2 -0
- package/dist/chunk-96wdxfn4.js +2 -0
- package/dist/{chunk-rdrstnn9.js → chunk-9atdw0p8.js} +2 -2
- package/dist/chunk-9bc23bv2.js +2 -0
- package/dist/{chunk-5jrpzepc.js → chunk-9bexzgws.js} +2 -2
- package/dist/{chunk-0gc1hez6.js → chunk-9tj16d70.js} +3 -3
- package/dist/chunk-9xzej52j.js +2 -0
- package/dist/{chunk-rzmk73fz.js → chunk-ab1z38gj.js} +2 -2
- package/dist/chunk-abxwggen.js +2 -0
- package/dist/{chunk-n642g6n0.js → chunk-afmmrqee.js} +15 -15
- package/dist/{chunk-68r2zs20.js → chunk-ahf9j8wb.js} +4 -4
- package/dist/chunk-asewbsct.js +2 -0
- package/dist/{chunk-0b57fgpn.js → chunk-b234w3mf.js} +30 -10
- package/dist/chunk-bcspywrd.js +2 -0
- package/dist/chunk-bprjp80g.js +2 -0
- package/dist/{chunk-n7rwbccm.js → chunk-bpx9cys7.js} +6 -6
- package/dist/{chunk-945zygwa.js → chunk-c08jvjqt.js} +27 -27
- package/dist/{chunk-gyqg3xjp.js → chunk-c5cxpkfy.js} +5 -5
- package/dist/chunk-c60egpe6.js +2 -0
- package/dist/chunk-cjq455ve.js +2 -0
- package/dist/chunk-ck4ypzet.js +3 -0
- package/dist/{chunk-46khhke2.js → chunk-cpt9sg6d.js} +1 -1
- package/dist/{chunk-73ebyhqq.js → chunk-cq4cwfqf.js} +2 -2
- package/dist/chunk-cqq68aw8.js +2 -0
- package/dist/{chunk-qs0zk04y.js → chunk-cwcmmgvz.js} +2 -2
- package/dist/{chunk-5gnt3qtn.js → chunk-d4hnj3ct.js} +3 -3
- package/dist/{chunk-6c8s1pax.js → chunk-e4tbq8a0.js} +9 -9
- package/dist/{chunk-qykbjg3z.js → chunk-e5rag6rh.js} +2 -2
- package/dist/{chunk-150cz8qq.js → chunk-eca022er.js} +7 -7
- package/dist/{chunk-fksmr50h.js → chunk-ekyx5z50.js} +6 -6
- package/dist/{chunk-xr1s56k5.js → chunk-eptzpvn0.js} +3 -3
- package/dist/chunk-exc8y30f.js +42 -0
- package/dist/{chunk-ty5frr9t.js → chunk-fds6vvq0.js} +150 -149
- package/dist/{chunk-de61k0ab.js → chunk-fs43342z.js} +2 -2
- package/dist/{chunk-essmq8yb.js → chunk-fwffn130.js} +9 -9
- package/dist/{chunk-54x7h3sb.js → chunk-fycxc75p.js} +1 -1
- package/dist/chunk-fzh73jtc.js +2 -0
- package/dist/{chunk-gnf1e5q7.js → chunk-fznjm7qt.js} +2 -2
- package/dist/{chunk-r0az4z6d.js → chunk-gfp39bzr.js} +2 -2
- package/dist/{chunk-8xb09hnn.js → chunk-gg31th5s.js} +4 -4
- package/dist/chunk-gjnxnfrg.js +2 -0
- package/dist/chunk-gjzs6p2v.js +2 -0
- package/dist/chunk-gmczbe3j.js +2 -0
- package/dist/{chunk-7nf7mp27.js → chunk-gyv2bsmn.js} +2 -2
- package/dist/chunk-h7xqba9k.js +2 -0
- package/dist/{chunk-9w7whtbx.js → chunk-hhspwfva.js} +2 -2
- package/dist/chunk-hpxhxwda.js +2 -0
- package/dist/chunk-j661q889.js +2 -0
- package/dist/chunk-j90sfypd.js +2 -0
- package/dist/{chunk-4hk1mjtv.js → chunk-jhegz7az.js} +5 -5
- package/dist/{chunk-tqm66mh3.js → chunk-jj78m9k1.js} +132 -51
- package/dist/chunk-jnk3nk5k.js +2 -0
- package/dist/{chunk-mry67rsk.js → chunk-jttzrv0w.js} +6 -6
- package/dist/{chunk-5tm1pvt3.js → chunk-jz37h2z0.js} +2 -2
- package/dist/chunk-jzbte09f.js +2 -0
- package/dist/chunk-k5v22gn4.js +2 -0
- package/dist/{chunk-e3svj8ex.js → chunk-kcphqn2k.js} +1 -1
- package/dist/{chunk-50wjk5ap.js → chunk-kmy34he2.js} +2 -2
- package/dist/{chunk-bx5y6qsg.js → chunk-m9cye9t8.js} +43 -43
- package/dist/chunk-mgcakk1m.js +2 -0
- package/dist/chunk-mkm9drk3.js +2 -0
- package/dist/{chunk-vw7crz0z.js → chunk-mpfm5ctr.js} +4 -4
- package/dist/chunk-n3bt1sv5.js +2 -0
- package/dist/chunk-n62nqhey.js +2 -0
- package/dist/{chunk-k3566kgd.js → chunk-nan0ysys.js} +2 -2
- package/dist/{chunk-w96jck0a.js → chunk-nmywrw6v.js} +1 -1
- package/dist/chunk-nrap20qt.js +2 -0
- package/dist/{chunk-4z926gay.js → chunk-nzqr3w35.js} +7 -7
- package/dist/{chunk-g5nts6e0.js → chunk-p3et6xjr.js} +5 -5
- package/dist/{chunk-9hwg13ec.js → chunk-pc89t52s.js} +5 -5
- package/dist/{chunk-7b3dqeyr.js → chunk-phzhmnnm.js} +2 -2
- package/dist/chunk-pp89n1et.js +2 -0
- package/dist/chunk-ptrz5xwt.js +2 -0
- package/dist/chunk-q2jag6wt.js +2 -0
- package/dist/chunk-q9yahsww.js +2 -0
- package/dist/chunk-qgc59a7d.js +2 -0
- package/dist/chunk-qjkpwjg6.js +2 -0
- package/dist/chunk-qq31bcsq.js +2 -0
- package/dist/{chunk-8vbx58s6.js → chunk-qvj0bzw5.js} +10 -10
- package/dist/chunk-r5xt6vdq.js +2 -0
- package/dist/{chunk-5mrt1enm.js → chunk-razwegar.js} +2 -2
- package/dist/chunk-rt6fn071.js +2 -0
- package/dist/{chunk-67pq803s.js → chunk-sdf4c754.js} +2 -2
- package/dist/chunk-se0pjx71.js +2 -0
- package/dist/chunk-senrtnx2.js +2 -0
- package/dist/chunk-sjrx0dj8.js +2 -0
- package/dist/chunk-ta5fpj2a.js +2 -0
- package/dist/{chunk-bgkj0rxe.js → chunk-ta7cwykn.js} +4 -4
- package/dist/{chunk-jj1f1v1r.js → chunk-tszhkmny.js} +7 -7
- package/dist/{chunk-vbmvft7g.js → chunk-v0yay1kw.js} +1 -1
- package/dist/{chunk-2sz1kh9m.js → chunk-va4xam1q.js} +1 -1
- package/dist/chunk-vbh5tknp.js +2 -0
- package/dist/{chunk-q33x40dg.js → chunk-vmphrcaa.js} +2 -2
- package/dist/{chunk-s8v6dxhg.js → chunk-w1pga3s6.js} +4 -4
- package/dist/{chunk-bzd387yx.js → chunk-w3y8408q.js} +4 -4
- package/dist/chunk-w4177qn3.js +3 -0
- package/dist/{chunk-esm0pnpz.js → chunk-w98yt4d4.js} +2 -2
- package/dist/{chunk-7nn5s0c3.js → chunk-wbsbrm6n.js} +30 -30
- package/dist/chunk-wchz1sye.js +2 -0
- package/dist/{chunk-9ze3xvsr.js → chunk-wk6g0b9h.js} +4 -4
- package/dist/{chunk-m0p328a3.js → chunk-wna2herj.js} +3 -3
- package/dist/{chunk-71d353be.js → chunk-wxk0t61p.js} +3 -3
- package/dist/chunk-x1svtz8k.js +2 -0
- package/dist/{chunk-qt2mr3f0.js → chunk-x39v2ch2.js} +5 -5
- package/dist/chunk-xahn0h9f.js +2 -0
- package/dist/{chunk-65c11t6g.js → chunk-xfjp5q2m.js} +15 -15
- package/dist/{chunk-27qkwvbe.js → chunk-xpcqyzdc.js} +2 -2
- package/dist/chunk-ykx4zt07.js +2 -0
- package/dist/{chunk-w10vj4rc.js → chunk-yqs88qj4.js} +6 -6
- package/dist/chunk-yt8k715e.js +2 -0
- package/dist/{chunk-g32hc78c.js → chunk-yzgtsrjb.js} +2 -2
- package/dist/{chunk-btyb4bfz.js → chunk-z0d1asbw.js} +2 -2
- package/dist/{chunk-tx27trcp.js → chunk-zcwx8z8z.js} +5 -5
- package/dist/{chunk-t14bn66j.js → chunk-zk1c6tg7.js} +3 -3
- package/dist/{chunk-9rxxm68c.js → chunk-zrsrhdxw.js} +3 -3
- package/dist/cli.js +21 -21
- package/dist/client-parameter-bindings.js +12 -5
- package/dist/component-renderer.js +2 -24
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/runtime/craft-bridge.js +5 -1
- package/dist/native/runtime/craft.d.ts +4 -0
- package/dist/offline/app-service-worker.d.ts +1 -0
- package/dist/offline/app-service-worker.js +99 -17
- package/dist/production-server.d.ts +0 -9
- package/dist/production-server.js +26 -11
- package/dist/pwa.js +3 -3
- package/dist/route-response-cache.js +4 -3
- package/dist/server-bindings.js +3 -1
- package/dist/spa-nav.d.ts +6 -0
- package/dist/spa-nav.js +5 -1
- package/dist/ssg.js +10 -10
- package/dist/stx-virtual-ts.d.ts +4 -0
- package/dist/stx-virtual-ts.js +22 -0
- package/dist/utils.js +22 -2
- package/package.json +5 -5
- package/dist/chunk-0ht6exrv.js +0 -2
- package/dist/chunk-1pbghytr.js +0 -2
- package/dist/chunk-31r1tk86.js +0 -2
- package/dist/chunk-3ahvypx3.js +0 -2
- package/dist/chunk-576wtm6d.js +0 -2
- package/dist/chunk-5astk182.js +0 -2
- package/dist/chunk-5g5khx0m.js +0 -3
- package/dist/chunk-5tvse0vw.js +0 -2
- package/dist/chunk-5zcjcyys.js +0 -2
- package/dist/chunk-6h6aahc8.js +0 -2
- package/dist/chunk-726w7fm2.js +0 -2
- package/dist/chunk-7r294vc9.js +0 -2
- package/dist/chunk-7rn7w53f.js +0 -2
- package/dist/chunk-81qvg3yd.js +0 -2
- package/dist/chunk-96jntfwp.js +0 -3
- package/dist/chunk-9pjzj75t.js +0 -2
- package/dist/chunk-a1k0aj2r.js +0 -2
- package/dist/chunk-am2v9pqa.js +0 -2
- package/dist/chunk-cb9h2wwq.js +0 -2
- package/dist/chunk-cp82351f.js +0 -2
- package/dist/chunk-cvxg2rc1.js +0 -2
- package/dist/chunk-dmc91qke.js +0 -2
- package/dist/chunk-dpgc8wmw.js +0 -2
- package/dist/chunk-dw23nre3.js +0 -2
- package/dist/chunk-dyz7cmf4.js +0 -2
- package/dist/chunk-fznzn35q.js +0 -2
- package/dist/chunk-gyzebnpx.js +0 -2
- package/dist/chunk-hc8ks7y3.js +0 -2
- package/dist/chunk-hs2a040z.js +0 -2
- package/dist/chunk-jr3fmkq7.js +0 -2
- package/dist/chunk-k2fw6paw.js +0 -2
- package/dist/chunk-k79dvx67.js +0 -2
- package/dist/chunk-kf6j1ht4.js +0 -2
- package/dist/chunk-km1k3c4e.js +0 -2
- package/dist/chunk-kvjbpbmw.js +0 -2
- package/dist/chunk-m2dgf6pt.js +0 -2
- package/dist/chunk-mhv84p0x.js +0 -2
- package/dist/chunk-mmk5xqhr.js +0 -2
- package/dist/chunk-pd8ck9p3.js +0 -2
- package/dist/chunk-pjpy86c3.js +0 -3
- package/dist/chunk-q3ztpbz4.js +0 -2
- package/dist/chunk-qchmvwds.js +0 -2
- package/dist/chunk-qx4wkt90.js +0 -2
- package/dist/chunk-qzx6h6af.js +0 -2
- package/dist/chunk-r9rwdg9k.js +0 -3
- package/dist/chunk-s0sxq6ap.js +0 -2
- package/dist/chunk-scdkctdb.js +0 -2
- package/dist/chunk-sxqq3tft.js +0 -2
- package/dist/chunk-tf0feafg.js +0 -2
- package/dist/chunk-tgwwa872.js +0 -2
- package/dist/chunk-tspqdt8e.js +0 -2
- package/dist/chunk-tzebte8p.js +0 -2
- package/dist/chunk-v0r6zb87.js +0 -2
- package/dist/chunk-vbq6vt0e.js +0 -2
- package/dist/chunk-vh9yx344.js +0 -2
- package/dist/chunk-vxtna1b1.js +0 -2
- package/dist/chunk-wh07jf0t.js +0 -2
- package/dist/chunk-x43x2c6v.js +0 -2
- package/dist/chunk-xqx8t9w5.js +0 -2
- package/dist/chunk-xzmsfrez.js +0 -2
- package/dist/chunk-ymeemdg9.js +0 -42
- package/dist/chunk-z33r3pzy.js +0 -2
- package/dist/chunk-z43xcwnk.js +0 -2
- package/dist/chunk-zb6fa26w.js +0 -2
- package/dist/chunk-zkr42285.js +0 -2
- package/dist/chunk-zrs22j09.js +0 -2
- package/dist/chunk-zve1xqvs.js +0 -2
- package/dist/chunk-zw6tgr0s.js +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import x from"fs";import u from"path";import p from"fs";import w from"path";var y=["components","layouts","partials","emails"];function M(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return M(e.replace(/^\//,""))}function
|
|
3
|
-
`),o=w.join(t,"route-types.d.ts");try{if(p.existsSync(o)&&p.readFileSync(o,"utf8")===n)return;p.mkdirSync(t,{recursive:!0}),p.writeFileSync(o,n)}catch{}}function
|
|
4
|
-
`))}import I from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),D=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),G=new RegExp(`\\.(?:${D})$`),E=`(?![^/]*\\.(?:${D})$)`;function Dt(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&G.test(r)}function R(e,t){let r=I.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(I.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 Se(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function $r(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function Ws(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return Se(a,t)}import X from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(X.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function B(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...B(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class Rr{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((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=B(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:j,params:O}=Se(g,{page:!0}),T=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:j,params:O,filePath:h,isDynamic:O.length>0,layout:T.length>0?T[T.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Ci(this.routes,s),Ei(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((o,i)=>{n[o]=r[i+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,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));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 qs(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function Ks(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function xg(e){k=e.replace(/\/$/,"")}function Sg(e,t,a={}){f[e]={path:t,name:e,params:a}}function kg(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 Ar(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function _g(){for(let e of Object.keys(f))delete f[e];k=""}import F from"fs";import q from"path";function Cg(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Eg(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function Tg(e,t={}){return{handler:e,mode:t.mode??"universal"}}function P(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(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 Yc(e,t){let a=e.headers.get("cookie")||"",r=P(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function Zc(){return{get(e){if(typeof document>"u")return;return P(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return P(document.cookie)}}}function Qc(){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}}}var v=new Map;function Ti(e,t){v.set(e,t)}function el(e){return v.get(e)}function $g(e){return v.has(e)}function Lt(){v.clear()}function jt(){return Array.from(v.keys())}async function Bt(e,t="middleware"){let a=q.resolve(e,t);if(!F.existsSync(a))return;let r=F.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=q.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")Ti(o,s);else if(typeof s==="function")Ti(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function K(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function Ft(e,t,a,r=""){return{path:e,params:t,query:K(r),fullPath:r?`${e}?${r}`:e,meta:a}}function zt(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?Yc(a,i):Zc(),storage:Qc(),state:{},request:a,responseHeaders:i}}async function Ht(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=el(n);if(!o)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(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function Gs(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 pt(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]||Gs(n)}}var A,C;function W(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function U(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0,syntax:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").replace(/<\/script/gi,"<\\/script").trim()}catch{return e}}function H(){return`
|
|
2
|
+
import x from"fs";import u from"path";import p from"fs";import w from"path";var y=["components","layouts","partials","emails"];function M(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return M(e.replace(/^\//,""))}function Ti(e,t){let a=e.filter((i)=>!b(i.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 i of a){let c=[];for(let l of i.params){let d=i.pattern.includes(`:${l}?`)?"?":"";c.push(`${l}${d}: string`)}let s=c.join("; ");r.push(` '${i.pattern}': { ${s} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
|
|
3
|
+
`),o=w.join(t,"route-types.d.ts");try{if(p.existsSync(o)&&p.readFileSync(o,"utf8")===n)return;p.mkdirSync(t,{recursive:!0}),p.writeFileSync(o,n)}catch{}}function $i(e,t,a){let r=process.cwd(),n=w.relative(r,a),o=e.filter((c)=>!b(c.pattern)),i=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let c of o){let s=w.relative(r,c.filePath).replace(/\\/g,"/"),l=JSON.stringify(c.params),d=c.layout?`, layout: '${w.relative(r,c.layout).replace(/\\/g,"/")}'`:"";i.push(` { pattern: '${c.pattern}', filePath: '${s}', isDynamic: ${c.isDynamic}, params: ${l}${d} },`)}i.push("] as const",""),i.push("export type RouteName = typeof routes[number]['pattern']",""),p.mkdirSync(t,{recursive:!0}),p.writeFileSync(w.join(t,"routes.ts"),i.join(`
|
|
4
|
+
`))}import I from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),D=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),K=new RegExp(`\\.(?:${D})$`),E=`(?![^/]*\\.(?:${D})$)`;function Dt(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&K.test(r)}function R(e,t){let r=I.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(I.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 Se(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function Rr(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function Ks(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return Se(a,t)}import W from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(W.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function B(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...B(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class Ar{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((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=B(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:j,params:O}=Se(g,{page:!0}),T=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:j,params:O,filePath:h,isDynamic:O.length>0,layout:T.length>0?T[T.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Ti(this.routes,s),$i(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((o,i)=>{n[o]=r[i+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,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));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 Xs(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function Gs(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function _g(e){k=e.replace(/\/$/,"")}function Cg(e,t,a={}){f[e]={path:t,name:e,params:a}}function Eg(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 Pr(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Tg(){for(let e of Object.keys(f))delete f[e];k=""}import F from"fs";import U from"path";function $g(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Rg(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function Ag(e,t={}){return{handler:e,mode:t.mode??"universal"}}function P(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(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 el(e,t){let a=e.headers.get("cookie")||"",r=P(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function tl(){return{get(e){if(typeof document>"u")return;return P(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return P(document.cookie)}}}function nl(){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}}}var v=new Map;function Ri(e,t){v.set(e,t)}function rl(e){return v.get(e)}function Pg(e){return v.has(e)}function Lt(){v.clear()}function jt(){return Array.from(v.keys())}async function Bt(e,t="middleware"){let a=U.resolve(e,t);if(!F.existsSync(a))return;let r=F.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")Ri(o,s);else if(typeof s==="function")Ri(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function z(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function Ft(e,t,a,r=""){return{path:e,params:t,query:z(r),fullPath:r?`${e}?${r}`:e,meta:a}}function zt(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?el(a,i):tl(),storage:nl(),state:{},request:a,responseHeaders:i}}async function Ht(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=rl(n);if(!o)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(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function Cn(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 We(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]||Cn(n)}}var q="X-STX-Have-Layout",H="X-STX-Have-Layout-Group";function Ai(e,t){let a=e.group||Cn(e.layout),r=t.group||Cn(t.layout);if(a!==r)return!0;return Boolean(e.layout&&t.layout&&e.layout!==t.layout)}function Pi(e){let t=e.get(q),a=e.get(H);if(t===null&&a===null)return null;return{layout:t??"",group:a??""}}var A,C;function V(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function G(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0,syntax:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").replace(/<\/script/gi,"<\\/script").trim()}catch{return e}}function X(){return`
|
|
5
5
|
;(function(){
|
|
6
6
|
'use strict';
|
|
7
7
|
var ROUTER_REV=8;
|
|
8
8
|
if(window.__stxRouter&&window.__stxRouter.__rev===ROUTER_REV)return;
|
|
9
9
|
|
|
10
10
|
// \u2500\u2500 Configuration \u2500\u2500
|
|
11
|
-
var defaults={container:'main',loadingClass:'stx-navigating',viewTransitions:true,cache:true,scrollToTop:true,prefetch:true,progress:true,progressColor:'#78dce8',progressHeight:'2px',interceptAllLinks:false,prefetchCacheMax:50,routeFocus:true,announceRoute:true,interceptForms:false,cssLoadTimeout:1500,scrollRestoration:true,screens:'auto',screenLimit:8,navDuration:350,swipeBack:true,swipeEdge:20,prefetchVisible:true,prefetchVisibleMax:12,revalidate:true,revalidateAfter:3000,keepOpening:true};
|
|
11
|
+
var defaults={container:'main',loadingClass:'stx-navigating',viewTransitions:true,cache:true,scrollToTop:true,prefetch:true,progress:true,progressColor:'#78dce8',progressHeight:'2px',interceptAllLinks:false,prefetchCacheMax:50,routeFocus:true,announceRoute:true,interceptForms:false,cssLoadTimeout:1500,scrollRestoration:true,screens:'auto',screenLimit:8,navDuration:350,swipeBack:true,swipeEdge:20,prefetchVisible:true,prefetchVisibleMax:12,revalidate:true,revalidateAfter:3000,keepOpening:true,navigationTimeout:10000};
|
|
12
12
|
var o=Object.assign({},defaults,window.__stxRouterConfig||{},window.STX_ROUTER_OPTIONS||{});
|
|
13
13
|
var containerSel=o.container;
|
|
14
14
|
var debug=!!o.debug;
|
|
@@ -1260,11 +1260,29 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
1260
1260
|
// fresh: past every cache, the offline worker's included (it hands a
|
|
1261
1261
|
// no-store request straight to the network). For recoverUnbound, whose
|
|
1262
1262
|
// whole point is that the kept copy is the broken one.
|
|
1263
|
+
//
|
|
1264
|
+
// A fragment request says which layout this page is on, so a server can
|
|
1265
|
+
// answer a page on another layout with the whole document at once. The
|
|
1266
|
+
// router used to read that fragment, see the layout change and fetch the
|
|
1267
|
+
// page again, and the server rendered it twice for one click.
|
|
1268
|
+
//
|
|
1269
|
+
// And a navigation has a time limit (navigationTimeout, 0 for none). Past
|
|
1270
|
+
// it the browser loads the page itself: a server that has not answered is
|
|
1271
|
+
// better waited on by the browser, with its own spinner and stop button,
|
|
1272
|
+
// than behind a link that looks as if it was never pressed.
|
|
1263
1273
|
function routerFetch(url,headers,fresh){
|
|
1264
|
-
|
|
1265
|
-
|
|
1274
|
+
if(headers['X-STX-Router'])haveLayoutHeaders(headers);
|
|
1275
|
+
var init={headers:headers},abort=navAbort,limit=+o.navigationTimeout||0,timer;
|
|
1276
|
+
if(abort)init.signal=abort.signal;
|
|
1266
1277
|
if(fresh)init.cache='no-store';
|
|
1267
|
-
|
|
1278
|
+
// The controller says it was the limit, so failed() loads the page.
|
|
1279
|
+
if(abort&&limit>0)timer=setTimeout(function(){abort.late=1;abort.abort()},limit);
|
|
1280
|
+
return fetch(url,init).finally(function(){clearTimeout(timer)});
|
|
1281
|
+
}
|
|
1282
|
+
function haveLayoutHeaders(h){
|
|
1283
|
+
var m=qs(LAYOUT_META);
|
|
1284
|
+
h['X-STX-Have-Layout']=m&&m.getAttribute('content')||'';
|
|
1285
|
+
h['X-STX-Have-Layout-Group']=getCurrentLayoutGroup();
|
|
1268
1286
|
}
|
|
1269
1287
|
function navigate(url,pushState,force){
|
|
1270
1288
|
// Tenant shells can keep their explicit scope on links and programmatic
|
|
@@ -1358,7 +1376,9 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
1358
1376
|
// in place of its content, where a document load used to be the answer
|
|
1359
1377
|
// to everything -- offline that load is the offline page, or nothing.
|
|
1360
1378
|
function failed(err){
|
|
1361
|
-
if(stale()
|
|
1379
|
+
if(stale())return false;
|
|
1380
|
+
if(navAbort&&navAbort.late){location.assign(url);return false}
|
|
1381
|
+
if(err&&err.name==='AbortError')return false;
|
|
1362
1382
|
console.error('[router] fetch error:',err);
|
|
1363
1383
|
return showNavError(url,err,pushState,targetHash,ctx);
|
|
1364
1384
|
}
|
|
@@ -3293,7 +3313,7 @@ else {
|
|
|
3293
3313
|
// screen is never swapped out from under the user.
|
|
3294
3314
|
function prefetchHeaders(fragment){
|
|
3295
3315
|
var headers={'Accept':'text/html','Purpose':'prefetch'};
|
|
3296
|
-
if(fragment)headers['X-STX-Router']='true';
|
|
3316
|
+
if(fragment){headers['X-STX-Router']='true';haveLayoutHeaders(headers)}
|
|
3297
3317
|
return headers;
|
|
3298
3318
|
}
|
|
3299
3319
|
function revalidate(key,url){
|
|
@@ -4218,4 +4238,4 @@ else {
|
|
|
4218
4238
|
|
|
4219
4239
|
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
|
|
4220
4240
|
})();
|
|
4221
|
-
`}function ft(){if(A)return A;return A=
|
|
4241
|
+
`}function ft(){if(A)return A;return A=G(V(X()),!0),A}function Ig(){if(C)return C;return C=G(X()),C}export{Ti,$i,Dt,Se,Rr,Ks,Ar,Xs,Gs,_g,Cg,Eg,Pr,Tg,$g,Rg,Ag,el,tl,nl,Ri,rl,Pg,Lt,jt,Bt,Ft,zt,Ht,Cn,We,Ai,Pi,ft,Ig};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{qa,Bu,rr,fh,Fu,zu,Hu,gh}from"./chunk-wxk0t61p.js";import"./chunk-fds6vvq0.js";import"./chunk-ab1z38gj.js";import"./chunk-w98yt4d4.js";import"./chunk-c08jvjqt.js";import"./chunk-phzhmnnm.js";import"./chunk-ck4ypzet.js";import"./chunk-0jdz31q1.js";import"./chunk-4b110x6r.js";export{rr as Validator,Bu as defineForm,Fu as processErrorDirective,zu as processErrorsDirective,gh as processFormValidationDirectives,Hu as processHasErrorsDirective,qa as useForm,fh as v};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Z}from"./chunk-
|
|
3
|
-
`)}async function
|
|
2
|
+
import{Z}from"./chunk-13awnyq0.js";import R from"path";var B=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function ns(...d){let g=new Set;for(let l of d){if(!l||!l.includes("__stxModules["))continue;for(let e of l.matchAll(B))try{g.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...g].sort()}function $o(...d){let g=new Map,l=(e,n)=>{let o=g.get(e);if(o===null)return;if(n===null){g.set(e,null);return}let s=o??new Set;for(let i of n)s.add(i);g.set(e,s)};for(let e of d){if(!e||!e.includes("__stxModules["))continue;let n=[];for(let s of e.matchAll(/([\w$]+)\s*=\s*globalThis\.__stxModules\s*&&\s*globalThis\.__stxModules\["((?:[^"\\]|\\.)*)"\]/g)){let i;try{i=JSON.parse(`"${s[2]}"`)}catch{continue}n.push({variable:s[1],id:i,start:s.index+s[0].length,end:e.length})}let o=e.match(/__stxModules\["(?:[^"\\]|\\.)*"\]/g)?.length??0;if(n.length===0||o!==n.length){for(let s of ns(e))l(s,null);continue}for(let[s,i]of n.entries()){let p=n.slice(s+1).find((h)=>h.variable===i.variable);i.end=p?p.start:e.length}for(let s of n){let i=new Set,p=!1,h=s.variable.replace(/[$]/g,"\\$&"),r=e.slice(s.start,s.end);for(let a of r.matchAll(new RegExp(`(?<![\\w$.])${h}(?![\\w$])`,"g"))){let f=r.slice(a.index+s.variable.length,a.index+s.variable.length+200),c=/^\s*\[\s*(["'])([A-Za-z_$][\w$]*)\1\s*\]/.exec(f)??/^\s*\.\s*([A-Za-z_$][\w$]*)/.exec(f);if(c){i.add(c[c.length-1]);continue}if(/^\s*[!=]==?\s*(?:undefined|void 0)\b/.test(f))continue;p=!0;break}l(s.id,p?null:i)}}return g}function k(d,g,l){let e=[],n=[];return d.forEach((o,s)=>{let i=o.startsWith("npm:")?o.slice(4):R.resolve(g,o),p=`__stxRegistered${s}`,h=JSON.stringify(o),r=l?.get(o);if(r&&[...r].every((a)=>/^[A-Za-z_$][\w$]*$/.test(a))){let a=[...r].sort(),f=a.map((m,_)=>`${m} as ${p}_${_}`);e.push(a.length>0?`import { ${f.join(", ")} } from ${JSON.stringify(i)};`:`import ${JSON.stringify(i)};`);let c=a.map((m,_)=>`get ${JSON.stringify(m)}() { return ${p}_${_}; }`).join(", ");n.push(`if (!globalThis.__stxModules[${h}]) globalThis.__stxModules[${h}] = { ${c} };`);return}e.push(`import * as ${p} from ${JSON.stringify(i)};`),n.push(`if (!globalThis.__stxModules[${h}]) globalThis.__stxModules[${h}] = ${p};`)}),[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...n].join(`
|
|
3
|
+
`)}async function vm(d,g={}){if(d.length===0)return null;let l=process.cwd(),e=k(d,l,g.names),n;try{let{bundleClientScript:f}=await import("./chunk-4dh1b9yr.js"),c=()=>f(e,R.join(l,".stx-module-registry.ts"),{projectRoot:l,minify:g.minify,externalizeUserModules:!1,collectInputs:g.collectInputs,throwOnFailure:!0});try{n=await c()}catch(m){if(!g.names)throw m;e=k(d,l,void 0),n=await c()}}catch(f){let{formatBuildFailure:c}=await import("./chunk-nrap20qt.js"),m=c(f);console.warn(`[stx] could not build the page module registry (#1957): ${m}`);let _=`[stx] the page module registry did not build, so ${d.join(", ")} cannot load (#1957): ${m}`;return`;console.error(${JSON.stringify(_)});`}let{transformAutoImports:o,generateAutoImportDestructuring:s}=await import("./chunk-4a6mptfc.js"),i=o(n),p=s(i.stxImports,i.browserImports),{transformStoreImports:h}=await import("./chunk-q9yahsww.js");n=h(i.code);let r=JSON.stringify(new Bun.CryptoHasher("md5").update(e).digest("hex").slice(0,12)),a=Z(n);return[a?";await (async function() {":";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${r}]) { ${a?"await __stxBundles["+r+"];":""} return; }`,a?`var __resolveBundle, __rejectBundle;
|
|
4
4
|
__stxBundles[${r}]=new Promise(function(resolve,reject){__resolveBundle=resolve;__rejectBundle=reject;});
|
|
5
5
|
__stxBundles[${r}].catch(function(){});
|
|
6
6
|
try {`:`__stxBundles[${r}] = true;`,p,n,a?`__resolveBundle();
|
|
7
7
|
} catch(error) { delete __stxBundles[${r}]; __rejectBundle(error); throw error; }`:"","})();"].join(`
|
|
8
8
|
`)}var j=/^import(?:[ \t]*(\{[^}]*\})[ \t]*from|[ \t]*\*[ \t]*as[ \t]+([\w$]+)[ \t]+from)?[ \t]*["']\.\/(chunk-[\w-]+)\.js["'][ \t]*;?[ \t]*$/gm,O=/^export\s*\{([^}]*)\}\s*;?[ \t]*$/gm,I=new Set(["__preload","__chunks"]),N=/^("[^"]*"|[\w$]+)(?:\s+as\s+("[^"]*"|[\w$]+))?$/;function P(d){let g=[],l=[],e=!0,o=d.replace(/^var __chunkGraphs;[\s\S]*?^var __chunks = [\s\S]*?^\};[ \t]*\n?/m,"").replace(/^__chunks\(import\.meta\.url,[^\n]*\);[ \t]*\n?/gm,"").replace(j,(h,r,a,f)=>{let c=`__stxChunkExports${g.length}`;if(g.push(f),l.push(`var ${c} = __stxChunk(${JSON.stringify(f)});`),a)l.push(`var ${a} = ${c};`);else if(r)for(let m of r.slice(1,-1).split(",")){let _=m.trim();if(!_)continue;let w=N.exec(_);if(!w){e=!1;continue}if(I.has(w[1]))continue;let M=w[1].startsWith('"')?JSON.parse(w[1]):w[1],t=w[2]??w[1];if(t.startsWith('"')){e=!1;continue}l.push(`var ${t} = ${c}[${JSON.stringify(M)}];`)}return""});if(!e)throw Error("an import it does not read");let s=[];o=o.replace(/\(\s*__preload\([^)]*\)\s*,\s*import\(\s*["']\.\/(chunk-[\w-]+)\.js["']\s*\)\s*\)|\bimport\(\s*["']\.\/(chunk-[\w-]+)\.js["']\s*\)/g,(h,r,a)=>{let f=r??a;return s.push(f),`Promise.resolve().then(function () { return __stxChunk(${JSON.stringify(f)}); })`});let i=[];o=o.replace(O,(h,r)=>{for(let a of r.split(",")){let f=a.trim();if(!f)continue;let c=N.exec(f);if(!c||c[1].startsWith('"')){e=!1;continue}if(I.has(c[1]))continue;let m=c[2]??c[1];i.push([c[1],m.startsWith('"')?JSON.parse(m):m])}return""});let p=[/\bimport\.meta\b/,/\b__chunks\b/,/\b__preload\b/,/^\s*export\s+(?:default\b|const\b|let\b|var\b|function\b|class\b|async\b|\*|\{)/m,/\bfrom\s*["']\.\/chunk-/,/^\s*import\s*["']\.\/chunk-/m].find((h)=>h.test(o));if(!e||p)throw Error(`${p?`${p.source} is left in it`:"an export it does not read"}`);return{reads:l.join(`
|
|
9
|
-
`),chunks:g,lazy:s,body:o,exports:i}}function
|
|
10
|
-
`).length)>200)return!1;for(let g of d.matchAll(/\bexport\s*\{([^}]*)\}(?!\s*from\b)/g))for(let l of g[1].split(",")){let e=l.trim().split(/\s+as\s+/)[0].trim();if(!/^[A-Za-z_$][\w$]*$/.test(e))continue;let n=e.replace(/[$]/g,"\\$&");if(!new RegExp(`(?<![\\w$.])(?:let|var)\\s+${n}(?![\\w$])`,"g").test(d))continue;let s=new RegExp(`(?<![\\w$.])${n}\\s*(?:=(?![=>])|[-+*/%&|^]=|\\*\\*=|<<=|>>>?=|&&=|\\|\\|=|\\?\\?=|\\+\\+|--)|(?:\\+\\+|--)\\s*${n}(?![\\w$])`,"g"),i=new RegExp(`(?<![\\w$.])(?:let|var|const)\\s+${n}\\s*=`,"g");if((d.match(s)?.length??0)>(d.match(i)?.length??0))return!0}return!1}async function
|
|
9
|
+
`),chunks:g,lazy:s,body:o,exports:i}}function su(d){if(/\bexport\s+(?:let|var)\b/.test(d))return!0;if(d.length/Math.max(1,d.split(`
|
|
10
|
+
`).length)>200)return!1;for(let g of d.matchAll(/\bexport\s*\{([^}]*)\}(?!\s*from\b)/g))for(let l of g[1].split(",")){let e=l.trim().split(/\s+as\s+/)[0].trim();if(!/^[A-Za-z_$][\w$]*$/.test(e))continue;let n=e.replace(/[$]/g,"\\$&");if(!new RegExp(`(?<![\\w$.])(?:let|var)\\s+${n}(?![\\w$])`,"g").test(d))continue;let s=new RegExp(`(?<![\\w$.])${n}\\s*(?:=(?![=>])|[-+*/%&|^]=|\\*\\*=|<<=|>>>?=|&&=|\\|\\|=|\\?\\?=|\\+\\+|--)|(?:\\+\\+|--)\\s*${n}(?![\\w$])`,"g"),i=new RegExp(`(?<![\\w$.])(?:let|var|const)\\s+${n}\\s*=`,"g");if((d.match(s)?.length??0)>(d.match(i)?.length??0))return!0}return!1}async function Ro(d,g={}){let l=d.filter((n)=>n.ids.length>0);if(l.length===0)return{chunks:new Map,routes:new Map,reads:new Map};let e=process.cwd();try{let{bundleClientEntriesSplit:n}=await import("./chunk-4dh1b9yr.js"),o=[],s=await n(new Map(l.map((t)=>[t.name,k(t.ids,e,t.names)])),{projectRoot:e,filePath:R.join(e,".stx-module-registry.ts"),collectInputs:o});g.collectInputs?.push(...o);let{transformAutoImports:i,generateAutoImportDestructuring:p}=await import("./chunk-4a6mptfc.js"),{transformStoreImports:h}=await import("./chunk-q9yahsww.js"),r=new Map;for(let[t,u]of[...s.chunks,...s.entries])try{r.set(t,P(u))}catch(x){throw Error(`cannot read ${t}: ${x instanceof Error?x.message:String(x)}`)}for(let[t,u]of[...s.chunks,...s.entries])if(/\b__esm\(/.test(u))throw Error(`${t} initialises a module lazily`);for(let t of o)if(/\.(?:[cm]?[jt]sx?)$/.test(t)&&su(await Bun.file(t).text()))throw Error(`${t} exports a binding that changes after it is read`);let a=new Set,f=new Set,c=(t)=>{if(f.has(t))return;if(a.has(t))throw Error(`the chunks import each other (${t})`);a.add(t);for(let u of r.get(t)?.chunks??[]){if(!r.has(u))throw Error(`${t} imports ${u}, which was not built`);c(u)}for(let u of r.get(t)?.lazy??[])if(!r.has(u))throw Error(`${t} imports ${u}, which was not built`);a.delete(t),f.add(t)};for(let t of r.keys())c(t);let m=(t)=>{let u=i(t.body);return{prelude:p(u.stxImports,u.browserImports),body:h(u.code)}},_=new Map;for(let t of s.chunks.keys()){let u=r.get(t),{prelude:x,body:v}=m(u),b=u.exports.map(([S,y])=>`get ${JSON.stringify(y)}() { return ${S}; }`).join(", ");_.set(t,`function (__stxChunk) {
|
|
11
11
|
${x}
|
|
12
12
|
${u.reads}
|
|
13
13
|
${v}
|
|
@@ -17,5 +17,5 @@ var __stxChunk = function (name) { return globalThis.__stxNativeRuntime.chunk(na
|
|
|
17
17
|
${x}
|
|
18
18
|
${u.reads}
|
|
19
19
|
${v}
|
|
20
|
-
})();`);let b=new Set,S=(y)=>{if(b.has(y))return;b.add(y);let E=r.get(y);for(let A of[...E.chunks,...E.lazy])S(A)};for(let y of[...u.chunks,...u.lazy])S(y);M.set(t,[...b].sort())}return{chunks:_,routes:w,reads:M}}catch(n){let{formatBuildFailure:o}=await import("./chunk-
|
|
21
|
-
export{
|
|
20
|
+
})();`);let b=new Set,S=(y)=>{if(b.has(y))return;b.add(y);let E=r.get(y);for(let A of[...E.chunks,...E.lazy])S(A)};for(let y of[...u.chunks,...u.lazy])S(y);M.set(t,[...b].sort())}return{chunks:_,routes:w,reads:M}}catch(n){let{formatBuildFailure:o}=await import("./chunk-nrap20qt.js");return console.warn(`[stx] could not share the native routes' modules, building each route's alone: ${o(n)}`),null}}
|
|
21
|
+
export{ns,$o,vm,su,Ro};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{T}from"./chunk-0jdz31q1.js";import{ne}from"./chunk-
|
|
3
|
-
${e.message}`),t&&e.line){let o=
|
|
2
|
+
import{T}from"./chunk-0jdz31q1.js";import{ne}from"./chunk-e5rag6rh.js";import{L}from"./chunk-8tfpv6zf.js";import je from"path";var n={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function J(e){for(let[t,r]of Object.entries(n))if(r===e)return t;return}import ut from"path";var gt={showRelativePaths:!1,enableAutoRecovery:ne(),logRecoveryWarnings:!0},Z={...gt};function P(){return{...Z}}function F(e){if(!Z.showRelativePaths||!e)return e;let t=Z.baseDir||process.cwd();try{let r=ut.relative(t,e);return r.startsWith("..")?e:r}catch{return e}}class N extends Error{code;filePath;line;column;context;numericCode;constructor(e,t,r,i,s,o,a){super(e);this.code=t;this.filePath=r;this.line=i;this.column=s;this.context=o;if(this.name="StxError",this.numericCode=a||n.EVALUATION_ERROR,this.filePath)this.filePath=F(this.filePath)}}class ce extends N{constructor(e,t,r,i,s,o){super(e,"stx_RUNTIME_ERROR",t,r,i,s,o||n.EVALUATION_ERROR);this.name="StxRuntimeError"}}class Vr extends N{constructor(e,t,r,i,s,o){super(e,"stx_FILE_ERROR",t,r,i,s,o||n.FILE_NOT_FOUND);this.name="StxFileError"}}class te extends N{isFatal=!0;constructor(e,t,r,i,s,o){super(e,"stx_VALIDATION_ERROR",t,r,i,s,o||n.DOM_API_VIOLATION);this.name="StxValidationError"}}function xe(e){let{type:t,message:r,code:i,filePath:s,line:o,column:a,template:c,offset:g,snippet:l,suggestion:h,format:f="text"}=e,y=o,b=a;if(!y&&c&&g!==void 0){let Y=Et(c,g);y=Y.line,b=Y.column}let w=s?F(s):void 0,x=i?J(i):void 0,v={type:t,code:i,codeName:x,message:r,filePath:w,line:y,column:b,snippet:l,suggestion:h,timestamp:new Date().toISOString()},C;switch(f){case"html":C=ft(v);break;case"json":C=JSON.stringify(v,null,2);break;case"console":C=dt(v,c,g);break;case"text":default:C=pt(v,c,g);break}return{formatted:C,data:v}}function pt(e,t,r){let i=[],s=e.code?` [${e.codeName||e.code}]`:"";if(i.push(`[${e.type} Error${s}]`),e.filePath){let o=e.filePath;if(e.line){if(o+=`:${e.line}`,e.column)o+=`:${e.column}`}i.push(`at ${o}`)}if(i.push(`
|
|
3
|
+
${e.message}`),t&&e.line){let o=mt(t,e.line,2);if(o)i.push(`
|
|
4
4
|
${o}`)}if(e.snippet)i.push(`
|
|
5
5
|
Snippet: ${e.snippet}`);if(e.suggestion)i.push(`
|
|
6
|
-
Suggestion: ${e.suggestion}`);return i.join(" ")}function
|
|
6
|
+
Suggestion: ${e.suggestion}`);return i.join(" ")}function ft(e){let t=e.code?` [${e.code}]`:"",r=e.filePath?` in ${e.filePath}${e.line?`:${e.line}`:""}`:"",i=`<!-- [${e.type} Error${t}]${r}: ${ye(e.message)}`;if(e.suggestion)i+=` | Suggestion: ${ye(e.suggestion)}`;return i+=" -->",i}function dt(e,t,r){let l=[],h=e.code?` [${e.codeName||e.code}]`:"";if(l.push(`\x1B[1m${"\x1B[31m"}\u2501\u2501\u2501 ${e.type} Error${h} \u2501\u2501\u2501${"\x1B[0m"}`),e.filePath){let f=`\x1B[36m${e.filePath}\x1B[0m`;if(e.line){if(f+=`\x1B[90m:${e.line}\x1B[0m`,e.column)f+=`\x1B[90m:${e.column}\x1B[0m`}l.push(`
|
|
7
7
|
\x1B[90mat\x1B[0m ${f}`)}if(l.push(`
|
|
8
8
|
|
|
9
|
-
${e.message}`),t&&e.line){let f=
|
|
9
|
+
${e.message}`),t&&e.line){let f=ht(t,e.line,2);if(f)l.push(`
|
|
10
10
|
|
|
11
11
|
\x1B[90mContext:\x1B[0m
|
|
12
12
|
${f}`)}if(e.suggestion)l.push(`
|
|
13
13
|
|
|
14
14
|
\x1B[33mSuggestion:\x1B[0m ${e.suggestion}`);return l.push(`
|
|
15
|
-
${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${"\x1B[0m"}`),l.join("")}function
|
|
15
|
+
${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${"\x1B[0m"}`),l.join("")}function mt(e,t,r){let i=e.split(`
|
|
16
16
|
`),s=Math.max(0,t-r-1),o=Math.min(i.length-1,t+r-1),a=[];for(let c=s;c<=o;c++){let g=(c+1).toString().padStart(4),l=c===t-1?">":" ";a.push(`${l}${g} | ${i[c]}`)}return a.join(`
|
|
17
|
-
`)}function
|
|
17
|
+
`)}function ht(e,t,r){let i=e.split(`
|
|
18
18
|
`),s=Math.max(0,t-r-1),o=Math.min(i.length-1,t+r-1),a="\x1B[90m",c="\x1B[31m",g="\x1B[0m",l=[];for(let h=s;h<=o;h++){let f=(h+1).toString().padStart(4),y=h===t-1,b=y?"\x1B[31m>\x1B[0m":" ",w=y?`\x1B[31m${i[h]}\x1B[0m`:`\x1B[90m${i[h]}\x1B[0m`;l.push(`${b}\x1B[90m${f}\x1B[0m | ${w}`)}return l.join(`
|
|
19
|
-
`)}function ye(e){return e.replace(/--/g,"- -").replace(/>/g,">")}function
|
|
20
|
-
`);return{line:i.length,column:i[i.length-1].length}}function u(e,t,r){return
|
|
19
|
+
`)}function ye(e){return e.replace(/--/g,"- -").replace(/>/g,">")}function Et(e,t){let i=e.substring(0,t).split(`
|
|
20
|
+
`);return{line:i.length,column:i[i.length-1].length}}function u(e,t,r){return xe({type:e,message:t,code:r,format:"html"}).formatted}async function De(e,t,r){try{return await e()}catch(i){if(r&&i instanceof Error)r(i);return t}}var Qi={isEnabled(){return P().enableAutoRecovery},fixCommonSyntaxErrors(e){let t=P();if(!t.enableAutoRecovery)return{fixed:e,fixes:[]};let r=e,i=[],s=(r.match(/\{\{/g)||[]).length,o=(r.match(/\}\}/g)||[]).length;if(s>o){let c=s-o;r+="}}".repeat(c),i.push(`Added ${c} missing closing braces '}}'`)}let a=["if","foreach","for","switch","section"];for(let c of a){let g=(r.match(new RegExp(`@${c}\\b`,"g"))||[]).length,l=(r.match(new RegExp(`@end${c}\\b`,"g"))||[]).length;if(g>l){let h=g-l;for(let f=0;f<h;f++)r+=`
|
|
21
21
|
@end${c}`;i.push(`Added ${h} missing @end${c}`)}}if(i.length>0&&t.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),i.forEach((c)=>console.warn(` - ${c}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:r,fixes:i}},createFallbackContent(e,t){if(ne())return`<!-- ${e} failed: ${t.message} -->`;return"<!-- stx rendering error -->"}};class Q{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,t,r="error"){let i={timestamp:new Date,error:e,context:t,level:r};if(this.errors.push(i),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(r))this.writeToFile(i)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let t=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)t.push(` Stack: ${e.error.stack.split(`
|
|
22
22
|
`).slice(1).join(`
|
|
23
23
|
`)}`);if(e.context)t.push(` Context: ${JSON.stringify(e.context)}`);return t.join(`
|
|
24
24
|
`)}writeToFile(e){this.writeQueue=this.writeQueue.then(async()=>{try{let t=await import("fs"),r=await import("path"),i=r.dirname(this.logFilePath);if(!t.existsSync(i))t.mkdirSync(i,{recursive:!0});await this.rotateIfNeeded(t);let s=`${this.formatEntry(e)}
|
|
25
25
|
`;t.appendFileSync(this.logFilePath,s,"utf-8")}catch(t){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",t)}})}async rotateIfNeeded(e){try{if(!e.existsSync(this.logFilePath))return;if(e.statSync(this.logFilePath).size<this.maxFileSize)return;for(let r=this.maxLogFiles-1;r>=1;r--){let i=`${this.logFilePath}.${r}`,s=`${this.logFilePath}.${r+1}`;if(e.existsSync(i))if(r>=this.maxLogFiles-1)e.unlinkSync(i);else e.renameSync(i,s)}if(this.maxLogFiles<=1)e.writeFileSync(this.logFilePath,"");else e.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(t){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",t)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((t)=>t.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((t)=>t.level===e)}clear(){this.errors.length=0}async clearLogFile(){try{let e=await import("fs");if(e.existsSync(this.logFilePath))e.writeFileSync(this.logFilePath,"","utf-8")}catch(e){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",e)}}getStats(){let e={},t={error:0,warning:0,info:0};for(let r of this.errors){let i=r.error.constructor.name;e[i]=(e[i]||0)+1;let s=r.level||"error";t[s]=(t[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:t}}async exportToFile(e,t="json"){let r=await import("fs"),i=await import("path"),s=i.dirname(e);if(!r.existsSync(s))r.mkdirSync(s,{recursive:!0});if(t==="json"){let o=this.errors.map((a)=>({timestamp:a.timestamp.toISOString(),level:a.level||"error",type:a.error.constructor.name,message:a.error.message,stack:a.error.stack,context:a.context}));r.writeFileSync(e,JSON.stringify(o,null,2),"utf-8")}else{let o=this.errors.map((a)=>this.formatEntry(a));r.writeFileSync(e,o.join(`
|
|
26
26
|
|
|
27
|
-
`),"utf-8")}}async flush(){await this.writeQueue}}var K=new Q,
|
|
27
|
+
`),"utf-8")}}async flush(){await this.writeQueue}}var K=new Q,jn={isDevelopment(){return ne()},logDetailedError(e,t){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",e.message),console.error("Stack:",e.stack),t)console.error("Context:",t);console.error("========================")},createErrorReport(e,t){let r=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${e.message}`,`Type: ${e.constructor.name}`,`Stack: ${e.stack}`];if(t)r.push(`Context: ${JSON.stringify(t,null,2)}`);return r.push("========================"),r.join(`
|
|
28
28
|
`)}};class be{context;source;pos=0;line=1;column=0;tokens=[];constructor(e,t="template"){this.context=t;this.source=e}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let e=this.nextToken();if(e)this.tokens.push(e)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let e=this.pos,t=this.line,r=this.column,i=this.source[this.pos];if(/\s/.test(i))return this.readWhitespace(e,t,r);if(i==="/"&&this.peek(1)==="/")return this.readLineComment(e,t,r);if(i==="/"&&this.peek(1)==="*")return this.readBlockComment(e,t,r);if(i==='"'||i==="'")return this.readString(i,e,t,r);if(i==="`")return this.readTemplateString(e,t,r);if(/\d/.test(i)||i==="."&&/\d/.test(this.peek(1)||""))return this.readNumber(e,t,r);if(/[a-z_$]/i.test(i))return this.readIdentifier(e,t,r);if(this.context==="template"&&i==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:e,end:this.pos,line:t,column:r};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:e,end:this.pos,line:t,column:r};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:e,end:this.pos,line:t,column:r}}if(this.context==="template"&&i==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:e,end:this.pos,line:t,column:r};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:e,end:this.pos,line:t,column:r}}if(this.context==="template"&&i==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:e,end:this.pos,line:t,column:r};if(i==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective(e,t,r);let s=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let o of s)if(this.source.slice(this.pos,this.pos+o.length)===o)return this.advance(o.length),{type:"OPERATOR",value:o,start:e,end:this.pos,line:t,column:r};if(/[+\-*/%<>=!&|^~?:]/.test(i))return this.advance(),{type:"OPERATOR",value:i,start:e,end:this.pos,line:t,column:r};if(/[()[\]{},;.]/.test(i))return this.advance(),{type:"PUNCTUATION",value:i,start:e,end:this.pos,line:t,column:r};return this.advance(),{type:"PUNCTUATION",value:i,start:e,end:this.pos,line:t,column:r}}readWhitespace(e,t,r){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readLineComment(e,t,r){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
|
|
29
29
|
`)this.advance();return{type:"COMMENT",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readBlockComment(e,t,r){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readString(e,t,r,i){this.advance();while(this.pos<this.source.length){let s=this.source[this.pos];if(s==="\\"){this.advance(2);continue}if(s===e){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(t,this.pos),start:t,end:this.pos,line:r,column:i}}readTemplateString(e,t,r){this.advance();let i=0,s=256;while(this.pos<this.source.length){let o=this.source[this.pos];if(o==="\\"){this.advance(2);continue}if(o==="$"&&this.peek(1)==="{"){if(i>=s){this.pos=this.source.length;break}this.advance(2),i++;continue}if(o==="{"&&i>0){i++,this.advance();continue}if(o==="}"&&i>0){i--,this.advance();continue}if(o==="`"&&i===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readNumber(e,t,r){if(this.source[this.pos]==="0"){let i=this.peek(1)?.toLowerCase();if(i==="x"||i==="o"||i==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&(this.context==="javascript"||/\d/.test(this.peek(1)||""))){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readIdentifier(e,t,r){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readDirective(e,t,r){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}advance(e=1){for(let t=0;t<e&&this.pos<this.source.length;t++){if(this.source[this.pos]===`
|
|
30
|
-
`)this.line++,this.column=0;else this.column++;this.pos++}}peek(e){return this.source[this.pos+e]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState(e){this.pos=e.pos,this.line=e.line,this.column=e.column}}function _(e,t,r,i=0){let s=0,o=i,a=null,c=0,g=!1;while(o<e.length){let l=e[o];if(a&&g){g=!1,o++;continue}if(a&&l==="\\"){g=!0,o++;continue}if(g=!1,(l==='"'||l==="'"||l==="`")&&!a){a=l,o++;continue}if(l===a&&a!=="`"){a=null,o++;continue}if(a==="`"&&l==="$"&&e[o+1]==="{"){c++,o+=2;continue}if(c>0&&l==="}"){c--,o++;continue}if(l==="`"&&a==="`"&&c===0){a=null,o++;continue}if(a){o++;continue}if(l===t)s++;else if(l===r){if(s--,s===0)return o}o++}return-1}function Al(e,t){let r=t,i={paren:0,bracket:0,brace:0},s=null,o=0;while(r<e.length){let a=e[r];if((r>0?e[r-1]:"")==="\\"&&s){r++;continue}if((a==='"'||a==="'")&&!s){s=a,r++;continue}if(a===s&&s!=="`"){s=null,r++;continue}if(a==="`"&&!s){s="`",r++;continue}if(a==="`"&&s==="`"&&o===0){s=null,r++;continue}if(s==="`"&&a==="$"&&e[r+1]==="{"){o++,r+=2;continue}if(o>0){if(a==="{")o++;else if(a==="}")o--;r++;continue}if(s){r++;continue}if(i.paren===0&&i.bracket===0&&i.brace===0){if(e.slice(r,r+2)==="}}"||e.slice(r,r+3)==="!!}")break;if(a===","||a===";")break}if(a==="(")i.paren++;else if(a===")"){if(i.paren--,i.paren<0)break}else if(a==="[")i.bracket++;else if(a==="]"){if(i.bracket--,i.bracket<0)break}else if(a==="{")i.brace++;else if(a==="}"){if(i.brace--,i.brace<0)break}r++}return{expression:e.slice(t,r),endPos:r}}var Et={maxSanitizeDepth:10,allowBracketNotation:!1},Ce={...Et};var z=/\bnew\s+/,U="__stx_safe_ctors",Te=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],ee=[...Te,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],xe=ee.map(()=>{return}),re=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is})),se=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,z,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],oe=new Set([...Te,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",U]),ae=new Set(["__proto__","constructor","prototype"]);function Ae(e){let t="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o];if(s){s=!1;continue}if(a==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&a==="$"&&o+1<e.length&&e[o+1]==="{"){let c=1;o+=2;while(o<e.length&&c>0){if(e[o]==="{")c++;else if(e[o]==="}")c--;if(c>0)t+=e[o],r.push(o),o++}continue}if(a===i)i=null;continue}if(a==='"'||a==="'"||a==="`"){i=a;continue}t+=a,r.push(o)}return{text:t,map:r}}function _e(e){return Ae(e).text}var Ie=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],Oe=(()=>{let e={Date,URL,URLSearchParams},t=Intl;for(let r of Ie)if(typeof t[r]==="function")e[`Intl_${r}`]=t[r];return Object.freeze(Object.assign(Object.create(null),e))})(),xt=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,we=/(?<![\w$])new(?![\w$])/g,Se=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Ie.join(",")}}() are allowed`;function St(e){let{text:t,map:r}=Ae(e),i=[];we.lastIndex=0;let s;while((s=we.exec(t))!==null){let a=s.index;if(/(?<!\.)\.\s*$/.test(t.slice(0,a)))continue;let c=xt.exec(t.slice(a)),g=c?.[3],l=!c?null:g?`Intl_${g}`:c[2];if(!c||!l||!(l in Oe))throw new S(`matched /${z.source}/; ${Se}`,e);let h=a+c[0].length,f=r[a],y=r[h-1]+1;if(e.slice(f,y)!==t.slice(a,h))throw new S(`matched /${z.source}/; ${Se}`,e);let b=f+3+c[1].length;i.push({start:b,end:b+c[2].length,key:l})}let o=e;for(let a=i.length-1;a>=0;a--){let c=i[a];o=`${o.slice(0,c.start)}${U}.${c.key}${o.slice(c.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class S extends Error{rule;expression;constructor(e,t,r){super(r??`Potentially unsafe expression (${e}): ${t}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=t}}function fo(e){try{return le(e),null}catch(t){return t instanceof S?t.rule:t instanceof Error?t.message:String(t)}}function Ne(e,t){let r=/[$A-Z_a-z][$\w]*/g,i;while((i=r.exec(e))!==null){let s=i[0],o=e[i.index-1];if(oe.has(s))throw new S(`matched /\\b${s}\\b/; identifier ${s}`,t);if(o==="."&&ae.has(s))throw new S(`matched /.${s}/; property ${s}`,t)}}function Le(e,t=!0){let r=/(?:[$\w)\].]|\?\.)\s*\[([^\]]*)\]/g,i=new Set,s;while((s=r.exec(e))!==null){let o=s.index+s[0].indexOf("["),a=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(a))continue;let c=s[1].trim(),g=/^'(?:[^'\\]|\\.)*'$/.test(c),l=/^"(?:[^"\\]|\\.)*"$/.test(c);if(/^\d+$/.test(c))continue;if(g||l){let f=c.slice(1,-1);if(ae.has(f))throw new S(`bracket key ${f}`,e);if(!Ce.allowBracketNotation)throw new S("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",e,`Bracket notation with strings not allowed: ${e}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);continue}if(t&&/^[$A-Z_a-z][$\w]*$/.test(c)){i.add(c);continue}throw new S("dynamic bracket notation is not allowed",e)}return[...i]}function le(e){let t=e.trim(),r=_e(t);Ne(r,t);let i=Le(t);for(let s of se){if(s===z)continue;if(s.test(r))throw new S(`matched /${s.source}/`,t)}return{...St(t),dynamicKeys:i}}function Xi(e){return le(e),e.trim()}var go=Symbol("stx.sanitizeCache"),kt=4000,D=new Map;function $t(e){let t=D.get(e);if(t===void 0){if(t=se.some((r)=>r.test(e)),D.size>=kt)D.clear();D.set(e,t)}return t}function V(e){let t={},r=e[go];t.Math=Math,t.JSON=JSON,t.Date=Date,t.String=String,t.Number=Number,t.Boolean=Boolean,t.Array=Array,t.Object=re,t.parseInt=Number.parseInt,t.parseFloat=Number.parseFloat,t.isNaN=Number.isNaN,t.isFinite=Number.isFinite,t.encodeURIComponent=encodeURIComponent,t.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||$t(i))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=ie(s),r?.set(s,o);t[i]=o}else t[i]=s}return t}function ie(e,t=0){if(t>=Ce.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>ie(i,t+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let r={};for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||i==="constructor"||i==="prototype")continue;if(s&&typeof s==="object")r[i]=ie(s,t+1);else r[i]=s}return r}function d(e,t){try{let r=V(t),i=Object.keys(r),s=Object.values(r);return p(e,i)(...s)}catch{return}}function m(e){try{return Xi(e),!0}catch{return!1}}var j=new Set;function Rt(e,t,r){if(!t.startsWith("__")||!(t in r))return;let i=`${t}\x00${e}`;if(j.has(i))return;if(j.add(i),j.size>500)j.clear();console.warn(`[stx] a condition reads \`${t}\`, which conditions cannot see, so \`${e.trim()}\` is false and nothing it guards is rendered. Names starting with \`__\` are withheld from @if, @elseif and @unless. Derive a plain value in the server script (for example \`const hasRows = ${t}.length > 0\`) and test that instead.`)}function Rl(e,t){try{let r=V(t),i=Object.keys(r),s=Object.values(r),o=!1,c=p(e,i,(g)=>{o=!0,Rt(e,g,t)})(...s);return!o&&Boolean(c)}catch{return!1}}function M(e,t){try{let r=d(e,t);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var Pe=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),ke=`stx-compile-probe:${globalThis.crypto.randomUUID()}`,Ct=0,Tt=0;function At(e,t){let r="__stx_compile_probe";while(e.includes(r))r+="_";let i=Array.from({length:e.length+1});i[e.length]=ke;for(let s=0;s<16;s++){let o=`c${++Ct}`,a=`'use strict';if(${r}===${JSON.stringify(ke)})return ${JSON.stringify(o)};`,c=Function(...e,r,a+t);if(c(...i)===o)return c;Tt++}throw Error("[stx] the JavaScript runtime repeatedly returned code compiled from a different source; refusing to evaluate with it.")}var _t=2000,B=new Map;function ve(e,t){let r=`${e.join(",")}\x00${t}`,i=B.get(r);if(i)return i;let s=At(e,t);if(B.size>=_t)B.clear();return B.set(r,s),s}function yt(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var It=/^[A-Za-z_$][\w$]*$/;function Hr(e){return It.test(e)&&!Pe.has(e)}var $e=new T(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function p(e,t,r){let i=JSON.stringify([e,t]),s=$e.get(i);if(!s)s=Ot(e,[...t]),s.sourceBytes+=i.length*2,$e.set(i,s);return Nt(Lt(s.buildFunc,s.filteredKeys,s.contextKeys,s.validEntries,s.validIndices,r),s.contextKeys,s.dynamicKeys)}function Ot(e,t){let{source:r,usesSafeConstructors:i,dynamicKeys:s}=le(e),o=[];for(let f=0;f<t.length;f++){if(!Hr(t[f]))continue;if(t[f]===U||t[f]==="Object"||oe.has(t[f]))continue;o.push({key:t[f],index:f})}o.sort((f,y)=>f.key<y.key?-1:1);let a=o.map((f)=>f.key),c=o.map((f)=>f.index),g=`
|
|
30
|
+
`)this.line++,this.column=0;else this.column++;this.pos++}}peek(e){return this.source[this.pos+e]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState(e){this.pos=e.pos,this.line=e.line,this.column=e.column}}function _(e,t,r,i=0){let s=0,o=i,a=null,c=0,g=!1;while(o<e.length){let l=e[o];if(a&&g){g=!1,o++;continue}if(a&&l==="\\"){g=!0,o++;continue}if(g=!1,(l==='"'||l==="'"||l==="`")&&!a){a=l,o++;continue}if(l===a&&a!=="`"){a=null,o++;continue}if(a==="`"&&l==="$"&&e[o+1]==="{"){c++,o+=2;continue}if(c>0&&l==="}"){c--,o++;continue}if(l==="`"&&a==="`"&&c===0){a=null,o++;continue}if(a){o++;continue}if(l===t)s++;else if(l===r){if(s--,s===0)return o}o++}return-1}function Ol(e,t){let r=t,i={paren:0,bracket:0,brace:0},s=null,o=0;while(r<e.length){let a=e[r];if((r>0?e[r-1]:"")==="\\"&&s){r++;continue}if((a==='"'||a==="'")&&!s){s=a,r++;continue}if(a===s&&s!=="`"){s=null,r++;continue}if(a==="`"&&!s){s="`",r++;continue}if(a==="`"&&s==="`"&&o===0){s=null,r++;continue}if(s==="`"&&a==="$"&&e[r+1]==="{"){o++,r+=2;continue}if(o>0){if(a==="{")o++;else if(a==="}")o--;r++;continue}if(s){r++;continue}if(i.paren===0&&i.bracket===0&&i.brace===0){if(e.slice(r,r+2)==="}}"||e.slice(r,r+3)==="!!}")break;if(a===","||a===";")break}if(a==="(")i.paren++;else if(a===")"){if(i.paren--,i.paren<0)break}else if(a==="[")i.bracket++;else if(a==="]"){if(i.bracket--,i.bracket<0)break}else if(a==="{")i.brace++;else if(a==="}"){if(i.brace--,i.brace<0)break}r++}return{expression:e.slice(t,r),endPos:r}}var xt={maxSanitizeDepth:10,allowBracketNotation:!1},Te={...xt};var z=/\bnew\s+/,U="__stx_safe_ctors",Ae=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],ee=[...Ae,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],we=ee.map(()=>{return}),re=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is})),se=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,z,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],oe=new Set([...Ae,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",U]),ae=new Set(["__proto__","constructor","prototype"]);function _e(e){let t="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o];if(s){s=!1;continue}if(a==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&a==="$"&&o+1<e.length&&e[o+1]==="{"){let c=1;o+=2;while(o<e.length&&c>0){if(e[o]==="{")c++;else if(e[o]==="}")c--;if(c>0)t+=e[o],r.push(o),o++}continue}if(a===i)i=null;continue}if(a==='"'||a==="'"||a==="`"){i=a;continue}t+=a,r.push(o)}return{text:t,map:r}}function Ie(e){return _e(e).text}var Oe=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],Ne=(()=>{let e={Date,URL,URLSearchParams},t=Intl;for(let r of Oe)if(typeof t[r]==="function")e[`Intl_${r}`]=t[r];return Object.freeze(Object.assign(Object.create(null),e))})(),St=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,Se=/(?<![\w$])new(?![\w$])/g,ke=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Oe.join(",")}}() are allowed`;function kt(e){let{text:t,map:r}=_e(e),i=[];Se.lastIndex=0;let s;while((s=Se.exec(t))!==null){let a=s.index;if(/(?<!\.)\.\s*$/.test(t.slice(0,a)))continue;let c=St.exec(t.slice(a)),g=c?.[3],l=!c?null:g?`Intl_${g}`:c[2];if(!c||!l||!(l in Ne))throw new S(`matched /${z.source}/; ${ke}`,e);let h=a+c[0].length,f=r[a],y=r[h-1]+1;if(e.slice(f,y)!==t.slice(a,h))throw new S(`matched /${z.source}/; ${ke}`,e);let b=f+3+c[1].length;i.push({start:b,end:b+c[2].length,key:l})}let o=e;for(let a=i.length-1;a>=0;a--){let c=i[a];o=`${o.slice(0,c.start)}${U}.${c.key}${o.slice(c.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class S extends Error{rule;expression;constructor(e,t,r){super(r??`Potentially unsafe expression (${e}): ${t}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=t}}function mo(e){try{return le(e),null}catch(t){return t instanceof S?t.rule:t instanceof Error?t.message:String(t)}}function Pe(e,t){let r=/[$A-Z_a-z][$\w]*/g,i;while((i=r.exec(e))!==null){let s=i[0],o=e[i.index-1];if(oe.has(s))throw new S(`matched /\\b${s}\\b/; identifier ${s}`,t);if(o==="."&&ae.has(s))throw new S(`matched /.${s}/; property ${s}`,t)}}function Me(e,t=!0){let r=/(?:[$\w)\].]|\?\.)\s*\[([^\]]*)\]/g,i=new Set,s;while((s=r.exec(e))!==null){let o=s.index+s[0].indexOf("["),a=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(a))continue;let c=s[1].trim(),g=/^'(?:[^'\\]|\\.)*'$/.test(c),l=/^"(?:[^"\\]|\\.)*"$/.test(c);if(/^\d+$/.test(c))continue;if(g||l){let f=c.slice(1,-1);if(ae.has(f))throw new S(`bracket key ${f}`,e);if(!Te.allowBracketNotation)throw new S("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",e,`Bracket notation with strings not allowed: ${e}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);continue}if(t&&/^[$A-Z_a-z][$\w]*$/.test(c)){i.add(c);continue}throw new S("dynamic bracket notation is not allowed",e)}return[...i]}function le(e){let t=e.trim(),r=Ie(t);Pe(r,t);let i=Me(t);for(let s of se){if(s===z)continue;if(s.test(r))throw new S(`matched /${s.source}/`,t)}return{...kt(t),dynamicKeys:i}}function Zi(e){return le(e),e.trim()}var ho=Symbol("stx.sanitizeCache"),vt=4000,D=new Map;function $t(e){let t=D.get(e);if(t===void 0){if(t=se.some((r)=>r.test(e)),D.size>=vt)D.clear();D.set(e,t)}return t}function V(e){let t={},r=e[ho];t.Math=Math,t.JSON=JSON,t.Date=Date,t.String=String,t.Number=Number,t.Boolean=Boolean,t.Array=Array,t.Object=re,t.parseInt=Number.parseInt,t.parseFloat=Number.parseFloat,t.isNaN=Number.isNaN,t.isFinite=Number.isFinite,t.encodeURIComponent=encodeURIComponent,t.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||$t(i))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=ie(s),r?.set(s,o);t[i]=o}else t[i]=s}return t}function ie(e,t=0){if(t>=Te.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>ie(i,t+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let r={};for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||i==="constructor"||i==="prototype")continue;if(s&&typeof s==="object")r[i]=ie(s,t+1);else r[i]=s}return r}function d(e,t){try{let r=V(t),i=Object.keys(r),s=Object.values(r);return p(e,i)(...s)}catch{return}}function m(e){try{return Zi(e),!0}catch{return!1}}var j=new Set;function Rt(e,t,r){if(!t.startsWith("__")||!(t in r))return;let i=`${t}\x00${e}`;if(j.has(i))return;if(j.add(i),j.size>500)j.clear();console.warn(`[stx] a condition reads \`${t}\`, which conditions cannot see, so \`${e.trim()}\` is false and nothing it guards is rendered. Names starting with \`__\` are withheld from @if, @elseif and @unless. Derive a plain value in the server script (for example \`const hasRows = ${t}.length > 0\`) and test that instead.`)}function Il(e,t){try{let r=V(t),i=Object.keys(r),s=Object.values(r),o=!1,c=p(e,i,(g)=>{o=!0,Rt(e,g,t)})(...s);return!o&&Boolean(c)}catch{return!1}}function M(e,t){try{let r=d(e,t);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var Fe=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),ve=`stx-compile-probe:${globalThis.crypto.randomUUID()}`,Ct=0,Tt=0;function At(e,t){let r="__stx_compile_probe";while(e.includes(r))r+="_";let i=Array.from({length:e.length+1});i[e.length]=ve;for(let s=0;s<16;s++){let o=`c${++Ct}`,a=`'use strict';if(${r}===${JSON.stringify(ve)})return ${JSON.stringify(o)};`,c=Function(...e,r,a+t);if(c(...i)===o)return c;Tt++}throw Error("[stx] the JavaScript runtime repeatedly returned code compiled from a different source; refusing to evaluate with it.")}var _t=2000,B=new Map;function $e(e,t){let r=`${e.join(",")}\x00${t}`,i=B.get(r);if(i)return i;let s=At(e,t);if(B.size>=_t)B.clear();return B.set(r,s),s}function Ee(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var It=/^[A-Za-z_$][\w$]*$/;function Ur(e){return It.test(e)&&!Fe.has(e)}var Re=new T(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function p(e,t,r){let i=JSON.stringify([e,t]),s=Re.get(i);if(!s)s=Ot(e,[...t]),s.sourceBytes+=i.length*2,Re.set(i,s);return Nt(Lt(s.buildFunc,s.filteredKeys,s.contextKeys,s.validEntries,s.validIndices,r),s.contextKeys,s.dynamicKeys)}function Ot(e,t){let{source:r,usesSafeConstructors:i,dynamicKeys:s}=le(e),o=[];for(let f=0;f<t.length;f++){if(!Ur(t[f]))continue;if(t[f]===U||t[f]==="Object"||oe.has(t[f]))continue;o.push({key:t[f],index:f})}o.sort((f,y)=>f.key<y.key?-1:1);let a=o.map((f)=>f.key),c=o.map((f)=>f.index),g=`
|
|
31
31
|
'use strict';
|
|
32
32
|
try {
|
|
33
33
|
return ${r};
|
|
@@ -38,31 +38,31 @@ catch (e) {
|
|
|
38
38
|
}
|
|
39
39
|
throw e;
|
|
40
40
|
}
|
|
41
|
-
`,l=i?(f)=>{let y
|
|
41
|
+
`,l=i?(f)=>{let y=$e([U,"Object",...ee,...a,...f],g);return(...b)=>y(Ne,re,...we,...b)}:(f)=>{let y=$e(["Object",...ee,...a,...f],g);return(...b)=>y(re,...we,...b)},h=l([]);return{sourceBytes:e.length*2+t.reduce((f,y)=>f+y.length*2,0),contextKeys:t,filteredKeys:a,validEntries:o,validIndices:c,dynamicKeys:s,buildFunc:(f)=>f.length===0?h:l(f)}}function Nt(e,t,r){if(r.length===0)return e;let i=r.map((s)=>t.indexOf(s));return(...s)=>{for(let o of i){if(o<0)continue;let a=s[o];if(typeof a==="string"&&ae.has(a))return}return e(...s)}}function Lt(e,t,r,i,s,o){let a=e([]),c=i.every((l,h)=>l.index===h);if(t.length===r.length&&c)return Ce(a,t,e,void 0,o);return Ce((...l)=>{let h=Array(s.length);for(let f=0;f<s.length;f++)h[f]=l[s[f]];return a(...h)},t,e,(l)=>{a=e(l)},o)}function Ce(e,t,r,i,s){let a=/^(\w+) is not defined$/,c=e,g=[],l=new Set(t);return(...h)=>{for(let f=0;f<=8;f++)try{return c(...h)}catch(y){let b=y instanceof Error?y.message:"",w=a.exec(b);if(!(y instanceof ReferenceError)||!w)return;let x=w[1];if(l.has(x)||Fe.has(x)||oe.has(x))return;if(s?.(x),l.add(x),g.push(x),i)i(g);else c=r(g)}return}}function yo(e){let t=e.trim();try{let r=Ie(t);if(/\b(?:eval|function|import|require|process|globalthis|window|document|fetch|bun|deno|buffer|console|reflect|proxy|prototype|constructor|this)\b/i.test(r))return!1;Pe(r,t),Me(t);for(let i of se)if(i.test(r))return!1}catch{return!1}return!0}function ea(e,t){let r=[];t.lastIndex=0;let i;while((i=t.exec(e))!==null){let s=i.index,o=s+i[0].length-1,a=_(e,"(",")",o);if(a===-1){r.push({start:s,end:-1,args:"",call:e.slice(s,Math.min(e.length,s+80))}),t.lastIndex=o+1;continue}r.push({start:s,end:a+1,args:e.slice(o+1,a),call:e.slice(s,a+1)}),t.lastIndex=a+1}return r}function Yt(e,t,r,i){let s="",o=0;for(let a of ea(e,t)){if(s+=e.slice(o,a.start),a.end===-1){s+=i(a.call),o=a.start;continue}s+=r(a.args,a.call),o=a.end}return s+e.slice(o)}function Zt(e){let t=[],r=0,i=null,s="";for(let o=0;o<e.length;o++){let a=e[o];if(i){if(s+=a,a==="\\"&&o+1<e.length){s+=e[++o];continue}if(a===i)i=null;continue}if(a==="'"||a==='"'||a==="`")i=a;else if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===","&&r===0){t.push(s.trim()),s="";continue}s+=a}if(s.trim())t.push(s.trim());return t}function yt(e){let t=e.trim(),r=t[0];if(r!=="'"&&r!=='"'&&r!=="`"||t.length<2||t.at(-1)!==r)return null;let i="",s={b:"\b",f:"\f",n:`
|
|
42
42
|
`,r:"\r",t:"\t",v:"\v",0:"\x00"};for(let o=1;o<t.length-1;o++){let a=t[o];if(a==="\\"){if(++o>=t.length-1)return null;let c=t[o];if(/[1-9]/.test(c)||c==="0"&&/\d/.test(t[o+1]??""))return null;if(c===`
|
|
43
43
|
`||c==="\u2028"||c==="\u2029")continue;if(c==="\r"){if(t[o+1]===`
|
|
44
44
|
`)o++;continue}if(c==="x"||c==="u"){let g=c==="u"&&t[o+1]==="{",l=g?t.indexOf("}",o+2):o+(c==="x"?2:4)+1,h=t.slice(o+(g?2:1),l);if(l<0||l>=t.length||!/^[\da-f]+$/i.test(h)||!g&&h.length!==(c==="x"?2:4))return null;let f=Number.parseInt(h,16);if(f>1114111)return null;i+=String.fromCodePoint(f),o=g?l:l-1;continue}i+=Object.hasOwn(s,c)?s[c]:c;continue}if(a===r||r!=="`"&&(a===`
|
|
45
45
|
`||a==="\r"))return null;if(r==="`"&&a==="$"&&t[o+1]==="{")return null;if(r==="`"&&a==="\r"){if(t[o+1]===`
|
|
46
46
|
`)o++;i+=`
|
|
47
|
-
`}else i+=a}return i}var Pt=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Qt(e,t){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:n.INVALID_DIRECTIVE_SYNTAX};let i=
|
|
48
|
-
${i}${e.slice(r)}`}var ge=
|
|
49
|
-
${o[0]}${e.slice(r,o.index)}${e.slice(a,s)}${e.slice(s)}`}function
|
|
50
|
-
${t[0]}${i.slice(s)}`}var Kt="[data-stx-component-wrapper]:not([stx-hydrate]){display:contents}",
|
|
51
|
-
`}function Jt(e){let t=[],r=0;while(r<e.length){let o=e.slice(r),a=o.match(/^\s+/);if(a){r+=a[0].length;continue}if(o.startsWith("<!--")){let f=e.indexOf("-->",r);if(f===-1)break;r=f+3;continue}let c=o.match(/^<script\b[^>]*>/i);if(c){let f=e.toLowerCase().indexOf("</script>",r+c[0].length);if(f===-1)break;r=f+9;continue}let g=o.match(/^<link\b[^>]*>/i);if(g){t.push(g[0]),r+=g[0].length;continue}let l=o.match(/^<meta\b[^>]*>/i);if(l){t.push(l[0]),r+=l[0].length;continue}let h=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(h){t.push(h[0]),r+=h[0].length;continue}break}if(t.length===0)return{body:e,hoisted:t};let i="",s=0;while(s<e.length&&s<r){let o=e.slice(s),a=o.match(/^<link\b[^>]*>/i);if(a&&t.includes(a[0])){s+=a[0].length;continue}let c=o.match(/^<meta\b[^>]*>/i);if(c&&t.includes(c[0])){s+=c[0].length;continue}let g=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(g&&t.includes(g[0])){s+=g[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:t}}function en(e,t={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:a=[],script:c=[],headRaw:g="",htmlAttrs:l={},bodyClass:h="",bodyAttrs:f={}}=t,y=r.title||i,b=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],w=new Set(o.map(
|
|
52
|
-
`),
|
|
53
|
-
`),
|
|
54
|
-
`),
|
|
55
|
-
<html${
|
|
47
|
+
`}else i+=a}return i}var Pt=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Qt(e,t){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:n.INVALID_DIRECTIVE_SYNTAX};let i=mo(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:n.UNSAFE_EXPRESSION};let s=V(t),o;try{o=p(r,Object.keys(s))(...Object.values(s))}catch(c){return{ok:!1,message:`the expression could not be evaluated: ${c instanceof Error?c.message:String(c)}`,code:n.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let a=[...new Set(Ee(r))].filter((c)=>!Pt.has(c)&&!(c in s)&&!(c in globalThis));if(a.length>0)return{ok:!1,message:`${a.map((g)=>`"${g}"`).join(", ")} ${a.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:n.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:n.EVALUATION_ERROR};return{ok:!0,value:o}}function tt(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function bt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Be(e){if(!e)return"";return je.isAbsolute(e)?je.relative(process.cwd(),e)||e:e}function ue(e){let t=e.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}...`:t}function H(e,t,r,i,s=n.EVALUATION_ERROR){let o=i?` in ${Be(i)}`:"";return console.warn(`[stx] ${ue(t)}${o}: ${r}`),u(e,`${ue(t)}: ${r}`,s)}function bo(e,t,r){let i=r?` in ${Be(r)}`:"";console.warn(`[stx] ${ue(e)}${i}: ${t}`)}function ta(){return{afterOpen:[],beforeClose:[]}}function Mt(e){return e.afterOpen.length>0||e.beforeClose.length>0}function Nl(e,t){if(!Mt(t))return e;let r=t.afterOpen.join(""),i=t.beforeClose.join(""),s=L(e),o=r?Wr(e):null,a=i&&s!==-1?s:null;if(o===null&&a===null)return e;if(o!==null&&a!==null)return`${e.slice(0,o)}${r}${e.slice(o,a)}${i}${e.slice(a)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,a)}${i}${e.slice(a)}`}var ze=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function Wr(e){let t=/<head\b[^>]*>/i.exec(e);if(!t)return null;let r=t.index+t[0].length;ze.lastIndex=r;let i=ze.exec(e);return i?r+i[0].length:r}var pe="data-stx-color-mode-boot",He="__STX_COLOR_MODE__",Ft=new Set(["light","dark","auto","system"]),Dt=new Set(["auto","system"]),jt=/^[a-z][\w:-]*$/i,Bt=/^[\w-]+$/;function zt(e){let t=e.storageKey??"stx-color-mode",r=e.initialMode??"auto",i=e.darkClass===void 0?"dark":e.darkClass,s=e.attribute??null,o=e.autoValue??null,a=e.respectExisting===!0;if(typeof t!=="string"||t.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!Ft.has(r))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(r)}`);if(i!==null&&(typeof i!=="string"||!Bt.test(i)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(i)}`);if(s!==null&&(typeof s!=="string"||!jt.test(s)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(s)}`);if(o!==null&&!Dt.has(o))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(o)}`);if(i===null&&s===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(a&&s===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:t,initialMode:r==="system"?"auto":r,darkClass:i,attribute:s,autoValue:o,respectExisting:a}}function Ht(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function fe(e={}){let t=zt(e),r=Ht(t),i=`(function(){"use strict";var o=window.${He};if(o&&typeof o.sync==="function"){o.sync();return}var c=${r};var r=document.documentElement;function read(){var p=c.initialMode,a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}return{p:p,a:a}}function sys(){try{return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){return"light"}}function stamp(m){if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}}var s=read();var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f||(s.p==="auto"?sys():s.p);var p=s.p;stamp(m);var g=null;function sync(){var t=read(),n=f||(t.p==="auto"?sys():t.p);var moved=n!==m,chose=t.p!==p;if(moved){r.style.setProperty("transition","none","important");stamp(n);void r.offsetHeight;r.style.removeProperty("transition")}else stamp(n);m=n;p=t.p;if(g){g.mode=n;g.preference=t.p;if(t.a)g.autoValue=t.a}if(moved||chose){try{window.dispatchEvent(new CustomEvent("stx:color-mode",{detail:{mode:n,preference:t.p}}))}catch(e){}}}try{g=window.${He}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:s.a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m,watching:true,sync:sync}}catch(e){}try{var q=matchMedia("(prefers-color-scheme: dark)");if(q.addEventListener)q.addEventListener("change",sync);else if(q.addListener)q.addListener(sync)}catch(e){}try{addEventListener("pageshow",sync);addEventListener("storage",function(e){if(e.key===null||e.key===c.storageKey)sync()});document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")sync()})}catch(e){}}());`;return`<script ${pe}>${i}</script>`}function qr(e,t={}){if(e.includes(pe))return e;let r=ge(e);if(r===null)return e;let i=fe(t);return`${e.slice(0,r)}
|
|
48
|
+
${i}${e.slice(r)}`}var ge=Wr,Ut=new RegExp(`<script\\b[^>]*\\b${pe}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),Ue=/<meta\b[^>]*\bcharset\b[^>]*>/gi,Ve=/<\/head>/gi;function Vt(e){let t=/<head\b[^>]*>/i.exec(e);if(!t)return e;let r=t.index+t[0].length;Ve.lastIndex=r;let i=Ve.exec(e),s=i?i.index:e.length;Ue.lastIndex=r;let o=Ue.exec(e);if(!o||o.index>=s)return e;if(e.slice(r,o.index).trim()==="")return e;let a=o.index+o[0].length;return`${e.slice(0,r)}
|
|
49
|
+
${o[0]}${e.slice(r,o.index)}${e.slice(a,s)}${e.slice(s)}`}function Ml(e){return Wt(Vt(e))}function Wt(e){let t=Ut.exec(e);if(!t)return e;let r=ge(e);if(r===null)return e;if(t.index<=r||e.slice(r,t.index).trim()==="")return e;let i=e.slice(0,t.index)+e.slice(t.index+t[0].length),s=ge(i);if(s===null)return e;return`${i.slice(0,s)}
|
|
50
|
+
${t[0]}${i.slice(s)}`}var Kt="[data-stx-component-wrapper]:not([stx-hydrate]){display:contents}",Xe=`<style data-stx-cloak>[x-cloak]{display:none !important}${Kt}</style>`,W="data-stx-html-attrs",X="data-stx-html-class",qe=/^[A-Za-z_:][\w:.-]*$/;function k(e){return String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Xt(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function wt(e){if(e.name)return`name="${e.name}"`;if(e.property)return`property="${e.property}"`;if(e.charset!=null)return"charset=";if(e["http-equiv"])return`http-equiv="${e["http-equiv"]}"`;return""}function qt(e){let t=/^\s*<meta\b([^>]*)>/i.exec(e);if(!t)return null;let r={};for(let i of t[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[i[1].toLowerCase()]=i[2]??i[3]??i[4]??"";return r}function A(e,t){return Object.entries(e).filter(([r])=>!t?.(r)).map(([r,i])=>`${r}="${k(String(i))}"`).join(" ")}function q(e){let t=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?t.replace(/<\//g,"<\\/"):t}function Ge(e){let t=A(e,(r)=>r==="content");return`<script${t?` ${t}`:""}>${q(e)}</script>`}function Gt(e={},t="en"){let r=[],i=[],s="",o=t;for(let[c,g]of Object.entries(e||{})){if(g==null)continue;let l=c.trim();if(!qe.test(l))continue;let h=l.toLowerCase();if(h==="lang"){o=String(g);continue}if(h==="class"){s=String(g).trim();continue}r.push(` ${l}="${k(String(g))}"`),i.push(l)}let a=` lang="${k(o)}"`;if(s)a+=` class="${k(s)}"`;if(a+=r.join(""),s)a+=` ${X}="${k(s)}"`;if(i.length)a+=` ${W}="${k(i.join(" "))}"`;return a}function Dl(e={},t={}){let r={...e,...t};if(e.class&&t.class){let i=e.class.split(/\s+/).filter(Boolean);for(let s of t.class.split(/\s+/).filter(Boolean))if(!i.includes(s))i.push(s);r.class=i.join(" ")}return r}function Kr(e,t={}){if(!t||Object.keys(t).length===0)return e;let r=e.match(/<html\b([^>]*)>/i);if(!r)return e;let i={},s=[],o=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,a;while((a=o.exec(r[1]))!==null){let h=a[1];if(!(h in i))s.push(h);i[h]=a[2]??a[3]??a[4]??""}let c=[],g=[];for(let[h,f]of Object.entries(t)){if(f==null)continue;let y=h.trim();if(!qe.test(y))continue;let b=y.toLowerCase();if(b==="class"){let w=(i.class||"").split(/\s+/).filter(Boolean);for(let x of String(f).split(/\s+/).filter(Boolean))if(!w.includes(x))w.push(x),c.push(x);if(!("class"in i))s.push("class");i.class=w.join(" ");continue}if(!(y in i))s.push(y);if(i[y]=String(f),b!=="lang")g.push(y)}if(c.length){if(!(X in i))s.push(X);i[X]=c.join(" ")}if(g.length){if(!(W in i))s.push(W);i[W]=g.join(" ")}let l=s.map((h)=>` ${h}="${k(i[h])}"`).join("");return e.replace(r[0],()=>`<html${l}>`)}function Ll(e){if(e.includes("data-stx-cloak"))return null;if(L(e)===-1)return null;return`${Xe}
|
|
51
|
+
`}function Jt(e){let t=[],r=0;while(r<e.length){let o=e.slice(r),a=o.match(/^\s+/);if(a){r+=a[0].length;continue}if(o.startsWith("<!--")){let f=e.indexOf("-->",r);if(f===-1)break;r=f+3;continue}let c=o.match(/^<script\b[^>]*>/i);if(c){let f=e.toLowerCase().indexOf("</script>",r+c[0].length);if(f===-1)break;r=f+9;continue}let g=o.match(/^<link\b[^>]*>/i);if(g){t.push(g[0]),r+=g[0].length;continue}let l=o.match(/^<meta\b[^>]*>/i);if(l){t.push(l[0]),r+=l[0].length;continue}let h=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(h){t.push(h[0]),r+=h[0].length;continue}break}if(t.length===0)return{body:e,hoisted:t};let i="",s=0;while(s<e.length&&s<r){let o=e.slice(s),a=o.match(/^<link\b[^>]*>/i);if(a&&t.includes(a[0])){s+=a[0].length;continue}let c=o.match(/^<meta\b[^>]*>/i);if(c&&t.includes(c[0])){s+=c[0].length;continue}let g=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(g&&t.includes(g[0])){s+=g[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:t}}function en(e,t={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:a=[],script:c=[],headRaw:g="",htmlAttrs:l={},bodyClass:h="",bodyAttrs:f={}}=t,y=r.title||i,b=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],w=new Set(o.map(wt).filter(Boolean)),{body:x,hoisted:v}=Jt(e),C=new Set(v.flatMap((E)=>{let O=qt(E);return O?[wt(O)].filter(Boolean):[]})),et=[...b.filter((E)=>!w.has(wt(E))),...o].filter((E)=>!C.has(wt(E))).map((E)=>` <meta ${A(E)}>`).join(`
|
|
52
|
+
`),rt=a.map((E)=>` <link ${A(E)}>`).join(`
|
|
53
|
+
`),it=c.map((E)=>{if(E.src)return` <script ${A(E,(O)=>O==="content")}></script>`;if(E.content)return` ${Ge(E)}`;return""}).filter(Boolean).join(`
|
|
54
|
+
`),st=Gt(l,s),ot=Object.entries(f).map(([E,O])=>` ${E}="${k(String(O))}"`).join(""),at=h?` class="${k(h)}"`:"",ct=[et,r.colorMode?` ${fe(r.colorMode)}`:"",` <title>${r.titleIsHtml?y:Xt(y)}</title>`,` ${Xe}`,rt,it,g?` ${g}`:"",...(r.styles||[]).map((E)=>` ${E}`),...v.map((E)=>` ${E}`),...(r.headScripts||[]).map((E)=>` ${E}`),r.headStack||""].filter(Boolean),lt=[x,...(r.bodyScripts||[]).map((E)=>E),r.bodyStack||""].filter(Boolean);return`<!DOCTYPE html>
|
|
55
|
+
<html${st}>
|
|
56
56
|
<head>
|
|
57
|
-
${
|
|
57
|
+
${ct.join(`
|
|
58
58
|
`)}
|
|
59
59
|
</head>
|
|
60
|
-
<body${
|
|
61
|
-
${
|
|
60
|
+
<body${at}${ot}>
|
|
61
|
+
${lt.join(`
|
|
62
62
|
`)}
|
|
63
63
|
</body>
|
|
64
|
-
</html>`}var de=/\s+/y,me=/<(script|style)\b[^>]*>/iy,tn=/<\/script>/gi,nn=/<\/style>/gi,
|
|
64
|
+
</html>`}var de=/\s+/y,me=/<(script|style)\b[^>]*>/iy,tn=/<\/script>/gi,nn=/<\/style>/gi,We=/<!DOCTYPE\b/iy,Ke=/<html[\s>]/iy;function Bn(e){let t=0;while(t<e.length){if(de.lastIndex=t,de.exec(e)){t=de.lastIndex;continue}if(e.startsWith("<!--",t)){let s=e.indexOf("-->",t);if(s===-1)return!1;t=s+3;continue}me.lastIndex=t;let i=me.exec(e);if(i){let s=i[1].toLowerCase()==="script"?tn:nn;s.lastIndex=me.lastIndex;let o=s.exec(e);if(o===null)return!1;t=o.index+o[0].length;continue}if(We.lastIndex=t,We.test(e))return!0;return Ke.lastIndex=t,Ke.test(e)}return!1}function na(e){return Bn(e)}function jl(e,t={}){let r=L(e);if(r===-1)return e;let{meta:i=[],link:s=[],script:o=[],headRaw:a=""}=t,c=e.slice(0,r),g=[];for(let l of i){let h=wt(l);if(h&&c.includes(h))continue;g.push(` <meta ${A(l)}>`)}for(let l of s){if(l.href&&c.includes(`href="${l.href}"`))continue;g.push(` <link ${A(l)}>`)}for(let l of o)if(l.src){if(c.includes(`src="${l.src}"`))continue;g.push(` <script ${A(l,(h)=>h==="content")}></script>`)}else if(l.content){if(c.includes(q(l)))continue;g.push(` ${Ge(l)}`)}if(a&&!c.includes(a))g.push(` ${a}`);if(g.length===0)return e;return`${e.slice(0,r)}${g.join(`
|
|
65
65
|
`)}
|
|
66
|
-
${e.slice(r)}`}function
|
|
67
|
-
`)}function
|
|
68
|
-
`,"")),headContent:t.trim()}}function
|
|
66
|
+
${e.slice(r)}`}function Xr(e,t={},r={},i){if(i??na(e))return e;return en(e,t,r)}var rn=["og:","article:","book:","profile:","fb:","music:","video:"],sn=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function Gr(e,t){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:n.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:n.INVALID_DIRECTIVE_SYNTAX};let r=on(e[0],t);if(typeof r!=="string")return r;let i;if(e.length===2){let o=an(e[1],t);if(typeof o!=="string")return o;i=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,a=t.openGraph,c=t[o]??(bt(a)?a[o]:void 0);i=c===void 0||c===null||typeof c==="object"?"":String(c)}if(!i)return{kind:"empty"};return{kind:"tag",tag:rn.some((o)=>r.startsWith(o))?{property:r,content:i}:{name:r,content:i}}}function on(e,t){let r=yt(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:n.INVALID_DIRECTIVE_SYNTAX};if(sn.test(e.trim()))return e.trim();let i=Qt(e,t);if(!i.ok)return{kind:"error",message:`meta name: ${i.message}`,code:i.code};if(typeof i.value!=="string"||!i.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${tt(i.value)}`,code:n.TYPE_ERROR};return i.value}function an(e,t){let r=yt(e);if(r!==null)return r;let i=Qt(e,t);if(!i.ok)return{kind:"error",message:i.message,code:i.code};let s=i.value;if(s===void 0||s===null||s===!1)return"";if(Array.isArray(s))return s.filter((o)=>o!==void 0&&o!==null&&o!=="").map(String).join(", ");if(typeof s==="object"&&!(s instanceof Date))return{kind:"error",message:`the content must be text, got ${tt(s)}`,code:n.TYPE_ERROR};return String(s)}var Jr=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],wo=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],Ze={links:"link",metas:"meta",scripts:"script",styles:"style"},Ye=new Set,Je=new WeakMap;function he(e){if(Ye.has(e))return;Ye.add(e),console.warn(e)}function cn(e,t){let r=Array.from({length:t.length+1},(i,s)=>s);for(let i=1;i<=e.length;i++){let s=r[0];r[0]=i;for(let o=1;o<=t.length;o++){let a=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,s+(e[i-1]===t[o-1]?0:1)),s=a}}return r[t.length]}function ln(e,t){let r=e.toLowerCase(),i=t.find((g)=>g.toLowerCase()===r);if(i)return i;let s=Ze[r];if(s&&t.includes(s))return s;let o,a=1/0;for(let g of t){let l=cn(r,g.toLowerCase());if(l<a)o=g,a=l}let c=Math.min(e.length,o?.length??0)<=4?1:2;return a<=c?o:void 0}function Le(e,t){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=Je.get(e);if(r)return r;let{known:i,source:s}=t,o=e;for(let a of Object.keys(e)){if(i.includes(a))continue;let c=Ze[a];if(c&&i.includes(c)&&Array.isArray(e[a])){if(o===e)o={...e};let l=Array.isArray(o[c])?o[c]:[];o[c]=[...l,...e[a]],delete o[a],he(`[stx] ${s}.${a} is not a head key; reading it as ${s}.${c}. Rename it to \`${c}\`.`);continue}if(/^styles?$/.test(a)&&!i.includes("style")){he(`[stx] ${s}.${a} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let g=ln(a,i);he(g?`[stx] ${s}.${a} is not a head key and is ignored. Did you mean \`${g}\`?`:`[stx] ${s}.${a} is not a head key and is ignored. Known keys: ${i.join(", ")}.`)}return Je.set(e,o),o}var R={},un=[],G={};function ra(){return R}function jy(){return G}function By(){R={},un.length=0,G={}}function Bl(e){R=nt(R,Le(e,{known:wo,source:"useHead()"}))}function Qe(e,t,r){let i=[...e||[]];for(let s of t||[]){let o=r(s),a=o?i.findIndex((c)=>r(c)===o):-1;if(a<0)i.push(s);else i[a]=s}return i}function nt(e,t){return{title:t.title??e.title,titleTemplate:t.titleTemplate??e.titleTemplate,base:t.base??e.base,meta:Qe(e.meta,t.meta,(r)=>r.name||r.property||(r.httpEquiv?`http:${r.httpEquiv}`:void 0)),link:Qe(e.link,t.link,(r)=>["icon","apple-touch-icon","canonical"].includes(r.rel||"")?[r.rel,r.type,r.media,r.sizes].join(":"):void 0),script:[...e.script||[],...t.script||[]],style:[...e.style||[],...t.style||[]],htmlAttrs:{...e.htmlAttrs,...t.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...t.bodyAttrs}}}function tm(e){Bl(vo(e))}function vo(e){let t=[];if(e.description)t.push({name:"description",content:e.description});if(e.keywords){let g=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;t.push({name:"keywords",content:g})}if(e.author)t.push({name:"author",content:e.author});if(e.robots)t.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,i=e.ogDescription??e.description;if(r)t.push({property:"og:title",content:r});if(i)t.push({property:"og:description",content:i});if(e.ogImage){if(t.push({property:"og:image",content:e.ogImage}),e.ogImageType)t.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)t.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)t.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)t.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)t.push({property:"og:url",content:e.ogUrl});if(e.ogType)t.push({property:"og:type",content:e.ogType});if(e.ogSiteName)t.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)t.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)t.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)t.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)t.push({property:"profile:username",content:e.profileUsername});let s=e.twitterTitle??e.title,o=e.twitterDescription??e.description,a=e.twitterImage??e.ogImage;if(e.twitterCard)t.push({name:"twitter:card",content:e.twitterCard});if(s)t.push({name:"twitter:title",content:s});if(o)t.push({name:"twitter:description",content:o});if(a){t.push({name:"twitter:image",content:a});let g=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(g)t.push({name:"twitter:image:alt",content:g})}if(e.twitterSite)t.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)t.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)t.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)t.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)t.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)t.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let g of e.articleTags)t.push({property:"article:tag",content:g});let c=[];if(e.canonical)c.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:t,link:c}}function Fy(e){if(G={...G,...e},e.title||e.description)tm({title:e.title,description:e.description})}function zy(e){let t=typeof e==="function"?e():e;Bl({title:t})}function Hy(e=R){let t=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);t.push(`<title>${I(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([i,s])=>`${i}="${I(s)}"`).join(" ");t.push(`<base ${r}>`)}for(let r of e.meta||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s==="httpEquiv"?"http-equiv":s}="${I(String(o))}"`).join(" ");t.push(`<meta ${i}>`)}for(let r of e.link||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s}="${I(String(o))}"`).join(" ");t.push(`<link ${i}>`)}for(let r of e.script||[]){let{content:i,...s}=r,o=Object.entries(s).filter(([a,c])=>c!==void 0).map(([a,c])=>{if(typeof c==="boolean")return c?a:"";return`${a}="${I(String(c))}"`}).filter(Boolean).join(" ");if(i)t.push(`<script ${o}>${q(r)}</script>`);else t.push(`<script ${o}></script>`)}for(let r of e.style||[]){let i=r.type?` type="${r.type}"`:"";t.push(`<style${i}>${r.content}</style>`)}return t.join(`
|
|
67
|
+
`)}function Uy(e=R){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([t,r])=>`${t}="${I(r)}"`).join(" ")}function Vy(e=R){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([t,r])=>`${t}="${I(r)}"`).join(" ")}function I(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Wy(e=R){if(typeof document>"u")return;if(e.title){let t=e.title;if(e.titleTemplate)t=typeof e.titleTemplate==="function"?e.titleTemplate(t):e.titleTemplate.replace("%s",t);document.title=t}for(let t of e.meta||[]){let r=t.name?`meta[name="${t.name}"]`:t.property?`meta[property="${t.property}"]`:null;if(r){let i=document.querySelector(r);if(!i){if(i=document.createElement("meta"),t.name)i.setAttribute("name",t.name);if(t.property)i.setAttribute("property",t.property);document.head.appendChild(i)}i.setAttribute("content",t.content)}}for(let t of e.link||[]){let r=`link[rel="${t.rel}"]${t.href?`[href="${t.href}"]`:""}`,i=document.querySelector(r);if(!i)i=document.createElement("link"),document.head.appendChild(i);for(let[s,o]of Object.entries(t))if(o!==void 0)i.setAttribute(s,String(o))}if(e.htmlAttrs)for(let[t,r]of Object.entries(e.htmlAttrs))if(t==="class")for(let i of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(i);else document.documentElement.setAttribute(t,r);if(e.bodyAttrs)for(let[t,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(t,r)}function qy(e){let t="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(i,s)=>(t+=s.trim()+`
|
|
68
|
+
`,"")),headContent:t.trim()}}function Ky(e,t){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let a=i?s:t[(o||"").trim()]??o,c=t.__stx_runtime_head??{};return t.__stx_runtime_head=nt(c,{title:a}),""})}function Xy(e,t,r=""){if(!e.includes("@meta"))return e;return Yt(e,/(?<![\w$@])@meta\s*\(/g,(i,s)=>{let o=Gr(Zt(i),t);if(o.kind==="error")return H("Meta",s,o.message,r,o.code);if(o.kind==="tag"){let a=t.__stx_runtime_head??{};t.__stx_runtime_head=nt(a,{meta:[o.tag]})}return""},(i)=>H("Meta",i,"the call has no closing parenthesis",r,n.INVALID_DIRECTIVE_SYNTAX))}export{mo,Zi,ho,d,m,Il,M,Ee,Ur,p,yo,n,ce,Vr,te,u,De,Qi,K,jn,be,_,Ol,ea,Yt,Zt,yt,Qt,tt,bt,H,bo,ta,Nl,Wr,qr,Ml,wt,Dl,Kr,Ll,Bn,na,jl,Xr,Gr,Jr,wo,Le,ra,jy,By,Bl,nt,tm,vo,Fy,zy,Hy,Uy,Vy,Wy,qy,Ky,Xy};
|