@stacksjs/stx 0.2.415 → 0.2.416
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-02k2v1mb.js +2 -0
- package/dist/chunk-0dh1rgg8.js +2 -0
- package/dist/{chunk-eed4fwps.js → chunk-0es4h5v1.js} +2 -2
- package/dist/chunk-0hrqt5c2.js +2 -0
- package/dist/chunk-0vtk2rpr.js +2 -0
- package/dist/{chunk-mp6hy8g4.js → chunk-1ctvgd7v.js} +1 -1
- package/dist/chunk-1rd3jzrq.js +2 -0
- package/dist/{chunk-b98be3yp.js → chunk-26j2q9rq.js} +7 -7
- package/dist/chunk-2py27bzq.js +2 -0
- package/dist/{chunk-px7fvbj6.js → chunk-2qa7hjp2.js} +2 -2
- package/dist/chunk-35e6zj5x.js +2 -0
- package/dist/{chunk-qghxz7jm.js → chunk-388rx71h.js} +6 -6
- package/dist/chunk-3ch40ebr.js +2 -0
- package/dist/{chunk-bay9s6rs.js → chunk-3g8zzdgs.js} +5 -5
- package/dist/{chunk-md8rqn48.js → chunk-3t0yaexe.js} +5 -5
- package/dist/{chunk-b84h16er.js → chunk-3wrmz1j9.js} +6 -6
- package/dist/{chunk-ak1cgcah.js → chunk-41k0th97.js} +4 -4
- package/dist/chunk-49cpqjx2.js +2 -0
- package/dist/chunk-4k1nkp9r.js +2 -0
- package/dist/chunk-50vq8k55.js +2 -0
- package/dist/chunk-56pkjk55.js +2 -0
- package/dist/chunk-5hnh00ry.js +2 -0
- package/dist/chunk-5j52h3e3.js +2 -0
- package/dist/chunk-5y1mekxe.js +2 -0
- package/dist/chunk-5zryk911.js +2 -0
- package/dist/{chunk-h6zsqb9r.js → chunk-6agy2x1f.js} +2 -2
- package/dist/chunk-72w28vm8.js +2 -0
- package/dist/{chunk-3kthfs03.js → chunk-7mbpjv9e.js} +2 -2
- package/dist/chunk-7s7k94as.js +2 -0
- package/dist/{chunk-9g27ybyr.js → chunk-7tabykst.js} +2 -2
- package/dist/chunk-7wb6jf17.js +2 -0
- package/dist/{chunk-9p9qkbtg.js → chunk-7zjvsacw.js} +2 -2
- package/dist/{chunk-fh1qrp68.js → chunk-89xcpdsp.js} +5 -5
- package/dist/chunk-8cbkqckh.js +2 -0
- package/dist/chunk-8ycy1b0e.js +2 -0
- package/dist/chunk-8ygks6dx.js +3 -0
- package/dist/{chunk-xtvf6n6f.js → chunk-95165j9c.js} +2 -2
- package/dist/{chunk-re8b5r9x.js → chunk-9fyss0yk.js} +2 -2
- package/dist/{chunk-8eqrwj1k.js → chunk-9rnh52t2.js} +10 -10
- package/dist/{chunk-169n1vpx.js → chunk-9t2xx2y4.js} +3 -3
- package/dist/{chunk-0zaess6f.js → chunk-a47yp92z.js} +5 -5
- package/dist/{chunk-765e1s44.js → chunk-ae7j3n39.js} +6 -6
- package/dist/chunk-aqrnpgn7.js +2 -0
- package/dist/{chunk-amtr3rmf.js → chunk-at0ar6t3.js} +3 -3
- package/dist/chunk-b9rebdtq.js +2 -0
- package/dist/{chunk-7gkv67ky.js → chunk-bfjzfrw3.js} +2 -2
- package/dist/{chunk-z0g9jvv0.js → chunk-c4bkj1xw.js} +6 -6
- package/dist/chunk-c4thhfx9.js +2 -0
- package/dist/{chunk-6hc5vz20.js → chunk-cn9hgyh5.js} +2 -2
- package/dist/{chunk-pgzvyrv6.js → chunk-cq408jrm.js} +3 -3
- package/dist/chunk-cw6kqb63.js +2 -0
- package/dist/chunk-d3vtgnep.js +2 -0
- package/dist/chunk-d4ynv4z2.js +2 -0
- package/dist/chunk-d7xrewxq.js +2 -0
- package/dist/{chunk-q9bdh4s5.js → chunk-dd5fa7d6.js} +2 -2
- package/dist/{chunk-shr559s7.js → chunk-ddk6fx5b.js} +2 -2
- package/dist/{chunk-8nhshfz6.js → chunk-de2pv6ys.js} +2 -2
- package/dist/{chunk-3efw27as.js → chunk-dg1n3g1d.js} +146 -146
- package/dist/chunk-ecr598p7.js +2 -0
- package/dist/chunk-eev80mpy.js +2 -0
- package/dist/chunk-ef5vz9w5.js +2 -0
- package/dist/chunk-f5qd84w8.js +2 -0
- package/dist/{chunk-gawrg4gb.js → chunk-fctjn68q.js} +6 -6
- package/dist/{chunk-amd6ey3t.js → chunk-fkhxz1dx.js} +5 -5
- package/dist/chunk-g69tnqga.js +2 -0
- package/dist/chunk-gacycmb0.js +2 -0
- package/dist/chunk-ggywfyzm.js +2 -0
- package/dist/chunk-gp1bhn7t.js +2 -0
- package/dist/{chunk-vgvtnwxa.js → chunk-gq97zh73.js} +3 -3
- package/dist/chunk-gr3r9xdh.js +2 -0
- package/dist/{chunk-ngc2wke4.js → chunk-gxrewzhv.js} +2 -2
- package/dist/{chunk-wfy1zq53.js → chunk-gyv1t0f0.js} +5 -5
- package/dist/{chunk-340a824p.js → chunk-h8wegkb5.js} +1 -1
- package/dist/{chunk-e9hs7kk6.js → chunk-hec0bvvf.js} +1 -1
- package/dist/chunk-hg1eq72d.js +2 -0
- package/dist/chunk-hvyqs5tf.js +2 -0
- package/dist/{chunk-y5310237.js → chunk-j8rxdbe5.js} +2 -2
- package/dist/{chunk-5qns2sdz.js → chunk-jr4dwkvc.js} +2 -2
- package/dist/chunk-kbysqxmd.js +2 -0
- package/dist/chunk-kmnsrvrp.js +2 -0
- package/dist/chunk-m6fvj7g1.js +2 -0
- package/dist/{chunk-j03revz2.js → chunk-m9xdkzm6.js} +3 -3
- package/dist/chunk-mgw2cvb7.js +2 -0
- package/dist/chunk-mvwt1c8f.js +2 -0
- package/dist/{chunk-v91p6ekp.js → chunk-n5k88y07.js} +3 -3
- package/dist/{chunk-r3f9jcf7.js → chunk-nj8edn4m.js} +3 -3
- package/dist/chunk-nvh31cxn.js +2 -0
- package/dist/{chunk-fr2txj8q.js → chunk-p1tb8kxq.js} +4 -4
- package/dist/chunk-p34gbb4z.js +2 -0
- package/dist/chunk-peyt18ce.js +2 -0
- package/dist/{chunk-jnkrn913.js → chunk-ppse812s.js} +1 -1
- package/dist/{chunk-752hw7cd.js → chunk-qff4qkx5.js} +3 -3
- package/dist/chunk-qpx8kvd8.js +2 -0
- package/dist/{chunk-f46qsp4m.js → chunk-qzkebqm3.js} +2 -2
- package/dist/chunk-rb272g9d.js +3 -0
- package/dist/{chunk-m4sk62wb.js → chunk-rfdqrv5v.js} +4 -4
- package/dist/{chunk-9vrja6vp.js → chunk-rg6csnkw.js} +1 -1
- package/dist/chunk-rh1dyfsn.js +2 -0
- package/dist/{chunk-czxt605c.js → chunk-rhw7pqhy.js} +4 -4
- package/dist/{chunk-thyt8ed8.js → chunk-rp4khnan.js} +3 -3
- package/dist/{chunk-s5xezjps.js → chunk-rqc4jx2v.js} +1 -1
- package/dist/chunk-rspc8gn8.js +2 -0
- package/dist/{chunk-9amp82bx.js → chunk-rv5bk83t.js} +2 -2
- package/dist/chunk-rvs61c88.js +2 -0
- package/dist/chunk-sf1vhfrb.js +2 -0
- package/dist/{chunk-96k8s808.js → chunk-sh5c60a2.js} +2 -2
- package/dist/{chunk-ym95v4nc.js → chunk-std6xw3y.js} +2 -2
- package/dist/{chunk-pbh4smw3.js → chunk-t9axxwy9.js} +4 -4
- package/dist/{chunk-wzx0164n.js → chunk-tc274fcv.js} +4 -4
- package/dist/{chunk-9pt8fd2n.js → chunk-tfhjbjq5.js} +3 -3
- package/dist/chunk-ty7t3gp4.js +3 -0
- package/dist/{chunk-6h38kkjf.js → chunk-v096a6fw.js} +6 -6
- package/dist/chunk-vc9wa97m.js +2 -0
- package/dist/{chunk-y1cmjvk3.js → chunk-vvp4cmfq.js} +5 -5
- package/dist/{chunk-t4hzprsm.js → chunk-vvs75dse.js} +2 -2
- package/dist/{chunk-tafqyf2g.js → chunk-wjag92ch.js} +73 -73
- package/dist/chunk-wjzqz3yr.js +2 -0
- package/dist/{chunk-hepd9qgx.js → chunk-wpe72ann.js} +5 -5
- package/dist/{chunk-ej9j6k1q.js → chunk-x0mq57pe.js} +2 -2
- package/dist/chunk-x7j0krz8.js +2 -0
- package/dist/chunk-xkv0evbf.js +2 -0
- package/dist/{chunk-x0q32ees.js → chunk-y5cqkmkf.js} +2 -2
- package/dist/{chunk-42wbs8vq.js → chunk-y6rahx7t.js} +5 -5
- package/dist/{chunk-yazk54jr.js → chunk-yk63jd7v.js} +1 -1
- package/dist/chunk-yt452b4a.js +2 -0
- package/dist/{chunk-hkrmcbwy.js → chunk-yt6h8c6g.js} +11 -11
- package/dist/chunk-yxfx44fv.js +2 -0
- package/dist/{chunk-ce1sejr3.js → chunk-yzv8n6qw.js} +2 -2
- package/dist/{chunk-g186znp9.js → chunk-zcctf7tx.js} +3 -3
- package/dist/{chunk-ft4p6d28.js → chunk-znbay168.js} +2 -2
- package/dist/{chunk-xfp7k0v8.js → chunk-zyxp0nb3.js} +7 -7
- package/dist/cli.js +20 -20
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/dev-server/serve-app.js +3 -0
- package/dist/dev-server/serve-multi.js +1 -1
- package/dist/document-shell.js +15 -3
- package/dist/native/components/primitives.d.ts +2 -0
- package/dist/production-server.js +4 -4
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +15 -15
- package/package.json +5 -5
- package/dist/chunk-020xyn9q.js +0 -3
- package/dist/chunk-04jhmfbz.js +0 -2
- package/dist/chunk-0pnj3zt2.js +0 -2
- package/dist/chunk-1098mas0.js +0 -2
- package/dist/chunk-18vmfkcc.js +0 -2
- package/dist/chunk-1b6t12hd.js +0 -2
- package/dist/chunk-1zs30k3y.js +0 -2
- package/dist/chunk-2ce7f416.js +0 -2
- package/dist/chunk-393341w7.js +0 -2
- package/dist/chunk-39g1134q.js +0 -2
- package/dist/chunk-3qn1wcdg.js +0 -2
- package/dist/chunk-3s2vnqcf.js +0 -2
- package/dist/chunk-4bjravgk.js +0 -2
- package/dist/chunk-5gsxpaqk.js +0 -2
- package/dist/chunk-6cfa3g0r.js +0 -2
- package/dist/chunk-7z2ra0yf.js +0 -2
- package/dist/chunk-92ps1xpk.js +0 -2
- package/dist/chunk-9xrbve19.js +0 -2
- package/dist/chunk-atws6p5s.js +0 -2
- package/dist/chunk-dd8cja4h.js +0 -2
- package/dist/chunk-dgdm3hy3.js +0 -2
- package/dist/chunk-f1sxycmv.js +0 -2
- package/dist/chunk-fbcv4fes.js +0 -2
- package/dist/chunk-fjs0a8h7.js +0 -2
- package/dist/chunk-fpfzm238.js +0 -2
- package/dist/chunk-fyzajkrx.js +0 -2
- package/dist/chunk-fzapbw9p.js +0 -3
- package/dist/chunk-g03s93qr.js +0 -3
- package/dist/chunk-gc1drn2p.js +0 -2
- package/dist/chunk-gea5hf0v.js +0 -2
- package/dist/chunk-gqv3ta5d.js +0 -2
- package/dist/chunk-h6kp2m9r.js +0 -2
- package/dist/chunk-hbxz85wy.js +0 -2
- package/dist/chunk-hhnw2sn3.js +0 -2
- package/dist/chunk-hjg3ndgh.js +0 -2
- package/dist/chunk-hk1mj4tz.js +0 -2
- package/dist/chunk-hn9pkyv8.js +0 -2
- package/dist/chunk-hpgr4qgp.js +0 -2
- package/dist/chunk-hrbbbtbn.js +0 -2
- package/dist/chunk-j9qcrwbg.js +0 -2
- package/dist/chunk-jk4njz0w.js +0 -2
- package/dist/chunk-jmabeqfq.js +0 -2
- package/dist/chunk-jp10q90g.js +0 -2
- package/dist/chunk-jt0n43mk.js +0 -2
- package/dist/chunk-m1vdghnx.js +0 -2
- package/dist/chunk-nc8my58s.js +0 -2
- package/dist/chunk-nn2vstke.js +0 -2
- package/dist/chunk-nppdrf0x.js +0 -2
- package/dist/chunk-p2v2a68k.js +0 -2
- package/dist/chunk-pazfr1a1.js +0 -2
- package/dist/chunk-pdb5fw3r.js +0 -2
- package/dist/chunk-pdt69hpb.js +0 -2
- package/dist/chunk-q6vrb2pe.js +0 -2
- package/dist/chunk-q7qchkvk.js +0 -2
- package/dist/chunk-sd321bn3.js +0 -2
- package/dist/chunk-t5pvq5mx.js +0 -2
- package/dist/chunk-w72qx0eb.js +0 -2
- package/dist/chunk-xwzvfqcb.js +0 -2
- package/dist/chunk-ydjfar14.js +0 -2
- package/dist/chunk-z23kaxq6.js +0 -2
- package/dist/chunk-z8xn5ta3.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var g=0;function p(){return`async-${++g}-${Date.now().toString(36)}`}function
|
|
2
|
+
var g=0;function p(){return`async-${++g}-${Date.now().toString(36)}`}function Ml(e,t={},c){let o=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@error\s*([\s\S]*?)@endasync/gi,i=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@endasync/gi,n=e;return n=n.replace(o,(r,s,a,d)=>{let l=p(),y=u(s);return m(l,y,a.trim(),d.trim())}),n=n.replace(i,(r,s,a)=>{let d=p(),l=u(s);return m(d,l,a.trim(),'<div class="stx-async-error">Failed to load component</div>')}),n}function u(e){let t={component:"",timeout:30000,delay:200,suspensible:!0,retries:0},c=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,o;while((o=c.exec(e))!==null){let i=o[1],n=o[2]||o[3],r=o[4],s=o[5];switch(i){case"component":t.component=n||s||"";break;case"timeout":t.timeout=r?parseInt(r,10):30000;break;case"delay":t.delay=r?parseInt(r,10):200;break;case"suspensible":t.suspensible=s==="true";break;case"retries":t.retries=r?parseInt(r,10):0;break;case"loadingComponent":t.loadingComponent=n||s;break;case"errorComponent":t.errorComponent=n||s;break}}return t}function m(e,t,c,o){let{component:i,timeout:n,delay:r,suspensible:s,retries:a}=t;return`
|
|
3
3
|
<div class="stx-async-component" data-async-id="${e}" data-component="${i}" data-status="pending">
|
|
4
4
|
<div class="stx-async-loading" data-async-loading="${e}">
|
|
5
5
|
${c}
|
|
@@ -226,7 +226,7 @@ catch (error) {
|
|
|
226
226
|
loadComponent();
|
|
227
227
|
})();
|
|
228
228
|
</script>
|
|
229
|
-
`}function
|
|
229
|
+
`}function Nl(e){return{__asyncComponent:!0,...typeof e==="function"?{loader:e}:e}}function Ll(e){return typeof e==="object"&&e!==null&&"__asyncComponent"in e&&e.__asyncComponent===!0}function jl(){return`
|
|
230
230
|
/* STX Async Component Styles */
|
|
231
231
|
.stx-async-component {
|
|
232
232
|
position: relative;
|
|
@@ -300,7 +300,7 @@ catch (error) {
|
|
|
300
300
|
background-size: 200% 100%;
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
`}function
|
|
303
|
+
`}function Bl(){return`
|
|
304
304
|
// STX Async Component Runtime
|
|
305
305
|
(function() {
|
|
306
306
|
if (typeof window === 'undefined') return;
|
|
@@ -355,4 +355,4 @@ catch (error) {
|
|
|
355
355
|
console.log('[stx] Async component runtime initialized');
|
|
356
356
|
})();
|
|
357
357
|
`}
|
|
358
|
-
export{
|
|
358
|
+
export{Ml,Nl,Ll,jl,Bl};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ln,Ne,Le,ye,Hi,Fn,ee,X,on,d,r,A}from"./chunk-dg1n3g1d.js";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function _(o){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let n=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,n);function m(s,p){let u;while((u=s.exec(o))!==null){let t=u.index,i=t+u[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((s,p)=>s.start-p.start);let a="",c=0;for(let s of e){if(s.start<c)continue;a+=o.slice(c,s.start),a+=`@raw${o.slice(s.start,s.end)}@endraw`,c=s.end}return a+=o.slice(c),a}async function b(o,e={}){let{data:n,content:m}=Ln(o),c=await(e.renderer??((s)=>Ne(s)))(m);return{html:_(c),frontmatter:n??{}}}import{dirname as C,resolve as R}from"path";function k(o){let e=o,n=ee(o);if(n)e=n.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],s=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),u;while((u=m.exec(o))!==null){let i=u[1],l=u[2],f=u[0],g=i.includes("server");if(p(l))s.push(f);else if(g)c.push(l);else a.push(f)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,f=[];while((l=i.exec(t))!==null){let g=l.index+l[0].length,x=t.indexOf("</script>",g);if(x===-1)continue;f.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let g=f.length-1;g>=0;g--)t=t.substring(0,f[g].start)+t.substring(f[g].end)}for(let i of a)t=t.replace(i,"");return{templateContent:t,serverScripts:c,clientScripts:a,signalsScripts:s}}function v(o,e){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -9,10 +9,10 @@ import{Nn,Ne,Le,ye,zi,Bn,ee,X,sn,d,r,A}from"./chunk-3efw27as.js";function h(o){r
|
|
|
9
9
|
<body>
|
|
10
10
|
${o}
|
|
11
11
|
</body>
|
|
12
|
-
</html>`}async function
|
|
12
|
+
</html>`}async function Ei(o,e={}){let n=R(o),m=Bun.file(n);if(!await m.exists())throw Error(`Template file not found: ${n}`);let a=await m.text(),c=null;if(h(n)){let s=await b(a,{renderer:e.markdownRenderer});a=s.html,c=s.frontmatter}if(c)e={...e,context:{...c,...e.context||{}}};if(e.layout){let s=R(e.layout),p=Bun.file(s);if(!await p.exists())throw Error(`Layout template not found: ${s}`);let{layout:u,injectCSS:t,...i}=e,l={...e.context||{}};on(l);let f=await S(a,n,{...i,context:{...l,__stx_defer_server_data:!0},injectCSS:!1}),g=await p.text(),x={...l,content:f},w={...i,context:x,injectCSS:t};return S(g,s,w)}return S(a,n,e)}async function S(o,e,n={}){let{templateContent:m,serverScripts:a,clientScripts:c}=k(o),s={...A,...n.options},p={__filename:e,__dirname:C(e),__stx:{},__stx_options:s,__stx_sfc_mode:!0,__stx_inject_css:n.injectCSS===!0,__stxServeContext:void 0,...Fn(n.context??{}),definePageMeta:()=>{},...n.context||{}};for(let i of a)await d(i,p,e);let u=new Set,t=m;if(t=await r(t,p,e,s,u),Hi(p,n.context),n.templateOnly){if(t=t.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),t=t.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),c.length>0)t+=`
|
|
13
13
|
${c.join(`
|
|
14
14
|
`)}`}else{if(n.processClientScripts!==!1&&c.length>0){let i=p.__stx_event_bindings||[],l=Le(p),g=(await Promise.all(c.map(async(w)=>{let y=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!y)return w;return await ye(y[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})}))).join(`
|
|
15
15
|
`);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${g}
|
|
16
16
|
$1`);else t+=`
|
|
17
|
-
${g}`}t=await X(t)}if(n.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,n.title)}if(n.injectCSS)try{let{injectCss:i}=await import("./chunk-
|
|
18
|
-
export{
|
|
17
|
+
${g}`}t=await X(t)}if(n.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,n.title)}if(n.injectCSS)try{let{injectCss:i}=await import("./chunk-1rd3jzrq.js");t=await i(t)}catch{}return t}
|
|
18
|
+
export{Ei};
|
|
@@ -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 Sl(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 kl(){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{Sl,kl};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import i from"path";var Rt=".stx",s="STX_DIR",e=null;function So(t){e=t?.trim()||null}function dn(){return process.env[s]?.trim()||e||Rt}function o(t=process.cwd(),...n){let r=dn();return i.isAbsolute(r)?i.join(r,...n):i.join(t,r,...n)}function pn(t){if(!t||i.isAbsolute(t))return t;let n=t.replace(/\\/g,"/");if(n!==Rt&&!n.startsWith(`${Rt}/`))return t;let r=n.slice(Rt.length+1);return r?i.join(dn(),r):dn()}
|
|
3
|
+
export{Rt,So,dn,o,pn};
|
|
@@ -159,7 +159,7 @@ else {
|
|
|
159
159
|
stxIslands.initIslands();
|
|
160
160
|
}
|
|
161
161
|
})();
|
|
162
|
-
</script>`}function b(e){let t=e.match(/<([A-Z][a-zA-Z0-9]+)[\s/>]/);if(t)return t[1];let n=e.match(/<([a-z][a-z0-9]*-[a-z0-9-]+)[\s/>]/);if(n)return n[1];return null}function w(e,t){let n={},r=/:([a-zA-Z_][\w-]*)\s*=\s*"([^"]+)"/g,i;while((i=r.exec(e))!==null){let d=i[1],o=i[2];if(o in t)n[d]=t[o];else n[d]=o}return n}function
|
|
162
|
+
</script>`}function b(e){let t=e.match(/<([A-Z][a-zA-Z0-9]+)[\s/>]/);if(t)return t[1];let n=e.match(/<([a-z][a-z0-9]*-[a-z0-9-]+)[\s/>]/);if(n)return n[1];return null}function w(e,t){let n={},r=/:([a-zA-Z_][\w-]*)\s*=\s*"([^"]+)"/g,i;while((i=r.exec(e))!==null){let d=i[1],o=i[2];if(o in t)n[d]=t[o];else n[d]=o}return n}function ga(){let e=new Map;return{islands:e,register(t){e.set(t.id,t)},get(t){return e.get(t)},async hydrate(t){let n=e.get(t);if(!n||n.hydrated)return;if(n.hydrated=!0,typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hydrate",{detail:{id:t,component:n.component}}))},async hydrateAll(){let t=Array.from(e.values()).filter((n)=>!n.hydrated).map((n)=>this.hydrate(n.id));await Promise.all(t)}}}function I(e){return`
|
|
163
163
|
<script data-hydrate="${e}">
|
|
164
164
|
(function() {
|
|
165
165
|
const island = document.querySelector('[data-island="${e}"]');
|
|
@@ -311,7 +311,7 @@ else {
|
|
|
311
311
|
});
|
|
312
312
|
})();
|
|
313
313
|
</script>
|
|
314
|
-
`}function
|
|
314
|
+
`}function ma(e,t={},n){let r=e,i=!1,d=/@client:(load|idle|visible|media|only|hover|event)/i.test(e);if(r=u(r,"load",t),r=u(r,"idle",t),r=u(r,"visible",t),r=u(r,"media",t),r=M(r),r=u(r,"hover",t),r=u(r,"event",t),i=d&&r!==e,i)r+=`
|
|
315
315
|
`+v();return r}function u(e,t,n){let r=new RegExp(`@client:${t}(?:\\s*\\(([^)]*)\\))?\\s*([\\s\\S]*?)@endclient`,"gi");return e.replace(r,(i,d,o)=>{let a={strategy:t};if(d)try{let E=d.split(",").map((h)=>h.trim());for(let h of E){let[m,g]=h.split(":").map((p)=>p.trim());if(m&&g){let p=g.replace(/^['"]|['"]$/g,"");a[m]=p}}}catch{}let s=`island-${Math.random().toString(36).substring(2,9)}`,y=b(o.trim()),f=w(o.trim(),n),c=[];if(a.rootMargin)c.push(`data-root-margin="${a.rootMargin}"`);if(a.threshold!==void 0)c.push(`data-threshold="${a.threshold}"`);if(a.media)c.push(`data-media="${a.media}"`);if(a.event)c.push(`data-event="${a.event}"`);if(y)c.push(`data-component="${y}"`);let x=Object.keys(f).length>0?`
|
|
316
316
|
<script type="application/json" data-island-props="${s}">${JSON.stringify(f)}</script>`:"",l="";switch(t){case"load":l=I(s);break;case"idle":l=L(s,a);break;case"visible":l=C(s,a);break;case"media":l=S(s,a);break;case"hover":l=k(s);break;case"event":l=H(s,a);break}return`
|
|
317
317
|
<div data-island="${s}"
|
|
@@ -342,7 +342,7 @@ else {
|
|
|
342
342
|
}
|
|
343
343
|
})();
|
|
344
344
|
</script>
|
|
345
|
-
`})}function
|
|
345
|
+
`})}function ha(){return`
|
|
346
346
|
/* Island base styles */
|
|
347
347
|
.stx-island {
|
|
348
348
|
display: contents;
|
|
@@ -383,9 +383,9 @@ else {
|
|
|
383
383
|
.stx-island.hydrated {
|
|
384
384
|
opacity: 1;
|
|
385
385
|
}
|
|
386
|
-
`}function
|
|
386
|
+
`}function ya(e){if(typeof window>"u")return;let t=document.querySelector(`[data-island="${e}"]`);if(!t||t.classList.contains("hydrated"))return;t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))}function ba(e){if(typeof window>"u")return;document.querySelectorAll(`[data-strategy="${e}"]:not(.hydrated)`).forEach((n)=>{n.classList.add("hydrated"),n.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function va(){if(typeof window>"u")return;document.querySelectorAll(".stx-island:not(.hydrated)").forEach((t)=>{t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function wa(e){if(typeof window>"u")return!1;return document.querySelector(`[data-island="${e}"]`)?.classList.contains("hydrated")??!1}function xa(e){return new Promise((t)=>{if(typeof window>"u"){t();return}let n=document.querySelector(`[data-island="${e}"]`);if(!n){t();return}if(n.classList.contains("hydrated")){t();return}n.addEventListener("stx:hydrated",()=>t(),{once:!0})})}function Sa(e){return e.replace(/@static\s*([\s\S]*?)@endstatic/gi,(t,n)=>`<div class="stx-static">${n.trim()}</div>`)}function ka(e){let t=e.map((n)=>({id:n.id,component:n.component,strategy:n.options.strategy,props:n.props}));return`
|
|
387
387
|
<script type="application/json" id="stx-island-manifest">
|
|
388
388
|
${JSON.stringify(t)}
|
|
389
389
|
</script>
|
|
390
|
-
`}var
|
|
391
|
-
export{
|
|
390
|
+
`}var hl={processPartialHydrationDirectives:ma,processStaticDirectives:Sa,generatePartialHydrationCSS:ha,generateIslandManifest:ka,createIslandRegistry:ga,hydrateIsland:ya,hydrateByStrategy:ba,hydrateAll:va,isHydrated:wa,onHydrated:xa};
|
|
391
|
+
export{ga,ma,ha,ya,ba,va,wa,xa,Sa,ka,hl};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Qo,pl,ea,ta,fl,gl}from"./chunk-sh5c60a2.js";import"./chunk-dg1n3g1d.js";import"./chunk-qff4qkx5.js";import"./chunk-ddk6fx5b.js";import"./chunk-41k0th97.js";import"./chunk-rv5bk83t.js";import"./chunk-26j2q9rq.js";import"./chunk-gxrewzhv.js";import"./chunk-zyxp0nb3.js";import"./chunk-rfdqrv5v.js";import"./chunk-c4bkj1xw.js";import"./chunk-de2pv6ys.js";import"./chunk-bfjzfrw3.js";import"./chunk-yzv8n6qw.js";import"./chunk-rhw7pqhy.js";export{gl as applySlots,fl as extractSlotContent,pl as parseSlotElement,Qo as parseSlots,ta as processSlots,ea as renderSlot};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{L,j,B,
|
|
2
|
+
import{L,j,B,jt,Z,oe,Ie,dt,Bt,Ft,zt,F,Ht,Vt}from"./chunk-0es4h5v1.js";import{qe}from"./chunk-tfexmdkt.js";function jo(s,r={}){let{src:e,alt:t,width:n,height:a,sizes:i="100vw",loading:m="lazy",priority:o=!1,quality:u=B,placeholder:l="none",formats:f=j,widths:y=L,decoding:c="async",fetchpriority:h,objectFit:d,objectPosition:g}=s,{class:p,style:v}=s,{processedImage:w,variants:I,optimize:b=!0,isDev:A=!1}=r;if(I&&I.length>0)return ee(s,I,w);if(A||!b)return te(s);return se(s)}function ee(s,r,e){let{src:t,alt:n,width:a,height:i,sizes:m="100vw",loading:o="lazy",priority:u=!1,decoding:l="async",fetchpriority:f,objectFit:y,objectPosition:c,placeholder:h="none"}=s,{class:d,style:g}=s,p=Ft(r),v=Bt(r),w=typeof m==="object"?dt(m):m,I=e?e.aspectRatio:a&&i?Number(a)/Number(i):void 0,b=[];if(I)b.push(`aspect-ratio: ${I}`);if(y)b.push(`object-fit: ${y}`);if(c)b.push(`object-position: ${c}`);if(g)b.push(g);let A=b.length>0?` style="${b.join("; ")}"`:"",S=d?` class="${d}"`:"",C=u?"":` loading="${o}"`,T=` decoding="${l}"`,O=f?` fetchpriority="${f}"`:u?' fetchpriority="high"':"",V=["avif","webp","jpeg","png"],q=[];for(let k of V){let z=p.get(k);if(z&&z.length>0){let M=Ie(z),X=F(k);q.push(` <source type="${X}" srcset="${M}" sizes="${w}" />`)}}let N="",W="",E;if(h!=="none"&&e?.placeholder){let k=`img-${Math.random().toString(36).slice(2,8)}`;if(N=`<div class="stx-image-wrapper" id="${k}">`,W="</div>",h==="blur")E=`
|
|
3
3
|
#${k} {
|
|
4
4
|
position: relative;
|
|
5
5
|
background-image: url('${e.placeholder}');
|
|
@@ -23,14 +23,14 @@ ${q.join(`
|
|
|
23
23
|
src="${v?.url||t}"
|
|
24
24
|
alt="${U(n)}"${J}${K}${S}${A}${C}${T}${O}
|
|
25
25
|
/>
|
|
26
|
-
</picture>${W}`,_;if(u&&v){let k=p.get("webp"),z=k?.[Math.floor(k.length/2)]||v,M=F(z.format);_=`<link rel="preload" as="image" href="${z.url}" type="${M}" />`}return{html:G,preloadLink:_,placeholderCss:E}}function te(s){let{src:r,alt:e,width:t,height:n,loading:a="lazy",decoding:i="async",priority:m=!1,fetchpriority:o,objectFit:u,objectPosition:l}=s,{class:f,style:y}=s,c=[];if(u)c.push(`object-fit: ${u}`);if(l)c.push(`object-position: ${l}`);if(y)c.push(y);let h=c.length>0?` style="${c.join("; ")}"`:"",d=f?` class="${f}"`:"",g=t?` width="${t}"`:"",p=n?` height="${n}"`:"",v=m?"":` loading="${a}"`,w=` decoding="${i}"`,I=o?` fetchpriority="${o}"`:m?' fetchpriority="high"':"";return{html:`<img src="${r}" alt="${U(e)}"${g}${p}${d}${h}${v}${w}${I} />`}}function se(s){let{src:r,alt:e,width:t,height:n,sizes:a="100vw",loading:i="lazy",priority:m=!1,quality:o=B,formats:u=j,widths:l=L,decoding:f="async",fetchpriority:y,objectFit:c,objectPosition:h}=s,{class:d,style:g}=s,p=[];if(c)p.push(`object-fit: ${c}`);if(h)p.push(`object-position: ${h}`);if(g)p.push(g);let v=p.length>0?` style="${p.join("; ")}"`:"",w=d?` class="${d}"`:"",I=t?` width="${t}"`:"",b=n?` height="${n}"`:"",A=m?"":` loading="${i}"`,S=` decoding="${f}"`,C=y?` fetchpriority="${y}"`:m?' fetchpriority="high"':"",T=typeof a==="object"?
|
|
26
|
+
</picture>${W}`,_;if(u&&v){let k=p.get("webp"),z=k?.[Math.floor(k.length/2)]||v,M=F(z.format);_=`<link rel="preload" as="image" href="${z.url}" type="${M}" />`}return{html:G,preloadLink:_,placeholderCss:E}}function te(s){let{src:r,alt:e,width:t,height:n,loading:a="lazy",decoding:i="async",priority:m=!1,fetchpriority:o,objectFit:u,objectPosition:l}=s,{class:f,style:y}=s,c=[];if(u)c.push(`object-fit: ${u}`);if(l)c.push(`object-position: ${l}`);if(y)c.push(y);let h=c.length>0?` style="${c.join("; ")}"`:"",d=f?` class="${f}"`:"",g=t?` width="${t}"`:"",p=n?` height="${n}"`:"",v=m?"":` loading="${a}"`,w=` decoding="${i}"`,I=o?` fetchpriority="${o}"`:m?' fetchpriority="high"':"";return{html:`<img src="${r}" alt="${U(e)}"${g}${p}${d}${h}${v}${w}${I} />`}}function se(s){let{src:r,alt:e,width:t,height:n,sizes:a="100vw",loading:i="lazy",priority:m=!1,quality:o=B,formats:u=j,widths:l=L,decoding:f="async",fetchpriority:y,objectFit:c,objectPosition:h}=s,{class:d,style:g}=s,p=[];if(c)p.push(`object-fit: ${c}`);if(h)p.push(`object-position: ${h}`);if(g)p.push(g);let v=p.length>0?` style="${p.join("; ")}"`:"",w=d?` class="${d}"`:"",I=t?` width="${t}"`:"",b=n?` height="${n}"`:"",A=m?"":` loading="${i}"`,S=` decoding="${f}"`,C=y?` fetchpriority="${y}"`:m?' fetchpriority="high"':"",T=typeof a==="object"?dt(a):a,O=`
|
|
27
27
|
data-stx-image
|
|
28
28
|
data-src="${r}"
|
|
29
29
|
data-sizes="${T}"
|
|
30
30
|
data-quality="${o}"
|
|
31
31
|
data-formats="${u.join(",")}"
|
|
32
32
|
data-widths="${l.join(",")}"
|
|
33
|
-
`.replace(/\s+/g," ").trim();return{html:`<img src="${r}" alt="${U(e)}"${I}${b}${w}${v}${A}${S}${C} ${O} />`}}function
|
|
33
|
+
`.replace(/\s+/g," ").trim();return{html:`<img src="${r}" alt="${U(e)}"${I}${b}${w}${v}${A}${S}${C} ${O} />`}}function Ys(s){let r=s.match(/<Image\s+([^>]*?)\/?>/);if(!r)return null;let e=r[1],t={},n=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,a;while((a=n.exec(e))!==null){let[,i,m,o,u]=a,l=m??o??u??!0;switch(i){case"src":t.src=String(l);break;case"alt":t.alt=String(l);break;case"width":t.width=Number(l)||l;break;case"height":t.height=Number(l)||l;break;case"sizes":t.sizes=String(l);break;case"loading":t.loading=l;break;case"priority":t.priority=l===!0||l==="true";break;case"quality":t.quality=Number(l);break;case"placeholder":t.placeholder=l;break;case"class":t.class=String(l);break;case"style":t.style=String(l);break;case"decoding":t.decoding=l;break;case"fetchpriority":t.fetchpriority=l;break;case"objectFit":t.objectFit=l;break;case"objectPosition":t.objectPosition=String(l);break}}if(!t.src||!t.alt)return null;return t}async function Bo(s,r){let e=/<Image\s+[^>]*?\/?>/g,t=[],n=[],a=s,i,m=[];while((i=e.exec(s))!==null)m.push({match:i[0],index:i.index});for(let o=m.length-1;o>=0;o--){let{match:u}=m[o],l=Ys(u);if(l){let f=await r(l);if(a=a.replace(u,f.html),f.preloadLink)t.push(f.preloadLink);if(f.placeholderCss)n.push(f.placeholderCss)}}return{html:a,preloadLinks:t,styles:n}}function U(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var D=new Map;function Fo(){D.clear()}async function re(s,r){let e=`${s}:${JSON.stringify(r)}`;if(D.has(e))return D.get(e);try{let t=await oe(s,r);return D.set(e,t),t}catch{return null}}function Zs(){return qe({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async(s,r,e)=>{let{src:t,alt:n,options:a}=ae(s,r,e);if(!t)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let i={widths:a.widths||(a.width?[a.width]:L),formats:a.formats||j,quality:a.quality||B,placeholder:(a.placeholder==="color"?"dominant-color":a.placeholder)||"none"};if(!await Z())return H(t,n||"",a);let o=await re(t,i);if(!o)return H(t,n||"",a);return ne(o,n||"",a)}})}function ae(s,r,e){if(r.src)return{src:String(r.src),alt:String(r.alt||""),options:r.options||{}};let n=s.trim();if(n.startsWith("@image(")||n.startsWith("("))n=n.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let a=ie(n),i=a[0]||"",m=a[1]||"",o={};if(i&&!i.startsWith("/")&&!i.startsWith(".")&&!i.startsWith("http")){let u=e[i];if(typeof u==="string")i=u}if(a[2])try{if(typeof a[2]==="string")o=JSON.parse(a[2]);else o=a[2]}catch{}return{src:i,alt:m,options:o}}function ie(s){let r=[],e="",t=!1,n="",a=0,i=0;for(let m=0;m<s.length;m++){let o=s[m],u=m>0?s[m-1]:"";if((o==='"'||o==="'")&&u!=="\\"){if(!t)t=!0,n=o;else if(o===n)t=!1,n="";else e+=o;continue}if(!t){if(o==="{")a++;if(o==="}")a--;if(o==="[")i++;if(o==="]")i--;if(o===","&&a===0&&i===0){r.push(e.trim()),e="";continue}}e+=o}if(e.trim())r.push(e.trim());return r}function H(s,r,e){let t=[`src="${x(s)}"`];if(r)t.push(`alt="${x(r)}"`);if(e.width)t.push(`width="${e.width}"`);if(e.height)t.push(`height="${e.height}"`);if(e.class)t.push(`class="${x(e.class)}"`);if(e.style)t.push(`style="${x(e.style)}"`);if(e.lazy!==!1)t.push('loading="lazy"');return t.push('decoding="async"'),`<img ${t.join(" ")} />`}function ne(s,r,e){let{variants:t,placeholder:n,width:a,height:i,aspectRatio:m}=s,o=new Map;for(let g of t){let p=o.get(g.format)||[];p.push(g),o.set(g.format,p)}let u=["avif","webp","jpeg","png"],l=[];for(let g of u){let p=o.get(g);if(p&&p.length>0){let v=Ie(p),w=F(g),I=e.sizes||"100vw";l.push(` <source type="${w}" srcset="${x(v)}" sizes="${x(I)}" />`)}}let f=o.get("jpeg")||[],y=f.length>0?f[Math.floor(f.length/2)]:t[Math.floor(t.length/2)],c=[`src="${y?.url||s.src}"`,`alt="${x(r)}"`];if(e.width||a)c.push(`width="${e.width||a}"`);if(e.height||i)c.push(`height="${e.height||i}"`);if(e.class)c.push(`class="${x(e.class)}"`);let h=[];if(m)h.push(`aspect-ratio: ${m.toFixed(4)}`);if(e.style)h.push(e.style);if(h.length>0)c.push(`style="${h.join("; ")}"`);if(e.lazy!==!1&&!e.priority)c.push('loading="lazy"');if(c.push('decoding="async"'),e.priority)c.push('fetchpriority="high"');let d=`<picture>
|
|
34
34
|
`;if(d+=l.join(`
|
|
35
35
|
`)+`
|
|
36
36
|
`,d+=` <img ${c.join(" ")} />
|
|
@@ -39,5 +39,5 @@ ${d}
|
|
|
39
39
|
</div>`}else if(e.placeholder==="color"){let p=n.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");d=`<div id="${g}" class="stx-image-placeholder" style="background-color: ${p};">
|
|
40
40
|
${d}
|
|
41
41
|
</div>`}}if(e.priority&&y){let g=F(y.format);d=`<link rel="preload" as="image" href="${x(y.url)}" type="${g}" />
|
|
42
|
-
`+d}return d}function x(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var
|
|
43
|
-
export{
|
|
42
|
+
`+d}return d}function x(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var zo=Zs();import P from"fs";import R from"path";function Ho(s={}){let{inputDirs:r=["public","src/assets","assets"],outputDir:e="dist/images",baseUrl:t="/images",formats:n=j,widths:a=L,quality:i=B,placeholder:m="none",concurrency:o=4,cache:u=!0,cacheDir:l=".stx/image-cache",referencedOnly:f=!1,verbose:y=!1}=s,c={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(h){if(!await Z()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(u)await P.promises.mkdir(l,{recursive:!0});if(y){let g=await jt();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${g?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),console.log(` Input dirs: ${r.join(", ")}`),console.log(` Output dir: ${e}`),console.log(` Formats: ${n.join(", ")}`),console.log(` Widths: ${a.join(", ")}`)}},async buildStart(){c.imageReferences.clear(),c.processedImages.clear(),c.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(h,d){if(d.endsWith(".html")||d.endsWith(".stx")){let g=ce(h);for(let p of g)c.imageReferences.add(p)}if(h.includes("<Image")||h.includes("@image"))return await ge(h,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t,processedImages:c.processedImages});return h},async buildEnd(h){if(!await Z())return;await P.promises.mkdir(e,{recursive:!0});let g=[];for(let w of r){if(!P.existsSync(w))continue;let I=await Q(w);g.push(...I)}let p=f?g.filter((w)=>le(w,c.imageReferences)):g;if(c.stats.totalImages=p.length,y)console.log(`[stx-images] Processing ${p.length} images...`);let v=Y(p,o);for(let w of v)await Promise.all(w.map(async(I)=>{try{let b=await oe(I,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t});c.processedImages.set(I,b),c.stats.optimizedImages++,c.stats.variants+=b.variants.length;let A=P.statSync(I).size,S=Ht(b.variants);if(c.stats.savedBytes+=Math.max(0,A-S/b.variants.length),y)console.log(` \u2713 ${R.basename(I)} \u2192 ${b.variants.length} variants`)}catch(b){console.error(`[stx-images] Error processing ${I}:`,b)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${c.stats.optimizedImages}/${c.stats.totalImages}`),console.log(` Variants: ${c.stats.variants}`),c.stats.savedBytes>0)console.log(` Saved: ~${Vt(c.stats.savedBytes)}`)}}}function ce(s){let r=[],e=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,t;while((t=e.exec(s))!==null)r.push(t[1]);let n=/<Image[^>]+src=["']([^"']+)["']/gi;while((t=n.exec(s))!==null)r.push(t[1]);let a=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((t=a.exec(s))!==null)r.push(t[1]);let i=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((t=i.exec(s))!==null)r.push(t[1]);return r}function le(s,r){let e=R.basename(s);for(let t of r)if(t.endsWith(e)||t.includes(e))return!0;return!1}async function ge(s,r){return s}async function Q(s){let r=[];async function e(t){let n=await P.promises.readdir(t,{withFileTypes:!0});for(let a of n){let i=R.join(t,a.name);if(a.isDirectory())await e(i);else if(a.isFile()&&zt(i))r.push(i)}}return await e(s),r}function Y(s,r){let e=[];for(let t=0;t<s.length;t+=r)e.push(s.slice(t,t+r));return e}async function Vo(s,r,e={}){if(!await Z())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return oe(s,{...e,outputDir:r})}async function Uo(s,r,e={}){let{formats:t=j,widths:n=L,quality:a=B,placeholder:i="none",concurrency:m=4,verbose:o=!1}=e;if(!await Z())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await P.promises.mkdir(r,{recursive:!0});let l=await Q(s),f=[],y={totalImages:l.length,optimizedImages:0,savedBytes:0,variants:0},c=Y(l,m);for(let h of c){let d=await Promise.all(h.map(async(g)=>{try{let p=await oe(g,{formats:t,widths:n,quality:a,placeholder:i,outputDir:r,baseUrl:"/"});if(y.optimizedImages++,y.variants+=p.variants.length,o)console.log(` \u2713 ${R.basename(g)}`);return p}catch(p){return console.error(`Error processing ${g}:`,p),null}}));f.push(...d.filter((g)=>g!==null))}return{processed:f,stats:y}}function Qs(s){let r={};for(let e of s)r[e.src]={variants:e.variants,placeholder:e.placeholder};return r}async function Wo(s,r){let e=Qs(s);await Bun.write(r,JSON.stringify(e,null,2))}var Wc={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"};
|
|
43
|
+
export{jo,Ys,Bo,Fo,Zs,zo,Ho,Vo,Uo,Qs,Wo,Wc};
|
|
@@ -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 _a(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{_a};
|