@stacksjs/stx 0.2.633 → 0.2.635
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/chunk-0d7dqt4d.js +2 -0
- package/dist/chunk-0grt24vd.js +2 -0
- package/dist/{chunk-7q55jxf5.js → chunk-0tm9ep8b.js} +2 -2
- package/dist/{chunk-7gq7w95h.js → chunk-14yjt309.js} +3 -3
- package/dist/{chunk-ygpa12ez.js → chunk-1d25z8q2.js} +3 -3
- package/dist/{chunk-6bhaa9g7.js → chunk-1wb98s7b.js} +13 -13
- package/dist/{chunk-nh7bcc4h.js → chunk-2efrxnnt.js} +2 -2
- package/dist/chunk-2vzfn6vy.js +2 -0
- package/dist/chunk-3bsz101e.js +2 -0
- package/dist/{chunk-w9e17a74.js → chunk-3e2v2fdh.js} +4 -4
- package/dist/{chunk-jq7ymh7q.js → chunk-3f4xy76k.js} +6 -6
- package/dist/chunk-3jwjesb5.js +2 -0
- package/dist/{chunk-968jp303.js → chunk-3td99hnc.js} +3 -3
- package/dist/chunk-4b4es5wg.js +2 -0
- package/dist/{chunk-phbnrw2h.js → chunk-4n24jbfs.js} +2 -2
- package/dist/{chunk-72p9brmx.js → chunk-4vkpgz28.js} +9 -9
- package/dist/chunk-4xeafdr6.js +2 -0
- package/dist/chunk-4xkqdfqd.js +2 -0
- package/dist/chunk-5k989nr4.js +2 -0
- package/dist/chunk-5v95x083.js +3 -0
- package/dist/chunk-5yf9yzkp.js +2 -0
- package/dist/{chunk-923vrf9c.js → chunk-6gwrmn3w.js} +7 -7
- package/dist/{chunk-p77g4mhy.js → chunk-6w1ngwsd.js} +2 -2
- package/dist/chunk-7m5xrqnj.js +2852 -0
- package/dist/chunk-7mtdjjbt.js +2 -0
- package/dist/{chunk-94yycjz8.js → chunk-7vdcsr14.js} +2 -2
- package/dist/{chunk-k5atee35.js → chunk-839m1t8t.js} +1 -1
- package/dist/chunk-88dxeynx.js +2 -0
- package/dist/chunk-8er7jc3c.js +2 -0
- package/dist/chunk-8phbb8wj.js +2 -0
- package/dist/{chunk-p4hmv654.js → chunk-8y3mff5c.js} +2 -2
- package/dist/{chunk-gqdh68vx.js → chunk-954tcahb.js} +2 -2
- package/dist/{chunk-sg5zgq5v.js → chunk-97zrn4wb.js} +5 -5
- package/dist/{chunk-q6evk3a4.js → chunk-9gx5p7zh.js} +2 -2
- package/dist/{chunk-g2rxbaah.js → chunk-a6hv03yw.js} +3 -3
- package/dist/chunk-a7s1j320.js +127 -0
- package/dist/chunk-a83r1xx9.js +2 -0
- package/dist/chunk-abpeac2d.js +2 -0
- package/dist/chunk-adzsqsjt.js +2 -0
- package/dist/{chunk-4fv3jq16.js → chunk-ahyq08mp.js} +2 -2
- package/dist/chunk-b1ndskw9.js +2 -0
- package/dist/chunk-b7fp3zta.js +2 -0
- package/dist/{chunk-pbphq5pj.js → chunk-b7hv69ty.js} +2 -2
- package/dist/{chunk-avt9cske.js → chunk-baw176ay.js} +6 -6
- package/dist/chunk-bgfkbesj.js +2 -0
- package/dist/{chunk-cy1j2zpr.js → chunk-bk9bx2ns.js} +2 -2
- package/dist/{chunk-gh34r6qb.js → chunk-bsts9pr5.js} +2 -2
- package/dist/{chunk-jzmz66a3.js → chunk-bysyrwfa.js} +3 -3
- package/dist/{chunk-y89m80pf.js → chunk-c4ysk7x2.js} +4 -4
- package/dist/{chunk-90pe63me.js → chunk-camd8j1q.js} +3 -3
- package/dist/{chunk-0qt1887j.js → chunk-cdab66xt.js} +2 -2
- package/dist/{chunk-gv15dd41.js → chunk-cjr8cpb7.js} +3 -3
- package/dist/{chunk-y8h823cb.js → chunk-cw9pc5yx.js} +41 -41
- package/dist/chunk-cy83yfy9.js +2 -0
- package/dist/chunk-dbqb1a51.js +2 -0
- package/dist/{chunk-pk757m0k.js → chunk-e0nq8g9j.js} +1 -1
- package/dist/chunk-e8t64hxk.js +2 -0
- package/dist/chunk-e943xk88.js +2 -0
- package/dist/{chunk-w8bf4mbw.js → chunk-emcbmr0r.js} +3 -3
- package/dist/{chunk-kpxty3pe.js → chunk-f30t1g74.js} +2 -2
- package/dist/{chunk-tx4xxpgg.js → chunk-f3agc1a3.js} +3 -3
- package/dist/{chunk-27784ceh.js → chunk-fm80xpxn.js} +4 -4
- package/dist/{chunk-xrrkf04f.js → chunk-fwawm5r3.js} +2 -2
- package/dist/chunk-g039c67x.js +2 -0
- package/dist/{chunk-gxpgwpq7.js → chunk-g9dz0mx9.js} +2 -2
- package/dist/{chunk-bd5na0h0.js → chunk-g9sdjgfw.js} +5 -5
- package/dist/{chunk-k2nrx78c.js → chunk-gcj5jfbv.js} +2 -2
- package/dist/chunk-ghfxfcr9.js +2 -0
- package/dist/chunk-gvyq9xt6.js +2 -0
- package/dist/chunk-h30y9k44.js +2 -0
- package/dist/{chunk-236twqn4.js → chunk-hbzk179w.js} +3 -3
- package/dist/chunk-hwp3m8a8.js +2 -0
- package/dist/{chunk-2bxsc7gf.js → chunk-j79f6syh.js} +4 -4
- package/dist/chunk-jarptkbv.js +2 -0
- package/dist/{chunk-ftkrsvqp.js → chunk-jtr30kkz.js} +1 -1
- package/dist/{chunk-fdy0hka5.js → chunk-kjtvdqb9.js} +13 -13
- package/dist/chunk-kk6tq07c.js +3 -0
- package/dist/chunk-km4xp898.js +2 -0
- package/dist/{chunk-j1rnhv0w.js → chunk-kr14jt4m.js} +3 -3
- package/dist/{chunk-az1y9jks.js → chunk-kwwrrasa.js} +2 -2
- package/dist/chunk-kxbw0e2f.js +3 -0
- package/dist/{chunk-a887js9p.js → chunk-m56ee2tw.js} +5 -5
- package/dist/chunk-meze7k8v.js +2 -0
- package/dist/chunk-mfwrxz9z.js +2 -0
- package/dist/chunk-mmpm1awz.js +2 -0
- package/dist/{chunk-0whv8hnp.js → chunk-mn97jhaq.js} +2 -2
- package/dist/{chunk-3yh585yv.js → chunk-mpb0ezee.js} +3 -3
- package/dist/{chunk-g35zftfn.js → chunk-mvt5n2q4.js} +1 -1
- package/dist/chunk-n7vetrt4.js +2 -0
- package/dist/chunk-nd716zha.js +2 -0
- package/dist/{chunk-0hs8jgw5.js → chunk-npn3h566.js} +2 -2
- package/dist/{chunk-5x59qjzs.js → chunk-pak6ngv0.js} +6 -6
- package/dist/{chunk-v5500ews.js → chunk-pp6ycfay.js} +2 -2
- package/dist/{chunk-vhktd16g.js → chunk-psranzfr.js} +2 -2
- package/dist/chunk-ptjz4f2e.js +2 -0
- package/dist/{chunk-8qrhz7n7.js → chunk-ptv5f34x.js} +6 -6
- package/dist/{chunk-86zj56pf.js → chunk-q0kbn64j.js} +5 -5
- package/dist/chunk-q4hmgj72.js +2 -0
- package/dist/chunk-q841b6x4.js +2 -0
- package/dist/{chunk-v4tmwamd.js → chunk-qa58qdz8.js} +2 -2
- package/dist/{chunk-8hjrr8j3.js → chunk-qczse5w4.js} +33 -33
- package/dist/{chunk-tn7hgtyn.js → chunk-qjfgdcck.js} +5 -5
- package/dist/chunk-qnh5x7vv.js +2 -0
- package/dist/chunk-qxjfvkjt.js +2 -0
- package/dist/chunk-rhhwz7e9.js +2 -0
- package/dist/chunk-rpbe5h6v.js +2 -0
- package/dist/chunk-rrdn4qnn.js +2 -0
- package/dist/{chunk-xm911f1g.js → chunk-ry1w4ghk.js} +1 -1
- package/dist/chunk-s7c9kb53.js +2 -0
- package/dist/chunk-sfj84n72.js +2 -0
- package/dist/chunk-sgr2hhsc.js +2 -0
- package/dist/{chunk-jbmjcs83.js → chunk-shcn4wve.js} +2 -2
- package/dist/{chunk-zs7t42b5.js → chunk-sn0a8cjd.js} +5 -5
- package/dist/chunk-taztcvv3.js +2 -0
- package/dist/chunk-vczt5k2j.js +2 -0
- package/dist/chunk-vj5fghnv.js +2 -0
- package/dist/{chunk-6dzqjbsz.js → chunk-vyjdzpb8.js} +2 -2
- package/dist/chunk-wj4rf7sb.js +2 -0
- package/dist/chunk-wn1s8af8.js +2 -0
- package/dist/{chunk-t7e9y46s.js → chunk-x7g0946r.js} +1 -1
- package/dist/{chunk-rq1c46zb.js → chunk-xdwpbqzz.js} +34 -9
- package/dist/chunk-y3jyk5bj.js +2 -0
- package/dist/chunk-y51ndrdb.js +2 -0
- package/dist/{chunk-xrkechs8.js → chunk-y5b25eks.js} +5 -5
- package/dist/{chunk-tc7gm68a.js → chunk-ycz5th6b.js} +2 -2
- package/dist/{chunk-3kkf43fv.js → chunk-ym0e374a.js} +2 -2
- package/dist/{chunk-pxpmx8vc.js → chunk-ymntav9f.js} +1 -1
- package/dist/{chunk-8kc6byaz.js → chunk-yp8tk3v3.js} +5 -5
- package/dist/{chunk-bng1ayzm.js → chunk-ytv0k9gy.js} +9 -9
- package/dist/chunk-ytxzy6eg.js +2 -0
- package/dist/chunk-ywf319rp.js +2 -0
- package/dist/chunk-yww6c9we.js +2 -0
- package/dist/chunk-yy43hxb7.js +2 -0
- package/dist/chunk-z42jb949.js +2 -0
- package/dist/{chunk-y04hzz4w.js → chunk-zfrpss8y.js} +4 -4
- package/dist/{chunk-8b2452m1.js → chunk-zpzk4wd2.js} +11 -11
- package/dist/chunk-zw20a7q4.js +2 -0
- package/dist/cli.js +76 -76
- package/dist/client/signals-public-api-runtime.js +1 -0
- package/dist/client/signals-timer-runtime.js +24 -0
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/lazy-module.js +2 -1
- package/dist/menubar.d.ts +2 -0
- package/dist/menubar.js +15 -2
- package/dist/native/compiler/headwind-to-style.d.ts +6 -3
- package/dist/native/compiler/headwind-to-style.js +25 -3
- package/dist/native/compiler/html-to-ir.js +4 -4
- package/dist/native/prop-names.d.ts +1 -1
- package/dist/native/prop-names.js +3 -1
- package/dist/native/runtime/native-host.js +66 -7
- package/dist/pwa.js +3 -3
- package/dist/runtime-globals.js +1 -0
- package/dist/ssg.js +9 -9
- package/dist/stx-module.d.ts +1 -0
- package/package.json +5 -5
- package/stx-module.d.ts +1 -0
- package/stx.d.ts +7 -0
- package/dist/chunk-0mgtrbaa.js +0 -2
- package/dist/chunk-0xc6rncm.js +0 -2852
- package/dist/chunk-1tpr8d8n.js +0 -2
- package/dist/chunk-20kjbf3h.js +0 -2
- package/dist/chunk-3gcg3gvy.js +0 -2
- package/dist/chunk-3wsrhj0k.js +0 -2
- package/dist/chunk-575cqc6z.js +0 -2
- package/dist/chunk-5x836mv3.js +0 -2
- package/dist/chunk-5yceay9n.js +0 -2
- package/dist/chunk-6pg2kxsq.js +0 -2
- package/dist/chunk-7nthebqr.js +0 -2
- package/dist/chunk-7s5304ae.js +0 -2
- package/dist/chunk-8dybd0g5.js +0 -2
- package/dist/chunk-8em788gc.js +0 -2
- package/dist/chunk-9svygzeg.js +0 -2
- package/dist/chunk-9z4qr5w9.js +0 -2
- package/dist/chunk-af4ss0p5.js +0 -2
- package/dist/chunk-aj34t5h3.js +0 -2
- package/dist/chunk-atcy4zq6.js +0 -2
- package/dist/chunk-az28kd7f.js +0 -2
- package/dist/chunk-cncdgxk3.js +0 -2
- package/dist/chunk-d2t2pq1s.js +0 -3
- package/dist/chunk-dcx2t3sy.js +0 -2
- package/dist/chunk-dn28q0m3.js +0 -2
- package/dist/chunk-dn89zg1v.js +0 -2
- package/dist/chunk-dwddzp5f.js +0 -2
- package/dist/chunk-enchx79c.js +0 -2
- package/dist/chunk-ev8ma4ph.js +0 -2
- package/dist/chunk-ftrsaag8.js +0 -2
- package/dist/chunk-g6efz3ww.js +0 -2
- package/dist/chunk-gd59tkhr.js +0 -2
- package/dist/chunk-h1g9m148.js +0 -2
- package/dist/chunk-h8tew5mz.js +0 -2
- package/dist/chunk-hdrcgepx.js +0 -127
- package/dist/chunk-hn64343d.js +0 -2
- package/dist/chunk-htaed68z.js +0 -2
- package/dist/chunk-j5jkh05f.js +0 -2
- package/dist/chunk-j90yng9b.js +0 -2
- package/dist/chunk-jabb3v4c.js +0 -2
- package/dist/chunk-jczvjn7z.js +0 -2
- package/dist/chunk-kqkhcbrx.js +0 -2
- package/dist/chunk-mgzegkvk.js +0 -2
- package/dist/chunk-mk71833d.js +0 -2
- package/dist/chunk-n3s3w1f5.js +0 -2
- package/dist/chunk-nj0b4ryt.js +0 -2
- package/dist/chunk-ny6enm8b.js +0 -3
- package/dist/chunk-p8ndfekp.js +0 -2
- package/dist/chunk-qhjm9hvz.js +0 -2
- package/dist/chunk-qzy34xmt.js +0 -2
- package/dist/chunk-ra40trfh.js +0 -2
- package/dist/chunk-rjq597cn.js +0 -2
- package/dist/chunk-rrdwynz4.js +0 -2
- package/dist/chunk-sddytf9n.js +0 -2
- package/dist/chunk-shhtbdnj.js +0 -2
- package/dist/chunk-t4g97h08.js +0 -2
- package/dist/chunk-t7f9zmy8.js +0 -2
- package/dist/chunk-tme29zh9.js +0 -3
- package/dist/chunk-x1xx8qt0.js +0 -2
- package/dist/chunk-xmfhb2v0.js +0 -2
- package/dist/chunk-xsw183n7.js +0 -2
- package/dist/chunk-xtwe2rnp.js +0 -2
- package/dist/chunk-xxnh7gv8.js +0 -2
- package/dist/chunk-y84n0dvg.js +0 -2
- package/dist/chunk-zr0k9pz5.js +0 -2
- package/dist/chunk-zytcxy8p.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import s from"path";var h=new Set([".jpg",".jpeg",".png",".gif"]),d=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}];async function
|
|
3
|
-
export{
|
|
2
|
+
import s from"path";var h=new Set([".jpg",".jpeg",".png",".gif"]),d=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}];async function ac(e,r){let a=r.formats??d;if(!r.publicDir)return e;let i=y(e),o=[],m=/<img\b[^>]*?>/gi,c=[],u;while((u=m.exec(e))!==null){let t=u[0],n=t.match(/\bsrc=["']([^"']+)["']/i);if(!n)continue;if(A(u.index,i))continue;c.push({idx:u.index,length:t.length,src:n[1],raw:t})}if(c.length===0)return e;let f=await Promise.all(c.map(async(t)=>{let n=await S(t.src,r.publicDir,a);return{match:t,sources:n}}));for(let{match:t,sources:n}of f){if(n.length===0)continue;let x=`<picture>${n.map((p)=>`<source type="${p.mime}" srcset="${P(p.url)}">`).join("")}${t.raw}</picture>`;o.push({start:t.idx,end:t.idx+t.length,replacement:x})}if(o.length===0)return e;let l="",g=0;for(let t of o)l+=e.slice(g,t.start),l+=t.replacement,g=t.end;return l+=e.slice(g),l}async function S(e,r,a){if(!w(e))return[];let i=s.extname(e).toLowerCase();if(!h.has(i))return[];if(!e.startsWith("/"))return[];let o=s.join(r,e.slice(1)),m=s.dirname(o),c=s.basename(o,i),u=s.resolve(m),f=s.resolve(r);if(!u.startsWith(f))return[];let l=s.posix.dirname(e),g=a.map(async(n)=>{let b=s.join(m,`${c}${n.ext}`);if(!await Bun.file(b).exists())return null;return{url:s.posix.join(l,`${c}${n.ext}`),mime:n.mime}});return(await Promise.all(g)).filter((n)=>n!==null)}function w(e){if(!e)return!1;if(e.startsWith("http://")||e.startsWith("https://"))return!1;if(e.startsWith("//"))return!1;if(e.startsWith("data:"))return!1;return!0}function y(e){let r=[],a=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,i;while((i=a.exec(e))!==null)r.push([i.index,i.index+i[0].length]);return r}function A(e,r){for(let[a,i]of r)if(e>=a&&e<i)return!0;return!1}function P(e){return e.replace(/&/g,"&").replace(/"/g,""")}
|
|
3
|
+
export{ac};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function
|
|
2
|
+
function Ho(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="id",dynamicHeight:d=!1,estimatedItemHeight:g=l,direction:x="vertical"}=c,e=[...v],t=0,n=new Map;function f(){if(d)return h();let i=Math.max(0,Math.floor(t/l)-s),r=Math.ceil(u/l),m=Math.min(e.length-1,i+r+s*2);return{startIndex:i,endIndex:m}}function h(){let i=0,r=0,m=e.length-1;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+M>t){r=Math.max(0,p-s);break}i+=M}i=0;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+=M,i>t+u){m=Math.min(e.length-1,p+s);break}}return{startIndex:r,endIndex:m}}function w(){if(d){let i=0;for(let r=0;r<e.length;r++)i+=n.get(r)||g;return i}return e.length*l}function y(i){if(d){let r=0;for(let m=0;m<i;m++)r+=n.get(m)||g;return r}return i*l}function S(){let{startIndex:i,endIndex:r}=f();return{startIndex:i,endIndex:r,scrollTop:t,totalHeight:w(),visibleItems:e.slice(i,r+1),itemHeights:new Map(n)}}function L(i,r="auto"){let m=y(i);a(m,r)}function a(i,r="auto"){t=Math.max(0,Math.min(i,w()-u))}function o(){f()}function H(i){e=[...i],n.clear(),o()}function I(){e=[],n.clear()}return{scrollToIndex:L,scrollToOffset:a,getState:S,refresh:o,setItems:H,destroy:I}}function Vo(v,c={},l){let u=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualList: items "${x}" not found or not an array -->`;let t={itemHeight:50,containerHeight:400,overscan:3};if(d)try{let a=d.trim(),o=Function(`return ${a}`)();t={...t,...o}}catch{}let n=`vlist-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(t.containerHeight/t.itemHeight),h=t.overscan||3,w=0,y=Math.min(e.length-1,f+h),S="";for(let a=w;a<=y&&a<e.length;a++){let o=e[a],H=g.replace(/\{\{\s*item\s*\}\}/g,typeof o==="object"?JSON.stringify(o):String(o)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(I,i)=>{if(typeof o==="object"&&o!==null)return String(o[i]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(a));S+=`
|
|
3
3
|
<div class="virtual-item ${t.itemClass||""}"
|
|
4
4
|
style="position: absolute; top: ${a*t.itemHeight}px; height: ${t.itemHeight}px; width: 100%;"
|
|
5
5
|
data-index="${a}">
|
|
@@ -76,7 +76,7 @@ function zo(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
76
76
|
};
|
|
77
77
|
})();
|
|
78
78
|
</script>
|
|
79
|
-
`})}function
|
|
79
|
+
`})}function Va(){return`
|
|
80
80
|
.virtual-list-container {
|
|
81
81
|
position: relative;
|
|
82
82
|
overflow-y: auto;
|
|
@@ -124,7 +124,7 @@ function zo(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
124
124
|
0% { background-position: 200% 0; }
|
|
125
125
|
100% { background-position: -200% 0; }
|
|
126
126
|
}
|
|
127
|
-
`}function
|
|
127
|
+
`}function Ua(v,c){let l=null,u=()=>{if(!l)l=Ho(v(),c);return l};return{visibleItems:()=>u().getState().visibleItems,totalHeight:()=>u().getState().totalHeight,containerProps:()=>({style:{height:`${c.containerHeight}px`,overflow:"auto",position:"relative"},onScroll:(s)=>{let b=s.target;if(l)l.scrollToOffset(b.scrollTop)}}),itemProps:(s)=>({style:{position:"absolute",top:`${s*c.itemHeight}px`,height:`${c.itemHeight}px`,width:"100%"},"data-index":s}),scrollToIndex:(s)=>{u().scrollToIndex(s)}}}function Wa(v,c={},l){let u=/@infiniteList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@loading\s*([\s\S]*?)@endinfiniteList/gi;return v.replace(u,(s,b,d,g,x)=>{let e=b.trim(),t=c[e];if(!t||!Array.isArray(t))return`<!-- infiniteList: items "${e}" not found or not an array -->`;let n={itemHeight:50,containerHeight:400,overscan:3,threshold:100,hasMore:!0};if(d)try{let w=Function(`return ${d.trim()}`)();n={...n,...w}}catch{}let f=`ilist-${Math.random().toString(36).substring(2,9)}`,h=Vo(`@virtualList(${e}, ${JSON.stringify({itemHeight:n.itemHeight,containerHeight:n.containerHeight,overscan:n.overscan,containerClass:n.containerClass})})${g}@endvirtualList`,c);return h=h.replace("</script>",`
|
|
128
128
|
// Infinite scroll detection
|
|
129
129
|
container.addEventListener('scroll', function() {
|
|
130
130
|
const scrollBottom = container.scrollTop + container.clientHeight;
|
|
@@ -142,7 +142,7 @@ function zo(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
142
142
|
${x}
|
|
143
143
|
</div>
|
|
144
144
|
</div>
|
|
145
|
-
`})}function
|
|
145
|
+
`})}function qa(v,c={},l){let u=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualGrid: items "${x}" not found or not an array -->`;let t={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(d)try{let o=Function(`return ${d.trim()}`)();t={...t,...o}}catch{}let n=`vgrid-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(e.length/t.columns),h=f*(t.rowHeight+(t.gap||0)),w=Math.ceil(t.containerHeight/(t.rowHeight+(t.gap||0))),y=t.overscan||2,S=0,L=Math.min(f-1,w+y),a="";for(let o=S;o<=L;o++)for(let H=0;H<t.columns;H++){let I=o*t.columns+H;if(I>=e.length)break;let i=e[I],r=H*(100/t.columns),m=o*(t.rowHeight+(t.gap||0)),p=g.replace(/\{\{\s*item\s*\}\}/g,typeof i==="object"?JSON.stringify(i):String(i)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(M,T)=>{if(typeof i==="object"&&i!==null)return String(i[T]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(I));a+=`
|
|
146
146
|
<div class="virtual-grid-item"
|
|
147
147
|
style="position: absolute; top: ${m}px; left: ${r}%; width: calc(${100/t.columns}% - ${t.gap||0}px); height: ${t.rowHeight}px;"
|
|
148
148
|
data-index="${I}">
|
|
@@ -212,5 +212,5 @@ function zo(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
212
212
|
});
|
|
213
213
|
})();
|
|
214
214
|
</script>
|
|
215
|
-
`})}var
|
|
216
|
-
export{
|
|
215
|
+
`})}var tu={createVirtualList:Ho,processVirtualListDirectives:Vo,processInfiniteListDirectives:Wa,processVirtualGridDirectives:qa,generateVirtualListCSS:Va,useVirtualList:Ua};
|
|
216
|
+
export{Ho,Vo,Va,Ua,Wa,qa,tu};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Zr,Qr,es,Fa,ts,ns,za,rs,ss,zo,Ha}from"./chunk-camd8j1q.js";export{Zr as VideoProcessorCache,zo as analyzeVideo,Fa as clearVideoCache,ss as generateDASHManifest,rs as generateHLSManifest,ts as generatePoster,za as generateSpriteSheet,ns as generateThumbnails,Qr as getCachedVideoResult,Ha as processVideo,es as setCachedVideoResult};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Vt,C}from"./chunk-fwawm5r3.js";import m from"fs";import e from"path";async function An(r,o,i){if(r.__stx_runtime_config)return;let n=Vt();if(n||i){r.__stx_runtime_config=n??C(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-5k989nr4.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=C(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Gs(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
|
|
3
3
|
declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
|
|
4
4
|
`),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
|
|
5
5
|
declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
|
|
6
6
|
`)}
|
|
7
|
-
export{
|
|
7
|
+
export{An,Gs};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function t(n){if(!n||typeof n!=="object")return!1;let i=n;return typeof i.message==="string"&&(i.name==="BuildMessage"||i.name==="ResolveMessage"||("position"in i))}function o(n){if(n&&typeof n==="object"&&Array.isArray(n.errors))return n.errors;return[n]}function
|
|
2
|
+
function t(n){if(!n||typeof n!=="object")return!1;let i=n;return typeof i.message==="string"&&(i.name==="BuildMessage"||i.name==="ResolveMessage"||("position"in i))}function o(n){if(n&&typeof n==="object"&&Array.isArray(n.errors))return n.errors;return[n]}function bn(n,i){let e=[];for(let r of o(n)){if(t(r)){let s=r.position||void 0;e.push({file:i||s?.file,line:s?.line,column:s?.column,message:r.message??"",lineText:s?.lineText});continue}e.push({file:i,message:r instanceof Error?r.message:String(r)})}return e}function fe(n,i){return bn(n,i).map((e)=>{let r=e.file?`${e.file}${e.line?`:${e.line}${e.column?`:${e.column}`:""}`:""}`:"",s=e.lineText?`
|
|
3
3
|
${e.lineText.trim()}`:"";return r?`${r}: ${e.message}${s}`:`${e.message}${s}`}).join(`
|
|
4
|
-
`)}export{
|
|
4
|
+
`)}export{bn,fe};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,i,N}from"./chunk-
|
|
3
|
-
`),n=[{obj:a,indent:-1}];for(let r of s){let l=r.replace(/#.*$/,"").trimEnd();if(!l.trim())continue;let c=l.search(/\S/);if(c===-1)continue;while(n.length>1&&n[n.length-1].indent>=c)n.pop();let u=n[n.length-1].obj,o=l.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(o){let[,,g,f]=o,p=g.trim(),m=f.trim();if(m==="")u[p]={},n.push({obj:u[p],indent:c});else u[p]=X(m)}}return a}function X(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);let a=e.toLowerCase();if(a==="true"||a==="yes")return!0;if(a==="false"||a==="no")return!1;if(a==="null"||a==="~")return null;let s=Number(e);if(!Number.isNaN(s)&&e!=="")return s;return e}function ee(e){switch(e){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function te(e,a){return G(e,a)}function re(e,a){for(let s of e){let n=s.trim(),r=n.match(/^\{(\d+)\}\s*(.*)$/);if(r){let c=Number.parseInt(r[1],10);if(a===c)return r[2];continue}let l=n.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(l){let c=Number.parseInt(l[1],10),u=l[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(l[2],10);if(a>=c&&a<=u)return l[3];continue}}if(e.length===2)return a===1?e[0].trim():e[1].trim();if(a<e.length)return e[a].trim();return e[e.length-1].trim()}function ne(e,a={}){return j(e,a)}function j(e,a){let s="",n=0;while(n<e.length)if(e[n]==="{"){let r=ie(e,n);if(r===-1){s+=e[n],n++;continue}let l=e.slice(n+1,r);s+=se(l,a),n=r+1}else if(e[n]==="'"&&n+1<e.length)if(e[n+1]==="'")s+="'",n+=2;else if(e[n+1]==="{"||e[n+1]==="}")s+=e[n+1],n+=2;else s+=e[n],n++;else s+=e[n],n++;return s}function ie(e,a){let s=0;for(let n=a;n<e.length;n++)if(e[n]==="{")s++;else if(e[n]==="}"){if(s--,s===0)return n}return-1}function se(e,a){let s=ae(e);if(s.length===0)return`{${e}}`;let n=s[0].trim(),r=a[n];if(s.length===1)return r!==void 0?String(r):`{${n}}`;switch(s[1].trim().toLowerCase()){case"plural":return oe(r,s.slice(2).join(","),a);case"select":return ce(r,s.slice(2).join(","));case"selectordinal":return ue(r,s.slice(2).join(","));case"number":return ge(r,s[2]?.trim());case"date":return pe(r,s[2]?.trim());case"time":return fe(r,s[2]?.trim());default:return r!==void 0?String(r):`{${e}}`}}function ae(e){let a=[],s="",n=0;for(let r=0;r<e.length;r++){let l=e[r];if(l==="{")n++,s+=l;else if(l==="}")n--,s+=l;else if(l===","&&n===0)a.push(s),s="";else s+=l}if(s)a.push(s);return a}function oe(e,a,s){let n=Number(e)||0,r=P(a),l=`=${n}`;if(r[l])return R(r[l],n,s);let c=le(n);if(r[c])return R(r[c],n,s);if(r.other)return R(r.other,n,s);return String(n)}function R(e,a,s){let n=e.replace(/#/g,String(a));return j(n,s)}function le(e){let a=Math.abs(e),s=Math.floor(a),n=String(e).includes(".")?String(e).split(".")[1].length:0;if(s===1&&n===0)return"one";return"other"}function ce(e,a){let s=String(e||""),n=P(a);if(n[s])return n[s];return n.other||String(e)}function ue(e,a){let s=Number(e)||0,n=P(a),r=de(s);if(n[r])return n[r].replace(/#/g,String(s));if(n.other)return n.other.replace(/#/g,String(s));return String(s)}function de(e){let a=Math.abs(e),s=a%10,n=a%100;if(s===1&&n!==11)return"one";if(s===2&&n!==12)return"two";if(s===3&&n!==13)return"few";return"other"}function P(e){let a={},s=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,n=s.exec(e);while(n!==null)a[n[1]]=n[2],n=s.exec(e);return a}function ge(e,a){let s=Number(e);if(Number.isNaN(s))return String(e);switch(a){case"integer":return Math.floor(s).toLocaleString();case"percent":return`${(s*100).toFixed(0)}%`;case"currency":return s.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return s.toLocaleString()}}function pe(e,a){let s=e instanceof Date?e:new Date(String(e));if(Number.isNaN(s.getTime()))return String(e);let n={};switch(a){case"short":n.dateStyle="short";break;case"medium":n.dateStyle="medium";break;case"long":n.dateStyle="long";break;case"full":n.dateStyle="full";break;default:n.dateStyle="medium"}return s.toLocaleDateString(void 0,n)}function fe(e,a){let s=e instanceof Date?e:new Date(String(e));if(Number.isNaN(s.getTime()))return String(e);let n={};switch(a){case"short":n.timeStyle="short";break;case"medium":n.timeStyle="medium";break;case"long":n.timeStyle="long";break;case"full":n.timeStyle="full";break;default:n.timeStyle="short"}return s.toLocaleTimeString(void 0,n)}function me(e){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test(e)}function O(e,a,s=!0,n={}){let r=e.split("."),l=a;for(let u of r){if(l===void 0||l===null)break;l=l[u]}if(l===void 0||l===null)return s?e:"";let c=String(l);if(me(c))return ne(c,n);if(c.includes("|")&&"count"in n){let u=Number(n.count),o=c.split("|");c=re(o,u)}for(let[u,o]of Object.entries(n)){let g=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");c=c.replace(new RegExp(`:${g}`,"g"),String(o))}return c}var D=new Set(["ar","arc","ckb","dv","fa","he","khw","ks","nqo","prs","ps","sd","syr","ug","ur","uz-af","yi"]),be=new Set(["adlm","arab","aran","hebr","nkoo","rohg","syrc","thaa","yezi"]);function _(e){if(!e)return"ltr";let a=e.trim().toLowerCase().replace(/_/g,"-").split("-"),s=a[0];if(!s)return"ltr";let n=a[1]?.length===4?a[1]:void 0;if(n)return be.has(n)?"rtl":"ltr";if(a.length>1&&D.has(`${s}-${a[1]}`))return"rtl";return D.has(s)?"rtl":"ltr"}async function ji(e,a,s,n){let r=e,l=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,c={...T,...n.i18n},u=await te(c.locale,n);a.__translations=u,a.__locale=c.locale,a.__i18nConfig=c,r=await F(r,l,async(f,p,m,w,h)=>{try{let b={};if(m)try{let d=[()=>JSON.parse(m),()=>{let x=`{"data":${m}}`,A=JSON.parse(x);return typeof A.data==="object"?A.data:{}},()=>N(m,a)];for(let x of d)try{if(b=x(),Object.keys(b).length>0)break}catch{}}catch(d){if(n.debug)console.error("Error parsing parameters for @translate directive:",d)}return O(p,u,c.fallbackToKey,b)||w.trim()}catch(b){if(n.debug)console.error("Error processing @translate directive:",b);return i("Translate",`Error in @translate('${p}'): ${b instanceof Error?b.message:String(b)}`,t.EVALUATION_ERROR)}});let o=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(n.debug){console.warn(`Processing translations in template. Sections: ${r.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let f=[...r.matchAll(o)];console.warn(`Found ${f.length} @translate matches`),f.forEach((p,m)=>console.warn(`Match ${m}: ${p[0]}, Key: ${p[1]}, Params: ${p[2]||"none"}`))}return r=await F(r,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(f,p,m,w)=>{try{let h={};if(m)try{let b=[()=>JSON.parse(m),()=>{let y=`{"data":${m}}`,d=JSON.parse(y);return typeof d.data==="object"?d.data:{}},()=>N(m,a)];for(let y of b)try{if(h=y(),Object.keys(h).length>0)break}catch{}}catch(b){if(n.debug)console.error("Error parsing parameters for @translate directive:",b)}return O(p,u,c.fallbackToKey,h)}catch(h){if(n.debug)console.error("Error processing @translate directive:",h);return i("Translate",`Error in @translate('${p}'): ${h instanceof Error?h.message:String(h)}`,t.EVALUATION_ERROR)}}),r}async function F(e,a,s){let n=[];return e.replace(a,(l,...c)=>{let u=s(l,...c).then((o)=>({match:l,replacement:o}));return n.push(u),l}),(await Promise.all(n)).reduce((l,{match:c,replacement:u})=>l.replace(c,u),e)}function q(e,a){if(!e||_(e)!=="rtl")return!1;return!a||a.trim().toLowerCase()!=="rtl"}function V(e){if(!e)return!1;return e.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||e.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function I(e,a){let s=new RegExp(`\\b${a}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);if(!s)return null;return s[2]??s[3]??s[4]??null}function Bi(e,a,s,n){let r=e;r=r.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,u,o)=>{let f={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[u]||"Make this element accessible";return`<!-- a11y-hint: ${o||f} -->`});let l=/@screenReader\(([^@]*)\)@endScreenReader/g;return r=r.replace(l,(c,u)=>`<span class="sr-only">${u.trim()}</span>`),r=r.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(c,u,o)=>`<span id="${`desc-${u}`}" class="sr-only">${o}</span>`),r}function he(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function ye(e){let a=new Map,s=e.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,(r,l,c)=>{let u=a.get(c);if(!u)u=`stx-a11y-component-${a.size}`,a.set(c,u);return`<${l}${u}`}),n=new Map([...a.entries()].map(([r,l])=>[l,r]));return{protectedSource:s,restore:(r)=>r.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(l,c,u)=>{let o=n.get(u);return o?`<${c}${o}`:l})}}function xe(e,a){let s=[],n=/<img\s+([^>]*)>/gi,r;r=n.exec(e);while(r!==null){let d=r[1];if(!/\balt\s*=/i.test(d))s.push({type:"missing-alt",element:r[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});r=n.exec(e)}let l=/<button([^>]*)>\s*<\/button>/gi;r=l.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))s.push({type:"missing-accessible-name",element:r[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});r=l.exec(e)}let c=/<a\s+([^>]*)>\s*<\/a>/gi;r=c.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))s.push({type:"link-missing-text",element:r[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});r=c.exec(e)}let u=/<(input|select|textarea)\s+([^>]*)>/gi;r=u.exec(e);while(r!==null){let d=r[2];if(/\btype\s*=\s*["']hidden["']/i.test(d)){r=u.exec(e);continue}let x=/\baria-label\s*=/i.test(d)||/\baria-labelledby\s*=/i.test(d),A=d.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!x){let B=A&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${A[1]}["']`,"i").test(e),U=r.index,M=e.substring(0,U),Ae=e.substring(U),H=(M.match(/<label\b/gi)||[]).length,z=(M.match(/<\/label>/gi)||[]).length,K=H>z;if(!B&&!K)s.push({type:"input-missing-label",element:r[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}r=u.exec(e)}let o=/<h([1-6])[^>]*>/gi,g=[];r=o.exec(e);while(r!==null)g.push(Number.parseInt(r[1],10)),r=o.exec(e);let f=0;for(let d of g){if(f>0&&d>f+1)s.push({type:"heading-skip",element:`<h${d}>`,message:`Heading level skipped from h${f} to h${d}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});f=d}if(/<html\b/i.test(e)&&!/<html[^>]*\slang\s*=/i.test(e))s.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let p=e.match(/<html\b([^>]*)>/i);if(p&&q(I(p[1],"lang"),I(p[1],"dir")))s.push({type:"missing-dir",element:p[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let m=/<table([^>]*)>([\s\S]*?)<\/table>/gi;r=m.exec(e);while(r!==null){let d=r[2];if(!V(I(r[1],"role"))&&!/<th\b/i.test(d))s.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});r=m.exec(e)}let w=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;r=w.exec(e);while(r!==null){if(!/\bmuted\b/i.test(r[0]))s.push({type:"autoplay-audio",element:`<${r[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});r=w.exec(e)}let h=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;r=h.exec(e);while(r!==null)s.push({type:"positive-tabindex",element:`tabindex="${r[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),r=h.exec(e);let b=/<iframe\s+([^>]*)>/gi;r=b.exec(e);while(r!==null){let d=r[1];if(!/\btitle\s*=/i.test(d)&&!/\baria-label\s*=/i.test(d))s.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});r=b.exec(e)}let y=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;r=y.exec(e);while(r!==null){let d=r[1].toLowerCase(),x=r[2];if(d!=="button"&&!/\btabindex\s*=/i.test(x))s.push({type:"button-not-focusable",element:r[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});r=y.exec(e)}return s}async function we(e,a){let{protectedSource:s}=ye(e);if(!he())return xe(s,a);let n=[];try{let r=globalThis.document.createElement("div");r.innerHTML=s,r.querySelectorAll("img").forEach((o)=>{if(!o.hasAttribute("alt"))n.push({type:"missing-alt",element:`<${o.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),r.querySelectorAll('button, a, [role="button"]').forEach((o)=>{if(!(o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby")||o.textContent&&o.textContent.trim().length>0))n.push({type:"missing-accessible-name",element:`<${o.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),r.querySelectorAll("input, select, textarea").forEach((o)=>{let g=o.getAttribute("id"),f=g&&r.querySelector(`label[for="${g}"]`),p=o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby"),m=o.closest("label")!==null;if(!f&&!p&&!m)n.push({type:"input-missing-label",element:`<${o.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let l=Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")),c=0;for(let o of l){let g=Number.parseInt(o.tagName.charAt(1));if(c>0&&g>c+1)n.push({type:"heading-skip",element:`<${o.outerHTML}>`,message:`Heading level skipped from h${c} to h${g}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});c=g}let u=r.querySelector("html");if(s.includes("<html")&&u&&!u.hasAttribute("lang"))n.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(u&&q(u.getAttribute("lang"),u.getAttribute("dir")))n.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if(r.querySelectorAll("a").forEach((o)=>{let g=o.textContent&&o.textContent.trim().length>0,f=o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby"),p=o.hasAttribute("title"),m=o.querySelector("img[alt]");if(!g&&!f&&!p&&!m)n.push({type:"link-missing-text",element:`<${o.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),s.includes("<nav")||s.includes("<header")){if(!r.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&r.querySelectorAll("a").length>5)n.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(r.querySelectorAll("table").forEach((o)=>{if(V(o.getAttribute("role")))return;let g=o.querySelector("caption");if(!o.querySelector("th"))n.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!g&&!o.hasAttribute("aria-label")&&!o.hasAttribute("aria-labelledby"))n.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),r.querySelectorAll('[style*="color"]').forEach((o)=>{let g=o.getAttribute("style")||"";if(g.includes("color:")&&!g.includes("background"))n.push({type:"potential-contrast-issue",element:`<${o.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),r.querySelectorAll("video[autoplay], audio[autoplay]").forEach((o)=>{if(!o.hasAttribute("muted"))n.push({type:"autoplay-audio",element:`<${o.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),r.querySelectorAll("[tabindex]").forEach((o)=>{if(Number.parseInt(o.getAttribute("tabindex")||"0")>0)n.push({type:"positive-tabindex",element:`<${o.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),r.querySelectorAll('[role="button"]').forEach((o)=>{if(!o.hasAttribute("tabindex"))n.push({type:"button-not-focusable",element:`<${o.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),s.includes("<body")&&!r.querySelector('main, [role="main"]'))n.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});r.querySelectorAll("iframe").forEach((o)=>{if(!o.hasAttribute("title")&&!o.hasAttribute("aria-label"))n.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(r){console.error(`Error checking accessibility in ${a}:`,r)}return n}async function Fi(e,a={}){let s={},{recursive:n=!0,ignorePaths:r=[]}=a,l=Array.isArray(e)?e:[e],c=await Us(l,{recursive:n,ignorePaths:r}),u=[];for(let o of c)try{let g=await Bun.file(o).text();if(o.endsWith("good-a11y.stx"))continue;let f=await we(g,o);if(u.push(o),f.length>0)s[o]=f}catch(g){console.error(`Error scanning ${o}:`,g)}return{results:s,scannedFiles:u}}var zi={name:"a11y",handler:(e,a,s,n)=>{if(!a.length)return e;let r=a[0].replace(/['"]/g,""),l=a.length>1?a[1].replace(/['"]/g,""):"",u={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[r]||"Make this element accessible";return`<!-- a11y-hint: ${l||u} -->${e}`},hasEndTag:!1},Hi={name:"screenReader",handler:(e)=>`<span class="sr-only">${e}</span>`,hasEndTag:!0};
|
|
4
|
-
export{
|
|
2
|
+
import{t,i,N}from"./chunk-ptv5f34x.js";import{Ws}from"./chunk-f30t1g74.js";import E from"path";var S;async function W(){if(S!==void 0)return S;try{let e=await import("@stacksjs/ts-i18n");S=e.loadLocale??null}catch{S=null}return S}var T={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},v={},L={},k={};function J(e,a=0){if(a<=0)return!1;return Date.now()-e.loadedAt>a}async function G(e,a){if({...T,...a.i18n}.cache&&v[e]){let r=v[e],l=a.i18n?.cacheMaxAge??0;if(!J(r,l))return r.translations}if(L[e]?.state==="loading")return L[e].promise;k[e]="loading";let n=C(e,a).then((r)=>(k[e]="loaded",delete L[e],r)).catch((r)=>{throw k[e]="error",L[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return L[e]={promise:n,state:"loading"},n}async function C(e,a){let s={...T,...a.i18n},n=E.isAbsolute(s.translationsDir)?s.translationsDir:E.resolve(a.root||process.cwd(),s.translationsDir);try{let r=await W(),l=r?await r(e,{translationsDir:n,defaultLocale:s.defaultLocale,sources:ee(s.format)}):await Y(e,s,n);if(l===void 0){let u=e!==s.defaultLocale?await C(s.defaultLocale,a):{};if(s.cache)v[e]={translations:u,loadedAt:Date.now(),locale:e};return u}let c=l;if(s.cache)v[e]={translations:c,loadedAt:Date.now(),locale:e};return c}catch(r){if(a.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==s.defaultLocale)return C(s.defaultLocale,a);return{}}}async function Y(e,a,s){let n=E.join(s,`${e}${Z(a.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let l=await Bun.file(n).text();if(a.format==="yaml"||a.format==="yml")return Q(l);if(a.format==="json")return JSON.parse(l);throw r}catch{return}}}function Z(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function Q(e){let a={},s=e.split(`
|
|
3
|
+
`),n=[{obj:a,indent:-1}];for(let r of s){let l=r.replace(/#.*$/,"").trimEnd();if(!l.trim())continue;let c=l.search(/\S/);if(c===-1)continue;while(n.length>1&&n[n.length-1].indent>=c)n.pop();let u=n[n.length-1].obj,o=l.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(o){let[,,g,f]=o,p=g.trim(),m=f.trim();if(m==="")u[p]={},n.push({obj:u[p],indent:c});else u[p]=X(m)}}return a}function X(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);let a=e.toLowerCase();if(a==="true"||a==="yes")return!0;if(a==="false"||a==="no")return!1;if(a==="null"||a==="~")return null;let s=Number(e);if(!Number.isNaN(s)&&e!=="")return s;return e}function ee(e){switch(e){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function te(e,a){return G(e,a)}function re(e,a){for(let s of e){let n=s.trim(),r=n.match(/^\{(\d+)\}\s*(.*)$/);if(r){let c=Number.parseInt(r[1],10);if(a===c)return r[2];continue}let l=n.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(l){let c=Number.parseInt(l[1],10),u=l[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(l[2],10);if(a>=c&&a<=u)return l[3];continue}}if(e.length===2)return a===1?e[0].trim():e[1].trim();if(a<e.length)return e[a].trim();return e[e.length-1].trim()}function ne(e,a={}){return j(e,a)}function j(e,a){let s="",n=0;while(n<e.length)if(e[n]==="{"){let r=ie(e,n);if(r===-1){s+=e[n],n++;continue}let l=e.slice(n+1,r);s+=se(l,a),n=r+1}else if(e[n]==="'"&&n+1<e.length)if(e[n+1]==="'")s+="'",n+=2;else if(e[n+1]==="{"||e[n+1]==="}")s+=e[n+1],n+=2;else s+=e[n],n++;else s+=e[n],n++;return s}function ie(e,a){let s=0;for(let n=a;n<e.length;n++)if(e[n]==="{")s++;else if(e[n]==="}"){if(s--,s===0)return n}return-1}function se(e,a){let s=ae(e);if(s.length===0)return`{${e}}`;let n=s[0].trim(),r=a[n];if(s.length===1)return r!==void 0?String(r):`{${n}}`;switch(s[1].trim().toLowerCase()){case"plural":return oe(r,s.slice(2).join(","),a);case"select":return ce(r,s.slice(2).join(","));case"selectordinal":return ue(r,s.slice(2).join(","));case"number":return ge(r,s[2]?.trim());case"date":return pe(r,s[2]?.trim());case"time":return fe(r,s[2]?.trim());default:return r!==void 0?String(r):`{${e}}`}}function ae(e){let a=[],s="",n=0;for(let r=0;r<e.length;r++){let l=e[r];if(l==="{")n++,s+=l;else if(l==="}")n--,s+=l;else if(l===","&&n===0)a.push(s),s="";else s+=l}if(s)a.push(s);return a}function oe(e,a,s){let n=Number(e)||0,r=P(a),l=`=${n}`;if(r[l])return R(r[l],n,s);let c=le(n);if(r[c])return R(r[c],n,s);if(r.other)return R(r.other,n,s);return String(n)}function R(e,a,s){let n=e.replace(/#/g,String(a));return j(n,s)}function le(e){let a=Math.abs(e),s=Math.floor(a),n=String(e).includes(".")?String(e).split(".")[1].length:0;if(s===1&&n===0)return"one";return"other"}function ce(e,a){let s=String(e||""),n=P(a);if(n[s])return n[s];return n.other||String(e)}function ue(e,a){let s=Number(e)||0,n=P(a),r=de(s);if(n[r])return n[r].replace(/#/g,String(s));if(n.other)return n.other.replace(/#/g,String(s));return String(s)}function de(e){let a=Math.abs(e),s=a%10,n=a%100;if(s===1&&n!==11)return"one";if(s===2&&n!==12)return"two";if(s===3&&n!==13)return"few";return"other"}function P(e){let a={},s=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,n=s.exec(e);while(n!==null)a[n[1]]=n[2],n=s.exec(e);return a}function ge(e,a){let s=Number(e);if(Number.isNaN(s))return String(e);switch(a){case"integer":return Math.floor(s).toLocaleString();case"percent":return`${(s*100).toFixed(0)}%`;case"currency":return s.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return s.toLocaleString()}}function pe(e,a){let s=e instanceof Date?e:new Date(String(e));if(Number.isNaN(s.getTime()))return String(e);let n={};switch(a){case"short":n.dateStyle="short";break;case"medium":n.dateStyle="medium";break;case"long":n.dateStyle="long";break;case"full":n.dateStyle="full";break;default:n.dateStyle="medium"}return s.toLocaleDateString(void 0,n)}function fe(e,a){let s=e instanceof Date?e:new Date(String(e));if(Number.isNaN(s.getTime()))return String(e);let n={};switch(a){case"short":n.timeStyle="short";break;case"medium":n.timeStyle="medium";break;case"long":n.timeStyle="long";break;case"full":n.timeStyle="full";break;default:n.timeStyle="short"}return s.toLocaleTimeString(void 0,n)}function me(e){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test(e)}function O(e,a,s=!0,n={}){let r=e.split("."),l=a;for(let u of r){if(l===void 0||l===null)break;l=l[u]}if(l===void 0||l===null)return s?e:"";let c=String(l);if(me(c))return ne(c,n);if(c.includes("|")&&"count"in n){let u=Number(n.count),o=c.split("|");c=re(o,u)}for(let[u,o]of Object.entries(n)){let g=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");c=c.replace(new RegExp(`:${g}`,"g"),String(o))}return c}var D=new Set(["ar","arc","ckb","dv","fa","he","khw","ks","nqo","prs","ps","sd","syr","ug","ur","uz-af","yi"]),be=new Set(["adlm","arab","aran","hebr","nkoo","rohg","syrc","thaa","yezi"]);function _(e){if(!e)return"ltr";let a=e.trim().toLowerCase().replace(/_/g,"-").split("-"),s=a[0];if(!s)return"ltr";let n=a[1]?.length===4?a[1]:void 0;if(n)return be.has(n)?"rtl":"ltr";if(a.length>1&&D.has(`${s}-${a[1]}`))return"rtl";return D.has(s)?"rtl":"ltr"}async function Bi(e,a,s,n){let r=e,l=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,c={...T,...n.i18n},u=await te(c.locale,n);a.__translations=u,a.__locale=c.locale,a.__i18nConfig=c,r=await F(r,l,async(f,p,m,w,h)=>{try{let b={};if(m)try{let d=[()=>JSON.parse(m),()=>{let x=`{"data":${m}}`,A=JSON.parse(x);return typeof A.data==="object"?A.data:{}},()=>N(m,a)];for(let x of d)try{if(b=x(),Object.keys(b).length>0)break}catch{}}catch(d){if(n.debug)console.error("Error parsing parameters for @translate directive:",d)}return O(p,u,c.fallbackToKey,b)||w.trim()}catch(b){if(n.debug)console.error("Error processing @translate directive:",b);return i("Translate",`Error in @translate('${p}'): ${b instanceof Error?b.message:String(b)}`,t.EVALUATION_ERROR)}});let o=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(n.debug){console.warn(`Processing translations in template. Sections: ${r.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let f=[...r.matchAll(o)];console.warn(`Found ${f.length} @translate matches`),f.forEach((p,m)=>console.warn(`Match ${m}: ${p[0]}, Key: ${p[1]}, Params: ${p[2]||"none"}`))}return r=await F(r,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(f,p,m,w)=>{try{let h={};if(m)try{let b=[()=>JSON.parse(m),()=>{let y=`{"data":${m}}`,d=JSON.parse(y);return typeof d.data==="object"?d.data:{}},()=>N(m,a)];for(let y of b)try{if(h=y(),Object.keys(h).length>0)break}catch{}}catch(b){if(n.debug)console.error("Error parsing parameters for @translate directive:",b)}return O(p,u,c.fallbackToKey,h)}catch(h){if(n.debug)console.error("Error processing @translate directive:",h);return i("Translate",`Error in @translate('${p}'): ${h instanceof Error?h.message:String(h)}`,t.EVALUATION_ERROR)}}),r}async function F(e,a,s){let n=[];return e.replace(a,(l,...c)=>{let u=s(l,...c).then((o)=>({match:l,replacement:o}));return n.push(u),l}),(await Promise.all(n)).reduce((l,{match:c,replacement:u})=>l.replace(c,u),e)}function q(e,a){if(!e||_(e)!=="rtl")return!1;return!a||a.trim().toLowerCase()!=="rtl"}function V(e){if(!e)return!1;return e.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||e.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function I(e,a){let s=new RegExp(`\\b${a}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);if(!s)return null;return s[2]??s[3]??s[4]??null}function Fi(e,a,s,n){let r=e;r=r.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,u,o)=>{let f={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[u]||"Make this element accessible";return`<!-- a11y-hint: ${o||f} -->`});let l=/@screenReader\(([^@]*)\)@endScreenReader/g;return r=r.replace(l,(c,u)=>`<span class="sr-only">${u.trim()}</span>`),r=r.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(c,u,o)=>`<span id="${`desc-${u}`}" class="sr-only">${o}</span>`),r}function he(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function ye(e){let a=new Map,s=e.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,(r,l,c)=>{let u=a.get(c);if(!u)u=`stx-a11y-component-${a.size}`,a.set(c,u);return`<${l}${u}`}),n=new Map([...a.entries()].map(([r,l])=>[l,r]));return{protectedSource:s,restore:(r)=>r.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(l,c,u)=>{let o=n.get(u);return o?`<${c}${o}`:l})}}function xe(e,a){let s=[],n=/<img\s+([^>]*)>/gi,r;r=n.exec(e);while(r!==null){let d=r[1];if(!/\balt\s*=/i.test(d))s.push({type:"missing-alt",element:r[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});r=n.exec(e)}let l=/<button([^>]*)>\s*<\/button>/gi;r=l.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))s.push({type:"missing-accessible-name",element:r[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});r=l.exec(e)}let c=/<a\s+([^>]*)>\s*<\/a>/gi;r=c.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))s.push({type:"link-missing-text",element:r[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});r=c.exec(e)}let u=/<(input|select|textarea)\s+([^>]*)>/gi;r=u.exec(e);while(r!==null){let d=r[2];if(/\btype\s*=\s*["']hidden["']/i.test(d)){r=u.exec(e);continue}let x=/\baria-label\s*=/i.test(d)||/\baria-labelledby\s*=/i.test(d),A=d.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!x){let B=A&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${A[1]}["']`,"i").test(e),U=r.index,M=e.substring(0,U),Ae=e.substring(U),H=(M.match(/<label\b/gi)||[]).length,z=(M.match(/<\/label>/gi)||[]).length,K=H>z;if(!B&&!K)s.push({type:"input-missing-label",element:r[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}r=u.exec(e)}let o=/<h([1-6])[^>]*>/gi,g=[];r=o.exec(e);while(r!==null)g.push(Number.parseInt(r[1],10)),r=o.exec(e);let f=0;for(let d of g){if(f>0&&d>f+1)s.push({type:"heading-skip",element:`<h${d}>`,message:`Heading level skipped from h${f} to h${d}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});f=d}if(/<html\b/i.test(e)&&!/<html[^>]*\slang\s*=/i.test(e))s.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let p=e.match(/<html\b([^>]*)>/i);if(p&&q(I(p[1],"lang"),I(p[1],"dir")))s.push({type:"missing-dir",element:p[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let m=/<table([^>]*)>([\s\S]*?)<\/table>/gi;r=m.exec(e);while(r!==null){let d=r[2];if(!V(I(r[1],"role"))&&!/<th\b/i.test(d))s.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});r=m.exec(e)}let w=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;r=w.exec(e);while(r!==null){if(!/\bmuted\b/i.test(r[0]))s.push({type:"autoplay-audio",element:`<${r[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});r=w.exec(e)}let h=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;r=h.exec(e);while(r!==null)s.push({type:"positive-tabindex",element:`tabindex="${r[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),r=h.exec(e);let b=/<iframe\s+([^>]*)>/gi;r=b.exec(e);while(r!==null){let d=r[1];if(!/\btitle\s*=/i.test(d)&&!/\baria-label\s*=/i.test(d))s.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});r=b.exec(e)}let y=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;r=y.exec(e);while(r!==null){let d=r[1].toLowerCase(),x=r[2];if(d!=="button"&&!/\btabindex\s*=/i.test(x))s.push({type:"button-not-focusable",element:r[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});r=y.exec(e)}return s}async function we(e,a){let{protectedSource:s}=ye(e);if(!he())return xe(s,a);let n=[];try{let r=globalThis.document.createElement("div");r.innerHTML=s,r.querySelectorAll("img").forEach((o)=>{if(!o.hasAttribute("alt"))n.push({type:"missing-alt",element:`<${o.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),r.querySelectorAll('button, a, [role="button"]').forEach((o)=>{if(!(o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby")||o.textContent&&o.textContent.trim().length>0))n.push({type:"missing-accessible-name",element:`<${o.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),r.querySelectorAll("input, select, textarea").forEach((o)=>{let g=o.getAttribute("id"),f=g&&r.querySelector(`label[for="${g}"]`),p=o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby"),m=o.closest("label")!==null;if(!f&&!p&&!m)n.push({type:"input-missing-label",element:`<${o.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let l=Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")),c=0;for(let o of l){let g=Number.parseInt(o.tagName.charAt(1));if(c>0&&g>c+1)n.push({type:"heading-skip",element:`<${o.outerHTML}>`,message:`Heading level skipped from h${c} to h${g}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});c=g}let u=r.querySelector("html");if(s.includes("<html")&&u&&!u.hasAttribute("lang"))n.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(u&&q(u.getAttribute("lang"),u.getAttribute("dir")))n.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if(r.querySelectorAll("a").forEach((o)=>{let g=o.textContent&&o.textContent.trim().length>0,f=o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby"),p=o.hasAttribute("title"),m=o.querySelector("img[alt]");if(!g&&!f&&!p&&!m)n.push({type:"link-missing-text",element:`<${o.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),s.includes("<nav")||s.includes("<header")){if(!r.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&r.querySelectorAll("a").length>5)n.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(r.querySelectorAll("table").forEach((o)=>{if(V(o.getAttribute("role")))return;let g=o.querySelector("caption");if(!o.querySelector("th"))n.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!g&&!o.hasAttribute("aria-label")&&!o.hasAttribute("aria-labelledby"))n.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),r.querySelectorAll('[style*="color"]').forEach((o)=>{let g=o.getAttribute("style")||"";if(g.includes("color:")&&!g.includes("background"))n.push({type:"potential-contrast-issue",element:`<${o.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),r.querySelectorAll("video[autoplay], audio[autoplay]").forEach((o)=>{if(!o.hasAttribute("muted"))n.push({type:"autoplay-audio",element:`<${o.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),r.querySelectorAll("[tabindex]").forEach((o)=>{if(Number.parseInt(o.getAttribute("tabindex")||"0")>0)n.push({type:"positive-tabindex",element:`<${o.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),r.querySelectorAll('[role="button"]').forEach((o)=>{if(!o.hasAttribute("tabindex"))n.push({type:"button-not-focusable",element:`<${o.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),s.includes("<body")&&!r.querySelector('main, [role="main"]'))n.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});r.querySelectorAll("iframe").forEach((o)=>{if(!o.hasAttribute("title")&&!o.hasAttribute("aria-label"))n.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(r){console.error(`Error checking accessibility in ${a}:`,r)}return n}async function zi(e,a={}){let s={},{recursive:n=!0,ignorePaths:r=[]}=a,l=Array.isArray(e)?e:[e],c=await Ws(l,{recursive:n,ignorePaths:r}),u=[];for(let o of c)try{let g=await Bun.file(o).text();if(o.endsWith("good-a11y.stx"))continue;let f=await we(g,o);if(u.push(o),f.length>0)s[o]=f}catch(g){console.error(`Error scanning ${o}:`,g)}return{results:s,scannedFiles:u}}var Hi={name:"a11y",handler:(e,a,s,n)=>{if(!a.length)return e;let r=a[0].replace(/['"]/g,""),l=a.length>1?a[1].replace(/['"]/g,""):"",u={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[r]||"Make this element accessible";return`<!-- a11y-hint: ${l||u} -->${e}`},hasEndTag:!1},Vi={name:"screenReader",handler:(e)=>`<span class="sr-only">${e}</span>`,hasEndTag:!0};
|
|
4
|
+
export{Bi,Fi,zi,Hi,Vi};
|
|
@@ -1,7 +1,7 @@
|
|
|
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 P(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return P(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 ee(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 zn(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 Ar(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return ee(a,t)}import j 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(j.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function F(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(...F(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 Hn{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=F(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:H,params:M}=ee(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.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");ao(this.routes,s),co(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 Pr(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 Ir(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 cl(e){k=e.replace(/\/$/,"")}function ll(e,t,a={}){f[e]={path:t,name:e,params:a}}function ul(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 Vn(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 dl(){for(let e of Object.keys(f))delete f[e];k=""}import B from"fs";import U from"path";function pl(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function fl(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function gl(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(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 ua(e,t){let a=e.headers.get("cookie")||"",r=O(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 da(){return{get(e){if(typeof document>"u")return;return O(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 O(document.cookie)}}}function pa(){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 lo(e,t){v.set(e,t)}function fa(e){return v.get(e)}function ml(e){return v.has(e)}function pt(){v.clear()}function ft(){return Array.from(v.keys())}async function gt(e,t="middleware"){let a=U.resolve(e,t);if(!B.existsSync(a))return;let r=B.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")lo(o,s);else if(typeof s==="function")lo(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 mt(e,t,a,r=""){return{path:e,params:t,query:K(r),fullPath:r?`${e}?${r}`:e,meta:a}}function ht(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?ua(a,i):da(),storage:pa(),state:{},request:a,responseHeaders:i}}async function yt(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=fa(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 Or(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 Oe(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]||Or(n)}}var A,T;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 q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){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 P(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return P(e.replace(/^\//,""))}function co(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 lo(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("|"),G=new RegExp(`\\.(?:${D})$`),E=`(?![^/]*\\.(?:${D})$)`;function pt(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 ee(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 Hn(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 Pr(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return ee(a,t)}import j 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(j.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function F(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(...F(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 Vn{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=F(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:H,params:M}=ee(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.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");co(this.routes,s),lo(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 Ir(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 Or(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 ll(e){k=e.replace(/\/$/,"")}function ul(e,t,a={}){f[e]={path:t,name:e,params:a}}function dl(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 Un(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 pl(){for(let e of Object.keys(f))delete f[e];k=""}import B from"fs";import U from"path";function fl(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function gl(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function ml(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(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 da(e,t){let a=e.headers.get("cookie")||"",r=O(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 pa(){return{get(e){if(typeof document>"u")return;return O(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 O(document.cookie)}}}function fa(){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 uo(e,t){v.set(e,t)}function ga(e){return v.get(e)}function hl(e){return v.has(e)}function ft(){v.clear()}function gt(){return Array.from(v.keys())}async function mt(e,t="middleware"){let a=U.resolve(e,t);if(!B.existsSync(a))return;let r=B.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")uo(o,s);else if(typeof s==="function")uo(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 ht(e,t,a,r=""){return{path:e,params:t,query:K(r),fullPath:r?`${e}?${r}`:e,meta:a}}function yt(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?da(a,i):pa(),storage:fa(),state:{},request:a,responseHeaders:i}}async function bt(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=ga(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 Nr(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 Ne(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]||Nr(n)}}var A,T;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 q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
|
|
5
5
|
;(function(){
|
|
6
6
|
'use strict';
|
|
7
7
|
var ROUTER_REV=7;
|
|
@@ -3939,4 +3939,4 @@ else {
|
|
|
3939
3939
|
|
|
3940
3940
|
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
|
|
3941
3941
|
})();
|
|
3942
|
-
`}function
|
|
3942
|
+
`}function De(){if(A)return A;return A=q(W(X()),!0),A}function yl(){if(T)return T;return T=q(X()),T}export{co,lo,pt,ee,Hn,Pr,Vn,Ir,Or,ll,ul,dl,Un,pl,fl,gl,ml,da,pa,fa,uo,ga,hl,ft,gt,mt,ht,yt,bt,Nr,Ne,De,yl};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R,k,
|
|
3
|
-
`)}async function
|
|
2
|
+
import{R,k,sn,on,an}from"./chunk-4n24jbfs.js";import{resolve as Q,basename as J,extname as K,join as Y}from"path";import{mkdir as Z}from"fs/promises";var N={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class Zr{config;constructor(t={}){this.config={...N,...t}}async get(t,e){return sn(t,e,"video",this.config)}async set(t,e,a){return on(t,e,a,"video",this.config)}async clear(){return an("video",this.config)}updateConfig(t){this.config={...this.config,...t}}}var v=null;function B(t){if(!v)v=new Zr(t);else if(t)v.updateConfig(t);return v}async function Qr(t,e,a){let c=a?{directory:`${a.outputDir}/../.cache`}:{};return B(c).get(t,e)}async function es(t,e,a,c){let r=c?{directory:`${c.outputDir}/../.cache`}:{};return B(r).set(t,e,a)}async function Fa(){return B().clear()}import{resolve as _,basename as D,extname as A,join as H}from"path";import{mkdir as M}from"fs/promises";async function L(){try{return await import("ts-videos")}catch{return null}}async function ts(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let n=_(t);if(!await k(n))return null;await M(a,{recursive:!0});let i=await R(n),s=D(t,A(t)),o=e.format||"webp",h=e.timestamp||0,y=`${s}-poster-${i}.${o}`,u=H(a,y),m=await r.extractThumbnails(n,{timestamps:[h],width:e.width||1280,height:e.height,format:o,quality:e.quality||85,outputDir:a,outputPattern:y.replace(`.${o}`,"")});if(m&&m.length>0){let d=m[0];return{path:u,url:`${c}/${y}`,width:d.width||e.width||1280,height:d.height||720,timestamp:h,size:d.size||0}}return null}catch(n){return console.warn(`[stx-media] Failed to generate poster: ${n}`),null}}async function ns(t,e,a,c){let r=await L();if(!r)return[];try{let n=_(t);if(!await k(n))return[];await M(a,{recursive:!0});let i=await R(n),s=D(t,A(t)),o=e.format||"webp",u=(await new r.Input(n).getInfo()).duration||60,m=e.count||10,d=e.interval||u/m,g=[];for(let f=0;f<m&&f*d<u;f++)g.push(f*d);let l=await r.extractThumbnails(n,{timestamps:g,width:e.width||320,format:o,quality:e.quality||80,outputDir:a,outputPattern:`${s}-thumb-${i}`});if(l&&l.length>0)return l.map((f,b)=>({path:f.path||H(a,`${s}-thumb-${i}-${b}.${o}`),url:`${c}/${s}-thumb-${i}-${b}.${o}`,width:f.width||e.width||320,height:f.height||180,timestamp:g[b],size:f.size||0}));return[]}catch(n){return console.warn(`[stx-media] Failed to generate thumbnails: ${n}`),[]}}async function za(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let n=_(t);if(!await k(n))return null;await M(a,{recursive:!0});let i=await R(n),s=D(t,A(t)),y=(await new r.Input(n).getInfo()).duration||60,u=e.columns||10,m=e.interval||5,d=e.thumbnailWidth||160,g=e.thumbnailHeight||90,l=e.format||"jpeg",f=Math.ceil(y/m),b=Math.ceil(f/u),S=`${s}-sprite-${i}.${l}`,w=H(a,S),C=[];for(let P=0;P<f;P++)C.push(P*m);let p=await r.extractThumbnails(n,{timestamps:C,width:d,height:g,format:l,quality:e.quality||70,outputDir:H(a,".temp")});if(!p||p.length===0)return null;try{let P=await import("ts-images"),x=u*d,ie=b*g,re=await P.createSprite({images:p.map((U)=>U.path),columns:u,padding:0,outputPath:w,format:l,quality:e.quality||70});return{url:`${c}/${S}`,path:w,columns:u,rows:b,thumbnailWidth:d,thumbnailHeight:g,interval:m,totalFrames:f}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(n){return console.warn(`[stx-media] Failed to generate sprite sheet: ${n}`),null}}import{resolve as E,basename as F,extname as W,join as V}from"path";import{mkdir as T,writeFile as q}from"fs/promises";async function z(){try{return await import("ts-videos")}catch{return null}}var j=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function rs(t,e,a,c,r){let n=await z();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let i=E(t);if(!await k(i))return null;let s=await R(i),o=F(t,W(t)),h=V(a,`${o}-${s}-hls`);await T(h,{recursive:!0});let y=e.length>0?e:j,u=r?.segmentDuration||6,g=(await new n.Input(i).getInfo()).duration||0,l=[],f=0;for(let w of y){let C=V(h,w.label);await T(C,{recursive:!0});let p=`${w.label}.m3u8`,P=V(C,p);try{let x=await n.generateHLS(i,{outputDir:C,segmentDuration:u,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate,playlistName:w.label});if(x)l.push({quality:w,url:`${c}/${o}-${s}-hls/${w.label}/${p}`,path:P}),f+=x.segmentCount||Math.ceil(g/u)}catch(x){console.warn(`[stx-media] Failed to generate HLS for ${w.label}: ${x}`)}}if(l.length===0)return null;let b=V(h,"master.m3u8"),S=X(l,c,o,s);return await q(b,S),{manifestUrl:`${c}/${o}-${s}-hls/master.m3u8`,manifestPath:b,playlists:l,segmentCount:f,duration:g}}catch(i){return console.warn(`[stx-media] Failed to generate HLS manifest: ${i}`),null}}function X(t,e,a,c){let r=["#EXTM3U","#EXT-X-VERSION:3"];for(let n of t){let{quality:i}=n,s=i.bitrate+(i.audioBitrate||128000),o=`${i.width}x${i.height||Math.round(i.width*9/16)}`;r.push(`#EXT-X-STREAM-INF:BANDWIDTH=${s},RESOLUTION=${o},NAME="${i.label}"`,`${i.label}/${i.label}.m3u8`)}return r.join(`
|
|
3
|
+
`)}async function ss(t,e,a,c,r){let n=await z();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let i=E(t);if(!await k(i))return null;let s=await R(i),o=F(t,W(t)),h=V(a,`${o}-${s}-dash`);await T(h,{recursive:!0});let y=e.length>0?e:j,u=r?.segmentDuration||4,m=r?.minBufferTime||2,l=(await new n.Input(i).getInfo()).duration||0,f=[],b=[];for(let p of y){let P=V(h,p.label);await T(P,{recursive:!0});try{if(await n.generateDASH(i,{outputDir:P,segmentDuration:u,width:p.width,height:p.height,videoBitrate:p.bitrate,audioBitrate:p.audioBitrate})){if(f.push({bandwidth:p.bitrate,width:p.width,height:p.height||Math.round(p.width*9/16),url:`${c}/${o}-${s}-dash/${p.label}/video`}),p.audioBitrate)b.push({bandwidth:p.audioBitrate,url:`${c}/${o}-${s}-dash/${p.label}/audio`})}}catch(x){console.warn(`[stx-media] Failed to generate DASH for ${p.label}: ${x}`)}}if(f.length===0)return null;let S=V(h,"manifest.mpd"),w=G(f,b,l,u,m);await q(S,w);let C=[{type:"video",representations:f}];if(b.length>0)C.push({type:"audio",representations:b});return{manifestUrl:`${c}/${o}-${s}-dash/manifest.mpd`,manifestPath:S,adaptationSets:C,duration:l}}catch(i){return console.warn(`[stx-media] Failed to generate DASH manifest: ${i}`),null}}function G(t,e,a,c,r){let n=I(a),i=I(r),s=`<?xml version="1.0" encoding="UTF-8"?>
|
|
4
4
|
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
|
|
5
5
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
6
6
|
xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
|
|
@@ -26,4 +26,4 @@ import{R,k,rn,sn,on}from"./chunk-phbnrw2h.js";import{resolve as Q,basename as J,
|
|
|
26
26
|
</Representation>
|
|
27
27
|
`}s+=` </AdaptationSet>
|
|
28
28
|
`}return s+=` </Period>
|
|
29
|
-
</MPD>`,s}function I(t){let e=Math.floor(t/3600),a=Math.floor(t%3600/60),c=Math.floor(t%60),r="PT";if(e>0)r+=`${e}H`;if(a>0)r+=`${a}M`;return r+=`${c}S`,r}async function O(){try{return await import("ts-videos")}catch{return null}}function ee(t){switch(t){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function te(t){switch(t){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function
|
|
29
|
+
</MPD>`,s}function I(t){let e=Math.floor(t/3600),a=Math.floor(t%3600/60),c=Math.floor(t%60),r="PT";if(e>0)r+=`${e}H`;if(a>0)r+=`${a}M`;return r+=`${c}S`,r}async function O(){try{return await import("ts-videos")}catch{return null}}function ee(t){switch(t){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function te(t){switch(t){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function zo(t){let e=await O();if(!e)return null;try{let a=Q(t),r=await new e.Input(a).getInfo();return{duration:r.duration||0,width:r.width||0,height:r.height||0,frameRate:r.frameRate||0,bitrate:r.bitrate||0,codec:r.videoCodec||"",audioCodec:r.audioCodec}}catch(a){return console.warn(`[stx-media] Failed to analyze video: ${a}`),null}}async function Ha(t,e,a,c){let r=await O();if(!r)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:t,processed:!1};let n=await Qr(t,e,a);if(n)return n;try{let i=Q(t);if(!await k(i))return{src:t,processed:!1,errors:[`Source file not found: ${t}`]};let s=a.outputDir||"dist/videos",o=a.baseUrl||"/videos";await Z(s,{recursive:!0});let h=await R(i),y=J(t,K(t)),u={src:t,processed:!0,hash:h};c?.({percentage:5,stage:"analyzing"}),u.metadata=await zo(i)||void 0;let m={};if(e.quality)m.bitrate=ee(e.quality);if(e.platform)Object.assign(m,te(e.platform));if(e.transcode)Object.assign(m,e.transcode);if(Object.keys(m).length>0||e.process){c?.({percentage:10,stage:"transcoding"});let d=`${y}-${h}.mp4`,g=Y(s,d);try{let l=await ae(i,g,m,r,(f)=>c?.({percentage:10+f*0.5,stage:"transcoding"}));if(l)u.transcoded={path:g,url:`${o}/${d}`,duration:l.duration,size:l.size,video:{codec:m.codec||"h264",width:l.width,height:l.height,bitrate:l.bitrate,frameRate:l.frameRate},audio:l.audioCodec?{codec:m.audioCodec||"aac",bitrate:m.audioBitrate||128000,sampleRate:m.sampleRate||48000,channels:m.channels||2}:void 0}}catch(l){u.errors=u.errors||[],u.errors.push(`Transcoding failed: ${l}`)}}if(e.generatePoster){c?.({percentage:65,stage:"generating-poster"});let d=typeof e.generatePoster==="object"?e.generatePoster:{timestamp:0},g=await ts(i,d,s,o);if(g)u.poster=g}if(a.thumbnails?.enabled){c?.({percentage:70,stage:"generating-thumbnails"});let d=await ns(i,a.thumbnails,s,o);if(d.length>0)u.thumbnails=d}if(e.streaming){c?.({percentage:80,stage:"generating-manifests"});let d=typeof e.streaming==="object"?e.streaming:a.streaming||{format:"hls"};if(d.format==="hls"||d.format===void 0){let g=await rs(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,hls:g}}if(d.format==="dash"){let g=await ss(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,dash:g}}}if(e.spriteSheet)c?.({percentage:90,stage:"generating-sprite-sheet"});return c?.({percentage:100,stage:"complete"}),await es(t,e,u,a),u}catch(i){return{src:t,processed:!1,errors:[`Processing failed: ${i}`]}}}async function ae(t,e,a,c,r){try{let i=await new c.Conversion(t,e,{videoCodec:a.codec,videoBitrate:a.bitrate,width:a.maxWidth,height:a.maxHeight,frameRate:a.frameRate,audioCodec:a.audioCodec,audioBitrate:a.audioBitrate,sampleRate:a.sampleRate,channels:a.channels}).run((s)=>{r?.(s.percentage/100)});return{duration:i.duration||0,size:i.size||0,width:i.width||a.maxWidth||0,height:i.height||a.maxHeight||0,bitrate:i.bitrate||a.bitrate||0,frameRate:i.frameRate||a.frameRate||30,audioCodec:i.audioCodec}}catch(n){return console.error(`[stx-media] Transcoding failed: ${n}`),null}}export{Zr,Qr,es,Fa,ts,ns,za,rs,ss,zo,Ha};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{V}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{V}from"./chunk-g9dz0mx9.js";import R from"fs";import g from"path";import C from"crypto";var S=new Set(["webp","avif","jpeg","png"]),T=new Set(["cover","contain","fill","inside","outside"]),q=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"]),k=4096,D=80,U="cover";async function jo(e,t){let r=t.routePath??"/_stx/img",h=new URL(e.url);if(h.pathname!==r)return null;let a=A(h,t);if(!a.ok)return new Response(a.error,{status:a.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:n,srcUrl:d,width:l,height:i,format:s,quality:u,fit:c}=a,m;try{m=R.statSync(n)}catch{return new Response(`Source image not found: ${d}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!m.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let w=t.cacheDir??".stx/cache/img";await R.promises.mkdir(w,{recursive:!0});let b=`${n}:${m.mtimeMs}:${m.size}`,I=`${l}x${i}:${s}:${u}:${c}`,f=C.createHash("sha256").update(`${b}|${I}`).digest("hex").slice(0,16),o=g.join(w,`${f}.${s}`),p={"Content-Type":V(s),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${f}"`,"X-Stx-Image-Cache":"HIT"};if(e.headers.get("if-none-match")===`"${f}"`)return new Response(null,{status:304,headers:p});let v=Bun.file(o);if(await v.exists())return new Response(v,{headers:p});try{let x=Buffer.from(await Bun.file(n).arrayBuffer()),{resizeAndConvert:P}=await L(),F=await P(x,{width:l,height:i,format:s,quality:u,fit:c});return await Bun.write(o,F),p["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(F),{headers:p})}catch(x){let P=x.message;return new Response(`Image processing failed: ${P}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function Aa(e){return async(t)=>await jo(t,e)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}function A(e,t){let r=e.searchParams.get("src");if(!r)return{ok:!1,error:"Missing required param: src",status:400};if(!r.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(r.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let h=g.extname(r).toLowerCase();if(!q.has(h))return{ok:!1,error:`Unsupported source extension: ${h}`,status:400};let a=g.resolve(t.publicDir),n=g.resolve(a,r.slice(1));if(!n.startsWith(`${a}${g.sep}`)&&n!==a)return{ok:!1,error:"src is outside publicDir",status:400};let d=t.maxWidth??k,l=t.maxHeight??k,i=e.searchParams.get("w"),s=e.searchParams.get("h"),u=i?Number.parseInt(i,10):0,c=s?Number.parseInt(s,10):0;if(i&&(!Number.isFinite(u)||u<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(s&&(!Number.isFinite(c)||c<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!i&&!s)return{ok:!1,error:"At least one of w or h is required",status:400};let m=Math.min(u||d,d),w=Math.min(c||l,l),b=e.searchParams.get("f")||"webp";if(!S.has(b))return{ok:!1,error:`Invalid f (must be one of: ${[...S].join(", ")})`,status:400};let I=b,f=e.searchParams.get("q"),o=f?Number.parseInt(f,10):t.defaultQuality??D;if(!Number.isFinite(o)||o<1||o>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let y=e.searchParams.get("fit")||t.defaultFit||U;if(!T.has(y))return{ok:!1,error:`Invalid fit (must be one of: ${[...T].join(", ")})`,status:400};return{ok:!0,srcFsPath:n,srcUrl:r,width:m,height:w,format:I,quality:o,fit:y}}async function L(){return await import("./chunk-4xkqdfqd.js")}
|
|
3
|
+
export{jo,Aa};
|
|
@@ -45,12 +45,12 @@ var p=0;function f(){return`stx-teleport-${++p}`}function g(t){let e=t.split(","
|
|
|
45
45
|
});
|
|
46
46
|
})();
|
|
47
47
|
</script>
|
|
48
|
-
`}function
|
|
48
|
+
`}function cu(t,e,l){p=0;let o=/@teleport\s*\(([^)]+)\)\s*([\s\S]*?)@endteleport/g;return t.replace(o,(r,s,d)=>{let a=f(),{target:u,disabled:n}=g(s),c=d.trim();if(n)try{let i=!1;if(n==="true")i=!0;else if(n==="false")i=!1;else if(n in e)i=Boolean(e[n]);if(i)return`<div class="stx-teleport-inline" data-teleport-disabled>${c}</div>`}catch{}let m=h(a,u);return`
|
|
49
49
|
<div id="${a}" class="stx-teleport-source" style="display: none;">
|
|
50
50
|
<template>${c}</template>
|
|
51
51
|
</div>
|
|
52
52
|
${m}
|
|
53
|
-
`})}function
|
|
53
|
+
`})}function lu(){return`
|
|
54
54
|
<script>
|
|
55
55
|
(function() {
|
|
56
56
|
// Common teleport targets
|
|
@@ -68,4 +68,4 @@ var p=0;function f(){return`stx-teleport-${++p}`}function g(t){let e=t.split(","
|
|
|
68
68
|
})();
|
|
69
69
|
</script>
|
|
70
70
|
`}
|
|
71
|
-
export{
|
|
71
|
+
export{cu,lu};
|